147 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
150 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
152 if (!is_object($outputlangs)) {
153 $outputlangs = $langs;
157 $outputlangs->charset_output =
'ISO-8859-1';
161 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
163 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
164 global $outputlangsbis;
165 $outputlangsbis =
new Translate(
'', $conf);
166 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
167 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
170 $nblines = is_array($object->lines) ? count($object->lines) : 0;
174 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
178 $realpatharray = array();
179 $this->atleastonephoto =
false;
181 $objphoto =
new Product($this->db);
183 for ($i = 0; $i < $nblines; $i++) {
184 if (empty($object->lines[$i]->fk_product)) {
188 $objphoto->fetch($object->lines[$i]->fk_product);
191 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
192 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
194 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
195 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
199 foreach ($pdir as $midir) {
201 $dir = $conf->product->dir_output.
'/'.$midir;
203 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
205 if ($obj[
'photo_vignette']) {
206 $filename = $obj[
'photo_vignette'];
208 $filename = $obj[
'photo'];
211 $filename = $obj[
'photo'];
214 $realpath = $dir.$filename;
216 $this->atleastonephoto =
true;
221 if ($realpath && $arephoto) {
222 $realpatharray[$i] = $realpath;
229 if ($conf->stocktransfer->dir_output) {
230 $object->fetch_thirdparty();
235 if ($object->specimen) {
236 $dir = $conf->stocktransfer->multidir_output[$conf->entity];
237 $file = $dir.
"/SPECIMEN.pdf";
240 $dir = $conf->stocktransfer->multidir_output[$conf->entity].
"/".$object->element.
"/".$objectref;
241 $file = $dir.
"/".$objectref.
"-proforma.pdf";
244 if (!file_exists($dir)) {
246 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
251 if (file_exists($dir)) {
253 if (!is_object($hookmanager)) {
254 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
257 $hookmanager->initHooks(array(
'pdfgeneration'));
258 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
260 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
265 $pdf->SetAutoPageBreak(1, 0);
267 $heightforinfotot = 40;
268 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
269 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
271 if (class_exists(
'TCPDF')) {
272 $pdf->setPrintHeader(
false);
273 $pdf->setPrintFooter(
false);
278 $logodir = $conf->mycompany->dir_output;
279 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
280 $logodir = $conf->mycompany->multidir_output[$object->entity];
282 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
283 $tplidx = $pdf->importPage(1);
288 $pdf->SetDrawColor(128, 128, 128);
290 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
291 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
292 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
293 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
296 $pdf->SetCompression(
false);
299 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
302 foreach ($object->lines as $line) {
303 if ($line->remise_percent) {
304 $this->atleastonediscount =
true;
312 if (!empty($tplidx)) {
313 $pdf->useTemplate($tplidx);
316 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
317 $pdf->SetFont(
'',
'', $default_font_size - 1);
318 $pdf->MultiCell(0, 3,
'');
319 $pdf->SetTextColor(0, 0, 0);
322 $tab_top = 90 + $top_shift;
323 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
327 if ($conf->incoterm->enabled) {
328 $desc_incoterms = $object->getIncotermsForPDF();
329 if ($desc_incoterms) {
332 $pdf->SetFont(
'',
'', $default_font_size - 1);
333 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
334 $nexY = $pdf->GetY();
335 $height_incoterms = $nexY - $tab_top;
338 $pdf->SetDrawColor(192, 192, 192);
339 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
341 $tab_top = $nexY + 6;
346 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
349 if (is_object($object->thirdparty)) {
350 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
351 $salerepobj =
new User($this->db);
352 $salerepobj->fetch($salereparray[0][
'id']);
353 if (!empty($salerepobj->signature)) {
354 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
360 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
361 if (!empty($extranote)) {
365 $pagenb = $pdf->getPage();
367 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
368 $pageposbeforenote = $pagenb;
377 $pdf->startTransaction();
379 $pdf->SetFont(
'',
'', $default_font_size - 1);
380 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
382 $pageposafternote = $pdf->getPage();
383 $posyafter = $pdf->GetY();
385 if ($pageposafternote > $pageposbeforenote) {
386 $pdf->rollbackTransaction(
true);
389 while ($pagenb < $pageposafternote) {
392 if (!empty($tplidx)) {
393 $pdf->useTemplate($tplidx);
396 $this->
_pagehead($pdf, $object, 0, $outputlangs);
399 $pdf->setTopMargin($tab_top_newpage);
401 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
405 $pdf->setPage($pageposbeforenote);
406 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
407 $pdf->SetFont(
'',
'', $default_font_size - 1);
408 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
409 $pageposafternote = $pdf->getPage();
411 $posyafter = $pdf->GetY();
413 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
414 $pdf->AddPage(
'',
'',
true);
417 $pdf->setPage($pageposafternote);
418 $pdf->setTopMargin($tab_top_newpage);
420 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
426 $i = $pageposbeforenote;
427 while ($i < $pageposafternote) {
431 $pdf->SetDrawColor(128, 128, 128);
433 if ($i > $pageposbeforenote) {
434 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
435 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
437 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
438 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
442 $pdf->setPageOrientation(
'', 1, 0);
443 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
449 $pdf->setPage($pageposafternote);
450 if (!empty($tplidx)) {
451 $pdf->useTemplate($tplidx);
454 $this->
_pagehead($pdf, $object, 0, $outputlangs);
456 $height_note = $posyafter - $tab_top_newpage;
457 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
459 $pdf->commitTransaction();
460 $posyafter = $pdf->GetY();
461 $height_note = $posyafter - $tab_top;
462 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
465 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
467 $pdf->AddPage(
'',
'',
true);
470 $pdf->setPage($pageposafternote);
471 if (!empty($tplidx)) {
472 $pdf->useTemplate($tplidx);
475 $this->
_pagehead($pdf, $object, 0, $outputlangs);
478 $posyafter = $tab_top_newpage;
482 $tab_height = $tab_height - $height_note;
483 $tab_top = $posyafter + 6;
493 $pdf->startTransaction();
494 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
495 $pdf->rollbackTransaction(
true);
497 $nexY = $tab_top + $this->tabTitleHeight;
500 $pageposbeforeprintlines = $pdf->getPage();
501 $pagenb = $pageposbeforeprintlines;
502 for ($i = 0; $i < $nblines; $i++) {
504 $pdf->SetFont(
'',
'', $default_font_size - 1);
505 $pdf->SetTextColor(0, 0, 0);
508 $imglinesize = array();
509 if (!empty($realpatharray[$i])) {
513 $pdf->setTopMargin($tab_top_newpage);
514 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
515 $pageposbefore = $pdf->getPage();
518 $showpricebeforepagebreak = 1;
523 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
524 $pdf->AddPage(
'',
'',
true);
525 if (!empty($tplidx)) {
526 $pdf->useTemplate($tplidx);
528 $pdf->setPage($pageposbefore + 1);
530 $curY = $tab_top_newpage;
534 $showpricebeforepagebreak = 1;
536 $showpricebeforepagebreak = 0;
540 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
541 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
543 $posYAfterImage = $curY + $imglinesize[
'height'];
548 $pdf->startTransaction();
550 if (method_exists($object->lines[$i],
'fetch_product')) {
551 $object->lines[$i]->fetch_product();
552 $object->lines[$i]->label = $object->lines[$i]->product->label;
553 $object->lines[$i]->description = $object->lines[$i]->product->description;
554 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
557 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
559 $pageposafter = $pdf->getPage();
560 if ($pageposafter > $pageposbefore) {
561 $pdf->rollbackTransaction(
true);
562 $pageposafter = $pageposbefore;
564 $pdf->setPageOrientation(
'', 1, $heightforfooter);
566 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
567 $pageposafter = $pdf->getPage();
568 $posyafter = $pdf->GetY();
569 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
570 if ($i == ($nblines - 1)) {
571 $pdf->AddPage(
'',
'',
true);
572 if (!empty($tplidx)) {
573 $pdf->useTemplate($tplidx);
576 $pdf->setPage($pageposafter + 1);
582 $showpricebeforepagebreak = 1;
584 $showpricebeforepagebreak = 0;
588 $pdf->commitTransaction();
594 $nexY = max($pdf->GetY(), $posYAfterImage);
597 $pageposafter = $pdf->getPage();
599 $pdf->setPage($pageposbefore);
600 $pdf->setTopMargin($this->marge_haute);
601 $pdf->setPageOrientation(
'', 1, 0);
604 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
605 $pdf->setPage($pageposafter);
606 $curY = $tab_top_newpage;
609 $pdf->SetFont(
'',
'', $default_font_size - 1);
615 $nexY = max($pdf->GetY(), $nexY);
620 $pmp = $object->lines[$i]->pmp;
622 $nexY = max($pdf->GetY(), $nexY);
630 $nexY = max($pdf->GetY(), $nexY);
636 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
638 $nexY = max($pdf->GetY(), $nexY);
642 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
645 $nexY = max($pdf->GetY(), $nexY);
650 $pmp_qty = $pmp * $object->lines[$i]->qty;
652 $nexY = max($pdf->GetY(), $nexY);
656 if (!empty($object->lines[$i]->array_options)) {
657 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
661 $nexY = max($pdf->GetY(), $nexY);
672 'outputlangs' => $outputlangs,
673 'hidedetails' => $hidedetails
675 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
679 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
680 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
682 $tvaligne = $object->lines[$i]->total_tva;
685 $localtax1ligne = $object->lines[$i]->total_localtax1;
686 $localtax2ligne = $object->lines[$i]->total_localtax2;
687 $localtax1_rate = $object->lines[$i]->localtax1_tx;
688 $localtax2_rate = $object->lines[$i]->localtax2_tx;
689 $localtax1_type = $object->lines[$i]->localtax1_type;
690 $localtax2_type = $object->lines[$i]->localtax2_type;
697 $vatrate = (string) $object->lines[$i]->tva_tx;
700 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
701 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
703 $localtax1_type = $localtaxtmp_array[0];
704 $localtax2_type = $localtaxtmp_array[2];
708 if ($localtax1_type && $localtax1ligne != 0) {
709 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
710 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
712 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
715 if ($localtax2_type && $localtax2ligne != 0) {
716 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
717 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
719 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
723 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
726 if (!isset($this->tva[$vatrate])) {
727 $this->tva[$vatrate] = 0;
729 $this->tva[$vatrate] += $tvaligne;
733 $pdf->setPage($pageposafter);
734 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
736 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
737 $pdf->SetLineStyle(array(
'dash'=>0));
742 while ($pagenb < $pageposafter) {
743 $pdf->setPage($pagenb);
744 if ($pagenb == $pageposbeforeprintlines) {
745 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
747 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
749 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
751 $pdf->setPage($pagenb);
752 $pdf->setPageOrientation(
'', 1, 0);
754 $this->
_pagehead($pdf, $object, 0, $outputlangs);
757 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
758 if ($pagenb == $pageposafter) {
759 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
761 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
763 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
766 if (!empty($tplidx)) {
767 $pdf->useTemplate($tplidx);
771 $this->
_pagehead($pdf, $object, 0, $outputlangs);
777 if ($pagenb == $pageposbeforeprintlines) {
778 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
780 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
782 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
789 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
792 $this->
_pagefoot($pdf, $object, $outputlangs);
793 if (method_exists($pdf,
'AliasNbPages')) {
794 $pdf->AliasNbPages();
799 $pdf->Output($file,
'F');
802 $hookmanager->initHooks(array(
'pdfgeneration'));
803 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
805 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
807 $this->error = $hookmanager->error;
808 $this->errors = $hookmanager->errors;
813 $this->result = array(
'fullpath'=>$file);
817 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
821 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
837 global $conf, $mysoc;
840 $pdf->SetFont(
'',
'', $default_font_size - 1);
843 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
844 $pdf->SetFont(
'',
'B', $default_font_size - 2);
845 $pdf->SetXY($this->marge_gauche, $posy);
846 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
848 $posy = $pdf->GetY() + 4;
854 if ($object->cond_reglement_code || $object->cond_reglement) {
855 $pdf->SetFont(
'',
'B', $default_font_size - 2);
856 $pdf->SetXY($this->marge_gauche, $posy);
857 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
858 $pdf->MultiCell(43, 4, $titre, 0,
'L');
860 $pdf->SetFont(
'',
'', $default_font_size - 2);
861 $pdf->SetXY($posxval, $posy);
862 $lib_condition_paiement = ($outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) !=
'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
863 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
864 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
866 $posy = $pdf->GetY() + 3;
897 if (!empty($object->delivery_date)) {
898 $outputlangs->load(
"sendings");
899 $pdf->SetFont(
'',
'B', $default_font_size - 2);
900 $pdf->SetXY($this->marge_gauche, $posy);
901 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
902 $pdf->MultiCell(80, 4, $titre, 0,
'L');
903 $pdf->SetFont(
'',
'', $default_font_size - 2);
904 $pdf->SetXY($posxval, $posy);
905 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
906 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
908 $posy = $pdf->GetY() + 1;
909 } elseif ($object->availability_code || $object->availability) {
910 $pdf->SetFont(
'',
'B', $default_font_size - 2);
911 $pdf->SetXY($this->marge_gauche, $posy);
912 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
913 $pdf->MultiCell(80, 4, $titre, 0,
'L');
914 $pdf->SetTextColor(0, 0, 0);
915 $pdf->SetFont(
'',
'', $default_font_size - 2);
916 $pdf->SetXY($posxval, $posy);
917 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) !=
'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability :
'');
918 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
919 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
921 $posy = $pdf->GetY() + 1;
925 if ($object->mode_reglement_code
926 && $object->mode_reglement_code !=
'CHQ'
927 && $object->mode_reglement_code !=
'VIR') {
928 $pdf->SetFont(
'',
'B', $default_font_size - 2);
929 $pdf->SetXY($this->marge_gauche, $posy);
930 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
931 $pdf->MultiCell(80, 5, $titre, 0,
'L');
933 $pdf->SetFont(
'',
'', $default_font_size - 2);
934 $pdf->SetXY($posxval, $posy);
935 $lib_mode_reg = $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) !=
'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
936 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
938 $posy = $pdf->GetY() + 2;
942 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
946 $account =
new Account($this->db);
949 $pdf->SetXY($this->marge_gauche, $posy);
950 $pdf->SetFont(
'',
'B', $default_font_size - 3);
951 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
952 $posy = $pdf->GetY() + 1;
955 $pdf->SetXY($this->marge_gauche, $posy);
956 $pdf->SetFont(
'',
'', $default_font_size - 3);
957 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
958 $posy = $pdf->GetY() + 2;
962 $pdf->SetXY($this->marge_gauche, $posy);
963 $pdf->SetFont(
'',
'B', $default_font_size - 3);
964 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
965 $posy = $pdf->GetY() + 1;
968 $pdf->SetXY($this->marge_gauche, $posy);
969 $pdf->SetFont(
'',
'', $default_font_size - 3);
970 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
971 $posy = $pdf->GetY() + 2;
978 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
979 if (!empty($object->fk_account) || !empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
980 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
981 if (!empty($object->fk_bank)) {
982 $bankid = $object->fk_bank;
984 $account =
new Account($this->db);
985 $account->fetch($bankid);
987 $curx = $this->marge_gauche;
990 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1168 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1171 global $conf, $langs, $hookmanager;
1174 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1185 $pdf->SetTextColor(0, 0, 60);
1186 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1190 $posy = $this->marge_haute;
1191 $posx = $this->page_largeur - $this->marge_droite - 100;
1193 $pdf->SetXY($this->marge_gauche, $posy);
1197 if ($this->emetteur->logo) {
1198 $logodir = $conf->mycompany->dir_output;
1199 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1200 $logodir = $conf->mycompany->multidir_output[$object->entity];
1203 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1205 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1207 if (is_readable($logo)) {
1209 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1211 $pdf->SetTextColor(200, 0, 0);
1212 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1213 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1214 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1217 $text = $this->emetteur->name;
1218 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1222 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1223 $pdf->SetXY($posx, $posy);
1224 $pdf->SetTextColor(0, 0, 60);
1225 $title = $outputlangs->transnoentities($titlekey);
1226 $pdf->MultiCell($w, 3, $title,
'',
'R');
1228 $pdf->SetFont(
'',
'B', $default_font_size);
1231 $pdf->SetXY($posx, $posy);
1232 $pdf->SetTextColor(0, 0, 60);
1233 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1236 $pdf->SetFont(
'',
'', $default_font_size - 1);
1239 if (!empty($object->date_prevue_depart)) {
1241 $pdf->SetXY($posx, $posy);
1242 $pdf->SetTextColor(0, 0, 60);
1243 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date($object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1247 if (!empty($object->date_prevue_arrivee)) {
1249 $pdf->SetXY($posx, $posy);
1250 $pdf->SetTextColor(0, 0, 60);
1251 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date($object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1255 if (!empty($object->date_reelle_depart)) {
1257 $pdf->SetXY($posx, $posy);
1258 $pdf->SetTextColor(0, 0, 60);
1259 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date($object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1263 if (!empty($object->date_reelle_arrivee)) {
1265 $pdf->SetXY($posx, $posy);
1266 $pdf->SetTextColor(0, 0, 60);
1267 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date($object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1270 if ($object->ref_client) {
1272 $pdf->SetXY($posx, $posy);
1273 $pdf->SetTextColor(0, 0, 60);
1274 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1278 $object->fetch_projet();
1279 if (!empty($object->project->ref)) {
1281 $pdf->SetXY($posx, $posy);
1282 $pdf->SetTextColor(0, 0, 60);
1283 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1288 $object->fetch_projet();
1289 if (!empty($object->project->ref)) {
1291 $pdf->SetXY($posx, $posy);
1292 $pdf->SetTextColor(0, 0, 60);
1293 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1297 if (
getDolGlobalString(
'DOC_SHOW_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetTextColor(0, 0, 60);
1301 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1306 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1307 if (count($arrayidcontact) > 0) {
1308 $usertmp =
new User($this->db);
1309 $usertmp->fetch($arrayidcontact[0]);
1311 $pdf->SetXY($posx, $posy);
1312 $pdf->SetTextColor(0, 0, 60);
1313 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1321 $current_y = $pdf->getY();
1322 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1323 if ($current_y < $pdf->getY()) {
1324 $top_shift = $pdf->getY() - $current_y;
1329 $carac_emetteur =
'';
1331 $arrayidcontact = array();
1332 $arrayidcontact = $object->getIdContact(
'external',
'STFROM');
1334 $usecontact =
false;
1335 if (count($arrayidcontact) > 0) {
1339 $result = $object->fetch_contact($arrayidcontact[0]);
1343 $thirdparty = $object->contact;
1345 $thirdparty = $this->emetteur;
1348 if (!empty($thirdparty)) {
1353 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1,
'targetwithdetails', $object);
1355 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1360 $posx = $this->marge_gauche;
1362 $posx = $this->page_largeur - $this->marge_droite - 80;
1369 $pdf->SetTextColor(0, 0, 0);
1370 $pdf->SetFont(
'',
'', $default_font_size - 2);
1371 $pdf->SetXY($posx, $posy - 5);
1372 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1373 $pdf->SetXY($posx, $posy);
1374 $pdf->SetFillColor(230, 230, 230);
1375 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1376 $pdf->SetTextColor(0, 0, 60);
1377 $pdf->SetFillColor(255, 255, 255);
1380 $pdf->SetXY($posx + 2, $posy + 3);
1381 $pdf->SetFont(
'',
'B', $default_font_size);
1382 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1383 $posy = $pdf->getY();
1386 $pdf->SetXY($posx + 2, $posy);
1387 $pdf->SetFont(
'',
'', $default_font_size - 1);
1388 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1392 $usecontact =
false;
1393 $arrayidcontact = $object->getIdContact(
'external',
'STDEST');
1394 if (count($arrayidcontact) > 0) {
1396 $result = $object->fetch_contact($arrayidcontact[0]);
1402 $thirdparty = $object->contact;
1404 $thirdparty = $object->thirdparty;
1407 if (!empty($thirdparty)) {
1411 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1415 if ($this->page_largeur < 210) {
1419 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1421 $posx = $this->marge_gauche;
1425 $pdf->SetTextColor(0, 0, 0);
1426 $pdf->SetFont(
'',
'', $default_font_size - 2);
1427 $pdf->SetXY($posx + 2, $posy - 5);
1428 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1429 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1432 $pdf->SetXY($posx + 2, $posy + 3);
1433 $pdf->SetFont(
'',
'B', $default_font_size);
1434 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1436 $posy = $pdf->getY();
1439 $pdf->SetFont(
'',
'', $default_font_size - 1);
1440 $pdf->SetXY($posx + 2, $posy);
1441 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1444 $pdf->SetTextColor(0, 0, 0);