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 $logodir = $conf->mycompany->dir_output;
286 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
287 $logodir = $conf->mycompany->multidir_output[
$object->entity];
289 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
290 $tplidx = $pdf->importPage(1);
295 $pdf->SetDrawColor(128, 128, 128);
297 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
298 $pdf->SetSubject($outputlangs->transnoentities(
"StockTransferSheetProforma"));
299 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
300 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
301 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"StockTransfer"));
303 $pdf->SetCompression(
false);
307 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
310 if (is_array(
$object->lines)) {
311 foreach (
$object->lines as $line) {
312 if ($line->remise_percent) {
313 $this->atleastonediscount =
true;
321 if (!empty($tplidx)) {
322 $pdf->useTemplate($tplidx);
326 $pdf->SetFont(
'',
'', $default_font_size - 1);
327 $pdf->MultiCell(0, 3,
'');
328 $pdf->SetTextColor(0, 0, 0);
331 $tab_top = 90 + $top_shift;
332 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
336 $height_incoterms = 0;
337 if (isModEnabled(
'incoterm')) {
338 $desc_incoterms =
$object->getIncotermsForPDF();
339 if ($desc_incoterms) {
342 $pdf->SetFont(
'',
'', $default_font_size - 1);
343 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
344 $nexY = $pdf->GetY();
345 $height_incoterms = $nexY - $tab_top;
348 $pdf->SetDrawColor(192, 192, 192);
349 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
351 $tab_top = $nexY + 6;
352 $height_incoterms += 4;
357 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
360 if (is_object(
$object->thirdparty)) {
361 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
362 $salerepobj =
new User($this->db);
363 $salerepobj->fetch($salereparray[0][
'id']);
364 if (!empty($salerepobj->signature)) {
365 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
371 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
372 if (!empty($extranote)) {
376 $pagenb = $pdf->getPage();
378 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
379 $pageposbeforenote = $pagenb;
388 $pdf->startTransaction();
390 $pdf->SetFont(
'',
'', $default_font_size - 1);
391 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
393 $pageposafternote = $pdf->getPage();
394 $posyafter = $pdf->GetY();
396 if ($pageposafternote > $pageposbeforenote) {
397 $pdf->rollbackTransaction(
true);
400 while ($pagenb < $pageposafternote) {
403 if (!empty($tplidx)) {
404 $pdf->useTemplate($tplidx);
410 $pdf->setTopMargin($tab_top_newpage);
412 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
416 $pdf->setPage($pageposbeforenote);
417 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
418 $pdf->SetFont(
'',
'', $default_font_size - 1);
419 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
420 $pageposafternote = $pdf->getPage();
422 $posyafter = $pdf->GetY();
424 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
425 $pdf->AddPage(
'',
'',
true);
428 $pdf->setPage($pageposafternote);
429 $pdf->setTopMargin($tab_top_newpage);
431 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
437 $i = $pageposbeforenote;
438 while ($i < $pageposafternote) {
442 $pdf->SetDrawColor(128, 128, 128);
444 if ($i > $pageposbeforenote) {
445 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
446 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
448 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
449 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
453 $pdf->setPageOrientation(
'', 1, 0);
460 $pdf->setPage($pageposafternote);
461 if (!empty($tplidx)) {
462 $pdf->useTemplate($tplidx);
467 $height_note = $posyafter - $tab_top_newpage;
468 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
470 $pdf->commitTransaction();
471 $posyafter = $pdf->GetY();
472 $height_note = $posyafter - $tab_top;
473 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
476 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
478 $pdf->AddPage(
'',
'',
true);
481 $pdf->setPage($pageposafternote);
482 if (!empty($tplidx)) {
483 $pdf->useTemplate($tplidx);
489 $posyafter = $tab_top_newpage;
493 $tab_height = $tab_height - $height_note;
494 $tab_top = $posyafter + 6;
504 $pdf->startTransaction();
505 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
506 $pdf->rollbackTransaction(
true);
508 $nexY = $tab_top + $this->tabTitleHeight;
511 $pageposbeforeprintlines = $pdf->getPage();
512 $pagenb = $pageposbeforeprintlines;
513 for ($i = 0; $i < $nblines; $i++) {
515 $pdf->SetFont(
'',
'', $default_font_size - 1);
516 $pdf->SetTextColor(0, 0, 0);
519 $imglinesize = array();
520 if (!empty($realpatharray[$i])) {
524 $pdf->setTopMargin($tab_top_newpage);
525 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
526 $pageposbefore = $pdf->getPage();
529 $showpricebeforepagebreak = 1;
534 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
535 $pdf->AddPage(
'',
'',
true);
536 if (!empty($tplidx)) {
537 $pdf->useTemplate($tplidx);
539 $pdf->setPage($pageposbefore + 1);
541 $curY = $tab_top_newpage;
545 $showpricebeforepagebreak = 1;
547 $showpricebeforepagebreak = 0;
551 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
552 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
554 $posYAfterImage = $curY + $imglinesize[
'height'];
559 $pdf->startTransaction();
561 if (method_exists(
$object->lines[$i],
'fetch_product')) {
562 $object->lines[$i]->fetch_product();
564 $object->lines[$i]->description =
$object->lines[$i]->product->description;
565 $object->lines[$i]->fk_unit =
$object->lines[$i]->product->fk_unit;
570 $pageposafter = $pdf->getPage();
571 if ($pageposafter > $pageposbefore) {
572 $pdf->rollbackTransaction(
true);
573 $pageposafter = $pageposbefore;
575 $pdf->setPageOrientation(
'', 1, $heightforfooter);
578 $pageposafter = $pdf->getPage();
579 $posyafter = $pdf->GetY();
580 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
581 if ($i == ($nblines - 1)) {
582 $pdf->AddPage(
'',
'',
true);
583 if (!empty($tplidx)) {
584 $pdf->useTemplate($tplidx);
587 $pdf->setPage($pageposafter + 1);
593 $showpricebeforepagebreak = 1;
595 $showpricebeforepagebreak = 0;
599 $pdf->commitTransaction();
605 $nexY = max($pdf->GetY(), $posYAfterImage);
608 $pageposafter = $pdf->getPage();
610 $pdf->setPage($pageposbefore);
611 $pdf->setTopMargin($this->marge_haute);
612 $pdf->setPageOrientation(
'', 1, 0);
615 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
616 $pdf->setPage($pageposafter);
617 $curY = $tab_top_newpage;
620 $pdf->SetFont(
'',
'', $default_font_size - 1);
626 $nexY = max($pdf->GetY(), $nexY);
631 $pmp =
$object->lines[$i]->pmp;
633 $nexY = max($pdf->GetY(), $nexY);
641 $nexY = max($pdf->GetY(), $nexY);
649 $nexY = max($pdf->GetY(), $nexY);
656 $nexY = max($pdf->GetY(), $nexY);
661 $pmp_qty = $pmp *
$object->lines[$i]->qty;
663 $nexY = max($pdf->GetY(), $nexY);
667 if (!empty(
$object->lines[$i]->array_options)) {
668 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
672 $nexY = max($pdf->GetY(), $nexY);
683 'outputlangs' => $outputlangs,
684 'hidedetails' => $hidedetails
686 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
690 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
691 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
693 $tvaligne =
$object->lines[$i]->total_tva;
741 $pdf->setPage($pageposafter);
742 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
744 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
745 $pdf->SetLineStyle(array(
'dash' => 0));
750 while ($pagenb < $pageposafter) {
751 $pdf->setPage($pagenb);
752 if ($pagenb == $pageposbeforeprintlines) {
753 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
755 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
759 $pdf->setPage($pagenb);
760 $pdf->setPageOrientation(
'', 1, 0);
765 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
766 if ($pagenb == $pageposafter) {
767 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
769 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
774 if (!empty($tplidx)) {
775 $pdf->useTemplate($tplidx);
785 if ($pagenb == $pageposbeforeprintlines) {
786 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
788 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
790 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
797 if (method_exists($pdf,
'AliasNbPages')) {
798 $pdf->AliasNbPages();
803 $pdf->Output($file,
'F');
806 $hookmanager->initHooks(array(
'pdfgeneration'));
807 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
809 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
811 $this->error = $hookmanager->error;
812 $this->errors = $hookmanager->errors;
817 $this->result = array(
'fullpath' => $file);
821 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
825 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"STOCKTRANSFER_OUTPUTDIR");
841 global $conf, $mysoc;
844 $pdf->SetFont(
'',
'', $default_font_size - 1);
847 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
848 $pdf->SetFont(
'',
'B', $default_font_size - 2);
849 $pdf->SetXY($this->marge_gauche, $posy);
850 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
852 $posy = $pdf->GetY() + 4;
859 $pdf->SetFont(
'',
'B', $default_font_size - 2);
860 $pdf->SetXY($this->marge_gauche, $posy);
861 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
862 $pdf->MultiCell(43, 4, $titre, 0,
'L');
864 $pdf->SetFont(
'',
'', $default_font_size - 2);
865 $pdf->SetXY($posxval, $posy);
866 $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);
867 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
868 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
870 $posy = $pdf->GetY() + 3;
901 if (!empty(
$object->delivery_date)) {
902 $outputlangs->load(
"sendings");
903 $pdf->SetFont(
'',
'B', $default_font_size - 2);
904 $pdf->SetXY($this->marge_gauche, $posy);
905 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
906 $pdf->MultiCell(80, 4, $titre, 0,
'L');
907 $pdf->SetFont(
'',
'', $default_font_size - 2);
908 $pdf->SetXY($posxval, $posy);
910 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
912 $posy = $pdf->GetY() + 1;
914 $pdf->SetFont(
'',
'B', $default_font_size - 2);
915 $pdf->SetXY($this->marge_gauche, $posy);
916 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
917 $pdf->MultiCell(80, 4, $titre, 0,
'L');
918 $pdf->SetTextColor(0, 0, 0);
919 $pdf->SetFont(
'',
'', $default_font_size - 2);
920 $pdf->SetXY($posxval, $posy);
921 $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 :
'');
922 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
923 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
925 $posy = $pdf->GetY() + 1;
929 if (
$object->mode_reglement_code
930 &&
$object->mode_reglement_code !=
'CHQ'
931 &&
$object->mode_reglement_code !=
'VIR') {
932 $pdf->SetFont(
'',
'B', $default_font_size - 2);
933 $pdf->SetXY($this->marge_gauche, $posy);
934 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
935 $pdf->MultiCell(80, 5, $titre, 0,
'L');
937 $pdf->SetFont(
'',
'', $default_font_size - 2);
938 $pdf->SetXY($posxval, $posy);
939 $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);
940 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
942 $posy = $pdf->GetY() + 2;
946 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
950 $account =
new Account($this->db);
953 $pdf->SetXY($this->marge_gauche, $posy);
954 $pdf->SetFont(
'',
'B', $default_font_size - 3);
955 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
956 $posy = $pdf->GetY() + 1;
959 $pdf->SetXY($this->marge_gauche, $posy);
960 $pdf->SetFont(
'',
'', $default_font_size - 3);
961 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
962 $posy = $pdf->GetY() + 2;
966 $pdf->SetXY($this->marge_gauche, $posy);
967 $pdf->SetFont(
'',
'B', $default_font_size - 3);
968 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
969 $posy = $pdf->GetY() + 1;
972 $pdf->SetXY($this->marge_gauche, $posy);
973 $pdf->SetFont(
'',
'', $default_font_size - 3);
974 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
975 $posy = $pdf->GetY() + 2;
982 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
984 $bankid = (empty(
$object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
985 if (!empty(
$object->fk_bank)) {
988 $account =
new Account($this->db);
989 $account->fetch($bankid);
991 $curx = $this->marge_gauche;
994 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1016 global $conf, $mysoc;
1022 $pdf->SetFont(
'',
'', $default_font_size - 1);
1027 if ($this->page_largeur < 210) {
1030 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1034 $outputlangsbis =
null;
1036 $outputlangsbis =
new Translate(
'', $conf);
1038 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1050 $pdf->SetFillColor(248, 248, 248);
1052 $total_ttc =
$object->getValorisationTotale();
1054 $this->atleastoneratenotnull = 0;
1058 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1059 $pdf->SetTextColor(0, 0, 60);
1060 $pdf->SetFillColor(224, 224, 224);
1061 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"Total", $mysoc->country_code) :
''), $useborder,
'L', 1);
1063 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1064 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1066 $pdf->SetTextColor(0, 0, 0);
1068 $creditnoteamount = 0;
1069 $depositsamount = 0;
1073 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1078 if ($deja_regle > 0) {
1082 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1083 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1084 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1088 $pdf->SetTextColor(0, 0, 60);
1089 $pdf->SetFillColor(224, 224, 224);
1090 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1091 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1093 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1094 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1096 $pdf->SetFont(
'',
'', $default_font_size - 1);
1097 $pdf->SetTextColor(0, 0, 0);
1101 return ($tab2_top + ($tab2_hl * $index));
1172 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $titlekey =
"StockTransferSheetProforma")
1175 global $conf, $langs;
1178 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1189 $pdf->SetTextColor(0, 0, 60);
1190 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1194 $posy = $this->marge_haute;
1195 $posx = $this->page_largeur - $this->marge_droite - $w;
1197 $pdf->SetXY($this->marge_gauche, $posy);
1201 if ($this->emetteur->logo) {
1202 $logodir = $conf->mycompany->dir_output;
1203 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1204 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1207 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1209 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1211 if (is_readable($logo)) {
1213 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1215 $pdf->SetTextColor(200, 0, 0);
1216 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1217 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1218 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1221 $text = $this->emetteur->name;
1222 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1226 $pdf->SetDrawColor(128, 128, 128);
1228 $posx = $this->page_largeur - $w - $this->marge_droite;
1229 $posy = $this->marge_haute;
1231 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1232 $pdf->SetXY($posx, $posy);
1233 $pdf->SetTextColor(0, 0, 60);
1234 $title = $outputlangs->transnoentities(
"StockTransferSheet").
' '.
$object->ref;
1235 $pdf->MultiCell($w, 4, $title,
'',
'R');
1237 $pdf->SetFont(
'',
'', $default_font_size + 1);
1240 if (!empty(
$object->date_prevue_depart)) {
1242 $pdf->SetXY($posx, $posy);
1243 $pdf->SetTextColor(0, 0, 60);
1244 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date(
$object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1248 if (!empty(
$object->date_prevue_arrivee)) {
1250 $pdf->SetXY($posx, $posy);
1251 $pdf->SetTextColor(0, 0, 60);
1252 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date(
$object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1256 if (!empty(
$object->date_reelle_depart)) {
1258 $pdf->SetXY($posx, $posy);
1259 $pdf->SetTextColor(0, 0, 60);
1260 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date(
$object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1264 if (!empty(
$object->date_reelle_arrivee)) {
1266 $pdf->SetXY($posx, $posy);
1267 $pdf->SetTextColor(0, 0, 60);
1268 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date(
$object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1271 if (!empty(
$object->thirdparty->code_client)) {
1273 $pdf->SetXY($posx, $posy);
1274 $pdf->SetTextColor(0, 0, 60);
1275 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1280 $pdf->SetXY($posx, $posy);
1281 $pdf->SetTextColor(0, 0, 60);
1282 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1287 if (!empty(
$object->project->ref)) {
1289 $pdf->SetXY($posx, $posy);
1290 $pdf->SetTextColor(0, 0, 60);
1291 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->projet->title),
'',
'R');
1297 if (!empty(
$object->project->ref)) {
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetTextColor(0, 0, 60);
1301 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->projet->ref),
'',
'R');
1307 $pdf->SetXY($posx, $posy);
1308 $pdf->SetTextColor(0, 0, 60);
1309 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1314 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1315 if (count($arrayidcontact) > 0) {
1316 $usertmp =
new User($this->db);
1317 $usertmp->fetch($arrayidcontact[0]);
1319 $pdf->SetXY($posx, $posy);
1320 $pdf->SetTextColor(0, 0, 60);
1321 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1329 $current_y = $pdf->getY();
1331 if ($current_y < $pdf->getY()) {
1332 $top_shift = $pdf->getY() - $current_y;
1337 $carac_emetteur =
'';
1339 $arrayidcontact = array();
1340 $arrayidcontact =
$object->getIdContact(
'external',
'STFROM');
1342 $usecontact =
false;
1343 if (count($arrayidcontact) > 0) {
1347 $result =
$object->fetch_contact($arrayidcontact[0]);
1351 $thirdparty =
$object->contact;
1353 $thirdparty = $this->emetteur;
1356 if (!empty($thirdparty)) {
1368 $posx = $this->marge_gauche;
1370 $posx = $this->page_largeur - $this->marge_droite - 80;
1377 $pdf->SetTextColor(0, 0, 0);
1378 $pdf->SetFont(
'',
'', $default_font_size - 2);
1379 $pdf->SetXY($posx, $posy - 5);
1380 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1381 $pdf->SetXY($posx, $posy);
1382 $pdf->SetFillColor(230, 230, 230);
1383 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1384 $pdf->SetTextColor(0, 0, 60);
1385 $pdf->SetFillColor(255, 255, 255);
1388 $pdf->SetXY($posx + 2, $posy + 3);
1389 $pdf->SetFont(
'',
'B', $default_font_size);
1390 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1391 $posy = $pdf->getY();
1394 $pdf->SetXY($posx + 2, $posy);
1395 $pdf->SetFont(
'',
'', $default_font_size - 1);
1396 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1400 $usecontact =
false;
1401 $arrayidcontact =
$object->getIdContact(
'external',
'STDEST');
1402 if (count($arrayidcontact) > 0) {
1404 $result =
$object->fetch_contact($arrayidcontact[0]);
1410 $thirdparty =
$object->contact;
1412 $thirdparty =
$object->thirdparty;
1415 $carac_client_name =
'';
1416 if (!empty($thirdparty)) {
1424 if ($this->page_largeur < 210) {
1428 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1430 $posx = $this->marge_gauche;
1434 $pdf->SetTextColor(0, 0, 0);
1435 $pdf->SetFont(
'',
'', $default_font_size - 2);
1436 $pdf->SetXY($posx + 2, $posy - 5);
1437 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1438 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1441 $pdf->SetXY($posx + 2, $posy + 3);
1442 $pdf->SetFont(
'',
'B', $default_font_size);
1443 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1445 $posy = $pdf->getY();
1448 $pdf->SetFont(
'',
'', $default_font_size - 1);
1449 $pdf->SetXY($posx + 2, $posy);
1450 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1453 $pdf->SetTextColor(0, 0, 0);