⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 templates_calendar.php

📁 开源的CRM,功能全面,国内最优秀的源码
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php
if(empty($GLOBALS['sugarEntry'])) die('Not A Valid Entry Point');


/*********************************************************************************
 * The contents of this file are subject to the SugarCRM Public License Version
 * 1.1.3 ("License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 ********************************************************************************/
/////////////////////////////////
// template
/////////////////////////////////
$timedate = new TimeDate();
function template_cal_tabs(& $args) {
	global $mod_strings;
	$tabs = array ('day', 'week', 'month', 'year', 'shared');

	$other_class = 'button';
	$sel_class = 'buttonOn';
?>

<table id="cal_tabs" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="padding-bottom: 2px;">
<?php

	$bg = $other_class;
	$time_arr = array ();

	foreach ($tabs as $tab) {
		if ($args['view'] == $tab) {
			$bg = $sel_class;
		} else {
			$bg = $other_class;
		} 
?>
<input onclick="window.location.href='index.php?module=Calendar&action=index&view=<?php echo $tab; ?><?php echo $args['calendar']->date_time->get_date_str(); ?>'" type="button" class="<?php echo $bg; ?>" value=" <?php echo $mod_strings["LBL_".$args['calendar']->get_view_name($tab)]; ?> " title="<?php echo $mod_strings["LBL_".$args['calendar']->get_view_name($tab)]; ?>"></a>&nbsp;
<?php } ?>
</td>
</tr>
</table>

<?php

	}

	/////////////////////////////////
	// template
	/////////////////////////////////
	function template_cal_month_slice(& $args) {
?>
<?php

		template_echo_slice_date($args);
		$newargs = array ();
		$cal_arr = array ();
		$cal_arr['month'] = $args['slice']->start_time->month;
		$cal_arr['year'] = $args['slice']->start_time->year;
		$newargs['calendar'] = new Calendar('month', $cal_arr);
		$newargs['calendar']->show_only_current_slice = true;
		$newargs['calendar']->show_activities = false;
		$newargs['calendar']->show_week_on_month_view = false;
		template_calendar_month($newargs);
?>
<?php

	}

	/////////////////////////////////
	// template
	/////////////////////////////////
	function template_echo_slice_activities(& $args) {
		global $app_list_strings;
		global $image_path;
		global $current_user;
		
		// calmod - added
		template_echo_user_slice_activities($args, $current_user->id);
		/* calmod - start removed //
		$count = 0;
		if (empty ($args['slice']->acts_arr[$current_user->id])) {
			return;
		}
		foreach ($args['slice']->acts_arr[$current_user->id] as $act) {
			$extra = '';
			$count ++;
			echo '<div style="margin-top: 1px;"><table cellpadding="0" cellspacing="0" 
					border="0" width="100%" class="monthCalBodyDayItem"><tr>';
			if ($act->sugar_bean->object_name == 'Call') { 
				echo '<td class="monthCalBodyDayIconTd">' . get_image($image_path.'Calls','alt="'.$app_list_strings['call_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'"') . '</td>
						<td class="monthCalBodyDayItemTd" width="100%"><a ' . $extra . ' href="index.php?module=Calls&action=DetailView&record=' . 
						$act->sugar_bean->id . '" class="monthCalBodyDayItemLink">' . $app_list_strings['call_status_dom'][$act->sugar_bean->status] . ': ' . $act->sugar_bean->name . '</a></td>';
			} else if ($act->sugar_bean->object_name == 'Meeting') { 
				echo '<td class="monthCalBodyDayIconTd">' . get_image($image_path.'Meetings','alt="'.$app_list_strings['meeting_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'"') . '</td>
						<td class="monthCalBodyDayItemTd" width="100%"><a ' . $extra . ' href="index.php?module=Meetings&action=DetailView&record=' . 
						$act->sugar_bean->id . '" class="monthCalBodyDayItemLink">' . $app_list_strings['meeting_status_dom'][$act->sugar_bean->status] . ': ' . $act->sugar_bean->name .'</a></td>';
			} else if ($act->sugar_bean->object_name == 'Task') {
				echo '<td class="monthCalBodyDayIconTd">' .  get_image($image_path.'Tasks','alt="'.$act->sugar_bean->status.': '.$act->sugar_bean->name.'"') . '</td>
						<td class="monthCalBodyDayItemTd" width="100%"><a ' . $extra . ' href="index.php?module=Tasks&action=DetailView&record=' . $act->sugar_bean->id . '" class="monthCalBodyDayItemLink">'.$act->sugar_bean->status.': ' . $act->sugar_bean->name . '</a></td>';
			}
			echo '</tr></table><div>';
		}
		// calmod - end removed */
	}
	// calmod - start added
	function template_echo_user_slice_activities(& $args, $user_id, $show_contacts=true) {
		global $app_list_strings, $app_strings;
		global $image_path;
		global $mod_strings;
		global $timedate;
		$count = 0;
		if (empty ($args['slice']->acts_arr[$user_id])) {
			return;
		}
		foreach ($args['slice']->acts_arr[$user_id] as $act) {
			$count ++;

			// Get the times to print for the user
			$startPrintTime = date($args['calendar']->timeFormat, $act->start_time->ts);
		
			if($act->sugar_bean->object_name != 'Task') {
				$newEnd = DateTime::get_time_end(
					$act->start_time,
					$act->sugar_bean->duration_hours,
					$act->sugar_bean->duration_minutes+ (1/60)
					);
				$endPrintTime = date($args['calendar']->timeFormat, $newEnd->ts + 1);
				$printTime = $startPrintTime . '-' . $endPrintTime;
			}
			else
				$printTime = '';
			
			switch($act->sugar_bean->object_name) {
				case 'Call':
					$status = $app_list_strings['call_status_dom'][$act->sugar_bean->status];
					$mod = 'Calls';
					$contacts = is_array($act->sugar_bean->contacts_arr) ? $act->sugar_bean->contacts_arr : array();
					break;
				case 'Meeting':
					$status = $app_list_strings['meeting_status_dom'][$act->sugar_bean->status];
					$mod = 'Meetings';
					$contacts = is_array($act->sugar_bean->contacts_arr) ? $act->sugar_bean->contacts_arr : array();
					break;
				case 'Task':
					$status = 'Due';
					$mod = 'Tasks';
					$contacts = array();
					if(! empty($act->sugar_bean->contact_id)) {
						$ct = new Contact();
						$ct->retrieve($act->sugar_bean->contact_id);
						$contacts[] = $ct;
					}
					break;
			}
			$link = "index.php?module=". $mod. "&action=DetailView&record=". $act->sugar_bean->id;
			$image = get_image($image_path.$mod,'alt="'.$status.': '.$act->sugar_bean->name.'"');

?>
	<div style="margin-top: 1px;">
		<table cellpadding="0" cellspacing="0" border="0" width="100%" class="monthCalBodyDayItem">
		<tr>
		<td class="monthCalBodyDayIconTd"><?php echo $image; ?></td>
		<td class="monthCalBodyDayItemTd" width="100%"><?php echo $printTime . '&nbsp;&nbsp;' . $status; ?>: <a href="<?php echo $link; ?>" class="monthCalBodyDayItemLink"><?php echo $act->sugar_bean->name; ?></a>
		<?php
			// Now for the contacts
			if ($args['calendar']->view== 'week' && count($contacts)> 0 && $show_contacts)
			{
				echo '<span>&nbsp;&nbsp;&nbsp;'. $app_strings['LBL_CONTACTS'] .':';
				for($x = 0; $x < count($contacts); $x++)
				{
					$aContact =& $contacts[$x];
					echo ($x == 0 ? '' : ',');
					echo '&nbsp;<a  class="monthCalBodyDayItemLink" href="index.php?module=Contacts&action=DetailView&record=' . $aContact->id . '">' . $aContact->first_name . ' ' . $aContact->last_name . '</a>';
				}
				echo '</span>';
			}
		?>
		</td>
		</tr>
		</table>
	</div>
<?php
		}
	}
	// calmod - end added
	

	function template_echo_slice_activities_shared(& $args) {
		global $app_list_strings;
		global $image_path;
		global $shared_user, $timedate;
		$count = 0;
		
		// calmod - added
		template_echo_user_slice_activities($args, $shared_user->id, false);
		/* calmod - start removed //
		if (empty ($args['slice']->acts_arr[$shared_user->id])) {
			return;
		}
		
		foreach ($args['slice']->acts_arr[$shared_user->id] as $act) {
			$count ++;
			echo "<div style=\"margin-top: 1px;\">
			<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"monthCalBodyDayItem\">";
			
			if($act->sugar_bean->object_name == 'Call') { 
				echo "<tr><td class=\"monthCalBodyDayIconTd\">";
				get_image($image_path.'Calls','alt=\"'.$app_list_strings['call_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'\"'); 
				echo "</td>";
	
				if(empty($act->sugar_bean->name)) {
					echo "<td class=\"monthCalBodyDayItemTd\" width=\"100%\">";
					echo $timedate->to_display_time($act->sugar_bean->time_start, false, false); 
					echo "</td></tr>";
				} else {
					echo "<td class=\"monthCalBodyDayItemTd\" width=\"100%\">
						<a href=\"index.php?module=Calls&action=DetailView&record=".
						$act->sugar_bean->id."\" class=\"monthCalBodyDayItemLink\">".
						$app_list_strings['call_status_dom'][$act->sugar_bean->status].":".
						$act->sugar_bean->name."(".
						$timedate->to_display_time($act->sugar_bean->time_start, false, false)."
						)</a></td></tr>";
				}
			} else if ($act->sugar_bean->object_name == 'Meeting') { 
				echo "<td class=\"monthCalBodyDayIconTd\">".
					get_image($image_path.'Meetings','alt=\"'.$app_list_strings['meeting_status_dom'][$act->sugar_bean->status].': '.$act->sugar_bean->name.'\"'); 
				echo "</td>";
			
				if (empty($act->sugar_bean->name)) {
					echo "<td class=\"monthCalBodyDayItemTd\" width=\"100%\">".
						$timedate->to_display_time($act->sugar_bean->time_start, true, false); 
					echo "</td></tr>";
				} else {
					echo "<td class=\"monthCalBodyDayItemTd\" width=\"100%\">
						<a href=\"index.php?module=Meetings&action=DetailView&record=".
						$act->sugar_bean->id."\" class=\"monthCalBodyDayItemLink\">".
						$app_list_strings['meeting_status_dom'][$act->sugar_bean->status].":".
						$act->sugar_bean->name."(".
						$timedate->to_display_time($act->sugar_bean->time_start, true, false).")
						</a></td></tr>";
				}
			}
			echo "</table><div>";
		}
		// calmod - end removed */
	}

	/////////////////////////////////
	// template
	/////////////////////////////////
	function template_cal_day_slice(& $args) {
		/*
			echo "cale:".$args['calendar']->view;
			echo "cal1:".$args['calendar']->date_time->month;
			echo "cal3:".$args['slice']->date_time->month;
		*/
		if ($args['calendar']->show_only_current_slice == false || $args['calendar']->date_time->month == $args['slice']->start_time->month) {
			template_echo_slice_date($args);

			if ($args['calendar']->show_activities == true) {
				template_echo_slice_activities($args);
			}

		}
	}

	/////////////////////////////////
	// template
	/////////////////////////////////
	function template_calendar(& $args) {
		global $timedate;
		if (isset ($args['size']) && $args['size'] = 'small') {
			$args['calendar']->show_activities = false;
			$args['calendar']->show_week_on_month_view = false;
		}

		$newargs = array ();
		$newargs['view'] = $args['view'];
		$newargs['calendar'] = $args['calendar'];
		if (!isset ($args['size']) || $args['size'] != 'small') {
			template_cal_tabs($newargs);
		}

		if (isset ($_REQUEST['view']) && $_REQUEST['view'] == 'shared') {
			global $ids;
			global $current_user;
			global $mod_strings;
			global $app_list_strings, $current_language, $currentModule, $action, $theme, $image_path, $app_strings;
			$current_module_strings = return_module_language($current_language, 'Calendar');

			$ids = array ();
			$user_ids = $current_user->getPreference('shared_ids');
			//get list of user ids for which to display data
			if (!empty ($user_ids) && count($user_ids) != 0 && !isset ($_REQUEST['shared_ids'])) {
				$ids = $user_ids;
			}
			elseif (isset ($_REQUEST['shared_ids']) && count($_REQUEST['shared_ids']) > 0) {
				$ids = $_REQUEST['shared_ids'];
				$current_user->setPreference('shared_ids', $_REQUEST['shared_ids']);
			} else {
				$ids = get_user_array(false);
				$ids = array_keys($ids);
			}


			//get team id for which to display user list
			$team = $current_user->getPreference('team_id');

			if (!empty ($team) && !isset ($_REQUEST['team_id'])) {
				$team_id = $team;
			}
			elseif (isset ($_REQUEST['team_id'])) {
				$team_id = $_REQUEST['team_id'];
				$current_user->setPreference('team_id', $_REQUEST['team_id']);
			} else {
				$team_id = '';
			}

			if (empty ($_SESSION['team_id'])) {
				$_SESSION['team_id'] = "";
			}


			$tools = '<div align="right"><a href="index.php?module='.$currentModule.'&action='.$action.'&view=shared" class="chartToolsLink">&nbsp;<a href="javascript: toggleDisplay(\'shared_cal_edit\');" class="chartToolsLink">'.get_image($image_path.'edit', 'alt="Edit"  border="0"  align="absmiddle"').'&nbsp;'.$current_module_strings['LBL_EDIT'].'</a></div>';

			echo get_form_header($mod_strings['LBL_SHARED_CAL_TITLE'], $tools, false);
			if (empty ($_SESSION['shared_ids']))
				$_SESSION['shared_ids'] = "";

			echo "
			<script language=\"javascript\">
			function up(name) {
				var td = document.getElementById(name+'_td');
				var obj = td.getElementsByTagName('select')[0];
				obj = (typeof obj == \"string\") ? document.getElementById(obj) : obj;
				if (obj.tagName.toLowerCase() != \"select\" && obj.length < 2)
					return false;
				var sel = new Array();
			
				for (i=0; i<obj.length; i++) {
					if (obj[i].selected == true) {
						sel[sel.length] = i;
					}
				}
				for (i in sel) {
					if (sel[i] != 0 && !obj[sel[i]-1].selected) {
						var tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value);
						obj[sel[i]-1].text = obj[sel[i]].text;
						obj[sel[i]-1].value = obj[sel[i]].value;
						obj[sel[i]].text = tmp[0];
						obj[sel[i]].value = tmp[1];
						obj[sel[i]-1].selected = true;
						obj[sel[i]].selected = false;
					}
				}
			}
			
			function down(name) {
				var td = document.getElementById(name+'_td');
				var obj = td.getElementsByTagName('select')[0];
				if (obj.tagName.toLowerCase() != \"select\" && obj.length < 2)
					return false;
				var sel = new Array();
				for (i=obj.length-1; i>-1; i--) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -