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