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;
208 $this->result = array(
'fullpath'=>$file);
210 $outputlangs->charset_output = $sav_charset_output;
225 public function Header(&$pdf, $page, $pages, $outputlangs)
232 $outputlangs->loadLangs(array(
"compta",
"banks"));
234 $title = $outputlangs->transnoentities(
"CheckReceipt");
235 $pdf->SetFont(
'',
'B', $default_font_size);
237 $pdf->MultiCell(0, 2, $title, 0,
'L');
239 $pdf->SetFont(
'',
'', $default_font_size);
241 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Ref"), 0,
'L');
243 $pdf->SetFont(
'',
'', $default_font_size);
244 $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ?
" - ".$this->ref_ext :
'')), 0,
'L');
246 $pdf->SetFont(
'',
'', $default_font_size);
248 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Date"), 0,
'L');
250 $pdf->SetFont(
'',
'', $default_font_size);
251 $pdf->MultiCell(60, 2,
dol_print_date($this->date,
"day",
false, $outputlangs));
253 $pdf->SetFont(
'',
'', $default_font_size);
255 $pdf->MultiCell(22, 2, $outputlangs->transnoentities(
"Owner"), 0,
'L');
256 $pdf->SetFont(
'',
'', $default_font_size);
258 $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0,
'L');
260 $pdf->SetFont(
'',
'', $default_font_size);
262 $pdf->MultiCell(0, 2, $outputlangs->transnoentities(
"Account"), 0,
'L');
263 pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
265 $pdf->SetFont(
'',
'', $default_font_size);
266 $pdf->SetXY(114, 15);
267 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Signature"), 0,
'L');
269 $pdf->Rect(9, 14, 192, 35);
270 $pdf->line(9, 19, 112, 19);
271 $pdf->line(9, 25, 112, 25);
273 $pdf->line(9, 31, 112, 31);
275 $pdf->line(30, 14, 30, 49);
276 $pdf->line(112, 14, 112, 49);
280 $pdf->Rect(9, $posy, 192, 6);
281 $pdf->line(55, $posy, 55, $posy + 6);
282 $pdf->line(140, $posy, 140, $posy + 6);
283 $pdf->line(170, $posy, 170, $posy + 6);
285 $pdf->SetFont(
'',
'', $default_font_size);
286 $pdf->SetXY(10, $posy + 1);
287 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"NumberOfCheques"), 0,
'L');
289 $pdf->SetFont(
'',
'B', $default_font_size);
290 $pdf->SetXY(57, $posy + 1);
291 $pdf->MultiCell(40, 2, $this->nbcheque, 0,
'L');
293 $pdf->SetFont(
'',
'', $default_font_size);
294 $pdf->SetXY(148, $posy + 1);
295 $pdf->MultiCell(40, 2, $langs->trans(
"Total"));
297 $pdf->SetFont(
'',
'B', $default_font_size);
298 $pdf->SetXY(170, $posy + 1);
299 $pdf->MultiCell(31, 2,
price($this->amount), 0,
'C', 0);
302 $pdf->SetFont(
'',
'', $default_font_size - 2);
303 $pdf->SetXY(11, $this->tab_top + 2);
304 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Num"), 0,
'L');
305 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
307 $pdf->SetXY(41, $this->tab_top + 2);
308 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"Bank"), 0,
'L');
309 $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
311 $pdf->SetXY(101, $this->tab_top + 2);
312 $pdf->MultiCell(40, 2, $outputlangs->transnoentities(
"CheckTransmitter"), 0,
'L');
313 $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
315 $pdf->SetXY(180, $this->tab_top + 2);
316 $pdf->MultiCell(20, 2, $outputlangs->transnoentities(
"Amount"), 0,
'R');
317 $pdf->line(9, $this->tab_top + 8, 201, $this->tab_top + 8);
319 $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10);
333 public function Body(&$pdf, $pagenb, $pages, $outputlangs)
340 $pdf->SetFont(
'',
'', $default_font_size - 1);
342 $pdf->SetFillColor(220, 220, 220);
345 $num = count($this->lines);
346 for ($j = 0; $j < $num; $j++) {
348 $dynamic_line_height = array();
349 $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
350 $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
351 $max_line_height = max($dynamic_line_height);
353 if ($max_line_height > $this->line_height) {
354 $nb_lines = floor($max_line_height / $this->line_height) + 1;
360 if ($lineinpage >= ($this->line_per_page - 1)) {
367 $this->
Header($pdf, $pagenb, $pages, $outputlangs);
368 $pdf->SetFont(
'',
'', $default_font_size - 1);
369 $pdf->MultiCell(0, 3,
'');
370 $pdf->SetTextColor(0, 0, 0);
373 $lineinpage += $nb_lines;
375 $pdf->SetXY(1, $this->tab_top + 10 + $yp);
376 $pdf->MultiCell(8, $this->line_height, $j + 1, 0,
'R', 0);
378 $pdf->SetXY(10, $this->tab_top + 10 + $yp);
379 $pdf->MultiCell(30, $this->line_height, $this->lines[$j]->num_chq ? $this->lines[$j]->num_chq :
'', 0,
'L', 0);
381 $pdf->SetXY(40, $this->tab_top + 10 + $yp);
382 $pdf->MultiCell(60, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq, 44), 0,
'L', 0);
384 $pdf->SetXY(100, $this->tab_top + 10 + $yp);
385 $pdf->MultiCell(80, $this->line_height, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq, 50), 0,
'L', 0);
387 $pdf->SetXY(180, $this->tab_top + 10 + $yp);
388 $pdf->MultiCell(20, $this->line_height,
price($this->lines[$j]->amount_chq), 0,
'R', 0);
390 $yp = $yp + ($this->line_height * $nb_lines);