--- /tmp/dsg/dolibarr/htdocs/core/modules/expensereport/doc/github_19.0.3_pdf_standard.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/expensereport/doc/client_pdf_standard.modules.php @@ -4,2 +4,2 @@ - * Copyright (C) 2016-2023 Philippe Grand - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2016-2019 Philippe Grand + * Copyright (C) 2018 Frédéric France @@ -47,2 +47,70 @@ - /** - * @var DoliDb Database handler + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe @@ -50,42 +118 @@ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var int Save the name of generated file as the main doc when generating a doc with this template - */ - public $update_main_doc_field; - - /** - * @var string document type - */ - public $type; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - public $posxpiece; - public $posxcomment; - public $posxtva; - public $posxup; - public $posxqty; - public $posxtype; - - /** - * @var int posx date - */ - public $posxdate; - public $posxprojet; - public $postotalht; - public $postotalttc; + public $emetteur; @@ -109 +135,0 @@ - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template @@ -117,11 +143,12 @@ - $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); - $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); - $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); - $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - - $this->option_logo = 1; // Display logo - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_modereg = 1; // Display payment mode - $this->option_condreg = 1; // Display payment terms - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte @@ -135,3 +162 @@ - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined @@ -145,6 +170,5 @@ - $this->posxtva = 112; - $this->posxup = 127; - $this->posxqty = 150; - $this->postotalht = 160; - $this->postotalttc = 180; - // if (!isModEnabled('project')) { + $this->posxtva = 130; + $this->posxup = 145; + $this->posxqty = 168; + $this->postotalttc = 178; + // if (empty($conf->projet->enabled)) { @@ -156 +180,2 @@ - if ($this->page_largeur < 210) { // To work with US executive format + if ($this->page_largeur < 210) // To work with US executive format + { @@ -167 +191,0 @@ - $this->tva_array = array(); @@ -171 +194,0 @@ - $this->atleastonediscount = 0; @@ -179,7 +202,7 @@ - * @param ExpenseReport $object Object to generate - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return int 1=OK, 0=KO + * @param Object $object Object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO @@ -189 +212 @@ - // phpcs:enable + // phpcs:enable @@ -192,3 +215 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -196,3 +217 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -210 +229,3 @@ - } else { + } + else + { @@ -216,2 +237,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -223 +246,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -225 +249,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -238,18 +263,18 @@ - $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 + 12; // Height reserved to output the footer (value include bottom margin) - if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { - $heightforfooter += 6; - } - - $pdf->SetAutoPageBreak(1, 0); - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $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 + 12; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + + $pdf->SetAutoPageBreak(1, 0); + + 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); + } @@ -266,3 +291 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -274,3 +297 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -284,3 +305,3 @@ - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 65 : 10); - - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10); + $tab_height = 130; + $tab_height_newpage = 150; @@ -290 +311,2 @@ - if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) { + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + { @@ -292 +314,2 @@ - if (is_object($object->thirdparty)) { + if (is_object($object->thirdparty)) + { @@ -296,3 +319 @@ - if (!empty($salerepobj->signature)) { - $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); - } + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); @@ -301 +322,2 @@ - if ($notetoshow) { + if ($notetoshow) + { @@ -320 +342,3 @@ - } else { + } + else + { @@ -332 +356 @@ - while ($i < $nblines) { + while ($i < $nblines) { @@ -337,5 +361,5 @@ - if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) { - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - } else { - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. - } + if (empty($showpricebeforepagebreak)) { + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + } else { + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + } @@ -344,4 +368,4 @@ - $curY = $nexY; - $pdf->startTransaction(); - $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); - $pageposafter = $pdf->getPage(); + $curY = $nexY; + $pdf->startTransaction(); + $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); + $pageposafter = $pdf->getPage(); @@ -349 +373 @@ - // There is a pagebreak + // There is a pagebreak @@ -351 +374,0 @@ - @@ -355,20 +378,20 @@ - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $pdf->setPage($pageposafter + 1); - $showpricebeforepagebreak = 1; - $nexY = $tab_top_newpage; - $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines - $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage - $pdf->SetTextColor(0, 0, 0); - - $pdf->setTopMargin($tab_top_newpage); - continue; - } else { - $pdf->setPageOrientation('', 1, $heightforfooter); - $showpricebeforepagebreak = 0; - } + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + $pdf->setPage($pageposafter + 1); + $showpricebeforepagebreak = 1; + $nexY = $tab_top_newpage; + $nexY += ($pdf->getFontSize() * 1.3); // Passe espace entre les lignes + $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage + $pdf->SetTextColor(0, 0, 0); + + $pdf->setTopMargin($tab_top_newpage); + continue; + } else { + $pdf->setPageOrientation('', 1, $heightforfooter); + $showpricebeforepagebreak = 0; + } @@ -381 +404 @@ - // There is no space left for total+free text + // There is no space left for total+free text @@ -383 +406 @@ - // No more lines, and no space left to show total, so we create a new page + // No more lines, and no space left to show total, so we create a new page @@ -385,6 +408,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -393 +412,3 @@ - } else { + } + else + { @@ -396 +417 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -398 +419 @@ - } else { + else @@ -400 +420,0 @@ - } @@ -402 +422,3 @@ - } else { // No pagebreak + } + else // No pagebreak + { @@ -406,9 +428,9 @@ - //nexY - $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. - - //$nblineFollowComment = 1; - // Search number of lines coming to know if there is enough room + //nexY + $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. + + //$nblineFollowComment = 1; + // Search number of lines coming to know if there is enough room @@ -425 +447 @@ - // $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed); + // $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed); @@ -428,2 +450,2 @@ - //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines - $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines + //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines + $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines @@ -432 +454,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -435 +458,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -437 +461,3 @@ - } else { + } + else + { @@ -444,2 +470,7 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + 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 == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); @@ -447,8 +478,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - } - if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { - if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + else + { @@ -460,3 +485 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -464,3 +487 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -474 +495,3 @@ - } else { + } + else + { @@ -481 +504 @@ - // Show total area box + // Show total area box @@ -490,2 +513,3 @@ - if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) { - // TODO Show vat amout per tax level + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) + { + // TODO Show vat amout per tax level @@ -510 +534 @@ - if ($sumPayments > 0 && !getDolGlobalString('PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS')) { + if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { @@ -516,3 +540 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -529,6 +551,8 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; - } - - dolChmod($file); + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -539 +563,3 @@ - } else { + } + else + { @@ -543 +569,3 @@ - } else { + } + else + { @@ -550,7 +578,7 @@ - * @param TCPDF $pdf Object PDF - * @param ExpenseReport $object Object to show - * @param int $linenumber line number - * @param int $curY current y position - * @param int $default_font_size default siez of font - * @param Translate $outputlangs Object lang for output - * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) + * @param TCPDF $pdf Object PDF + * @param Object $object Object to show + * @param int $linenumber line number + * @param int $curY current y position + * @param int $default_font_size default siez of font + * @param Translate $outputlangs Object lang for output + * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) @@ -561,23 +589,22 @@ - global $conf; - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetTextColor(0, 0, 0); - - // Accountancy piece - $pdf->SetXY($this->posxpiece, $curY); - $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1); - - // Date - //$pdf->SetXY($this->posxdate -1, $curY); - //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C'); - - // Type - $pdf->SetXY($this->posxtype - 1, $curY); - $nextColumnPosX = $this->posxup; - if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) { - $nextColumnPosX = $this->posxtva; - } - if (isModEnabled('project')) { - $nextColumnPosX = $this->posxprojet; - } - - $expensereporttypecode = $object->lines[$linenumber]->type_fees_code; + global $conf; + $pdf->SetFont('', '', $default_font_size - 1); + + // Accountancy piece + $pdf->SetXY($this->posxpiece, $curY); + $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1); + + // Date + //$pdf->SetXY($this->posxdate -1, $curY); + //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C'); + + // Type + $pdf->SetXY($this->posxtype - 1, $curY); + $nextColumnPosX = $this->posxup; + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { + $nextColumnPosX = $this->posxtva; + } + if (!empty($conf->projet->enabled)) { + $nextColumnPosX = $this->posxprojet; + } + + $expensereporttypecode = $object->lines[$linenumber]->type_fees_code; @@ -588,46 +615,42 @@ - $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); - } - //$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); - - //$pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); - - // Project - //if (isModEnabled('project')) - //{ - // $pdf->SetFont('','', $default_font_size - 1); - // $pdf->SetXY($this->posxprojet, $curY); - // $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$linenumber]->projet_ref, 0, 'C'); - //} - - // VAT Rate - if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) { - $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R'); - } - - // Unit price - $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); - - // Quantity - $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); - - // Total without taxes - $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4, price($object->lines[$linenumber]->total_ht), 0, 'R'); - - // Total with all taxes - $pdf->SetXY($this->postotalttc - 1, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); - - // Comments - $pdf->SetXY($this->posxcomment, $curY); - $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; - $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'
'; - if (!empty($object->lines[$linenumber]->projet_ref)) { - $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'
'; - } - $comment .= $object->lines[$linenumber]->comments; - $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1); + $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); + } + //$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); + + //$pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); + + // Project + //if (! empty($conf->projet->enabled)) + //{ + // $pdf->SetFont('','', $default_font_size - 1); + // $pdf->SetXY($this->posxprojet, $curY); + // $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$linenumber]->projet_ref, 0, 'C'); + //} + + // VAT Rate + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { + $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxtva, $curY); + $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R'); + } + + // Unit price + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); + + // Quantity + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); + + // Total with all taxes + $pdf->SetXY($this->postotalttc - 1, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); + + // Comments + $pdf->SetXY($this->posxcomment, $curY); + $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; + $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'
'; + if (!empty($object->lines[$linenumber]->projet_ref)) { + $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'
'; + } + $comment .= $object->lines[$linenumber]->comments; + $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1); @@ -637 +660 @@ - /** + /** @@ -640,4 +663,4 @@ - * @param TCPDF $pdf Object PDF - * @param ExpenseReport $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output + * @param PDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output @@ -664,3 +687,3 @@ - // Draft watermark - if ($object->fk_statut == 0 && getDolGlobalString('EXPENSEREPORT_DRAFT_WATERMARK')) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK); + // Draft watermark + if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK); @@ -681,2 +704,2 @@ - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) @@ -689 +712,3 @@ - } else { + } + else + { @@ -696 +721 @@ - $pdf->SetTextColor(0, 0, 60); + $pdf->SetTextColor(0, 0, 60); @@ -701,24 +726,24 @@ - // Ref complete - $posy += 8; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); - - // Date start period - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart")." : ".($object->date_debut > 0 ? dol_print_date($object->date_debut, "day", false, $outputlangs) : ''), '', 'R'); - - // Date end period - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd")." : ".($object->date_fin > 0 ? dol_print_date($object->date_fin, "day", false, $outputlangs) : ''), '', 'R'); - - // Status Expense Report - $posy += 6; - $pdf->SetXY($posx, $posy); - $pdf->SetFont('', 'B', $default_font_size + 2); - $pdf->SetTextColor(111, 81, 124); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities($object->labelStatusShort[$object->status]), '', 'R'); + // Ref complete + $posy += 8; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); + + // Date start period + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart")." : ".($object->date_debut > 0 ?dol_print_date($object->date_debut, "day", false, $outputlangs) : ''), '', 'R'); + + // Date end period + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd")." : ".($object->date_fin > 0 ?dol_print_date($object->date_fin, "day", false, $outputlangs) : ''), '', 'R'); + + // Status Expense Report + $posy += 6; + $pdf->SetXY($posx, $posy); + $pdf->SetFont('', 'B', $default_font_size + 2); + $pdf->SetTextColor(111, 81, 124); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities($object->statuts_short[$object->status]), '', 'R'); @@ -732,12 +757,4 @@ - if ($this->emetteur->phone) { - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); - } - if ($this->emetteur->fax) { - $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '').$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); - } - if ($this->emetteur->email) { - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); - } - if ($this->emetteur->url) { - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); - } + if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '').$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); @@ -754,6 +771,2 @@ - if ($receiver->email) { - $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($receiver->email); - } - if ($receiver_account->iban) { - $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->transnoentities("IBAN")." : ".$outputlangs->convToOutputCharset($receiver_account->iban); - } + if ($receiver->email) $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($receiver->email); + if ($receiver_account->iban) $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->transnoentities("IBAN")." : ".$outputlangs->convToOutputCharset($receiver_account->iban); @@ -765,3 +778 @@ - if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) { - $posx = 118; - } + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = 118; @@ -773 +784 @@ - $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripSociete"), '', 'L'); + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("TripSociete")." :", '', 'L'); @@ -780 +791 @@ - if (!getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) { + if (empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { @@ -799,3 +810 @@ - if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) { - $posx = $this->marge_gauche; - } + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; @@ -810 +819 @@ - // Informations for expense report (dates and users workflow) + // Informations for trip (dates and users workflow) @@ -818 +827 @@ - $posy = $pdf->GetY() + 1; + $posy += 5; @@ -826,2 +835 @@ - $userfee->fetch($object->fk_user_refuse); - $posy += 6; + $userfee->fetch($object->fk_user_refuse); $posy += 6; @@ -837 +845,3 @@ - } elseif ($object->fk_statut == 4) { + } + elseif ($object->fk_statut == 4) + { @@ -840,2 +850 @@ - $userfee->fetch($object->fk_user_cancel); - $posy += 6; + $userfee->fetch($object->fk_user_cancel); $posy += 6; @@ -851 +860,3 @@ - } else { + } + else + { @@ -854,2 +865 @@ - $userfee->fetch($object->fk_user_approve); - $posy += 6; + $userfee->fetch($object->fk_user_approve); $posy += 6; @@ -867,2 +877 @@ - $userfee->fetch($object->fk_user_paid); - $posy += 6; + $userfee->fetch($object->fk_user_paid); $posy += 6; @@ -883 +892 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -899,3 +908 @@ - if ($hidetop) { - $hidetop = -1; - } + if ($hidetop) $hidetop = -1; @@ -927 +934 @@ - $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1, '', '', 'R'); + $pdf->MultiCell($this->posxcomment - $this->posxpiece - 1, 1, '', '', 'R'); @@ -934 +941 @@ - $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities("Description"), '', 'L'); + $pdf->MultiCell($this->posxdate - $this->posxcomment - 1, 1, $outputlangs->transnoentities("Description"), '', 'L'); @@ -953,9 +960,9 @@ - //if (isModEnabled('project')) - //{ - // // Project - // $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); - // if (empty($hidetop)) { - // $pdf->SetXY($this->posxprojet - 1, $tab_top + 1); - // $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C'); - // } - //} + //if (!empty($conf->projet->enabled)) + //{ + // // Project + // $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); + // if (empty($hidetop)) { + // $pdf->SetXY($this->posxprojet - 1, $tab_top + 1); + // $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C'); + // } + //} @@ -964 +971 @@ - if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) { + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -967 +974 @@ - $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1); + $pdf->SetXY($this->posxtva - 1, $tab_top + 1); @@ -972 +979 @@ - // Unit price + // Unit price @@ -975,2 +982,2 @@ - $pdf->SetXY($this->posxup - 0.8, $tab_top + 1); - $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUTTC"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C'); @@ -982,9 +989,2 @@ - $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1); - $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); - } - - // Total without taxes - $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height); - if (empty($hidetop)) { - $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1); - $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalttc - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); @@ -996,2 +996,2 @@ - $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); + $pdf->SetXY($this->postotalttc - 1, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); @@ -1006,5 +1006,5 @@ - * @param TCPDF $pdf Object PDF - * @param ExpenseReport $object Object expensereport - * @param int $posy Position y in PDF - * @param Translate $outputlangs Object langs for output - * @return int Return integer <0 if KO, >0 if OK + * @param PDF $pdf Object PDF + * @param Object $object Object invoice + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK @@ -1038 +1038 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) { @@ -1056 +1056 @@ - $sql .= " WHERE e.rowid = ".((int) $object->id); + $sql .= " WHERE e.rowid = '".$object->id."'"; @@ -1062 +1062,2 @@ - if ($resql) { + if ($resql) + { @@ -1078 +1079 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) { @@ -1087 +1088,2 @@ - if ($num > 0 && $object->paid == 0) { + if ($num > 0 && $object->paid == 0) + { @@ -1106 +1108,3 @@ - } else { + } + else + { @@ -1110 +1113,0 @@ - return -1; @@ -1116,6 +1119,6 @@ - * - * @param TCPDF $pdf PDF - * @param ExpenseReport $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text @@ -1125 +1128,2 @@ - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); + global $conf; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;