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;
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 -= $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);
415 $nexY += ($pdf->getFontSize() * 1.3);
418 while ($pagenb < $pageposafter) {
419 $pdf->setPage($pagenb);
420 $pdf->setPageOrientation(
'', 1, 0);
422 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
424 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
428 $pdf->setPage($pagenb);
429 $pdf->setPageOrientation(
'', 1, 0);
433 if (!empty($tplidx)) {
434 $pdf->useTemplate($tplidx);
437 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
439 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
441 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
446 if (!empty($tplidx)) {
447 $pdf->useTemplate($tplidx);
458 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
459 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
461 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
462 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
465 $pdf->SetFont(
'',
'', 10);
468 $posy = $bottomlasttab + 5;
469 $posy_start_of_totals = $posy;
470 $pdf->SetXY(130, $posy);
471 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalHT"), 1,
'L');
472 $pdf->SetXY(180, $posy);
473 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_ht), 1,
'R');
474 $pdf->SetFillColor(248, 248, 248);
479 $pdf->SetXY(130, $posy);
480 $pdf->SetTextColor(0, 0, 60);
481 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalVAT"), 1,
'L');
482 $pdf->SetXY(180, $posy);
483 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_tva), 1,
'R');
487 $pdf->SetXY(130, $posy);
488 $pdf->SetFont(
'',
'B', 10);
489 $pdf->SetTextColor(0, 0, 60);
490 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalTTC"), 1,
'L');
491 $pdf->SetXY(180, $posy);
492 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_ttc), 1,
'R');
495 $sumPayments =
$object->getSumPayments();
496 if ($sumPayments > 0 && !
getDolGlobalString(
'PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS')) {
502 if (method_exists($pdf,
'AliasNbPages')) {
503 $pdf->AliasNbPages();
508 $pdf->Output($file,
'F');
511 $hookmanager->initHooks(array(
'pdfgeneration'));
512 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
514 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
516 $this->error = $hookmanager->error;
517 $this->errors = $hookmanager->errors;
522 $this->result = array(
'fullpath' => $file);
526 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
530 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"EXPENSEREPORT_OUTPUTDIR");
545 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
548 $pdf->SetFont(
'',
'', $default_font_size - 1);
549 $pdf->SetTextColor(0, 0, 0);
552 $pdf->SetXY($this->posxpiece, $curY);
553 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
560 $pdf->SetXY($this->posxtype - 1, $curY);
561 $nextColumnPosX = $this->posxup;
563 $nextColumnPosX = $this->posxtva;
565 if (isModEnabled(
'project')) {
566 $nextColumnPosX = $this->posxprojet;
569 $expensereporttypecode =
$object->lines[$linenumber]->type_fees_code;
570 $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ?
$object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
573 if ($expensereporttypecodetoshow == $expensereporttypecode) {
574 $expensereporttypecodetoshow = preg_replace(
'/^(EX_|TF_)/',
'', $expensereporttypecodetoshow);
591 $pdf->SetXY($this->posxtva, $curY);
592 $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0,
'R');
596 $pdf->SetXY($this->posxup, $curY);
597 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4,
price(
$object->lines[$linenumber]->value_unit), 0,
'R');
600 $pdf->SetXY($this->posxqty, $curY);
601 $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4,
$object->lines[$linenumber]->qty, 0,
'R');
604 $pdf->SetXY($this->postotalht, $curY);
605 $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4,
price(
$object->lines[$linenumber]->total_ht), 0,
'R');
608 $pdf->SetXY($this->postotalttc - 1, $curY);
609 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4,
price(
$object->lines[$linenumber]->total_ttc), 0,
'R');
612 $pdf->SetXY($this->posxcomment, $curY);
613 $comment = $outputlangs->trans(
"Date").
':'.
dol_print_date(
$object->lines[$linenumber]->date,
"day",
false, $outputlangs).
' ';
614 $comment .= $outputlangs->trans(
"Type").
':'.$expensereporttypecodetoshow.
'<br>';
615 if (!empty(
$object->lines[$linenumber]->projet_ref)) {
616 $comment .= $outputlangs->trans(
"Project").
':'.
$object->lines[$linenumber]->projet_ref.
'<br>';
618 $comment .=
$object->lines[$linenumber]->comments;
619 $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
635 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
638 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
652 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
655 $pdf->SetTextColor(0, 0, 60);
656 $pdf->SetFont(
'',
'B', $default_font_size + 3);
658 $posy = $this->marge_haute;
659 $posx = $this->page_largeur - $this->marge_droite - 100;
661 $pdf->SetXY($this->marge_gauche, $posy);
664 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
665 if ($this->emetteur->logo) {
666 if (is_readable($logo)) {
668 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
670 $pdf->SetTextColor(200, 0, 0);
671 $pdf->SetFont(
'',
'B', $default_font_size - 2);
672 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
673 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
676 $text = $this->emetteur->name;
677 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
680 $pdf->SetFont(
'',
'B', $default_font_size + 4);
681 $pdf->SetXY($posx, $posy);
682 $pdf->SetTextColor(0, 0, 60);
683 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans(
"ExpenseReport"), 0,
'R');
685 $pdf->SetFont(
'',
'', $default_font_size - 1);
689 $pdf->SetXY($posx, $posy);
690 $pdf->SetTextColor(0, 0, 60);
691 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".
$object->ref,
'',
'R');
695 $pdf->SetXY($posx, $posy);
696 $pdf->SetTextColor(0, 0, 60);
697 $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');
701 $pdf->SetXY($posx, $posy);
702 $pdf->SetTextColor(0, 0, 60);
703 $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');
707 $pdf->SetXY($posx, $posy);
708 $pdf->SetFont(
'',
'B', $default_font_size + 2);
709 $pdf->SetTextColor(111, 81, 124);
710 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
$object->labelStatusShort[
$object->status]),
'',
'R');
714 $carac_emetteur =
'';
715 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->address);
716 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->zip).
' '.$outputlangs->convToOutputCharset($this->emetteur->town);
717 $carac_emetteur .=
"\n";
718 if ($this->emetteur->phone) {
719 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
" : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
721 if ($this->emetteur->fax) {
722 $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
" : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
724 if ($this->emetteur->email) {
725 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($this->emetteur->email);
727 if ($this->emetteur->url) {
728 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
" : ".$outputlangs->convToOutputCharset($this->emetteur->url);
732 $receiver =
new User($this->db);
733 $receiver->fetch(
$object->fk_user_author);
735 $receiver_account->fetch(0,
'',
$object->fk_user_author);
736 $expense_receiver =
'';
737 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->address);
738 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->zip).
' '.$outputlangs->convToOutputCharset($receiver->town);
739 $expense_receiver .=
"\n";
740 if ($receiver->email) {
741 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($receiver->email);
743 if ($receiver_account->iban) {
744 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"IBAN").
" : ".$outputlangs->convToOutputCharset($receiver_account->iban);
749 $posx = $this->marge_gauche;
756 $pdf->SetTextColor(0, 0, 0);
757 $pdf->SetFont(
'',
'B', $default_font_size - 2);
758 $pdf->SetXY($posx, $posy - 5);
759 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripSociete"),
'',
'L');
760 $pdf->SetXY($posx, $posy);
761 $pdf->SetFillColor(224, 224, 224);
762 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
763 $pdf->SetTextColor(0, 0, 60);
767 $pdf->SetXY($posx + 2, $posy + 3);
768 $pdf->SetFont(
'',
'B', $default_font_size);
769 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
770 $pdf->SetXY($posx + 2, $posy + 8);
771 $pdf->SetFont(
'',
'', $default_font_size - 1);
772 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
774 $pdf->SetXY($posx + 2, $posy + 3);
775 $pdf->SetFont(
'',
'B', $default_font_size);
776 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(
dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0,
'L');
777 $pdf->SetXY($posx + 2, $posy + 8);
778 $pdf->SetFont(
'',
'', $default_font_size - 1);
779 $pdf->MultiCell(80, 4, $expense_receiver, 0,
'L');
786 $posx = $this->marge_gauche;
790 $pdf->SetTextColor(0, 0, 0);
791 $pdf->SetFont(
'',
'B', 8);
792 $pdf->SetXY($posx, $posy - 5);
793 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripNDF").
" :", 0,
'L');
794 $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
797 if (
$object->fk_user_author > 0) {
798 $userfee =
new User($this->db);
799 $userfee->fetch(
$object->fk_user_author);
801 $pdf->SetXY($posx + 2, $posy);
802 $pdf->SetFont(
'',
'', 10);
803 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
804 $posy = $pdf->GetY() + 1;
805 $pdf->SetXY($posx + 2, $posy);
806 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateCreation").
" : ".
dol_print_date(
$object->date_create,
"day",
false, $outputlangs), 0,
'L');
809 if (
$object->fk_statut == 99) {
810 if (
$object->fk_user_refuse > 0) {
811 $userfee =
new User($this->db);
812 $userfee->fetch(
$object->fk_user_refuse);
814 $pdf->SetXY($posx + 2, $posy);
815 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"REFUSEUR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
817 $pdf->SetXY($posx + 2, $posy);
818 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_REFUS").
" : ".$outputlangs->convToOutputCharset(
$object->detail_refuse), 0,
'L');
820 $pdf->SetXY($posx + 2, $posy);
821 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_REFUS").
" : ".
dol_print_date(
$object->date_refuse,
"day",
false, $outputlangs), 0,
'L');
823 } elseif (
$object->fk_statut == 4) {
824 if (
$object->fk_user_cancel > 0) {
825 $userfee =
new User($this->db);
826 $userfee->fetch(
$object->fk_user_cancel);
828 $pdf->SetXY($posx + 2, $posy);
829 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"CANCEL_USER").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
831 $pdf->SetXY($posx + 2, $posy);
832 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_CANCEL").
" : ".$outputlangs->convToOutputCharset(
$object->detail_cancel), 0,
'L');
834 $pdf->SetXY($posx + 2, $posy);
835 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_CANCEL").
" : ".
dol_print_date(
$object->date_cancel,
"day",
false, $outputlangs), 0,
'L');
838 if (
$object->fk_user_approve > 0) {
839 $userfee =
new User($this->db);
840 $userfee->fetch(
$object->fk_user_approve);
842 $pdf->SetXY($posx + 2, $posy);
843 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"VALIDOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
845 $pdf->SetXY($posx + 2, $posy);
846 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateApprove").
" : ".
dol_print_date(
$object->date_approve,
"day",
false, $outputlangs), 0,
'L');
851 if (
$object->fk_user_paid > 0) {
852 $userfee =
new User($this->db);
853 $userfee->fetch(
$object->fk_user_paid);
855 $pdf->SetXY($posx + 2, $posy);
856 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHORPAIEMENT").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
858 $pdf->SetXY($posx + 2, $posy);
859 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_PAIEMENT").
" : ".
dol_print_date(
$object->date_paiement,
"day",
false, $outputlangs), 0,
'L');
881 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
891 $currency = !empty($currency) ? $currency : $conf->currency;
895 $pdf->SetTextColor(0, 0, 0);
896 $pdf->SetFont(
'',
'', $default_font_size - 2);
897 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
898 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
899 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
901 $pdf->SetDrawColor(128, 128, 128);
904 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
906 if (empty($hidetop)) {
907 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
910 $pdf->SetFont(
'',
'', 8);
913 if (empty($hidetop)) {
914 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
915 $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1,
'',
'',
'R');
919 $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
920 if (empty($hidetop)) {
921 $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
922 $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities(
"Description"),
'',
'L');
953 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
954 if (empty($hidetop)) {
955 $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
956 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
961 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
962 if (empty($hidetop)) {
963 $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
964 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUTTC"),
'',
'C');
968 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
969 if (empty($hidetop)) {
970 $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
971 $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
975 $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
976 if (empty($hidetop)) {
977 $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
978 $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
982 $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
983 if (empty($hidetop)) {
984 $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
985 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'R');
988 $pdf->SetTextColor(0, 0, 0);
1005 $tab3_posx = $this->marge_gauche;
1012 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1013 $pdf->SetFont(
'',
'', $default_font_size - 2);
1014 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1015 $pdf->SetTextColor(0, 0, 0);
1016 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1018 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top);
1020 $pdf->SetXY($tab3_posx, $tab3_top + 1);
1021 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Date"), 0,
'L', 0);
1022 $pdf->SetXY($tab3_posx + 19, $tab3_top + 1);
1023 $pdf->MultiCell(15, 3, $outputlangs->transnoentities(
"Amount"), 0,
'C', 0);
1024 $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
1025 $pdf->MultiCell(30, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1026 if (isModEnabled(
"bank")) {
1027 $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
1028 $pdf->MultiCell(25, 3, $outputlangs->transnoentities(
"BankAccount"), 0,
'L', 0);
1030 $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height);
1037 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1038 $sql .=
"c.code as p_code, c.libelle as payment_type,";
1039 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1040 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1041 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1042 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1043 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1044 $sql .=
" WHERE e.rowid = ".((int)
$object->id);
1045 $sql .=
" AND p.fk_expensereport = e.rowid";
1046 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1047 $sql .=
" ORDER BY dp";
1049 $resql = $this->db->query($sql);
1051 $num = $this->db->num_rows($resql);
1056 $row = $this->db->fetch_object($resql);
1058 $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
1059 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->dp),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1060 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
1061 $pdf->MultiCell(15, 3,
price($sign * $row->amount, 0, $outputlangs), 0,
'R', 0);
1062 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
1063 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->p_code);
1065 $pdf->MultiCell(40, 3, $oper, 0,
'L', 0);
1066 if (isModEnabled(
"bank")) {
1067 $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
1068 $pdf->MultiCell(30, 3, $row->baref, 0,
'L', 0);
1071 $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height);
1072 $totalpaid += $row->amount;
1075 if ($num > 0 &&
$object->paid == 0) {
1078 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1079 $pdf->MultiCell(15, 3,
price($totalpaid), 0,
'R', 0);
1080 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1081 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AlreadyPaid"), 0,
'L', 0);
1082 $y += $tab3_height - 2;
1083 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1084 $pdf->MultiCell(15, 3,
price(
$object->total_ttc), 0,
'R', 0);
1085 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1086 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AmountExpected"), 0,
'L', 0);
1087 $y += $tab3_height - 2;
1088 $remaintopay =
$object->total_ttc - $totalpaid;
1089 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1090 $pdf->MultiCell(15, 3,
price($remaintopay), 0,
'R', 0);
1091 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1092 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"RemainderToPay"), 0,
'L', 0);
1095 $this->error = $this->db->lasterror();