155 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
158 global $user, $langs,
$conf,
$mysoc, $db, $hookmanager, $nblines;
160 '@phan-var-force StockTransfer $object';
162 if (!is_object($outputlangs)) {
163 $outputlangs = $langs;
167 $outputlangs->charset_output =
'ISO-8859-1';
172 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"sendings",
"productbatch",
"stocks",
"stocktransfer@stocktransfer"));
174 global $outputlangsbis;
175 $outputlangsbis =
null;
179 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"sendings",
"productbatch"));
190 $realpatharray = array();
191 $this->atleastonephoto =
false;
193 $objphoto =
new Product($this->db);
195 for ($i = 0; $i < $nblines; $i++) {
196 if (empty(
$object->lines[$i]->fk_product)) {
200 $objphoto->fetch(
$object->lines[$i]->fk_product);
204 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
205 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
207 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
208 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
213 foreach ($pdir as $midir) {
215 $dir =
$conf->product->dir_output.
'/'.$midir;
217 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
219 if ($obj[
'photo_vignette']) {
220 $filename = $obj[
'photo_vignette'];
222 $filename = $obj[
'photo'];
225 $filename = $obj[
'photo'];
228 $realpath = $dir.$filename;
230 $this->atleastonephoto =
true;
235 if ($realpath && $arephoto) {
236 $realpatharray[$i] = $realpath;
243 if (
$conf->stocktransfer->dir_output) {
250 $dir =
$conf->stocktransfer->multidir_output[
$conf->entity];
251 $file = $dir.
"/SPECIMEN.pdf";
254 $dir =
$conf->stocktransfer->multidir_output[
$conf->entity].
"/".
$object->element.
"/".$objectref;
255 $file = $dir.
"/".$objectref.
"-proforma.pdf";
258 if (!file_exists($dir)) {
260 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
265 if (file_exists($dir)) {
267 if (!is_object($hookmanager)) {
268 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
271 $hookmanager->initHooks(array(
'pdfgeneration'));
272 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
274 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
282 $pdf->setAutoPageBreak(
true, 0);
284 $heightforinfotot = 40;
286 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
287 $pdf->setAutoPageBreak(
true, 0);
289 if (class_exists(
'TCPDF')) {
290 $pdf->setPrintHeader(
false);
291 $pdf->setPrintFooter(
false);
296 $logodir =
$conf->mycompany->dir_output;
297 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
300 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
301 $tplidx = $pdf->importPage(1);
306 $pdf->SetDrawColor(128, 128, 128);
308 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
309 $pdf->SetSubject($outputlangs->transnoentities(
"StockTransferSheetProforma"));
310 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
311 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
312 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"StockTransfer"));
314 $pdf->SetCompression(
false);
318 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
321 if (is_array(
$object->lines)) {
322 foreach (
$object->lines as $line) {
323 if ($line->remise_percent) {
324 $this->atleastonediscount =
true;
332 if (!empty($tplidx)) {
333 $pdf->useTemplate($tplidx);
337 $pdf->SetFont(
'',
'', $default_font_size - 1);
338 $pdf->MultiCell(0, 3,
'');
339 $pdf->SetTextColor(0, 0, 0);
342 $tab_top = 90 + $top_shift;
343 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
347 $height_incoterms = 0;
349 $desc_incoterms =
$object->getIncotermsForPDF();
350 if ($desc_incoterms) {
353 $pdf->SetFont(
'',
'', $default_font_size - 1);
354 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
355 $nexY = $pdf->GetY();
356 $height_incoterms = $nexY - $tab_top;
359 $pdf->SetDrawColor(192, 192, 192);
360 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
362 $tab_top = $nexY + 6;
363 $height_incoterms += 4;
371 if (is_object(
$object->thirdparty)) {
372 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
373 $salerepobj =
new User($this->db);
374 $salerepobj->fetch($salereparray[0][
'id']);
375 if (!empty($salerepobj->signature)) {
376 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
382 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
383 if (!empty($extranote)) {
387 $pagenb = $pdf->getPage();
389 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
390 $pageposbeforenote = $pagenb;
399 $pdf->startTransaction();
401 $pdf->SetFont(
'',
'', $default_font_size - 1);
402 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
404 $pageposafternote = $pdf->getPage();
405 $posyafter = $pdf->GetY();
407 if ($pageposafternote > $pageposbeforenote) {
408 $pdf->rollbackTransaction(
true);
411 while ($pagenb < $pageposafternote) {
414 if (!empty($tplidx)) {
415 $pdf->useTemplate($tplidx);
421 $pdf->setTopMargin($tab_top_newpage);
423 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
427 $pdf->setPage($pageposbeforenote);
428 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
429 $pdf->SetFont(
'',
'', $default_font_size - 1);
430 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
431 $pageposafternote = $pdf->getPage();
433 $posyafter = $pdf->GetY();
435 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
436 $pdf->AddPage(
'',
'',
true);
439 $pdf->setPage($pageposafternote);
440 $pdf->setTopMargin($tab_top_newpage);
442 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
448 $i = $pageposbeforenote;
449 while ($i < $pageposafternote) {
453 $pdf->SetDrawColor(128, 128, 128);
455 if ($i > $pageposbeforenote) {
456 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
457 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
459 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
460 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
464 $pdf->setPageOrientation(
'',
true, 0);
471 $pdf->setPage($pageposafternote);
472 if (!empty($tplidx)) {
473 $pdf->useTemplate($tplidx);
478 $height_note = $posyafter - $tab_top_newpage;
479 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
481 $pdf->commitTransaction();
482 $posyafter = $pdf->GetY();
483 $height_note = $posyafter - $tab_top;
484 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
487 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
489 $pdf->AddPage(
'',
'',
true);
492 $pdf->setPage($pageposafternote);
493 if (!empty($tplidx)) {
494 $pdf->useTemplate($tplidx);
500 $posyafter = $tab_top_newpage;
504 $tab_height -= $height_note;
505 $tab_top = $posyafter + 6;
515 $pdf->startTransaction();
516 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
517 $pdf->rollbackTransaction(
true);
519 $nexY = $tab_top + $this->tabTitleHeight;
522 $pageposbeforeprintlines = $pdf->getPage();
523 $pagenb = $pageposbeforeprintlines;
524 for ($i = 0; $i < $nblines; $i++) {
526 $pdf->SetFont(
'',
'', $default_font_size - 1);
527 $pdf->SetTextColor(0, 0, 0);
530 $imglinesize = array();
531 if (!empty($realpatharray[$i])) {
535 $pdf->setTopMargin($tab_top_newpage);
536 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
537 $pageposbefore = $pdf->getPage();
540 $showpricebeforepagebreak = 1;
545 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
546 $pdf->AddPage(
'',
'',
true);
547 if (!empty($tplidx)) {
548 $pdf->useTemplate($tplidx);
550 $pdf->setPage($pageposbefore + 1);
552 $curY = $tab_top_newpage;
556 $showpricebeforepagebreak = 1;
558 $showpricebeforepagebreak = 0;
562 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
563 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
565 $posYAfterImage = $curY + $imglinesize[
'height'];
570 $pdf->startTransaction();
572 if (method_exists(
$object->lines[$i],
'fetch_product')) {
573 $object->lines[$i]->fetch_product();
575 $object->lines[$i]->description =
$object->lines[$i]->product->description;
576 $object->lines[$i]->fk_unit =
$object->lines[$i]->product->fk_unit;
581 $pageposafter = $pdf->getPage();
582 if ($pageposafter > $pageposbefore) {
583 $pdf->rollbackTransaction(
true);
584 $pageposafter = $pageposbefore;
586 $pdf->setPageOrientation(
'',
true, $heightforfooter);
589 $pageposafter = $pdf->getPage();
590 $posyafter = $pdf->GetY();
591 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
592 if ($i == ($nblines - 1)) {
593 $pdf->AddPage(
'',
'',
true);
594 if (!empty($tplidx)) {
595 $pdf->useTemplate($tplidx);
598 $pdf->setPage($pageposafter + 1);
604 $showpricebeforepagebreak = 1;
606 $showpricebeforepagebreak = 0;
610 $pdf->commitTransaction();
616 $nexY = max($pdf->GetY(), $posYAfterImage);
619 $pageposafter = $pdf->getPage();
621 $pdf->setPage($pageposbefore);
622 $pdf->setTopMargin($this->marge_haute);
623 $pdf->setPageOrientation(
'',
true, 0);
626 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
627 $pdf->setPage($pageposafter);
628 $curY = $tab_top_newpage;
631 $pdf->SetFont(
'',
'', $default_font_size - 1);
637 $nexY = max($pdf->GetY(), $nexY);
642 $pmp =
$object->lines[$i]->pmp;
644 $nexY = max($pdf->GetY(), $nexY);
654 $nexY = max($pdf->GetY(), $nexY);
662 $nexY = max($pdf->GetY(), $nexY);
669 $nexY = max($pdf->GetY(), $nexY);
674 $pmp_qty = $pmp *
$object->lines[$i]->qty;
676 $nexY = max($pdf->GetY(), $nexY);
680 if (!empty(
$object->lines[$i]->array_options)) {
681 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
685 $nexY = max($pdf->GetY(), $nexY);
696 'outputlangs' => $outputlangs,
697 'hidedetails' => $hidedetails
699 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
704 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
706 $tvaligne =
$object->lines[$i]->total_tva;
754 $pdf->setPage($pageposafter);
755 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
757 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
758 $pdf->SetLineStyle(array(
'dash' => 0));
763 while ($pagenb < $pageposafter) {
764 $pdf->setPage($pagenb);
765 if ($pagenb == $pageposbeforeprintlines) {
766 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
768 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
772 $pdf->setPage($pagenb);
773 $pdf->setPageOrientation(
'',
true, 0);
778 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
779 if ($pagenb == $pageposafter) {
780 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
782 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
787 if (!empty($tplidx)) {
788 $pdf->useTemplate($tplidx);
798 if ($pagenb == $pageposbeforeprintlines) {
799 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
801 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
803 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
810 if (method_exists($pdf,
'AliasNbPages')) {
811 $pdf->AliasNbPages();
816 $pdf->Output($file,
'F');
819 $hookmanager->initHooks(array(
'pdfgeneration'));
820 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
822 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
823 $this->warnings = $hookmanager->warnings;
825 $this->error = $hookmanager->error;
826 $this->errors = $hookmanager->errors;
833 $this->result = array(
'fullpath' => $file);
837 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
841 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
858 '@phan-var-force Commande|Propal|Facture $object';
862 $pdf->SetFont(
'',
'', $default_font_size - 1);
865 if ($this->emetteur->country_code ==
'FR' && empty(
$mysoc->tva_assuj)) {
866 $pdf->SetFont(
'',
'B', $default_font_size - 2);
867 $pdf->SetXY($this->marge_gauche, $posy);
868 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
870 $posy = $pdf->GetY() + 4;
877 $pdf->SetFont(
'',
'B', $default_font_size - 2);
878 $pdf->SetXY($this->marge_gauche, $posy);
879 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
880 $pdf->MultiCell(43, 4, $titre, 0,
'L');
882 $pdf->SetFont(
'',
'', $default_font_size - 2);
883 $pdf->SetXY($posxval, $posy);
884 $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);
885 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
886 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
888 $posy = $pdf->GetY() + 3;
919 if (!empty(
$object->delivery_date)) {
920 $outputlangs->load(
"sendings");
921 $pdf->SetFont(
'',
'B', $default_font_size - 2);
922 $pdf->SetXY($this->marge_gauche, $posy);
923 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
924 $pdf->MultiCell(80, 4, $titre, 0,
'L');
925 $pdf->SetFont(
'',
'', $default_font_size - 2);
926 $pdf->SetXY($posxval, $posy);
928 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
930 $posy = $pdf->GetY() + 1;
931 } elseif (property_exists(
$object,
'availability_code')
932 && property_exists(
$object,
'availability')
940 $pdf->SetFont(
'',
'B', $default_font_size - 2);
941 $pdf->SetXY($this->marge_gauche, $posy);
942 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
943 $pdf->MultiCell(80, 4, $titre, 0,
'L');
944 $pdf->SetTextColor(0, 0, 0);
945 $pdf->SetFont(
'',
'', $default_font_size - 2);
946 $pdf->SetXY($posxval, $posy);
947 $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 :
'');
948 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
949 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
951 $posy = $pdf->GetY() + 1;
955 if (
$object->mode_reglement_code
956 &&
$object->mode_reglement_code !=
'CHQ'
957 &&
$object->mode_reglement_code !=
'VIR') {
958 $pdf->SetFont(
'',
'B', $default_font_size - 2);
959 $pdf->SetXY($this->marge_gauche, $posy);
960 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
961 $pdf->MultiCell(80, 5, $titre, 0,
'L');
963 $pdf->SetFont(
'',
'', $default_font_size - 2);
964 $pdf->SetXY($posxval, $posy);
965 $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);
966 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
968 $posy = $pdf->GetY() + 2;
972 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
976 $account =
new Account($this->db);
979 $pdf->SetXY($this->marge_gauche, $posy);
980 $pdf->SetFont(
'',
'B', $default_font_size - 3);
981 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
982 $posy = $pdf->GetY() + 1;
985 $pdf->SetXY($this->marge_gauche, $posy);
986 $pdf->SetFont(
'',
'', $default_font_size - 3);
987 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
988 $posy = $pdf->GetY() + 2;
992 $pdf->SetXY($this->marge_gauche, $posy);
993 $pdf->SetFont(
'',
'B', $default_font_size - 3);
994 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
995 $posy = $pdf->GetY() + 1;
998 $pdf->SetXY($this->marge_gauche, $posy);
999 $pdf->SetFont(
'',
'', $default_font_size - 3);
1000 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1001 $posy = $pdf->GetY() + 2;
1008 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1010 $bankid = (empty(
$object->fk_account) ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1011 if (!empty(
$object->fk_bank)) {
1014 $account =
new Account($this->db);
1015 $account->fetch($bankid);
1017 $curx = $this->marge_gauche;
1020 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1048 $pdf->SetFont(
'',
'', $default_font_size - 1);
1053 if ($this->page_largeur < 210) {
1056 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1060 $outputlangsbis =
null;
1064 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1076 $pdf->SetFillColor(248, 248, 248);
1078 $total_ttc =
$object->getValorisationTotale();
1080 $this->atleastoneratenotnull = 0;
1084 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1085 $pdf->SetTextColor(0, 0, 60);
1086 $pdf->SetFillColor(224, 224, 224);
1087 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"Total",
$mysoc->country_code) :
''), $useborder,
'L',
true);
1089 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1090 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1092 $pdf->SetTextColor(0, 0, 0);
1094 $creditnoteamount = 0;
1095 $depositsamount = 0;
1099 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1104 if ($deja_regle > 0) {
1108 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1109 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1110 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1111 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1114 $pdf->SetTextColor(0, 0, 60);
1115 $pdf->SetFillColor(224, 224, 224);
1116 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1117 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L',
true);
1119 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1120 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1122 $pdf->SetFont(
'',
'', $default_font_size - 1);
1123 $pdf->SetTextColor(0, 0, 0);
1127 return ($tab2_top + ($tab2_hl * $index));
1198 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1201 global
$conf, $langs;
1203 '@phan-var-force StockTransfer $object';
1206 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1217 $pdf->SetTextColor(0, 0, 60);
1218 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1222 $posy = $this->marge_haute;
1223 $posx = $this->page_largeur - $this->marge_droite - $w;
1225 $pdf->SetXY($this->marge_gauche, $posy);
1229 if ($this->emetteur->logo) {
1230 $logodir =
$conf->mycompany->dir_output;
1231 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
1235 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1237 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1239 if (is_readable($logo)) {
1241 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1243 $pdf->SetTextColor(200, 0, 0);
1244 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1245 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1246 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1249 $text = $this->emetteur->name;
1250 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1254 $pdf->SetDrawColor(128, 128, 128);
1256 $posx = $this->page_largeur - $w - $this->marge_droite;
1257 $posy = $this->marge_haute;
1259 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1260 $pdf->SetXY($posx, $posy);
1261 $pdf->SetTextColor(0, 0, 60);
1262 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.
$object->ref;
1263 $pdf->MultiCell($w, 4, $title,
'',
'R');
1265 $pdf->SetFont(
'',
'', $default_font_size + 1);
1268 if (!empty(
$object->date_prevue_depart)) {
1270 $pdf->SetXY($posx, $posy);
1271 $pdf->SetTextColor(0, 0, 60);
1272 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date(
$object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1276 if (!empty(
$object->date_prevue_arrivee)) {
1278 $pdf->SetXY($posx, $posy);
1279 $pdf->SetTextColor(0, 0, 60);
1280 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date(
$object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1284 if (!empty(
$object->date_reelle_depart)) {
1286 $pdf->SetXY($posx, $posy);
1287 $pdf->SetTextColor(0, 0, 60);
1288 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date(
$object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1292 if (!empty(
$object->date_reelle_arrivee)) {
1294 $pdf->SetXY($posx, $posy);
1295 $pdf->SetTextColor(0, 0, 60);
1296 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date(
$object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1299 if (!empty(
$object->thirdparty->code_client)) {
1301 $pdf->SetXY($posx, $posy);
1302 $pdf->SetTextColor(0, 0, 60);
1303 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
1308 $pdf->SetXY($posx, $posy);
1309 $pdf->SetTextColor(0, 0, 60);
1310 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1315 if (!empty(
$object->project->ref)) {
1317 $pdf->SetXY($posx, $posy);
1318 $pdf->SetTextColor(0, 0, 60);
1319 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1325 if (!empty(
$object->project->ref)) {
1327 $pdf->SetXY($posx, $posy);
1328 $pdf->SetTextColor(0, 0, 60);
1329 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1335 $pdf->SetXY($posx, $posy);
1336 $pdf->SetTextColor(0, 0, 60);
1337 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
1342 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1343 if (count($arrayidcontact) > 0) {
1344 $usertmp =
new User($this->db);
1345 $usertmp->fetch($arrayidcontact[0]);
1347 $pdf->SetXY($posx, $posy);
1348 $pdf->SetTextColor(0, 0, 60);
1349 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1357 $current_y = $pdf->getY();
1359 if ($current_y < $pdf->getY()) {
1360 $top_shift = $pdf->getY() - $current_y;
1365 $carac_emetteur =
'';
1367 $arrayidcontact = array();
1368 $arrayidcontact =
$object->getIdContact(
'external',
'STFROM');
1370 $usecontact =
false;
1371 if (count($arrayidcontact) > 0) {
1375 $result =
$object->fetch_contact($arrayidcontact[0]);
1379 $thirdparty =
$object->contact;
1381 $thirdparty = $this->emetteur;
1384 if (!empty($thirdparty)) {
1387 $carac_emetteur_name =
'';
1398 $posx = $this->marge_gauche;
1400 $posx = $this->page_largeur - $this->marge_droite - 80;
1407 $pdf->SetTextColor(0, 0, 0);
1408 $pdf->SetFont(
'',
'', $default_font_size - 2);
1409 $pdf->SetXY($posx, $posy - 5);
1410 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1411 $pdf->SetXY($posx, $posy);
1412 $pdf->SetFillColor(230, 230, 230);
1413 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1414 $pdf->SetTextColor(0, 0, 60);
1415 $pdf->SetFillColor(255, 255, 255);
1418 $pdf->SetXY($posx + 2, $posy + 3);
1419 $pdf->SetFont(
'',
'B', $default_font_size);
1420 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1421 $posy = $pdf->getY();
1424 $pdf->SetXY($posx + 2, $posy);
1425 $pdf->SetFont(
'',
'', $default_font_size - 1);
1426 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1430 $usecontact =
false;
1431 $arrayidcontact =
$object->getIdContact(
'external',
'STDEST');
1432 if (count($arrayidcontact) > 0) {
1434 $result =
$object->fetch_contact($arrayidcontact[0]);
1440 $thirdparty =
$object->contact;
1442 $thirdparty =
$object->thirdparty;
1445 $carac_client_name =
'';
1446 if (!empty($thirdparty)) {
1454 if ($this->page_largeur < 210) {
1458 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1460 $posx = $this->marge_gauche;
1464 $pdf->SetTextColor(0, 0, 0);
1465 $pdf->SetFont(
'',
'', $default_font_size - 2);
1466 $pdf->SetXY($posx + 2, $posy - 5);
1467 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1468 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1471 $pdf->SetXY($posx + 2, $posy + 3);
1472 $pdf->SetFont(
'',
'B', $default_font_size);
1473 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1475 $posy = $pdf->getY();
1478 $pdf->SetFont(
'',
'', $default_font_size - 1);
1479 $pdf->SetXY($posx + 2, $posy);
1480 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1483 $pdf->SetTextColor(0, 0, 0);