187 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
190 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
192 if (!is_object($outputlangs)) {
193 $outputlangs = $langs;
197 $outputlangs->charset_output =
'ISO-8859-1';
201 $outputlangs->loadLangs(array(
"main",
"trips",
"projects",
"dict",
"bills",
"banks"));
203 $nblines = count($object->lines);
205 if ($conf->expensereport->dir_output) {
207 if ($object->specimen) {
208 $dir = $conf->expensereport->dir_output;
209 $file = $dir.
"/SPECIMEN.pdf";
212 $dir = $conf->expensereport->dir_output.
"/".$objectref;
213 $file = $dir.
"/".$objectref.
".pdf";
216 if (!file_exists($dir)) {
218 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
223 if (file_exists($dir)) {
225 if (!is_object($hookmanager)) {
226 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
229 $hookmanager->initHooks(array(
'pdfgeneration'));
230 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
232 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
237 $heightforinfotot = 40;
238 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
239 $heightforfooter = $this->marge_basse + 12;
241 $heightforfooter += 6;
244 $pdf->SetAutoPageBreak(1, 0);
246 if (class_exists(
'TCPDF')) {
247 $pdf->setPrintHeader(
false);
248 $pdf->setPrintFooter(
false);
253 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
254 $tplidx = $pdf->importPage(1);
259 $pdf->SetDrawColor(128, 128, 128);
261 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
262 $pdf->SetSubject($outputlangs->transnoentities(
"Trips"));
263 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
264 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
265 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Trips"));
267 $pdf->SetCompression(
false);
270 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
274 if (!empty($tplidx)) {
275 $pdf->useTemplate($tplidx);
278 $this->
_pagehead($pdf, $object, 1, $outputlangs);
279 $pdf->SetFont(
'',
'', $default_font_size - 1);
280 $pdf->MultiCell(0, 3,
'');
281 $pdf->SetTextColor(0, 0, 0);
284 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 65 : 10);
286 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
289 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
292 if (is_object($object->thirdparty)) {
293 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
294 $salerepobj =
new User($this->db);
295 $salerepobj->fetch($salereparray[0][
'id']);
296 if (!empty($salerepobj->signature)) {
297 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
309 $pdf->SetFont(
'',
'', $default_font_size - 1);
310 $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
311 $nexY = $pdf->GetY();
312 $height_note = $nexY - $tab_top;
315 $pdf->SetDrawColor(192, 192, 192);
316 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
318 $tab_height = $tab_height - $height_note;
319 $tab_top = $nexY + 6;
324 $iniY = $tab_top + 7;
325 $initialY = $tab_top + 7;
326 $nexY = $tab_top + 7;
328 $showpricebeforepagebreak = 1;
329 $pdf->setTopMargin($tab_top_newpage);
332 while ($i < $nblines) {
333 $pdf->SetFont(
'',
'', $default_font_size - 2);
334 $pdf->SetTextColor(0, 0, 0);
336 $pdf->setTopMargin($tab_top_newpage);
337 if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) {
338 $pdf->setPageOrientation(
'', 1, $heightforfooter);
340 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
343 $pageposbefore = $pdf->getPage();
345 $pdf->startTransaction();
346 $this->
printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
347 $pageposafter = $pdf->getPage();
348 if ($pageposafter > $pageposbefore) {
350 $pdf->rollbackTransaction(
true);
352 $pageposafter = $pageposbefore;
354 if (empty($showpricebeforepagebreak)) {
355 $pdf->AddPage(
'',
'',
true);
356 if (!empty($tplidx)) {
357 $pdf->useTemplate($tplidx);
360 $this->
_pagehead($pdf, $object, 0, $outputlangs);
362 $pdf->setPage($pageposafter + 1);
363 $showpricebeforepagebreak = 1;
364 $nexY = $tab_top_newpage;
365 $nexY += ($pdf->getFontSize() * 1.3);
366 $pdf->SetFont(
'',
'', $default_font_size - 2);
367 $pdf->SetTextColor(0, 0, 0);
369 $pdf->setTopMargin($tab_top_newpage);
372 $pdf->setPageOrientation(
'', 1, $heightforfooter);
373 $showpricebeforepagebreak = 0;
376 $this->
printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
377 $pageposafter = $pdf->getPage();
378 $posyafter = $pdf->GetY();
380 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
382 if ($i == ($nblines - 1)) {
384 $pdf->AddPage(
'',
'',
true);
385 if (!empty($tplidx)) {
386 $pdf->useTemplate($tplidx);
389 $this->
_pagehead($pdf, $object, 0, $outputlangs);
391 $pdf->setPage($pageposafter + 1);
397 $showpricebeforepagebreak = 1;
399 $showpricebeforepagebreak = 0;
403 $pdf->commitTransaction();
407 $nexY = $pdf->GetY();
408 $pageposafter = $pdf->getPage();
409 $pdf->setPage($pageposbefore);
410 $pdf->setTopMargin($this->marge_haute);
411 $pdf->setPageOrientation(
'', 1, 0);
429 $nexY += ($pdf->getFontSize() * 1.3);
432 while ($pagenb < $pageposafter) {
433 $pdf->setPage($pagenb);
434 $pdf->setPageOrientation(
'', 1, 0);
436 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
438 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
440 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
442 $pdf->setPage($pagenb);
443 $pdf->setPageOrientation(
'', 1, 0);
445 $this->
_pagehead($pdf, $object, 0, $outputlangs);
447 if (!empty($tplidx)) {
448 $pdf->useTemplate($tplidx);
451 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
453 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
455 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
457 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
460 if (!empty($tplidx)) {
461 $pdf->useTemplate($tplidx);
465 $this->
_pagehead($pdf, $object, 0, $outputlangs);
472 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
473 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
475 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
476 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
479 $pdf->SetFont(
'',
'', 10);
482 $posy = $bottomlasttab + 5;
483 $posy_start_of_totals = $posy;
484 $pdf->SetXY(130, $posy);
485 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalHT"), 1,
'L');
486 $pdf->SetXY(180, $posy);
487 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_ht), 1,
'R');
488 $pdf->SetFillColor(248, 248, 248);
493 $pdf->SetXY(130, $posy);
494 $pdf->SetTextColor(0, 0, 60);
495 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalVAT"), 1,
'L');
496 $pdf->SetXY(180, $posy);
497 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_tva), 1,
'R');
501 $pdf->SetXY(130, $posy);
502 $pdf->SetFont(
'',
'B', 10);
503 $pdf->SetTextColor(0, 0, 60);
504 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalTTC"), 1,
'L');
505 $pdf->SetXY(180, $posy);
506 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_ttc), 1,
'R');
509 $sumPayments = $object->getSumPayments();
510 if ($sumPayments > 0 && !
getDolGlobalString(
'PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS')) {
511 $posy = $this->
tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs);
515 $this->
_pagefoot($pdf, $object, $outputlangs);
516 if (method_exists($pdf,
'AliasNbPages')) {
517 $pdf->AliasNbPages();
522 $pdf->Output($file,
'F');
525 $hookmanager->initHooks(array(
'pdfgeneration'));
526 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
528 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
530 $this->error = $hookmanager->error;
531 $this->errors = $hookmanager->errors;
536 $this->result = array(
'fullpath'=>$file);
540 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
544 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"EXPENSEREPORT_OUTPUTDIR");
559 protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
562 $pdf->SetFont(
'',
'', $default_font_size - 1);
563 $pdf->SetTextColor(0, 0, 0);
566 $pdf->SetXY($this->posxpiece, $curY);
567 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
574 $pdf->SetXY($this->posxtype - 1, $curY);
575 $nextColumnPosX = $this->posxup;
577 $nextColumnPosX = $this->posxtva;
579 if (isModEnabled(
'project')) {
580 $nextColumnPosX = $this->posxprojet;
583 $expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
584 $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
587 if ($expensereporttypecodetoshow == $expensereporttypecode) {
588 $expensereporttypecodetoshow = preg_replace(
'/^(EX_|TF_)/',
'', $expensereporttypecodetoshow);
605 $pdf->SetXY($this->posxtva, $curY);
606 $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0,
'R');
610 $pdf->SetXY($this->posxup, $curY);
611 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4,
price($object->lines[$linenumber]->value_unit), 0,
'R');
614 $pdf->SetXY($this->posxqty, $curY);
615 $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0,
'R');
618 $pdf->SetXY($this->postotalht, $curY);
619 $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4,
price($object->lines[$linenumber]->total_ht), 0,
'R');
622 $pdf->SetXY($this->postotalttc - 1, $curY);
623 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4,
price($object->lines[$linenumber]->total_ttc), 0,
'R');
626 $pdf->SetXY($this->posxcomment, $curY);
627 $comment = $outputlangs->trans(
"Date").
':'.
dol_print_date($object->lines[$linenumber]->date,
"day",
false, $outputlangs).
' ';
628 $comment .= $outputlangs->trans(
"Type").
':'.$expensereporttypecodetoshow.
'<br>';
629 if (!empty($object->lines[$linenumber]->projet_ref)) {
630 $comment .= $outputlangs->trans(
"Project").
':'.$object->lines[$linenumber]->projet_ref.
'<br>';
632 $comment .= $object->lines[$linenumber]->comments;
633 $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
646 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
649 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
652 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
666 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
669 $pdf->SetTextColor(0, 0, 60);
670 $pdf->SetFont(
'',
'B', $default_font_size + 3);
672 $posy = $this->marge_haute;
673 $posx = $this->page_largeur - $this->marge_droite - 100;
675 $pdf->SetXY($this->marge_gauche, $posy);
678 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
679 if ($this->emetteur->logo) {
680 if (is_readable($logo)) {
682 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
684 $pdf->SetTextColor(200, 0, 0);
685 $pdf->SetFont(
'',
'B', $default_font_size - 2);
686 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
687 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
690 $text = $this->emetteur->name;
691 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
694 $pdf->SetFont(
'',
'B', $default_font_size + 4);
695 $pdf->SetXY($posx, $posy);
696 $pdf->SetTextColor(0, 0, 60);
697 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans(
"ExpenseReport"), 0,
'R');
699 $pdf->SetFont(
'',
'', $default_font_size - 1);
703 $pdf->SetXY($posx, $posy);
704 $pdf->SetTextColor(0, 0, 60);
705 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".$object->ref,
'',
'R');
709 $pdf->SetXY($posx, $posy);
710 $pdf->SetTextColor(0, 0, 60);
711 $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');
715 $pdf->SetXY($posx, $posy);
716 $pdf->SetTextColor(0, 0, 60);
717 $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');
721 $pdf->SetXY($posx, $posy);
722 $pdf->SetFont(
'',
'B', $default_font_size + 2);
723 $pdf->SetTextColor(111, 81, 124);
724 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities($object->labelStatusShort[$object->status]),
'',
'R');
728 $carac_emetteur =
'';
729 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->address);
730 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->zip).
' '.$outputlangs->convToOutputCharset($this->emetteur->town);
731 $carac_emetteur .=
"\n";
732 if ($this->emetteur->phone) {
733 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
" : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
735 if ($this->emetteur->fax) {
736 $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
" : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
738 if ($this->emetteur->email) {
739 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($this->emetteur->email);
741 if ($this->emetteur->url) {
742 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
" : ".$outputlangs->convToOutputCharset($this->emetteur->url);
746 $receiver =
new User($this->db);
747 $receiver->fetch($object->fk_user_author);
749 $receiver_account->fetch(0,
'', $object->fk_user_author);
750 $expense_receiver =
'';
751 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->address);
752 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->zip).
' '.$outputlangs->convToOutputCharset($receiver->town);
753 $expense_receiver .=
"\n";
754 if ($receiver->email) {
755 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($receiver->email);
757 if ($receiver_account->iban) {
758 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"IBAN").
" : ".$outputlangs->convToOutputCharset($receiver_account->iban);
763 $posx = $this->marge_gauche;
770 $pdf->SetTextColor(0, 0, 0);
771 $pdf->SetFont(
'',
'B', $default_font_size - 2);
772 $pdf->SetXY($posx, $posy - 5);
773 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripSociete"),
'',
'L');
774 $pdf->SetXY($posx, $posy);
775 $pdf->SetFillColor(224, 224, 224);
776 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
777 $pdf->SetTextColor(0, 0, 60);
781 $pdf->SetXY($posx + 2, $posy + 3);
782 $pdf->SetFont(
'',
'B', $default_font_size);
783 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
784 $pdf->SetXY($posx + 2, $posy + 8);
785 $pdf->SetFont(
'',
'', $default_font_size - 1);
786 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
788 $pdf->SetXY($posx + 2, $posy + 3);
789 $pdf->SetFont(
'',
'B', $default_font_size);
790 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(
dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0,
'L');
791 $pdf->SetXY($posx + 2, $posy + 8);
792 $pdf->SetFont(
'',
'', $default_font_size - 1);
793 $pdf->MultiCell(80, 4, $expense_receiver, 0,
'L');
800 $posx = $this->marge_gauche;
804 $pdf->SetTextColor(0, 0, 0);
805 $pdf->SetFont(
'',
'B', 8);
806 $pdf->SetXY($posx, $posy - 5);
807 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripNDF").
" :", 0,
'L');
808 $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
811 if ($object->fk_user_author > 0) {
812 $userfee =
new User($this->db);
813 $userfee->fetch($object->fk_user_author);
815 $pdf->SetXY($posx + 2, $posy);
816 $pdf->SetFont(
'',
'', 10);
817 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
818 $posy = $pdf->GetY() + 1;
819 $pdf->SetXY($posx + 2, $posy);
820 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateCreation").
" : ".
dol_print_date($object->date_create,
"day",
false, $outputlangs), 0,
'L');
823 if ($object->fk_statut == 99) {
824 if ($object->fk_user_refuse > 0) {
825 $userfee =
new User($this->db);
826 $userfee->fetch($object->fk_user_refuse);
828 $pdf->SetXY($posx + 2, $posy);
829 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"REFUSEUR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
831 $pdf->SetXY($posx + 2, $posy);
832 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_REFUS").
" : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0,
'L');
834 $pdf->SetXY($posx + 2, $posy);
835 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_REFUS").
" : ".
dol_print_date($object->date_refuse,
"day",
false, $outputlangs), 0,
'L');
837 } elseif ($object->fk_statut == 4) {
838 if ($object->fk_user_cancel > 0) {
839 $userfee =
new User($this->db);
840 $userfee->fetch($object->fk_user_cancel);
842 $pdf->SetXY($posx + 2, $posy);
843 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"CANCEL_USER").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
845 $pdf->SetXY($posx + 2, $posy);
846 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_CANCEL").
" : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0,
'L');
848 $pdf->SetXY($posx + 2, $posy);
849 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_CANCEL").
" : ".
dol_print_date($object->date_cancel,
"day",
false, $outputlangs), 0,
'L');
852 if ($object->fk_user_approve > 0) {
853 $userfee =
new User($this->db);
854 $userfee->fetch($object->fk_user_approve);
856 $pdf->SetXY($posx + 2, $posy);
857 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"VALIDOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
859 $pdf->SetXY($posx + 2, $posy);
860 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateApprove").
" : ".
dol_print_date($object->date_approve,
"day",
false, $outputlangs), 0,
'L');
864 if ($object->fk_statut == 6) {
865 if ($object->fk_user_paid > 0) {
866 $userfee =
new User($this->db);
867 $userfee->fetch($object->fk_user_paid);
869 $pdf->SetXY($posx + 2, $posy);
870 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHORPAIEMENT").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
872 $pdf->SetXY($posx + 2, $posy);
873 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_PAIEMENT").
" : ".
dol_print_date($object->date_paiement,
"day",
false, $outputlangs), 0,
'L');
893 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
903 $currency = !empty($currency) ? $currency : $conf->currency;
907 $pdf->SetTextColor(0, 0, 0);
908 $pdf->SetFont(
'',
'', $default_font_size - 2);
909 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
910 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
911 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
913 $pdf->SetDrawColor(128, 128, 128);
916 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
918 if (empty($hidetop)) {
919 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
922 $pdf->SetFont(
'',
'', 8);
925 if (empty($hidetop)) {
926 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
927 $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1,
'',
'',
'R');
931 $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
932 if (empty($hidetop)) {
933 $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
934 $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities(
"Description"),
'',
'L');
965 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
966 if (empty($hidetop)) {
967 $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
968 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
973 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
974 if (empty($hidetop)) {
975 $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
976 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUTTC"),
'',
'C');
980 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
981 if (empty($hidetop)) {
982 $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
983 $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
987 $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
988 if (empty($hidetop)) {
989 $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
990 $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
994 $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
995 if (empty($hidetop)) {
996 $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
997 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'R');
1000 $pdf->SetTextColor(0, 0, 0);
1017 $tab3_posx = $this->marge_gauche;
1024 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1025 $pdf->SetFont(
'',
'', $default_font_size - 2);
1026 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1027 $pdf->SetTextColor(0, 0, 0);
1028 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1030 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top);
1032 $pdf->SetXY($tab3_posx, $tab3_top + 1);
1033 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Date"), 0,
'L', 0);
1034 $pdf->SetXY($tab3_posx + 19, $tab3_top + 1);
1035 $pdf->MultiCell(15, 3, $outputlangs->transnoentities(
"Amount"), 0,
'C', 0);
1036 $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
1037 $pdf->MultiCell(30, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1038 if (isModEnabled(
"banque")) {
1039 $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
1040 $pdf->MultiCell(25, 3, $outputlangs->transnoentities(
"BankAccount"), 0,
'L', 0);
1042 $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height);
1049 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1050 $sql .=
"c.code as p_code, c.libelle as payment_type,";
1051 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1052 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1053 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1054 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1055 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1056 $sql .=
" WHERE e.rowid = ".((int) $object->id);
1057 $sql .=
" AND p.fk_expensereport = e.rowid";
1058 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1059 $sql .=
" ORDER BY dp";
1061 $resql = $this->db->query($sql);
1063 $num = $this->db->num_rows($resql);
1068 $row = $this->db->fetch_object($resql);
1070 $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
1071 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->dp),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1072 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
1073 $pdf->MultiCell(15, 3,
price($sign * $row->amount, 0, $outputlangs), 0,
'R', 0);
1074 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
1075 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->p_code);
1077 $pdf->MultiCell(40, 3, $oper, 0,
'L', 0);
1078 if (isModEnabled(
"banque")) {
1079 $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
1080 $pdf->MultiCell(30, 3, $row->baref, 0,
'L', 0);
1083 $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height);
1084 $totalpaid += $row->amount;
1087 if ($num > 0 && $object->paid == 0) {
1090 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1091 $pdf->MultiCell(15, 3,
price($totalpaid), 0,
'R', 0);
1092 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1093 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AlreadyPaid"), 0,
'L', 0);
1094 $y += $tab3_height - 2;
1095 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1096 $pdf->MultiCell(15, 3,
price($object->total_ttc), 0,
'R', 0);
1097 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1098 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AmountExpected"), 0,
'L', 0);
1099 $y += $tab3_height - 2;
1100 $remaintopay = $object->total_ttc - $totalpaid;
1101 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1102 $pdf->MultiCell(15, 3,
price($remaintopay), 0,
'R', 0);
1103 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1104 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"RemainderToPay"), 0,
'L', 0);
1107 $this->error = $this->db->lasterror();