diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 3b49e427d5b..4ff0aadcae4 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -50,7 +50,7 @@ if ($_GET["action"] == 'specimen') $exp = new Expedition($db); $exp->initAsSpecimen(); - $exp->fetch_commande(); + //$exp->fetch_commande(); // Charge le modele $dir = DOL_DOCUMENT_ROOT . "/expedition/mods/pdf/"; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 378d9b1b5b9..5fd74a080f6 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -57,7 +57,7 @@ if ($_GET["action"] == 'specimen') $exp = new Expedition($db); $exp->initAsSpecimen(); - $exp->fetch_commande(); + //$exp->fetch_commande(); // Charge le modele $dir = DOL_DOCUMENT_ROOT . "/livraison/mods/pdf/"; diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index 7854c8ba7e5..45bc7a093d0 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -16,10 +16,6 @@ * 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$ - * $Id$ - * $Source$ */ // Code identique a /expedition/fiche.php @@ -27,7 +23,7 @@ /** \file htdocs/expedition/commande.php \ingroup expedition - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -396,6 +392,7 @@ if ($_GET["id"] > 0) /* * Boutons Actions */ + if ($user->societe_id == 0) { print '
'; @@ -403,11 +400,12 @@ if ($_GET["id"] > 0) // Bouton expedier sans gestion des stocks if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer) { - print ''.$langs->trans("NewSending").''; + print ''.$langs->trans("NewSending").''; } print "
"; } + print '\n"; $var=True; @@ -158,7 +158,7 @@ if ($resql) print " "; print strftime("%Y",$objp->date_expedition)."\n"; - print ''; + print ''; print "\n"; $i++; diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php index 5bcb937c4d1..9e1fad2f523 100644 --- a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php @@ -17,16 +17,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ */ /** \file htdocs/expedition/mods/pdf/pdf_expedition_dorade.modules.php \ingroup expedition \brief Fichier de la classe permettant de générer les bordereaux envoi au modèle Merou - \version $Revision$ + \version $Id$ */ require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php"; diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php index 93de2ccb650..454402cd3f9 100644 --- a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php @@ -16,16 +16,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ */ /** \file htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php \ingroup expedition \brief Fichier de la classe permettant de générer les bordereaux envoi au modèle Rouget - \version $Revision$ + \version $Id$ */ require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php"; diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index fc1c5939a2b..8d226b5ea57 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -18,16 +18,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$ - * $Source$ */ /** \file htdocs/livraison/fiche.php \ingroup livraison \brief Fiche descriptive d'un bon de livraison - \version $Revision$ + \version $Id$ */ require("./pre.inc.php");
'; /* @@ -435,7 +433,7 @@ if ($_GET["id"] > 0) print ''; print ''; print ''; - print ''; + print ''; print ''; $entrepot = new Entrepot($db); diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index e92f0df2663..c9eccd37d4e 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -87,10 +87,10 @@ class Expedition extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition"; $sql.= ", fk_soc"; $sql.= ")"; - $sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition); + $sql.= " VALUES ('(PROV)', now(), $user->id, ".$this->db->idate($this->date_expedition); $sql.= ", ".$this->socid; $sql.= ")"; @@ -105,13 +105,13 @@ class Expedition extends CommonObject // 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)) + if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0) { $error++; } } - if ($this->id && $this->origin_id) + if (! $error && $this->id && $this->origin_id) { if ($conf->commande->enabled) { @@ -126,10 +126,10 @@ class Expedition extends CommonObject { $error++; } - } - else - { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')'; + } + 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++; @@ -142,9 +142,9 @@ class Expedition extends CommonObject $error++; } } - } + } - if ($error==0) + if (! $error) { $this->db->commit(); return $this->id; @@ -152,7 +152,7 @@ class Expedition extends CommonObject else { $error++; - $this->error=$this->db->error()." - sql=$sql"; + $this->error=$this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } @@ -160,7 +160,7 @@ class Expedition extends CommonObject else { $error++; - $this->error=$this->db->error()." - sql=$sql"; + $this->error=$this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } @@ -183,17 +183,15 @@ class Expedition extends CommonObject $error = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)"; - $sql .= " VALUES (".$this->id.", ".$entrepot_id.", ".$origin_line_id.", ".$qty.")"; - - if (! $this->db->query($sql) ) + $sql .= " VALUES (".$this->id.", ".($entrepot_id?$entrepot_id:'null').", ".$origin_line_id.", ".$qty.")"; + //print 'x'.$sql; + if (! $this->db->query($sql)) { $error++; } - if ($error == 0 ) - { - return 1; - } + if (! $error) return 1; + else return -1; } /** @@ -640,6 +638,11 @@ class Expedition extends CommonObject if ($statut==0) return img_picto($langs->trans('StatusSendingDraft'),'statut0').' '.$langs->trans('StatusSendingDraft'); if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated'); } + if ($mode == 5) + { + if ($statut==0) return $langs->trans('StatusSendingDraftShort').' '.img_picto($langs->trans('StatusSendingDraft'),'statut0'); + if ($statut==1) return $langs->trans('StatusSendingValidatedShort').' '.img_picto($langs->trans('StatusSendingValidated'),'statut4'); + } } /** @@ -683,13 +686,15 @@ class Expedition extends CommonObject } } + $order=new Commande($this->db); + $order->initAsSpecimen(); + // Initialise paramètres $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; $socid = rand(1, $num_socs); $this->statut = 1; - $this->commande_id = 0; if ($conf->livraison->enabled) { $this->livraison_id = 0; @@ -699,6 +704,9 @@ class Expedition extends CommonObject $this->adresse_livraison_id = 0; $this->socid = $socids[$socid]; + $this->commande_id = 0; + $this->commande = $order; + $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index be9076b4699..f6d4ec5102d 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -17,8 +17,6 @@ * 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$ */ // Code identique a /expedition/commande.php @@ -27,7 +25,7 @@ \file htdocs/expedition/fiche.php \ingroup expedition \brief Fiche descriptive d'une expedition - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -56,8 +54,8 @@ if ($user->societe_id > 0) $socid = $user->societe_id; } -$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; -$origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; +$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal +$origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal /* * Actions @@ -81,6 +79,7 @@ if ($_POST["action"] == 'add') $object = new $class($db); $object->fetch($expedition->origin_id); //$object->fetch_lines(); + $expedition->socid = $object->socid; @@ -188,239 +187,246 @@ if ($_GET["action"] == 'create') { print_titre($langs->trans("CreateASending")); - + if (! $origin) + { + $mesg='
'.$langs->trans("ErrorBadParameters").'
'; + } + if ($mesg) { print $mesg.'
'; } - $class = ucfirst($origin); - - $object = new $class($db); - $object->loadExpeditions(); - - if ( $object->fetch($origin_id)) + if ($origin) { - $soc = new Societe($db); - $soc->fetch($object->socid); - - $author = new User($db); - $author->id = $object->user_author_id; - $author->fetch(); - - $entrepot = new Entrepot($db); - - /* - * Document source - */ - print ''; - print ''; - print ''; - print ''; - if ($_GET["entrepot_id"]) + $class = ucfirst($origin); + + $object = new $class($db); + $object->loadExpeditions(); + + if ( $object->fetch($origin_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 '"; - } - - print "
'; - if ($conf->commande->enabled) - { - print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; + $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 '"; + } + + 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 ''; + + 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); + } + + // 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 ''; + } + } + else + { + // Quantité à livrer + print ''; + } + + print "\n"; + + $indiceAsked++; + $var=!$var; + } + + /* + * + */ + + 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.''; + $quantityDelivered = $object->expeditions[$ligne->fk_product]; + print $quantityDelivered; + 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 ''; + print ''; + print ''; + print '

"; + print ''; } else { - print $langs->trans("RefProposal").'
'.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; + dolibarr_print_error($db); } - 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 ''; - - 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); - } - - // 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 ''; - } - } - else - { - // Quantité à livrer - print ''; - } - - print "\n"; - - $indiceAsked++; - $var=!$var; - } - - /* - * - */ - - 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.''; - $quantityDelivered = $object->expeditions[$ligne->fk_product]; - print $quantityDelivered; - 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 ''; - print ''; - print ''; - print '

"; - print ''; - } - else - { - dolibarr_print_error($db); } } else diff --git a/htdocs/expedition/liste.php b/htdocs/expedition/liste.php index 9f8abc3da20..a2836786428 100644 --- a/htdocs/expedition/liste.php +++ b/htdocs/expedition/liste.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2008 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -114,7 +114,7 @@ if ($resql) print_liste_field_titre($langs->trans("Proposal"),"liste.php","ori.ref", "", "&socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); } print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&socid=$socid",'width="10%" align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&socid=$socid",'width="10%" align="right"',$sortfield,$sortorder); print "
'.$expedition->statuts[$objp->fk_statut].''.$expedition->LibStatut($objp->fk_statut,5).'