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/app/application/core/MY_Controller.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

	public function __construct() {
		parent::__construct();
		$this->get_notification_data();
		$this->get_total_due_amount();
	}
	protected function is_logged_in() {
		return $this->session->userdata('admin') ? 1 : 0;
	}
	protected function redirect_guest() {
		if (!$this->session->userdata('admin')) {
			redirect('admin/index', 'refresh');
		}
	}
	protected function redirect_customer() {
		if (!$this->session->userdata('customer_data')) {
			redirect(WEBSITE_URL, 'refresh');
		}
	}
	
	protected function is_logged_in_user() {
		return $this->session->userdata('front_end_user') ? 1 : 0;
	}
	protected function redirect_guest_user() {
		if (!$this->session->userdata('front_end_user')) {
			redirect('index', 'refresh');
		}
	}

	protected function get_notification_data(){
		$customer_data = $this->session->userdata('customer_data');
		$this->db->select('*');
		$this->db->from("customer_notification");		
		$this->db->where("customer_notification.customer_id",$customer_data['customer_id']);
		$this->db->order_by('is_read','ASC');
		$this->db->order_by('created_ts','DESC');
		$query=$this->db->get();
		$this->notification_list = $query->result_array();
		
		$this->db->select('COUNT(*) as cnt');
		$this->db->from("customer_notification");		
		$this->db->where("customer_notification.customer_id",$customer_data['customer_id']);
		$this->db->where("customer_notification.is_read",0);
		$query=$this->db->get();
		$notification_unread=$query->row_array();
		$this->notification_unread=$notification_unread['cnt'];

	}

	protected function get_total_due_amount(){
		$customer_data = $this->session->userdata('customer_data');
		$this->db->select('get_total_due_amount("'.$customer_data['customer_id'].'") as total_due_amount');
		$query=$this->db->get();
		$this->total_due_amount = $query->row_array();
		//echo '<pre>'; print_r($this->total_due_amount); die;
	}
	
}