32 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/user/class/userbankaccount.class.php';
65 public $update_main_doc_field;
76 public $phpmin = array(7, 0);
82 public $version =
'dolibarr';
108 global $conf, $langs, $mysoc, $user;
111 $langs->loadLangs(array(
"main",
"trips",
"projects"));
115 $this->
description = $langs->trans(
'PDFStandardExpenseReports');
116 $this->update_main_doc_field = 1;
121 $this->page_largeur = $formatarray[
'width'];
122 $this->page_hauteur = $formatarray[
'height'];
123 $this->format = array($this->page_largeur, $this->page_hauteur);
129 $this->option_logo = 1;
130 $this->option_tva = 1;
131 $this->option_modereg = 1;
132 $this->option_condreg = 1;
133 $this->option_multilang = 1;
134 $this->option_escompte = 0;
135 $this->option_credit_note = 0;
136 $this->option_freetext = 1;
137 $this->option_draft_watermark = 1;
140 $this->emetteur = $mysoc;
142 if (empty($this->emetteur->country_code)) {
143 $this->emetteur->country_code = substr($langs->defaultlang, -2);
147 $this->posxpiece = $this->marge_gauche + 1;
148 $this->posxcomment = $this->marge_gauche + 10;
152 $this->posxtva = 112;
154 $this->posxqty = 150;
155 $this->postotalht = 160;
156 $this->postotalttc = 180;
163 if ($this->page_largeur < 210) {
164 $this->posxdate -= 20;
165 $this->posxtype -= 20;
166 $this->posxprojet -= 20;
167 $this->posxtva -= 20;
169 $this->posxqty -= 20;
170 $this->postotalttc -= 20;
173 $this->tva = array();
174 $this->tva_array = array();
175 $this->localtax1 = array();
176 $this->localtax2 = array();
177 $this->atleastoneratenotnull = 0;
178 $this->atleastonediscount = 0;
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;
203 if (!empty($conf->global->MAIN_USE_FPDF)) {
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) {
214 if ($object->specimen) {
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;
245 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
246 $heightforfooter = $this->marge_basse + 12;
247 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
248 $heightforfooter += 6;
251 $pdf->SetAutoPageBreak(1, 0);
253 if (class_exists(
'TCPDF')) {
254 $pdf->setPrintHeader(
false);
255 $pdf->setPrintFooter(
false);
259 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
260 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->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);
277 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
281 if (!empty($tplidx)) {
282 $pdf->useTemplate($tplidx);
285 $this->
_pagehead($pdf, $object, 1, $outputlangs);
286 $pdf->SetFont(
'',
'', $default_font_size - 1);
287 $pdf->MultiCell(0, 3,
'');
288 $pdf->SetTextColor(0, 0, 0);
291 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 65 : 10);
293 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
296 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
297 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
299 if (is_object($object->thirdparty)) {
300 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
301 $salerepobj =
new User($this->
db);
302 $salerepobj->fetch($salereparray[0][
'id']);
303 if (!empty($salerepobj->signature)) {
304 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
316 $pdf->SetFont(
'',
'', $default_font_size - 1);
317 $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
318 $nexY = $pdf->GetY();
319 $height_note = $nexY - $tab_top;
322 $pdf->SetDrawColor(192, 192, 192);
323 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
325 $tab_height = $tab_height - $height_note;
326 $tab_top = $nexY + 6;
331 $iniY = $tab_top + 7;
332 $initialY = $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);
367 $this->
_pagehead($pdf, $object, 0, $outputlangs);
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);
396 $this->
_pagehead($pdf, $object, 0, $outputlangs);
398 $pdf->setPage($pageposafter + 1);
403 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
404 $showpricebeforepagebreak = 1;
406 $showpricebeforepagebreak = 0;
411 $pdf->commitTransaction();
415 $nexY = $pdf->GetY();
416 $pageposafter = $pdf->getPage();
417 $pdf->setPage($pageposbefore);
418 $pdf->setTopMargin($this->marge_haute);
419 $pdf->setPageOrientation(
'', 1, 0);
437 $nexY += ($pdf->getFontSize() * 1.3);
440 while ($pagenb < $pageposafter) {
441 $pdf->setPage($pagenb);
442 $pdf->setPageOrientation(
'', 1, 0);
444 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
446 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
448 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
450 $pdf->setPage($pagenb);
451 $pdf->setPageOrientation(
'', 1, 0);
453 $this->
_pagehead($pdf, $object, 0, $outputlangs);
455 if (!empty($tplidx)) {
456 $pdf->useTemplate($tplidx);
459 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
461 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
465 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
468 if (!empty($tplidx)) {
469 $pdf->useTemplate($tplidx);
473 $this->
_pagehead($pdf, $object, 0, $outputlangs);
480 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
481 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
484 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
487 $pdf->SetFont(
'',
'', 10);
490 $posy = $bottomlasttab + 5;
491 $posy_start_of_totals = $posy;
492 $pdf->SetXY(130, $posy);
493 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalHT"), 1,
'L');
494 $pdf->SetXY(180, $posy);
495 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_ht), 1,
'R');
496 $pdf->SetFillColor(248, 248, 248);
498 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
501 $pdf->SetXY(130, $posy);
502 $pdf->SetTextColor(0, 0, 60);
503 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalVAT"), 1,
'L');
504 $pdf->SetXY(180, $posy);
505 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_tva), 1,
'R');
509 $pdf->SetXY(130, $posy);
510 $pdf->SetFont(
'',
'B', 10);
511 $pdf->SetTextColor(0, 0, 60);
512 $pdf->MultiCell(70, 5, $outputlangs->transnoentities(
"TotalTTC"), 1,
'L');
513 $pdf->SetXY(180, $posy);
514 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5,
price($object->total_ttc), 1,
'R');
517 $sumPayments = $object->getSumPayments();
518 if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) {
519 $posy = $this->
tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs);
523 $this->
_pagefoot($pdf, $object, $outputlangs);
524 if (method_exists($pdf,
'AliasNbPages')) {
525 $pdf->AliasNbPages();
530 $pdf->Output($file,
'F');
533 $hookmanager->initHooks(array(
'pdfgeneration'));
534 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
536 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
538 $this->error = $hookmanager->error;
539 $this->errors = $hookmanager->errors;
544 $this->result = array(
'fullpath'=>$file);
548 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
552 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"EXPENSEREPORT_OUTPUTDIR");
567 protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
570 $pdf->SetFont(
'',
'', $default_font_size - 1);
571 $pdf->SetTextColor(0, 0, 0);
574 $pdf->SetXY($this->posxpiece, $curY);
575 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
582 $pdf->SetXY($this->posxtype - 1, $curY);
583 $nextColumnPosX = $this->posxup;
584 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
585 $nextColumnPosX = $this->posxtva;
588 $nextColumnPosX = $this->posxprojet;
591 $expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
592 $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
595 if ($expensereporttypecodetoshow == $expensereporttypecode) {
596 $expensereporttypecodetoshow = preg_replace(
'/^(EX_|TF_)/',
'', $expensereporttypecodetoshow);
611 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
613 $pdf->SetXY($this->posxtva, $curY);
614 $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0,
'R');
618 $pdf->SetXY($this->posxup, $curY);
619 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4,
price($object->lines[$linenumber]->value_unit), 0,
'R');
622 $pdf->SetXY($this->posxqty, $curY);
623 $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0,
'R');
626 $pdf->SetXY($this->postotalht, $curY);
627 $pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4,
price($object->lines[$linenumber]->total_ht), 0,
'R');
630 $pdf->SetXY($this->postotalttc - 1, $curY);
631 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4,
price($object->lines[$linenumber]->total_ttc), 0,
'R');
634 $pdf->SetXY($this->posxcomment, $curY);
635 $comment = $outputlangs->trans(
"Date").
':'.
dol_print_date($object->lines[$linenumber]->date,
"day",
false, $outputlangs).
' ';
636 $comment .= $outputlangs->trans(
"Type").
':'.$expensereporttypecodetoshow.
'<br>';
637 if (!empty($object->lines[$linenumber]->projet_ref)) {
638 $comment .= $outputlangs->trans(
"Project").
':'.$object->lines[$linenumber]->projet_ref.
'<br>';
640 $comment .= $object->lines[$linenumber]->comments;
641 $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
654 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
657 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
660 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
673 if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) {
674 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
677 $pdf->SetTextColor(0, 0, 60);
678 $pdf->SetFont(
'',
'B', $default_font_size + 3);
680 $posy = $this->marge_haute;
681 $posx = $this->page_largeur - $this->marge_droite - 100;
683 $pdf->SetXY($this->marge_gauche, $posy);
686 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
687 if ($this->emetteur->logo) {
688 if (is_readable($logo)) {
690 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
692 $pdf->SetTextColor(200, 0, 0);
693 $pdf->SetFont(
'',
'B', $default_font_size - 2);
694 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
695 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
698 $text = $this->emetteur->name;
699 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
702 $pdf->SetFont(
'',
'B', $default_font_size + 4);
703 $pdf->SetXY($posx, $posy);
704 $pdf->SetTextColor(0, 0, 60);
705 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans(
"ExpenseReport"), 0,
'R');
707 $pdf->SetFont(
'',
'', $default_font_size - 1);
711 $pdf->SetXY($posx, $posy);
712 $pdf->SetTextColor(0, 0, 60);
713 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".$object->ref,
'',
'R');
717 $pdf->SetXY($posx, $posy);
718 $pdf->SetTextColor(0, 0, 60);
719 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"DateStart").
" : ".($object->date_debut > 0 ?
dol_print_date($object->date_debut,
"day",
false, $outputlangs) :
''),
'',
'R');
723 $pdf->SetXY($posx, $posy);
724 $pdf->SetTextColor(0, 0, 60);
725 $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');
729 $pdf->SetXY($posx, $posy);
730 $pdf->SetFont(
'',
'B', $default_font_size + 2);
731 $pdf->SetTextColor(111, 81, 124);
732 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities($object->statuts_short[$object->status]),
'',
'R');
736 $carac_emetteur =
'';
737 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->address);
738 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($this->emetteur->zip).
' '.$outputlangs->convToOutputCharset($this->emetteur->town);
739 $carac_emetteur .=
"\n";
740 if ($this->emetteur->phone) {
741 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
" : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
743 if ($this->emetteur->fax) {
744 $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
" : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
746 if ($this->emetteur->email) {
747 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($this->emetteur->email);
749 if ($this->emetteur->url) {
750 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
" : ".$outputlangs->convToOutputCharset($this->emetteur->url);
754 $receiver =
new User($this->
db);
755 $receiver->fetch($object->fk_user_author);
757 $receiver_account->fetch(0,
'', $object->fk_user_author);
758 $expense_receiver =
'';
759 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->address);
760 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->convToOutputCharset($receiver->zip).
' '.$outputlangs->convToOutputCharset($receiver->town);
761 $expense_receiver .=
"\n";
762 if ($receiver->email) {
763 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
" : ".$outputlangs->convToOutputCharset($receiver->email);
765 if ($receiver_account->iban) {
766 $expense_receiver .= ($expense_receiver ?
"\n" :
'').$outputlangs->transnoentities(
"IBAN").
" : ".$outputlangs->convToOutputCharset($receiver_account->iban);
771 $posx = $this->marge_gauche;
773 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
778 $pdf->SetTextColor(0, 0, 0);
779 $pdf->SetFont(
'',
'B', $default_font_size - 2);
780 $pdf->SetXY($posx, $posy - 5);
781 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripSociete"),
'',
'L');
782 $pdf->SetXY($posx, $posy);
783 $pdf->SetFillColor(224, 224, 224);
784 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
785 $pdf->SetTextColor(0, 0, 60);
788 if (empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
789 $pdf->SetXY($posx + 2, $posy + 3);
790 $pdf->SetFont(
'',
'B', $default_font_size);
791 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
792 $pdf->SetXY($posx + 2, $posy + 8);
793 $pdf->SetFont(
'',
'', $default_font_size - 1);
794 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
796 $pdf->SetXY($posx + 2, $posy + 3);
797 $pdf->SetFont(
'',
'B', $default_font_size);
798 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(
dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0,
'L');
799 $pdf->SetXY($posx + 2, $posy + 8);
800 $pdf->SetFont(
'',
'', $default_font_size - 1);
801 $pdf->MultiCell(80, 4, $expense_receiver, 0,
'L');
807 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
808 $posx = $this->marge_gauche;
812 $pdf->SetTextColor(0, 0, 0);
813 $pdf->SetFont(
'',
'B', 8);
814 $pdf->SetXY($posx, $posy - 5);
815 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"TripNDF").
" :", 0,
'L');
816 $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
819 if ($object->fk_user_author > 0) {
820 $userfee =
new User($this->
db);
821 $userfee->fetch($object->fk_user_author);
823 $pdf->SetXY($posx + 2, $posy);
824 $pdf->SetFont(
'',
'', 10);
825 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
826 $posy = $pdf->GetY() + 1;
827 $pdf->SetXY($posx + 2, $posy);
828 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateCreation").
" : ".
dol_print_date($object->date_create,
"day",
false, $outputlangs), 0,
'L');
831 if ($object->fk_statut == 99) {
832 if ($object->fk_user_refuse > 0) {
833 $userfee =
new User($this->
db);
834 $userfee->fetch($object->fk_user_refuse);
836 $pdf->SetXY($posx + 2, $posy);
837 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"REFUSEUR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
839 $pdf->SetXY($posx + 2, $posy);
840 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_REFUS").
" : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0,
'L');
842 $pdf->SetXY($posx + 2, $posy);
843 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_REFUS").
" : ".
dol_print_date($object->date_refuse,
"day",
false, $outputlangs), 0,
'L');
845 } elseif ($object->fk_statut == 4) {
846 if ($object->fk_user_cancel > 0) {
847 $userfee =
new User($this->
db);
848 $userfee->fetch($object->fk_user_cancel);
850 $pdf->SetXY($posx + 2, $posy);
851 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"CANCEL_USER").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
853 $pdf->SetXY($posx + 2, $posy);
854 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"MOTIF_CANCEL").
" : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0,
'L');
856 $pdf->SetXY($posx + 2, $posy);
857 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_CANCEL").
" : ".
dol_print_date($object->date_cancel,
"day",
false, $outputlangs), 0,
'L');
860 if ($object->fk_user_approve > 0) {
861 $userfee =
new User($this->
db);
862 $userfee->fetch($object->fk_user_approve);
864 $pdf->SetXY($posx + 2, $posy);
865 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"VALIDOR").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
867 $pdf->SetXY($posx + 2, $posy);
868 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DateApprove").
" : ".
dol_print_date($object->date_approve,
"day",
false, $outputlangs), 0,
'L');
872 if ($object->fk_statut == 6) {
873 if ($object->fk_user_paid > 0) {
874 $userfee =
new User($this->
db);
875 $userfee->fetch($object->fk_user_paid);
877 $pdf->SetXY($posx + 2, $posy);
878 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"AUTHORPAIEMENT").
" : ".
dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0,
'L');
880 $pdf->SetXY($posx + 2, $posy);
881 $pdf->MultiCell(96, 4, $outputlangs->transnoentities(
"DATE_PAIEMENT").
" : ".
dol_print_date($object->date_paiement,
"day",
false, $outputlangs), 0,
'L');
901 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
911 $currency = !empty($currency) ? $currency : $conf->currency;
915 $pdf->SetTextColor(0, 0, 0);
916 $pdf->SetFont(
'',
'', $default_font_size - 2);
917 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
918 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
919 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
921 $pdf->SetDrawColor(128, 128, 128);
924 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
926 if (empty($hidetop)) {
927 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
930 $pdf->SetFont(
'',
'', 8);
933 if (empty($hidetop)) {
934 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
935 $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1,
'',
'',
'R');
939 $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
940 if (empty($hidetop)) {
941 $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
942 $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities(
"Description"),
'',
'L');
972 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
973 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
974 if (empty($hidetop)) {
975 $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
976 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
981 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
982 if (empty($hidetop)) {
983 $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
984 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUTTC"),
'',
'C');
988 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
989 if (empty($hidetop)) {
990 $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
991 $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
995 $pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
996 if (empty($hidetop)) {
997 $pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
998 $pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1002 $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
1003 if (empty($hidetop)) {
1004 $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
1005 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'R');
1008 $pdf->SetTextColor(0, 0, 0);
1025 $tab3_posx = $this->marge_gauche;
1032 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1033 $pdf->SetFont(
'',
'', $default_font_size - 2);
1034 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1035 $pdf->SetTextColor(0, 0, 0);
1036 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1038 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top);
1040 $pdf->SetXY($tab3_posx, $tab3_top + 1);
1041 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Date"), 0,
'L', 0);
1042 $pdf->SetXY($tab3_posx + 19, $tab3_top + 1);
1043 $pdf->MultiCell(15, 3, $outputlangs->transnoentities(
"Amount"), 0,
'C', 0);
1044 $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
1045 $pdf->MultiCell(30, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1047 $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
1048 $pdf->MultiCell(25, 3, $outputlangs->transnoentities(
"BankAccount"), 0,
'L', 0);
1050 $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height);
1057 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1058 $sql .=
"c.code as p_code, c.libelle as payment_type,";
1059 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1060 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1061 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1062 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1063 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1064 $sql .=
" WHERE e.rowid = ".((int) $object->id);
1065 $sql .=
" AND p.fk_expensereport = e.rowid";
1066 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1067 $sql .=
" ORDER BY dp";
1069 $resql = $this->
db->query(
$sql);
1071 $num = $this->
db->num_rows($resql);
1076 $row = $this->
db->fetch_object($resql);
1078 $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
1079 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->dp),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1080 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
1081 $pdf->MultiCell(15, 3,
price($sign * $row->amount, 0, $outputlangs), 0,
'R', 0);
1082 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
1083 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->p_code);
1085 $pdf->MultiCell(40, 3, $oper, 0,
'L', 0);
1087 $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
1088 $pdf->MultiCell(30, 3, $row->baref, 0,
'L', 0);
1091 $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height);
1092 $totalpaid += $row->amount;
1095 if ($num > 0 && $object->paid == 0) {
1098 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1099 $pdf->MultiCell(15, 3,
price($totalpaid), 0,
'R', 0);
1100 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1101 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AlreadyPaid"), 0,
'L', 0);
1102 $y += $tab3_height - 2;
1103 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1104 $pdf->MultiCell(15, 3,
price($object->total_ttc), 0,
'R', 0);
1105 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1106 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"AmountExpected"), 0,
'L', 0);
1107 $y += $tab3_height - 2;
1108 $remaintopay = $object->total_ttc - $totalpaid;
1109 $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
1110 $pdf->MultiCell(15, 3,
price($remaintopay), 0,
'R', 0);
1111 $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
1112 $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv(
"RemainderToPay"), 0,
'L', 0);
1115 $this->error = $this->
db->lasterror();
1130 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1132 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1133 return pdf_pagefoot($pdf, $outputlangs,
'EXPENSEREPORT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);