mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
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 Conflicts: htdocs/supplier_proposal/class/supplier_proposal.class.php
This commit is contained in:
parent
549bf076d7
commit
1904ae0e82
|
|
@ -218,6 +218,8 @@ if (empty($reshook))
|
|||
$object->priv = GETPOST("priv", 'int');
|
||||
$object->note_public = GETPOST("note_public", 'none');
|
||||
$object->note_private = GETPOST("note_private", 'none');
|
||||
$object->roles = GETPOST("roles", 'array');
|
||||
|
||||
$object->statut = 1; //Defult status to Actif
|
||||
|
||||
// Note: Correct date should be completed with location to have exact GM time of birth.
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ class Contact extends CommonObject
|
|||
|
||||
if (!$error)
|
||||
{
|
||||
$result = $this->update($this->id, $user, 1, 'add');
|
||||
$result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ...
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
|
|
@ -1639,6 +1639,10 @@ class Contact extends CommonObject
|
|||
{
|
||||
$tab = array();
|
||||
|
||||
if ($element == 'action') {
|
||||
$element = 'agenda';
|
||||
}
|
||||
|
||||
$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";
|
||||
|
|
|
|||
|
|
@ -1242,14 +1242,15 @@ abstract class CommonObject
|
|||
/**
|
||||
* 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)
|
||||
* @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 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)
|
||||
*/
|
||||
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
|
||||
global $langs, $conf;
|
||||
|
|
@ -1260,8 +1261,12 @@ abstract class CommonObject
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
|
||||
$sqlWhere = array();
|
||||
if (!empty($element))
|
||||
if (!empty($element)) {
|
||||
$sqlWhere[] = " tc.element='".$this->db->escape($element)."'";
|
||||
}
|
||||
if (!empty($excludeelement)) {
|
||||
$sqlWhere[] = " tc.element <> '".$this->db->escape($excludeelement)."'";
|
||||
}
|
||||
|
||||
if ($activeonly == 1)
|
||||
$sqlWhere[] = " tc.active=1"; // only the active types
|
||||
|
|
@ -1284,18 +1289,19 @@ abstract class CommonObject
|
|||
$num = $this->db->num_rows($resql);
|
||||
if ($num > 0) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$modulename = $obj->element;
|
||||
if (strpos($obj->element, 'project') !== false) {
|
||||
$element = 'projet';
|
||||
$modulename = 'projet';
|
||||
} elseif ($obj->element == 'contrat') {
|
||||
$element = 'contract';
|
||||
} elseif ($obj->element == 'action') {
|
||||
$modulename = 'agenda';
|
||||
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
|
||||
$element = 'fournisseur';
|
||||
$modulename = 'fournisseur';
|
||||
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
|
||||
$element = 'fournisseur';
|
||||
} else {
|
||||
$element = $obj->element;
|
||||
$modulename = 'fournisseur';
|
||||
}
|
||||
if ($conf->{$element}->enabled) {
|
||||
if ($conf->{$modulename}->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);
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ class FormCompany extends Form
|
|||
|
||||
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) {
|
||||
$newselected = array();
|
||||
foreach ($selected as $key=>$val) {
|
||||
|
|
|
|||
|
|
@ -66,48 +66,52 @@ class InterfaceContactRoles extends DolibarrTriggers
|
|||
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);
|
||||
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_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);
|
||||
|
||||
$socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc);
|
||||
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
|
||||
|
||||
if (! empty($socid) && $socid > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
$contactdefault = new Contact($this->db);
|
||||
$contactdefault->socid=$socid;
|
||||
$TContact = $contactdefault->getContactRoles($object->element);
|
||||
if (! empty($socid) && $socid > 0) {
|
||||
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($this->db);
|
||||
$r = $cloneFrom->fetch($object->id);
|
||||
if (is_array($TContact) && ! empty($TContact))
|
||||
{
|
||||
$TContactAlreadyLinked = array();
|
||||
if ($object->id > 0)
|
||||
{
|
||||
/* $class = get_class($object);
|
||||
$cloneFrom = new $class($this->db);
|
||||
$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 (is_array($TContact))
|
||||
{
|
||||
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]);
|
||||
if (!empty($cloneFrom->id)) {
|
||||
$TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nb = 0;
|
||||
foreach($TContact as $infos) {
|
||||
$res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']);
|
||||
if ($res > 0) $nb++;
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if($nb > 0) {
|
||||
setEventMessages($langs->trans('ContactAddedAutomatically', $nb), null, 'mesgs');
|
||||
$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;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1010,7 +1010,7 @@ ContactDefault_project=Project
|
|||
ContactDefault_project_task=Task
|
||||
ContactDefault_propal=Proposal
|
||||
ContactDefault_supplier_proposal=Supplier Proposal
|
||||
ContactDefault_ticketsup=Ticket
|
||||
ContactDefault_ticket=Ticket
|
||||
ContactAddedAutomatically=Contact added from contact thirdparty roles
|
||||
More=More
|
||||
ShowDetails=Show details
|
||||
|
|
|
|||
|
|
@ -1069,7 +1069,7 @@ class SupplierProposal extends CommonObject
|
|||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_SUPPLIER_CREATE', $user);
|
||||
$result = $this->call_trigger('PROPOSAL_SUPPLIER_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
|
@ -2834,7 +2834,7 @@ class SupplierProposalLine extends CommonObjectLine
|
|||
// From llx_product
|
||||
/**
|
||||
* @deprecated
|
||||
* @see product_ref
|
||||
* @see $product_ref
|
||||
*/
|
||||
public $ref;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user