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",
"deliveries",
"sendings",
"productbatch",
"stocks",
"stocktransfer@stocktransfer"));
174 global $outputlangsbis;
175 $outputlangsbis =
null;
179 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"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])) {
298 $logodir =
$conf->mycompany->multidir_output[
$object->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->getFullName($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;
348 if (isModEnabled(
'incoterm')) {
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;
368 $notetoshow = empty(
$object->note_public) ?
'' : (string)
$object->note_public;
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);
703 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
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);
824 $this->error = $hookmanager->error;
825 $this->errors = $hookmanager->errors;
830 $this->result = array(
'fullpath' => $file);
834 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
838 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
854 global
$conf, $mysoc;
855 '@phan-var-force Commande|Propal|Facture $object';
859 $pdf->SetFont(
'',
'', $default_font_size - 1);
862 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
863 $pdf->SetFont(
'',
'B', $default_font_size - 2);
864 $pdf->SetXY($this->marge_gauche, $posy);
865 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
867 $posy = $pdf->GetY() + 4;
874 $pdf->SetFont(
'',
'B', $default_font_size - 2);
875 $pdf->SetXY($this->marge_gauche, $posy);
876 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
877 $pdf->MultiCell(43, 4, $titre, 0,
'L');
879 $pdf->SetFont(
'',
'', $default_font_size - 2);
880 $pdf->SetXY($posxval, $posy);
881 $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);
882 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
883 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
885 $posy = $pdf->GetY() + 3;
916 if (!empty(
$object->delivery_date)) {
917 $outputlangs->load(
"sendings");
918 $pdf->SetFont(
'',
'B', $default_font_size - 2);
919 $pdf->SetXY($this->marge_gauche, $posy);
920 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
921 $pdf->MultiCell(80, 4, $titre, 0,
'L');
922 $pdf->SetFont(
'',
'', $default_font_size - 2);
923 $pdf->SetXY($posxval, $posy);
925 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
927 $posy = $pdf->GetY() + 1;
928 } elseif (property_exists(
$object,
'availability_code')
929 && property_exists(
$object,
'availability')
937 $pdf->SetFont(
'',
'B', $default_font_size - 2);
938 $pdf->SetXY($this->marge_gauche, $posy);
939 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
940 $pdf->MultiCell(80, 4, $titre, 0,
'L');
941 $pdf->SetTextColor(0, 0, 0);
942 $pdf->SetFont(
'',
'', $default_font_size - 2);
943 $pdf->SetXY($posxval, $posy);
944 $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 :
'');
945 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
946 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
948 $posy = $pdf->GetY() + 1;
952 if (
$object->mode_reglement_code
953 &&
$object->mode_reglement_code !=
'CHQ'
954 &&
$object->mode_reglement_code !=
'VIR') {
955 $pdf->SetFont(
'',
'B', $default_font_size - 2);
956 $pdf->SetXY($this->marge_gauche, $posy);
957 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
958 $pdf->MultiCell(80, 5, $titre, 0,
'L');
960 $pdf->SetFont(
'',
'', $default_font_size - 2);
961 $pdf->SetXY($posxval, $posy);
962 $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);
963 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
965 $posy = $pdf->GetY() + 2;
969 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
973 $account =
new Account($this->db);
976 $pdf->SetXY($this->marge_gauche, $posy);
977 $pdf->SetFont(
'',
'B', $default_font_size - 3);
978 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
979 $posy = $pdf->GetY() + 1;
982 $pdf->SetXY($this->marge_gauche, $posy);
983 $pdf->SetFont(
'',
'', $default_font_size - 3);
984 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
985 $posy = $pdf->GetY() + 2;
989 $pdf->SetXY($this->marge_gauche, $posy);
990 $pdf->SetFont(
'',
'B', $default_font_size - 3);
991 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
992 $posy = $pdf->GetY() + 1;
995 $pdf->SetXY($this->marge_gauche, $posy);
996 $pdf->SetFont(
'',
'', $default_font_size - 3);
997 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
998 $posy = $pdf->GetY() + 2;
1005 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1007 $bankid = (empty(
$object->fk_account) ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1008 if (!empty(
$object->fk_bank)) {
1011 $account =
new Account($this->db);
1012 $account->fetch($bankid);
1014 $curx = $this->marge_gauche;
1017 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1039 global
$conf, $mysoc;
1045 $pdf->SetFont(
'',
'', $default_font_size - 1);
1050 if ($this->page_largeur < 210) {
1053 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1057 $outputlangsbis =
null;
1061 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1073 $pdf->SetFillColor(248, 248, 248);
1075 $total_ttc =
$object->getValorisationTotale();
1077 $this->atleastoneratenotnull = 0;
1081 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1082 $pdf->SetTextColor(0, 0, 60);
1083 $pdf->SetFillColor(224, 224, 224);
1084 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"Total", $mysoc->country_code) :
''), $useborder,
'L',
true);
1086 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1087 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1089 $pdf->SetTextColor(0, 0, 0);
1091 $creditnoteamount = 0;
1092 $depositsamount = 0;
1096 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1101 if ($deja_regle > 0) {
1105 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1106 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1107 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1108 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1111 $pdf->SetTextColor(0, 0, 60);
1112 $pdf->SetFillColor(224, 224, 224);
1113 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1114 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L',
true);
1116 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1117 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1119 $pdf->SetFont(
'',
'', $default_font_size - 1);
1120 $pdf->SetTextColor(0, 0, 0);
1124 return ($tab2_top + ($tab2_hl * $index));
1195 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1198 global
$conf, $langs;
1200 '@phan-var-force StockTransfer $object';
1203 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1214 $pdf->SetTextColor(0, 0, 60);
1215 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1219 $posy = $this->marge_haute;
1220 $posx = $this->page_largeur - $this->marge_droite - $w;
1222 $pdf->SetXY($this->marge_gauche, $posy);
1226 if ($this->emetteur->logo) {
1227 $logodir =
$conf->mycompany->dir_output;
1228 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1229 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1232 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1234 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1236 if (is_readable($logo)) {
1238 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1240 $pdf->SetTextColor(200, 0, 0);
1241 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1242 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1243 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1246 $text = $this->emetteur->name;
1247 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1251 $pdf->SetDrawColor(128, 128, 128);
1253 $posx = $this->page_largeur - $w - $this->marge_droite;
1254 $posy = $this->marge_haute;
1256 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1257 $pdf->SetXY($posx, $posy);
1258 $pdf->SetTextColor(0, 0, 60);
1259 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.
$object->ref;
1260 $pdf->MultiCell($w, 4, $title,
'',
'R');
1262 $pdf->SetFont(
'',
'', $default_font_size + 1);
1265 if (!empty(
$object->date_prevue_depart)) {
1267 $pdf->SetXY($posx, $posy);
1268 $pdf->SetTextColor(0, 0, 60);
1269 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date(
$object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1273 if (!empty(
$object->date_prevue_arrivee)) {
1275 $pdf->SetXY($posx, $posy);
1276 $pdf->SetTextColor(0, 0, 60);
1277 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date(
$object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1281 if (!empty(
$object->date_reelle_depart)) {
1283 $pdf->SetXY($posx, $posy);
1284 $pdf->SetTextColor(0, 0, 60);
1285 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date(
$object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1289 if (!empty(
$object->date_reelle_arrivee)) {
1291 $pdf->SetXY($posx, $posy);
1292 $pdf->SetTextColor(0, 0, 60);
1293 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date(
$object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1296 if (!empty(
$object->thirdparty->code_client)) {
1298 $pdf->SetXY($posx, $posy);
1299 $pdf->SetTextColor(0, 0, 60);
1300 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1305 $pdf->SetXY($posx, $posy);
1306 $pdf->SetTextColor(0, 0, 60);
1307 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1312 if (!empty(
$object->project->ref)) {
1314 $pdf->SetXY($posx, $posy);
1315 $pdf->SetTextColor(0, 0, 60);
1316 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->projet->title),
'',
'R');
1322 if (!empty(
$object->project->ref)) {
1324 $pdf->SetXY($posx, $posy);
1325 $pdf->SetTextColor(0, 0, 60);
1326 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->projet->ref),
'',
'R');
1332 $pdf->SetXY($posx, $posy);
1333 $pdf->SetTextColor(0, 0, 60);
1334 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1339 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1340 if (count($arrayidcontact) > 0) {
1341 $usertmp =
new User($this->db);
1342 $usertmp->fetch($arrayidcontact[0]);
1344 $pdf->SetXY($posx, $posy);
1345 $pdf->SetTextColor(0, 0, 60);
1346 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1354 $current_y = $pdf->getY();
1356 if ($current_y < $pdf->getY()) {
1357 $top_shift = $pdf->getY() - $current_y;
1362 $carac_emetteur =
'';
1364 $arrayidcontact = array();
1365 $arrayidcontact =
$object->getIdContact(
'external',
'STFROM');
1367 $usecontact =
false;
1368 if (count($arrayidcontact) > 0) {
1372 $result =
$object->fetch_contact($arrayidcontact[0]);
1376 $thirdparty =
$object->contact;
1378 $thirdparty = $this->emetteur;
1381 if (!empty($thirdparty)) {
1384 $carac_emetteur_name =
'';
1395 $posx = $this->marge_gauche;
1397 $posx = $this->page_largeur - $this->marge_droite - 80;
1404 $pdf->SetTextColor(0, 0, 0);
1405 $pdf->SetFont(
'',
'', $default_font_size - 2);
1406 $pdf->SetXY($posx, $posy - 5);
1407 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1408 $pdf->SetXY($posx, $posy);
1409 $pdf->SetFillColor(230, 230, 230);
1410 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1411 $pdf->SetTextColor(0, 0, 60);
1412 $pdf->SetFillColor(255, 255, 255);
1415 $pdf->SetXY($posx + 2, $posy + 3);
1416 $pdf->SetFont(
'',
'B', $default_font_size);
1417 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1418 $posy = $pdf->getY();
1421 $pdf->SetXY($posx + 2, $posy);
1422 $pdf->SetFont(
'',
'', $default_font_size - 1);
1423 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1427 $usecontact =
false;
1428 $arrayidcontact =
$object->getIdContact(
'external',
'STDEST');
1429 if (count($arrayidcontact) > 0) {
1431 $result =
$object->fetch_contact($arrayidcontact[0]);
1437 $thirdparty =
$object->contact;
1439 $thirdparty =
$object->thirdparty;
1442 $carac_client_name =
'';
1443 if (!empty($thirdparty)) {
1451 if ($this->page_largeur < 210) {
1455 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1457 $posx = $this->marge_gauche;
1461 $pdf->SetTextColor(0, 0, 0);
1462 $pdf->SetFont(
'',
'', $default_font_size - 2);
1463 $pdf->SetXY($posx + 2, $posy - 5);
1464 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1465 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1468 $pdf->SetXY($posx + 2, $posy + 3);
1469 $pdf->SetFont(
'',
'B', $default_font_size);
1470 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1472 $posy = $pdf->getY();
1475 $pdf->SetFont(
'',
'', $default_font_size - 1);
1476 $pdf->SetXY($posx + 2, $posy);
1477 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1480 $pdf->SetTextColor(0, 0, 0);