From 13f2fe84f9938fa9bf107eeb55587da013c2a6ec Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 24 Feb 2012 16:31:51 +0100 Subject: [PATCH 1/3] Fix: missing object $db and missing variables declaration --- htdocs/admin/fichinter.php | 15 ++++----------- .../fichinter/doc/pdf_soleil.modules.php | 17 ++++++++++++++++- .../modules/fichinter/modules_fichinter.php | 5 +++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 5202a00667d..dc24a1869b8 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -383,7 +383,7 @@ foreach ($conf->file->dol_document_root as $dirroot) echo "$name"; print "\n"; require_once($dir.$file); - $module = new $classname(); + $module = new $classname($db); print $module->description; print ''; @@ -391,16 +391,9 @@ foreach ($conf->file->dol_document_root as $dirroot) if (in_array($name, $def)) { print "\n"; - //if ($conf->global->FICHEINTER_ADDON_PDF != "$name") - //{ - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - //} - //else - //{ - // print img_picto($langs->trans("Enabled"),'switch_on'); - //} + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; print ""; } else diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 133e9124a57..015c1387405 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -37,13 +37,28 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); */ class pdf_soleil extends ModelePDFFicheinter { + var $db; + var $name; + var $description; + var $type; + + var $phpmin = array(4,3,0); // Minimum version of PHP required by module + var $version = 'dolibarr'; + + var $page_largeur; + var $page_hauteur; + var $format; + var $marge_gauche; + var $marge_droite; + var $marge_haute; + var $marge_basse; /** * Constructor * * @param DoliDB $db Database handler */ - function pdf_soleil($db) + function __construct($db) { global $conf,$langs,$mysoc; diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index f7ebef61859..c2c030735db 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -38,8 +38,9 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator /** - * \brief Return list of active generation modules - * \param $db Database handler + * Return list of active generation modules + * + * @param DoliDB $db Database handler */ function liste_modeles($db) { From 3b0beed51ddb4eac87c6358edd4fe7f49cd20f1f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 24 Feb 2012 16:52:33 +0100 Subject: [PATCH 2/3] Fix: professionnal id only visible if not empty --- htdocs/core/lib/pdf.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 47f25af52c1..bd08331552d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -223,25 +223,25 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); // Professionnal Ids - if ($conf->global->MAIN_PROFID1_IN_ADDRESS) + if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) { $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code); if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); } - if ($conf->global->MAIN_PROFID2_IN_ADDRESS) + if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) { $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code); if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); } - if ($conf->global->MAIN_PROFID3_IN_ADDRESS) + if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) { $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code); if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); } - if ($conf->global->MAIN_PROFID4_IN_ADDRESS) + if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) { $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code); if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; From e2cea80f699c5beea14ceb65e7fd01ce95484021 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 24 Feb 2012 17:25:53 +0100 Subject: [PATCH 3/3] Fix: problem with this pdf --- .../fichinter/doc/pdf_soleil.modules.php | 55 +++++++++---------- htdocs/fichinter/class/fichinter.class.php | 18 +++--- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 015c1387405..bc0d10ad00f 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -168,7 +168,7 @@ class pdf_soleil extends ModelePDFFicheinter $tab_top = 100; $tab_top_middlepage = 50; $tab_top_newpage = 50; - $tab_height = 110; + $tab_height = 120; $tab_height_newpage = 150; $tab_height_middlepage = 200; $tab_height_endpage = 170; @@ -199,7 +199,7 @@ class pdf_soleil extends ModelePDFFicheinter $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; -/* + $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8 ); @@ -223,7 +223,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. -*/ + $nblines = count($object->lines); // Loop on each lines @@ -236,15 +236,17 @@ class pdf_soleil extends ModelePDFFicheinter { $curY = $nexY; + $pdf->SetFont('','B', $default_font_size - 1); $pdf->SetXY($this->marge_gauche, $curY); $txt=dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration),1,$outputlangs->charset_output); $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY, $txt, 0, 1, 0); - $nexY = $pdf->GetY(); + $curY = $pdf->GetY(); + $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY($this->marge_gauche, $curY + 3); $desc = dol_htmlentitiesbr($objectligne->desc,1); $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY + 3, $desc, 0, 1, 0); - //$nexY+=dol_nboflines_bis($objectligne->desc,52,$outputlangs->charset_output)*3; + $nexY+=dol_nboflines_bis($objectligne->desc,52,$outputlangs->charset_output)*3; $nexY+=2; // Passe espace entre les lignes @@ -297,26 +299,19 @@ class pdf_soleil extends ModelePDFFicheinter } } } - //$pdf->line(10, $tab_top+$tab_height+3, 200, $tab_top+$tab_height+3); + + // 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; + } - // Rectangle for title and all lines - /* - $pdf->Rect($this->marge_gauche, $tab_top, ($this->page_largeur-$this->marge_gauche-$this->marge_droite), $tab_height+3); - $pdf->SetXY($this->marge_gauche, $pdf->GetY() + 20); - $pdf->MultiCell(60, 5, '', 0, 'J', 0); - - $pdf->SetXY(20,220); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); - - $pdf->SetXY(20,225); - $pdf->MultiCell(80,30, '', 1); - - $pdf->SetXY(110,220); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); - - $pdf->SetXY(110,225); - $pdf->MultiCell(80,30, '', 1); -*/ $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $this->_pagefoot($pdf,$object,$outputlangs); @@ -359,7 +354,7 @@ class pdf_soleil extends ModelePDFFicheinter { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); - +/* $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); @@ -383,21 +378,21 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. - +*/ $pdf->Rect($this->marge_gauche, $tab_top, ($this->page_largeur-$this->marge_gauche-$this->marge_droite), $tab_height+3); $pdf->SetXY($this->marge_gauche, $pdf->GetY() + 20); $pdf->MultiCell(60, 5, '', 0, 'J', 0); - $pdf->SetXY(20,220); + $pdf->SetXY(20,230); $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); - $pdf->SetXY(20,225); + $pdf->SetXY(20,235); $pdf->MultiCell(80,30, '', 1); - $pdf->SetXY(110,220); + $pdf->SetXY(110,230); $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); - $pdf->SetXY(110,225); + $pdf->SetXY(110,235); $pdf->MultiCell(80,30, '', 1); } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index b72df22e2de..6917c2b4231 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -60,11 +60,11 @@ class Fichinter extends CommonObject /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function Fichinter($DB) + function __construct($db) { - $this->db = $DB ; + $this->db = $db ; $this->products = array(); $this->fk_project = 0; $this->statut = 0; @@ -814,9 +814,9 @@ class Fichinter extends CommonObject { $sql = 'SELECT rowid, description, duree, date, rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet'; - $sql.= ' where fk_fichinter = '.$this->id; + $sql.= ' WHERE fk_fichinter = '.$this->id; - dol_syslog("Fichinter::fetch_lines sql=".$sql); + dol_syslog(get_class($this)."::fetch_lines sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -872,11 +872,11 @@ class FichinterLigne /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function FichinterLigne($DB) + function __construct($db) { - $this->db= $DB; + $this->db = $db; } /**