Qual: Debug of replenishment feature

This commit is contained in:
Laurent Destailleur 2013-10-09 20:30:49 +02:00
parent 43fd4d0784
commit f4a83f0851
7 changed files with 454 additions and 417 deletions

View File

@ -102,6 +102,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3102__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/liste.php', 'List', 1, 'stocks', '$user->rights->stock->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3102__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/liste.php', 'List', 1, 'stocks', '$user->rights->stock->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3103__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/valo.php', 'EnhancedValue', 1, 'stocks', '$user->rights->stock->lire', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3103__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/valo.php', 'EnhancedValue', 1, 'stocks', '$user->rights->stock->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/mouvement.php', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/mouvement.php', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 3105__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/replenish.php', 'Replenishments', 1, 'stocks', '$user->rights->stock->mouvement->lire && $user->rights->fournisseur->lire', '', 2, 4, __ENTITY__);
-- Product - Categories -- Product - Categories
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3200__+MAX_llx_menu__, 'products', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3200__+MAX_llx_menu__, 'products', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3201__+MAX_llx_menu__, 'products', '', 3200__+MAX_llx_menu__, '/categories/fiche.php?action=create&type=0', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3201__+MAX_llx_menu__, 'products', '', 3200__+MAX_llx_menu__, '/categories/fiche.php?action=create&type=0', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__);

View File

@ -1007,7 +1007,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/liste.php", $langs->trans("List"), 1, $user->rights->stock->lire); if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/liste.php", $langs->trans("List"), 1, $user->rights->stock->lire);
if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/valo.php", $langs->trans("EnhancedValue"), 1, $user->rights->stock->lire); if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/valo.php", $langs->trans("EnhancedValue"), 1, $user->rights->stock->lire);
if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire); if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->lire); if ($conf->fournisseur->enabled) if (empty($leftmenu) || $leftmenu=="stock") $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->lire && $user->rights->fournisseur->lire);
} }
// Expeditions // Expeditions

View File

@ -143,11 +143,11 @@ NoStockForThisProduct=No stock for this product
NoStock=No Stock NoStock=No Stock
Restock=Restock Restock=Restock
ProductSpecial=Special ProductSpecial=Special
QtyMin=Min. Order Qty. QtyMin=Minimum Qty
PriceQty=Price for this quantity PriceQty=Price for this quantity
PriceQtyMin=MOQ Price (w/o discount) PriceQtyMin=Price for this min. qty (w/o discount)
VATRateForSupplierProduct=VAT Rate (for this supplier/product) VATRateForSupplierProduct=VAT Rate (for this supplier/product)
DiscountQtyMin=MOQ Discount (by default) DiscountQtyMin=Default discount for qty
NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product
NoSupplierPriceDefinedForThisProduct=No supplier price/qty defined for this product NoSupplierPriceDefinedForThisProduct=No supplier price/qty defined for this product
RecordedProducts=Products recorded RecordedProducts=Products recorded

View File

@ -95,8 +95,10 @@ Replenishment=Replenishment
ReplenishmentOrders=Replenishment orders ReplenishmentOrders=Replenishment orders
UseVirtualStock=Use virtual stock instead of physical stock UseVirtualStock=Use virtual stock instead of physical stock
RuleForStockReplenishment=Rule for stocks replenishment RuleForStockReplenishment=Rule for stocks replenishment
SelectProduct=Select at least one product SelectProductWithNotNullQty=Select at least one product with a qty not null and a supplier
AlertOnly= Alerts only 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.
ReplenishmentOrdersDesc=This is list of all opened supplier orders

View File

@ -95,8 +95,10 @@ Replenishment=Réapprovisionnement
ReplenishmentOrders=Commandes de réapprovisionnement ReplenishmentOrders=Commandes de réapprovisionnement
UseVirtualStock=Utiliser le stock théorique à la place du stock physique UseVirtualStock=Utiliser le stock théorique à la place du stock physique
RuleForStockReplenishment=Règle de gestion du réapprovisionnement des stocks RuleForStockReplenishment=Règle de gestion du réapprovisionnement des stocks
SelectProduct=Sélectionnez au moins un produit SelectProductWithNotNullQty=Sélectionnez au moins un produit avec une quantité non nulle et un fournisseur
AlertOnly = Alertes seulement 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
ReplenishmentOrdersDesc=Voici la liste des commandes fournisseurs en cours

