From 14afe7a82f7933d28971e326f2c2be46d09fa8c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 May 2009 21:38:56 +0000 Subject: [PATCH] Fix: Can not validate an order if there is a discount Qual: Uniformize code for stock decrease --- htdocs/commande/commande.class.php | 120 ++++++---- htdocs/commande/index.php | 240 ++++++++++--------- htdocs/expedition/expedition.class.php | 313 +++++++++++++------------ htdocs/expedition/fiche.php | 43 ++-- htdocs/facture.class.php | 311 ++++++++++++------------ htdocs/product/stock/mouvement.php | 23 +- 6 files changed, 546 insertions(+), 504 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 20c98fa749e..746b5f92f39 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -205,8 +205,8 @@ class Commande extends CommonObject /** * \brief Validate order - * \param user Utilisateur qui valide - * \return int <=0 si ko, >0 si ok + * \param user User making status change + * \return int <=0 if OK, >0 if KO */ function valid($user) { @@ -217,12 +217,14 @@ class Commande extends CommonObject // Protection if ($this->statut == 1) { + dol_syslog("Commande::valid no draft status", LOG_WARNING); return 0; } if (! $user->rights->commande->valider) { $this->error='Permission denied'; + dol_syslog("Commande::valid ".$this->error, LOG_ERR); return -1; } @@ -231,13 +233,12 @@ class Commande extends CommonObject // Definition du nom de module de numerotation de commande $soc = new Societe($this->db); $soc->fetch($this->socid); - $num=$this->getNextNumRef($soc); // Class of company linked to order $result=$soc->set_as_client(); - // check if temporary number - if (eregi('^\(PROV', $this->ref)) + // Define new ref + if (! $error && (eregi('^\(PROV', $this->ref) || eregi('^PROV', $this->ref))) { $num = $this->getNextNumRef($soc); } @@ -246,22 +247,53 @@ class Commande extends CommonObject $num = $this->ref; } + // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql.= " SET ref = '".$num."'"; $sql.= ", fk_statut = 1"; $sql.= ", date_valid=".$this->db->idate(mktime()); $sql.= ", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = 0"; + dol_syslog("Commande::valid() sql=".$sql); $resql=$this->db->query($sql); - if ($resql) + if (! $resql) { - // On efface le repertoire de pdf provisoire - if (eregi('^\(PROV', $this->ref)) + dol_syslog("Commande::valid() Echec update - 10 - sql=".$sql, LOG_ERR); + dol_print_error($this->db); + $error++; + } + + if (! $error) + { + // If stock is incremented on validate order, we must increment it + if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { - // On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref) - // afin de ne pas perdre les fichiers attach�s + require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); + + // Loop on each line + for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) + { + if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0) + { + $mouvP = new MouvementStock($this->db); + // We decrement stock of product (and sub-products) + $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP + $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); + if ($result < 0) { $error++; } + } + } + } + } + + if (! $error) + { + // Rename directory if dir was a temporary ref + if (eregi('^\(PROV', $this->ref) || eregi('^PROV', $this->ref)) + { + // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref) + // afin de ne pas perdre les fichiers attaches $comref = dol_sanitizeFileName($this->ref); $snum = dol_sanitizeFileName($num); $dirsource = $conf->commande->dir_output.'/'.$comref; @@ -278,44 +310,28 @@ class Commande extends CommonObject } } } + } + // Set new ref + if (! $error) + { + $this->ref = $num; + } - // If stock is incremented on validate order, we must increment it - if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) - { - require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) - { - $mouvP = new MouvementStock($this->db); - // We decrement stock of product (and sub-products) - $entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot - $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); - if ($result < 0) { $error++; } - } - } - - if ($error == 0) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - - if ($error == 0) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } + if (! $error) + { + $this->db->commit(); + return 1; } else { @@ -892,7 +908,7 @@ class Commande extends CommonObject function fetch($id,$ref='') { global $conf; - + // Check parameters if (empty($id) && empty($ref)) return -1; @@ -1509,7 +1525,7 @@ class Commande extends CommonObject function liste_array ($brouillon=0, $user='') { global $conf; - + $ga = array(); $sql = "SELECT rowid, ref"; @@ -2091,13 +2107,13 @@ class Commande extends CommonObject // Charge tableau des id de societe socids $socids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE client = 1"; $sql.= " AND entity = ".$conf->entity; $sql.= " LIMIT 10"; - + $resql = $this->db->query($sql); if ($resql) { @@ -2114,12 +2130,12 @@ class Commande extends CommonObject // Charge tableau des produits prodids $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE envente = 1"; $sql.= " AND entity = ".$conf->entity; - + $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 40d4878034c..510ba60919b 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -77,36 +77,39 @@ print "
\n"; /* * Commandes brouillons */ -$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; -$sql.= " AND c.fk_statut = 0"; -if ($socid) $sql.= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - -if ( $db->query($sql) ) +if ($conf->commande->enabled) { - $langs->load("orders"); - $num = $db->num_rows(); - if ($num) + $sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 0"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + + if ( $db->query($sql) ) { - $i = 0; print ''; print ''; print ''; - $var = True; - while ($i < $num) + $langs->load("orders"); + $num = $db->num_rows(); + if ($num) { - $var=!$var; - $obj = $db->fetch_object(); - print ""; - print '"; - print ''; - $i++; + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object(); + print ""; + print '"; + print ''; + $i++; + } } print "
'.$langs->trans("DraftOrders").'
'; - print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).'
'; + print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).'

"; } @@ -115,128 +118,133 @@ if ( $db->query($sql) ) /* * Commandes à traiter */ -$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; -$sql.=" FROM ".MAIN_DB_PREFIX."commande as c"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; -$sql.= " AND c.fk_statut = 1"; -if ($socid) $sql.= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.rowid DESC"; - -if ( $db->query($sql) ) +if ($conf->commande->enabled) { - print ''; - print ''; - print ''; + $sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; + $sql.=" FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 1"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; - $num = $db->num_rows(); - if ($num) + if ( $db->query($sql) ) { - $i = 0; - $var = True; - while ($i < $num) + print '
'.$langs->trans("OrdersToProcess").'
'; + print ''; + print ''; + + $num = $db->num_rows(); + if ($num) { - $var=!$var; - $obj = $db->fetch_object(); - print ""; - print '"; + print '
'.$langs->trans("OrdersToProcess").'
'; + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object(); + print "
'; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id=$obj->rowid; + $commandestatic->ref=$obj->ref; - print ''; - print ''; + print '
'; - print $commandestatic->getNomUrl(1); - print '
'; + print ''; - print ''; + print ''; - print '
'; + print $commandestatic->getNomUrl(1); + print ''; - print ' '; - print ''; + print ' '; + print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); - print '
'; + print '
'; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + print '
'; - print ''; - print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).''; - $i++; + print ''; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).''; + $i++; + } } + + print "
"; } - - print "
"; } - print ''; /* * Commandes en cours */ -$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.rowid as socid"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; -$sql.= " AND c.fk_statut = 2 "; -if ($socid) $sql.= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.rowid DESC"; - -if ( $db->query($sql) ) +if ($conf->commande->enabled) { - $num = $db->num_rows(); + $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 2 "; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; - print ''; - print ''; - print ''; - - if ($num) + if ( $db->query($sql) ) { - $i = 0; - $var = True; - while ($i < $num) + $num = $db->num_rows(); + + print '
'.$langs->trans("OnProcessOrders").' ('.$num.')
'; + print ''; + print ''; + + if ($num) { - $var=!$var; - $obj = $db->fetch_object(); - print ""; - print '"; + print '
'.$langs->trans("OnProcessOrders").' ('.$num.')
'; + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object(); + print "
'; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id=$obj->rowid; + $commandestatic->ref=$obj->ref; - print ''; - print ''; + print '
'; - print $commandestatic->getNomUrl(1); - print '
'; + print ''; - print ''; + print ''; - print '
'; + print $commandestatic->getNomUrl(1); + print ''; - print ' '; - print ''; + print ' '; + print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); - print '
'; + print '
'; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + print '
'; - print ''; + print ''; - print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; - print ''.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).''; - print ''; - $i++; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; + print ''.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).''; + print ''; + $i++; + } } + print "
"; } - print "
"; } /* diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 6805efd1a45..4fffedcc895 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -138,7 +138,7 @@ class Expedition extends CommonObject { if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0) { - $error++; + $error++; } } @@ -146,32 +146,32 @@ class Expedition extends CommonObject { if ($conf->commande->enabled) { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')'; - if (!$this->db->query($sql)) - { - $error++; - } + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')'; + if (!$this->db->query($sql)) + { + $error++; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id; - if (! $this->db->query($sql)) - { - $error++; - } + $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id; + if (! $this->db->query($sql)) + { + $error++; + } } else { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')'; - if (!$this->db->query($sql)) - { - $error++; - } + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')'; + if (!$this->db->query($sql)) + { + $error++; + } - //Todo: definir un statut - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id; - if (! $this->db->query($sql)) - { - $error++; - } + //Todo: definir un statut + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id; + if (! $this->db->query($sql)) + { + $error++; + } } } @@ -340,7 +340,7 @@ class Expedition extends CommonObject } /** - * \brief Valide l'expedition, et met a jour le stock si stock géré + * \brief Validate object and update stock if option enabled * \param user Objet de l'utilisateur qui valide * \return int */ @@ -348,140 +348,143 @@ class Expedition extends CommonObject { global $conf; - require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; - dol_syslog("Expedition::valid"); - $this->db->begin(); - - $error = 0; - $provref = $this->ref; - - if ($user->rights->expedition->valider) + // Protection + if ($this->statut) { - $this->ref = "EXP".$this->id; - - // Tester si non dejà au statut validé. Si oui, on arrete afin d'éviter - // de décrémenter 2 fois le stock. - $sql = "SELECT ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; - $sql.= " WHERE ref='".$this->ref."'"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " AND fk_statut <> '0'"; - - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num > 0) - { - dol_syslog("Expedition::valid already validated", LOG_WARNING); - $this->db->rollback(); - return 0; - } - } - - $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; - $sql.= " SET ref='".$this->ref."'"; - $sql.= ", fk_statut = 1"; - $sql.= ", date_valid = ".$this->db->idate(mktime()); - $sql.= ", fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = 0"; - - dol_syslog("Expedition::valid update expedition sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - // If stock increment is done on sending (recommanded choice) - if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT) - { - /* - * Enregistrement d'un mouvement de stock pour chaque produit de l'expedition - */ - $sql = "SELECT cd.fk_product, ed.qty, ed.fk_entrepot"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_origin_line"; - - dol_syslog("Expedition::valid select details sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i=0; - while($i < $num) - { - dol_syslog("Expedition::valid movment nb ".$i); - - $obj = $this->db->fetch_object($resql); - - $mouvS = new MouvementStock($this->db); - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty); - if ($result < 0) - { - $this->db->rollback(); - $this->error=$this->db->error()." - sql=$sql"; - dol_syslog("Expedition::valid ".$this->error, LOG_ERR); - return -3; - } - - $i++; - } - - } - else - { - $this->db->rollback(); - $this->error=$this->db->error()." - sql=$sql"; - dol_syslog("Expedition::valid ".$this->error, LOG_ERR); - return -2; - } - } - - // On efface le répertoire de pdf provisoire - $expeditionref = dol_sanitizeFileName($provref); - if ($conf->expedition->dir_output) - { - $dir = $conf->expedition->dir_output . "/" . $expeditionref; - $file = $dir . "/" . $expeditionref . ".pdf"; - if (file_exists($file)) - { - if (!dol_delete_file($file)) - { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); - } - } - if (file_exists($dir)) - { - if (!dol_delete_dir($dir)) - { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); - } - } - } - - } - else - { - $this->db->rollback(); - $this->error=$this->db->error(); - dol_syslog("Expedition::valid ".$this->error, LOG_ERR); - return -1; - } + dol_syslog("Expedition::valid no draft status", LOG_WARNING); + return 0; } - else + + if (! $user->rights->expedition->valider) { - $this->db->rollback(); - $this->error="Non autorise"; + $this->error='Permission denied'; dol_syslog("Expedition::valid ".$this->error, LOG_ERR); return -1; } - $this->db->commit(); - //dol_syslog("Expedition::valid commit"); - return 1; + $this->db->begin(); + + // Define new ref + $num = "EXP".$this->id; + + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; + $sql.= " SET ref='".$num."'"; + $sql.= ", fk_statut = 1"; + $sql.= ", date_valid = ".$this->db->idate(mktime()); + $sql.= ", fk_user_valid = ".$user->id; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog("Expedition::valid update expedition sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + dol_syslog("Expedition::valid() Echec update - 10 - sql=".$sql, LOG_ERR); + dol_print_error($this->db); + $error++; + } + + if (! $error) + { + // If stock increment is done on sending (recommanded choice) + if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT) + { + require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; + + // Loop on each product line to add a stock movement + $sql = "SELECT cd.fk_product, ed.qty, ed.fk_entrepot"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql.= " WHERE ed.fk_expedition = ".$this->id; + $sql.= " AND cd.rowid = ed.fk_origin_line"; + dol_syslog("Expedition::valid select details sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i=0; + while($i < $num) + { + dol_syslog("Expedition::valid movment index ".$i); + $obj = $this->db->fetch_object($resql); + + if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0) + { + $mouvS = new MouvementStock($this->db); + // We decrement stock of product (and sub-products) + $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty); + if ($result < 0) { $error++; } + } + + $i++; + } + } + else + { + $this->db->rollback(); + $this->error=$this->db->error()." - sql=$sql"; + dol_syslog("Expedition::valid ".$this->error, LOG_ERR); + return -2; + } + } + } + + if (! $error) + { + // On efface le répertoire de pdf provisoire + $expeditionref = dol_sanitizeFileName($this->ref); + if ($conf->expedition->dir_output) + { + $dir = $conf->expedition->dir_output . "/" . $expeditionref; + $file = $dir . "/" . $expeditionref . ".pdf"; + if (file_exists($file)) + { + if (!dol_delete_file($file)) + { + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + } + } + if (file_exists($dir)) + { + if (!dol_delete_dir($dir)) + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + } + } + } + } + + // Set new ref + if (! $error) + { + $this->ref = $num; + } + + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('ORDER_SHIPPING',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } } @@ -572,8 +575,8 @@ class Expedition extends CommonObject { $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id; if ( $this->db->query($sql) ) - { - $this->db->commit(); + { + $this->db->commit(); // On efface le répertoire de pdf provisoire $expref = dol_sanitizeFileName($this->ref); @@ -605,7 +608,7 @@ class Expedition extends CommonObject $this->db->rollback(); return -3; } - } + } else { $this->db->rollback(); @@ -738,13 +741,13 @@ class Expedition extends CommonObject // Charge tableau des id de société socids $socids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE client = 1"; $sql.= " AND entity = ".$conf->entity; $sql.= " LIMIT 10"; - + $resql = $this->db->query($sql); if ($resql) { @@ -761,12 +764,12 @@ class Expedition extends CommonObject // Charge tableau des produits prodids $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE envente = 1"; $sql.= " AND entity = ".$conf->entity; - + $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 79b3dfbbe6e..30cf3e6fdcc 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -139,7 +139,7 @@ if ($_GET["action"] == 'create_delivery' && $conf->livraison_bon->enabled && $us } } -if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->valider) +if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $user->rights->expedition->valider) { $expedition = new Expedition($db); $expedition->fetch($_GET["id"]); @@ -147,7 +147,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user-> //$expedition->PdfWrite(); } -if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') +if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') { if ($user->rights->expedition->supprimer ) { @@ -554,7 +554,7 @@ else */ if ($_GET["action"] == 'delete') { - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$expedition->ref),'confirm_delete'); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$expedition->ref),'confirm_delete','',0,1); if ($ret == 'html') print '
'; } @@ -564,7 +564,7 @@ else */ if ($_GET["action"] == 'valid') { - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),$langs->trans("ConfirmValidateSending",$expedition->ref),'confirm_valid'); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),$langs->trans("ConfirmValidateSending",$expedition->ref),'confirm_valid','',0,1); if ($ret == 'html') print '
'; } /* @@ -573,7 +573,7 @@ else */ if ($_GET["action"] == 'annuler') { - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$expedition->ref),'confirm_cancel'); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$expedition->ref),'confirm_cancel','',0,1); if ($ret == 'html') print '
'; } @@ -812,29 +812,26 @@ else { print '
'; - if (! eregi('^(valid|delete)',$_REQUEST["action"])) + if ($expedition->statut == 0 && $num_prod > 0) { - if ($expedition->statut == 0 && $num_prod > 0) + if ($user->rights->expedition->valider) { - if ($user->rights->expedition->valider) - { - print ''.$langs->trans("Validate").''; - } - else - { - print ''.$langs->trans("Validate").''; - } + print ''.$langs->trans("Validate").''; } + else + { + print ''.$langs->trans("Validate").''; + } + } - if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && !$expedition->livraison_id) - { - print ''.$langs->trans("DeliveryOrder").''; - } + if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && !$expedition->livraison_id) + { + print ''.$langs->trans("DeliveryOrder").''; + } - if ($user->rights->expedition->supprimer) - { - print ''.$langs->trans("Delete").''; - } + if ($user->rights->expedition->supprimer) + { + print ''.$langs->trans("Delete").''; } print '
'; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index c79687f4d44..5b569f844ee 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -506,7 +506,7 @@ class Facture extends CommonObject function fetch($rowid,$ref='') { global $conf; - + $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql.= ','.$this->db->pdate('f.datef').' as df'; $sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr'; @@ -1181,7 +1181,7 @@ class Facture extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql.= ' SET fk_facture = NULL'; $sql.= ' WHERE fk_facture = '.$this->id; - + $resql=$this->db->query($sql); if ($resql) { @@ -1223,111 +1223,149 @@ class Facture extends CommonObject { global $conf,$langs; - $error = 0; - if ($this->brouillon) + $error=0; + + // Protection + if (! $this->brouillon) { - $this->db->begin(); + dol_syslog("Facture::valid no draft status", LOG_WARNING); + return 0; + } - $this->fetch_client(); - $this->fetch_lines(); + if (! $user->rights->commande->valider) + { + $this->error='Permission denied'; + dol_syslog("Expedition::valid ".$this->error, LOG_ERR); + return -1; + } - // Verification paramètres - if ($this->type == 1) // si facture de remplacement + $this->db->begin(); + + $this->fetch_client(); + $this->fetch_lines(); + + // Check parameters + if ($this->type == 1) // si facture de remplacement + { + // Controle que facture source connue + if ($this->fk_facture_source <= 0) { - // Controle que facture source connue - if ($this->fk_facture_source <= 0) - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("InvoiceReplacement")); - $this->db->rollback(); - return -10; - } - - // Charge la facture source a remplacer - $facreplaced=new Facture($this->db); - $result=$facreplaced->fetch($this->fk_facture_source); - if ($result <= 0) - { - $this->error=$langs->trans("ErrorBadInvoice"); - $this->db->rollback(); - return -11; - } - - // Controle que facture source non deja remplacee par une autre - $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); - if ($idreplacement && $idreplacement != $this->id) - { - $facreplacement=new Facture($this->db); - $facreplacement->fetch($idreplacement); - $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced",$facreplaced->ref,$facreplacement->ref); - $this->db->rollback(); - return -12; - } - - $result=$facreplaced->set_canceled($user,'replaced',''); - if ($result < 0) - { - $this->error=$facreplaced->error." sql=".$sql; - $this->db->rollback(); - return -13; - } + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("InvoiceReplacement")); + $this->db->rollback(); + return -10; } - - // on vérifie si la facture est en numérotation provisoire - $facref = substr($this->ref, 1, 4); - - if ($force_number) + // Charge la facture source a remplacer + $facreplaced=new Facture($this->db); + $result=$facreplaced->fetch($this->fk_facture_source); + if ($result <= 0) { - $numfa = $force_number; - } - else if ($facref == 'PROV') - { - $savdate=$this->date; - if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date - { - $this->date=gmmktime(); - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - } - $numfa = $this->getNextNumRef($this->client); - } - else - { - $numfa = $this->ref; + $this->error=$langs->trans("ErrorBadInvoice"); + $this->db->rollback(); + return -11; } - $this->update_price(); + // Controle que facture source non deja remplacee par une autre + $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); + if ($idreplacement && $idreplacement != $this->id) + { + $facreplacement=new Facture($this->db); + $facreplacement->fetch($idreplacement); + $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced",$facreplaced->ref,$facreplacement->ref); + $this->db->rollback(); + return -12; + } - // Validation de la facture - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET facnumber='".$numfa."', fk_statut = 1, fk_user_valid = ".$user->id; + $result=$facreplaced->set_canceled($user,'replaced',''); + if ($result < 0) + { + $this->error=$facreplaced->error." sql=".$sql; + $this->db->rollback(); + return -13; + } + } + + // Define new ref + if ($force_number) + { + $num = $force_number; + } + else if (eregi('^\(PROV', $this->ref) || eregi('^PROV', $this->ref)) + { if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date { - $sql.= ', datef='.$this->db->idate($this->date); - $sql.= ', date_lim_reglement='.$this->db->idate($this->date_lim_reglement); + $this->date=gmmktime(); + $this->date_lim_reglement=$this->calculate_date_lim_reglement(); } - $sql.= ' WHERE rowid = '.$this->id; + $num = $this->getNextNumRef($this->client); + } + else + { + $num = $this->ref; + } - dol_syslog("Facture::set_valid() sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) + $this->update_price(); + + // Validate + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; + $sql.= " SET facnumber='".$num."', fk_statut = 1, fk_user_valid = ".$user->id; + if ($conf->global->FAC_FORCE_DATE_VALIDATION) // If option enabled, we force invoice date + { + $sql.= ', datef='.$this->db->idate($this->date); + $sql.= ', date_lim_reglement='.$this->db->idate($this->date_lim_reglement); + } + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog("Facture::set_valid() sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + dol_syslog("Facture::set_valid() Echec update - 10 - sql=".$sql, LOG_ERR); + dol_print_error($this->db); + $error++; + } + + // On vérifie si la facture était une provisoire + if (! $error && (eregi('^\(PROV', $this->ref) || eregi('^PROV', $this->ref))) + { + // La vérif qu'une remise n'est pas utilisée 2 fois est faite au moment de l'insertion de ligne + } + + if (! $error) + { + // Define third party as a customer + $result=$this->client->set_as_client(); + + // Si activé on décrémente le produit principal et ses composants à la validation de facture + if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) { - $this->facnumber=$numfa; - } - else - { - dol_syslog("Facture::set_valid() Echec update - 10 - sql=".$sql, LOG_DEBUG); - dol_print_error($this->db); - $error++; + require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); + + // Loop on each line + for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) + { + if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0) + { + $mouvP = new MouvementStock($this->db); + // We decrease stock for product + $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP + $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); + if ($result < 0) { $error++; } + } + } } + } - - // On vérifie si la facture était une provisoire - if ($facref == 'PROV') + if (! $error) + { + // Rename directory if dir was a temporary ref + if (eregi('^\(PROV', $this->ref) || eregi('^PROV', $this->ref)) { - // On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref) + // On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref) // afin de ne pas perdre les fichiers attachés $facref = dol_sanitizeFileName($this->ref); - $snumfa = dol_sanitizeFileName($numfa); + $snumfa = dol_sanitizeFileName($num); $dirsource = $conf->facture->dir_output.'/'.$facref; $dirdest = $conf->facture->dir_output.'/'.$snumfa; if (file_exists($dirsource)) @@ -1342,65 +1380,38 @@ class Facture extends CommonObject } } } + } - // On vérifie si la facture était une provisoire - if (! $error && $facref == 'PROV') - { - // La vérif qu'une remise n'est pas utilisée 2 fois est faite au moment de l'insertion de ligne - } + // Set new ref + if (! $error) + { + $this->ref = $num; + $this->facnumber=$num; + } - if (! $error) - { - // Define third party as a customer - $result=$this->client->set_as_client(); + $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0); - // Si activé on décrémente le produit principal et ses composants à la validation de facture - if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) - { - require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); + // Trigger calls + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } - // Loop on each line - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) - { - if ($this->lignes[$i]->fk_product && $this->lignes[$i]->product_type == 0) - { - $mouvP = new MouvementStock($this->db); - // We decrease stock for product - $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot - // TODO Add price of product in method or '' to update PMP - $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); - } - } - } - - $this->ref = $numfa; - - $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0); - - if ($result > 0) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - - } - else - { - $this->db->rollback(); - return -1; - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; } } @@ -1713,7 +1724,7 @@ class Facture extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql.= ' SET fk_facture_line = NULL'; $sql.= ' WHERE fk_facture_line = '.$rowid; - + dol_syslog("Facture::Deleteline sql=".$sql); $result = $this->db->query($sql); if (! $result) @@ -1727,7 +1738,7 @@ class Facture extends CommonObject // Efface ligne de facture $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet'; $sql.= ' WHERE rowid = '.$rowid; - + dol_syslog("Facture::Deleteline sql=".$sql); $result = $this->db->query($sql); if (! $result) @@ -2416,7 +2427,7 @@ class Facture extends CommonObject function list_qualified_avoir_invoices($socid=0) { global $conf; - + $return = array(); $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, pf.fk_paiement"; @@ -2480,7 +2491,7 @@ class Facture extends CommonObject $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql.= ' WHERE fk_facture = '.$this->id; $sql.= ' AND traite = 0'; - + if ( $this->db->query( $sql) ) { $row = $this->db->fetch_row(); @@ -2626,13 +2637,13 @@ class Facture extends CommonObject // Charge tableau des id de société socids $socids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE client = 1"; $sql.= " AND entity = ".$conf->entity; $sql.= " LIMIT 10"; - + $resql = $this->db->query($sql); if ($resql) { @@ -2649,12 +2660,12 @@ class Facture extends CommonObject // Charge tableau des produits prodids $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE envente = 1"; $sql.= " AND entity = ".$conf->entity; - + $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 074a555a40b..8d3e08afa1b 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -19,10 +19,10 @@ */ /** - \file htdocs/product/stock/mouvement.php - \ingroup stock - \brief Page liste des mouvements de stocks - \version $Id$ + * \file htdocs/product/stock/mouvement.php + * \ingroup stock + * \brief Page liste des mouvements de stocks + * \version $Id$ */ require("./pre.inc.php"); @@ -49,7 +49,7 @@ $form=new Form($db); $sql = "SELECT p.rowid, p.label as produit,"; $sql.= " s.label as stock, s.rowid as entrepot_id,"; -$sql.= " m.value, ".$db->pdate("m.datem")." as datem"; +$sql.= " m.rowid as mid, m.value, m.datem"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as s"; $sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; @@ -121,7 +121,7 @@ if ($resql) $head[$h][1] = $langs->trans("Users"); $h++; } - + $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; $head[$h][1] = $langs->trans("Info"); $h++; @@ -134,7 +134,7 @@ if ($resql) print ''.$langs->trans("Ref").''; print $form->showrefnav($entrepot,'id','',1,'rowid','libelle'); print ''; - + print ''.$langs->trans("LocationSummary").''.$entrepot->lieu.''; // Statut @@ -152,6 +152,7 @@ if ($resql) print ''; print ""; + //print_liste_field_titre($langs->trans("Id"),"mouvement.php", "m.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),"mouvement.php", "m.datem","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Product"),"mouvement.php", "p.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Warehouse"),"mouvement.php", "s.label","",$param,"",$sortfield,$sortorder); @@ -164,13 +165,19 @@ if ($resql) $objp = $db->fetch_object($resql); $var=!$var; print ""; - print ''; + // Id movement + //print ''; // This is primary not movement id + // Date + print ''; + // Product print "\n"; + // Warehouse print '\n"; + // Value print '';
'.dol_print_date($objp->datem,'dayhour').''.$objp->mid.''.dol_print_date($db->jdate($objp->datem),'dayhour').'rowid\">"; print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit; print "'; print img_object($langs->trans("ShowWarehouse"),"stock").' '.$objp->stock; print "'; if ($objp->value > 0) print '+'; print $objp->value.'