diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index dc6d19614f9..12dc4ac3e9d 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2013 Florian Henry * Copyright (C) 2013-2016 Alexandre Spangaro @@ -50,8 +50,8 @@ $langs->load("commercial"); $mesg=''; $error=0; $errors=array(); $action = (GETPOST('action','alpha') ? GETPOST('action','alpha') : 'view'); -$confirm = GETPOST('confirm','alpha'); -$backtopage = GETPOST('backtopage','alpha'); +$confirm = GETPOST('confirm','alpha'); +$backtopage = GETPOST('backtopage','alpha'); $id = GETPOST('id','int'); $socid = GETPOST('socid','int'); @@ -137,63 +137,64 @@ if (empty($reshook)) } - // Confirmation desactivation - if ($action == 'disable') - { - $object->fetch($id); - if ($object->setstatus(0)<0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - else - { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - } - } + // Confirmation desactivation + if ($action == 'disable') + { + $object->fetch($id); + if ($object->setstatus(0)<0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + else + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } + } - // Confirmation activation - if ($action == 'enable') - { - $object->fetch($id); - if ($object->setstatus(1)<0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - else - { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - } - } + // Confirmation activation + if ($action == 'enable') + { + $object->fetch($id); + if ($object->setstatus(1)<0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + else + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } + } - // Add contact - if ($action == 'add' && $user->rights->societe->contact->creer) - { - $db->begin(); + // Add contact + if ($action == 'add' && $user->rights->societe->contact->creer) + { + $db->begin(); if ($canvas) $object->canvas=$canvas; + $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); $object->socid = GETPOST("socid",'int'); $object->lastname = GETPOST("lastname"); $object->firstname = GETPOST("firstname"); - $object->civility_id = GETPOST("civility_id",'alpha'); + $object->civility_id = GETPOST("civility_id",'alpha'); $object->poste = GETPOST("poste"); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); + $object->address = GETPOST("address"); + $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id",'int'); - $object->state_id = GETPOST("state_id",'int'); + $object->state_id = GETPOST("state_id",'int'); $object->skype = GETPOST("skype"); $object->email = GETPOST("email",'alpha'); $object->phone_pro = GETPOST("phone_pro"); - $object->phone_perso = GETPOST("phone_perso"); + $object->phone_perso = GETPOST("phone_perso"); $object->phone_mobile = GETPOST("phone_mobile"); - $object->fax = GETPOST("fax"); + $object->fax = GETPOST("fax"); $object->jabberid = GETPOST("jabberid",'alpha'); $object->no_email = GETPOST("no_email",'int'); $object->priv = GETPOST("priv",'int'); - $object->note_public = GETPOST("note_public"); + $object->note_public = GETPOST("note_public"); $object->note_private = GETPOST("note_private"); $object->statut = 1; //Defult status to Actif @@ -347,26 +348,26 @@ if (empty($reshook)) $object->socid = GETPOST("socid",'int'); $object->lastname = GETPOST("lastname"); $object->firstname = GETPOST("firstname"); - $object->civility_id = GETPOST("civility_id",'alpha'); + $object->civility_id = GETPOST("civility_id",'alpha'); $object->poste = GETPOST("poste"); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); + $object->address = GETPOST("address"); + $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); - $object->state_id = GETPOST("state_id",'int'); + $object->state_id = GETPOST("state_id",'int'); $object->fk_departement = GETPOST("state_id",'int'); // For backward compatibility $object->country_id = GETPOST("country_id",'int'); $object->email = GETPOST("email",'alpha'); $object->skype = GETPOST("skype",'alpha'); $object->phone_pro = GETPOST("phone_pro"); - $object->phone_perso = GETPOST("phone_perso"); + $object->phone_perso = GETPOST("phone_perso"); $object->phone_mobile = GETPOST("phone_mobile"); - $object->fax = GETPOST("fax"); + $object->fax = GETPOST("fax"); $object->jabberid = GETPOST("jabberid",'alpha'); $object->no_email = GETPOST("no_email",'int'); $object->priv = GETPOST("priv",'int'); - $object->note_public = GETPOST("note_public"); + $object->note_public = GETPOST("note_public"); $object->note_private = GETPOST("note_private"); // Fill array 'array_options' with data from add form @@ -531,12 +532,14 @@ else print ''; print ''; print ''; + if (! empty($objsoc)) { + print ''; + } dol_fiche_head($head, 'card', '', 0, ''); print ''; - // Name print ''; print ''; @@ -673,7 +676,7 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="3"','cols'=>3); + $parameters=array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 08fe253dffd..ca4880d68b8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -187,7 +187,7 @@ class Contact extends CommonObject $sql.= ", statut"; $sql.= ", canvas"; $sql.= ", entity"; - $sql.= ",ref_ext"; + $sql.= ", ref_ext"; $sql.= ", import_key"; $sql.= ") VALUES ("; $sql.= "'".$this->db->idate($now)."',"; @@ -199,7 +199,7 @@ class Contact extends CommonObject $sql.= " ".$this->priv.","; $sql.= " ".$this->statut.","; $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; - $sql.= " ".$conf->entity.","; + $sql.= " ".$this->entity.","; $sql.= "'".$this->db->escape($this->ref_ext)."',"; $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= ")"; @@ -642,7 +642,7 @@ class Contact extends CommonObject $langs->load("companies"); - $sql = "SELECT c.rowid, c.fk_soc, c.ref_ext, c.civility as civility_id, c.lastname, c.firstname,"; + $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_id, c.lastname, c.firstname,"; $sql.= " c.address, c.statut, c.zip, c.town,"; $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement,"; @@ -671,41 +671,42 @@ class Contact extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->rowid; $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_id; - $this->civility_code = $obj->civility_id; + $this->civility_code = $obj->civility_id; $this->lastname = $obj->lastname; - $this->firstname = $obj->firstname; + $this->firstname = $obj->firstname; $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; $this->fk_departement = $obj->fk_departement; // deprecated $this->state_id = $obj->fk_departement; - $this->departement_code = $obj->state_code; // deprecated - $this->state_code = $obj->state_code; + $this->departement_code = $obj->state_code; // deprecated + $this->state_code = $obj->state_code; $this->departement = $obj->state; // deprecated - $this->state = $obj->state; + $this->state = $obj->state; $this->country_id = $obj->country_id; $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->socid = $obj->fk_soc; + $this->socid = $obj->fk_soc; $this->socname = $obj->socname; - $this->poste = $obj->poste; + $this->poste = $obj->poste; $this->statut = $obj->statut; - $this->phone_pro = trim($obj->phone); + $this->phone_pro = trim($obj->phone); $this->fax = trim($obj->fax); $this->phone_perso = trim($obj->phone_perso); $this->phone_mobile = trim($obj->phone_mobile); - $this->email = $obj->email; + $this->email = $obj->email; $this->jabberid = $obj->jabberid; - $this->skype = $obj->skype; - $this->photo = $obj->photo; + $this->skype = $obj->skype; + $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email;
lastname).'" autofocus="autofocus">