pdf_sepamandate.modules.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <?php
  2. /* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. * or see https://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
  21. * \ingroup project
  22. * \brief File of class to generate document with template sepamandate
  23. */
  24. require_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
  25. require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  29. /**
  30. * Class to generate SEPA mandate
  31. */
  32. class pdf_sepamandate extends ModeleBankAccountDoc
  33. {
  34. /**
  35. * Issuer
  36. * @var Societe
  37. */
  38. public $emetteur;
  39. /**
  40. * Dolibarr version of the loaded document
  41. * @var string
  42. */
  43. public $version = 'dolibarr';
  44. /**
  45. * Constructor
  46. *
  47. * @param DoliDB $db Database handler
  48. */
  49. public function __construct($db)
  50. {
  51. global $conf, $langs, $mysoc;
  52. // Translations
  53. $langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
  54. $this->db = $db;
  55. $this->name = "sepamandate";
  56. $this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate");
  57. // Page size for A4 format
  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 = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
  64. $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
  65. $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
  66. $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
  67. $this->option_logo = 1; // Display logo FAC_PDF_LOGO
  68. $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
  69. // Retrieves transmitter
  70. $this->emetteur = $mysoc;
  71. if (!$this->emetteur->country_code) {
  72. $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
  73. }
  74. // Define column position
  75. $this->posxref = $this->marge_gauche;
  76. }
  77. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  78. /**
  79. * Function to create pdf of company bank account sepa mandate
  80. *
  81. * @param CompanyBankAccount $object Object bank account to generate document for
  82. * @param Translate $outputlangs Lang output object
  83. * @param string $srctemplatepath Full path of source filename for generator using a template file
  84. * @param int $hidedetails Do not show line details (not used for this template)
  85. * @param int $hidedesc Do not show desc (not used for this template)
  86. * @param int $hideref Do not show ref (not used for this template)
  87. * @param null|array $moreparams More parameters
  88. * @return int 1 if OK, <=0 if KO
  89. */
  90. public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
  91. {
  92. // phpcs:enable
  93. global $conf, $hookmanager, $langs, $user, $mysoc;
  94. if (!is_object($outputlangs)) {
  95. $outputlangs = $langs;
  96. }
  97. // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
  98. if (!empty($conf->global->MAIN_USE_FPDF)) {
  99. $outputlangs->charset_output = 'ISO-8859-1';
  100. }
  101. // Load translation files required by the page
  102. $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
  103. if (!empty($conf->bank->dir_output)) {
  104. //$nblines = count($object->lines); // This is set later with array of tasks
  105. // Definition of $dir and $file
  106. if ($object->specimen) {
  107. if (!empty($moreparams['force_dir_output'])) {
  108. $dir = $moreparams['force_dir_output'];
  109. } else {
  110. $dir = $conf->bank->dir_output;
  111. }
  112. $file = $dir."/SPECIMEN.pdf";
  113. } else {
  114. $objectref = dol_sanitizeFileName($object->ref);
  115. if (!empty($moreparams['force_dir_output'])) {
  116. $dir = $moreparams['force_dir_output'];
  117. } else {
  118. $dir = $conf->bank->dir_output."/".$objectref;
  119. }
  120. $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
  121. }
  122. if (!file_exists($dir)) {
  123. if (dol_mkdir($dir) < 0) {
  124. $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
  125. return 0;
  126. }
  127. }
  128. if (file_exists($dir)) {
  129. // Add pdfgeneration hook
  130. if (!is_object($hookmanager)) {
  131. include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
  132. $hookmanager = new HookManager($this->db);
  133. }
  134. $hookmanager->initHooks(array('pdfgeneration'));
  135. $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
  136. global $action;
  137. $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  138. $pdf = pdf_getInstance($this->format);
  139. $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
  140. $heightforinfotot = 50; // Height reserved to output the info and total part
  141. $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
  142. $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
  143. if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
  144. $heightforfooter += 6;
  145. }
  146. $pdf->SetAutoPageBreak(1, 0);
  147. if (class_exists('TCPDF')) {
  148. $pdf->setPrintHeader(false);
  149. $pdf->setPrintFooter(false);
  150. }
  151. $pdf->SetFont(pdf_getPDFFont($outputlangs));
  152. $pdf->Open();
  153. $pagenb = 0;
  154. $pdf->SetDrawColor(128, 128, 128);
  155. $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
  156. $pdf->SetSubject($outputlangs->transnoentities("SepaMandate"));
  157. $pdf->SetCreator("Dolibarr ".DOL_VERSION);
  158. $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
  159. $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate"));
  160. if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
  161. $pdf->SetCompression(false);
  162. }
  163. $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
  164. // New page
  165. $pdf->AddPage();
  166. $pagenb++;
  167. $this->_pagehead($pdf, $object, 1, $outputlangs);
  168. $pdf->SetFont('', '', $default_font_size - 1);
  169. $pdf->MultiCell(0, 3, ''); // Set interline to 3
  170. $pdf->SetTextColor(0, 0, 0);
  171. $tab_top = 50;
  172. $tab_top_newpage = 40;
  173. $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
  174. // Show notes
  175. if (!empty($object->note_public)) {
  176. $pdf->SetFont('', '', $default_font_size - 1);
  177. $pdf->writeHTMLCell(190, 3, $this->posxref, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
  178. $nexY = $pdf->GetY();
  179. $height_note = $nexY - ($tab_top - 2);
  180. // Rect takes a length in 3rd parameter
  181. $pdf->SetDrawColor(192, 192, 192);
  182. $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
  183. $tab_height = $tab_height - $height_note;
  184. $tab_top = $nexY + 6;
  185. } else {
  186. $height_note = 0;
  187. }
  188. $iniY = $tab_top + 7;
  189. $curY = $tab_top + 7;
  190. $nexY = $tab_top + 7;
  191. $posY = $curY;
  192. $pdf->SetFont('', '', $default_font_size);
  193. $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
  194. $posY += 2;
  195. $pdf->SetXY($this->marge_gauche, $posY);
  196. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").') : '.$object->rum, 0, 'L');
  197. $posY = $pdf->GetY();
  198. $posY += 2;
  199. $pdf->SetXY($this->marge_gauche, $posY);
  200. $ics = '';
  201. $idbankfordirectdebit = getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT');
  202. if ($idbankfordirectdebit > 0) {
  203. $tmpbankfordirectdebit = new Account($this->db);
  204. $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
  205. $ics = $tmpbankfordirectdebit->ics; // ICS for direct debit
  206. }
  207. if (empty($ics) && !empty($conf->global->PRELEVEMENT_ICS)) {
  208. $ics = $conf->global->PRELEVEMENT_ICS;
  209. }
  210. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").') : '.$ics, 0, 'L');
  211. $posY = $pdf->GetY();
  212. $posY += 1;
  213. $pdf->SetXY($this->marge_gauche, $posY);
  214. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L');
  215. $posY = $pdf->GetY();
  216. $posY += 1;
  217. $pdf->SetXY($this->marge_gauche, $posY);
  218. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
  219. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0, 'L');
  220. $posY = $pdf->GetY();
  221. $posY += 3;
  222. $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
  223. $pdf->SetFont('', '', $default_font_size - 1);
  224. $posY += 8;
  225. $pdf->SetXY($this->marge_gauche, $posY);
  226. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L');
  227. // Your data form
  228. $posY = $pdf->GetY();
  229. $posY += 8;
  230. $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
  231. $posY += 2;
  232. $pdf->SetFont('', '', $default_font_size);
  233. $pdf->SetXY($this->marge_gauche, $posY);
  234. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C');
  235. $thirdparty = new Societe($this->db);
  236. if ($object->socid > 0) {
  237. $thirdparty->fetch($object->socid);
  238. }
  239. $sepaname = '______________________________________________';
  240. if ($thirdparty->id > 0) {
  241. $sepaname = $thirdparty->name.($object->proprio ? ' ('.$object->proprio.')' : '');
  242. }
  243. $posY = $pdf->GetY();
  244. $posY += 3;
  245. $pdf->SetXY($this->marge_gauche, $posY);
  246. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L');
  247. $pdf->SetXY(80, $posY);
  248. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L');
  249. $sepavatid = '__________________________________________________';
  250. if (!empty($thirdparty->idprof1)) {
  251. $sepavatid = $thirdparty->idprof1;
  252. }
  253. $posY = $pdf->GetY();
  254. $posY += 1;
  255. $pdf->SetXY($this->marge_gauche, $posY);
  256. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv('ProfId1'.$thirdparty->country_code).' * : ', 0, 'L');
  257. $pdf->SetXY(80, $posY);
  258. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0, 'L');
  259. $address = '______________________________________________';
  260. if ($thirdparty->id > 0) {
  261. $tmpaddresswithoutcountry = $thirdparty->getFullAddress(); // we test on address without country
  262. if ($tmpaddresswithoutcountry) {
  263. $address = $thirdparty->getFullAddress(1); // full address
  264. }
  265. }
  266. $posY = $pdf->GetY();
  267. $posY += 1;
  268. $pdf->SetXY($this->marge_gauche, $posY);
  269. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
  270. $pdf->SetXY(80, $posY);
  271. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
  272. if (preg_match('/_____/', $address)) {
  273. $posY += 6;
  274. $pdf->SetXY(80, $posY);
  275. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
  276. }
  277. $ban = '__________________________________________________';
  278. if (!empty($object->iban)) {
  279. $ban = $object->iban;
  280. }
  281. $posY = $pdf->GetY();
  282. $posY += 1;
  283. $pdf->SetXY($this->marge_gauche, $posY);
  284. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L');
  285. $pdf->SetXY(80, $posY);
  286. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L');
  287. $bic = '__________________________________________________';
  288. if (!empty($object->bic)) {
  289. $bic = $object->bic;
  290. }
  291. $posY = $pdf->GetY();
  292. $posY += 1;
  293. $pdf->SetXY($this->marge_gauche, $posY);
  294. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L');
  295. $pdf->SetXY(80, $posY);
  296. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L');
  297. $posY = $pdf->GetY();
  298. $posY += 1;
  299. $pdf->SetXY($this->marge_gauche, $posY);
  300. $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : ';
  301. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
  302. $pdf->Rect(80, $posY, 5, 5);
  303. $pdf->SetXY(80, $posY);
  304. if ($object->frstrecur == 'RECUR') {
  305. $pdf->MultiCell(5, 3, 'X', 0, 'L');
  306. }
  307. $pdf->SetXY(86, $posY);
  308. $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or");
  309. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
  310. $posY += 6;
  311. $pdf->Rect(80, $posY, 5, 5);
  312. $pdf->SetXY(80, $posY);
  313. if ($object->frstrecur == 'FRST') {
  314. $pdf->MultiCell(5, 3, 'X', 0, 'L');
  315. }
  316. $pdf->SetXY(86, $posY);
  317. $txt = $langs->transnoentitiesnoconv("ModeFRST");
  318. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
  319. if (empty($object->frstrecur)) {
  320. $posY += 6;
  321. $pdf->SetXY(80, $posY);
  322. $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
  323. $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
  324. }
  325. $posY = $pdf->GetY();
  326. $posY += 3;
  327. $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
  328. $posY += 3;
  329. // Show square
  330. if ($pagenb == 1) {
  331. $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
  332. $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
  333. } else {
  334. $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
  335. $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
  336. }
  337. //var_dump($tab_top);
  338. //var_dump($heightforinfotot);
  339. //var_dump($heightforfreetext);
  340. //var_dump($heightforfooter);
  341. //var_dump($bottomlasttab);
  342. // Affiche zone infos
  343. $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
  344. /*
  345. * Footer of the page
  346. */
  347. $this->_pagefoot($pdf, $object, $outputlangs);
  348. if (method_exists($pdf, 'AliasNbPages')) {
  349. $pdf->AliasNbPages();
  350. }
  351. $pdf->Close();
  352. $pdf->Output($file, 'F');
  353. // Add pdfgeneration hook
  354. if (!is_object($hookmanager)) {
  355. include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
  356. $hookmanager = new HookManager($this->db);
  357. }
  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 ($reshook < 0) {
  363. $this->error = $hookmanager->error;
  364. $this->errors = $hookmanager->errors;
  365. }
  366. if (!empty($conf->global->MAIN_UMASK)) {
  367. @chmod($file, octdec($conf->global->MAIN_UMASK));
  368. }
  369. $this->result = array('fullpath'=>$file);
  370. return 1; // No error
  371. } else {
  372. $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
  373. return 0;
  374. }
  375. }
  376. $this->error = $langs->transnoentities("ErrorConstantNotDefined", "DELIVERY_OUTPUTDIR");
  377. return 0;
  378. }
  379. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
  380. /**
  381. * Show table for lines
  382. *
  383. * @param TCPDF $pdf Object PDF
  384. * @param string $tab_top Top position of table
  385. * @param string $tab_height Height of table (rectangle)
  386. * @param int $nexY Y
  387. * @param Translate $outputlangs Langs object
  388. * @param int $hidetop Hide top bar of array
  389. * @param int $hidebottom Hide bottom bar of array
  390. * @return void
  391. */
  392. protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
  393. {
  394. // phpcs:enable
  395. global $conf, $mysoc;
  396. $default_font_size = pdf_getPDFFontSize($outputlangs);
  397. }
  398. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
  399. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  400. /**
  401. * Show miscellaneous information (payment mode, payment term, ...)
  402. *
  403. * @param TCPDF $pdf Object PDF
  404. * @param CompanyBankAccount $object Object to show
  405. * @param int $posy Y
  406. * @param Translate $outputlangs Langs object
  407. * @return void
  408. */
  409. protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
  410. {
  411. // phpcs:enable
  412. global $conf, $mysoc;
  413. $default_font_size = pdf_getPDFFontSize($outputlangs);
  414. $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
  415. $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
  416. $pdf->SetXY($this->marge_gauche, $posy);
  417. $pdf->SetFont('', '', $default_font_size);
  418. $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
  419. $posy = $pdf->GetY() + 2;
  420. $pdf->SetXY($this->marge_gauche, $posy);
  421. $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
  422. $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
  423. $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress(1)), 0, 'L', 0);
  424. $posy = $pdf->GetY() + 2;
  425. return $posy;
  426. }
  427. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
  428. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  429. /**
  430. * Show area for the customer to sign
  431. *
  432. * @param TCPDF $pdf Object PDF
  433. * @param CompanyBankAccount $object Object invoice
  434. * @param int $posy Position depart
  435. * @param Translate $outputlangs Objet langs
  436. * @return int Position pour suite
  437. */
  438. protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
  439. {
  440. // phpcs:enable
  441. $default_font_size = pdf_getPDFFontSize($outputlangs);
  442. $tab_top = $posy + 4;
  443. $tab_hl = 4;
  444. $posx = $this->marge_gauche;
  445. $pdf->SetXY($posx, $tab_top + 0);
  446. $pdf->SetFont('', '', $default_font_size - 2);
  447. $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
  448. $pdf->MultiCell(100, 3, ' ');
  449. $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
  450. $posx = 120;
  451. $largcol = ($this->page_largeur - $this->marge_droite - $posx);
  452. $useborder = 0;
  453. $index = 0;
  454. // Total HT
  455. $pdf->SetFillColor(255, 255, 255);
  456. $pdf->SetXY($posx, $tab_top + 0);
  457. $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
  458. $pdf->SetXY($posx, $tab_top + $tab_hl);
  459. $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
  460. return ($tab_hl * 7);
  461. }
  462. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
  463. /**
  464. * Show top header of page.
  465. *
  466. * @param TCPDF $pdf Object PDF
  467. * @param CompanyBankAccount $object Object to show
  468. * @param int $showaddress 0=no, 1=yes
  469. * @param Translate $outputlangs Object lang for output
  470. * @return void
  471. */
  472. protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
  473. {
  474. // phpcs:enable
  475. global $langs, $conf, $mysoc;
  476. $default_font_size = pdf_getPDFFontSize($outputlangs);
  477. pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
  478. $pdf->SetTextColor(0, 0, 60);
  479. $pdf->SetFont('', 'B', $default_font_size + 3);
  480. $posx = $this->page_largeur - $this->marge_droite - 100;
  481. $posy = $this->marge_haute;
  482. $pdf->SetXY($this->marge_gauche, $posy);
  483. // Logo
  484. $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
  485. if ($mysoc->logo) {
  486. if (is_readable($logo)) {
  487. $height = pdf_getHeightForLogo($logo);
  488. $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
  489. } else {
  490. $pdf->SetTextColor(200, 0, 0);
  491. $pdf->SetFont('', 'B', $default_font_size - 2);
  492. $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
  493. $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
  494. }
  495. } else {
  496. $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
  497. }
  498. $pdf->SetFont('', 'B', $default_font_size + 3);
  499. $pdf->SetXY($posx, $posy);
  500. $pdf->SetTextColor(0, 0, 60);
  501. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R');
  502. $pdf->SetFont('', '', $default_font_size + 2);
  503. $posy += 6;
  504. $pdf->SetXY($posx, $posy);
  505. $pdf->SetTextColor(0, 0, 60);
  506. $daterum = '__________________';
  507. if (!empty($object->date_rum)) {
  508. $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
  509. } else {
  510. $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved.
  511. }
  512. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R');
  513. /*$posy+=6;
  514. $pdf->SetXY($posx,$posy);
  515. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
  516. */
  517. $pdf->SetTextColor(0, 0, 60);
  518. // Add list of linked objects
  519. /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
  520. $object->fetchObjectLinked();
  521. foreach($object->linkedObjects as $objecttype => $objects)
  522. {
  523. var_dump($objects);exit;
  524. if ($objecttype == 'commande')
  525. {
  526. $outputlangs->load('orders');
  527. $num=count($objects);
  528. for ($i=0;$i<$num;$i++)
  529. {
  530. $posy+=4;
  531. $pdf->SetXY($posx,$posy);
  532. $pdf->SetFont('','', $default_font_size - 1);
  533. $text=$objects[$i]->ref;
  534. if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
  535. $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
  536. }
  537. }
  538. }
  539. */
  540. }
  541. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
  542. /**
  543. * Show footer of page. Need this->emetteur object
  544. *
  545. * @param TCPDF $pdf PDF
  546. * @param CompanyBankAccount $object Object to show
  547. * @param Translate $outputlangs Object lang for output
  548. * @param int $hidefreetext 1=Hide free text
  549. * @return integer
  550. */
  551. protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
  552. {
  553. // phpcs:enable
  554. global $conf;
  555. $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
  556. return pdf_pagefoot($pdf, $outputlangs, 'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
  557. }
  558. }