forked from Business/BinStack
Add desired quantity tracking (Close #2)
This commit is contained in:
parent
1118fce702
commit
f3899029f7
@ -47,6 +47,13 @@ switch ($VARS['action']) {
|
|||||||
}
|
}
|
||||||
if (is_empty($VARS['qty'])) {
|
if (is_empty($VARS['qty'])) {
|
||||||
$VARS['qty'] = 1;
|
$VARS['qty'] = 1;
|
||||||
|
} else if (!is_numeric($VARS['qty'])) {
|
||||||
|
returnToSender('field_nan');
|
||||||
|
}
|
||||||
|
if (is_empty($VARS['want'])) {
|
||||||
|
$VARS['want'] = 0;
|
||||||
|
} else if (!is_numeric($VARS['want'])) {
|
||||||
|
returnToSender('field_nan');
|
||||||
}
|
}
|
||||||
if (!$database->has('categories', ['catid' => $VARS['cat']])) {
|
if (!$database->has('categories', ['catid' => $VARS['cat']])) {
|
||||||
returnToSender('invalid_category');
|
returnToSender('invalid_category');
|
||||||
@ -71,6 +78,7 @@ switch ($VARS['action']) {
|
|||||||
'catid' => $VARS['cat'],
|
'catid' => $VARS['cat'],
|
||||||
'locid' => $VARS['loc'],
|
'locid' => $VARS['loc'],
|
||||||
'qty' => $VARS['qty'],
|
'qty' => $VARS['qty'],
|
||||||
|
'want' => $VARS['want'],
|
||||||
'userid' => $userid
|
'userid' => $userid
|
||||||
];
|
];
|
||||||
|
|
||||||
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -77,5 +77,12 @@ define("STRINGS", [
|
|||||||
"placeholder location name" => "Over the Hills",
|
"placeholder location name" => "Over the Hills",
|
||||||
"description" => "Description",
|
"description" => "Description",
|
||||||
"notes" => "Notes",
|
"notes" => "Notes",
|
||||||
"comments" => "Comments"
|
"comments" => "Comments",
|
||||||
|
"minwant" => "Minimum On Hand",
|
||||||
|
"want" => "Need",
|
||||||
|
"field not a number" => "You entered something that isn't a number when a number was expected.",
|
||||||
|
"understocked items" => "Understocked Items",
|
||||||
|
"view understocked" => "View Understocked",
|
||||||
|
"only showing understocked" => "Only showing understocked items.",
|
||||||
|
"show all items" => "Show all items"
|
||||||
]);
|
]);
|
@ -69,4 +69,8 @@ define("MESSAGES", [
|
|||||||
"string" => "location in use",
|
"string" => "location in use",
|
||||||
"type" => "danger"
|
"type" => "danger"
|
||||||
],
|
],
|
||||||
|
"field_nan" => [
|
||||||
|
"string" => "field not a number",
|
||||||
|
"type" => "danger"
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
@ -8,11 +8,18 @@ require_once __DIR__ . '/userinfo.php';
|
|||||||
|
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
$showwant = ($VARS['show_want'] == 1);
|
||||||
|
|
||||||
$out = [];
|
$out = [];
|
||||||
|
|
||||||
$out['draw'] = intval($VARS['draw']);
|
$out['draw'] = intval($VARS['draw']);
|
||||||
|
|
||||||
$out['recordsTotal'] = $database->count('items');
|
if ($showwant) {
|
||||||
|
$out['recordsTotal'] = $database->count('items', ["AND" => ["qty[<]want", "want[>]" => 0]]);
|
||||||
|
} else {
|
||||||
|
$out['recordsTotal'] = $database->count('items');
|
||||||
|
}
|
||||||
|
|
||||||
$filter = false;
|
$filter = false;
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
@ -40,25 +47,33 @@ switch ($VARS['order'][0]['column']) {
|
|||||||
case 7:
|
case 7:
|
||||||
$order = ["qty" => $sortby];
|
$order = ["qty" => $sortby];
|
||||||
break;
|
break;
|
||||||
|
case 8:
|
||||||
|
$order = ["want" => $sortby];
|
||||||
|
break;
|
||||||
// Note: We're not going to sort by assigned user. It's too hard. Maybe later.
|
// Note: We're not going to sort by assigned user. It's too hard. Maybe later.
|
||||||
}
|
}
|
||||||
|
|
||||||
// search
|
// search
|
||||||
if (!is_empty($VARS['search']['value'])) {
|
if (!is_empty($VARS['search']['value'])) {
|
||||||
$filter = true;
|
$filter = true;
|
||||||
$wherenolimit = [
|
$wherenolimit = [];
|
||||||
"OR" => [
|
if ($showwant) {
|
||||||
"name[~]" => $VARS['search']['value'],
|
$wherenolimit["AND"] = ["qty[<]want", "want[>]" => 0];
|
||||||
"catname[~]" => $VARS['search']['value'],
|
}
|
||||||
"locname[~]" => $VARS['search']['value'],
|
$wherenolimit["AND"]["OR"] = [
|
||||||
"code1[~]" => $VARS['search']['value'],
|
"name[~]" => $VARS['search']['value'],
|
||||||
"code2[~]" => $VARS['search']['value']
|
"catname[~]" => $VARS['search']['value'],
|
||||||
]
|
"locname[~]" => $VARS['search']['value'],
|
||||||
|
"code1[~]" => $VARS['search']['value'],
|
||||||
|
"code2[~]" => $VARS['search']['value']
|
||||||
];
|
];
|
||||||
$where = $wherenolimit;
|
$where = $wherenolimit;
|
||||||
$where["LIMIT"] = [$VARS['start'], $VARS['length']];
|
$where["LIMIT"] = [$VARS['start'], $VARS['length']];
|
||||||
} else {
|
} else {
|
||||||
$where = ["LIMIT" => [$VARS['start'], $VARS['length']]];
|
$where = ["LIMIT" => [$VARS['start'], $VARS['length']]];
|
||||||
|
if ($showwant) {
|
||||||
|
$where["AND"] = ["qty[<]want", "want[>]" => 0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!is_null($order)) {
|
if (!is_null($order)) {
|
||||||
$where["ORDER"] = $order;
|
$where["ORDER"] = $order;
|
||||||
@ -77,6 +92,7 @@ $items = $database->select('items', [
|
|||||||
'code1',
|
'code1',
|
||||||
'code2',
|
'code2',
|
||||||
'qty',
|
'qty',
|
||||||
|
'want',
|
||||||
'userid'
|
'userid'
|
||||||
], $where);
|
], $where);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ $itemdata = [
|
|||||||
'text2' => '',
|
'text2' => '',
|
||||||
'text3' => '',
|
'text3' => '',
|
||||||
'qty' => 1,
|
'qty' => 1,
|
||||||
|
'want' => 0,
|
||||||
'userid' => ''];
|
'userid' => ''];
|
||||||
|
|
||||||
$editing = false;
|
$editing = false;
|
||||||
@ -46,6 +47,7 @@ if (!is_empty($VARS['id'])) {
|
|||||||
'locname',
|
'locname',
|
||||||
'loccode',
|
'loccode',
|
||||||
'qty',
|
'qty',
|
||||||
|
'want',
|
||||||
'userid'
|
'userid'
|
||||||
], [
|
], [
|
||||||
'itemid' => $VARS['id']
|
'itemid' => $VARS['id']
|
||||||
@ -123,12 +125,18 @@ if (!is_empty($VARS['id'])) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-md-6">
|
<div class="col-xs-12 col-md-3">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="qty"><i class="fa fa-hashtag"></i> <?php lang('quantity'); ?></label>
|
<label for="qty"><i class="fa fa-hashtag"></i> <?php lang('quantity'); ?></label>
|
||||||
<input type="number" class="form-control" id="qty" name="qty" placeholder="1" value="<?php echo $itemdata['qty']; ?>" />
|
<input type="number" class="form-control" id="qty" name="qty" placeholder="1" value="<?php echo $itemdata['qty']; ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="want"><i class="fa fa-hashtag"></i> <?php lang('minwant'); ?></label>
|
||||||
|
<input type="number" class="form-control" id="want" name="want" placeholder="1" value="<?php echo $itemdata['want']; ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col-xs-12 col-md-6">
|
<div class="col-xs-12 col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="assignedto"><i class="fa fa-user"></i> <?php lang('assigned to'); ?></label>
|
<label for="assignedto"><i class="fa fa-user"></i> <?php lang('assigned to'); ?></label>
|
||||||
|
@ -11,29 +11,21 @@ redirectifnotloggedin();
|
|||||||
<h1><i class="fa fa-fw fa-cubes"></i> <?php echo $database->count('items'); ?></h1>
|
<h1><i class="fa fa-fw fa-cubes"></i> <?php echo $database->count('items'); ?></h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<a style="color: black;" href="app.php?page=items"><i class="fa fa-arrow-right fa-fw"></i> <?php lang('view items'); ?></a>
|
<a href="app.php?page=items" style="color: black;"><i class="fa fa-arrow-right"></i> <?php lang("view items"); ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-6 col-md-4">
|
<div class="col-xs-12 col-sm-6 col-md-4">
|
||||||
<div class="panel panel-deep-orange">
|
<?php
|
||||||
<div class="panel-heading"><div class="panel-title"><?php lang("locations") ?></div></div>
|
$lowcnt = $database->count('items', ["AND" => ["qty[<]want", "want[>]" => 0]]);
|
||||||
|
?>
|
||||||
|
<div class="panel panel-<?php echo ($lowcnt > 0 ? "orange" : "green"); ?>">
|
||||||
|
<div class="panel-heading"><div class="panel-title"><?php lang("understocked items") ?></div></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h1><i class="fa fa-fw fa-map-marker"></i> <?php echo $database->count('locations'); ?></h1>
|
<h1><i class="fa fa-fw fa-tachometer"></i> <?php echo $lowcnt; ?></h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<a style="color: black;" href="app.php?page=locations"><i class="fa fa-arrow-right fa-fw"></i> <?php lang('view locations'); ?></a>
|
<a href="app.php?page=items&filter=stock" style="color: black;"><i class="fa fa-arrow-right"></i> <?php lang("view understocked"); ?></a>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-12 col-sm-6 col-md-4">
|
|
||||||
<div class="panel panel-blue">
|
|
||||||
<div class="panel-heading"><div class="panel-title"><?php lang("categories") ?></div></div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<h1><i class="fa fa-fw fa-archive"></i> <?php echo $database->count('categories'); ?></h1>
|
|
||||||
</div>
|
|
||||||
<div class="panel-footer">
|
|
||||||
<a style="color: black;" href="app.php?page=categories"><i class="fa fa-arrow-right fa-fw"></i> <?php lang('view categories'); ?></a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,6 +8,13 @@ redirectifnotloggedin();
|
|||||||
<div class="btn-group" style="margin-bottom: 10px;">
|
<div class="btn-group" style="margin-bottom: 10px;">
|
||||||
<a href="app.php?page=edititem" class="btn btn-success"><i class="fa fa-plus"></i> <?php lang("new item"); ?></a>
|
<a href="app.php?page=edititem" class="btn btn-success"><i class="fa fa-plus"></i> <?php lang("new item"); ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if ($_GET['filter'] == 'stock') { ?>
|
||||||
|
<script>var filter = "stock";</script>
|
||||||
|
<div class="alert alert-blue-grey"><i class="fa fa-filter fa-fw"></i> <?php lang("only showing understocked"); ?> <a href="app.php?page=items" class="btn btn-sm btn-blue-grey"><?php lang("show all items"); ?></a></div>
|
||||||
|
<?php } else {
|
||||||
|
echo "<script>var filter = null;</script>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
<table id="itemtable" class="table table-bordered table-striped">
|
<table id="itemtable" class="table table-bordered table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -19,6 +26,7 @@ redirectifnotloggedin();
|
|||||||
<th data-priority="3"><i class="fa fa-fw fa-barcode hidden-xs"></i> <?php lang('code 1'); ?></th>
|
<th data-priority="3"><i class="fa fa-fw fa-barcode hidden-xs"></i> <?php lang('code 1'); ?></th>
|
||||||
<th data-priority="4"><i class="fa fa-fw fa-qrcode hidden-xs"></i> <?php lang('code 2'); ?></th>
|
<th data-priority="4"><i class="fa fa-fw fa-qrcode hidden-xs"></i> <?php lang('code 2'); ?></th>
|
||||||
<th data-priority="3"><i class="fa fa-fw fa-hashtag hidden-xs"></i> <?php lang('qty'); ?></th>
|
<th data-priority="3"><i class="fa fa-fw fa-hashtag hidden-xs"></i> <?php lang('qty'); ?></th>
|
||||||
|
<th data-priority="4"><i class="fa fa-fw fa-hashtag hidden-xs"></i> <?php lang('want'); ?></th>
|
||||||
<th data-priority="3"><i class="fa fa-fw fa-user hidden-xs"></i> <?php lang('assigned to'); ?></th>
|
<th data-priority="3"><i class="fa fa-fw fa-user hidden-xs"></i> <?php lang('assigned to'); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -36,6 +44,7 @@ redirectifnotloggedin();
|
|||||||
'code1',
|
'code1',
|
||||||
'code2',
|
'code2',
|
||||||
'qty',
|
'qty',
|
||||||
|
'want',
|
||||||
'userid'
|
'userid'
|
||||||
], ["LIMIT" => 100]);
|
], ["LIMIT" => 100]);
|
||||||
$usercache = [];
|
$usercache = [];
|
||||||
@ -60,6 +69,7 @@ redirectifnotloggedin();
|
|||||||
<td><?php echo $item['code1']; ?></td>
|
<td><?php echo $item['code1']; ?></td>
|
||||||
<td><?php echo $item['code2']; ?></td>
|
<td><?php echo $item['code2']; ?></td>
|
||||||
<td><?php echo $item['qty']; ?></td>
|
<td><?php echo $item['qty']; ?></td>
|
||||||
|
<td><?php echo $item['want']; ?></td>
|
||||||
<td><?php echo $user; ?></td>
|
<td><?php echo $user; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@ -76,6 +86,7 @@ redirectifnotloggedin();
|
|||||||
<th data-priority="3"><i class="fa fa-fw fa-barcode hidden-xs"></i> <?php lang('code 1'); ?></th>
|
<th data-priority="3"><i class="fa fa-fw fa-barcode hidden-xs"></i> <?php lang('code 1'); ?></th>
|
||||||
<th data-priority="4"><i class="fa fa-fw fa-qrcode hidden-xs"></i> <?php lang('code 2'); ?></th>
|
<th data-priority="4"><i class="fa fa-fw fa-qrcode hidden-xs"></i> <?php lang('code 2'); ?></th>
|
||||||
<th data-priority="3"><i class="fa fa-fw fa-hashtag hidden-xs"></i> <?php lang('qty'); ?></th>
|
<th data-priority="3"><i class="fa fa-fw fa-hashtag hidden-xs"></i> <?php lang('qty'); ?></th>
|
||||||
|
<th data-priority="4"><i class="fa fa-fw fa-hashtag hidden-xs"></i> <?php lang('want'); ?></th>
|
||||||
<th data-priority="3"><i class="fa fa-fw fa-user hidden-xs"></i> <?php lang('assigned to'); ?></th>
|
<th data-priority="3"><i class="fa fa-fw fa-user hidden-xs"></i> <?php lang('assigned to'); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
@ -34,6 +34,11 @@ var itemtable = $('#itemtable').DataTable({
|
|||||||
serverSide: true,
|
serverSide: true,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "lib/getitemtable.php",
|
url: "lib/getitemtable.php",
|
||||||
|
data: function (d) {
|
||||||
|
if (filter == "stock") {
|
||||||
|
d.show_want = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
dataFilter: function (data) {
|
dataFilter: function (data) {
|
||||||
var json = jQuery.parseJSON(data);
|
var json = jQuery.parseJSON(data);
|
||||||
json.data = [];
|
json.data = [];
|
||||||
@ -47,6 +52,7 @@ var itemtable = $('#itemtable').DataTable({
|
|||||||
row.code1,
|
row.code1,
|
||||||
row.code2,
|
row.code2,
|
||||||
row.qty,
|
row.qty,
|
||||||
|
row.want,
|
||||||
row.username
|
row.username
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user