Merge pull request #798 from lrq3000/develop3
Add: ODTSubstitution and ODTSubstitutionLine hooks with $odfHandler for ...
This commit is contained in:
commit
281cd49f32
@ -3598,7 +3598,9 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='
|
|||||||
$module=$reg[1];
|
$module=$reg[1];
|
||||||
|
|
||||||
dol_syslog("Library functions_".$substitfile['name']." found into ".$dir);
|
dol_syslog("Library functions_".$substitfile['name']." found into ".$dir);
|
||||||
|
// Include the user's functions file
|
||||||
require_once $dir.$substitfile['name'];
|
require_once $dir.$substitfile['name'];
|
||||||
|
// Call the user's function, and only if it is defined
|
||||||
$function_name=$module."_".$callfunc;
|
$function_name=$module."_".$callfunc;
|
||||||
if (function_exists($function_name)) $function_name($substitutionarray,$outputlangs,$object,$parameters);
|
if (function_exists($function_name)) $function_name($substitutionarray,$outputlangs,$object,$parameters);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -260,6 +260,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add odtgeneration hook
|
||||||
|
if (! is_object($hookmanager))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager=new HookManager($this->db);
|
||||||
|
}
|
||||||
|
$hookmanager->initHooks(array('odtgeneration'));
|
||||||
|
global $action;
|
||||||
|
|
||||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
$outputlangs->charset_output='UTF-8';
|
$outputlangs->charset_output='UTF-8';
|
||||||
@ -346,6 +355,9 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
'__TOTAL_VAT__' => $object->total_vat
|
'__TOTAL_VAT__' => $object->total_vat
|
||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
|
||||||
|
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Line of free text
|
// Line of free text
|
||||||
$newfreetext='';
|
$newfreetext='';
|
||||||
@ -445,6 +457,9 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
// Replace tags of object + external modules
|
// Replace tags of object + external modules
|
||||||
$tmparray=$this->get_substitutionarray_object($object,$outputlangs);
|
$tmparray=$this->get_substitutionarray_object($object,$outputlangs);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('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
|
||||||
foreach($tmparray as $key=>$value)
|
foreach($tmparray as $key=>$value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -470,6 +485,9 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||||
|
// Call the ODTSubstitutionLine hook
|
||||||
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
||||||
|
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
foreach($tmparray as $key => $val)
|
foreach($tmparray as $key => $val)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -494,15 +512,8 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add odtgeneration hook
|
// Call the beforeODTSave hook
|
||||||
if (! is_object($hookmanager))
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager=new HookManager($this->db);
|
|
||||||
}
|
|
||||||
$hookmanager->initHooks(array('odtgeneration'));
|
|
||||||
$parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
|
||||||
global $action;
|
|
||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
|
|||||||
@ -283,6 +283,15 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add odtgeneration hook
|
||||||
|
if (! is_object($hookmanager))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager=new HookManager($this->db);
|
||||||
|
}
|
||||||
|
$hookmanager->initHooks(array('odtgeneration'));
|
||||||
|
global $action;
|
||||||
|
|
||||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
$outputlangs->charset_output='UTF-8';
|
$outputlangs->charset_output='UTF-8';
|
||||||
@ -375,6 +384,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
'__TOTAL_VAT__' => $object->total_tva
|
'__TOTAL_VAT__' => $object->total_tva
|
||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
|
||||||
|
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Line of free text
|
// Line of free text
|
||||||
$newfreetext='';
|
$newfreetext='';
|
||||||
@ -420,6 +432,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
|
|
||||||
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
|
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('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
|
||||||
|
|
||||||
//var_dump($tmparray); exit;
|
//var_dump($tmparray); exit;
|
||||||
foreach($tmparray as $key=>$value)
|
foreach($tmparray as $key=>$value)
|
||||||
@ -448,6 +463,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||||
|
// Call the ODTSubstitutionLine hook
|
||||||
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
||||||
|
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
foreach($tmparray as $key => $val)
|
foreach($tmparray as $key => $val)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -472,15 +490,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add odtgeneration hook
|
// Call the beforeODTSave hook
|
||||||
if (! is_object($hookmanager))
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager=new HookManager($this->db);
|
|
||||||
}
|
|
||||||
$hookmanager->initHooks(array('odtgeneration'));
|
|
||||||
$parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
|
||||||
global $action;
|
|
||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
|
|||||||
@ -222,6 +222,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add odtgeneration hook
|
||||||
|
if (! is_object($hookmanager))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager=new HookManager($this->db);
|
||||||
|
}
|
||||||
|
$hookmanager->initHooks(array('odtgeneration'));
|
||||||
|
global $action;
|
||||||
|
|
||||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
$outputlangs->charset_output='UTF-8';
|
$outputlangs->charset_output='UTF-8';
|
||||||
@ -308,6 +317,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
'__TOTAL_VAT__' => $object->total_vat
|
'__TOTAL_VAT__' => $object->total_vat
|
||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
|
||||||
|
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Line of free text
|
// Line of free text
|
||||||
$newfreetext='';
|
$newfreetext='';
|
||||||
@ -408,6 +420,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
$tmparray=$this->get_substitutionarray_propal($object,$outputlangs);
|
$tmparray=$this->get_substitutionarray_propal($object,$outputlangs);
|
||||||
//print_r($tmparray); exit;
|
//print_r($tmparray); exit;
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('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
|
||||||
foreach($tmparray as $key=>$value)
|
foreach($tmparray as $key=>$value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -433,6 +448,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_propal_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_propal_lines($line,$outputlangs);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||||
|
// Call the ODTSubstitutionLine hook
|
||||||
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
||||||
|
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
foreach($tmparray as $key => $val)
|
foreach($tmparray as $key => $val)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -457,10 +475,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add odtgeneration hook
|
// Call the beforeODTSave hook
|
||||||
$hookmanager->initHooks(array('odtgeneration'));
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||||
$parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
|
||||||
global $action;
|
|
||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
|
|||||||
@ -173,6 +173,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add odtgeneration hook
|
||||||
|
if (! is_object($hookmanager))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager=new HookManager($this->db);
|
||||||
|
}
|
||||||
|
$hookmanager->initHooks(array('odtgeneration'));
|
||||||
|
global $action;
|
||||||
|
|
||||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
$outputlangs->charset_output='UTF-8';
|
$outputlangs->charset_output='UTF-8';
|
||||||
@ -276,6 +285,9 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
// Make substitutions into odt of thirdparty + external modules
|
// Make substitutions into odt of thirdparty + external modules
|
||||||
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
|
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
|
// Call the ODTSubstitution hook
|
||||||
|
$parameters=array('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
|
||||||
//var_dump($object->id); exit;
|
//var_dump($object->id); exit;
|
||||||
foreach($tmparray as $key=>$value)
|
foreach($tmparray as $key=>$value)
|
||||||
{
|
{
|
||||||
@ -296,10 +308,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add odtgeneration hook
|
// Call the beforeODTSave hook
|
||||||
$hookmanager->initHooks(array('odtgeneration'));
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||||
$parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
|
||||||
global $action;
|
|
||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user