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

📄 new.php

📁 本代码是为客户联系管理而做的系统
💻 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: new.php,v $
// | $Date: 2004/02/10 01:34:25 $
// | $Revision: 1.41 $
// +-------------------------------------------------------------+
// | File Details:
// | - New task creation.
// +-------------------------------------------------------------+

error_reporting(E_ALL ^ E_NOTICE);

// start file
require("./../global.php");

// globalise variables
$global = array	(
			array('id')			// ticketid
);
rg($global);

// default do
$_REQUEST['do'] = trim($_REQUEST['do']);
if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
	$_REQUEST['do'] = "new";
}

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

############################### CREATE TASK ###############################

if ($_REQUEST['do'] == "new2") { 
	if ($_REQUEST['using_time']) { // sort out 24 hour clock
		if ($_REQUEST['twelvetime'] == "PM") {
			if ($_REQUEST['htime'] == "12") {
				$htime = "00";
			} else {
				$htime = $_REQUEST['htime'] + 12;
			}
		} else {
			$htime = $_REQUEST['htime'];
		}
		$starttime = "$htime:$_REQUEST[mtime]:00";
	}

	if (!(trim($_REQUEST['title']))) {
		$error .= 'The title was left empty\\n';
	}

	if (!(trim($_REQUEST['description']))) {
		$error .= 'The description was left empty\\n';
	}

	// repeat options
	if ($_REQUEST['type'] > 0) {
		if ($_REQUEST['type'] == '1') {
			$value1 = $_REQUEST['value11'];
		} elseif ($_REQUEST['type'] == '2') {
			if (is_array($_REQUEST['value22'])) {
				foreach($_REQUEST['value22'] AS $key => $var) {
					$value2 .= $key . '|';
				}
				$value2 = substr($value2, 0, -1);
			}
			$value1 = $_REQUEST['value21'];
		} elseif ($_REQUEST['type'] == '3') {
			$value1 = $_REQUEST['value31'];
			$value2 = $_REQUEST['value32'];
		} elseif ($_REQUEST['type'] == '4') {
			$value1 = $_REQUEST['value41'];
			$value2 = $_REQUEST['value42'];
		}
	}

	if (count($_REQUEST[techs]) > 1) {
		$multistaff = 1;
	}

	$startdate = "$_REQUEST[ystartdate]-$_REQUEST[mstartdate]-$_REQUEST[dstartdate]";
	if (!validate_ymd($startdate)) {
		$error .= 'The starting date entered was not valid\\n';
	} 

	if ($_REQUEST[repeat_until]) {
		$enddate = "$_REQUEST[yenddate]-$_REQUEST[menddate]-$_REQUEST[denddate]";
		if (!validate_ymd($enddate)) {
			$error .= 'The ending date entered was not valid\\n';
		}
	} else {
		$enddate = "0000-00-00";
	}

	if (is_array($_REQUEST['techs'])) {
		if (!count($_REQUEST['techs'])) {
			$error .= 'At least one technician must be assigned.\\n';
		}
	} else {
		$error .= 'At least one technician must be assigned.\\n';
	}

	if (!$error) {
	    $checks = xss_check(array($_REQUEST['title'], $_REQUEST['description']), 'tech');
		$db->query("INSERT INTO calendar_task SET
					title = '" . mysql_escape_string($checks[0]) . "',
					description = '" . mysql_escape_string($checks[1]) . "',
					starttime = '$starttime',
					repeattype = '" . intval($_REQUEST['type']) . "',
					value1 = '" . intval($value1) . "',
					value2 = '" . mysql_escape_string($value2) . "',
					multistaff = '" . intval($multistaff) . "',
					notifycompletion = '" . intval($_REQUEST['notifycompletion']) . "',
					globalcomplete = '" . intval($_REQUEST['globalcomplete']) . "',
					timezone = '" . mysql_escape_string($_REQUEST['timezone']) . "',
					startdate = '$startdate',
					enddate = '$enddate',
					techmaker = '$user[id]'
				
		");

		$id = $db->last_id();

		// assignments
		if (is_array($_REQUEST['techs'])) {
			$db->query("SELECT id, username, email FROM tech WHERE id IN" . 
				array2sql($_REQUEST['techs']) . " or id = '$user[id]'");
			while ($result = $db->row_array()) {
				$emails[$result['id']]['username'] 	= $result['username'];
				$emails[$result['id']]['email'] 	= $result['email'];
			}

			foreach ($_REQUEST['techs'] AS $key => $var) {
				$db->query("INSERT INTO calendar_task_tech SET 
						email_due = '" . intval($_REQUEST['email_due']) . "',
						email_before1 = '" . intval($_REQUEST['email_before1']) . "',
						email_before2 = '" . intval($_REQUEST['email_before2']) . "',
						techid = '" . intval($var) . "',
						eventid = '" . intval($id) . "',
						stamp = '" . time() . "'"
				);

				$message = '';

				if ($_REQUEST['email_now']) {
					$taskusername = $emails[$user['id']]['username'];
					$taskurl = $settings['helpdesk_url'] . "/tech/calendar/viewtask.php?id=$id";
					$tasktitle = $_REQUEST['title'];
					$taskdescription = $_REQUEST['description'];
					eval(makeemaileval('message', 'TECHBODY_newtask', $subject));
					dp_mail($emails[$var][email], $subject, $message);
				}
			}
		}

		jump('index.php?do=added', 'Task added.');
		exit;
	} else {
		alert($error);
	}
}

tech_nav('calendar');

############################### CREATE NEW TASK ###############################
echo "<form action=\"new.php\" method=\"post\">";

////////////////////////// ENTRY DETAILS //////////////////////////

$table[] = array(table_thelp('<b>Entry Title</b> ', 'Calendar', 'Events: Title'), form_input('title', $_REQUEST['title']));
if ($startdate) {
	$startdate = formatymd($startdate);
}
$table[] = array(table_thelp('<b>Entry Date</b> ', 'Calendar', 'Events: Due Date'), form_date('startdate', '', '', 1, '', $startdate));
$table[] = array(table_thelp('<b>Entry Time</b> ', 'Calendar', 'Events: Time'), form_checkbox_single('using_time', 1, $_REQUEST['using_time']) . "&nbsp;&nbsp;&nbsp;" . form_time('time', 1, 1));
$table[] = array(table_thelp('<b>Entry Timezone</b>', 'Calendar', 'Events: Timezone'), make_timezone($settings['timezone']));

$table[] = array(table_thelp('<b>Entry Description</b> ', 'Calendar', 'Events: Description'), form_textarea('description', 60, 8, $_REQUEST['description']));
$table[] = array(table_thelp('<b>Email Reminders</b> ', 'Calendar', 'Events: Reminders'),
						form_checkbox_single('email_due', 1, $_REQUEST['email_due']) . " on due day<br />" .
						"and/or " . form_input('email_before1', $_REQUEST['email_before1'], 2) . " day(s) before<br />" .
						"and/or " . form_input('email_before2', $_REQUEST['email_before2'], 2) . " day(s) before<br />"
						);

$width = array('60%', '40%');
table_header('Create a New Task');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table);

