From fd45bb16bdc50879f1efd72844877751806916ed Mon Sep 17 00:00:00 2001 From: jfefe Date: Wed, 30 Apr 2014 19:18:51 +0200 Subject: [PATCH] Fix : make ODT substitution for company after contacts --- .../core/class/commondocgenerator.class.php | 51 ++++++++++--------- .../societe/doc/doc_generic_odt.modules.php | 22 ++++---- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 691ae054646..702c2d93014 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -224,31 +224,32 @@ abstract class CommonDocGenerator } $array_contact = array ( - $array_key . '_lastname' => $object->lastname, - $array_key . '_firstname' => $object->firstname, - $array_key . '_address' => $object->address, - $array_key . '_zip' => $object->zip, - $array_key . '_town' => $object->town, - $array_key . '_state_id' => $object->state_id, - $array_key . '_state_code' => $object->state_code, - $array_key . '_state' => $object->state, - $array_key . '_country_id' => $object->country_id, - $array_key . '_country_code' => $object->country_code, - $array_key . '_country' => $object->country, - $array_key . '_poste' => $object->poste, - $array_key . '_socid' => $object->socid, - $array_key . '_statut' => $object->statut, - $array_key . '_code' => $object->code, - $array_key . '_email' => $object->email, - $array_key . '_jabberid' => $object->jabberid, - $array_key . '_phone_pro' => $object->phone_pro, - $array_key . '_phone_perso' => $object->phone_perso, - $array_key . '_phone_mobile' => $object->phone_mobile, - $array_key . '_fax' => $object->fax, - $array_key . '_birthday' => $object->birthday, - $array_key . '_default_lang' => $object->default_lang, - $array_key . '_note_public' => $object->note_public, - $array_key . '_note_private' => $object->note_private + $array_key . '_fullname' => $object->getFullName($outputlangs, 1), + $array_key . '_lastname' => $object->lastname, + $array_key . '_firstname' => $object->firstname, + $array_key . '_address' => $object->address, + $array_key . '_zip' => $object->zip, + $array_key . '_town' => $object->town, + $array_key . '_state_id' => $object->state_id, + $array_key . '_state_code' => $object->state_code, + $array_key . '_state' => $object->state, + $array_key . '_country_id' => $object->country_id, + $array_key . '_country_code' => $object->country_code, + $array_key . '_country' => $object->country, + $array_key . '_poste' => $object->poste, + $array_key . '_socid' => $object->socid, + $array_key . '_statut' => $object->statut, + $array_key . '_code' => $object->code, + $array_key . '_email' => $object->email, + $array_key . '_jabberid' => $object->jabberid, + $array_key . '_phone_pro' => $object->phone_pro, + $array_key . '_phone_perso' => $object->phone_perso, + $array_key . '_phone_mobile' => $object->phone_mobile, + $array_key . '_fax' => $object->fax, + $array_key . '_birthday' => $object->birthday, + $array_key . '_default_lang' => $object->default_lang, + $array_key . '_note_public' => $object->note_public, + $array_key . '_note_private' => $object->note_private ); // Retrieve extrafields diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index d83ca92d702..75b54ba285e 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -293,20 +293,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc // setVars failed, probably because key not found } } - // Make substitutions into odt of thirdparty + external modules - $tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object); // Replace tags of lines for contacts - $contact_arrray=array(); $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; - dol_syslog('doc_generic_odt :: sql='.$sql,LOG_DEBUG); $result = $this->db->query($sql); $num = $this->db->num_rows($result); @@ -315,27 +310,23 @@ class doc_generic_odt extends ModeleThirdPartyDoc if ($num) { $i=0; - $contactstatic = new Contact($this->db); - while ($i < $num) + while($i < $num) { $obj = $this->db->fetch_object($result); $contact_arrray[$i] = $obj->rowid; - //$contactstatic; - - $i++; } } - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) + if((is_array($contact_arrray) && count($contact_arrray) > 0)) { try { $listlines = $odfHandler->setSegment('companycontacts'); - foreach ($contact_arrray as $array_key => $contact_id) + foreach($contact_arrray as $array_key => $contact_id) { $res_contact = $contactstatic->fetch($contact_id); //$contact['fullname']=$objectdetail->getFullName($outputlangs,1); @@ -399,8 +390,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc { } } + + + // Make substitutions into odt of thirdparty + external modules + $tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object); - // Call the beforeODTSave hook + // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks