diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index 5b901d79b67..95023786453 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -24,9 +24,9 @@ // Code identique a /expedition/fiche.php /** - \file htdocs/expedition/commande.php - \ingroup expedition - \version $Revision$ + \file htdocs/expedition/commande.php + \ingroup expedition + \version $Revision$ */ require("./pre.inc.php"); @@ -48,29 +48,28 @@ $user->getrights('expedition'); if (!$user->rights->commande->lire) accessforbidden(); - // Sécurité accés client if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } +// Chargement des permissions +$error = $user->load_entrepots(); /* * Actions */ if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes') { - $commande = new Commande($db); - $commande->fetch($_GET["id"]); - $result = $commande->cloture($user); + $commande = new Commande($db); + $commande->fetch($_GET["id"]); + $result = $commande->cloture($user); } - $html = new Form($db); - /* *************************************************************************** */ /* */ /* Mode vue et edition */ @@ -79,7 +78,6 @@ $html = new Form($db); llxHeader('',$langs->trans("OrderCard")); - if ($_GET["id"] > 0) { $commande = New Commande($db); @@ -108,108 +106,108 @@ if ($_GET["id"] > 0) } // Onglet commande - $nbrow=8; - if ($conf->projet->enabled) $nbrow++; + $nbrow=8; + if ($conf->projet->enabled) $nbrow++; - print ''; + print '
'; - // Ref - print ''; - print ''; - print ''; + // Ref + print ''; + print ''; + print ''; - // Ref commande client - print ''; - print ''; - - - // Société - print ''; - print ''; - print ''; - - // Date - print ''; - print ''; - print ''; - print ''; - - // Date de livraison - print ''; - print ''; - print ''; - - - // Adresse de livraison - print ''; - - // Conditions et modes de réglement + // Ref commande client + print ''; + print ''; + + + // Société + print ''; + print ''; + print ''; + + // Date + print ''; + print ''; + print ''; + print ''; + + // Date de livraison + print ''; + print ''; + print ''; + + + // Adresse de livraison + print ''; + + // Conditions et modes de réglement print '
'.$langs->trans('Ref').''.$commande->ref.'
'.$langs->trans('Ref').''.$commande->ref.'
'; - print ''; - if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print ''.img_edit($langs->trans('Edit')).'
'; - print '
'; - if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') - { - print '
'; - print ''; - print ''; - print ' '; - print '
'; - } - else - { - print $commande->ref_client; - } - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Date').''.dolibarr_print_date($commande->date,'%A %d %B %Y').''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ; - if ($commande->source == 0) - { - // Si source = propal - $propal = new Propal($db); - $propal->fetch($commande->propale_id); - print ' -> '.$propal->ref.''; - } - print '
'; - print ''; - - if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DateDelivery'); - print 'id.'">'.img_edit($langs->trans('SetDateDelivery'),1).'
'; - print '
'; - if ($_GET['action'] == 'editdate_livraison') - { - print '
'; - print ''; - $html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison"); - print ''; - print '
'; - } - else - { - print dolibarr_print_date($commande->date_livraison,'%A %d %B %Y'); - } - print '
'.$langs->trans('NotePublic').' :
'; - print nl2br($commande->note_public); - print '
'; - print ''; - - if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print '
'; - - if ($_GET['action'] == 'editdelivery_adress') - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); - } - else - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); - } - print '
'; + print ''; + if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print ''.img_edit($langs->trans('Edit')).'
'; + print '
'; + if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') + { + print '
'; + print ''; + print ''; + print ' '; + print '
'; + } + else + { + print $commande->ref_client; + } + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Date').''.dolibarr_print_date($commande->date,'%A %d %B %Y').''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ; + if ($commande->source == 0) + { + // Si source = propal + $propal = new Propal($db); + $propal->fetch($commande->propale_id); + print ' -> '.$propal->ref.''; + } + print '
'; + print ''; + + if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DateDelivery'); + print 'id.'">'.img_edit($langs->trans('SetDateDelivery'),1).'
'; + print '
'; + if ($_GET['action'] == 'editdate_livraison') + { + print '
'; + print ''; + $html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison"); + print ''; + print '
'; + } + else + { + print dolibarr_print_date($commande->date_livraison,'%A %d %B %Y'); + } + print '
'.$langs->trans('NotePublic').' :
'; + print nl2br($commande->note_public); + print '
'; + print ''; + + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; + print '
'; + + if ($_GET['action'] == 'editdelivery_adress') + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + } + else + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); + } + print '
'; print '
'; print $langs->trans('PaymentConditionsShort'); @@ -399,42 +397,40 @@ if ($_GET["id"] > 0) * Boutons Actions */ if ($user->societe_id == 0) - { + { print '
'; // 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 "
"; } + print '
'; - - print ''; print ''; print ''; /*
'; - - /* - * Documents générés - * - */ - $comref = sanitize_string($commande->ref); - $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; - $relativepath = $comref.'/'.$comref.'.pdf'; - $filedir = $conf->commande->dir_output . '/' . $comref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; - $genallowed=0; - $delallowed=0; - - $somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); + /* + * Documents générés + * + */ + $comref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->dir_output . '/' . $comref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; + $genallowed=0; + $delallowed=0; + + $somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); print ''; - // Bouton expedier avec gestion des stocks + // Bouton expedier avec gestion des stocks if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) { print_titre($langs->trans("NewSending")); @@ -448,13 +444,26 @@ if ($_GET["id"] > 0) $entrepot = new Entrepot($db); $langs->load("stocks"); + + print '
'.$langs->trans("Warehouse").''; - $html->select_array("entrepot_id",$entrepot->list_array()); + + if (sizeof($user->entrepots) === 1) + { + $uentrepot = array(); + $uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label']; + $html->select_array("entrepot_id",$uentrepot); + } + else + { + $html->select_array("entrepot_id",$entrepot->list_array()); + } + if (sizeof($entrepot->list_array()) <= 0) { - print '   Aucun entrepôt définit, definissez en un'; + print '   Aucun entrepôt définit, definissez en un'; } print '