View File

@ -67,7 +67,8 @@ $offset = $limit * $page ;
* Actions * Actions
*/ */
if (isset($_POST['button_removefilter']) || isset($_POST['valid'])) { if (isset($_POST['button_removefilter']) || isset($_POST['valid']))
{
$sref = ''; $sref = '';
$snom = ''; $snom = '';
$sal = ''; $sal = '';
@ -75,16 +76,19 @@ if (isset($_POST['button_removefilter']) || isset($_POST['valid'])) {
} }
//orders creation //orders creation
//FIXME: could go in the lib //TODO: could go in the lib
if ($action == 'order' && isset($_POST['valid'])) { if ($action == 'order' && isset($_POST['valid']))
{
$linecount = GETPOST('linecount', 'int'); $linecount = GETPOST('linecount', 'int');
$box = 0; $box = 0;
unset($_POST['linecount']); unset($_POST['linecount']);
if ($linecount > 0) { if ($linecount > 0) {
$suppliers = array(); $suppliers = array();
for ($i = 0; $i < $linecount; $i++) { for ($i = 0; $i < $linecount; $i++)
if(GETPOST($i, 'alpha') === 'on' {
&& GETPOST('fourn' . $i, 'int') > 0) { //one line if (GETPOST($i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0)
{
//one line
$box = $i; $box = $i;
$supplierpriceid = GETPOST('fourn'.$i, 'int'); $supplierpriceid = GETPOST('fourn'.$i, 'int');
//get all the parameters needed to create a line //get all the parameters needed to create a line
@ -95,7 +99,10 @@ if ($action == 'order' && isset($_POST['valid'])) {
$sql .= MAIN_DB_PREFIX . 'product_fournisseur_price'; $sql .= MAIN_DB_PREFIX . 'product_fournisseur_price';
$sql .= ' WHERE rowid = ' . $supplierpriceid; $sql .= ' WHERE rowid = ' . $supplierpriceid;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql && $db->num_rows($resql) > 0) { if ($resql && $db->num_rows($resql) > 0)
{
if ($qty)
{
//might need some value checks //might need some value checks
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$line = new CommandeFournisseurLigne($db); $line = new CommandeFournisseurLigne($db);
@ -110,7 +117,10 @@ if ($action == 'order' && isset($_POST['valid'])) {
$line->total_ttc = $line->total_ht + $line->total_tva; $line->total_ttc = $line->total_ht + $line->total_tva;
$line->ref_fourn = $obj->ref_fourn; $line->ref_fourn = $obj->ref_fourn;
$suppliers[$obj->fk_soc]['lines'][] = $line; $suppliers[$obj->fk_soc]['lines'][] = $line;
} else { }
}
else
{
$error=$db->lasterror(); $error=$db->lasterror();
dol_print_error($db); dol_print_error($db);
dol_syslog('replenish.php: '.$error, LOG_ERR); dol_syslog('replenish.php: '.$error, LOG_ERR);
@ -120,11 +130,13 @@ if ($action == 'order' && isset($_POST['valid'])) {
} }
unset($_POST[$i]); unset($_POST[$i]);
} }
//we now know how many orders we need and what lines they have //we now know how many orders we need and what lines they have
$i = 0; $i = 0;
$orders = array(); $orders = array();
$suppliersid = array_keys($suppliers); $suppliersid = array_keys($suppliers);
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier)
{
$order = new CommandeFournisseur($db); $order = new CommandeFournisseur($db);
$order->socid = $suppliersid[$i]; $order->socid = $suppliersid[$i];
//trick to know which orders have been generated this way //trick to know which orders have been generated this way
@ -150,13 +162,15 @@ if ($action == 'order' && isset($_POST['valid'])) {
} }
} }
if ($box == 0) { if ($box == 0) {
setEventMessage($langs->trans('SelectProduct'), 'warnings'); setEventMessage($langs->trans('SelectProductWithNotNullQty'), 'warnings');
} }
} }
/* /*
* View * View
*/ */
$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';
@ -196,33 +210,36 @@ 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(COALESCE(s.reel, 0))';
$sql .= ' AND p.desiredstock > 0'; $sql .= ' AND p.desiredstock > 0';
if ($salert == 'on') { if ($salert == 'on')
{
$sql .= ' AND SUM(COALESCE(s.reel, 0)) < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL'; $sql .= ' AND SUM(COALESCE(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);
$resql = $db->query($sql); $resql = $db->query($sql);
if (empty($resql))
{
dol_print_error($db);
exit;
}
if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|'; $helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|';
$helpurl .= 'ES:M&oacute;dulo_Stocks'; $helpurl .= 'ES:M&oacute;dulo_Stocks';
llxHeader('', $title, $helpurl, $title); llxHeader('', $title, $helpurl, $title);
$head = array(); $head = array();
$head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; $head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php';
$head[0][1] = $title; $head[0][1] = $title;
@ -230,7 +247,11 @@ if ($resql) {
$head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; $head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php';
$head[1][1] = $langs->trans("ReplenishmentOrders"); $head[1][1] = $langs->trans("ReplenishmentOrders");
$head[1][2] = 'replenishorders'; $head[1][2] = 'replenishorders';
dol_fiche_head($head, 'replenish', $langs->trans('Replenishment'), 0, 'stock'); dol_fiche_head($head, 'replenish', $langs->trans('Replenishment'), 0, 'stock');
print $langs->trans("ReplenishmentStatusDesc").'<br><br>';
if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) { if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
$filters = '&sref=' . $sref . '&snom=' . $snom; $filters = '&sref=' . $sref . '&snom=' . $snom;
$filters .= '&sall=' . $sall; $filters .= '&sall=' . $sall;
@ -370,11 +391,10 @@ if ($resql) {
$sortfield, $sortfield,
$sortorder $sortorder
); );
print '<td>&nbsp;</td>'. print '</tr>';
'</tr>'.
// Lignes des champs de filtre // Lignes des champs de filtre
'<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" value="' . $sref . '">'.
@ -384,15 +404,12 @@ if ($resql) {
'</td>'; '</td>';
if (!empty($conf->service->enabled) && $type == 1) if (!empty($conf->service->enabled) && $type == 1)
{ {
print '<td class="liste_titre">'. print '<td class="liste_titre">&nbsp;</td>';
'&nbsp;'.
'</td>';
} }
print '<td class="liste_titre">&nbsp;</td>'. print '<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" name="salert" ' . $alertchecked . '></td>'. '<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" name="salert" ' . $alertchecked . '></td>'.
'<td class="liste_titre" align="right">&nbsp;</td>'. '<td class="liste_titre" align="right">&nbsp;</td>'.
'<td class="liste_titre">&nbsp;</td>'. '<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre" align="right">'. '<td class="liste_titre" align="right">'.
'<input type="image" class="liste_titre" name="button_search"'. '<input type="image" class="liste_titre" name="button_search"'.
'src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" alt="' . $langs->trans("Search") . '">'. 'src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" alt="' . $langs->trans("Search") . '">'.
@ -404,24 +421,26 @@ if ($resql) {
$prod = new Product($db); $prod = new Product($db);
$var = True; $var = True;
while ($i < min($num, $limit)) { while ($i < min($num, $limit))
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
if ($conf->global->STOCK_SUPPORTS_SERVICES
|| $objp->fk_product_type == 0) { if ($conf->global->STOCK_SUPPORTS_SERVICES || $objp->fk_product_type == 0)
{
// Multilangs // Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) { if (! empty($conf->global->MAIN_MULTILANGS))
{
$sql = 'SELECT label'; $sql = 'SELECT label';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang';
$sql .= ' WHERE fk_product = ' . $objp->rowid; $sql .= ' WHERE fk_product = ' . $objp->rowid;
$sql .= ' AND lang = "' . $langs->getDefaultLang() . '"'; $sql .= ' AND lang = "' . $langs->getDefaultLang() . '"';
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';
$result = $db->query($sql); $resqlm = $db->query($sql);
if ($result) { if ($resqlm)
$objtp = $db->fetch_object($result); {
if (!empty($objtp->label)) { $objtp = $db->fetch_object($resqlm);
$objp->label = $objtp->label; if (!empty($objtp->label)) $objp->label = $objtp->label;
}
} }
} }
$form = new Form($db); $form = new Form($db);
@ -431,7 +450,8 @@ if ($resql) {
$prod->type = $objp->fk_product_type; $prod->type = $objp->fk_product_type;
$ordered = ordered($prod->id); $ordered = ordered($prod->id);
if ($conf->global->USE_VIRTUAL_STOCK) { if ($conf->global->USE_VIRTUAL_STOCK)
{
//compute virtual stock //compute virtual stock
$prod->fetch($prod->id); $prod->fetch($prod->id);
$result=$prod->load_stats_commande(0, '1,2'); $result=$prod->load_stats_commande(0, '1,2');
@ -445,12 +465,15 @@ if ($resql) {
} }
$stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty']; $stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty'];
$stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur; $stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur;
} else { }
else
{
$stock = $objp->stock_physique; $stock = $objp->stock_physique;
} }
$warning=''; $warning='';
if ($objp->seuil_stock_alerte
&& ($stock < $objp->seuil_stock_alerte)) { if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte))
{
$warning = img_warning($langs->trans('StockTooLow')) . ' '; $warning = img_warning($langs->trans('StockTooLow')) . ' ';
} }
//depending on conf, use either physical stock or //depending on conf, use either physical stock or
@ -468,9 +491,13 @@ if ($resql) {
} else { } else {
$picto = img_picto('', './img/no', '', 1); $picto = img_picto('', './img/no', '', 1);
} }
print '<tr ' . $bc[$var] . '>'. print '<tr ' . $bc[$var] . '>';
'<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>'.
'<td class="nowrap">'. // Select field
//print '<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>';
print '<td><input type="checkbox" class="check" name="' . $i . '"></td>';
print '<td class="nowrap">'.
$prod->getNomUrl(1, '', 16). $prod->getNomUrl(1, '', 16).
'</td>'. '</td>'.
'<td>' . $objp->label . '</td>'. '<td>' . $objp->label . '</td>'.
@ -498,16 +525,16 @@ if ($resql) {
'<td align="right">'. '<td align="right">'.
'<a href="replenishorders.php?sproduct=' . $prod->id . '">'. '<a href="replenishorders.php?sproduct=' . $prod->id . '">'.
$ordered . '</a> ' . $picto. $ordered . '</a> ' . $picto.
'</td>'. '</td>';
'<td align="right">'.
'<input type="text" name="tobuy' . $i . // To order
'" value="' . $stocktobuy . '" ' . $disabled . '>'. //print '<td align="right"><input type="text" name="tobuy'.$i.'" value="'.$stocktobuy.'" '.$disabled.'></td>';
'</td>'. print '<td align="right"><input type="text" name="tobuy'.$i.'" value="'.$stocktobuy.'"></td>';
'<td align="right">'.
$form->select_product_fourn_price($prod->id, 'fourn'.$i, 1). // Supplier
'</td>'. print '<td align="right">'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, 1).'</td>';
'<td>&nbsp</td>'.
'</tr>'; print '</tr>';
} }
$i++; $i++;
} }
@ -515,8 +542,8 @@ if ($resql) {
print '</table>'. print '</table>'.
'</div>'. '</div>'.
'<table width="100%">'. '<table width="100%">'.
'<tr><td align="right">'. '<tr><td align="center">'.
'<input class="butAction" type="submit" name="valid" value="' . $value . '">'. '<input class="button" type="submit" name="valid" value="' . $value . '">'.
'</td></tr></table>'. '</td></tr></table>'.
'</form>'; '</form>';
@ -560,7 +587,9 @@ if ($resql) {
} }
$db->free($resql); $db->free($resql);
print ' <script type="text/javascript">
print '
<script type="text/javascript">
function toggle(source) function toggle(source)
{ {
checkboxes = document.getElementsByClassName("check"); checkboxes = document.getElementsByClassName("check");
@ -569,10 +598,9 @@ print ' <script type="text/javascript">
checkboxes[i].checked = source.checked; checkboxes[i].checked = source.checked;
} }
} }
} </script>';
} else {
dol_print_error($db);
} }
</script>';
llxFooter(); llxFooter();

