188 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
191 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
193 if (!is_object($outputlangs)) {
194 $outputlangs = $langs;
197 if (!empty($conf->global->MAIN_USE_FPDF)) {
198 $outputlangs->charset_output =
'ISO-8859-1';
202 $outputlangs->loadLangs(array(
"main",
"trips",
"projects",
"dict",
"bills",
"banks"));
204 $nblines = count($object->lines);
206 if ($conf->expensereport->dir_output) {
208 if ($object->specimen) {
209 $dir = $conf->expensereport->dir_output;
210 $file = $dir.
"/SPECIMEN.pdf";
213 $dir = $conf->expensereport->dir_output.
"/".$objectref;
214 $file = $dir.
"/".$objectref.
".pdf";
217 if (!file_exists($dir)) {
219 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
224 if (file_exists($dir)) {
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(
'beforePDFCreation', $parameters, $object, $action);
238 $heightforinfotot = 40;
239 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
240 $heightforfooter = $this->marge_basse + 12;
241 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
242 $heightforfooter += 6;
245 $pdf->SetAutoPageBreak(1, 0);
247 if (class_exists(
'TCPDF')) {
248 $pdf->setPrintHeader(
false);
249 $pdf->setPrintFooter(
false);
253 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
254 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
255 $tplidx = $pdf->importPage(1);
260 $pdf->SetDrawColor(128, 128, 128);
262 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
263 $pdf->SetSubject($outputlangs->transnoentities(
"Trips"));
264 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
265 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
266 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Trips"));
268 $pdf->SetCompression(
false);
271 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
275 if (!empty($tplidx)) {
276 $pdf->useTemplate($tplidx);
279 $this->
_pagehead($pdf, $object, 1, $outputlangs);
280 $pdf->SetFont(
'',
'', $default_font_size - 1);
281 $pdf->MultiCell(0, 3,
'');
282 $pdf->SetTextColor(0, 0, 0);
285 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 65 : 10);
287 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
290 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
291 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
293 if (is_object($object->thirdparty)) {
294 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
295 $salerepobj =
new User($this->db);
296 $salerepobj->fetch($salereparray[0][
'id']);
297 if (!empty($salerepobj->signature)) {
298 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
310 $pdf->SetFont(
'',
'', $default_font_size - 1);
311 $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
312 $nexY = $pdf->GetY();
313 $height_note = $nexY - $tab_top;
316 $pdf->SetDrawColor(192, 192, 192);
317 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
319 $tab_height = $tab_height - $height_note;
320 $tab_top = $nexY + 6;
325 $iniY = $tab_top + 7;
326 $initialY = $tab_top + 7;
327 $nexY = $tab_top + 7;
329 $showpricebeforepagebreak = 1;
330 $pdf->setTopMargin($tab_top_newpage);
333 while ($i < $nblines) {
334 $pdf->SetFont(
'',
'', $default_font_size - 2);
335 $pdf->SetTextColor(0, 0, 0);
337 $pdf->setTopMargin($tab_top_newpage);
338 if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) {
339 $pdf->setPageOrientation(
'', 1, $heightforfooter);
341 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
344 $pageposbefore = $pdf->getPage();
346 $pdf->startTransaction();
347 $this->
printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
348 $pageposafter = $pdf->getPage();
349 if ($pageposafter > $pageposbefore) {
351 $pdf->rollbackTransaction(
true);
353 $pageposafter = $pageposbefore;
355 if (empty($showpricebeforepagebreak)) {
356 $pdf->AddPage(
'',
'',
true);
357 if (!empty($tplidx)) {
358 $pdf->useTemplate($tplidx);
361 $this->
_pagehead($pdf, $object, 0, $outputlangs);
363 $pdf->setPage($pageposafter + 1);
364 $showpricebeforepagebreak = 1;
365 $nexY = $tab_top_newpage;
366 $nexY += ($pdf->getFontSize() * 1.3);
367 $pdf->SetFont(
'',
'', $default_font_size - 2);
368 $pdf->SetTextColor(0, 0, 0);
370 $pdf->setTopMargin($tab_top_newpage);
373 $pdf->setPageOrientation(
'', 1, $heightforfooter);
374 $showpricebeforepagebreak = 0;
377 $this->
printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
378 $pageposafter = $pdf->getPage();
379 $posyafter = $pdf->GetY();
381 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
383 if ($i == ($nblines - 1)) {
385 $pdf->AddPage(
'',
'',
true);
386 if (!empty($tplidx)) {
387 $pdf->useTemplate($tplidx);
390 $this->
_pagehead($pdf, $object, 0, $outputlangs);
392 $pdf->setPage($pageposafter + 1);
397 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
398 $showpricebeforepagebreak = 1;
400 $showpricebeforepagebreak = 0;
405 $pdf->commitTransaction();
409 $nexY = $pdf->GetY();
410 $pageposafter = $pdf->getPage();
411 $pdf->setPage($pageposbefore);
412 $pdf->setTopMargin($this->marge_haute);
413 $pdf->setPageOrientation(
'', 1, 0);
431 $nexY += ($pdf->getFontSize() * 1.3);
434 while ($pagenb < $pageposafter) {
435 $pdf->setPage($pagenb);
436 $pdf->setPageOrientation(
'', 1, 0);
438 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
440 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
442 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
444 $pdf->setPage($pagenb);
445 $pdf->setPageOrientation(
'', 1, 0);
447 $this->
_pagehead($pdf, $object, 0, $outputlangs);
449 if (!empty($tplidx)) {
450 $pdf->useTemplate($tplidx);
453 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
455 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
457 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
459 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
462 if (!empty($tplidx)) {
463 $pdf->useTemplate($tplidx);
467 $this->
_pagehead($pdf, $object, 0, $outputlangs);
474 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
475 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
477 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
478 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
481 $pdf->SetFont(
'',
'', 10);
484 $posy = $bottomlasttab + 5;
485 $posy_start_of_totals = $posy;
486 $pdf->SetXY(130, $posy);
487 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalHT"), 1,
'L');
488 $pdf->SetXY(180, $posy);
489 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_ht), 1,
'R');
490 $pdf->SetFillColor(248, 248, 248);
492 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
495 $pdf->SetXY(130, $posy);
496 $pdf->SetTextColor(0, 0, 60);
497 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalVAT"), 1,
'L');
498 $pdf->SetXY(180, $posy);
499 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_tva), 1,
'R');
503 $pdf->SetXY(130, $posy);
504 $pdf->SetFont(
'',
'B', 10);
505 $pdf->SetTextColor(0, 0, 60);
506 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalTTC"), 1,
'L');
507 $pdf->SetXY(180, $posy);
508 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_ttc), 1,
'R');
511 $sumPayments = $object->getSumPayments();
512 if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) {
513 $posy = $this->
tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs);
517 $this->
_pagefoot($pdf, $object, $outputlangs);
518 if (method_exists($pdf,
'AliasNbPages')) {
519 $pdf->AliasNbPages();
524 $pdf->Output($file,
'F');
527 $hookmanager->initHooks(array(
'pdfgeneration'));
528 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
530 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
532 $this->error = $hookmanager->error;
533 $this->errors = $hookmanager->errors;
538 $this->result = array(
'fullpath'=>$file);
542 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
546 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"EXPENSEREPORT_OUTPUTDIR");
561 protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
564 $pdf->SetFont(
'',
'', $default_font_size - 1);
565 $pdf->SetTextColor(0, 0, 0);
568 $pdf->SetXY($this->posxpiece, $curY);
569 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
576 $pdf->SetXY($this->posxtype - 1, $curY);
577 $nextColumnPosX = $this->posxup;
578 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
579 $nextColumnPosX = $this->posxtva;
581 if (isModEnabled(
'project')) {
582 $nextColumnPosX = $this->posxprojet;
585 $expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
586 $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
589 if ($expensereporttypecodetoshow == $expensereporttypecode) {
590 $expensereporttypecodetoshow = preg_replace(
'/^(EX_|TF_)/',
'', $expensereporttypecodetoshow);
605 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
607 $pdf->SetXY($this->posxtva, $curY);
608 $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0,
'R');
612 $pdf->SetXY($this->posxup, $curY);
613 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4,
price($object->lines[$linenumber]->value_unit), 0,
'R');
616 $pdf->SetXY($this->posxqty, $curY);
617 $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0,
'R');
620 $pdf->SetXY($this->postotalht, $curY);
621 $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4,
price($object->lines[$linenumber]->total_ht), 0,
'R');
624 $pdf->SetXY($this->postotalttc - 1, $curY);
625 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4,
price($object->lines[$linenumber]->total_ttc), 0,
'R');
628 $pdf->SetXY($this->posxcomment, $curY);
629 $comment = $outputlangs->trans(
"Date").
':'.
dol_print_date($object->lines[$linenumber]->date,
"day",
false, $outputlangs).
' ';
630 $comment .= $outputlangs->trans(
"Type").
':'.$expensereporttypecodetoshow.
'<br>';
631 if (!empty($object->lines[$linenumber]->projet_ref)) {
632 $comment .= $outputlangs->trans(
"Project").
':'.$object->lines[$linenumber]->projet_ref.
'<br>';
634 $comment .= $object->lines[$linenumber]->comments;
635 $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
648 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
651 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
654 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
667 if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) {
668 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
671 $pdf->SetTextColor(0, 0, 60);
672 $pdf->SetFont(
'',
'B', $default_font_size + 3);
674 $posy = $this->marge_haute;
675 $posx = $this->page_largeur - $this->marge_droite - 100;
677 $pdf->SetXY($this->marge_gauche, $posy);
680 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
681 if ($this->emetteur->logo) {
682 if (is_readable($logo)) {
684 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
686 $pdf->SetTextColor(200, 0, 0);
687 $pdf->SetFont(
'',
'B', $default_font_size - 2);
688 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
689 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
692 $text = $this->emetteur->name;
693 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
696 $pdf->SetFont(
'',
'B', $default_font_size + 4);
697 $pdf->SetXY($posx, $posy);
698 $pdf->SetTextColor(0, 0, 60);
699 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans(
"ExpenseReport"), 0,
'R');
701 $pdf->SetFont(
'',
'', $default_font_size - 1);
705 $pdf->SetXY($posx, $posy);
706 $pdf->SetTextColor(0, 0, 60);
707 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".$object->ref,
'',
'R');
711 $pdf->SetXY($posx, $posy);
712 $pdf->SetTextColor(0, 0, 60);
713 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"DateStart").
" : ".($object->date_debut > 0 ?
dol_print_date($object->date_debut,
"day",
false, $outputlangs) :
''),
'',
'R');
717 $pdf->SetXY($posx, $posy);
718 $pdf->SetTextColor(0, 0, 60);
719 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"DateEnd").
" : ".($object->date_fin > 0 ?
dol_print_date($object->date_fin,
"day",
false, $outputlangs) :
''),
'',
'R');
723 $pdf->SetXY($posx, $posy);
724 $pdf->SetFont(
'',
'B', $default_font_size + 2);
725 $pdf->SetTextColor(111, 81, 124);
726 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities($object->statuts_short[$object->status]),
'',
'R');
730 $carac_emetteur =
'';
731 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->address);
732 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->zip).
' '.$outputlangs->convToOutputCharset($this->emetteur->town);
733 $carac_emetteur .=
"\n";
734 if ($this->emetteur->phone) {
735 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
" : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
737 if ($this->emetteur->fax) {
738 $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
" : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
740 if ($this->emetteur->email) {
741 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($this->emetteur->email);
743 if ($this->emetteur->url) {
744 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
" : ".$outputlangs->convToOutputCharset($this->emetteur->url);
748 $receiver =
new User($this->db);
749 $receiver->fetch($object->fk_user_author);
751 $receiver_account->fetch(0,
'', $object->fk_user_author);
752 $expense_receiver =
'';
753 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->address);
754 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->zip).
' '.$outputlangs->convToOutputCharset($receiver->town);
755 $expense_receiver .=
"\n";
756 if ($receiver->email) {
757 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($receiver->email);
759 if ($receiver_account->iban) {
760 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"IBAN").
" : ".$outputlangs->convToOutputCharset($receiver_account->iban);
765 $posx = $this->marge_gauche;
767 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
772 $pdf->SetTextColor(0, 0, 0);
773 $pdf->SetFont(
'',
'B', $default_font_size - 2);
774 $pdf->SetXY($posx, $posy - 5);
775 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripSociete"),
'',
'L');
776 $pdf->SetXY($posx, $posy);
777 $pdf->SetFillColor(224, 224, 224);
778 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
779 $pdf->SetTextColor(0, 0, 60);
782 if (empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
783 $pdf->SetXY($posx + 2, $posy + 3);
784 $pdf->SetFont(
'',
'B', $default_font_size);
785 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
786 $pdf->SetXY($posx + 2, $posy + 8);
787 $pdf->SetFont(
'',
'', $default_font_size - 1);
788 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
790 $pdf->SetXY($posx + 2, $posy + 3);
791 $pdf->SetFont(
'',
'B', $default_font_size);
792 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(
dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0,
'L');
793 $pdf->SetXY($posx + 2, $posy + 8);
794 $pdf->SetFont(
'',
'', $default_font_size - 1);
795 $pdf->MultiCell(80, 4, $expense_receiver, 0,
'L');
801 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
802 $posx = $this->marge_gauche;
806 $pdf->SetTextColor(0, 0, 0);
807 $pdf->SetFont(
'',
'B', 8);
808 $pdf->SetXY($posx, $posy - 5);
809 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripNDF").
" :", 0,
'L');
810 $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
813 if ($object->fk_user_author > 0) {
814 $userfee =
new User($this->db);
815 $userfee->fetch($object->fk_user_author);
817 $pdf->SetXY($posx + 2, $posy);
818 $pdf->SetFont(
'',
'', 10);
819 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
820 $posy = $pdf->GetY() + 1;
821 $pdf->SetXY($posx + 2, $posy);
822 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateCreation").
" : ".
dol_print_date($object->date_create,
"day",
false, $outputlangs), 0,
'L');
825 if ($object->fk_statut == 99) {
826 if ($object->fk_user_refuse > 0) {
827 $userfee =
new User($this->db);
828 $userfee->fetch($object->fk_user_refuse);
830 $pdf->SetXY($posx + 2, $posy);
831 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"REFUSEUR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
833 $pdf->SetXY($posx + 2, $posy);
834 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_REFUS").
" : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0,
'L');
836 $pdf->SetXY($posx + 2, $posy);
837 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_REFUS").
" : ".
dol_print_date($object->date_refuse,
"day",
false, $outputlangs), 0,
'L');
839 } elseif ($object->fk_statut == 4) {
840 if ($object->fk_user_cancel > 0) {
841 $userfee =
new User($this->db);
842 $userfee->fetch($object->fk_user_cancel);
844 $pdf->SetXY($posx + 2, $posy);
845 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"CANCEL_USER").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
847 $pdf->SetXY($posx + 2, $posy);
848 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_CANCEL").
" : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0,
'L');
850 $pdf->SetXY($posx + 2, $posy);
851 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_CANCEL").
" : ".
dol_print_date($object->date_cancel,
"day",
false, $outputlangs), 0,
'L');
854 if ($object->fk_user_approve > 0) {
855 $userfee =
new User($this->db);
856 $userfee->fetch($object->fk_user_approve);
858 $pdf->SetXY($posx + 2, $posy);
859 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"VALIDOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
861 $pdf->SetXY($posx + 2, $posy);
862 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateApprove").
" : ".
dol_print_date($object->date_approve,
"day",
false, $outputlangs), 0,
'L');
866 if ($object->fk_statut == 6) {
867 if ($object->fk_user_paid > 0) {
868 $userfee =
new User($this->db);
869 $userfee->fetch($object->fk_user_paid);
871 $pdf->SetXY($posx + 2, $posy);
872 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHORPAIEMENT").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
874 $pdf->SetXY($posx + 2, $posy);
875 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_PAIEMENT").
" : ".
dol_print_date($object->date_paiement,
"day",
false, $outputlangs), 0,
'L');
895 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
905 $currency = !empty($currency) ? $currency : $conf->currency;
909 $pdf->SetTextColor(0, 0, 0);
910 $pdf->SetFont(
'',
'', $default_font_size - 2);
911 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
912 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
913 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
915 $pdf->SetDrawColor(128, 128, 128);
918 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
920 if (empty($hidetop)) {
921 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
924 $pdf->SetFont(
'',
'', 8);
927 if (empty($hidetop)) {
928 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
929 $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1,
'',
'',
'R');
933 $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
934 if (empty($hidetop)) {
935 $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
936 $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities(
"Description"),
'',
'L');
966 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
967 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
968 if (empty($hidetop)) {
969 $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
970 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
975 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
976 if (empty($hidetop)) {
977 $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
978 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUTTC"),
'',
'C');
982 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
983 if (empty($hidetop)) {
984 $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
985 $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
989 $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
990 if (empty($hidetop)) {
991 $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
992 $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
996 $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
997 if (empty($hidetop)) {
998 $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
999 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'R');
1002 $pdf->SetTextColor(0, 0, 0);
1019 $tab3_posx = $this->marge_gauche;
1026 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1027 $pdf->SetFont(
'',
'', $default_font_size - 2);
1028 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1029 $pdf->SetTextColor(0, 0, 0);
1030 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1032 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top);
1034 $pdf->SetXY($tab3_posx, $tab3_top + 1);
1035 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Date"), 0,
'L', 0);
1036 $pdf->SetXY($tab3_posx + 19, $tab3_top + 1);
1037 $pdf->MultiCell(15, 3, $outputlangs->transnoentities(
"Amount"), 0,
'C', 0);
1038 $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
1039 $pdf->MultiCell(30, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1040 if (isModEnabled(
"banque")) {
1041 $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
1042 $pdf->MultiCell(25, 3, $outputlangs->transnoentities(
"BankAccount"), 0,
'L', 0);
1044 $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height);
1051 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1052 $sql .=
"c.code as p_code, c.libelle as payment_type,";
1053 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1054 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1055 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1056 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1057 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1058 $sql .=
" WHERE e.rowid = ".((int) $object->id);
1059 $sql .=
" AND p.fk_expensereport = e.rowid";
1060 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1061 $sql .=
" ORDER BY dp";
1063 $resql = $this->db->query($sql);
1065 $num = $this->db->num_rows($resql);
1070 $row = $this->db->fetch_object($resql);
1072 $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
1073 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->dp),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1074 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
1075 $pdf->MultiCell(15, 3,
price($sign * $row->amount, 0, $outputlangs), 0,
'R', 0);
1076 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
1077 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->p_code);
1079 $pdf->MultiCell(40, 3, $oper, 0,
'L', 0);
1080 if (isModEnabled(
"banque")) {
1081 $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
1082 $pdf->MultiCell(30, 3, $row->baref, 0,
'L', 0);
1085 $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height);
1086 $totalpaid += $row->amount;
1089 if ($num > 0 && $object->paid == 0) {
1092 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1093 $pdf->MultiCell(15, 3,
price($totalpaid), 0,
'R', 0);
1094 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1095 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AlreadyPaid"), 0,
'L', 0);
1096 $y += $tab3_height - 2;
1097 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1098 $pdf->MultiCell(15, 3,
price($object->total_ttc), 0,
'R', 0);
1099 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1100 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AmountExpected"), 0,
'L', 0);
1101 $y += $tab3_height - 2;
1102 $remaintopay = $object->total_ttc - $totalpaid;
1103 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1104 $pdf->MultiCell(15, 3,
price($remaintopay), 0,
'R', 0);
1105 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1106 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"RemainderToPay"), 0,
'L', 0);
1109 $this->error = $this->db->lasterror();