Skip to content

Commit

Permalink
Merge pull request #27159 from atm-lena/17.0_FIX_MultilangsTranslatio…
Browse files Browse the repository at this point in the history
…nPDFLinesDescription

FIX Multilangs : PDF lines description
  • Loading branch information
eldy authored Jan 15, 2025
2 parents 49feeee + 66a175e commit 88d81aa
Showing 1 changed file with 55 additions and 16 deletions.
71 changes: 55 additions & 16 deletions htdocs/core/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1410,29 +1410,68 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
{
global $db, $conf, $langs;

$idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
$label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : ''));
$desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : ''));
$ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
$multilangsactive = getDolGlobalInt('MAIN_MULTILANGS');

if ($issupplierline) {
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$prodser = new ProductFournisseur($db);
} else {
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$prodser = new Product($db);
if ($issupplierline) {

Check failure on line 1415 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';

Check failure on line 1416 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$prodser = new ProductFournisseur($db);

Check failure on line 1417 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
} else {

Check failure on line 1418 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';

Check failure on line 1419 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$prodser = new Product($db);

Check failure on line 1420 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed

if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {

Check failure on line 1422 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';

Check failure on line 1423 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
}

Check failure on line 1424 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed
}

Check failure on line 1425 in htdocs/core/lib/pdf.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed

//id
$idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
if($idprod) {
$prodser->fetch($idprod);
//load multilangs
if($multilangsactive){
$prodser->getMultiLangs();
$object->lines[$i]->multilangs = $prodser->multilangs;
}
}
//label
if (!empty($object->lines[$i]->label)) {
$label = $object->lines[$i]->label;
} else {
if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']) && $multilangsactive) {
$label = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['label'];
} else {
if (!empty($object->lines[$i]->product_label)) {
$label = $object->lines[$i]->product_label;
} else {
$label = '';
}
}
}
//description
if (!empty($object->lines[$i]->desc)) {
$desc = $object->lines[$i]->desc;
} else {
if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']) && $multilangsactive) {
$desc = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['description'];
} else {
if (!empty($object->lines[$i]->description)) {
$desc = $object->lines[$i]->description;
} else {
$desc = '';
}
}
}
//ref supplier
$ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
//note
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
//dbatch
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);

if ($idprod) {
$prodser->fetch($idprod);
// If a predefined product and multilang and on other lang, we renamed label with label translated
if (getDolGlobalInt('MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) {
if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) {
$translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it)

// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
Expand Down

0 comments on commit 88d81aa

Please sign in to comment.