Clean code

This commit is contained in:
ldestailleur 2025-10-04 14:12:46 +02:00
parent 597088f030
commit fbfeb5c978
4 changed files with 15 additions and 16 deletions

View file

@ -579,13 +579,13 @@ class Orders extends DolibarrApi
}
/**
* Get contacts of given order
* Get contacts of a given order
*
* Return an array with contact information
*
* @param int $id ID of order
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
* @return Object Object with cleaned properties
* @param int $id ID of order
* @param string $type Type of the contact ('BILLING', 'SHIPPING', 'CUSTOMER', ...)
* @return array<int,mixed> Array of contacts
*
* @url GET {id}/contacts
*
@ -608,7 +608,7 @@ class Orders extends DolibarrApi
$contacts = $this->commande->liste_contact(-1, 'external', 0, $type);
return $this->_cleanObjectDatas($contacts);
return $contacts;
}
/**

View file

@ -1905,7 +1905,7 @@ class Contact extends CommonObject
* Get thirdparty contact roles of a given contact
*
* @param string $element Element type
* @return array<array{fk_socpeople:int,type_contact:int}>|int<-1,-1> Array of contact roles or -1
* @return array<array{fk_socpeople:int,type_contact:int}>|int<-1,-1> Array of contact roles or -1 if error
* @throws Exception
*/
public function getContactRoles($element = '')
@ -1921,20 +1921,19 @@ class Contact extends CommonObject
$sql .= ", ".MAIN_DB_PREFIX."societe_contacts sc";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."socpeople sp";
$sql .= " ON sc.fk_socpeople = sp.rowid AND sp.statut = 1";
$sql .= " WHERE sc.fk_soc =".((int) $this->socid);
$sql .= " WHERE sc.fk_soc = ".((int) $this->socid);
$sql .= " AND sc.fk_c_type_contact=tc.rowid";
$sql .= " AND tc.element = '".$this->db->escape($element)."'";
$sql .= " AND sp.entity IN (".getEntity('contact').")";
$sql .= " AND tc.active = 1";
dol_syslog(__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);
$tab[$obj->id] = array('fk_socpeople' => $obj->id, 'type_contact' => $obj->fk_c_type_contact);
$i++;
}

View file

@ -404,10 +404,10 @@ class SupplierOrders extends DolibarrApi
*
* Return an array with contact information
*
* @param int $id ID of supplier order
* @param string $source Source of the contact (internal, external, all).
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...)
* @return Object Object with cleaned properties
* @param int $id ID of supplier order
* @param string $source Source of the contact (internal, external, all).
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...)
* @return array<int,mixed> Array of contacts
*
* @url GET {id}/contacts
*
@ -439,7 +439,7 @@ class SupplierOrders extends DolibarrApi
$contacts = array_merge($contacts, $tmpContacts);
}
return $this->_cleanObjectDatas($contacts);
return $contacts;
}
/**

View file

@ -5738,7 +5738,7 @@ class Societe extends CommonObject
if (!$list) {
$transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_label);
$tab[$i] = array(
$tab[$obj->id] = array(
'source' => $obj->source,
'socid' => $obj->socid,
'id' => $obj->id,
@ -5758,7 +5758,7 @@ class Societe extends CommonObject
'fk_c_type_contact' => $obj->fk_c_type_contact
);
} else {
$tab[$i] = $obj->id;
$tab[$obj->id] = $obj->id;
}
$i++;