PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/modules/SavedSearch/Bug42915Test.php

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