forked from Wavyzz/dolibarr
Fix link to prospect with filter on commercial status
Enhance natural_search method to allow to search on several ids.
This commit is contained in:
@@ -219,34 +219,23 @@ $sql.= " AND s.client IN (2, 3)";
|
|||||||
$sql.= ' AND s.entity IN ('.getEntity('societe', 1).')';
|
$sql.= ' AND s.entity IN ('.getEntity('societe', 1).')';
|
||||||
if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc";
|
if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc";
|
||||||
if ($socid) $sql.= " AND s.rowid = " .$socid;
|
if ($socid) $sql.= " AND s.rowid = " .$socid;
|
||||||
if ($search_stcomm != '') $sql.= " AND s.fk_stcomm=".$search_stcomm;
|
if ($search_stcomm != '') $sql.= natural_search("s.fk_stcomm",$search_stcomm,2);
|
||||||
if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid;
|
if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid;
|
||||||
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||||
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
|
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
|
||||||
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||||
if ($search_nom) {
|
if ($search_nom) $sql .= natural_search('s.nom', $search_nom);
|
||||||
$sql .= natural_search('s.nom', $search_nom);
|
|
||||||
}
|
|
||||||
if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'";
|
if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'";
|
||||||
if ($search_town) {
|
if ($search_town) $sql .= natural_search('s.town', $search_town);
|
||||||
$sql .= natural_search('s.town', $search_town);
|
if ($search_state) $sql .= natural_search('d.nom', $search_state);
|
||||||
}
|
if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
|
||||||
if ($search_state) {
|
|
||||||
$sql .= natural_search('d.nom', $search_state);
|
|
||||||
}
|
|
||||||
if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
|
|
||||||
if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status);
|
if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status);
|
||||||
// Insert levels filters
|
// Insert levels filters
|
||||||
if ($search_levels)
|
if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
|
||||||
{
|
|
||||||
$sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
|
|
||||||
}
|
|
||||||
// Insert sale filter
|
// Insert sale filter
|
||||||
if ($search_sale > 0)
|
if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
|
||||||
|
if ($socname)
|
||||||
{
|
{
|
||||||
$sql .= " AND sc.fk_user = ".$db->escape($search_sale);
|
|
||||||
}
|
|
||||||
if ($socname) {
|
|
||||||
$sql .= natural_search('s.nom', $search_nom);
|
$sql .= natural_search('s.nom', $search_nom);
|
||||||
$sortfield = "s.nom";
|
$sortfield = "s.nom";
|
||||||
$sortorder = "ASC";
|
$sortorder = "ASC";
|
||||||
@@ -362,22 +351,17 @@ if ($resql)
|
|||||||
print '<input class="flat" type="text" size="10" name="search_datec" value="'.$search_datec.'">';
|
print '<input class="flat" type="text" size="10" name="search_datec" value="'.$search_datec.'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Added by Matelli
|
// Prospect levelt
|
||||||
print '<td class="liste_titre" align="center">';
|
print '<td class="liste_titre" align="center">';
|
||||||
// Generate in $options_from the list of each option sorted
|
$options_from = '<option value=""> </option>'; // Generate in $options_from the list of each option sorted
|
||||||
$options_from = '<option value=""> </option>';
|
|
||||||
foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
|
foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
|
||||||
{
|
{
|
||||||
$options_from .= '<option value="'.$tab_level_sortorder.'"'.($search_level_from == $tab_level_sortorder ? ' selected':'').'>';
|
$options_from .= '<option value="'.$tab_level_sortorder.'"'.($search_level_from == $tab_level_sortorder ? ' selected':'').'>';
|
||||||
$options_from .= $langs->trans($tab_level_label);
|
$options_from .= $langs->trans($tab_level_label);
|
||||||
$options_from .= '</option>';
|
$options_from .= '</option>';
|
||||||
}
|
}
|
||||||
|
array_reverse($tab_level, true); // Reverse the list
|
||||||
// Reverse the list
|
$options_to = '<option value=""> </option>'; // Generate in $options_to the list of each option sorted in the reversed order
|
||||||
array_reverse($tab_level, true);
|
|
||||||
|
|
||||||
// Generate in $options_to the list of each option sorted in the reversed order
|
|
||||||
$options_to = '<option value=""> </option>';
|
|
||||||
foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
|
foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
|
||||||
{
|
{
|
||||||
$options_to .= '<option value="'.$tab_level_sortorder.'"'.($search_level_to == $tab_level_sortorder ? ' selected':'').'>';
|
$options_to .= '<option value="'.$tab_level_sortorder.'"'.($search_level_to == $tab_level_sortorder ? ' selected':'').'>';
|
||||||
@@ -392,8 +376,11 @@ if ($resql)
|
|||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
// Prospect status
|
||||||
print '<td class="liste_titre" align="center">';
|
print '<td class="liste_titre" align="center">';
|
||||||
print ' ';
|
// TODO Add here a list of prospect status
|
||||||
|
//print $form->selectarray($htmlname, $array, $search_stcomm);
|
||||||
|
//print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td class="liste_titre" align="center">';
|
print '<td class="liste_titre" align="center">';
|
||||||
|
|||||||
@@ -4304,36 +4304,40 @@ class Form
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a HTML select string, built from an array of key+value.
|
* Return a HTML select string, built from an array of key+value.
|
||||||
* Note: Do not use returned string into a langs->trans function, content may be entity encoded twice.
|
* Note: Do not apply langs->trans function on returned content, content may be entity encoded twice.
|
||||||
*
|
*
|
||||||
* @param string $htmlname Name of html select area
|
* @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect
|
||||||
* @param array $array Array with key+value
|
* @param array $array Array with key+value
|
||||||
* @param string $id Preselected key
|
* @param string|string[] $id Preselected key or preselected keys for multiselect
|
||||||
* @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' ').
|
* @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' ').
|
||||||
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
|
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
|
||||||
* @param int $value_as_key 1 to use value as key
|
* @param int $value_as_key 1 to use value as key
|
||||||
* @param string $moreparam Add more parameters onto the select tag
|
* @param string $moreparam Add more parameters onto the select tag
|
||||||
* @param int $translate Translate and encode value
|
* @param int $translate Translate and encode value
|
||||||
* @param int $maxlen Length maximum for labels
|
* @param int $maxlen Length maximum for labels
|
||||||
* @param int $disabled Html select box is disabled
|
* @param int $disabled Html select box is disabled
|
||||||
* @param int $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' = Do not sort
|
* @param int $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' = Do not sort
|
||||||
* @param string $morecss Add more class to css styles
|
* @param string $morecss Add more class to css styles
|
||||||
* @param int $addjscombo Add js combo
|
* @param int $addjscombo Add js combo
|
||||||
* @return string HTML select string.
|
* @return string HTML select string.
|
||||||
* @see multiselectarray
|
* @see multiselectarray
|
||||||
*/
|
*/
|
||||||
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0)
|
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
// Do we want a multiselect ?
|
||||||
|
$multiselect = 0;
|
||||||
|
if (preg_match('/^multi/',$htmlname)) $multiselect = 1;
|
||||||
|
|
||||||
if ($value_as_key) $array=array_combine($array, $array);
|
if ($value_as_key) $array=array_combine($array, $array);
|
||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
|
|
||||||
// Add code for jquery to use multiselect
|
// Add code for jquery to use multiselect
|
||||||
if ($addjscombo && empty($conf->dol_use_jmobile) && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))
|
if ($addjscombo && empty($conf->dol_use_jmobile) && $multiselect)
|
||||||
{
|
{
|
||||||
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT')?constant('REQUIRE_JQUERY_MULTISELECT'):'select2':$conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
||||||
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@@ -4393,12 +4397,11 @@ class Form
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a HTML select string, built from an array of key+value.
|
* Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL.
|
||||||
* Note: Do not use returned string into a langs->trans function, content may be entity encoded twice.
|
* Note: Do not apply langs->trans function on returned content, content may be entity encoded twice.
|
||||||
*
|
*
|
||||||
* @param string $url Url
|
|
||||||
* @param string $htmlname Name of html select area
|
* @param string $htmlname Name of html select area
|
||||||
* @param array $array Array with key+value
|
* @param string $url Url
|
||||||
* @param string $id Preselected key
|
* @param string $id Preselected key
|
||||||
* @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' ').
|
* @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' ').
|
||||||
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
|
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
|
||||||
@@ -4412,7 +4415,7 @@ class Form
|
|||||||
* @param int $addjscombo Add js combo
|
* @param int $addjscombo Add js combo
|
||||||
* @return string HTML select string.
|
* @return string HTML select string.
|
||||||
*/
|
*/
|
||||||
static function selectArrayAjax($url, $htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0)
|
static function selectArrayAjax($htmlname, $url, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0)
|
||||||
{
|
{
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
@@ -4455,7 +4458,7 @@ class Form
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO get values from ajax page to use a standard already completed array
|
// TODO get all values from $url into $array
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4974,21 +4974,22 @@ function dol_getmypid()
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate natural SQL search string
|
* Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields)
|
||||||
*
|
*
|
||||||
* @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query
|
* @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR)
|
||||||
* @param string $value The value to look for.
|
* @param string $value The value to look for.
|
||||||
* If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
|
* If param $mode is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
|
||||||
* If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000"
|
* If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000"
|
||||||
* @param integer $numeric 0=value is list of keywords, 1=value is a numeric test
|
* If param $mode is 2, can contains a list of id separated by comma like "1,3,4"
|
||||||
|
* @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4')
|
||||||
* @param integer $nofinaland 1=Do now output the final 'AND'
|
* @param integer $nofinaland 1=Do now output the final 'AND'
|
||||||
* @return string $res The statement to append to the SQL query
|
* @return string $res The statement to append to the SQL query
|
||||||
*/
|
*/
|
||||||
function natural_search($fields, $value, $numeric=0, $nofinaland=0)
|
function natural_search($fields, $value, $mode=0, $nofinaland=0)
|
||||||
{
|
{
|
||||||
global $db,$langs;
|
global $db,$langs;
|
||||||
|
|
||||||
if ($numeric)
|
if ($mode == 1)
|
||||||
{
|
{
|
||||||
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
|
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
|
||||||
}
|
}
|
||||||
@@ -5005,7 +5006,7 @@ function natural_search($fields, $value, $numeric=0, $nofinaland=0)
|
|||||||
$newres = '';
|
$newres = '';
|
||||||
foreach ($fields as $field)
|
foreach ($fields as $field)
|
||||||
{
|
{
|
||||||
if ($numeric)
|
if ($mode == 1)
|
||||||
{
|
{
|
||||||
$operator='=';
|
$operator='=';
|
||||||
$newcrit = preg_replace('/([<>=]+)/','',trim($crit));
|
$newcrit = preg_replace('/([<>=]+)/','',trim($crit));
|
||||||
@@ -5029,8 +5030,13 @@ function natural_search($fields, $value, $numeric=0, $nofinaland=0)
|
|||||||
$i2++; // a criteria was added to string
|
$i2++; // a criteria was added to string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ($mode == 2)
|
||||||
{
|
{
|
||||||
|
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")";
|
||||||
|
$i2++; // a criteria was added to string
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
|
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
|
||||||
$i2++; // a criteria was added to string
|
$i2++; // a criteria was added to string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -583,11 +583,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
$langs->load("commercial");
|
$langs->load("commercial");
|
||||||
$newmenu->add("/comm/prospect/list.php?leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'prospects');
|
$newmenu->add("/comm/prospect/list.php?leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'prospects');
|
||||||
|
|
||||||
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=-1", $langs->trans("LastProspectDoNotContact"), 2, $user->rights->societe->lire);
|
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=-1", $langs->trans("LastProspectDoNotContact"), 2, $user->rights->societe->lire);
|
||||||
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=0", $langs->trans("LastProspectNeverContacted"), 2, $user->rights->societe->lire);
|
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=0", $langs->trans("LastProspectNeverContacted"), 2, $user->rights->societe->lire);
|
||||||
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=1", $langs->trans("LastProspectToContact"), 2, $user->rights->societe->lire);
|
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=1", $langs->trans("LastProspectToContact"), 2, $user->rights->societe->lire);
|
||||||
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=2", $langs->trans("LastProspectContactInProcess"), 2, $user->rights->societe->lire);
|
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=2", $langs->trans("LastProspectContactInProcess"), 2, $user->rights->societe->lire);
|
||||||
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=3", $langs->trans("LastProspectContactDone"), 2, $user->rights->societe->lire);
|
if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=3", $langs->trans("LastProspectContactDone"), 2, $user->rights->societe->lire);
|
||||||
|
|
||||||
$newmenu->add("/societe/soc.php?leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
|
$newmenu->add("/societe/soc.php?leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
|
||||||
//$newmenu->add("/contact/list.php?leftmenu=customers&type=p", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
|
//$newmenu->add("/contact/list.php?leftmenu=customers&type=p", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ print "Test 4c: a select with ajax refresh<br>\n";
|
|||||||
//$array=array(0=>'',1=>'Search into xxx',2=>'Search into yyy',3=>'Search into zzz');
|
//$array=array(0=>'',1=>'Search into xxx',2=>'Search into yyy',3=>'Search into zzz');
|
||||||
$array=array();
|
$array=array();
|
||||||
$selected=-1;
|
$selected=-1;
|
||||||
print $form->selectArrayAjax(DOL_URL_ROOT.'/core/ajax/selecsearchbox.php', 'testselectc', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
|
print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selecsearchbox.php', $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '<br><br>'."\n";
|
print '<br><br>'."\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user