124 global $user, $conf, $langs, $hookmanager;
126 if (!is_object($outputlangs)) {
127 $outputlangs = $langs;
130 $sav_charset_output = $outputlangs->charset_output;
132 $outputlangs->charset_output =
'ISO-8859-1';
136 $outputlangs->loadLangs(array(
"main",
"companies",
"bills",
"products",
"compta"));
144 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
149 $file = $dir.
"/bordereau-".$number.
".pdf";
152 if (!is_object($hookmanager)) {
153 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
156 $hookmanager->initHooks(array(
'pdfgeneration'));
157 $parameters = array(
'file' => $file,
'outputlangs' => $outputlangs);
159 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
163 $heightforinfotot = 50;
165 $heightforfooter = $this->marge_basse + 8;
167 $heightforfooter += 6;
169 $pdf->setAutoPageBreak(
true, 0);
171 if (class_exists(
'TCPDF')) {
172 $pdf->setPrintHeader(
false);
173 $pdf->setPrintFooter(
false);
179 $pdf->SetDrawColor(128, 128, 128);
181 $pdf->SetTitle($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
182 $pdf->SetSubject($outputlangs->transnoentities(
"CheckReceipt"));
183 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
184 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
185 $pdf->SetKeyWords($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
187 $pdf->SetCompression(
false);
191 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
193 $nboflines = count($this->lines);
196 $pages = intval($nboflines / $this->line_per_page);
197 if (($nboflines % $this->line_per_page) > 0) {
207 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
209 $this->
Body($pdf, $pagenb, $pages, $outputlangs);
212 $this->
_pagefoot($pdf,
null, $outputlangs);
213 if (method_exists($pdf,
'AliasNbPages')) {
214 $pdf->AliasNbPages();
219 $pdf->Output($file,
'F');
222 if (!is_object($hookmanager)) {
223 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
226 $hookmanager->initHooks(array(
'pdfgeneration'));
227 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
229 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
230 $this->warnings = $hookmanager->warnings;
232 $this->error = $hookmanager->error;
233 $this->errors = $hookmanager->errors;
240 $this->result = array(
'fullpath' => $file);
242 $outputlangs->charset_output = $sav_charset_output;
257 public function Header(&$pdf, $page, $pages, $outputlangs)
264 $outputlangs->loadLangs(array(
"compta",
"banks"));
266 $title = $outputlangs->transnoentities(
"CheckReceipt");
267 $pdf->SetFont(
'',
'B', $default_font_size);
269 $pdf->MultiCell(0, 2, $title, 0,
'L');
271 $pdf->SetFont(
'',
'', $default_font_size);
273 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Ref"), 0,
'L');
275 $pdf->SetFont(
'',
'', $default_font_size);
276 $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ?
" - ".$this->ref_ext :
'')), 0,
'L');
278 $pdf->SetFont(
'',
'', $default_font_size);
280 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Date"), 0,
'L');
282 $pdf->SetFont(
'',
'', $default_font_size);
285 $pdf->SetFont(
'',
'', $default_font_size);
287 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Owner"), 0,
'L');
288 $pdf->SetFont(
'',
'', $default_font_size);
290 $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->owner_name), 0,
'L');
292 $pdf->SetFont(
'',
'', $default_font_size);
294 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"BankAccount"), 0,
'L');
295 pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
297 $pdf->SetFont(
'',
'', $default_font_size);
298 $pdf->SetXY(114, 15);
299 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Signature"), 0,
'L');
301 $pdf->RoundedRect(9, 14, 192, 35, $this->corner_radius,
'1234',
'D');
302 $pdf->line(9, 19, 112, 19);
303 $pdf->line(9, 25, 112, 25);
305 $pdf->line(9, 31, 112, 31);
307 $pdf->line(30, 14, 30, 49);
308 $pdf->line(112, 14, 112, 49);
312 $pdf->RoundedRect(9, $posy, 192, 6, $this->corner_radius,
'1234',
'D');
313 $pdf->line(55, $posy, 55, $posy + 6);
314 $pdf->line(140, $posy, 140, $posy + 6);
315 $pdf->line(170, $posy, 170, $posy + 6);
317 $pdf->SetFont(
'',
'', $default_font_size);
318 $pdf->SetXY(10, $posy + 1);
319 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"NumberOfCheques"), 0,
'L');
321 $pdf->SetFont(
'',
'B', $default_font_size);
322 $pdf->SetXY(57, $posy + 1);
323 $pdf->MultiCell(40, 2, (
string) $this->nbcheque, 0,
'L');
325 $pdf->SetFont(
'',
'', $default_font_size);
326 $pdf->SetXY(148, $posy + 1);
327 $pdf->MultiCell(40, 2, $langs->trans(
"Total"));
329 $pdf->SetFont(
'',
'B', $default_font_size);
330 $pdf->SetXY(170, $posy + 1);
331 $pdf->MultiCell(31, 2,
price($this->
amount), 0,
'C',
false);
334 $pdf->SetFont(
'',
'', $default_font_size - 2);
335 $pdf->SetXY(11, $this->tab_top + 2);
336 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Num"), 0,
'L');
337 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
339 $pdf->SetXY(41, $this->tab_top + 2);
340 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Bank"), 0,
'L');
341 $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
343 $pdf->SetXY(101, $this->tab_top + 2);
344 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"CheckTransmitter"), 0,
'L');
345 $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
347 $pdf->SetXY(180, $this->tab_top + 2);
348 $pdf->MultiCell(20, 2, $outputlangs->transnoentities(
"Amount"), 0,
'R');
349 $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8);
351 $pdf->RoundedRect(9, $this->tab_top, 192, $this->tab_height + 10, $this->corner_radius,
'1234',
'D');
365 public function Body(&$pdf, $pagenb, $pages, $outputlangs)
372 $pdf->SetFont(
'',
'', $default_font_size - 1);
374 $pdf->SetFillColor(220, 220, 220);
377 $num = count($this->lines);
378 for ($j = 0; $j < $num; $j++) {
380 $dynamic_line_height = array();
381 $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
382 $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
383 $max_line_height = max($dynamic_line_height);
385 if ($max_line_height > $this->line_height) {
386 $nb_lines = floor($max_line_height / $this->line_height) + 1;
392 if ($lineinpage >= ($this->line_per_page - 1)) {
399 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
400 $pdf->SetFont(
'',
'', $default_font_size - 1);
401 $pdf->MultiCell(0, 3,
'');
402 $pdf->SetTextColor(0, 0, 0);
405 $lineinpage += $nb_lines;
407 $pdf->SetXY(1, $this->tab_top + 10 + $yp);
408 $pdf->MultiCell(8, $this->line_height, (
string) ($j + 1), 0,
'R',
false);
410 $pdf->SetXY(10, $this->tab_top + 10 + $yp);
411 $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq :
'', 0,
'L',
false);
413 $pdf->SetXY(40, $this->tab_top + 10 + $yp);
414 $pdf->MultiCell(60, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq,
'44'), 0,
'L',
false);
416 $pdf->SetXY(100, $this->tab_top + 10 + $yp);
417 $pdf->MultiCell(80, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq,
'50'), 0,
'L',
false);
419 $pdf->SetXY(180, $this->tab_top + 10 + $yp);
420 $pdf->MultiCell(20, $this->line_height,
price($this->lines[$j]->amount_chq), 0,
'R',
false);
422 $yp += ($this->line_height * $nb_lines);