Fix : make ODT substitution for company after contacts

This commit is contained in:
jfefe 2014-04-30 19:18:51 +02:00
parent 00cd616f4c
commit fd45bb16bd
2 changed files with 35 additions and 38 deletions

View File

@ -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

View File

@ -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