PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/modules/SavedSearch/Bug42378Test.php

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