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;
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) {
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;
242 $heightforfooter += 6;
245 $pdf->SetAutoPageBreak(1, 0);
247 if (class_exists(
'TCPDF')) {
248 $pdf->setPrintHeader(
false);
249 $pdf->setPrintFooter(
false);
254 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'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);
272 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
276 if (!empty($tplidx)) {
277 $pdf->useTemplate($tplidx);
281 $pdf->SetFont(
'',
'', $default_font_size - 1);
282 $pdf->MultiCell(0, 3,
'');
283 $pdf->SetTextColor(0, 0, 0);
286 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 65 : 10);
288 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
291 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
294 if (is_object(
$object->thirdparty)) {
295 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
296 $salerepobj =
new User($this->db);
297 $salerepobj->fetch($salereparray[0][
'id']);
298 if (!empty($salerepobj->signature)) {
299 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
311 $pdf->SetFont(
'',
'', $default_font_size - 1);
312 $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
313 $nexY = $pdf->GetY();
314 $height_note = $nexY - $tab_top;
317 $pdf->SetDrawColor(192, 192, 192);
318 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
320 $tab_height = $tab_height - $height_note;
321 $tab_top = $nexY + 6;
326 $iniY = $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);
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);
392 $pdf->setPage($pageposafter + 1);
398 $showpricebeforepagebreak = 1;
400 $showpricebeforepagebreak = 0;
404 $pdf->commitTransaction();
408 $nexY = $pdf->GetY();
409 $pageposafter = $pdf->getPage();
410 $pdf->setPage($pageposbefore);
411 $pdf->setTopMargin($this->marge_haute);
412 $pdf->setPageOrientation(
'', 1, 0);
430 $nexY += ($pdf->getFontSize() * 1.3);
433 while ($pagenb < $pageposafter) {
434 $pdf->setPage($pagenb);
435 $pdf->setPageOrientation(
'', 1, 0);
437 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
439 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
443 $pdf->setPage($pagenb);
444 $pdf->setPageOrientation(
'', 1, 0);
448 if (!empty($tplidx)) {
449 $pdf->useTemplate($tplidx);
452 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
454 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
456 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
473 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
474 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
476 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
477 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
480 $pdf->SetFont(
'',
'', 10);
483 $posy = $bottomlasttab + 5;
484 $posy_start_of_totals = $posy;
485 $pdf->SetXY(130, $posy);
486 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalHT"), 1,
'L');
487 $pdf->SetXY(180, $posy);
488 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_ht), 1,
'R');
489 $pdf->SetFillColor(248, 248, 248);
494 $pdf->SetXY(130, $posy);
495 $pdf->SetTextColor(0, 0, 60);
496 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalVAT"), 1,
'L');
497 $pdf->SetXY(180, $posy);
498 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_tva), 1,
'R');
502 $pdf->SetXY(130, $posy);
503 $pdf->SetFont(
'',
'B', 10);
504 $pdf->SetTextColor(0, 0, 60);
505 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalTTC"), 1,
'L');
506 $pdf->SetXY(180, $posy);
507 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_ttc), 1,
'R');
510 $sumPayments =
$object->getSumPayments();
511 if ($sumPayments > 0 && !
getDolGlobalString(
'PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS')) {
517 if (method_exists($pdf,
'AliasNbPages')) {
518 $pdf->AliasNbPages();
523 $pdf->Output($file,
'F');
526 $hookmanager->initHooks(array(
'pdfgeneration'));
527 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
529 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
531 $this->error = $hookmanager->error;
532 $this->errors = $hookmanager->errors;
537 $this->result = array(
'fullpath' => $file);
541 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
545 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"EXPENSEREPORT_OUTPUTDIR");
560 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
563 $pdf->SetFont(
'',
'', $default_font_size - 1);
564 $pdf->SetTextColor(0, 0, 0);
567 $pdf->SetXY($this->posxpiece, $curY);
568 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
575 $pdf->SetXY($this->posxtype - 1, $curY);
576 $nextColumnPosX = $this->posxup;
578 $nextColumnPosX = $this->posxtva;
580 if (isModEnabled(
'project')) {
581 $nextColumnPosX = $this->posxprojet;
584 $expensereporttypecode =
$object->lines[$linenumber]->type_fees_code;
585 $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ?
$object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
588 if ($expensereporttypecodetoshow == $expensereporttypecode) {
589 $expensereporttypecodetoshow = preg_replace(
'/^(EX_|TF_)/',
'', $expensereporttypecodetoshow);
606 $pdf->SetXY($this->posxtva, $curY);
607 $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0,
'R');
611 $pdf->SetXY($this->posxup, $curY);
612 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4,
price(
$object->lines[$linenumber]->value_unit), 0,
'R');
615 $pdf->SetXY($this->posxqty, $curY);
616 $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4,
$object->lines[$linenumber]->qty, 0,
'R');
619 $pdf->SetXY($this->postotalht, $curY);
620 $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4,
price(
$object->lines[$linenumber]->total_ht), 0,
'R');
623 $pdf->SetXY($this->postotalttc - 1, $curY);
624 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4,
price(
$object->lines[$linenumber]->total_ttc), 0,
'R');
627 $pdf->SetXY($this->posxcomment, $curY);
628 $comment = $outputlangs->trans(
"Date").
':'.
dol_print_date(
$object->lines[$linenumber]->date,
"day",
false, $outputlangs).
' ';
629 $comment .= $outputlangs->trans(
"Type").
':'.$expensereporttypecodetoshow.
'<br>';
630 if (!empty(
$object->lines[$linenumber]->projet_ref)) {
631 $comment .= $outputlangs->trans(
"Project").
':'.
$object->lines[$linenumber]->projet_ref.
'<br>';
633 $comment .=
$object->lines[$linenumber]->comments;
634 $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
650 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
653 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
667 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
670 $pdf->SetTextColor(0, 0, 60);
671 $pdf->SetFont(
'',
'B', $default_font_size + 3);
673 $posy = $this->marge_haute;
674 $posx = $this->page_largeur - $this->marge_droite - 100;
676 $pdf->SetXY($this->marge_gauche, $posy);
679 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
680 if ($this->emetteur->logo) {
681 if (is_readable($logo)) {
683 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
685 $pdf->SetTextColor(200, 0, 0);
686 $pdf->SetFont(
'',
'B', $default_font_size - 2);
687 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
688 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
691 $text = $this->emetteur->name;
692 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
695 $pdf->SetFont(
'',
'B', $default_font_size + 4);
696 $pdf->SetXY($posx, $posy);
697 $pdf->SetTextColor(0, 0, 60);
698 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans(
"ExpenseReport"), 0,
'R');
700 $pdf->SetFont(
'',
'', $default_font_size - 1);
704 $pdf->SetXY($posx, $posy);
705 $pdf->SetTextColor(0, 0, 60);
706 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".
$object->ref,
'',
'R');
710 $pdf->SetXY($posx, $posy);
711 $pdf->SetTextColor(0, 0, 60);
712 $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');
716 $pdf->SetXY($posx, $posy);
717 $pdf->SetTextColor(0, 0, 60);
718 $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');
722 $pdf->SetXY($posx, $posy);
723 $pdf->SetFont(
'',
'B', $default_font_size + 2);
724 $pdf->SetTextColor(111, 81, 124);
725 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
$object->labelStatusShort[
$object->status]),
'',
'R');
729 $carac_emetteur =
'';
730 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->address);
731 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->zip).
' '.$outputlangs->convToOutputCharset($this->emetteur->town);
732 $carac_emetteur .=
"\n";
733 if ($this->emetteur->phone) {
734 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
" : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
736 if ($this->emetteur->fax) {
737 $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
" : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
739 if ($this->emetteur->email) {
740 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($this->emetteur->email);
742 if ($this->emetteur->url) {
743 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
" : ".$outputlangs->convToOutputCharset($this->emetteur->url);
747 $receiver =
new User($this->db);
748 $receiver->fetch(
$object->fk_user_author);
750 $receiver_account->fetch(0,
'',
$object->fk_user_author);
751 $expense_receiver =
'';
752 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->address);
753 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->zip).
' '.$outputlangs->convToOutputCharset($receiver->town);
754 $expense_receiver .=
"\n";
755 if ($receiver->email) {
756 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($receiver->email);
758 if ($receiver_account->iban) {
759 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"IBAN").
" : ".$outputlangs->convToOutputCharset($receiver_account->iban);
764 $posx = $this->marge_gauche;
771 $pdf->SetTextColor(0, 0, 0);
772 $pdf->SetFont(
'',
'B', $default_font_size - 2);
773 $pdf->SetXY($posx, $posy - 5);
774 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripSociete"),
'',
'L');
775 $pdf->SetXY($posx, $posy);
776 $pdf->SetFillColor(224, 224, 224);
777 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
778 $pdf->SetTextColor(0, 0, 60);
782 $pdf->SetXY($posx + 2, $posy + 3);
783 $pdf->SetFont(
'',
'B', $default_font_size);
784 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
785 $pdf->SetXY($posx + 2, $posy + 8);
786 $pdf->SetFont(
'',
'', $default_font_size - 1);
787 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
789 $pdf->SetXY($posx + 2, $posy + 3);
790 $pdf->SetFont(
'',
'B', $default_font_size);
791 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(
dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0,
'L');
792 $pdf->SetXY($posx + 2, $posy + 8);
793 $pdf->SetFont(
'',
'', $default_font_size - 1);
794 $pdf->MultiCell(80, 4, $expense_receiver, 0,
'L');
801 $posx = $this->marge_gauche;
805 $pdf->SetTextColor(0, 0, 0);
806 $pdf->SetFont(
'',
'B', 8);
807 $pdf->SetXY($posx, $posy - 5);
808 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripNDF").
" :", 0,
'L');
809 $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
812 if (
$object->fk_user_author > 0) {
813 $userfee =
new User($this->db);
814 $userfee->fetch(
$object->fk_user_author);
816 $pdf->SetXY($posx + 2, $posy);
817 $pdf->SetFont(
'',
'', 10);
818 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
819 $posy = $pdf->GetY() + 1;
820 $pdf->SetXY($posx + 2, $posy);
821 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateCreation").
" : ".
dol_print_date(
$object->date_create,
"day",
false, $outputlangs), 0,
'L');
824 if (
$object->fk_statut == 99) {
825 if (
$object->fk_user_refuse > 0) {
826 $userfee =
new User($this->db);
827 $userfee->fetch(
$object->fk_user_refuse);
829 $pdf->SetXY($posx + 2, $posy);
830 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"REFUSEUR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
832 $pdf->SetXY($posx + 2, $posy);
833 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_REFUS").
" : ".$outputlangs->convToOutputCharset(
$object->detail_refuse), 0,
'L');
835 $pdf->SetXY($posx + 2, $posy);
836 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_REFUS").
" : ".
dol_print_date(
$object->date_refuse,
"day",
false, $outputlangs), 0,
'L');
838 } elseif (
$object->fk_statut == 4) {
839 if (
$object->fk_user_cancel > 0) {
840 $userfee =
new User($this->db);
841 $userfee->fetch(
$object->fk_user_cancel);
843 $pdf->SetXY($posx + 2, $posy);
844 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"CANCEL_USER").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
846 $pdf->SetXY($posx + 2, $posy);
847 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_CANCEL").
" : ".$outputlangs->convToOutputCharset(
$object->detail_cancel), 0,
'L');
849 $pdf->SetXY($posx + 2, $posy);
850 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_CANCEL").
" : ".
dol_print_date(
$object->date_cancel,
"day",
false, $outputlangs), 0,
'L');
853 if (
$object->fk_user_approve > 0) {
854 $userfee =
new User($this->db);
855 $userfee->fetch(
$object->fk_user_approve);
857 $pdf->SetXY($posx + 2, $posy);
858 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"VALIDOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
860 $pdf->SetXY($posx + 2, $posy);
861 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateApprove").
" : ".
dol_print_date(
$object->date_approve,
"day",
false, $outputlangs), 0,
'L');
866 if (
$object->fk_user_paid > 0) {
867 $userfee =
new User($this->db);
868 $userfee->fetch(
$object->fk_user_paid);
870 $pdf->SetXY($posx + 2, $posy);
871 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHORPAIEMENT").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
873 $pdf->SetXY($posx + 2, $posy);
874 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_PAIEMENT").
" : ".
dol_print_date(
$object->date_paiement,
"day",
false, $outputlangs), 0,
'L');
896 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
906 $currency = !empty($currency) ? $currency : $conf->currency;
910 $pdf->SetTextColor(0, 0, 0);
911 $pdf->SetFont(
'',
'', $default_font_size - 2);
912 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
913 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
914 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
916 $pdf->SetDrawColor(128, 128, 128);
919 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
921 if (empty($hidetop)) {
922 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
925 $pdf->SetFont(
'',
'', 8);
928 if (empty($hidetop)) {
929 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
930 $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1,
'',
'',
'R');
934 $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
935 if (empty($hidetop)) {
936 $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
937 $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities(
"Description"),
'',
'L');
968 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
969 if (empty($hidetop)) {
970 $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
971 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
976 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
977 if (empty($hidetop)) {
978 $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
979 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUTTC"),
'',
'C');
983 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
984 if (empty($hidetop)) {
985 $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
986 $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
990 $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
991 if (empty($hidetop)) {
992 $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
993 $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
997 $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
998 if (empty($hidetop)) {
999 $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
1000 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'R');
1003 $pdf->SetTextColor(0, 0, 0);
1020 $tab3_posx = $this->marge_gauche;
1027 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1028 $pdf->SetFont(
'',
'', $default_font_size - 2);
1029 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1030 $pdf->SetTextColor(0, 0, 0);
1031 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1033 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top);
1035 $pdf->SetXY($tab3_posx, $tab3_top + 1);
1036 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Date"), 0,
'L', 0);
1037 $pdf->SetXY($tab3_posx + 19, $tab3_top + 1);
1038 $pdf->MultiCell(15, 3, $outputlangs->transnoentities(
"Amount"), 0,
'C', 0);
1039 $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
1040 $pdf->MultiCell(30, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1041 if (isModEnabled(
"bank")) {
1042 $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
1043 $pdf->MultiCell(25, 3, $outputlangs->transnoentities(
"BankAccount"), 0,
'L', 0);
1045 $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height);
1052 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1053 $sql .=
"c.code as p_code, c.libelle as payment_type,";
1054 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1055 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1056 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1057 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1058 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1059 $sql .=
" WHERE e.rowid = ".((int)
$object->id);
1060 $sql .=
" AND p.fk_expensereport = e.rowid";
1061 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1062 $sql .=
" ORDER BY dp";
1064 $resql = $this->db->query($sql);
1066 $num = $this->db->num_rows($resql);
1071 $row = $this->db->fetch_object($resql);
1073 $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
1074 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->dp),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1075 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
1076 $pdf->MultiCell(15, 3,
price($sign * $row->amount, 0, $outputlangs), 0,
'R', 0);
1077 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
1078 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->p_code);
1080 $pdf->MultiCell(40, 3, $oper, 0,
'L', 0);
1081 if (isModEnabled(
"bank")) {
1082 $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
1083 $pdf->MultiCell(30, 3, $row->baref, 0,
'L', 0);
1086 $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height);
1087 $totalpaid += $row->amount;
1090 if ($num > 0 &&
$object->paid == 0) {
1093 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1094 $pdf->MultiCell(15, 3,
price($totalpaid), 0,
'R', 0);
1095 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1096 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AlreadyPaid"), 0,
'L', 0);
1097 $y += $tab3_height - 2;
1098 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1099 $pdf->MultiCell(15, 3,
price(
$object->total_ttc), 0,
'R', 0);
1100 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1101 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AmountExpected"), 0,
'L', 0);
1102 $y += $tab3_height - 2;
1103 $remaintopay =
$object->total_ttc - $totalpaid;
1104 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1105 $pdf->MultiCell(15, 3,
price($remaintopay), 0,
'R', 0);
1106 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1107 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"RemainderToPay"), 0,
'L', 0);
1110 $this->error = $this->db->lasterror();