From 0d308f74be0fafdbaba332d0f448c583c2b2bf2e Mon Sep 17 00:00:00 2001 From: Andreas Pachler Date: Thu, 24 Mar 2016 09:16:24 +0100 Subject: [PATCH 1/4] Added functionality to get project customer contact as contact_xx tags --- .../doc/doc_generic_project_odt.modules.php | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index d4ee4bacb80..b8dfa111446 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -482,7 +482,30 @@ class doc_generic_project_odt extends ModelePDFProjects dol_mkdir($conf->projet->dir_temp); - $socobject=$object->thirdparty; + // If PROJECTLEADER contact defined on project, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','PROJECTLEADER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } // Make substitution $substitutionarray=array( @@ -527,8 +550,12 @@ class doc_generic_project_odt extends ModelePDFProjects $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in project as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); From 7eded39e2803f4070ff50e355f56f54b420049f0 Mon Sep 17 00:00:00 2001 From: Andreas Pachler Date: Wed, 30 Mar 2016 08:34:32 +0200 Subject: [PATCH 2/4] Reworked functionality to get project contact as contact_xx tags --- .../doc/doc_generic_project_odt.modules.php | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index b8dfa111446..8b06239c996 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -494,19 +494,12 @@ class doc_generic_project_odt extends ModelePDFProjects // Recipient name if (! empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { - $socobject = $object->thirdparty; - // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } - } - else - { - $socobject=$object->thirdparty; + // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; } + $socobject=$object->thirdparty; + // Make substitution $substitutionarray=array( '__FROM_NAME__' => $this->emetteur->name, @@ -551,11 +544,11 @@ class doc_generic_project_odt extends ModelePDFProjects $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in project as contact_xxx tags - $array_thirdparty_contact = array(); + $array_project_contact = array(); if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); From 98ef17930707be7a5f653eb7713494e15c4aeb28 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 30 Mar 2016 21:09:27 +0200 Subject: [PATCH 3/4] Add contact hook I use the same hook name as contactpl --- htdocs/projet/tasks/contact.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 0faf21c1cc2..f3f58c17119 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -492,6 +492,13 @@ if ($id > 0 || ! empty($ref)) } } +if (is_object($hookmanager)) +{ + $hookmanager->initHooks(array('contacttpl')); + $parameters=array(); + $reshook=$hookmanager->executeHooks('formContactTpl',$parameters,$object,$action); +} + llxFooter(); From fbe0414a1fcf213cda5e824fb0b5ac483c5ab472 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Sun, 3 Apr 2016 20:49:57 +0200 Subject: [PATCH 4/4] Change FactureRec superclass CommonInvoice --- htdocs/compta/facture/class/facture-rec.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 87e2fea156c..8e4e05037a8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** * Classe de gestion des factures recurrentes/Modeles */ -class FactureRec extends Facture +class FactureRec extends CommonInvoice { public $element='facturerec'; public $table_element='facture_rec';