Add stock location as filter to detailed sales + receivings reports

This commit is contained in:
jekkos
2015-07-10 19:04:52 +02:00
parent 70b7a03c63
commit 83a297cf15
9 changed files with 61 additions and 71 deletions

View File

@@ -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');

View File

@@ -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');

View File

@@ -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

View File

@@ -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();