Fixing Reports

- Added checks for array keys not set
- Renamed functions so that reports would generate
- Minor reformatting
- Added sale_id to the groupBy() call to remove error when only full group by is enabled.

Signed-off-by: objecttothis <objecttothis@gmail.com>
This commit is contained in:
objecttothis
2024-04-23 16:36:14 +04:00
committed by jekkos
parent 658a9ce553
commit 35e3adeca8
4 changed files with 25 additions and 25 deletions

View File

@@ -145,7 +145,7 @@ class Reports extends Secure_Controller
foreach($report_data as $row)
{
$tabular_data[] = [
'sale_date' => to_date(strtotime($row['sale_date'])),
'sale_date' => to_date(strtotime($row['sale_date']) ?? null),
'sales' => to_quantity_decimals($row['sales']),
'quantity' => to_quantity_decimals($row['quantity_purchased']),
'subtotal' => to_currency($row['subtotal']),
@@ -771,7 +771,7 @@ class Reports extends Secure_Controller
$series = [];
foreach($report_data as $row)
{
$date = to_date(strtotime($row['sale_date']));
$date = to_date(strtotime($row['sale_date'] ?? null));
$labels[] = $date;
$series[] = ['meta' => $date, 'value' => $row['total']];
}
@@ -1211,7 +1211,7 @@ class Reports extends Secure_Controller
* @param string $payment_type
* @return void
*/
public function specific_customer(string $start_date, string $end_date, string $customer_id, string $sale_type, string $payment_type): void
public function specific_customers(string $start_date, string $end_date, string $customer_id, string $sale_type, string $payment_type): void
{
$this->clearCache();
@@ -1245,7 +1245,7 @@ class Reports extends Secure_Controller
'id' => $row['sale_id'],
'type_code' => $row['type_code'],
'sale_time' => to_datetime(strtotime($row['sale_time'])),
'sale_date' => to_date(strtotime($row['sale_date'])),
'sale_date' => to_date(strtotime($row['sale_date'] ?? null)),
'quantity' => to_quantity_decimals($row['items_purchased']),
'employee_name' => $row['employee_name'],
'subtotal' => to_currency($row['subtotal']),
@@ -1340,7 +1340,7 @@ class Reports extends Secure_Controller
* @param string $sale_type
* @return void
*/
public function specific_employee(string $start_date, string $end_date, string $employee_id, string $sale_type): void
public function specific_employees(string $start_date, string $end_date, string $employee_id, string $sale_type): void
{
$this->clearCache();
@@ -1373,7 +1373,7 @@ class Reports extends Secure_Controller
$summary_data[] = [
'id' => $row['sale_id'],
'type_code' => $row['type_code'],
'sale_date' => to_date(strtotime($row['sale_date'])),
'sale_date' => to_date(strtotime($row['sale_date'] ?? null)),
'quantity' => to_quantity_decimals($row['items_purchased']),
'customer_name' => $row['customer_name'],
'subtotal' => to_currency($row['subtotal']),
@@ -1466,7 +1466,7 @@ class Reports extends Secure_Controller
* @param string $discount_type
* @return void
*/
public function specific_discount(string $start_date, string $end_date, string $discount, string $sale_type, string $discount_type): void
public function specific_discounts(string $start_date, string $end_date, string $discount, string $sale_type, string $discount_type): void
{
$this->clearCache();
@@ -1505,7 +1505,7 @@ class Reports extends Secure_Controller
$summary_data[] = [
'id' => $row['sale_id'],
'type_code' => $row['type_code'],
'sale_date' => to_date(strtotime($row['sale_date'])),
'sale_date' => to_date(strtotime($row['sale_date']?? null)),
'quantity' => to_quantity_decimals($row['items_purchased']),
'employee_name' => $row['employee_name'],
'customer_name' => $row['customer_name'],
@@ -1648,7 +1648,7 @@ class Reports extends Secure_Controller
* @param string $sale_type
* @return void
*/
public function specific_supplier(string $start_date, string $end_date, string $supplier_id, string $sale_type): void
public function specific_suppliers(string $start_date, string $end_date, string $supplier_id, string $sale_type): void
{
$inputs = [
'start_date' => $start_date,
@@ -1669,7 +1669,7 @@ class Reports extends Secure_Controller
$tabular_data[] = [
'id' => $row['sale_id'],
'type_code' => $row['type_code'],
'sale_date' => to_date(strtotime($row['sale_date'])),
'sale_date' => to_date(strtotime($row['sale_date'] ?? null)),
'name' => $row['name'],
'category' => $row['category'],
'item_number' => $row['item_number'],
@@ -1768,7 +1768,7 @@ class Reports extends Secure_Controller
$summary_data[] = [
'id' => $row['sale_id'],
'type_code' => $row['type_code'],
'sale_date' => isset($row['sale_date']) ? to_date(strtotime($row['sale_date'])) : null,
'sale_date' => to_date(strtotime($row['sale_date'] ?? null)),
'quantity' => to_quantity_decimals($row['items_purchased']),
'employee_name' => $row['employee_name'],
'customer_name' => $row['customer_name'],
@@ -1908,7 +1908,7 @@ class Reports extends Secure_Controller
{
$summary_data[] = [
'id' => $row['receiving_id'],
'receiving_date' => to_date(strtotime($row['receiving_date'])),
'receiving_date' => to_date(strtotime($row['receiving_date'] ?? null)),
'quantity' => to_quantity_decimals($row['items_purchased']),
'employee_name' => $row['employee_name'],
'supplier_name' => $row['supplier_name'],

View File

@@ -117,7 +117,7 @@ class Specific_supplier extends Report
$builder->where('sale_type', SALE_TYPE_RETURN);
}
$builder->groupBy('item_id');
$builder->groupBy(['item_id', 'sale_id']);
$builder->orderBy('sale_id');
return $builder->get()->getResultArray();

View File

@@ -43,8 +43,8 @@ $detailed_reports = [
<?php
}
}
?>
</div>
?>
</div>
</div>
</div>
@@ -64,8 +64,8 @@ $detailed_reports = [
<?php
}
}
?>
</div>
?>
</div>
</div>
</div>
@@ -85,8 +85,8 @@ $detailed_reports = [
<?php
}
}
?>
</div>
?>
</div>
</div>
<?php
@@ -100,15 +100,15 @@ $detailed_reports = [
<div class="list-group">
<?php
$inventory_low_report = get_report_link('reports_inventory_low');
$inventory_summary_report = get_report_link('reports_inventory_summary');
?>
$inventory_summary_report = get_report_link('reports_inventory_summary');
?>
<a class="list-group-item" href="<?= $inventory_low_report['path'] ?>"><?= $inventory_low_report['label'] ?></a>
<a class="list-group-item" href="<?= $inventory_summary_report['path'] ?>"><?= $inventory_summary_report['label'] ?></a>
</div>
</div>
<?php
}
?>
?>
</div>
</div>

View File

@@ -51,7 +51,7 @@
.addClass("table-striped")
.addClass("table-bordered")
.bootstrapTable({
columns: <?= transform_headers(esc($headers, 'js'), true, false) ?>,
columns: <?= transform_headers(esc($headers), true, false) ?>,
stickyHeader: true,
stickyHeaderOffsetLeft: $('#table').offset().left + 'px',
stickyHeaderOffsetRight: $('#table').offset().right + 'px',
@@ -62,10 +62,10 @@
exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel', 'pdf'],
pagination: true,
showColumns: true,
data: <?= json_encode(esc($data, 'js')) ?>,
data: <?= json_encode(esc($data)) ?>,
iconSize: 'sm',
paginationVAlign: 'bottom',
escape: false,
escape: true,
search: true
});
});