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