Hello Mehul,
You have to extend the class quicksearchQuery
and override the function constructWhere
create a file custom/modules/Home/QuickSearch.php
<?php
require 'modules/Home/QuickSearch.php';
class quicksearchQueryCustom extends quicksearchQuery
{
/**
* Internal function to construct where clauses
*
* @param Object $focus
* @param array $args
* @return string
*/
protected function constructWhere($focus, $args)
{
global $db, $locale, $current_user;
$table = $focus->getTableName();
if (!empty($table)) {
$table_prefix = $db->getValidDBName($table).".";
} else {
$table_prefix = '';
}
$conditionArray = array();
if (!is_array($args['conditions'])) {
$args['conditions'] = array();
}
foreach($args['conditions'] as $condition)
{
switch ($condition['op'])
{
case self::CONDITION_CONTAINS:
array_push(
$conditionArray,
sprintf(
"%s like '%%%s%%'",
$table_prefix . $db->getValidDBName($condition['name']),
urldecode($db->quote($condition['value'])
)));
break;
case self::CONDITION_LIKE_CUSTOM:
$like = '%';
if (!empty($condition['begin'])) {
$like .= $db->quote($condition['begin']);
}
$like .= urldecode($db->quote($condition['value']));
if (!empty($condition['end'])) {
$like .= $db->quote($condition['end']);
}
if ($focus instanceof Person){
$nameFormat = $locale->getLocaleFormatMacro($current_user);
if (strpos($nameFormat,'l') > strpos($nameFormat,'f')) {
array_push(
$conditionArray,
$db->concat($table, array('first_name','last_name')) . " like '$like'"
);
} else {
array_push(
$conditionArray,
$db->concat($table, array('last_name','first_name')) . " like '$like'"
);
}
}
elseif ($focus instanceof Team) {
array_push(
$conditionArray,
'(' . $table_prefix . $db->getValidDBName($condition['name']) . sprintf(" like '%s%%'", urldecode($db->quote($condition['value']))) . ' or ' . $table_prefix . 'name_2' . sprintf(" like '%s%%'", urldecode($db->quote($condition['value']))) . ')'
);
$condition['exclude_private_teams'] = true;
}
else {
array_push(
$conditionArray,
$table_prefix . $db->getValidDBName($condition['name']) . sprintf(" like '%s'", $like)
);
}
break;
case self::CONDITION_EQUAL:
if ($condition['value']) {
array_push(
$conditionArray,
sprintf("(%s = '%s')", $db->getValidDBName($condition['name']), urldecode($db->quote($condition['value'])))
);
}
break;
default:
array_push(
$conditionArray,
$table_prefix.$db->getValidDBName($condition['name']) . sprintf(" like '%s%%'", urldecode($db->quote($condition['value'])))
);
}
}
$whereClauseArray = array();
if (!empty($conditionArray)) {
$whereClauseArray[] = sprintf('(%s)', implode(" {$args['group']} ", $conditionArray));
}
if(!empty($this->extra_where)) {
$whereClauseArray[] = "({$this->extra_where})";
}
if ($table == 'users') {
$whereClauseArray[] = "users.status='Active'";
}
return implode(' AND ', $whereClauseArray);
}
}
Thank you Hiren,
its solved my problem..
Thank you Hiren,
its solved my problem..