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

📄 newticket.php

📁 本代码是为客户联系管理而做的系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		}

		if ($_REQUEST['tech'] != $user['id']) {
			notify_technicians('assigned', $ticket, $user_details, array($_REQUEST[usermessage], $_REQUEST[reply]), $added);
		} elseif (!$_REQUEST['tech']) {
			notify_technicians('new', $ticket, $user_details, array($_REQUEST[usermessage], $_REQUEST[reply]), $added);
		}

		if ($_REQUEST['create_faq']) {
			$title = urlencode($_REQUEST['subject']);
			$question = urlencode($_REQUEST['usermessage']);
			$answer = urlencode($_REQUEST['reply']);
			jump("../faq/view.php?do=add&title=$title&question=$question&answer=$answer", 'Ticket Created. Redirecting you to the FAQ article addition page.');
		} else {
			jump("ticketview.php?id=$id", 'Ticket Created. Redirecting you to ticket');
		}
	}

	/******************* PROCESS ERRORS ***********************/
	if ($error) {
		
		if ($newpass) { // dont show new passwords
			unset($_REQUEST['password'], $_REQUEST['password1']);
		}

		if ($newusername AND !$usercreated) {
			unset($_REQUEST['username']);
		}

		// have we created the user?
		if ($user_created) { 
			
			if ($error) {
				$error = 'The user has been created, but a problem was encountered:\n\n' . $error;
			}

			$_REQUEST['new_user'] = 'old';
			$_REQUEST['user'] = $_REQUEST['email'];
		}
			
		if ($error) {
			alert($error);
		}

		$repeat = 1;
		$_REQUEST['do'] = 'start';
	}
}

############################### CREATE NEW TICKET ###############################

