Fix: Stock management debug

This commit is contained in:
Laurent Destailleur 2008-05-26 21:27:50 +00:00
parent 3691acd09a
commit b728c133fb
7 changed files with 848 additions and 833 deletions

View File

@ -464,7 +464,7 @@ if ($_GET["id"] > 0)
print "</td></tr></table>";
print '<br>';
show_list_sending_receive('commande',$commande->id);

File diff suppressed because it is too large Load Diff

View File

@ -113,6 +113,7 @@ else
// Check if GD installed
if (! function_exists("imagecreate"))
{
$langs->load("errors");
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportGD")."<br>\n";
// $checksok=0; // If image ko, just warning. So check must still be 1 (otherwise no way to install)
}

View File

@ -38,9 +38,10 @@ EnhancedValueOfWarehouses=Warehouses value
UserWarehouseAutoCreate=Create a stock automatically when creating a user
QtyDispatched=Quantity dispatched
OrderDispatch=Order dispatching
DeStockReStockOnBill=Decrease/increase stocks on invoices/credit notes
DeStockReStockOnValidateOrder=Decrease/increase stocks on orders notes
DeStockReStockOnShipment=Decrease/increase stocks on shipment
DeStockReStockOnBill=Decrease/increase real stocks on invoices/credit notes
DeStockReStockOnValidateOrder=Decrease/increase real stocks on orders notes
DeStockReStockOnShipment=Decrease/increase real stocks on shipment
StockDiffPhysicTeoric=Reason for difference stock physical and theorical
StockLimitShort=Limit
StockLimit=Stock limit for alerts
PhysicalStock=Physical stock

View File

