📄 ticketview.php
字号:
$table_ticket_fields2[] = array("
<b>$ticket_data[display_name]</b><br />$ticket_data[description]",
$ticket_custom[$ticket_data[name]]
);
}
}
############################### EDIT FIELDS (displayed after a click) ###############################
if (!(($ticket[tech] != $user[id]) && ($ticket[tech] != "0") && ($user[p_tech_edit] != "1"))) {
$bit = form_input('subject', $ticket['subject']);
$table_temp[] = array('<b>Subject</b>', $bit);
$bit = form_select('category', $category, '', $ticket['category']);
$table_temp[] = array("<b>Category</b>", $bit);
$bit = form_select('priority', $priority, '', $ticket['priority']);
$table_temp[] = array('<b>Priority</b>', $bit);
$bit = form_select('tech', $techname, '', $ticket['techid']);
if (!$ticket['awaiting_tech']) {
$bit = "<table><tr><td>$bit</td><td>" . form_checkbox_single('awaiting_tech', 1, 1) . ' Mark ticket "Awaiting Tech Response"</td></tr></table>';
}
$table_temp[] = array('<b>Tech</b>', $bit);
$table_ticket_fields2 = array_merge($table_temp, $table_ticket_fields2);
}
############################### CALENDAR FUNCTIONS ###############################
$table_calendar[0] .= "<table cellpadding=\"0\" cellspacing=\"0\"><tr>";
$table_calendar[0] .= form_hidden('do', 'reminder');
$table_calendar[0] .= form_hidden('id', $ticket[id]);
$table_calendar[0] .= "<td><b>Remind</b> ";
$table_calendar[0] .= form_select('tech', $techlist, NULL, $user['id']);
$table_calendar[0] .= "<select name=\"days\">
<option value=\"1\">1</option>
<option value=\"7\">7</option>
<option value=\"14\">14</option>
<option value=\"21\">21</option>
<option value=\"28\">28</option>
</select>";
$table_calendar[0] .= " <b>days</b> <input type=\"submit\" name=\"remind1\" value=\"Remind\"> " . thelp('Tickets - Viewing and Responding', 'Remind After Interval');
$table_calendar[0] .= "</td></tr>";
$table_calendar[0] .= "</table>";
$table_calendar[1] .= "<table cellpadding=\"0\" cellspacing=\"0\"><tr>";
$table_calendar[1] .= "<td><b>Remind</b> ";
$table_calendar[1] .= form_select('tech2', $techlist, NULL, $user['id']);
$table_calendar[1] .= form_date('date', '', '', '1');
$table_calendar[1] .= " <input type=\"submit\" name=\"remind2\" value=\"Remind\"> " . thelp('Tickets - Viewing and Responding', 'Remind On Date');
$table_calendar[1] .= "</td></tr>";
$table_calendar[1] .= "</table>";
$watches = $db->query_return_array("SELECT * FROM tech_ticket_watch WHERE ticketid = '$id' AND techid = '$user[id]'");
if (is_array($watches)) {
$table_calendar[2] = table_midheader('Reminders');
$table_calendar[3] .= "<TABLE><TR>
<TD ALIGN=\"center\"><B>Added</B></TD><TD> </TD>
<TD ALIGN=\"center\"><B>Due</B></TD><TD> </TD>
<TD ALIGN=\"center\"><B>Done?</B></TD></TR>";
foreach ($watches AS $watch) {
$watch['datetodo_exp'] = explode('-', $watch['datetodo']);
$link = "<A HREF=\"ticketedit.php?do=remindertoggle&id=$id&watchid=$watch[id]\">";
$table_calendar[3] .= "<TR><TD>" . our_date($watch['created']) . "</TD><TD> </TD><TD>"
. our_date(strtotime($watch['datetodo'])) . "</TD><TD> </TD><TD>" .
iff($watch['completed'], "$link Yes</A>", "$link No</A>") . "</TD></TR>";
}
$table_calendar[3] .= "</TABLE>";
}
############################### PAYMENT FUNCTIONS ################################
$table_payment[] .= "<input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"hidden\" name=\"do\" value=\"charge\">Charge this user: <input type=\"text\" name=\"charge\" size=\"5\" value=\"0.00\"> <input type=\"submit\" name=\"charge1\" value=\"Charge\"> " . thelp('Tickets - Viewing and Responding', 'Charge Amount');
$table_payment[] .= "<input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"hidden\" name=\"userid\" value=\"$ticket[userid]\">Add time charge: <input type=\"text\" name=\"hours\" size=\"2\"> h <input type=\"text\" name=\"minutes\" size=\"2\"> m <input type=\"text\" name=\"seconds\" size=\"2\"> s <input type=\"submit\" name=\"charge2\" value=\"Charge\"> " . thelp('Tickets - Viewing and Responding', 'Charge Time');
$table_payment[] .= "<input type=\"button\" name=\"remind1\" value=\"Start Timer\" onClick=\"timer_Start(); return true\"> <input type=\"button\" name=\"remind1\" value=\"Stop Timer\" onClick=\"timer_Stop();\"> <input type=\"button\" name=\"remind1\" value=\"Stop/Reset Timer\" onClick=\"timer_Reset(); timer_Stop(); return true;\"> " . thelp('Tickets - Viewing and Responding', 'Timer');
############################### BILLING DETAILS ################################
$db->query("SELECT user_bill.*, tech.username AS techname
FROM user_bill
LEFT JOIN tech ON tech.id = user_bill.techid
WHERE ticketid = '$ticket[id]'
ORDER BY stamp");
$help = thelp('Tickets - Viewing and Responding', 'Billing Details and Actions');
$table_billing_cols = array('Billing Tech', 'Time', 'Charge', "Paid $help", "Billable $help", 'Date', "Delete $help");
while ($bill = $db->row_array()) {
if ($bill['paid']) {
$bill['paid'] = "<A HREF=\"ticketedit.php?do=updatebillingpaid&id=$id&billid=$bill[id]&paid=0\">Y</A>";
} else {
$bill['paid'] = "<A HREF=\"ticketedit.php?do=updatebillingpaid&id=$id&billid=$bill[id]&paid=1\">N</A>";
}
if ($bill['billable']) {
$bill['billable'] = "<A HREF=\"ticketedit.php?do=updatebillingbillable&id=$id&billid=$bill[id]&billable=0\">Y</A>";
} else {
$bill['billable'] = "<A HREF=\"ticketedit.php?do=updatebillingbillable&id=$id&billid=$bill[id]&billable=1\">N</A>";
}
$table_billing[] = array(
$bill['techname'],
clean_time($bill['time']),
number_format($bill['charge'], 2),
$bill['paid'],
$bill['billable'],
our_date($bill['stamp']),
"<A HREF=\"ticketedit.php?do=deletebilling&id=$id&billid=$bill[id]\">Delete</A>"
);
}
if (!count($table_billing)) {
$table_billing[] = array('No billing events.');
$billing = 0;
} else {
$billing = 1;
}
############################### USER DATA ###############################
$banned = unserialize(get_data('email_ban'));
if (@in_array($ticket['email'], $banned)) {
$banned = ' <I>Banned</I>';
} else {
$banned = '';
}
$ticket_user = $db->query_return("SELECT * FROM user WHERE id = '$ticket[userid]'");
if (!$ticket_user['email']) {
$ticket_user['email'] = '<I>None</I>';
} else {
$ticket_user['email'] = "<A HREF=\"mailto:$ticket_user[email]\">$ticket_user[email]</A>";
}
$table_user[] = array("<b>Name:</b>", iff($ticket_user[name], $ticket_username['name'], 'n/a'));
$table_user[] = array("<b>Username</b>", $ticket_user['username'] . " <A HREF=\"newticket.php?oldusername=$ticket_user[username]\">(new ticket)</A>");
$table_user[] = array("<b>Email</b>", "$ticket_user[email] $banned");
if ($ticket_user['autoresponds']) {
$autoresp = "<A HREF=\"ticketactions.php?do=autoresp&id=$id&userid=$ticket_user[id]&val=0\"><B>Yes</B></A>";
} else {
$autoresp = "<A HREF=\"ticketactions.php?do=autoresp&id=$id&userid=$ticket_user[id]&val=1\">No</A>";
}
$table_user[] = array(table_thelp('<B>Autoresponds?</B>', 'Users', 'Edit: Has Autoresponder?'), $autoresp);
$db->query("
SELECT * FROM user_def WHERE tech_viewable ORDER by displayorder
");
while ($user_data = $db->row_array()) {
$user_data['display_name'] = unserialize($user_data[display_name]);
$user_data['display_name'] = $user_data[display_name][$settings[default_language]];
$table_user[] = array("<B>$user_data[display_name]</B>", field_display($user_data, $ticket_user[$user_data['name']]));
}
############################### ADMIN FIELDS ###############################
if (is_array($admincols)) {
foreach($admincols AS $name => $val) {
$val = addslashes($val);
eval("\$val = \"$val\";");
$table_ticket_fields[] = array("<B>$name</B>", $val);
}
}
############################### USER TICKETS ###############################
if ($_REQUEST['do'] == 'viewall') {
$term = '';
} else {
$term = 'LIMIT 0,10';
}
$db->query("
SELECT id,subject,is_open,awaiting_tech
FROM ticket
WHERE userid = '$ticket[userid]'
AND id != '$ticket[id]'
ORDER BY is_open desc, awaiting_tech desc, date_lastreply $term
");
while ($user_tickets = $db->row_array()) {
if ($user_tickets[is_open]) {
$isopen = "Open";
} else {
$isopen = "Closed";
}
$table_user_tickets[] = array(
"<a href=\"ticketview.php?id=$user_tickets[id]\">$user_tickets[subject]</a>",
$isopen,
iff($user_tickets['awaiting_tech'], 'Tech', 'User'),
jprompt("This will merge ticket #$user_tickets[id] into the ticket being viewed (#$ticket[id]).\\n Note that any fields set for ticket #$user_tickets[id] will be lost if you proceed.",
"ticketactions.php?do=merge&fromticket=$user_tickets[id]&toticket=$ticket[id]",
'Merge'
)
);
}
if ($_REQUEST['do'] == 'viewall') {
$table_user_tickets_header = "Showing user's $count[total] other ticket(s)";
$table_user_tickets_footer = redirect_button('Show only recent tickets', "./../tickets/ticketview.php?id=$ticket[id]");
} else {
// need to get total
$count = $db->query_return("
SELECT COUNT(*) AS total
FROM ticket
WHERE userid = '$ticket[userid]'
AND id != '$ticket[id]'
");
if ($count[total] > 10) {
$table_user_tickets_header = "Showing last 10 of $count[total] other tickets";
$table_user_tickets_footer = redirect_button('Show all tickets', "./../tickets/ticketview.php?do=viewall&id=$ticket[id]");
} else {
$table_user_tickets_header = "Showing user's $count[total] other ticket(s)";
$table_user_tickets_footer = '';
}
}
############################### ATTACHMENTS ###############################
$db->query("SELECT filesize, id, filename FROM ticket_attachments WHERE ticketid = '$id'");
if ($db->num_rows() > 0) {
$is_attachment = 1;
$cols = array(
'Name',
'Size',
'Uploaded By',
'Download',
'Delete'
);
while ($attachment = $db->row_array()) {
$attachment['filesize'] = number_format($attachment[filesize] / 1024, 2);
$table_attachments[] = array(
$attachment['filename'],
$attachment['filesize'] . " kb",
"<a href=\"attachment.php?id=$attachment[id]\">download</a>",
jprompt(
'This will delete the attachment.',
"attachment.php?do=delete&id=$attachment[id]",
"Delete"
)
);
}
}
############################### MESSAGES ###############################
function quotemessage($message) {
$message = preg_replace("/(\r\n|\n|\r)/", "\n> ", $message);
$message = addslashes_js($message);
$message = '\\r\\n> ' . $message;
return $message;
}
$table_messages[0] = '';
$table_message_count = 0;
$total_messages = $db->query_return("SELECT count(*) AS total FROM ticket_message WHERE ticketid = '$id'");
$total_messages = $total_messages['total'];
if ($_REQUEST[messages] == 'all') {
$table_message_start = 0;
$limit = '';
} else {
$table_message_start = $total_messages - 10;
if ($table_message_start < 0) {
$table_message_start = 0;
}
$limit = "LIMIT $table_message_start,10";
}
$db->query("
SELECT ticket_message.*, tech.username AS t_username, user.username AS u_username
FROM ticket_message
LEFT JOIN tech ON ticket_message.techid = tech.id
LEFT JOIN user ON ticket_message.userid = user.id
WHERE ticket_message.ticketid = '$id'
ORDER by ticket_message.date
$limit
");
$timerjs = "
<script language=\"JavaScript\">
var timerID = 0;
var tStart = null;
function timer_UpdateTimer() {
if(timerID) {
clearTimeout(timerID);
timerID = 0;
}
if(!tStart) {
tStart = new Date();
}
var tDate = new Date();
var tDiff = (tDate.getTime() - tStart.getTime()) + 1000;
tDiff = tDiff / 1000;
var tHours = parseInt(tDiff / 3600);
tDiff = tDiff - (tHours * 3600);
var tMinutes = parseInt(tDiff / 60);
tDiff = tDiff - (tMinutes * 60);
var tSeconds = parseInt(tDiff);
document.payment.hours.value = tHours;
document.payment.minutes.value = tMinutes;
document.payment.seconds.value = tSeconds;
timerID = setTimeout(\"timer_UpdateTimer()\", 1000);
}
function validate() {
if (document.dpreply.reply.value == '') {
alert('Please enter a message.');
return false;
} else {
return true;
}
}
function timer_Start() {
tStart = new Date();
document.payment.hours.value = \"0\";
document.payment.minutes.value = \"0\";
document.payment.seconds.value = \"0\";
timerID = setTimeout(\"timer_UpdateTimer()\", 1000);
}
function timer_Stop() {
if(timerID) {
clearTimeout(timerID);
timerID = 0;
}
tStart = null;
}
function timer_Reset() {
tStart = null;
document.payment.hours.value = \"0\";
document.payment.minutes.value = \"0\";
document.payment.seconds.value = \"0\";
}
timer_Stop();
</script>
";
$js = "
<SCRIPT LANGUAGE=\"JavaScript\">
function quote(id) {
var data = new Array();
";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -