HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/pmw24/driver_settlement/application/controllers/admin/Notification.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Notification extends MY_Controller {


	public function __construct() {		
		parent::__construct();
		//$this->redirect_guest();
		
		$this->load->model('admin/mdocket');	
		
		if($this->session->userdata('admin') != 1)
		{
			redirect('admin');
			
		}	
		
	}
	// Default load function for header and footer inculded
	private function _load_view($data) {
		$this->load->view('admin/layouts/index',$data);
	}
	public function index()
	{
		$data 			= array();
		$notification_data 	= $this->mcommon->getNotificationList();
		if(!empty($notification_data)){
			$data['notification_details']		= $notification_data;
		}
		else{
			$data['notification_details']		= '';
		}
		$data['content']	= 'admin/notification/notification_list';
		$this->_load_view($data);
	}
	/*public function notification()
	{
		$result 			= array();
		$notification_list	= array();
		$condition			= array('notification_flag' =>'0');
		$notification_data 	= $this->mcommon->getDetails('notification',$condition);
		//pr($notification_data);
		if(!empty($notification_data)){
			foreach($notification_data as $list){				
				if($list['notification_type'] == 'service_due_notification'){
					$condnservice_notefn		= array('service_notification_id' => $list['referrence_id']);
					$service_notification_list 	= $this->mcommon->getRow('service_notification',$condnservice_notefn);
					//pr($service_notification_list);
					if(!empty($service_notification_list)){
						$notification_list['service_notification']	= $service_notification_list;
					}
					else{
						$notification_list['service_notification']	= '';
					}
				}
				elseif($list['notification_type'] == 'inspection'){
					$inspection_joindata   = array(	'select' =>'inspection_answer.answer,inspection.inspection_id,inspection.car_id,',
							                        'first_table'   =>'inspection',
							                        'second_table'  =>'inspection_answer',
							                        'dependency1'   =>'inspection.inspection_id = inspection_answer.inspection_id',
							                        'join_type1'    =>'inner'
			                      				);
					$condnservice_inspection	= array('inspection.inspection_id' => $list['referrence_id'],'inspection_answer.answer'=>'0');
					$inspection_list 	= $this->mcommon->joinQuery($inspection_joindata,$condnservice_inspection,'row','','');
					//pr($inspection_list);
					if(!empty($inspection_list)){
						$notification_list['inspection']	= $inspection_list;
					}
					else{
						$notification_list['inspection']	= '';
					}
				}
				elseif($list['notification_type'] == 'bond_refund_due'){

				}
			}
			return $notification_list;
		}
	}*/
	public function ReadNotification()
	{	
		$notification_id = $this->input->post('notification_id');
		$condition 		 = array('notification_id' =>$notification_id);
		$updatearr		 = array('notification_flag'=>1);
		$update_resp	 = $this->mcommon->update('notification',$condition,$updatearr);
		//$notification_data = $this->mcommon->getRow

		echo $update_resp;exit;
	}
	public function BondRefundDueNotification(){
		$notification_data	 = $this->mcommon->getFullDetails('driver_refund_settlement');
		if(!empty($notification_data)){
			foreach($notification_data as $list){
				$cunrt_dt_timestr		= strtotime(date('Y-m-d'));
				$refund_due_dt_7		= strtotime('-7 day', strtotime($list['bond_refund_due_dt']));
				$refund_due_dt_3		= strtotime('-3 day', strtotime($list['bond_refund_due_dt']));
				$refund_due_dt_timestr	= strtotime($list['bond_refund_due_dt']);
				if($cunrt_dt_timestr == $refund_due_dt_7){
					$instdata 		= array('notification_flag'			=> 0,
											'notification_type'			=> 'bond_refund_due',
											'notification_title'		=> 'Bond Refund Due Notification',
											'notification_description'	=> '7 days left to expair the bond refund due date.',
											'notification_link'			=> 'admin/driver-refund-settlement/',
											'referrence_id'				=> $list['dr_refund_settlement_id'],
											'created_on'				=> date('Y-m-d')
											);
					$this->mcommon->insert('notification',$instdata);
					echo "success";exit;
				}
				elseif($cunrt_dt_timestr == $refund_due_dt_3){
					$instdata 		= array('notification_flag'			=> 0,
											'notification_type'			=> 'bond_refund_due',
											'referrence_id'				=> $list['dr_refund_settlement_id'],
											'notification_title'		=> 'Bond Refund Due Notification',
											'notification_description'	=> '3 days left to expair the bond refund due date.',
											'notification_link'			=> 'admin/driver-refund-settlement/',
											'referrence_id'				=> $list['dr_refund_settlement_id'],
											'created_on'				=> date('Y-m-d')
											);
					$this->mcommon->insert('notification',$instdata);
					echo "success";exit;
				}
				elseif($cunrt_dt_timestr == $refund_due_dt_timestr){
					$instdata 		= array('notification_flag'			=> 0,
											'notification_type'			=> 'bond_refund_due',
											'notification_title'		=> 'Bond Refund Due Notification',
											'notification_description'	=> 'Today will expair the bond refund due date.',
											'notification_link'			=> 'admin/driver-refund-settlement/',
											'referrence_id'				=> $list['dr_refund_settlement_id'],
											'created_on'				=> date('Y-m-d')
											);
					$this->mcommon->insert('notification',$instdata);
					echo "success";exit;
				}
				else{
					//nothing to do;
				}
			}
		}
	}
}