FIX Bad use of a forced contact of another company on PDF/ODT documents

This commit is contained in:
Laurent Destailleur 2021-10-05 13:09:32 +02:00
parent b559dc9053
commit b11dbf069e
39 changed files with 175 additions and 147 deletions

View File

@ -165,7 +165,8 @@ class Contact extends CommonObject
/** /**
* @var int Thirdparty ID * @var int Thirdparty ID
*/ */
public $socid; public $socid; // both socid and fk_soc are used
public $fk_soc; // both socid and fk_soc are used
/** /**
* @var int 0=inactive, 1=active * @var int 0=inactive, 1=active
@ -1027,7 +1028,8 @@ class Contact extends CommonObject
$this->country_code = $obj->country_id ? $obj->country_code : ''; $this->country_code = $obj->country_id ? $obj->country_code : '';
$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; $this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : '';
$this->socid = $obj->fk_soc; $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used
$this->socid = $obj->fk_soc; // Both fk_soc and socid are used
$this->socname = $obj->socname; $this->socname = $obj->socname;
$this->poste = $obj->poste; $this->poste = $obj->poste;
$this->statut = $obj->statut; $this->statut = $obj->statut;

View File

@ -295,12 +295,14 @@ class doc_generic_bom_odt extends ModelePDFBom
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
// On peut utiliser le nom de la societe du contact // We can use the company of contact instead of thirdparty company
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$socobject = $object->contact; $object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -96,7 +96,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$this->option_freetext = 1; // Support add of a personalised text $this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts $this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur // Get source company
$this->emetteur = $mysoc; $this->emetteur = $mysoc;
if (!$this->emetteur->country_code) { if (!$this->emetteur->country_code) {
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
@ -307,11 +307,14 @@ class doc_generic_order_odt extends ModelePDFCommandes
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {
@ -379,6 +382,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$array_other = $this->get_substitutionarray_other($outputlangs); $array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in object as contact_xxx tags // retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array(); $array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) { if ($usecontact && is_object($contactobject)) {
$array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
} }

View File

@ -1438,7 +1438,7 @@ class pdf_einstein extends ModelePDFCommandes
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -1623,7 +1623,7 @@ class pdf_eratosthene extends ModelePDFCommandes
} }
//Recipient name //Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -295,11 +295,14 @@ class doc_generic_contract_odt extends ModelePDFContract
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -716,7 +716,7 @@ class pdf_strato extends ModelePDFContract
$this->recipient = $object->thirdparty; $this->recipient = $object->thirdparty;
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -860,7 +860,7 @@ class pdf_storm extends ModelePDFDeliveryOrder
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -859,7 +859,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -307,11 +307,14 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a SHIPPING contact and we dont use as recipient we store the contact object for later use // if we have a SHIPPING contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1117,7 +1117,7 @@ class pdf_espadon extends ModelePdfExpedition
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -676,7 +676,7 @@ class pdf_merou extends ModelePdfExpedition
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -1067,7 +1067,7 @@ class pdf_rouget extends ModelePdfExpedition
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -308,11 +308,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use // if we have a BILLING contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1888,7 +1888,7 @@ class pdf_crabe extends ModelePDFFactures
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -2117,7 +2117,7 @@ class pdf_sponge extends ModelePDFFactures
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -670,7 +670,7 @@ class pdf_soleil extends ModelePDFFicheinter
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -295,11 +295,14 @@ class doc_generic_member_odt extends ModelePDFMember
// Recipient name // Recipient name
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -302,11 +302,14 @@ class doc_generic_mo_odt extends ModelePDFMo
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -319,11 +319,14 @@ class doc_generic_product_odt extends ModelePDFProduct
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -335,11 +335,14 @@ class doc_generic_proposal_odt extends ModelePDFPropales
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1605,7 +1605,7 @@ class pdf_azur extends ModelePDFPropales
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -1719,7 +1719,7 @@ class pdf_cyan extends ModelePDFPropales
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -62,8 +62,7 @@ class doc_generic_reception_odt extends ModelePdfReception
{ {
global $conf, $langs, $mysoc; global $conf, $langs, $mysoc;
$langs->load("main"); $langs->loadLangs(array("main", "companies"));
$langs->load("companies");
$this->db = $db; $this->db = $db;
$this->name = "ODT templates"; $this->name = "ODT templates";
@ -173,6 +172,11 @@ class doc_generic_reception_odt extends ModelePdfReception
} }
$texte .= '</div>'; $texte .= '</div>';
} }
// Add input to upload a new template file.
$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte .= '<input type="hidden" value="RECEPTION_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte .= '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
$texte .= '</div>';
$texte .= '</td>'; $texte .= '</td>';
@ -223,10 +227,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$sav_charset_output = $outputlangs->charset_output; $sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8'; $outputlangs->charset_output = 'UTF-8';
$outputlangs->load("main"); $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
if ($conf->reception->dir_output."/reception") { if ($conf->reception->dir_output."/reception") {
// If $object is id instead of object // If $object is id instead of object
@ -288,21 +289,25 @@ class doc_generic_reception_odt extends ModelePdfReception
return -1; return -1;
} }
// If BILLING contact defined on invoice, we use it // If CUSTOMER contact defined on reception, we use it
$usecontact = false; $usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'BILLING'); $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0) { if (count($arrayidcontact) > 0) {
$usecontact = true; $usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]); $result = $object->fetch_contact($arrayidcontact[0]);
} }
// Recipient name // Recipient name
$contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {
@ -318,6 +323,7 @@ class doc_generic_reception_odt extends ModelePdfReception
'__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 // Call the ODTSubstitution hook
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); $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 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
@ -343,6 +349,7 @@ class doc_generic_reception_odt extends ModelePdfReception
); );
} catch (Exception $e) { } catch (Exception $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1; return -1;
} }
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
@ -359,67 +366,23 @@ class doc_generic_reception_odt extends ModelePdfReception
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
// Make substitutions into odt of user info // Define substitution array
$tmparray = $this->get_substitutionarray_user($user, $outputlangs); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
//var_dump($tmparray); exit; $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
foreach ($tmparray as $key => $value) { $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
try { $array_user = $this->get_substitutionarray_user($user, $outputlangs);
if (preg_match('/logo$/', $key)) { // Image $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
//var_dump($value);exit; $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
if (file_exists($value)) { $array_other = $this->get_substitutionarray_other($outputlangs);
$odfHandler->setImage($key, $value); // retrieve contact information for use in object as contact_xxx tags
} else { $array_thirdparty_contact = array();
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); if ($usecontact && is_object($contactobject)) {
$array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
} }
} else // Text
{ $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Make substitutions into odt of mysoc
$tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
//var_dump($tmparray); exit;
foreach ($tmparray as $key => $value) {
try {
if (preg_match('/logo$/', $key)) { // Image
//var_dump($value);exit;
if (file_exists($value)) {
$odfHandler->setImage($key, $value);
} else {
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
} else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Make substitutions into odt of thirdparty
$tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
foreach ($tmparray as $key => $value) {
try {
if (preg_match('/logo$/', $key)) { // Image
if (file_exists($value)) {
$odfHandler->setImage($key, $value);
} else {
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
} else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Replace tags of object + external modules
$tmparray = $this->get_substitutionarray_reception($object, $outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook // Call the ODTSubstitution hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $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 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
@ -440,9 +403,19 @@ class doc_generic_reception_odt extends ModelePdfReception
} }
} }
// Replace tags of lines // Replace tags of lines
try {
$foundtagforlines = 1;
try { try {
$listlines = $odfHandler->setSegment('lines'); $listlines = $odfHandler->setSegment('lines');
} catch (OdfException $e) {
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
$linenumber = 0;
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
$linenumber++;
$tmparray = $this->get_substitutionarray_reception_lines($line, $outputlangs); $tmparray = $this->get_substitutionarray_reception_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 // Call the ODTSubstitutionLine hook
@ -460,6 +433,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$listlines->merge(); $listlines->merge();
} }
$odfHandler->mergeSegment($listlines); $odfHandler->mergeSegment($listlines);
}
} catch (OdfException $e) { } catch (OdfException $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING); dol_syslog($this->error, LOG_WARNING);
@ -486,6 +460,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$odfHandler->exportAsAttachedPDF($file); $odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) { } catch (Exception $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1; return -1;
} }
} else { } else {
@ -493,6 +468,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$odfHandler->saveToDisk($file); $odfHandler->saveToDisk($file);
} catch (Exception $e) { } catch (Exception $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1; return -1;
} }
} }
@ -505,6 +481,8 @@ class doc_generic_reception_odt extends ModelePdfReception
$odfHandler = null; // Destroy object $odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success return 1; // Success
} else { } else {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);

View File

@ -972,7 +972,7 @@ class pdf_squille extends ModelePdfReception
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -308,11 +308,14 @@ class doc_generic_stock_odt extends ModelePDFStock
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1238,7 +1238,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $mysoc; $thirdparty = $mysoc;

View File

@ -298,11 +298,14 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1407,7 +1407,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -1314,7 +1314,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -332,11 +332,14 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1418,7 +1418,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
// Recipient name // Recipient name
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$socname = $object->contact; $socname = $object->contact;
} else { } else {
$socname = $object->thirdparty; $socname = $object->thirdparty;

View File

@ -293,11 +293,14 @@ class doc_generic_ticket_odt extends ModelePDFTicket
// Recipient name // Recipient name
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -325,7 +325,7 @@ class doc_generic_user_odt extends ModelePDFUser
// Recipient name // Recipient name
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$socobject = $object->contact; $socobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;

View File

@ -315,11 +315,14 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
// Recipient name // Recipient name
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -301,11 +301,14 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1110,7 +1110,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
} }
// Recipient name // Recipient name
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;

View File

@ -294,11 +294,14 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// Recipient name // Recipient name
$contactobject = null; $contactobject = null;
if (!empty($usecontact)) { if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { // We can use the company of contact instead of thirdparty company
$socobject = $object->contact; if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$object->contact->fetch_thirdparty();
$socobject = $object->contact->thirdparty;
$contactobject = $object->contact;
} else { } else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} else { } else {

View File

@ -1026,7 +1026,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
} }
// Recipient name // Recipient name
/*if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { /*if ($usecontact && $object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;