Fix: [ bug #1436 ] réapprovisionnement sur plusieurs pages
Removed also strange image (no way to understand meaning).
This commit is contained in:
parent
d0dffc8999
commit
e1a461b3d6
@ -90,37 +90,42 @@ function dispatchedOrders()
|
|||||||
*/
|
*/
|
||||||
function ordered($product_id)
|
function ordered($product_id)
|
||||||
{
|
{
|
||||||
global $db, $langs, $conf;
|
global $db, $langs, $conf;
|
||||||
$sql = 'SELECT DISTINCT cfd.fk_product, SUM(cfd.qty) FROM';
|
|
||||||
$sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseurdet as cfd ';
|
|
||||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf';
|
|
||||||
$sql .= ' ON cfd.fk_commande = cf.rowid WHERE';
|
|
||||||
if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
|
|
||||||
$sql .= ' cf.fk_statut < 3';
|
|
||||||
} else if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) {
|
|
||||||
$sql .= ' cf.fk_statut < 6 AND cf.rowid NOT IN ' . dispatchedOrders();
|
|
||||||
} else {
|
|
||||||
$sql .= ' cf.fk_statut < 5';
|
|
||||||
}
|
|
||||||
$sql .= ' AND cfd.fk_product = ' . $product_id;
|
|
||||||
$sql .= ' GROUP BY cfd.fk_product';
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$sql = 'SELECT DISTINCT cfd.fk_product, SUM(cfd.qty) as qty FROM';
|
||||||
if ($resql) {
|
$sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseurdet as cfd ';
|
||||||
$exists = $db->num_rows($resql);
|
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf';
|
||||||
if ($exists) {
|
$sql .= ' ON cfd.fk_commande = cf.rowid WHERE';
|
||||||
$obj = $db->fetch_array($resql);
|
if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
|
||||||
return $obj['SUM(cfd.qty)']; //. ' ' . img_picto('','tick');
|
$sql .= ' cf.fk_statut < 3';
|
||||||
} else {
|
} else if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) {
|
||||||
return null;//img_picto('', 'stcomm-1');
|
$sql .= ' cf.fk_statut < 6 AND cf.rowid NOT IN ' . dispatchedOrders();
|
||||||
}
|
} else {
|
||||||
} else {
|
$sql .= ' cf.fk_statut < 5';
|
||||||
$error = $db->lasterror();
|
}
|
||||||
dol_print_error($db);
|
$sql .= ' AND cfd.fk_product = ' . $product_id;
|
||||||
dol_syslog('replenish.php: ' . $error, LOG_ERR);
|
$sql .= ' GROUP BY cfd.fk_product';
|
||||||
|
|
||||||
return $langs->trans('error');
|
$resql = $db->query($sql);
|
||||||
}
|
if ($resql)
|
||||||
|
{
|
||||||
|
$exists = $db->num_rows($resql);
|
||||||
|
if ($exists)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_array($resql);
|
||||||
|
return $obj['qty']; //. ' ' . img_picto('','tick');
|
||||||
|
} else {
|
||||||
|
return null; //img_picto('', 'stcomm-1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error = $db->lasterror();
|
||||||
|
dol_print_error($db);
|
||||||
|
dol_syslog('replenish.php: ' . $error, LOG_ERR);
|
||||||
|
|
||||||
|
return $langs->trans('error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -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>
|
* Copyright (C) 2013-2014 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
|
||||||
@ -64,6 +64,10 @@ if (!$sortorder) {
|
|||||||
$limit = $conf->liste_limit;
|
$limit = $conf->liste_limit;
|
||||||
$offset = $limit * $page ;
|
$offset = $limit * $page ;
|
||||||
|
|
||||||
|
// Force limit to non (currently solution to solve loosing selection when using pagination. No pagination on this page)
|
||||||
|
$limit = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
@ -183,6 +187,8 @@ if ($action == 'order' && isset($_POST['valid']))
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
$virtualdiffersfromphysical=0;
|
$virtualdiffersfromphysical=0;
|
||||||
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|
||||||
|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
|
|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
|
||||||
@ -362,9 +368,9 @@ $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert;
|
|||||||
$param .= '&sref=' . $sref;
|
$param .= '&sref=' . $sref;
|
||||||
$param .= '&mode=' . $mode;
|
$param .= '&mode=' . $mode;
|
||||||
|
|
||||||
// Lignes des titres
|
// Lines of title
|
||||||
print '<tr class="liste_titre">'.
|
print '<tr class="liste_titre"><td><input type="checkbox" onClick="toggle(this)" /></td>';
|
||||||
'<td><input type="checkbox" onClick="toggle(this)" /></td>';
|
|
||||||
print_liste_field_titre(
|
print_liste_field_titre(
|
||||||
$langs->trans('Ref'),
|
$langs->trans('Ref'),
|
||||||
$_SERVER["PHP_SELF"],
|
$_SERVER["PHP_SELF"],
|
||||||
@ -481,7 +487,7 @@ print '<td class="liste_titre"> </td>'.
|
|||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
|
|
||||||
$var = True;
|
$var = True;
|
||||||
while ($i < min($num, $limit))
|
while ($i < ($limit ? min($num, $limit) : $num))
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
@ -503,13 +509,15 @@ while ($i < min($num, $limit))
|
|||||||
if (!empty($objtp->label)) $objp->label = $objtp->label;
|
if (!empty($objtp->label)) $objp->label = $objtp->label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$form = new Form($db);
|
|
||||||
$var =! $var;
|
$var =! $var;
|
||||||
$prod->ref = $objp->ref;
|
$prod->ref = $objp->ref;
|
||||||
$prod->id = $objp->rowid;
|
$prod->id = $objp->rowid;
|
||||||
$prod->type = $objp->fk_product_type;
|
$prod->type = $objp->fk_product_type;
|
||||||
|
|
||||||
|
// Get number already ordered.
|
||||||
$ordered = ordered($prod->id);
|
$ordered = ordered($prod->id);
|
||||||
|
|
||||||
|
// Defined current stock number and warning if required
|
||||||
if ($usevirtualstock)
|
if ($usevirtualstock)
|
||||||
{
|
{
|
||||||
// If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock.
|
// If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock.
|
||||||
@ -531,26 +539,29 @@ while ($i < min($num, $limit))
|
|||||||
$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
|
||||||
//virtual stock to compute the stock to buy value
|
//virtual stock to compute the stock to buy value
|
||||||
$stocktobuy = max($objp->desiredstock - $stock - $ordered, 0);
|
$stocktobuy = max($objp->desiredstock - $stock - $ordered, 0);
|
||||||
|
/*
|
||||||
$disabled = '';
|
$disabled = '';
|
||||||
if($ordered > 0) {
|
if($ordered > 0)
|
||||||
if($ordered + $stock >= $objp->desiredstock) {
|
{
|
||||||
$picto = img_picto('', './img/yes', '', 1);
|
if ($ordered + $stock >= $objp->desiredstock)
|
||||||
|
{
|
||||||
|
$picto = img_picto('', 'ok', '');
|
||||||
$disabled = 'disabled="disabled"';
|
$disabled = 'disabled="disabled"';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$picto = img_picto('', './img/no', '', 1);
|
$picto = img_picto($langs->trans("NotEnough"), 'warning', '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$picto = img_picto('', './img/no', '', 1);
|
$picto = img_picto('', 'info', '');
|
||||||
}
|
}*/
|
||||||
|
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
|
|
||||||
@ -558,13 +569,12 @@ while ($i < min($num, $limit))
|
|||||||
//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).'</td>';
|
||||||
$prod->getNomUrl(1, '', 16).
|
|
||||||
'</td>'.
|
|
||||||
'<td>' . $objp->label . '</td>'.
|
|
||||||
'<input type="hidden" name="desc' . $i . '" value="' . $objp->label . '" >';
|
|
||||||
|
|
||||||
if (!empty($conf->service->enabled) && $type == 1) {
|
print '<td>' . $objp->label . '<input type="hidden" name="desc' . $i . '" value="' . $objp->label . '" ></td>';
|
||||||
|
|
||||||
|
if (!empty($conf->service->enabled) && $type == 1)
|
||||||
|
{
|
||||||
if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) {
|
if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) {
|
||||||
$duration = $regs[1] . ' ' . $langs->trans('DurationYear');
|
$duration = $regs[1] . ' ' . $langs->trans('DurationYear');
|
||||||
} elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) {
|
} elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) {
|
||||||
@ -574,19 +584,17 @@ while ($i < min($num, $limit))
|
|||||||
} else {
|
} else {
|
||||||
$duration = $objp->duration;
|
$duration = $objp->duration;
|
||||||
}
|
}
|
||||||
print '<td align="center">'.
|
print '<td align="center">'.$duration.'</td>';
|
||||||
$duration.
|
|
||||||
'</td>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<td align="right">' . $objp->desiredstock . '</td>'.
|
// Desired stock
|
||||||
'<td align="right">'.
|
print '<td align="right">' . $objp->desiredstock . '</td>';
|
||||||
$warning . $stock.
|
|
||||||
'</td>'.
|
// Current stock
|
||||||
'<td align="right">'.
|
print '<td align="right">'. $warning . $stock. '</td>';
|
||||||
'<a href="replenishorders.php?sproduct=' . $prod->id . '">'.
|
|
||||||
$ordered . '</a> ' . $picto.
|
// Already ordered
|
||||||
'</td>';
|
print '<td align="right"><a href="replenishorders.php?sproduct=' . $prod->id . '">'. $ordered . '</a> ' . $picto. '</td>';
|
||||||
|
|
||||||
// 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>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user