inventory.php 2.63 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
//    Pastèque Web back office, Stocks module
//
//    Copyright (C) 2013 Scil (http://scil.coop)
//
//    This file is part of Pastèque.
//
//    Pastèque is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Pastèque is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Pastèque.  If not, see <http://www.gnu.org/licenses/>.

namespace BaseStocks;

$products = \Pasteque\ProductsService::getAll();
24
25
$stocks = \Pasteque\StocksService::getQties();
$levels = \Pasteque\StocksService::getLevels();
26
27
?>
<h1><?php \pi18n("Inventory", PLUGIN_NAME); ?></h1>
28

29
30
31
32
33
34
35
<table cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th></th>
			<th><?php \pi18n("Product.reference"); ?></th>
			<th><?php \pi18n("Product.label"); ?></th>
			<th><?php \pi18n("Quantity"); ?></th>
36
			<th><?php \pi18n("Security threshold", PLUGIN_NAME); ?></th>
37
			<th><?php \pi18n("Maximum", PLUGIN_NAME); ?></th>
38
39
40
41
42
43
44
		</tr>
	</thead>
	<tbody>
<?php
$par = FALSE;
foreach ($products as $product) {
$par = !$par;
45
46
47
48
$qty = isset($stocks[$product->id]) ? $stocks[$product->id] : 0;
$security = isset($levels[$product->id]) ? $levels[$product->id]->security : NULL;
$max = isset($levels[$product->id]) ? $levels[$product->id]->max : NULL;
$class = "";
49
$help = "";
50
51
if ($security !== NULL && $qty < $security) {
    $class=" warn-level";
52
    $help = ' title="' . \i18n("Stock is below security level!", PLUGIN_NAME) . '"';
53
}
54
if ($qty < 0) {
55
    $class=" alert-level";
56
    $help = ' title="' . \i18n("Stock is negative!", PLUGIN_NAME) . '"';
57
58
59
} else if ($max !== NULL && $qty > $max) {
    $class=" alert-level";
    $help = ' title="' . \i18n("Overstock!", PLUGIN_NAME) . '"';
60
}
61
62
63
64
65
?>
	<tr class="row-<?php echo $par ? 'par' : 'odd'; ?>">
	    <td><img class="thumbnail" src="?<?php echo \Pasteque\URL_ACTION_PARAM; ?>=img&w=product&id=<?php echo $product->id; ?>" />
		<td><?php echo $product->reference; ?></td>
		<td><?php echo $product->label; ?></td>
66
		<td class="numeric<?php echo $class; ?>"<?php echo $help; ?>><?php echo $qty; ?></td>
67
		<td class="numeric"><?php echo $security === NULL ? \i18n("Undefined") : $security; ?></td>
68
		<td class="numeric"><?php echo $max === NULL ? \i18n("Undefined") : $max; ?></td>
69
70
71
72
73
74
	</tr>
<?php
}
?>
	</tbody>
</table>