124 public function write_file($object, $_dir, $number, $outputlangs)
127 global $user, $conf, $langs, $hookmanager;
129 if (!is_object($outputlangs)) {
130 $outputlangs = $langs;
133 $sav_charset_output = $outputlangs->charset_output;
135 $outputlangs->charset_output =
'ISO-8859-1';
139 $outputlangs->loadLangs(array(
"main",
"companies",
"bills",
"products",
"compta"));
141 $dir = $_dir.
"/".
get_exdir($number, 0, 1, 0, $object,
'checkdeposits');
147 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
152 $file = $dir.
"/bordereau-".$number.
".pdf";
155 if (!is_object($hookmanager)) {
156 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
159 $hookmanager->initHooks(array(
'pdfgeneration'));
160 $parameters = array(
'file'=>$file,
'outputlangs'=>$outputlangs);
162 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
166 $heightforinfotot = 50;
167 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
168 $heightforfooter = $this->marge_basse + 8;
170 $heightforfooter += 6;
172 $pdf->SetAutoPageBreak(1, 0);
174 if (class_exists(
'TCPDF')) {
175 $pdf->setPrintHeader(
false);
176 $pdf->setPrintFooter(
false);
182 $pdf->SetDrawColor(128, 128, 128);
184 $pdf->SetTitle($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
185 $pdf->SetSubject($outputlangs->transnoentities(
"CheckReceipt"));
186 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
187 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
188 $pdf->SetKeyWords($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
190 $pdf->SetCompression(
false);
193 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
195 $nboflines = count($this->lines);
198 $pages = intval($nboflines / $this->line_per_page);
199 if (($nboflines % $this->line_per_page) > 0) {
209 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
211 $this->
Body($pdf, $pagenb, $pages, $outputlangs);
214 $this->
_pagefoot($pdf,
'', $outputlangs);
215 if (method_exists($pdf,
'AliasNbPages')) {
216 $pdf->AliasNbPages();
221 $pdf->Output($file,
'F');
224 if (!is_object($hookmanager)) {
225 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
228 $hookmanager->initHooks(array(
'pdfgeneration'));
229 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
231 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
233 $this->error = $hookmanager->error;
234 $this->errors = $hookmanager->errors;
239 $this->result = array(
'fullpath'=>$file);
241 $outputlangs->charset_output = $sav_charset_output;
256 public function Header(&$pdf, $page, $pages, $outputlangs)
263 $outputlangs->loadLangs(array(
"compta",
"banks"));
265 $title = $outputlangs->transnoentities(
"CheckReceipt");
266 $pdf->SetFont(
'',
'B', $default_font_size);
268 $pdf->MultiCell(0, 2, $title, 0,
'L');
270 $pdf->SetFont(
'',
'', $default_font_size);
272 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Ref"), 0,
'L');
274 $pdf->SetFont(
'',
'', $default_font_size);
275 $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ?
" - ".$this->ref_ext :
'')), 0,
'L');
277 $pdf->SetFont(
'',
'', $default_font_size);
279 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Date"), 0,
'L');
281 $pdf->SetFont(
'',
'', $default_font_size);
282 $pdf->MultiCell(60, 2,
dol_print_date($this->date,
"day",
false, $outputlangs));
284 $pdf->SetFont(
'',
'', $default_font_size);
286 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Owner"), 0,
'L');
287 $pdf->SetFont(
'',
'', $default_font_size);
289 $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0,
'L');
291 $pdf->SetFont(
'',
'', $default_font_size);
293 $pdf->MultiCell(0, 2, $outputlangs->transnoentities(
"Account"), 0,
'L');
294 pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
296 $pdf->SetFont(
'',
'', $default_font_size);
297 $pdf->SetXY(114, 15);
298 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Signature"), 0,
'L');
300 $pdf->Rect(9, 14, 192, 35);
301 $pdf->line(9, 19, 112, 19);
302 $pdf->line(9, 25, 112, 25);
304 $pdf->line(9, 31, 112, 31);
306 $pdf->line(30, 14, 30, 49);
307 $pdf->line(112, 14, 112, 49);
311 $pdf->Rect(9, $posy, 192, 6);
312 $pdf->line(55, $posy, 55, $posy + 6);
313 $pdf->line(140, $posy, 140, $posy + 6);
314 $pdf->line(170, $posy, 170, $posy + 6);
316 $pdf->SetFont(
'',
'', $default_font_size);
317 $pdf->SetXY(10, $posy + 1);
318 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"NumberOfCheques"), 0,
'L');
320 $pdf->SetFont(
'',
'B', $default_font_size);
321 $pdf->SetXY(57, $posy + 1);
322 $pdf->MultiCell(40, 2, $this->nbcheque, 0,
'L');
324 $pdf->SetFont(
'',
'', $default_font_size);
325 $pdf->SetXY(148, $posy + 1);
326 $pdf->MultiCell(40, 2, $langs->trans(
"Total"));
328 $pdf->SetFont(
'',
'B', $default_font_size);
329 $pdf->SetXY(170, $posy + 1);
330 $pdf->MultiCell(31, 2,
price($this->amount), 0,
'C', 0);
333 $pdf->SetFont(
'',
'', $default_font_size - 2);
334 $pdf->SetXY(11, $this->tab_top + 2);
335 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Num"), 0,
'L');
336 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
338 $pdf->SetXY(41, $this->tab_top + 2);
339 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Bank"), 0,
'L');
340 $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
342 $pdf->SetXY(101, $this->tab_top + 2);
343 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"CheckTransmitter"), 0,
'L');
344 $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
346 $pdf->SetXY(180, $this->tab_top + 2);
347 $pdf->MultiCell(20, 2, $outputlangs->transnoentities(
"Amount"), 0,
'R');
348 $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8);
350 $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10);
364 public function Body(&$pdf, $pagenb, $pages, $outputlangs)
371 $pdf->SetFont(
'',
'', $default_font_size - 1);
373 $pdf->SetFillColor(220, 220, 220);
376 $num = count($this->lines);
377 for ($j = 0; $j < $num; $j++) {
379 $dynamic_line_height = array();
380 $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
381 $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
382 $max_line_height = max($dynamic_line_height);
384 if ($max_line_height > $this->line_height) {
385 $nb_lines = floor($max_line_height / $this->line_height) + 1;
391 if ($lineinpage >= ($this->line_per_page - 1)) {
398 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
399 $pdf->SetFont(
'',
'', $default_font_size - 1);
400 $pdf->MultiCell(0, 3,
'');
401 $pdf->SetTextColor(0, 0, 0);
404 $lineinpage += $nb_lines;
406 $pdf->SetXY(1, $this->tab_top + 10 + $yp);
407 $pdf->MultiCell(8, $this->line_height, $j + 1, 0,
'R', 0);
409 $pdf->SetXY(10, $this->tab_top + 10 + $yp);
410 $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq :
'', 0,
'L', 0);
412 $pdf->SetXY(40, $this->tab_top + 10 + $yp);
413 $pdf->MultiCell(60, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq, 44), 0,
'L', 0);
415 $pdf->SetXY(100, $this->tab_top + 10 + $yp);
416 $pdf->MultiCell(80, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq, 50), 0,
'L', 0);
418 $pdf->SetXY(180, $this->tab_top + 10 + $yp);
419 $pdf->MultiCell(20, $this->line_height,
price($this->lines[$j]->amount_chq), 0,
'R', 0);
421 $yp = $yp + ($this->line_height * $nb_lines);