Skip to content

Commit

Permalink
Merge pull request #451 from boxwise/hotfix/removing-limit-in-manage-box
Browse files Browse the repository at this point in the history
Fixes sorting and displaying the total number of boxes in the manage box
  • Loading branch information
HaGuesto authored Nov 30, 2021
2 parents 2678032 + 54c73e9 commit 7f7deef
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions include/stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ function () use ($action, &$cmsmain) {
if (!$ajax) {
initlist();

listsetting('maxlimit', 500);

$cmsmain->assign('title', 'Manage Boxes');
listsetting('search', ['box_id', 'l.label', 's.label', 'g.label', 'p.name', 'stock.comments']);

Expand Down Expand Up @@ -115,7 +113,8 @@ function get_filter2_query($applied_filter, $custom_outgoing_locations)
($_SESSION['filter4']['stock'] ? ' AND (p.category_id = '.$_SESSION['filter4']['stock'].')' : '');

$data = getlistdata($query);

$totalboxes = 0;
$totalitems = 0;
foreach ($data as $key => $value) {
if ($data[$key]['ordered']) {
$data[$key]['order'] = '<span class="hide">1</span><i class="fa fa-shopping-cart tooltip-this" title="This box is ordered for the shop by '.$data[$key]['ordered_name'].' on '.strftime('%d-%m-%Y', strtotime($data[$key]['ordered'])).'"></i>';
Expand All @@ -124,13 +123,8 @@ function get_filter2_query($applied_filter, $custom_outgoing_locations)
} else {
$data[$key]['order'] = '<span class="hide">0</span>';
}
}

$totalboxes = 0;
$totalitems = 0;
foreach ($data as $key => $d) {
++$totalboxes;
$totalitems += $d['items'];
$totalitems += $value['items'];
}

addcolumn('text', 'Box ID', 'box_id');
Expand All @@ -154,11 +148,6 @@ function get_filter2_query($applied_filter, $custom_outgoing_locations)
addbutton('order', 'Order from warehouse', ['icon' => 'fa-shopping-cart', 'disableif' => true]);
addbutton('undo-order', 'Undo order', ['icon' => 'fa-undo']);

// Notify the user of the limit on the number of records
if (count($data) >= 500) {
$cmsmain->assign('notification', 'Only the first 500 boxes are shown. Use the filter and search to find the rest.');
}

$cmsmain->assign('firstline', ['Total', '', '', '', $totalboxes.' boxes', $totalitems.' items', '', '']);
$cmsmain->assign('listfooter', ['Total', '', '', '', $totalboxes.' boxes', $totalitems.' items', '', '']);

Expand Down

0 comments on commit 7f7deef

Please sign in to comment.