diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 54f714b68ef..8bf470024b9 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -1891,7 +1891,7 @@ class Commande extends CommonObject /** \brief Renvoie nom clicable (avec eventuellement le picto) \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - \param option Sur quoi pointe le lien: 0,1,2,4,-1 fiche commande, 3 fiche compta commande + \param option Sur quoi pointe le lien: 0=fiche commande,3=fiche compta commande,4=fiche expedition commande \return string Chaine avec URL */ function getNomUrl($withpicto=0,$option=0) @@ -1902,6 +1902,7 @@ class Commande extends CommonObject $urlOption=''; if ($option == 3) $urlOption = '/compta'; + if ($option == 4) $urlOption = '/expedition'; $lien = ''; $lienfin=''; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 90c987a569f..4aae735c925 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -533,15 +533,22 @@ else print ''; if ($conf->commande->enabled) { + $order=new Commande($db); + $order->fetch($expedition->$object->id); print $langs->trans("RefOrder").''; - print ''.img_object($langs->trans("ShowOrder"),'order').' '.$expedition->$object->ref; + print ''; + print $order->getNomUrl(1,4); + print "\n"; } else { + $propal=new Propal($db); + $propal->fetch($livraison->origin_id); print $langs->trans("RefProposal").''; - print ''.img_object($langs->trans("ShowProposal"),'propal').' '.$expedition->$object->ref; + print ''; + print $propal->getNomUrl(1,'expedition'); + print "\n"; } - print "\n"; print ''; // Ref client diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 5f2a9342064..21ee602b83b 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -21,11 +21,11 @@ */ /** - \file htdocs/livraison/fiche.php - \ingroup livraison - \brief Fiche descriptive d'un bon de livraison - \version $Id$ -*/ + \file htdocs/livraison/fiche.php + \ingroup livraison + \brief Fiche descriptive d'un bon de livraison + \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/livraison/mods/modules_livraison.php"); @@ -39,14 +39,14 @@ $langs->load("bills"); $langs->load('deliveries'); if (!$user->rights->expedition->livraison->lire) - accessforbidden(); +accessforbidden(); // S�curit� acc�s client -if ($user->societe_id > 0) +if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } @@ -54,92 +54,92 @@ if ($user->societe_id > 0) * Actions */ -if ($_POST["action"] == 'add') +if ($_POST["action"] == 'add') { - $db->begin(); - - // Creation de l'objet livraison - $livraison = new Livraison($db); - - $livraison->date_livraison = time(); - $livraison->note = $_POST["note"]; - $livraison->commande_id = $_POST["commande_id"]; - - if (!$conf->expedition_bon->enabled && $conf->stock->enabled) - { - $expedition->entrepot_id = $_POST["entrepot_id"]; - } - - // On boucle sur chaque ligne de commande pour compl�ter objet livraison - // avec qt� � livrer - $commande = new Commande($db); - $commande->fetch($livraison->commande_id); - $commande->fetch_lines(); - for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) - { - $qty = "qtyl".$i; - $idl = "idl".$i; - if ($_POST[$qty] > 0) - { - $livraison->addline($_POST[$idl],$_POST[$qty]); - } - } - - $ret=$livraison->create($user); - if ($ret > 0) - { - $db->commit(); - Header("Location: fiche.php?id=".$livraison->id); - exit; - } - else - { - $db->rollback(); - $mesg='
'.$livraison->error.'
'; - $_GET["commande_id"]=$_POST["commande_id"]; - $_GET["action"]='create'; - } + $db->begin(); + + // Creation de l'objet livraison + $livraison = new Livraison($db); + + $livraison->date_livraison = time(); + $livraison->note = $_POST["note"]; + $livraison->commande_id = $_POST["commande_id"]; + + if (!$conf->expedition_bon->enabled && $conf->stock->enabled) + { + $expedition->entrepot_id = $_POST["entrepot_id"]; + } + + // On boucle sur chaque ligne de commande pour compl�ter objet livraison + // avec qt� � livrer + $commande = new Commande($db); + $commande->fetch($livraison->commande_id); + $commande->fetch_lines(); + for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) + { + $qty = "qtyl".$i; + $idl = "idl".$i; + if ($_POST[$qty] > 0) + { + $livraison->addline($_POST[$idl],$_POST[$qty]); + } + } + + $ret=$livraison->create($user); + if ($ret > 0) + { + $db->commit(); + Header("Location: fiche.php?id=".$livraison->id); + exit; + } + else + { + $db->rollback(); + $mesg='
'.$livraison->error.'
'; + $_GET["commande_id"]=$_POST["commande_id"]; + $_GET["action"]='create'; + } } if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->livraison->valider) { - $livraison = new Livraison($db); - $livraison->fetch($_GET["id"]); - $result = $livraison->valid($user); - //$livraison->PdfWrite(); + $livraison = new Livraison($db); + $livraison->fetch($_GET["id"]); + $result = $livraison->valid($user); + //$livraison->PdfWrite(); } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { - if ($user->rights->expedition->livraison->supprimer ) - { - $livraison = new Livraison($db); - $livraison->fetch($_GET["id"]); - $expedition_id = $_GET["expid"]; - $livraison->delete(); - if ($conf->expedition_bon->enabled) - { - Header("Location: ".DOL_URL_ROOT.'/expedition/fiche.php?id='.$expedition_id); - } - else - { - Header("Location: liste.php"); - } - } + if ($user->rights->expedition->livraison->supprimer ) + { + $livraison = new Livraison($db); + $livraison->fetch($_GET["id"]); + $expedition_id = $_GET["expid"]; + $livraison->delete(); + if ($conf->expedition_bon->enabled) + { + Header("Location: ".DOL_URL_ROOT.'/expedition/fiche.php?id='.$expedition_id); + } + else + { + Header("Location: liste.php"); + } + } } /* - * G�n�rer ou reg�n�rer le PDF + * Build document */ if ($_REQUEST['action'] == 'builddoc') // En get ou en post { - $delivery = new Livraison($db, 0, $_REQUEST['id']); - $delivery->fetch($_REQUEST['id']); + $delivery = new Livraison($db, 0, $_REQUEST['id']); + $delivery->fetch($_REQUEST['id']); - if ($_REQUEST['model']) - { - $delivery->setDocModel($user, $_REQUEST['model']); - } + if ($_REQUEST['model']) + { + $delivery->setDocModel($user, $_REQUEST['model']); + } if ($_REQUEST['lang_id']) { @@ -147,16 +147,16 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs->setDefaultLang($_REQUEST['lang_id']); } $result=delivery_order_pdf_create($db, $_REQUEST['id'],$_REQUEST['model'],$outputlangs); - if ($result <= 0) - { - dolibarr_print_error($db,$result); - exit; - } + if ($result <= 0) + { + dolibarr_print_error($db,$result); + exit; + } } /* - * + * View */ llxHeader('',$langs->trans('Delivery'),'Livraison'); @@ -169,123 +169,123 @@ $formfile = new FormFile($db); * Mode creation * *********************************************************************/ -if ($_GET["action"] == 'create') +if ($_GET["action"] == 'create') { - - print_titre($langs->trans("CreateADeliveryOrder")); - if ($mesg) - { - print $mesg.'
'; - } - - $commande = new Commande($db); - $commande->livraison_array(); - - if ( $commande->fetch($_GET["commande_id"])) - { - $soc = new Societe($db); - $soc->fetch($commande->socid); - $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); - - if (!$conf->expedition_bon->enabled && $conf->stock->enabled) - { - $entrepot = new Entrepot($db); - } - - /* - * Commande - */ - print '
'; - print ''; - print ''; - if (!$conf->expedition_bon->enabled && $conf->stock->enabled) - { - print ''; - } - print ''; - print ''; - print ''; - - print '"; - - print ""; - print "\n"; - - print '\n"; - - print ''; - - if (!$conf->expedition_bon->enabled && $conf->stock->enabled) - { - print ''; - print ''; - } - - print "\n"; - - if ($commande->note) + if ($mesg) { - print '"; + print $mesg.'
'; } - print "
'.$langs->trans("Customer").''.$soc->nom.''; + print_titre($langs->trans("CreateADeliveryOrder")); - print "
".$langs->trans("Date")."".dolibarr_print_date($commande->date,'dayhourtext')."'.$langs->trans("Order").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.''; - print "
'.$langs->trans("Warehouse").''; - $ents = $entrepot->list_array(); - print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; - print '".$langs->trans("Author")."$author->fullname
Note : '.nl2br($commande->note)."
"; - - /* - * Lignes de commandes - * - */ - echo '
'; - - $lignes = $commande->fetch_lines(1); - - /* Lecture des livraisons d�j� effectu�es */ - $commande->livraison_array(); - - $num = sizeof($commande->lignes); - $i = 0; - - if ($num) + + $commande = new Commande($db); + $commande->livraison_array(); + + if ( $commande->fetch($_GET["commande_id"])) { + $soc = new Societe($db); + $soc->fetch($commande->socid); + $author = new User($db); + $author->id = $commande->user_author_id; + $author->fetch(); + + if (!$conf->expedition_bon->enabled && $conf->stock->enabled) + { + $entrepot = new Entrepot($db); + } + + /* + * Commande + */ + print ''; + print ''; + print ''; + if (!$conf->expedition_bon->enabled && $conf->stock->enabled) + { + print ''; + } + print '
'; + print ''; + print ''; + + print '"; + + print ""; + print "\n"; + + print '\n"; + + print ''; + + if (!$conf->expedition_bon->enabled && $conf->stock->enabled) + { + print ''; + print ''; + } + + print "\n"; + + if ($commande->note) + { + print '"; + } + print "
'.$langs->trans("Customer").''.$soc->nom.''; + + print "
".$langs->trans("Date")."".dolibarr_print_date($commande->date,'dayhourtext')."'.$langs->trans("Order").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.''; + print "
'.$langs->trans("Warehouse").''; + $ents = $entrepot->list_array(); + print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; + print '".$langs->trans("Author")."$author->fullname
Note : '.nl2br($commande->note)."
"; + + /* + * Lignes de commandes + * + */ + echo '
'; + + $lignes = $commande->fetch_lines(1); + + /* Lecture des livraisons d�j� effectu�es */ + $commande->livraison_array(); + + $num = sizeof($commande->lignes); + $i = 0; + + if ($num) + { print ''; print ''; print ''; print ''; print ''; if ($conf->stock->enabled) - { - print ''; - } + { + print ''; + } print "\n"; - } - $var=true; - while ($i < $num) - { + } + $var=true; + while ($i < $num) + { $ligne = $commande->lignes[$i]; $var=!$var; print "\n"; if ($ligne->fk_product > 0) - { - $product = new Product($db); - $product->fetch($ligne->fk_product); - - print ''; - } + { + $product = new Product($db); + $product->fetch($ligne->fk_product); + + print ''; + } else - { - print "\n"; - } - + { + print "\n"; + } + print ''; /* * @@ -297,57 +297,57 @@ if ($_GET["action"] == 'create') $quantite_commandee = $ligne->qty; $quantite_a_livrer = $quantite_commandee - $quantite_livree; - - if ($conf->stock->enabled) - { - $stock = $product->stock_entrepot[$_GET["entrepot_id"]]; - $stock+=0; // Convertit en num�rique - - // Quantit� � livrer - print ''; - - // Stock - if ($stock < $quantite_a_livrer) - { - print ''; - } - else - { - print ''; - } - } - else - { - // Quantit� � livrer - print ''; - } + + if ($conf->stock->enabled) + { + $stock = $product->stock_entrepot[$_GET["entrepot_id"]]; + $stock+=0; // Convertit en num�rique + + // Quantit� � livrer + print ''; + + // Stock + if ($stock < $quantite_a_livrer) + { + print ''; + } + else + { + print ''; + } + } + else + { + // Quantit� � livrer + print ''; + } print "\n"; - + $i++; $var=!$var; - } + } - /* - * - */ + /* + * + */ - print ''; - print "
'.$langs->trans("Description").'Quan. command�eQuan. livr�eQuan. � livrer'.$langs->trans("Stock").''.$langs->trans("Stock").'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($ligne->description) print nl2br($ligne->description); - print ''; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($ligne->description) print nl2br($ligne->description); + print '".nl2br($ligne->description)."".nl2br($ligne->description)."'.$ligne->qty.''; - print ''; - print ''; - print ''.$stock.' '.img_alerte().''.$stock.''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''.$stock.' '.img_alerte().''.$stock.''; + print ''; + print ''; + print '

"; - print '
'; - } - else - { - dolibarr_print_error($db); - } -} -else + print '
'; + print ""; + print ''; + } + else + { + dolibarr_print_error($db); + } +} +else /* *************************************************************************** */ /* */ /* Mode vue et edition */ @@ -355,284 +355,293 @@ else /* *************************************************************************** */ { if ($_GET["id"] > 0) - { - $livraison = new Livraison($db); - $result = $livraison->fetch($_GET["id"]); - - if ($livraison->origin_id) - { - $object = $livraison->origin; - $livraison->fetch_object(); - } + { + $livraison = new Livraison($db); + $result = $livraison->fetch($_GET["id"]); + $livraison->fetch_client(); + + if ($livraison->origin_id) + { + $object = $livraison->origin; + $livraison->fetch_object(); + } - if ( $livraison->id > 0) - { - $soc = new Societe($db); - $soc->fetch($livraison->socid); - - $h=0; - if ($conf->expedition_bon->enabled) - { - $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$livraison->expedition_id; - $head[$h][1] = $langs->trans("SendingCard"); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$livraison->id; - $head[$h][1] = $langs->trans("DeliveryCard"); - $hselected = $h; - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")); - - /* - * Confirmation de la suppression - * - */ - if ($_GET["action"] == 'delete') - { - $expedition_id = $_GET["expid"]; - $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id.'&expid='.$expedition_id,'Supprimer le bon de livraison','Etes-vous s�r de vouloir supprimer ce bon de livraison ?','confirm_delete'); - print '
'; - } - - /* - * Confirmation de la validation - * - */ - if ($_GET["action"] == 'valid') - { - $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id,$langs->trans("ValidateDeliveryReceipt"),$langs->trans("ValidateDeliveryReceiptConfirm"),'confirm_valid'); - print '
'; - } - - - /* - * Livraison - */ - print ''; - - // Ref - print ''; - print ''; - - // Client - print ''; - print ''; - print ""; - - // Document origine - if ($conf->commande->enabled) - { - print ''; - print '\n"; - print ''; - } - else - { - print ''; - print '\n"; - print ''; - } - - // Ref client - print ''; - print '\n"; - print ''; - - // Date - print ''; - print '\n"; - print ''; - - // Statut - print ''; - print '\n"; - print ''; - - if (!$conf->expedition_bon->enabled && $conf->stock->enabled) - { - // Entrepot - $entrepot = new Entrepot($db); - $entrepot->fetch($livraison->entrepot_id); - print ''; - print ''; - print ''; - } - - print "
'.$langs->trans("Ref").''.$livraison->ref.'
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'.$langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$livraison->commande->ref."
'.$langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$livraison->propal->ref."
'.$langs->trans("RefCustomer").''.$livraison->ref_client."
'.$langs->trans("Date").''.dolibarr_print_date($livraison->date_creation,'dayhourtext')."
'.$langs->trans("Status").''.$livraison->getLibStatut(4)."
'.$langs->trans("Warehouse").''.$entrepot->libelle.'
\n"; - - /* - * Lignes produits - */ - print '
'; - - $num_prod = sizeof($livraison->lignes); - - if ($num_prod) - { - $i = 0; - - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=true; - while ($i < $num_prod) - { - $var=!$var; - print ""; - if ($livraison->lignes[$i]->fk_product > 0) - { - $product = new Product($db); - $product->fetch($livraison->lignes[$i]->fk_product); - - print ''; - } - else - { - print "\n"; - } - - print ''; - print ''; - - print ""; - - $i++; - } - } - - print "
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($livraison->lignes[$i]->description) print '
'.$livraison->lignes[$i]->description; - print '
".$livraison->lignes[$i]->description."'.$livraison->lignes[$i]->qty_asked.''.$livraison->lignes[$i]->qty_shipped.'
\n"; - - print "\n\n"; - - - /* - * Boutons actions - */ - - if ($user->societe_id == 0) - { - print '
'; - - if (! eregi('^(valid|delete)',$_REQUEST["action"])) - { - if ($livraison->statut == 0 && $user->rights->expedition->livraison->valider && $num_prod > 0) - { - print ''.$langs->trans("Validate").''; - } - - if ($livraison->brouillon && $user->rights->expedition->livraison->supprimer) - { - if ($conf->expedition_bon->enabled) - { - print ''.$langs->trans("Delete").''; - } - else - { - print ''.$langs->trans("Delete").''; - } - } - } - - print '
'; - } - print "\n"; - - print "
"; - - /* - * Documents g�n�r�s - */ - - $livraisonref = sanitize_string($livraison->ref); - $filedir = $conf->livraison_bon->dir_output . '/' . $livraisonref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$livraison->id; - - $genallowed=$user->rights->expedition->livraison->creer; - $delallowed=$user->rights->expedition->livraison->supprimer; - - $somethingshown=$formfile->show_documents('livraison',$livraisonref,$filedir,$urlsource,$genallowed,$delallowed,$livraison->modelpdf); - - /* - * D�j� livre - */ - $sql = "SELECT ld.fk_product, ld.description, ld.qty as qty_shipped, ld.fk_livraison as livraison_id"; - $sql.= ", l.ref, ".$db->pdate("l.date_livraison")." as date_livraison"; - $sql.= ", cd.rowid, cd.qty as qty_commande"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= " , ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l"; - $sql.= " WHERE l.rowid <> ".$livraison->id; - $sql.= " AND cd.rowid = ld.fk_origin_line"; - $sql.= " AND ld.fk_livraison = l.rowid"; - $sql.= " AND l.fk_statut > 0"; - $sql.= " ORDER BY cd.fk_product"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - if ($num) - { - print '
'; - - print_titre($langs->trans("OtherSendingsForSameOrder")); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $var=!$var; - $objp = $db->fetch_object($resql); - print ""; - print ''; - if ($objp->fk_product > 0) - { - $product = new Product($db); - $product->fetch($objp->fk_product); - - print ''; - } - else - { - print "\n"; - } - print ''; - print ''; - print ''; - $i++; - } - - print '
'.$langs->trans("Sending").''.$langs->trans("Description").''.$langs->trans("QtyShipped").''.$langs->trans("Date").'
'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.''; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($objp->description) print nl2br($objp->description); - print '".stripslashes(nl2br($objp->description))."'.$objp->qty_shipped.''.dolibarr_print_date($objp->date_livraison,"dayhour").'
'; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - - print '
'; + if ( $livraison->id > 0) + { + $soc = new Societe($db); + $soc->fetch($livraison->socid); + + $h=0; + if ($conf->expedition_bon->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$livraison->expedition_id; + $head[$h][1] = $langs->trans("SendingCard"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$livraison->id; + $head[$h][1] = $langs->trans("DeliveryCard"); + $hselected = $h; + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")); + + /* + * Confirmation de la suppression + * + */ + if ($_GET["action"] == 'delete') + { + $expedition_id = $_GET["expid"]; + $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id.'&expid='.$expedition_id,'Supprimer le bon de livraison','Etes-vous s�r de vouloir supprimer ce bon de livraison ?','confirm_delete'); + print '
'; + } + + /* + * Confirmation de la validation + * + */ + if ($_GET["action"] == 'valid') + { + $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id,$langs->trans("ValidateDeliveryReceipt"),$langs->trans("ValidateDeliveryReceiptConfirm"),'confirm_valid'); + print '
'; + } + + + /* + * Livraison + */ + print ''; + + // Ref + print ''; + print ''; + + // Client + print ''; + print ''; + print ""; + + // Document origine + if ($conf->commande->enabled) + { + print ''; + $order=new Commande($db); + $order->fetch($livraison->origin_id); + print '\n"; + print ''; + } + else + { + $propal=new Propal($db); + $propal->fetch($livraison->origin_id); + print ''; + print '\n"; + print ''; + } + + // Ref client + print ''; + print '\n"; + print ''; + + // Date + print ''; + print '\n"; + print ''; + + // Statut + print ''; + print '\n"; + print ''; + + if (!$conf->expedition_bon->enabled && $conf->stock->enabled) + { + // Entrepot + $entrepot = new Entrepot($db); + $entrepot->fetch($livraison->entrepot_id); + print ''; + print ''; + print ''; + } + + print "
'.$langs->trans("Ref").''.$livraison->ref.'
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'.$langs->trans("RefOrder").''; + print $order->getNomUrl(1,4); + print "
'.$langs->trans("RefProposal").''; + print $propal->getNomUrl(1,'expedition'); + print "
'.$langs->trans("RefCustomer").''.$livraison->ref_client."
'.$langs->trans("Date").''.dolibarr_print_date($livraison->date_creation,'dayhourtext')."
'.$langs->trans("Status").''.$livraison->getLibStatut(4)."
'.$langs->trans("Warehouse").''.$entrepot->libelle.'
\n"; + + /* + * Lignes produits + */ + print '
'; + + $num_prod = sizeof($livraison->lignes); + + if ($num_prod) + { + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=true; + while ($i < $num_prod) + { + $var=!$var; + print ""; + if ($livraison->lignes[$i]->fk_product > 0) + { + $product = new Product($db); + $product->fetch($livraison->lignes[$i]->fk_product); + + print ''; + } + else + { + print "\n"; + } + + print ''; + print ''; + + print ""; + + $i++; + } + } + + print "
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").'
'; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($livraison->lignes[$i]->description) print '
'.$livraison->lignes[$i]->description; + print '
".$livraison->lignes[$i]->description."'.$livraison->lignes[$i]->qty_asked.''.$livraison->lignes[$i]->qty_shipped.'
\n"; + + print "\n\n"; + + + /* + * Boutons actions + */ + + if ($user->societe_id == 0) + { + print '
'; + + if (! eregi('^(valid|delete)',$_REQUEST["action"])) + { + if ($livraison->statut == 0 && $user->rights->expedition->livraison->valider && $num_prod > 0) + { + print ''.$langs->trans("Validate").''; + } + + if ($livraison->brouillon && $user->rights->expedition->livraison->supprimer) + { + if ($conf->expedition_bon->enabled) + { + print ''.$langs->trans("Delete").''; + } + else + { + print ''.$langs->trans("Delete").''; + } + } + } + + print '
'; + } + print "\n"; + + print "
"; + + /* + * Documents g�n�r�s + */ + + $livraisonref = sanitize_string($livraison->ref); + $filedir = $conf->livraison_bon->dir_output . '/' . $livraisonref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$livraison->id; + + $genallowed=$user->rights->expedition->livraison->creer; + $delallowed=$user->rights->expedition->livraison->supprimer; + + $somethingshown=$formfile->show_documents('livraison',$livraisonref,$filedir,$urlsource,$genallowed,$delallowed,$livraison->modelpdf); + + /* + * D�j� livre + */ + $sql = "SELECT ld.fk_product, ld.description, ld.qty as qty_shipped, ld.fk_livraison as livraison_id"; + $sql.= ", l.ref, ".$db->pdate("l.date_livraison")." as date_livraison"; + $sql.= ", cd.rowid, cd.qty as qty_commande"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sql.= " , ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l"; + $sql.= " WHERE l.rowid <> ".$livraison->id; + $sql.= " AND cd.rowid = ld.fk_origin_line"; + $sql.= " AND ld.fk_livraison = l.rowid"; + $sql.= " AND l.fk_statut > 0"; + $sql.= " ORDER BY cd.fk_product"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + if ($num) + { + print '
'; + + print_titre($langs->trans("OtherSendingsForSameOrder")); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $var=!$var; + $objp = $db->fetch_object($resql); + print ""; + print ''; + if ($objp->fk_product > 0) + { + $product = new Product($db); + $product->fetch($objp->fk_product); + + print ''; + } + else + { + print "\n"; + } + print ''; + print ''; + print ''; + $i++; + } + + print '
'.$langs->trans("Sending").''.$langs->trans("Description").''.$langs->trans("QtyShipped").''.$langs->trans("Date").'
'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.''; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($objp->description) print nl2br($objp->description); + print '".stripslashes(nl2br($objp->description))."'.$objp->qty_shipped.''.dolibarr_print_date($objp->date_livraison,"dayhour").'
'; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + + print '
'; // Rien � droite - + print '
'; } else @@ -642,10 +651,10 @@ else } } else - { - /* Expedition non trouv�e */ - print "Expedition inexistante ou acc�s refus�"; - } + { + /* Expedition non trouv�e */ + print "Expedition inexistante ou acc�s refus�"; + } } $db->close(); diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 304ac860571..1b941dff72b 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -1890,7 +1890,11 @@ class Propal extends CommonObject { $lien = ''; } - $lienfin=''; + if($option == 'expedition') + { + $lien = ''; + } + $lienfin=''; $picto='order'; $label=$langs->trans("ShowPropal").': '.$this->ref;