diff --git a/application/config/routes.php b/application/config/routes.php index d52708ea5..ef981724e 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -50,9 +50,9 @@ $route['reports/graphical_:any'] = "reports/date_input"; $route['reports/(inventory_:any)/(:any)'] = "reports/$1/$2"; $route['reports/inventory_:any'] = "reports/excel_export"; -$route['reports/(detailed_sales)/(:any)/(:any)'] = "reports/$1/$2/$3"; -$route['reports/detailed_sales'] = "reports/date_input"; -$route['reports/(detailed_receivings)/(:any)/(:any)'] = "reports/$1/$2/$3"; +$route['reports/(detailed_sales)/(:any)/(:any)/(:any)'] = "reports/$1/$2/$3$/$4"; +$route['reports/detailed_sales'] = "reports/date_input_sales"; +$route['reports/(detailed_receivings)/(:any)/(:any)/(:any)'] = "reports/$1/$2/$3/$4"; $route['reports/detailed_receivings'] = "reports/date_input_recv"; $route['reports/(specific_:any)/(:any)/(:any)/(:any)'] = "reports/$1/$2/$3/$4"; $route['reports/specific_customer'] = "reports/specific_customer_input"; diff --git a/application/controllers/reports.php b/application/controllers/reports.php index 8d78cb39e..bc588b7ab 100644 --- a/application/controllers/reports.php +++ b/application/controllers/reports.php @@ -333,9 +333,11 @@ class Reports extends Secure_area } //Input for reports that require only a date range. (see routes.php to see that all graphical summary reports route here) - function date_input() + function date_input_sales() { $data = $this->_get_common_report_data(); + $stock_locations = $this->Stock_locations->get_allowed_locations('sales'); + $data['stock_locations'] = array_merge(array('all' => $this->lang->line('reports_all')), $stock_locations); $data['mode'] = 'sale'; $this->load->view("reports/date_input",$data); } @@ -343,14 +345,9 @@ class Reports extends Secure_area function date_input_recv() { $data = $this->_get_common_report_data(); - $data['mode'] = 'receiving'; - $this->load->view("reports/date_input",$data); - } - - function date_input_reqs() - { - $data = $this->_get_common_report_data(); - $data['mode'] = 'requisition'; + $stock_locations = $this->Stock_locations->get_allowed_locations('receivings'); + $data['stock_locations'] = array_merge(array('all' => $this->lang->line('reports_all')), $stock_locations); + $data['mode'] = 'receiving'; $this->load->view("reports/date_input",$data); } @@ -843,13 +840,13 @@ class Reports extends Secure_area } - function detailed_sales($start_date, $end_date, $sale_type, $export_excel=0) + function detailed_sales($start_date, $end_date, $sale_type, $location_id='all', $export_excel=0) { $this->load->model('reports/Detailed_sales'); $model = $this->Detailed_sales; $headers = $model->getDataColumns(); - $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type' => $sale_type)); + $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $summary_data = array(); $details_data = array(); @@ -886,13 +883,13 @@ class Reports extends Secure_area $this->load->view("reports/tabular_details",$data); } - function detailed_receivings($start_date, $end_date, $receiving_type, $export_excel=0) + function detailed_receivings($start_date, $end_date, $receiving_type, $location_id='all', $export_excel=0) { $this->load->model('reports/Detailed_receivings'); $model = $this->Detailed_receivings; $headers = $model->getDataColumns(); - $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'receiving_type'=>$receiving_type)); + $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'receiving_type'=>$receiving_type, 'location_id' => $location_id)); $summary_data = array(); $details_data = array(); @@ -930,39 +927,6 @@ class Reports extends Secure_area $this->load->view("reports/tabular_details",$data); } - function detailed_requisition($start_date, $end_date , $export_excel=0) - { - $this->load->model('reports/Detailed_requisition'); - $model = $this->Detailed_requisition; - $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date)); - - $summary_data = array(); - $details_data = array(); - - foreach($report_data['summary'] as $key=>$row) - { - $summary_data[] = array(anchor('receivings/requisition_receipt/'.$row['requisition_id'], 'REQS '.$row['requisition_id'], array('target' => '_blank')), $row['requisition_date'], $row['employee_name'], $row['comment']); - - foreach($report_data['details'][$key] as $drow) - { - $details_data[$key][] = array($drow['name'], $drow['requisition_quantity'], - $drow['related_item_id'], $drow['related_item_quantity'], - $drow['related_item_total_quantity']); - } - } - - $data = array( - "title" =>$this->lang->line('reports_detailed_requisition_report'), - "subtitle" => date('m/d/Y', strtotime($start_date)) .'-'.date('m/d/Y', strtotime($end_date)), - "headers" => $model->getDataColumns(), - "summary_data" => $summary_data, - "details_data" => $details_data, - "overall_summary_data" => '', - "export_excel" => $export_excel - ); - $this->load->view("reports/tabular_details",$data); - } - function excel_export() { $this->load->view("reports/excel_export",array()); diff --git a/application/models/reports/detailed_receivings.php b/application/models/reports/detailed_receivings.php index 2179e91af..15fa72b99 100644 --- a/application/models/reports/detailed_receivings.php +++ b/application/models/reports/detailed_receivings.php @@ -30,7 +30,11 @@ class Detailed_receivings extends Report $this->db->from('receivings_items_temp'); $this->db->join('people as employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('people as supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); - $this->db->where('receiving_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"'); + $this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' and '. $this->db->escape($inputs['end_date'])); + if ($inputs['location_id'] != 'all') + { + $this->db->where('item_location', $inputs['location_id']); + } if ($inputs['receiving_type'] == 'receiving') { $this->db->where('quantity_purchased > 0'); @@ -67,7 +71,7 @@ class Detailed_receivings extends Report { $this->db->select('sum(total) as total'); $this->db->from('receivings_items_temp'); - $this->db->where('receiving_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"'); + $this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' and '. $this->db->escape($inputs['end_date'])); if ($inputs['receiving_type'] == 'receiving') { $this->db->where('quantity_purchased > 0'); diff --git a/application/models/reports/detailed_sales.php b/application/models/reports/detailed_sales.php index 1a30fe10a..789a664dd 100644 --- a/application/models/reports/detailed_sales.php +++ b/application/models/reports/detailed_sales.php @@ -30,7 +30,11 @@ class Detailed_sales extends Report $this->db->from('sales_items_temp'); $this->db->join('people as employee', 'sales_items_temp.employee_id = employee.person_id'); $this->db->join('people as customer', 'sales_items_temp.customer_id = customer.person_id', 'left'); - $this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"'); + $this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' and '. $this->db->escape($inputs['end_date'])); + if ($inputs['location_id'] != 'all') + { + $this->db->where('item_location', $inputs['location_id']); + } if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -51,7 +55,7 @@ class Detailed_sales extends Report $this->db->select('name, category, quantity_purchased, item_location, serialnumber, sales_items_temp.description, subtotal,total, tax, profit, discount_percent'); $this->db->from('sales_items_temp'); $this->db->join('items', 'sales_items_temp.item_id = items.item_id'); - $this->db->where('sale_id = '.$value['sale_id']); + $this->db->where('sale_id', $value['sale_id']); $data['details'][$key] = $this->db->get()->result_array(); } @@ -62,7 +66,7 @@ class Detailed_sales extends Report { $this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit'); $this->db->from('sales_items_temp'); - $this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"'); + $this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' and '. $this->db->escape($inputs['end_date'])); if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); diff --git a/application/models/sale.php b/application/models/sale.php index fe0c63d19..167cdaa41 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -416,8 +416,7 @@ class Sale extends CI_Model .$this->db->dbprefix('sales_items').'.line='.$this->db->dbprefix('sales_items_taxes').'.line'." GROUP BY sale_id, item_id, line)"); - //Update null item_tax_percents to be 0 instead of null - $this->db->where('item_tax_percent IS NULL'); + //Update null item_tax_percents to be 0 instead of null$this->db->where('item_tax_percent IS NULL'); $this->db->update('sales_items_temp', array('item_tax_percent' => 0)); //Update null tax to be 0 instead of null diff --git a/application/models/stock_locations.php b/application/models/stock_locations.php index 6962016ca..a9d6ce183 100644 --- a/application/models/stock_locations.php +++ b/application/models/stock_locations.php @@ -39,7 +39,7 @@ class Stock_locations extends CI_Model { return $this->get_all()->num_rows() > 1; } - + function get_allowed_locations($module_id='items') { $stock = $this->get_undeleted_all($module_id)->result_array(); diff --git a/application/views/partial/footer.php b/application/views/partial/footer.php index fe1c50460..c4ffdf6ee 100644 --- a/application/views/partial/footer.php +++ b/application/views/partial/footer.php @@ -1,6 +1,6 @@
+lang->line('common_please_visit_my'); ?> lang->line('common_website'); ?> lang->line('common_learn_about_project'); ?>.