<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Ban_cron extends CI_Controller
{
	public function index()
	{
		$this->load->model('common_model');
		$banned_users = $this->common_model->getAllMultipleJoin('usr_users',array('ban_status'=>1),array(array('feu_userdetails','usr_users.id = feu_userdetails.user_id')));
		//pr($banned_users);
		if(count($banned_users)>0)
	    {
	    	foreach ($banned_users as $key => $value) {
	    		$banned = 0;
	    		if(strtotime($value['ban_date']) >= strtotime(date("Y-m-d", strtotime("-30 days"))))
				{
					echo $banned = 1;
				}
				else
				{
					$this->common_model->UpdateData('usr_users',array('ban_status'=>0,'ban_date'=>0),array('id'=>$value['user_id']));
					$to = $value['email'];
	                $sub = getLang('Ban_finish_mail');
	                $body= '<p>'.getLang('happy_your_ban_on_our_website_is_finished').'</p>';
	                $bodys=' <table cellspacing="0" cellpadding="0" border="0" align="center" bgcolor="#22222c" width="100%" style="max-width: 600px;">
	                    <tr>
	                       <td>
	                          <table cellspacing="0" cellpadding="0" border="0" width="100%">
	                             <tr>
	                                <td align="center" style="padding: 40px; font-family: sans-serif; font-size: 15px; mso-height-rule: exactly; line-height: 20px; color: #b3975b;">
	                                   <h2>'.getLang('Hello').' <span style="text-transform:capitalize">'.$value['username'].'</span> </h2>
	                                </td>
	                             </tr>
	                             <tr>
	                                <td style="font-family: sans-serif; color: #fff; padding: 0px 40px 40px; font-size: 16px; line-height: 30px;">
	                                   '.$body.'
	                                </td>
	                             </tr>
	                             <tr>
	                                <td align="center" style="font-family: sans-serif; color: rgb(179, 151, 91); padding: 20px 40px; border-top: 1px solid rgb(79, 79, 79); background: rgb(19, 18, 24) none repeat scroll 0px 0px;">
	                                    '.getLang('Best_regards').' <br>
	                                    <p style="margin:5px 0 0">'.getLang('Your_Castleevents_Team').'</p> 
	                                </td>
	                             </tr>
	                          </table>
	                       </td>
	                    </tr>
	                </table>';
	                $this->utility->sendCIRenewMail($to,$sub,$bodys);
				}
	    	}
	    }
	}
}