Showing posts with label advance search. Show all posts
Showing posts with label advance search. Show all posts

Saturday, January 9, 2016

[sugarcrm] Add fields non-db into search advance

Example for this case that i want add from date and to date for advance search.
i want to find student with condition student of birhtday.
I do the some step below
Step 1: Go to custome Vardefs modue (ex: custom\Extension\modules\isa_students\Ext\Vardefs\ )folder and create new file with name tanphuqn_field_nondb_fromdatetodate.php
Then you copy and paste my scirpt
// taphuqn add 01/11/2015
 $dictionary["isa_students"]["fields"]["fromdatetodate_non_db"]= array(
   'name' => 'fromdatetodate_non_db',
    'rname' => 'fromdatetodate_non_db',
   'vname' => 'LBL_FROMDATE_TODATE_NON_DB',
   'source' => 'non-db',
   'dbType' => 'non-db',
   'type' => 'date',
   'options' => 'date_range_search_dom',
   'enable_range_search' => true,
   'studio' => 'visible',
   'is_date_field' => true,
);

this field is non db when source and dbType is non-db.

Step 2: Add language for this non-db field. You go to custom module(ex:custom\modules\isa_students\language\)
Ex:
'LBL_FROMDATE_TODATE_NON_DB' => 'From date and to date',

Step 3: Repair sugarcrm
You go to Admin-> Repair

Then you click Quick Repair and Rebuild
Step 4: Add field which you have just added to advance search
Go to Admin->Studio and select module which you added non-db field. Ex this module is student
Then you go to advance seach layout


Click advance search icon 

Then you select this non-db field(ex: from date and to date) to Default from Hidden

Step 5: Quick Repair and Rebuild again
Step 6: Check advance search on module which you want to display non-db field (ex: student module)




Friday, January 8, 2016

[sugarcrm] Add today, tomorrow and yesterday into date range search drowdown

If you want to add 3 items (today, tomorrow and yesterday) into date range search dropdown on search field.
We need to modify some things
Step 1: if en_us.lang.php don't exist, you need to create new file en_us.lang.php and save it at custom\include\language\ then you add 3 items

$GLOBALS['app_list_strings']['date_range_search_dom']=array (
    '=' => 'Equals',
    'today' => 'Today',
    'yesterday' => 'Yesterday',
    'tomorrow' => 'Tomorrow',

    'not_equal' => 'Not On',
    'greater_than' => 'After',
    'less_than' => 'Before',
    'last_7_days' => 'Last 7 Days',
    'next_7_days' => 'Next 7 Days',
    'last_30_days' => 'Last 30 Days',
    'next_30_days' => 'Next 30 Days',
    'last_month' => 'Last Month',
    'this_month' => 'This Month',
    'next_month' => 'Next Month',
    'last_year' => 'Last Year',
    'this_year' => 'This Year',
    'next_year' => 'Next Year',
    'between' => 'Is Between',
  );




Step 2: Copy SearchForm2.php file from \include\SearchForm\ to custom\include\SearchForm.
Then you go to line 1154(case 'next_year':) then add new code.
case 'next_year':
case 'yesterday':
case 'today':
case 'tomorrow': 


Step 3: Open include\MVC\View\views\ view.list.php file then go to line 216. You need to replace old  to new script.

// tanphuqn begin to comment this code for run custom search form on 31/12/2015
//require_once('include/SearchForm/SearchForm2.php');
require_once('custom/include/SearchForm/SearchForm2.php');
// tanphuqn end31/12/2015


This my result: