<?php

/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 23/06/2018
 * Time: 03:56 AM
 */
class MY_Controller extends CI_Controller
{
    public $user_lastLogin, $user_name, $user_access, $user_mobile, $user_userName, $user_id, $user_img, $event, $event_count, $event_countToday;

    function __construct()
    {
        parent::__construct();
        $this->load->view('layout/jdf');
        $this->load->model('Header_Model');
        $this->user_id = $this->session->userdata('user_id');
        $this->user_userName = $this->session->userdata('user_userName');
        $this->user_access = $this->session->userdata('user_Access');
        $this->user_mobile = $this->session->userdata('user_Mobile');
        $this->user_img = $this->session->userdata('user_Img');
        $this->user_lastLogin = $this->session->userdata('user_lastLogin');
        $this->user_name = $this->session->userdata('user_firstName') . ' ' . $this->session->userdata('user_lastName');
        $this->db->join('user', 'user.user_Id = event.event_Agent');
        $this->db->order_by('event.event_Id', 'DESC');
        $this->db->limit(4);
        $this->event = $this->db->get('event')->result();
        $this->event_count = $this->Header_Model->count_AllEvent();
        $this->event_countToday = $this->Header_Model->count_AllEvent_Today();
        if (!isset($this->user_userName)) {
            redirect('Login');
        }
    }

    function my_date($title, $separate)
    {
        $day_number = jdate('j');
        $month_number = jdate('F');
        $year_number = jdate('Y');
        $day_name = jdate('l');
        $date = $title . ' : ' . $day_name . ' - ' . $day_number . $separate . $month_number . $separate . $year_number;
        return $date;
    }

    function NowDate()
    {
        $date = jdate('Y/n/j');
        return $date;
    }

    function NowTime()
    {
        $date = jdate('H:i:s');
        return $date;
    }

    function NowDateTime()
    {
        $date = jdate('Y/n/j H:i:s');
        return $date;
    }
}