Try to address a better solution for #19776
This commit is contained in:
parent
4bac7e012f
commit
512df3c580
@ -1354,6 +1354,7 @@ if ($action == 'create') {
|
||||
$dateexample = $object->date_when;
|
||||
}
|
||||
|
||||
// Help of substitution key
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
|
||||
|
||||
$substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%m').')';
|
||||
|
||||
@ -400,6 +400,20 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_propal, $array_other, $array_thirdparty_contact);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
|
||||
// Complete also with substitution from keys directly found into template
|
||||
// TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding
|
||||
// property of object and use the xxxx to know how to format it.
|
||||
// Before that, we hard code this substitution as if we have found them into the template.
|
||||
$tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m');
|
||||
$tmparray['object_MONTH'] = dol_print_date($this->date, '%m');
|
||||
$tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m');
|
||||
$tmparray['object_PREVIOUS_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B');
|
||||
$tmparray['object_MONTH_TEXT'] = dol_print_date($this->date, '%B');
|
||||
$tmparray['object_NEXT_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B');
|
||||
$tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y');
|
||||
$tmparray['object_YEAR'] = dol_print_date($this->date, '%Y');
|
||||
$tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y');
|
||||
|
||||
// Call the ODTSubstitution hook
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
Loading…
Reference in New Issue
Block a user