////////////////////////// TECH ASSIGNED //////////////////////////

$db->query("SELECT id,username FROM tech WHERE !disabled");
while ($result = $db->row_array()) {
	$tech[$result['id']] = $result['username'];
}
$total = $db->num_rows();
	
$tmp .= form_checkbox_single($user['id'], 1, '', 'techs') . "&nbsp;&nbsp;&nbsp;" . $user['username'] . "<br />";
if ($total < 10) {
	$selsize = $total;
} else {
	$selsize = 10;
}

if (!$_REQUEST['techs']) {
	$_REQUEST['techs'] = array($user[id]);
}

$_REQUEST['techs'][$user['id']] = $user['username'];
$tmp = form_select('techs', $tech, '', $_REQUEST['techs'], '', '', $selsize);

$table[] = array(table_thelp('<b>Assign to Technician(s)</b> ', 'Calendar', 'Events: Assignments'), $tmp);
$table[] = array(table_thelp('<b>E-mail Now</b> ', 'Calendar', 'Events: Mail Now?'), form_radio_yn('email_now', $_REQUEST['email_now']));

if ($_REQUEST['globalcomplete']) {
	$glob0 = 0;
	$glob1 = 1;
} else {
	$glob0 = 1;
	$glob1 = 0;
}

$table[] = array(table_thelp('<b>Multiple or Single?</b> ', 'Calendar', 'Events: Multiple or Single?'), form_radio_single('globalcomplete', 0, $glob0) . "&nbsp;&nbsp;&nbsp;<B>Yes</B>, every assigned technician must complete the task<br />" . form_radio_single('globalcomplete', 1, $glob1) . "&nbsp;&nbsp;&nbsp;<B>No</B>, once any assigned technician completes the task, it is complete for everyone");
$table[] = array(table_thelp('<b>E-mail on Completion?</b> ', 'Calendar', 'Events: E-mail on Completion?'), form_radio_yn('notifycompletion', $_REQUEST['notifycompletion']));

table_header('Assigned Technicians');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table);

////////////////////////// REPEAT OPTIONS //////////////////////////

$month = array('1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec');

$table[] = table_midheader('Repeat Type');

$type1 = 0;
$type2 = 0;
$type3 = 0;
$type4 = 0;
$type5 = 0;

switch ($_REQUEST['type']) {
	case 1: $type1 = 'checked'; break;
	case 2: $type2 = 'checked'; break;
	case 3: $type3 = 'checked'; break;
	case 4: $type4 = 'checked'; break;
	default: 
	case 5: $type5 = 'checked'; break;
}
$table[] = array(table_thelp('<b>Daily Repeat</b> ', 'Calendar', 'Events: Repeat Type'), 
			"<input type=\"radio\" name=\"type\" value=\"1\" $type1>&nbsp;&nbsp;&nbsp;Repeat every " . form_input('value11', $_REQUEST['value11'], 1) . " day(s)<br />");

$table[] = array(table_thelp('<b>Weekly Repeat</b> ', 'Calendar', 'Events: Repeat Type'),
			"<input type=\"radio\" name=\"type\" value=\"2\" $type2>&nbsp;&nbsp;&nbsp;Repeat every " . form_input('value21', $_REQUEST['value21'], 1) . " week(s) on <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" .
				form_checkbox_single('1', 1, $_REQUEST['value22'][1], 'value22') . "&nbsp;Sun&nbsp;&nbsp;" .
				form_checkbox_single('2', 1, $_REQUEST['value22'][2], 'value22') . "&nbsp;Mon&nbsp;&nbsp;" .
				form_checkbox_single('3', 1, $_REQUEST['value22'][3], 'value22') . "&nbsp;Tue&nbsp;&nbsp;" .
				form_checkbox_single('4', 1, $_REQUEST['value22'][4], 'value22') . "&nbsp;Wed&nbsp;&nbsp;" .
				form_checkbox_single('5', 1, $_REQUEST['value22'][5], 'value22') . "&nbsp;Thu&nbsp;&nbsp;" .
				form_checkbox_single('6', 1, $_REQUEST['value22'][6], 'value22') . "&nbsp;Fri&nbsp;&nbsp;" .
				form_checkbox_single('7', 1, $_REQUEST['value22'][7], 'value22') . "&nbsp;Sat&nbsp;&nbsp;");
$table[] = array(table_thelp('<b>Monthly Repeat</b> ', 'Calendar', 'Events: Repeat Type'),
			"<input type=\"radio\" name=\"type\" value=\"3\" $type3>&nbsp;&nbsp;&nbsp;Repeat on date " . form_select('value31', make_numberarray(1, 31), '', $_REQUEST['value31']) . " of every " . form_input('value32', $_REQUEST['value32'], 3) . " month(s)");
$table[] = array(table_thelp('<b>Yearly Repeat</b> ', 'Calendar', 'Events: Repeat Type'),
			"<input type=\"radio\" name=\"type\" value=\"4\" $type4>&nbsp;&nbsp;&nbsp;Repeat every year on date " . form_select('value41', make_numberarray(1, 31), '', $_REQUEST['value41']) . " " . form_select('value42', $month));
$table[] = array(table_thelp('<b>No Repeat</b> ', 'Calendar', 'Events: Repeat Type'), "<input type=\"radio\" name=\"type\" value=\"5\" $type5>&nbsp;&nbsp;&nbsp;Not a repeating event");

$table[] = table_midheader('Repetition Options');
$table[] = array(table_thelp('<b>End Date</b> ', 'Calendar', 'Events: Repeat End Date'),  
				form_radio_single('repeat_until', '0') . "&nbsp;Repeat Forever<BR>" .
				form_radio_single('repeat_until', '1') . "&nbsp;Repeat Until:&nbsp;" .
				form_date('enddate', '', '', 1));

table_header('Repeat Options');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table);

echo form_hidden('do', 'new2');
echo "<center><input type=\"submit\" name=\"submit\" value=\"Create Task\"></center></form>";

tech_footer();
?>

⌨️ 快捷键说明

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