27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
50 global $conf, $langs, $mysoc;
53 $langs->loadLangs(array(
"main",
"bills"));
56 $this->
name =
"blochet";
63 $this->page_largeur = $formatarray[
'width'];
64 $this->page_hauteur = $formatarray[
'height'];
65 $this->format = array($this->page_largeur, $this->page_hauteur);
72 $this->emetteur = $mysoc;
73 if (!$this->emetteur->country_code) {
74 $this->emetteur->country_code = substr($langs->defaultlang, -2);
78 $this->line_height = 5;
79 $this->line_per_page = 40;
80 $this->tab_height = 200;
93 public function write_file($object, $_dir, $number, $outputlangs)
96 global $user, $conf, $langs, $hookmanager;
98 if (!is_object($outputlangs)) {
99 $outputlangs = $langs;
102 $sav_charset_output = $outputlangs->charset_output;
103 if (!empty($conf->global->MAIN_USE_FPDF)) {
104 $outputlangs->charset_output =
'ISO-8859-1';
108 $outputlangs->loadLangs(array(
"main",
"companies",
"bills",
"products",
"compta"));
110 $dir = $_dir.
"/".
get_exdir($number, 0, 1, 0, $object,
'checkdeposits');
116 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
121 $file = $dir.
"/bordereau-".$number.
".pdf";
124 if (!is_object($hookmanager)) {
125 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
128 $hookmanager->initHooks(array(
'pdfgeneration'));
129 $parameters = array(
'file'=>$file,
'outputlangs'=>$outputlangs);
131 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
135 $heightforinfotot = 50;
136 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
137 $heightforfooter = $this->marge_basse + 8;
138 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
139 $heightforfooter += 6;
141 $pdf->SetAutoPageBreak(1, 0);
143 if (class_exists(
'TCPDF')) {
144 $pdf->setPrintHeader(
false);
145 $pdf->setPrintFooter(
false);
151 $pdf->SetDrawColor(128, 128, 128);
153 $pdf->SetTitle($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
154 $pdf->SetSubject($outputlangs->transnoentities(
"CheckReceipt"));
155 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
156 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
157 $pdf->SetKeyWords($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
159 $pdf->SetCompression(
false);
162 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
164 $nboflines = count($this->lines);
167 $pages = intval($nboflines / $this->line_per_page);
168 if (($nboflines % $this->line_per_page) > 0) {
178 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
180 $this->
Body($pdf, $pagenb, $pages, $outputlangs);
183 $this->
_pagefoot($pdf,
'', $outputlangs);
184 if (method_exists($pdf,
'AliasNbPages')) {
185 $pdf->AliasNbPages();
190 $pdf->Output($file,
'F');
193 if (!is_object($hookmanager)) {
194 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
197 $hookmanager->initHooks(array(
'pdfgeneration'));
198 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
200 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
202 $this->error = $hookmanager->error;
203 $this->errors = $hookmanager->errors;
206 if (!empty($conf->global->MAIN_UMASK)) {
207 @chmod($file, octdec($conf->global->MAIN_UMASK));
210 $this->result = array(
'fullpath'=>$file);
212 $outputlangs->charset_output = $sav_charset_output;
227 public function Header(&$pdf, $page, $pages, $outputlangs)
234 $outputlangs->loadLangs(array(
"compta",
"banks"));
236 $title = $outputlangs->transnoentities(
"CheckReceipt");
237 $pdf->SetFont(
'',
'B', $default_font_size);
239 $pdf->MultiCell(0, 2, $title, 0,
'L');
241 $pdf->SetFont(
'',
'', $default_font_size);
243 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Ref"), 0,
'L');
245 $pdf->SetFont(
'',
'', $default_font_size);
246 $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ?
" - ".$this->ref_ext :
'')), 0,
'L');
248 $pdf->SetFont(
'',
'', $default_font_size);
250 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Date"), 0,
'L');
252 $pdf->SetFont(
'',
'', $default_font_size);
253 $pdf->MultiCell(60, 2,
dol_print_date($this->date,
"day",
false, $outputlangs));
255 $pdf->SetFont(
'',
'', $default_font_size);
257 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Owner"), 0,
'L');
258 $pdf->SetFont(
'',
'', $default_font_size);
260 $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0,
'L');
262 $pdf->SetFont(
'',
'', $default_font_size);
264 $pdf->MultiCell(0, 2, $outputlangs->transnoentities(
"Account"), 0,
'L');
265 pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
267 $pdf->SetFont(
'',
'', $default_font_size);
268 $pdf->SetXY(114, 15);
269 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Signature"), 0,
'L');
271 $pdf->Rect(9, 14, 192, 35);
272 $pdf->line(9, 19, 112, 19);
273 $pdf->line(9, 25, 112, 25);
275 $pdf->line(9, 31, 112, 31);
277 $pdf->line(30, 14, 30, 49);
278 $pdf->line(112, 14, 112, 49);
282 $pdf->Rect(9, $posy, 192, 6);
283 $pdf->line(55, $posy, 55, $posy + 6);
284 $pdf->line(140, $posy, 140, $posy + 6);
285 $pdf->line(170, $posy, 170, $posy + 6);
287 $pdf->SetFont(
'',
'', $default_font_size);
288 $pdf->SetXY(10, $posy + 1);
289 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"NumberOfCheques"), 0,
'L');
291 $pdf->SetFont(
'',
'B', $default_font_size);
292 $pdf->SetXY(57, $posy + 1);
293 $pdf->MultiCell(40, 2, $this->nbcheque, 0,
'L');
295 $pdf->SetFont(
'',
'', $default_font_size);
296 $pdf->SetXY(148, $posy + 1);
297 $pdf->MultiCell(40, 2, $langs->trans(
"Total"));
299 $pdf->SetFont(
'',
'B', $default_font_size);
300 $pdf->SetXY(170, $posy + 1);
301 $pdf->MultiCell(31, 2,
price($this->amount), 0,
'C', 0);
304 $pdf->SetFont(
'',
'', $default_font_size - 2);
305 $pdf->SetXY(11, $this->tab_top + 2);
306 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Num"), 0,
'L');
307 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
309 $pdf->SetXY(41, $this->tab_top + 2);
310 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Bank"), 0,
'L');
311 $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
313 $pdf->SetXY(101, $this->tab_top + 2);
314 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"CheckTransmitter"), 0,
'L');
315 $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
317 $pdf->SetXY(180, $this->tab_top + 2);
318 $pdf->MultiCell(20, 2, $outputlangs->transnoentities(
"Amount"), 0,
'R');
319 $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8);
321 $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10);
335 public function Body(&$pdf, $pagenb, $pages, $outputlangs)
342 $pdf->SetFont(
'',
'', $default_font_size - 1);
344 $pdf->SetFillColor(220, 220, 220);
347 $num = count($this->lines);
348 for ($j = 0; $j < $num; $j++) {
350 $dynamic_line_height = array();
351 $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
352 $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
353 $max_line_height = max($dynamic_line_height);
355 if ($max_line_height > $this->line_height) {
356 $nb_lines = floor($max_line_height / $this->line_height) + 1;
362 if ($lineinpage >= ($this->line_per_page - 1)) {
369 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
370 $pdf->SetFont(
'',
'', $default_font_size - 1);
371 $pdf->MultiCell(0, 3,
'');
372 $pdf->SetTextColor(0, 0, 0);
375 $lineinpage += $nb_lines;
377 $pdf->SetXY(1, $this->tab_top + 10 + $yp);
378 $pdf->MultiCell(8, $this->line_height, $j + 1, 0,
'R', 0);
380 $pdf->SetXY(10, $this->tab_top + 10 + $yp);
381 $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq :
'', 0,
'L', 0);
383 $pdf->SetXY(40, $this->tab_top + 10 + $yp);
384 $pdf->MultiCell(60, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq, 44), 0,
'L', 0);
386 $pdf->SetXY(100, $this->tab_top + 10 + $yp);
387 $pdf->MultiCell(80, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq, 50), 0,
'L', 0);
389 $pdf->SetXY(180, $this->tab_top + 10 + $yp);
390 $pdf->MultiCell(20, $this->line_height,
price($this->lines[$j]->amount_chq), 0,
'R', 0);
392 $yp = $yp + ($this->line_height * $nb_lines);
406 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
410 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
416 $paramfreetext =
'BANK_CHEQUERECEIPT_FREE_TEXT';
417 if (!empty($conf->global->$paramfreetext)) {
421 return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
Class of file to build cheque deposit receipts.
__construct($db)
Constructor.
Body(&$pdf, $pagenb, $pages, $outputlangs)
Output array.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Header(&$pdf, $page, $pages, $outputlangs)
Generate Header.
write_file($object, $_dir, $number, $outputlangs)
Fonction to generate document on disk.
Class parent for templates of document generation.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.