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