diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 061b876328d..11f9b3d2b68 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -659,7 +659,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) if ($prop->lignes[$i]->date_debut_reel) $date_start=$prop->lignes[$i]->date_debut_reel; $date_end=$prop->lignes[$i]->date_fin_prevue; if ($prop->lignes[$i]->date_fin_reel) $date_end=$prop->lignes[$i]->date_fin_reel; - + $result = $facture->addline( $facid, $desc, @@ -961,7 +961,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST $date_end=''; $date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']); $date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']); - + // Define info_bits $info_bits=0; if (eregi('\*',$_POST['tva_tx'])) $info_bits |= 0x01; @@ -2605,7 +2605,7 @@ else } else { - if ($objp->product_type==1) $text = img_object($langs->trans('Service'),'service'); + if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); print $text.' '.nl2br($objp->description); print_date_range($objp->date_start,$objp->date_end); diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 8c29c57e070..48e19878fbe 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -84,7 +84,7 @@ class Expedition extends CommonObject // Clean parameters $this->brouillon = 1; $this->tracking_number = sanitizeFileName($this->tracking_number); - + $this->user = $user; @@ -125,7 +125,7 @@ class Expedition extends CommonObject { $error++; } - + $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id; if (! $this->db->query($sql)) { @@ -139,7 +139,7 @@ class Expedition extends CommonObject { $error++; } - + //Todo: definir un statut $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id; if (! $this->db->query($sql)) @@ -592,7 +592,7 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked"; $sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; - $sql.= ", p.ref, p.label, p.weight, p.weight_units, p.volume, p.volume_units"; + $sql.= ", p.ref, p.fk_product_type, p.label, p.weight, p.weight_units, p.volume, p.volume_units"; $sql.= " FROM (".MAIN_DB_PREFIX."commandedet as cd"; $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = cd.fk_product)"; @@ -612,7 +612,9 @@ class Expedition extends CommonObject $ligne->origin_line_id = $obj->fk_origin_line; $ligne->entrepot_id = $obj->fk_entrepot; $ligne->fk_product = $obj->fk_product; + $ligne->fk_product_type= $obj->fk_product_type; $ligne->ref = $obj->ref; + $ligne->label = $obj->label; // deprecated $ligne->libelle = $obj->label; $ligne->description = $obj->description; $ligne->qty_asked = $obj->qty_asked; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 0fdd5dd640e..629d8090e55 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -742,16 +742,34 @@ else for ($i = 0 ; $i < $num_prod ; $i++) { print ""; + if ($lignes[$i]->fk_product > 0) { print ''; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$lignes[$i]->ref.' - '.$lignes[$i]->libelle; - if ($lignes[$i]->description) print '
'.nl2br($lignes[$i]->description); - print ''; + + // Affiche ligne produit + $text = ''; + if ($lignes[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); + else $text.= img_object($langs->trans('ShowProduct'),'product'); + $text.= ' '.$lignes[$i]->ref.''; + $text.= ' - '.$lignes[$i]->label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($lignes[$i]->description)); + //print $description; + print $html->textwithtooltip($text,$description,3,'','',$i); + print_date_range($lignes[$i]->date_start,$lignes[$i]->date_end); + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($lignes[$i]->description && $lignes[$i]->description!=$lignes[$i]->product)?'
'.dol_htmlentitiesbr($lignes[$i]->description):''; + } } else { - print "".nl2br($lignes[$i]->description)."\n"; + print ""; + if ($lignes[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($lignes[$i]->description); + print_date_range($lignes[$i]->date_start,$lignes[$i]->date_end); + print "\n"; } // Qte commande diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index 40ae34edbbc..27b3b9403d7 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -49,6 +49,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $langs->load("main"); $langs->load("bills"); $langs->load("sendings"); + $langs->load("companies"); $this->db = $db; $this->name = "sirocco"; @@ -68,7 +69,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $this->emetteur=$mysoc; if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'�tait pas d�fini - $this->error = ""; + $this->tva=array(); } @@ -93,6 +94,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO + $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); @@ -118,6 +120,8 @@ class pdf_sirocco extends ModelePDFDeliveryOrder } } + $nblignes = sizeof($delivery->lignes); + $deliveryref = sanitizeFileName($delivery->ref); $dir = $conf->livraison_bon->dir_output; if (! eregi('specimen',$deliveryref)) $dir.= "/" . $deliveryref; @@ -159,28 +163,25 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $pdf->SetKeyWords($outputlangs->convToOutputCharset($delivery->ref)." ".$outputlangs->transnoentities("DeliveryOrder")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetAutoPageBreak(1,0); + // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $delivery, $outputlangs); + $this->_pagehead($pdf, $delivery, 1, $outputlangs); $pdf->SetFont('Arial','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); $tab_top = 100; + $tab_top_newpage = 50; $tab_height = 140; + $tab_height_newpage = 190; - $pdf->SetFillColor(220,220,220); - - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','', 10); - - $pdf->SetXY (10, $tab_top + 10 ); - - $iniY = $pdf->GetY(); - $curY = $pdf->GetY(); - $nexY = $pdf->GetY(); - $nblignes = sizeof($delivery->lignes); + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; for ($i = 0 ; $i < $nblignes ; $i++) { @@ -189,51 +190,107 @@ class pdf_sirocco extends ModelePDFDeliveryOrder // Description de la ligne produit $libelleproduitservice=pdf_getlinedesc($delivery->lignes[$i],$outputlangs); - $pdf->SetXY (30, $curY ); + $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); + $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page $nexY = $pdf->GetY(); $pdf->SetXY (10, $curY ); - $pdf->MultiCell(20, 5, $outputlangs->convToOutputCharset($delivery->lignes[$i]->ref), 0, 'C'); + $pdf->MultiCell(20, 3, $outputlangs->convToOutputCharset($delivery->lignes[$i]->ref), 0, 'C'); // \TODO Field not yet saved in database //$pdf->SetXY (133, $curY ); //$pdf->MultiCell(10, 5, $delivery->lignes[$i]->tva_tx, 0, 'C'); $pdf->SetXY (145, $curY ); - $pdf->MultiCell(10, 5, $delivery->lignes[$i]->qty_shipped, 0, 'C'); + $pdf->MultiCell(10, 3, $delivery->lignes[$i]->qty_shipped, 0, 'C'); // \TODO Field not yet saved in database //$pdf->SetXY (156, $curY ); - //$pdf->MultiCell(18, 5, price($delivery->lignes[$i]->price), 0, 'R', 0); + //$pdf->MultiCell(18, 3, price($delivery->lignes[$i]->price), 0, 'R', 0); // \TODO Field not yet saved in database //$pdf->SetXY (174, $curY ); //$total = price($delivery->lignes[$i]->price * $delivery->lignes[$i]->qty_shipped); - //$pdf->MultiCell(26, 5, $total, 0, 'R', 0); + //$pdf->MultiCell(26, 3, $total, 0, 'R', 0); - $pdf->line(10, $curY, 200, $curY ); + $pdf->line(10, $curY-1, 200, $curY-1); - if ($nexY > 240 && $i < $nblignes - 1) + + $nexY+=2; // Passe espace entre les lignes + + // Cherche nombre de lignes a venir pour savoir si place suffisante + if ($i < ($nblignes - 1)) // If it's not last line { - $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + //on récupère la description du produit suivant + $follow_descproduitservice = $delivery->lignes[$i+1]->desc; + //on compte le nombre de ligne afin de vérifier la place disponible (largeur de ligne 52 caracteres) + $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4); + } + else // If it's last line + { + $nblineFollowDesc = 0; + } - $nexY = $iniY; + // Test if a new page is required + if ($pagenb == 1) + { + $tab_top_in_current_page=$tab_top; + $tab_height_in_current_page=$tab_height; + } + else + { + $tab_top_in_current_page=$tab_top_newpage; + $tab_height_in_current_page=$tab_height_newpage; + } + + if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); + } + + $this->_pagefoot($pdf, $outputlangs); // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $delivery, $outputlangs); + $this->_pagehead($pdf, $delivery, 0, $outputlangs); $pdf->SetFont('Arial','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); + + $nexY = $tab_top_newpage + 7; } } - $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top + $tab_height + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); + $bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; + } + + /* + * Pied de page + */ + $this->_pagefoot($pdf,$outputlangs); + $pdf->AliasNbPages(); + + $pdf->Close(); $pdf->Output($file); if (! empty($conf->global->MAIN_UMASK)) @@ -250,7 +307,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder } /** - * \brief Affiche la grille des lignes de propales + * \brief Affiche la grille des lignes * \param pdf objet PDF */ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) @@ -283,17 +340,22 @@ class pdf_sirocco extends ModelePDFDeliveryOrder } /** - * \brief Affiche en-tete propale - * \param pdf objet PDF - * \param fac objet propale + * \brief Affiche en-tete + * \param pdf objet PDF + * \param delivery object delivery * \param showadress 0=non, 1=oui */ - function _pagehead(&$pdf, $delivery, $outputlangs) + function _pagehead(&$pdf, $delivery, $showadress=1, $outputlangs) { global $langs; - $outputlangs->load("deliveries"); - $pdf->SetXY(10,5); + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',13); + + $posy=$this->marge_haute; + + $pdf->SetXY($this->marge_gauche,$posy); + if (defined("MAIN_INFO_SOCIETE_NOM")) { $pdf->SetTextColor(0,0,200); @@ -316,7 +378,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($this->emetteur->url); $pdf->SetFont('Arial','',9); - $pdf->SetXY(10,10); + $pdf->SetXY($this->marge_gauche,$posy+4); $pdf->MultiCell(80,3, $carac_emetteur); /* diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index c68ec5058d8..6e90af6c5ab 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -53,6 +53,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $langs->load("main"); $langs->load("bills"); $langs->load("sendings"); + $langs->load("companies"); $this->db = $db; $this->name = "typhon"; @@ -79,8 +80,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->emetteur=$mysoc; if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'�tait pas d�fini - $this->tva=array(); - // Defini position des colonnes $this->posxdesc=$this->marge_gauche+1; $this->posxcomm=120; @@ -90,6 +89,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->posxdiscount=162; $this->postotalht=177; + $this->tva=array(); $this->atleastoneratenotnull=0; $this->atleastonediscount=0; } @@ -115,6 +115,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO + $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); @@ -252,8 +253,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut - $nexY = $pdf->GetY(); + /* // TVA $pdf->SetXY ($this->posxtva, $curY); @@ -265,19 +266,19 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ // Quantity $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell(30, 4, $delivery->lignes[$i]->qty_shipped, 0, 'R'); + $pdf->MultiCell(30, 3, $delivery->lignes[$i]->qty_shipped, 0, 'R'); /* // Remise sur ligne $pdf->SetXY ($this->posxdiscount, $curY); if ($delivery->lignes[$i]->remise_percent) { - $pdf->MultiCell(14, 4, $delivery->lignes[$i]->remise_percent."%", 0, 'R'); + $pdf->MultiCell(14, 3, $delivery->lignes[$i]->remise_percent."%", 0, 'R'); } // Total HT ligne $pdf->SetXY ($this->postotalht, $curY); $total = price($delivery->lignes[$i]->price * $delivery->lignes[$i]->qty); - $pdf->MultiCell(23, 4, $total, 0, 'R', 0); + $pdf->MultiCell(23, 3, $total, 0, 'R', 0); // Collecte des totaux par valeur de tva // dans le tableau tva["taux"]=total_tva @@ -287,6 +288,19 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ $nexY+=2; // Passe espace entre les lignes + // Cherche nombre de lignes a venir pour savoir si place suffisante + if ($i < ($nblignes - 1)) // If it's not last line + { + //on récupère la description du produit suivant + $follow_descproduitservice = $delivery->lignes[$i+1]->desc; + //on compte le nombre de ligne afin de vérifier la place disponible (largeur de ligne 52 caracteres) + $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4); + } + else // If it's last line + { + $nblineFollowDesc = 0; + } + // Test if a new page is required if ($pagenb == 1) { @@ -314,7 +328,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $delivery, 1, $outputlangs); + $this->_pagehead($pdf, $delivery, 0, $outputlangs); $pdf->SetFont('Arial','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -363,7 +377,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder /* - * \brief Affiche la grille des lignes de propales + * \brief Affiche la grille des lignes * \param pdf objet PDF */ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) @@ -413,9 +427,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** * \brief Affiche en-tete bon livraison - * \param pdf objet PDF - * \param fac objet propale - * \param showadress 0=non, 1=oui + * \param pdf objet PDF + * \param delivery object delivery + * \param showadress 0=non, 1=oui */ function _pagehead(&$pdf, $delivery, $showadress=1, $outputlangs) { diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 0bf4ab784eb..15299a9c9c9 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -202,7 +202,7 @@ class pdf_propale_azur extends ModelePDFPropales $pagenb++; $this->_pagehead($pdf, $propale, 1, $outputlangs); $pdf->SetFont('Arial','', 9); - $pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 3 + $pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 4 $pdf->SetTextColor(0,0,0); $tab_top = 90; diff --git a/htdocs/langs/fr_FR/deliveries.lang b/htdocs/langs/fr_FR/deliveries.lang index e64ebd0be86..c5dd628e022 100644 --- a/htdocs/langs/fr_FR/deliveries.lang +++ b/htdocs/langs/fr_FR/deliveries.lang @@ -12,6 +12,8 @@ QtyDelivered=Qté livrée SetDeliveryDate=Définir la date de livraison ValidateDeliveryReceipt=Valider le bon de livraison ValidateDeliveryReceiptConfirm=Etes-vous sur de vouloir valider ce bon de livraison ? +DeleteDeliveryReceipt=Supprimer le bon de livraison +DeleteDeliveryReceiptConfirm=Etes-vous sur de vouloir supprimer ce bon de livraison ? DeliveryMethod=Méthode de livraison TrackingNumber=Numero de suivi diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index f9e06ad860f..ecf3cb775b6 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2005-2008 Regis Houssin @@ -365,7 +365,7 @@ else $expedition=new Expedition($db); $result = $expedition->fetch($livraison->expedition_id); - + if ($livraison->origin_id) { $object = $livraison->origin; @@ -399,7 +399,7 @@ else 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'); + $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id.'&expid='.$expedition_id,$langs->trans("DeleteDeliveryReceipt"),$langs->trans("DeleteDeliveryReceiptConfirm"),'confirm_delete'); print '
'; } @@ -475,52 +475,71 @@ else print ''; } - print "\n"; + print "
\n"; /* * Lignes produits */ - print '
'; $num_prod = sizeof($livraison->lignes); + $i = 0; $total = 0; + + print '
'; if ($num_prod) { $i = 0; - + print ''; print ''; print ''; print ''; print "\n"; - - $var=true; - while ($i < $num_prod) + } + $var=true; + while ($i < $num_prod) + { + $var=!$var; + + print ""; + if ($livraison->lignes[$i]->fk_product > 0) { - $var=!$var; - print ""; - if ($livraison->lignes[$i]->fk_product > 0) + $product = new Product($db); + $product->fetch($livraison->lignes[$i]->fk_product); + + print ''; + print ($livraison->lignes[$i]->description && $livraison->lignes[$i]->description!=$livraison->lignes[$i]->label)?'
'.dol_htmlentitiesbr($livraison->lignes[$i]->description):''; } - else - { - print "\n"; - } - - print ''; - print ''; - - print ""; - - $i++; } + else + { + print "\n"; + } + + print ''; + print ''; + + print ""; + + $i++; } print "
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").'
'; + + // Affiche ligne produit + $text = ''; + if ($livraison->lignes[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); + else $text.= img_object($langs->trans('ShowProduct'),'product'); + $text.= ' '.$livraison->lignes[$i]->ref.''; + $text.= ' - '.$livraison->lignes[$i]->label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($livraison->lignes[$i]->description)); + //print $description; + print $html->textwithtooltip($text,$description,3,'','',$i); + print_date_range($livraison->lignes[$i]->date_start,$livraison->lignes[$i]->date_end); + if ($conf->global->PRODUIT_DESC_IN_FORM) { - $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; - print '
".$livraison->lignes[$i]->description."'.$livraison->lignes[$i]->qty_asked.''.$livraison->lignes[$i]->qty_shipped.'
"; + if ($livraison->lignes[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($livraison->lignes[$i]->description); + print_date_range($objp->date_start,$objp->date_end); + print "'.$livraison->lignes[$i]->qty_asked.''.$livraison->lignes[$i]->qty_shipped.'
\n"; @@ -535,7 +554,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) @@ -555,7 +574,7 @@ else } } } - + print '
'; } print "\n"; @@ -579,7 +598,7 @@ else print ''; // Rien a droite - + print ''; print '
'; diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index db55703c940..d14afe7a014 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -50,8 +50,8 @@ class Livraison extends CommonObject var $date_livraison; var $date_creation; var $date_valid; - - + + /** * Initialisation * @@ -62,11 +62,11 @@ class Livraison extends CommonObject $this->db = $DB; $this->lignes = array(); - + $this->statuts[-1] = $langs->trans("Canceled"); $this->statuts[0] = $langs->trans("Draft"); $this->statuts[1] = $langs->trans("Validated"); - + $this->products = array(); } @@ -78,18 +78,18 @@ class Livraison extends CommonObject function create($user) { global $conf; - + dolibarr_syslog("Livraison::create"); - + $error = 0; - + /* On positionne en mode brouillon le bon de livraison */ $this->brouillon = 1; - + $this->user = $user; - + $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraison (ref, fk_soc, date_creation, fk_user_author,"; $sql.= " fk_adresse_livraison"; if ($this->expedition_id) $sql.= ", fk_expedition"; @@ -98,15 +98,18 @@ class Livraison extends CommonObject $sql.= " ".($this->adresse_livraison_id > 0?$this->adresse_livraison_id:"null"); if ($this->expedition_id) $sql.= ", $this->expedition_id"; $sql.= ")"; - + + dolibarr_syslog("Livraison::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison"); - + $numref="(PROV".$this->id.")"; $sql = "UPDATE ".MAIN_DB_PREFIX."livraison "; $sql.= "SET ref='".addslashes($numref)."' WHERE rowid=".$this->id; + + dolibarr_syslog("Livraison::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -116,8 +119,8 @@ class Livraison extends CommonObject $commande->id = $this->commande_id; $this->lignes = $commande->fetch_lines(); } - - + + /* * Insertion des produits dans la base */ @@ -125,37 +128,27 @@ class Livraison extends CommonObject { $origin_id=$this->lignes[$i]->origin_line_id; if (! $origin_id) $origin_id=$this->lignes[$i]->commande_ligne_id; // For backward compatibility - - if (! $this->create_line(0, $origin_id, $this->lignes[$i]->qty, $this->lignes[$i]->fk_product)) - { - $error++; - } - } - - /* - if ($conf->livraison->enabled && $this->origin_id) - { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_liv (fk_livraison, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')'; - if (!$this->db->query($sql)) - { - $error++; - } + if (! $this->create_line(0, $origin_id, $this->lignes[$i]->qty, $this->lignes[$i]->fk_product, $this->lignes[$i]->description)) + { + $error++; + } } - */ if (! $conf->expedition->enabled) { $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql.= " SET fk_statut = 2"; $sql.= " WHERE rowid=".$this->commande_id; + + dolibarr_syslog("Livraison::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { $error++; } } - + if ($error==0) { $this->db->commit(); @@ -188,43 +181,43 @@ class Livraison extends CommonObject return -1; } } - + /** * * */ - function create_line($transaction, $commande_ligne_id, $qty, $fk_product=0) + function create_line($transaction, $commande_ligne_id, $qty, $fk_product=0, $description) { $error = 0; $idprod = $fk_product; $j = 0; - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_origin_line,"; - if ($idprod) $sql.=" fk_product,"; - $sql.= " qty)"; + $sql.= " fk_product, description, qty)"; $sql.= " VALUES (".$this->id.",".$commande_ligne_id.","; - if ($idprod) $sql.=" ".$idprod.","; + $sql.= " ".($idprod>0?$idprod:"null").","; + $sql.= " ".($description?"'".addslashes($description)."'":"null").","; $sql.= $qty.")"; - + + dolibarr_syslog("Livraison::create_line sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql) ) { $error++; } - + if ($error == 0 ) { return 1; } } - + /** - * Lit un bon de livraison - * + * \brief Read a delivery receipt */ function fetch($id) { global $conf; - + $sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_client, l.fk_user_author,"; $sql.=" l.total_ht, l.fk_statut, l.fk_expedition, l.fk_user_valid, l.note, l.note_public"; $sql.= ", ".$this->db->pdate("l.date_livraison")." as date_livraison, l.fk_adresse_livraison, l.model_pdf"; @@ -254,7 +247,7 @@ class Livraison extends CommonObject if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - + $this->id = $obj->rowid; $this->date_livraison = $obj->date_livraison; $this->date_creation = $obj->date_creation; @@ -271,9 +264,9 @@ class Livraison extends CommonObject $this->note = $obj->note; $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; - + $this->db->free($result); - + if ($this->origin_id) { if ($conf->commande->enabled) @@ -285,12 +278,12 @@ class Livraison extends CommonObject $this->origin = "propal"; } } - + if ($this->statut == 0) $this->brouillon = 1; - + $file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id,2) . "/" . $this->id.".pdf"; $this->pdf_filename = $file; - + /* * Lignes */ @@ -299,7 +292,7 @@ class Livraison extends CommonObject { return -3; } - + return 1; } else @@ -316,7 +309,7 @@ class Livraison extends CommonObject return -1; } } - + /** * \brief Valide l'expedition, et met a jour le stock si stock gere * \param user Objet de l'utilisateur qui valide @@ -325,13 +318,13 @@ class Livraison extends CommonObject function valid($user) { global $conf; - + dolibarr_syslog("livraison.class.php::valid begin"); - + $this->db->begin(); - + $error = 0; - + if ($user->rights->expedition->livraison->valider) { if (defined('LIVRAISON_ADDON')) @@ -339,22 +332,22 @@ class Livraison extends CommonObject if (is_readable(DOL_DOCUMENT_ROOT .'/includes/modules/livraison/'.LIVRAISON_ADDON.'.php')) { require_once DOL_DOCUMENT_ROOT .'/includes/modules/livraison/'.LIVRAISON_ADDON.'.php'; - + // Definition du nom de module de numerotation de commande $modName=LIVRAISON_ADDON; - + // Recuperation de la nouvelle reference $objMod = new $modName($this->db); $soc = new Societe($this->db); $soc->fetch($this->socid); - + // on verifie si le bon de livraison est en num�rotation provisoire $livref = substr($this->ref, 1, 4); if ($livref == 'PROV') { $this->ref = $objMod->livraison_get_num($soc,$this); } - + // Tester si non dej� au statut valid�. Si oui, on arrete afin d'�viter // de decrementer 2 fois le stock. $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."livraison where ref='".$this->ref."' AND fk_statut <> 0"; @@ -377,16 +370,16 @@ class Livraison extends CommonObject // Si module stock g�r� et que expedition faite depuis un entrepot if (!$conf->expedition->enabled && $conf->stock->enabled && $this->entrepot_id && $conf->global->STOCK_CALCULATE_ON_SHIPMENT == 1) { - + //Enregistrement d'un mouvement de stock pour chaque produit de l'expedition - - + + dolibarr_syslog("livraison.class.php::valid enregistrement des mouvements"); - + $sql = "SELECT cd.fk_product, ld.qty "; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; $sql.= " WHERE ld.fk_livraison = $this->id AND cd.rowid = ld.fk_commande_ligne"; - + $resql=$this->db->query($sql); if ($resql) { @@ -395,9 +388,9 @@ class Livraison extends CommonObject while($i < $num) { dolibarr_syslog("livraison.class.php::valid movment $i"); - + $obj = $this->db->fetch_object($resql); - + $mouvS = new MouvementStock($this->db); // TODO Add price of product in method or '' to update PMP $result=$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty); @@ -410,7 +403,7 @@ class Livraison extends CommonObject } $i++; } - + } else { @@ -418,10 +411,10 @@ class Livraison extends CommonObject $this->error=$this->db->error()." - sql=$sql"; dolibarr_syslog("livraison.class.php::valid ".$this->error); return -2; - + } } - + // On efface le repertoire de pdf provisoire $livraisonref = sanitizeFileName($this->ref); if ($conf->expedition->dir_output) @@ -445,7 +438,7 @@ class Livraison extends CommonObject } } } - + dolibarr_syslog("livraison.class.php::valid ok"); } else @@ -464,12 +457,12 @@ class Livraison extends CommonObject dolibarr_syslog("livraison.class.php::valid ".$this->error); return -1; } - + $this->db->commit(); dolibarr_syslog("livraison.class.php::valid commit"); return 1; } - + /** \brief Cr�� le bon de livraison depuis une exp�dition existante * \param user Utilisateur qui cr�e * \param sending_id Id de l'exp�dition qui sert de mod�le @@ -478,11 +471,11 @@ class Livraison extends CommonObject { $expedition = new Expedition($this->db); $result=$expedition->fetch($sending_id); - + $this->lignes = array(); $this->date_livraison = time(); $this->expedition_id = $sending_id; - + for ($i = 0 ; $i < sizeof($expedition->lignes) ; $i++) { $LivraisonLigne = new LivraisonLigne($this->db); @@ -494,7 +487,7 @@ class Livraison extends CommonObject $LivraisonLigne->ref = $expedition->lignes[$i]->ref; $this->lignes[$i] = $LivraisonLigne; } - + $this->origin = $expedition->origin; $this->origin_id = $expedition->origin_id; $this->note = $expedition->note; @@ -502,11 +495,11 @@ class Livraison extends CommonObject $this->date_livraison = $expedition->date_livraison; $this->adresse_livraison_id = $expedition->adresse_livraison_id; $this->socid = $expedition->socid; - + return $this->create($user); } - - + + /** * Ajoute une ligne * @@ -515,13 +508,13 @@ class Livraison extends CommonObject { $num = sizeof($this->lignes); $ligne = new LivraisonLigne($this->db); - + $ligne->commande_ligne_id = $id; $ligne->qty = $qty; - + $this->lignes[$num] = $ligne; } - + /** * * @@ -531,11 +524,11 @@ class Livraison extends CommonObject if ($this->statut == 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne"; - + if ($this->db->query($sql) ) { $this->update_price(); - + return 1; } else @@ -544,7 +537,7 @@ class Livraison extends CommonObject } } } - + /** * Supprime la fiche * @@ -552,7 +545,7 @@ class Livraison extends CommonObject function delete() { $this->db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet WHERE fk_livraison = $this->id ;"; if ( $this->db->query($sql) ) { @@ -560,7 +553,7 @@ class Livraison extends CommonObject if ( $this->db->query($sql) ) { $this->db->commit(); - + // On efface le repertoire de pdf provisoire $livref = sanitizeFileName($this->ref); if ($conf->livraison->dir_output) @@ -584,7 +577,7 @@ class Livraison extends CommonObject } } } - + return 1; } else @@ -599,7 +592,7 @@ class Livraison extends CommonObject return -1; } } - + /** * \brief Read linked document @@ -611,12 +604,12 @@ class Livraison extends CommonObject $this->$object = & new $class($this->db); $this->$object->fetch($this->origin_id); } - + /** * * */ - + function fetch_adresse_livraison($id) { $idadresse = $id; @@ -624,7 +617,7 @@ class Livraison extends CommonObject $adresse->fetch_adresse_livraison($idadresse); $this->adresse = $adresse; } - + /** * * @@ -632,10 +625,10 @@ class Livraison extends CommonObject function fetch_lignes() { $this->lignes = array(); - - $sql = "SELECT p.label, p.ref,"; + + $sql = "SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped,"; $sql.= " cd.qty as qty_asked,"; - $sql.= " ld.description, ld.fk_product, ld.subprice, ld.total_ht, ld.qty as qty_shipped"; + $sql.= " p.ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc"; $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; @@ -649,24 +642,29 @@ class Livraison extends CommonObject while ($i < $num) { $ligne = new LivraisonLigne($this->db); - + $obj = $this->db->fetch_object($resql); + $ligne->description = $obj->description; $ligne->fk_product = $obj->fk_product; $ligne->qty_asked = $obj->qty_asked; $ligne->qty_shipped = $obj->qty_shipped; + $ligne->ref = $obj->ref; + $ligne->libelle = $obj->label; // Label produit $ligne->label = $obj->label; - $ligne->description = $obj->description; + $ligne->product_desc = $obj->product_desc; // Description produit + $ligne->product_type = $obj->fk_product_type; + $ligne->price = $obj->price; $ligne->total_ht = $obj->total_ht; - + $this->lignes[$i] = $ligne; $i++; } $this->db->free($resql); } - + return $this->lignes; } @@ -679,7 +677,7 @@ class Livraison extends CommonObject { return $this->LibStatut($this->statut,$mode); } - + /** * \brief Renvoi le libell� d'un statut donn� * \param statut Id statut @@ -710,7 +708,7 @@ class Livraison extends CommonObject } } - + /** * \brief Initialise object with default value to be used as example */ @@ -772,7 +770,7 @@ class Livraison extends CommonObject $ligne->total_ht = 100; $this->lignes[$i] = $ligne; } - + } @@ -784,7 +782,7 @@ class Livraison extends CommonObject class LivraisonLigne { var $db; - + // From llx_expeditiondet var $qty; var $qty_asked; @@ -795,10 +793,10 @@ class LivraisonLigne var $label; // Label produit var $description; // Description produit var $ref; - + function LivraisonLigne($DB) { - $this->db=$DB; + $this->db=$DB; } }