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);
294 $logodir =
$conf->mycompany->dir_output;
295 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
296 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
298 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
299 $tplidx = $pdf->importPage(1);
304 $pdf->SetDrawColor(128, 128, 128);
306 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
307 $pdf->SetSubject($outputlangs->transnoentities(
"StockTransferSheetProforma"));
308 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
309 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
310 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"StockTransfer"));
312 $pdf->SetCompression(
false);
316 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
319 if (is_array(
$object->lines)) {
320 foreach (
$object->lines as $line) {
321 if ($line->remise_percent) {
322 $this->atleastonediscount =
true;
330 if (!empty($tplidx)) {
331 $pdf->useTemplate($tplidx);
335 $pdf->SetFont(
'',
'', $default_font_size - 1);
336 $pdf->MultiCell(0, 3,
'');
337 $pdf->SetTextColor(0, 0, 0);
340 $tab_top = 90 + $top_shift;
341 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
345 $height_incoterms = 0;
346 if (isModEnabled(
'incoterm')) {
347 $desc_incoterms =
$object->getIncotermsForPDF();
348 if ($desc_incoterms) {
351 $pdf->SetFont(
'',
'', $default_font_size - 1);
352 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
353 $nexY = $pdf->GetY();
354 $height_incoterms = $nexY - $tab_top;
357 $pdf->SetDrawColor(192, 192, 192);
358 $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');
360 $tab_top = $nexY + 6;
361 $height_incoterms += 4;
366 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
369 if (is_object(
$object->thirdparty)) {
370 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
371 $salerepobj =
new User($this->db);
372 $salerepobj->fetch($salereparray[0][
'id']);
373 if (!empty($salerepobj->signature)) {
374 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
380 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
381 if (!empty($extranote)) {
385 $pagenb = $pdf->getPage();
387 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
388 $pageposbeforenote = $pagenb;
397 $pdf->startTransaction();
399 $pdf->SetFont(
'',
'', $default_font_size - 1);
400 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
402 $pageposafternote = $pdf->getPage();
403 $posyafter = $pdf->GetY();
405 if ($pageposafternote > $pageposbeforenote) {
406 $pdf->rollbackTransaction(
true);
409 while ($pagenb < $pageposafternote) {
412 if (!empty($tplidx)) {
413 $pdf->useTemplate($tplidx);
419 $pdf->setTopMargin($tab_top_newpage);
421 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
425 $pdf->setPage($pageposbeforenote);
426 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
427 $pdf->SetFont(
'',
'', $default_font_size - 1);
428 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
429 $pageposafternote = $pdf->getPage();
431 $posyafter = $pdf->GetY();
433 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
434 $pdf->AddPage(
'',
'',
true);
437 $pdf->setPage($pageposafternote);
438 $pdf->setTopMargin($tab_top_newpage);
440 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
446 $i = $pageposbeforenote;
447 while ($i < $pageposafternote) {
451 $pdf->SetDrawColor(128, 128, 128);
453 if ($i > $pageposbeforenote) {
454 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
455 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
457 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
458 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
462 $pdf->setPageOrientation(
'', 1, 0);
469 $pdf->setPage($pageposafternote);
470 if (!empty($tplidx)) {
471 $pdf->useTemplate($tplidx);
476 $height_note = $posyafter - $tab_top_newpage;
477 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
479 $pdf->commitTransaction();
480 $posyafter = $pdf->GetY();
481 $height_note = $posyafter - $tab_top;
482 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
485 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
487 $pdf->AddPage(
'',
'',
true);
490 $pdf->setPage($pageposafternote);
491 if (!empty($tplidx)) {
492 $pdf->useTemplate($tplidx);
498 $posyafter = $tab_top_newpage;
502 $tab_height -= $height_note;
503 $tab_top = $posyafter + 6;
513 $pdf->startTransaction();
514 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
515 $pdf->rollbackTransaction(
true);
517 $nexY = $tab_top + $this->tabTitleHeight;
520 $pageposbeforeprintlines = $pdf->getPage();
521 $pagenb = $pageposbeforeprintlines;
522 for ($i = 0; $i < $nblines; $i++) {
524 $pdf->SetFont(
'',
'', $default_font_size - 1);
525 $pdf->SetTextColor(0, 0, 0);
528 $imglinesize = array();
529 if (!empty($realpatharray[$i])) {
533 $pdf->setTopMargin($tab_top_newpage);
534 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
535 $pageposbefore = $pdf->getPage();
538 $showpricebeforepagebreak = 1;
543 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
544 $pdf->AddPage(
'',
'',
true);
545 if (!empty($tplidx)) {
546 $pdf->useTemplate($tplidx);
548 $pdf->setPage($pageposbefore + 1);
550 $curY = $tab_top_newpage;
554 $showpricebeforepagebreak = 1;
556 $showpricebeforepagebreak = 0;
560 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
561 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
563 $posYAfterImage = $curY + $imglinesize[
'height'];
568 $pdf->startTransaction();
570 if (method_exists(
$object->lines[$i],
'fetch_product')) {
571 $object->lines[$i]->fetch_product();
573 $object->lines[$i]->description =
$object->lines[$i]->product->description;
574 $object->lines[$i]->fk_unit =
$object->lines[$i]->product->fk_unit;
579 $pageposafter = $pdf->getPage();
580 if ($pageposafter > $pageposbefore) {
581 $pdf->rollbackTransaction(
true);
582 $pageposafter = $pageposbefore;
584 $pdf->setPageOrientation(
'', 1, $heightforfooter);
587 $pageposafter = $pdf->getPage();
588 $posyafter = $pdf->GetY();
589 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
590 if ($i == ($nblines - 1)) {
591 $pdf->AddPage(
'',
'',
true);
592 if (!empty($tplidx)) {
593 $pdf->useTemplate($tplidx);
596 $pdf->setPage($pageposafter + 1);
602 $showpricebeforepagebreak = 1;
604 $showpricebeforepagebreak = 0;
608 $pdf->commitTransaction();
614 $nexY = max($pdf->GetY(), $posYAfterImage);
617 $pageposafter = $pdf->getPage();
619 $pdf->setPage($pageposbefore);
620 $pdf->setTopMargin($this->marge_haute);
621 $pdf->setPageOrientation(
'', 1, 0);
624 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
625 $pdf->setPage($pageposafter);
626 $curY = $tab_top_newpage;
629 $pdf->SetFont(
'',
'', $default_font_size - 1);
635 $nexY = max($pdf->GetY(), $nexY);
640 $pmp =
$object->lines[$i]->pmp;
642 $nexY = max($pdf->GetY(), $nexY);
650 $nexY = max($pdf->GetY(), $nexY);
658 $nexY = max($pdf->GetY(), $nexY);
665 $nexY = max($pdf->GetY(), $nexY);
670 $pmp_qty = $pmp *
$object->lines[$i]->qty;
672 $nexY = max($pdf->GetY(), $nexY);
676 if (!empty(
$object->lines[$i]->array_options)) {
677 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
681 $nexY = max($pdf->GetY(), $nexY);
692 'outputlangs' => $outputlangs,
693 'hidedetails' => $hidedetails
695 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
699 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
700 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
702 $tvaligne =
$object->lines[$i]->total_tva;
750 $pdf->setPage($pageposafter);
751 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
753 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
754 $pdf->SetLineStyle(array(
'dash' => 0));
759 while ($pagenb < $pageposafter) {
760 $pdf->setPage($pagenb);
761 if ($pagenb == $pageposbeforeprintlines) {
762 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
764 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
768 $pdf->setPage($pagenb);
769 $pdf->setPageOrientation(
'', 1, 0);
774 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
775 if ($pagenb == $pageposafter) {
776 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
778 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
783 if (!empty($tplidx)) {
784 $pdf->useTemplate($tplidx);
794 if ($pagenb == $pageposbeforeprintlines) {
795 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
797 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
799 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
806 if (method_exists($pdf,
'AliasNbPages')) {
807 $pdf->AliasNbPages();
812 $pdf->Output($file,
'F');
815 $hookmanager->initHooks(array(
'pdfgeneration'));
816 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
818 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
820 $this->error = $hookmanager->error;
821 $this->errors = $hookmanager->errors;
826 $this->result = array(
'fullpath' => $file);
830 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
834 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
850 global
$conf, $mysoc;
851 '@phan-var-force Commande|Propal|Facture $object';
855 $pdf->SetFont(
'',
'', $default_font_size - 1);
858 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
859 $pdf->SetFont(
'',
'B', $default_font_size - 2);
860 $pdf->SetXY($this->marge_gauche, $posy);
861 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
863 $posy = $pdf->GetY() + 4;
870 $pdf->SetFont(
'',
'B', $default_font_size - 2);
871 $pdf->SetXY($this->marge_gauche, $posy);
872 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
873 $pdf->MultiCell(43, 4, $titre, 0,
'L');
875 $pdf->SetFont(
'',
'', $default_font_size - 2);
876 $pdf->SetXY($posxval, $posy);
877 $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);
878 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
879 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
881 $posy = $pdf->GetY() + 3;
912 if (!empty(
$object->delivery_date)) {
913 $outputlangs->load(
"sendings");
914 $pdf->SetFont(
'',
'B', $default_font_size - 2);
915 $pdf->SetXY($this->marge_gauche, $posy);
916 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
917 $pdf->MultiCell(80, 4, $titre, 0,
'L');
918 $pdf->SetFont(
'',
'', $default_font_size - 2);
919 $pdf->SetXY($posxval, $posy);
921 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
923 $posy = $pdf->GetY() + 1;
924 } elseif (property_exists(
$object,
'availability_code')
925 && property_exists(
$object,
'availability')
933 $pdf->SetFont(
'',
'B', $default_font_size - 2);
934 $pdf->SetXY($this->marge_gauche, $posy);
935 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
936 $pdf->MultiCell(80, 4, $titre, 0,
'L');
937 $pdf->SetTextColor(0, 0, 0);
938 $pdf->SetFont(
'',
'', $default_font_size - 2);
939 $pdf->SetXY($posxval, $posy);
940 $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 :
'');
941 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
942 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
944 $posy = $pdf->GetY() + 1;
948 if (
$object->mode_reglement_code
949 &&
$object->mode_reglement_code !=
'CHQ'
950 &&
$object->mode_reglement_code !=
'VIR') {
951 $pdf->SetFont(
'',
'B', $default_font_size - 2);
952 $pdf->SetXY($this->marge_gauche, $posy);
953 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
954 $pdf->MultiCell(80, 5, $titre, 0,
'L');
956 $pdf->SetFont(
'',
'', $default_font_size - 2);
957 $pdf->SetXY($posxval, $posy);
958 $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);
959 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
961 $posy = $pdf->GetY() + 2;
965 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
969 $account =
new Account($this->db);
972 $pdf->SetXY($this->marge_gauche, $posy);
973 $pdf->SetFont(
'',
'B', $default_font_size - 3);
974 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
975 $posy = $pdf->GetY() + 1;
978 $pdf->SetXY($this->marge_gauche, $posy);
979 $pdf->SetFont(
'',
'', $default_font_size - 3);
980 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
981 $posy = $pdf->GetY() + 2;
985 $pdf->SetXY($this->marge_gauche, $posy);
986 $pdf->SetFont(
'',
'B', $default_font_size - 3);
987 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
988 $posy = $pdf->GetY() + 1;
991 $pdf->SetXY($this->marge_gauche, $posy);
992 $pdf->SetFont(
'',
'', $default_font_size - 3);
993 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
994 $posy = $pdf->GetY() + 2;
1001 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1003 $bankid = (empty(
$object->fk_account) ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1004 if (!empty(
$object->fk_bank)) {
1007 $account =
new Account($this->db);
1008 $account->fetch($bankid);
1010 $curx = $this->marge_gauche;
1013 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1035 global
$conf, $mysoc;
1041 $pdf->SetFont(
'',
'', $default_font_size - 1);
1046 if ($this->page_largeur < 210) {
1049 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1053 $outputlangsbis =
null;
1057 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1069 $pdf->SetFillColor(248, 248, 248);
1071 $total_ttc =
$object->getValorisationTotale();
1073 $this->atleastoneratenotnull = 0;
1077 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078 $pdf->SetTextColor(0, 0, 60);
1079 $pdf->SetFillColor(224, 224, 224);
1080 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"Total", $mysoc->country_code) :
''), $useborder,
'L', 1);
1082 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1083 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1085 $pdf->SetTextColor(0, 0, 0);
1087 $creditnoteamount = 0;
1088 $depositsamount = 0;
1092 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1097 if ($deja_regle > 0) {
1101 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1103 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1104 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1107 $pdf->SetTextColor(0, 0, 60);
1108 $pdf->SetFillColor(224, 224, 224);
1109 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1110 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1112 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1113 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1115 $pdf->SetFont(
'',
'', $default_font_size - 1);
1116 $pdf->SetTextColor(0, 0, 0);
1120 return ($tab2_top + ($tab2_hl * $index));
1191 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1194 global
$conf, $langs;
1196 '@phan-var-force StockTransfer $object';
1199 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1210 $pdf->SetTextColor(0, 0, 60);
1211 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1215 $posy = $this->marge_haute;
1216 $posx = $this->page_largeur - $this->marge_droite - $w;
1218 $pdf->SetXY($this->marge_gauche, $posy);
1222 if ($this->emetteur->logo) {
1223 $logodir =
$conf->mycompany->dir_output;
1224 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1225 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1228 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1230 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1232 if (is_readable($logo)) {
1234 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1236 $pdf->SetTextColor(200, 0, 0);
1237 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1238 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1239 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1242 $text = $this->emetteur->name;
1243 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1247 $pdf->SetDrawColor(128, 128, 128);
1249 $posx = $this->page_largeur - $w - $this->marge_droite;
1250 $posy = $this->marge_haute;
1252 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1253 $pdf->SetXY($posx, $posy);
1254 $pdf->SetTextColor(0, 0, 60);
1255 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.
$object->ref;
1256 $pdf->MultiCell($w, 4, $title,
'',
'R');
1258 $pdf->SetFont(
'',
'', $default_font_size + 1);
1261 if (!empty(
$object->date_prevue_depart)) {
1263 $pdf->SetXY($posx, $posy);
1264 $pdf->SetTextColor(0, 0, 60);
1265 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date(
$object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1269 if (!empty(
$object->date_prevue_arrivee)) {
1271 $pdf->SetXY($posx, $posy);
1272 $pdf->SetTextColor(0, 0, 60);
1273 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date(
$object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1277 if (!empty(
$object->date_reelle_depart)) {
1279 $pdf->SetXY($posx, $posy);
1280 $pdf->SetTextColor(0, 0, 60);
1281 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date(
$object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1285 if (!empty(
$object->date_reelle_arrivee)) {
1287 $pdf->SetXY($posx, $posy);
1288 $pdf->SetTextColor(0, 0, 60);
1289 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date(
$object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1292 if (!empty(
$object->thirdparty->code_client)) {
1294 $pdf->SetXY($posx, $posy);
1295 $pdf->SetTextColor(0, 0, 60);
1296 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1301 $pdf->SetXY($posx, $posy);
1302 $pdf->SetTextColor(0, 0, 60);
1303 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1308 if (!empty(
$object->project->ref)) {
1310 $pdf->SetXY($posx, $posy);
1311 $pdf->SetTextColor(0, 0, 60);
1312 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->projet->title),
'',
'R');
1318 if (!empty(
$object->project->ref)) {
1320 $pdf->SetXY($posx, $posy);
1321 $pdf->SetTextColor(0, 0, 60);
1322 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->projet->ref),
'',
'R');
1328 $pdf->SetXY($posx, $posy);
1329 $pdf->SetTextColor(0, 0, 60);
1330 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1335 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1336 if (count($arrayidcontact) > 0) {
1337 $usertmp =
new User($this->db);
1338 $usertmp->fetch($arrayidcontact[0]);
1340 $pdf->SetXY($posx, $posy);
1341 $pdf->SetTextColor(0, 0, 60);
1342 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1350 $current_y = $pdf->getY();
1352 if ($current_y < $pdf->getY()) {
1353 $top_shift = $pdf->getY() - $current_y;
1358 $carac_emetteur =
'';
1360 $arrayidcontact = array();
1361 $arrayidcontact =
$object->getIdContact(
'external',
'STFROM');
1363 $usecontact =
false;
1364 if (count($arrayidcontact) > 0) {
1368 $result =
$object->fetch_contact($arrayidcontact[0]);
1372 $thirdparty =
$object->contact;
1374 $thirdparty = $this->emetteur;
1377 if (!empty($thirdparty)) {
1389 $posx = $this->marge_gauche;
1391 $posx = $this->page_largeur - $this->marge_droite - 80;
1398 $pdf->SetTextColor(0, 0, 0);
1399 $pdf->SetFont(
'',
'', $default_font_size - 2);
1400 $pdf->SetXY($posx, $posy - 5);
1401 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1402 $pdf->SetXY($posx, $posy);
1403 $pdf->SetFillColor(230, 230, 230);
1404 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1405 $pdf->SetTextColor(0, 0, 60);
1406 $pdf->SetFillColor(255, 255, 255);
1409 $pdf->SetXY($posx + 2, $posy + 3);
1410 $pdf->SetFont(
'',
'B', $default_font_size);
1411 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1412 $posy = $pdf->getY();
1415 $pdf->SetXY($posx + 2, $posy);
1416 $pdf->SetFont(
'',
'', $default_font_size - 1);
1417 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1421 $usecontact =
false;
1422 $arrayidcontact =
$object->getIdContact(
'external',
'STDEST');
1423 if (count($arrayidcontact) > 0) {
1425 $result =
$object->fetch_contact($arrayidcontact[0]);
1431 $thirdparty =
$object->contact;
1433 $thirdparty =
$object->thirdparty;
1436 $carac_client_name =
'';
1437 if (!empty($thirdparty)) {
1445 if ($this->page_largeur < 210) {
1449 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1451 $posx = $this->marge_gauche;
1455 $pdf->SetTextColor(0, 0, 0);
1456 $pdf->SetFont(
'',
'', $default_font_size - 2);
1457 $pdf->SetXY($posx + 2, $posy - 5);
1458 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1459 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1462 $pdf->SetXY($posx + 2, $posy + 3);
1463 $pdf->SetFont(
'',
'B', $default_font_size);
1464 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1466 $posy = $pdf->getY();
1469 $pdf->SetFont(
'',
'', $default_font_size - 1);
1470 $pdf->SetXY($posx + 2, $posy);
1471 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1474 $pdf->SetTextColor(0, 0, 0);