if ($_REQUEST['do'] == "start") {

	echo "<form method=\"post\" enctype=\"multipart/form-data\" name=\"dpreply\" id=\"dpreply\" action=\"newticket.php\">" . form_hidden('do', 'new');

	// category information
	$categories[0] = '';
	$db->query("SELECT * FROM ticket_cat ORDER by cat_order");
	while ($cat = $db->row_array()) {
		$categories[$cat[id]] = $cat[name];
	}

	// get priority data
	$priority[0] = '';
	$db->query("SELECT * from ticket_pri ORDER by pri_order");
	while ($pri = $db->row_array()) {
		$priority[$pri[id]] = $pri[name];
	}

	$tech[0] = 'Unassigned';
	$db->query("SELECT * FROM tech ORDER by username");
	while ($result = $db->row_array()) {
		$tech[$result[id]] = $result[username];
	}

	// get current users

	$db->query("SELECT username, id 
		FROM user, tech_start_tickets 
		WHERE !disabled
			AND tech_start_tickets.userid = user.id
			AND tech_start_tickets.techid = '$user[id]'
		");

	if ($db->num_rows() > 0) {
		$userselect[0] = '';
		while ($result = $db->row_array()) {
			$userselect[$result['id']] = $result[username];
		}
	}

	if (!$_REQUEST['new_user']) {
		$_REQUEST['new_user'] = 'old';
	}

	if ($_REQUEST['new_user'] == 'old') {
		$old_start = 1;
		$new_start = 0;
	} else {
		$new_start = 1;
		$old_start = 0;
	}

	// are we coming from the comment form? If so prefill the user message
	if ($_REQUEST['commentid']) {
		
		$comment = $db->query_return("SELECT * FROM faq_comments WHERE id = '$_REQUEST[commentid]'");
		$_REQUEST['usermessage'] = $comment['comments'];

		// if we have userid, get username
		if ($comment['userid']) {
			$user = $db->query_return("SELECT username FROM user WHERE id = '$comment[userid]'");
			$_REQUEST['oldusername'] = $user['username'];
		
		// only have email address. Check if there is a username or not
		} elseif ($comment['useremail']) {

			if ($userid = userid_from_email($comment['useremail'])) {

				// we found the user, so get username
				$user = $db->query_return("SELECT username FROM user WHERE id = '$userid'");
				$_REQUEST['oldusername'] = $user['username'];
			
			} else {

				// new user
				$new_user_email  = $comment['useremail'];
				$new_start = 1;
			}
		}
	}

	$help = table_thelp('<B>Email / Username for current user</B>', 'Tickets - Starting New', 'Specifying User');

	$bit =  form_radio_single('new_user', 'old', $old_start, 'onClick="oc2(\'0\',\'user_creation\');"') . "&nbsp;&nbsp;&nbsp;" . form_input('oldusername', $_REQUEST['oldusername']) . iff(is_array($userselect), "&nbsp;&nbsp;&nbsp;" . form_select('userchoice', $userselect, '', $_REQUEST['userchoice'])) . "$html&nbsp;&nbsp;&nbsp;<a href=\"#\" onClick=\"openWindow('./../users/quickfind.php?name=dpreply.oldusername', 450, 600, 'userfind')\">" . html_image('tech/bul084.gif') . "</a>";
	$table[] = array($help, $bit);

	$help = table_thelp('<B>Email address of new user</B>', 'Tickets - Starting New', 'Specifying User');

	$bit =  form_radio_single('new_user', 'new', $new_start, ' onClick="oc2(\'1\',\'user_creation\');"') . "&nbsp;&nbsp;&nbsp;" .  form_input('email', $new_user_email);
	$table[] = array($help, $bit);

	$help = table_thelp('<B>Subject</B>', 'Tickets - Starting New', 'Subject');
	$bit = form_input('subject', $_REQUEST['subject']);
	$table[] = array($help, $bit);

	$help = table_thelp('<B>Category</B>', 'Tickets - Starting New', 'Category');
	$bit = form_select('ticket_category', $categories, '', $_REQUEST[ticket_category]);
	$table[] = array($help, $bit);

	$help = table_thelp('<B>Priority</B>', 'Tickets - Starting New', 'Priority');
	$bit = form_select('priority', $priority, '', $_REQUEST[priority]);
	$table[] = array($help, $bit);

	if ($repeat) {
		$starting_techs = $_REQUEST['tech'];
	} else {
		$starting_techs = $user['id'];
	}

	$help = table_thelp('<B>Assigned Technician</B>', 'Tickets - Starting New', 'Assigned Technician');
	$bit = form_select('tech', $tech, '', $starting_techs);
	$table[] = array($help, $bit);

	$help = table_thelp('<B>Attachments</B>', 'Tickets - Starting New', 'Attachment');
	$table[] = array($help, "<input type=\"file\" name=\"attachment1\"><br /><input type=\"file\" name=\"attachment2\"><br /><input type=\"file\" name=\"attachment3\"><br /><input type=\"file\" name=\"attachment4\"><br /><input type=\"file\" name=\"attachment5\">");

	$table[] = table_midheader('Message');

	// sort out old message / signature
	if ($_REQUEST[reply]) {
		$show_message = $_REQUEST[reply];
	} else {
		$show_message = "\n\n--\n$user[signature]";
	}

	$help = thelp('Quick Replies', 'Inserting into Tickets');
	$uhelp = table_thelp('User Message', 'Tickets - Starting New', 'User Message');
	$thelp = table_thelp('Your Message', 'Tickets - Viewing and Responding', 'Your Message');
	$table[] = array(
		'<center>
		<select name="drop" style="width:150" onchange="top.empty.showdata(dpreply.drop.value)"></select><br /><br />
		<select size="10" name="list3" style="width:150"></select><BR />
		<input type="hidden" name="category" value="1">
		<input type="button" onClick="top.empty.godeep(dpreply.list3.value,dpreply.category.value)" value="Insert into Reply"><br /><br /> ' . $help . '
		</center>',
		"<table cellpadding=\"0\" cellspacing=\"0\"><tr>
		<td>$uhelp<b>" . 
		form_textarea('usermessage' ,'85', '5', $_REQUEST['usermessage']) . spellcheck_button('dpreply', 'usermessage') .
		"<br />$thelp
		<TEXTAREA NAME=\"reply\" ROWS=\"12\" COLS=\"85\"
			ONSELECT=\"top.empty.storeCaret(this);\"
			ONCLICK=\"top.empty.storeCaret(this);\"
	        ONKEYUP=\"top.empty.storeCaret(this);\">$show_message</TEXTAREA>" . spellcheck_button('dpreply', 'reply') . "
		</td> </tr><tr><td colspan=\"2\">
		</td></tr></table>"
		);

	$help = table_thelp('<B>Options</B>', 'Tickets - Starting New', 'Options');
	$table[] = array($help, "
		<table>
		<tr>
		<td>" . form_checkbox_single('create_faq', 1, $_REQUEST['create_faq']) . " Create FAQ article from this ticket</td>
		<td>" . form_checkbox_single('close_ticket', 1, $_REQUEST['close_ticket']) . " Close this ticket</td>
		</tr>
		<tr><td>" . form_checkbox_single('email_user', '1', if_default($_REQUEST['email_user'], $repeat, 1)) . " Email this ticket to the user</td>
		<td>" . form_checkbox_single('set_awaiting_user', '1', if_default($_REQUEST['set_awaiting_user'], $repeat, 1)) . " Set ticket as Awaiting User Response</td>
		</tr>
		</table>");

	// get rest of ticket data
	$db->query("
	SELECT * 
	FROM ticket_def
	WHERE tech_editable
	");

	if ($db->num_rows()) {
		$table[] = table_midheader('Custom Ticket Fields');
		while ($result = $db->row_array()) {
			$result[display_name] = unserialize($result[display_name]);
			$result[display_name] = $result[display_name][$settings[default_language]];
			$result[description] = unserialize($result[description]);
			$result[description] = $result[description][$settings[default_language]];
			
			$table[] = array("<b>" . $result[display_name] . "</b><br />" . $result[description], 
				field_def(
				$result, 
				'redo', 
				$_REQUEST[ticket_fields][$result[name]], 
				$_REQUEST[ticket_fields]["extra" . $result[name]], 
				'', 
				'ticket_fields')
			);
		}
	}

	table_header('Create new ticket', '', '', '', 'dpreply', 1);
	table_content('', $table);
	table_footer('', '', "<input type=\"submit\" name=\"Send\" value=\"Create Ticket\">");	
	unset($columns, $table);

	?>
	<SCRIPT langauge="JavaScript">
	top.empty.buildselect();
	top.empty.showdata('0');

	</SCRIPT>

	<?

############################### FIELD TO ENTER NEW USER DATA ###############################

	$db->query("SELECT * FROM user_def WHERE tech_editable ORDER BY displayorder");

	$table[] = array(error_marker('username') . '<b>Username</b>', form_input('username', $_REQUEST['username']));
	$table[] = array(error_marker('password') . '<b>Password</b><br />If left empty a random password will be generated', form_password('password', $_REQUEST['password']));
	$table[] = array(error_marker('password1') . '<b>Repeat Password</b>', form_password('password1', $_REQUEST['password1']));
	
	if ($db->num_rows()) {
		$table[] = table_midheader('Custom User Fields');
	}

	while ($result =  $db->row_array()) {

		$result[display_name] = unserialize($result[display_name]);
		$result[display_name] = $result[display_name][$settings[default_language]];

		$result[description] = unserialize($result[description]);
		$result[description] = $result[display_name][$settings[description]];

		$bit = field_def(
			$result, 
			'redo', 
			$_REQUEST[user_fields][$result[name]], 
			$_REQUEST[user_fields]["extra" . $result[name]], 
			'', 
			'user_fields'
		);
		$table[] = array("<b>$result[display_name]</b>", $bit);

	}

	echo "<DIV id='user_creation'>";

	table_header('Custom User Fields (Optional)');
	table_content($columns, $table);
	table_footer('', '', "<input type=\"submit\" name=\"Send\" value=\"Create Ticket\">");

	echo "
	<SCRIPT language='javascript'>
	function oc2(element, id) {
		e=document.getElementById(id).style;
		if (element == 0) {
			e.display='none';
		} else {
			e.display='';
		}
	}
	";

	// display or not display user fields
	if (!$new_start) {
		echo "oc('user_creation')";
	}

	echo "
	</SCRIPT>
	";

	echo "</form>";
}

tech_footer();
?>

⌨️ 快捷键说明

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