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 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
279 $tplidx = $pdf->importPage(1);
284 $pdf->SetDrawColor(128, 128, 128);
286 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
287 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
288 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
289 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
290 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
292 $pdf->SetCompression(
false);
295 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
298 foreach ($object->lines as $line) {
299 if ($line->remise_percent) {
300 $this->atleastonediscount =
true;
308 if (!empty($tplidx)) {
309 $pdf->useTemplate($tplidx);
312 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
313 $pdf->SetFont(
'',
'', $default_font_size - 1);
314 $pdf->MultiCell(0, 3,
'');
315 $pdf->SetTextColor(0, 0, 0);
318 $tab_top = 90 + $top_shift;
319 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
323 if ($conf->incoterm->enabled) {
324 $desc_incoterms = $object->getIncotermsForPDF();
325 if ($desc_incoterms) {
328 $pdf->SetFont(
'',
'', $default_font_size - 1);
329 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
330 $nexY = $pdf->GetY();
331 $height_incoterms = $nexY - $tab_top;
334 $pdf->SetDrawColor(192, 192, 192);
335 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
337 $tab_top = $nexY + 6;
342 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
345 if (is_object($object->thirdparty)) {
346 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
347 $salerepobj =
new User($this->db);
348 $salerepobj->fetch($salereparray[0][
'id']);
349 if (!empty($salerepobj->signature)) {
350 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
356 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
357 if (!empty($extranote)) {
361 $pagenb = $pdf->getPage();
363 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
364 $pageposbeforenote = $pagenb;
373 $pdf->startTransaction();
375 $pdf->SetFont(
'',
'', $default_font_size - 1);
376 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
378 $pageposafternote = $pdf->getPage();
379 $posyafter = $pdf->GetY();
381 if ($pageposafternote > $pageposbeforenote) {
382 $pdf->rollbackTransaction(
true);
385 while ($pagenb < $pageposafternote) {
388 if (!empty($tplidx)) {
389 $pdf->useTemplate($tplidx);
392 $this->
_pagehead($pdf, $object, 0, $outputlangs);
395 $pdf->setTopMargin($tab_top_newpage);
397 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
401 $pdf->setPage($pageposbeforenote);
402 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
403 $pdf->SetFont(
'',
'', $default_font_size - 1);
404 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
405 $pageposafternote = $pdf->getPage();
407 $posyafter = $pdf->GetY();
409 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
410 $pdf->AddPage(
'',
'',
true);
413 $pdf->setPage($pageposafternote);
414 $pdf->setTopMargin($tab_top_newpage);
416 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
422 $i = $pageposbeforenote;
423 while ($i < $pageposafternote) {
427 $pdf->SetDrawColor(128, 128, 128);
429 if ($i > $pageposbeforenote) {
430 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
431 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
433 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
434 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
438 $pdf->setPageOrientation(
'', 1, 0);
439 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
445 $pdf->setPage($pageposafternote);
446 if (!empty($tplidx)) {
447 $pdf->useTemplate($tplidx);
450 $this->
_pagehead($pdf, $object, 0, $outputlangs);
452 $height_note = $posyafter - $tab_top_newpage;
453 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
455 $pdf->commitTransaction();
456 $posyafter = $pdf->GetY();
457 $height_note = $posyafter - $tab_top;
458 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
461 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
463 $pdf->AddPage(
'',
'',
true);
466 $pdf->setPage($pageposafternote);
467 if (!empty($tplidx)) {
468 $pdf->useTemplate($tplidx);
471 $this->
_pagehead($pdf, $object, 0, $outputlangs);
474 $posyafter = $tab_top_newpage;
478 $tab_height = $tab_height - $height_note;
479 $tab_top = $posyafter + 6;
489 $pdf->startTransaction();
490 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
491 $pdf->rollbackTransaction(
true);
493 $nexY = $tab_top + $this->tabTitleHeight;
496 $pageposbeforeprintlines = $pdf->getPage();
497 $pagenb = $pageposbeforeprintlines;
498 for ($i = 0; $i < $nblines; $i++) {
500 $pdf->SetFont(
'',
'', $default_font_size - 1);
501 $pdf->SetTextColor(0, 0, 0);
504 $imglinesize = array();
505 if (!empty($realpatharray[$i])) {
509 $pdf->setTopMargin($tab_top_newpage);
510 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
511 $pageposbefore = $pdf->getPage();
514 $showpricebeforepagebreak = 1;
519 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
520 $pdf->AddPage(
'',
'',
true);
521 if (!empty($tplidx)) {
522 $pdf->useTemplate($tplidx);
524 $pdf->setPage($pageposbefore + 1);
526 $curY = $tab_top_newpage;
530 $showpricebeforepagebreak = 1;
532 $showpricebeforepagebreak = 0;
536 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
537 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
539 $posYAfterImage = $curY + $imglinesize[
'height'];
544 $pdf->startTransaction();
546 if (method_exists($object->lines[$i],
'fetch_product')) {
547 $object->lines[$i]->fetch_product();
548 $object->lines[$i]->label = $object->lines[$i]->product->label;
549 $object->lines[$i]->description = $object->lines[$i]->product->description;
550 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
553 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
555 $pageposafter = $pdf->getPage();
556 if ($pageposafter > $pageposbefore) {
557 $pdf->rollbackTransaction(
true);
558 $pageposafter = $pageposbefore;
560 $pdf->setPageOrientation(
'', 1, $heightforfooter);
562 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
563 $pageposafter = $pdf->getPage();
564 $posyafter = $pdf->GetY();
565 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
566 if ($i == ($nblines - 1)) {
567 $pdf->AddPage(
'',
'',
true);
568 if (!empty($tplidx)) {
569 $pdf->useTemplate($tplidx);
572 $pdf->setPage($pageposafter + 1);
578 $showpricebeforepagebreak = 1;
580 $showpricebeforepagebreak = 0;
584 $pdf->commitTransaction();
590 $nexY = max($pdf->GetY(), $posYAfterImage);
593 $pageposafter = $pdf->getPage();
595 $pdf->setPage($pageposbefore);
596 $pdf->setTopMargin($this->marge_haute);
597 $pdf->setPageOrientation(
'', 1, 0);
600 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
601 $pdf->setPage($pageposafter);
602 $curY = $tab_top_newpage;
605 $pdf->SetFont(
'',
'', $default_font_size - 1);
611 $nexY = max($pdf->GetY(), $nexY);
616 $pmp = $object->lines[$i]->pmp;
618 $nexY = max($pdf->GetY(), $nexY);
626 $nexY = max($pdf->GetY(), $nexY);
632 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
634 $nexY = max($pdf->GetY(), $nexY);
638 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
641 $nexY = max($pdf->GetY(), $nexY);
646 $pmp_qty = $pmp * $object->lines[$i]->qty;
648 $nexY = max($pdf->GetY(), $nexY);
652 if (!empty($object->lines[$i]->array_options)) {
653 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
657 $nexY = max($pdf->GetY(), $nexY);
668 'outputlangs' => $outputlangs,
669 'hidedetails' => $hidedetails
671 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
675 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
676 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
678 $tvaligne = $object->lines[$i]->total_tva;
681 $localtax1ligne = $object->lines[$i]->total_localtax1;
682 $localtax2ligne = $object->lines[$i]->total_localtax2;
683 $localtax1_rate = $object->lines[$i]->localtax1_tx;
684 $localtax2_rate = $object->lines[$i]->localtax2_tx;
685 $localtax1_type = $object->lines[$i]->localtax1_type;
686 $localtax2_type = $object->lines[$i]->localtax2_type;
693 $vatrate = (string) $object->lines[$i]->tva_tx;
696 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
697 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
699 $localtax1_type = $localtaxtmp_array[0];
700 $localtax2_type = $localtaxtmp_array[2];
704 if ($localtax1_type && $localtax1ligne != 0) {
705 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
706 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
708 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
711 if ($localtax2_type && $localtax2ligne != 0) {
712 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
713 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
715 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
719 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
722 if (!isset($this->tva[$vatrate])) {
723 $this->tva[$vatrate] = 0;
725 $this->tva[$vatrate] += $tvaligne;
729 $pdf->setPage($pageposafter);
730 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
732 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
733 $pdf->SetLineStyle(array(
'dash'=>0));
738 while ($pagenb < $pageposafter) {
739 $pdf->setPage($pagenb);
740 if ($pagenb == $pageposbeforeprintlines) {
741 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
743 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
745 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
747 $pdf->setPage($pagenb);
748 $pdf->setPageOrientation(
'', 1, 0);
750 $this->
_pagehead($pdf, $object, 0, $outputlangs);
753 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
754 if ($pagenb == $pageposafter) {
755 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
757 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
759 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
762 if (!empty($tplidx)) {
763 $pdf->useTemplate($tplidx);
767 $this->
_pagehead($pdf, $object, 0, $outputlangs);
773 if ($pagenb == $pageposbeforeprintlines) {
774 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
776 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
778 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
785 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
788 $this->
_pagefoot($pdf, $object, $outputlangs);
789 if (method_exists($pdf,
'AliasNbPages')) {
790 $pdf->AliasNbPages();
795 $pdf->Output($file,
'F');
798 $hookmanager->initHooks(array(
'pdfgeneration'));
799 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
801 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
803 $this->error = $hookmanager->error;
804 $this->errors = $hookmanager->errors;
809 $this->result = array(
'fullpath'=>$file);
813 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
817 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
833 global $conf, $mysoc;
836 $pdf->SetFont(
'',
'', $default_font_size - 1);
839 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
840 $pdf->SetFont(
'',
'B', $default_font_size - 2);
841 $pdf->SetXY($this->marge_gauche, $posy);
842 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
844 $posy = $pdf->GetY() + 4;
850 if ($object->cond_reglement_code || $object->cond_reglement) {
851 $pdf->SetFont(
'',
'B', $default_font_size - 2);
852 $pdf->SetXY($this->marge_gauche, $posy);
853 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
854 $pdf->MultiCell(43, 4, $titre, 0,
'L');
856 $pdf->SetFont(
'',
'', $default_font_size - 2);
857 $pdf->SetXY($posxval, $posy);
858 $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);
859 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
860 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
862 $posy = $pdf->GetY() + 3;
893 if (!empty($object->delivery_date)) {
894 $outputlangs->load(
"sendings");
895 $pdf->SetFont(
'',
'B', $default_font_size - 2);
896 $pdf->SetXY($this->marge_gauche, $posy);
897 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
898 $pdf->MultiCell(80, 4, $titre, 0,
'L');
899 $pdf->SetFont(
'',
'', $default_font_size - 2);
900 $pdf->SetXY($posxval, $posy);
901 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
902 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
904 $posy = $pdf->GetY() + 1;
905 } elseif ($object->availability_code || $object->availability) {
906 $pdf->SetFont(
'',
'B', $default_font_size - 2);
907 $pdf->SetXY($this->marge_gauche, $posy);
908 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
909 $pdf->MultiCell(80, 4, $titre, 0,
'L');
910 $pdf->SetTextColor(0, 0, 0);
911 $pdf->SetFont(
'',
'', $default_font_size - 2);
912 $pdf->SetXY($posxval, $posy);
913 $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 :
'');
914 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
915 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
917 $posy = $pdf->GetY() + 1;
921 if ($object->mode_reglement_code
922 && $object->mode_reglement_code !=
'CHQ'
923 && $object->mode_reglement_code !=
'VIR') {
924 $pdf->SetFont(
'',
'B', $default_font_size - 2);
925 $pdf->SetXY($this->marge_gauche, $posy);
926 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
927 $pdf->MultiCell(80, 5, $titre, 0,
'L');
929 $pdf->SetFont(
'',
'', $default_font_size - 2);
930 $pdf->SetXY($posxval, $posy);
931 $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);
932 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
934 $posy = $pdf->GetY() + 2;
938 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
942 $account =
new Account($this->db);
945 $pdf->SetXY($this->marge_gauche, $posy);
946 $pdf->SetFont(
'',
'B', $default_font_size - 3);
947 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
948 $posy = $pdf->GetY() + 1;
951 $pdf->SetXY($this->marge_gauche, $posy);
952 $pdf->SetFont(
'',
'', $default_font_size - 3);
953 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
954 $posy = $pdf->GetY() + 2;
958 $pdf->SetXY($this->marge_gauche, $posy);
959 $pdf->SetFont(
'',
'B', $default_font_size - 3);
960 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
961 $posy = $pdf->GetY() + 1;
964 $pdf->SetXY($this->marge_gauche, $posy);
965 $pdf->SetFont(
'',
'', $default_font_size - 3);
966 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
967 $posy = $pdf->GetY() + 2;
974 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
975 if (!empty($object->fk_account) || !empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
976 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
977 if (!empty($object->fk_bank)) {
978 $bankid = $object->fk_bank;
980 $account =
new Account($this->db);
981 $account->fetch($bankid);
983 $curx = $this->marge_gauche;
986 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1164 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1167 global $conf, $langs, $hookmanager;
1170 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1181 $pdf->SetTextColor(0, 0, 60);
1182 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1186 $posy = $this->marge_haute;
1187 $posx = $this->page_largeur - $this->marge_droite - 100;
1189 $pdf->SetXY($this->marge_gauche, $posy);
1193 if ($this->emetteur->logo) {
1194 $logodir = $conf->mycompany->dir_output;
1195 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1196 $logodir = $conf->mycompany->multidir_output[$object->entity];
1199 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1201 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1203 if (is_readable($logo)) {
1205 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1207 $pdf->SetTextColor(200, 0, 0);
1208 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1209 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1210 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1213 $text = $this->emetteur->name;
1214 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1218 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1219 $pdf->SetXY($posx, $posy);
1220 $pdf->SetTextColor(0, 0, 60);
1221 $title = $outputlangs->transnoentities($titlekey);
1222 $pdf->MultiCell($w, 3, $title,
'',
'R');
1224 $pdf->SetFont(
'',
'B', $default_font_size);
1227 $pdf->SetXY($posx, $posy);
1228 $pdf->SetTextColor(0, 0, 60);
1229 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1232 $pdf->SetFont(
'',
'', $default_font_size - 1);
1235 if (!empty($object->date_prevue_depart)) {
1237 $pdf->SetXY($posx, $posy);
1238 $pdf->SetTextColor(0, 0, 60);
1239 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date($object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1243 if (!empty($object->date_prevue_arrivee)) {
1245 $pdf->SetXY($posx, $posy);
1246 $pdf->SetTextColor(0, 0, 60);
1247 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date($object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1251 if (!empty($object->date_reelle_depart)) {
1253 $pdf->SetXY($posx, $posy);
1254 $pdf->SetTextColor(0, 0, 60);
1255 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date($object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1259 if (!empty($object->date_reelle_arrivee)) {
1261 $pdf->SetXY($posx, $posy);
1262 $pdf->SetTextColor(0, 0, 60);
1263 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date($object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1266 if ($object->ref_client) {
1268 $pdf->SetXY($posx, $posy);
1269 $pdf->SetTextColor(0, 0, 60);
1270 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1274 $object->fetch_projet();
1275 if (!empty($object->project->ref)) {
1277 $pdf->SetXY($posx, $posy);
1278 $pdf->SetTextColor(0, 0, 60);
1279 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1284 $object->fetch_projet();
1285 if (!empty($object->project->ref)) {
1287 $pdf->SetXY($posx, $posy);
1288 $pdf->SetTextColor(0, 0, 60);
1289 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1293 if (
getDolGlobalString(
'DOC_SHOW_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1295 $pdf->SetXY($posx, $posy);
1296 $pdf->SetTextColor(0, 0, 60);
1297 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1302 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1303 if (count($arrayidcontact) > 0) {
1304 $usertmp =
new User($this->db);
1305 $usertmp->fetch($arrayidcontact[0]);
1307 $pdf->SetXY($posx, $posy);
1308 $pdf->SetTextColor(0, 0, 60);
1309 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1317 $current_y = $pdf->getY();
1318 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1319 if ($current_y < $pdf->getY()) {
1320 $top_shift = $pdf->getY() - $current_y;
1325 $carac_emetteur =
'';
1327 $arrayidcontact = array();
1328 $arrayidcontact = $object->getIdContact(
'external',
'STFROM');
1330 $usecontact =
false;
1331 if (count($arrayidcontact) > 0) {
1335 $result = $object->fetch_contact($arrayidcontact[0]);
1339 $thirdparty = $object->contact;
1341 $thirdparty = $this->emetteur;
1344 if (!empty($thirdparty)) {
1349 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1,
'targetwithdetails', $object);
1351 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1356 $posx = $this->marge_gauche;
1358 $posx = $this->page_largeur - $this->marge_droite - 80;
1365 $pdf->SetTextColor(0, 0, 0);
1366 $pdf->SetFont(
'',
'', $default_font_size - 2);
1367 $pdf->SetXY($posx, $posy - 5);
1368 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1369 $pdf->SetXY($posx, $posy);
1370 $pdf->SetFillColor(230, 230, 230);
1371 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1372 $pdf->SetTextColor(0, 0, 60);
1373 $pdf->SetFillColor(255, 255, 255);
1376 $pdf->SetXY($posx + 2, $posy + 3);
1377 $pdf->SetFont(
'',
'B', $default_font_size);
1378 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1379 $posy = $pdf->getY();
1382 $pdf->SetXY($posx + 2, $posy);
1383 $pdf->SetFont(
'',
'', $default_font_size - 1);
1384 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1388 $usecontact =
false;
1389 $arrayidcontact = $object->getIdContact(
'external',
'STDEST');
1390 if (count($arrayidcontact) > 0) {
1392 $result = $object->fetch_contact($arrayidcontact[0]);
1398 $thirdparty = $object->contact;
1400 $thirdparty = $object->thirdparty;
1403 if (!empty($thirdparty)) {
1407 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1411 if ($this->page_largeur < 210) {
1415 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1417 $posx = $this->marge_gauche;
1421 $pdf->SetTextColor(0, 0, 0);
1422 $pdf->SetFont(
'',
'', $default_font_size - 2);
1423 $pdf->SetXY($posx + 2, $posy - 5);
1424 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1425 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1428 $pdf->SetXY($posx + 2, $posy + 3);
1429 $pdf->SetFont(
'',
'B', $default_font_size);
1430 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1432 $posy = $pdf->getY();
1435 $pdf->SetFont(
'',
'', $default_font_size - 1);
1436 $pdf->SetXY($posx + 2, $posy);
1437 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1440 $pdf->SetTextColor(0, 0, 0);