Debug v20

This commit is contained in:
Laurent Destailleur 2024-08-02 14:35:42 +02:00
parent bc9afff591
commit cd17e88a50
2 changed files with 60 additions and 55 deletions

View file

@ -120,7 +120,7 @@ class pdf_eagle extends ModelePDFStockTransfer
// Get source company
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) {
if (empty($this->emetteur->country_code)) {
$this->emetteur->country_code = substr($langs->defaultlang, -2);
}
@ -192,7 +192,7 @@ class pdf_eagle extends ModelePDFStockTransfer
$outputlangs->charset_output = 'ISO-8859-1';
}
// Load traductions files required by page
// Load translation files required by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer"));
global $outputlangsbis;
@ -264,7 +264,7 @@ class pdf_eagle extends ModelePDFStockTransfer
}
if ($conf->stocktransfer->dir_output) {
// Definition de $dir et $file
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->stocktransfer->dir_output;
$file = $dir."/SPECIMEN.pdf";
@ -325,10 +325,10 @@ class pdf_eagle extends ModelePDFStockTransfer
}
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
$pdf->SetSubject($outputlangs->transnoentities("StockTransfer"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("StockTransfer"));
if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
$pdf->SetCompression(false);
}
@ -755,7 +755,7 @@ class pdf_eagle extends ModelePDFStockTransfer
return 0;
}
} else {
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR");
return 0;
}
}
@ -1010,14 +1010,15 @@ class pdf_eagle extends ModelePDFStockTransfer
// phpcs:enable
global $conf, $langs;
$langs->load("orders");
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
if ($object->statut == 0 && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) {
if ($object->statut == 0 && (getDolGlobalString('STOCKTRANSFER_DRAFT_WATERMARK'))) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
}
@ -1272,6 +1273,6 @@ class pdf_eagle extends ModelePDFStockTransfer
{
// phpcs:enable
$showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
return pdf_pagefoot($pdf, $outputlangs, 'STOCKTRANSFER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}

View file

@ -86,7 +86,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
global $langs, $mysoc;
// Translations
$langs->loadLangs(array("main", "bills", "products"));
$langs->loadLangs(array("main", "bills", "products", "stocks"));
$this->db = $db;
$this->name = $langs->trans("StockTransferSheetProforma");
@ -158,14 +158,15 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$outputlangs->charset_output = 'ISO-8859-1';
}
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
// Load translation files required by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer"));
global $outputlangsbis;
$outputlangsbis = null;
if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
global $outputlangsbis;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
$outputlangsbis->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
}
$nblines = is_array($object->lines) ? count($object->lines) : 0;
@ -178,7 +179,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
$this->atleastonephoto = false;
if (getDolGlobalString('MAIN_GENERATE_ORDERS_WITH_PICTURE')) {
if (getDolGlobalString('MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE')) {
$objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++) {
@ -261,14 +262,18 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Set nblines with the new facture lines content after hook
$nblines = is_array($object->lines) ? count($object->lines) : 0;
// Create pdf instance
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
@ -276,7 +281,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
@ -286,10 +291,10 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
$pdf->SetSubject($outputlangs->transnoentities("StockTransferProFormat"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle").($object->thirdparty ? " ".$outputlangs->convToOutputCharset($object->thirdparty->name) : ''));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("StockTransfer"));
if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
$pdf->SetCompression(false);
}
@ -324,7 +329,8 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$tab_height = 130;
// Incoterm
if ($conf->incoterm->enabled) {
$height_incoterms = 0;
if (isModEnabled('incoterm')) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top -= 2;
@ -339,6 +345,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
$tab_top = $nexY + 6;
$height_incoterms += 4;
}
}
@ -562,8 +569,8 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
@ -682,6 +689,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$tvaligne = $object->lines[$i]->total_tva;
}
/*
$localtax1ligne = $object->lines[$i]->total_localtax1;
$localtax2ligne = $object->lines[$i]->total_localtax2;
$localtax1_rate = $object->lines[$i]->localtax1_tx;
@ -689,11 +697,6 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$localtax1_type = $object->lines[$i]->localtax1_type;
$localtax2_type = $object->lines[$i]->localtax2_type;
// TODO remise_percent is an obsolete field for object parent
/*if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;*/
$vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
@ -727,6 +730,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$this->tva[$vatrate] = 0;
}
$this->tva[$vatrate] += $tvaligne;
*/
// Add line
if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
@ -781,14 +785,10 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
}
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos
// ! No paiement information for this model !
//$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
// Display total area
$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Pied de page
// Pagefoot
$this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) {
$pdf->AliasNbPages();
@ -1178,7 +1178,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
if ($object->statut == 0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) {
if ($object->statut == 0 && getDolGlobalString('STOCKTRANSFER_DRAFT_WATERMARK')) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
}
@ -1188,7 +1188,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$w = 110;
$posy = $this->marge_haute;
$posx = $this->page_largeur - $this->marge_droite - 100;
$posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy);
@ -1219,21 +1219,18 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
}
}
$pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetDrawColor(128, 128, 128);
$posx = $this->page_largeur - $w - $this->marge_droite;
$posy = $this->marge_haute;
$pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities($titlekey);
$pdf->MultiCell($w, 3, $title, '', 'R');
$title = $outputlangs->transnoentities("StockTransferSheet").' '.$object->ref;
$pdf->MultiCell($w, 4, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
$posy += 1;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetFont('', '', $default_font_size + 1);
// Date prévue depart
if (!empty($object->date_prevue_depart)) {
@ -1267,6 +1264,13 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
}
if (!empty($object->thirdparty->code_client)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
}
if ($object->ref_client) {
$posy += 5;
$pdf->SetXY($posx, $posy);
@ -1369,7 +1373,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
@ -1414,8 +1418,8 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
// Show recipient
$widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
if ($this->page_largeur < 210) {
$widthrecbox = 84;
} // To work with US executive format
$widthrecbox = 84; // To work with US executive format
}
$posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
@ -1452,17 +1456,17 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
/**
* Show footer of page. Need this->emetteur object
*
* @param TCPDF $pdf PDF
* @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
* @param TCPDF $pdf PDF
* @param StockTransfer $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
// phpcs:enable
$showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
return pdf_pagefoot($pdf, $outputlangs, 'STOCKTRANSFER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}