Skip to content

Commit

Permalink
Merge pull request #42 from frederic34/dev
Browse files Browse the repository at this point in the history
fix warnings
  • Loading branch information
frederic34 authored Feb 8, 2024
2 parents f098d49 + 0601e71 commit 6caf77f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 61 deletions.
7 changes: 4 additions & 3 deletions core/modules/commande/doc/doc_easydoc_order_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(['pdfgeneration']);
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs];
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

Expand Down Expand Up @@ -321,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$this->errors = $e->getMessage();
return -1;
}

$logo = '';
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
Expand Down Expand Up @@ -352,6 +352,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$tmparray = explode('_', $mysoc->country_code);
$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
$label_payment_conditions = '';
if ($object->cond_reglement_code) {
$label_payment_conditions = ($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 ? $object->cond_reglement_doc : $object->cond_reglement_label);

Check warning on line 357 in core/modules/commande/doc/doc_easydoc_order_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 300 characters; contains 386 characters
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
Expand Down Expand Up @@ -396,7 +397,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray);

// Call the ODTSubstitution hook
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);

// Line of free text
Expand Down
14 changes: 3 additions & 11 deletions core/modules/contract/doc/doc_easydoc_contract_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(['pdfgeneration']);
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs];
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

Expand Down Expand Up @@ -321,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$this->errors = $e->getMessage();
return -1;
}

$logo = '';
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
Expand Down Expand Up @@ -352,13 +352,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$tmparray = explode('_', $mysoc->country_code);
$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
if ($object->cond_reglement_code) {
$label_payment_conditions = ($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 ? $object->cond_reglement_doc : $object->cond_reglement_label);
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
if ($object->deposit_percent > 0) {
$label_payment_conditions = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $label_payment_conditions);
}
}
// If CUSTOMER contact defined on contract, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
Expand Down Expand Up @@ -396,7 +389,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray);

// Call the ODTSubstitution hook
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);

// Line of free text
Expand Down Expand Up @@ -458,7 +451,6 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
'lines' => [],
'linkedObjects' => $linkedObjects,
'footerinfo' => getPdfPagefoot($outputlangs, $paramfreetext, $mysoc, $object),
'labelpaymentconditions' => $label_payment_conditions,
'currency' => $currency,
'currencyinfo' => $outputlangs->trans("AmountInCurrency", $outputlangs->trans("Currency" . $currency)),
]);
Expand Down
5 changes: 3 additions & 2 deletions core/modules/facture/doc/doc_easydoc_invoice_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(['pdfgeneration']);
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs];
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

Expand Down Expand Up @@ -322,7 +322,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$this->errors = $e->getMessage();
return -1;
}

$logo = '';
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
Expand Down Expand Up @@ -353,6 +353,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$tmparray = explode('_', $mysoc->country_code);
$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
$label_payment_conditions = '';
if ($object->cond_reglement_code) {
$label_payment_conditions = ($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 ? $object->cond_reglement_doc : $object->cond_reglement_label);

Check warning on line 358 in core/modules/facture/doc/doc_easydoc_invoice_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 300 characters; contains 386 characters
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
Expand Down
69 changes: 34 additions & 35 deletions core/modules/product/doc/doc_easydoc_product_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct($db)
// Name of constant that is used to save list of directories to scan
$this->scandir = 'PRODUCT_ADDON_EASYDOC_TEMPLATES_PATH';
// Save the name of generated file as the main doc when generating a doc with this template
$this->update_main_doc_field = ((int) DOL_VERSION < 20) ? 0 : 1;
$this->update_main_doc_field = ((int) DOL_VERSION < 21) ? 0 : 1;

// Page size for A4 format
$this->type = 'pdf';
Expand Down Expand Up @@ -259,7 +259,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(['pdfgeneration']);
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs];
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

Expand Down Expand Up @@ -321,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$this->errors = $e->getMessage();
return -1;
}

$logo = '';
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
Expand Down Expand Up @@ -382,7 +382,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray);

// Call the ODTSubstitution hook
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);

// Line of free text
Expand All @@ -407,44 +407,43 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
'lines' => [],
'linkedObjects' => $linkedObjects,
'footerinfo' => getPdfPagefoot($outputlangs, $paramfreetext, $mysoc, $object),
'labelpaymentconditions' => $label_payment_conditions,
'currency' => $currency,
'currencyinfo' => $outputlangs->trans("AmountInCurrency", $outputlangs->trans("Currency" . $currency)),
]);
// var_dump($substitutions);
$subtotal_ht = 0;
$subtotal_ttc = 0;
$linenumber = 1;
foreach ($object->lines as $key => $line) {
$subtotal_ht += $line->total_ht;
$subtotal_ttc += $line->total_ttc;
if ($line->special_code == 104777 && $line->qty == 99) {
$line->total_ht = $subtotal_ht;
$line->total_ttc = $subtotal_ttc;
$subtotal_ht = 0;
$subtotal_ttc = 0;
}
$substitutions['lines'][$key] = [
'linenumber' => $linenumber,
'qty' => $line->qty,
'ref' => $line->product_ref,
'label' => $line->label,
'description' => $line->desc,
'product_label' => $line->product_label,
'product_description' => $line->product_desc,
'subprice' => price($line->subprice),
'total_ht' => price($line->total_ht),
'total_ttc' => price($line->total_ttc),
'vatrate' => price($line->tva_tx) . '%',
'special_code' => $line->special_code,
'product_type' => $line->product_type,
'line_options' => [],
'product_options' => [],
];
if (empty($line->special_code)) {
$linenumber++;
}
}
// foreach ($object->lines as $key => $line) {
// $subtotal_ht += $line->total_ht;
// $subtotal_ttc += $line->total_ttc;
// if ($line->special_code == 104777 && $line->qty == 99) {
// $line->total_ht = $subtotal_ht;
// $line->total_ttc = $subtotal_ttc;
// $subtotal_ht = 0;
// $subtotal_ttc = 0;
// }
// $substitutions['lines'][$key] = [
// 'linenumber' => $linenumber,
// 'qty' => $line->qty,
// 'ref' => $line->product_ref,
// 'label' => $line->label,
// 'description' => $line->desc,
// 'product_label' => $line->product_label,
// 'product_description' => $line->product_desc,
// 'subprice' => price($line->subprice),
// 'total_ht' => price($line->total_ht),
// 'total_ttc' => price($line->total_ttc),
// 'vatrate' => price($line->tva_tx) . '%',
// 'special_code' => $line->special_code,
// 'product_type' => $line->product_type,
// 'line_options' => [],
// 'product_options' => [],
// ];
// if (empty($line->special_code)) {
// $linenumber++;
// }
// }

// var_dump($substitutions);
$substitutions['debug'] = '<pre>' . print_r($substitutions, true) . '</pre>';
Expand Down
5 changes: 3 additions & 2 deletions core/modules/propale/doc/doc_easydoc_propale_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(['pdfgeneration']);
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs];
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

Expand Down Expand Up @@ -322,7 +322,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$this->errors = $e->getMessage();
return -1;
}

$logo = '';
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
Expand Down Expand Up @@ -353,6 +353,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$tmparray = explode('_', $mysoc->country_code);
$flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
}
$label_payment_conditions = '';
if ($object->cond_reglement_code) {
$label_payment_conditions = ($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 ? $object->cond_reglement_doc : $object->cond_reglement_label);

Check warning on line 358 in core/modules/propale/doc/doc_easydoc_propale_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 300 characters; contains 386 characters
$label_payment_conditions = str_replace('\n', "\n", $label_payment_conditions);
Expand Down
18 changes: 10 additions & 8 deletions core/modules/stock/doc/doc_easydoc_stock_html.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(['pdfgeneration']);
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs];
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

Expand Down Expand Up @@ -322,7 +322,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$this->errors = $e->getMessage();
return -1;
}

$logo = '';
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
Expand Down Expand Up @@ -390,7 +390,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$substitutionarray = array_merge(getCommonSubstitutionArray($outputlangs, 0, null, $object), $substitutionarray);

// Call the ODTSubstitution hook
$parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$parameters = ['object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray];
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);

// Line of free text
Expand All @@ -409,10 +409,12 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$substitutions = array_merge($substitutions, getEachVarObject($object, $outputlangs, 0));

// thirdparty
$substitutions = array_merge($substitutions, getEachVarObject($object->thirdparty, $outputlangs, 1, 'thirdparty'));
$substitutions['thirdparty']['flag'] = DOL_DOCUMENT_ROOT . '/theme/common/flags/' . strtolower($object->thirdparty->country_code) . '.png';
$substitutions['thirdparty']['phone_formatted'] = dol_print_phone($object->thirdparty->phone, $object->thirdparty->country_code, 0, 0, '', ' ');
$substitutions['thirdparty']['fax_formatted'] = dol_print_phone($object->thirdparty->fax, $object->thirdparty->country_code, 0, 0, '', ' ');
if (!empty($object->thirdparty)) {
$substitutions = array_merge($substitutions, getEachVarObject($object->thirdparty, $outputlangs, 1, 'thirdparty'));
$substitutions['thirdparty']['flag'] = DOL_DOCUMENT_ROOT . '/theme/common/flags/' . strtolower($object->thirdparty->country_code) . '.png';
$substitutions['thirdparty']['phone_formatted'] = dol_print_phone($object->thirdparty->phone, $object->thirdparty->country_code, 0, 0, '', ' ');
$substitutions['thirdparty']['fax_formatted'] = dol_print_phone($object->thirdparty->fax, $object->thirdparty->country_code, 0, 0, '', ' ');
}

$typescontact = [
'external' => [
Expand Down Expand Up @@ -508,7 +510,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
$mpdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$mpdf->SetCreator('Dolibarr ' . DOL_VERSION);
$mpdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$mpdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("PdfStockTitle") . " " . $outputlangs->convToOutputCharset($object->thirdparty->name));
$mpdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("PdfStockTitle"));
// Watermark
$text = getDolGlobalString('STOCK_DRAFT_WATERMARK');
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null);
Expand Down

0 comments on commit 6caf77f

Please sign in to comment.