]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/SavedSearch/Bug42378Test.php
Release 6.2.0
[Github/sugarcrm.git] / tests / modules / SavedSearch / Bug42378Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 require_once('modules/MySettings/StoreQuery.php');
38
39 class Bug42378Test extends Sugar_PHPUnit_Framework_TestCase 
40 {
41         var $saved_search_id;
42         
43     public function setUp() 
44     {
45         $this->saved_search_id = md5(gmmktime());
46         
47         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
48         $datetime_prefs = $GLOBALS['current_user']->getUserDateTimePreferences();
49         $GLOBALS['current_user']->setPreference('datef', 'm/d/Y', 0, 'global');
50         $GLOBALS['current_user']->save();
51         $GLOBALS['db']->query("INSERT INTO saved_search (id, name, search_module, deleted, date_entered, date_modified, assigned_user_id, contents) VALUES ('" . $this->saved_search_id . "', 'Bug42738', 'Opportunities', 0, '2011-03-10 17:05:27', '2011-03-10 17:05:27', '".$GLOBALS["current_user"]->id."', 'YTo0OTp7czoxMzoic2VhcmNoRm9ybVRhYiI7czoxNToiYWR2YW5jZWRfc2VhcmNoIjtzOjU6InF1ZXJ5IjtzOjQ6InRydWUiO3M6MTM6Im5hbWVfYWR2YW5jZWQiO3M6MDoiIjtzOjIxOiJhY2NvdW50X25hbWVfYWR2YW5jZWQiO3M6MDoiIjtzOjM0OiJjdXN0b21kYXRlX2NfYWR2YW5jZWRfcmFuZ2VfY2hvaWNlIjtzOjE6Ij0iO3M6Mjc6InJhbmdlX2N1c3RvbWRhdGVfY19hZHZhbmNlZCI7czoxMDoiMDMvMDEvMjAxMSI7czozMzoic3RhcnRfcmFuZ2VfY3VzdG9tZGF0ZV9jX2FkdmFuY2VkIjtzOjA6IiI7czozMToiZW5kX3JhbmdlX2N1c3RvbWRhdGVfY19hZHZhbmNlZCI7czowOiIiO3M6Mzg6ImN1c3RvbWRhdGV0aW1lX2NfYWR2YW5jZWRfcmFuZ2VfY2hvaWNlIjtzOjE6Ij0iO3M6MzE6InJhbmdlX2N1c3RvbWRhdGV0aW1lX2NfYWR2YW5jZWQiO3M6MTA6IjAzLzAyLzIwMTEiO3M6Mzc6InN0YXJ0X3JhbmdlX2N1c3RvbWRhdGV0aW1lX2NfYWR2YW5jZWQiO3M6MDoiIjtzOjM1OiJlbmRfcmFuZ2VfY3VzdG9tZGF0ZXRpbWVfY19hZHZhbmNlZCI7czowO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zOjE2OiJzdWdhcl91c2VyX3RoZW1lIjtzOjU6IlN1Z2FyIjtzOjEzOiJDb250YWN0c19kaXZzIjtzOjE3OiJvcHBvcnR1bml0aWVzX3Y9IyI7czoxMzoiTW9kdWxlQnVpbGRlciI7czoxNToiaGVscEhpZGRlbj10cnVlIjtzOjIyOiJzdWdhcl90aGVtZV9nbV9jdXJyZW50IjtzOjM6IkFsbCI7czoxNToiZ2xvYmFsTGlua3NPcGVuIjtzOjQ6InRydWUiO3M6ODoiYWR2YW5jZWQiO2I6MTt9')");
52     }
53     
54     public function tearDown() 
55     {
56         //$GLOBALS['db']->query("DELETE FROM saved_search where id = '{$this->saved_search_id}'"); 
57         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
58         unset($GLOBALS['current_user']);
59     }
60     
61     /**
62      * This test captures the scenario for date_modified field where range search is enabled
63      */    
64     public function testSaveRangeDateFields() 
65     {
66         require_once('modules/SavedSearch/SavedSearch.php');
67             $focus = new SavedSearch();
68                 $focus->retrieve($this->saved_search_id);
69                 $_REQUEST = unserialize(base64_decode($focus->contents));
70                 $mockBean = new Bug42377MockOpportunity();
71                 $focus->handleSave('', false, '', $this->saved_search_id, $mockBean);
72                 
73                 //Now retrieve what we have saved and test
74                 $focus = new SavedSearch();
75                 $focus->retrieve($this->saved_search_id);
76                 $formatted_data = unserialize(base64_decode($focus->contents));
77                 $this->assertEquals($formatted_data['range_date_modified_advanced'], '2011-03-01', "Assert that value is in db format ('2011-03-01')");
78                 $this->assertEquals($formatted_data['start_range_date_entered_advanced'], '2011-03-01', "Assert that value is in db format ('2011-03-01')");
79                 $this->assertEquals($formatted_data['end_range_date_entered_advanced'], '2011-03-05', "Assert that value is in db format ('2011-03-05')");              
80                 
81                 //Last check to see that the macro value is okay and preserved
82                 $this->assertEquals($formatted_data['range_date_closed_advanced'], '[last_7_days]', "Assert that the macro date value [last_7_days] was preserved");
83                 $this->assertEquals($formatted_data['date_closed_advanced_range_choice'], 'last_7_days', "Assert that the macro date value choice last_7_days was preserved");          
84     }
85     
86     /**
87      * This test captures the scenario for date_modified field where range search is not enabled
88      */
89     public function testSaveDateFields() 
90     {
91         require_once('modules/SavedSearch/SavedSearch.php');
92             $focus = new SavedSearch();
93                 $focus->retrieve($this->saved_search_id);
94                 $_REQUEST = unserialize(base64_decode($focus->contents));
95                 unset($_REQUEST['start_range_date_modified_advanced']);
96                 unset($_REQUEST['end_range_date_modified_advanced']);
97                 unset($_REQUEST['range_date_modified_advanced']);
98                 $_REQUEST['date_modified_advanced'] = '07/03/2009'; //Special date :)
99                 $mockBean = new Bug42377MockOpportunity();
100                 $focus->handleSave('', false, '', $this->saved_search_id, $mockBean);
101                 
102                 //Now retrieve what we have saved and test
103                 $focus = new SavedSearch();
104                 $focus->retrieve($this->saved_search_id);
105                 $formatted_data = unserialize(base64_decode($focus->contents));
106                 $this->assertEquals($formatted_data['date_modified_advanced'], '2009-07-03', "Assert that value is in db format ('2009-07-03')");               
107
108         //Now test that when we populate the search form, we bring it back to user's date format
109         $focus->retrieveSavedSearch($this->saved_search_id);
110                 $focus->populateRequest();
111         $this->assertEquals($_REQUEST['date_modified_advanced'], '07/03/2009', "Assert that dates in db format were converted back to user's date preference");    
112     
113         //Take this a step further, assume date format now changes, will date be populated correctly?
114         global $current_user;
115         $current_user->setPreference('datef', 'd/m/Y', 0, 'global');
116         $current_user->save();  
117
118         //Now test that when we populate the search form, we bring it back to user's date format
119         $focus->retrieveSavedSearch($this->saved_search_id);
120                 $focus->populateRequest();
121         $this->assertEquals($_REQUEST['date_modified_advanced'], '03/07/2009', "Assert that dates in db format were converted back to user's date preference");            
122     }       
123     
124     public function testStoreQuerySaveAndPopulate()
125     {
126         global $current_user, $timedate;
127         
128         $storeQuery = new StoreQuery();
129         //Simulate a search request here
130         $_REQUEST = array
131                         (
132                             'module' => 'Opportunities',
133                             'action' => 'index',
134                             'searchFormTab' => 'advanced_search',
135                             'query' => true,
136                             'name_advanced' => '',
137                             'account_name_advanced' => '',
138                             'amount_advanced_range_choice' => '=',
139                             'range_amount_advanced' => '',
140                             'start_range_amount_advanced' => '',
141                             'end_range_amount_advanced' => '',
142                             'date_closed_advanced_range_choice' => '=',
143                             'range_date_closed_advanced' => '09/01/2008',
144                             'start_range_date_closed_advanced' => '',
145                             'end_range_date_closed_advanced' => '',
146                             'next_step_advanced' => '',
147                             'update_fields_team_name_advanced_collection' => '',
148                             'team_name_advanced_new_on_update' => false,
149                             'team_name_advanced_allow_update' => '',
150                             'team_name_advanced_allowed_to_check' => false,
151                             'team_name_advanced_collection_0' => '',
152                             'id_team_name_advanced_collection_0' => '',
153                             'team_name_advanced_type' => 'any',
154                             'favorites_only_advanced' => 0,
155                             'showSSDIV' => 'no',
156                             'saved_search_name' => '',
157                             'search_module' => '',
158                             'saved_search_action' => '',
159                             'displayColumns' => 'NAME|ACCOUNT_NAME|SALES_STAGE|AMOUNT_USDOLLAR|DATE_CLOSED|ASSIGNED_USER_NAME|DATE_ENTERED',
160                             'hideTabs' => 'OPPORTUNITY_TYPE|LEAD_SOURCE|NEXT_STEP|PROBABILITY|CREATED_BY_NAME|TEAM_NAME|MODIFIED_BY_NAME',
161                             'orderBy' => 'NAME',
162                             'sortOrder' => 'ASC',
163                             'button' => 'Search',
164                             'saved_search_select' => '_none',
165                             'sugar_user_theme' => 'Sugar',
166                             'ModuleBuilder' => 'helpHidden=true',
167                             'Contacts_divs' => 'quotes_v=#',
168                             'sugar_theme_gm_current' => 'All',
169                             'globalLinksOpen' => 'true',
170                             'SQLiteManager_currentLangue' => '2',
171                             'PHPSESSID' => 'b8e4b4b955ef3c4b29291779751b5fca',
172                         );
173         
174         $storeQuery->saveFromRequest('Opportunities');
175         
176         $storedSearch = StoreQuery::getStoredQueryForUser('Opportunities');
177         $this->assertEquals($storedSearch['range_date_closed_advanced'], '2008-09-01', 'Assert that search date 09/02/2008 was saved in db format 2008-09-01');
178
179         //Test that value is converted to user date preferences when retrieved
180         unset($_REQUEST['range_date_closed_advanced']);
181         $storeQuery->loadQuery('Opportunities');
182         $storeQuery->populateRequest();
183         $this->assertTrue(isset($_REQUEST['range_date_closed_advanced']), 'Assert that the field was correctly populated');
184         $this->assertEquals($_REQUEST['range_date_closed_advanced'], '09/01/2008', 'Assert that search date in db_format 2008-09-01 was converted to user date preference 09/01/2008');
185         
186         //Now say the user changes his date preferences and switches back to this StoredQuery
187         $current_user->setPreference('datef', 'Y.m.d', 0, 'global');
188         $current_user->save();
189
190         //Now when we reload this store query, the $_REQUEST array should be populated with new user date preference
191         unset($_REQUEST['range_date_closed_advanced']);
192         $storeQuery->loadQuery('Opportunities');
193         $storeQuery->populateRequest();
194         $this->assertTrue(isset($_REQUEST['range_date_closed_advanced']), 'Assert that the field was correctly populated');
195         $this->assertEquals($_REQUEST['range_date_closed_advanced'], '2008.09.01', 'Assert that search date in db_format 2008-09-01 was converted to user date preference 2008.09.01');                 
196     }
197     
198 }
199
200
201 class Bug42377MockOpportunity extends Opportunity
202 {
203         
204 var $field_defs = array (
205                           'id' => 
206                           array (
207                             'name' => 'id',
208                             'vname' => 'LBL_ID',
209                             'type' => 'id',
210                             'required' => true,
211                             'reportable' => true,
212                             'comment' => 'Unique identifier',
213                           ),
214                           'name' => 
215                           array (
216                             'name' => 'name',
217                             'vname' => 'LBL_OPPORTUNITY_NAME',
218                             'type' => 'name',
219                             'dbType' => 'varchar',
220                             'len' => '50',
221                             'unified_search' => true,
222                             'comment' => 'Name of the opportunity',
223                             'merge_filter' => 'selected',
224                             'importable' => 'required',
225                             'required' => true,
226                           ),
227                           'date_entered' => 
228                           array (
229                             'name' => 'date_entered',
230                             'vname' => 'LBL_DATE_ENTERED',
231                             'type' => 'datetime',
232                             'group' => 'created_by_name',
233                             'comment' => 'Date record created',
234                             'enable_range_search' => '1',
235                             'options' => 'date_range_search_dom',
236                           ),
237                           'date_modified' => 
238                           array (
239                             'name' => 'date_modified',
240                             'vname' => 'LBL_DATE_MODIFIED',
241                             'type' => 'datetime',
242                             'group' => 'modified_by_name',
243                             'comment' => 'Date record last modified',
244                             'enable_range_search' => '1',
245                             'options' => 'date_range_search_dom',
246                           ),
247                           'modified_user_id' => 
248                           array (
249                             'name' => 'modified_user_id',
250                             'rname' => 'user_name',
251                             'id_name' => 'modified_user_id',
252                             'vname' => 'LBL_MODIFIED',
253                             'type' => 'assigned_user_name',
254                             'table' => 'users',
255                             'isnull' => 'false',
256                             'group' => 'modified_by_name',
257                             'dbType' => 'id',
258                             'reportable' => true,
259                             'comment' => 'User who last modified record',
260                           ),
261                           'modified_by_name' => 
262                           array (
263                             'name' => 'modified_by_name',
264                             'vname' => 'LBL_MODIFIED_NAME',
265                             'type' => 'relate',
266                             'reportable' => false,
267                             'source' => 'non-db',
268                             'rname' => 'user_name',
269                             'table' => 'users',
270                             'id_name' => 'modified_user_id',
271                             'module' => 'Users',
272                             'link' => 'modified_user_link',
273                             'duplicate_merge' => 'disabled',
274                           ),
275                           'created_by' => 
276                           array (
277                             'name' => 'created_by',
278                             'rname' => 'user_name',
279                             'id_name' => 'modified_user_id',
280                             'vname' => 'LBL_CREATED',
281                             'type' => 'assigned_user_name',
282                             'table' => 'users',
283                             'isnull' => 'false',
284                             'dbType' => 'id',
285                             'group' => 'created_by_name',
286                             'comment' => 'User who created record',
287                           ),
288                           'created_by_name' => 
289                           array (
290                             'name' => 'created_by_name',
291                             'vname' => 'LBL_CREATED',
292                             'type' => 'relate',
293                             'reportable' => false,
294                             'link' => 'created_by_link',
295                             'rname' => 'user_name',
296                             'source' => 'non-db',
297                             'table' => 'users',
298                             'id_name' => 'created_by',
299                             'module' => 'Users',
300                             'duplicate_merge' => 'disabled',
301                             'importable' => 'false',
302                           ),
303                           'description' => 
304                           array (
305                             'name' => 'description',
306                             'vname' => 'LBL_DESCRIPTION',
307                             'type' => 'text',
308                             'comment' => 'Full text of the note',
309                             'rows' => 6,
310                             'cols' => 80,
311                           ),
312                           'deleted' => 
313                           array (
314                             'name' => 'deleted',
315                             'vname' => 'LBL_DELETED',
316                             'type' => 'bool',
317                             'default' => '0',
318                             'reportable' => false,
319                             'comment' => 'Record deletion indicator',
320                           ),
321                           'created_by_link' => 
322                           array (
323                             'name' => 'created_by_link',
324                             'type' => 'link',
325                             'relationship' => 'opportunities_created_by',
326                             'vname' => 'LBL_CREATED_USER',
327                             'link_type' => 'one',
328                             'module' => 'Users',
329                             'bean_name' => 'User',
330                             'source' => 'non-db',
331                           ),
332                           'modified_user_link' => 
333                           array (
334                             'name' => 'modified_user_link',
335                             'type' => 'link',
336                             'relationship' => 'opportunities_modified_user',
337                             'vname' => 'LBL_MODIFIED_USER',
338                             'link_type' => 'one',
339                             'module' => 'Users',
340                             'bean_name' => 'User',
341                             'source' => 'non-db',
342                           ),
343                           'assigned_user_id' => 
344                           array (
345                             'name' => 'assigned_user_id',
346                             'rname' => 'user_name',
347                             'id_name' => 'assigned_user_id',
348                             'vname' => 'LBL_ASSIGNED_TO_ID',
349                             'group' => 'assigned_user_name',
350                             'type' => 'relate',
351                             'table' => 'users',
352                             'module' => 'Users',
353                             'reportable' => true,
354                             'isnull' => 'false',
355                             'dbType' => 'id',
356                             'audited' => true,
357                             'comment' => 'User ID assigned to record',
358                             'duplicate_merge' => 'disabled',
359                           ),
360                           'assigned_user_name' => 
361                           array (
362                             'name' => 'assigned_user_name',
363                             'link' => 'assigned_user_link',
364                             'vname' => 'LBL_ASSIGNED_TO_NAME',
365                             'rname' => 'user_name',
366                             'type' => 'relate',
367                             'reportable' => false,
368                             'source' => 'non-db',
369                             'table' => 'users',
370                             'id_name' => 'assigned_user_id',
371                             'module' => 'Users',
372                             'duplicate_merge' => 'disabled',
373                           ),
374                           'assigned_user_link' => 
375                           array (
376                             'name' => 'assigned_user_link',
377                             'type' => 'link',
378                             'relationship' => 'opportunities_assigned_user',
379                             'vname' => 'LBL_ASSIGNED_TO_USER',
380                             'link_type' => 'one',
381                             'module' => 'Users',
382                             'bean_name' => 'User',
383                             'source' => 'non-db',
384                             'duplicate_merge' => 'enabled',
385                             'rname' => 'user_name',
386                             'id_name' => 'assigned_user_id',
387                             'table' => 'users',
388                           ),
389                           'team_id' => 
390                           array (
391                             'name' => 'team_id',
392                             'vname' => 'LBL_TEAM_ID',
393                             'group' => 'team_name',
394                             'reportable' => false,
395                             'dbType' => 'id',
396                             'type' => 'team_list',
397                             'audited' => true,
398                             'comment' => 'Team ID for the account',
399                           ),
400                           'team_set_id' => 
401                           array (
402                             'name' => 'team_set_id',
403                             'rname' => 'id',
404                             'id_name' => 'team_set_id',
405                             'vname' => 'LBL_TEAM_SET_ID',
406                             'type' => 'id',
407                             'audited' => true,
408                             'studio' => 'false',
409                             'dbType' => 'id',
410                           ),
411                           'team_count' => 
412                           array (
413                             'name' => 'team_count',
414                             'rname' => 'team_count',
415                             'id_name' => 'team_id',
416                             'vname' => 'LBL_TEAMS',
417                             'join_name' => 'ts1',
418                             'table' => 'teams',
419                             'type' => 'relate',
420                             'isnull' => 'true',
421                             'module' => 'Teams',
422                             'link' => 'team_count_link',
423                             'massupdate' => false,
424                             'dbType' => 'int',
425                             'source' => 'non-db',
426                             'importable' => 'false',
427                             'reportable' => false,
428                             'duplicate_merge' => 'disabled',
429                             'studio' => 'false',
430                             'hideacl' => true,
431                           ),
432                           'team_name' => 
433                           array (
434                             'name' => 'team_name',
435                             'db_concat_fields' => 
436                             array (
437                               0 => 'name',
438                               1 => 'name_2',
439                             ),
440                             'sort_on' => 'tj.name',
441                             'join_name' => 'tj',
442                             'rname' => 'name',
443                             'id_name' => 'team_id',
444                             'vname' => 'LBL_TEAMS',
445                             'type' => 'relate',
446                             'table' => 'teams',
447                             'isnull' => 'true',
448                             'module' => 'Teams',
449                             'link' => 'team_link',
450                             'massupdate' => false,
451                             'dbType' => 'varchar',
452                             'source' => 'non-db',
453                             'len' => 36,
454                             'custom_type' => 'teamset',
455                           ),
456                           'team_link' => 
457                           array (
458                             'name' => 'team_link',
459                             'type' => 'link',
460                             'relationship' => 'opportunities_team',
461                             'vname' => 'LBL_TEAMS_LINK',
462                             'link_type' => 'one',
463                             'module' => 'Teams',
464                             'bean_name' => 'Team',
465                             'source' => 'non-db',
466                             'duplicate_merge' => 'disabled',
467                             'studio' => 'false',
468                           ),
469                           'team_count_link' => 
470                           array (
471                             'name' => 'team_count_link',
472                             'type' => 'link',
473                             'relationship' => 'opportunities_team_count_relationship',
474                             'link_type' => 'one',
475                             'module' => 'Teams',
476                             'bean_name' => 'TeamSet',
477                             'source' => 'non-db',
478                             'duplicate_merge' => 'disabled',
479                             'reportable' => false,
480                             'studio' => 'false',
481                           ),
482                           'teams' => 
483                           array (
484                             'name' => 'teams',
485                             'type' => 'link',
486                             'relationship' => 'opportunities_teams',
487                             'bean_filter_field' => 'team_set_id',
488                             'rhs_key_override' => true,
489                             'source' => 'non-db',
490                             'vname' => 'LBL_TEAMS',
491                             'link_class' => 'TeamSetLink',
492                             'link_file' => 'modules/Teams/TeamSetLink.php',
493                             'studio' => 'false',
494                             'reportable' => false,
495                           ),
496                           'opportunity_type' => 
497                           array (
498                             'name' => 'opportunity_type',
499                             'vname' => 'LBL_TYPE',
500                             'type' => 'enum',
501                             'options' => 'opportunity_type_dom',
502                             'len' => '255',
503                             'audited' => true,
504                             'comment' => 'Type of opportunity (ex: Existing, New)',
505                             'merge_filter' => 'enabled',
506                           ),
507                           'account_name' => 
508                           array (
509                             'name' => 'account_name',
510                             'rname' => 'name',
511                             'id_name' => 'account_id',
512                             'vname' => 'LBL_ACCOUNT_NAME',
513                             'type' => 'relate',
514                             'table' => 'accounts',
515                             'join_name' => 'accounts',
516                             'isnull' => 'true',
517                             'module' => 'Accounts',
518                             'dbType' => 'varchar',
519                             'link' => 'accounts',
520                             'len' => '255',
521                             'source' => 'non-db',
522                             'unified_search' => true,
523                             'required' => true,
524                             'importable' => 'required',
525                           ),
526                           'account_id' => 
527                           array (
528                             'name' => 'account_id',
529                             'vname' => 'LBL_ACCOUNT_ID',
530                             'type' => 'id',
531                             'source' => 'non-db',
532                             'audited' => true,
533                           ),
534                           'campaign_id' => 
535                           array (
536                             'name' => 'campaign_id',
537                             'comment' => 'Campaign that generated lead',
538                             'vname' => 'LBL_CAMPAIGN_ID',
539                             'rname' => 'id',
540                             'type' => 'id',
541                             'dbType' => 'id',
542                             'table' => 'campaigns',
543                             'isnull' => 'true',
544                             'module' => 'Campaigns',
545                             'reportable' => false,
546                             'massupdate' => false,
547                             'duplicate_merge' => 'disabled',
548                           ),
549                           'campaign_name' => 
550                           array (
551                             'name' => 'campaign_name',
552                             'rname' => 'name',
553                             'id_name' => 'campaign_id',
554                             'vname' => 'LBL_CAMPAIGN',
555                             'type' => 'relate',
556                             'link' => 'campaign_opportunities',
557                             'isnull' => 'true',
558                             'table' => 'campaigns',
559                             'module' => 'Campaigns',
560                             'source' => 'non-db',
561                           ),
562                           'campaign_opportunities' => 
563                           array (
564                             'name' => 'campaign_opportunities',
565                             'type' => 'link',
566                             'vname' => 'LBL_CAMPAIGN_OPPORTUNITY',
567                             'relationship' => 'campaign_opportunities',
568                             'source' => 'non-db',
569                           ),
570                           'lead_source' => 
571                           array (
572                             'name' => 'lead_source',
573                             'vname' => 'LBL_LEAD_SOURCE',
574                             'type' => 'enum',
575                             'options' => 'lead_source_dom',
576                             'len' => '50',
577                             'comment' => 'Source of the opportunity',
578                             'merge_filter' => 'enabled',
579                           ),
580                           'amount' => 
581                           array (
582                             'name' => 'amount',
583                             'vname' => 'LBL_AMOUNT',
584                             'type' => 'currency',
585                             'dbType' => 'double',
586                             'comment' => 'Unconverted amount of the opportunity',
587                             'duplicate_merge' => 'disabled',
588                             'importable' => 'required',
589                             'required' => true,
590                             'options' => 'numeric_range_search_dom',
591                             'enable_range_search' => '1',
592                           ),
593                           'amount_usdollar' => 
594                           array (
595                             'name' => 'amount_usdollar',
596                             'vname' => 'LBL_AMOUNT_USDOLLAR',
597                             'type' => 'currency',
598                             'group' => 'amount',
599                             'dbType' => 'double',
600                             'disable_num_format' => true,
601                             'audited' => true,
602                             'comment' => 'Formatted amount of the opportunity',
603                           ),
604                           'currency_id' => 
605                           array (
606                             'name' => 'currency_id',
607                             'type' => 'id',
608                             'group' => 'currency_id',
609                             'vname' => 'LBL_CURRENCY',
610                             'function' => 
611                             array (
612                               'name' => 'getCurrencyDropDown',
613                               'returns' => 'html',
614                             ),
615                             'reportable' => false,
616                             'comment' => 'Currency used for display purposes',
617                           ),
618                           'currency_name' => 
619                           array (
620                             'name' => 'currency_name',
621                             'rname' => 'name',
622                             'id_name' => 'currency_id',
623                             'vname' => 'LBL_CURRENCY_NAME',
624                             'type' => 'relate',
625                             'isnull' => 'true',
626                             'table' => 'currencies',
627                             'module' => 'Currencies',
628                             'source' => 'non-db',
629                             'function' => 
630                             array (
631                               'name' => 'getCurrencyNameDropDown',
632                               'returns' => 'html',
633                             ),
634                             'studio' => 'false',
635                             'duplicate_merge' => 'disabled',
636                           ),
637                           'currency_symbol' => 
638                           array (
639                             'name' => 'currency_symbol',
640                             'rname' => 'symbol',
641                             'id_name' => 'currency_id',
642                             'vname' => 'LBL_CURRENCY_SYMBOL',
643                             'type' => 'relate',
644                             'isnull' => 'true',
645                             'table' => 'currencies',
646                             'module' => 'Currencies',
647                             'source' => 'non-db',
648                             'function' => 
649                             array (
650                               'name' => 'getCurrencySymbolDropDown',
651                               'returns' => 'html',
652                             ),
653                             'studio' => 'false',
654                             'duplicate_merge' => 'disabled',
655                           ),
656                           'date_closed' => 
657                           array (
658                             'name' => 'date_closed',
659                             'vname' => 'LBL_DATE_CLOSED',
660                             'type' => 'date',
661                             'audited' => true,
662                             'comment' => 'Expected or actual date the oppportunity will close',
663                             'importable' => 'required',
664                             'required' => true,
665                             'enable_range_search' => '1',
666                             'options' => 'date_range_search_dom',
667                           ),
668                           'next_step' => 
669                           array (
670                             'name' => 'next_step',
671                             'vname' => 'LBL_NEXT_STEP',
672                             'type' => 'varchar',
673                             'len' => '100',
674                             'comment' => 'The next step in the sales process',
675                             'merge_filter' => 'enabled',
676                           ),
677                           'sales_stage' => 
678                           array (
679                             'name' => 'sales_stage',
680                             'vname' => 'LBL_SALES_STAGE',
681                             'type' => 'enum',
682                             'options' => 'sales_stage_dom',
683                             'len' => '255',
684                             'audited' => true,
685                             'comment' => 'Indication of progression towards closure',
686                             'merge_filter' => 'enabled',
687                             'importable' => 'required',
688                             'required' => true,
689                           ),
690                           'probability' => 
691                           array (
692                             'name' => 'probability',
693                             'vname' => 'LBL_PROBABILITY',
694                             'type' => 'int',
695                             'dbType' => 'double',
696                             'audited' => true,
697                             'comment' => 'The probability of closure',
698                             'validation' => 
699                             array (
700                               'type' => 'range',
701                               'min' => 0,
702                               'max' => 100,
703                             ),
704                             'merge_filter' => 'enabled',
705                           ),
706                           'accounts' => 
707                           array (
708                             'name' => 'accounts',
709                             'type' => 'link',
710                             'relationship' => 'accounts_opportunities',
711                             'source' => 'non-db',
712                             'link_type' => 'one',
713                             'module' => 'Accounts',
714                             'bean_name' => 'Account',
715                             'vname' => 'LBL_ACCOUNTS',
716                           ),
717                           'contacts' => 
718                           array (
719                             'name' => 'contacts',
720                             'type' => 'link',
721                             'relationship' => 'opportunities_contacts',
722                             'source' => 'non-db',
723                             'module' => 'Contacts',
724                             'bean_name' => 'Contact',
725                             'rel_fields' => 
726                             array (
727                               'contact_role' => 
728                               array (
729                                 'type' => 'enum',
730                                 'options' => 'opportunity_relationship_type_dom',
731                               ),
732                             ),
733                             'vname' => 'LBL_CONTACTS',
734                           ),
735                           'tasks' => 
736                           array (
737                             'name' => 'tasks',
738                             'type' => 'link',
739                             'relationship' => 'opportunity_tasks',
740                             'source' => 'non-db',
741                             'vname' => 'LBL_TASKS',
742                           ),
743                           'notes' => 
744                           array (
745                             'name' => 'notes',
746                             'type' => 'link',
747                             'relationship' => 'opportunity_notes',
748                             'source' => 'non-db',
749                             'vname' => 'LBL_NOTES',
750                           ),
751                           'meetings' => 
752                           array (
753                             'name' => 'meetings',
754                             'type' => 'link',
755                             'relationship' => 'opportunity_meetings',
756                             'source' => 'non-db',
757                             'vname' => 'LBL_MEETINGS',
758                           ),
759                           'calls' => 
760                           array (
761                             'name' => 'calls',
762                             'type' => 'link',
763                             'relationship' => 'opportunity_calls',
764                             'source' => 'non-db',
765                             'vname' => 'LBL_CALLS',
766                           ),
767                           'emails' => 
768                           array (
769                             'name' => 'emails',
770                             'type' => 'link',
771                             'relationship' => 'emails_opportunities_rel',
772                             'source' => 'non-db',
773                             'vname' => 'LBL_EMAILS',
774                           ),
775                           'documents' => 
776                           array (
777                             'name' => 'documents',
778                             'type' => 'link',
779                             'relationship' => 'documents_opportunities',
780                             'source' => 'non-db',
781                             'vname' => 'LBL_DOCUMENTS_SUBPANEL_TITLE',
782                           ),
783                           'quotes' => 
784                           array (
785                             'name' => 'quotes',
786                             'type' => 'link',
787                             'relationship' => 'quotes_opportunities',
788                             'source' => 'non-db',
789                             'vname' => 'LBL_QUOTES',
790                           ),
791                           'project' => 
792                           array (
793                             'name' => 'project',
794                             'type' => 'link',
795                             'relationship' => 'projects_opportunities',
796                             'source' => 'non-db',
797                             'vname' => 'LBL_PROJECTS',
798                           ),
799                           'leads' => 
800                           array (
801                             'name' => 'leads',
802                             'type' => 'link',
803                             'relationship' => 'opportunity_leads',
804                             'source' => 'non-db',
805                             'vname' => 'LBL_LEADS',
806                           ),
807                           'campaigns' => 
808                           array (
809                             'name' => 'campaigns',
810                             'type' => 'link',
811                             'relationship' => 'opportunities_campaign',
812                             'module' => 'CampaignLog',
813                             'bean_name' => 'CampaignLog',
814                             'source' => 'non-db',
815                             'vname' => 'LBL_CAMPAIGNS',
816                           ),
817                           'campaign_link' => 
818                           array (
819                             'name' => 'campaign_link',
820                             'type' => 'link',
821                             'relationship' => 'opportunities_campaign',
822                             'vname' => 'LBL_CAMPAIGNS',
823                             'link_type' => 'one',
824                             'module' => 'Campaigns',
825                             'bean_name' => 'Campaign',
826                             'source' => 'non-db',
827                           ),
828                           'currencies' => 
829                           array (
830                             'name' => 'currencies',
831                             'type' => 'link',
832                             'relationship' => 'opportunity_currencies',
833                             'source' => 'non-db',
834                             'vname' => 'LBL_CURRENCIES',
835                           ),
836                           'contracts' => 
837                           array (
838                             'name' => 'contracts',
839                             'type' => 'link',
840                             'vname' => 'LBL_CONTRACTS',
841                             'relationship' => 'contracts_opportunities',
842                             'source' => 'non-db',
843                           ),
844                           'customdate_c' => 
845                           array (
846                             'options' => 'date_range_search_dom',
847                             'enforced' => 'false',
848                             'dependency' => '',
849                             'enable_range_search' => '1',
850                             'required' => false,
851                             'source' => 'custom_fields',
852                             'name' => 'customdate_c',
853                             'vname' => 'LBL_CUSTOMDATE',
854                             'type' => 'date',
855                             'massupdate' => '0',
856                             'default' => NULL,
857                             'comments' => '',
858                             'help' => '',
859                             'importable' => 'true',
860                             'duplicate_merge' => 'disabled',
861                             'duplicate_merge_dom_value' => '0',
862                             'audited' => false,
863                             'reportable' => true,
864                             'calculated' => false,
865                             'size' => '20',
866                             'id' => 'Opportunitiescustomdate_c',
867                             'custom_module' => 'Opportunities',
868                           ),
869                           'customdatetime_c' => 
870                           array (
871                             'enforced' => 'false',
872                             'dependency' => '',
873                             'required' => false,
874                             'source' => 'custom_fields',
875                             'name' => 'customdatetime_c',
876                             'vname' => 'LBL_CUSTOMDATETIME',
877                             'type' => 'datetimecombo',
878                             'massupdate' => '0',
879                             'default' => NULL,
880                             'comments' => '',
881                             'help' => '',
882                             'importable' => 'true',
883                             'duplicate_merge' => 'disabled',
884                             'duplicate_merge_dom_value' => '0',
885                             'audited' => false,
886                             'reportable' => true,
887                             'calculated' => false,
888                             'size' => '20',
889                             'enable_range_search' => false,
890                             'dbType' => 'datetime',
891                             'id' => 'Opportunitiescustomdatetime_c',
892                             'custom_module' => 'Opportunities',
893                           ),
894 );
895 }