diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 2a109fb0f5c..a09290273aa 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1257,9 +1257,10 @@ class Form
* @param array $ajaxoptions Options for ajax_autocompleter
* @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter)
* @param array $excludeids Exclude IDs from the select combo
+ * @param int $showcode Show code
* @return string HTML string with select box for thirdparty.
*/
- public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false, $excludeids = array())
+ public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false, $excludeids = array(), $showcode = 0)
{
// phpcs:enable
global $conf, $user, $langs;
@@ -1284,7 +1285,7 @@ class Form
}
// mode 1
- $urloption = 'htmlname='.urlencode(str_replace('.', '_', $htmlname)).'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ? '' : '&excludeids='.join(',', $excludeids)).($showtype ? '&showtype='.urlencode($showtype) : '');
+ $urloption = 'htmlname='.urlencode(str_replace('.', '_', $htmlname)).'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ? '' : '&excludeids='.join(',', $excludeids)).($showtype ? '&showtype='.urlencode($showtype) : '').($showcode ? '&showcode='.urlencode($showcode) : '');
$out .= '';
if (empty($hidelabel)) {
@@ -1303,7 +1304,7 @@ class Form
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
} else {
// Immediate load of all database
- $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple, $excludeids);
+ $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
}
return $out;
@@ -1328,9 +1329,10 @@ class Form
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param bool $multiple add [] in the name of element and add 'multiple' attribut
* @param array $excludeids Exclude IDs from the select combo
+ * @param int $showcode Show code in list
* @return string HTML string with
*/
- public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false, $excludeids = array())
+ public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false, $excludeids = array(), $showcode = 0)
{
// phpcs:enable
global $conf, $user, $langs;
@@ -1442,13 +1444,15 @@ class Form
$out .= ''."\n";
}
+ $companytemp = new Societe($this->db);
+
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$label = '';
- if ($conf->global->SOCIETE_ADD_REF_IN_LIST) {
+ if ($showcode || !empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
if (($obj->client) && (!empty($obj->code_client))) {
$label = $obj->code_client.' - ';
}
@@ -1468,7 +1472,17 @@ class Form
$label .= ' - '.$obj->tva_intra.'';
}
+ $labelhtml = $label;
+
if ($showtype) {
+ $companytemp->id = $obj->rowid;
+ $companytemp->client = $obj->client;
+ $companytemp->fournisseur = $obj->fournisseur;
+ $tmptype = $companytemp->getTypeUrl(1, '', 0, 'span');
+ if ($tmptype) {
+ $labelhtml .= ' '.$tmptype;
+ }
+
if ($obj->client || $obj->fournisseur) {
$label .= ' (';
}
@@ -1487,20 +1501,22 @@ class Form
}
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
- $label .= ($obj->address ? ' - '.$obj->address : '').($obj->zip ? ' - '.$obj->zip : '').($obj->town ? ' '.$obj->town : '');
+ $s = ($obj->address ? ' - '.$obj->address : '').($obj->zip ? ' - '.$obj->zip : '').($obj->town ? ' '.$obj->town : '');
if (!empty($obj->country_code)) {
- $label .= ', '.$langs->trans('Country'.$obj->country_code);
+ $s .= ', '.$langs->trans('Country'.$obj->country_code);
}
+ $label .= $s;
+ $labelhtml .= $s;
}
if (empty($outputmode)) {
if (in_array($obj->rowid, $selected)) {
- $out .= '';
+ $out .= '';
} else {
- $out .= '';
+ $out .= '';
}
} else {
- array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
+ array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label, 'labelhtml'=>$labelhtml));
}
$i++;
diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php
index 5c02afe85dc..f845c161ab2 100644
--- a/htdocs/societe/ajax/company.php
+++ b/htdocs/societe/ajax/company.php
@@ -50,7 +50,8 @@ $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
$action = GETPOST('action', 'aZ09');
$id = GETPOST('id', 'int');
$excludeids = GETPOST('excludeids', 'intcomma');
-$showtype = GETPOST('showtype', 'int');
+$showtype = GETPOSTINT('showtype');
+$showcode = GETPOSTINT('showcode');
$object = new Societe($db);
if ($id > 0) {
@@ -123,7 +124,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
$excludeids = array();
}
- $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids);
+ $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode);
$db->close();
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 0946201b100..d13893ca7dd 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2784,29 +2784,30 @@ class Societe extends CommonObject
/**
* Return link(s) on type of thirdparty (with picto)
*
- * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
- * @param string $option ''=All
- * @param int $notooltip 1=Disable tooltip
- * @return string String with URL
+ * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
+ * @param string $option ''=All
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $tag Tag 'a' or 'span'
+ * @return string String with URL
*/
- public function getTypeUrl($withpicto = 0, $option = '', $notooltip = 0)
+ public function getTypeUrl($withpicto = 0, $option = '', $notooltip = 0, $tag = 'a')
{
global $conf, $langs;
$s = '';
if (empty($option) || preg_match('/prospect/', $option)) {
if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
- $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).'';
+ $s .= '<'.$tag.' class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).''.$tag.'>';
}
}
if (empty($option) || preg_match('/customer/', $option)) {
if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
- $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).'';
+ $s .= '<'.$tag.' class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).''.$tag.'>';
}
}
if (empty($option) || preg_match('/supplier/', $option)) {
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) {
- $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).'';
+ $s .= '<'.$tag.' class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).''.$tag.'>';
}
}
return $s;