187 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
190 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
192 if (!is_object($outputlangs)) $outputlangs = $langs;
194 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
197 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
199 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
200 global $outputlangsbis;
201 $outputlangsbis =
new Translate(
'', $conf);
202 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
203 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
206 $nblines = is_array($object->lines) ? count($object->lines) : 0;
209 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
210 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
214 $realpatharray = array();
215 $this->atleastonephoto =
false;
216 if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
217 $objphoto =
new Product($this->db);
219 for ($i = 0; $i < $nblines; $i++) {
220 if (empty($object->lines[$i]->fk_product))
continue;
222 $objphoto->fetch($object->lines[$i]->fk_product);
225 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
226 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
228 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
229 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
233 foreach ($pdir as $midir) {
235 $dir = $conf->product->dir_output.
'/'.$midir;
237 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
239 if ($obj[
'photo_vignette']) {
240 $filename = $obj[
'photo_vignette'];
242 $filename = $obj[
'photo'];
245 $filename = $obj[
'photo'];
248 $realpath = $dir.$filename;
250 $this->atleastonephoto =
true;
255 if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
261 if ($conf->stocktransfer->dir_output) {
262 $object->fetch_thirdparty();
267 if ($object->specimen) {
268 $dir = $conf->stocktransfer->multidir_output[$conf->entity];
269 $file = $dir.
"/SPECIMEN.pdf";
272 $dir = $conf->stocktransfer->multidir_output[$conf->entity].
"/".$object->element.
"/".$objectref;
273 $file = $dir.
"/".$objectref.
"-proforma.pdf";
276 if (!file_exists($dir)) {
278 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
283 if (file_exists($dir)) {
285 if (!is_object($hookmanager)) {
286 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
289 $hookmanager->initHooks(array(
'pdfgeneration'));
290 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
292 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
297 $pdf->SetAutoPageBreak(1, 0);
299 $heightforinfotot = 40;
300 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
301 $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
303 if (class_exists(
'TCPDF')) {
304 $pdf->setPrintHeader(
false);
305 $pdf->setPrintFooter(
false);
309 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
310 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
311 $tplidx = $pdf->importPage(1);
316 $pdf->SetDrawColor(128, 128, 128);
318 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
319 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
320 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
321 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
322 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
324 $pdf->SetCompression(
false);
327 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
330 foreach ($object->lines as $line) {
331 if ($line->remise_percent) {
332 $this->atleastonediscount =
true;
340 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
342 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
343 $pdf->SetFont(
'',
'', $default_font_size - 1);
344 $pdf->MultiCell(0, 3,
'');
345 $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 ($conf->incoterm->enabled) {
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->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
366 $tab_top = $nexY + 6;
371 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
372 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
374 if (is_object($object->thirdparty)) {
375 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
376 $salerepobj =
new User($this->db);
377 $salerepobj->fetch($salereparray[0][
'id']);
378 if (!empty($salerepobj->signature)) $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
383 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
384 if (!empty($extranote)) {
388 $pagenb = $pdf->getPage();
390 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
391 $pageposbeforenote = $pagenb;
400 $pdf->startTransaction();
402 $pdf->SetFont(
'',
'', $default_font_size - 1);
403 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
405 $pageposafternote = $pdf->getPage();
406 $posyafter = $pdf->GetY();
408 if ($pageposafternote > $pageposbeforenote) {
409 $pdf->rollbackTransaction(
true);
412 while ($pagenb < $pageposafternote) {
415 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
418 $pdf->setTopMargin($tab_top_newpage);
420 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
424 $pdf->setPage($pageposbeforenote);
425 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
426 $pdf->SetFont(
'',
'', $default_font_size - 1);
427 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
428 $pageposafternote = $pdf->getPage();
430 $posyafter = $pdf->GetY();
432 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
433 $pdf->AddPage(
'',
'',
true);
436 $pdf->setPage($pageposafternote);
437 $pdf->setTopMargin($tab_top_newpage);
439 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
445 $i = $pageposbeforenote;
446 while ($i < $pageposafternote) {
450 $pdf->SetDrawColor(128, 128, 128);
452 if ($i > $pageposbeforenote) {
453 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
454 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
456 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
457 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
461 $pdf->setPageOrientation(
'', 1, 0);
462 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
468 $pdf->setPage($pageposafternote);
469 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
471 $height_note = $posyafter - $tab_top_newpage;
472 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
475 $pdf->commitTransaction();
476 $posyafter = $pdf->GetY();
477 $height_note = $posyafter - $tab_top;
478 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
481 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
483 $pdf->AddPage(
'',
'',
true);
486 $pdf->setPage($pageposafternote);
487 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
490 $posyafter = $tab_top_newpage;
494 $tab_height = $tab_height - $height_note;
495 $tab_top = $posyafter + 6;
505 $pdf->startTransaction();
506 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
507 $pdf->rollbackTransaction(
true);
509 $nexY = $tab_top + $this->tabTitleHeight;
512 $pageposbeforeprintlines = $pdf->getPage();
513 $pagenb = $pageposbeforeprintlines;
514 for ($i = 0; $i < $nblines; $i++) {
516 $pdf->SetFont(
'',
'', $default_font_size - 1);
517 $pdf->SetTextColor(0, 0, 0);
520 $imglinesize = array();
523 $pdf->setTopMargin($tab_top_newpage);
524 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
525 $pageposbefore = $pdf->getPage();
528 $showpricebeforepagebreak = 1;
533 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
534 $pdf->AddPage(
'',
'',
true);
535 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
536 $pdf->setPage($pageposbefore + 1);
538 $curY = $tab_top_newpage;
541 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
542 $showpricebeforepagebreak = 1;
543 else $showpricebeforepagebreak = 0;
546 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
547 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
549 $posYAfterImage = $curY + $imglinesize[
'height'];
554 $pdf->startTransaction();
556 if (method_exists($object->lines[$i],
'fetch_product')) {
557 $object->lines[$i]->fetch_product();
558 $object->lines[$i]->label = $object->lines[$i]->product->label;
559 $object->lines[$i]->description = $object->lines[$i]->product->description;
560 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
563 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
565 $pageposafter = $pdf->getPage();
566 if ($pageposafter > $pageposbefore) {
567 $pdf->rollbackTransaction(
true);
568 $pageposafter = $pageposbefore;
570 $pdf->setPageOrientation(
'', 1, $heightforfooter);
572 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
573 $pageposafter = $pdf->getPage();
574 $posyafter = $pdf->GetY();
575 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
576 if ($i == ($nblines - 1)) {
577 $pdf->AddPage(
'',
'',
true);
578 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
580 $pdf->setPage($pageposafter + 1);
585 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
586 $showpricebeforepagebreak = 1;
587 else $showpricebeforepagebreak = 0;
591 $pdf->commitTransaction();
597 $nexY = max($pdf->GetY(), $posYAfterImage);
600 $pageposafter = $pdf->getPage();
602 $pdf->setPage($pageposbefore);
603 $pdf->setTopMargin($this->marge_haute);
604 $pdf->setPageOrientation(
'', 1, 0);
607 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
608 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
611 $pdf->SetFont(
'',
'', $default_font_size - 1);
617 $nexY = max($pdf->GetY(), $nexY);
622 $pmp = $object->lines[$i]->pmp;
624 $nexY = max($pdf->GetY(), $nexY);
632 $nexY = max($pdf->GetY(), $nexY);
638 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
640 $nexY = max($pdf->GetY(), $nexY);
644 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
647 $nexY = max($pdf->GetY(), $nexY);
652 $pmp_qty = $pmp * $object->lines[$i]->qty;
654 $nexY = max($pdf->GetY(), $nexY);
658 if (!empty($object->lines[$i]->array_options)) {
659 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
663 $nexY = max($pdf->GetY(), $nexY);
674 'outputlangs' => $outputlangs,
675 'hidedetails' => $hidedetails
677 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
681 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
682 else $tvaligne = $object->lines[$i]->total_tva;
684 $localtax1ligne = $object->lines[$i]->total_localtax1;
685 $localtax2ligne = $object->lines[$i]->total_localtax2;
686 $localtax1_rate = $object->lines[$i]->localtax1_tx;
687 $localtax2_rate = $object->lines[$i]->localtax2_tx;
688 $localtax1_type = $object->lines[$i]->localtax1_type;
689 $localtax2_type = $object->lines[$i]->localtax2_type;
696 $vatrate = (string) $object->lines[$i]->tva_tx;
699 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
700 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
702 $localtax1_type = $localtaxtmp_array[0];
703 $localtax2_type = $localtaxtmp_array[2];
707 if ($localtax1_type && $localtax1ligne != 0) {
708 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
709 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
711 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
714 if ($localtax2_type && $localtax2ligne != 0) {
715 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
716 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
718 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
722 if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .=
'*';
723 if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
724 $this->tva[$vatrate] += $tvaligne;
727 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
728 $pdf->setPage($pageposafter);
729 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
731 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
732 $pdf->SetLineStyle(array(
'dash'=>0));
737 while ($pagenb < $pageposafter) {
738 $pdf->setPage($pagenb);
739 if ($pagenb == $pageposbeforeprintlines) {
740 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
742 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
744 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
746 $pdf->setPage($pagenb);
747 $pdf->setPageOrientation(
'', 1, 0);
750 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
751 if ($pagenb == $pageposafter) {
752 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
754 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
756 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
759 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
766 if ($pagenb == $pageposbeforeprintlines)
767 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
768 else $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
769 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
776 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
787 $this->
_pagefoot($pdf, $object, $outputlangs);
788 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
792 $pdf->Output($file,
'F');
795 $hookmanager->initHooks(array(
'pdfgeneration'));
796 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
798 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
800 $this->error = $hookmanager->error;
801 $this->errors = $hookmanager->errors;
806 $this->result = array(
'fullpath'=>$file);
810 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
814 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
843 global $conf, $mysoc;
846 $pdf->SetFont(
'',
'', $default_font_size - 1);
849 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
850 $pdf->SetFont(
'',
'B', $default_font_size - 2);
851 $pdf->SetXY($this->marge_gauche, $posy);
852 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
854 $posy = $pdf->GetY() + 4;
860 if ($object->cond_reglement_code || $object->cond_reglement) {
861 $pdf->SetFont(
'',
'B', $default_font_size - 2);
862 $pdf->SetXY($this->marge_gauche, $posy);
863 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
864 $pdf->MultiCell(43, 4, $titre, 0,
'L');
866 $pdf->SetFont(
'',
'', $default_font_size - 2);
867 $pdf->SetXY($posxval, $posy);
868 $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);
869 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
870 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
872 $posy = $pdf->GetY() + 3;
903 if (!empty($object->date_livraison)) {
904 $outputlangs->load(
"sendings");
905 $pdf->SetFont(
'',
'B', $default_font_size - 2);
906 $pdf->SetXY($this->marge_gauche, $posy);
907 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
908 $pdf->MultiCell(80, 4, $titre, 0,
'L');
909 $pdf->SetFont(
'',
'', $default_font_size - 2);
910 $pdf->SetXY($posxval, $posy);
911 $dlp =
dol_print_date($object->date_livraison,
"daytext",
false, $outputlangs,
true);
912 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
914 $posy = $pdf->GetY() + 1;
915 } elseif ($object->availability_code || $object->availability) {
916 $pdf->SetFont(
'',
'B', $default_font_size - 2);
917 $pdf->SetXY($this->marge_gauche, $posy);
918 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
919 $pdf->MultiCell(80, 4, $titre, 0,
'L');
920 $pdf->SetTextColor(0, 0, 0);
921 $pdf->SetFont(
'',
'', $default_font_size - 2);
922 $pdf->SetXY($posxval, $posy);
923 $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 :
'');
924 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
925 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
927 $posy = $pdf->GetY() + 1;
931 if ($object->mode_reglement_code
932 && $object->mode_reglement_code !=
'CHQ'
933 && $object->mode_reglement_code !=
'VIR') {
934 $pdf->SetFont(
'',
'B', $default_font_size - 2);
935 $pdf->SetXY($this->marge_gauche, $posy);
936 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
937 $pdf->MultiCell(80, 5, $titre, 0,
'L');
939 $pdf->SetFont(
'',
'', $default_font_size - 2);
940 $pdf->SetXY($posxval, $posy);
941 $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);
942 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
944 $posy = $pdf->GetY() + 2;
948 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
951 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
952 $account =
new Account($this->db);
955 $pdf->SetXY($this->marge_gauche, $posy);
956 $pdf->SetFont(
'',
'B', $default_font_size - 3);
957 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
958 $posy = $pdf->GetY() + 1;
960 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
961 $pdf->SetXY($this->marge_gauche, $posy);
962 $pdf->SetFont(
'',
'', $default_font_size - 3);
963 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
964 $posy = $pdf->GetY() + 2;
968 $pdf->SetXY($this->marge_gauche, $posy);
969 $pdf->SetFont(
'',
'B', $default_font_size - 3);
970 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
971 $posy = $pdf->GetY() + 1;
973 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
974 $pdf->SetXY($this->marge_gauche, $posy);
975 $pdf->SetFont(
'',
'', $default_font_size - 3);
976 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
977 $posy = $pdf->GetY() + 2;
984 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
985 if (!empty($object->fk_account) || !empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
986 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
987 if (!empty($object->fk_bank)) $bankid = $object->fk_bank;
988 $account =
new Account($this->db);
989 $account->fetch($bankid);
991 $curx = $this->marge_gauche;
994 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1167 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1170 global $conf, $langs, $hookmanager;
1173 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1184 $pdf->SetTextColor(0, 0, 60);
1185 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1187 $posy = $this->marge_haute;
1188 $posx = $this->page_largeur - $this->marge_droite - 100;
1190 $pdf->SetXY($this->marge_gauche, $posy);
1194 if ($this->emetteur->logo) {
1195 $logodir = $conf->mycompany->dir_output;
1196 if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1198 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1200 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1202 if (is_readable($logo)) {
1204 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1206 $pdf->SetTextColor(200, 0, 0);
1207 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1208 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1209 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1212 $text = $this->emetteur->name;
1213 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1217 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1218 $pdf->SetXY($posx, $posy);
1219 $pdf->SetTextColor(0, 0, 60);
1220 $title = $outputlangs->transnoentities($titlekey);
1221 $pdf->MultiCell(100, 3, $title,
'',
'R');
1223 $pdf->SetFont(
'',
'B', $default_font_size);
1226 $pdf->SetXY($posx, $posy);
1227 $pdf->SetTextColor(0, 0, 60);
1228 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1231 $pdf->SetFont(
'',
'', $default_font_size - 1);
1234 if (!empty($object->date_prevue_depart)) {
1236 $pdf->SetXY($posx, $posy);
1237 $pdf->SetTextColor(0, 0, 60);
1238 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date($object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1242 if (!empty($object->date_prevue_arrivee)) {
1244 $pdf->SetXY($posx, $posy);
1245 $pdf->SetTextColor(0, 0, 60);
1246 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date($object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1250 if (!empty($object->date_reelle_depart)) {
1252 $pdf->SetXY($posx, $posy);
1253 $pdf->SetTextColor(0, 0, 60);
1254 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date($object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1258 if (!empty($object->date_reelle_arrivee)) {
1260 $pdf->SetXY($posx, $posy);
1261 $pdf->SetTextColor(0, 0, 60);
1262 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date($object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1265 if ($object->ref_client) {
1267 $pdf->SetXY($posx, $posy);
1268 $pdf->SetTextColor(0, 0, 60);
1269 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1272 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1273 $object->fetch_projet();
1274 if (!empty($object->project->ref)) {
1276 $pdf->SetXY($posx, $posy);
1277 $pdf->SetTextColor(0, 0, 60);
1278 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1282 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1283 $object->fetch_projet();
1284 if (!empty($object->project->ref)) {
1286 $pdf->SetXY($posx, $posy);
1287 $pdf->SetTextColor(0, 0, 60);
1288 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1292 if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1294 $pdf->SetXY($posx, $posy);
1295 $pdf->SetTextColor(0, 0, 60);
1296 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1300 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1301 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1302 if (count($arrayidcontact) > 0) {
1303 $usertmp =
new User($this->db);
1304 $usertmp->fetch($arrayidcontact[0]);
1306 $pdf->SetXY($posx, $posy);
1307 $pdf->SetTextColor(0, 0, 60);
1308 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1316 $current_y = $pdf->getY();
1317 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1318 if ($current_y < $pdf->getY()) {
1319 $top_shift = $pdf->getY() - $current_y;
1324 $carac_emetteur =
'';
1326 $arrayidcontact = array();
1327 $arrayidcontact = $object->getIdContact(
'external',
'STFROM');
1329 $usecontact =
false;
1330 if (count($arrayidcontact) > 0) {
1334 $result = $object->fetch_contact($arrayidcontact[0]);
1337 if ($usecontact) $thirdparty = $object->contact;
1338 else $thirdparty = $this->emetteur;
1342 if ($usecontact) $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1,
'targetwithdetails', $object);
1343 else $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1346 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1347 $posx = $this->marge_gauche;
1348 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1350 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1351 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1354 $pdf->SetTextColor(0, 0, 0);
1355 $pdf->SetFont(
'',
'', $default_font_size - 2);
1356 $pdf->SetXY($posx, $posy - 5);
1357 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1358 $pdf->SetXY($posx, $posy);
1359 $pdf->SetFillColor(230, 230, 230);
1360 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1361 $pdf->SetTextColor(0, 0, 60);
1362 $pdf->SetFillColor(255, 255, 255);
1365 $pdf->SetXY($posx + 2, $posy + 3);
1366 $pdf->SetFont(
'',
'B', $default_font_size);
1367 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1368 $posy = $pdf->getY();
1371 $pdf->SetXY($posx + 2, $posy);
1372 $pdf->SetFont(
'',
'', $default_font_size - 1);
1373 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1377 $usecontact =
false;
1378 $arrayidcontact = $object->getIdContact(
'external',
'STDEST');
1379 if (count($arrayidcontact) > 0) {
1381 $result = $object->fetch_contact($arrayidcontact[0]);
1387 $thirdparty = $object->contact;
1389 $thirdparty = $object->thirdparty;
1394 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1397 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1398 if ($this->page_largeur < 210) $widthrecbox = 84;
1399 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1400 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1401 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1404 $pdf->SetTextColor(0, 0, 0);
1405 $pdf->SetFont(
'',
'', $default_font_size - 2);
1406 $pdf->SetXY($posx + 2, $posy - 5);
1407 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1408 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1411 $pdf->SetXY($posx + 2, $posy + 3);
1412 $pdf->SetFont(
'',
'B', $default_font_size);
1413 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1415 $posy = $pdf->getY();
1418 $pdf->SetFont(
'',
'', $default_font_size - 1);
1419 $pdf->SetXY($posx + 2, $posy);
1420 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1423 $pdf->SetTextColor(0, 0, 0);