179 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
182 global $user, $langs,
$conf, $hookmanager, $mysoc, $nblines;
184 if (!is_object($outputlangs)) {
185 $outputlangs = $langs;
189 $outputlangs->charset_output =
'ISO-8859-1';
193 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
195 $nblines = count(
$object->lines);
198 $realpatharray = array();
200 for ($i = 0; $i < $nblines; $i++) {
201 if (empty(
$object->lines[$i]->fk_product)) {
205 $objphoto =
new Product($this->db);
206 $objphoto->fetch(
$object->lines[$i]->fk_product);
209 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
210 $dir =
$conf->product->dir_output.
'/'.$pdir;
212 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
213 $dir =
$conf->product->dir_output.
'/'.$pdir;
216 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
218 if ($obj[
'photo_vignette']) {
219 $filename = $obj[
'photo_vignette'];
221 $filename = $obj[
'photo'];
224 $filename = $obj[
'photo'];
226 $realpath = $dir.$filename;
231 $realpatharray[$i] = $realpath;
235 if (count($realpatharray) == 0) {
236 $this->posxpicture = $this->posxtva;
239 if (
$conf->fournisseur->commande->dir_output) {
243 $amount_credit_notes_included = 0;
244 $amount_deposits_included = 0;
250 $dir =
$conf->fournisseur->commande->dir_output;
251 $file = $dir.
"/SPECIMEN.pdf";
255 $dir =
$conf->fournisseur->commande->dir_output.
'/'.$objectref;
256 $file = $dir.
"/".$objectref.
".pdf";
258 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
262 if (!file_exists($dir)) {
264 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
269 if (file_exists($dir)) {
271 if (!is_object($hookmanager)) {
272 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
275 $hookmanager->initHooks(array(
'pdfgeneration'));
276 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
278 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
280 $nblines = count(
$object->lines);
284 $heightforinfotot = 50;
286 $heightforfooter = $this->marge_basse + 8;
288 $heightforfooter += 6;
290 $pdf->SetAutoPageBreak(1, 0);
292 if (class_exists(
'TCPDF')) {
293 $pdf->setPrintHeader(
false);
294 $pdf->setPrintFooter(
false);
299 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
300 $tplidx = $pdf->importPage(1);
305 $pdf->SetDrawColor(128, 128, 128);
307 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
308 $pdf->SetSubject($outputlangs->transnoentities(
"PurchaseOrder"));
309 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
310 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
312 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PurchaseOrder").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
314 $pdf->SetCompression(
false);
318 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
321 for ($i = 0; $i < $nblines; $i++) {
322 if (
$object->lines[$i]->remise_percent) {
323 $this->atleastonediscount++;
326 if (empty($this->atleastonediscount)) {
327 $delta = ($this->postotalht - $this->posxdiscount);
328 $this->posxpicture += $delta;
329 $this->posxtva += $delta;
330 $this->posxup += $delta;
331 $this->posxqty += $delta;
332 $this->posxunit += $delta;
333 $this->posxdiscount += $delta;
339 if (!empty($tplidx)) {
340 $pdf->useTemplate($tplidx);
344 $pdf->SetFont(
'',
'', $default_font_size - 1);
345 $pdf->MultiCell(0, 3,
'');
346 $pdf->SetTextColor(0, 0, 0);
348 $tab_top = 90 + $top_shift;
349 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
352 if (isModEnabled(
'incoterm')) {
353 $desc_incoterms =
$object->getIncotermsForPDF();
354 if ($desc_incoterms) {
357 $pdf->SetFont(
'',
'', $default_font_size - 1);
358 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
359 $nexY = $pdf->GetY();
360 $height_incoterms = $nexY - $tab_top;
363 $pdf->SetDrawColor(192, 192, 192);
364 $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');
366 $tab_top = $nexY + 6;
371 if (!empty(
$object->note_public)) {
374 $pdf->SetFont(
'',
'', $default_font_size - 1);
376 $nexY = $pdf->GetY();
377 $height_note = $nexY - $tab_top;
380 $pdf->SetDrawColor(192, 192, 192);
381 $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');
383 $tab_top = $nexY + 6;
386 $iniY = $tab_top + 7;
387 $curY = $tab_top + 7;
388 $nexY = $tab_top + 7;
391 for ($i = 0; $i < $nblines; $i++) {
393 $pdf->SetFont(
'',
'', $default_font_size - 1);
394 $pdf->SetTextColor(0, 0, 0);
397 $imglinesize = array();
398 if (!empty($realpatharray[$i])) {
402 $pdf->setTopMargin($tab_top_newpage);
403 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
404 $pageposbefore = $pdf->getPage();
406 $showpricebeforepagebreak = 1;
408 $posYAfterDescription = 0;
411 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
412 $pdf->AddPage(
'',
'',
true);
413 if (!empty($tplidx)) {
414 $pdf->useTemplate($tplidx);
419 $pdf->setPage($pageposbefore + 1);
421 $curY = $tab_top_newpage;
425 $showpricebeforepagebreak = 1;
427 $showpricebeforepagebreak = 0;
431 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
432 $curX = $this->posxpicture - 1;
433 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
435 $posYAfterImage = $curY + $imglinesize[
'height'];
438 $curX = $this->posxdesc - 1;
439 $showpricebeforepagebreak = 1;
441 $pdf->startTransaction();
442 if ($posYAfterImage > 0) {
443 $descWidth = $this->posxpicture - $curX;
445 $descWidth = $this->posxtva - $curX;
447 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
449 $pageposafter = $pdf->getPage();
450 if ($pageposafter > $pageposbefore) {
451 $pdf->rollbackTransaction(
true);
452 $pageposafter = $pageposbefore;
454 $pdf->setPageOrientation(
'', 1, $heightforfooter);
455 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
456 $posyafter = $pdf->GetY();
457 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
458 if ($i == ($nblines - 1)) {
459 $pdf->AddPage(
'',
'',
true);
460 if (!empty($tplidx)) {
461 $pdf->useTemplate($tplidx);
466 $pdf->setPage($pageposafter + 1);
472 $showpricebeforepagebreak = 1;
474 $showpricebeforepagebreak = 0;
478 $pdf->commitTransaction();
481 $nexY = $pdf->GetY();
482 $pageposafter = $pdf->getPage();
483 $pdf->setPage($pageposbefore);
484 $pdf->setTopMargin($this->marge_haute);
485 $pdf->setPageOrientation(
'', 1, 0);
488 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
489 $pdf->setPage($pageposafter);
490 $curY = $tab_top_newpage;
493 $pdf->SetFont(
'',
'', $default_font_size - 1);
498 $pdf->SetXY($this->posxtva, $curY);
499 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0,
'R');
503 if (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE')) {
505 $pdf->SetXY($this->posxup, $curY);
506 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
511 $pdf->SetXY($this->posxqty, $curY);
512 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
517 $pdf->SetXY($this->posxunit, $curY);
518 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
522 $pdf->SetXY($this->posxdiscount, $curY);
523 if (
$object->lines[$i]->remise_percent) {
525 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0,
'R');
529 if (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN')) {
531 $pdf->SetXY($this->postotalht, $curY);
532 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
536 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
537 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
539 $tvaligne =
$object->lines[$i]->total_tva;
542 $localtax1ligne =
$object->lines[$i]->total_localtax1;
543 $localtax2ligne =
$object->lines[$i]->total_localtax2;
544 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
545 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
546 $localtax1_type =
$object->lines[$i]->localtax1_type;
547 $localtax2_type =
$object->lines[$i]->localtax2_type;
560 $vatrate = (string)
$object->lines[$i]->tva_tx;
563 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
564 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
566 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
567 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
571 if ($localtax1_type && $localtax1ligne != 0) {
572 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
573 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
575 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
578 if ($localtax2_type && $localtax2ligne != 0) {
579 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
580 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
582 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
586 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
591 if (!isset($this->tva[$vatrate])) {
592 $this->tva[$vatrate] = 0;
594 $this->tva[$vatrate] += $tvaligne;
595 $vatcode =
$object->lines[$i]->vat_src_code;
596 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
597 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
599 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
601 if ($posYAfterImage > $posYAfterDescription) {
602 $nexY = $posYAfterImage;
607 $pdf->setPage($pageposafter);
608 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
610 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
611 $pdf->SetLineStyle(array(
'dash' => 0));
617 while ($pagenb < $pageposafter) {
618 $pdf->setPage($pagenb);
620 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
622 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
626 $pdf->setPage($pagenb);
627 $pdf->setPageOrientation(
'', 1, 0);
631 if (!empty($tplidx)) {
632 $pdf->useTemplate($tplidx);
635 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
637 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
639 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
644 if (!empty($tplidx)) {
645 $pdf->useTemplate($tplidx);
656 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
657 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
659 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
660 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
670 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
676 if (method_exists($pdf,
'AliasNbPages')) {
677 $pdf->AliasNbPages();
682 $pdf->Output($file,
'F');
685 $hookmanager->initHooks(array(
'pdfgeneration'));
686 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
688 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
690 $this->error = $hookmanager->error;
691 $this->errors = $hookmanager->errors;
696 $this->result = array(
'fullpath' => $file);
700 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
704 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
805 global
$conf, $mysoc;
811 $pdf->SetFont(
'',
'', $default_font_size - 1);
816 if ($this->page_largeur < 210) {
819 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
825 $pdf->SetFillColor(255, 255, 255);
826 $pdf->SetXY($col1x, $tab2_top);
827 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
829 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
830 $pdf->SetXY($col2x, $tab2_top);
831 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
834 $pdf->SetFillColor(248, 248, 248);
836 $this->atleastoneratenotnull = 0;
837 foreach ($this->tva as $tvakey => $tvaval) {
839 $this->atleastoneratenotnull++;
842 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
846 if (preg_match(
'/\*/', $tvakey)) {
847 $tvakey = str_replace(
'*',
'', $tvakey);
848 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
851 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
852 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
853 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
855 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
856 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
859 if (!$this->atleastoneratenotnull) {
861 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
862 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
864 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
865 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
870 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
871 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
872 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
873 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
879 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
880 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
881 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
882 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
888 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
889 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
893 foreach ($localtax_rate as $tvakey => $tvaval) {
898 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
901 if (preg_match(
'/\*/', (
string) $tvakey)) {
902 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
903 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
905 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
906 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
907 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
909 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
910 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
918 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
919 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
923 foreach ($localtax_rate as $tvakey => $tvaval) {
928 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
931 if (preg_match(
'/\*/', (
string) $tvakey)) {
932 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
933 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
935 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
936 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
937 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
939 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
940 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
948 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
949 $pdf->SetTextColor(0, 0, 60);
950 $pdf->SetFillColor(224, 224, 224);
951 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
953 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
954 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
955 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
956 $pdf->SetFont(
'',
'', $default_font_size - 1);
957 $pdf->SetTextColor(0, 0, 0);
959 $creditnoteamount = 0;
964 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
969 if ($deja_regle > 0) {
973 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
974 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
975 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
976 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
979 $pdf->SetTextColor(0, 0, 60);
980 $pdf->SetFillColor(224, 224, 224);
981 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
982 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
984 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
985 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
987 $pdf->SetFont(
'',
'', $default_font_size - 1);
988 $pdf->SetTextColor(0, 0, 0);
992 return ($tab2_top + ($tab2_hl * $index));
1009 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1019 $currency = !empty($currency) ? $currency :
$conf->currency;
1023 $pdf->SetTextColor(0, 0, 0);
1024 $pdf->SetFont(
'',
'', $default_font_size - 2);
1026 if (empty($hidetop)) {
1027 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1028 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1029 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1033 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1037 $pdf->SetDrawColor(128, 128, 128);
1038 $pdf->SetFont(
'',
'', $default_font_size - 1);
1041 $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');
1043 if (empty($hidetop)) {
1044 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1046 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1047 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1051 $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1052 if (empty($hidetop)) {
1053 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1054 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1058 $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
1059 if (empty($hidetop)) {
1060 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1061 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1064 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1065 if (empty($hidetop)) {
1066 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1067 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1071 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1072 if (empty($hidetop)) {
1073 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1074 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1078 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1079 if (empty($hidetop)) {
1080 if ($this->atleastonediscount) {
1081 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1082 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1086 if ($this->atleastonediscount) {
1087 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1089 if (empty($hidetop)) {
1090 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1091 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1107 global $langs,
$conf, $mysoc;
1109 $ltrdirection =
'L';
1110 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1111 $ltrdirection =
'R';
1115 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1129 $pdf->SetTextColor(0, 0, 60);
1130 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1134 $posx = $this->page_largeur - $this->marge_droite - 100;
1135 $posy = $this->marge_haute;
1137 $pdf->SetXY($this->marge_gauche, $posy);
1141 if ($this->emetteur->logo) {
1142 $logodir =
$conf->mycompany->dir_output;
1143 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1144 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1147 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1149 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1151 if (is_readable($logo)) {
1153 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1155 $pdf->SetTextColor(200, 0, 0);
1156 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1157 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1158 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1161 $text = $this->emetteur->name;
1162 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1166 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1167 $pdf->SetXY($posx, $posy);
1168 $pdf->SetTextColor(0, 0, 60);
1169 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1170 if (
$object->status == $object::STATUS_DRAFT) {
1171 $pdf->SetTextColor(128, 0, 0);
1172 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1174 $pdf->MultiCell($w, 3, $title,
'',
'R');
1179 $pdf->SetFont(
'',
'B', $default_font_size);
1180 $pdf->SetXY($posx, $posy);
1181 $pdf->SetTextColor(0, 0, 60);
1182 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1186 $pdf->SetFont(
'',
'', $default_font_size - 1);
1190 if (!empty(
$object->project->ref)) {
1192 $pdf->SetXY($posx, $posy);
1193 $pdf->SetTextColor(0, 0, 60);
1194 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1200 if (!empty(
$object->project->ref)) {
1201 $outputlangs->load(
"projects");
1203 $pdf->SetXY($posx, $posy);
1204 $langs->load(
"projects");
1205 $pdf->SetTextColor(0, 0, 60);
1206 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1210 if (!empty(
$object->date_commande)) {
1212 $pdf->SetXY($posx, $posy);
1213 $pdf->SetTextColor(0, 0, 60);
1214 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1224 $pdf->SetTextColor(0, 0, 60);
1225 $usehourmin =
'day';
1227 $usehourmin =
'dayhour';
1229 if (!empty(
$object->delivery_date)) {
1231 $pdf->SetXY($posx - 90, $posy);
1232 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1235 if (
$object->thirdparty->code_fournisseur) {
1237 $pdf->SetXY($posx, $posy);
1238 $pdf->SetTextColor(0, 0, 60);
1239 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1244 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1245 if (count($arrayidcontact) > 0) {
1246 $usertmp =
new User($this->db);
1247 $usertmp->fetch($arrayidcontact[0]);
1249 $pdf->SetXY($posx, $posy);
1250 $pdf->SetTextColor(0, 0, 60);
1251 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1256 $pdf->SetTextColor(0, 0, 60);
1260 $current_y = $pdf->getY();
1262 if ($current_y < $pdf->getY()) {
1263 $top_shift = $pdf->getY() - $current_y;
1268 $carac_emetteur =
'';
1270 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1271 if (count($arrayidcontact) > 0) {
1272 $object->fetch_user($arrayidcontact[0]);
1273 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1274 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1276 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1280 $carac_emetteur .=
"\n";
1286 $posy = 42 + $top_shift;
1287 $posx = $this->marge_gauche;
1289 $posx = $this->page_largeur - $this->marge_droite - 80;
1294 $pdf->SetTextColor(0, 0, 0);
1295 $pdf->SetFont(
'',
'', $default_font_size - 2);
1296 $pdf->SetXY($posx, $posy - 5);
1297 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1298 $pdf->SetXY($posx, $posy);
1299 $pdf->SetFillColor(230, 230, 230);
1300 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1301 $pdf->SetTextColor(0, 0, 60);
1304 $pdf->SetXY($posx + 2, $posy + 3);
1305 $pdf->SetFont(
'',
'B', $default_font_size);
1306 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1307 $posy = $pdf->getY();
1310 $pdf->SetXY($posx + 2, $posy);
1311 $pdf->SetFont(
'',
'', $default_font_size - 1);
1312 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1316 $usecontact =
false;
1317 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1318 if (count($arrayidcontact) > 0) {
1320 $result =
$object->fetch_contact($arrayidcontact[0]);
1324 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1325 $thirdparty =
$object->contact;
1327 $thirdparty =
$object->thirdparty;
1336 if ($this->page_largeur < 210) {
1339 $posy = 42 + $top_shift;
1340 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1342 $posx = $this->marge_gauche;
1346 $pdf->SetTextColor(0, 0, 0);
1347 $pdf->SetFont(
'',
'', $default_font_size - 2);
1348 $pdf->SetXY($posx + 2, $posy - 5);
1349 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1350 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1353 $pdf->SetXY($posx + 2, $posy + 3);
1354 $pdf->SetFont(
'',
'B', $default_font_size);
1356 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1358 $posy = $pdf->getY();
1361 $pdf->SetFont(
'',
'', $default_font_size - 1);
1362 $pdf->SetXY($posx + 2, $posy);
1364 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);