Fix: debug replanishment feature

This commit is contained in:
Laurent Destailleur 2013-10-09 21:09:15 +02:00
parent 661faa63dd
commit a11a0d6491
4 changed files with 44 additions and 39 deletions

View File

@ -42,7 +42,7 @@ $debit=GETPOST("debit");
$credit=GETPOST("credit"); $credit=GETPOST("credit");
$type=GETPOST("type"); $type=GETPOST("type");
$account=GETPOST("account"); $account=GETPOST("account");
$bid=GETPOST("bid"); $bid=GETPOST("bid","int");
$param=''; $param='';
if ($description) $param.='&description='.$description; if ($description) $param.='&description='.$description;
@ -83,7 +83,7 @@ $sql.= " b.fk_account, b.fk_type,";
$sql.= " ba.rowid as bankid, ba.ref as bankref,"; $sql.= " ba.rowid as bankid, ba.ref as bankref,";
$sql.= " bu.label as labelurl, bu.url_id"; $sql.= " bu.label as labelurl, bu.url_id";
$sql.= " FROM "; $sql.= " FROM ";
if (! empty($_REQUEST["bid"])) $sql.= MAIN_DB_PREFIX."bank_class as l,"; if ($bid) $sql.= MAIN_DB_PREFIX."bank_class as l,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,";
$sql.= " ".MAIN_DB_PREFIX."bank as b"; $sql.= " ".MAIN_DB_PREFIX."bank as b";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'";
@ -92,21 +92,21 @@ $sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND ba.entity = ".$conf->entity;
if (GETPOST("req_nb")) if (GETPOST("req_nb"))
{ {
$sql.= " AND b.num_chq like '%".$db->escape(GETPOST("req_nb"))."%'"; $sql.= " AND b.num_chq LIKE '%".$db->escape(GETPOST("req_nb"))."%'";
$param.='&req_nb='.urlencode(GETPOST("req_nb")); $param.='&req_nb='.urlencode(GETPOST("req_nb"));
} }
if (GETPOST("thirdparty")) if (GETPOST("thirdparty"))
{ {
$sql.=" AND (COALESCE(s.nom,'') LIKE '%".$db->escape(GETPOST("thirdparty"))."%')"; $sql.=" AND s.nom LIKE '%".$db->escape(GETPOST("thirdparty"))."%'";
$param.='&thirdparty='.urlencode(GETPOST("thirdparty")); $param.='&thirdparty='.urlencode(GETPOST("thirdparty"));
} }
if (! empty($_REQUEST["bid"])) if ($bid)
{ {
$sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$_REQUEST["bid"]; $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid;
} }
if(! empty($type)) if (! empty($type))
{ {
$sql .= " AND b.fk_type = '" . $type ."' "; $sql.= " AND b.fk_type = '".$db->escape($type)."' ";
} }
// Search criteria amount // Search criteria amount
$si=0; $si=0;

View File

@ -100,5 +100,6 @@ AlertOnly= Alerts only
WarehouseForStockDecrease=The warehouse <b>%s</b> will be used for stock decrease WarehouseForStockDecrease=The warehouse <b>%s</b> will be used for stock decrease
WarehouseForStockIncrease=The warehouse <b>%s</b> will be used for stock increase WarehouseForStockIncrease=The warehouse <b>%s</b> will be used for stock increase
ForThisWarehouse=For this warehouse ForThisWarehouse=For this warehouse
ReplenishmentStatusDesc=This is list of all product with a physical stock lower than desired stock and suggest you to create supplier orders to fill the difference. ReplenishmentStatusDesc=This is list of all product with a physical stock lower than desired stock (or alert value if checkbox "alert only" is checked) and suggest you to create supplier orders to fill the difference.
ReplenishmentOrdersDesc=This is list of all opened supplier orders ReplenishmentOrdersDesc=This is list of all opened supplier orders
Replenishments=Replenishments

View File

