180 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
183 global $user, $langs,
$conf, $hookmanager, $mysoc, $nblines;
185 if (!is_object($outputlangs)) {
186 $outputlangs = $langs;
190 $outputlangs->charset_output =
'ISO-8859-1';
194 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
196 $nblines = count(
$object->lines);
199 $realpatharray = array();
201 for ($i = 0; $i < $nblines; $i++) {
202 if (empty(
$object->lines[$i]->fk_product)) {
206 $objphoto =
new Product($this->db);
207 $objphoto->fetch(
$object->lines[$i]->fk_product);
210 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
211 $dir =
$conf->product->dir_output.
'/'.$pdir;
213 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
214 $dir =
$conf->product->dir_output.
'/'.$pdir;
217 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
219 if ($obj[
'photo_vignette']) {
220 $filename = $obj[
'photo_vignette'];
222 $filename = $obj[
'photo'];
225 $filename = $obj[
'photo'];
227 $realpath = $dir.$filename;
232 $realpatharray[$i] = $realpath;
236 if (count($realpatharray) == 0) {
237 $this->posxpicture = $this->posxtva;
240 if (
$conf->fournisseur->commande->dir_output) {
244 $amount_credit_notes_included = 0;
245 $amount_deposits_included = 0;
251 $dir =
$conf->fournisseur->commande->dir_output;
252 $file = $dir.
"/SPECIMEN.pdf";
256 $dir =
$conf->fournisseur->commande->dir_output.
'/'.$objectref;
257 $file = $dir.
"/".$objectref.
".pdf";
259 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
263 if (!file_exists($dir)) {
265 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
270 if (file_exists($dir)) {
272 if (!is_object($hookmanager)) {
273 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
276 $hookmanager->initHooks(array(
'pdfgeneration'));
277 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
279 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
281 $nblines = count(
$object->lines);
285 $heightforinfotot = 50;
287 $heightforfooter = $this->marge_basse + 8;
289 $heightforfooter += 6;
291 $pdf->setAutoPageBreak(
true, 0);
293 if (class_exists(
'TCPDF')) {
294 $pdf->setPrintHeader(
false);
295 $pdf->setPrintFooter(
false);
300 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
301 $tplidx = $pdf->importPage(1);
306 $pdf->SetDrawColor(128, 128, 128);
308 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
309 $pdf->SetSubject($outputlangs->transnoentities(
"PurchaseOrder"));
310 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
311 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
313 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PurchaseOrder").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
315 $pdf->SetCompression(
false);
319 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
322 for ($i = 0; $i < $nblines; $i++) {
323 if (
$object->lines[$i]->remise_percent) {
324 $this->atleastonediscount++;
327 if (empty($this->atleastonediscount)) {
328 $delta = ($this->postotalht - $this->posxdiscount);
329 $this->posxpicture += $delta;
330 $this->posxtva += $delta;
331 $this->posxup += $delta;
332 $this->posxqty += $delta;
333 $this->posxunit += $delta;
334 $this->posxdiscount += $delta;
340 if (!empty($tplidx)) {
341 $pdf->useTemplate($tplidx);
345 $pdf->SetFont(
'',
'', $default_font_size - 1);
346 $pdf->MultiCell(0, 3,
'');
347 $pdf->SetTextColor(0, 0, 0);
349 $tab_top = 90 + $top_shift;
350 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
353 if (isModEnabled(
'incoterm')) {
354 $desc_incoterms =
$object->getIncotermsForPDF();
355 if ($desc_incoterms) {
358 $pdf->SetFont(
'',
'', $default_font_size - 1);
359 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
360 $nexY = $pdf->GetY();
361 $height_incoterms = $nexY - $tab_top;
364 $pdf->SetDrawColor(192, 192, 192);
365 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
367 $tab_top = $nexY + 6;
372 if (!empty(
$object->note_public)) {
375 $pdf->SetFont(
'',
'', $default_font_size - 1);
377 $nexY = $pdf->GetY();
378 $height_note = $nexY - $tab_top;
381 $pdf->SetDrawColor(192, 192, 192);
382 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
384 $tab_top = $nexY + 6;
387 $iniY = $tab_top + 7;
388 $curY = $tab_top + 7;
389 $nexY = $tab_top + 7;
392 for ($i = 0; $i < $nblines; $i++) {
394 $pdf->SetFont(
'',
'', $default_font_size - 1);
395 $pdf->SetTextColor(0, 0, 0);
398 $imglinesize = array();
399 if (!empty($realpatharray[$i])) {
403 $pdf->setTopMargin($tab_top_newpage);
404 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
405 $pageposbefore = $pdf->getPage();
407 $showpricebeforepagebreak = 1;
409 $posYAfterDescription = 0;
412 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
413 $pdf->AddPage(
'',
'',
true);
414 if (!empty($tplidx)) {
415 $pdf->useTemplate($tplidx);
420 $pdf->setPage($pageposbefore + 1);
422 $curY = $tab_top_newpage;
426 $showpricebeforepagebreak = 1;
428 $showpricebeforepagebreak = 0;
432 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
433 $curX = $this->posxpicture - 1;
434 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
436 $posYAfterImage = $curY + $imglinesize[
'height'];
439 $curX = $this->posxdesc - 1;
440 $showpricebeforepagebreak = 1;
442 $pdf->startTransaction();
443 if ($posYAfterImage > 0) {
444 $descWidth = $this->posxpicture - $curX;
446 $descWidth = $this->posxtva - $curX;
448 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
450 $pageposafter = $pdf->getPage();
451 if ($pageposafter > $pageposbefore) {
452 $pdf->rollbackTransaction(
true);
453 $pageposafter = $pageposbefore;
455 $pdf->setPageOrientation(
'',
true, $heightforfooter);
456 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
457 $posyafter = $pdf->GetY();
458 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
459 if ($i == ($nblines - 1)) {
460 $pdf->AddPage(
'',
'',
true);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
467 $pdf->setPage($pageposafter + 1);
473 $showpricebeforepagebreak = 1;
475 $showpricebeforepagebreak = 0;
479 $pdf->commitTransaction();
482 $nexY = $pdf->GetY();
483 $pageposafter = $pdf->getPage();
484 $pdf->setPage($pageposbefore);
485 $pdf->setTopMargin($this->marge_haute);
486 $pdf->setPageOrientation(
'',
true, 0);
489 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
490 $pdf->setPage($pageposafter);
491 $curY = $tab_top_newpage;
494 $pdf->SetFont(
'',
'', $default_font_size - 1);
499 $pdf->SetXY($this->posxtva, $curY);
500 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0,
'R');
504 if (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE')) {
506 $pdf->SetXY($this->posxup, $curY);
507 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
512 $pdf->SetXY($this->posxqty, $curY);
513 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
518 $pdf->SetXY($this->posxunit, $curY);
519 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
523 $pdf->SetXY($this->posxdiscount, $curY);
524 if (
$object->lines[$i]->remise_percent) {
526 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0,
'R');
530 if (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN')) {
532 $pdf->SetXY($this->postotalht, $curY);
533 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
537 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
538 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
540 $tvaligne =
$object->lines[$i]->total_tva;
543 $localtax1ligne =
$object->lines[$i]->total_localtax1;
544 $localtax2ligne =
$object->lines[$i]->total_localtax2;
545 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
546 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
547 $localtax1_type =
$object->lines[$i]->localtax1_type;
548 $localtax2_type =
$object->lines[$i]->localtax2_type;
561 $vatrate = (string)
$object->lines[$i]->tva_tx;
564 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
565 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
567 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
568 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
572 if ($localtax1_type && $localtax1ligne != 0) {
573 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
574 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
576 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
579 if ($localtax2_type && $localtax2ligne != 0) {
580 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
581 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
583 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
587 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
592 if (!isset($this->tva[$vatrate])) {
593 $this->tva[$vatrate] = 0;
595 $this->tva[$vatrate] += $tvaligne;
596 $vatcode =
$object->lines[$i]->vat_src_code;
597 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
598 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
600 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
602 if ($posYAfterImage > $posYAfterDescription) {
603 $nexY = $posYAfterImage;
608 $pdf->setPage($pageposafter);
609 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
611 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
612 $pdf->SetLineStyle(array(
'dash' => 0));
618 while ($pagenb < $pageposafter) {
619 $pdf->setPage($pagenb);
621 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
623 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
627 $pdf->setPage($pagenb);
628 $pdf->setPageOrientation(
'',
true, 0);
632 if (!empty($tplidx)) {
633 $pdf->useTemplate($tplidx);
636 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
638 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
640 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
645 if (!empty($tplidx)) {
646 $pdf->useTemplate($tplidx);
657 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
658 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
660 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
661 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
671 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
677 if (method_exists($pdf,
'AliasNbPages')) {
678 $pdf->AliasNbPages();
683 $pdf->Output($file,
'F');
686 $hookmanager->initHooks(array(
'pdfgeneration'));
687 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
689 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
691 $this->error = $hookmanager->error;
692 $this->errors = $hookmanager->errors;
697 $this->result = array(
'fullpath' => $file);
701 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
705 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
806 global
$conf, $mysoc;
812 $pdf->SetFont(
'',
'', $default_font_size - 1);
817 if ($this->page_largeur < 210) {
820 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
826 $pdf->SetFillColor(255, 255, 255);
827 $pdf->SetXY($col1x, $tab2_top);
828 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
830 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
831 $pdf->SetXY($col2x, $tab2_top);
832 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R',
true);
835 $pdf->SetFillColor(248, 248, 248);
837 $this->atleastoneratenotnull = 0;
838 foreach ($this->tva as $tvakey => $tvaval) {
840 $this->atleastoneratenotnull++;
843 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
847 if (preg_match(
'/\*/', $tvakey)) {
848 $tvakey = str_replace(
'*',
'', $tvakey);
849 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
852 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
853 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
854 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
856 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
857 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
860 if (!$this->atleastoneratenotnull) {
862 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
863 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L',
true);
865 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
866 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R',
true);
871 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
872 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L',
true);
873 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
874 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R',
true);
880 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
881 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L',
true);
882 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
883 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R',
true);
889 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
890 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
894 foreach ($localtax_rate as $tvakey => $tvaval) {
899 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
902 if (preg_match(
'/\*/', (
string) $tvakey)) {
903 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
904 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
906 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
907 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
908 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
910 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
911 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
919 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
920 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
924 foreach ($localtax_rate as $tvakey => $tvaval) {
929 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
932 if (preg_match(
'/\*/', (
string) $tvakey)) {
933 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
934 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
936 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
937 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
938 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
940 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
941 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R',
true);
949 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
950 $pdf->SetTextColor(0, 0, 60);
951 $pdf->SetFillColor(224, 224, 224);
952 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
954 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
955 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
956 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R',
true);
957 $pdf->SetFont(
'',
'', $default_font_size - 1);
958 $pdf->SetTextColor(0, 0, 0);
960 $creditnoteamount = 0;
965 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
970 if ($deja_regle > 0) {
974 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
975 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L',
false);
976 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
977 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R',
false);
980 $pdf->SetTextColor(0, 0, 60);
981 $pdf->SetFillColor(224, 224, 224);
982 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
986 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R',
true);
988 $pdf->SetFont(
'',
'', $default_font_size - 1);
989 $pdf->SetTextColor(0, 0, 0);
993 return ($tab2_top + ($tab2_hl * $index));
1010 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1020 $currency = !empty($currency) ? $currency :
$conf->currency;
1024 $pdf->SetTextColor(0, 0, 0);
1025 $pdf->SetFont(
'',
'', $default_font_size - 2);
1027 if (empty($hidetop)) {
1028 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1029 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1030 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1034 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1038 $pdf->SetDrawColor(128, 128, 128);
1039 $pdf->SetFont(
'',
'', $default_font_size - 1);
1042 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1044 if (empty($hidetop)) {
1045 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1047 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1048 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1052 $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1053 if (empty($hidetop)) {
1054 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1055 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1059 $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
1060 if (empty($hidetop)) {
1061 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1062 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1065 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1066 if (empty($hidetop)) {
1067 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1068 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1072 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1073 if (empty($hidetop)) {
1074 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1075 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1079 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1080 if (empty($hidetop)) {
1081 if ($this->atleastonediscount) {
1082 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1083 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1087 if ($this->atleastonediscount) {
1088 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1090 if (empty($hidetop)) {
1091 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1092 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1108 global $langs,
$conf, $mysoc;
1110 $ltrdirection =
'L';
1111 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1112 $ltrdirection =
'R';
1116 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1130 $pdf->SetTextColor(0, 0, 60);
1131 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1135 $posx = $this->page_largeur - $this->marge_droite - 100;
1136 $posy = $this->marge_haute;
1138 $pdf->SetXY($this->marge_gauche, $posy);
1142 if ($this->emetteur->logo) {
1143 $logodir =
$conf->mycompany->dir_output;
1144 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1145 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1148 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1150 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1152 if (is_readable($logo)) {
1154 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1156 $pdf->SetTextColor(200, 0, 0);
1157 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1158 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1159 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1162 $text = $this->emetteur->name;
1163 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1167 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1168 $pdf->SetXY($posx, $posy);
1169 $pdf->SetTextColor(0, 0, 60);
1170 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1171 if (
$object->status == $object::STATUS_DRAFT) {
1172 $pdf->SetTextColor(128, 0, 0);
1173 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1175 $pdf->MultiCell($w, 3, $title,
'',
'R');
1180 $pdf->SetFont(
'',
'B', $default_font_size);
1181 $pdf->SetXY($posx, $posy);
1182 $pdf->SetTextColor(0, 0, 60);
1183 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1187 $pdf->SetFont(
'',
'', $default_font_size - 1);
1191 if (!empty(
$object->project->ref)) {
1193 $pdf->SetXY($posx, $posy);
1194 $pdf->SetTextColor(0, 0, 60);
1195 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1201 if (!empty(
$object->project->ref)) {
1202 $outputlangs->load(
"projects");
1204 $pdf->SetXY($posx, $posy);
1205 $langs->load(
"projects");
1206 $pdf->SetTextColor(0, 0, 60);
1207 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1211 if (!empty(
$object->date_commande)) {
1213 $pdf->SetXY($posx, $posy);
1214 $pdf->SetTextColor(0, 0, 60);
1215 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1225 $pdf->SetTextColor(0, 0, 60);
1226 $usehourmin =
'day';
1228 $usehourmin =
'dayhour';
1230 if (!empty(
$object->delivery_date)) {
1232 $pdf->SetXY($posx - 90, $posy);
1233 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1236 if (
$object->thirdparty->code_fournisseur) {
1238 $pdf->SetXY($posx, $posy);
1239 $pdf->SetTextColor(0, 0, 60);
1240 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1245 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1246 if (count($arrayidcontact) > 0) {
1247 $usertmp =
new User($this->db);
1248 $usertmp->fetch($arrayidcontact[0]);
1250 $pdf->SetXY($posx, $posy);
1251 $pdf->SetTextColor(0, 0, 60);
1252 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1257 $pdf->SetTextColor(0, 0, 60);
1261 $current_y = $pdf->getY();
1263 if ($current_y < $pdf->getY()) {
1264 $top_shift = $pdf->getY() - $current_y;
1269 $carac_emetteur =
'';
1271 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1272 if (count($arrayidcontact) > 0) {
1273 $object->fetch_user($arrayidcontact[0]);
1274 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1275 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1277 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1281 $carac_emetteur .=
"\n";
1287 $posy = 42 + $top_shift;
1288 $posx = $this->marge_gauche;
1290 $posx = $this->page_largeur - $this->marge_droite - 80;
1295 $pdf->SetTextColor(0, 0, 0);
1296 $pdf->SetFont(
'',
'', $default_font_size - 2);
1297 $pdf->SetXY($posx, $posy - 5);
1298 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetFillColor(230, 230, 230);
1301 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1302 $pdf->SetTextColor(0, 0, 60);
1305 $pdf->SetXY($posx + 2, $posy + 3);
1306 $pdf->SetFont(
'',
'B', $default_font_size);
1307 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1308 $posy = $pdf->getY();
1311 $pdf->SetXY($posx + 2, $posy);
1312 $pdf->SetFont(
'',
'', $default_font_size - 1);
1313 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1317 $usecontact =
false;
1318 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1319 if (count($arrayidcontact) > 0) {
1321 $result =
$object->fetch_contact($arrayidcontact[0]);
1325 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1326 $thirdparty =
$object->contact;
1328 $thirdparty =
$object->thirdparty;
1337 if ($this->page_largeur < 210) {
1340 $posy = 42 + $top_shift;
1341 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1343 $posx = $this->marge_gauche;
1347 $pdf->SetTextColor(0, 0, 0);
1348 $pdf->SetFont(
'',
'', $default_font_size - 2);
1349 $pdf->SetXY($posx + 2, $posy - 5);
1350 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1351 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1354 $pdf->SetXY($posx + 2, $posy + 3);
1355 $pdf->SetFont(
'',
'B', $default_font_size);
1357 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1359 $posy = $pdf->getY();
1362 $pdf->SetFont(
'',
'', $default_font_size - 1);
1363 $pdf->SetXY($posx + 2, $posy);
1365 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);