173 public function write_file(
$object, $outputlangs =
null, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
176 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
178 if (!is_object($outputlangs)) {
179 $outputlangs = $langs;
183 $outputlangs->charset_output =
'ISO-8859-1';
187 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
189 $nblines = count(
$object->lines);
192 $realpatharray = array();
194 for ($i = 0; $i < $nblines; $i++) {
195 if (empty(
$object->lines[$i]->fk_product)) {
199 $objphoto =
new Product($this->db);
200 $objphoto->fetch(
$object->lines[$i]->fk_product);
203 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
204 $dir = $conf->product->dir_output.
'/'.$pdir;
206 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
207 $dir = $conf->product->dir_output.
'/'.$pdir;
210 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
212 if ($obj[
'photo_vignette']) {
213 $filename = $obj[
'photo_vignette'];
215 $filename = $obj[
'photo'];
218 $filename = $obj[
'photo'];
220 $realpath = $dir.$filename;
225 $realpatharray[$i] = $realpath;
229 if (count($realpatharray) == 0) {
230 $this->posxpicture = $this->posxtva;
233 if ($conf->fournisseur->commande->dir_output) {
237 $amount_credit_notes_included = 0;
238 $amount_deposits_included = 0;
244 $dir = $conf->fournisseur->commande->dir_output;
245 $file = $dir.
"/SPECIMEN.pdf";
249 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
250 $file = $dir.
"/".$objectref.
".pdf";
252 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
256 if (!file_exists($dir)) {
258 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
263 if (file_exists($dir)) {
265 if (!is_object($hookmanager)) {
266 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
269 $hookmanager->initHooks(array(
'pdfgeneration'));
270 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
272 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
274 $nblines = count(
$object->lines);
278 $heightforinfotot = 50;
279 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
280 $heightforfooter = $this->marge_basse + 8;
282 $heightforfooter += 6;
284 $pdf->SetAutoPageBreak(1, 0);
286 if (class_exists(
'TCPDF')) {
287 $pdf->setPrintHeader(
false);
288 $pdf->setPrintFooter(
false);
293 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
294 $tplidx = $pdf->importPage(1);
299 $pdf->SetDrawColor(128, 128, 128);
301 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
302 $pdf->SetSubject($outputlangs->transnoentities(
"PurchaseOrder"));
303 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
304 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
306 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PurchaseOrder").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
308 $pdf->SetCompression(
false);
312 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
315 for ($i = 0; $i < $nblines; $i++) {
316 if (
$object->lines[$i]->remise_percent) {
317 $this->atleastonediscount++;
320 if (empty($this->atleastonediscount)) {
321 $delta = ($this->postotalht - $this->posxdiscount);
322 $this->posxpicture += $delta;
323 $this->posxtva += $delta;
324 $this->posxup += $delta;
325 $this->posxqty += $delta;
326 $this->posxunit += $delta;
327 $this->posxdiscount += $delta;
333 if (!empty($tplidx)) {
334 $pdf->useTemplate($tplidx);
338 $pdf->SetFont(
'',
'', $default_font_size - 1);
339 $pdf->MultiCell(0, 3,
'');
340 $pdf->SetTextColor(0, 0, 0);
342 $tab_top = 90 + $top_shift;
343 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
346 if (isModEnabled(
'incoterm')) {
347 $desc_incoterms =
$object->getIncotermsForPDF();
348 if ($desc_incoterms) {
351 $pdf->SetFont(
'',
'', $default_font_size - 1);
352 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
353 $nexY = $pdf->GetY();
354 $height_incoterms = $nexY - $tab_top;
357 $pdf->SetDrawColor(192, 192, 192);
358 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
360 $tab_top = $nexY + 6;
365 if (!empty(
$object->note_public)) {
368 $pdf->SetFont(
'',
'', $default_font_size - 1);
370 $nexY = $pdf->GetY();
371 $height_note = $nexY - $tab_top;
374 $pdf->SetDrawColor(192, 192, 192);
375 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
377 $tab_top = $nexY + 6;
380 $iniY = $tab_top + 7;
381 $curY = $tab_top + 7;
382 $nexY = $tab_top + 7;
385 for ($i = 0; $i < $nblines; $i++) {
387 $pdf->SetFont(
'',
'', $default_font_size - 1);
388 $pdf->SetTextColor(0, 0, 0);
391 $imglinesize = array();
392 if (!empty($realpatharray[$i])) {
396 $pdf->setTopMargin($tab_top_newpage);
397 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
398 $pageposbefore = $pdf->getPage();
400 $showpricebeforepagebreak = 1;
402 $posYAfterDescription = 0;
405 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
406 $pdf->AddPage(
'',
'',
true);
407 if (!empty($tplidx)) {
408 $pdf->useTemplate($tplidx);
413 $pdf->setPage($pageposbefore + 1);
415 $curY = $tab_top_newpage;
419 $showpricebeforepagebreak = 1;
421 $showpricebeforepagebreak = 0;
425 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
426 $curX = $this->posxpicture - 1;
427 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
429 $posYAfterImage = $curY + $imglinesize[
'height'];
432 $curX = $this->posxdesc - 1;
433 $showpricebeforepagebreak = 1;
435 $pdf->startTransaction();
436 if ($posYAfterImage > 0) {
437 $descWidth = $this->posxpicture - $curX;
439 $descWidth = $this->posxtva - $curX;
441 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
443 $pageposafter = $pdf->getPage();
444 if ($pageposafter > $pageposbefore) {
445 $pdf->rollbackTransaction(
true);
446 $pageposafter = $pageposbefore;
448 $pdf->setPageOrientation(
'', 1, $heightforfooter);
449 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
450 $posyafter = $pdf->GetY();
451 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
452 if ($i == ($nblines - 1)) {
453 $pdf->AddPage(
'',
'',
true);
454 if (!empty($tplidx)) {
455 $pdf->useTemplate($tplidx);
460 $pdf->setPage($pageposafter + 1);
466 $showpricebeforepagebreak = 1;
468 $showpricebeforepagebreak = 0;
472 $pdf->commitTransaction();
475 $nexY = $pdf->GetY();
476 $pageposafter = $pdf->getPage();
477 $pdf->setPage($pageposbefore);
478 $pdf->setTopMargin($this->marge_haute);
479 $pdf->setPageOrientation(
'', 1, 0);
482 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
483 $pdf->setPage($pageposafter);
484 $curY = $tab_top_newpage;
487 $pdf->SetFont(
'',
'', $default_font_size - 1);
492 $pdf->SetXY($this->posxtva, $curY);
493 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0,
'R');
497 if (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE')) {
499 $pdf->SetXY($this->posxup, $curY);
500 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
505 $pdf->SetXY($this->posxqty, $curY);
506 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
511 $pdf->SetXY($this->posxunit, $curY);
512 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
516 $pdf->SetXY($this->posxdiscount, $curY);
517 if (
$object->lines[$i]->remise_percent) {
519 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0,
'R');
523 if (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN')) {
525 $pdf->SetXY($this->postotalht, $curY);
526 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
530 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
531 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
533 $tvaligne =
$object->lines[$i]->total_tva;
536 $localtax1ligne =
$object->lines[$i]->total_localtax1;
537 $localtax2ligne =
$object->lines[$i]->total_localtax2;
538 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
539 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
540 $localtax1_type =
$object->lines[$i]->localtax1_type;
541 $localtax2_type =
$object->lines[$i]->localtax2_type;
554 $vatrate = (string)
$object->lines[$i]->tva_tx;
557 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
558 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
560 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
561 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
565 if ($localtax1_type && $localtax1ligne != 0) {
566 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
567 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
569 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
572 if ($localtax2_type && $localtax2ligne != 0) {
573 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
574 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
576 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
580 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
585 if (!isset($this->tva[$vatrate])) {
586 $this->tva[$vatrate] = 0;
588 $this->tva[$vatrate] += $tvaligne;
589 $vatcode =
$object->lines[$i]->vat_src_code;
590 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
591 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
593 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
595 if ($posYAfterImage > $posYAfterDescription) {
596 $nexY = $posYAfterImage;
601 $pdf->setPage($pageposafter);
602 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
604 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
605 $pdf->SetLineStyle(array(
'dash' => 0));
611 while ($pagenb < $pageposafter) {
612 $pdf->setPage($pagenb);
614 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
616 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
620 $pdf->setPage($pagenb);
621 $pdf->setPageOrientation(
'', 1, 0);
625 if (!empty($tplidx)) {
626 $pdf->useTemplate($tplidx);
629 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
631 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
633 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
638 if (!empty($tplidx)) {
639 $pdf->useTemplate($tplidx);
650 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
651 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
653 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
654 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
664 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
670 if (method_exists($pdf,
'AliasNbPages')) {
671 $pdf->AliasNbPages();
676 $pdf->Output($file,
'F');
679 $hookmanager->initHooks(array(
'pdfgeneration'));
680 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
682 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
684 $this->error = $hookmanager->error;
685 $this->errors = $hookmanager->errors;
690 $this->result = array(
'fullpath' => $file);
694 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
698 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
799 global $conf, $mysoc;
805 $pdf->SetFont(
'',
'', $default_font_size - 1);
810 if ($this->page_largeur < 210) {
813 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
819 $pdf->SetFillColor(255, 255, 255);
820 $pdf->SetXY($col1x, $tab2_top);
821 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
823 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
824 $pdf->SetXY($col2x, $tab2_top);
825 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
828 $pdf->SetFillColor(248, 248, 248);
830 $this->atleastoneratenotnull = 0;
831 foreach ($this->tva as $tvakey => $tvaval) {
833 $this->atleastoneratenotnull++;
836 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
840 if (preg_match(
'/\*/', $tvakey)) {
841 $tvakey = str_replace(
'*',
'', $tvakey);
842 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
845 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
846 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
847 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
849 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
850 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
853 if (!$this->atleastoneratenotnull) {
855 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
856 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
858 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
859 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
864 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
865 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
866 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
867 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
873 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
874 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
875 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
876 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
882 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
883 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
887 foreach ($localtax_rate as $tvakey => $tvaval) {
892 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
895 if (preg_match(
'/\*/', (
string) $tvakey)) {
896 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
897 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
899 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
900 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
901 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
903 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
904 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
912 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
913 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
917 foreach ($localtax_rate as $tvakey => $tvaval) {
922 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925 if (preg_match(
'/\*/', (
string) $tvakey)) {
926 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
927 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
929 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
930 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
931 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
933 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
934 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
942 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
943 $pdf->SetTextColor(0, 0, 60);
944 $pdf->SetFillColor(224, 224, 224);
945 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
947 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
948 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
949 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
950 $pdf->SetFont(
'',
'', $default_font_size - 1);
951 $pdf->SetTextColor(0, 0, 0);
953 $creditnoteamount = 0;
958 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
963 if ($deja_regle > 0) {
967 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
968 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
969 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
973 $pdf->SetTextColor(0, 0, 60);
974 $pdf->SetFillColor(224, 224, 224);
975 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
976 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
978 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
979 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
981 $pdf->SetFont(
'',
'', $default_font_size - 1);
982 $pdf->SetTextColor(0, 0, 0);
986 return ($tab2_top + ($tab2_hl * $index));
1003 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1013 $currency = !empty($currency) ? $currency : $conf->currency;
1017 $pdf->SetTextColor(0, 0, 0);
1018 $pdf->SetFont(
'',
'', $default_font_size - 2);
1020 if (empty($hidetop)) {
1021 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1022 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1023 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1027 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1031 $pdf->SetDrawColor(128, 128, 128);
1032 $pdf->SetFont(
'',
'', $default_font_size - 1);
1035 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1037 if (empty($hidetop)) {
1038 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1040 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1041 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1045 $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1046 if (empty($hidetop)) {
1047 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1048 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1052 $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
1053 if (empty($hidetop)) {
1054 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1055 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1058 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1059 if (empty($hidetop)) {
1060 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1061 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1065 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1066 if (empty($hidetop)) {
1067 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1068 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1072 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1073 if (empty($hidetop)) {
1074 if ($this->atleastonediscount) {
1075 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1076 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1080 if ($this->atleastonediscount) {
1081 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1083 if (empty($hidetop)) {
1084 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1085 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1101 global $langs, $conf, $mysoc;
1103 $ltrdirection =
'L';
1104 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1105 $ltrdirection =
'R';
1109 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1123 $pdf->SetTextColor(0, 0, 60);
1124 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1128 $posx = $this->page_largeur - $this->marge_droite - 100;
1129 $posy = $this->marge_haute;
1131 $pdf->SetXY($this->marge_gauche, $posy);
1135 if ($this->emetteur->logo) {
1136 $logodir = $conf->mycompany->dir_output;
1137 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1138 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1141 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1143 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1145 if (is_readable($logo)) {
1147 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1149 $pdf->SetTextColor(200, 0, 0);
1150 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1151 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1152 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1155 $text = $this->emetteur->name;
1156 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1160 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1161 $pdf->SetXY($posx, $posy);
1162 $pdf->SetTextColor(0, 0, 60);
1163 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1164 if (
$object->status == $object::STATUS_DRAFT) {
1165 $pdf->SetTextColor(128, 0, 0);
1166 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1168 $pdf->MultiCell($w, 3, $title,
'',
'R');
1173 $pdf->SetFont(
'',
'B', $default_font_size);
1174 $pdf->SetXY($posx, $posy);
1175 $pdf->SetTextColor(0, 0, 60);
1176 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1180 $pdf->SetFont(
'',
'', $default_font_size - 1);
1184 if (!empty(
$object->project->ref)) {
1186 $pdf->SetXY($posx, $posy);
1187 $pdf->SetTextColor(0, 0, 60);
1188 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1194 if (!empty(
$object->project->ref)) {
1195 $outputlangs->load(
"projects");
1197 $pdf->SetXY($posx, $posy);
1198 $langs->load(
"projects");
1199 $pdf->SetTextColor(0, 0, 60);
1200 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1204 if (!empty(
$object->date_commande)) {
1206 $pdf->SetXY($posx, $posy);
1207 $pdf->SetTextColor(0, 0, 60);
1208 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1218 $pdf->SetTextColor(0, 0, 60);
1219 $usehourmin =
'day';
1221 $usehourmin =
'dayhour';
1223 if (!empty(
$object->delivery_date)) {
1225 $pdf->SetXY($posx - 90, $posy);
1226 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1229 if (
$object->thirdparty->code_fournisseur) {
1231 $pdf->SetXY($posx, $posy);
1232 $pdf->SetTextColor(0, 0, 60);
1233 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1238 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1239 if (count($arrayidcontact) > 0) {
1240 $usertmp =
new User($this->db);
1241 $usertmp->fetch($arrayidcontact[0]);
1243 $pdf->SetXY($posx, $posy);
1244 $pdf->SetTextColor(0, 0, 60);
1245 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1250 $pdf->SetTextColor(0, 0, 60);
1254 $current_y = $pdf->getY();
1256 if ($current_y < $pdf->getY()) {
1257 $top_shift = $pdf->getY() - $current_y;
1262 $carac_emetteur =
'';
1264 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1265 if (count($arrayidcontact) > 0) {
1266 $object->fetch_user($arrayidcontact[0]);
1267 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1268 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1270 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1274 $carac_emetteur .=
"\n";
1280 $posy = 42 + $top_shift;
1281 $posx = $this->marge_gauche;
1283 $posx = $this->page_largeur - $this->marge_droite - 80;
1288 $pdf->SetTextColor(0, 0, 0);
1289 $pdf->SetFont(
'',
'', $default_font_size - 2);
1290 $pdf->SetXY($posx, $posy - 5);
1291 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1292 $pdf->SetXY($posx, $posy);
1293 $pdf->SetFillColor(230, 230, 230);
1294 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1295 $pdf->SetTextColor(0, 0, 60);
1298 $pdf->SetXY($posx + 2, $posy + 3);
1299 $pdf->SetFont(
'',
'B', $default_font_size);
1300 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1301 $posy = $pdf->getY();
1304 $pdf->SetXY($posx + 2, $posy);
1305 $pdf->SetFont(
'',
'', $default_font_size - 1);
1306 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1310 $usecontact =
false;
1311 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1312 if (count($arrayidcontact) > 0) {
1314 $result =
$object->fetch_contact($arrayidcontact[0]);
1318 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1319 $thirdparty =
$object->contact;
1321 $thirdparty =
$object->thirdparty;
1330 if ($this->page_largeur < 210) {
1333 $posy = 42 + $top_shift;
1334 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1336 $posx = $this->marge_gauche;
1340 $pdf->SetTextColor(0, 0, 0);
1341 $pdf->SetFont(
'',
'', $default_font_size - 2);
1342 $pdf->SetXY($posx + 2, $posy - 5);
1343 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1344 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1347 $pdf->SetXY($posx + 2, $posy + 3);
1348 $pdf->SetFont(
'',
'B', $default_font_size);
1350 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1352 $posy = $pdf->getY();
1355 $pdf->SetFont(
'',
'', $default_font_size - 1);
1356 $pdf->SetXY($posx + 2, $posy);
1358 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);