<commit_before><?php

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

class Admin extends PX_Controller {

    public function __construct() {
        parent::__construct();
        // $data_row_ctr = $this->model_basic->select_where($this->table_menu,'target','admin')->row();
        $this->controller_attr = array('controller' => 'admin', 'controller_name' => 'Admin', 'controller_id' => 0);
    }

    public function index() {
        $data = $this->controller_attr;
        if ($this->session->userdata('admin') != FALSE) {
            redirect('admin/dashboard');
        } else
            redirect('admin/login');
    }

    function dashboard() {
        $this->load->model('model_order', 'order');
        $data = $this->get_app_settings();
        $data += $this->controller_attr;
        $data += $this->get_function('Admin', 'admin');
        $data += $this->get_menu();
        if ($this->session->userdata('admin') != FALSE) {
            $data['total_order'] = $this->db->get($this->tbl_order)->num_rows();
            $data['total_customer'] = $this->db->get($this->tbl_customer)->num_rows();
            $data['unconfirmed'] = $this->model_basic->select_where($this->tbl_order, 'status', 0)->num_rows();
            $data['paid'] = $this->model_basic->select_where($this->tbl_order, 'status', 3)->num_rows();
            $data['city'] = $this->order->order_by_city()->result();
            $data['content'] = $this->load->view('backend/admin/dashboard', $data, true);
            $this->load->view('backend/index', $data);
        } else
            redirect('admin');
    }

    function get_total_income_chart(){
        $this->load->model('model_order');
        // for($i=6;$i>0;$i--){
        //     $d = new dateTime("$i month ago");
        //     $month[] = $d->format('M-Y');
        //     $income[] = die(print_r($income));
        //     // print_r($this->db->last_query());
        // }
        $data = $this->model_order->get_monthly_income()->result();
        foreach ($data as $d) {  
            // $month[] = $d->month;
            // $total[] = $d->total;
            // die($d->month);
            $datax[] = array('y' => $d->month,
            'a' => $d->total);

        }
        // $income

        // print_r($data);die();

        echo json_encode($datax,true);
    }

    function login() {
        $data = $this->get_app_settings();
        $data += $this->controller_attr;
        $data += $this->get_function('Admin Login', 'admin_login');
        $data += $this->get_menu();
        $this->load->view('backend/admin/login', $data);
    }

    function do_login() {
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        $user_data = $this->model_basic->select_where($this->tbl_user, 'username', $username)->row();
        if ($user_data) {
            if ($this->encrypt->decode($user_data->password) == $password) {
                $user_group = $this->model_basic->select_where($this->tbl_usergroup, 'id', $user_data->id_usergroup)->row()->usergroup_name;<commit_msg>update dashboard<commit_after><?php

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

class Admin extends PX_Controller {

    public function __construct() {
        parent::__construct();
        // $data_row_ctr = $this->model_basic->select_where($this->table_menu,'target','admin')->row();
        $this->controller_attr = array('controller' => 'admin', 'controller_name' => 'Admin', 'controller_id' => 0);
    }

    public function index() {
        $data = $this->controller_attr;
        if ($this->session->userdata('admin') != FALSE) {
            redirect('admin/dashboard');
        } else
            redirect('admin/login');
    }

    function dashboard() {
        $this->load->model('model_order', 'order');
        $data = $this->get_app_settings();
        $data += $this->controller_attr;
        $data += $this->get_function('Admin', 'admin');
        $data += $this->get_menu();
        if ($this->session->userdata('admin') != FALSE) {
            $data['total_order'] = $this->db->get($this->tbl_order)->num_rows();
            $data['total_customer'] = $this->db->get($this->tbl_customer)->num_rows();
            $data['unconfirmed'] = $this->model_basic->select_where($this->tbl_order, 'status', 0)->num_rows();
            $data['paid'] = $this->model_basic->select_where($this->tbl_order, 'status', 3)->num_rows();
            $data['city'] = $this->order->order_by_city()->result();
            $data['content'] = $this->load->view('backend/admin/dashboard', $data, true);
            $this->load->view('backend/index', $data);
        } else
            redirect('admin');
    }

    function get_total_income_chart(){
        $this->load->model('model_order');
        // for($i=6;$i>0;$i--){
        //     $d = new dateTime("$i month ago");
        //     $month[] = $d->format('M-Y');
        //     $income[] = die(print_r($income));
        //     // print_r($this->db->last_query());
        // }
        $data = $this->model_order->get_monthly_income()->result();
        foreach ($data as $d) {  
            // $month[] = $d->month;
            // $total[] = $d->total;
            // die($d->month);
            $datax[] = array('y' => $d->month.' - '.$d->year,
            'a' => $d->total);

        }
        // $income

        // print_r($data);die();

        echo json_encode($datax,true);
    }

    function login() {
        $data = $this->get_app_settings();
        $data += $this->controller_attr;
        $data += $this->get_function('Admin Login', 'admin_login');
        $data += $this->get_menu();
        $this->load->view('backend/admin/login', $data);
    }

    function do_login() {
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        $user_data = $this->model_basic->select_where($this->tbl_user, 'username', $username)->row();
        if ($user_data) {
            if ($this->encrypt->decode($user_data->password) == $password) {
                $user_group = $this->model_basic->select_where($this->tbl_usergroup, 'id', $user_data->id_usergroup)->row()->usergroup_name;
{'fraction_non_alphanumeric': 0.21076377699000967, 'fraction_numerical': 0.0016113438607798904, 'mean_word_length': 2.506779661016949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 166, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2115641', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1895, 'n_words': 283}