PageRenderTime 60ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/facture/core/modules/facture/doc/pdf_crabe.modules.php

https://bitbucket.org/speedealing/speedealing
PHP | 1208 lines | 840 code | 192 blank | 176 comment | 182 complexity | 917d3607bae67ea3bee3b45bc156ea2d MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
  5. * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013 Herve Prot <herve.prot@symeos.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. * or see http://www.gnu.org/
  21. */
  22. require_once DOL_DOCUMENT_ROOT . '/facture/core/modules/facture/modules_facture.php';
  23. require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
  24. require_once DOL_DOCUMENT_ROOT . '/societe/lib/societe.lib.php';
  25. require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
  26. require_once DOL_DOCUMENT_ROOT . '/core/lib/pdf.lib.php';
  27. /**
  28. * Class to manage PDF invoice template Crabe
  29. */
  30. class pdf_crabe extends ModelePDFFactures {
  31. var $db;
  32. var $name;
  33. var $description;
  34. var $type;
  35. var $phpmin = array(4, 3, 0); // Minimum version of PHP required by module
  36. var $version = 'dolibarr';
  37. var $page_largeur;
  38. var $page_hauteur;
  39. var $format;
  40. var $marge_gauche;
  41. var $marge_droite;
  42. var $marge_haute;
  43. var $marge_basse;
  44. var $emetteur; // Objet societe qui emet
  45. /**
  46. * Constructor
  47. *
  48. * @param DoliDB $db Database handler
  49. */
  50. function __construct($db = '') {
  51. global $conf, $langs, $mysoc;
  52. $langs->load("main");
  53. $langs->load("bills");
  54. $this->db = $db;
  55. $this->name = "crabe";
  56. $this->description = $langs->trans('PDFCrabeDescription');
  57. // Dimension page pour format A4
  58. $this->type = 'pdf';
  59. $formatarray = pdf_getFormat();
  60. $this->page_largeur = $formatarray['width'];
  61. $this->page_hauteur = $formatarray['height'];
  62. $this->format = array($this->page_largeur, $this->page_hauteur);
  63. $this->marge_gauche = 10;
  64. $this->marge_droite = 10;
  65. $this->marge_haute = 10;
  66. $this->marge_basse = 10;
  67. $this->option_logo = 1; // Affiche logo
  68. $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
  69. $this->option_modereg = 1; // Affiche mode reglement
  70. $this->option_condreg = 1; // Affiche conditions reglement
  71. $this->option_codeproduitservice = 1; // Affiche code produit-service
  72. $this->option_multilang = 1; // Dispo en plusieurs langues
  73. $this->option_escompte = 1; // Affiche si il y a eu escompte
  74. $this->option_credit_note = 1; // Support credit notes
  75. $this->option_freetext = 1; // Support add of a personalised text
  76. $this->option_draft_watermark = 1; // Support add of a watermark on drafts
  77. $this->franchise = !$mysoc->tva_assuj;
  78. // Get source company
  79. $this->emetteur = $mysoc;
  80. if (empty($this->emetteur->country_code))
  81. $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
  82. // Defini position des colonnes
  83. $this->posxdesc = $this->marge_gauche + 1;
  84. $this->posxtva = 111;
  85. $this->posxup = 126;
  86. $this->posxqty = 145;
  87. $this->posxdiscount = 162;
  88. $this->postotalht = 174;
  89. $this->tva = array();
  90. $this->localtax1 = array();
  91. $this->localtax2 = array();
  92. $this->atleastoneratenotnull = 0;
  93. $this->atleastonediscount = 0;
  94. }
  95. /**
  96. * Function to build pdf onto disk
  97. *
  98. * @param Object $object Object to generate
  99. * @param Translate $outputlangs Lang output object
  100. * @param string $srctemplatepath Full path of source filename for generator using a template file
  101. * @param int $hidedetails Do not show line details
  102. * @param int $hidedesc Do not show desc
  103. * @param int $hideref Do not show ref
  104. * @return int 1=OK, 0=KO
  105. */
  106. function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) {
  107. global $user, $langs, $conf, $mysoc, $hookmanager;
  108. if (!is_object($outputlangs))
  109. $outputlangs = $langs;
  110. // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
  111. if (!empty($conf->global->MAIN_USE_FPDF))
  112. $outputlangs->charset_output = 'ISO-8859-1';
  113. $outputlangs->load("main");
  114. $outputlangs->load("dict");
  115. $outputlangs->load("companies");
  116. $outputlangs->load("bills");
  117. $outputlangs->load("products");
  118. $default_font_size = pdf_getPDFFontSize($outputlangs);
  119. if ($conf->facture->dir_output) {
  120. $object->fetch_thirdparty();
  121. $deja_regle = 0; // $object->getSommePaiement();
  122. $amount_credit_notes_included = 0; //$object->getSumCreditNotesUsed();
  123. $amount_deposits_included = 0; //$object->getSumDepositsUsed();
  124. // Definition of $dir and $file
  125. if ($object->specimen) {
  126. $dir = $conf->facture->dir_output;
  127. $file = $dir . "/SPECIMEN.pdf";
  128. } else {
  129. $objectref = dol_sanitizeFileName($object->ref);
  130. $dir = $conf->facture->dir_output . "/" . $objectref;
  131. $file = $dir . "/" . $objectref . ".pdf";
  132. }
  133. if (!file_exists($dir)) {
  134. if (dol_mkdir($dir) < 0) {
  135. $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
  136. return 0;
  137. }
  138. }
  139. if (file_exists($dir)) {
  140. $nblignes = count($object->lines);
  141. $pdf = pdf_getInstance($this->format);
  142. $heightforinfotot = 50; // Height reserved to output the info and total part
  143. $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
  144. $pdf->SetAutoPageBreak(1, 0);
  145. if (class_exists('TCPDF')) {
  146. $pdf->setPrintHeader(false);
  147. $pdf->setPrintFooter(false);
  148. }
  149. $pdf->SetFont(pdf_getPDFFont($outputlangs));
  150. // Set path to the background PDF File
  151. if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
  152. $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
  153. $tplidx = $pdf->importPage(1);
  154. }
  155. $pdf->Open();
  156. $pagenb = 0;
  157. $pdf->SetDrawColor(128, 128, 128);
  158. $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
  159. $pdf->SetSubject($outputlangs->transnoentities("Invoice"));
  160. $pdf->SetCreator("Speedealing " . DOL_VERSION);
  161. $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
  162. $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Invoice"));
  163. if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION))
  164. $pdf->SetCompression(false);
  165. $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
  166. // Positionne $this->atleastonediscount si on a au moins une remise
  167. for ($i = 0; $i < $nblignes; $i++) {
  168. if ($object->lines[$i]->remise_percent) {
  169. $this->atleastonediscount++;
  170. }
  171. }
  172. // New page
  173. $pdf->AddPage();
  174. if (!empty($tplidx))
  175. $pdf->useTemplate($tplidx);
  176. $pagenb++;
  177. $this->_pagehead($pdf, $object, 1, $outputlangs);
  178. $pdf->SetFont('', '', $default_font_size - 1);
  179. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  180. $pdf->SetTextColor(0, 0, 0);
  181. $tab_top = 90;
  182. $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
  183. $tab_height = 130;
  184. $tab_height_newpage = 150;
  185. // Affiche notes
  186. if (!empty($object->note_public)) {
  187. $tab_top = 88;
  188. $pdf->SetFont('', '', $default_font_size - 1);
  189. $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
  190. $nexY = $pdf->GetY();
  191. $height_note = $nexY - $tab_top;
  192. // Rect prend une longueur en 3eme param
  193. $pdf->SetDrawColor(192, 192, 192);
  194. //print $pdf->getStringHeight(200,'SPECIMEN',false,false);
  195. //print "$this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1";exit;
  196. $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
  197. $tab_height = $tab_height - $height_note;
  198. $tab_top = $nexY + 6;
  199. } else {
  200. $height_note = 0;
  201. }
  202. $iniY = $tab_top + 7;
  203. $curY = $tab_top + 7;
  204. $nexY = $tab_top + 7;
  205. // Loop on each lines
  206. for ($i = 0; $i < $nblignes; $i++) {
  207. $curY = $nexY;
  208. $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
  209. $pdf->SetTextColor(0, 0, 0);
  210. $pdf->setTopMargin($tab_top_newpage);
  211. $pdf->setPageOrientation('', 1, $this->marge_basse + $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
  212. $pageposbefore = $pdf->getPage();
  213. // Description of product line
  214. $curX = $this->posxdesc - 1;
  215. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
  216. $nexY = $pdf->GetY();
  217. $pageposafter = $pdf->getPage();
  218. $pdf->setPage($pageposbefore);
  219. $pdf->setTopMargin($this->marge_haute);
  220. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  221. // We suppose that a too long description is moved completely on next page
  222. if ($pageposafter > $pageposbefore) {
  223. $pdf->setPage($pageposafter);
  224. $curY = $tab_top_newpage;
  225. }
  226. $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
  227. // VAT Rate
  228. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
  229. $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
  230. $pdf->SetXY($this->posxtva, $curY);
  231. $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
  232. }
  233. // Unit price before discount
  234. $up_excl_tax = price($object->lines[$i]->pu_ht); //pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
  235. $pdf->SetXY($this->posxup, $curY);
  236. $pdf->MultiCell($this->posxqty - $this->posxup - 1, 3, $up_excl_tax, 0, 'R', 0);
  237. // Quantity
  238. $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
  239. $pdf->SetXY($this->posxqty, $curY);
  240. $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 3, $qty, 0, 'R'); // Enough for 6 chars
  241. // Discount on line
  242. if ($object->lines[$i]->remise_percent) {
  243. $pdf->SetXY($this->posxdiscount - 2, $curY);
  244. $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
  245. $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
  246. }
  247. // Total HT line
  248. $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
  249. $pdf->SetXY($this->postotalht, $curY);
  250. $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
  251. // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
  252. $tvaligne = $object->lines[$i]->total_tva;
  253. $localtax1ligne = $object->lines[$i]->total_localtax1;
  254. $localtax2ligne = $object->lines[$i]->total_localtax2;
  255. if ($object->remise_percent)
  256. $tvaligne-=($tvaligne * $object->remise_percent) / 100;
  257. if ($object->remise_percent)
  258. $localtax1ligne-=($localtax1ligne * $object->remise_percent) / 100;
  259. if ($object->remise_percent)
  260. $localtax2ligne-=($localtax2ligne * $object->remise_percent) / 100;
  261. $vatrate = (string) $object->lines[$i]->tva_tx;
  262. $localtax1rate = (string) $object->lines[$i]->localtax1_tx;
  263. $localtax2rate = (string) $object->lines[$i]->localtax2_tx;
  264. if (($object->lines[$i]->info_bits & 0x01) == 0x01)
  265. $vatrate.='*';
  266. if (!isset($this->tva[$vatrate]))
  267. $this->tva[$vatrate] = '';
  268. if (!isset($this->localtax1[$localtax1rate]))
  269. $this->localtax1[$localtax1rate] = '';
  270. if (!isset($this->localtax2[$localtax2rate]))
  271. $this->localtax2[$localtax2rate] = '';
  272. $this->tva[$vatrate] += $tvaligne;
  273. $this->localtax1[$localtax1rate]+=$localtax1ligne;
  274. $this->localtax2[$localtax2rate]+=$localtax2ligne;
  275. $nexY+=2; // Passe espace entre les lignes
  276. // Detect if some page were added automatically and output _tableau for past pages
  277. while ($pagenb < $pageposafter) {
  278. $pdf->setPage($pagenb);
  279. if ($pagenb == 1) {
  280. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  281. } else {
  282. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  283. }
  284. $this->_pagefoot($pdf, $object, $outputlangs);
  285. $pagenb++;
  286. $pdf->setPage($pagenb);
  287. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
  288. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD))
  289. $this->_pagehead($pdf, $object, 0, $outputlangs);
  290. }
  291. if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
  292. if ($pagenb == 1) {
  293. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
  294. } else {
  295. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
  296. }
  297. $this->_pagefoot($pdf, $object, $outputlangs);
  298. // New page
  299. $pdf->AddPage();
  300. if (!empty($tplidx))
  301. $pdf->useTemplate($tplidx);
  302. $pagenb++;
  303. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD))
  304. $this->_pagehead($pdf, $object, 0, $outputlangs);
  305. }
  306. }
  307. // Show square
  308. if ($pagenb == 1) {
  309. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0);
  310. $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfooter + 1;
  311. } else {
  312. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0);
  313. $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfooter + 1;
  314. }
  315. // Affiche zone infos
  316. $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
  317. // Affiche zone totaux
  318. $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
  319. // Affiche zone versements
  320. if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
  321. $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
  322. }
  323. // Pied de page
  324. $this->_pagefoot($pdf, $object, $outputlangs);
  325. $pdf->AliasNbPages();
  326. if (!empty($mysoc->cgv)) {
  327. $pdf->AddPage();
  328. if (!empty($tplidx))
  329. $pdf->useTemplate($tplidx);
  330. $pagenb++;
  331. //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD))
  332. // $this->_pagehead($pdf, $object, 0, $outputlangs);
  333. $tab_top = 20;
  334. $pdf->SetFont('', 'B', $default_font_size + 3);
  335. $posy = $this->marge_haute;
  336. $posx = $this->page_largeur - $this->marge_droite - 100;
  337. $pdf->SetXY($this->marge_gauche, $posy);
  338. $pdf->SetTextColor(0, 0, 60);
  339. $title = "Conditions générales de vente";
  340. $pdf->MultiCell(100, 4, $title, '', 'L');
  341. $pdf->SetFont('', '', $default_font_size - 4);
  342. $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($mysoc->cgv), 0, 1);
  343. $nexY = $pdf->GetY();
  344. $height_cgv = $nexY - $tab_top;
  345. // Rect prend une longueur en 3eme param
  346. //$pdf->SetDrawColor(192, 192, 192);
  347. //print $pdf->getStringHeight(200,'SPECIMEN',false,false);
  348. //print "$this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1";exit;
  349. //$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
  350. $tab_height = $tab_height - $height_cgv;
  351. }
  352. // Pied de page
  353. $this->_pagefoot($pdf, $object, $outputlangs);
  354. $pdf->AliasNbPages();
  355. $pdf->Close();
  356. $pdf->Output($file, 'F');
  357. // Add pdfgeneration hook
  358. $hookmanager->initHooks(array('pdfgeneration'));
  359. $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
  360. global $action;
  361. $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  362. if (!empty($conf->global->MAIN_UMASK))
  363. @chmod($file, octdec($conf->global->MAIN_UMASK));
  364. return 1; // Pas d'erreur
  365. }
  366. else {
  367. $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
  368. return 0;
  369. }
  370. } else {
  371. $this->error = $langs->trans("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
  372. return 0;
  373. }
  374. $this->error = $langs->trans("ErrorUnknown");
  375. return 0; // Erreur par defaut
  376. }
  377. /**
  378. * Show payments table
  379. *
  380. * @param PDF &$pdf Object PDF
  381. * @param Object $object Object invoice
  382. * @param int $posy Position y in PDF
  383. * @param Translate $outputlangs Object langs for output
  384. * @return int <0 if KO, >0 if OK
  385. */
  386. function _tableau_versements(&$pdf, $object, $posy, $outputlangs) {
  387. $tab3_posx = 120;
  388. $tab3_top = $posy + 8;
  389. $tab3_width = 80;
  390. $tab3_height = 4;
  391. $default_font_size = pdf_getPDFFontSize($outputlangs);
  392. $pdf->SetFont('', '', $default_font_size - 2);
  393. $pdf->SetXY($tab3_posx, $tab3_top - 5);
  394. $pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
  395. $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
  396. $pdf->SetFont('', '', $default_font_size - 4);
  397. $pdf->SetXY($tab3_posx, $tab3_top);
  398. $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
  399. $pdf->SetXY($tab3_posx + 21, $tab3_top);
  400. $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
  401. $pdf->SetXY($tab3_posx + 40, $tab3_top);
  402. $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
  403. $pdf->SetXY($tab3_posx + 58, $tab3_top);
  404. $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
  405. $y = 0;
  406. $pdf->SetFont('', '', $default_font_size - 4);
  407. // Loop on each deposits and credit notes included
  408. $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
  409. $sql.= " re.description, re.fk_facture_source,";
  410. $sql.= " f.type, f.datef";
  411. $sql.= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re, " . MAIN_DB_PREFIX . "facture as f";
  412. $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = " . $object->id;
  413. $resql = $this->db->query($sql);
  414. if ($resql) {
  415. $num = $this->db->num_rows($resql);
  416. $i = 0;
  417. $invoice = new Facture($this->db);
  418. while ($i < $num) {
  419. $y+=3;
  420. $obj = $this->db->fetch_object($resql);
  421. if ($obj->type == 2)
  422. $text = $outputlangs->trans("CreditNote");
  423. elseif ($obj->type == 3)
  424. $text = $outputlangs->trans("Deposit");
  425. else
  426. $text = $outputlangs->trans("UnknownType");
  427. $invoice->fetch($obj->fk_facture_source);
  428. $pdf->SetXY($tab3_posx, $tab3_top + $y);
  429. $pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
  430. $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
  431. $pdf->MultiCell(20, 3, price($obj->amount_ttc), 0, 'L', 0);
  432. $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
  433. $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
  434. $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
  435. $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
  436. $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
  437. $i++;
  438. }
  439. }
  440. else {
  441. $this->error = $this->db->lasterror();
  442. dol_syslog($this->db, $this->error, LOG_ERR);
  443. return -1;
  444. }
  445. // Loop on each payment
  446. $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,";
  447. $sql.= " cp.code";
  448. $sql.= " FROM " . MAIN_DB_PREFIX . "paiement_facture as pf, " . MAIN_DB_PREFIX . "paiement as p";
  449. $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_paiement as cp ON p.fk_paiement = cp.id";
  450. $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = " . $object->id;
  451. $sql.= " ORDER BY p.datep";
  452. $resql = $this->db->query($sql);
  453. if ($resql) {
  454. $num = $this->db->num_rows($resql);
  455. $i = 0;
  456. while ($i < $num) {
  457. $y+=3;
  458. $row = $this->db->fetch_object($resql);
  459. $pdf->SetXY($tab3_posx, $tab3_top + $y);
  460. $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
  461. $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
  462. $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
  463. $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
  464. $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
  465. $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
  466. $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
  467. $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
  468. $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
  469. $i++;
  470. }
  471. } else {
  472. $this->error = $this->db->lasterror();
  473. dol_syslog($this->db, $this->error, LOG_ERR);
  474. return -1;
  475. }
  476. }
  477. /**
  478. * Show miscellaneous information (payment mode, payment term, ...)
  479. *
  480. * @param PDF &$pdf Object PDF
  481. * @param Object $object Object to show
  482. * @param int $posy Y
  483. * @param Translate $outputlangs Langs object
  484. * @return void
  485. */
  486. function _tableau_info(&$pdf, $object, $posy, $outputlangs) {
  487. global $conf;
  488. $default_font_size = pdf_getPDFFontSize($outputlangs);
  489. $pdf->SetFont('', '', $default_font_size - 1);
  490. // If France, show VAT mention if not applicable
  491. if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) {
  492. $pdf->SetFont('', 'B', $default_font_size - 2);
  493. $pdf->SetXY($this->marge_gauche, $posy);
  494. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
  495. $posy = $pdf->GetY() + 4;
  496. }
  497. // Show payments conditions
  498. if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
  499. $pdf->SetFont('', 'B', $default_font_size - 2);
  500. $pdf->SetXY($this->marge_gauche, $posy);
  501. $titre = $outputlangs->transnoentities("PaymentConditions") . ':';
  502. $pdf->MultiCell(80, 4, $titre, 0, 'L');
  503. $pdf->SetFont('', '', $default_font_size - 2);
  504. $pdf->SetXY(52, $posy);
  505. $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != ('PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
  506. $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
  507. $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
  508. $posy = $pdf->GetY() + 3;
  509. }
  510. if ($object->type != 2) {
  511. // Check a payment mode is defined
  512. if (empty($object->mode_reglement_code)
  513. && !$conf->global->FACTURE_CHQ_NUMBER
  514. && !$conf->global->FACTURE_RIB_NUMBER) {
  515. $pdf->SetXY($this->marge_gauche, $posy);
  516. $pdf->SetTextColor(200, 0, 0);
  517. $pdf->SetFont('', 'B', $default_font_size - 2);
  518. $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"), 0, 'L', 0);
  519. $pdf->SetTextColor(0, 0, 0);
  520. $posy = $pdf->GetY() + 1;
  521. }
  522. // Show payment mode
  523. if ($object->mode_reglement_code
  524. && $object->mode_reglement_code != 'CHQ'
  525. && $object->mode_reglement_code != 'VIR') {
  526. $pdf->SetFont('', 'B', $default_font_size - 2);
  527. $pdf->SetXY($this->marge_gauche, $posy);
  528. $titre = $outputlangs->transnoentities("PaymentMode") . ':';
  529. $pdf->MultiCell(80, 5, $titre, 0, 'L');
  530. $pdf->SetFont('', '', $default_font_size - 2);
  531. $pdf->SetXY(50, $posy);
  532. $lib_mode_reg = $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) != ('PaymentType' . $object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
  533. $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
  534. $posy = $pdf->GetY() + 2;
  535. }
  536. // Show payment mode CHQ
  537. if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
  538. // Si mode reglement non force ou si force a CHQ
  539. if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
  540. if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
  541. $account = new Account($this->db);
  542. $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
  543. $pdf->SetXY($this->marge_gauche, $posy);
  544. $pdf->SetFont('', 'B', $default_font_size - 3);
  545. $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio) . ':', 0, 'L', 0);
  546. $posy = $pdf->GetY() + 1;
  547. $pdf->SetXY($this->marge_gauche, $posy);
  548. $pdf->SetFont('', '', $default_font_size - 3);
  549. $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
  550. $posy = $pdf->GetY() + 2;
  551. }
  552. if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
  553. $pdf->SetXY($this->marge_gauche, $posy);
  554. $pdf->SetFont('', 'B', $default_font_size - 3);
  555. $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort') . ' ' . $outputlangs->convToOutputCharset($this->emetteur->name) . ' ' . $outputlangs->transnoentities('SendTo') . ':', 0, 'L', 0);
  556. $posy = $pdf->GetY() + 1;
  557. $pdf->SetXY($this->marge_gauche, $posy);
  558. $pdf->SetFont('', '', $default_font_size - 3);
  559. $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
  560. $posy = $pdf->GetY() + 2;
  561. }
  562. }
  563. }
  564. // If payment mode not forced or forced to VIR, show payment with BAN
  565. if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
  566. if (!empty($conf->global->FACTURE_RIB_NUMBER)) {
  567. $account = new Account($this->db);
  568. $account->fetch($conf->global->FACTURE_RIB_NUMBER);
  569. $curx = $this->marge_gauche;
  570. $cury = $posy;
  571. $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
  572. $posy+=2;
  573. }
  574. }
  575. }
  576. return $posy;
  577. }
  578. /**
  579. * Show total to pay
  580. *
  581. * @param PDF &$pdf Object PDF
  582. * @param Facture $object Object invoice
  583. * @param int $deja_regle Montant deja regle
  584. * @param int $posy Position depart
  585. * @param Translate $outputlangs Objet langs
  586. * @return int Position pour suite
  587. */
  588. function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) {
  589. global $conf, $mysoc;
  590. $sign = 1;
  591. if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE))
  592. $sign = -1;
  593. $default_font_size = pdf_getPDFFontSize($outputlangs);
  594. $tab2_top = $posy;
  595. $tab2_hl = 4;
  596. $pdf->SetFont('', '', $default_font_size - 1);
  597. // Tableau total
  598. $col1x = 120;
  599. $col2x = 170;
  600. $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
  601. $useborder = 0;
  602. $index = 0;
  603. // Total HT
  604. $pdf->SetFillColor(255, 255, 255);
  605. $pdf->SetXY($col1x, $tab2_top + 0);
  606. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
  607. $pdf->SetXY($col2x, $tab2_top + 0);
  608. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (!empty($object->remise) ? $object->remise : 0))), 0, 'R', 1);
  609. // Show VAT by rates and total
  610. $pdf->SetFillColor(248, 248, 248);
  611. $this->atleastoneratenotnull = 0;
  612. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
  613. $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
  614. if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
  615. // Nothing to do
  616. } else {
  617. foreach ($this->tva as $tvakey => $tvaval) {
  618. if ($tvakey > 0) { // On affiche pas taux 0
  619. $this->atleastoneratenotnull++;
  620. $index++;
  621. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  622. $tvacompl = '';
  623. if (preg_match('/\*/', $tvakey)) {
  624. $tvakey = str_replace('*', '', $tvakey);
  625. $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
  626. }
  627. $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
  628. $totalvat.=vatrate($tvakey, 1) . $tvacompl;
  629. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
  630. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  631. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1);
  632. }
  633. }
  634. if (!$this->atleastoneratenotnull) { // If no vat at all
  635. $index++;
  636. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  637. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
  638. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  639. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_tva), 0, 'R', 1);
  640. // Total LocalTax1
  641. if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) {
  642. $index++;
  643. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  644. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1" . $mysoc->country_code), $useborder, 'L', 1);
  645. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  646. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax1), $useborder, 'R', 1);
  647. }
  648. // Total LocalTax2
  649. if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) {
  650. $index++;
  651. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  652. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2" . $mysoc->country_code), $useborder, 'L', 1);
  653. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  654. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax2), $useborder, 'R', 1);
  655. }
  656. } else {
  657. if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on') {
  658. //Local tax 1
  659. foreach ($this->localtax1 as $tvakey => $tvaval) {
  660. if ($tvakey != 0) { // On affiche pas taux 0
  661. //$this->atleastoneratenotnull++;
  662. $index++;
  663. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  664. $tvacompl = '';
  665. if (preg_match('/\*/', $tvakey)) {
  666. $tvakey = str_replace('*', '', $tvakey);
  667. $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
  668. }
  669. $totalvat = $outputlangs->transnoentities("TotalLT1" . $mysoc->country_code) . ' ';
  670. $totalvat.=vatrate($tvakey, 1) . $tvacompl;
  671. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
  672. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  673. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1);
  674. }
  675. }
  676. }
  677. if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on') {
  678. //Local tax 2
  679. foreach ($this->localtax2 as $tvakey => $tvaval) {
  680. if ($tvakey != 0) { // On affiche pas taux 0
  681. //$this->atleastoneratenotnull++;
  682. $index++;
  683. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  684. $tvacompl = '';
  685. if (preg_match('/\*/', $tvakey)) {
  686. $tvakey = str_replace('*', '', $tvakey);
  687. $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
  688. }
  689. $totalvat = $outputlangs->transnoentities("TotalLT2" . $mysoc->country_code) . ' ';
  690. $totalvat.=vatrate($tvakey, 1) . $tvacompl;
  691. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
  692. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  693. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1);
  694. }
  695. }
  696. }
  697. }
  698. // Total TTC
  699. $index++;
  700. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  701. $pdf->SetTextColor(0, 0, 60);
  702. $pdf->SetFillColor(224, 224, 224);
  703. $text = $outputlangs->transnoentities("TotalTTC");
  704. if ($object->type == 2)
  705. $text = $outputlangs->transnoentities("TotalTTCToYourCredit");
  706. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $text, $useborder, 'L', 1);
  707. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  708. $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc), $useborder, 'R', 1);
  709. }
  710. }
  711. $pdf->SetTextColor(0, 0, 0);
  712. $creditnoteamount = $object->getSumCreditNotesUsed();
  713. $depositsamount = $object->getSumDepositsUsed();
  714. //print "x".$creditnoteamount."-".$depositsamount;exit;
  715. $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
  716. if ($object->paye)
  717. $resteapayer = 0;
  718. if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) {
  719. // Already paid + Deposits
  720. $index++;
  721. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  722. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
  723. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  724. $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount), 0, 'R', 0);
  725. // Credit note
  726. if ($creditnoteamount) {
  727. $index++;
  728. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  729. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
  730. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  731. $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0);
  732. }
  733. // Escompte
  734. if ($object->close_code == 'discount_vat') {
  735. $index++;
  736. $pdf->SetFillColor(255, 255, 255);
  737. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  738. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
  739. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  740. $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount), $useborder, 'R', 1);
  741. $resteapayer = 0;
  742. }
  743. $index++;
  744. $pdf->SetTextColor(0, 0, 60);
  745. $pdf->SetFillColor(224, 224, 224);
  746. $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
  747. $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
  748. $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
  749. $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
  750. // Fin
  751. $pdf->SetFont('', '', $default_font_size - 1);
  752. $pdf->SetTextColor(0, 0, 0);
  753. }
  754. $index++;
  755. return ($tab2_top + ($tab2_hl * $index));
  756. }
  757. /**
  758. * Show table for lines
  759. *
  760. * @param PDF &$pdf Object PDF
  761. * @param string $tab_top Top position of table
  762. * @param string $tab_height Height of table (rectangle)
  763. * @param int $nexY Y (not used)
  764. * @param Translate $outputlangs Langs object
  765. * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
  766. * @param int $hidebottom Hide bottom bar of array
  767. * @return void
  768. */
  769. function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) {
  770. global $conf;
  771. // Force to disable hidetop and hidebottom
  772. $hidebottom = 0;
  773. if ($hidetop)
  774. $hidetop = -1;
  775. $default_font_size = pdf_getPDFFontSize($outputlangs);
  776. // Amount in (at tab_top - 1)
  777. $pdf->SetTextColor(0, 0, 0);
  778. $pdf->SetFont('', '', $default_font_size - 2);
  779. if (empty($hidetop)) {
  780. $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency));
  781. $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
  782. $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
  783. }
  784. $pdf->SetDrawColor(128, 128, 128);
  785. $pdf->SetFont('', '', $default_font_size - 1);
  786. // Output Rect
  787. $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
  788. if (empty($hidetop)) {
  789. $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
  790. $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
  791. $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
  792. }
  793. if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
  794. $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
  795. if (empty($hidetop)) {
  796. $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
  797. $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
  798. }
  799. }
  800. $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
  801. if (empty($hidetop)) {
  802. $pdf->SetXY($this->posxup - 1, $tab_top + 1);
  803. $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
  804. }
  805. $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
  806. if (empty($hidetop)) {
  807. $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
  808. $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
  809. }
  810. $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
  811. if (empty($hidetop)) {
  812. if ($this->atleastonediscount) {
  813. $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
  814. $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
  815. }
  816. }
  817. if ($this->atleastonediscount) {
  818. $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
  819. }
  820. if (empty($hidetop)) {
  821. $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
  822. $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
  823. }
  824. }
  825. /**
  826. * Show top header of page.
  827. *
  828. * @param PDF &$pdf Object PDF
  829. * @param Object $object Object to show
  830. * @param int $showaddress 0=no, 1=yes
  831. * @param Translate $outputlangs Object lang for output
  832. * @return void
  833. */
  834. function _pagehead(&$pdf, $object, $showaddress, $outputlangs) {
  835. global $conf, $langs, $mysoc;
  836. $outputlangs->load("main");
  837. $outputlangs->load("bills");
  838. $outputlangs->load("propal");
  839. $outputlangs->load("companies");
  840. $default_font_size = pdf_getPDFFontSize($outputlangs);
  841. pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
  842. // Show Draft Watermark
  843. if ($object->statut == 0 && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
  844. pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
  845. }
  846. $pdf->SetTextColor(0, 0, 60);
  847. $pdf->SetFont('', 'B', $default_font_size + 3);
  848. $posy = $this->marge_haute;
  849. $posx = $this->page_largeur - $this->marge_droite - 100;
  850. $pdf->SetXY($this->marge_gauche, $posy);
  851. // Logo
  852. if ($this->emetteur->logo && !empty($mysoc->logo)) {
  853. $logo = base64_decode($mysoc->getFileBase64($mysoc->logo));
  854. if (strlen($logo)>1) {
  855. $height = pdf_getHeightForLogo($logo);
  856. $pdf->Image('@'.$logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
  857. } else {
  858. $pdf->SetTextColor(200, 0, 0);
  859. $pdf->SetFont('', 'B', $default_font_size - 2);
  860. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
  861. $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
  862. }
  863. } else {
  864. $text = $this->emetteur->name;
  865. $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
  866. }
  867. $pdf->SetFont('', 'B', $default_font_size + 3);
  868. $pdf->SetXY($posx, $posy);
  869. $pdf->SetTextColor(0, 0, 60);
  870. $title = $outputlangs->transnoentities("Invoice");
  871. if ($object->type == 1)
  872. $title = $outputlangs->transnoentities("InvoiceReplacement");
  873. if ($object->type == 2)
  874. $titl

Large files files are truncated, but you can click here to view the full file