148 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
151 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
153 if (!is_object($outputlangs)) {
154 $outputlangs = $langs;
158 $outputlangs->charset_output =
'ISO-8859-1';
162 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch",
"stocks",
"stocktransfer@stocktransfer"));
164 global $outputlangsbis;
165 $outputlangsbis =
null;
167 $outputlangsbis =
new Translate(
'', $conf);
169 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
180 $realpatharray = array();
181 $this->atleastonephoto =
false;
183 $objphoto =
new Product($this->db);
185 for ($i = 0; $i < $nblines; $i++) {
186 if (empty(
$object->lines[$i]->fk_product)) {
190 $objphoto->fetch(
$object->lines[$i]->fk_product);
194 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
195 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
197 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
198 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
202 foreach ($pdir as $midir) {
204 $dir = $conf->product->dir_output.
'/'.$midir;
206 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
208 if ($obj[
'photo_vignette']) {
209 $filename = $obj[
'photo_vignette'];
211 $filename = $obj[
'photo'];
214 $filename = $obj[
'photo'];
217 $realpath = $dir.$filename;
219 $this->atleastonephoto =
true;
224 if ($realpath && $arephoto) {
225 $realpatharray[$i] = $realpath;
232 if ($conf->stocktransfer->dir_output) {
239 $dir = $conf->stocktransfer->multidir_output[$conf->entity];
240 $file = $dir.
"/SPECIMEN.pdf";
243 $dir = $conf->stocktransfer->multidir_output[$conf->entity].
"/".
$object->element.
"/".$objectref;
244 $file = $dir.
"/".$objectref.
"-proforma.pdf";
247 if (!file_exists($dir)) {
249 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
254 if (file_exists($dir)) {
256 if (!is_object($hookmanager)) {
257 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
260 $hookmanager->initHooks(array(
'pdfgeneration'));
261 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
263 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
271 $pdf->SetAutoPageBreak(1, 0);
273 $heightforinfotot = 40;
274 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
275 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
276 $pdf->SetAutoPageBreak(1, 0);
278 if (class_exists(
'TCPDF')) {
279 $pdf->setPrintHeader(
false);
280 $pdf->setPrintFooter(
false);
285 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[
$object->entity].
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
286 $tplidx = $pdf->importPage(1);
291 $pdf->SetDrawColor(128, 128, 128);
293 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
294 $pdf->SetSubject($outputlangs->transnoentities(
"StockTransferSheetProforma"));
295 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
296 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
297 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"StockTransfer"));
299 $pdf->SetCompression(
false);
303 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
306 if (is_array(
$object->lines)) {
307 foreach (
$object->lines as $line) {
308 if ($line->remise_percent) {
309 $this->atleastonediscount =
true;
317 if (!empty($tplidx)) {
318 $pdf->useTemplate($tplidx);
322 $pdf->SetFont(
'',
'', $default_font_size - 1);
323 $pdf->MultiCell(0, 3,
'');
324 $pdf->SetTextColor(0, 0, 0);
327 $tab_top = 90 + $top_shift;
328 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
332 $height_incoterms = 0;
333 if (isModEnabled(
'incoterm')) {
334 $desc_incoterms =
$object->getIncotermsForPDF();
335 if ($desc_incoterms) {
338 $pdf->SetFont(
'',
'', $default_font_size - 1);
339 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
340 $nexY = $pdf->GetY();
341 $height_incoterms = $nexY - $tab_top;
344 $pdf->SetDrawColor(192, 192, 192);
345 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
347 $tab_top = $nexY + 6;
348 $height_incoterms += 4;
353 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
356 if (is_object(
$object->thirdparty)) {
357 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
358 $salerepobj =
new User($this->db);
359 $salerepobj->fetch($salereparray[0][
'id']);
360 if (!empty($salerepobj->signature)) {
361 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
367 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
368 if (!empty($extranote)) {
372 $pagenb = $pdf->getPage();
374 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
375 $pageposbeforenote = $pagenb;
384 $pdf->startTransaction();
386 $pdf->SetFont(
'',
'', $default_font_size - 1);
387 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
389 $pageposafternote = $pdf->getPage();
390 $posyafter = $pdf->GetY();
392 if ($pageposafternote > $pageposbeforenote) {
393 $pdf->rollbackTransaction(
true);
396 while ($pagenb < $pageposafternote) {
399 if (!empty($tplidx)) {
400 $pdf->useTemplate($tplidx);
406 $pdf->setTopMargin($tab_top_newpage);
408 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
412 $pdf->setPage($pageposbeforenote);
413 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
414 $pdf->SetFont(
'',
'', $default_font_size - 1);
415 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
416 $pageposafternote = $pdf->getPage();
418 $posyafter = $pdf->GetY();
420 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
421 $pdf->AddPage(
'',
'',
true);
424 $pdf->setPage($pageposafternote);
425 $pdf->setTopMargin($tab_top_newpage);
427 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
433 $i = $pageposbeforenote;
434 while ($i < $pageposafternote) {
438 $pdf->SetDrawColor(128, 128, 128);
440 if ($i > $pageposbeforenote) {
441 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
442 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
444 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
445 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
449 $pdf->setPageOrientation(
'', 1, 0);
456 $pdf->setPage($pageposafternote);
457 if (!empty($tplidx)) {
458 $pdf->useTemplate($tplidx);
463 $height_note = $posyafter - $tab_top_newpage;
464 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
466 $pdf->commitTransaction();
467 $posyafter = $pdf->GetY();
468 $height_note = $posyafter - $tab_top;
469 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
472 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
474 $pdf->AddPage(
'',
'',
true);
477 $pdf->setPage($pageposafternote);
478 if (!empty($tplidx)) {
479 $pdf->useTemplate($tplidx);
485 $posyafter = $tab_top_newpage;
489 $tab_height = $tab_height - $height_note;
490 $tab_top = $posyafter + 6;
500 $pdf->startTransaction();
501 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
502 $pdf->rollbackTransaction(
true);
504 $nexY = $tab_top + $this->tabTitleHeight;
507 $pageposbeforeprintlines = $pdf->getPage();
508 $pagenb = $pageposbeforeprintlines;
509 for ($i = 0; $i < $nblines; $i++) {
511 $pdf->SetFont(
'',
'', $default_font_size - 1);
512 $pdf->SetTextColor(0, 0, 0);
515 $imglinesize = array();
516 if (!empty($realpatharray[$i])) {
520 $pdf->setTopMargin($tab_top_newpage);
521 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
522 $pageposbefore = $pdf->getPage();
525 $showpricebeforepagebreak = 1;
530 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
531 $pdf->AddPage(
'',
'',
true);
532 if (!empty($tplidx)) {
533 $pdf->useTemplate($tplidx);
535 $pdf->setPage($pageposbefore + 1);
537 $curY = $tab_top_newpage;
541 $showpricebeforepagebreak = 1;
543 $showpricebeforepagebreak = 0;
547 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
548 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
550 $posYAfterImage = $curY + $imglinesize[
'height'];
555 $pdf->startTransaction();
557 if (method_exists(
$object->lines[$i],
'fetch_product')) {
558 $object->lines[$i]->fetch_product();
560 $object->lines[$i]->description =
$object->lines[$i]->product->description;
561 $object->lines[$i]->fk_unit =
$object->lines[$i]->product->fk_unit;
566 $pageposafter = $pdf->getPage();
567 if ($pageposafter > $pageposbefore) {
568 $pdf->rollbackTransaction(
true);
569 $pageposafter = $pageposbefore;
571 $pdf->setPageOrientation(
'', 1, $heightforfooter);
574 $pageposafter = $pdf->getPage();
575 $posyafter = $pdf->GetY();
576 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
577 if ($i == ($nblines - 1)) {
578 $pdf->AddPage(
'',
'',
true);
579 if (!empty($tplidx)) {
580 $pdf->useTemplate($tplidx);
583 $pdf->setPage($pageposafter + 1);
589 $showpricebeforepagebreak = 1;
591 $showpricebeforepagebreak = 0;
595 $pdf->commitTransaction();
601 $nexY = max($pdf->GetY(), $posYAfterImage);
604 $pageposafter = $pdf->getPage();
606 $pdf->setPage($pageposbefore);
607 $pdf->setTopMargin($this->marge_haute);
608 $pdf->setPageOrientation(
'', 1, 0);
611 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
612 $pdf->setPage($pageposafter);
613 $curY = $tab_top_newpage;
616 $pdf->SetFont(
'',
'', $default_font_size - 1);
622 $nexY = max($pdf->GetY(), $nexY);
627 $pmp =
$object->lines[$i]->pmp;
629 $nexY = max($pdf->GetY(), $nexY);
637 $nexY = max($pdf->GetY(), $nexY);
645 $nexY = max($pdf->GetY(), $nexY);
652 $nexY = max($pdf->GetY(), $nexY);
657 $pmp_qty = $pmp *
$object->lines[$i]->qty;
659 $nexY = max($pdf->GetY(), $nexY);
663 if (!empty(
$object->lines[$i]->array_options)) {
664 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
668 $nexY = max($pdf->GetY(), $nexY);
679 'outputlangs' => $outputlangs,
680 'hidedetails' => $hidedetails
682 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
686 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
687 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
689 $tvaligne =
$object->lines[$i]->total_tva;
737 $pdf->setPage($pageposafter);
738 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
740 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
741 $pdf->SetLineStyle(array(
'dash' => 0));
746 while ($pagenb < $pageposafter) {
747 $pdf->setPage($pagenb);
748 if ($pagenb == $pageposbeforeprintlines) {
749 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
751 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
755 $pdf->setPage($pagenb);
756 $pdf->setPageOrientation(
'', 1, 0);
761 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
762 if ($pagenb == $pageposafter) {
763 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
765 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
770 if (!empty($tplidx)) {
771 $pdf->useTemplate($tplidx);
781 if ($pagenb == $pageposbeforeprintlines) {
782 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
784 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
786 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
793 if (method_exists($pdf,
'AliasNbPages')) {
794 $pdf->AliasNbPages();
799 $pdf->Output($file,
'F');
802 $hookmanager->initHooks(array(
'pdfgeneration'));
803 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
805 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
807 $this->error = $hookmanager->error;
808 $this->errors = $hookmanager->errors;
813 $this->result = array(
'fullpath' => $file);
817 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
821 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
837 global $conf, $mysoc;
840 $pdf->SetFont(
'',
'', $default_font_size - 1);
843 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
844 $pdf->SetFont(
'',
'B', $default_font_size - 2);
845 $pdf->SetXY($this->marge_gauche, $posy);
846 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
848 $posy = $pdf->GetY() + 4;
855 $pdf->SetFont(
'',
'B', $default_font_size - 2);
856 $pdf->SetXY($this->marge_gauche, $posy);
857 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
858 $pdf->MultiCell(43, 4, $titre, 0,
'L');
860 $pdf->SetFont(
'',
'', $default_font_size - 2);
861 $pdf->SetXY($posxval, $posy);
862 $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);
863 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
864 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
866 $posy = $pdf->GetY() + 3;
897 if (!empty(
$object->delivery_date)) {
898 $outputlangs->load(
"sendings");
899 $pdf->SetFont(
'',
'B', $default_font_size - 2);
900 $pdf->SetXY($this->marge_gauche, $posy);
901 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
902 $pdf->MultiCell(80, 4, $titre, 0,
'L');
903 $pdf->SetFont(
'',
'', $default_font_size - 2);
904 $pdf->SetXY($posxval, $posy);
906 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
908 $posy = $pdf->GetY() + 1;
910 $pdf->SetFont(
'',
'B', $default_font_size - 2);
911 $pdf->SetXY($this->marge_gauche, $posy);
912 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
913 $pdf->MultiCell(80, 4, $titre, 0,
'L');
914 $pdf->SetTextColor(0, 0, 0);
915 $pdf->SetFont(
'',
'', $default_font_size - 2);
916 $pdf->SetXY($posxval, $posy);
917 $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 :
'');
918 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
919 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
921 $posy = $pdf->GetY() + 1;
925 if (
$object->mode_reglement_code
926 &&
$object->mode_reglement_code !=
'CHQ'
927 &&
$object->mode_reglement_code !=
'VIR') {
928 $pdf->SetFont(
'',
'B', $default_font_size - 2);
929 $pdf->SetXY($this->marge_gauche, $posy);
930 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
931 $pdf->MultiCell(80, 5, $titre, 0,
'L');
933 $pdf->SetFont(
'',
'', $default_font_size - 2);
934 $pdf->SetXY($posxval, $posy);
935 $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);
936 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
938 $posy = $pdf->GetY() + 2;
942 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
946 $account =
new Account($this->db);
949 $pdf->SetXY($this->marge_gauche, $posy);
950 $pdf->SetFont(
'',
'B', $default_font_size - 3);
951 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
952 $posy = $pdf->GetY() + 1;
955 $pdf->SetXY($this->marge_gauche, $posy);
956 $pdf->SetFont(
'',
'', $default_font_size - 3);
957 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
958 $posy = $pdf->GetY() + 2;
962 $pdf->SetXY($this->marge_gauche, $posy);
963 $pdf->SetFont(
'',
'B', $default_font_size - 3);
964 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
965 $posy = $pdf->GetY() + 1;
968 $pdf->SetXY($this->marge_gauche, $posy);
969 $pdf->SetFont(
'',
'', $default_font_size - 3);
970 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
971 $posy = $pdf->GetY() + 2;
978 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
980 $bankid = (empty(
$object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
981 if (!empty(
$object->fk_bank)) {
984 $account =
new Account($this->db);
985 $account->fetch($bankid);
987 $curx = $this->marge_gauche;
990 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1012 global $conf, $mysoc;
1018 $pdf->SetFont(
'',
'', $default_font_size - 1);
1023 if ($this->page_largeur < 210) {
1026 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1030 $outputlangsbis =
null;
1032 $outputlangsbis =
new Translate(
'', $conf);
1034 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1046 $pdf->SetFillColor(248, 248, 248);
1048 $total_ttc =
$object->getValorisationTotale();
1050 $this->atleastoneratenotnull = 0;
1054 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1055 $pdf->SetTextColor(0, 0, 60);
1056 $pdf->SetFillColor(224, 224, 224);
1057 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"Total", $mysoc->country_code) :
''), $useborder,
'L', 1);
1059 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1062 $pdf->SetTextColor(0, 0, 0);
1064 $creditnoteamount = 0;
1065 $depositsamount = 0;
1069 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1074 if ($deja_regle > 0) {
1078 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1079 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1080 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1081 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1084 $pdf->SetTextColor(0, 0, 60);
1085 $pdf->SetFillColor(224, 224, 224);
1086 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1087 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1089 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1090 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1092 $pdf->SetFont(
'',
'', $default_font_size - 1);
1093 $pdf->SetTextColor(0, 0, 0);
1097 return ($tab2_top + ($tab2_hl * $index));
1168 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1171 global $conf, $langs;
1174 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1185 $pdf->SetTextColor(0, 0, 60);
1186 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1190 $posy = $this->marge_haute;
1191 $posx = $this->page_largeur - $this->marge_droite - $w;
1193 $pdf->SetXY($this->marge_gauche, $posy);
1197 if ($this->emetteur->logo) {
1198 $logodir = $conf->mycompany->dir_output;
1199 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1200 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1203 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1205 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1207 if (is_readable($logo)) {
1209 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1211 $pdf->SetTextColor(200, 0, 0);
1212 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1213 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1214 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1217 $text = $this->emetteur->name;
1218 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1222 $pdf->SetDrawColor(128, 128, 128);
1224 $posx = $this->page_largeur - $w - $this->marge_droite;
1225 $posy = $this->marge_haute;
1227 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1228 $pdf->SetXY($posx, $posy);
1229 $pdf->SetTextColor(0, 0, 60);
1230 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.
$object->ref;
1231 $pdf->MultiCell($w, 4, $title,
'',
'R');
1233 $pdf->SetFont(
'',
'', $default_font_size + 1);
1236 if (!empty(
$object->date_prevue_depart)) {
1238 $pdf->SetXY($posx, $posy);
1239 $pdf->SetTextColor(0, 0, 60);
1240 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date(
$object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1244 if (!empty(
$object->date_prevue_arrivee)) {
1246 $pdf->SetXY($posx, $posy);
1247 $pdf->SetTextColor(0, 0, 60);
1248 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date(
$object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1252 if (!empty(
$object->date_reelle_depart)) {
1254 $pdf->SetXY($posx, $posy);
1255 $pdf->SetTextColor(0, 0, 60);
1256 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date(
$object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1260 if (!empty(
$object->date_reelle_arrivee)) {
1262 $pdf->SetXY($posx, $posy);
1263 $pdf->SetTextColor(0, 0, 60);
1264 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date(
$object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1267 if (!empty(
$object->thirdparty->code_client)) {
1269 $pdf->SetXY($posx, $posy);
1270 $pdf->SetTextColor(0, 0, 60);
1271 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1276 $pdf->SetXY($posx, $posy);
1277 $pdf->SetTextColor(0, 0, 60);
1278 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1283 if (!empty(
$object->project->ref)) {
1285 $pdf->SetXY($posx, $posy);
1286 $pdf->SetTextColor(0, 0, 60);
1287 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->projet->title),
'',
'R');
1293 if (!empty(
$object->project->ref)) {
1295 $pdf->SetXY($posx, $posy);
1296 $pdf->SetTextColor(0, 0, 60);
1297 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->projet->ref),
'',
'R');
1303 $pdf->SetXY($posx, $posy);
1304 $pdf->SetTextColor(0, 0, 60);
1305 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1310 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1311 if (count($arrayidcontact) > 0) {
1312 $usertmp =
new User($this->db);
1313 $usertmp->fetch($arrayidcontact[0]);
1315 $pdf->SetXY($posx, $posy);
1316 $pdf->SetTextColor(0, 0, 60);
1317 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1325 $current_y = $pdf->getY();
1327 if ($current_y < $pdf->getY()) {
1328 $top_shift = $pdf->getY() - $current_y;
1333 $carac_emetteur =
'';
1335 $arrayidcontact = array();
1336 $arrayidcontact =
$object->getIdContact(
'external',
'STFROM');
1338 $usecontact =
false;
1339 if (count($arrayidcontact) > 0) {
1343 $result =
$object->fetch_contact($arrayidcontact[0]);
1347 $thirdparty =
$object->contact;
1349 $thirdparty = $this->emetteur;
1352 if (!empty($thirdparty)) {
1364 $posx = $this->marge_gauche;
1366 $posx = $this->page_largeur - $this->marge_droite - 80;
1373 $pdf->SetTextColor(0, 0, 0);
1374 $pdf->SetFont(
'',
'', $default_font_size - 2);
1375 $pdf->SetXY($posx, $posy - 5);
1376 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1377 $pdf->SetXY($posx, $posy);
1378 $pdf->SetFillColor(230, 230, 230);
1379 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1380 $pdf->SetTextColor(0, 0, 60);
1381 $pdf->SetFillColor(255, 255, 255);
1384 $pdf->SetXY($posx + 2, $posy + 3);
1385 $pdf->SetFont(
'',
'B', $default_font_size);
1386 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1387 $posy = $pdf->getY();
1390 $pdf->SetXY($posx + 2, $posy);
1391 $pdf->SetFont(
'',
'', $default_font_size - 1);
1392 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1396 $usecontact =
false;
1397 $arrayidcontact =
$object->getIdContact(
'external',
'STDEST');
1398 if (count($arrayidcontact) > 0) {
1400 $result =
$object->fetch_contact($arrayidcontact[0]);
1406 $thirdparty =
$object->contact;
1408 $thirdparty =
$object->thirdparty;
1411 $carac_client_name =
'';
1412 if (!empty($thirdparty)) {
1420 if ($this->page_largeur < 210) {
1424 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1426 $posx = $this->marge_gauche;
1430 $pdf->SetTextColor(0, 0, 0);
1431 $pdf->SetFont(
'',
'', $default_font_size - 2);
1432 $pdf->SetXY($posx + 2, $posy - 5);
1433 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1434 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1437 $pdf->SetXY($posx + 2, $posy + 3);
1438 $pdf->SetFont(
'',
'B', $default_font_size);
1439 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1441 $posy = $pdf->getY();
1444 $pdf->SetFont(
'',
'', $default_font_size - 1);
1445 $pdf->SetXY($posx + 2, $posy);
1446 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1449 $pdf->SetTextColor(0, 0, 0);