]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Calendar/templates/templates_calendar.php
Release 6.3.1
[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 Community Edition 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)]; ?> " id="<?php echo $tab; ?>_tab_id" 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                         
113                         $extra = "id=\"adspan_{$act->sugar_bean->id}\" "
114                                         . "onmouseover=\"return SUGAR.util.getAdditionalDetails( '{$act->sugar_bean->module_dir}','{$act->sugar_bean->id}', 'adspan_{$act->sugar_bean->id}');\" "
115                                         . "onmouseout=\"return SUGAR.util.clearAdditionalDetailsCall()\" onmouseout=\"return nd(1000);\" ";
116
117
118                         $count ++;
119                         echo '<div style="margin-top: 1px;"><table cellpadding="0" cellspacing="0"
120                                         border="0" width="100%"><tr>';
121                         if($act->sugar_bean->object_name == 'Call') {
122                             if ( isset($app_list_strings['call_status_dom'][$act->sugar_bean->status]) ) {
123                                 $callStatus = $app_list_strings['call_status_dom'][$act->sugar_bean->status];
124                             }
125                             else {
126                                 $callStatus = '';
127                             }
128                                 echo '<td>' . SugarThemeRegistry::current()->getImage('Calls','alt="'.$callStatus.': '.$act->sugar_bean->name.'"') . '</td>
129                                                 <td width="100%"><a ' . $extra . ' href="index.php?module=Calls&action=DetailView&record=' .
130                                                 $act->sugar_bean->id . '">' . $callStatus . ': ' . $act->sugar_bean->name . '</a></td>';
131                         } else if($act->sugar_bean->object_name == 'Meeting') {
132                                 if ( isset($app_list_strings['meeting_status_dom'][$act->sugar_bean->status]) ) {
133                                 $meetingStatus = $app_list_strings['meeting_status_dom'][$act->sugar_bean->status];
134                             }
135                             else {
136                                 $meetingStatus = '';
137                             }
138                                 $out = '<td>' . SugarThemeRegistry::current()->getImage('Meetings','alt="'.$meetingStatus.': '.$act->sugar_bean->name.'"') . '</td>
139                                                 <td width="100%"><a ' . $extra . ' href="index.php?module=Meetings&action=DetailView&record=' .
140                                                 $act->sugar_bean->id . '">' . $meetingStatus . ': ' . $act->sugar_bean->name .'</a>';
141
142                                 ///////////////////////////////////////////////////////////////
143                                 ////    MEETING INTEGRATION
144                                 if(method_exists($act->sugar_bean, 'hasIntegratedMeeting')) {
145                                         if($act->sugar_bean->hasIntegratedMeeting()) {
146                                                 $out .= $act->sugar_bean->miIcon;
147                                         }
148                                 }
149                                 ////    END MEETING INTEGRATION
150                                 ///////////////////////////////////////////////////////////////
151                                 $out .= "</td>";
152                                 echo $out;
153
154                         } else if($act->sugar_bean->object_name == 'Task') {
155                             if ( isset($app_list_strings['task_status_dom'][$act->sugar_bean->status]) ) 
156                             {
157                                 $taskStatus = $app_list_strings['task_status_dom'][$act->sugar_bean->status];
158                             }
159                             else 
160                             {
161                                 $taskStatus = '';
162                             }
163
164                             echo '<td>' .  SugarThemeRegistry::current()->getImage('Tasks','alt="'.$taskStatus.': '.$act->sugar_bean->name.'"') . '</td>
165                                                 <td width="100%"><a ' . $extra . ' href="index.php?module=Tasks&action=DetailView&record=' . $act->sugar_bean->id . '">'.$taskStatus.': ' . $act->sugar_bean->name . '</a></td>';
166                         }
167                         echo '</tr></table><div>';
168                 }
169         }
170
171         function template_echo_slice_activities_shared($args) {
172                 global $app_list_strings;
173
174                 global $shared_user, $timedate;
175                 $count = 0;
176                 if(empty($args['slice']->acts_arr[$shared_user->id])) {
177                         return;
178                 }
179
180                 $out = '';
181
182                 foreach($args['slice']->acts_arr[$shared_user->id] as $act) {
183                         $count ++;
184                         echo "<div style=\"margin-top: 1px;\">
185                         <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
186
187                         if($act->sugar_bean->object_name == 'Call') {
188                                 echo "<tr><td>" . SugarThemeRegistry::current()->getImage('Calls','alt=\"'.$app_list_strings['call_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'\"') . "</td>";
189
190                                 if(empty($act->sugar_bean->name)) {
191                                         echo "<td width=\"100%\">";
192                                         echo $timedate->getTimePart($act->sugar_bean->date_start);
193                                         echo "</td></tr>";
194                                 } else {
195                                         echo "<td width=\"100%\">
196                                                 <a href=\"index.php?module=Calls&action=DetailView&record=".
197                                                 $act->sugar_bean->id."\">".
198                                                 $app_list_strings['call_status_dom'][$act->sugar_bean->status].": ".
199                                                 $act->sugar_bean->name."<br>(".
200                                                 $timedate->getTimePart($act->sugar_bean->date_start).")</a></td></tr>";
201                                 }
202                         } else if($act->sugar_bean->object_name == 'Meeting') {
203                                 echo "<td>".
204                                         SugarThemeRegistry::current()->getImage('Meetings','alt=\"'.$app_list_strings['meeting_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'\"');
205                                 echo "</td>";
206
207                                 if(empty($act->sugar_bean->name)) {
208                                         echo "<td width=\"100%\">".
209                                                 $timedate->getTimePart($act->sugar_bean->date_start);
210                                         echo "</td></tr>";
211                                 } else {
212                                         echo "<td width=\"100%\">
213                                                 <a href=\"index.php?module=Meetings&action=DetailView&record=".
214                                                 $act->sugar_bean->id."\">".
215                                                 $app_list_strings['meeting_status_dom'][$act->sugar_bean->status].":".
216                                                 $act->sugar_bean->name."<br>(".
217                                                 $timedate->getTimePart($act->sugar_bean->date_start).")</a>";
218
219                                         // MEETING INTEGRATION
220                                         if($act->sugar_bean->hasIntegratedMeeting()) {
221                                                 $out .= $act->sugar_bean->miIcon;
222                                         }
223                                         // END MEETING INTEGRATION
224
225                                         $out .= "</td></tr>";
226                                         echo $out;
227                                 }
228                         } else if($act->sugar_bean->object_name == 'Task') {
229                                 echo "<td>".
230                                         SugarThemeRegistry::current()->getImage('Tasks','alt="'.$app_list_strings['task_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'"');
231                                 echo "</td>";
232
233                                 if(empty($act->sugar_bean->name)) {
234                                         echo "<td width=\"100%\">".
235                                                 $timedate->getTimePart($act->sugar_bean->date_due);
236                                         echo "</td></tr>";
237                                 } else {
238                                         echo "<td width=\"100%\">
239                                                 <a href=\"index.php?module=Tasks&action=DetailView&record=".
240                                                 $act->sugar_bean->id."\">".
241                                                 $app_list_strings['task_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name."<br>(".
242                                                 $timedate->getTimePart($act->sugar_bean->date_due).")</a></td></tr>";
243                                 }
244                         }
245                         echo "</table></div>";
246                 }
247         }
248
249         /////////////////////////////////
250         // template
251         /////////////////////////////////
252         function template_cal_day_slice($args) {
253                 /*
254                         echo "cale:".$args['calendar']->view;
255                         echo "cal1:".$args['calendar']->date_time->month;
256                         echo "cal3:".$args['slice']->date_time->month;
257                 */
258                 if($args['calendar']->show_only_current_slice == false || $args['calendar']->date_time->month == $args['slice']->start_time->month) {
259                         template_echo_slice_date($args);
260
261                         if($args['calendar']->show_activities == true) {
262                                 template_echo_slice_activities($args);
263                         }
264
265                 }
266         }
267
268         /////////////////////////////////
269         // template
270         /////////////////////////////////
271         function template_calendar($args) {
272                 global $timedate;
273                 if(isset($args['size']) && $args['size'] == 'small') {
274                         $args['calendar']->show_activities = false;
275                         $args['calendar']->show_week_on_month_view = false;
276                 }
277
278                 $newargs = array();
279                 $newargs['view'] = $args['view'];
280                 $newargs['calendar'] = $args['calendar'];
281                 if(!isset($args['size']) || $args['size'] != 'small') {
282                         template_cal_tabs($newargs);
283                 }
284
285                 if(isset($_REQUEST['view']) && $_REQUEST['view'] == 'shared') {
286                         global $ids;
287                         global $current_user;
288                         global $mod_strings;
289                         global $app_list_strings, $current_language, $currentModule, $action, $app_strings;
290                         $current_module_strings = return_module_language($current_language, 'Calendar');
291
292                         $ids = array();
293                         $user_ids = $current_user->getPreference('shared_ids');
294                         //get list of user ids for which to display data
295                         if(!empty($user_ids) && count($user_ids) != 0 && !isset($_REQUEST['shared_ids'])) {
296                                 $ids = $user_ids;
297                         }
298                         elseif(isset($_REQUEST['shared_ids']) && count($_REQUEST['shared_ids']) > 0) {
299                                 $ids = $_REQUEST['shared_ids'];
300                                 $current_user->setPreference('shared_ids', $_REQUEST['shared_ids']);
301                         } else {
302                                 //$ids = get_user_array(false);
303                                 //$ids = array_keys($ids);
304                                 $ids = array($current_user->id);
305
306                         }
307
308
309                         //get team id for which to display user list
310
311                         $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>';
312
313                         echo get_form_header($mod_strings['LBL_SHARED_CAL_TITLE'], $tools, false);
314                         if(empty($_SESSION['shared_ids']))
315                                 $_SESSION['shared_ids'] = "";
316
317                         echo "
318                         <script language=\"javascript\">
319                         function up(name) {
320                                 var td = document.getElementById(name+'_td');
321                                 var obj = td.getElementsByTagName('select')[0];
322                                 obj =(typeof obj == \"string\") ? document.getElementById(obj) : obj;
323                                 if(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)
324                                         return false;
325                                 var sel = new Array();
326
327                                 for(i=0; i<obj.length; i++) {
328                                         if(obj[i].selected == true) {
329                                                 sel[sel.length] = i;
330                                         }
331                                 }
332                                 for(i in sel) {
333                                         if(sel[i] != 0 && !obj[sel[i]-1].selected) {
334                                                 var tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value);
335                                                 obj[sel[i]-1].text = obj[sel[i]].text;
336                                                 obj[sel[i]-1].value = obj[sel[i]].value;
337                                                 obj[sel[i]].text = tmp[0];
338                                                 obj[sel[i]].value = tmp[1];
339                                                 obj[sel[i]-1].selected = true;
340                                                 obj[sel[i]].selected = false;
341                                         }
342                                 }
343                         }
344
345                         function down(name) {
346                                 var td = document.getElementById(name+'_td');
347                                 var obj = td.getElementsByTagName('select')[0];
348                                 if(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)
349                                         return false;
350                                 var sel = new Array();
351                                 for(i=obj.length-1; i>-1; i--) {
352                                         if(obj[i].selected == true) {
353                                                 sel[sel.length] = i;
354                                         }
355                                 }
356                                 for(i in sel) {
357                                         if(sel[i] != obj.length-1 && !obj[sel[i]+1].selected) {
358                                                 var tmp = new Array(obj[sel[i]+1].text, obj[sel[i]+1].value);
359                                                 obj[sel[i]+1].text = obj[sel[i]].text;
360                                                 obj[sel[i]+1].value = obj[sel[i]].value;
361                                                 obj[sel[i]].text = tmp[0];
362                                                 obj[sel[i]].value = tmp[1];
363                                                 obj[sel[i]+1].selected = true;
364                                                 obj[sel[i]].selected = false;
365                                         }
366                                 }
367                         }
368                         </script>
369
370                         <div id='shared_cal_edit' style='display: none;'>
371                         <form name='shared_cal' action=\"index.php\" method=\"post\" >
372                         <input type=\"hidden\" name=\"module\" value=\"".$currentModule."\">
373                         <input type=\"hidden\" name=\"action\" value=\"".$action."\">
374                         <input type=\"hidden\" name=\"view\" value=\"shared\">
375                         <input type=\"hidden\" name=\"edit\" value=\"0\">
376                         <table cellpadding=\"0\" cellspacing=\"3\" border=\"0\" align=\"center\">
377                         <tr><th valign=\"top\"  align=\"center\" colspan=\"2\">
378                         ";
379
380                         echo $current_module_strings['LBL_SELECT_USERS'];
381                         echo "
382                         </th>
383                         </tr>
384                         <tr><td valign=\"top\">";
385                         echo "
386             </td><td valign=\"top\">
387
388                         <table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"edit view\" align=\"center\">
389                         <tr>
390                                 <td valign='top' nowrap><b>".$current_module_strings['LBL_USERS']."</b></td>
391                                 <td valign='top' id=\"shared_ids_td\"><select id=\"shared_ids\" name=\"shared_ids[]\" multiple size='3'>";
392
393                                 echo get_select_options_with_id(get_user_array(false), $ids);
394
395                         echo "  </select></td>
396                                 <td><a onclick=\"up('shared_ids');\">".SugarThemeRegistry::current()->getImage('uparrow_big', 'border="0" style="margin-bottom: 1px;" alt="'.$app_strings['LBL_SORT'].'"')."</a><br>
397                                 <a onclick=\"down('shared_ids');\">".SugarThemeRegistry::current()->getImage('downarrow_big', 'border="0" style="margin-top: 1px;"  alt="'.$app_strings['LBL_SORT'].'"')."</a></td>
398                         </tr>
399                         <tr>";
400                         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>
401                         </tr>
402                         </table>
403                         </td></tr>
404                         </table>
405                         </form>";
406
407                 } // end "shared" view
408
409                 echo "</div></p>";
410
411                 if(isset($_REQUEST['edit']) && $_REQUEST['edit'])
412                         echo " <script language=\"javascript\"> toggleDisplay('shared_cal_edit'); </script>";
413
414                 echo "
415                 <table id=\"daily_cal_table_outside\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthBox\">
416                 <tr>
417                 <td>
418                   <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthHeader\">
419                   <tr>
420                   <td width=\"1%\" nowrap>";
421
422                 if(!isset($args['size']) || $args['size'] != 'small') {
423                         template_get_previous_calendar($args);
424                 }
425
426                 echo "
427                   </td>
428                   <td width=\" 98 % \" align=center scope='row'>";
429
430                 if(isset( $args['size']) && $args['size'] = 'small')
431                 {
432                 ?>
433                 <a style="text-decoration: none;"
434                         href="index.php?module=Calendar&action=index&view=month<?php echo $args['calendar']->date_time->get_date_str();?>">
435 <?php
436
437         }
438 ?>
439 <h3>
440 <?php template_echo_date_info($args['view'],$args['calendar']->date_time); ?>
441 </h3>
442 <?php
443
444         if(isset($args['size']) && $args['size'] = 'small') {
445                 echo "</a>";
446         }
447 ?>
448
449   </td>
450   <td align="right" width="1%" nowrap><?php
451
452
453         if(!isset($args['size']) || $args['size'] != 'small') {
454                 template_get_next_calendar($args);
455         }
456 ?> </td>
457   </tr>
458   </table>
459 </td>
460 </tr>
461 <tr>
462 <td class="monthCalBody">
463 <?php
464
465         if($args['calendar']->view == 'month') {
466                 template_calendar_month($args);
467         } else
468                 if($args['calendar']->view == 'year') {
469                         template_calendar_year($args);
470                 } else
471                         if($args['calendar']->view == 'shared') {
472
473                                 global $current_user, $shared_user;
474                                 $shared_args = array();
475                                 foreach($args as $key => $val) {
476                                         $shared_args[$key] = $val;
477                                 }
478                                 $shared_args['calendar'] = $args['calendar'];
479                                 $shared_user = new User();
480                                 foreach($ids as $member) {
481                                         $shared_user->retrieve($member);
482                                         $shared_args['calendar']->show_tasks = true;
483                                         $shared_args['calendar']->add_activities($shared_user);
484                                         $shared_args['show_link'] = 'off';
485                                         if(($shared_user->id == $current_user->id))
486                                                 $shared_args['show_link'] = 'on';
487                                         echo '<h5 class="calSharedUser">'.$shared_user->full_name.'</h5>';
488                                         template_calendar_horizontal($shared_args);
489                                 }
490                         } else {
491                                 template_calendar_vertical($args);
492                         }
493 ?>
494 </td>
495 </tr>
496 <tr>
497 <td>
498   <table width="100%" cellspacing="0" cellpadding="0" class="monthFooter">
499   <tr>
500   <td width="50%"><?php template_get_previous_calendar($args); ?></td>
501   <td align="right" width="50%"><?php template_get_next_calendar($args); ?></td>
502   </tr>
503   </table>
504
505 </td>
506 </tr>
507 </table>
508 <?php
509
510
511 }
512
513 function template_calendar_vertical($args) {
514 ?>
515   <table id="daily_cal_table" border="0" cellpadding="0" cellspacing="1" width="100%">
516   <?php
517
518         // need to change these values after we find out what activities
519         // occur outside of these values
520         $start_slice_idx = $args['calendar']->get_start_slice_idx();
521         $end_slice_idx = $args['calendar']->get_end_slice_idx();
522         $cur_slice_idx = 1;
523         for($cur_slice_idx = $start_slice_idx; $cur_slice_idx <= $end_slice_idx; $cur_slice_idx ++) {
524                 $calendar = $args['calendar'];
525                 $args['slice'] = $calendar->slice_hash[$calendar->slices_arr[$cur_slice_idx]];
526 ?>
527   <tr>
528   <?php template_cal_vertical_slice($args); ?>
529   </tr>
530   <?php
531
532         }
533 ?>
534   </table>
535 <?php
536
537 }
538
539 function template_calendar_horizontal($args) {
540         echo "<table id=\"daily_cal_table\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\"><tr>";
541
542         // need to change these values after we find out what activities
543         // occur outside of these values
544         $start_slice_idx = $args['calendar']->get_start_slice_idx();
545         $end_slice_idx = $args['calendar']->get_end_slice_idx();
546         $cur_slice_idx = 1;
547         for($cur_slice_idx = $start_slice_idx; $cur_slice_idx <= $end_slice_idx; $cur_slice_idx ++) {
548                 $calendar = $args['calendar'];
549                 $args['slice'] = $calendar->slice_hash[$calendar->slices_arr[$cur_slice_idx]];
550
551                 template_cal_horizontal_slice($args);
552         }
553
554         echo "</tr></table>";
555 }
556
557 function template_cal_vertical_slice($args) {
558         global $timedate;
559 ?>
560 <th width="1%" id="bodytime">
561 <?php template_echo_slice_date($args) ; ?>
562
563 </td>
564 <td width="99%" id="bodyitem">
565
566 <div style="display:none;" id='<?php echo template_echo_daily_view_24_hour($args); ?>_appt'> <?php
567
568         require_once('modules/Calls/CallFormBase.php');
569         $callForm = new CallFormBase();
570         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>";
571 ?></div>
572
573 <?php template_echo_slice_activities($args); ?>
574 </td>
575 <?php
576
577 }
578
579 function template_cal_horizontal_slice($args) {
580         echo "<td width=\"14%\" id=\"bodyItem\" scope='row' valign=\"top\">";
581
582         if($args['show_link'] == 'on') {
583                 template_echo_slice_date($args);
584         } else {
585                 template_echo_slice_date_nolink($args);
586         }
587
588         template_echo_slice_activities_shared($args);
589
590         echo "</td>";
591 }
592
593 function template_calendar_year($args) {
594         $count = 0;
595 ?>
596 <table cellspacing="0" cellpadding="0" border="0" width="100%">
597 <tr>
598     <td class="yearCalBody">
599   <table id="daily_cal_table" border="0" cellpadding="0"  cellspacing="1" width="100%">
600 <?php
601
602
603         for($i = 0; $i < 4; $i ++) {
604 ?>
605 <tr>
606 <?php
607
608                 for($j = 0; $j < 3; $j ++) {
609                         $args['slice'] = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]];
610 ?>
611
612 <td valign="top" align="center" scope='row' class="yearCalBodyMonth"><?php template_cal_month_slice($args); ?></td>
613
614 <?php
615
616                         $count ++;
617                 }
618 ?>
619 </tr>
620 <?php
621
622         }
623 ?>
624 </table>
625 </td>
626 </tr>
627 </table>
628
629 <?php
630
631 }
632
633 function template_calendar_month($args) {
634         global $mod_strings;
635 ?>
636
637 <table width="100%" id="daily_cal_table" border="0" cellspacing="1" cellpadding="0" >
638   <?php
639
640         // need to change these values after we find out what activities
641         // occur outside of these values
642         /*
643           $start_slice_idx = $args['calendar']->get_start_slice_idx();
644           $end_slice_idx = $args['calendar']->get_end_slice_idx();
645           $cur_slice_idx = 1;
646         */
647         $count = 0;
648         if($args['calendar']->slice_hash[$args['calendar']->slices_arr[35]]->start_time->month != $args['calendar']->date_time->month) {
649                 $rows = 5;
650         } else {
651                 $rows = 6;
652         }
653 ?>
654 <tr class="monthCalBodyTH">
655 <?php
656
657
658         for($i = 0; $i < 7; $i ++) {
659                 $first_row_slice = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$i]];
660 ?>
661 <th width="14%"><?php echo $first_row_slice->start_time->get_day_of_week_short(); ?></th>
662 <?php
663
664         }
665 ?>
666 </tr>
667 <?php
668
669
670         if(isset($_REQUEST['view']) && $_REQUEST['view'] == 'month') {
671                 $height_class = "monthViewDayHeight";
672         } else
673                 if(isset($args['size']) && $args['size'] == 'small') {
674                         $height_class = "";
675                 } else {
676                         $height_class = "monthViewDayHeight yearViewDayHeight";
677                 }
678
679         for($i = 0; $i < $rows; $i ++) {
680 ?>
681 <tr class="<?php echo $height_class; ?>">
682 <?php
683
684                 for($j = 0; $j < 7; $j ++) {
685                         $args['slice'] = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]];
686 ?>
687
688 <td <?php if($j==0 || $j==6) { ?>class="weekEnd"<?php } ?>><?php  template_cal_day_slice($args); ?></td>
689
690 <?php
691
692                         $count ++;
693                 }
694 ?>
695 </tr>
696 <?php
697
698         }
699 ?>
700 </table>
701 <?php
702
703 }
704
705 function get_current_day($args) {
706         global $timedate;
707         $slice = $args['slice'];
708         if($slice->start_time->get_mysql_date() == $timedate->nowDbDate()) {
709                 return true;
710         }
711         return false;
712 }
713
714 function template_echo_daily_view_hour($args) {
715
716         $slice = $args['slice'];
717         $hour = $slice->start_time->get_hour();
718         return $hour;
719
720 }
721
722 function template_echo_daily_view_24_hour($args) {
723
724         $slice = $args['slice'];
725         $hour = $slice->start_time->get_24_hour();
726         return $hour;
727
728 }
729
730 function template_echo_slice_date($args) {
731         global $mod_strings;
732     global $timedate;
733         $slice = $args['slice'];
734
735         if($slice->view != 'hour') {
736                 if($slice->start_time->get_day_of_week_short() == 'Sun' || $slice->start_time->get_day_of_week_short() == 'Sat') {
737                         echo "<a href=\"index.php?module=Calendar&action=index&view=".$slice->get_view().$slice->start_time->get_date_str()."\" ";
738                 } else {
739                         echo "<a href=\"index.php?module=Calendar&action=index&view=".$slice->get_view().$slice->start_time->get_date_str()."\" ";
740                 }
741         }
742
743         if($slice->view == 'day' &&($args['calendar']->view == 'week')) {
744                 echo ">";
745                 echo $slice->start_time->get_day_of_week_short();
746                 echo "&nbsp;";
747                 echo $slice->start_time->get_day();
748         }
749         elseif($args['calendar']->view == 'shared') {
750                 echo ">";
751                 echo $slice->start_time->get_day_of_week_short();
752                 echo "&nbsp;";
753                 echo $slice->start_time->get_day();
754         } else
755                 if($slice->view == 'day') {
756                         echo ">";
757                         if($slice->start_time->get_month() == $args['calendar']->date_time->get_month()) {
758                                 echo $slice->start_time->get_day();
759                         }
760                         //echo $slice->start_time->get_day();
761                 } else
762                         if($slice->view == 'month') {
763                                 echo ">";
764                                 echo $slice->start_time->get_month_name();
765                         } else
766                                 if($slice->view == 'hour') {
767                                         if($args['calendar']->toggle_appt == true) {
768                                                 echo '<a href="javascript:void  toggleDisplay(\''.$slice->start_time->get_24_hour().'_appt\');">';
769                                         }
770                     //Bug 13324, We are now using the users time format instead of a custom AM/PM setting
771                     echo $timedate->to_display_time($slice->start_time->get_24_hour() . ":00:00", true, false);
772                                 } else {
773                                         sugar_die("template_echo_slice_date: view not supported");
774                                 }
775
776         echo "</a>";
777 }
778
779 function template_echo_slice_date_nolink($args) {
780         global $mod_strings;
781         $slice = $args['slice'];
782         echo $slice->start_time->get_day_of_week_short();
783         echo "&nbsp;";
784         echo $slice->start_time->get_day();
785 }
786
787 function template_echo_date_info($view, $date_time) {
788         global $current_user;
789         $dateFormat = $current_user->getUserDateTimePreferences();
790
791         if($view == 'month') {
792                 for($i=0; $i<strlen($dateFormat['date']); $i++) {
793                         switch($dateFormat['date']{$i}) {
794                                 case "Y":
795                                         echo " ".$date_time->year;
796                                         break;
797                                 case "m":
798                                         echo " ".$date_time->get_month_name();
799                                         break;
800                         }
801                 }
802         } else
803                 if($view == 'week' || $view == 'shared') {
804                         $first_day = $date_time->get_day_by_index_this_week(0);
805                         $last_day = $date_time->get_day_by_index_this_week(6);
806
807                         for($i=0; $i<strlen($dateFormat['date']); $i++) {
808                                 switch($dateFormat['date']{$i}) {
809                                         case "Y":
810                                                 echo " ".$first_day->year;
811                                                 break;
812                                         case "m":
813                                                 echo " ".$first_day->get_month_name();
814                                                 break;
815                                         case "d":
816                                                 echo " ".$first_day->get_day();
817                                                 break;
818                                 }
819                         }
820                         echo " - ";
821                         for($i=0; $i<strlen($dateFormat['date']); $i++) {
822                                 switch($dateFormat['date']{$i}) {
823                                         case "Y":
824                                                 echo " ".$last_day->year;
825                                                 break;
826                                         case "m":
827                                                 echo " ".$last_day->get_month_name();
828                                                 break;
829                                         case "d":
830                                                 echo " ".$last_day->get_day();
831                                                 break;
832                                 }
833                         }
834                 } else
835                         if($view == 'day') {
836                                 echo $date_time->get_day_of_week()." ";
837
838                                 for($i=0; $i<strlen($dateFormat['date']); $i++) {
839                                         switch($dateFormat['date']{$i}) {
840                                                 case "Y":
841                                                         echo " ".$date_time->year;
842                                                         break;
843                                                 case "m":
844                                                         echo " ".$date_time->get_month_name();
845                                                         break;
846                                                 case "d":
847                                                         echo " ".$date_time->get_day();
848                                                         break;
849                                         }
850                                 }
851                         } else
852                                 if($view == 'year') {
853                                         echo $date_time->year;
854                                 } else {
855                                         sugar_die("echo_date_info: date not supported");
856                                 }
857 }
858
859 function template_get_next_calendar($args) {
860
861         global $mod_strings;
862 ?>
863 <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>
864 <?php
865
866 }
867
868 function template_get_previous_calendar($args) {
869         global $mod_strings;
870
871 ?>
872 <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>
873 <?php
874
875 }
876 ?>