123 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
126 global $user, $langs,
$conf, $hookmanager;
128 if (!is_object($outputlangs)) {
129 $outputlangs = $langs;
132 $sav_charset_output = $outputlangs->charset_output;
134 $outputlangs->charset_output =
'ISO-8859-1';
138 $outputlangs->loadLangs(array(
"main",
"companies",
"bills",
"products",
"compta"));
143 $this->ref_ext =
$object->ref_ext;
145 $this->nbcheque =
$object->nbcheque;
148 $this->account =
new Account($this->db);
149 $this->account->fetch(
$object->account_id);
151 $sql =
"SELECT b.banque, b.emetteur, b.amount, b.num_chq";
152 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
153 $sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
154 $sql .=
", ".MAIN_DB_PREFIX.
"bordereau_cheque as bc";
155 $sql .=
" WHERE b.fk_account = ba.rowid";
156 $sql .=
" AND b.fk_bordereau = bc.rowid";
157 $sql .=
" AND bc.rowid = ".((int)
$object->id);
158 $sql .=
" AND bc.entity = ".((int)
$conf->entity);
159 $sql .=
" ORDER BY b.dateo ASC, b.rowid ASC";
161 dol_syslog(
"pdf_blochet::write_file", LOG_DEBUG);
162 $this->lines = array();
163 $resql = $this->db->query($sql);
165 $this->error = $this->db->lasterror();
169 while ($objp = $this->db->fetch_object($resql)) {
171 $this->lines[$i]->bank_chq = $objp->banque;
172 $this->lines[$i]->emetteur_chq = $objp->emetteur;
173 $this->lines[$i]->amount_chq = $objp->amount;
174 $this->lines[$i]->num_chq = $objp->num_chq;
177 $this->db->free($resql);
185 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
190 $file = $dir.
"/bordereau-".$number.
".pdf";
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,
'outputlangs' => $outputlangs);
200 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
204 $heightforinfotot = 50;
206 $heightforfooter = $this->marge_basse + 8;
208 $heightforfooter += 6;
210 $pdf->setAutoPageBreak(
true, 0);
212 if (class_exists(
'TCPDF')) {
213 $pdf->setPrintHeader(
false);
214 $pdf->setPrintFooter(
false);
220 $pdf->SetDrawColor(128, 128, 128);
222 $pdf->SetTitle($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
223 $pdf->SetSubject($outputlangs->transnoentities(
"CheckReceipt"));
224 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
225 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
226 $pdf->SetKeyWords($outputlangs->transnoentities(
"CheckReceipt").
" ".$number);
228 $pdf->SetCompression(
false);
232 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
234 $nboflines = count($this->lines);
237 $pages = intval($nboflines / $this->line_per_page);
238 if (($nboflines % $this->line_per_page) > 0) {
248 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
250 $this->
Body($pdf, $pagenb, $pages, $outputlangs);
253 $this->
_pagefoot($pdf,
null, $outputlangs);
254 if (method_exists($pdf,
'AliasNbPages')) {
255 $pdf->AliasNbPages();
260 $pdf->Output($file,
'F');
263 if (!is_object($hookmanager)) {
264 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
267 $hookmanager->initHooks(array(
'pdfgeneration'));
268 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
270 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
271 $this->warnings = $hookmanager->warnings;
273 $this->error = $hookmanager->error;
274 $this->errors = $hookmanager->errors;
281 $this->result = array(
'fullpath' => $file);
283 $outputlangs->charset_output = $sav_charset_output;
298 public function Header(&$pdf, $page, $pages, $outputlangs)
305 $outputlangs->loadLangs(array(
"compta",
"banks"));
307 $title = $outputlangs->transnoentities(
"CheckReceipt");
308 $pdf->SetFont(
'',
'B', $default_font_size);
310 $pdf->MultiCell(0, 2, $title, 0,
'L');
312 $pdf->SetFont(
'',
'', $default_font_size);
314 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Ref"), 0,
'L');
316 $pdf->SetFont(
'',
'', $default_font_size);
317 $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ?
" - ".$this->ref_ext :
'')), 0,
'L');
319 $pdf->SetFont(
'',
'', $default_font_size);
321 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Date"), 0,
'L');
323 $pdf->SetFont(
'',
'', $default_font_size);
326 $pdf->SetFont(
'',
'', $default_font_size);
328 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Owner"), 0,
'L');
329 $pdf->SetFont(
'',
'', $default_font_size);
331 $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->owner_name), 0,
'L');
333 $pdf->SetFont(
'',
'', $default_font_size);
335 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"BankAccount"), 0,
'L');
336 pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
338 $pdf->SetFont(
'',
'', $default_font_size);
339 $pdf->SetXY(114, 15);
340 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Signature"), 0,
'L');
342 $pdf->RoundedRect(9, 14, 192, 35, $this->corner_radius,
'1234',
'D');
343 $pdf->line(9, 19, 112, 19);
344 $pdf->line(9, 25, 112, 25);
346 $pdf->line(9, 31, 112, 31);
348 $pdf->line(30, 14, 30, 49);
349 $pdf->line(112, 14, 112, 49);
353 $pdf->RoundedRect(9, $posy, 192, 6, $this->corner_radius,
'1234',
'D');
354 $pdf->line(55, $posy, 55, $posy + 6);
355 $pdf->line(140, $posy, 140, $posy + 6);
356 $pdf->line(170, $posy, 170, $posy + 6);
358 $pdf->SetFont(
'',
'', $default_font_size);
359 $pdf->SetXY(10, $posy + 1);
360 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"NumberOfCheques"), 0,
'L');
362 $pdf->SetFont(
'',
'B', $default_font_size);
363 $pdf->SetXY(57, $posy + 1);
364 $pdf->MultiCell(40, 2, (
string) $this->nbcheque, 0,
'L');
366 $pdf->SetFont(
'',
'', $default_font_size);
367 $pdf->SetXY(148, $posy + 1);
368 $pdf->MultiCell(40, 2, $langs->trans(
"Total"));
370 $pdf->SetFont(
'',
'B', $default_font_size);
371 $pdf->SetXY(170, $posy + 1);
372 $pdf->MultiCell(31, 2,
price($this->
amount), 0,
'C',
false);
375 $pdf->SetFont(
'',
'', $default_font_size - 2);
376 $pdf->SetXY(11, $this->tab_top + 2);
377 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Num"), 0,
'L');
378 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
380 $pdf->SetXY(41, $this->tab_top + 2);
381 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Bank"), 0,
'L');
382 $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
384 $pdf->SetXY(101, $this->tab_top + 2);
385 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"CheckTransmitter"), 0,
'L');
386 $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
388 $pdf->SetXY(180, $this->tab_top + 2);
389 $pdf->MultiCell(20, 2, $outputlangs->transnoentities(
"Amount"), 0,
'R');
390 $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8);
392 $pdf->RoundedRect(9, $this->tab_top, 192, $this->tab_height + 10, $this->corner_radius,
'1234',
'D');
406 public function Body(&$pdf, $pagenb, $pages, $outputlangs)
413 $pdf->SetFont(
'',
'', $default_font_size - 1);
415 $pdf->SetFillColor(220, 220, 220);
418 $num = count($this->lines);
419 for ($j = 0; $j < $num; $j++) {
421 $dynamic_line_height = array();
422 $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
423 $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
424 $max_line_height = max($dynamic_line_height);
426 if ($max_line_height > $this->line_height) {
427 $nb_lines = floor($max_line_height / $this->line_height) + 1;
433 if ($lineinpage >= ($this->line_per_page - 1)) {
440 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
441 $pdf->SetFont(
'',
'', $default_font_size - 1);
442 $pdf->MultiCell(0, 3,
'');
443 $pdf->SetTextColor(0, 0, 0);
446 $lineinpage += $nb_lines;
448 $pdf->SetXY(1, $this->tab_top + 10 + $yp);
449 $pdf->MultiCell(8, $this->line_height, (
string) ($j + 1), 0,
'R',
false);
451 $pdf->SetXY(10, $this->tab_top + 10 + $yp);
452 $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq :
'', 0,
'L',
false);
454 $pdf->SetXY(40, $this->tab_top + 10 + $yp);
455 $pdf->MultiCell(60, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq,
'44'), 0,
'L',
false);
457 $pdf->SetXY(100, $this->tab_top + 10 + $yp);
458 $pdf->MultiCell(80, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq,
'50'), 0,
'L',
false);
460 $pdf->SetXY(180, $this->tab_top + 10 + $yp);
461 $pdf->MultiCell(20, $this->line_height,
price($this->lines[$j]->amount_chq), 0,
'R',
false);
463 $yp += ($this->line_height * $nb_lines);