function NewTicket()
{
    DoMenu();
    global $db, $socketfrom, $socketfromname, $maintablewidth, $maintablealign, $sess_uid, $prefix, $cookie, $tr_color1;
    // IF THE FORM IS SUBMITTED THEN VERIFY SOME CONTENTS
    if (isset($_POST[submit])) {
        // IF FORM IS NOT FILLED OUT CORRECTLY THEN SHOW ERROR MESSAGES
        if ($_POST['message'] == '' || $_POST['ticketsubject'] == '') {
            ?>
					<table width="<?php 
            echo $maintablewidth;
            ?>
" cellspacing="1" cellpadding="1" border="1" class="boxborder" align="<?php 
            echo $maintablealign;
            ?>
">
					  <tr>
						<td><br /><blockquote><p>Please complete all the fields.</p></blockquote></td>
					  </tr>
					</table>
<?php 
        } else {
            $urgency = explode('|', $_POST['urgency']);
            $category = explode('|', $_POST['category']);
            $date = getdate();
            $query = "INSERT INTO " . $prefix . "_hosting_tickets_tickets\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\ttickets_uid = '" . $sess_uid . "',\r\n\t\t\t\t\t\t\t\ttickets_subject = '" . $_POST[ticketsubject] . "',\r\n\t\t\t\t\t\t\t\ttickets_timestamp = '" . $date[mon] . "/" . $date[mday] . "/" . $date[year] . " - " . $date[hours] . ":" . $date[minutes] . ":" . $date[seconds] . "',\r\n\t\t\t\t\t\t\t\ttickets_name = '" . $_POST[PostName] . "',\r\n\t\t\t\t\t\t\t\ttickets_email = '" . $_POST[email] . "',\r\n\t\t\t\t\t\t\t\ttickets_urgency = '" . $urgency[0] . "',\r\n\t\t\t\t\t\t\t\ttickets_category = '" . $category[0] . "',\r\n\t\t\t\t\t\t\t\ttickets_admin = '" . $cookie[1] . "',\r\n\t\t\t\t\t\t\t\ttickets_question = '" . addslashes($_POST[message]) . "'";
            if ($db->sql_query($query)) {
                $result = $db->sql_query("SELECT tickets_id FROM " . $prefix . "_hosting_tickets_tickets WHERE tickets_uid = '" . $sess_uid . "' ORDER BY tickets_id ASC");
                while ($row = $db->sql_fetchrow($result)) {
                    $lastinsertid = $row[tickets_id];
                }
                // CHECK THE FILE ATTACHMENT AND DISPLAY ANY ERRORS
                if ($allowattachments == 'TRUE') {
                    FileUploadsVerification("{$_FILES}(userfile)", $lastinsertid);
                }
                // EMAIL ADMINISTRATOR THE TICKET NOTIFICATION
                $message = "Ticket ID:\t " . $lastinsertid . "\n";
                $message .= "Name:\t\t " . $_POST['PostName'] . "\n";
                $message .= "Email:\t " . $_POST['email'] . "\n";
                $message .= "Subject:\t " . $_POST['ticketsubject'] . "\n";
                $message .= "Urgency:\t " . $urgency['1'] . "\n";
                $message .= "Department:\t " . $category['1'] . "\n";
                $message .= "Post Date:\t " . date($dformatemail) . "\n";
                $message .= "----------------------------------------------------------------------\n";
                $message .= "Message:\n";
                $message .= stripslashes($_POST['message']) . "\n";
                $message .= "----------------------------------------------------------------------\n";
                $mailheaders = "From: " . $_POST['email'] . "\n";
                $mailheaders .= "Reply-To: " . $_POST['email'] . "\n\n";
                $subject = "New Ticket Created: " . $lastinsertid . "\n\n";
                mail($socketfrom, $subject, $message, $mailheaders);
            } else {
                echo "error";
            }
            ?>
<meta http-equiv="refresh" content="0;URL=<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?name=<?php 
            echo $_GET[name];
            ?>
&amp;caseid=view&amp;ticketid=<?php 
            echo $lastinsertid;
            ?>
" /><?php 
        }
    } else {
        // PRODUCE THE FORM SO THE PERSON CAN WRITE THE NEW TICKET
        $query = "\tSELECT user_email, username FROM " . $prefix . "_users WHERE user_id = '" . $sess_uid . "' LIMIT 0,1";
        $result = $db->sql_query($query);
        $row = $db->sql_fetchrow($result);
        ?>
			<form enctype="multipart/form-data" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?name=<?php 
        echo $_GET[name];
        ?>
&amp;caseid=NewTicket" method="post">
			<table width="<?php 
        echo $maintablewidth;
        ?>
" cellspacing="1" cellpadding="4" border="1" class="boxborder" align="<?php 
        echo $maintablealign;
        ?>
">
			  <tr>
				<td class="boxborder" width="50%" valign="top"><p>

				<table width="100%" cellspacing="1" cellpadding="1" border="1" class="boxborder" align="center">
				  <tr bgcolor="<?php 
        echo $tr_color1;
        ?>
">
					<td class="boxborder" colspan="2"><p><b>New Support Ticket - All Fields Required</b></p></td>
				  </tr>
				  <tr>
					<td bgcolor="<?php 
        echo $tr_color1;
        ?>
" class="boxborder"><p><b>Username:</b></p></td>
					<td class="boxborder"><p><input type="hidden" name="PostName" size="40" value="<?php 
        echo $row[username];
        ?>
" /><?php 
        echo $row[username];
        ?>
</p></td>
				  </tr>
				  <tr>
					<td bgcolor="<?php 
        echo $tr_color1;
        ?>
" class="boxborder"><p><b>Email:</b></p></td>
					<td class="boxborder"><p><input type="hidden" name="email" size="40" value="<?php 
        echo $row[user_email];
        ?>
" /><?php 
        echo $row[user_email];
        ?>
</p></td>
				  </tr>
				  <tr>
					<td bgcolor="<?php 
        echo $tr_color1;
        ?>
" class="boxborder"><p><b>Subject:</b></p></td>
					<td class="boxborder"><p><input name="ticketsubject" size="40"
<?php 
        if (isset($_POST['ticketsubject']) && $_POST['ticketsubject'] != '') {
            echo ' value="' . $_POST['ticketsubject'] . '"';
        }
        ?>
					></p></td>
				  </tr>
				  <tr>
					<td bgcolor="<?php 
        echo $tr_color1;
        ?>
" class="boxborder"><p><b>Department:</b></p></td>
					<td class="boxborder"><p>
					<select name="category">
<?php 
        $query = "\tSELECT tickets_categories_id, tickets_categories_name\r\n\t\t\t\t\tFROM " . $prefix . "_hosting_tickets_categories\r\n\t\t\t\t\tORDER BY tickets_categories_name ASC";
        $result = $db->sql_query($query);
        while ($row = $db->sql_fetchrow($result)) {
            echo '<option value="' . $row['tickets_categories_id'] . '|' . $row['tickets_categories_name'] . '">' . $row['tickets_categories_name'] . '</option>';
        }
        ?>
					</select>
					</p></td>
				  </tr>
				  <tr>
					<td bgcolor="<?php 
        echo $tr_color1;
        ?>
" class="boxborder"><p><b>Urgency:</b></p></td>
					<td class="boxborder"><p>
					<select name="urgency">
<?php 
        $query = "\tSELECT tickets_status_id, tickets_status_name, tickets_status_color\r\n\t\t\t\t\tFROM " . $prefix . "_hosting_tickets_status\r\n\t\t\t\t\tORDER BY tickets_status_order ASC";
        $result = $db->sql_query($query);
        while ($row = $db->sql_fetchrow($result)) {
            echo '<option style="background-color:#' . $row['tickets_status_color'] . '" value="' . $row['tickets_status_id'] . '|' . $row['tickets_status_name'] . '">' . $row['tickets_status_name'] . '</option>';
        }
        ?>
					</select></p></td>
				  </tr>
				</table><div style="padding-top:5px"></div>

				<table width="100%" cellspacing="1" cellpadding="1" border="1" class="boxborder" align="center">
				  <tr bgcolor="<?php 
        echo $tr_color1;
        ?>
">
					<td class="boxborder"><p><b>Question</b></p></td>
				  </tr>
				  <tr>
					<td align="right">
					<textarea name="message" cols="65" rows="10">
<?php 
        if (isset($_POST['message']) && $_POST['message'] != '') {
            echo $_POST['message'] . '</textarea>';
        } else {
            echo '</textarea>';
        }
        ?>
					<input type="submit" name="submit" value="Submit" />
					</td>
				  </tr>
				</table>
<?php 
        // ALLOW THE USERS TO ATTACH A FILE TO THE TICKET
        if ($allowattachments == 'TRUE') {
            FileUploadForm();
        }
        ?>
				</p></td>
				</p></td>
				<td class="boxborder" width="50%" valign="top">

				<table width="100%" cellspacing="1" cellpadding="1" border="1" class="boxborder" align="center">
<?php 
        // IF ATTACHMENTS ARE TRUE THEN SHOW ALLOWED FILETYPES
        if ($allowattachments == 'TRUE') {
            ?>
				  <tr>
					<td><p><b>Allowed FILE TYPES for attachments:</b><br />
<?php 
            for ($i = '0'; $i <= COUNT($allowedtypes) - 1; $i++) {
                echo $allowedtypes[$i] . '<br />';
            }
            ?>
					</p></td>
				  </tr>
<?php 
        }
        ?>
				</table>

				</td>
			  </tr>
			</table>
			</form>
<?php 
        if (isset($refresh) && $refresh == 'TRUE') {
            ?>
				<meta http-equiv="refresh" content="2;URL=<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?name=<?php 
            echo $_GET[name];
            ?>
&amp;caseid=view&amp;ticketid=<?php 
            echo $lastinsertid;
            ?>
" />
<?php 
        }
    }
}
示例#2
0
          <tr>
            <td class="text" colspan="2"> Firstly you must assign this ticket to an already active account. If the
              user is not active then please add them <a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?caseid=AddUser" title="add user">here</a>. </td>
          </tr>
          <?php 
        }
        ?>
        </table>
        <div style="padding-top:5px"></div>
        <?php 
        // ALLOW THE USERS TO ATTACH A FILE TO THE TICKET
        if (isset($_POST['account']) && $allowattachments == 'TRUE' && (!isset($_COOKIE['demomode']) || $demomode != 'ON')) {
            FileUploadForm();
        }
        ?>
        <br /></td>
      <td class="boxborder" width="50%" valign="top" style="padding-top:5px"><table width="97%" cellspacing="1" cellpadding="1" class="boxborder" align="center">
          <tr>
            <td class="text">Please fill in all the information. And make sure the question is very
              explicit as to what the problem is, some guidelines follow:
              <ul>
                <li>Type of question (bug / content / Other)</li>
                <li>When did you see this (date and time)</li>
                <li>Is there a location to see this bug (URL / Media)</li>
                <li>Description (detailed but concise)</li>
              </ul>
              Make sure all fields are filled in; the script will check for
              a correctly formed email address. Please choose the category that
    function AdminView()
    {
        global $db, $uploadpath, $aid, $prefix, $relativepath, $socketfrom, $socketfromname;
        if (isset($_GET['closesub'])) {
            $query = "UPDATE nuke_hosting_tickets_tickets\r\n\t\t\t\t\t\tSET tickets_status = '" . $_GET['closesub'] . "'\r\n\t\t\t\t\t\tWHERE tickets_id = '" . $_GET['ticketid'] . "'";
            if ($db->sql_query($query)) {
                $msg = 'Ticket ' . $_GET['closesub'];
            } else {
                $msg = 'This could not be done at this time';
            }
            ?>
				<table width="<?php 
            echo $maintablewidth;
            ?>
" cellspacing="1" cellpadding="1" border="1"  align="<?php 
            echo $maintablealign;
            ?>
">
				  <tr bgcolor="#AACCEE">
					<td><p><?php 
            echo $msg;
            ?>
</p></td>
				  </tr>
				</table>
<?php 
        }
        // AND A NEW RESPONSE AND ATTACHMENT TO THE SYSTEM
        if (isset($_POST[submit])) {
            if ($_POST['message'] == '') {
                $msg = 'Please complete all the fields';
            } else {
                $urgency = explode('|', $_POST['posturgency']);
                $category = explode('|', $_POST['postdept']);
                $date = getdate();
                $query = "INSERT INTO nuke_hosting_tickets_tickets\r\n\t\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\ttickets_uid = '" . $_POST[uid] . "',\r\n\t\t\t\t\t\t\t\ttickets_subject = '" . $_POST['postsubject'] . "',\r\n\t\t\t\t\t\t\t\ttickets_timestamp = '" . $date[mon] . "/" . $date[mday] . "/" . $date[year] . " - " . $date[hours] . ":" . $date[minutes] . ":" . $date[seconds] . "',\r\n\t\t\t\t\t\t\t\ttickets_urgency = '" . $urgency['0'] . "',\r\n\t\t\t\t\t\t\t\ttickets_category = '" . $category['0'] . "',\r\n\t\t\t\t\t\t\t\ttickets_admin = '" . $aid . "',\r\n\t\t\t\t\t\t\t\ttickets_child = '" . $_GET['ticketid'] . "',\r\n\t\t\t\t\t\t\t\ttickets_question = '" . $_POST['message'] . "'";
                if ($result = $db->sql_query($query)) {
                    // CHECK THE FILE ATTACHMENT AND DISPLAY ANY ERRORS
                    if ($allowattachments == 'TRUE') {
                        FileUploadsVerification("{$_FILES}(userfile)", mysql_insert_id());
                    }
                    // MAIL THE PERSON WHO STARTED THE TICKET
                    $message = "Ticket ID:\t " . $_GET['ticketid'] . " - This has been responded too.\n";
                    $message .= "Name:\t\t " . $_POST['name'] . "\n";
                    $message .= "Email:\t " . $_POST['email'] . "\n";
                    $message .= "Subject:\t " . $_POST['postsubject'] . "\n";
                    $message .= "Urgency:\t " . $urgency['1'] . "\n";
                    $message .= "Department:\t " . $category['1'] . "\n";
                    $message .= "Post Date:\t " . $date[mon] . "/" . $date[mday] . "/" . $date[year] . " - " . $date[hours] . ":" . $date[minutes] . ":" . $date[seconds] . "\n";
                    $message .= "----------------------------------------------------------------------\n";
                    $message .= "Message:\n";
                    $message .= stripslashes($_POST['message']) . "\n";
                    $message .= "----------------------------------------------------------------------\n\n\n";
                    $message .= "Previous Thread Messages (Latest First):\n";
                    $message .= "----------------------------------------------------------------------\n";
                    // LOOP THROUGH THE PREVIOUS MESSAGES AND ADD DATA REGARDING QUESTION TIME AND ATTACHMENT
                    for ($i = count($_POST['ticketquestion']) - 1; $i >= 0; $i--) {
                        $message .= $_POST['postedby'][$i] . " - " . $_POST['postdate'][$i] . "\n";
                        $message .= stripslashes($_POST['ticketquestion'][$i]);
                        if (isset($_POST['attachment'][$i]) && $_POST['attachment'][$i] != '') {
                            $message .= "\nAttachment - " . $_POST['attachment'][$i];
                        }
                        $message .= "\n----------------------------------------------------------------------\n";
                    }
                    $message .= "\nRegards\n\n";
                    $message .= $socketfromname;
                    $mailheaders = "From: " . $socketfrom . "\n";
                    $mailheaders .= "Reply-To: " . $socketfrom . "\n\n";
                    $subject = "Response to your ticket: " . $_GET[ticketid] . "\n\n";
                    mail($_POST[email], $subject, $message, $mailheaders);
                }
            }
        }
        // QUERY TO GET THE TICKET INFORMATION
        $query = "\tSELECT tickets_id, tickets_subject, tickets_uid, tickets_timestamp, tickets_status, tickets_name, tickets_email, tickets_admin, tickets_child, tickets_question, tickets_status_id, tickets_status_name, tickets_status_color, tickets_categories_id, tickets_categories_name\r\n\t\t\t\t\tFROM nuke_hosting_tickets_tickets a, nuke_hosting_tickets_status b, nuke_hosting_tickets_categories c\r\n\t\t\t\t\tWHERE (a.tickets_id = '" . $_GET[ticketid] . "'\r\n\t\t\t\t\tOR tickets_child = '" . $_GET[ticketid] . "')\r\n\t\t\t\t\tAND a.tickets_urgency = b.tickets_status_id\r\n\t\t\t\t\tAND a.tickets_category = c.tickets_categories_id\r\n\t\t\t\t\tORDER BY tickets_id ASC";
        $result = $db->sql_query($query);
        $totaltickets = $db->sql_numrows($result);
        $row = $db->sql_fetchrow($result);
        ?>
			<table width="<?php 
        echo $maintablewidth;
        ?>
" cellspacing="1" cellpadding="1" border="1"  align="<?php 
        echo $maintablealign;
        ?>
">
			  <tr>
				<td width="50%" valign="top">

				<table width="97%" cellspacing="1" cellpadding="1" border="1"  align="<?php 
        echo $maintablealign;
        ?>
">
				  <tr bgcolor="#AABBDD">
					<td  colspan="2"><p><b>Ticket #<?php 
        echo $_GET['ticketid'];
        ?>
 Information</b></p></td>
					<td  width="50%" onmouseover="this.style.background='';" onmouseout="this.style.background='#FFF000';" bgcolor="#FFF000" align="center">
<?php 
        if ($row[tickets_status] == 'Open') {
            ?>
					<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?op=Support&amp;caseid=AdminView&amp;ticketid=<?php 
            echo $row[tickets_id];
            ?>
&amp;closesub=Closed" style="width:94%;color:#000000">Close Ticket
<?php 
        } else {
            ?>
						<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?op=Support&amp;caseid=AdminView&amp;ticketid=<?php 
            echo $row[tickets_id];
            ?>
&amp;closesub=Open" style="width:94%;color:#000000">Reopen Ticket
<?php 
        }
        ?>
					</td>
				  </tr>
				  <tr>
					<td bgcolor="#CCCCCC" ><p><b>Username:</b></p></td>
					<td  colspan="2"><p><?php 
        echo $row[tickets_admin];
        ?>
</p></td>
				  </tr>
				  <tr>
					<td bgcolor="#CCCCCC" ><p><b>Email:</b></p></td>
					<td  colspan="2"><p><?php 
        echo $row[tickets_email];
        ?>
</p></td>
				  </tr>
				  <tr>
					<td bgcolor="#CCCCCC" ><p><b>Subject:</b></p></td>
					<td  colspan="2"><p><?php 
        echo $row[tickets_subject];
        ?>
</p></td>
				  </tr>
				  <tr>
					<td bgcolor="#CCCCCC" ><p><b>Department:</b></p></td>
					<td  colspan="2"><p><?php 
        echo $row[tickets_categories_name];
        ?>
</p></td>
				  </tr>
				  <tr>
					<td bgcolor="#CCCCCC" ><p><b>Urgency:</b></p></td>
					<td  colspan="2" bgcolor="#<?php 
        echo $row[tickets_status_color];
        ?>
">
						<p><b><?php 
        echo $row[tickets_status_name];
        ?>
</b></p></td>
				  </tr>
				  <tr>
					<td bgcolor="#CCCCCC" ><p><b>Status:</b></p></td>
					<td  colspan="2"><p>
<?php 
        if ($tickets_status == 'Closed') {
            echo '<span style="color:#FF0000">';
        } else {
            echo '<span>';
        }
        echo $row[tickets_status] . '</span></p></td>
				  </tr>';
        ?>
				</table><div style="padding-top:5px"></div>

				<form action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?op=Support&amp;caseid=AdminView&amp;ticketid=<?php 
        echo $_GET['ticketid'];
        ?>
" method="post">
				<table width="97%" cellspacing="1" cellpadding="1" border="1"  align="<?php 
        echo $maintablealign;
        ?>
">
				  <tr bgcolor="#AABBDD">
					<td ><p><b>Respond</b></p></td>
				  </tr>
				  <tr>
					<td align="right"><p><textarea name="message" cols="45" rows="10"></textarea>
					<input type="hidden" name="name" value="<?php 
        echo $row[tickets_name];
        ?>
" />
					<input type="hidden" name="uid" value="<?php 
        echo $row[tickets_uid];
        ?>
" />
					<input type="hidden" name="email" value="<?php 
        echo $row[tickets_email];
        ?>
" />
					<input type="hidden" name="postsubject" value="<?php 
        echo $row[tickets_subject];
        ?>
" />
					<input type="hidden" name="posturgency" value="<?php 
        echo $row[tickets_status_id];
        ?>
|<?php 
        echo $row[tickets_status_name];
        ?>
" />
					<input type="hidden" name="postdept" value="<?php 
        echo $row[tickets_categories_id];
        ?>
|<?php 
        echo $row[tickets_categories_name];
        ?>
" />
					<input type="submit" name="submit" value="Submit" /></p></td>
				  </tr>
				</table><div style="padding-top:5px"></div>
<?php 
        // ALLOW THE USERS TO ATTACH A FILE TO THE TICKET
        if ($allowattachments == 'TRUE') {
            FileUploadForm();
        }
        ?>
				<br /></td>
				<td valign="top">
<?php 
        // LIST THE ASSOCIATED RESPONSES TO THIS TICKET
        $j = '0';
        $result = $db->sql_query($query);
        while ($row = $db->sql_fetchrow($result)) {
            ?>
				<table width="97%" cellspacing="1" cellpadding="1" border="1"  align="<?php 
            echo $maintablealign;
            ?>
">
				  <tr bgcolor="#AABBDD">
					<td ><p><b>
<?php 
            if ($j == '0') {
                echo '	Dialog Question';
            } else {
                echo '	Response ' . $j;
            }
            ?>
					</b></p></td>
					<td  bgcolor="#AACCDD" width="50%" align="right"><p><?php 
            echo $row[tickets_timestamp];
            ?>
</p></td>
				  </tr>
<?php 
            if ($row[tickets_admin] == 'Admin') {
                $bgcolor = '#FFF000';
            } else {
                $bgcolor = '#AACCEE';
            }
            ?>
				  <tr>
					<td  colspan="2"><p><?php 
            echo nl2br($row[tickets_question]);
            ?>
</p></td>
				  </tr>
				  <tr bgcolor="<?php 
            echo $bgcolor;
            ?>
">
					<td ><p>Posted By: <?php 
            echo $row[tickets_admin];
            ?>
</p></td>
					<td ><p align="right">
<?php 
            // SCAN THE UPLOAD DIRECTORY FOR ATTACHMENTS TO THIS POST
            $d = dir($uploadpath);
            while (false != ($files = $d->read())) {
                $files = explode('.', $files);
                if ($files['0'] == $row[tickets_id]) {
                    ?>
						  	<b>Attachment:</b> <?php 
                    echo $files['0'];
                    ?>
.<?php 
                    echo $files['1'];
                    ?>
							<a href="<?php 
                    echo "http://" . $relativepath . $files['0'];
                    ?>
.<?php 
                    echo $files['1'];
                    ?>
" target="_blank">
							<img src="modules/Support/images/download.gif" width="13" height="13" align="absmiddle" border="0" /></a>
<?php 
                    $filename = $files['0'] . '.' . $files['1'];
                    ?>
							<input type="hidden" name="attachment[<?php 
                    echo $_GET['ticketid'] - 1;
                    ?>
]" value="<?php 
                    echo $filename;
                    ?>
" />
<?php 
                } else {
                    $filename = '';
                }
            }
            $d->close();
            ?>
					</td>
				  </tr>
				</table><div style="padding-top:5px"></div>

				<input type="hidden" name="ticketquestion[]" value="<?php 
            echo $row[tickets_question];
            ?>
" />
				<input type="hidden" name="postedby[]" value="<?php 
            echo $row[tickets_admin];
            ?>
" />
				<input type="hidden" name="postdate[]" value="<?php 
            echo $row[tickets_timestamp];
            ?>
" />
<?php 
            $j++;
        }
        ?>
				</td>
			  </tr>
			</table>
			</form>
<?php 
    }