Add desired quantity tracking (Close #2)

master
Skylar Ittner 7 years ago
parent 1118fce702
commit f3899029f7

@ -47,6 +47,13 @@ switch ($VARS['action']) {
}
if (is_empty($VARS['qty'])) {
$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']])) {
returnToSender('invalid_category');
@ -71,6 +78,7 @@ switch ($VARS['action']) {
'catid' => $VARS['cat'],
'locid' => $VARS['loc'],
'qty' => $VARS['qty'],
'want' => $VARS['want'],
'userid' => $userid
];

Binary file not shown.

@ -77,5 +77,12 @@ define("STRINGS", [
"placeholder location name" => "Over the Hills",
"description" => "Description",
"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",
"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");
$showwant = ($VARS['show_want'] == 1);
$out = [];
$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;
// sort
@ -40,25 +47,33 @@ switch ($VARS['order'][0]['column']) {
case 7:
$order = ["qty" => $sortby];
break;
case 8:
$order = ["want" => $sortby];
break;
// Note: We're not going to sort by assigned user. It's too hard. Maybe later.
}
// search
if (!is_empty($VARS['search']['value'])) {
$filter = true;
$wherenolimit = [
"OR" => [
"name[~]" => $VARS['search']['value'],
"catname[~]" => $VARS['search']['value'],
"locname[~]" => $VARS['search']['value'],
"code1[~]" => $VARS['search']['value'],
"code2[~]" => $VARS['search']['value']
]
$wherenolimit = [];
if ($showwant) {
$wherenolimit["AND"] = ["qty[<]want", "want[>]" => 0];
}
$wherenolimit["AND"]["OR"] = [
"name[~]" => $VARS['search']['value'],
"catname[~]" => $VARS['search']['value'],
"locname[~]" => $VARS['search']['value'],
"code1[~]" => $VARS['search']['value'],
"code2[~]" => $VARS['search']['value']
];
$where = $wherenolimit;
$where["LIMIT"] = [$VARS['start'], $VARS['length']];
} else {
$where = ["LIMIT" => [$VARS['start'], $VARS['length']]];
if ($showwant) {
$where["AND"] = ["qty[<]want", "want[>]" => 0];
}
}
if (!is_null($order)) {
$where["ORDER"] = $order;
@ -77,6 +92,7 @@ $items = $database->select('items', [
'code1',
'code2',
'qty',
'want',
'userid'
], $where);

@ -18,6 +18,7 @@ $itemdata = [
'text2' => '',
'text3' => '',
'qty' => 1,
'want' => 0,
'userid' => ''];
$editing = false;
@ -46,6 +47,7 @@ if (!is_empty($VARS['id'])) {
'locname',
'loccode',
'qty',
'want',
'userid'
], [
'itemid' => $VARS['id']
@ -123,12 +125,18 @@ if (!is_empty($VARS['id'])) {
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="col-xs-12 col-md-3">
<div class="form-group">
<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']; ?>" />
</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="form-group">
<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>
</div>
<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 class="col-xs-12 col-sm-6 col-md-4">
<div class="panel panel-deep-orange">
<div class="panel-heading"><div class="panel-title"><?php lang("locations") ?></div></div>
<?php
$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">
<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 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>
</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>
<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>

@ -8,6 +8,13 @@ redirectifnotloggedin();
<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>
</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"); ?> &nbsp; <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">
<thead>
<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="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="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>
</tr>
</thead>
@ -36,6 +44,7 @@ redirectifnotloggedin();
'code1',
'code2',
'qty',
'want',
'userid'
], ["LIMIT" => 100]);
$usercache = [];
@ -60,6 +69,7 @@ redirectifnotloggedin();
<td><?php echo $item['code1']; ?></td>
<td><?php echo $item['code2']; ?></td>
<td><?php echo $item['qty']; ?></td>
<td><?php echo $item['want']; ?></td>
<td><?php echo $user; ?></td>
</tr>
<?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="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="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>
</tr>
</tfoot>

@ -34,6 +34,11 @@ var itemtable = $('#itemtable').DataTable({
serverSide: true,
ajax: {
url: "lib/getitemtable.php",
data: function (d) {
if (filter == "stock") {
d.show_want = 1;
}
},
dataFilter: function (data) {
var json = jQuery.parseJSON(data);
json.data = [];
@ -47,6 +52,7 @@ var itemtable = $('#itemtable').DataTable({
row.code1,
row.code2,
row.qty,
row.want,
row.username
]);
});

Loading…
Cancel
Save