2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
41 require_once('include/Dashlets/DashletGeneric.php');
44 class MyCallsDashlet extends DashletGeneric {
45 function MyCallsDashlet($id, $def = null) {
46 global $current_user, $app_strings;
47 require('modules/Calls/Dashlets/MyCallsDashlet/MyCallsDashlet.data.php');
49 parent::DashletGeneric($id, $def);
51 if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_CALLS', 'Calls');
52 $this->searchFields = $dashletData['MyCallsDashlet']['searchFields'];
53 if(empty($def['filters'])){
54 if(isset($this->searchFields['status'])){
55 if(!empty($this->searchFields['status']['default'])){
56 $this->filters['status'] = $this->searchFields['status']['default'];
60 $this->columns = $dashletData['MyCallsDashlet']['columns'];
61 $this->columns['set_accept_links']= array('width' => '10',
62 'label' => translate('LBL_ACCEPT_THIS', 'Meetings'),
64 'related_fields' => array('status'),
66 $this->seedBean = new Call();
70 function process($lvsParams = array()) {
71 global $current_language, $app_list_strings, $current_user;
72 $mod_strings = return_module_language($current_language, 'Calls');
74 // handle myitems only differently -- set the custom query to show assigned meetings and invitee meetings
75 if($this->myItemsOnly) {
76 //join with meeting_users table to process related users
77 $this->seedBean->listview_inner_join = array('LEFT JOIN calls_users c_u on c_u.call_id = calls.id');
79 //set the custom query to include assigned meetings
80 $lvsParams['custom_where'] = ' AND (calls.assigned_user_id = \'' . $current_user->id . '\' OR c_u.user_id = \'' . $current_user->id . '\' AND c_u.deleted = 0) ';
83 $this->myItemsOnly = false;
84 //query needs to be distinct to avoid multiple records being returned for the same meeting (one for each invited user),
85 //so we need to make sure date entered is also set so the sort can work with the group by
86 $lvsParams['custom_select']=', calls.date_entered ';
87 $lvsParams['distinct']=true;
89 parent::process($lvsParams);
92 foreach($this->lvs->data['data'] as $num => $row) {
98 $query = "SELECT call_id, accept_status FROM calls_users WHERE deleted = 0 and user_id = '" . $current_user->id . "' AND call_id IN ('" . implode("','", $keys ). "')";
99 $result = $GLOBALS['db']->query($query);
101 while($row = $GLOBALS['db']->fetchByAssoc($result)) {
102 $rowNums = $this->lvs->data['pageData']['idIndex'][$row['call_id']]; // figure out which rows have this guid
103 foreach($rowNums as $rowNum) {
104 $this->lvs->data['data'][$rowNum]['ACCEPT_STATUS'] = $row['accept_status'];
109 foreach($this->lvs->data['data'] as $rowNum => $row) {
110 if(empty($this->lvs->data['data'][$rowNum]['DURATION_HOURS'])) $this->lvs->data['data'][$rowNum]['DURATION'] = '0' . $mod_strings['LBL_HOURS_ABBREV'];
111 else $this->lvs->data['data'][$rowNum]['DURATION'] = $this->lvs->data['data'][$rowNum]['DURATION_HOURS'] . $mod_strings['LBL_HOURS_ABBREV'];
113 if(empty($this->lvs->data['data'][$rowNum]['DURATION_MINUTES']) || empty($this->seedBean->minutes_values[$this->lvs->data['data'][$rowNum]['DURATION_MINUTES']])) {
114 $this->lvs->data['data'][$rowNum]['DURATION'] .= '00';
117 $this->lvs->data['data'][$rowNum]['DURATION'] .= $this->seedBean->minutes_values[$this->lvs->data['data'][$rowNum]['DURATION_MINUTES']];
119 if ($this->lvs->data['data'][$rowNum]['STATUS'] == $app_list_strings['meeting_status_dom']['Planned'])
121 if ($this->lvs->data['data'][$rowNum]['ACCEPT_STATUS'] == ''){
122 //if no status has been set, then do not show accept options
123 $this->lvs->data['data'][$rowNum]['SET_ACCEPT_LINKS'] = "<div id=\"accept".$this->id."\" ></div>";
124 }elseif($this->lvs->data['data'][$rowNum]['ACCEPT_STATUS'] == 'none')
126 $this->lvs->data['data'][$rowNum]['SET_ACCEPT_LINKS'] = "<div id=\"accept".$this->id."\"><a title=\"".$app_list_strings['dom_meeting_accept_options']['accept'].
127 "\" href=\"javascript:SUGAR.util.retrieveAndFill('index.php?module=Activities&to_pdf=1&action=SetAcceptStatus&id=".$this->id."&object_type=Call&object_id=".$this->lvs->data['data'][$rowNum]['ID'] . "&accept_status=accept', null, null, SUGAR.mySugar.retrieveDashlet, '{$this->id}');\">".
128 SugarThemeRegistry::current()->getImage("accept_inline","alt='".$app_list_strings['dom_meeting_accept_options']['accept'].
129 "' border='0'"). "</a> <a title=\"".$app_list_strings['dom_meeting_accept_options']['tentative'].
130 "\" href=\"javascript:SUGAR.util.retrieveAndFill('index.php?module=Activities&to_pdf=1&action=SetAcceptStatus&id=".$this->id."&object_type=Call&object_id=".$this->lvs->data['data'][$rowNum]['ID'] . "&accept_status=tentative', null, null, SUGAR.mySugar.retrieveDashlet, '{$this->id}');\">".
131 SugarThemeRegistry::current()->getImage("tentative_inline","alt='".$app_list_strings['dom_meeting_accept_options']['tentative']."' border='0'").
132 "</a> <a title=\"".$app_list_strings['dom_meeting_accept_options']['decline'].
133 "\" href=\"javascript:SUGAR.util.retrieveAndFill('index.php?module=Activities&to_pdf=1&action=SetAcceptStatus&id=".$this->id."&object_type=Call&object_id=".$this->lvs->data['data'][$rowNum]['ID'] . "&accept_status=decline', null, null, SUGAR.mySugar.retrieveDashlet, '{$this->id}');\">".
134 SugarThemeRegistry::current()->getImage("decline_inline","alt='".$app_list_strings['dom_meeting_accept_options']['decline'].
135 "' border='0'")."</a></div>";
139 $this->lvs->data['data'][$rowNum]['SET_ACCEPT_LINKS'] = $app_list_strings['dom_meeting_accept_status'][$this->lvs->data['data'][$rowNum]['ACCEPT_STATUS']];
144 $this->lvs->data['data'][$rowNum]['DURATION'] .= $mod_strings['LBL_MINSS_ABBREV'];
146 $this->displayColumns[]= "set_accept_links";
149 function displayOptions() {
150 $this->processDisplayOptions();
151 $this->configureSS->assign('strings', array('general' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_GENERAL'],
152 'filters' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_FILTERS'],
153 'myItems' => translate('LBL_DASHLET_CONFIGURE_MY_ITEMS_ONLY', 'Calls'),
154 'displayRows' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_DISPLAY_ROWS'],
155 'title' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_TITLE'],
156 'save' => $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'],
157 'autoRefresh' => $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH'],
159 return $this->configureSS->fetch($this->configureTpl);