128 global $user, $conf, $langs, $hookmanager;
130 if (!is_object($outputlangs)) {
131 $outputlangs = $langs;
134 $sav_charset_output = $outputlangs->charset_output;
136 $outputlangs->charset_output =
'ISO-8859-1';
140 $outputlangs->loadLangs(array(
"main",
"companies",
"bills",
"products",
"compta"));
148 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
153 $file = $dir.
"/bordereau-".$number.
".pdf";
156 if (!is_object($hookmanager)) {
157 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
160 $hookmanager->initHooks(array(
'pdfgeneration'));
161 $parameters = array(
'file' => $file,
'outputlangs' => $outputlangs);
163 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
167 $heightforinfotot = 50;
168 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
169 $heightforfooter = $this->marge_basse + 8;
171 $heightforfooter += 6;
173 $pdf->SetAutoPageBreak(1, 0);
175 if (class_exists(
'TCPDF')) {
176 $pdf->setPrintHeader(
false);
177 $pdf->setPrintFooter(
false);
183 $pdf->SetDrawColor(128, 128, 128);
185 $pdf->SetTitle($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
186 $pdf->SetSubject($outputlangs->transnoentities(
"CheckReceipt"));
187 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
188 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
189 $pdf->SetKeyWords($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
191 $pdf->SetCompression(
false);
195 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
197 $nboflines = count($this->lines);
200 $pages = intval($nboflines / $this->line_per_page);
201 if (($nboflines % $this->line_per_page) > 0) {
211 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
213 $this->
Body($pdf, $pagenb, $pages, $outputlangs);
216 $this->
_pagefoot($pdf,
'', $outputlangs);
217 if (method_exists($pdf,
'AliasNbPages')) {
218 $pdf->AliasNbPages();
223 $pdf->Output($file,
'F');
226 if (!is_object($hookmanager)) {
227 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
230 $hookmanager->initHooks(array(
'pdfgeneration'));
231 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
233 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
235 $this->error = $hookmanager->error;
236 $this->errors = $hookmanager->errors;
241 $this->result = array(
'fullpath' => $file);
243 $outputlangs->charset_output = $sav_charset_output;
258 public function Header(&$pdf, $page, $pages, $outputlangs)
265 $outputlangs->loadLangs(array(
"compta",
"banks"));
267 $title = $outputlangs->transnoentities(
"CheckReceipt");
268 $pdf->SetFont(
'',
'B', $default_font_size);
270 $pdf->MultiCell(0, 2, $title, 0,
'L');
272 $pdf->SetFont(
'',
'', $default_font_size);
274 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Ref"), 0,
'L');
276 $pdf->SetFont(
'',
'', $default_font_size);
277 $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ?
" - ".$this->ref_ext :
'')), 0,
'L');
279 $pdf->SetFont(
'',
'', $default_font_size);
281 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Date"), 0,
'L');
283 $pdf->SetFont(
'',
'', $default_font_size);
284 $pdf->MultiCell(60, 2,
dol_print_date($this->date,
"day",
false, $outputlangs));
286 $pdf->SetFont(
'',
'', $default_font_size);
288 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Owner"), 0,
'L');
289 $pdf->SetFont(
'',
'', $default_font_size);
291 $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->owner_name), 0,
'L');
293 $pdf->SetFont(
'',
'', $default_font_size);
295 $pdf->MultiCell(0, 2, $outputlangs->transnoentities(
"BankAccount"), 0,
'L');
296 pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
298 $pdf->SetFont(
'',
'', $default_font_size);
299 $pdf->SetXY(114, 15);
300 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Signature"), 0,
'L');
302 $pdf->Rect(9, 14, 192, 35);
303 $pdf->line(9, 19, 112, 19);
304 $pdf->line(9, 25, 112, 25);
306 $pdf->line(9, 31, 112, 31);
308 $pdf->line(30, 14, 30, 49);
309 $pdf->line(112, 14, 112, 49);
313 $pdf->Rect(9, $posy, 192, 6);
314 $pdf->line(55, $posy, 55, $posy + 6);
315 $pdf->line(140, $posy, 140, $posy + 6);
316 $pdf->line(170, $posy, 170, $posy + 6);
318 $pdf->SetFont(
'',
'', $default_font_size);
319 $pdf->SetXY(10, $posy + 1);
320 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"NumberOfCheques"), 0,
'L');
322 $pdf->SetFont(
'',
'B', $default_font_size);
323 $pdf->SetXY(57, $posy + 1);
324 $pdf->MultiCell(40, 2, $this->nbcheque, 0,
'L');
326 $pdf->SetFont(
'',
'', $default_font_size);
327 $pdf->SetXY(148, $posy + 1);
328 $pdf->MultiCell(40, 2, $langs->trans(
"Total"));
330 $pdf->SetFont(
'',
'B', $default_font_size);
331 $pdf->SetXY(170, $posy + 1);
332 $pdf->MultiCell(31, 2,
price($this->amount), 0,
'C', 0);
335 $pdf->SetFont(
'',
'', $default_font_size - 2);
336 $pdf->SetXY(11, $this->tab_top + 2);
337 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Num"), 0,
'L');
338 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
340 $pdf->SetXY(41, $this->tab_top + 2);
341 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Bank"), 0,
'L');
342 $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
344 $pdf->SetXY(101, $this->tab_top + 2);
345 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"CheckTransmitter"), 0,
'L');
346 $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
348 $pdf->SetXY(180, $this->tab_top + 2);
349 $pdf->MultiCell(20, 2, $outputlangs->transnoentities(
"Amount"), 0,
'R');
350 $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8);
352 $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10);
366 public function Body(&$pdf, $pagenb, $pages, $outputlangs)
373 $pdf->SetFont(
'',
'', $default_font_size - 1);
375 $pdf->SetFillColor(220, 220, 220);
378 $num = count($this->lines);
379 for ($j = 0; $j < $num; $j++) {
381 $dynamic_line_height = array();
382 $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
383 $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
384 $max_line_height = max($dynamic_line_height);
386 if ($max_line_height > $this->line_height) {
387 $nb_lines = floor($max_line_height / $this->line_height) + 1;
393 if ($lineinpage >= ($this->line_per_page - 1)) {
400 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
401 $pdf->SetFont(
'',
'', $default_font_size - 1);
402 $pdf->MultiCell(0, 3,
'');
403 $pdf->SetTextColor(0, 0, 0);
406 $lineinpage += $nb_lines;
408 $pdf->SetXY(1, $this->tab_top + 10 + $yp);
409 $pdf->MultiCell(8, $this->line_height, $j + 1, 0,
'R', 0);
411 $pdf->SetXY(10, $this->tab_top + 10 + $yp);
412 $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq :
'', 0,
'L', 0);
414 $pdf->SetXY(40, $this->tab_top + 10 + $yp);
415 $pdf->MultiCell(60, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq, 44), 0,
'L', 0);
417 $pdf->SetXY(100, $this->tab_top + 10 + $yp);
418 $pdf->MultiCell(80, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq, 50), 0,
'L', 0);
420 $pdf->SetXY(180, $this->tab_top + 10 + $yp);
421 $pdf->MultiCell(20, $this->line_height,
price($this->lines[$j]->amount_chq), 0,
'R', 0);
423 $yp = $yp + ($this->line_height * $nb_lines);