Change SUM to MAX and a couple of indent issues.

This commit is contained in:
Steve Ireland
2017-01-22 16:40:20 -05:00
parent dc638c74b5
commit 476db84e86
5 changed files with 36 additions and 36 deletions

View File

@@ -247,18 +247,18 @@ class Receiving extends CI_Model
MAX(employee_id) AS employee_id,
items.item_id,
MAX(receivings.supplier_id) AS supplier_id,
SUM(quantity_purchased) AS quantity_purchased,
SUM(receivings_items.receiving_quantity) AS receiving_quantity,
MAX(quantity_purchased) AS quantity_purchased,
MAX(receivings_items.receiving_quantity) AS receiving_quantity,
MAX(item_cost_price) AS item_cost_price,
MAX(item_unit_price) AS item_unit_price,
MAX(discount_percent) AS discount_percent,
receivings_items.line,
MAX(serialnumber) AS serialnumber,
MAX(receivings_items.description) AS description,
SUM(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
SUM(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
SUM((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit,
SUM(item_cost_price * quantity_purchased) AS cost
MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
MAX((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit,
MAX(item_cost_price * quantity_purchased) AS cost
FROM ' . $this->db->dbprefix('receivings_items') . ' AS receivings_items
INNER JOIN ' . $this->db->dbprefix('receivings') . ' AS receivings
ON receivings_items.receiving_id = receivings.receiving_id

View File

@@ -64,8 +64,8 @@ class Sale extends CI_Model
MAX(customer_p.comments) AS comments,
' . "
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
SUM(payments.sale_payment_amount) AS amount_tendered,
(SUM(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
MAX(payments.sale_payment_amount) AS amount_tendered,
(MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
" . '
MAX(payments.payment_type) AS payment_type
');
@@ -845,7 +845,7 @@ class Sale extends CI_Model
MAX(items.name) AS name,
MAX(items.category) AS category,
MAX(items.supplier_id) AS supplier_id,
SUM(sales_items.quantity_purchased) AS quantity_purchased,
MAX(sales_items.quantity_purchased) AS quantity_purchased,
MAX(sales_items.item_cost_price) AS item_cost_price,
MAX(sales_items.item_unit_price) AS item_unit_price,
MAX(sales_items.discount_percent) AS discount_percent,
@@ -854,7 +854,7 @@ class Sale extends CI_Model
MAX(sales_items.item_location) AS item_location,
MAX(sales_items.description) AS description,
MAX(payments.payment_type) AS payment_type,
SUM(payments.sale_payment_amount) AS sale_payment_amount,
MAX(payments.sale_payment_amount) AS sale_payment_amount,
IFNULL(SUM(sales_items_taxes.percent), 0) AS item_tax_percent,
' . "
ROUND($sale_subtotal, $decimals) AS subtotal,

View File

@@ -26,7 +26,7 @@ class Detailed_receivings extends Report
array('supplier' => $this->lang->line('reports_supplied_by')),
array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
array('payment_type' => $this->lang->line('reports_payment_type')),
array('comment' => $this->lang->line('reports_comments')),
array('comment' => $this->lang->line('reports_comments')),
array('reference' => $this->lang->line('receivings_reference'))),
'details' => array(
$this->lang->line('reports_item_number'),
@@ -57,27 +57,27 @@ class Detailed_receivings extends Report
$this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
$this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
$this->db->where('receiving_id', $receiving_id);
$this->db->group_by('receiving_id');
$this->db->group_by('receiving_id');
return $this->db->get()->row_array();
}
return $this->db->get()->row_array();
}
public function getData(array $inputs)
{
public function getData(array $inputs)
{
$this->db->select('receiving_id,
MAX(receiving_date) as receiving_date,
SUM(quantity_purchased) AS items_purchased,
MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name,
MAX(supplier.company_name) AS supplier_name,
SUM(total) AS total,
SUM(profit) AS profit,
MAX(payment_type) AS payment_type,
MAX(comment) AS comment,
MAX(reference) AS reference');
$this->db->from('receivings_items_temp AS receivings_items_temp');
$this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
$this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
$this->db->select('receiving_id,
MAX(receiving_date) as receiving_date,
SUM(quantity_purchased) AS items_purchased,
MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name,
MAX(supplier.company_name) AS supplier_name,
SUM(total) AS total,
SUM(profit) AS profit,
MAX(payment_type) AS payment_type,
MAX(comment) AS comment,
MAX(reference) AS reference');
$this->db->from('receivings_items_temp AS receivings_items_temp');
$this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
$this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
if($inputs['location_id'] != 'all')
{

View File

@@ -10,14 +10,14 @@ if(isset($error))
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-stats">&nbsp</span><?php echo $this->lang->line('reports_graphical_reports'); ?></h3>
</div>
</div>
<div class="list-group">
<?php
foreach($grants as $grant)
{
if (preg_match('/reports_/', $grant['permission_id']) && !preg_match('/(inventory|receivings)/', $grant['permission_id']))
if (preg_match('/reports_/', $grant['permission_id']) && !preg_match('/(inventory|receivings)/', $grant['permission_id']))
{
show_report('graphical_summary', $grant['permission_id']);
}
@@ -29,9 +29,9 @@ if(isset($error))
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-list">&nbsp</span><?php echo $this->lang->line('reports_summary_reports'); ?></h3>
</div>
</div>
<div class="list-group">
<?php
foreach($grants as $grant)
@@ -48,9 +48,9 @@ if(isset($error))
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-list-alt">&nbsp</span><?php echo $this->lang->line('reports_detailed_reports'); ?></h3>
</div>
</div>
<div class="list-group">
<?php
$person_id = $this->session->userdata('person_id');