forked from Wavyzz/dolibarr
implemented
This commit is contained in:
@@ -931,36 +931,40 @@ class Form
|
||||
/**
|
||||
* Output html form to select a third party
|
||||
*
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in form
|
||||
* @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)')
|
||||
* @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty')
|
||||
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @param int $limit Maximum number of elements
|
||||
* @param string $morecss Add more css styles to the SELECT component
|
||||
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
|
||||
* @return string HTML string with select box for thirdparty.
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in form
|
||||
* @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)')
|
||||
* @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty')
|
||||
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @param int $limit Maximum number of elements
|
||||
* @param string $morecss Add more css styles to the SELECT component
|
||||
* @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 string $selected_input_value Value of preselected input text (for use with ajax)
|
||||
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
|
||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||
* @return string HTML string with select box for thirdparty.
|
||||
*/
|
||||
function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='')
|
||||
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())
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
$out='';
|
||||
|
||||
/* TODO Use ajax_autocompleter like for products (not finished)
|
||||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo)
|
||||
{
|
||||
$placeholder='';
|
||||
|
||||
if ($selected && empty($selected_input_value))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/ajaxcompanies.php';
|
||||
$societe = new Societe($this->db);
|
||||
$societe->fetch($selected);
|
||||
$selected_input_value=$societe->ref;
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
$societetmp = new Societe($this->db);
|
||||
$societetmp->fetch($selected);
|
||||
$selected_input_value=$societetmp->name;
|
||||
unset($societetmp);
|
||||
}
|
||||
// mode=1 means customers products
|
||||
$urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished;
|
||||
// mode 1
|
||||
$urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter;
|
||||
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
||||
if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : ';
|
||||
else if ($hidelabel > 1) {
|
||||
@@ -970,15 +974,15 @@ class Form
|
||||
print img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
print '<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
|
||||
print '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
|
||||
if ($hidelabel == 3) {
|
||||
print img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
{
|
||||
$out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam);
|
||||
//}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -1004,7 +1008,8 @@ class Form
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
$out=''; $num=0;
|
||||
$out='';
|
||||
$num=0;
|
||||
$outarray=array();
|
||||
|
||||
// On recherche les societes
|
||||
@@ -1020,19 +1025,18 @@ class Form
|
||||
if ($filterkey && $filterkey != '')
|
||||
{
|
||||
$sql.=" AND (";
|
||||
if (! empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index
|
||||
{
|
||||
$sql.="(s.name LIKE '".$this->db->escape($filterkey)."%')";
|
||||
$prefix=empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if COMPANY_DONOTSEARCH_ANYWHERE is on
|
||||
// For natural search
|
||||
$scrit = explode(' ', $filterkey);
|
||||
$i=0;
|
||||
if (count($scrit) > 1) $sql.="(";
|
||||
foreach ($scrit as $crit) {
|
||||
if ($i > 0) $sql.=" AND ";
|
||||
$sql.="(s.nom LIKE '".$this->db->escape($prefix.$crit)."%')";
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For natural search
|
||||
$scrit = explode(' ', $filterkey);
|
||||
foreach ($scrit as $crit) {
|
||||
$sql.=" AND (s.name LIKE '%".$this->db->escape($crit)."%')";
|
||||
}
|
||||
}
|
||||
if (! empty($conf->barcode->enabled))
|
||||
if (count($scrit) > 1) $sql.=")";
|
||||
if (! empty($conf->barcode->enabled))
|
||||
{
|
||||
$sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'";
|
||||
}
|
||||
@@ -1041,20 +1045,22 @@ class Form
|
||||
$sql.=$this->db->order("nom","ASC");
|
||||
if ($limit > 0) $sql.=$this->db->plimit($limit);
|
||||
|
||||
// Build output string
|
||||
dol_syslog(get_class($this)."::select_thirdparty_list", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$events = null;
|
||||
|
||||
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$comboenhancement =ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
||||
$out.= $comboenhancement;
|
||||
$nodatarole=($comboenhancement?' data-role="none"':'');
|
||||
}
|
||||
|
||||
// Construct $out and $outarray
|
||||
$out.= '<select id="'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'"'.($moreparam?' '.$moreparam:'').' name="'.$htmlname.'"'.$nodatarole.'>'."\n";
|
||||
$out.= '<select id="'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'"'.($moreparam?' '.$moreparam:'').' name="'.$htmlname.'">'."\n";
|
||||
|
||||
$textifempty='';
|
||||
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
@@ -1066,7 +1072,7 @@ class Form
|
||||
}
|
||||
if ($showempty) $out.= '<option value="-1">'.$textifempty.'</option>'."\n";
|
||||
|
||||
$num = $this->db->num_rows($resql);
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
@@ -1109,7 +1115,7 @@ class Form
|
||||
$out.= '<option value="'.$obj->rowid.'">'.$label.'</option>';
|
||||
}
|
||||
|
||||
array_push($outarray, array('key'=>$obj->rowid, 'value'=>$obj->rowid, 'label'=>$label));
|
||||
array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
|
||||
|
||||
$i++;
|
||||
if (($i % 10) == 0) $out.="\n";
|
||||
|
||||
@@ -118,7 +118,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $langs->trans("ThirdParty").' ';
|
||||
print '</td><td class="nowrap" style="padding-bottom: 2px;">';
|
||||
print $form->select_company($socid, 'socid', '', 1);
|
||||
print $form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, null, 0);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user