188 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
191 global $db, $user, $conf, $langs, $hookmanager;
193 $object->fetch_thirdparty();
197 if (!is_object($outputlangs)) $outputlangs = $langs;
199 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
202 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch",
"stocks",
"stocktransfer@stocktransfer"));
204 $nblines = is_array($object->lines) ? count($object->lines) : 0;
207 $realpatharray = array();
208 if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) {
209 $objphoto =
new Product($this->db);
211 for ($i = 0; $i < $nblines; $i++) {
212 if (empty($object->lines[$i]->fk_product))
continue;
214 $objphoto =
new Product($this->db);
215 $objphoto->fetch($object->lines[$i]->fk_product);
217 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
218 $dir = $conf->product->dir_output.
'/'.$pdir;
220 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
221 $dir = $conf->product->dir_output.
'/'.$pdir;
226 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
229 if ($obj[
'photo_vignette']) {
230 $filename = $obj[
'photo_vignette'];
232 $filename = $obj[
'photo'];
235 $filename = $obj[
'photo'];
238 $realpath = $dir.$filename;
242 if ($realpath) $realpatharray[$i] = $realpath;
246 if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
250 $this->posxpicture = $this->posxlot;
251 if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
254 if ($conf->stocktransfer->dir_output) {
256 if ($object->specimen) {
257 $dir = $conf->stocktransfer->dir_output;
258 $file = $dir.
"/SPECIMEN.pdf";
261 $dir = $conf->stocktransfer->dir_output.
'/'.$object->element.
"/".$stocktransferref;
262 $file = $dir.
"/".$stocktransferref.
".pdf";
265 if (!file_exists($dir)) {
267 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
272 if (file_exists($dir)) {
274 if (!is_object($hookmanager)) {
275 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
278 $hookmanager->initHooks(array(
'pdfgeneration'));
279 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
281 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
284 $nblines = is_array($object->lines) ? count($object->lines) : 0;
288 $heightforinfotot = 8;
289 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
290 $heightforfooter = $this->marge_basse + 8;
291 if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
292 $pdf->SetAutoPageBreak(1, 0);
294 if (class_exists(
'TCPDF')) {
295 $pdf->setPrintHeader(
false);
296 $pdf->setPrintFooter(
false);
300 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
301 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
302 $tplidx = $pdf->importPage(1);
307 $pdf->SetDrawColor(128, 128, 128);
309 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
311 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
312 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
313 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
314 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
315 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
317 $pdf->SetCompression(
false);
320 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
324 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
326 $this->
_pagehead($pdf, $object, 1, $outputlangs);
327 $pdf->SetFont(
'',
'', $default_font_size - 1);
328 $pdf->MultiCell(0, 3,
'');
329 $pdf->SetTextColor(0, 0, 0);
332 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
334 $tab_height_newpage = 150;
337 $height_incoterms = 0;
338 if ($conf->incoterm->enabled) {
339 $desc_incoterms = $object->getIncotermsForPDF();
340 if ($desc_incoterms) {
343 $pdf->SetFont(
'',
'', $default_font_size - 1);
344 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
345 $nexY = $pdf->GetY();
346 $height_incoterms = $nexY - $tab_top;
349 $pdf->SetDrawColor(192, 192, 192);
350 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
352 $tab_top = $nexY + 6;
353 $height_incoterms += 4;
357 if (!empty($object->note_public) || !empty($object->tracking_number)) {
358 $tab_top = 88 + $height_incoterms;
359 $tab_top_alt = $tab_top;
361 $pdf->SetFont(
'',
'B', $default_font_size - 2);
366 if (!empty($object->tracking_number)) {
367 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
368 $tab_top_alt = $pdf->GetY();
370 $object->getUrlTrackingStatus($object->tracking_number);
371 if (!empty($object->tracking_url)) {
372 if ($object->shipping_method_id > 0) {
374 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
376 if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
377 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
379 if ($object->tracking_url != $object->tracking_number) {
381 $label .= $object->tracking_url;
383 $pdf->SetFont(
'',
'B', $default_font_size - 2);
384 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
386 $tab_top_alt = $pdf->GetY();
392 if (!empty($object->note_public)) {
393 $pdf->SetFont(
'',
'', $default_font_size - 1);
394 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
397 $nexY = $pdf->GetY();
398 $height_note = $nexY - $tab_top;
401 $pdf->SetDrawColor(192, 192, 192);
402 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
404 $tab_height = $tab_height - $height_note;
405 $tab_top = $nexY + 6;
410 $iniY = $tab_top + 7;
411 $curY = $tab_top + 7;
412 $nexY = $tab_top + 7;
414 $TCacheEntrepots=array();
416 for ($i = 0; $i < $nblines; $i++) {
418 $pdf->SetFont(
'',
'', $default_font_size - 1);
419 $pdf->SetTextColor(0, 0, 0);
422 $imglinesize = array();
425 $pdf->setTopMargin($tab_top_newpage);
426 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
427 $pageposbefore = $pdf->getPage();
429 $showpricebeforepagebreak = 1;
431 $posYAfterDescription = 0;
434 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
435 $pdf->AddPage(
'',
'',
true);
436 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
438 $pdf->setPage($pageposbefore + 1);
440 $curY = $tab_top_newpage;
443 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
444 $showpricebeforepagebreak = 1;
445 else $showpricebeforepagebreak = 0;
448 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
449 $curX = $this->posxpicture - 1;
450 $pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxweightvol - $imglinesize[
'width']
451 + (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME) ? (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) : 0)) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
453 $posYAfterImage = $curY + $imglinesize[
'height'];
457 $curX = $this->posxdesc - 1;
459 $pdf->startTransaction();
460 if (method_exists($object->lines[$i],
'fetch_product')) {
461 $object->lines[$i]->fetch_product();
462 $object->lines[$i]->label = $object->lines[$i]->product->label;
463 $object->lines[$i]->description = $object->lines[$i]->product->description;
464 $object->lines[$i]->weight = $object->lines[$i]->product->weight;
465 $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
466 $object->lines[$i]->length = $object->lines[$i]->product->length;
467 $object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
468 $object->lines[$i]->surface = $object->lines[$i]->product->surface;
469 $object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units;
470 $object->lines[$i]->volume = $object->lines[$i]->product->volume;
471 $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
472 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
476 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
478 $pageposafter = $pdf->getPage();
479 if ($pageposafter > $pageposbefore) {
480 $pdf->rollbackTransaction(
true);
481 $pageposafter = $pageposbefore;
483 $pdf->setPageOrientation(
'', 1, $heightforfooter);
484 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
486 $pageposafter = $pdf->getPage();
487 $posyafter = $pdf->GetY();
489 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
490 if ($i == ($nblines - 1)) {
491 $pdf->AddPage(
'',
'',
true);
492 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
494 $pdf->setPage($pageposafter + 1);
500 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
501 $showpricebeforepagebreak = 1;
502 else $showpricebeforepagebreak = 0;
506 $pdf->commitTransaction();
508 $posYAfterDescription = $pdf->GetY();
510 $nexY = $pdf->GetY();
511 $pageposafter = $pdf->getPage();
513 $pdf->setPage($pageposbefore);
514 $pdf->setTopMargin($this->marge_haute);
515 $pdf->setPageOrientation(
'', 1, 0);
518 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
519 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
523 if ($pageposafter > $pageposbefore) {
524 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
527 $pdf->SetFont(
'',
'', $default_font_size - 1);
530 if (isModEnabled(
'productbatch')) {
531 $pdf->SetXY($this->posxlot, $curY);
532 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch,
'',
'C');
536 $pdf->SetXY($this->posxweightvol, $curY);
538 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
539 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
542 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
543 $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
547 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
548 $pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
553 $pdf->SetXY($this->posxqty, $curY);
554 $pdf->writeHTMLCell($this->posxwarehousesource - $this->posxqty + 2, 3, $this->posxqty - 1, $curY, $object->lines[$i]->qty, 0, 0,
false,
true,
'C');
559 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
561 $wh_source->fetch($object->lines[$i]->fk_warehouse_source);
562 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
564 $pdf->SetXY($this->posxwarehousesource, $curY);
565 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 3, $wh_source->ref.(!empty($wh_source->lieu) ?
' - '.$wh_source->lieu :
''),
'',
'C');
568 $wh_destination =
new Entrepot($db);
569 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
571 $wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
572 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
574 $pdf->SetXY($this->posxwarehousedestination, $curY);
575 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ?
' - '.$wh_destination->lieu :
''),
'',
'C');
577 if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
578 $pdf->SetXY($this->posxpuht, $curY);
579 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
581 $pdf->SetXY($this->posxtotalht, $curY);
582 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
586 if ($weighttxt && $voltxt) $nexY += 2;
589 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
590 $pdf->setPage($pageposafter);
591 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
593 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
594 $pdf->SetLineStyle(array(
'dash'=>0));
598 while ($pagenb < $pageposafter) {
599 $pdf->setPage($pagenb);
601 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
603 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
605 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
607 $pdf->setPage($pagenb);
608 $pdf->setPageOrientation(
'', 1, 0);
611 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
613 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
615 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
617 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
620 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
628 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
629 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
631 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
632 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
636 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
639 $this->
_pagefoot($pdf, $object, $outputlangs);
640 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
644 $pdf->Output($file,
'F');
647 $hookmanager->initHooks(array(
'pdfgeneration'));
648 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
650 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
652 $this->error = $hookmanager->error;
653 $this->errors = $hookmanager->errors;
658 $this->result = array(
'fullpath'=>$file);
662 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
666 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
897 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
900 global $conf, $langs, $mysoc;
902 $langs->load(
"orders");
909 if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
910 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
914 $pdf->SetTextColor(0, 0, 60);
915 $pdf->SetFont(
'',
'B', $default_font_size + 3);
919 $posy = $this->marge_haute;
920 $posx = $this->page_largeur - $this->marge_droite - $w;
922 $pdf->SetXY($this->marge_gauche, $posy);
925 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
926 if ($this->emetteur->logo) {
927 if (is_readable($logo)) {
929 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
931 $pdf->SetTextColor(200, 0, 0);
932 $pdf->SetFont(
'',
'B', $default_font_size - 2);
933 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
934 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
937 $text = $this->emetteur->name;
938 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
942 if (isModEnabled(
'barcode')) {
945 $posx = $this->marge_gauche + 3;
948 if (isModEnabled(
'barcode')) {
954 $pdf->SetDrawColor(128, 128, 128);
955 if (isModEnabled(
'barcode')) {
962 $posx = $this->page_largeur - $w - $this->marge_droite;
963 $posy = $this->marge_haute;
965 $pdf->SetFont(
'',
'B', $default_font_size + 2);
966 $pdf->SetXY($posx, $posy);
967 $pdf->SetTextColor(0, 0, 60);
968 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.$object->ref;
969 $pdf->MultiCell($w, 4, $title,
'',
'R');
971 $pdf->SetFont(
'',
'', $default_font_size + 1);
974 if (!empty($object->date_prevue_depart)) {
976 $pdf->SetXY($posx, $posy);
977 $pdf->SetTextColor(0, 0, 60);
978 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date($object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
982 if (!empty($object->date_prevue_arrivee)) {
984 $pdf->SetXY($posx, $posy);
985 $pdf->SetTextColor(0, 0, 60);
986 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date($object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
990 if (!empty($object->date_reelle_depart)) {
992 $pdf->SetXY($posx, $posy);
993 $pdf->SetTextColor(0, 0, 60);
994 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date($object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
998 if (!empty($object->date_reelle_arrivee)) {
1000 $pdf->SetXY($posx, $posy);
1001 $pdf->SetTextColor(0, 0, 60);
1002 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date($object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1005 if (!empty($object->thirdparty->code_client)) {
1007 $pdf->SetXY($posx, $posy);
1008 $pdf->SetTextColor(0, 0, 60);
1009 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1013 $pdf->SetFont(
'',
'', $default_font_size + 3);
1017 $origin = $object->origin;
1018 $origin_id = $object->origin_id;
1021 if (!empty($conf->$origin->enabled)) {
1022 $outputlangs->load(
'orders');
1024 $classname = ucfirst($origin);
1025 $linkedobject =
new $classname($this->db);
1026 $result = $linkedobject->fetch($origin_id);
1030 $pdf->SetFont(
'',
'', $default_font_size - 2);
1031 $text = $linkedobject->ref;
1032 if ($linkedobject->ref_client) $text .=
' ('.$linkedobject->ref_client.
')';
1034 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1035 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1037 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1038 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1044 $carac_emetteur =
'';
1046 $arrayidcontact = array();
1047 $arrayidcontact = $object->getIdContact(
'external',
'STFROM');
1049 $usecontact =
false;
1050 if (count($arrayidcontact) > 0) {
1054 $result = $object->fetch_contact($arrayidcontact[0]);
1057 if ($usecontact) $thirdparty = $object->contact;
1058 else $thirdparty = $this->emetteur;
1062 if ($usecontact) $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1,
'targetwithdetails', $object);
1063 else $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1066 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1067 $posx = $this->marge_gauche;
1068 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1070 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1071 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1074 $pdf->SetTextColor(0, 0, 0);
1075 $pdf->SetFont(
'',
'', $default_font_size - 2);
1076 $pdf->SetXY($posx, $posy - 5);
1077 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1078 $pdf->SetXY($posx, $posy);
1079 $pdf->SetFillColor(230, 230, 230);
1080 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1081 $pdf->SetTextColor(0, 0, 60);
1082 $pdf->SetFillColor(255, 255, 255);
1085 $pdf->SetXY($posx + 2, $posy + 3);
1086 $pdf->SetFont(
'',
'B', $default_font_size);
1087 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1088 $posy = $pdf->getY();
1091 $pdf->SetXY($posx + 2, $posy);
1092 $pdf->SetFont(
'',
'', $default_font_size - 1);
1093 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1097 $usecontact =
false;
1098 $arrayidcontact = $object->getIdContact(
'external',
'STDEST');
1099 if (count($arrayidcontact) > 0) {
1101 $result = $object->fetch_contact($arrayidcontact[0]);
1107 $thirdparty = $object->contact;
1109 $thirdparty = $object->thirdparty;
1114 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1117 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1118 if ($this->page_largeur < 210) $widthrecbox = 84;
1119 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1120 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1121 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1124 $pdf->SetTextColor(0, 0, 0);
1125 $pdf->SetFont(
'',
'', $default_font_size - 2);
1126 $pdf->SetXY($posx + 2, $posy - 5);
1127 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1128 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1131 $pdf->SetXY($posx + 2, $posy + 3);
1132 $pdf->SetFont(
'',
'B', $default_font_size);
1133 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1135 $posy = $pdf->getY();
1138 $pdf->SetFont(
'',
'', $default_font_size - 1);
1139 $pdf->SetXY($posx + 2, $posy);
1140 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1143 $pdf->SetTextColor(0, 0, 0);