FIX Type of contact for event does not exists and not supported
FIX Type of contact not saved when creating a contact FIX SQL Overload in default contact trigger. FIX Trigger name PROPAL_SUPPLIER_TRIGGER into PROPOSAL_SUPPLIER_TRIGGER
This commit is contained in:
parent
4b5cda5cd2
commit
a02f5cde92
@ -218,6 +218,8 @@ 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');
|
||||||
|
|
||||||
$object->statut = 1; //Defult status to Actif
|
$object->statut = 1; //Defult status to Actif
|
||||||
|
|
||||||
// Note: Correct date should be completed with location to have exact GM time of birth.
|
// Note: Correct date should be completed with location to have exact GM time of birth.
|
||||||
|
|||||||
@ -358,7 +358,7 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$result = $this->update($this->id, $user, 1, 'add');
|
$result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ...
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -1643,6 +1643,10 @@ class Contact extends CommonObject
|
|||||||
{
|
{
|
||||||
$tab = array();
|
$tab = array();
|
||||||
|
|
||||||
|
if ($element == 'action') {
|
||||||
|
$element = 'agenda';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
|
$sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."societe_contacts sc";
|
$sql .= ", ".MAIN_DB_PREFIX."societe_contacts sc";
|
||||||
|
|||||||
@ -1269,10 +1269,11 @@ abstract class CommonObject
|
|||||||
* @param int $option 0=Return array id->label, 1=Return array code->label
|
* @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 int $activeonly 0=all status of contact, 1=only the active
|
||||||
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
|
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
|
||||||
* @param string $element Filter Element Type
|
* @param string $element Filter on 1 element type
|
||||||
|
* @param string $excludeelement Exclude 1 element type. Example: 'agenda'
|
||||||
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
|
* @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 = '')
|
public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '', $excludeelement = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
@ -1283,8 +1284,12 @@ abstract class CommonObject
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
|
|
||||||
$sqlWhere = array();
|
$sqlWhere = array();
|
||||||
if (!empty($element))
|
if (!empty($element)) {
|
||||||
$sqlWhere[] = " tc.element='".$this->db->escape($element)."'";
|
$sqlWhere[] = " tc.element='".$this->db->escape($element)."'";
|
||||||
|
}
|
||||||
|
if (!empty($excludeelement)) {
|
||||||
|
$sqlWhere[] = " tc.element <> '".$this->db->escape($excludeelement)."'";
|
||||||
|
}
|
||||||
|
|
||||||
if ($activeonly == 1)
|
if ($activeonly == 1)
|
||||||
$sqlWhere[] = " tc.active=1"; // only the active types
|
$sqlWhere[] = " tc.active=1"; // only the active types
|
||||||
@ -1307,18 +1312,19 @@ abstract class CommonObject
|
|||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
if ($num > 0) {
|
if ($num > 0) {
|
||||||
while ($obj = $this->db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
$modulename = $obj->element;
|
||||||
if (strpos($obj->element, 'project') !== false) {
|
if (strpos($obj->element, 'project') !== false) {
|
||||||
$element = 'projet';
|
$modulename = 'projet';
|
||||||
} elseif ($obj->element == 'contrat') {
|
} elseif ($obj->element == 'contrat') {
|
||||||
$element = 'contract';
|
$element = 'contract';
|
||||||
|
} elseif ($obj->element == 'action') {
|
||||||
|
$modulename = 'agenda';
|
||||||
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
|
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
|
||||||
$element = 'fournisseur';
|
$modulename = 'fournisseur';
|
||||||
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
|
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
|
||||||
$element = 'fournisseur';
|
$modulename = 'fournisseur';
|
||||||
} else {
|
|
||||||
$element = $obj->element;
|
|
||||||
}
|
}
|
||||||
if ($conf->{$element}->enabled) {
|
if ($conf->{$modulename}->enabled) {
|
||||||
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
|
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
|
||||||
$transkey = "TypeContact_".$this->element."_".$source."_".$obj->code;
|
$transkey = "TypeContact_".$this->element."_".$source."_".$obj->code;
|
||||||
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
|
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
|
||||||
|
|||||||
@ -767,7 +767,7 @@ class FormCompany extends Form
|
|||||||
|
|
||||||
if ($rendermode === 'edit')
|
if ($rendermode === 'edit')
|
||||||
{
|
{
|
||||||
$contactType = $contact->listeTypeContacts('external', '', 1);
|
$contactType = $contact->listeTypeContacts('external', '', 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
|
||||||
if (count($selected) > 0) {
|
if (count($selected) > 0) {
|
||||||
$newselected = array();
|
$newselected = array();
|
||||||
foreach ($selected as $key=>$val) {
|
foreach ($selected as $key=>$val) {
|
||||||
|
|||||||
@ -66,8 +66,9 @@ class InterfaceContactRoles extends DolibarrTriggers
|
|||||||
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
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'
|
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE'
|
||||||
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') {
|
|| $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE'
|
||||||
|
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') {
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
|
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
|
||||||
@ -78,18 +79,21 @@ class InterfaceContactRoles extends DolibarrTriggers
|
|||||||
$contactdefault->socid = $socid;
|
$contactdefault->socid = $socid;
|
||||||
$TContact = $contactdefault->getContactRoles($object->element);
|
$TContact = $contactdefault->getContactRoles($object->element);
|
||||||
|
|
||||||
|
if (is_array($TContact) && ! empty($TContact))
|
||||||
|
{
|
||||||
$TContactAlreadyLinked = array();
|
$TContactAlreadyLinked = array();
|
||||||
if ($object->id > 0)
|
if ($object->id > 0)
|
||||||
{
|
{
|
||||||
$class = get_class($object);
|
/* $class = get_class($object);
|
||||||
$cloneFrom = new $class($this->db);
|
$cloneFrom = new $class($this->db);
|
||||||
$r = $cloneFrom->fetch($object->id);
|
$r = $cloneFrom->fetch($object->id); */
|
||||||
|
$cloneFrom = dol_clone($object, 1);
|
||||||
|
|
||||||
if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
|
if (!empty($cloneFrom->id)) {
|
||||||
|
$TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($TContact))
|
|
||||||
{
|
|
||||||
foreach($TContact as $i => $infos) {
|
foreach($TContact as $i => $infos) {
|
||||||
foreach ($TContactAlreadyLinked as $contactData) {
|
foreach ($TContactAlreadyLinked as $contactData) {
|
||||||
if ($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]);
|
if ($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]);
|
||||||
|
|||||||
@ -1010,7 +1010,7 @@ ContactDefault_project=Project
|
|||||||
ContactDefault_project_task=Task
|
ContactDefault_project_task=Task
|
||||||
ContactDefault_propal=Proposal
|
ContactDefault_propal=Proposal
|
||||||
ContactDefault_supplier_proposal=Supplier Proposal
|
ContactDefault_supplier_proposal=Supplier Proposal
|
||||||
ContactDefault_ticketsup=Ticket
|
ContactDefault_ticket=Ticket
|
||||||
ContactAddedAutomatically=Contact added from contact thirdparty roles
|
ContactAddedAutomatically=Contact added from contact thirdparty roles
|
||||||
More=More
|
More=More
|
||||||
ShowDetails=Show details
|
ShowDetails=Show details
|
||||||
|
|||||||
@ -1069,7 +1069,7 @@ class SupplierProposal extends CommonObject
|
|||||||
if (!$error && !$notrigger)
|
if (!$error && !$notrigger)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('PROPAL_SUPPLIER_CREATE', $user);
|
$result = $this->call_trigger('PROPOSAL_SUPPLIER_CREATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user