154 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
157 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
159 '@phan-var-force StockTransfer $object';
161 if (!is_object($outputlangs)) {
162 $outputlangs = $langs;
166 $outputlangs->charset_output =
'ISO-8859-1';
171 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch",
"stocks",
"stocktransfer@stocktransfer"));
173 global $outputlangsbis;
174 $outputlangsbis =
null;
178 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
189 $realpatharray = array();
190 $this->atleastonephoto =
false;
192 $objphoto =
new Product($this->db);
194 for ($i = 0; $i < $nblines; $i++) {
195 if (empty(
$object->lines[$i]->fk_product)) {
199 $objphoto->fetch(
$object->lines[$i]->fk_product);
203 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
204 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
206 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
207 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
211 foreach ($pdir as $midir) {
213 $dir =
$conf->product->dir_output.
'/'.$midir;
215 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
217 if ($obj[
'photo_vignette']) {
218 $filename = $obj[
'photo_vignette'];
220 $filename = $obj[
'photo'];
223 $filename = $obj[
'photo'];
226 $realpath = $dir.$filename;
228 $this->atleastonephoto =
true;
233 if ($realpath && $arephoto) {
234 $realpatharray[$i] = $realpath;
241 if (
$conf->stocktransfer->dir_output) {
248 $dir =
$conf->stocktransfer->multidir_output[
$conf->entity];
249 $file = $dir.
"/SPECIMEN.pdf";
252 $dir =
$conf->stocktransfer->multidir_output[
$conf->entity].
"/".
$object->element.
"/".$objectref;
253 $file = $dir.
"/".$objectref.
"-proforma.pdf";
256 if (!file_exists($dir)) {
258 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
263 if (file_exists($dir)) {
265 if (!is_object($hookmanager)) {
266 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
269 $hookmanager->initHooks(array(
'pdfgeneration'));
270 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
272 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
280 $pdf->SetAutoPageBreak(1, 0);
282 $heightforinfotot = 40;
284 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
285 $pdf->SetAutoPageBreak(1, 0);
287 if (class_exists(
'TCPDF')) {
288 $pdf->setPrintHeader(
false);
289 $pdf->setPrintFooter(
false);
295 $tplidx = $pdf->importPage(1);
300 $pdf->SetDrawColor(128, 128, 128);
302 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
303 $pdf->SetSubject($outputlangs->transnoentities(
"StockTransferSheetProforma"));
304 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
305 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
306 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"StockTransfer"));
308 $pdf->SetCompression(
false);
312 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
315 if (is_array(
$object->lines)) {
316 foreach (
$object->lines as $line) {
317 if ($line->remise_percent) {
318 $this->atleastonediscount =
true;
326 if (!empty($tplidx)) {
327 $pdf->useTemplate($tplidx);
331 $pdf->SetFont(
'',
'', $default_font_size - 1);
332 $pdf->MultiCell(0, 3,
'');
333 $pdf->SetTextColor(0, 0, 0);
336 $tab_top = 90 + $top_shift;
337 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
341 $height_incoterms = 0;
342 if (isModEnabled(
'incoterm')) {
343 $desc_incoterms =
$object->getIncotermsForPDF();
344 if ($desc_incoterms) {
347 $pdf->SetFont(
'',
'', $default_font_size - 1);
348 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
349 $nexY = $pdf->GetY();
350 $height_incoterms = $nexY - $tab_top;
353 $pdf->SetDrawColor(192, 192, 192);
354 $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');
356 $tab_top = $nexY + 6;
357 $height_incoterms += 4;
362 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
365 if (is_object(
$object->thirdparty)) {
366 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
367 $salerepobj =
new User($this->db);
368 $salerepobj->fetch($salereparray[0][
'id']);
369 if (!empty($salerepobj->signature)) {
370 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
376 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
377 if (!empty($extranote)) {
381 $pagenb = $pdf->getPage();
383 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
384 $pageposbeforenote = $pagenb;
393 $pdf->startTransaction();
395 $pdf->SetFont(
'',
'', $default_font_size - 1);
396 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
398 $pageposafternote = $pdf->getPage();
399 $posyafter = $pdf->GetY();
401 if ($pageposafternote > $pageposbeforenote) {
402 $pdf->rollbackTransaction(
true);
405 while ($pagenb < $pageposafternote) {
408 if (!empty($tplidx)) {
409 $pdf->useTemplate($tplidx);
415 $pdf->setTopMargin($tab_top_newpage);
417 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
421 $pdf->setPage($pageposbeforenote);
422 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
423 $pdf->SetFont(
'',
'', $default_font_size - 1);
424 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
425 $pageposafternote = $pdf->getPage();
427 $posyafter = $pdf->GetY();
429 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
430 $pdf->AddPage(
'',
'',
true);
433 $pdf->setPage($pageposafternote);
434 $pdf->setTopMargin($tab_top_newpage);
436 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
442 $i = $pageposbeforenote;
443 while ($i < $pageposafternote) {
447 $pdf->SetDrawColor(128, 128, 128);
449 if ($i > $pageposbeforenote) {
450 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
451 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
453 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
454 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
458 $pdf->setPageOrientation(
'', 1, 0);
465 $pdf->setPage($pageposafternote);
466 if (!empty($tplidx)) {
467 $pdf->useTemplate($tplidx);
472 $height_note = $posyafter - $tab_top_newpage;
473 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
475 $pdf->commitTransaction();
476 $posyafter = $pdf->GetY();
477 $height_note = $posyafter - $tab_top;
478 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
481 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
483 $pdf->AddPage(
'',
'',
true);
486 $pdf->setPage($pageposafternote);
487 if (!empty($tplidx)) {
488 $pdf->useTemplate($tplidx);
494 $posyafter = $tab_top_newpage;
498 $tab_height -= $height_note;
499 $tab_top = $posyafter + 6;
509 $pdf->startTransaction();
510 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
511 $pdf->rollbackTransaction(
true);
513 $nexY = $tab_top + $this->tabTitleHeight;
516 $pageposbeforeprintlines = $pdf->getPage();
517 $pagenb = $pageposbeforeprintlines;
518 for ($i = 0; $i < $nblines; $i++) {
520 $pdf->SetFont(
'',
'', $default_font_size - 1);
521 $pdf->SetTextColor(0, 0, 0);
524 $imglinesize = array();
525 if (!empty($realpatharray[$i])) {
529 $pdf->setTopMargin($tab_top_newpage);
530 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
531 $pageposbefore = $pdf->getPage();
534 $showpricebeforepagebreak = 1;
539 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
540 $pdf->AddPage(
'',
'',
true);
541 if (!empty($tplidx)) {
542 $pdf->useTemplate($tplidx);
544 $pdf->setPage($pageposbefore + 1);
546 $curY = $tab_top_newpage;
550 $showpricebeforepagebreak = 1;
552 $showpricebeforepagebreak = 0;
556 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
557 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
559 $posYAfterImage = $curY + $imglinesize[
'height'];
564 $pdf->startTransaction();
566 if (method_exists(
$object->lines[$i],
'fetch_product')) {
567 $object->lines[$i]->fetch_product();
569 $object->lines[$i]->description =
$object->lines[$i]->product->description;
570 $object->lines[$i]->fk_unit =
$object->lines[$i]->product->fk_unit;
575 $pageposafter = $pdf->getPage();
576 if ($pageposafter > $pageposbefore) {
577 $pdf->rollbackTransaction(
true);
578 $pageposafter = $pageposbefore;
580 $pdf->setPageOrientation(
'', 1, $heightforfooter);
583 $pageposafter = $pdf->getPage();
584 $posyafter = $pdf->GetY();
585 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
586 if ($i == ($nblines - 1)) {
587 $pdf->AddPage(
'',
'',
true);
588 if (!empty($tplidx)) {
589 $pdf->useTemplate($tplidx);
592 $pdf->setPage($pageposafter + 1);
598 $showpricebeforepagebreak = 1;
600 $showpricebeforepagebreak = 0;
604 $pdf->commitTransaction();
610 $nexY = max($pdf->GetY(), $posYAfterImage);
613 $pageposafter = $pdf->getPage();
615 $pdf->setPage($pageposbefore);
616 $pdf->setTopMargin($this->marge_haute);
617 $pdf->setPageOrientation(
'', 1, 0);
620 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
621 $pdf->setPage($pageposafter);
622 $curY = $tab_top_newpage;
625 $pdf->SetFont(
'',
'', $default_font_size - 1);
631 $nexY = max($pdf->GetY(), $nexY);
636 $pmp =
$object->lines[$i]->pmp;
638 $nexY = max($pdf->GetY(), $nexY);
646 $nexY = max($pdf->GetY(), $nexY);
654 $nexY = max($pdf->GetY(), $nexY);
661 $nexY = max($pdf->GetY(), $nexY);
666 $pmp_qty = $pmp *
$object->lines[$i]->qty;
668 $nexY = max($pdf->GetY(), $nexY);
672 if (!empty(
$object->lines[$i]->array_options)) {
673 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
677 $nexY = max($pdf->GetY(), $nexY);
688 'outputlangs' => $outputlangs,
689 'hidedetails' => $hidedetails
691 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
695 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
696 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
698 $tvaligne =
$object->lines[$i]->total_tva;
746 $pdf->setPage($pageposafter);
747 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
749 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
750 $pdf->SetLineStyle(array(
'dash' => 0));
755 while ($pagenb < $pageposafter) {
756 $pdf->setPage($pagenb);
757 if ($pagenb == $pageposbeforeprintlines) {
758 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
760 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
764 $pdf->setPage($pagenb);
765 $pdf->setPageOrientation(
'', 1, 0);
770 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
771 if ($pagenb == $pageposafter) {
772 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
774 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
779 if (!empty($tplidx)) {
780 $pdf->useTemplate($tplidx);
790 if ($pagenb == $pageposbeforeprintlines) {
791 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
793 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
795 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
802 if (method_exists($pdf,
'AliasNbPages')) {
803 $pdf->AliasNbPages();
808 $pdf->Output($file,
'F');
811 $hookmanager->initHooks(array(
'pdfgeneration'));
812 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
814 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
816 $this->error = $hookmanager->error;
817 $this->errors = $hookmanager->errors;
822 $this->result = array(
'fullpath' => $file);
826 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
830 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
846 global
$conf, $mysoc;
847 '@phan-var-force Commande|Propal|Facture $object';
851 $pdf->SetFont(
'',
'', $default_font_size - 1);
854 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
855 $pdf->SetFont(
'',
'B', $default_font_size - 2);
856 $pdf->SetXY($this->marge_gauche, $posy);
857 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
859 $posy = $pdf->GetY() + 4;
866 $pdf->SetFont(
'',
'B', $default_font_size - 2);
867 $pdf->SetXY($this->marge_gauche, $posy);
868 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
869 $pdf->MultiCell(43, 4, $titre, 0,
'L');
871 $pdf->SetFont(
'',
'', $default_font_size - 2);
872 $pdf->SetXY($posxval, $posy);
873 $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);
874 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
875 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
877 $posy = $pdf->GetY() + 3;
908 if (!empty(
$object->delivery_date)) {
909 $outputlangs->load(
"sendings");
910 $pdf->SetFont(
'',
'B', $default_font_size - 2);
911 $pdf->SetXY($this->marge_gauche, $posy);
912 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
913 $pdf->MultiCell(80, 4, $titre, 0,
'L');
914 $pdf->SetFont(
'',
'', $default_font_size - 2);
915 $pdf->SetXY($posxval, $posy);
917 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
919 $posy = $pdf->GetY() + 1;
920 } elseif (property_exists(
$object,
'availability_code')
921 && property_exists(
$object,
'availability')
929 $pdf->SetFont(
'',
'B', $default_font_size - 2);
930 $pdf->SetXY($this->marge_gauche, $posy);
931 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
932 $pdf->MultiCell(80, 4, $titre, 0,
'L');
933 $pdf->SetTextColor(0, 0, 0);
934 $pdf->SetFont(
'',
'', $default_font_size - 2);
935 $pdf->SetXY($posxval, $posy);
936 $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 :
'');
937 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
938 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
940 $posy = $pdf->GetY() + 1;
944 if (
$object->mode_reglement_code
945 &&
$object->mode_reglement_code !=
'CHQ'
946 &&
$object->mode_reglement_code !=
'VIR') {
947 $pdf->SetFont(
'',
'B', $default_font_size - 2);
948 $pdf->SetXY($this->marge_gauche, $posy);
949 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
950 $pdf->MultiCell(80, 5, $titre, 0,
'L');
952 $pdf->SetFont(
'',
'', $default_font_size - 2);
953 $pdf->SetXY($posxval, $posy);
954 $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);
955 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
957 $posy = $pdf->GetY() + 2;
961 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
965 $account =
new Account($this->db);
968 $pdf->SetXY($this->marge_gauche, $posy);
969 $pdf->SetFont(
'',
'B', $default_font_size - 3);
970 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
971 $posy = $pdf->GetY() + 1;
974 $pdf->SetXY($this->marge_gauche, $posy);
975 $pdf->SetFont(
'',
'', $default_font_size - 3);
976 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
977 $posy = $pdf->GetY() + 2;
981 $pdf->SetXY($this->marge_gauche, $posy);
982 $pdf->SetFont(
'',
'B', $default_font_size - 3);
983 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
984 $posy = $pdf->GetY() + 1;
987 $pdf->SetXY($this->marge_gauche, $posy);
988 $pdf->SetFont(
'',
'', $default_font_size - 3);
989 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
990 $posy = $pdf->GetY() + 2;
997 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
999 $bankid = (empty(
$object->fk_account) ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1000 if (!empty(
$object->fk_bank)) {
1003 $account =
new Account($this->db);
1004 $account->fetch($bankid);
1006 $curx = $this->marge_gauche;
1009 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1031 global
$conf, $mysoc;
1037 $pdf->SetFont(
'',
'', $default_font_size - 1);
1042 if ($this->page_largeur < 210) {
1045 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1049 $outputlangsbis =
null;
1053 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1065 $pdf->SetFillColor(248, 248, 248);
1067 $total_ttc =
$object->getValorisationTotale();
1069 $this->atleastoneratenotnull = 0;
1073 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1074 $pdf->SetTextColor(0, 0, 60);
1075 $pdf->SetFillColor(224, 224, 224);
1076 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"Total", $mysoc->country_code) :
''), $useborder,
'L', 1);
1078 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1079 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1081 $pdf->SetTextColor(0, 0, 0);
1083 $creditnoteamount = 0;
1084 $depositsamount = 0;
1088 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1093 if ($deja_regle > 0) {
1097 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1098 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1099 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1100 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1103 $pdf->SetTextColor(0, 0, 60);
1104 $pdf->SetFillColor(224, 224, 224);
1105 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1106 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1108 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1109 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1111 $pdf->SetFont(
'',
'', $default_font_size - 1);
1112 $pdf->SetTextColor(0, 0, 0);
1116 return ($tab2_top + ($tab2_hl * $index));
1187 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1190 global
$conf, $langs;
1192 '@phan-var-force StockTransfer $object';
1195 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1206 $pdf->SetTextColor(0, 0, 60);
1207 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1211 $posy = $this->marge_haute;
1212 $posx = $this->page_largeur - $this->marge_droite - $w;
1214 $pdf->SetXY($this->marge_gauche, $posy);
1218 if ($this->emetteur->logo) {
1219 $logodir =
$conf->mycompany->dir_output;
1220 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1221 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1224 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1226 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1228 if (is_readable($logo)) {
1230 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1232 $pdf->SetTextColor(200, 0, 0);
1233 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1234 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1235 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1238 $text = $this->emetteur->name;
1239 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1243 $pdf->SetDrawColor(128, 128, 128);
1245 $posx = $this->page_largeur - $w - $this->marge_droite;
1246 $posy = $this->marge_haute;
1248 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1249 $pdf->SetXY($posx, $posy);
1250 $pdf->SetTextColor(0, 0, 60);
1251 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.
$object->ref;
1252 $pdf->MultiCell($w, 4, $title,
'',
'R');
1254 $pdf->SetFont(
'',
'', $default_font_size + 1);
1257 if (!empty(
$object->date_prevue_depart)) {
1259 $pdf->SetXY($posx, $posy);
1260 $pdf->SetTextColor(0, 0, 60);
1261 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date(
$object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1265 if (!empty(
$object->date_prevue_arrivee)) {
1267 $pdf->SetXY($posx, $posy);
1268 $pdf->SetTextColor(0, 0, 60);
1269 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date(
$object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1273 if (!empty(
$object->date_reelle_depart)) {
1275 $pdf->SetXY($posx, $posy);
1276 $pdf->SetTextColor(0, 0, 60);
1277 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date(
$object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1281 if (!empty(
$object->date_reelle_arrivee)) {
1283 $pdf->SetXY($posx, $posy);
1284 $pdf->SetTextColor(0, 0, 60);
1285 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date(
$object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1288 if (!empty(
$object->thirdparty->code_client)) {
1290 $pdf->SetXY($posx, $posy);
1291 $pdf->SetTextColor(0, 0, 60);
1292 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1297 $pdf->SetXY($posx, $posy);
1298 $pdf->SetTextColor(0, 0, 60);
1299 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1304 if (!empty(
$object->project->ref)) {
1306 $pdf->SetXY($posx, $posy);
1307 $pdf->SetTextColor(0, 0, 60);
1308 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->projet->title),
'',
'R');
1314 if (!empty(
$object->project->ref)) {
1316 $pdf->SetXY($posx, $posy);
1317 $pdf->SetTextColor(0, 0, 60);
1318 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->projet->ref),
'',
'R');
1324 $pdf->SetXY($posx, $posy);
1325 $pdf->SetTextColor(0, 0, 60);
1326 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1331 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1332 if (count($arrayidcontact) > 0) {
1333 $usertmp =
new User($this->db);
1334 $usertmp->fetch($arrayidcontact[0]);
1336 $pdf->SetXY($posx, $posy);
1337 $pdf->SetTextColor(0, 0, 60);
1338 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1346 $current_y = $pdf->getY();
1348 if ($current_y < $pdf->getY()) {
1349 $top_shift = $pdf->getY() - $current_y;
1354 $carac_emetteur =
'';
1356 $arrayidcontact = array();
1357 $arrayidcontact =
$object->getIdContact(
'external',
'STFROM');
1359 $usecontact =
false;
1360 if (count($arrayidcontact) > 0) {
1364 $result =
$object->fetch_contact($arrayidcontact[0]);
1368 $thirdparty =
$object->contact;
1370 $thirdparty = $this->emetteur;
1373 if (!empty($thirdparty)) {
1385 $posx = $this->marge_gauche;
1387 $posx = $this->page_largeur - $this->marge_droite - 80;
1394 $pdf->SetTextColor(0, 0, 0);
1395 $pdf->SetFont(
'',
'', $default_font_size - 2);
1396 $pdf->SetXY($posx, $posy - 5);
1397 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1398 $pdf->SetXY($posx, $posy);
1399 $pdf->SetFillColor(230, 230, 230);
1400 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1401 $pdf->SetTextColor(0, 0, 60);
1402 $pdf->SetFillColor(255, 255, 255);
1405 $pdf->SetXY($posx + 2, $posy + 3);
1406 $pdf->SetFont(
'',
'B', $default_font_size);
1407 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1408 $posy = $pdf->getY();
1411 $pdf->SetXY($posx + 2, $posy);
1412 $pdf->SetFont(
'',
'', $default_font_size - 1);
1413 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1417 $usecontact =
false;
1418 $arrayidcontact =
$object->getIdContact(
'external',
'STDEST');
1419 if (count($arrayidcontact) > 0) {
1421 $result =
$object->fetch_contact($arrayidcontact[0]);
1427 $thirdparty =
$object->contact;
1429 $thirdparty =
$object->thirdparty;
1432 $carac_client_name =
'';
1433 if (!empty($thirdparty)) {
1441 if ($this->page_largeur < 210) {
1445 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1447 $posx = $this->marge_gauche;
1451 $pdf->SetTextColor(0, 0, 0);
1452 $pdf->SetFont(
'',
'', $default_font_size - 2);
1453 $pdf->SetXY($posx + 2, $posy - 5);
1454 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1455 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1458 $pdf->SetXY($posx + 2, $posy + 3);
1459 $pdf->SetFont(
'',
'B', $default_font_size);
1460 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1462 $posy = $pdf->getY();
1465 $pdf->SetFont(
'',
'', $default_font_size - 1);
1466 $pdf->SetXY($posx + 2, $posy);
1467 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1470 $pdf->SetTextColor(0, 0, 0);