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