194 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
197 global $user, $langs,
$conf, $mysoc, $db, $hookmanager;
199 if (!is_object($outputlangs)) {
200 $outputlangs = $langs;
204 $outputlangs->charset_output =
'ISO-8859-1';
208 $outputlangs->loadLangs(array(
"main",
"trips",
"projects",
"dict",
"bills",
"banks"));
210 $nblines = count(
$object->lines);
212 if (
$conf->expensereport->dir_output) {
215 $dir =
$conf->expensereport->dir_output;
216 $file = $dir.
"/SPECIMEN.pdf";
219 $dir =
$conf->expensereport->dir_output.
"/".$objectref;
220 $file = $dir.
"/".$objectref.
".pdf";
223 if (!file_exists($dir)) {
225 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
230 if (file_exists($dir)) {
232 if (!is_object($hookmanager)) {
233 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
236 $hookmanager->initHooks(array(
'pdfgeneration'));
237 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
239 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
244 $heightforinfotot = 40;
246 $heightforfooter = $this->marge_basse + 12;
248 $heightforfooter += 6;
251 $pdf->SetAutoPageBreak(1, 0);
253 if (class_exists(
'TCPDF')) {
254 $pdf->setPrintHeader(
false);
255 $pdf->setPrintFooter(
false);
260 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
261 $tplidx = $pdf->importPage(1);
266 $pdf->SetDrawColor(128, 128, 128);
268 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
269 $pdf->SetSubject($outputlangs->transnoentities(
"Trips"));
270 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
271 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
272 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Trips"));
274 $pdf->SetCompression(
false);
278 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
282 if (!empty($tplidx)) {
283 $pdf->useTemplate($tplidx);
287 $pdf->SetFont(
'',
'', $default_font_size - 1);
288 $pdf->MultiCell(0, 3,
'');
289 $pdf->SetTextColor(0, 0, 0);
292 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 65 : 10);
294 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
297 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
300 if (is_object(
$object->thirdparty)) {
301 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
302 $salerepobj =
new User($this->db);
303 $salerepobj->fetch($salereparray[0][
'id']);
304 if (!empty($salerepobj->signature)) {
305 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
317 $pdf->SetFont(
'',
'', $default_font_size - 1);
318 $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
319 $nexY = $pdf->GetY();
320 $height_note = $nexY - $tab_top;
323 $pdf->SetDrawColor(192, 192, 192);
324 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius,
'1234',
'D');
326 $tab_height -= $height_note;
327 $tab_top = $nexY + 6;
332 $iniY = $tab_top + 7;
333 $nexY = $tab_top + 7;
335 $showpricebeforepagebreak = 1;
336 $pdf->setTopMargin($tab_top_newpage);
339 while ($i < $nblines) {
340 $pdf->SetFont(
'',
'', $default_font_size - 2);
341 $pdf->SetTextColor(0, 0, 0);
343 $pdf->setTopMargin($tab_top_newpage);
344 if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) {
345 $pdf->setPageOrientation(
'', 1, $heightforfooter);
347 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
350 $pageposbefore = $pdf->getPage();
352 $pdf->startTransaction();
353 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
354 $pageposafter = $pdf->getPage();
355 if ($pageposafter > $pageposbefore) {
357 $pdf->rollbackTransaction(
true);
359 $pageposafter = $pageposbefore;
361 if (empty($showpricebeforepagebreak)) {
362 $pdf->AddPage(
'',
'',
true);
363 if (!empty($tplidx)) {
364 $pdf->useTemplate($tplidx);
369 $pdf->setPage($pageposafter + 1);
370 $showpricebeforepagebreak = 1;
371 $nexY = $tab_top_newpage;
372 $nexY += ($pdf->getFontSize() * 1.3);
373 $pdf->SetFont(
'',
'', $default_font_size - 2);
374 $pdf->SetTextColor(0, 0, 0);
376 $pdf->setTopMargin($tab_top_newpage);
379 $pdf->setPageOrientation(
'', 1, $heightforfooter);
380 $showpricebeforepagebreak = 0;
383 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
384 $pageposafter = $pdf->getPage();
385 $posyafter = $pdf->GetY();
387 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
389 if ($i == ($nblines - 1)) {
391 $pdf->AddPage(
'',
'',
true);
392 if (!empty($tplidx)) {
393 $pdf->useTemplate($tplidx);
398 $pdf->setPage($pageposafter + 1);
404 $showpricebeforepagebreak = 1;
406 $showpricebeforepagebreak = 0;
410 $pdf->commitTransaction();
414 $nexY = $pdf->GetY();
415 $pageposafter = $pdf->getPage();
416 $pdf->setPage($pageposbefore);
417 $pdf->setTopMargin($this->marge_haute);
418 $pdf->setPageOrientation(
'', 1, 0);
421 $nexY += ($pdf->getFontSize() * 1.3);
424 while ($pagenb < $pageposafter) {
425 $pdf->setPage($pagenb);
426 $pdf->setPageOrientation(
'', 1, 0);
428 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
430 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
434 $pdf->setPage($pagenb);
435 $pdf->setPageOrientation(
'', 1, 0);
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
443 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
445 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
452 if (!empty($tplidx)) {
453 $pdf->useTemplate($tplidx);
464 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
465 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
467 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
468 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
471 $pdf->SetFont(
'',
'', 10);
474 $posy = $bottomlasttab + 5;
475 $posy_start_of_totals = $posy;
476 $pdf->SetXY(130, $posy);
477 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalHT"), 1,
'L');
478 $pdf->SetXY(180, $posy);
479 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_ht), 1,
'R');
480 $pdf->SetFillColor(248, 248, 248);
485 $pdf->SetXY(130, $posy);
486 $pdf->SetTextColor(0, 0, 60);
487 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalVAT"), 1,
'L');
488 $pdf->SetXY(180, $posy);
489 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_tva), 1,
'R');
493 $pdf->SetXY(130, $posy);
494 $pdf->SetFont(
'',
'B', 10);
495 $pdf->SetTextColor(0, 0, 60);
496 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalTTC"), 1,
'L');
497 $pdf->SetXY(180, $posy);
498 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price(
$object->total_ttc), 1,
'R');
501 $sumPayments =
$object->getSumPayments();
502 if ($sumPayments > 0 && !
getDolGlobalString(
'PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS')) {
508 if (method_exists($pdf,
'AliasNbPages')) {
509 $pdf->AliasNbPages();
514 $pdf->Output($file,
'F');
517 $hookmanager->initHooks(array(
'pdfgeneration'));
518 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
520 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
522 $this->error = $hookmanager->error;
523 $this->errors = $hookmanager->errors;
528 $this->result = array(
'fullpath' => $file);
532 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
536 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"EXPENSEREPORT_OUTPUTDIR");
551 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
554 $pdf->SetFont(
'',
'', $default_font_size - 1);
555 $pdf->SetTextColor(0, 0, 0);
558 $pdf->SetXY($this->posxpiece, $curY);
559 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
566 $pdf->SetXY($this->posxtype - 1, $curY);
567 $nextColumnPosX = $this->posxup;
569 $nextColumnPosX = $this->posxtva;
571 if (isModEnabled(
'project')) {
572 $nextColumnPosX = $this->posxprojet;
575 $expensereporttypecode =
$object->lines[$linenumber]->type_fees_code;
576 $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ?
$object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
579 if ($expensereporttypecodetoshow == $expensereporttypecode) {
580 $expensereporttypecodetoshow = preg_replace(
'/^(EX_|TF_)/',
'', $expensereporttypecodetoshow);
597 $pdf->SetXY($this->posxtva, $curY);
598 $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0,
'R');
602 $pdf->SetXY($this->posxup, $curY);
603 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4,
price(
$object->lines[$linenumber]->value_unit), 0,
'R');
606 $pdf->SetXY($this->posxqty, $curY);
607 $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4,
$object->lines[$linenumber]->qty, 0,
'R');
610 $pdf->SetXY($this->postotalht, $curY);
611 $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4,
price(
$object->lines[$linenumber]->total_ht), 0,
'R');
614 $pdf->SetXY($this->postotalttc - 1, $curY);
615 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4,
price(
$object->lines[$linenumber]->total_ttc), 0,
'R');
618 $pdf->SetXY($this->posxcomment, $curY);
619 $comment = $outputlangs->trans(
"Date").
':'.
dol_print_date(
$object->lines[$linenumber]->date,
"day",
false, $outputlangs).
' ';
620 $comment .= $outputlangs->trans(
"Type").
':'.$expensereporttypecodetoshow.
'<br>';
621 if (!empty(
$object->lines[$linenumber]->projet_ref)) {
622 $comment .= $outputlangs->trans(
"Project").
':'.
$object->lines[$linenumber]->projet_ref.
'<br>';
624 $comment .=
$object->lines[$linenumber]->comments;
625 $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
641 global $user, $langs,
$conf, $mysoc, $db, $hookmanager;
644 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
658 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm',
$conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
661 $pdf->SetTextColor(0, 0, 60);
662 $pdf->SetFont(
'',
'B', $default_font_size + 3);
664 $posy = $this->marge_haute;
665 $posx = $this->page_largeur - $this->marge_droite - 100;
667 $pdf->SetXY($this->marge_gauche, $posy);
670 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
671 if ($this->emetteur->logo) {
672 if (is_readable($logo)) {
674 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
676 $pdf->SetTextColor(200, 0, 0);
677 $pdf->SetFont(
'',
'B', $default_font_size - 2);
678 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
679 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
682 $text = $this->emetteur->name;
683 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
686 $pdf->SetFont(
'',
'B', $default_font_size + 4);
687 $pdf->SetXY($posx, $posy);
688 $pdf->SetTextColor(0, 0, 60);
689 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans(
"ExpenseReport"), 0,
'R');
691 $pdf->SetFont(
'',
'', $default_font_size - 1);
695 $pdf->SetXY($posx, $posy);
696 $pdf->SetTextColor(0, 0, 60);
697 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".
$object->ref,
'',
'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(
"DateStart").
" : ".(
$object->date_debut > 0 ?
dol_print_date(
$object->date_debut,
"day",
false, $outputlangs) :
''),
'',
'R');
707 $pdf->SetXY($posx, $posy);
708 $pdf->SetTextColor(0, 0, 60);
709 $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');
713 $pdf->SetXY($posx, $posy);
714 $pdf->SetFont(
'',
'B', $default_font_size + 2);
715 $pdf->SetTextColor(111, 81, 124);
716 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
$object->labelStatusShort[
$object->status]),
'',
'R');
720 $carac_emetteur =
'';
721 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->address);
722 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->zip).
' '.$outputlangs->convToOutputCharset($this->emetteur->town);
723 $carac_emetteur .=
"\n";
724 if ($this->emetteur->phone) {
725 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
" : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
727 if ($this->emetteur->fax) {
728 $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
" : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
730 if ($this->emetteur->email) {
731 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($this->emetteur->email);
733 if ($this->emetteur->url) {
734 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
" : ".$outputlangs->convToOutputCharset($this->emetteur->url);
738 $receiver =
new User($this->db);
739 $receiver->fetch(
$object->fk_user_author);
741 $receiver_account->fetch(0,
'',
$object->fk_user_author);
742 $expense_receiver =
'';
743 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->address);
744 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->zip).
' '.$outputlangs->convToOutputCharset($receiver->town);
745 $expense_receiver .=
"\n";
746 if ($receiver->email) {
747 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($receiver->email);
749 if ($receiver_account->iban) {
750 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"IBAN").
" : ".$outputlangs->convToOutputCharset($receiver_account->iban);
755 $posx = $this->marge_gauche;
762 $pdf->SetTextColor(0, 0, 0);
763 $pdf->SetFont(
'',
'B', $default_font_size - 2);
764 $pdf->SetXY($posx, $posy - 5);
765 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripSociete"),
'',
'L');
766 $pdf->SetXY($posx, $posy);
767 $pdf->SetFillColor(224, 224, 224);
768 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
769 $pdf->SetTextColor(0, 0, 60);
773 $pdf->SetXY($posx + 2, $posy + 3);
774 $pdf->SetFont(
'',
'B', $default_font_size);
775 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
776 $pdf->SetXY($posx + 2, $posy + 8);
777 $pdf->SetFont(
'',
'', $default_font_size - 1);
778 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
780 $pdf->SetXY($posx + 2, $posy + 3);
781 $pdf->SetFont(
'',
'B', $default_font_size);
782 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(
dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0,
'L');
783 $pdf->SetXY($posx + 2, $posy + 8);
784 $pdf->SetFont(
'',
'', $default_font_size - 1);
785 $pdf->MultiCell(80, 4, $expense_receiver, 0,
'L');
792 $posx = $this->marge_gauche;
796 $pdf->SetTextColor(0, 0, 0);
797 $pdf->SetFont(
'',
'B', 8);
798 $pdf->SetXY($posx, $posy - 5);
799 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripNDF").
" :", 0,
'L');
800 $pdf->RoundedRect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre, $this->corner_radius,
'1234',
'D');
803 if (
$object->fk_user_author > 0) {
804 $userfee =
new User($this->db);
805 $userfee->fetch(
$object->fk_user_author);
807 $pdf->SetXY($posx + 2, $posy);
808 $pdf->SetFont(
'',
'', 10);
809 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
810 $posy = $pdf->GetY() + 1;
811 $pdf->SetXY($posx + 2, $posy);
812 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateCreation").
" : ".
dol_print_date(
$object->date_create,
"day",
false, $outputlangs), 0,
'L');
815 if (
$object->fk_statut == 99) {
816 if (
$object->fk_user_refuse > 0) {
817 $userfee =
new User($this->db);
818 $userfee->fetch(
$object->fk_user_refuse);
820 $pdf->SetXY($posx + 2, $posy);
821 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"REFUSEUR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
823 $pdf->SetXY($posx + 2, $posy);
824 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_REFUS").
" : ".$outputlangs->convToOutputCharset(
$object->detail_refuse), 0,
'L');
826 $pdf->SetXY($posx + 2, $posy);
827 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_REFUS").
" : ".
dol_print_date(
$object->date_refuse,
"day",
false, $outputlangs), 0,
'L');
829 } elseif (
$object->fk_statut == 4) {
830 if (
$object->fk_user_cancel > 0) {
831 $userfee =
new User($this->db);
832 $userfee->fetch(
$object->fk_user_cancel);
834 $pdf->SetXY($posx + 2, $posy);
835 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"CANCEL_USER").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
837 $pdf->SetXY($posx + 2, $posy);
838 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_CANCEL").
" : ".$outputlangs->convToOutputCharset(
$object->detail_cancel), 0,
'L');
840 $pdf->SetXY($posx + 2, $posy);
841 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_CANCEL").
" : ".
dol_print_date(
$object->date_cancel,
"day",
false, $outputlangs), 0,
'L');
844 if (
$object->fk_user_approve > 0) {
845 $userfee =
new User($this->db);
846 $userfee->fetch(
$object->fk_user_approve);
848 $pdf->SetXY($posx + 2, $posy);
849 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"VALIDOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
851 $pdf->SetXY($posx + 2, $posy);
852 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateApprove").
" : ".
dol_print_date(
$object->date_approve,
"day",
false, $outputlangs), 0,
'L');
857 if (
$object->fk_user_paid > 0) {
858 $userfee =
new User($this->db);
859 $userfee->fetch(
$object->fk_user_paid);
861 $pdf->SetXY($posx + 2, $posy);
862 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHORPAIEMENT").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
864 $pdf->SetXY($posx + 2, $posy);
865 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_PAIEMENT").
" : ".
dol_print_date(
$object->date_paiement,
"day",
false, $outputlangs), 0,
'L');
887 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
897 $currency = !empty($currency) ? $currency :
$conf->currency;
901 $pdf->SetTextColor(0, 0, 0);
902 $pdf->SetFont(
'',
'', $default_font_size - 2);
903 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
904 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
905 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
907 $pdf->SetDrawColor(128, 128, 128);
910 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius,
'1234',
'D');
911 if (empty($hidetop)) {
912 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
915 $pdf->SetFont(
'',
'', 8);
918 if (empty($hidetop)) {
919 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
920 $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1,
'',
'',
'R');
924 $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
925 if (empty($hidetop)) {
926 $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
927 $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities(
"Description"),
'',
'L');
958 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
959 if (empty($hidetop)) {
960 $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
961 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
966 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
967 if (empty($hidetop)) {
968 $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
969 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUTTC"),
'',
'C');
973 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
974 if (empty($hidetop)) {
975 $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
976 $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
980 $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
981 if (empty($hidetop)) {
982 $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
983 $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
987 $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
988 if (empty($hidetop)) {
989 $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
990 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'R');
993 $pdf->SetTextColor(0, 0, 0);
1010 $tab3_posx = $this->marge_gauche;
1017 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1018 $pdf->SetFont(
'',
'', $default_font_size - 2);
1019 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1020 $pdf->SetTextColor(0, 0, 0);
1021 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1023 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top);
1025 $pdf->SetXY($tab3_posx, $tab3_top + 1);
1026 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Date"), 0,
'L', 0);
1027 $pdf->SetXY($tab3_posx + 19, $tab3_top + 1);
1028 $pdf->MultiCell(15, 3, $outputlangs->transnoentities(
"Amount"), 0,
'C', 0);
1029 $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
1030 $pdf->MultiCell(30, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1031 if (isModEnabled(
"bank")) {
1032 $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
1033 $pdf->MultiCell(25, 3, $outputlangs->transnoentities(
"BankAccount"), 0,
'L', 0);
1035 $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height);
1042 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1043 $sql .=
"c.code as p_code, c.libelle as payment_type,";
1044 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1045 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1046 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1047 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1048 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1049 $sql .=
" WHERE e.rowid = ".((int)
$object->id);
1050 $sql .=
" AND p.fk_expensereport = e.rowid";
1051 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1052 $sql .=
" ORDER BY dp";
1054 $resql = $this->db->query($sql);
1056 $num = $this->db->num_rows($resql);
1061 $row = $this->db->fetch_object($resql);
1063 $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
1064 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->dp),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1065 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
1066 $pdf->MultiCell(15, 3,
price($sign * $row->amount, 0, $outputlangs), 0,
'R', 0);
1067 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
1068 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->p_code);
1070 $pdf->MultiCell(40, 3, $oper, 0,
'L', 0);
1071 if (isModEnabled(
"bank")) {
1072 $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
1073 $pdf->MultiCell(30, 3, $row->baref, 0,
'L', 0);
1076 $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height);
1077 $totalpaid += $row->amount;
1080 if ($num > 0 &&
$object->paid == 0) {
1083 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1084 $pdf->MultiCell(15, 3,
price($totalpaid), 0,
'R', 0);
1085 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1086 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AlreadyPaid"), 0,
'L', 0);
1087 $y += $tab3_height - 2;
1088 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1089 $pdf->MultiCell(15, 3,
price(
$object->total_ttc), 0,
'R', 0);
1090 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1091 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AmountExpected"), 0,
'L', 0);
1092 $y += $tab3_height - 2;
1093 $remaintopay =
$object->total_ttc - $totalpaid;
1094 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1095 $pdf->MultiCell(15, 3,
price($remaintopay), 0,
'R', 0);
1096 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1097 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"RemainderToPay"), 0,
'L', 0);
1100 $this->error = $this->db->lasterror();