pdf_sepamandate.modules.php 25 KB

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