Commit 21be465c authored by philippe's avatar philippe
Browse files

Fixing issue 136 : Stock management ameliorations

new report (stocks alerts), improvement on stock inventory
http://redmine.scil.coop/issues/136
parent 162b8441
......@@ -729,4 +729,4 @@ function get_report($module, $name) {
} else {
return NULL;
}
}
\ No newline at end of file
}
......@@ -31,7 +31,7 @@ function redirectAction($path) {
function redirect_report($module, $name) {
if (!file_exists(PT::$ABSPATH . "/modules/" . $module . "/reports/" . $name . ".php")) {
$ret = array("error" => "No such seport");
$ret = array("error" => "No such report");
echo json_encode($ret);
return;
}
......
......@@ -31,6 +31,8 @@
"Image": "Image",
"Quantity": "Quantity",
"QuantityMin": "Minimal quantity",
"QuantityMax": "Maximal quantity",
"Undefined": "Undefined",
"Date": "Date",
"Total": "Total",
......@@ -151,6 +153,10 @@
"Location": "Warehouse",
"Location.label": "Name",
"Stock.SellValue": "Stock sell value",
"Stock.BuyValue": "Stock buy value",
"Stock.AlertReport": "Alert report",
"cash": "Cash",
"magcard": "Magcard",
"cheque": "Cheque",
......
......@@ -31,6 +31,8 @@
"Image": "Image",
"Quantity": "Quantité",
"QuantityMin": "Quantité minimale",
"QuantityMax": "Quantité maximale",
"Undefined": "Non défini",
"Date": "Date",
"Total": "Total",
......@@ -149,7 +151,11 @@
"Resource.label": "Désignation",
"Location": "Entrepôt",
"Location.label": "Désignation",
"Location.label": "Entrepôt",
"Stock.SellValue": "Valeur du stock à la revente",
"Stock.BuyValue": "Valeur du stock à l’achat",
"Stock.AlertReport": "Stocks en alerte",
"cash": "Espèces",
"magcard": "Carte bleue",
......
......@@ -82,7 +82,8 @@ $sqls[] = "SELECT CASHREGISTERS.NAME, CLOSEDCASH.DATESTART, "
$fields = array("NAME", "DATESTART", "DATEEND", "TICKETS", "AVERAGE",
"REALCS", "THEOCS", "THEOSCS");
$mergeFields = array("NAME", "DATESTART", "DATEEND");
$mergeFields = array("NAME","DATESTART","DATEEND");
$headers = array(
\i18n("CashRegister.label"), \i18n("Session.openDate"),
\i18n("Session.closeDate"), \i18n("Tickets", PLUGIN_NAME),
......
......@@ -35,7 +35,6 @@ $sql = "SELECT "
. "ORDER BY CLOSEDCASH.DATESTART ASC, TAXES.NAME ASC";
$fields = array("CASHREGISTER", "DATESTART", "DATEEND", "NAME", "BASE", "AMOUNT");
$mergeFields = array("NAME", "DATESTART", "DATEEND");
$headers = array(
\i18n("CashRegister.label"),
......
......@@ -83,6 +83,10 @@ foreach ($categories as $category) {
<th><?php \pi18n("Product.reference"); ?></th>
<th><?php \pi18n("Product.label"); ?></th>
<th><?php \pi18n("Quantity"); ?></th>
<th><?php \pi18n("Stock.SellValue"); ?></th>
<th><?php \pi18n("Stock.BuyValue"); ?></th>
<th><?php \pi18n("QuantityMin"); ?></th>
<th><?php \pi18n("QuantityMax"); ?></th>
</tr>
</thead>
<tbody>
......@@ -96,6 +100,8 @@ foreach ($categories as $category) {
$prdRef = "";
$prdLabel = "";
$imgSrc = "";
$prdSellPrice = 0;
$prdBuyPrice = 0;
$level = $prdLevel[$product->id];
if ($product->hasImage) {
$imgSrc = \Pasteque\PT::URL_ACTION_PARAM . "=img&w=product&id=" . $product->id;
......@@ -104,6 +110,8 @@ foreach ($categories as $category) {
}
$prdLabel = $product->label;
$prdRef = $product->reference;
$prdSellPrice = $product->priceSell;
$prdBuyPrice = $product->priceBuy;
$security = $level->security;
$max = $level->max;
$qty = $level->qty !== null ? $level->qty : 0;
......@@ -120,12 +128,22 @@ foreach ($categories as $category) {
$class=" alert-level";
$help = ' title="' . \Pasteque\esc_attr(\i18n("Overstock!", PLUGIN_NAME)) . '"';
}
if (!isset($security)) {
$security = \i18n("Undefined");
}
if (!isset($max)) {
$max = \i18n("Undefined");
}
?>
<tr class="row-<?php echo $par ? 'par' : 'odd'; ?>">
<td><img class="thumbnail" src="?<?php echo \Pasteque\esc_attr($imgSrc); ?>" />
<td><img class="thumbnail" src="?<?php echo \Pasteque\esc_attr($imgSrc); ?>" />
<td><?php echo \Pasteque\esc_html($prdRef); ?></td>
<td><?php echo \Pasteque\esc_html($prdLabel); ?></td>
<td class="numeric<?php echo $class; ?>"<?php echo $help; ?>><?php echo \Pasteque\esc_html($qty); ?></td>
<td><?php echo \Pasteque\esc_html(\i18nCurr($prdSellPrice*$qty)); ?></td>
<td><?php echo \Pasteque\esc_html(\i18nCurr($prdBuyPrice*$qty)); ?></td>
<td><?php echo \Pasteque\esc_html($security); ?></td>
<td><?php echo \Pasteque\esc_html($max); ?></td>
</tr>
<?php
} ?>
......
......@@ -25,6 +25,7 @@ function init() {
$MENU->addSection("stock", "Stocks", PLUGIN_NAME);
$MENU->registerModuleEntry("stock", PLUGIN_NAME, "menu_stock_move.png", "Moves", "moves");
$MENU->registerModuleEntry("stock", PLUGIN_NAME, "menu_stock_inventory.png", "Inventory", "inventory");
$MENU->registerModuleReport("stock", PLUGIN_NAME, "menu_stock_inventory.png", "AlertReport", "alert");
$MENU->registerModuleEntry("stock", PLUGIN_NAME, "menu_stock_check.png", "Check", "check");
\Pasteque\register_i18n(PLUGIN_NAME);
}
......
......@@ -14,6 +14,7 @@
"Overstock!": "Overstock",
"Inventory": "Inventory",
"AlertReport": "Alert report",
"Security threshold": "Security threshold",
"Maximum": "Maximum",
......
......@@ -14,6 +14,7 @@
"Overstock!": "Trop de stock !",
"Inventory": "Inventaire",
"AlertReport": "Stocks en alerte",
"Security threshold": "Seuil de sécurité",
"Maximum": "Maximum",
......
<?php
// Pastèque Web back office
//
// Copyright (C) 2015 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;
$sql = "SELECT "
. "LOCATIONS.NAME AS NAME, PRODUCTS.NAME AS PRODUCTNAME, STOCKCURRENT.UNITS, STOCKLEVEL.STOCKSECURITY, STOCKLEVEL.STOCKMAXIMUM "
. "FROM STOCKCURRENT "
. "LEFT JOIN PRODUCTS ON STOCKCURRENT.PRODUCT = PRODUCTS.ID "
. "LEFT JOIN STOCKLEVEL ON STOCKCURRENT.PRODUCT = STOCKLEVEL.PRODUCT "
. "LEFT JOIN LOCATIONS ON LOCATIONS.ID = STOCKCURRENT.LOCATION "
. "WHERE (STOCKCURRENT.UNITS < STOCKLEVEL.STOCKSECURITY "
. "AND STOCKCURRENT.UNITS > STOCKLEVEL.STOCKMAXIMUM) "
. "OR STOCKCURRENT.UNITS < 0 "
. "ORDER BY STOCKLEVEL.LOCATION";
$fields = array("NAME","PRODUCTNAME","UNITS","STOCKSECURITY","STOCKMAXIMUM");
$headers = array(
\i18n("Location.label"),
\i18n("Product.label"),
\i18n("Quantity"),
\i18n("QuantityMin"),
\i18n("QuantityMax")
);
$report = new \Pasteque\Report(PLUGIN_NAME, "alert",
\i18n("Stock.AlertReport"),
$sql, $headers, $fields);
\Pasteque\register_report($report);
......@@ -134,30 +134,32 @@ function __tpl_report_input($report, $values) {
echo "&" . $param['param'] . "=" . $values[$param['param']];
}
echo "\">" . \i18n("Export") . "</a></div>\n";
// Input form
echo "<form class=\"edit\" action=\"" . \Pasteque\get_current_url() . "\" "
. "method=\"post\">";
foreach($report->getParams() as $param) {
$id = $param['param'];
echo "<div class=\"row\">";
echo "<label for=\"" . $id . "\">" . $param['label'] . "</label>";
switch ($param['type']) {
case DB::DATE:
$value = \i18nDate($values[$id]);
echo "<input type=\"text\" name=\"" . $id . "\" id=\"" . $id
. "\" class=\"dateinput\" value=\"" . $value . "\" />";
break;
default:
$value = $values[$param['param']];
echo "<input type=\"text\" name=\"" . $id . "\" id=\"" . $id
. "\" value=\"" . $value . "\" />";
break;
if(is_array($report->getParams()) && sizeof($report->getParams()) > 0) {
// Input form
echo "<form class=\"edit\" action=\"" . \Pasteque\get_current_url() . "\" "
. "method=\"post\">";
foreach($report->getParams() as $param) {
$id = $param['param'];
echo "<div class=\"row\">";
echo "<label for=\"" . $id . "\">" . $param['label'] . "</label>";
switch ($param['type']) {
case DB::DATE:
$value = \i18nDate($values[$id]);
echo "<input type=\"text\" name=\"" . $id . "\" id=\"" . $id
. "\" class=\"dateinput\" value=\"" . $value . "\" />";
break;
default:
$value = $values[$param['param']];
echo "<input type=\"text\" name=\"" . $id . "\" id=\"" . $id
. "\" value=\"" . $value . "\" />";
break;
}
echo "</div>\n";
}
echo "</div>\n";
// Send
echo "<div class=\"row actions\">" . \Pasteque\form_send() . "</div>\n";
echo "</form>\n";
}
// Send
echo "<div class=\"row actions\">" . \Pasteque\form_send() . "</div>\n";
echo "</form>\n";
}
function __tpl_report_header($report) {
......
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