From 1a605050238d26b1353c813163f615acba2e508c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Feb 2009 00:42:07 +0000 Subject: [PATCH] Fix: Bad alignement of line in rouget model --- htdocs/commande/commande.class.php | 10 ++-- htdocs/commande/fiche.php | 48 ++----------------- .../pdf/pdf_expedition_rouget.modules.php | 35 ++++++++++++-- .../modules/facture/pdf_crabe.modules.php | 2 +- 4 files changed, 41 insertions(+), 54 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 3750a89b12e..3dca36b6d0a 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -702,8 +702,6 @@ class Commande extends CommonObject $ligne->price=$price; $ligne->remise=$remise; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Save the start and end date of the new line in the object $ligne->date_start=$date_start; $ligne->date_end=$date_end; @@ -2310,8 +2308,8 @@ class CommandeLigne if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; } else { $sql.='null,'; } $sql.= " '".price2num($this->remise_percent)."',"; - $sql.= " '".price2num($this->subprice)."',"; - $sql.= " '".price2num($this->price)."',"; + $sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").","; + $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").","; $sql.= " '".price2num($this->remise)."',"; if ($this->fk_remise_except) $sql.= $this->fk_remise_except.","; else $sql.= 'null,'; @@ -2326,9 +2324,9 @@ class CommandeLigne // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Insert in the database the start and end dates $sql.= " '".price2num($this->total_ttc)."',"; - if ($this->date_start) { $sql.= "'".$this->date_start."',"; } + if ($this->date_start) { $sql.= "'".$this->db->idate($this->date_start)."',"; } else { $sql.='null,'; } - if ($this->date_end) { $sql.= "'".$this->date_end."'"; } + if ($this->date_end) { $sql.= "'".$this->db->idate($this->date_end)."'"; } else { $sql.='null'; } $sql.= ')'; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 10a2bfbeceb..4138e517ba6 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -301,25 +301,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $ret=$commande->fetch_client(); $suffixe = $_POST['idprod'] ? '_prod' : ''; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Retrieve start and end date (for product/service lines or customizable lines) - $date_start=''; - $date_end=''; - if ($_POST['date_start'.$suffixe.'year'] && $_POST['date_start'.$suffixe.'month'] && $_POST['date_start'.$suffixe.'day']) - { - $date_start=$_POST['date_start'.$suffixe.'year'].'-'.$_POST['date_start'.$suffixe.'month'].'-'.$_POST['date_start'.$suffixe.'day']; - // If hour/minute are specified, append them - if (($_POST['date_start'.$suffixe.'hour']) && ($_POST['date_start'.$suffixe.'min'])) - $date_start.=' '.$_POST['date_start'.$suffixe.'hour'].':'.$_POST['date_start'.$suffixe.'min']; - } - if ($_POST['date_end'.$suffixe.'year'] && $_POST['date_end'.$suffixe.'month'] && $_POST['date_end'.$suffixe.'day']) - { - $date_end=$_POST['date_end'.$suffixe.'year'].'-'.$_POST['date_end'.$suffixe.'month'].'-'.$_POST['date_end'.$suffixe.'day']; - // If hour/minute are specified, append them - if (($_POST['date_end'.$suffixe.'hour']) && ($_POST['date_end'.$suffixe.'min'])) - $date_end.=' '.$_POST['date_end'.$suffixe.'hour'].':'.$_POST['date_end'.$suffixe.'min']; - } - + $date_start=dolibarr_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']); + $date_end=dolibarr_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']); $price_base_type = 'HT'; // Ecrase $pu par celui du produit @@ -362,7 +345,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) } $desc = $prod->description; - $desc.= $prod->description && $_POST['np_desc'] ? "\n" : ""; + $desc.= ($prod->description && $_POST['np_desc']) ? ((dol_textishtml($prod->description) || dol_textishtml($_POST['np_desc']))?"
":"\n") : ""; $desc.= $_POST['np_desc']; } else @@ -395,8 +378,6 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) 0, $price_base_type, $pu_ttc, - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Add the start and end dates $date_start, $date_end ); @@ -427,25 +408,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS $commande = new Commande($db,'',$_POST['id']); if (! $commande->fetch($_POST['id']) > 0) dolibarr_print_error($db); - - $date_start=''; - $date_end=''; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Retrieve start and end date (for product/service lines or customizable lines) - if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) - { - $date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday']; - // If hour/minute are specified, append them - if (($_POST['date_starthour']) && ($_POST['date_startmin'])) - $date_start.=' '.$_POST['date_starthour'].':'.$_POST['date_startmin']; - } - if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) - { - $date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday']; - // If hour/minute are specified, append them - if (($_POST['date_endhour']) && ($_POST['date_endmin'])) - $date_end.=' '.$_POST['date_endhour'].':'.$_POST['date_endmin']; - } + $date_start=dolibarr_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']); + $date_end=dolibarr_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']); // Define info_bits $info_bits=0; @@ -469,8 +433,6 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS $vat_rate, 'HT', $info_bits, - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Add the start and end dates $date_start, $date_end ); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php index c605eb171be..60e6c9a276e 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/ModelePdfExpedition.class.php"; require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); /** @@ -195,8 +196,8 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->SetTextColor(0,0,0); $tab_top = 90; - $height_note = 200; - $pdf->Rect($this->marge_gauche, 80, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 210); + $height_note = 180; + $pdf->Rect($this->marge_gauche, $tab_top-10, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+10); $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note); if ($this->barcode->enabled) { @@ -216,9 +217,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $curY = $this->tableau_top + 4; $pdf->writeHTMLCell(30, 3, 170, $curY, $outputlangs->trans("QtyToShip"), 0, 0); + $nexY = $this->tableau_top + 14; + for ($i = 0 ; $i < sizeof($this->expe->lignes) ; $i++) { - $curY = $this->tableau_top + 14 + ($i * 7); + $curY = $nexY; if ($this->barcode->enabled) { @@ -229,20 +232,30 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $libelleproduitservice=pdf_getlinedesc($this->expe->lignes[$i],$outputlangs); $pdf->SetFont('Arial','', 9); // Dans boucle pour g�rer multi-page - $pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); + $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut + $nexY = $pdf->GetY(); + $pdf->SetXY (160, $curY); $pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_asked); $pdf->SetXY (186, $curY); $pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_shipped); + + $nexY+=2; // Passe espace entre les lignes } + + + // Pied de page + $this->_pagefoot($pdf,$this->expe,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->setPhpLang(); // On restaure langue session return 1; @@ -264,6 +277,20 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $langs->setPhpLang(); // On restaure langue session return 0; // Erreur par defaut } + + + /** + * \brief Show footer of page + * \param pdf Object PDF + * \param object Object invoice + * \param outputlang Object lang for output + * \remarks Need this->emetteur object + */ + function _pagefoot(&$pdf,$object,$outputlangs) + { + return pdf_pagefoot($pdf,$outputlangs,'SENDING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); + } + } ?> diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 6dbcd7f4e09..488df648108 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -291,7 +291,7 @@ class pdf_crabe extends ModelePDFFactures { //on r�cup�re la description du produit suivant $follow_descproduitservice = $fac->lignes[$i+1]->desc; - //on compte le nombre de ligne afin de v�rifier la place disponible (largeur de ligne 52 caracteres) + //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52)*4; // Et si on affiche dates de validite, on ajoute encore une ligne if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end)