]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Calendar/templates/templates_calendar.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Calendar / templates / templates_calendar.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4
5 /*********************************************************************************
6  * SugarCRM is a customer relationship management program developed by
7  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8  * 
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Affero General Public License version 3 as published by the
11  * Free Software Foundation with the addition of the following permission added
12  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
13  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
14  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15  * 
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
19  * details.
20  * 
21  * You should have received a copy of the GNU Affero General Public License along with
22  * this program; if not, see http://www.gnu.org/licenses or write to the Free
23  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24  * 02110-1301 USA.
25  * 
26  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
27  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28  * 
29  * The interactive user interfaces in modified source and object code versions
30  * of this program must display Appropriate Legal Notices, as required under
31  * Section 5 of the GNU Affero General Public License version 3.
32  * 
33  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
34  * these Appropriate Legal Notices must retain the display of the "Powered by
35  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
36  * technical reasons, the Appropriate Legal Notices must display the words
37  * "Powered by SugarCRM".
38  ********************************************************************************/
39
40 /////////////////////////////////
41 // template
42 /////////////////////////////////
43 global $timedate;
44 function template_cal_tabs(& $args) {
45         global $mod_strings, $sugar_version, $sugar_config;
46         $tabs = array('day', 'week', 'month', 'year', 'shared');
47
48         if($args['view'] != 'day') {
49                 echo '<script type="text/javascript" src="' . getJSPath('include/javascript/sugar_grp_overlib.js') . '"></script>
50                         <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
51         }
52
53 ?>
54 <table id="cal_tabs" width="100%" border="0" cellpadding="0" cellspacing="0">
55 <tr>
56 <td>
57 <?php
58
59         $time_arr = array();
60
61         foreach($tabs as $tab) {
62 ?>
63 <input type="button" <?php if($args['view'] == $tab) {?>selected="selected" <?php } ?> value=" <?php echo $mod_strings["LBL_".$args['calendar']->get_view_name($tab)]; ?> " title="<?php echo $mod_strings["LBL_".$args['calendar']->get_view_name($tab)]; ?>" onclick="window.location.href='index.php?module=Calendar&action=index&view=<?php echo $tab; ?><?php echo $args['calendar']->date_time->get_date_str(); ?>'">&nbsp;
64 <?php } ?>
65 </td>
66 </tr>
67 </table>
68
69 <?php
70
71         }
72
73         /////////////////////////////////
74         // template
75         /////////////////////////////////
76         function template_cal_month_slice(& $args) {
77 ?>
78 <?php
79
80                 template_echo_slice_date($args);
81                 $newargs = array();
82                 $cal_arr = array();
83                 $cal_arr['month'] = $args['slice']->start_time->month;
84                 $cal_arr['year'] = $args['slice']->start_time->year;
85                 $newargs['calendar'] = new Calendar('month', $cal_arr);
86                 $newargs['calendar']->show_only_current_slice = true;
87                 $newargs['calendar']->show_activities = false;
88                 $newargs['calendar']->show_week_on_month_view = false;
89                 template_calendar_month($newargs);
90 ?>
91 <?php
92
93         }
94
95         /////////////////////////////////
96         // template
97         /////////////////////////////////
98         function template_echo_slice_activities(& $args) {
99                 global $app_list_strings, $current_user, $app_strings;
100
101                 $count = 0;
102
103                 if(empty($args['slice']->acts_arr[$current_user->id])) {
104                         return;
105                 }
106                 foreach($args['slice']->acts_arr[$current_user->id] as $act) {
107                         $fields = array();
108                         foreach($act->sugar_bean->field_name_map as $field) {
109                                         if(!empty($act->sugar_bean->$field['name']))
110                                                 $fields[strtoupper($field['name'])] = $act->sugar_bean->$field['name'];
111                         }
112                         if($act->sugar_bean->ACLAccess('DetailView') && file_exists('modules/' . $act->sugar_bean->module_dir . '/metadata/additionalDetails.php')) {
113                                 require_once('modules/' . $act->sugar_bean->module_dir . '/metadata/additionalDetails.php');
114                                 $ad_function = 'additionalDetails' . $act->sugar_bean->object_name;
115                                 $results = $ad_function($fields);
116                                 $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
117
118                                 if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
119                         }
120
121                         $extra = "onmouseover=\"return overlib('" .
122                                         str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string'])
123                                         . "', CAPTION, '{$app_strings['LBL_ADDITIONAL_DETAILS']}"
124                                         . "', DELAY, 200, STICKY, MOUSEOFF, 1000, WIDTH, "
125                                         .(empty($results['width']) ? '300' : $results['width'])
126                                         . ", CLOSETEXT, '<img border=0  style=\'margin-left:2px; margin-right: 2px;\' src=".SugarThemeRegistry::current()->getImageURL('close.gif').">', "
127                                         . "CLOSETITLE, '{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}', CLOSECLICK, FGCLASS, 'olFgClass', "
128                                         . "CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\" "
129                                         . "onmouseout=\"return nd(1000);\" ";
130
131
132                         $count ++;
133                         echo '<div style="margin-top: 1px;"><table cellpadding="0" cellspacing="0"
134                                         border="0" width="100%"><tr>';
135                         if($act->sugar_bean->object_name == 'Call') {
136                             if ( isset($app_list_strings['call_status_dom'][$act->sugar_bean->status]) ) {
137                                 $callStatus = $app_list_strings['call_status_dom'][$act->sugar_bean->status];
138                             }
139                             else {
140                                 $callStatus = '';
141                             }
142                                 echo '<td>' . SugarThemeRegistry::current()->getImage('Calls','alt="'.$app_list_strings['call_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'"') . '</td>
143                                                 <td width="100%"><a ' . $extra . ' href="index.php?module=Calls&action=DetailView&record=' .
144                                                 $act->sugar_bean->id . '">' . $callStatus . ': ' . $act->sugar_bean->name . '</a></td>';
145                         } else if($act->sugar_bean->object_name == 'Meeting') {
146                                 if ( isset($app_list_strings['meeting_status_dom'][$act->sugar_bean->status]) ) {
147                                 $meetingStatus = $app_list_strings['meeting_status_dom'][$act->sugar_bean->status];
148                             }
149                             else {
150                                 $meetingStatus = '';
151                             }
152                                 $out = '<td>' . SugarThemeRegistry::current()->getImage('Meetings','alt="'.$app_list_strings['meeting_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'"') . '</td>
153                                                 <td width="100%"><a ' . $extra . ' href="index.php?module=Meetings&action=DetailView&record=' .
154                                                 $act->sugar_bean->id . '">' . $meetingStatus . ': ' . $act->sugar_bean->name .'</a>';
155
156                                 ///////////////////////////////////////////////////////////////
157                                 ////    MEETING INTEGRATION
158                                 if(method_exists($act->sugar_bean, 'hasIntegratedMeeting')) {
159                                         if($act->sugar_bean->hasIntegratedMeeting()) {
160                                                 $out .= $act->sugar_bean->miIcon;
161                                         }
162                                 }
163                                 ////    END MEETING INTEGRATION
164                                 ///////////////////////////////////////////////////////////////
165                                 $out .= "</td>";
166                                 echo $out;
167
168                         } else if($act->sugar_bean->object_name == 'Task') {
169                                 echo '<td>' .  SugarThemeRegistry::current()->getImage('Tasks','alt="'.$app_list_strings['task_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'"') . '</td>
170                                                 <td width="100%"><a ' . $extra . ' href="index.php?module=Tasks&action=DetailView&record=' . $act->sugar_bean->id . '">'.$app_list_strings['task_status_dom'][$fields['STATUS']].': ' . $act->sugar_bean->name . '</a></td>';
171                         }
172                         echo '</tr></table><div>';
173                 }
174         }
175
176         function template_echo_slice_activities_shared(& $args) {
177                 global $app_list_strings;
178
179                 global $shared_user, $timedate;
180                 $count = 0;
181                 if(empty($args['slice']->acts_arr[$shared_user->id])) {
182                         return;
183                 }
184
185                 $out = '';
186
187                 foreach($args['slice']->acts_arr[$shared_user->id] as $act) {
188                         $count ++;
189                         echo "<div style=\"margin-top: 1px;\">
190                         <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
191
192                         if($act->sugar_bean->object_name == 'Call') {
193                                 echo "<tr><td>" . SugarThemeRegistry::current()->getImage('Calls','alt=\"'.$app_list_strings['call_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'\"') . "</td>";
194
195                                 if(empty($act->sugar_bean->name)) {
196                                         echo "<td width=\"100%\">";
197                                         echo $timedate->getTimePart($act->sugar_bean->date_start); 
198                                         echo "</td></tr>";
199                                 } else {
200                                         echo "<td width=\"100%\">
201                                                 <a href=\"index.php?module=Calls&action=DetailView&record=".
202                                                 $act->sugar_bean->id."\">".
203                                                 $app_list_strings['call_status_dom'][$act->sugar_bean->status].": ".
204                                                 $act->sugar_bean->name."<br>(".
205                                                 $timedate->getTimePart($act->sugar_bean->date_start).")</a></td></tr>";
206                                 }
207                         } else if($act->sugar_bean->object_name == 'Meeting') {
208                                 echo "<td>".
209                                         SugarThemeRegistry::current()->getImage('Meetings','alt=\"'.$app_list_strings['meeting_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'\"');
210                                 echo "</td>";
211
212                                 if(empty($act->sugar_bean->name)) {
213                                         echo "<td width=\"100%\">".
214                                                 $timedate->getTimePart($act->sugar_bean->date_start); 
215                                         echo "</td></tr>";
216                                 } else {
217                                         echo "<td width=\"100%\">
218                                                 <a href=\"index.php?module=Meetings&action=DetailView&record=".
219                                                 $act->sugar_bean->id."\">".
220                                                 $app_list_strings['meeting_status_dom'][$act->sugar_bean->status].":".
221                                                 $act->sugar_bean->name."<br>(".
222                                                 $timedate->getTimePart($act->sugar_bean->date_start).")</a>";
223                                                 
224                                         // MEETING INTEGRATION
225                                         if($act->sugar_bean->hasIntegratedMeeting()) {
226                                                 $out .= $act->sugar_bean->miIcon;
227                                         }
228                                         // END MEETING INTEGRATION
229
230                                         $out .= "</td></tr>";
231                                         echo $out;
232                                 }
233                         } else if($act->sugar_bean->object_name == 'Task') {
234                                 echo "<td>".
235                                         SugarThemeRegistry::current()->getImage('Tasks','alt="'.$act->sugar_bean->status.': '.$act->sugar_bean->name.'"');
236                                 echo "</td>";
237
238                                 if(empty($act->sugar_bean->name)) {
239                                         echo "<td width=\"100%\">".
240                                                 $timedate->getTimePart($act->sugar_bean->date_due); 
241                                         echo "</td></tr>";
242                                 } else {
243                                         echo "<td width=\"100%\">
244                                                 <a href=\"index.php?module=Tasks&action=DetailView&record=".
245                                                 $act->sugar_bean->id."\">".
246                                                 $act->sugar_bean->status.': '.$act->sugar_bean->name."<br>(".
247                                                 $timedate->getTimePart($act->sugar_bean->date_due).")</a></td></tr>";
248                                 }
249                         }
250                         echo "</table></div>";
251                 }
252         }
253
254         /////////////////////////////////
255         // template
256         /////////////////////////////////
257         function template_cal_day_slice(& $args) {
258                 /*
259                         echo "cale:".$args['calendar']->view;
260                         echo "cal1:".$args['calendar']->date_time->month;
261                         echo "cal3:".$args['slice']->date_time->month;
262                 */
263                 if($args['calendar']->show_only_current_slice == false || $args['calendar']->date_time->month == $args['slice']->start_time->month) {
264                         template_echo_slice_date($args);
265
266                         if($args['calendar']->show_activities == true) {
267                                 template_echo_slice_activities($args);
268                         }
269
270                 }
271         }
272
273         /////////////////////////////////
274         // template
275         /////////////////////////////////
276         function template_calendar(& $args) {
277                 global $timedate;
278                 if(isset($args['size']) && $args['size'] = 'small') {
279                         $args['calendar']->show_activities = false;
280                         $args['calendar']->show_week_on_month_view = false;
281                 }
282
283                 $newargs = array();
284                 $newargs['view'] = $args['view'];
285                 $newargs['calendar'] = $args['calendar'];
286                 if(!isset($args['size']) || $args['size'] != 'small') {
287                         template_cal_tabs($newargs);
288                 }
289
290                 if(isset($_REQUEST['view']) && $_REQUEST['view'] == 'shared') {
291                         global $ids;
292                         global $current_user;
293                         global $mod_strings;
294                         global $app_list_strings, $current_language, $currentModule, $action, $app_strings;
295                         $current_module_strings = return_module_language($current_language, 'Calendar');
296
297                         $ids = array();
298                         $user_ids = $current_user->getPreference('shared_ids');
299                         //get list of user ids for which to display data
300                         if(!empty($user_ids) && count($user_ids) != 0 && !isset($_REQUEST['shared_ids'])) {
301                                 $ids = $user_ids;
302                         }
303                         elseif(isset($_REQUEST['shared_ids']) && count($_REQUEST['shared_ids']) > 0) {
304                                 $ids = $_REQUEST['shared_ids'];
305                                 $current_user->setPreference('shared_ids', $_REQUEST['shared_ids']);
306                         } else {
307                                 //$ids = get_user_array(false);
308                                 //$ids = array_keys($ids);
309                                 $ids = array($current_user->id);
310
311                         }
312
313
314                         //get team id for which to display user list
315
316                         $tools = '<div align="right"><a href="index.php?module='.$currentModule.'&action='.$action.'&view=shared" class="tabFormAdvLink">&nbsp;<a href="javascript: toggleDisplay(\'shared_cal_edit\');" class="tabFormAdvLink">'.SugarThemeRegistry::current()->getImage('edit', 'alt="'.$current_module_strings['LBL_EDIT'].'"  border="0"  align="absmiddle"').'&nbsp;'.$current_module_strings['LBL_EDIT'].'</a></div>';
317
318                         echo get_form_header($mod_strings['LBL_SHARED_CAL_TITLE'], $tools, false);
319                         if(empty($_SESSION['shared_ids']))
320                                 $_SESSION['shared_ids'] = "";
321
322                         echo "
323                         <script language=\"javascript\">
324                         function up(name) {
325                                 var td = document.getElementById(name+'_td');
326                                 var obj = td.getElementsByTagName('select')[0];
327                                 obj =(typeof obj == \"string\") ? document.getElementById(obj) : obj;
328                                 if(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)
329                                         return false;
330                                 var sel = new Array();
331
332                                 for(i=0; i<obj.length; i++) {
333                                         if(obj[i].selected == true) {
334                                                 sel[sel.length] = i;
335                                         }
336                                 }
337                                 for(i in sel) {
338                                         if(sel[i] != 0 && !obj[sel[i]-1].selected) {
339                                                 var tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value);
340                                                 obj[sel[i]-1].text = obj[sel[i]].text;
341                                                 obj[sel[i]-1].value = obj[sel[i]].value;
342                                                 obj[sel[i]].text = tmp[0];
343                                                 obj[sel[i]].value = tmp[1];
344                                                 obj[sel[i]-1].selected = true;
345                                                 obj[sel[i]].selected = false;
346                                         }
347                                 }
348                         }
349
350                         function down(name) {
351                                 var td = document.getElementById(name+'_td');
352                                 var obj = td.getElementsByTagName('select')[0];
353                                 if(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)
354                                         return false;
355                                 var sel = new Array();
356                                 for(i=obj.length-1; i>-1; i--) {
357                                         if(obj[i].selected == true) {
358                                                 sel[sel.length] = i;
359                                         }
360                                 }
361                                 for(i in sel) {
362                                         if(sel[i] != obj.length-1 && !obj[sel[i]+1].selected) {
363                                                 var tmp = new Array(obj[sel[i]+1].text, obj[sel[i]+1].value);
364                                                 obj[sel[i]+1].text = obj[sel[i]].text;
365                                                 obj[sel[i]+1].value = obj[sel[i]].value;
366                                                 obj[sel[i]].text = tmp[0];
367                                                 obj[sel[i]].value = tmp[1];
368                                                 obj[sel[i]+1].selected = true;
369                                                 obj[sel[i]].selected = false;
370                                         }
371                                 }
372                         }
373                         </script>
374
375                         <div id='shared_cal_edit' style='display: none;'>
376                         <form name='shared_cal' action=\"index.php\" method=\"post\" >
377                         <input type=\"hidden\" name=\"module\" value=\"".$currentModule."\">
378                         <input type=\"hidden\" name=\"action\" value=\"".$action."\">
379                         <input type=\"hidden\" name=\"view\" value=\"shared\">
380                         <input type=\"hidden\" name=\"edit\" value=\"0\">
381                         <table cellpadding=\"0\" cellspacing=\"3\" border=\"0\" align=\"center\">
382                         <tr><th valign=\"top\"  align=\"center\" colspan=\"2\">
383                         ";
384
385                         echo $current_module_strings['LBL_SELECT_USERS'];
386                         echo "
387                         </th>
388                         </tr>
389                         <tr><td valign=\"top\">";
390                         echo "
391             </td><td valign=\"top\">
392
393                         <table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"edit view\" align=\"center\">
394                         <tr>
395                                 <td valign='top' nowrap><b>".$current_module_strings['LBL_USERS']."</b></td>
396                                 <td valign='top' id=\"shared_ids_td\"><select id=\"shared_ids\" name=\"shared_ids[]\" multiple size='3'>";
397
398                                 echo get_select_options_with_id(get_user_array(false), $ids);
399
400                         echo "  </select></td>
401                                 <td><a onclick=\"up('shared_ids');\">".SugarThemeRegistry::current()->getImage('uparrow_big', 'border="0" style="margin-bottom: 1px;" alt="'.$app_strings['LBL_SORT'].'"')."</a><br>
402                                 <a onclick=\"down('shared_ids');\">".SugarThemeRegistry::current()->getImage('downarrow_big', 'border="0" style="margin-top: 1px;"  alt="'.$app_strings['LBL_SORT'].'"')."</a></td>
403                         </tr>
404                         <tr>";
405                         echo "<td align=\"right\" colspan=\"2\"><input class=\"button\" type=\"submit\" title=\"".$app_strings['LBL_SELECT_BUTTON_TITLE']."\" accessKey=\"".$app_strings['LBL_SELECT_BUTTON_KEY']."\" value=\"".$app_strings['LBL_SELECT_BUTTON_LABEL']."\" /><input class=\"button\" onClick=\"javascript: toggleDisplay('shared_cal_edit');\" type=\"button\" title=\"".$app_strings['LBL_CANCEL_BUTTON_TITLE']."\" accessKey=\"".$app_strings['LBL_CANCEL_BUTTON_KEY']."\" value=\"".$app_strings['LBL_CANCEL_BUTTON_LABEL']."\"/></td>
406                         </tr>
407                         </table>
408                         </td></tr>
409                         </table>
410                         </form>";
411
412                 } // end "shared" view
413
414                 echo "</div></p>";
415
416                 if(isset($_REQUEST['edit']) && $_REQUEST['edit'])
417                         echo " <script language=\"javascript\"> toggleDisplay('shared_cal_edit'); </script>";
418
419                 echo "
420                 <table id=\"daily_cal_table_outside\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthBox\">
421                 <tr>
422                 <td>
423                   <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthHeader\">
424                   <tr>
425                   <td width=\"1%\" nowrap>";
426
427                 if(!isset($args['size']) || $args['size'] != 'small') {
428                         template_get_previous_calendar($args);
429                 }
430
431                 echo "
432                   </td>
433                   <td width=\" 98 % \" align=center scope='row'>";
434
435                 if(isset( $args['size']) && $args['size'] = 'small')
436                 {
437                 ?>
438                 <a style="text-decoration: none;"
439                         href="index.php?module=Calendar&action=index&view=month&<?php echo $args['calendar']->date_time->get_date_str();?>">
440 <?php
441
442         }
443 ?>
444 <h3>
445 <?php template_echo_date_info($args['view'],$args['calendar']->date_time); ?>
446 </h3>
447 <?php
448
449         if(isset($args['size']) && $args['size'] = 'small') {
450                 echo "</a>";
451         }
452 ?>
453
454   </td>
455   <td align="right" width="1%" nowrap><?php
456
457
458         if(!isset($args['size']) || $args['size'] != 'small') {
459                 template_get_next_calendar($args);
460         }
461 ?> </td>
462   </tr>
463   </table>
464 </td>
465 </tr>
466 <tr>
467 <td class="monthCalBody">
468 <?php
469
470         if($args['calendar']->view == 'month') {
471                 template_calendar_month($args);
472         } else
473                 if($args['calendar']->view == 'year') {
474                         template_calendar_year($args);
475                 } else
476                         if($args['calendar']->view == 'shared') {
477
478                                 global $current_user, $shared_user;
479                                 $shared_args = array();
480                                 foreach($args as $key => $val) {
481                                         $shared_args[$key] = $val;
482                                 }
483                                 $shared_args['calendar'] = $args['calendar'];
484                                 $shared_user = new User();
485                                 foreach($ids as $member) {
486                                         $shared_user->retrieve($member);
487                                         $shared_args['calendar']->show_tasks = true;
488                                         $shared_args['calendar']->add_activities($shared_user);
489                                         $shared_args['show_link'] = 'off';
490                                         if(($shared_user->id == $current_user->id))
491                                                 $shared_args['show_link'] = 'on';
492                                         echo '<h5 class="calSharedUser">'.$shared_user->full_name.'</h5>';
493                                         template_calendar_horizontal($shared_args);
494                                 }
495                         } else {
496                                 template_calendar_vertical($args);
497                         }
498 ?>
499 </td>
500 </tr>
501 <tr>
502 <td>
503   <table width="100%" cellspacing="0" cellpadding="0" class="monthFooter">
504   <tr>
505   <td width="50%"><?php template_get_previous_calendar($args); ?></td>
506   <td align="right" width="50%"><?php template_get_next_calendar($args); ?></td>
507   </tr>
508   </table>
509
510 </td>
511 </tr>
512 </table>
513 <?php
514
515
516 }
517
518 function template_calendar_vertical(& $args) {
519 ?>
520   <table id="daily_cal_table" border="0" cellpadding="0" cellspacing="1" width="100%">
521   <?php
522
523         // need to change these values after we find out what activities
524         // occur outside of these values
525         $start_slice_idx = $args['calendar']->get_start_slice_idx();
526         $end_slice_idx = $args['calendar']->get_end_slice_idx();
527         $cur_slice_idx = 1;
528         for($cur_slice_idx = $start_slice_idx; $cur_slice_idx <= $end_slice_idx; $cur_slice_idx ++) {
529                 $calendar = $args['calendar'];
530                 $args['slice'] = $calendar->slice_hash[$calendar->slices_arr[$cur_slice_idx]];
531 ?>
532   <tr>
533   <?php template_cal_vertical_slice($args); ?>
534   </tr>
535   <?php
536
537         }
538 ?>
539   </table>
540 <?php
541
542 }
543
544 function template_calendar_horizontal(& $args) {
545         echo "<table id=\"daily_cal_table\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\"><tr>";
546
547         // need to change these values after we find out what activities
548         // occur outside of these values
549         $start_slice_idx = $args['calendar']->get_start_slice_idx();
550         $end_slice_idx = $args['calendar']->get_end_slice_idx();
551         $cur_slice_idx = 1;
552         for($cur_slice_idx = $start_slice_idx; $cur_slice_idx <= $end_slice_idx; $cur_slice_idx ++) {
553                 $calendar = $args['calendar'];
554                 $args['slice'] = $calendar->slice_hash[$calendar->slices_arr[$cur_slice_idx]];
555
556                 template_cal_horizontal_slice($args);
557         }
558
559         echo "</tr></table>";
560 }
561
562 function template_cal_vertical_slice(& $args) {
563         global $timedate;
564 ?>
565 <th width="1%" id="bodytime">
566 <?php template_echo_slice_date($args) ; ?>
567
568 </td>
569 <td width="99%" id="bodyitem">
570
571 <div style="display:none;" id='<?php echo template_echo_daily_view_24_hour($args); ?>_appt'> <?php
572
573         require_once('modules/Calls/CallFormBase.php');
574         $callForm = new CallFormBase();
575         echo $callForm->getFormBody('', 'Calls', 'inlineCal'.template_echo_daily_view_24_hour($args).'CallSave', $timedate->to_display_date($args['calendar']->date_time->get_mysql_date(), false), $timedate->to_display_time(template_echo_daily_view_24_hour($args).':00:00', true, false))."<br>";
576 ?></div>
577
578 <?php template_echo_slice_activities($args); ?>
579 </td>
580 <?php
581
582 }
583
584 function template_cal_horizontal_slice(& $args) {
585         echo "<td width=\"14%\" id=\"bodyItem\" scope='row' valign=\"top\">";
586
587         if($args['show_link'] == 'on') {
588                 template_echo_slice_date($args);
589         } else {
590                 template_echo_slice_date_nolink($args);
591         }
592
593         template_echo_slice_activities_shared($args);
594
595         echo "</td>";
596 }
597
598 function template_calendar_year(& $args) {
599         $count = 0;
600 ?>
601 <table cellspacing="0" cellpadding="0" border="0" width="100%">
602 <tr>
603     <td class="yearCalBody">
604   <table id="daily_cal_table" border="0" cellpadding="0"  cellspacing="1" width="100%">
605 <?php
606
607
608         for($i = 0; $i < 4; $i ++) {
609 ?>
610 <tr>
611 <?php
612
613                 for($j = 0; $j < 3; $j ++) {
614                         $args['slice'] = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]];
615 ?>
616
617 <td valign="top" align="center" scope='row' class="yearCalBodyMonth"><?php template_cal_month_slice($args); ?></td>
618
619 <?php
620
621                         $count ++;
622                 }
623 ?>
624 </tr>
625 <?php
626
627         }
628 ?>
629 </table>
630 </td>
631 </tr>
632 </table>
633
634 <?php
635
636 }
637
638 function template_calendar_month(& $args) {
639         global $mod_strings;
640 ?>
641
642 <table width="100%" id="daily_cal_table" border="0" cellspacing="1" cellpadding="0" >
643   <?php
644
645         // need to change these values after we find out what activities
646         // occur outside of these values
647         /*
648           $start_slice_idx = $args['calendar']->get_start_slice_idx();
649           $end_slice_idx = $args['calendar']->get_end_slice_idx();
650           $cur_slice_idx = 1;
651         */
652         $count = 0;
653         if($args['calendar']->slice_hash[$args['calendar']->slices_arr[35]]->start_time->month != $args['calendar']->date_time->month) {
654                 $rows = 5;
655         } else {
656                 $rows = 6;
657         }
658 ?>
659 <tr class="monthCalBodyTH">
660 <?php if($args['calendar']->show_week_on_month_view ) { ?>
661 <th width="1%" scope='row'><?php echo $mod_strings['LBL_WEEK']; ?></th>
662 <?php } ?>
663 <?php
664
665
666         for($i = 0; $i < 7; $i ++) {
667                 $first_row_slice = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$i]];
668 ?>
669 <th width="14%"><?php echo $first_row_slice->start_time->get_day_of_week_short(); ?></th>
670 <?php
671
672         }
673 ?>
674 </tr>
675 <?php
676
677
678         if(isset($_REQUEST['view']) && $_REQUEST['view'] == 'month') {
679                 $height_class = "monthViewDayHeight";
680         } else
681                 if(isset($args['size']) && $args['size'] == 'small') {
682                         $height_class = "";
683                 } else {
684                         $height_class = "monthViewDayHeight yearViewDayHeight";
685                 }
686
687         for($i = 0; $i < $rows; $i ++) {
688 ?>
689 <tr class="<?php echo $height_class; ?>">
690 <?php if($args['calendar']->show_week_on_month_view ) { ?>
691 <td scope='row'><a href="index.php?module=Calendar&action=index&view=week&<?php echo $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]]->start_time->get_date_str(); ?>"><?php echo $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count + 1]]->start_time->week; ?></a></td>
692 <?php } ?>
693 <?php
694
695                 for($j = 0; $j < 7; $j ++) {
696                         $args['slice'] = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]];
697 ?>
698
699 <td <?php if($j==0 || $j==6) { ?>class="weekEnd"<?php } ?>><?php  template_cal_day_slice($args); ?></td>
700
701 <?php
702
703                         $count ++;
704                 }
705 ?>
706 </tr>
707 <?php
708
709         }
710 ?>
711 </table>
712 <?php
713
714 }
715
716 function get_current_day(& $args) {
717         global $timedate;
718         static $user_today_timestamp = null;
719
720         // adjust for user's TZ
721         if(!isset($user_today_timestamp)) {
722             $gmt_today = $timedate->get_gmt_db_datetime();
723             $user_today = $timedate->handle_offset($gmt_today, $GLOBALS['timedate']->get_db_date_time_format());
724                 preg_match_all('/\d*/', $user_today, $matches);
725                 $matches = $matches[0];
726                 $user_today_timestamp = mktime($matches[6], $matches[8], '0', $matches[2], $matches[4], $matches[0]);
727         }
728
729         $slice = $args['slice'];
730         if($slice->start_time->get_mysql_date() == date($GLOBALS['timedate']->get_db_date_time_format(), $user_today_timestamp)) {
731                 return true;
732         }
733 }
734
735 function template_echo_daily_view_hour(& $args) {
736
737         $slice = $args['slice'];
738         $hour = $slice->start_time->get_hour();
739         return $hour;
740
741 }
742
743 function template_echo_daily_view_24_hour(& $args) {
744
745         $slice = $args['slice'];
746         $hour = $slice->start_time->get_24_hour();
747         return $hour;
748
749 }
750
751 function template_echo_slice_date(& $args) {
752         global $mod_strings;
753     global $timedate;
754         $slice = $args['slice'];
755
756         if($slice->view != 'hour') {
757                 if($slice->start_time->get_day_of_week_short() == 'Sun' || $slice->start_time->get_day_of_week_short() == 'Sat') {
758                         echo "<a href=\"index.php?module=Calendar&action=index&view=".$slice->get_view()."&".$slice->start_time->get_date_str()."\" ";
759                 } else {
760                         echo "<a href=\"index.php?module=Calendar&action=index&view=".$slice->get_view()."&".$slice->start_time->get_date_str()."\" ";
761                 }
762         }
763
764         if($slice->view == 'day' &&($args['calendar']->view == 'week')) {
765                 echo ">";
766                 echo $slice->start_time->get_day_of_week_short();
767                 echo "&nbsp;";
768                 echo $slice->start_time->get_day();
769         }
770         elseif($args['calendar']->view == 'shared') {
771                 echo ">";
772                 echo $slice->start_time->get_day_of_week_short();
773                 echo "&nbsp;";
774                 echo $slice->start_time->get_day();
775         } else
776                 if($slice->view == 'day') {
777                         echo ">";
778                         if($slice->start_time->get_month() == $args['calendar']->date_time->get_month()) {
779                                 echo $slice->start_time->get_day();
780                         }
781                         //echo $slice->start_time->get_day();
782                 } else
783                         if($slice->view == 'month') {
784                                 echo ">";
785                                 echo $slice->start_time->get_month_name();
786                         } else
787                                 if($slice->view == 'hour') {
788                                         if($args['calendar']->toggle_appt == true) {
789                                                 echo '<a href="javascript:void  toggleDisplay(\''.$slice->start_time->get_24_hour().'_appt\');">';
790                                         }
791                     //Bug 13324, We are now using the users time format instead of a custom AM/PM setting
792                     echo $timedate->to_display_time($slice->start_time->get_24_hour() . ":00:00", true, false);
793                                 } else {
794                                         sugar_die("template_echo_slice_date: view not supported");
795                                 }
796
797         echo "</a>";
798 }
799
800 function template_echo_slice_date_nolink(& $args) {
801         global $mod_strings;
802         $slice = $args['slice'];
803         echo $slice->start_time->get_day_of_week_short();
804         echo "&nbsp;";
805         echo $slice->start_time->get_day();
806 }
807
808 function template_echo_date_info($view, $date_time) {
809         global $current_user;
810         $dateFormat = $current_user->getUserDateTimePreferences();
811
812         if($view == 'month') {
813                 for($i=0; $i<strlen($dateFormat['date']); $i++) {
814                         switch($dateFormat['date']{$i}) {
815                                 case "Y":
816                                         echo " ".$date_time->year;
817                                         break;
818                                 case "m":
819                                         echo " ".$date_time->get_month_name();
820                                         break;
821                         }
822                 }
823         } else
824                 if($view == 'week' || $view == 'shared') {
825                         $first_day = $date_time->get_day_by_index_this_week(0);
826                         $last_day = $date_time->get_day_by_index_this_week(6);
827
828                         for($i=0; $i<strlen($dateFormat['date']); $i++) {
829                                 switch($dateFormat['date']{$i}) {
830                                         case "Y":
831                                                 echo " ".$first_day->year;
832                                                 break;
833                                         case "m":
834                                                 echo " ".$first_day->get_month_name();
835                                                 break;
836                                         case "d":
837                                                 echo " ".$first_day->get_day();
838                                                 break;
839                                 }
840                         }
841                         echo " - ";
842                         for($i=0; $i<strlen($dateFormat['date']); $i++) {
843                                 switch($dateFormat['date']{$i}) {
844                                         case "Y":
845                                                 echo " ".$last_day->year;
846                                                 break;
847                                         case "m":
848                                                 echo " ".$last_day->get_month_name();
849                                                 break;
850                                         case "d":
851                                                 echo " ".$last_day->get_day();
852                                                 break;
853                                 }
854                         }
855                 } else
856                         if($view == 'day') {
857                                 echo $date_time->get_day_of_week()." ";
858
859                                 for($i=0; $i<strlen($dateFormat['date']); $i++) {
860                                         switch($dateFormat['date']{$i}) {
861                                                 case "Y":
862                                                         echo " ".$date_time->year;
863                                                         break;
864                                                 case "m":
865                                                         echo " ".$date_time->get_month_name();
866                                                         break;
867                                                 case "d":
868                                                         echo " ".$date_time->get_day();
869                                                         break;
870                                         }
871                                 }
872                         } else
873                                 if($view == 'year') {
874                                         echo $date_time->year;
875                                 } else {
876                                         sugar_die("echo_date_info: date not supported");
877                                 }
878 }
879
880 function template_get_next_calendar(& $args) {
881
882         global $mod_strings;
883 ?>
884 <a href="index.php?action=index&module=Calendar&view=<?php echo $args['calendar']->view; ?>&<?php echo $args['calendar']->get_next_date_str(); ?>"><?php echo $mod_strings["LBL_NEXT_".$args['calendar']->get_view_name($args['calendar']->view)]; ?>&nbsp;<?php echo SugarThemeRegistry::current()->getImage('calendar_next','alt="'. $mod_strings["LBL_NEXT_".$args['calendar']->get_view_name($args['calendar']->view)].'" align="absmiddle" border="0"'); ?></a>
885 <?php
886
887 }
888
889 function template_get_previous_calendar(& $args) {
890         global $mod_strings;
891
892 ?>
893 <a href="index.php?action=index&module=Calendar&view=<?php echo $args['calendar']->view; ?>&<?php echo $args['calendar']->get_previous_date_str(); ?>"><?php echo SugarThemeRegistry::current()->getImage('calendar_previous','alt="'. $mod_strings["LBL_PREVIOUS_".$args['calendar']->get_view_name($args['calendar']->view)].'" align="absmiddle" border="0"'); ?>&nbsp;&nbsp;<?php echo $mod_strings["LBL_PREVIOUS_".$args['calendar']->get_view_name($args['calendar']->view)]; ?></a>
894 <?php
895
896 }
897 ?>
898