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