@ -100,5 +100,6 @@ AlertOnly = Alertes seulement
WarehouseForStockDecrease=L'entrepôt <b>%s</b> sera utilisé pour la décrémentation du stock WarehouseForStockDecrease=L'entrepôt <b>%s</b> sera utilisé pour la décrémentation du stock
WarehouseForStockIncrease=L'entrepôt <b>%s</b> sera utilisé pour l'incrémentation du stock WarehouseForStockIncrease=L'entrepôt <b>%s</b> sera utilisé pour l'incrémentation du stock
ForThisWarehouse=Pour cet entrepôt ForThisWarehouse=Pour cet entrepôt
ReplenishmentStatusDesc=Cet écran permet de voir les produits avec un stock physique inférieure à la quantité minimale désirée et propose de créer des commandes fournisseurs pour compléter la différence ReplenishmentStatusDesc=Cet écran permet de voir les produits avec un stock physique inférieure à la quantité minimale désirée (ou à la quantité du seuil d'alerte si la case "Alertes seulement" est cochée) et propose de créer des commandes fournisseurs pour compléter la différence
ReplenishmentOrdersDesc=Voici la liste des commandes fournisseurs en cours ReplenishmentOrdersDesc=Voici la liste des commandes fournisseurs en cours
Replenishments=Réapprovisionnement

View File

@ -1,6 +1,6 @@
<?php <?php
/* /* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Laurent Destaileur <ely@users.sourceforge.net>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -173,14 +173,14 @@ if ($action == 'order' && isset($_POST['valid']))
$title = $langs->trans('Status'); $title = $langs->trans('Status');
$sql = 'SELECT p.rowid, p.ref, p.label, p.price'; $sql = 'SELECT p.rowid, p.ref, p.label, p.price,';
$sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type'; $sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,';
$sql .= ', p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,'; $sql.= ' p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,';
$sql .= ' SUM(COALESCE(s.reel, 0)) as stock_physique'; $sql.= ' p.desiredstock,';
$sql .= ', p.desiredstock'; $sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").') as stock_physique';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; $sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s';
$sql .= ' ON p.rowid = s.fk_product'; $sql.= ' ON p.rowid = s.fk_product';
$sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')'; $sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')';
if ($sall) { if ($sall) {
$sql .= ' AND (p.ref LIKE "%'.$db->escape($sall).'%" '; $sql .= ' AND (p.ref LIKE "%'.$db->escape($sall).'%" ';
@ -193,7 +193,7 @@ if (dol_strlen($type)) {
if ($type == 1) { if ($type == 1) {
$sql .= ' AND p.fk_product_type = 1'; $sql .= ' AND p.fk_product_type = 1';
} else { } else {
$sql .= ' AND p.fk_product_type != 1'; $sql .= ' AND p.fk_product_type <> 1';
} }
} }
if ($sref) { if ($sref) {
@ -210,21 +210,23 @@ if ($snom) {
$sql .= ' AND p.label LIKE "%' . $db->escape($crit) . '%"'; $sql .= ' AND p.label LIKE "%' . $db->escape($crit) . '%"';
} }
} }
$sql .= ' AND p.tobuy = 1'; $sql.= ' AND p.tobuy = 1';
if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"';
$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.price'; $sql.= ' GROUP BY p.rowid, p.ref, p.label, p.price';
$sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; $sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms';
$sql .= ', p.duration, p.tobuy, p.seuil_stock_alerte'; $sql.= ', p.duration, p.tobuy, p.seuil_stock_alerte';
$sql .= ', p.desiredstock, s.fk_product'; $sql.= ', p.desiredstock, s.fk_product';
$sql .= ' HAVING p.desiredstock > SUM(COALESCE(s.reel, 0))'; $sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").')';
$sql .= ' AND p.desiredstock > 0'; $sql.= ' AND p.desiredstock > 0';
if ($salert == 'on') if ($salert == 'on') // Option to see when stock is lower than alert
{ {
$sql .= ' AND SUM(COALESCE(s.reel, 0)) < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL'; $sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL';
$alertchecked = 'checked="checked"'; $alertchecked = 'checked="checked"';
} }
$sql .= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
$sql .= $db->plimit($limit + 1, $offset); $sql.= $db->plimit($limit + 1, $offset);
dol_syslog('Execute request sql='.$sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if (empty($resql)) if (empty($resql))
{ {
@ -397,10 +399,10 @@ print '</tr>';
print '<tr class="liste_titre">'. print '<tr class="liste_titre">'.
'<td class="liste_titre">&nbsp;</td>'. '<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre">'. '<td class="liste_titre">'.
'<input class="flat" type="text" name="sref" value="' . $sref . '">'. '<input class="flat" type="text" name="sref" size="8" value="'.dol_escape_htmltag($sref).'">'.
'</td>'. '</td>'.
'<td class="liste_titre">'. '<td class="liste_titre">'.
'<input class="flat" type="text" name="snom" value="' . $snom . '">'. '<input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).'">'.
'</td>'; '</td>';
if (!empty($conf->service->enabled) && $type == 1) if (!empty($conf->service->enabled) && $type == 1)
{ {
@ -491,11 +493,12 @@ while ($i < min($num, $limit))
} else { } else {
$picto = img_picto('', './img/no', '', 1); $picto = img_picto('', './img/no', '', 1);
} }
print '<tr ' . $bc[$var] . '>';
print '<tr '.$bc[$var].'>';
// Select field // Select field
//print '<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>'; //print '<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>';
print '<td><input type="checkbox" class="check" name="' . $i . '"></td>'; print '<td><input type="checkbox" class="check" name="'.$i.'"></td>';
print '<td class="nowrap">'. print '<td class="nowrap">'.
$prod->getNomUrl(1, '', 16). $prod->getNomUrl(1, '', 16).
@ -529,7 +532,7 @@ while ($i < min($num, $limit))
// To order // To order
//print '<td align="right"><input type="text" name="tobuy'.$i.'" value="'.$stocktobuy.'" '.$disabled.'></td>'; //print '<td align="right"><input type="text" name="tobuy'.$i.'" value="'.$stocktobuy.'" '.$disabled.'></td>';
print '<td align="right"><input type="text" name="tobuy'.$i.'" value="'.$stocktobuy.'"></td>'; print '<td align="right"><input type="text" size="4" name="tobuy'.$i.'" value="'.$stocktobuy.'"></td>';
// Supplier // Supplier
print '<td align="right">'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, 1).'</td>'; print '<td align="right">'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, 1).'</td>';