View File

@ -48,7 +48,9 @@ $head[0][2] = 'replenish';
$head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; $head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php';
$head[1][1] = $texte; $head[1][1] = $texte;
$head[1][2] = 'replenishorders'; $head[1][2] = 'replenishorders';
dol_fiche_head($head, 'replenishorders', $langs->trans('Replenishment'), 0, 'stock'); dol_fiche_head($head, 'replenishorders', $langs->trans('Replenishment'), 0, 'stock');
$commandestatic = new CommandeFournisseur($db); $commandestatic = new CommandeFournisseur($db);
$sref = GETPOST('search_ref', 'alpha'); $sref = GETPOST('search_ref', 'alpha');
$snom = GETPOST('search_nom', 'alpha'); $snom = GETPOST('search_nom', 'alpha');
@ -72,21 +74,15 @@ if (!$sortfield) {
$offset = $conf->liste_limit * $page ; $offset = $conf->liste_limit * $page ;
$sql = 'SELECT s.rowid as socid, s.nom, cf.date_creation as dc,'; $sql = 'SELECT s.rowid as socid, s.nom, cf.date_creation as dc,';
$sql .= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc'; $sql.= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,';
$sql .= ", cf.fk_user_author, u.login"; $sql.= ' u.login';
$sql .= ' FROM (' . MAIN_DB_PREFIX . 'societe as s,'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf';
$sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid';
if (!$user->rights->societe->client->voir && !$socid) { if (!$user->rights->societe->client->voir && !$socid) {
$sql.= ', ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc'; $sql.= ', ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc';
} }
$sql .= ') LEFT JOIN ' . MAIN_DB_PREFIX . 'user as u ';
$sql .= 'ON cf.fk_user_author = u.rowid';
$sql.= ' WHERE cf.fk_soc = s.rowid '; $sql.= ' WHERE cf.fk_soc = s.rowid ';
$sql.= ' AND cf.entity = ' . $conf->entity; $sql.= ' AND cf.entity = ' . $conf->entity;
if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
$sql .= ' AND cf.fk_statut < 3'; $sql .= ' AND cf.fk_statut < 3';
} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) { } elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) {
@ -94,7 +90,6 @@ if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
} else { } else {
$sql .= ' AND cf.fk_statut < 5'; $sql .= ' AND cf.fk_statut < 5';
} }
if (!$user->rights->societe->client->voir && !$socid) { if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = ' . $user->id; $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = ' . $user->id;
} }
@ -150,15 +145,19 @@ if ($resql)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
print $langs->trans("ReplenishmentOrdersDesc").'<br><br>';
print_barre_liste( print_barre_liste(
$langs->trans('ReplenishmentOrders'), '',
$page, $page,
'replenishorders.php', 'replenishorders.php',
'', '',
$sortfield, $sortfield,
$sortorder, $sortorder,
'', '',
$num $num,
0,
''
); );
print '<form action="replenishorders.php" method="GET">'. print '<form action="replenishorders.php" method="GET">'.
'<table class="noborder" width="100%">'. '<table class="noborder" width="100%">'.
@ -255,8 +254,7 @@ if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var = !$var; $var = !$var;
if (!dispatched($obj->rowid) && if (!dispatched($obj->rowid) && (!$sproduct || in_array($sproduct, getProducts($obj->rowid))))
(!$sproduct || in_array($sproduct, getProducts($obj->rowid))))
{ {
$href = DOL_URL_ROOT . '/fourn/commande/fiche.php?id=' . $obj->rowid; $href = DOL_URL_ROOT . '/fourn/commande/fiche.php?id=' . $obj->rowid;
print '<tr ' . $bc[$var] . '>'. print '<tr ' . $bc[$var] . '>'.
@ -288,9 +286,10 @@ if ($resql)
'<td>'. '<td>'.
price($obj->total_ttc). price($obj->total_ttc).
'</td>'; '</td>';
// Date // Date
if ($obj->dc) { if ($obj->dc) {
$date = dol_print_date($db->jdate($obj->dc), 'day'); $date = dol_print_date($db->jdate($obj->dc), 'dayhour');
} else { } else {
$date = '-'; $date = '-';
} }
@ -310,6 +309,10 @@ if ($resql)
$db->free($resql); $db->free($resql);
} }
else
{
dol_print_error($db);
}
llxFooter(); llxFooter();
$db->close(); $db->close();