Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.35 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Admin_dashboard extends CI_Controller {
  5.     private $profile_info;
  6.  
  7.     function __construct() {
  8.         parent::__construct();
  9.  
  10.         $this->load->model('admin_model');
  11.  
  12.         if(!$this->session->login_status) {
  13.             redirect(base_url('admin'));
  14.         } else {
  15.             $this->profile_info = $this->admin_model->profile_usn($this->session->usn)->row_array();
  16.         }
  17.         $this->load->model("comment_model");
  18.         $this->load->model("product_model");
  19.         $this->load->model("invoice_model");
  20.         $this->load->model("visitor_model");
  21.  
  22.     }
  23.    
  24.     public function index()
  25.     {
  26.         $datenow = date("Y-m-d")." 00:00:00";
  27.  
  28.         if($this->session->level != 1) {
  29.  
  30.             $pushdata['comments'] = $this->comment_model->get_list_comment([0,3])->result();
  31.             $pushdata['stocks'] = $this->product_model->get_list_product(["stock_product <=" => 10,"stock_product >=" => 0],["stock_product","ASC"],[0,10])->result();
  32.  
  33.             $pushdata['num_send'] = $this->invoice_model->get_list_invoice(['status_invoice' => 3],NULL,0)->num_rows();
  34.             $pushdata['num_success'] = $this->invoice_model->get_list_invoice(['status_invoice' => 5,"date_invoice >=" => $datenow],NULL,0)->num_rows();
  35.  
  36.             $pushdata['num_stock'] = $this->product_model->get_list_product(['stock_product' => 0],NULL,0)->num_rows();
  37.        
  38.             $pow = pow ( 10, 2 );
  39.             $value = $this->comment_model->get_average_rating();
  40.             $pushdata['num_rating'] = ( ceil ( $pow * $value ) + ceil ( $pow * $value - ceil ( $pow * $value ) ) ) / $pow;
  41.  
  42.             $load = "admin/dashboard/dashboard";
  43.  
  44.            
  45.         } else {
  46.             $chart = $this->invoice_model->get_monthly()->result_array();
  47.  
  48.             $month = "";
  49.             $pushdata['chart'] = "";
  50.             $text = ['Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember'];
  51.  
  52.             $firstmonth = $chart[0]['month'] - 1;
  53.             $count = count($chart) - 1;
  54.             $lastmonth = $chart[$count]['month'];
  55.             $pushdata['title_chart'] = $text[$firstmonth]." ".$chart[0]['year']." - ".$text[$count]." ".$chart[$count]['year'];
  56.  
  57.             $i = 1;
  58.             foreach($chart as $cht){
  59.                 $getnum = $cht['month'] - 1;
  60.                 if($i == count($chart)) {
  61.                     $month .= "'".$text[$getnum]."'";
  62.                     $pushdata['chart'] .= "'".$cht['hit']."'";
  63.                 } else {
  64.                     $month .= "'".$text[$getnum]."', ";
  65.                     $pushdata['chart'] .= "'".$cht['hit']."', ";
  66.                 }
  67.                 $i++;
  68.             }
  69.  
  70.             $pushdata['month'] = $month;
  71.  
  72.             $pushdata['num_comment'] = $this->comment_model->get_num_comment_where(['date_comment >=' => $datenow])->num_rows();
  73.  
  74.             $pushdata['num_new_order'] = $this->invoice_model->get_list_invoice(['status_invoice >=' => 3,'date_invoice >=' => $datenow],NULL,0)->num_rows();
  75.  
  76.             $profit = $this->invoice_model->get_profit(['status_invoice' => 5,'date_invoice >=' => $datenow])->row();
  77.  
  78.             $pushdata['num_profit'] = $this->toolset->rupiah_short($profit->total);
  79.             $pushdata['num_visitor'] = $this->visitor_model->get_today();
  80.             $pushdata['num_visitor_month'] = $this->visitor_model->get_month();
  81.             $pushdata['num_visitor_year'] = $this->visitor_model->get_year();
  82.             $pushdata['num_visitor_total'] = $this->visitor_model->get_total();
  83.  
  84.             $load = "admin/dashboard/index";
  85.         }
  86.  
  87.         $pushdata['admin_info'] = $this->profile_info;
  88.         $this->load->view('admin/header',$pushdata);
  89.         $this->load->view($load,$pushdata);
  90.         $this->load->view('admin/footer',$pushdata);
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement