diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 44f1d7050a3..1cbb92f13eb 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -21,11 +21,11 @@ // 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"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); @@ -44,14 +44,14 @@ $langs->load('stocks'); $langs->load('other'); if (! $user->rights->expedition->lire) - accessforbidden(); +accessforbidden(); // Security customer access if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } $origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal @@ -63,53 +63,53 @@ $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); + // Creation de l'objet expedition + $expedition = new Expedition($db); - $expedition->date_expedition = time(); - $expedition->note = $_POST["note"]; - $expedition->origin = $origin; - $expedition->origin_id = $origin_id; + $expedition->date_expedition = time(); + $expedition->note = $_POST["note"]; + $expedition->origin = $origin; + $expedition->origin_id = $origin_id; - // On boucle sur chaque ligne du document d'origine pour compléter objet expedition - // avec qté à livrer - $class = ucfirst($expedition->origin); - $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++) - { - $ent = "entl".$i; - $idl = "idl".$i; - $qty = "qtyl".$i; - $entrepot_id = $_POST[$ent]?$_POST[$ent]:$_POST["entrepot_id"]; - if ($_POST[$qty] > 0) - { - $expedition->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); - } - } - - $ret=$expedition->create($user); - if ($ret > 0) - { - $db->commit(); - Header("Location: fiche.php?id=".$expedition->id); - exit; - } - else - { - $db->rollback(); - $mesg='
'.$expedition->error.'
'; - $_GET["commande_id"]=$_POST["commande_id"]; - $_GET["action"]='create'; - } + // On boucle sur chaque ligne du document d'origine pour compléter objet expedition + // avec qté à livrer + $class = ucfirst($expedition->origin); + $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++) + { + $ent = "entl".$i; + $idl = "idl".$i; + $qty = "qtyl".$i; + $entrepot_id = $_POST[$ent]?$_POST[$ent]:$_POST["entrepot_id"]; + if ($_POST[$qty] > 0) + { + $expedition->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); + } + } + + $ret=$expedition->create($user); + if ($ret > 0) + { + $db->commit(); + Header("Location: fiche.php?id=".$expedition->id); + exit; + } + else + { + $db->rollback(); + $mesg='
'.$expedition->error.'
'; + $_GET["commande_id"]=$_POST["commande_id"]; + $_GET["action"]='create'; + } } /* @@ -117,38 +117,38 @@ 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) { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $result = $expedition->valid($user); - //$expedition->PdfWrite(); + $expedition = new Expedition($db); + $expedition->fetch($_GET["id"]); + $result = $expedition->valid($user); + //$expedition->PdfWrite(); } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { - if ($user->rights->expedition->supprimer ) - { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $expedition->delete(); - Header("Location: liste.php"); - exit; - } + if ($user->rights->expedition->supprimer ) + { + $expedition = new Expedition($db); + $expedition->fetch($_GET["id"]); + $expedition->delete(); + Header("Location: liste.php"); + exit; + } } /* @@ -171,11 +171,11 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs->setDefaultLang($_REQUEST['lang_id']); } $result=expedition_pdf_create($db,$expedition->id,$expedition->modelpdf,$outputlangs); - if ($result <= 0) - { - dolibarr_print_error($db,$result); - exit; - } + if ($result <= 0) + { + dolibarr_print_error($db,$result); + exit; + } } @@ -196,37 +196,37 @@ $formfile = new FormFile($db); if ($_GET["action"] == 'create') { - $expe = new Expedition($db); + $expe = new Expedition($db); - 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)) + 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)) + { $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 */ @@ -235,223 +235,223 @@ if ($_GET["action"] == 'create') print ''; print ''; if ($_GET["entrepot_id"]) - { - print ''; - } - + { + 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 ''; - } - + { + print ''; + print ''; + } + if ($object->note && ! $user->societe_id) - { - print '"; - } - + { + 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; - } + { + 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 $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("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("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 ''; 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) - { - if ($_GET["entrepot_id"]) - { - print ''; - } - else - { - print ''; - } - } - print "\n"; - } - + { + 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); - 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) + { + $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 ''; + + // 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++; - } + 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++; - } - + $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").'
'.$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 '
'; + 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 '
'; + $html->select_array('entl'.$i,$array,'',1,0,0); + print ''; + print ''; + print ''; + print '

"; print ''; - } - else - { + } + else + { dolibarr_print_error($db); + } } - } } else /* *************************************************************************** */ @@ -460,288 +460,293 @@ else /* */ /* *************************************************************************** */ { - 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(); - - if (strlen($expedition->tracking_number) && strlen($expedition->expedition_method_id)) { - $expedition->GetUrlTrackingStatus(); - } - - $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 '
'; - } - - /* - * 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 '
'; - } - /* - * 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 '
'; - } - - // 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; - } - - print ''; - - // Ref - print ''; - print ''; - - // Customer - print ''; - print ''; - print ""; - - // Document liée - print ''; - print '\n"; - } - else - { - $propal=new Propal($db); - $propal->fetch($livraison->origin_id); - print $langs->trans("RefProposal").''; - 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 ''; - - // Status - print ''; - print '\n"; - print ''; - - // Tracking Number - 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 $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."
\n"; - - /* - * Lignes produits - */ - print '
'; - print ''; - print ''; - print ''; - if ($expedition->fk_statut <= 1) - { - print ''; - } - else - { - print ''; - } - - print ''; - print ''; - - if ($conf->stock->enabled) - { - print ''; - } - print "\n"; - - $var=false; - - for ($i = 0 ; $i < $num_prod ; $i++) - { - print ""; - if ($lignes[$i]->fk_product > 0) + $expedition = New Expedition($db); + $result = $expedition->fetch($_GET["id"]); + if ($result < 0) { - print ''; - } - else - { - print "\n"; - } - - // Qte commandé - print ''; - - // Qte a expedier ou expedier - print ''; - - // Poids - print ''; - - // Volume - print ''; + dolibarr_print_error($db,$expedition->error); + exit -1; + } + $lignes = $expedition->lignes; + $num_prod = sizeof($lignes); - // Entrepot source - if ($conf->stock->enabled) - { - $entrepot = new Entrepot($db); - $entrepot->fetch($lignes[$i]->entrepot_id); - print ''; - } - + if ($expedition->id > 0) + { + $object = $expedition->origin; + $expedition->fetch_object(); - print ""; - - $var=!$var; - } - } + if (strlen($expedition->tracking_number) && strlen($expedition->expedition_method_id)) { + $expedition->GetUrlTrackingStatus(); + } - print "
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$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); - print '
".nl2br($lignes[$i]->description)."'.$lignes[$i]->qty_asked.''.$lignes[$i]->qty_shipped.''.$lignes[$i]->weight*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->weight_units,"weight").''.$lignes[$i]->volume*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->volume_units,"volume").''.$entrepot->getNomUrl(1).'
\n"; + $soc = new Societe($db); + $soc->fetch($expedition->socid); - print "\n\n"; + $h=0; + $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; + $head[$h][1] = $langs->trans("SendingCard"); + $hselected = $h; + $h++; - - /* - * Boutons actions - */ - - if ($user->societe_id == 0) - { - print '
'; - - if (! eregi('^(valid|delete)',$_REQUEST["action"])) - { - if ($expedition->statut == 0 && $user->rights->expedition->valider && $num_prod > 0) - { - 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 ($expedition->brouillon && $user->rights->expedition->supprimer) - { - print ''.$langs->trans("Delete").''; - } - } - - print '
'; - } - print "\n"; - - print "
"; - - - /* - * Documents générés - */ - if ($conf->expedition_bon->enabled) + if ($conf->livraison_bon->enabled && $expedition->livraison_id) { - $expeditionref = sanitize_string($expedition->ref); - $filedir = $conf->expedition_bon->dir_output . "/" .$expeditionref; - - $urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id; - - $genallowed=$user->rights->expedition->lire && ($expedition->statut > 0); - $delallowed=$user->rights->expedition->supprimer; - //$genallowed=1; - //$delallowed=0; - - $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf); - if ($genallowed && ! $somethingshown) $somethingshown=1; - } + $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 '
'; + } + + /* + * 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 '
'; + } + /* + * 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 '
'; + } + + // 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; + } + + print ''; + + // Ref + print ''; + print ''; + + // Customer + print ''; + print ''; + print ""; + + // Document liée + print ''; + print '\n"; + } + else + { + $propal=new Propal($db); + $propal->fetch($livraison->origin_id); + print $langs->trans("RefProposal").''; + 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 ''; + + // Status + print ''; + print '\n"; + print ''; + + // Tracking Number + 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 $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."
\n"; + + /* + * Lignes produits + */ + print '
'; + print ''; + print ''; + print ''; + if ($expedition->fk_statut <= 1) + { + print ''; + } + else + { + print ''; + } + + print ''; + print ''; + + if ($conf->stock->enabled) + { + print ''; + } + print "\n"; + + $var=false; + + for ($i = 0 ; $i < $num_prod ; $i++) + { + print ""; + if ($lignes[$i]->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + + // Qte commandé + print ''; + + // Qte a expedier ou expedier + print ''; + + // Poids + print ''; + + // Volume + print ''; + + // Entrepot source + if ($conf->stock->enabled) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($lignes[$i]->entrepot_id); + print ''; + } + + + print ""; + + $var=!$var; + } + } + + print "
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$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); + print '
".nl2br($lignes[$i]->description)."'.$lignes[$i]->qty_asked.''.$lignes[$i]->qty_shipped.''.$lignes[$i]->weight*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->weight_units,"weight").''.$lignes[$i]->volume*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->volume_units,"volume").''.$entrepot->getNomUrl(1).'
\n"; + + print "\n\n"; + + + /* + * Boutons actions + */ + + if ($user->societe_id == 0) + { + print '
'; + + if (! eregi('^(valid|delete)',$_REQUEST["action"])) + { + if ($expedition->statut == 0 && $user->rights->expedition->valider && $num_prod > 0) + { + 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 ($expedition->brouillon && $user->rights->expedition->supprimer) + { + print ''.$langs->trans("Delete").''; + } + } + + print '
'; + } + print "\n"; + + print "
"; + + + /* + * Documents générés + */ + if ($conf->expedition_bon->enabled) + { + $expeditionref = sanitize_string($expedition->ref); + $filedir = $conf->expedition_bon->dir_output . "/" .$expeditionref; + + $urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id; + + $genallowed=$user->rights->expedition->lire && ($expedition->statut > 0); + $delallowed=$user->rights->expedition->supprimer; + //$genallowed=1; + //$delallowed=0; + + $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf); + if ($genallowed && ! $somethingshown) $somethingshown=1; + } - print ''; + print ''; - // Rien a droite + // Rien a droite - print '
'; + print '
'; - print '
'; - show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); - - } - else - { - print "Expedition inexistante ou accés refusé"; - } + print '
'; + show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); + + } + else + { + print "Expedition inexistante ou accés refusé"; + } } $db->close();