diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index f23478dab18..543395e2baf 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1302,8 +1302,8 @@ class CommandeFournisseur extends CommonOrder
{
$this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch ";
- $sql.= " (fk_commande,fk_product, qty, fk_entrepot, fk_user, datec) VALUES ";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch";
+ $sql.= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec) VALUES ";
$sql.= " ('".$this->id."','".$product."','".$qty."',".($entrepot>0?"'".$entrepot."'":"null").",'".$user->id."','".$this->db->idate($now)."')";
dol_syslog(get_class($this)."::DispatchProduct", LOG_DEBUG);
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index c9884ab46de..8ac3299d849 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -96,7 +96,9 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece
setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors');
$error++;
}
- } else if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
+ }
+ else if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
+ {
//eat-by date dispatch
$prod = "product_".$reg[1]."_".$reg[2];
$qty = "qty_".$reg[1]."_".$reg[2];
@@ -166,10 +168,12 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece
* View
*/
- if (!empty($conf->productbatch->enabled)) {
+if (!empty($conf->productbatch->enabled))
+{
llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur",'',0,0,array('/core/js/lib_batch.js'));
-
- } else {
+}
+else
+{
llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur");
}
@@ -272,6 +276,8 @@ if ($id > 0 || ! empty($ref))
print '';
print '
';
+ // Set $products_dispatched with qty dispatech for each product id
+ $products_dispatched = array();
$sql = "SELECT cfd.fk_product, sum(cfd.qty) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " WHERE cfd.fk_commande = ".$commande->id;
@@ -280,7 +286,7 @@ if ($id > 0 || ! empty($ref))
$resql = $db->query($sql);
if ($resql)
{
- while ( $row = $db->fetch_row($resql) )
+ while ($row = $db->fetch_row($resql))
{
$products_dispatched[$row[0]] = $row[1];
}
@@ -338,7 +344,7 @@ if ($id > 0 || ! empty($ref))
}
else
{
- $remaintodispatch=($objp->qty - $products_dispatched[$objp->fk_product]); // Calculation of dispatched
+ $remaintodispatch=($objp->qty - (empty($products_dispatched[$objp->fk_product])?0:$products_dispatched[$objp->fk_product])); // Calculation of dispatched
if ($remaintodispatch < 0) $remaintodispatch=0;
if ($remaintodispatch)
{
diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql
index 7eeb02ab5cf..849ea9f51f5 100644
--- a/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql
+++ b/htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql
@@ -24,5 +24,8 @@ create table llx_commande_fournisseur_dispatch
qty float, -- qty
fk_entrepot integer,
fk_user integer,
- datec datetime
+ comment varchar(255),
+ status integer,
+ datec datetime,
+ tms timestamp
)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang
index e8c0556d550..e054f2241a0 100644
--- a/htdocs/langs/en_US/orders.lang
+++ b/htdocs/langs/en_US/orders.lang
@@ -29,7 +29,7 @@ StatusOrderDraftShort=Draft
StatusOrderValidatedShort=Validated
StatusOrderSentShort=In process
StatusOrderSent=Shipment in process
-StatusOrderOnProcessShort=Order sent
+StatusOrderOnProcessShort=Ordered
StatusOrderProcessedShort=Processed
StatusOrderToBillShort=Delivered
StatusOrderToBill2Short=To bill
@@ -41,7 +41,7 @@ StatusOrderReceivedAllShort=Everything received
StatusOrderCanceled=Canceled
StatusOrderDraft=Draft (needs to be validated)
StatusOrderValidated=Validated
-StatusOrderOnProcess=Order sent - Standby reception
+StatusOrderOnProcess=Ordered - Standby reception
StatusOrderProcessed=Processed
StatusOrderToBill=Delivered
StatusOrderToBill2=To bill