From d38c68e54f586478dc7cf8f93d2b13d698e93ceb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 11:10:04 +0200 Subject: [PATCH 1/8] Remove unexpected char --- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index a5c5ce7cf11..37639a5f8e6 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -1,4 +1,4 @@ -< * * This program is free software; you can redistribute it and/or modify From cd9431809b720ab83ca1548ffdf27cfdd8e2e8fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 11:44:21 +0200 Subject: [PATCH 2/8] Fix: do not loose country_code after update --- htdocs/societe/class/societe.class.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 078b0d85fe8..c91593b079f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1071,10 +1071,26 @@ class Societe extends CommonObject $resql=$this->db->query($sql); if ($resql) { - unset($this->country_code); // We clean this because it may have been changed after an update of country_id - unset($this->country); - unset($this->state_code); - unset($this->state); + if (is_object($this->oldcopy)) // If we have information on old values + { + if ($this->oldcopy->country_id != $this->country_id) + { + unset($this->country_code); + unset($this->country); + } + if ($this->oldcopy->state_id != $this->state_id) + { + unset($this->state_code); + unset($this->state); + } + } + else + { + unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id + unset($this->country); + unset($this->state_code); + unset($this->state); + } $nbrowsaffected = $this->db->affected_rows($resql); From fa99ea1f0fceb704dfb7226776846834ed5e3a50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 11:55:25 +0200 Subject: [PATCH 3/8] Fix thirdparty popup --- htdocs/core/boxes/box_contracts.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 6f9a62e1063..7592f882b59 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -40,7 +40,7 @@ class box_contracts extends ModeleBoxes * @var DoliDB Database handler. */ public $db; - + var $param; var $info_box_head = array(); @@ -83,7 +83,7 @@ class box_contracts extends ModeleBoxes $contractstatic=new Contrat($db); $thirdpartytmp=new Societe($db); - $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -108,6 +108,7 @@ class box_contracts extends ModeleBoxes while ($line < $num) { $objp = $db->fetch_object($resql); + $datec=$db->jdate($objp->datec); $dateterm=$db->jdate($objp->fin_validite); $dateclose=$db->jdate($objp->date_cloture); @@ -120,6 +121,13 @@ class box_contracts extends ModeleBoxes $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; // fin_validite is no more on contract but on services // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } From f6b3bc3bdb4009fe6d902bbe9177f34ec54ad30e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 12:03:22 +0200 Subject: [PATCH 4/8] Fix thirdparty popup --- htdocs/core/boxes/box_services_contracts.php | 11 +++++++++-- htdocs/core/boxes/box_services_expired.php | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 41d287d0c37..d07ce87dd47 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -41,7 +41,7 @@ class box_services_contracts extends ModeleBoxes * @var DoliDB Database handler. */ public $db; - + var $param; var $info_box_head = array(); @@ -88,7 +88,7 @@ class box_services_contracts extends ModeleBoxes $thirdpartytmp = new Societe($db); $productstatic = new Product($db); - $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " c.rowid, c.ref, c.statut as contract_status,"; $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; @@ -130,6 +130,13 @@ class box_services_contracts extends ModeleBoxes $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; // Multilangs if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index afc087ad715..c23e9940377 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -39,7 +39,7 @@ class box_services_expired extends ModeleBoxes * @var DoliDB Database handler. */ public $db; - + var $param; var $info_box_head = array(); @@ -84,7 +84,7 @@ class box_services_expired extends ModeleBoxes // Select contracts with at least one expired service $sql = "SELECT "; $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; - $sql.= " s.nom as name, s.rowid as socid,"; + $sql.= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -113,8 +113,15 @@ class box_services_expired extends ModeleBoxes $objp = $db->fetch_object($resql); - $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; $contract->id = $objp->rowid; $contract->ref = $objp->ref; From 868caa49916ba1efca2a48a5ecb12febae991215 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 12:05:31 +0200 Subject: [PATCH 5/8] Missing ref_customer in popup --- htdocs/core/boxes/box_services_contracts.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index d07ce87dd47..7c73bbbe328 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -89,7 +89,7 @@ class box_services_contracts extends ModeleBoxes $productstatic = new Product($db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as contract_status,"; + $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; @@ -127,6 +127,8 @@ class box_services_contracts extends ModeleBoxes $contractstatic->statut=$objp->contract_status; $contractstatic->id=$objp->rowid; $contractstatic->ref=$objp->ref; + $contractstatic->ref_customer=$objp->ref_customer; + $contractstatic->ref_supplier=$objp->ref_supplier; $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; From 4e6b21881fd8f9b9487681ae1454127286c68f36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 12:14:20 +0200 Subject: [PATCH 6/8] Fix bug reported by scrutinizer --- htdocs/core/ajax/ajaxdirtree.php | 5 +++-- htdocs/core/class/menubase.class.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index fc01474a072..173d8520423 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -468,16 +468,17 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, { //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n"; $newselecteddir = $val['fullrelativename']; + $newfullpathselecteddir=''; if ($modulepart == 'ecm') { $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); } - if ($modulepart == 'medias') + elseif ($modulepart == 'medias') { $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); } - treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); + if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); } print "\n"; diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 17ada096fd1..1ca10d9dd9b 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -126,7 +126,7 @@ class Menubase $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); $this->user=trim($this->user); - $this->position=trim($this->position); + if (empty($this->position)) $this->position=0; if (! $this->level) $this->level=0; // Check parameters From 2816bdf74705b49cf72d74ed2c368fa9bef17df0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2018 16:22:56 +0200 Subject: [PATCH 7/8] FIX Date into filename of FEC file. --- htdocs/accountancy/bookkeeping/list.php | 6 ++-- .../class/accountancyexport.class.php | 34 +++---------------- .../accountancy/class/bookkeeping.class.php | 3 +- htdocs/accountancy/tpl/export_journal.tpl.php | 21 +++++++++++- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 132aa4e0afa..e87c9b22aee 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -337,7 +337,7 @@ if ($action == 'delmouvconfirm') { } } -// Export into a file with format defined into setup +// Export into a file with format defined into setup (FEC, CSV, ...) if ($action == 'export_file') { $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); @@ -350,7 +350,9 @@ if ($action == 'export_file') { { $accountancyexport = new AccountancyExport($db); $accountancyexport->export($object->lines); - if (!empty($accountancyexport->errors)) { + + if (!empty($accountancyexport->errors)) + { setEventMessages('', $accountancyexport->errors, 'errors'); } exit; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 13fec3cf388..7b832976e89 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -206,7 +206,7 @@ class AccountancyExport /** - * Function who chose which export to use with the default config + * Function who chose which export to use with the default config, and make the export into a file * * @param array $TData data * @return void @@ -214,16 +214,16 @@ class AccountancyExport public function export(&$TData) { global $conf, $langs; + global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php - + // Define name of file to save $filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV); + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) { case self::$EXPORT_TYPE_NORMAL : - /*$this->exportNormal($TData); - break;*/ case self::$EXPORT_TYPE_CONFIGURABLE : $this->exportConfigurable($TData); break; @@ -261,32 +261,6 @@ class AccountancyExport } } - /** - * Export format : Normal - * - * @param array $objectLines data - * - * @return void - */ - /* Use $EXPORT_TYPE_CONFIGURABLE instead - public function exportNormal($objectLines) - { - global $conf; - - foreach ( $objectLines as $line ) { - // Std export - $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); - print $date . $this->separator; - print $line->doc_ref . $this->separator; - print length_accountg($line->numero_compte) . $this->separator; - print length_accounta($line->subledger_account) . $this->separator; - print price($line->debit) . $this->separator; - print price($line->credit) . $this->separator; - print $line->code_journal . $this->separator; - print $this->end_line; - } - } - */ /** * Export format : CEGID diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 87d561b6add..0550fb5a438 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1001,8 +1001,7 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')'; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 1d7e7fd6f54..d0d902770c0 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -37,7 +37,26 @@ header('Content-Type: text/csv'); if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11") // Specific filename for FEC model export { - $completefilename = $siren . "FEC" . $search_date_end . $endaccountingperiod . "." . $format; + + // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle + if (empty($search_date_end)) + { + // TODO Get the max date into bookeeping table + $search_date_end = dol_now(); + } + $datetouseforfilename = $search_date_end; + $tmparray=dol_getdate($datetouseforfilename); + $fiscalmonth=empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START; + // Define end of month to use + if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon']=$fiscalmonth; + else { + $tmparray['mon'] = $fiscalmonth; + $tmparray['year']++; + } + + $endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard'); + + $completefilename = $siren . "FEC" . $endaccountingperiod . "." . $format; } else { From f65df9e541db21f6b1f221cf33c7cac8d0319b30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Oct 2018 20:06:03 +0200 Subject: [PATCH 8/8] NEW Add option PDF_DISABLE_MYCOMPANY_LOGO to disable logo on PDF --- .../commande/doc/pdf_einstein.modules.php | 31 +- .../commande/doc/pdf_eratosthene.modules.php | 165 ++++----- .../modules/facture/doc/pdf_crabe.modules.php | 31 +- .../facture/doc/pdf_sponge.modules.php | 327 +++++++++--------- .../modules/propale/doc/pdf_azur.modules.php | 31 +- .../modules/propale/doc/pdf_cyan.modules.php | 177 +++++----- 6 files changed, 390 insertions(+), 372 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 273027f3b99..ad77e9bea32 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1261,27 +1261,30 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - if (is_readable($logo)) + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size -2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B', $default_font_size -2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 039f29fa379..89297d1bdc6 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -136,7 +136,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Define position of columns $this->posxdesc=$this->marge_gauche+1; - + $this->tva=array(); $this->localtax1=array(); @@ -252,7 +252,7 @@ class pdf_eratosthene extends ModelePDFCommandes break; } } - + if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxpicture+=($this->postotalht - $this->posxdiscount); @@ -316,25 +316,25 @@ class pdf_eratosthene extends ModelePDFCommandes { $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; $pageposbeforenote = $pagenb; - + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); - + $tab_top -= 2; - + $pdf->startTransaction(); - + $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); // Description $pageposafternote=$pdf->getPage(); $posyafter = $pdf->GetY(); - + if($pageposafternote>$pageposbeforenote ) { $pdf->rollbackTransaction(true); - + // prepar pages to receive notes while ($pagenb < $pageposafternote) { $pdf->AddPage(); @@ -346,16 +346,16 @@ class pdf_eratosthene extends ModelePDFCommandes // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); } - + // back to start $pdf->setPage($pageposbeforenote); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $pageposafternote=$pdf->getPage(); - + $posyafter = $pdf->GetY(); - + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text { $pdf->AddPage('','',true); @@ -367,14 +367,14 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); //$posyafter = $tab_top_newpage; } - - + + // apply note frame to previus pages $i = $pageposbeforenote; while ($i < $pageposafternote) { $pdf->setPage($i); - - + + $pdf->SetDrawColor(128,128,128); // Draw note frame if($i>$pageposbeforenote){ @@ -385,21 +385,21 @@ class pdf_eratosthene extends ModelePDFCommandes $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); } - + // Add footer $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $this->_pagefoot($pdf,$object,$outputlangs,1); - + $i++; } - + // apply note frame to last page $pdf->setPage($pageposafternote); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $height_note=$posyafter-$tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); - + } else // No pagebreak { @@ -407,8 +407,8 @@ class pdf_eratosthene extends ModelePDFCommandes $posyafter = $pdf->GetY(); $height_note=$posyafter-$tab_top; $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1); - - + + if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) ) { // not enough space, need to add page @@ -418,12 +418,12 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setPage($pageposafternote); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - + $posyafter = $tab_top_newpage; } - + } - + $tab_height = $tab_height - $height_note; $tab_top = $posyafter +6; } @@ -435,10 +435,10 @@ class pdf_eratosthene extends ModelePDFCommandes $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - + // Use new auto collum system $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref); - + // Loop on each lines $pageposbeforeprintlines=$pdf->getPage(); $pagenb = $pageposbeforeprintlines; @@ -456,7 +456,7 @@ class pdf_eratosthene extends ModelePDFCommandes $curX = $this->posxdesc-1; $showpricebeforepagebreak=1; - + if($this->getColumnStatus('desc')) { $pdf->startTransaction(); @@ -493,7 +493,7 @@ class pdf_eratosthene extends ModelePDFCommandes } $posYAfterDescription=$pdf->GetY(); } - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); @@ -515,7 +515,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate); $nexY = max($pdf->GetY(),$nexY); } - + // Unit price before discount if ($this->getColumnStatus('subprice')) { @@ -523,7 +523,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax); $nexY = max($pdf->GetY(),$nexY); } - + // Quantity // Enough for 6 chars if ($this->getColumnStatus('qty')) @@ -532,8 +532,8 @@ class pdf_eratosthene extends ModelePDFCommandes $this->printStdColumnContent($pdf, $curY, 'qty', $qty); $nexY = max($pdf->GetY(),$nexY); } - - + + // Unit if ($this->getColumnStatus('unit')) { @@ -541,7 +541,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->printStdColumnContent($pdf, $curY, 'unit', $unit); $nexY = max($pdf->GetY(),$nexY); } - + // Discount on line if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) { @@ -549,7 +549,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent); $nexY = max($pdf->GetY(),$nexY); } - + // Total HT line if ($this->getColumnStatus('totalexcltax')) { @@ -557,8 +557,8 @@ class pdf_eratosthene extends ModelePDFCommandes $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax); $nexY = max($pdf->GetY(),$nexY); } - - + + $parameters=array( 'object' => $object, 'i' => $i, @@ -569,7 +569,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'hidedetails' => $hidedetails ); $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this); // Note that $object may have been modified by hook - + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; @@ -1220,29 +1220,29 @@ class pdf_eratosthene extends ModelePDFCommandes foreach ($this->cols as $colKey => $colDef) { if(!$this->getColumnStatus($colKey)) continue; - + // get title label $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']); - + // Add column separator if(!empty($colDef['border-left'])){ $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); } - + if (empty($hidetop)) { $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] ); - + $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1]; $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']); } } - + if (empty($hidetop)){ $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param } - + } /** @@ -1281,27 +1281,30 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - if (is_readable($logo)) + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size -2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B', $default_font_size -2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); @@ -1469,9 +1472,9 @@ class pdf_eratosthene extends ModelePDFCommandes $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } - - + + /** * Define Array Column Field * @@ -1483,21 +1486,21 @@ class pdf_eratosthene extends ModelePDFCommandes * @return null */ function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){ - + global $conf, $hookmanager; - + // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); - + // Default field style for content $this->defaultTitlesFieldsStyle = array( 'align' => 'C', // R,C,L 'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); - + /* * For exemple $this->cols['theColKey'] = array( @@ -1515,7 +1518,7 @@ class pdf_eratosthene extends ModelePDFCommandes ), ); */ - + $rank=0; // do not use negative rank $this->cols['desc'] = array( 'rank' => $rank, @@ -1532,7 +1535,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'align' => 'L', ), ); - + $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, @@ -1547,13 +1550,13 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => false, // remove left line separator ); - + if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { $this->cols['photo']['status'] = true; } - - + + $rank = $rank + 10; $this->cols['vat'] = array( 'rank' => $rank, @@ -1564,12 +1567,12 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $this->cols['vat']['status'] = true; } - + $rank = $rank + 10; $this->cols['subprice'] = array( 'rank' => $rank, @@ -1580,7 +1583,7 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, @@ -1591,7 +1594,7 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - + $rank = $rank + 10; $this->cols['progress'] = array( 'rank' => $rank, @@ -1602,12 +1605,12 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => false, // add left line separator ); - + if($this->situationinvoice) { $this->cols['progress']['status'] = true; } - + $rank = $rank + 10; $this->cols['unit'] = array( 'rank' => $rank, @@ -1621,7 +1624,7 @@ class pdf_eratosthene extends ModelePDFCommandes if($conf->global->PRODUCT_USE_UNITS){ $this->cols['unit']['status'] = true; } - + $rank = $rank + 10; $this->cols['discount'] = array( 'rank' => $rank, @@ -1635,7 +1638,7 @@ class pdf_eratosthene extends ModelePDFCommandes if ($this->atleastonediscount){ $this->cols['discount']['status'] = true; } - + $rank = $rank + 10; $this->cols['totalexcltax'] = array( 'rank' => $rank, @@ -1646,8 +1649,8 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - - + + $parameters=array( 'object' => $object, 'outputlangs' => $outputlangs, @@ -1655,7 +1658,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'hidedesc' => $hidedesc, 'hideref' => $hideref ); - + $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this); // Note that $object may have been modified by hook if ($reshook < 0) { @@ -1669,7 +1672,7 @@ class pdf_eratosthene extends ModelePDFCommandes { $this->cols = $hookmanager->resArray; } - + } - + } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index af770999fda..c4d69424cb2 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1598,27 +1598,30 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - if (is_readable($logo)) + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B',$default_font_size - 2); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',$default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $text=$this->emetteur->name; + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 74f4bf34acf..ca27bd09aff 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -108,7 +108,7 @@ class pdf_sponge extends ModelePDFFactures function __construct($db) { global $conf,$langs,$mysoc; - + // Translations $langs->loadLangs(array("main", "bills")); @@ -147,8 +147,8 @@ class pdf_sponge extends ModelePDFFactures // Define position of columns $this->posxdesc=$this->marge_gauche+1; // used for notes ans other stuff - - // Use new system for position of columns, view $this->defineColumnField() + + // Use new system for position of columns, view $this->defineColumnField() $this->tva=array(); $this->localtax1=array(); @@ -173,27 +173,27 @@ class pdf_sponge extends ModelePDFFactures function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; - + if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - + // Translations $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); - + $nblignes = count($object->lines); - + // Loop on each lines to detect if there is at least one image to show $realpatharray=array(); $this->atleastonephoto = false; if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) { $objphoto = new Product($this->db); - + for ($i = 0 ; $i < $nblignes ; $i++) { if (empty($object->lines[$i]->fk_product)) continue; - + $objphoto->fetch($object->lines[$i]->fk_product); //var_dump($objphoto->ref);exit; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) @@ -206,14 +206,14 @@ class pdf_sponge extends ModelePDFFactures $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/"; // alternative } - + $arephoto = false; foreach ($pdir as $midir) { if (! $arephoto) { $dir = $conf->product->dir_output.'/'.$midir; - + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo @@ -231,28 +231,28 @@ class pdf_sponge extends ModelePDFFactures { $filename=$obj['photo']; } - + $realpath = $dir.$filename; $arephoto = true; $this->atleastonephoto = true; } } } - + if ($realpath && $arephoto) $realpatharray[$i]=$realpath; } } - + //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - + if ($conf->facture->dir_output) { $object->fetch_thirdparty(); - + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); - + // Definition of $dir and $file if ($object->specimen) { @@ -273,7 +273,7 @@ class pdf_sponge extends ModelePDFFactures return 0; } } - + if (file_exists($dir)) { // Add pdfgeneration hook @@ -286,47 +286,47 @@ class pdf_sponge extends ModelePDFFactures $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); $nbpayments = count($object->getListOfPayments()); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22); // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); - + // Set path to the background PDF File if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } - + $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); - + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - + // Does we have at least one line with discount $this->atleastonediscount foreach ($object->lines as $line) { if ($line->remise_percent){ @@ -334,30 +334,30 @@ class pdf_sponge extends ModelePDFFactures break; } } - - + + // Situation invoice handling if ($object->situation_cycle_ref) { $this->situationinvoice = true; } - + // New page $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); - + $tab_top = 90+$top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); $tab_height = 130-$top_shift; $tab_height_newpage = 150; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; - + // Incoterm $height_incoterms = 0; if ($conf->incoterm->enabled) @@ -366,21 +366,21 @@ class pdf_sponge extends ModelePDFFactures if ($desc_incoterms) { $tab_top -= 2; - + $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = max($pdf->GetY(),$nexY); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } } - + // Affiche notes $notetoshow=empty($object->note_public)?'':$object->note_public; if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) @@ -394,7 +394,7 @@ class pdf_sponge extends ModelePDFFactures if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); } } - + $pagenb = $pdf->getPage(); if ($notetoshow) { @@ -402,24 +402,24 @@ class pdf_sponge extends ModelePDFFactures $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; $pageposbeforenote = $pagenb; - + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); - - + + $pdf->startTransaction(); - + $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); // Description $pageposafternote=$pdf->getPage(); $posyafter = $pdf->GetY(); - + if($pageposafternote>$pageposbeforenote ) { $pdf->rollbackTransaction(true); - + // prepar pages to receive notes while ($pagenb < $pageposafternote) { $pdf->AddPage(); @@ -431,16 +431,16 @@ class pdf_sponge extends ModelePDFFactures // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); } - + // back to start $pdf->setPage($pageposbeforenote); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $pageposafternote=$pdf->getPage(); - + $posyafter = $pdf->GetY(); - + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text { $pdf->AddPage('','',true); @@ -452,14 +452,14 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); //$posyafter = $tab_top_newpage; } - - + + // apply note frame to previus pages $i = $pageposbeforenote; while ($i < $pageposafternote) { $pdf->setPage($i); - - + + $pdf->SetDrawColor(128,128,128); // Draw note frame if($i>$pageposbeforenote){ @@ -470,21 +470,21 @@ class pdf_sponge extends ModelePDFFactures $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); } - + // Add footer $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $this->_pagefoot($pdf,$object,$outputlangs,1); - + $i++; } - + // apply note frame to last page $pdf->setPage($pageposafternote); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $height_note=$posyafter-$tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); - + } else // No pagebreak { @@ -492,8 +492,8 @@ class pdf_sponge extends ModelePDFFactures $posyafter = $pdf->GetY(); $height_note=$posyafter-$tab_top; $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1); - - + + if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) ) { // not enough space, need to add page @@ -503,12 +503,12 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pageposafternote); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - + $posyafter = $tab_top_newpage; } - + } - + $tab_height = $tab_height - $height_note; $tab_top = $posyafter +6; } @@ -516,36 +516,36 @@ class pdf_sponge extends ModelePDFFactures { $height_note=0; } - + $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - + // Use new auto collum system $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref); - + // Loop on each lines $pageposbeforeprintlines=$pdf->getPage(); $pagenb = $pageposbeforeprintlines; for ($i = 0; $i < $nblignes; $i++) { - + $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); - + // Define size of image if we need it $imglinesize=array(); if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); - + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); - + $showpricebeforepagebreak=1; $posYAfterImage=0; $posYAfterDescription=0; - + if($this->getColumnStatus('photo')) { // We start with Photo of product line @@ -554,11 +554,11 @@ class pdf_sponge extends ModelePDFFactures $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pdf->setPage($pageposbefore+1); - + $curY = $tab_top_newpage; $showpricebeforepagebreak=0; } - + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi @@ -566,7 +566,7 @@ class pdf_sponge extends ModelePDFFactures $posYAfterImage=$curY+$imglinesize['height']; } } - + // Description of product line if ($this->getColumnStatus('desc')) { @@ -604,20 +604,20 @@ class pdf_sponge extends ModelePDFFactures } $posYAfterDescription=$pdf->GetY(); } - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - + // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - + // VAT Rate if ($this->getColumnStatus('vat')) { @@ -625,7 +625,7 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate); $nexY = max($pdf->GetY(),$nexY); } - + // Unit price before discount if ($this->getColumnStatus('subprice')) { @@ -633,7 +633,7 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax); $nexY = max($pdf->GetY(),$nexY); } - + // Quantity // Enough for 6 chars if ($this->getColumnStatus('qty')) @@ -642,7 +642,7 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'qty', $qty); $nexY = max($pdf->GetY(),$nexY); } - + // Situation progress if ($this->getColumnStatus('progress')) { @@ -650,7 +650,7 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'progress', $progress); $nexY = max($pdf->GetY(),$nexY); } - + // Unit if ($this->getColumnStatus('unit')) { @@ -658,7 +658,7 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'unit', $unit); $nexY = max($pdf->GetY(),$nexY); } - + // Discount on line if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) { @@ -666,7 +666,7 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent); $nexY = max($pdf->GetY(),$nexY); } - + // Total HT line if ($this->getColumnStatus('totalexcltax')) { @@ -674,8 +674,8 @@ class pdf_sponge extends ModelePDFFactures $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax); $nexY = max($pdf->GetY(),$nexY); } - - + + $parameters=array( 'object' => $object, 'i' => $i, @@ -686,9 +686,9 @@ class pdf_sponge extends ModelePDFFactures 'hidedetails' => $hidedetails ); $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this); // Note that $object may have been modified by hook - - - + + + $sign=1; if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva @@ -701,20 +701,20 @@ class pdf_sponge extends ModelePDFFactures if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva; else $tvaligne= $sign * $object->lines[$i]->total_tva; } - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; $localtax2_rate=$object->lines[$i]->localtax2_tx; $localtax1_type=$object->lines[$i]->localtax1_type; $localtax2_type=$object->lines[$i]->localtax2_type; - + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; - + $vatrate=(string) $object->lines[$i]->tva_tx; - + // Retrieve type from database for backward compatibility with old records if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax @@ -723,19 +723,19 @@ class pdf_sponge extends ModelePDFFactures $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } - + // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; - + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; $this->tva[$vatrate] += $tvaligne; - + $nexY = max($nexY,$posYAfterImage); - + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { @@ -745,9 +745,9 @@ class pdf_sponge extends ModelePDFFactures $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); $pdf->SetLineStyle(array('dash'=>0)); } - + $nexY+=2; // Passe espace entre les lignes - + // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { @@ -766,7 +766,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { if ($pagenb == $pageposafter) @@ -784,9 +784,9 @@ class pdf_sponge extends ModelePDFFactures $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - + } - + // Show square if ($pagenb == $pageposbeforeprintlines) { @@ -798,38 +798,38 @@ class pdf_sponge extends ModelePDFFactures $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - + // Affiche zone infos $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - + // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - + // Affiche zone versements if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); - + $pdf->Close(); - + $pdf->Output($file,'F'); - + // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - + if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - + $this->result = array('fullpath'=>$file); - + return 1; // No error } else @@ -1511,29 +1511,29 @@ class pdf_sponge extends ModelePDFFactures foreach ($this->cols as $colKey => $colDef) { if(!$this->getColumnStatus($colKey)) continue; - + // get title label $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']); - + // Add column separator if(!empty($colDef['border-left'])){ $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); } - + if (empty($hidetop)) { $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] ); - + $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1]; $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']); } } - + if (empty($hidetop)){ $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param } - + } /** @@ -1548,7 +1548,7 @@ class pdf_sponge extends ModelePDFFactures function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; - + // Translations $outputlangs->loadLangs(array("main", "bills", "propal", "companies")); @@ -1573,27 +1573,30 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - if (is_readable($logo)) + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B',$default_font_size - 2); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',$default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $text=$this->emetteur->name; + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); @@ -1822,9 +1825,9 @@ class pdf_sponge extends ModelePDFFactures return pdf_pagefoot($pdf,$outputlangs,'INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } - - - + + + /** * Define Array Column Field * @@ -1836,21 +1839,21 @@ class pdf_sponge extends ModelePDFFactures * @return null */ function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){ - + global $conf, $hookmanager; - + // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); - + // Default field style for content $this->defaultTitlesFieldsStyle = array( - 'align' => 'C', // R,C,L + 'align' => 'C', // R,C,L 'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); - + /* * For exemple $this->cols['theColKey'] = array( @@ -1859,19 +1862,19 @@ class pdf_sponge extends ModelePDFFactures 'title' => array( 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label 'label' => ' ', // the final label : used fore final generated text - 'align' => 'L', // text alignement : R,C,L + 'align' => 'L', // text alignement : R,C,L 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( - 'align' => 'L', // text alignement : R,C,L + 'align' => 'L', // text alignement : R,C,L 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); */ - + $rank=0; // do not use negative rank $this->cols['desc'] = array( - 'rank' => $rank, + 'rank' => $rank, 'width' => false, // only for desc 'status' => true, 'title' => array( @@ -1885,7 +1888,7 @@ class pdf_sponge extends ModelePDFFactures 'align' => 'L', ), ); - + // PHOTO $rank = $rank + 10; $this->cols['photo'] = array( @@ -1894,20 +1897,20 @@ class pdf_sponge extends ModelePDFFactures 'status' => false, 'title' => array( 'textkey' => 'Photo', - 'label' => ' ' + 'label' => ' ' ), 'content' => array( 'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'border-left' => false, // remove left line separator ); - + if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } - - + + $rank = $rank + 10; $this->cols['vat'] = array( 'rank' => $rank, @@ -1918,12 +1921,12 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $this->cols['vat']['status'] = true; } - + $rank = $rank + 10; $this->cols['subprice'] = array( 'rank' => $rank, @@ -1934,7 +1937,7 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, @@ -1945,7 +1948,7 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - + $rank = $rank + 10; $this->cols['progress'] = array( 'rank' => $rank, @@ -1956,12 +1959,12 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - + if($this->situationinvoice) { $this->cols['progress']['status'] = true; } - + $rank = $rank + 10; $this->cols['unit'] = array( 'rank' => $rank, @@ -1975,7 +1978,7 @@ class pdf_sponge extends ModelePDFFactures if($conf->global->PRODUCT_USE_UNITS){ $this->cols['unit']['status'] = true; } - + $rank = $rank + 10; $this->cols['discount'] = array( 'rank' => $rank, @@ -1989,7 +1992,7 @@ class pdf_sponge extends ModelePDFFactures if ($this->atleastonediscount){ $this->cols['discount']['status'] = true; } - + $rank = $rank + 10; $this->cols['totalexcltax'] = array( 'rank' => $rank, @@ -2000,8 +2003,8 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - - + + $parameters=array( 'object' => $object, 'outputlangs' => $outputlangs, @@ -2009,7 +2012,7 @@ class pdf_sponge extends ModelePDFFactures 'hidedesc' => $hidedesc, 'hideref' => $hideref ); - + $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this); // Note that $object may have been modified by hook if ($reshook < 0) { @@ -2023,8 +2026,8 @@ class pdf_sponge extends ModelePDFFactures { $this->cols = $hookmanager->resArray; } - + } - - + + } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 40b73e4bf7f..adb52867a36 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1463,27 +1463,30 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - if (is_readable($logo)) + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B',$default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',$default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } $pdf->SetFont('','B',$default_font_size + 3); $pdf->SetXY($posx,$posy); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index c9bce8b07a4..e1f874b6853 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -68,7 +68,7 @@ class pdf_cyan extends ModelePDFPropales function __construct($db) { global $conf,$langs,$mysoc; - + // Translations $langs->loadLangs(array("main", "bills")); @@ -107,8 +107,8 @@ class pdf_cyan extends ModelePDFPropales // Define position of columns $this->posxdesc=$this->marge_gauche+1; - - + + $this->tva=array(); $this->localtax1=array(); @@ -286,8 +286,8 @@ class pdf_cyan extends ModelePDFPropales break; } } - - + + // New page $pdf->AddPage(); @@ -308,7 +308,7 @@ class pdf_cyan extends ModelePDFPropales $tab_top = 90+$top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); - + // Incoterm $height_incoterms = 0; @@ -353,7 +353,7 @@ class pdf_cyan extends ModelePDFPropales if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; } - + $pagenb = $pdf->getPage(); if ($notetoshow) { @@ -361,24 +361,24 @@ class pdf_cyan extends ModelePDFPropales $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; $pageposbeforenote = $pagenb; - + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $pdf->startTransaction(); - + $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); // Description $pageposafternote=$pdf->getPage(); $posyafter = $pdf->GetY(); - + if($pageposafternote>$pageposbeforenote ) { $pdf->rollbackTransaction(true); - + // prepar pages to receive notes while ($pagenb < $pageposafternote) { $pdf->AddPage(); @@ -390,16 +390,16 @@ class pdf_cyan extends ModelePDFPropales // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); } - + // back to start $pdf->setPage($pageposbeforenote); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); $pdf->SetFont('','', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $pageposafternote=$pdf->getPage(); - + $posyafter = $pdf->GetY(); - + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text { $pdf->AddPage('','',true); @@ -411,14 +411,14 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); //$posyafter = $tab_top_newpage; } - - + + // apply note frame to previus pages $i = $pageposbeforenote; while ($i < $pageposafternote) { $pdf->setPage($i); - - + + $pdf->SetDrawColor(128,128,128); // Draw note frame if($i>$pageposbeforenote){ @@ -429,21 +429,21 @@ class pdf_cyan extends ModelePDFPropales $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); } - + // Add footer $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $this->_pagefoot($pdf,$object,$outputlangs,1); - + $i++; } - + // apply note frame to last page $pdf->setPage($pageposafternote); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $height_note=$posyafter-$tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); - + } else // No pagebreak { @@ -451,8 +451,8 @@ class pdf_cyan extends ModelePDFPropales $posyafter = $pdf->GetY(); $height_note=$posyafter-$tab_top; $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1); - - + + if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) ) { // not enough space, need to add page @@ -462,12 +462,12 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPage($pageposafternote); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - + $posyafter = $tab_top_newpage; } - + } - + $tab_height = $tab_height - $height_note; $tab_top = $posyafter +6; } @@ -479,10 +479,10 @@ class pdf_cyan extends ModelePDFPropales $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - + // Use new auto collum system $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref); - + // Loop on each lines $pageposbeforeprintlines=$pdf->getPage(); $pagenb = $pageposbeforeprintlines; @@ -513,12 +513,12 @@ class pdf_cyan extends ModelePDFPropales if (! empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pageposbefore+1); - + $curY = $tab_top_newpage; $showpricebeforepagebreak=0; } - - + + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi @@ -526,7 +526,7 @@ class pdf_cyan extends ModelePDFPropales $posYAfterImage=$curY+$imglinesize['height']; } } - + // Description of product line if($this->getColumnStatus('desc')) { @@ -540,7 +540,7 @@ class pdf_cyan extends ModelePDFPropales //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc); - + $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; @@ -596,7 +596,7 @@ class pdf_cyan extends ModelePDFPropales $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax); $nexY = max($pdf->GetY(),$nexY); } - + // Quantity // Enough for 6 chars if ($this->getColumnStatus('qty')) @@ -605,8 +605,8 @@ class pdf_cyan extends ModelePDFPropales $this->printStdColumnContent($pdf, $curY, 'qty', $qty); $nexY = max($pdf->GetY(),$nexY); } - - + + // Unit if ($this->getColumnStatus('unit')) { @@ -614,7 +614,7 @@ class pdf_cyan extends ModelePDFPropales $this->printStdColumnContent($pdf, $curY, 'unit', $unit); $nexY = max($pdf->GetY(),$nexY); } - + // Discount on line if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) { @@ -622,7 +622,7 @@ class pdf_cyan extends ModelePDFPropales $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent); $nexY = max($pdf->GetY(),$nexY); } - + // Total HT line if ($this->getColumnStatus('totalexcltax')) { @@ -630,8 +630,8 @@ class pdf_cyan extends ModelePDFPropales $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax); $nexY = max($pdf->GetY(),$nexY); } - - + + $parameters=array( 'object' => $object, 'i' => $i, @@ -642,8 +642,8 @@ class pdf_cyan extends ModelePDFPropales 'hidedetails' => $hidedetails ); $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this); // Note that $object may have been modified by hook - - + + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; @@ -1389,29 +1389,29 @@ class pdf_cyan extends ModelePDFPropales foreach ($this->cols as $colKey => $colDef) { if(!$this->getColumnStatus($colKey)) continue; - + // get title label $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']); - + // Add column separator if(!empty($colDef['border-left'])){ $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); } - + if (empty($hidetop)) { $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] ); - + $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1]; $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']); } } - + if (empty($hidetop)){ $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param } - + } /** @@ -1451,27 +1451,30 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - if (is_readable($logo)) + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B',$default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',$default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } $pdf->SetFont('','B',$default_font_size + 3); $pdf->SetXY($posx,$posy); @@ -1686,8 +1689,8 @@ class pdf_cyan extends ModelePDFPropales return ($tab_hl*7); } - - + + /** * Define Array Column Field * @@ -1699,21 +1702,21 @@ class pdf_cyan extends ModelePDFPropales * @return null */ function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){ - + global $conf, $hookmanager; - + // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); - + // Default field style for content $this->defaultTitlesFieldsStyle = array( 'align' => 'C', // R,C,L 'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); - + /* * For exemple $this->cols['theColKey'] = array( @@ -1731,7 +1734,7 @@ class pdf_cyan extends ModelePDFPropales ), ); */ - + $rank=0; // do not use negative rank $this->cols['desc'] = array( 'rank' => $rank, @@ -1748,7 +1751,7 @@ class pdf_cyan extends ModelePDFPropales 'align' => 'L', ), ); - + $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, @@ -1763,13 +1766,13 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => false, // remove left line separator ); - + if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } - - + + $rank = $rank + 10; $this->cols['vat'] = array( 'rank' => $rank, @@ -1780,12 +1783,12 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $this->cols['vat']['status'] = true; } - + $rank = $rank + 10; $this->cols['subprice'] = array( 'rank' => $rank, @@ -1796,7 +1799,7 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, @@ -1807,7 +1810,7 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - + $rank = $rank + 10; $this->cols['progress'] = array( 'rank' => $rank, @@ -1818,12 +1821,12 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => false, // add left line separator ); - + if($this->situationinvoice) { $this->cols['progress']['status'] = true; } - + $rank = $rank + 10; $this->cols['unit'] = array( 'rank' => $rank, @@ -1837,7 +1840,7 @@ class pdf_cyan extends ModelePDFPropales if($conf->global->PRODUCT_USE_UNITS){ $this->cols['unit']['status'] = true; } - + $rank = $rank + 10; $this->cols['discount'] = array( 'rank' => $rank, @@ -1851,7 +1854,7 @@ class pdf_cyan extends ModelePDFPropales if ($this->atleastonediscount){ $this->cols['discount']['status'] = true; } - + $rank = $rank + 10; $this->cols['totalexcltax'] = array( 'rank' => $rank, @@ -1862,8 +1865,8 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - - + + $parameters=array( 'object' => $object, 'outputlangs' => $outputlangs, @@ -1871,7 +1874,7 @@ class pdf_cyan extends ModelePDFPropales 'hidedesc' => $hidedesc, 'hideref' => $hideref ); - + $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this); // Note that $object may have been modified by hook if ($reshook < 0) { @@ -1885,7 +1888,7 @@ class pdf_cyan extends ModelePDFPropales { $this->cols = $hookmanager->resArray; } - + } - + }