Merge pull request #11829 from atm-florian/dev_contactdefault
NEW : Address/Contact by default on third parties
This commit is contained in:
commit
c6c498fd67
@ -371,6 +371,7 @@ if (empty($reshook))
|
|||||||
$object->priv = GETPOST("priv", 'int');
|
$object->priv = GETPOST("priv", 'int');
|
||||||
$object->note_public = GETPOST("note_public", 'none');
|
$object->note_public = GETPOST("note_public", 'none');
|
||||||
$object->note_private = GETPOST("note_private", 'none');
|
$object->note_private = GETPOST("note_private", 'none');
|
||||||
|
$object->roles = GETPOST("roles", 'array');
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
@ -474,9 +475,9 @@ else
|
|||||||
// Si edition contact deja existant
|
// Si edition contact deja existant
|
||||||
$object = new Contact($db);
|
$object = new Contact($db);
|
||||||
$res=$object->fetch($id, $user);
|
$res=$object->fetch($id, $user);
|
||||||
if ($res < 0) { dol_print_error($db, $object->error); exit; }
|
if ($res<0) {
|
||||||
$res=$object->fetch_optionals();
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
if ($res < 0) { dol_print_error($db, $object->error); exit; }
|
}
|
||||||
|
|
||||||
// Show tabs
|
// Show tabs
|
||||||
$head = contact_prepare_head($object);
|
$head = contact_prepare_head($object);
|
||||||
@ -724,6 +725,15 @@ else
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Role
|
||||||
|
if (!empty($socid)) {
|
||||||
|
print '<tr><td>' . $langs->trans("Role") . '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
$contactType = $object->listeTypeContacts('external', '', 1);
|
||||||
|
print $form->multiselectarray('roles', $contactType);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('socid' => $socid, 'objsoc' => $objsoc, '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
|
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
@ -1040,6 +1050,14 @@ else
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Role
|
||||||
|
if (!empty($object->socid)) {
|
||||||
|
print '<tr><td>' . $langs->trans("Role") . '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print $formcompany->showRoles("roles", $object, 'edit', $object->roles);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('colspan' => ' colspan="3"', 'cols'=>3);
|
$parameters=array('colspan' => ' colspan="3"', 'cols'=>3);
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
@ -1238,6 +1256,13 @@ else
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($object->socid)) {
|
||||||
|
print '<tr><td class="titlefield">' . $langs->trans("Roles") . '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print $formcompany->showRoles("roles", $object, 'view');
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$cols = 3;
|
$cols = 3;
|
||||||
$parameters=array('socid'=>$socid);
|
$parameters=array('socid'=>$socid);
|
||||||
|
|||||||
@ -124,6 +124,8 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
public $oldcopy; // To contains a clone of this when we need to save old properties of object
|
public $oldcopy; // To contains a clone of this when we need to save old properties of object
|
||||||
|
|
||||||
|
public $roles=array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -382,6 +384,14 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error) {
|
||||||
|
$result=$this->updateRoles();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error && $this->user_id > 0)
|
if (! $error && $this->user_id > 0)
|
||||||
{
|
{
|
||||||
$tmpobj = new User($this->db);
|
$tmpobj = new User($this->db);
|
||||||
@ -844,6 +854,11 @@ class Contact extends CommonObject
|
|||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$this->fetch_optionals();
|
$this->fetch_optionals();
|
||||||
|
|
||||||
|
$resultRole=$this->fetchRoles();
|
||||||
|
if ($resultRole<0) {
|
||||||
|
return $resultRole;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -978,6 +993,20 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
// Remove Roles
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
|
||||||
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error .= $this->db->lasterror();
|
||||||
|
$errorflag=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Remove category
|
// Remove category
|
||||||
@ -1435,4 +1464,150 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch Role for a contact
|
||||||
|
*
|
||||||
|
* @return float|int
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function fetchRoles()
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$error= 0;
|
||||||
|
$num=0;
|
||||||
|
|
||||||
|
$sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle, sc.rowid as contactroleid";
|
||||||
|
$sql.=" FROM ".MAIN_DB_PREFIX."societe_contacts as sc ";
|
||||||
|
$sql.=" INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
|
$sql.=" ON tc.rowid = sc.fk_c_type_contact";
|
||||||
|
$sql.=" AND sc.fk_socpeople = ". $this->id;
|
||||||
|
$sql.=" AND tc.source = 'external' AND tc.active=1";
|
||||||
|
$sql.=" AND sc.entity IN (".getEntity('societe').')';
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$this->roles=array();
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
if ($num > 0) {
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
|
||||||
|
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
|
||||||
|
$this->roles[$obj->contactroleid]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>$libelle_element. ' - '.($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
$this->errors[]=$this->db->lasterror();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($error)) {
|
||||||
|
return $num;
|
||||||
|
} else {
|
||||||
|
return $error * -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Contact roles for a thirdparty
|
||||||
|
*
|
||||||
|
* @param string $element element type
|
||||||
|
* @return array|int
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getContactRoles($element = '')
|
||||||
|
{
|
||||||
|
$tab=array();
|
||||||
|
|
||||||
|
$sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
|
||||||
|
$sql.= ", ".MAIN_DB_PREFIX."societe_contacts sc";
|
||||||
|
$sql.= " WHERE sc.fk_soc =".$this->socid;
|
||||||
|
$sql.= " AND sc.fk_c_type_contact=tc.rowid";
|
||||||
|
$sql.= " AND tc.element='".$element."'";
|
||||||
|
$sql.= " AND tc.active=1";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num=$this->db->num_rows($resql);
|
||||||
|
$i=0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$tab[]=array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact);
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tab;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates Roles
|
||||||
|
*
|
||||||
|
* @return float|int
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function updateRoles()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
$this->errors[]=$this->db->lasterror().' sql='.$sql;
|
||||||
|
$error++;
|
||||||
|
} else {
|
||||||
|
if (count($this->roles)>0) {
|
||||||
|
foreach ($this->roles as $keyRoles => $valRoles) {
|
||||||
|
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_contacts";
|
||||||
|
$sql .= " (entity,";
|
||||||
|
$sql .= "date_creation,";
|
||||||
|
$sql .= "fk_soc,";
|
||||||
|
$sql .= "fk_c_type_contact,";
|
||||||
|
$sql .= "fk_socpeople) ";
|
||||||
|
$sql .= " VALUES (" . $conf->entity . ",";
|
||||||
|
$sql .= "'" . $this->db->idate(dol_now()) . "',";
|
||||||
|
$sql .= $this->socid . ", ";
|
||||||
|
$sql .= $valRoles . " , " ;
|
||||||
|
$sql .= $this->id;
|
||||||
|
$sql .= ")";
|
||||||
|
dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
$this->errors[]=$this->db->lasterror().' sql='.$sql;
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($error)) {
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
$this->error=implode(' ', $this->errors);
|
||||||
|
$this->db->rollback();
|
||||||
|
return $error*-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("companies", "suppliers", "categories"));
|
$langs->loadLangs(array("companies", "suppliers", "categories"));
|
||||||
@ -84,6 +85,7 @@ $search_zip=GETPOST('search_zip', 'alpha');
|
|||||||
$search_town=GETPOST('search_town', 'alpha');
|
$search_town=GETPOST('search_town', 'alpha');
|
||||||
$search_import_key=GETPOST("search_import_key", "alpha");
|
$search_import_key=GETPOST("search_import_key", "alpha");
|
||||||
$search_country=GETPOST("search_country", 'intcomma');
|
$search_country=GETPOST("search_country", 'intcomma');
|
||||||
|
$search_roles=GETPOST("search_roles", 'array');
|
||||||
|
|
||||||
if ($search_status=='') $search_status=1; // always display active customer first
|
if ($search_status=='') $search_status=1; // always display active customer first
|
||||||
|
|
||||||
@ -243,6 +245,7 @@ if (empty($reshook))
|
|||||||
$search_import_key='';
|
$search_import_key='';
|
||||||
$toselect='';
|
$toselect='';
|
||||||
$search_array_options=array();
|
$search_array_options=array();
|
||||||
|
$search_roles=array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mass actions
|
// Mass actions
|
||||||
@ -263,6 +266,7 @@ if ($search_priv < 0) $search_priv='';
|
|||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$formother=new FormOther($db);
|
$formother=new FormOther($db);
|
||||||
|
$formcompany=new FormCompany($db);
|
||||||
$contactstatic=new Contact($db);
|
$contactstatic=new Contact($db);
|
||||||
|
|
||||||
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||||
@ -335,6 +339,9 @@ if (strlen($search_linkedin)) $sql.= natural_search('p.linkedin', $search_
|
|||||||
if (strlen($search_email)) $sql.= natural_search('p.email', $search_email);
|
if (strlen($search_email)) $sql.= natural_search('p.email', $search_email);
|
||||||
if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip);
|
if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip);
|
||||||
if (strlen($search_town)) $sql.= natural_search("p.town", $search_town);
|
if (strlen($search_town)) $sql.= natural_search("p.town", $search_town);
|
||||||
|
if (count($search_roles)>0) {
|
||||||
|
$sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))";
|
||||||
|
}
|
||||||
|
|
||||||
if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email);
|
if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email);
|
||||||
if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status);
|
if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status);
|
||||||
@ -439,6 +446,7 @@ if ($search_status != '') $param.='&search_status='.urlencode($search_status
|
|||||||
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
|
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
|
||||||
if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
|
if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
|
||||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||||
|
if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles);
|
||||||
|
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
@ -511,6 +519,10 @@ if (! empty($conf->categorie->enabled))
|
|||||||
$moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1);
|
$moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1);
|
||||||
$moreforfilter.='</div>';
|
$moreforfilter.='</div>';
|
||||||
}
|
}
|
||||||
|
$moreforfilter.='<div class="divsearchfield">';
|
||||||
|
$moreforfilter.=$langs->trans('Roles'). ': ';
|
||||||
|
$moreforfilter.=$formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles);
|
||||||
|
$moreforfilter.='</div>';
|
||||||
}
|
}
|
||||||
if ($moreforfilter)
|
if ($moreforfilter)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1217,6 +1217,82 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
/**
|
||||||
|
* Return array with list of possible values for type of contacts
|
||||||
|
*
|
||||||
|
* @param string $source 'internal', 'external' or 'all'
|
||||||
|
* @param int $option 0=Return array id->label, 1=Return array code->label
|
||||||
|
* @param int $activeonly 0=all status of contact, 1=only the active
|
||||||
|
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
|
||||||
|
* @param string $element Filter Element Type
|
||||||
|
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
|
||||||
|
*/
|
||||||
|
public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '')
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
|
$tab = array();
|
||||||
|
|
||||||
|
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
|
|
||||||
|
$sqlWhere=array();
|
||||||
|
if (!empty($element))
|
||||||
|
$sqlWhere[]=" tc.element='".$this->db->escape($element)."'";
|
||||||
|
|
||||||
|
if ($activeonly == 1)
|
||||||
|
$sqlWhere[]=" tc.active=1"; // only the active types
|
||||||
|
|
||||||
|
if (! empty($source) && $source != 'all')
|
||||||
|
$sqlWhere[]=" tc.source='".$this->db->escape($source)."'";
|
||||||
|
|
||||||
|
if (! empty($code))
|
||||||
|
$sqlWhere[]=" tc.code='".$this->db->escape($code)."'";
|
||||||
|
|
||||||
|
if (count($sqlWhere)>0) {
|
||||||
|
$sql .= " WHERE ". implode(' AND ', $sqlWhere);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql.= $this->db->order('tc.element, tc.position', 'ASC');
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
if ($num > 0) {
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
if (strpos($obj->element, 'project')!==false) {
|
||||||
|
$element='projet';
|
||||||
|
} elseif($obj->element=='contrat') {
|
||||||
|
$element='contract';
|
||||||
|
} elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') {
|
||||||
|
$element='fournisseur';
|
||||||
|
} elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') {
|
||||||
|
$element='fournisseur';
|
||||||
|
} else {
|
||||||
|
$element=$obj->element;
|
||||||
|
}
|
||||||
|
if ($conf->{$element}->enabled) {
|
||||||
|
$libelle_element = $langs->trans('ContactDefault_' . $obj->element);
|
||||||
|
$transkey = "TypeContact_" . $this->element . "_" . $source . "_" . $obj->code;
|
||||||
|
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
|
||||||
|
if (empty($option))
|
||||||
|
$tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type;
|
||||||
|
else $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $tab;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return id of contacts for a source and a contact code.
|
* Return id of contacts for a source and a contact code.
|
||||||
* Example: contact client de facturation ('external', 'BILLING')
|
* Example: contact client de facturation ('external', 'BILLING')
|
||||||
|
|||||||
@ -6574,7 +6574,6 @@ class Form
|
|||||||
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
|
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show linked object block.
|
* Show linked object block.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -29,28 +29,11 @@
|
|||||||
* Class to build HTML component for third parties management
|
* Class to build HTML component for third parties management
|
||||||
* Only common components are here.
|
* Only common components are here.
|
||||||
*/
|
*/
|
||||||
class FormCompany
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||||
|
|
||||||
|
class FormCompany extends Form
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler.
|
|
||||||
*/
|
|
||||||
public $db;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Error code (or message)
|
|
||||||
*/
|
|
||||||
public $error='';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param DoliDB $db Database handler
|
|
||||||
*/
|
|
||||||
public function __construct($db)
|
|
||||||
{
|
|
||||||
$this->db = $db;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
@ -763,6 +746,45 @@ class FormCompany
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* showContactRoles on view and edit mode
|
||||||
|
*
|
||||||
|
* @param string $htmlname Html component name and id
|
||||||
|
* @param Contact $contact Contact Obejct
|
||||||
|
* @param string $rendermode view, edit
|
||||||
|
* @param array $selected $key=>$val $val is selected Roles for input mode
|
||||||
|
* @return string String with contacts roles
|
||||||
|
*/
|
||||||
|
public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array())
|
||||||
|
{
|
||||||
|
if ($rendermode === 'view') {
|
||||||
|
$toprint = array();
|
||||||
|
foreach ($contact->roles as $key => $val) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa;">' . $val['label'] . '</li>';
|
||||||
|
}
|
||||||
|
return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="'.$htmlname.'"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rendermode === 'edit')
|
||||||
|
{
|
||||||
|
$contactType=$contact->listeTypeContacts('external', '', 1);
|
||||||
|
if (count($selected)>0) {
|
||||||
|
$newselected=array();
|
||||||
|
foreach($selected as $key=>$val) {
|
||||||
|
if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
|
||||||
|
$newselected[]=$val['id'];
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($newselected)>0) $selected=$newselected;
|
||||||
|
}
|
||||||
|
return $this->multiselectarray($htmlname, $contactType, $selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
|
||||||
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return a select list with zip codes and their town
|
* Return a select list with zip codes and their town
|
||||||
|
|||||||
@ -859,6 +859,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
global $user,$conf,$extrafields,$hookmanager;
|
global $user,$conf,$extrafields,$hookmanager;
|
||||||
global $contextpage;
|
global $contextpage;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
|
$formcompany = new FormCompany($db);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
$optioncss = GETPOST('optioncss', 'alpha');
|
$optioncss = GETPOST('optioncss', 'alpha');
|
||||||
@ -872,6 +874,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
$search_name = GETPOST("search_name", 'alpha');
|
$search_name = GETPOST("search_name", 'alpha');
|
||||||
$search_address = GETPOST("search_address", 'alpha');
|
$search_address = GETPOST("search_address", 'alpha');
|
||||||
$search_poste = GETPOST("search_poste", 'alpha');
|
$search_poste = GETPOST("search_poste", 'alpha');
|
||||||
|
$search_roles = GETPOST("search_roles", 'array');
|
||||||
|
|
||||||
$searchAddressPhoneDBFields = array(
|
$searchAddressPhoneDBFields = array(
|
||||||
//Address
|
//Address
|
||||||
@ -919,7 +922,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
|
'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
|
||||||
'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20),
|
'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20),
|
||||||
'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30),
|
'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30),
|
||||||
'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))),
|
'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40),
|
||||||
|
'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Definition of fields for list
|
// Definition of fields for list
|
||||||
@ -928,7 +932,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10),
|
't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10),
|
||||||
't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20),
|
't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20),
|
||||||
't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30),
|
't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30),
|
||||||
't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'),
|
'sc.role'=>array('label'=>"Roles", 'checked'=>1, 'position'=>40),
|
||||||
|
't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'),
|
||||||
);
|
);
|
||||||
// Extra fields
|
// Extra fields
|
||||||
if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label']))
|
if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label']))
|
||||||
@ -961,9 +966,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
{
|
{
|
||||||
$search_status = '';
|
$search_status = '';
|
||||||
$search_name = '';
|
$search_name = '';
|
||||||
|
$search_roles = array();
|
||||||
$search_address = '';
|
$search_address = '';
|
||||||
$search_poste = '';
|
$search_poste = '';
|
||||||
$search= [];
|
$search = array();
|
||||||
$search_array_options=array();
|
$search_array_options=array();
|
||||||
|
|
||||||
foreach($contactstatic->fields as $key => $val)
|
foreach($contactstatic->fields as $key => $val)
|
||||||
@ -1003,6 +1009,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
|
|
||||||
$param="socid=".urlencode($object->id);
|
$param="socid=".urlencode($object->id);
|
||||||
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
|
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
|
||||||
|
if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles);
|
||||||
if ($search_name != '') $param.='&search_name='.urlencode($search_name);
|
if ($search_name != '') $param.='&search_name='.urlencode($search_name);
|
||||||
if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste);
|
if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste);
|
||||||
if ($search_address != '') $param.='&search_address='.urlencode($search_address);
|
if ($search_address != '') $param.='&search_address='.urlencode($search_address);
|
||||||
@ -1021,6 +1028,9 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name);
|
if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name);
|
||||||
if ($search_poste) $sql .= natural_search('t.poste', $search_poste);
|
if ($search_poste) $sql .= natural_search('t.poste', $search_poste);
|
||||||
if ($search_address) $sql .= natural_search($searchAddressPhoneDBFields, $search_address);
|
if ($search_address) $sql .= natural_search($searchAddressPhoneDBFields, $search_address);
|
||||||
|
if (count($search_roles)>0) {
|
||||||
|
$sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))";
|
||||||
|
}
|
||||||
// Add where from extra fields
|
// Add where from extra fields
|
||||||
$extrafieldsobjectkey=$contactstatic->table_element;
|
$extrafieldsobjectkey=$contactstatic->table_element;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||||
@ -1047,7 +1057,9 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
||||||
if (in_array($key, array('statut'))){
|
if (in_array($key, array('statut'))){
|
||||||
print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status);
|
print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status);
|
||||||
} else {
|
}elseif (in_array($key, array('role'))) {
|
||||||
|
print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles);
|
||||||
|
} else {
|
||||||
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -1078,6 +1090,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
|
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
|
||||||
if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center';
|
if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center';
|
||||||
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||||
|
if ($key == 'role') $align.=($align?' ':'').'center';
|
||||||
|
if (! empty($arrayfields['sc.'.$key]['checked'])) {
|
||||||
|
print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Extra fields
|
// Extra fields
|
||||||
$extrafieldsobjectkey=$contactstatic->table_element;
|
$extrafieldsobjectkey=$contactstatic->table_element;
|
||||||
@ -1124,6 +1140,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
$contactstatic->setGenderFromCivility();
|
$contactstatic->setGenderFromCivility();
|
||||||
$contactstatic->fetch_optionals();
|
$contactstatic->fetch_optionals();
|
||||||
|
|
||||||
|
$resultRole=$contactstatic->fetchRoles();
|
||||||
|
if ($resultRole<0) {
|
||||||
|
setEventMessages(null, $contactstatic->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($contactstatic->array_options))
|
if (is_array($contactstatic->array_options))
|
||||||
{
|
{
|
||||||
foreach($contactstatic->array_options as $key => $val)
|
foreach($contactstatic->array_options as $key => $val)
|
||||||
@ -1167,6 +1188,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Role
|
||||||
|
if (! empty($arrayfields['sc.role']['checked']))
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print $formcompany->showRoles("roles", $contactstatic, 'view');
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
if (! empty($arrayfields['t.statut']['checked']))
|
if (! empty($arrayfields['t.statut']['checked']))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
|
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||||
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
|
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
|
||||||
|
* \ingroup agenda
|
||||||
|
* \brief Trigger file for agenda module
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class of triggered functions for agenda module
|
||||||
|
*/
|
||||||
|
class InterfaceContactRoles extends DolibarrTriggers
|
||||||
|
{
|
||||||
|
public $family = 'agenda';
|
||||||
|
public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version of the trigger
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $version = self::VERSION_DOLIBARR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Image of the trigger
|
||||||
|
*/
|
||||||
|
public $picto = 'action';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when a Dolibarrr business event is done.
|
||||||
|
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
|
||||||
|
*
|
||||||
|
* Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
|
||||||
|
* $object->socid or $object->fk_soc(id of thirdparty)
|
||||||
|
* $object->element (element type of object)
|
||||||
|
*
|
||||||
|
* @param string $action Event action code
|
||||||
|
* @param Object $object Object
|
||||||
|
* @param User $user Object user
|
||||||
|
* @param Translate $langs Object langs
|
||||||
|
* @param conf $conf Object conf
|
||||||
|
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
|
||||||
|
*/
|
||||||
|
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE'
|
||||||
|
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') {
|
||||||
|
|
||||||
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
|
$socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc);
|
||||||
|
|
||||||
|
if (! empty($socid) && $socid > 0) {
|
||||||
|
global $db, $langs;
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
|
$contactdefault = new Contact($this->db);
|
||||||
|
$contactdefault->socid=$socid;
|
||||||
|
$TContact = $contactdefault->getContactRoles($object->element);
|
||||||
|
|
||||||
|
$TContactAlreadyLinked = array();
|
||||||
|
if ($object->id > 0)
|
||||||
|
{
|
||||||
|
$class = get_class($object);
|
||||||
|
$cloneFrom = new $class($db);
|
||||||
|
$r = $cloneFrom->fetch($object->id);
|
||||||
|
|
||||||
|
if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($TContact as $i => $infos) {
|
||||||
|
foreach ($TContactAlreadyLinked as $contactData) {
|
||||||
|
if($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$nb = 0;
|
||||||
|
foreach($TContact as $infos) {
|
||||||
|
$res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']);
|
||||||
|
if($res > 0) $nb++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($nb > 0) {
|
||||||
|
setEventMessages($langs->trans('ContactAddedAutomatically', $nb), null, 'mesgs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -135,6 +135,23 @@ ALTER TABLE llx_projet ADD COLUMN usage_organize_event integer DEFAULT 0;
|
|||||||
|
|
||||||
UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0;
|
UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0;
|
||||||
|
|
||||||
|
create table llx_societe_contacts
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
entity integer DEFAULT 1 NOT NULL,
|
||||||
|
date_creation datetime NOT NULL,
|
||||||
|
fk_soc integer NOT NULL,
|
||||||
|
fk_c_type_contact int NOT NULL,
|
||||||
|
fk_socpeople integer NOT NULL,
|
||||||
|
tms TIMESTAMP,
|
||||||
|
import_key VARCHAR(14)
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_societe_contacts ADD UNIQUE INDEX idx_societe_contacts_idx1 (entity, fk_soc, fk_c_type_contact, fk_socpeople);
|
||||||
|
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid);
|
||||||
|
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
|
||||||
|
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid);
|
||||||
|
|
||||||
ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT;
|
ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT;
|
||||||
|
|
||||||
|
|
||||||
@ -281,3 +298,5 @@ create table llx_fichinterdet_rec
|
|||||||
import_key varchar(14) NULL DEFAULT NULL
|
import_key varchar(14) NULL DEFAULT NULL
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type;
|
||||||
|
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start;
|
||||||
|
|||||||
22
htdocs/install/mysql/tables/llx_societe_contacts.key.sql
Normal file
22
htdocs/install/mysql/tables/llx_societe_contacts.key.sql
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
-- ========================================================================
|
||||||
|
-- Copyright (C) 2019 Florian HENRY <florian.henry@atm-consulting.fr>
|
||||||
|
--
|
||||||
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
ALTER TABLE llx_societe_contacts ADD UNIQUE INDEX idx_societe_contacts_idx1 (entity, fk_soc, fk_c_type_contact, fk_socpeople);
|
||||||
|
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid);
|
||||||
|
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
|
||||||
|
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid);
|
||||||
30
htdocs/install/mysql/tables/llx_societe_contacts.sql
Normal file
30
htdocs/install/mysql/tables/llx_societe_contacts.sql
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
-- ========================================================================
|
||||||
|
-- Copyright (C) 2019 Florian HENRY <florian.henry@atm-consulting.fr>
|
||||||
|
--
|
||||||
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
|
||||||
|
create table llx_societe_contacts
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
entity integer DEFAULT 1 NOT NULL,
|
||||||
|
date_creation datetime NOT NULL,
|
||||||
|
fk_soc integer NOT NULL,
|
||||||
|
fk_c_type_contact int NOT NULL,
|
||||||
|
fk_socpeople integer NOT NULL,
|
||||||
|
tms TIMESTAMP,
|
||||||
|
import_key VARCHAR(14)
|
||||||
|
)ENGINE=innodb;
|
||||||
@ -991,4 +991,17 @@ ToApprove=To approve
|
|||||||
GlobalOpenedElemView=Global view
|
GlobalOpenedElemView=Global view
|
||||||
NoArticlesFoundForTheKeyword=No article found for the keyword '<strong>%s</strong>'
|
NoArticlesFoundForTheKeyword=No article found for the keyword '<strong>%s</strong>'
|
||||||
NoArticlesFoundForTheCategory=No article found for the category
|
NoArticlesFoundForTheCategory=No article found for the category
|
||||||
ToAcceptRefuse=To accept | refuse
|
ToAcceptRefuse=To accept | refuse
|
||||||
|
ContactDefault_agenda=Event
|
||||||
|
ContactDefault_commande=Order
|
||||||
|
ContactDefault_contrat=Contract
|
||||||
|
ContactDefault_facture=Invoice
|
||||||
|
ContactDefault_fichinter=Intervention
|
||||||
|
ContactDefault_invoice_supplier=Supplier Invoice
|
||||||
|
ContactDefault_order_supplier=Supplier Order
|
||||||
|
ContactDefault_project=Project
|
||||||
|
ContactDefault_project_task=Task
|
||||||
|
ContactDefault_propal=Proposal
|
||||||
|
ContactDefault_supplier_proposal=Supplier Proposal
|
||||||
|
ContactDefault_ticketsup=Ticket
|
||||||
|
ContactAddedAutomatically=Contact added from contact thirdparty roles
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user