From 55552d87d7657884d8b9a5122400f6cb1a65e9b1 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 1 Sep 2008 13:22:36 +0000 Subject: [PATCH] Add tracking url --- htdocs/expedition/expedition.class.php | 947 +++++++++++++------------ htdocs/expedition/fiche.php | 807 +++++++++++---------- 2 files changed, 905 insertions(+), 849 deletions(-) diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index abedd50084e..e6892678f5a 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -15,8 +15,7 @@ * GNU General Public License for more details. * * 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. + * along with this program. If not, see . */ /** @@ -69,448 +68,458 @@ class Expedition extends CommonObject $this->products = array(); } - /** - * \brief Créé expédition en base - * \param user Objet du user qui cré - * \return int <0 si erreur, id expédition créée si ok - */ - function create($user) - { - global $conf; + /** + * \brief Créé expédition en base + * \param user Objet du user qui cré + * \return int <0 si erreur, id expédition créée si ok + */ + function create($user) + { + global $conf; - require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; - $error = 0; - /* On positionne en mode brouillon l'expedition */ - $this->brouillon = 1; + require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; + $error = 0; + /* On positionne en mode brouillon l'expedition */ + $this->brouillon = 1; + + $this->user = $user; + + $this->expedition_method = sanitize_string($this->expedition_method); + $this->tracking_number = sanitize_string($this->tracking_number); - $this->user = $user; + $this->db->begin(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition"; + $sql.= ", fk_soc, fk_expedition_methode, tracking_number"; + $sql.= ")"; + $sql.= " VALUES ('(PROV)', ".$this->db->idate(mktime()).", $user->id, ".$this->db->idate($this->date_expedition); + $sql.= ", ".$this->socid.",'". $this->expedition_method_id."','". $this->tracking_number."'"; + $sql.= ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); + + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; + if ($this->db->query($sql)) + { + // Insertion des lignes + for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) + { + if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0) + { + $error++; + } + } - $this->db->begin(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition"; - $sql.= ", fk_soc"; - $sql.= ")"; - $sql.= " VALUES ('(PROV)', ".$this->db->idate(mktime()).", $user->id, ".$this->db->idate($this->date_expedition); - $sql.= ", ".$this->socid; - $sql.= ")"; + if (! $error && $this->id && $this->origin_id) + { + 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 = "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++; + } + + //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++; + } + } + } + + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $error++; + $this->error=$this->db->lasterror()." - sql=$sql"; + $this->db->rollback(); + return -3; + } + } + else + { + $error++; + $this->error=$this->db->lasterror()." - sql=$sql"; + $this->db->rollback(); + return -2; + } + } + else + { + $error++; + $this->error=$this->db->error()." - sql=$sql"; + $this->db->rollback(); + return -1; + } + } + + /** + * + * + */ + function create_line($entrepot_id, $origin_line_id, $qty) + { + $error = 0; + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)"; + $sql .= " VALUES (".$this->id.", ".($entrepot_id?$entrepot_id:'null').", ".$origin_line_id.", ".$qty.")"; + //print 'x'.$sql; + if (! $this->db->query($sql)) + { + $error++; + } + + if (! $error) return 1; + else return -1; + } + + /** + * \brief Lit une expedition + * \param id + */ + function fetch ($id) + { + global $conf; + + $sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut"; + $sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison"; + $sql.= ", e.fk_expedition_methode, e.tracking_number"; + if ($conf->commande->enabled) + { + $sql.=", ce.fk_commande as origin_id"; + } + else + { + $sql.=", pe.fk_propal as origin_id"; + } + if ($conf->livraison_bon->enabled) $sql.=", l.rowid as livraison_id"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; + if ($conf->commande->enabled) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; + } + else + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_exp as pe ON e.rowid = pe.fk_expedition"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as p ON pe.fk_propal = p.rowid"; + } + if ($conf->livraison_bon->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition"; + $sql.= " WHERE e.rowid = ".$id; + + $result = $this->db->query($sql) ; + + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->socid = $obj->socid; + $this->statut = $obj->fk_statut; + $this->origin_id = $obj->origin_id; + $this->livraison_id = $obj->livraison_id; + $this->user_author_id = $obj->fk_user_author; + $this->date = $obj->date_expedition; + $this->adresse_livraison_id = $obj->fk_adresse_livraison; + $this->modelpdf = $obj->model_pdf; + $this->expedition_method_id = $obj->fk_expedition_methode; + $this->tracking_number = $obj->tracking_number; + + if (strlen($this->tracking_number) && strlen($this->expedition_method_id)) { + $this->GetUrlTrackingStatus(); + } + + if ($conf->commande->enabled) + { + $this->origin = "commande"; + } + else + { + $this->origin = "propal"; + } + + $this->db->free($result); + if ($this->statut == 0) $this->brouillon = 1; + + $this->lignes = array(); + + $file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id,2) . "/" . $this->id.".pdf"; + $this->pdf_filename = $file; + + /* + * Lignes + */ + $result=$this->fetch_lines(); + if ($result < 0) + { + return -3; + } + + return 1; + } + else + { + dolibarr_syslog('Expedition::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql); + $this->error='Delivery with id '.$rowid.' not found sql='.$sql; + return -2; + } + } + else + { + dolibarr_syslog('Expedition::Fetch Error rowid='.$rowid.' Erreur dans fetch de l\'expedition'); + $this->error=$this->db->error(); + return -1; + } + } + + /** + * \brief Valide l'expedition, et met a jour le stock si stock géré + * \param user Objet de l'utilisateur qui valide + * \return int + */ + function valid($user) + { + global $conf; + + require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; + + dolibarr_syslog("Expedition::valid"); + + $this->db->begin(); + + $error = 0; + $provref = $this->ref; + + if ($user->rights->expedition->valider) + { + $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 FROM ".MAIN_DB_PREFIX."expedition where ref='".$this->ref."' AND fk_statut <> '0'"; + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num > 0) + { + dolibarr_syslog("Expedition::valid already validated", LOG_WARNING); + $this->db->rollback(); + return 0; + } + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; + $sql.= " SET ref='".$this->ref."', fk_statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid = ".$user->id; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + dolibarr_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, ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql.= " WHERE ed.fk_expedition = $this->id AND cd.rowid = ed.fk_origin_line"; + + dolibarr_syslog("Expedition::valid select details sql=".$sql); $resql=$this->db->query($sql); if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); - - $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; - if ($this->db->query($sql)) - { - // Insertion des lignes - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) - { - if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0) - { - $error++; - } - } - - if (! $error && $this->id && $this->origin_id) - { - 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 = "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++; - } - - //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++; - } - } - } - - if (! $error) - { - $this->db->commit(); - return $this->id; - } - else - { - $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; - $this->db->rollback(); - return -3; - } - } - else - { - $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; - $this->db->rollback(); - return -2; - } - } + { + $num = $this->db->num_rows($resql); + $i=0; + while($i < $num) + { + dolibarr_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"; + dolibarr_syslog("Expedition::valid ".$this->error); + return -3; + } + + $i++; + } + + } else - { - $error++; - $this->error=$this->db->error()." - sql=$sql"; - $this->db->rollback(); - return -1; - } - } - - /** - * - * - */ - function create_line($entrepot_id, $origin_line_id, $qty) - { - $error = 0; - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)"; - $sql .= " VALUES (".$this->id.", ".($entrepot_id?$entrepot_id:'null').", ".$origin_line_id.", ".$qty.")"; - //print 'x'.$sql; - if (! $this->db->query($sql)) - { - $error++; - } - - if (! $error) return 1; - else return -1; - } - - /** - * \brief Lit une expedition - * \param id - */ - function fetch ($id) - { - global $conf; - - $sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut"; - $sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison"; - if ($conf->commande->enabled) - { - $sql.=", ce.fk_commande as origin_id"; - } - else - { - $sql.=", pe.fk_propal as origin_id"; - } - if ($conf->livraison_bon->enabled) $sql.=", l.rowid as livraison_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - if ($conf->commande->enabled) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; - } - else - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_exp as pe ON e.rowid = pe.fk_expedition"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as p ON pe.fk_propal = p.rowid"; - } - if ($conf->livraison_bon->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition"; - $sql.= " WHERE e.rowid = ".$id; - - $result = $this->db->query($sql) ; - - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->socid = $obj->socid; - $this->statut = $obj->fk_statut; - $this->origin_id = $obj->origin_id; - $this->livraison_id = $obj->livraison_id; - $this->user_author_id = $obj->fk_user_author; - $this->date = $obj->date_expedition; - $this->adresse_livraison_id = $obj->fk_adresse_livraison; - $this->modelpdf = $obj->model_pdf; - - if ($conf->commande->enabled) - { - $this->origin = "commande"; - } - else - { - $this->origin = "propal"; - } - - $this->db->free($result); - - if ($this->statut == 0) $this->brouillon = 1; - - $this->lignes = array(); - - $file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id,2) . "/" . $this->id.".pdf"; - $this->pdf_filename = $file; - - /* - * Lignes - */ - $result=$this->fetch_lines(); - if ($result < 0) - { - return -3; - } - - return 1; - } - else - { - dolibarr_syslog('Expedition::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql); - $this->error='Delivery with id '.$rowid.' not found sql='.$sql; - return -2; - } - } - else - { - dolibarr_syslog('Expedition::Fetch Error rowid='.$rowid.' Erreur dans fetch de l\'expedition'); - $this->error=$this->db->error(); - return -1; - } - } - - /** - * \brief Valide l'expedition, et met a jour le stock si stock géré - * \param user Objet de l'utilisateur qui valide - * \return int - */ - function valid($user) - { - global $conf; - - require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; - - dolibarr_syslog("Expedition::valid"); - - $this->db->begin(); - - $error = 0; - $provref = $this->ref; - - if ($user->rights->expedition->valider) - { - $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 FROM ".MAIN_DB_PREFIX."expedition where ref='".$this->ref."' AND fk_statut <> '0'"; - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num > 0) - { - dolibarr_syslog("Expedition::valid already validated", LOG_WARNING); - $this->db->rollback(); - return 0; - } - } - - $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; - $sql.= " SET ref='".$this->ref."', fk_statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - dolibarr_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, ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= " WHERE ed.fk_expedition = $this->id AND cd.rowid = ed.fk_origin_line"; - - dolibarr_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) - { - dolibarr_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"; - dolibarr_syslog("Expedition::valid ".$this->error); - return -3; - } - - $i++; - } - - } - else - { - $this->db->rollback(); - $this->error=$this->db->error()." - sql=$sql"; - dolibarr_syslog("Expedition::valid ".$this->error); - return -2; - } - } - - // On efface le répertoire de pdf provisoire - $expeditionref = sanitize_string($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(); - dolibarr_syslog("Expedition::valid ".$this->error); - return -1; - } - } - else - { - $this->db->rollback(); - $this->error="Non autorise"; - dolibarr_syslog("Expedition::valid ".$this->error); - return -1; - } - - $this->db->commit(); - //dolibarr_syslog("expedition.class.php::valid commit"); - return 1; - } - - - /** - * \brief Crée un bon de livraison à partir de l'expédition - * \param user Utilisateur - * \return int <0 si ko, >=0 si ok - */ - function create_delivery($user) - { - global $conf; - - if ($conf->livraison_bon->enabled) - { - if ($this->statut == 1) - { - // Expédition validée - include_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php"); - $livraison = new Livraison($this->db); - $result=$livraison->create_from_sending($user, $this->id); - if ($result > 0) - { - return $result; - } - else - { - $this->error=$livraison->error; - return $result; - } - } - else return 0; - } - else return 0; - } - - /** - * Ajoute une ligne - * - */ - function addline( $entrepot_id, $id, $qty ) - { - $num = sizeof($this->lignes); - $ligne = new ExpeditionLigne($this->db); - - $ligne->entrepot_id = $entrepot_id; - $ligne->origin_line_id = $id; - $ligne->qty = $qty; - - $this->lignes[$num] = $ligne; - } - - /** - * - * - */ - function delete_line($idligne) - { - if ($this->statut == 0) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne"; - - if ($this->db->query($sql) ) - { - $this->update_price(); - return 1; - } - else - { - return 0; - } - } - } - - /** - * Supprime la fiche - * - */ - function delete() - { - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = ".$this->id; - if ( $this->db->query($sql) ) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id; - if ( $this->db->query($sql) ) - { - $this->db->commit(); - + { + $this->db->rollback(); + $this->error=$this->db->error()." - sql=$sql"; + dolibarr_syslog("Expedition::valid ".$this->error); + return -2; + } + } + + // On efface le répertoire de pdf provisoire + $expeditionref = sanitize_string($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(); + dolibarr_syslog("Expedition::valid ".$this->error); + return -1; + } + } + else + { + $this->db->rollback(); + $this->error="Non autorise"; + dolibarr_syslog("Expedition::valid ".$this->error); + return -1; + } + + $this->db->commit(); + //dolibarr_syslog("expedition.class.php::valid commit"); + return 1; + } + + + /** + * \brief Crée un bon de livraison à partir de l'expédition + * \param user Utilisateur + * \return int <0 si ko, >=0 si ok + */ + function create_delivery($user) + { + global $conf; + + if ($conf->livraison_bon->enabled) + { + if ($this->statut == 1) + { + // Expédition validée + include_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php"); + $livraison = new Livraison($this->db); + $result=$livraison->create_from_sending($user, $this->id); + if ($result > 0) + { + return $result; + } + else + { + $this->error=$livraison->error; + return $result; + } + } + else return 0; + } + else return 0; + } + + /** + * Ajoute une ligne + * + */ + function addline( $entrepot_id, $id, $qty ) + { + $num = sizeof($this->lignes); + $ligne = new ExpeditionLigne($this->db); + + $ligne->entrepot_id = $entrepot_id; + $ligne->origin_line_id = $id; + $ligne->qty = $qty; + + $this->lignes[$num] = $ligne; + } + + /** + * + * + */ + function delete_line($idligne) + { + if ($this->statut == 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne"; + + if ($this->db->query($sql) ) + { + $this->update_price(); + return 1; + } + else + { + return 0; + } + } + } + + /** + * Supprime la fiche + * + */ + function delete() + { + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = ".$this->id; + if ( $this->db->query($sql) ) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id; + if ( $this->db->query($sql) ) + { + $this->db->commit(); + // On efface le répertoire de pdf provisoire $expref = sanitize_string($this->ref); if ($conf->expedition->dir_output) @@ -733,26 +742,54 @@ class Expedition extends CommonObject $xnbp++; } } - /* - Fecth deliveries method and return an array - */ - function fetch_delivery_methods() - { - $meths = array(); + /* + Fetch deliveries method and return an array + */ + function fetch_delivery_methods() + { + $meths = array(); - $sql = "SELECT em.rowid, em.libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em"; - $sql.= " WHERE em.statut = 1"; + $sql = "SELECT em.rowid, em.libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em"; + $sql.= " WHERE em.statut = 1 ORDER BY em.libelle ASC"; + + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj = $this->db->fetch_object($resql)) + { + $this->meths[$obj->rowid] = $obj->libelle; + } + } + } + /* + Get tracking url status + */ + function GetUrlTrackingStatus() + { + $sql = "SELECT em.code"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em"; + $sql.= " WHERE em.rowid = ".$this->expedition_method_id; + + $resql = $this->db->query($sql); + if ($resql) + { + if ($obj = $this->db->fetch_object($resql)) + { + $code = $obj->code; + } + } - $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { - $this->meths[$obj->rowid] = $obj->libelle; - } - } - } + if ($code) { + $classe = "methode_expedition_".strtolower($code); + include "./mods/methode_expedition_".strtolower($code).".modules.php"; + $obj = new $classe; + $url = $obj->provider_url_status($this->tracking_number); + $this->tracking_url = sprintf('url',$url,$url); + } else { + $this->tracking_url = ''; + } + } } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index e8b51db79d5..e81675c52ae 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2003-2008 Rodolphe Quiedeville * Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2005-2008 Régis Houssin @@ -15,17 +15,16 @@ * GNU General Public License for more details. * * 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. + * along with this program. If not, see . */ // Code identique a /expedition/commande.php /** - \file htdocs/expedition/fiche.php - \ingroup expedition - \brief Fiche descriptive d'une expedition - \version $Id$ + \file htdocs/expedition/fiche.php + \ingroup expedition + \brief Fiche descriptive d'une expedition + \version $Id$ */ require("./pre.inc.php"); @@ -48,7 +47,7 @@ if (! $user->rights->expedition->lire) accessforbidden(); -// Sécurité accés client +// Security customer access if ($user->societe_id > 0) { $action = ''; @@ -64,7 +63,7 @@ $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id o if ($_POST["action"] == 'add') { - $db->begin(); + $db->begin(); // Creation de l'objet expedition $expedition = new Expedition($db); @@ -80,9 +79,10 @@ if ($_POST["action"] == 'add') $object = new $class($db); $object->fetch($expedition->origin_id); //$object->fetch_lines(); - $expedition->socid = $object->socid; + $expedition->expedition_method_id = $_POST["expedition_method_id"]; + $expedition->tracking_number = $_POST["tracking_number"]; for ($i = 0 ; $i < sizeof($object->lignes) ; $i++) { @@ -117,18 +117,18 @@ if ($_POST["action"] == 'add') */ if ($_GET["action"] == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $result = $expedition->create_delivery($user); - if ($result > 0) - { - Header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); - exit; - } - else - { - $mesg=$expedition->error; - } + $expedition = new Expedition($db); + $expedition->fetch($_GET["id"]); + $result = $expedition->create_delivery($user); + if ($result > 0) + { + Header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); + exit; + } + else + { + $mesg=$expedition->error; + } } if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->valider) @@ -196,421 +196,440 @@ $formfile = new FormFile($db); if ($_GET["action"] == 'create') { - print_titre($langs->trans("CreateASending")); - if (! $origin) - { - $mesg='
'.$langs->trans("ErrorBadParameters").'
'; - } - - if ($mesg) - { - print $mesg.'
'; - } + $expe = new Expedition($db); - if ($origin) + print_titre($langs->trans("CreateASending")); + if (! $origin) + { + $mesg='
'.$langs->trans("ErrorBadParameters").'
'; + } + + if ($mesg) + { + print $mesg.'
'; + } + + if ($origin) + { + $class = ucfirst($origin); + + $object = new $class($db); + $object->loadExpeditions(); + + if ( $object->fetch($origin_id)) { - $class = ucfirst($origin); - - $object = new $class($db); - $object->loadExpeditions(); - - if ( $object->fetch($origin_id)) + $soc = new Societe($db); + $soc->fetch($object->socid); + + $author = new User($db); + $author->id = $object->user_author_id; + $author->fetch(); + + if ($conf->stock->enabled) $entrepot = new Entrepot($db); + + /* + * Document source + */ + print '
'; + print ''; + print ''; + print ''; + if ($_GET["entrepot_id"]) + { + print ''; + } + + print ''; + + // Ref + print ''; + print "\n"; + + // Ref client + print ''; + print ''; + + // Tiers + print ''; + print ''; + print ''; + + // Date + print ""; + print '\n"; + + // Entrepot (si forcé) + if ($conf->stock->enabled && $_GET["entrepot_id"]) + { + print ''; + print ''; + } + + if ($object->note && ! $user->societe_id) + { + print '"; + } + + // Delivery method + print ""; + print '\n"; + // Tracking number + print ""; + print '\n"; + print "
'; + if ($conf->commande->enabled) + { + print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; + } + else + { + print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; + } + print '
'; + print $langs->trans('RefCustomer').''; + print $object->ref_client; + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
".$langs->trans("Date")."'.dolibarr_print_date($object->date,"day")."
'.$langs->trans("Warehouse").''; + $ents = $entrepot->list_array(); + print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; + print '
'.$langs->trans("NotePrivate").': '.nl2br($object->note)."
".$langs->trans("DeliveryMethod")."'; + + $expe->fetch_delivery_methods(); + $html->select_array("expedition_method_id",$expe->meths); + print "
".$langs->trans("TrackingNumber")."'; + print ''; + print "
"; + + /* + * Lignes de commandes + * + */ + print '
'; + + //$lignes = $object->fetch_lines(1); + $numAsked = sizeof($object->lignes); + + /* Lecture des expeditions déjà effectuées */ + $object->loadExpeditions(); + + if ($numAsked) + { + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->stock->enabled) { - $soc = new Societe($db); - $soc->fetch($object->socid); - - $author = new User($db); - $author->id = $object->user_author_id; - $author->fetch(); - - if ($conf->stock->enabled) $entrepot = new Entrepot($db); - - /* - * Document source - */ - print ''; - print ''; - print ''; - print ''; - if ($_GET["entrepot_id"]) - { - print ''; - } - - print '
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").'
'; - - // Ref - print ''; - print "\n"; - - // Ref client - print ''; - print ''; - - // Tiers - print ''; - print ''; - print ''; - - // Date - print ""; - print '\n"; - - // Entrepot (si forcé) - if ($conf->stock->enabled && $_GET["entrepot_id"]) - { - print ''; - print ''; - } - - if ($object->note && ! $user->societe_id) - { - print '"; - } - - print "
'; - if ($conf->commande->enabled) - { - print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; - } - else - { - print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; - } - print '
'; - print $langs->trans('RefCustomer').''; - print $object->ref_client; - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
".$langs->trans("Date")."'.dolibarr_print_date($object->date,"day")."
'.$langs->trans("Warehouse").''; - $ents = $entrepot->list_array(); - print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; - print '
'.$langs->trans("NotePrivate").': '.nl2br($object->note)."
"; - - /* - * Lignes de commandes - * - */ - print '
'; - - //$lignes = $object->fetch_lines(1); - $numAsked = sizeof($object->lignes); - - /* Lecture des expeditions déjà effectuées */ - $object->loadExpeditions(); - - if ($numAsked) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->stock->enabled) - { - if ($_GET["entrepot_id"]) - { - print ''; - } - else - { - print ''; - } - } - print "\n"; - } - - $var=true; - $indiceAsked = 0; - while ($indiceAsked < $numAsked) - { - $ligne = $object->lignes[$indiceAsked]; - $var=!$var; - print "\n"; - if ($ligne->fk_product > 0) - { - $product = new Product($db); - $product->fetch($ligne->fk_product); - - print ''; - } - else - { - print "\n"; - } - - print ''; - + if ($_GET["entrepot_id"]) + { + print ''; + } + else + { + print ''; + } + } + print "\n"; + } + + $var=true; + $indiceAsked = 0; + while ($indiceAsked < $numAsked) + { + $ligne = $object->lignes[$indiceAsked]; + $var=!$var; + print "\n"; + if ($ligne->fk_product > 0) + { + $product = new Product($db); + $product->fetch($ligne->fk_product); + + print ''; + } + else + { + print "\n"; + } + + print ''; + + print ''; + + $quantityAsked = $ligne->qty; + $quantityToBeDelivered = $quantityAsked - $quantityDelivered; + + if ($conf->stock->enabled) + { + $defaultqty=0; + if ($_GET["entrepot_id"]) + { + $stock = $product->stock_entrepot[$_GET["entrepot_id"]]; + $stock+=0; // Convertit en numérique + $defaultqty=min($quantityToBeDelivered, $stock); + if ($defaultqty < 0) $defaultqty=0; + } + + // Quantité à livrer print ''; - - $quantityAsked = $ligne->qty; - $quantityToBeDelivered = $quantityAsked - $quantityDelivered; - - if ($conf->stock->enabled) - { - $defaultqty=0; - if ($_GET["entrepot_id"]) - { - $stock = $product->stock_entrepot[$_GET["entrepot_id"]]; - $stock+=0; // Convertit en numérique - $defaultqty=min($quantityToBeDelivered, $stock); - if ($defaultqty < 0) $defaultqty=0; - } - - // Quantité à livrer - print ''; - - // Stock - if ($_GET["entrepot_id"]) - { - print ''; - } - else - { - $array=array(); - - $sql = "SELECT e.rowid, e.label, ps.reel"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e"; - $sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'"; - $result = $db->query($sql) ; - if ($result) - { - $num = $db->num_rows($result); - $i=0; - if ($num > 0) - { - while ($i < $num) - { - $obj = $db->fetch_object($result); - $array[$obj->rowid] = $obj->label.' ('.$obj->reel.')'; - $i++; - } - } - $db->free($result); - } - else - { - $this->error=$db->error(); - return -1; - } - - print ''; - } - } + + // Stock + if ($_GET["entrepot_id"]) + { + print ''; + } else - { - // Quantité à livrer - print ''; - } - - print "\n"; - - $indiceAsked++; - } - + { + $array=array(); + + $sql = "SELECT e.rowid, e.label, ps.reel"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e"; + $sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'"; + $result = $db->query($sql) ; + if ($result) + { + $num = $db->num_rows($result); + $i=0; + if ($num > 0) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + $array[$obj->rowid] = $obj->label.' ('.$obj->reel.')'; + $i++; + } + } + $db->free($result); + } + else + { + $this->error=$db->error(); + return -1; + } + + print ''; + } + } + else + { + // Quantité à livrer + print ''; + } + + print "\n"; + + $indiceAsked++; + } + /* - * - */ - + * + */ + print ''; print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").''.$langs->trans("Stock").''.$langs->trans("Warehouse").'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($ligne->description) print nl2br($ligne->description); - print '".nl2br($ligne->description)."'.$ligne->qty.''.$langs->trans("Stock").''.$langs->trans("Warehouse").'
'; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($ligne->description) print nl2br($ligne->description); + print '".nl2br($ligne->description)."'.$ligne->qty.''; + $quantityDelivered = $object->expeditions[$ligne->fk_product]; + print $quantityDelivered; + print ''; - $quantityDelivered = $object->expeditions[$ligne->fk_product]; - print $quantityDelivered; + print ''; + print ''; print ''; - print ''; - print ''; - print ''.$stock; - if ($stock < $quantityToBeDelivered) - { - print ' '.img_warning($langs->trans("StockTooLow")); - } - print ''; - $html->select_array('entl'.$i,$array,'',1,0,0); - print ''.$stock; + if ($stock < $quantityToBeDelivered) + { + print ' '.img_warning($langs->trans("StockTooLow")); + } + print ''; - print ''; - print ''; - print '
'; + $html->select_array('entl'.$i,$array,'',1,0,0); + print ''; + print ''; + print ''; + print '

"; print '
'; - } - else - { - dolibarr_print_error($db); - } } + else + { + dolibarr_print_error($db); + } + } } else /* *************************************************************************** */ /* */ -/* Mode vue et edition */ +/* Edit and view mode */ /* */ /* *************************************************************************** */ { - if ($_GET["id"] > 0) - { - $expedition = New Expedition($db); - $result = $expedition->fetch($_GET["id"]); - $lignes = $expedition->lignes; - $num_prod = sizeof($lignes); - - if ($expedition->id > 0) + if ($_GET["id"] > 0) { - $object = $expedition->origin; - $expedition->fetch_object(); - - $soc = new Societe($db); - $soc->fetch($expedition->socid); - - $h=0; - $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; - $head[$h][1] = $langs->trans("SendingCard"); - $hselected = $h; - $h++; - - if ($conf->livraison_bon->enabled && $expedition->livraison_id) - { - $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$expedition->livraison_id; - $head[$h][1] = $langs->trans("DeliveryCard"); - $h++; - } - - dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")); - - if ($mesg) print $mesg; + $expedition = New Expedition($db); + $result = $expedition->fetch($_GET["id"]); + $lignes = $expedition->lignes; + $num_prod = sizeof($lignes); - /* - * Confirmation de la suppression - * - */ - if ($_GET["action"] == 'delete') + if ($expedition->id > 0) + { + $object = $expedition->origin; + $expedition->fetch_object(); + + $soc = new Societe($db); + $soc->fetch($expedition->socid); + + $h=0; + $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; + $head[$h][1] = $langs->trans("SendingCard"); + $hselected = $h; + $h++; + + if ($conf->livraison_bon->enabled && $expedition->livraison_id) + { + $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$expedition->livraison_id; + $head[$h][1] = $langs->trans("DeliveryCard"); + $h++; + } + + dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")); + + if ($mesg) print $mesg; + + /* + * Confirmation de la suppression + * + */ + if ($_GET["action"] == 'delete') { - $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('DeleteSending'),'Etes-vous sûr de vouloir supprimer cette expedition ?','confirm_delete'); - print '
'; + $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('DeleteSending'),'Etes-vous sûr de vouloir supprimer cette expedition ?','confirm_delete'); + print '
'; } - - /* - * Confirmation de la validation - * - */ - if ($_GET["action"] == 'valid') + + /* + * Confirmation de la validation + * + */ + if ($_GET["action"] == 'valid') { - $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),'Etes-vous sûr de vouloir valider cette expédition ?','confirm_valid'); - print '
'; + $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),'Etes-vous sûr de vouloir valider cette expédition ?','confirm_valid'); + print '
'; } - /* - * Confirmation de l'annulation - * - */ - if ($_GET["action"] == 'annuler') + /* + * Confirmation de l'annulation + * + */ + if ($_GET["action"] == 'annuler') { - $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('CancelSending'),'Etes-vous sûr de vouloir annuler cette commande ?','confirm_cancel'); - print '
'; + $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('CancelSending'),'Etes-vous sûr de vouloir annuler cette commande ?','confirm_cancel'); + print '
'; } - - // calcul du poids total et du volume total des produits - //TODO: ajouter conversion pour le poids et le volume et selection de l'unité de mesure la plus utilisée - $totalWeight = ''; - $totalVolume = ''; - for ($i = 0 ; $i < $num_prod ; $i++) + + // calcul du poids total et du volume total des produits + //TODO: ajouter conversion pour le poids et le volume et selection de l'unité de mesure la plus utilisée + $totalWeight = ''; + $totalVolume = ''; + for ($i = 0 ; $i < $num_prod ; $i++) { - $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped; - $weightUnit = $lignes[$i]->weight_units; - $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped; - $volumeUnit = $lignes[$i]->volume_units; + $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped; + $weightUnit = $lignes[$i]->weight_units; + $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped; + $volumeUnit = $lignes[$i]->volume_units; } - - print ''; - - // Ref - print ''; - print ''; - - // Client - print ''; - print ''; - print ""; - - // Document liée - print '
'.$langs->trans("Ref").''.$expedition->ref.'
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'; - if ($conf->commande->enabled) + + print ''; + + // Ref + print ''; + print ''; + + // Customer + print ''; + print ''; + print ""; + + // Document liée + print ''; - print '\n"; + $order=new Commande($db); + $order->fetch($expedition->$object->id); + print $langs->trans("RefOrder").''; + print '\n"; } - else + else { - $propal=new Propal($db); - $propal->fetch($livraison->origin_id); - print $langs->trans("RefProposal").''; - print '\n"; + $propal=new Propal($db); + $propal->fetch($livraison->origin_id); + print $langs->trans("RefProposal").''; + print '\n"; } - print ''; + print ''; + + // Ref client + print ''; + print '\n"; + print ''; + + // Date + print ''; + print '\n"; + print ''; + + // Poids Total + print ''; + print '\n"; + print ''; + + // Volume Total + print ''; + print '\n"; + print ''; + + // Status + print ''; + print '\n"; + print ''; + + // Tracking Number + print ''; + print '\n"; + print ''; - // Ref client - print ''; - print '\n"; - print ''; - - // Date - print ''; - print '\n"; - print ''; - - // Poids Total - print ''; - print '\n"; - print ''; - - // Volume Total - print ''; - print '\n"; - print ''; - - // Statut - print ''; - print '\n"; - print ''; - - print "
'.$langs->trans("Ref").''.$expedition->ref.'
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'; + if ($conf->commande->enabled) { - $order=new Commande($db); - $order->fetch($expedition->$object->id); - print $langs->trans("RefOrder").''; - print $order->getNomUrl(1,4); - print "'; + print $order->getNomUrl(1,4); + print "'; - print $propal->getNomUrl(1,'expedition'); - print "'; + print $propal->getNomUrl(1,'expedition'); + print "
'.$langs->trans("RefCustomer").''.$object->ref_client."
'.$langs->trans("Date").''.dolibarr_print_date($expedition->date,"day")."
'.$langs->trans("TotalWeight").''.$totalWeight.' '.measuring_units_string($weightUnit,"weight")."
'.$langs->trans("TotalVolume").''.$totalVolume.' '.measuring_units_string($volumeUnit,"volume")."
'.$langs->trans("Status").''.$expedition->getLibStatut(4)."
'.$langs->trans("TrackingNumber").''.$expedition->tracking_number.''.$expedition->tracking_url."
'.$langs->trans("RefCustomer").''.$object->ref_client."
'.$langs->trans("Date").''.dolibarr_print_date($expedition->date,"day")."
'.$langs->trans("TotalWeight").''.$totalWeight.' '.measuring_units_string($weightUnit,"weight")."
'.$langs->trans("TotalVolume").''.$totalVolume.' '.measuring_units_string($volumeUnit,"volume")."
'.$langs->trans("Status").''.$expedition->getLibStatut(4)."
\n"; - - /* - * Lignes produits - */ - print '
'; - print ''; - print ''; - print ''; - if ($expedition->fk_statut <= 1) + print "
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").'
\n"; + + /* + * Lignes produits + */ + print '
'; + print ''; + print ''; + print ''; + if ($expedition->fk_statut <= 1) { - print ''; + print ''; } - else + else { - print ''; + print ''; } - - print ''; - print ''; - - if ($conf->stock->enabled) + + print ''; + print ''; + + if ($conf->stock->enabled) { print ''; } - print "\n"; - - $var=false; - - for ($i = 0 ; $i < $num_prod ; $i++) + print "\n"; + + $var=false; + + for ($i = 0 ; $i < $num_prod ; $i++) { print ""; if ($lignes[$i]->fk_product > 0) - { + { print '
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyToShip").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("QtyShipped").''.$langs->trans("Weight").''.$langs->trans("Volume").''.$langs->trans("Weight").''.$langs->trans("Volume").''.$langs->trans("WarehouseSource").'
'; print ''.img_object($langs->trans("ShowProduct"),"product").' '.$lignes[$i]->ref.' - '.$lignes[$i]->libelle; if ($lignes[$i]->description) print '
'.nl2br($lignes[$i]->description);