3 require_once('data/SugarBean.php');
4 require_once('modules/Contacts/Contact.php');
5 require_once('include/SubPanel/SubPanelDefinitions.php');
7 class Bug41738Test extends Sugar_PHPUnit_Framework_TestCase
11 public function setUp()
13 global $moduleList, $beanList, $beanFiles;
14 require('include/modules.php');
15 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
16 $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
17 $GLOBALS['modules_exempt_from_availability_check']['Calls']='Calls';
18 $GLOBALS['modules_exempt_from_availability_check']['Meetings']='Meetings';
19 $this->bean = new Opportunity();
22 public function tearDown()
24 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
25 unset($GLOBALS['current_user']);
28 public function testSubpanelCollectionWithSpecificQuery()
32 'sort_order' => 'desc',
33 'sort_by' => 'date_entered',
34 'type' => 'collection',
35 'subpanel_name' => 'history', //this values is not associated with a physical file.
36 'top_buttons' => array(),
37 'collection_list' => array(
39 'module' => 'Meetings',
40 'subpanel_name' => 'ForHistory',
41 'get_subpanel_data' => 'function:subpanelCollectionWithSpecificQueryMeetings',
42 'generate_select'=>false,
43 'function_parameters' => array(
44 'bean_id'=>$this->bean->id,
45 'import_function_file' => __FILE__
50 'subpanel_name' => 'ForHistory',
51 'get_subpanel_data' => 'function:subpanelCollectionWithSpecificQueryTasks',
52 'generate_select'=>false,
53 'function_parameters' => array(
54 'bean_id'=>$this->bean->id,
55 'import_function_file' => __FILE__
60 $subpanel_def = new aSubPanel("testpanel", $subpanel, $this->bean);
61 $query = $this->bean->get_union_related_list($this->bean, "", '', "", 0, 5, -1, 0, $subpanel_def);
62 $result = $this->bean->db->query($query["query"]);
63 $this->assertTrue($result != false, "Bad query: {$query['query']}");
70 function subpanelCollectionWithSpecificQueryMeetings($params)
72 $query = "SELECT meetings.id , meetings.name , meetings.status , 0 reply_to_status , ' ' contact_name , ' ' contact_id , ' ' contact_name_owner , ' ' contact_name_mod , meetings.parent_id , meetings.parent_type , meetings.date_modified , jt1.user_name assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, ' ' filename , meetings.assigned_user_id , 'meetings' panel_name
74 LEFT JOIN users jt1 ON jt1.id= meetings.assigned_user_id AND jt1.deleted=0 AND jt1.deleted=0
75 WHERE ( meetings.parent_type = \"Opportunities\"
76 AND meetings.deleted=0
77 AND (meetings.status='Held' OR meetings.status='Not Held')
78 AND meetings.parent_id IN(
81 INNER JOIN opportunities_contacts oc on o.id = oc.opportunity_id
82 AND oc.contact_id = '".$params['bean_id']."')
88 function subpanelCollectionWithSpecificQueryTasks($params)
90 $query = "SELECT tasks.id , tasks.name , tasks.status , 0 reply_to_status , ' ' contact_name , ' ' contact_id , ' ' contact_name_owner , ' ' contact_name_mod , tasks.parent_id , tasks.parent_type , tasks.date_modified , jt1.user_name assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, ' ' filename , tasks.assigned_user_id , 'tasks' panel_name
92 LEFT JOIN users jt1 ON jt1.id= tasks.assigned_user_id AND jt1.deleted=0 AND jt1.deleted=0
93 WHERE ( tasks.parent_type = \"Opportunities\"
95 AND (tasks.status='Completed' OR tasks.status='Deferred')
96 AND tasks.parent_id IN(
99 INNER JOIN opportunities_contacts oc on o.id = oc.opportunity_id
100 AND oc.contact_id = '".$params['bean_id']."')