Skip to content
Snippets Groups Projects
Commit e1a461b3 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: [ bug #1436 ] réapprovisionnement sur plusieurs pages

Removed also strange image (no way to understand meaning).
parent d0dffc89
Branches
No related tags found
No related merge requests found
...@@ -91,7 +91,8 @@ function dispatchedOrders() ...@@ -91,7 +91,8 @@ 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 = 'SELECT DISTINCT cfd.fk_product, SUM(cfd.qty) as qty FROM';
$sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseurdet as cfd '; $sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseurdet as cfd ';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf';
$sql .= ' ON cfd.fk_commande = cf.rowid WHERE'; $sql .= ' ON cfd.fk_commande = cf.rowid WHERE';
...@@ -106,15 +107,19 @@ function ordered($product_id) ...@@ -106,15 +107,19 @@ function ordered($product_id)
$sql .= ' GROUP BY cfd.fk_product'; $sql .= ' GROUP BY cfd.fk_product';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql)
{
$exists = $db->num_rows($resql); $exists = $db->num_rows($resql);
if ($exists) { if ($exists)
{
$obj = $db->fetch_array($resql); $obj = $db->fetch_array($resql);
return $obj['SUM(cfd.qty)']; //. ' ' . img_picto('','tick'); return $obj['qty']; //. ' ' . img_picto('','tick');
} else { } else {
return null; //img_picto('', 'stcomm-1'); return null; //img_picto('', 'stcomm-1');
} }
} 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);
......
<?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) { ...@@ -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'])) ...@@ -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; ...@@ -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">&nbsp;</td>'. ...@@ -481,7 +487,7 @@ print '<td class="liste_titre">&nbsp;</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)) ...@@ -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)) ...@@ -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)) ...@@ -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)) ...@@ -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>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment