Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic34 committed Jan 30, 2024
1 parent 14dfcbb commit 0a935b0
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 21 deletions.
40 changes: 20 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
]);
$mpdf->SetProtection(['print']);
$mpdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$mpdf->SetCreator('Dolibarr '.DOL_VERSION);

Check failure on line 477 in core/modules/commande/doc/doc_easydoc_order_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Expected at least 1 space before "."; 0 found

Check failure on line 477 in core/modules/commande/doc/doc_easydoc_order_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Expected at least 1 space after "."; 0 found
$mpdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$mpdf->SetWatermarkText(getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
if (!empty($conf->global->$paramfreetext)) {
$newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
}

// todo
// $test = getEachVarObject($object, $outputlangs);
// var_dump($test);
$substitutions = [
'mysoc' => [
'name' => $mysoc->name,
Expand Down Expand Up @@ -425,6 +427,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
'labelpaymentconditions' => $label_payment_conditions,
'currencyinfo' => $outputlangs->trans("AmountInCurrency", $outputlangs->trans("Currency" . $currency)),
];
$substitutions['debug'] = '<pre>' . print_r($substitutions, true) . '</pre>';
$subtotal_ht = 0;
$subtotal_ttc = 0;
$linenumber = 1;
Expand Down Expand Up @@ -473,6 +476,7 @@ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails
]);
$mpdf->SetProtection(['print']);
$mpdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$mpdf->SetCreator('Dolibarr '.DOL_VERSION);

Check failure on line 479 in core/modules/facture/doc/doc_easydoc_invoice_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Expected at least 1 space before "."; 0 found

Check failure on line 479 in core/modules/facture/doc/doc_easydoc_invoice_html.modules.php

View workflow job for this annotation

GitHub Actions / build

Expected at least 1 space after "."; 0 found
$mpdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$mpdf->SetWatermarkText(getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));

Expand Down
38 changes: 38 additions & 0 deletions lib/easydocgenerator.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,44 @@ function easydocgeneratorAdminPrepareHead()
return $head;
}

/**
* Define array with couple substitution key => substitution value
*
* @param Object $object Dolibarr Object
* @param Translate $outputlangs Language object for output
* @param boolean|int $recursive Want to fetch child array or child object.
* @return array Array of substitution key->code
*/
function getEachVarObject($object, $outputlangs, $recursive = 1)
{
$array_other = [];
if (!empty($object)) {
foreach ($object as $key => $value) {
if (in_array($key, array('db', 'fields', 'lines', 'modelpdf', 'model_pdf'))) { // discard some properties

Check failure on line 96 in lib/easydocgenerator.lib.php

View workflow job for this annotation

GitHub Actions / build

Short array syntax must be used to define arrays
continue;
}
if (!empty($value)) {
if (!is_array($value) && !is_object($value)) {
$array_other['object'][$key] = $value;
} elseif (is_array($value) && $recursive) {
$tmparray = getEachVarObject($value, $outputlangs, 0);
foreach ($tmparray as $key2 => $value2) {
$array_other['object'][$key . '_' . preg_replace('/^object_/', '', $key2)] = $value2;
}
} elseif (is_object($value) && $recursive) {
$tmparray = getEachVarObject($value, $outputlangs, 0);
foreach ($tmparray as $key2 => $value2) {
$array_other['object'][$key . '_' . preg_replace('/^object_/', '', $key2)] = $value2;
}
}
}
}
}

return $array_other;
}


/**
* Return footer info of page for PDF generation
*
Expand Down

0 comments on commit 0a935b0

Please sign in to comment.