Add stock movements report
This commit is contained in:
parent
841c03847e
commit
488988f7d4
@ -10,6 +10,7 @@
|
||||
"itemid": "Item ID",
|
||||
"id": "ID",
|
||||
"Edit Item": "Edit Item",
|
||||
"stockid": "Stock ID",
|
||||
"adding stock": "Adding stock for {item}",
|
||||
"removing stock": "Removing stock from {item}"
|
||||
}
|
||||
|
@ -5,5 +5,6 @@
|
||||
"choose an option": "Choose an option",
|
||||
"csv file": "CSV text file",
|
||||
"ods file": "ODS spreadsheet",
|
||||
"html file": "HTML web page"
|
||||
"html file": "HTML web page",
|
||||
"Stock": "Stock movements"
|
||||
}
|
||||
|
@ -151,6 +151,49 @@ function getLocationReport(): Report {
|
||||
return $report;
|
||||
}
|
||||
|
||||
function getStockReport($filter = []): Report {
|
||||
global $database, $Strings;
|
||||
$stock = $database->select(
|
||||
"stock", [
|
||||
"[>]items" => ["itemid"]
|
||||
], [
|
||||
"stockid",
|
||||
"itemid",
|
||||
"name",
|
||||
'timestamp',
|
||||
'stock',
|
||||
'stock.text1',
|
||||
'stock.userid'
|
||||
]);
|
||||
$report = new Report($Strings->get("Stock", false));
|
||||
$report->setHeader([
|
||||
$Strings->get("stockid", false),
|
||||
$Strings->get("itemid", false),
|
||||
$Strings->get("name", false),
|
||||
$Strings->get("date", false),
|
||||
$Strings->get("amount", false),
|
||||
$Strings->get("description", false),
|
||||
$Strings->get("changed by", false)
|
||||
]);
|
||||
for ($i = 0; $i < count($stock); $i++) {
|
||||
$user = "";
|
||||
if (!is_null($stock[$i]["userid"])) {
|
||||
$u = new User($stock[$i]["userid"]);
|
||||
$user = $u->getName() . " (" . $u->getUsername() . ')';
|
||||
}
|
||||
$report->addDataRow([
|
||||
$stock[$i]["stockid"],
|
||||
$stock[$i]["itemid"],
|
||||
$stock[$i]["name"],
|
||||
$stock[$i]["timestamp"],
|
||||
$stock[$i]["stock"],
|
||||
$stock[$i]["text1"],
|
||||
$user
|
||||
]);
|
||||
}
|
||||
return $report;
|
||||
}
|
||||
|
||||
function getReport($type): Report {
|
||||
switch ($type) {
|
||||
case "item":
|
||||
@ -165,6 +208,9 @@ function getReport($type): Report {
|
||||
case "itemstock":
|
||||
return getItemReport(["AND" => ["qty[<]want", "want[>]" => 0]]);
|
||||
break;
|
||||
case "stock":
|
||||
return getStockReport();
|
||||
break;
|
||||
default:
|
||||
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ if (!empty($VARS['id'])) {
|
||||
<div class="form-group">
|
||||
<label for="qty"><i class="fas fa-hashtag"></i> <?php $Strings->get('quantity'); ?></label>
|
||||
<?php
|
||||
if ($SETTINGS['stock_management'] && $editing && !$cloning){
|
||||
if ($SETTINGS['stock_management'] && $editing && !$cloning) {
|
||||
?>
|
||||
<input type="text" class="form-control" id="qty" name="qty" readonly value="<?php echo $itemdata['qty']; ?>" />
|
||||
<?php
|
||||
|
@ -16,6 +16,13 @@ redirectifnotloggedin();
|
||||
<div class="form-group">
|
||||
<label for="type"><?php $Strings->get("report type"); ?></label>
|
||||
<select name="type" class="form-control" required>
|
||||
<?php
|
||||
if ($SETTINGS['stock_management']) {
|
||||
?>
|
||||
<option value="stock"><?php $Strings->get("Stock") ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<option value="item"><?php $Strings->get("Items") ?></option>
|
||||
<option value="category"><?php $Strings->get("Categories") ?></option>
|
||||
<option value="location"><?php $Strings->get("Locations") ?></option>
|
||||
|
Loading…
x
Reference in New Issue
Block a user