Skip to content
Snippets Groups Projects
Commit 58328d36 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

To provide solution to get thirdparty when name is not unique.

parent 3a6314b1
No related branches found
No related tags found
No related merge requests found
......@@ -1004,21 +1004,22 @@ class Societe extends CommonObject
* @param int $rowid Id of third party to load
* @param string $ref Reference of third party, name (Warning, this can return several records)
* @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr)
* @param string $ref_int Internal reference of third party
* @param string $ref_int Internal reference of third party (not used by dolibarr)
* @param string $idprof1 Prof id 1 of third party (Warning, this can return several records)
* @param string $idprof2 Prof id 2 of third party (Warning, this can return several records)
* @param string $idprof3 Prof id 3 of third party (Warning, this can return several records)
* @param string $idprof4 Prof id 4 of third party (Warning, this can return several records)
* @param string $idprof5 Prof id 5 of third party (Warning, this can return several records)
* @param string $idprof6 Prof id 6 of third party (Warning, this can return several records)
* @param string $email Email (Warning, this can return several records)
* @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found.
*/
function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='')
function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='')
{
global $langs;
global $conf;
if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6)) return -1;
if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1;
$sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm';
$sql .= ', s.status';
......@@ -1062,6 +1063,7 @@ class Societe extends CommonObject
else if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")";
else if ($idprof5) $sql .= " WHERE s.idprof5 = '".$this->db->escape($idprof5)."' AND s.entity IN (".getEntity($this->element, 1).")";
else if ($idprof6) $sql .= " WHERE s.idprof6 = '".$this->db->escape($idprof6)."' AND s.entity IN (".getEntity($this->element, 1).")";
else if ($email) $sql .= " WHERE email = '".$this->db->escape($email)."' AND s.entity IN (".getEntity($this->element, 1).")";
$resql=$this->db->query($sql);
dol_syslog(get_class($this)."::fetch ".$sql);
......@@ -1886,7 +1888,7 @@ class Societe extends CommonObject
$label.= '<u>' . $langs->trans("ShowMargin") . '</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$this->id.'&type=1';
}
// By default
if (empty($linkstart))
{
......@@ -1907,7 +1909,7 @@ class Societe extends CommonObject
$label.= '<br><b>' . $langs->trans('CustomerAccountancyCode') . ':</b> '. $this->code_compta_client;
if (! empty($conf->accounting->enabled) && $this->fournisseur)
$label.= '<br><b>' . $langs->trans('SupplierAccountancyCode') . ':</b> '. $this->code_compta_fournisseur;
if (! empty($this->logo) && class_exists('Form'))
{
$label.= '</br><div class="photointooltip">';
......@@ -1949,7 +1951,7 @@ class Societe extends CommonObject
$linkstart='';
$linkend='';
}
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$linkstart.($maxlen?dol_trunc($name,$maxlen):$name).$linkend;
......@@ -3449,9 +3451,9 @@ class Societe extends CommonObject
return 0;
}
}
$modelpath = "core/modules/societe/doc/";
$result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
}
......@@ -3472,7 +3474,7 @@ class Societe extends CommonObject
public function setCategories($categories, $type)
{
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
// Decode type
if ($type == 'customer') {
$type_id = Categorie::TYPE_CUSTOMER;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment