can you do a date range search in sugarcrm search. from x date to y date retreive all records that match. if not i think that would be an important feature to add i think?
can you do a date range search in sugarcrm search. from x date to y date retreive all records that match. if not i think that would be an important feature to add i think?
Hi, mpatwi
it is right possible.
You have to modify the modules/Opportunities/metadata/SearchFields.php and set a search field for begin date (operator: >) and another one for end date (operator: <)
Cheers
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
Hi mpatwi!
if you want we can do it for you.
please feel free to contact us.
Petro Blagodir
petro@blagodir.ua
http://www.blagodir.com
Blagodir Ltd.( SugarCRM - Consultations, Development and Support)
Hi,Originally Posted by mpatwi
it's available on the DEMO version of Enhanced Search.
You'll find also many options for text search and OR / NOT operators.
Take a look at this thread for more details.
Hello, andopesOriginally Posted by andopes
This modification does not work. Look into the source code of SearchForm.php and SearchForm2.php, there are no cases for operators '<' and '>':
So, do you have any idea how to make it work?PHP Code:switch(strtolower($operator)) {
case 'subquery':
$sq = $parms['subquery'];
if(is_array($sq)){
$and_or = ' AND ';
if (isset($sq['OR'])){
$and_or = ' OR ';
}
$first = true;
foreach($sq as $q){
if(empty($q) || strlen($q)<2) continue;
if(!$first){
$where .= $and_or;
}
$where .= " {$db_field} IN ({$q} '{$field_value}%') ";
$first = false;
}
}else{
$where .= "{$db_field} IN ({$parms['subquery']} '{$field_value}%')";
}
break;
case 'like':
if(isset($parms['extra_search']) && !empty($parms['extra_search'])){
//$where .= "$parms[extra_search] like '$field_value$like_char' OR (($parms[extra_search]='') AND $db_field like '$field_value$like_char')";
if($GLOBALS['db']->dbType == 'mysql') {
$where .= "IFNULL($parms[extra_search],$db_field) like '$field_value$like_char'";
}elseif($GLOBALS['db']->dbType == 'mssql'){
$where .= "ISNULL($parms[extra_search],$db_field) like '$field_value$like_char'";
}elseif($GLOBALS['db']->dbType == 'oci8'){
$where .= "NVL($parms[extra_search],$db_field) like '$field_value$like_char'";
}
}else{
$where .= $db_field . " like '".$field_value.$like_char."'";
}
break;
case 'in':
$where .= $db_field . " in (".$field_value.')';
break;
case '=':
$where .= $db_field . " = '".$field_value ."'";
break;
case 'db_date':
if(preg_match('/^\d{4}.\d{1,2}$/', $field_value) == 0) {
$where .= $db_field . " = ". $field_value;
} else {
// Create correct date_format conversion String
if($GLOBALS['db']->dbType == 'oci8') {
$where .= db_convert($db_field,'date_format',array("'YYYY-MM'")) . " = '" . $field_value . "'";
} else {
$where .= db_convert($db_field,'date_format',array("'%Y-%m'")) . " = '" . $field_value . "'";
}
}
break;
// tyoung bug 15971 - need to add these special cases into the $where query
case 'custom_enum':
$where .= $field_value;
break;
}
Thank you
Last edited by 850039; 2008-11-21 at 01:07 PM.
I solved this problem in next way:
I made custom class CustomSearchForm which extends standard SearchForm, then I copied method generateSearchWhere and added my own cases. All that I needed to make it work just require my custom class instead of standard class in my view.
Hi,
I am trying to do the same thing as you. Would you mind giving me more detail on exactly what you did? Which files did you modify/add?
Thanks a lot,
Precar
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks