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

📄 calendar.php

📁 jsp程序开发系统
💻 PHP
字号:
<?php
// +-------------------------------------------------------------+
// | DeskPRO v [2.0.1 Production]
// | Copyright (C) 2001 - 2004 Headstart Solutions Limited
// | Supplied by WTN-WDYL
// | Nullified by WTN-WDYL
// | Distribution via WebForum, ForumRU and associated file dumps
// +-------------------------------------------------------------+
// | DESKPRO IS NOT FREE SOFTWARE
// +-------------------------------------------------------------+
// | License ID : Full Enterprise License =) ...
// | License Owner : WTN-WDYL Team
// +-------------------------------------------------------------+
// | $RCSfile: calendar.php,v $
// | $Date: 2004/02/10 01:34:25 $
// | $Revision: 1.11 $
// +-------------------------------------------------------------+
// | File Details:
// | - Send calendar reminders
// +-------------------------------------------------------------+

error_reporting(E_ALL ^ E_NOTICE);

cron_check();
require_once(INCLUDE_PATH.'/functions/calendar_functions.php');

// Starting date is today
$startdate = date('Y-m-d', time());
$startdate_ts = strtotime($startdate);
$enddate = $date;

// Find the maximum range of dates we must consider.
$max = $db->query_return('SELECT MAX(email_before1) AS b1, MAX(email_before2) AS b2 FROM calendar_task_tech');
if ($max['b1'] > $max['b2']) {
	$max = $max['b1'];
} else {
	$max = $max['b2'];
}

// Ending date is the current date plus $max days
if ($max) {
	$enddate = date('Y-m-d', strtotime("$enddate + $max days"));
}

// Get a list of all active techs
$db->query("SELECT id FROM tech WHERE !disabled");
while ($res = $db->row_array()) {
	$techs[] = $res['id'];
}

// Now list all tasks due between now and the maximum time we have to notify for
$tasks = cachetasks($startdate, $enddate, NULL, NULL, NULL, NULL, $techs, 0);

// For every task in the list returned by cachetasks, decide whether to notify or not.

if (is_array($tasks)) {
	foreach($tasks as $key => $var) {
		$date_ts = strtotime($key);
		if (is_array($var)) {
			foreach($var AS $key2 => $var2) {
				if ((($var2[9]['email_due']) AND ($date_ts == $startdate_ts)) 
				OR (($var2[9]['email_before1'] AND (strtotime("$key -" . $var2[9]['email_before1'] . " days") == $startdate_ts))) 
				OR (($var2[9]['email_before2'] AND (strtotime("$key -" . $var2[9]['email_before2'] . " days") == $startdate_ts)))) {
					$notifies[$var2[0]]['title'] = $var2[1];
					$notifies[$var2[0]]['description'] = $var2[2];
					$ids[] = $var2[0];
				}
			}
		}
	}
}

if (is_array($ids)) {
	if (count($ids)) { // Now, pile up a list of usernames and e-mails to send mail to.
		$db->query("SELECT email, username, eventid FROM tech, calendar_task_tech WHERE calendar_task_tech.eventid in " . array2sql($ids). " AND tech.id = calendar_task_tech.techid");
		while ($res = $db->row_array()) {
			$notifies[$res[eventid]][users][$res['username']] = $res['email'];
		}
	}

	// Send e-mails
	foreach($notifies AS $key => $val) {
		$task = $db->query_return("SELECT * FROM calendar_task WHERE id = $key");
		if (is_array($val[users])) {
			foreach($val[users] AS $username => $email) {
				eval(makeemaileval('message', 'TECHBODY_task_reminder', $subject));
				dp_mail($email, $subject, $message);
			}
		}
	}
}

⌨️ 快捷键说明

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