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:
Laurent Destailleur
2020-02-17 12:21:07 +01:00
parent 549bf076d7
commit 1904ae0e82
7 changed files with 68 additions and 52 deletions

View File

@@ -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);