@ -38,9 +38,10 @@ EnhancedValueOfWarehouses=Valorisation des stocks
UserWarehouseAutoCreate=Créer un stock automatiquement à la création d'un utilisateur
QtyDispatched=Quantité ventilée
OrderDispatch=Ventilation commande
DeStockReStockOnBill=Décrémente/Incrémente les stocks sur les factures/avoirs
DeStockReStockOnValidateOrder=Décrémente/Incrémente les stocks sur les commandes
DeStockReStockOnShipment=Décrémente/Incrémente les stocks sur les expéditions
DeStockReStockOnBill=Décrémente/Incrémente les stocks réels sur les factures/avoirs
DeStockReStockOnValidateOrder=Décrémente/Incrémente les stocks réels sur les commandes
DeStockReStockOnShipment=Décrémente/Incrémente les stocks réels sur les expéditions
StockDiffPhysicTeoric=Raison écart stock physique-théorique
StockLimitShort=Seuil
StockLimit=Seuil alerte stock
PhysicalStock=Stock physique

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -16,15 +16,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/
/**
\file htdocs/product/liste.php
\file htdocs/product/reassort.php
\ingroup produit
\brief Page liste des produits ou services
\version $Revision$
\version $Id$
*/
require("./pre.inc.php");
@ -181,13 +179,18 @@ if ($resql)
print "</div><br />";
}
print '<form action="reassort.php" method="post" name="formulaire">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<table class="liste" width="100%">';
// Lignes des titres
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"reassort.php", "p.ref","&amp;envente=$envente".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"reassort.php", "p.label","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("TheoreticalStock"),"reassort.php", "stock_theorique","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("TheoreticalStock"),"reassort.php", "stock_theorique","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield,$sortorder);
if ($conf->service->enabled && $type == 1) print_liste_field_titre($langs->trans("Duration"),"reassort.php", "p.duration","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PhysicalStock"),"reassort.php", "stock_physique","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("MininumStock"),"reassort.php", "p.seuil_stock_alerte","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield,$sortorder);
@ -195,10 +198,6 @@ if ($resql)
print "</tr>\n";
// Lignes des champs de filtre
print '<form action="reassort.php" method="post" name="formulaire">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="sref" value="'.$sref.'">';
@ -212,7 +211,7 @@ if ($resql)
print '&nbsp;';
print '</td>';
}
print '<td class="liste_titre" colspan="3">';
print '<td class="liste_titre" colspan="2">';
print '&nbsp;';
print '</td>';
print '<td class="liste_titre" align="right">';
@ -220,7 +219,6 @@ if ($resql)
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
print '</td>';
print '</tr>';
print '</form>';
$product_static=new Product($db);
@ -245,21 +243,12 @@ if ($resql)
$var=!$var;
print '<tr '.$bc[$var].'><td nowrap="nowrap">';
print "<a href=\"fiche.php?id=$objp->rowid\">";
if ($objp->fk_product_type==1)
{
print img_object($langs->trans("ShowService"),"service");
}
else
{
if ( $objp->stock_theorique > $objp->seuil_stock_alerte) {
print img_object($langs->trans("ShowProduct"),"product");
} else {
print img_warning($langs->trans("StockTooLow"));
}
}
print '</a> ';
print '<a href="fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></td>';
$product_static->ref=$objp->ref;
$product_static->id=$objp->rowid;
$product_static->type=$objp->fk_product_type;
print $product_static->getNomUrl(1,'',16);
//if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow"));
print '</td>';
print '<td>'.$objp->label.'</td>';
if ($conf->service->enabled && $type == 1)
@ -271,7 +260,7 @@ if ($resql)
else print $objp->duration;
print '</td>';
}
print '<td align="right">'.$objp->stock_theorique.'</td>';
//print '<td align="right">'.$objp->stock_theorique.'</td>';
print '<td align="right">'.$objp->stock_physique.'</td>';
print '<td align="right">'.$objp->seuil_stock_alerte.'</td>';
print '<td align="right" nowrap="nowrap">'.$product_static->LibStatut($objp->statut,5).'</td>';
@ -279,6 +268,9 @@ if ($resql)
$i++;
}
print "</table>";
print '</form>';
if ($num > $conf->liste_limit)
{
if ($sref || $snom || $sall || $_POST["search"])
@ -293,8 +285,6 @@ if ($resql)
$db->free($resql);
print "</table>";
}
else
{

View File

@ -21,11 +21,11 @@
*/
/**
\file htdocs/product/stock/product.php
\ingroup product
\brief Page de la fiche stock d'un produit
\version $Id$
*/
\file htdocs/product/stock/product.php
\ingroup product
\brief Page de la fiche stock d'un produit
\version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
@ -44,50 +44,50 @@ if (! $user->rights->produit->lire || ! $product->type == 0 || ! $conf->stock->e
/*
* Actions
*/
* Actions
*/
if ($_POST["action"] == "create_stock")
{
$product = new Product($db);
$product->id = $_GET["id"];
$product->create_stock($_POST["id_entrepot"], $_POST["nbpiece"]);
$product = new Product($db);
$product->id = $_GET["id"];
$product->create_stock($_POST["id_entrepot"], $_POST["nbpiece"]);
}
if ($_POST["action"] == "correct_stock" && $_POST["cancel"] <> $langs->trans("Cancel"))
{
if (is_numeric($_POST["nbpiece"]))
{
$product = new Product($db);
$product->id = $_GET["id"];
$product->correct_stock($user,
$_POST["id_entrepot"],
$_POST["nbpiece"],
$_POST["mouvement"]);
}
{
$product = new Product($db);
$product->id = $_GET["id"];
$product->correct_stock($user,
$_POST["id_entrepot"],
$_POST["nbpiece"],
$_POST["mouvement"]);
}
}
if ($_POST["action"] == "transfert_stock" && $_POST["cancel"] <> $langs->trans("Cancel"))
{
if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
{
if (is_numeric($_POST["nbpiece"]))
if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
{
if (is_numeric($_POST["nbpiece"]))
{
$product = new Product($db);
$product->id = $_GET["id"];
$product->correct_stock($user,
$_POST["id_entrepot_source"],
$_POST["nbpiece"],
1);
$product->correct_stock($user,
$_POST["id_entrepot_source"],
$_POST["nbpiece"],
1);
$product->correct_stock($user,
$_POST["id_entrepot_destination"],
$_POST["nbpiece"],
0);
$product->correct_stock($user,
$_POST["id_entrepot_destination"],
$_POST["nbpiece"],
0);
}
}
}
}
/*
@ -96,251 +96,271 @@ if ($_POST["action"] == "transfert_stock" && $_POST["cancel"] <> $langs->trans("
*/
if ($_GET["id"] || $_GET["ref"])
{
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
llxHeader("","",$langs->trans("CardProduct".$product->type));
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
if ($result > 0)
{
$head=product_prepare_head($product, $user);
$titre=$langs->trans("CardProduct".$product->type);
dolibarr_fiche_head($head, 'stock', $titre);
$html = new Form($db);
print($mesg);
llxHeader("","",$langs->trans("CardProduct".$product->type));
print '<table class="border" width="100%">';
if ($result > 0)
{
$head=product_prepare_head($product, $user);
$titre=$langs->trans("CardProduct".$product->type);
dolibarr_fiche_head($head, 'stock', $titre);
// Reference
print '<tr>';
print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
print $html->showrefnav($product,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Libellé
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '</tr>';
$html = new Form($db);
// Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
if ($product->price_base_type == 'TTC')
{
print price($product->price_ttc).' '.$langs->trans($product->price_base_type);
}
else
{
print price($product->price).' '.$langs->trans($product->price_base_type);
}
print '</td></tr>';
print($mesg);
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $product->getLibStatut(2);
print '</td></tr>';
print '<table class="border" width="100%">';
// Stock
print '<tr><td>'.$langs->trans("StockLimit").'</td>';
print '<td>'.$product->seuil_stock_alerte.'</td>';
print '</tr>';
// Stock
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
if ($product->stock_reel < $product->seuil_stock_alerte)
// Reference
print '<tr>';
print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
print $html->showrefnav($product,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Libellé
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '</tr>';
// Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
if ($product->price_base_type == 'TTC')
{
print '<td>'.$product->stock_reel.' '.img_warning().'</td>';
print price($product->price_ttc).' '.$langs->trans($product->price_base_type);
}
else
{
print "<td>".$product->stock_reel.'</td>';
print price($product->price).' '.$langs->trans($product->price_base_type);
}
print '</tr>';
// Stock
print '<tr><td>'.$langs->trans("VirtualStock").'</td>';
print "<td>".$langs->trans("FeatureNotYetAvailable").'</td>';
print '</tr>';
// Nbre de commande clients en cours
if ($conf->commande->enabled)
{
$result=$product->load_stats_commande(0,'2');
if ($result < 0) dolibarr_print_error($db,$product->error);
print '<tr><td>'.$langs->trans("CustomersOrdersRunning").'</td>';
print '<td>';
print $product->stats_commande['qty'];
$result=$product->load_stats_commande(0,'0,1');
if ($result < 0) dolibarr_print_error($db,$product->error);
print ' ('.$langs->trans("DraftOrWaitingShipped").': '.$product->stats_commande['qty'].')';
print '</td></tr>';
}
// Nbre de commande fournisseurs en cours
if ($conf->fournisseur->enabled)
{
$result=$product->load_stats_commande_fournisseur(0,'3');
if ($result < 0) dolibarr_print_error($db,$product->error);
print '<tr><td>'.$langs->trans("SuppliersOrdersRunning").'</td>';
print '<td>';
print $product->stats_commande_fournisseur['qty'];
$result=$product->load_stats_commande_fournisseur(0,'0,1,2');
if ($result < 0) dolibarr_print_error($db,$product->error);
print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')';
print '</td></tr>';
}
print "</table>";
print '</td></tr>';
}
print '</div>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $product->getLibStatut(2);
print '</td></tr>';
/*
* Correction du stock
*/
if ($_GET["action"] == "correction")
{
print_titre($langs->trans("StockCorrection"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="correct_stock">';
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td>';
// Entrepot
print '<td width="20%"><select class="flat" name="id_entrepot">';
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE statut = 1";
$sql .= " ORDER BY lower(e.label)";
// Stock physique
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
print '<td>'.$product->stock_reel.'</td>';
print '</tr>';
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td>';
print '<td width="20%">';
print '<select name="mouvement" class="flat">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1">'.$langs->trans("Delete").'</option>';
print '</select></td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" size="10" value=""></td>';
print '</tr>';
print '<tr><td colspan="5" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
// Calculating a theorical value of stock if stock increment is done on order
if ($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)
{
$stock_commande_client=$stock_commande_fournisseur=0;
if ($conf->commande->enabled)
{
$result=$product->load_stats_commande(0,'2');
if ($result < 0) dolibarr_print_error($db,$product->error);
$stock_commande_client=$product->stats_commande['qty'];
}
if ($conf->fournisseur->enabled)
{
$result=$product->load_stats_commande_fournisseur(0,'3');
if ($result < 0) dolibarr_print_error($db,$product->error);
$stock_commande_fournisseur=$product->stats_commande_fournisseur['qty'];
}
$product->stock_theorique=$product->stock_reel-$stock_commande_client+$stock_commande_fournisseur;
// Stock theorique
print '<tr><td>'.$langs->trans("VirtualStock").'</td>';
print "<td>".$product->stock_theorique;
if ($product->stock_theorique < $product->seuil_stock_alerte)
{
print ' '.img_warning($langs->trans("StockTooLow"));
}
print '</td>';
print '</tr>';
if ($product->stock_theorique != $product->stock_reel)
{
print '<tr><td>'.$langs->trans("StockDiffPhysicTeoric").'</td>';
print '<td>';
$found=0;
// Nbre de commande clients en cours
if ($conf->commande->enabled)
{
if ($found) print '<br>'; else $found=1;
print $langs->trans("CustomersOrdersRunning").': '.$stock_commande_client;
$result=$product->load_stats_commande(0,'0,1');
if ($result < 0) dolibarr_print_error($db,$product->error);
print ' ('.$langs->trans("DraftOrWaitingShipped").': '.$product->stats_commande['qty'].')';
}
// Nbre de commande fournisseurs en cours
if ($conf->fournisseur->enabled)
{
if ($found) print '<br>'; else $found=1;
print $langs->trans("SuppliersOrdersRunning").': '.$stock_commande_fournisseur;
$result=$product->load_stats_commande_fournisseur(0,'0,1,2');
if ($result < 0) dolibarr_print_error($db,$product->error);
print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')';
}
print '</td></tr>';
}
}
// Stock
print '<tr><td>'.$langs->trans("StockLimit").'</td>';
print '<td>'.$product->seuil_stock_alerte.'</td>';
print '</tr>';
}
/*
* Transfert de pièces
*/
if ($_GET["action"] == "transfert")
{
print_titre($langs->trans("Transfer"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="transfert_stock">';
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Source").'</td><td width="20%"><select name="id_entrepot_source">';
print "</table>";
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE statut = 1";
$sql .= " ORDER BY lower(e.label)";
}
print '</div>';
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td>';
/*
* Correction du stock
*/
if ($_GET["action"] == "correction")
{
print_titre($langs->trans("StockCorrection"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="correct_stock">';
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td width="20%">'.$langs->trans("Target").'</td><td width="20%"><select name="id_entrepot_destination">';
// Entrepot
print '<td width="20%"><select class="flat" name="id_entrepot">';
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE statut = 1";
$sql .= " ORDER BY lower(e.label)";
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE statut = 1";
$sql .= " ORDER BY lower(e.label)";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td>';
print '<td width="20%">';
print '<select name="mouvement" class="flat">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1">'.$langs->trans("Delete").'</option>';
print '</select></td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" size="10" value=""></td>';
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>';
print '<tr><td colspan="6" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
print '</tr>';
print '<tr><td colspan="5" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
}
/*
*
*/
if ($_GET["action"] == "definir")
{
print_titre($langs->trans("SetStock"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="create_stock">';
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td><td width="40%"><select name="id_entrepot">';
}
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " ORDER BY lower(e.label)";
/*
* Transfert de pièces
*/
if ($_GET["action"] == "transfert")
{
print_titre($langs->trans("Transfer"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="transfert_stock">';
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Source").'</td><td width="20%"><select name="id_entrepot_source">';
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td><td width="20%">Nb de pièce</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td></tr>';
print '</table>';
print '</form>';
}
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE statut = 1";
$sql .= " ORDER BY lower(e.label)";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td>';
print '<td width="20%">'.$langs->trans("Target").'</td><td width="20%"><select name="id_entrepot_destination">';
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE statut = 1";
$sql .= " ORDER BY lower(e.label)";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>';
print '<tr><td colspan="6" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
}
/*
*
*/
if ($_GET["action"] == "definir")
{
print_titre($langs->trans("SetStock"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="create_stock">';
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td><td width="40%"><select name="id_entrepot">';
$sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " ORDER BY lower(e.label)";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->label ;
$i++;
}
}
print '</select></td><td width="20%">Nb de pièce</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td></tr>';
print '</table>';
print '</form>';
}
}
else
{
dolibarr_print_error();
dolibarr_print_error();
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "<div class=\"tabsAction\">\n";
@ -351,7 +371,7 @@ if ($_GET["action"] == '' )
{
print '<a class="butAction" href="product.php?id='.$product->id.'&amp;action=transfert">'.$langs->trans("StockMovement").'</a>';
}
if ($user->rights->stock->creer)
{
print '<a class="butAction" href="product.php?id='.$product->id.'&amp;action=correction">'.$langs->trans("StockCorrection").'</a>';
@ -378,21 +398,21 @@ $entrepotstatic=new Entrepot($db);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i=0; $total=0; $var=false;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$entrepotstatic->id=$obj->rowid;
$entrepotstatic->libelle=$obj->label;
print '<tr '.$bc[$var].'>';
print '<td>'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->reel.'</td>';
print '</tr>'; ;
$total = $total + $obj->reel;
$i++;
$var=!$var;
}
$num = $db->num_rows($resql);
$i=0; $total=0; $var=false;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$entrepotstatic->id=$obj->rowid;
$entrepotstatic->libelle=$obj->label;
print '<tr '.$bc[$var].'>';
print '<td>'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->reel.'</td>';
print '</tr>'; ;
$total = $total + $obj->reel;
$i++;
$var=!$var;
}
}
print '<tr class="liste_total"><td align="right" class="liste_total">'.$langs->trans("Total").':</td><td class="liste_total" align="right">'.$total."</td></tr>";
print "</table>";