]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Meetings/Dashlets/MyMeetingsDashlet/MyMeetingsDashlet.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Meetings / Dashlets / MyMeetingsDashlet / MyMeetingsDashlet.php
1 <?php
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.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38
39
40
41
42 require_once('include/Dashlets/DashletGeneric.php');
43
44
45 class MyMeetingsDashlet extends DashletGeneric {
46     function MyMeetingsDashlet($id, $def = null) {
47         global $current_user, $app_strings;
48                 require('modules/Meetings/Dashlets/MyMeetingsDashlet/MyMeetingsDashlet.data.php');
49
50         parent::DashletGeneric($id, $def);
51
52         if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_MEETINGS', 'Meetings');
53
54         $this->searchFields = $dashletData['MyMeetingsDashlet']['searchFields'];
55         if(empty($def['filters'])){
56                         if(isset($this->searchFields['status'])){
57                                 if(!empty($this->searchFields['status']['default'])){
58                     $this->filters['status'] = $this->searchFields['status']['default'];
59                 }
60                         }
61         }
62         $this->columns = $dashletData['MyMeetingsDashlet']['columns'];
63
64         /*$this->columns['set_accept_links']= array('width'    => '10', 
65                                               'label'    => translate('LBL_ACCEPT_THIS', 'Meetings'),
66                                               'sortable' => false,
67                                               'default' => true,
68                                               'related_fields' => array('status'));*/
69         $this->hasScript = true;  // dashlet has javascript attached to it                
70
71         $this->seedBean = new Meeting();
72     }
73
74     function process($lvsParams = array()) {
75         global $current_language, $app_list_strings, $current_user;
76         $mod_strings = return_module_language($current_language, 'Meetings');
77
78         // handle myitems only differently --  set the custom query to show assigned meetings and invitee meetings
79         if($this->myItemsOnly) {
80                 //join with meeting_users table to process related users
81                 $this->seedBean->listview_inner_join = array('LEFT JOIN  meetings_users m_u on  m_u.meeting_id = meetings.id');
82                 //set the custom query to retrieve invitees AND assigned meetings            
83                 $lvsParams['custom_where'] = ' AND (meetings.assigned_user_id = \'' . $current_user->id . '\' OR m_u.user_id = \'' . $current_user->id . '\') AND m_u.deleted=0 ';
84         }
85
86         $this->myItemsOnly = false;
87                 //query needs to be distinct to avoid multiple records being returned for the same meeting (one for each invited user),
88                 //so we need to make sure date entered is also set so the sort can work with the group by
89                 $lvsParams['custom_select']=', meetings.date_entered ';
90                 $lvsParams['distinct']=true;
91
92         parent::process($lvsParams);
93
94         $keys = array();
95         foreach($this->lvs->data['data'] as $num => $row) {
96             $keys[] = $row['ID'];
97         }
98
99         // grab meeting status
100         if(!empty($keys)){
101             $query = "SELECT meeting_id, accept_status FROM meetings_users WHERE deleted = 0 AND user_id = '" . $current_user->id . "' AND meeting_id IN ('" . implode("','", $keys) . "')";
102             $result = $GLOBALS['db']->query($query);
103             while($row = $GLOBALS['db']->fetchByAssoc($result)) {
104                  $rowNums = $this->lvs->data['pageData']['idIndex'][$row['meeting_id']]; // figure out which rows have this guid
105                  foreach($rowNums as $rowNum) {
106                     $this->lvs->data['data'][$rowNum]['ACCEPT_STATUS'] = $row['accept_status'];
107                  }
108
109             }
110         }
111
112         foreach($this->lvs->data['data'] as $rowNum => $row) {
113
114             if(empty($this->lvs->data['data'][$rowNum]['DURATION_HOURS']))  $this->lvs->data['data'][$rowNum]['DURATION'] = '0' . $mod_strings['LBL_HOURS_ABBREV'];
115             else $this->lvs->data['data'][$rowNum]['DURATION'] = $this->lvs->data['data'][$rowNum]['DURATION_HOURS'] . $mod_strings['LBL_HOURS_ABBREV'];
116
117             if(empty($this->lvs->data['data'][$rowNum]['DURATION_MINUTES']) || empty($this->seedBean->minutes_values[$this->lvs->data['data'][$rowNum]['DURATION_MINUTES']])) {
118                 $this->lvs->data['data'][$rowNum]['DURATION'] .= '00';
119             }
120             else {
121                 $this->lvs->data['data'][$rowNum]['DURATION'] .= $this->seedBean->minutes_values[$this->lvs->data['data'][$rowNum]['DURATION_MINUTES']];
122             }
123             $this->lvs->data['data'][$rowNum]['DURATION'] .= $mod_strings['LBL_MINSS_ABBREV'];
124             if (!empty($this->lvs->data['data'][$rowNum]['STATUS']) && $this->lvs->data['data'][$rowNum]['STATUS'] == $app_list_strings['meeting_status_dom']['Planned'])
125             {
126                 if ($this->lvs->data['data'][$rowNum]['ACCEPT_STATUS'] == ''){
127                                         //if no status has been set, then do not show accept options
128                                         $this->lvs->data['data'][$rowNum]['SET_ACCEPT_LINKS'] = "<div id=\"accept".$this->id."\" class=\"acceptMeeting\"></div>";
129                                 }elseif($this->lvs->data['data'][$rowNum]['ACCEPT_STATUS'] == 'none')
130                 {
131                     $this->lvs->data['data'][$rowNum]['SET_ACCEPT_LINKS'] = "<div id=\"accept".$this->id."\" class=\"acceptMeeting\"><a title=\"".
132                         $app_list_strings['dom_meeting_accept_options']['accept'].
133                         "\" href=\"javascript:SUGAR.util.retrieveAndFill('index.php?module=Activities&to_pdf=1&action=SetAcceptStatus&id=".$this->id."&object_type=Meeting&object_id=".$this->lvs->data['data'][$rowNum]['ID'] . "&accept_status=accept', null, null, SUGAR.mySugar.retrieveDashlet, '{$this->id}');\">". 
134                         SugarThemeRegistry::current()->getImage("accept_inline","border='0'",null,null,'.gif',$app_list_strings['dom_meeting_accept_options']['accept']).
135                         "</a>&nbsp;<a title=\"".$app_list_strings['dom_meeting_accept_options']['tentative'].
136                         "\" href=\"javascript:SUGAR.util.retrieveAndFill('index.php?module=Activities&to_pdf=1&action=SetAcceptStatus&id=".$this->id."&object_type=Meeting&object_id=".$this->lvs->data['data'][$rowNum]['ID'] . "&accept_status=tentative', null, null, SUGAR.mySugar.retrieveDashlet, '{$this->id}');\">". 
137                         SugarThemeRegistry::current()->getImage("tentative_inline","border='0'",null,null,'.gif',$app_list_strings['dom_meeting_accept_options']['tentative']).
138                         "</a>&nbsp;<a title=\"".$app_list_strings['dom_meeting_accept_options']['decline'].
139                         "\" href=\"javascript:SUGAR.util.retrieveAndFill('index.php?module=Activities&to_pdf=1&action=SetAcceptStatus&id=".$this->id."&object_type=Meeting&object_id=".$this->lvs->data['data'][$rowNum]['ID'] . "&accept_status=decline', null, null, SUGAR.mySugar.retrieveDashlet, '{$this->id}');\">". 
140                         SugarThemeRegistry::current()->getImage("decline_inline","border='0'",null,null,'.gif',$app_list_strings['dom_meeting_accept_options']['decline'])."</a></div>";
141                 }    
142                 else
143                 {
144                     $this->lvs->data['data'][$rowNum]['SET_ACCEPT_LINKS'] = $app_list_strings['dom_meeting_accept_status'][$this->lvs->data['data'][$rowNum]['ACCEPT_STATUS']];
145
146                 }
147             }
148         }
149         $this->displayColumns[]= "set_accept_links";
150     }
151     /**
152      * Displays the javascript for the dashlet
153      *
154      * @return string javascript to use with this dashlet
155      */
156     function displayScript() {
157
158     }
159
160     function displayOptions() {
161         $this->processDisplayOptions();
162         $this->configureSS->assign('strings', array('general' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_GENERAL'],
163                                      'filters' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_FILTERS'],
164                                      'myItems' => translate('LBL_DASHLET_CONFIGURE_MY_ITEMS_ONLY', 'Meetings'),
165                                      'displayRows' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_DISPLAY_ROWS'],
166                                      'title' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_TITLE'],
167                                      'save' => $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'],
168                                      'autoRefresh' => $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH'],
169                                      'clear' => $GLOBALS['app_strings']['LBL_CLEAR_BUTTON_LABEL'],
170                                      ));
171
172         require_once('modules/Meetings/Meeting.php');
173         $types = getMeetingsExternalApiDropDown();
174         $this->currentSearchFields['type']['input'] = '<select size="3" multiple="true" name="type[]">'
175                                      . get_select_options_with_id($types, (empty($this->filters['type']) ? '' : $this->filters['type']))
176                                      . '</select>';
177         $this->configureSS->assign('searchFields', $this->currentSearchFields);
178
179         return $this->configureSS->fetch($this->configureTpl);
180     }
181
182     function saveStatus()
183     {
184
185     }
186 }
187
188 ?>