Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/kanvakanva.com/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Stat_sales extends Admin_Controller { function __construct() { parent::__construct(); $this->load->model('stat_sales_m'); } //this is to list all home_slideshow public function index() { $date = strtotime("+0 day"); $start_date = date( 'Y-m-d' , strtotime("-7 day", $date)); $end_date = date( 'Y-m-d' , strtotime("+0 day", $date)); $this->get_data($start_date, $end_date); //load view $this->data['subview'] = 'admin/stat_sales/index'; $this->load->view('admin/templates/header', $this->data); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } public function filter_date() { $data = explode(" - ", $this->input->post('daterange') ); $start_date = $data[0]; $end_date = $data[1]; $this->get_data($start_date, $end_date); //load view $this->data['subview'] = 'admin/stat_sales/index'; $this->load->view('admin/templates/header', $this->data); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } public function get_data($start_date, $end_date) { $end_date_filter = date('Y-m-d', strtotime("+1 day", strtotime($end_date))); $period = new DatePeriod( new DateTime( $start_date ), new DateInterval('P1D'), new DateTime( $end_date_filter ) ); $this->data['period'] = $period; // make aray data statistic $this->data['total_bersih'] =0; $this->data['total_kotor'] =0; foreach ($period as $key => $value) { $this->data['all_data']['tgl'][$value->format('Y-m-d')] = $this->stat_sales_m->get_sales_days($value->format('Y-m-d')); $this->data['total_bersih'] += $this->data['all_data']['tgl'][$value->format('Y-m-d')]->jumlah_bersih; $this->data['total_kotor'] += $this->data['all_data']['tgl'][$value->format('Y-m-d')]->jumlah_kotor; } $this->data['start_date'] = $start_date; $this->data['end_date'] = $end_date; // get all detail product sale $products = $this->stat_sales_m->get_product_sales($this->data['start_date'], $this->data['end_date']); $array = array(); foreach ($products as $key => $product) { $key = $product->item_name; $type = $product->size; // echo $key." "; if ( isset( $this->data['products'][$key] ) ) { $this->data['products'][$key]['count'] += $product->quantity; $this->data['products'][$key]['total'] += $product->subtotal; } else { $array[] = $key; $this->data['products'][$key]['type'] = $type; $this->data['products'][$key]['count'] = $product->quantity; $this->data['products'][$key]['total'] = $product->subtotal; } } $this->data['key'] = $array; } }