Example #1
0
 function _get_common_report_data()
 {
     $data = array();
     $data['report_date_range_simple'] = get_simple_date_ranges();
     $data['months'] = get_months();
     $data['days'] = get_days();
     $data['years'] = get_years();
     $data['selected_month'] = date('n');
     $data['selected_day'] = date('d');
     $data['selected_year'] = date('Y');
     return $data;
 }
Example #2
0
 function _get_common_report_data($time = false)
 {
     $data = array();
     $data['report_date_range_simple'] = get_simple_date_ranges($time);
     $data['months'] = get_months();
     $data['days'] = get_days();
     $data['years'] = get_years();
     $data['hours'] = get_hours($this->config->item('time_format'));
     $data['minutes'] = get_minutes();
     $data['selected_month'] = date('m');
     $data['selected_day'] = date('d');
     $data['selected_year'] = date('Y');
     return $data;
 }
Example #3
0
 public function index($force = '')
 {
     $data_sale = [];
     if ($force != '') {
         switch ($force) {
             case 'sale':
             case 'return':
             case 'shipping':
                 $this->sale_lib->set_mode($force);
                 break;
             default:
                 $force = $this->sale_lib->set_mode('sale');
                 break;
         }
     }
     //Customer
     $data_sale['customer'] = $this->sale_lib->get_customer();
     if ($data_sale['customer'] != -1) {
         $info = $this->Customer->get_info($data_sale['customer']);
         $data_sale['customer_name'] = $info->first_name . ' ' . $info->last_name;
         $data_sale['customer_email'] = $info->email;
     }
     $data_sale['mode'] = $this->sale_lib->get_mode();
     $this->sale_lib->nameS = $data_sale['mode'] . '_';
     $this->load->model('Transfers');
     $person_info = $this->Employee->get_logged_in_employee_info();
     $employee = $this->Employee->get_info($this->sale_lib->get_employee());
     $data_sale['employee'] = $employee->first_name . ' ' . $employee->last_name;
     $data_sale['cart'] = $this->sale_lib->get_cart();
     $data_sale['general_discount'] = $this->sale_lib->get_discount();
     if ($this->session->userdata('discounting') != 'checked') {
         $data_sale['general_discount'] = 0;
     }
     if (count($data_sale['cart']) == 0) {
         $data_sale['taxing'] = 'checked';
         $this->sale_lib->set_taxing(true);
     }
     $data_sale['modes'] = ['sale' => $this->lang->line('sales_sale'), 'return' => $this->lang->line('sales_return')];
     $data_sale['subtotal'] = $this->sale_lib->get_subtotal();
     $data_sale['taxes'] = $this->sale_lib->get_taxes();
     //Se cobran taxes?
     $data_sale['taxing'] = '';
     if ($this->sale_lib->get_taxing()) {
         $data_sale['taxing'] = 'checked';
     }
     $data_sale['total'] = $this->sale_lib->get_total();
     $data_sale['items_module_allowed'] = $this->Employee->has_permission('items', $person_info->person_id);
     $data_sale['comment'] = $this->sale_lib->get_comment();
     $data_sale['email_receipt'] = $this->sale_lib->get_email_receipt();
     $data_sale['payments_total'] = $this->sale_lib->get_payments_total();
     $data_sale['amount_due'] = $this->sale_lib->get_amount_due();
     $data_sale['payments'] = $this->sale_lib->get_payments(true);
     $data_sale['payment_options'] = [$this->lang->line('sales_cash') => $this->lang->line('sales_cash'), $this->lang->line('sales_check') => $this->lang->line('sales_check'), $this->lang->line('sales_giftcard') => $this->lang->line('sales_giftcard'), $this->lang->line('sales_debit') => $this->lang->line('sales_debit'), $this->lang->line('sales_credit') => $this->lang->line('sales_credit')];
     if ($data_sale['mode'] == 'sale' && $data_sale['customer'] != -1) {
         $lc = $this->Customer->get_info($data_sale['customer'])->max_amount_credit;
         if ($lc != '') {
             $data_sale['payment_options']['account'] = 'Account';
         }
     }
     //Filtros
     $data_report['cfilter'] = $this->input->post('filters');
     $data_report['sfilter'] = $this->input->post('filter_status') ? $this->input->post('filter_status') : 0;
     //Fechas
     $dateurl = get_simple_date_ranges();
     $dateurl = array_keys($dateurl);
     $data_sale['fechas'] = $dateurl;
     if ($data_report['cfilter']) {
         $data_report['all_time_date'] = $dateurl[$data_report['cfilter'] - 1];
     } else {
         $data_report['all_time_date'] = $dateurl[7];
     }
     $data_sale['all_time_date'] = $data_report['all_time_date'];
     list($data_report['start_date'], $data_report['end_date']) = explode('/', $data_report['all_time_date']);
     // if ($data_sale['mode']=='shipping') {
     // 	// array_push($data['payment_options'], array('30_dias' => 'A 30 dias', '60_dias' => 'A 60 dias'));
     // 	$data['payment_options']['30_days'] = $this->lang->line('30_days');
     // 	$data['payment_options']['60_days'] = $this->lang->line('60_days');
     // 	$data['payment_options']['90_days'] = $this->lang->line('90_days');
     // 	// $data[$key] = $value;
     // 	// $data['payment_options'] = '30_dias => A 30 dias';
     // }
     //Tab 2
     $data_sale['payments_cover_total'] = $data_report['payments_cover_total'] = $this->_payments_cover_total();
     // $loca = urldecode($this->input->get('loc'));
     // if ($loca) $location=$loca;
     $_data['view'] = 'reports/tabular_details';
     $this->load->model('reports/Detailed_sales');
     $model = $this->Detailed_sales;
     // $location='default';
     $this->Sale->con = $model->stabledb(false);
     $this->Sale->create_sales_items_temp_table();
     $report_data = $model->getData(['start_date' => $data_report['start_date'], 'end_date' => $data_report['end_date'], 'sale_type' => $force]);
     $summary_data = [];
     $details_data = [];
     foreach ($report_data['summary'] as $key => $row) {
         $summary_data[] = ['POS ' . $row['sale_id'], $row['sale_date'], $row['items_purchased'], $row['employee_name'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['profit']), $row['payment_type'], anchor('sales/receipt/' . $row['sale_id'], $this->lang->line('employees_profile_see'), ['class' => 'big_button', 'target' => '_blank', 'style' => 'padding: 5px 7px;'])];
         foreach ($report_data['details'][$key] as $drow) {
             $details_data[$key][] = [$drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['profit']), $drow['discount_percent'] . '%'];
         }
     }
     $data_re = ['title' => '', 'subtitle' => '', 'headers' => $model->getDataColumns(), 'summary_data' => $summary_data, 'details_data' => $details_data, 'location' => '', 'overall_summary_data' => $model->getSummaryData(['start_date' => $data_report['start_date'], 'end_date' => $data_report['end_date'], 'sale_type' => $force]), 'export_excel' => 0, 'sale_type' => $force, 'last' => true, 'cfilter' => $data_report['cfilter'], 'sfilter' => $data_report['sfilter']];
     $this->load->view('sales/index', ['register' => $data_sale, 'list' => $data_re]);
 }