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;
}
}