diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index a740b5e7e24..b93e67798c6 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -1089,23 +1089,29 @@ class Commande extends CommonObject } /** - * \brief Charge tableau avec les expeditions par ligne - * \param filtre_statut Filtre sur statut - * \return int <0 if KO, Nb of records if OK + * \brief Load array this->expeditions of nb of products sent by line in order + * \param filtre_statut Filter on status + * \return int <0 if KO, Nb of lines found if OK */ function loadExpeditions($filtre_statut=-1) { $num=0; $this->expeditions = array(); - $sql = 'SELECT fk_product, sum(ed.qty)'; - $sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd'; - $sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_commande = c.rowid'; - $sql.=' AND cd.fk_commande =' .$this->id; + $sql = 'SELECT cd.rowid, cd.fk_product,'; + $sql.= ' sum(ed.qty) as qty'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,'; + if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,'; + $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd'; + $sql.= ' WHERE'; + if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND'; + $sql.= ' ed.fk_origin_line = cd.rowid'; + $sql.= ' AND cd.fk_commande =' .$this->id; if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut; - $sql .= ' GROUP BY fk_product '; - - dolibarr_syslog("Commande::loadExpedition sql=".$sql,LOG_DEBUG); + $sql.= ' GROUP BY cd.rowid, cd.fk_product'; + //print $sql; + + dolibarr_syslog("Commande::loadExpeditions sql=".$sql,LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -1113,8 +1119,8 @@ class Commande extends CommonObject $i = 0; while ($i < $num) { - $row = $this->db->fetch_row($result); - $this->expeditions[$row[0]] = $row[1]; + $obj = $this->db->fetch_object($result); + $this->expeditions[$obj->rowid] = $obj->qty; $i++; } $this->db->free(); @@ -1123,6 +1129,7 @@ class Commande extends CommonObject else { $this->error=$this->db->lasterror(); + dolibarr_syslog("Commande::loadExpeditions ".$this->error,LOG_ERR); return -1; } diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index dc57c0ce323..792cdc8a9f9 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -21,10 +21,10 @@ // Code identique a /expedition/fiche.php /** - \file htdocs/expedition/commande.php - \ingroup expedition - \version $Id$ -*/ + \file htdocs/expedition/commande.php + \ingroup expedition + \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); @@ -43,13 +43,13 @@ $langs->load('deliveries'); $langs->load('stocks'); if (!$user->rights->commande->lire) - accessforbidden(); +accessforbidden(); // Sécurité accés client if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } // Chargement des permissions @@ -60,9 +60,9 @@ $error = $user->load_entrepots(); */ 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); } // Positionne ref commande client @@ -125,137 +125,137 @@ llxHeader('',$langs->trans("OrderCard")); if ($_GET["id"] > 0) { - $commande = New Commande($db); - if ( $commande->fetch($_GET["id"]) > 0) - { - $commande->loadExpeditions(1); + $commande = new Commande($db); + if ( $commande->fetch($_GET["id"]) > 0) + { + $commande->loadExpeditions(1); - $soc = new Societe($db); - $soc->fetch($commande->socid); + $soc = new Societe($db); + $soc->fetch($commande->socid); - $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author = new User($db); + $author->id = $commande->user_author_id; + $author->fetch(); $head = commande_prepare_head($commande); - dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder")); + dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder")); - /* - * Confirmation de la validation - * - */ - if ($_GET["action"] == 'cloture') - { - $html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture"); - print "
"; - } - - // Onglet commande - $nbrow=8; - if ($conf->projet->enabled) $nbrow++; - - 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 + /* + * Confirmation de la validation + * + */ + if ($_GET["action"] == 'cloture') + { + $html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture"); + print "
"; + } + + // Onglet commande + $nbrow=8; + if ($conf->projet->enabled) $nbrow++; + + print '
'.$langs->trans('Ref').''.$commande->ref.'
'; - print ''; - if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print ''.img_edit($langs->trans('Modify')).'
'; - 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,'daytext').''.$langs->trans('Source').' : '.$commande->getLabelSource(); - 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('DeliveryDate'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),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,'daytext'); - } - 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 '
'; + + // 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 print ''; - + // Projet if ($conf->projet->enabled) { $langs->load('projects'); - print ''; - } - + print ''; + } + // Lignes de 3 colonnes - // Total HT + // Total HT print ''; print ''; print ''; @@ -317,7 +317,7 @@ if ($_GET["id"] > 0) // Total TVA print ''; print ''; - + // Total TTC print ''; print ''; @@ -330,196 +330,197 @@ if ($_GET["id"] > 0) print '
'.$langs->trans('Ref').''.$commande->ref.'
'; + print ''; + if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print ''.img_edit($langs->trans('Modify')).'
'; + 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,'daytext').''.$langs->trans('Source').' : '.$commande->getLabelSource(); + 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('DeliveryDate'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),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,'daytext'); + } + 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'] != 'editconditions' && $commande->brouillon) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print '
'; @@ -284,32 +284,32 @@ if ($_GET["id"] > 0) $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none'); } print '
'; - print ''; - if ($_GET['action'] != 'classer' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('Project'); - print ''.img_edit($langs->trans('SetProject')).'
'; - print '
'; - if ($_GET['action'] == 'classer') - { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid'); - } - else - { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none'); - } - print '
'; + print ''; + if ($_GET['action'] != 'classer' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('Project'); + print ''.img_edit($langs->trans('SetProject')).'
'; + print '
'; + if ($_GET['action'] == 'classer') + { + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid'); + } + else + { + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none'); + } + print '
'.$langs->trans('AmountHT').''.price($commande->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($commande->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($commande->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'

'; - /** - * Lignes de commandes avec quantité livrées et reste à livrer - * Les quantités livrées sont stockées dans $commande->expeditions[fk_product] - */ - print ''; + /** + * Lignes de commandes avec quantité livrées et reste à livrer + * Les quantités livrées sont stockées dans $commande->expeditions[fk_product] + */ + print '
'; - $sql = "SELECT cd.fk_product, cd.description, cd.price, cd.qty, cd.rowid, cd.tva_tx, cd.subprice"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - $sql.= " WHERE cd.fk_commande = ".$commande->id; - $sql.= " AND p.fk_product_type <> 1"; - $sql.= " ORDER BY cd.rowid"; + $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx, cd.subprice"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; + $sql.= " WHERE cd.fk_commande = ".$commande->id; + // $sql.= " AND p.fk_product_type <> 1"; Why this line ? + $sql.= " ORDER BY cd.rowid"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + dolibarr_syslog("commande.php sql=".$sql, LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } - print "\n"; - - $var=true; - $reste_a_livrer = array(); - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - $product = new Product($db); - $product->fetch($objp->fk_product); - print ''; - } - else - { - print "\n"; - } - - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->stock->enabled) + { + print ''; + } + else + { + print ''; + } + print "\n"; - print ''; + $var=true; + $reste_a_livrer = array(); + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ""; + if ($objp->fk_product > 0) + { + $product = new Product($db); + $product->fetch($objp->fk_product); + print ''; + } + else + { + print "\n"; + } - $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree; - $reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product]; - print ''; + print ''; - if ($conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } - print ""; - - $i++; - $var=!$var; - } - $db->free($resql); - - if (! $num) - { - print '
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("Stock").' 
'; - print ''; - print img_object($langs->trans("Product"),"product").' '.$product->ref.''; - print $product->libelle?' - '.$product->libelle:''; - print '".nl2br($objp->description)."'.$objp->qty.'
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("Stock").' 
'; - $quantite_livree = $commande->expeditions[$objp->fk_product]; - print $quantite_livree; - print '
'; + print ''; + print img_object($langs->trans("Product"),"product").' '.$product->ref.''; + print $product->libelle?' - '.$product->libelle:''; + print '".nl2br($objp->description)."'; - print $reste_a_livrer[$objp->fk_product]; - print ''.$objp->qty.''; - print $product->stock_reel; - if ($product->stock_reel < $reste_a_livrer[$objp->fk_product]) - { - print ' '.img_warning($langs->trans("StockTooLow")); - } - print ' 
'.$langs->trans("NoArticleOfTypeProduct").'
'; - } - - print "
"; - } - else - { - dolibarr_print_error($db); - } - - print ''; - - - /* - * 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 "
"; - } - - - // Bouton expedier avec gestion des stocks - - print '
'; - - if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) - { - print_titre($langs->trans("NewSending")); - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - $entrepot = new Entrepot($db); - $langs->load("stocks"); - - print ''; - print ''; - print ''; - /* - print ''; - print ''; - */ - - print ''; - - print "
'.$langs->trans("Warehouse").''; - - 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 '
Mode d\'expédition'; - $html->select_array("entrepot_id",$entrepot->list_array()); - print '
'; - print ''; - print '
"; - print "
\n"; - - $somethingshown=1; - } - - print "
"; + print ''; + // Nb of sending products for this line of order + $quantite_livree = $commande->expeditions[$objp->rowid]; + print $quantite_livree; + print ''; - print '
'; - show_list_sending_receive('commande',$commande->id); - + $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree; + $reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product]; + print ''; + print $reste_a_livrer[$objp->fk_product]; + print ''; - } - else - { - /* Commande non trouvée */ - print "Commande inexistante"; - } + if ($conf->stock->enabled) + { + print ''; + print $product->stock_reel; + if ($product->stock_reel < $reste_a_livrer[$objp->fk_product]) + { + print ' '.img_warning($langs->trans("StockTooLow")); + } + print ''; + } + else + { + print ' '; + } + print ""; + + $i++; + $var=!$var; + } + $db->free($resql); + + if (! $num) + { + print ''.$langs->trans("NoArticleOfTypeProduct").'
'; + } + + print ""; + } + else + { + dolibarr_print_error($db); + } + + print ''; + + + /* + * 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 "
"; + } + + + // Bouton expedier avec gestion des stocks + + print '
'; + + if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) + { + print_titre($langs->trans("NewSending")); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $entrepot = new Entrepot($db); + $langs->load("stocks"); + + print ''; + print ''; + print ''; + /* + print ''; + print ''; + */ + + print ''; + + print "
'.$langs->trans("Warehouse").''; + + 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 '
Mode d\'expédition'; + $html->select_array("entrepot_id",$entrepot->list_array()); + print '
'; + print ''; + print '
"; + print "
\n"; + + $somethingshown=1; + } + + print "
"; + + print '
'; + show_list_sending_receive('commande',$commande->id); + + } + else + { + /* Commande non trouvée */ + print "Commande inexistante"; + } } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index fa11cfa46e0..4577c3a5e8d 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -214,230 +214,229 @@ if ($_GET["action"] == 'create') $class = ucfirst($origin); $object = new $class($db); - $object->loadExpeditions(); - if ( $object->fetch($origin_id)) + if ($object->fetch($origin_id)) { - $soc = new Societe($db); - $soc->fetch($object->socid); + $soc = new Societe($db); + $soc->fetch($object->socid); - $author = new User($db); - $author->id = $object->user_author_id; - $author->fetch(); + $author = new User($db); + $author->id = $object->user_author_id; + $author->fetch(); - if ($conf->stock->enabled) $entrepot = new Entrepot($db); + 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 ''; + 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; + /* + * Document source + */ + print ''; + print ''; + print ''; + print ''; + if ($_GET["entrepot_id"]) + { + print ''; } - print '
'; - print $langs->trans('RefCustomer').''; - print $object->ref_client; - print '
'; - // Tiers - print ''; - print ''; - print ''; + // Ref + print ''; + print "\n"; - // Date - print ""; - print '\n"; + // Ref client + print ''; + print ''; - // Entrepot (si forcé) - if ($conf->stock->enabled && $_GET["entrepot_id"]) - { - print ''; - print ''; - } + // Tiers + print ''; + print ''; + print ''; - if ($object->note && ! $user->societe_id) - { - print '"; - } + // Date + print ""; + print '\n"; - // Delivery method - print ""; - print ''; + print ''; + } - $expe->fetch_delivery_methods(); - $html->select_array("expedition_method_id",$expe->meths); - print "\n"; - // Tracking number - print ""; - print '\n"; - print "
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'; + 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 '
".$langs->trans("Date")."'.dolibarr_print_date($object->date,"day")."
'; + print $langs->trans('RefCustomer').''; + print $object->ref_client; + print '
'.$langs->trans("Warehouse").''; - $ents = $entrepot->list_array(); - print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans("NotePrivate").': '.nl2br($object->note)."
".$langs->trans("Date")."'.dolibarr_print_date($object->date,"day")."
".$langs->trans("DeliveryMethod")."'; + // Entrepot (si forcé) + if ($conf->stock->enabled && $_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("TrackingNumber")."'; - print ''; - print "
"; + if ($object->note && ! $user->societe_id) + { + print ''.$langs->trans("NotePrivate").': '.nl2br($object->note).""; + } - /* - * Lignes de commandes - * - */ - print '
'; + // Delivery method + print ""; + print '\n"; + // Tracking number + print ""; + print '\n"; + print "
".$langs->trans("DeliveryMethod")."'; - //$lignes = $object->fetch_lines(1); - $numAsked = sizeof($object->lignes); + $expe->fetch_delivery_methods(); + $html->select_array("expedition_method_id",$expe->meths); + print "
".$langs->trans("TrackingNumber")."'; + print ''; + print "
"; - /* Lecture des expeditions déjà effectuées */ - $object->loadExpeditions(); + /* + * Lignes de commandes + * + */ + print '
'; - if ($numAsked) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->stock->enabled) - { - if ($_GET["entrepot_id"]) - { - print ''; - } - else - { - print ''; - } - } - print "\n"; - } + //$lignes = $object->fetch_lines(1); + $numAsked = sizeof($object->lignes); - $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); + /* Lecture des expeditions déjà effectuées */ + $object->loadExpeditions(); - print ''; - } - else - {var_dump($ligne); - 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; - } + if ($numAsked) + { + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->stock->enabled) + { + if ($_GET["entrepot_id"]) + { + print ''; + } + else + { + print ''; + } + } + print "\n"; + } - // Quantité à livrer - print ''; + $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); - // Stock - if ($_GET["entrepot_id"]) - { - print ''; - } - else - { - $array=array(); + print ''; + } + else + {var_dump($ligne); + print "\n"; + } - $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 ''; - print ''; - } - } - else - { - // Quantité à livrer - print ''; - } - - print "\n"; - - $indiceAsked++; - } + 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 ''; + } + } + else + { + // Quantité à livrer + print ''; + } + + print "\n"; + + $indiceAsked++; + } /* * @@ -449,7 +448,7 @@ if ($_GET["action"] == 'create') } else { - dolibarr_print_error($db); + dolibarr_print_error($db); } } } @@ -462,7 +461,7 @@ else { if ($_GET["id"] > 0) { - $expedition = New Expedition($db); + $expedition = new Expedition($db); $result = $expedition->fetch($_GET["id"]); if ($result < 0) { @@ -582,7 +581,7 @@ else // Date print ''; - print '\n"; + print '\n"; print ''; // Poids Total @@ -715,7 +714,7 @@ else /* - * Documents générés + * Documents generated */ if ($conf->expedition_bon->enabled) { @@ -740,8 +739,9 @@ else 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->desc) print nl2br($ligne->desc); - print '".nl2br($ligne->desc)."'.$ligne->qty.''; - $quantityDelivered = $object->expeditions[$ligne->fk_product]; - print $quantityDelivered; - print '
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").''.$langs->trans("Stock").''.$langs->trans("Warehouse").'
'; - 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->desc) print nl2br($ligne->desc); + print '".nl2br($ligne->desc)."'.$ligne->qty.''; - $html->select_array('entl'.$i,$array,'',1,0,0); - print ''; - print ''; - print ''; - print '
'; + $quantityDelivered = $object->expeditions[$ligne->id]; + 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 '
'.$langs->trans("Date").''.dolibarr_print_date($expedition->date,"day")."'.dolibarr_print_date($expedition->date,"daytext")."
'; print '
'; - show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); - + //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); + show_list_sending_receive($expedition->origin,$expedition->origin_id); + } else { diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php index 329a29b2e09..7cacec03055 100644 --- a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php @@ -167,7 +167,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->SetFont('Arial','', 7); //Insertion de l entete - $this->_pagehead($pdf, $this->expe); + $this->_pagehead($pdf, $this->expe, $outputlangs); //Initialisation des coordonnées $tab_top = 53; @@ -180,7 +180,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $curY = $pdf->GetY(); $nexY = $pdf->GetY(); //Generation du tableau - $this->_tableau($pdf, $tab_top, $tab_height, $nexY); + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); //Recuperation des produits de la commande. $this->expe->commande->fetch_lines(1); $Produits = $this->expe->commande->lignes; @@ -199,27 +199,32 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Insertion du libelle $pdf->SetFont('Arial','', 7); $pdf->SetXY (50, $curY ); - $pdf->MultiCell(130, 5, $Prod->libelle, 0, 'L', 0); - //Insertion de la quantite + $pdf->MultiCell(90, 5, $Prod->libelle, 0, 'L', 0); + //Insertion de la quantite commandée $pdf->SetFont('Arial','', 7); - $pdf->SetXY (180, $curY ); - $pdf->MultiCell(20, 5, $Produits[$i]->qty, 0, 'L', 0); + $pdf->SetXY (140, $curY ); + $pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_asked, 0, 'C', 0); + //Insertion de la quantite à envoyer + $pdf->SetFont('Arial','', 7); + $pdf->SetXY (170, $curY ); + $pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_shipped, 0, 'C', 0); + //Generation de la page 2 $curY += 4; $nexY = $curY; if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1){ - $this->_tableau($pdf, $tab_top, $tab_height, $nexY); - $this->_pagefoot($pdf); + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + $this->_pagefoot($pdf, $outputlangs); $pdf->AliasNbPages(); $pdf->AddPage(); $nexY = $iniY; - $this->_pagehead($pdf, $this->expe); + $this->_pagehead($pdf, $this->expe, $outputlangs); $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','', 7); } } //Insertion du pied de page - $this->_pagefoot($pdf); + $this->_pagefoot($pdf, $outputlangs); $pdf->AliasNbPages(); @@ -252,7 +257,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //******************************** // Generation du tableau //******************************** - function _tableau(&$pdf, $tab_top, $tab_height, $nexY) + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) { global $langs; @@ -267,18 +272,20 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->MultiCell(10,5,"LR",0,'C',1); $pdf->line(30, $tab_top, 30, $tab_top + $tab_height); $pdf->SetXY(30,$tab_top); - $pdf->MultiCell(20,5,$langs->transnoentities("Ref"),0,'C',1); + $pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1); $pdf->SetXY(50,$tab_top); - $pdf->MultiCell(130,5,$langs->transnoentities("Description"),0,'L',1); - $pdf->SetXY(180,$tab_top); - $pdf->MultiCell(20,5,$langs->transnoentities("Quantity"),0,'L',1); + $pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1); + $pdf->SetXY(140,$tab_top); + $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1); + $pdf->SetXY(170,$tab_top); + $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1); $pdf->Rect(10, $tab_top, 190, $tab_height); } //******************************** // Generation du Pied de page //******************************** - function _pagefoot(&$pdf) + function _pagefoot(&$pdf, $outputlangs) { $pdf->SetFont('Arial','',8); $pdf->SetY(-23); @@ -295,7 +302,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //******************************** // Generation de l entete //******************************** - function _pagehead(&$pdf, $exp) + function _pagehead(&$pdf, $exp, $outputlangs) { global $conf, $langs; @@ -331,7 +338,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->SetXY(60,7); $pdf->SetFont('Arial','B',14); $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(0, 8, $langs->transnoentities("SendingSheet"), '' , 'L'); // Bordereau expedition + $pdf->MultiCell(0, 8, $outputlangs->transnoentities("SendingSheet"), '' , 'L'); // Bordereau expedition //Num Expedition $Yoff = $Yoff+7; $Xoff = 140; @@ -339,7 +346,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->SetXY($Xoff,$Yoff); $pdf->SetFont('Arial','',8); $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(0, 8, $langs->transnoentities("RefSending").': '.$exp->ref, '' , 'L'); + $pdf->MultiCell(0, 8, $outputlangs->transnoentities("RefSending").': '.$exp->ref, '' , 'L'); //$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //Num Commande $Yoff = $Yoff+4; @@ -347,7 +354,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->SetXY($Xoff,$Yoff); $pdf->SetFont('Arial','',8); $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(0, 8, $langs->transnoentities("RefOrder").': '.$exp->commande->ref, '' , 'L'); + $pdf->MultiCell(0, 8, $outputlangs->transnoentities("RefOrder").': '.$exp->commande->ref, '' , 'L'); $Xoff = 115; //$this->Code39($Xoff+43, $Yoff+1, $exp->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); @@ -491,7 +498,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Tel Client $pdf->SetXY($blDestX,$Yoff+$blSocY); $pdf->SetFont('Arial','',7); - $pdf->MultiCell($blW,3, "Tel : ".$this->destinataire->phone_pro, 0, 'L'); + $pdf->MultiCell($blW,3, $outputlangs->trans("Tel")." : ".$this->destinataire->phone_pro, 0, 'L'); } } ?> diff --git a/htdocs/langs/en_US/deliveries.lang b/htdocs/langs/en_US/deliveries.lang index 5a570a47a13..4fbe394d624 100644 --- a/htdocs/langs/en_US/deliveries.lang +++ b/htdocs/langs/en_US/deliveries.lang @@ -5,6 +5,7 @@ DeliveryCard=Delivery card DeliveryOrder=Delivery order DeliveryOrders=Delivery orders DeliveryDate=Delivery date +DeliveryDateShort=Deliv. date CreateDeliveryOrder=Generate delivery order SetDeliveryDate=Set shipping date ValidateDeliveryReceipt=Validate delivery receipt diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 3d3fd8b7d85..91814da1ded 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -21,7 +21,8 @@ QtyToShip=Qty to ship QtyReceived=Qty received KeepToShip=Keep to ship OtherSendingsForSameOrder=Other sendings for this order -DateSending=Date sending +DateSending=Date sending order +DateSendingShort=Date sending order SendingsForSameOrder=Sendings for this order SendingsAndReceivingForSameOrder=Sendings and receivings for this order SendingsToValidate=Sending to validate diff --git a/htdocs/langs/fr_FR/deliveries.lang b/htdocs/langs/fr_FR/deliveries.lang index b577ec8057c..59557dbab97 100644 --- a/htdocs/langs/fr_FR/deliveries.lang +++ b/htdocs/langs/fr_FR/deliveries.lang @@ -5,6 +5,7 @@ DeliveryCard=Fiche livraison DeliveryOrder=Bon de livraison DeliveryOrders=Bons de livraison DeliveryDate=Date de livraison +DeliveryDateShort=Date livr. CreateDeliveryOrder=Générer bon de livraison QtyDelivered=Qté livrée SetDeliveryDate=Définir la date de livraison diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 59fc73e3f07..bc218afa927 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -13,15 +13,16 @@ StatisticsOfSendings=Statistiques des exp NbOfSendings=Nombre d'expéditions SendingCard=Fiche expédition NewSending=Nouvelle expédition -CreateASending=Créer une expedition -CreateSending=Créer expedition +CreateASending=Créer une expédition +CreateSending=Créer expédition QtyOrdered=Qté commandée QtyShipped=Qté expédiée QtyToShip=Qté à expédier QtyReceived=Qté reçue KeepToShip=Reste à expédier OtherSendingsForSameOrder=Autres expéditions pour cette commande -DateSending=Date d'expedition +DateSending=Date ordre d'expédition +DateSendingShort=Date ordre expéd. SendingsForSameOrder=Expéditions pour cette commande SendingsAndReceivingForSameOrder=Expéditions et réceptions pour cette commande SendingsToValidate=Expéditions à valider diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php index 01cb3a7e26e..51cab637d63 100644 --- a/htdocs/lib/sendings.lib.php +++ b/htdocs/lib/sendings.lib.php @@ -17,10 +17,10 @@ */ /** - \file htdocs/lib/sendings.lib.php - \ingroup expedition - \brief Library for expedition module - \version $Id$ + * \file htdocs/lib/sendings.lib.php + * \ingroup expedition + * \brief Library for expedition module + * \version $Id$ */ @@ -37,10 +37,11 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') $sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.qty as qty_asked"; $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id"; $sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition"; - if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref"; - $sql.= " FROM ".MAIN_DB_PREFIX.$origin."det as obj"; - $sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; - if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid"; + if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, ".$db->pdate("l.date_livraison")." as date_delivery, ld.qty as qty_received"; + $sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,"; + $sql.= " ".MAIN_DB_PREFIX.$origin."det as obj,"; + $sql.= " ".MAIN_DB_PREFIX."expedition as e)"; + if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql.= " WHERE obj.fk_".$origin." = ".$origin_id; if ($filter) $sql.=$filter; $sql.= " AND obj.rowid = ed.fk_origin_line"; @@ -63,17 +64,16 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') print ''; print ''; - print ''; - print ''; - print ''; + print ''; + //print ''; + print ''; + print ''; print ''; - if ($conf->expedition_bon->enabled) - { - print ''; - } - if ($conf->livraison_bon->enabled) + if ($conf->livraison_bon->enabled) { print ''; + print ''; + print ''; } print "\n"; @@ -83,7 +83,8 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') $var=!$var; $objp = $db->fetch_object($resql); print ""; - print ''; + + // Description if ($objp->fk_product > 0) { $product = new Product($db); @@ -98,21 +99,28 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') { print "\n"; } + + //print ''; + + // Sending id + print ''; + print ''; + print ''; - if ($conf->expedition_bon->enabled) - { - print ''; - } if ($conf->livraison_bon->enabled) { if ($objp->livraison_id) { print ''; + print ''; + print ''; } else { print ''; + print ''; + print ''; } } print ''; diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 21ee602b83b..c7a6430cfee 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -21,15 +21,16 @@ */ /** - \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"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/sendings.lib.php"); if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php"); if ($conf->expedition_bon->enabled) require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php"); if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); @@ -42,7 +43,7 @@ if (!$user->rights->expedition->livraison->lire) accessforbidden(); -// S�curit� acc�s client +// Security check if ($user->societe_id > 0) { $action = ''; @@ -125,6 +126,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { Header("Location: liste.php"); } + exit; } } @@ -234,7 +236,7 @@ if ($_GET["action"] == 'create') if ($commande->note) { - print '"; + print '"; } print "
'.$langs->trans("Ref").''.$langs->trans("Description").''.$langs->trans("Qty").''.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("SendingSheet").''.$langs->trans("QtyShipped").''.$langs->trans("DateSending").''.$langs->trans("SendingSheet").''.$langs->trans("DeliveryOrder").''.$langs->trans("QtyReceived").''.$langs->trans("DeliveryDate").'
'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'".dol_htmlentitiesbr(dolibarr_trunc($objp->description,24))."'.$objp->qty_asked.''.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.''.$objp->qty_shipped.''.dolibarr_print_date($objp->date_expedition,'dayhour').''.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.''.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.''.$objp->qty_received.''.dolibarr_print_date($objp->date_delivery,'dayhour').'   
Note : '.nl2br($commande->note)."
Note : '.nl2br($commande->note)."
"; @@ -254,84 +256,84 @@ if ($_GET["action"] == 'create') if ($num) { - print ''; - print ''.$langs->trans("Description").''; - print 'Quan. command�e'; - print 'Quan. livr�e'; - print 'Quan. � livrer'; - if ($conf->stock->enabled) - { - print ''.$langs->trans("Stock").''; - } - print "\n"; + print ''; + print ''.$langs->trans("Description").''; + print 'Quan. command�e'; + print 'Quan. livr�e'; + print 'Quan. � livrer'; + if ($conf->stock->enabled) + { + print ''.$langs->trans("Stock").''; + } + print "\n"; } $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 ''; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($ligne->description) print nl2br($ligne->description); - print ''; - } - else - { - print "".nl2br($ligne->description)."\n"; - } - - print ''.$ligne->qty.''; - /* - * - */ - print ''; - $quantite_livree = $commande->livraisons[$ligne->fk_product]; - print $quantite_livree;; - print ''; + $ligne = $commande->lignes[$i]; + $var=!$var; + print "\n"; + if ($ligne->fk_product > 0) + { + $product = new Product($db); + $product->fetch($ligne->fk_product); - $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 + print ''; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($ligne->description) print nl2br($ligne->description); + print ''; + } + else + { + print "".nl2br($ligne->description)."\n"; + } - // Quantit� � livrer - print ''; - print ''; - print ''; - print ''; + print ''.$ligne->qty.''; + /* + * + */ + print ''; + $quantite_livree = $commande->livraisons[$ligne->id]; + print $quantite_livree;; + print ''; - // Stock - if ($stock < $quantite_a_livrer) - { - print ''.$stock.' '.img_alerte().''; - } - else - { - print ''.$stock.''; - } - } - else - { - // Quantit� � livrer - print ''; - print ''; - print ''; - print ''; - } + $quantite_commandee = $ligne->qty; + $quantite_a_livrer = $quantite_commandee - $quantite_livree; - print "\n"; - - $i++; - $var=!$var; + if ($conf->stock->enabled) + { + $stock = $product->stock_entrepot[$_GET["entrepot_id"]]; + $stock+=0; // Convertit en num�rique + + // Quantit� � livrer + print ''; + print ''; + print ''; + print ''; + + // Stock + if ($stock < $quantite_a_livrer) + { + print ''.$stock.' '.img_alerte().''; + } + else + { + print ''.$stock.''; + } + } + else + { + // Quantit� � livrer + print ''; + print ''; + print ''; + print ''; + } + + print "\n"; + + $i++; + $var=!$var; } /* @@ -359,6 +361,9 @@ else $livraison = new Livraison($db); $result = $livraison->fetch($_GET["id"]); $livraison->fetch_client(); + + $expedition=new Expedition($db); + $result = $expedition->fetch($livraison->expedition_id); if ($livraison->origin_id) { @@ -370,7 +375,7 @@ else { $soc = new Societe($db); $soc->fetch($livraison->socid); - + $h=0; if ($conf->expedition_bon->enabled) { @@ -378,7 +383,7 @@ else $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; @@ -427,7 +432,7 @@ else { print ''.$langs->trans("RefOrder").''; $order=new Commande($db); - $order->fetch($livraison->origin_id); + $order->fetch($expedition->origin_id); print ''; print $order->getNomUrl(1,4); print "\n"; @@ -481,13 +486,13 @@ else if ($num_prod) { $i = 0; - + print ''; print ''.$langs->trans("Products").''; print ''.$langs->trans("QtyOrdered").''; print ''.$langs->trans("QtyReceived").''; print "\n"; - + $var=true; while ($i < $num_prod) { @@ -497,7 +502,7 @@ else { $product = new Product($db); $product->fetch($livraison->lignes[$i]->fk_product); - + print ''; print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; if ($livraison->lignes[$i]->description) print '
'.$livraison->lignes[$i]->description; @@ -529,7 +534,7 @@ else if ($user->societe_id == 0) { print '
'; - + if (! eregi('^(valid|delete)',$_REQUEST["action"])) { if ($livraison->statut == 0 && $user->rights->expedition->livraison->valider && $num_prod > 0) @@ -549,15 +554,15 @@ else } } } - + print '
'; } print "\n"; - + print "
"; - + /* - * Documents g�n�r�s + * Documents generated */ $livraisonref = sanitize_string($livraison->ref); @@ -568,81 +573,17 @@ else $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); - } + if ($genallowed && ! $somethingshown) $somethingshown=1; print '
'; - // Rien � droite - + // Rien a droite + print '
'; + + print '
'; + //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); + show_list_sending_receive($expedition->origin,$expedition->origin_id); } else { diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index ec197b6b2f9..6a865afa62d 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -633,10 +633,11 @@ class Livraison extends CommonObject $this->lignes = array(); $sql = "SELECT p.label, p.ref,"; - $sql.= " l.description, l.fk_product, l.subprice, l.total_ht, l.qty as qty_shipped"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraisondet as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = l.fk_product"; - $sql.= " WHERE l.fk_livraison = ".$this->id; + $sql.= " cd.qty as qty_asked,"; + $sql.= " ld.description, ld.fk_product, ld.subprice, ld.total_ht, ld.qty as qty_shipped"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product"; + $sql.= " WHERE ld.fk_origin_line = cd.rowid AND ld.fk_livraison = ".$this->id; dolibarr_syslog("Livraison::fetch_lignes sql=".$sql); $resql = $this->db->query($sql); diff --git a/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php b/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php index e2dece74534..522737af296 100644 --- a/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php +++ b/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php @@ -153,7 +153,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($user->fullname); - $this->_pagehead($pdf, $delivery); + $this->_pagehead($pdf, $delivery, $outputlangs); $pagenb = 1; $tab_top = 100;