from_date_modified, from_modified_date? I could be wrong, but I think there are some serious mixups in there. This thread really did get me started though.. here's my take.
I need to search for cases that were closed within a certain date range. I already have a custom field called case_closed_c.
One possible caveat- I believe that creating start_date and end_date custom fields in the studio may mess this search up. Instead I manually added html form fields to SearchForm.html. I added an extra row in the studio then manually inserted the form fields into the tables hoping not to mess up the studio too much.
1) In the studio add a blank row to the 'advanced search' section for the module you are working with. I added the row at the bottom of the form for simplicity.
2) Edit SearchForms.html in the modules directory and insert two text area fields with descriptions. My fields are called 'closed_from_date' and 'closed_to_date'. My code looked like this:
Code:
<tr>
<td width="20%" class="dataLabel"><span sugar='slot21'>Date Closed Start:</span sugar='slot'></td>
<td width="25%" class="dataField"><span sugar='slot21b'><input name='closed_from_date' id='closed_from_date'
type="text" size='25' maxlength='50'></span sugar='slot'></td>
<td width="20%" class="dataLabel"><span sugar='slot22'>Date Closed End:</span sugar='slot'></td>
<td width="25%" class="dataField"><span sugar='slot22b'><input name='closed_to_date' id='closed_to_date' type="text"
size='25'
maxlength='50'></span sugar='slot'></td>
</tr>
3) Edit Listview.php in the modules directory. Before
Code:
$lv->setup($seedCase, 'include/ListView/ListViewGeneric.tpl', $where, $params);
add
Code:
///////
/// custom date range search
///////
if($_REQUEST['closed_from_date'] ){
$from_date = clean_string($_REQUEST['closed_from_date'], "NUMBER");
$where .= ' AND (cases_cstm.date_closed_c >= \''.$from_date.'\')';
}
if($_REQUEST['closed_to_date']){
$to_date = clean_string($_REQUEST['closed_to_date'], "NUMBER");
$where .= ' AND (cases_cstm.date_closed_c <= \''.$to_date.'\') ';
}
echo $where;
/////// This does not include the js calendar and you have to enter the date in yyyy-mm-dd format.
Note the "echo $where" at the end. This will echo the entire search string just below the advanced search after you submit.. Play with it. You'll notice that our custom search gets appended at the end of any standard search so I had to include the 'AND' at the beginning. If you do not supply any normal serach parameters you will have a problem because the search will effectively start with 'AND'.
As you can see this is rough, but it is working for me.. When I get around to it I'll work out the kinks. Right now only one user uses it so it's not a huge issue... big thanks to ivolator.
Bookmarks