Commit 0fab2093 authored by Cédric Houbart's avatar Cédric Houbart
Browse files

Fixed overstock message and stock levels typing

parent adbe87f5
......@@ -54,7 +54,7 @@ class StockLevel {
public $security;
public $max;
public function __build($id, $product_id, $location, $security, $max) {
public static function __build($id, $product_id, $location, $security, $max) {
$stock = new StockLevel($product_id, $location, $security, $max);
$stock->id = $id;
return $stock;
......@@ -63,7 +63,7 @@ class StockLevel {
public function __construct($product_id, $location, $security, $max) {
$this->product_id = $product_id;
$this->location = $location;
$this->security = $security;
$this->max = $max;
$this->security = intval($security);
$this->max = intval($max);
}
}
......@@ -39,7 +39,7 @@ class StocksService {
$stmt = $pdo->prepare($sql);
$stmt->execute();
while ($row = $stmt->fetch()) {
$qties[$row[0]] = $row[1];
$qties[$row[0]] = floatval($row[1]);
}
return $qties;
} else {
......@@ -56,14 +56,17 @@ class StocksService {
$stmt->bindParam(":id", $productId);
$stmt->execute();
$res = $stmt->fetchAll();
return $res[0];
return floatval($res[0]);
} else {
$stmt = $pdo->prepare("SELECT UNITS FROM STOCKCURRENT WHERE "
. "PRODUCT = :id AND LOCATION = :loc");
$stmt->bindParam(":id", $productId);
$stmt->bindParam(":loc", $warehouseId);
$stmt->execute();
return $stmt->fetchAll();
$ret = $stmt->fetchAll();
foreach ($ret as $key => $val) {
$ret[$key] = floatval($ret[$key]);
}
}
}
......
......@@ -34,6 +34,7 @@ $levels = \Pasteque\StocksService::getLevels();
<th><?php \pi18n("Product.label"); ?></th>
<th><?php \pi18n("Quantity"); ?></th>
<th><?php \pi18n("Security threshold", PLUGIN_NAME); ?></th>
<th><?php \pi18n("Maximum", PLUGIN_NAME); ?></th>
</tr>
</thead>
<tbody>
......@@ -50,9 +51,12 @@ if ($security !== NULL && $qty < $security) {
$class=" warn-level";
$help = ' title="' . \i18n("Stock is below security level!", PLUGIN_NAME) . '"';
}
if ($qty < 0 || ($max !== NULL && $qty > $max)) {
if ($qty < 0) {
$class=" alert-level";
$help = ' title="' . \i18n("Stock is negative!", PLUGIN_NAME) . '"';
} else if ($max !== NULL && $qty > $max) {
$class=" alert-level";
$help = ' title="' . \i18n("Overstock!", PLUGIN_NAME) . '"';
}
?>
<tr class="row-<?php echo $par ? 'par' : 'odd'; ?>">
......@@ -61,6 +65,7 @@ if ($qty < 0 || ($max !== NULL && $qty > $max)) {
<td><?php echo $product->label; ?></td>
<td class="numeric<?php echo $class; ?>"<?php echo $help; ?>><?php echo $qty; ?></td>
<td class="numeric"><?php echo $security === NULL ? \i18n("Undefined") : $security; ?></td>
<td class="numeric"><?php echo $max === NULL ? \i18n("Undefined") : $max; ?></td>
</tr>
<?php
}
......
......@@ -9,6 +9,7 @@
"Output (return to supplyer)": "Output (return to supplyer)",
"Stock is below security level!": "Stock is below security level!",
"Stock is negative!": "Stock is negative",
"Overstock!": "Overstock",
"Inventory": "Inventory",
"Security threshold": "Security threshold",
......
......@@ -9,6 +9,7 @@
"Output (return to supplyer": "Sortie (retour au fournisseur)",
"Stock is below security level!": "Le stock est sous le seuil de sécurité !",
"Stock is negative!": "Le stock est négatif !",
"Overstock!": "Trop de stock !",
"Inventory": "Inventaire",
"Security threshold": "Seuil de sécurité",
......
......@@ -30,10 +30,10 @@ function tpl_open() {
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php \pi18n("Pastèque"); ?></title>
<link rel="stylesheet" type="text/css" href="templates/pasteque/style.css" />
<link rel="stylesheet" type="text/css" href="templates/pasteque/catalog.css" />
<link rel="stylesheet" type="text/css" href="templates/pasteque/stock.css" />
<script type="text/javascript" src="templates/pasteque/js/jquery-1.9.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="templates/pos-tech/style.css" />
<link rel="stylesheet" type="text/css" href="templates/pos-tech/catalog.css" />
<link rel="stylesheet" type="text/css" href="templates/pos-tech/stock.css" />
<script type="text/javascript" src="templates/pos-tech/js/jquery-1.9.1.min.js"></script>
</head>
<body>
<?php tpl_menu(); ?>
......@@ -114,4 +114,4 @@ function tpl_report($report) {
echo "</table>\n";
}
?>
\ No newline at end of file
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment