Skip to content
Snippets Groups Projects
Commit c0948046 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add multi-file upload support to client interface

parent 0b87ace9
No related branches found
No related tags found
No related merge requests found
......@@ -106,10 +106,12 @@ table {
border-spacing: 0;
}
td {
th, td {
vertical-align: top;
}
th { text-align: left; font-weight: normal; }
h1, h2, h3, h4, h5, h6, form, fieldset {
margin: 0;
padding: 0;
......@@ -516,17 +518,23 @@ body {
display: block;
float: left;
}
#ticketForm div input[type=file] {
border: 0;
}
#ticketForm div select, #clientLogin div select {
display: block;
float: left;
}
#ticketForm div textarea, #clientLogin div textarea {
#ticketForm td textarea, #clientLogin div textarea {
width: 600px;
}
#ticketForm div em, #clientLogin div em {
#ticketForm td em, #clientLogin div em {
color: #777;
}
#ticketForm div .captcha, #clientLogin div .captcha {
#ticketForm td .captcha, #clientLogin div .captcha {
width: 88px;
height: 31px;
background: #000;
......@@ -534,20 +542,33 @@ body {
float: left;
margin-right: 20px;
}
#ticketForm div label.inline, #clientLogin div label.inline {
#ticketForm td label.inline, #clientLogin div label.inline {
width: auto;
padding: 0 10px;
}
#ticketForm div label.required, #clientLogin div label.required {
#ticketTable table tr th {
width: 160px;
font-weight: normal;
text-align: left;
}
#ticketForm table th.required, #ticketForm table td.required, #clientLogin div label.required {
font-weight: bold;
text-align: left;
}
#ticketForm div.captchaRow, #clientLogin div.captchaRow {
#ticketForm tr.captchaRow, #clientLogin div.captchaRow {
line-height: 31px;
}
#ticketForm div.captchaRow input, #clientLogin div.captchaRow input {
.captchaRow td input, #clientLogin div.captchaRow input {
position: relative;
top: 6px;
}
#ticketForm div.error input, #clientLogin div.error input {
border: 1px solid #a00;
}
......@@ -797,6 +818,14 @@ a.refresh {
font-family:helvetica, arial, sans-serif;
}
.uploads {
display:inline-block;
padding-right:20px;
}
.uploads label { padding:3px; padding-right:10px; width: auto !important }
.button:hover { background-color: #111; color: #fff; }
.button:active { top: 1px; box-shadow:none; -moz-box-shadow:none; -webkit-box-shadow:none; }
.button, .button:visited,
......
......@@ -12,8 +12,9 @@ header("Content-Type: text/html; charset=UTF-8\r\n");
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="<?php echo ASSETS_PATH; ?>css/theme.css" media="screen">
<link rel="stylesheet" href="<?php echo ASSETS_PATH; ?>css/print.css" media="print">
<script src="./js/jquery-1.7.2.min.js"></script>
<script src="./js/osticket.js"></script>
<script src="<?php echo ROOT_PATH; ?>js/jquery-1.7.2.min.js"></script>
<script src="<?php echo ROOT_PATH; ?>js/jquery.multifile.js"></script>
<script src="<?php echo ROOT_PATH; ?>js/osticket.js"></script>
</head>
<body>
<div id="container">
......
......@@ -13,99 +13,111 @@ $info=($_POST && $errors)?Format::htmlchars($_POST):$info;
<h1>Open a New Ticket</h1>
<p>Please fill in the form below to open a new ticket.</p>
<form id="ticketForm" method="post" action="open.php" enctype="multipart/form-data">
<?php csrf_token(); ?>
<input type="hidden" name="a" value="open">
<div>
<label for="name" class="required">Full Name:</label>
<?php
if($thisclient && $thisclient->isValid()) {
echo $thisclient->getName();
} else { ?>
<input id="name" type="text" name="name" size="30" value="<?php echo $info['name']; ?>">
<font class="error">*&nbsp;<?php echo $errors['name']; ?></font>
<?php
} ?>
</div>
<div>
<label for="email" class="required">Email Address:</label>
<?php
if($thisclient && $thisclient->isValid()) {
echo $thisclient->getEmail();
} else { ?>
<input id="email" type="text" name="email" size="30" value="<?php echo $info['email']; ?>">
<font class="error">*&nbsp;<?php echo $errors['email']; ?></font>
<?php
} ?>
</div>
<div>
<label for="phone">Telephone:</label>
<input id="phone" type="text" name="phone" size="17" value="<?php echo $info['phone']; ?>">
<label for="ext" class="inline">Ext.:</label>
<input id="ext" type="text" name="phone_ext" size="3" value="<?php echo $info['phone_ext']; ?>">
<font class="error">&nbsp;<?php echo $errors['phone']; ?>&nbsp;&nbsp;<?php echo $errors['phone_ext']; ?></font>
</div>
<br>
<div>
<label for="topicId" class="required">Help Topic:</label>
<select id="topicId" name="topicId">
<option value="" selected="selected">&mdash; Select a Help Topics &mdash;</option>
<?php csrf_token(); ?>
<input type="hidden" name="a" value="open">
<table width="800" cellpadding="1" cellspacing="0" border="0">
<tr>
<th class="required" width="160">Full Name:</th>
<td>
<?php
if($topics=Topic::getPublicHelpTopics()) {
foreach($topics as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['topicId']==$id)?'selected="selected"':'', $name);
}
if($thisclient && $thisclient->isValid()) {
echo $thisclient->getName();
} else { ?>
<option value="0" >General Inquiry</option>
<?php } ?>
</select>
<font class="error">*&nbsp;<?php echo $errors['topicId']; ?></font>
</div>
<div>
<label for="subject" class="required">Subject:</label>
<input id="subject" type="text" name="subject" size="40" value="<?php echo $info['subject']; ?>">
<font class="error">*&nbsp;<?php echo $errors['subject']; ?></font>
</div>
<div>
<label for="msg" class="required">Message:</label>
<span id="msg">
<em>Please provide as much details as possible so we can best assist you.</em> <font class="error">*&nbsp;<?php echo $errors['message']; ?></font></span>
</div>
<div>
<label for="message" class="required">&nbsp;</label>
<textarea id="message" cols="60" rows="8" name="message"><?php echo $info['message']; ?></textarea>
</div>
<input id="name" type="text" name="name" size="30" value="<?php echo $info['name']; ?>">
<font class="error">*&nbsp;<?php echo $errors['name']; ?></font>
<?php
} ?>
</td>
</tr>
<tr>
<th class="required" width="160">Email Address:</th>
<td>
<?php
if($thisclient && $thisclient->isValid()) {
echo $thisclient->getEmail();
} else { ?>
<input id="email" type="text" name="email" size="30" value="<?php echo $info['email']; ?>">
<font class="error">*&nbsp;<?php echo $errors['email']; ?></font>
<?php
} ?>
</td>
</tr>
<tr>
<th>Telephone:</th>
<td>
<input id="phone" type="text" name="phone" size="17" value="<?php echo $info['phone']; ?>">
<label for="ext" class="inline">Ext.:</label>
<input id="ext" type="text" name="phone_ext" size="3" value="<?php echo $info['phone_ext']; ?>">
<font class="error">&nbsp;<?php echo $errors['phone']; ?>&nbsp;&nbsp;<?php echo $errors['phone_ext']; ?></font>
</td>
</tr>
<tr><td colspan=2>&nbsp;</td></tr>
<tr>
<td class="required">Help Topic:</td>
<td>
<select id="topicId" name="topicId">
<option value="" selected="selected">&mdash; Select a Help Topics &mdash;</option>
<?php
if($topics=Topic::getPublicHelpTopics()) {
foreach($topics as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['topicId']==$id)?'selected="selected"':'', $name);
}
} else { ?>
<option value="0" >General Inquiry</option>
<?php
} ?>
</select>
<font class="error">*&nbsp;<?php echo $errors['topicId']; ?></font>
</td>
</tr>
<tr>
<td class="required">Subject:</td>
<td>
<input id="subject" type="text" name="subject" size="40" value="<?php echo $info['subject']; ?>">
<font class="error">*&nbsp;<?php echo $errors['subject']; ?></font>
</td>
</tr>
<tr>
<td class="required">Message:</td>
<td>
<div><em>Please provide as much details as possible so we can best assist you.</em> <font class="error">*&nbsp;<?php echo $errors['message']; ?></font></div>
<textarea id="message" cols="60" rows="8" name="message"><?php echo $info['message']; ?></textarea>
</td>
</tr>
<?php if(($cfg->allowOnlineAttachments() && !$cfg->allowAttachmentsOnlogin())
|| ($cfg->allowAttachmentsOnlogin() && ($thisclient && $thisclient->isValid()))) { ?>
<div>
<label for="attachments">Attachments:</label>
<span id="uploads"></span>
<input type="file" class="multifile" name="attachments[]" id="attachments" size="30" value="" />
<font class="error">&nbsp;<?php echo $errors['attachments']; ?></font>
</div>
<tr>
<td>Attachments:</td>
<td>
<div class="uploads"></div><br>
<input type="file" class="multifile" name="attachments[]" id="attachments" size="30" value="" />
<font class="error">&nbsp;<?php echo $errors['attachments']; ?></font>
</td>
</tr>
<tr><td colspan=2>&nbsp;</td></tr>
<?php } ?>
<?php
if($cfg->allowPriorityChange() && ($priorities=Priority::getPriorities())) { ?>
<div>
<label for="priority">Ticket Priority:</label>
<select id="priority" name="priorityId">
<?php
if(!$info['priorityId'])
$info['priorityId'] = $cfg->getDefaultPriorityId(); //System default.
foreach($priorities as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['priorityId']==$id)?'selected="selected"':'', $name);
<tr>
<td>Ticket Priority:</td>
<td>
<select id="priority" name="priorityId">
<?php
if(!$info['priorityId'])
$info['priorityId'] = $cfg->getDefaultPriorityId(); //System default.
foreach($priorities as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['priorityId']==$id)?'selected="selected"':'', $name);
}
?>
</select>
<font class="error">&nbsp;<?php echo $errors['priorityId']; ?></font>
</div>
}
?>
</select>
<font class="error">&nbsp;<?php echo $errors['priorityId']; ?></font>
</td>
</tr>
<?php
}
?>
......@@ -114,20 +126,23 @@ $info=($_POST && $errors)?Format::htmlchars($_POST):$info;
if($_POST && $errors && !$errors['captcha'])
$errors['captcha']='Please re-enter the text again';
?>
<br>
<div class="captchaRow">
<label for="captcha" class="required">CAPTCHA Text:</label>
<span class="captcha"><img src="captcha.php" border="0" align="left"></span>
<input id="captcha" type="text" name="captcha" size="6">
<em>Enter the text shown on the image.</em>
<font class="error">*&nbsp;<?php echo $errors['captcha']; ?></font>
</div>
<tr class="captchaRow">
<td class="required">CAPTCHA Text:</td>
<td>
<span class="captcha"><img src="captcha.php" border="0" align="left"></span>
&nbsp;&nbsp;
<input id="captcha" type="text" name="captcha" size="6">
<em>Enter the text shown on the image.</em>
<font class="error">*&nbsp;<?php echo $errors['captcha']; ?></font>
</td>
</tr>
<?php
} ?>
<br>
<p style="padding-left:150px;">
<tr><td colspan=2>&nbsp;</td></tr>
</table>
<p style="padding-left:150px;">
<input type="submit" value="Create Ticket">
<input type="reset" value="Reset">
<input type="button" value="Cancel" onClick='window.location.href="index.php"'>
</p>
</p>
</form>
......@@ -122,7 +122,7 @@ if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) {
<div class="uploads">
</div>
<div class="file_input">
<input type="file" name="attachments[]" size="30" value="" />
<input class="multifile" type="file" name="attachments[]" size="30" value="" />
</div>
</td>
</tr>
......
......@@ -32,6 +32,14 @@ if($_POST):
//Ticket::create...checks for errors..
if(($ticket=Ticket::create($_POST,$errors,SOURCE))){
$msg='Support ticket request created';
//Upload attachments...
if($cfg->allowOnlineAttachments()
&& $_FILES['attachments']
&& ($files=Format::files($_FILES['attachments']))) {
$ost->validateFileUploads($files); //Validator sets errors - if any.
$ticket->uploadAttachments($files, $ticket->getLastMsgId(), 'M');
}
//Logged in...simply view the newly created ticket.
if($thisclient && $thisclient->isValid()) {
if(!$cfg->showRelatedTickets())
......
......@@ -38,26 +38,15 @@ if($_POST && is_object($ticket) && $ticket->getId()):
if(!$_POST['message'])
$errors['message']='Message required';
//check attachment..if any is set
$files=($cfg->allowOnlineAttachments() && $_FILES['attachments'])?Format::files($_FILES['attachments']):array();
if($files) {
foreach($files as $file) {
if(!$file['name']) continue;
if(!$cfg->canUploadFileType($file['name']))
$errors['attachment']='Invalid file type [ '.$file['name'].' ]';
elseif($file['size']>$cfg->getMaxFileSize())
$errors['attachment']='File '.$file['name'].'is too big. Max '.$cfg->getMaxFileSize().' bytes allowed';
}
}
if(!$errors) {
//Everything checked out...do the magic.
if(($msgid=$ticket->postMessage($_POST['message'],'Web'))) {
if($files && $cfg->allowOnlineAttachments())
$ticket->uploadAttachments($files,$msgid,'M');
if($cfg->allowOnlineAttachments()
&& $_FILES['attachments']
&& ($files=Format::files($_FILES['attachments']))) {
$ost->validateFileUploads($files); //Validator sets errors - if any.
$ticket->uploadAttachments($files, $msgid, 'M');
}
$msg='Message Posted Successfully';
} else {
$errors['err']='Unable to post the message. Try again';
......@@ -68,7 +57,7 @@ if($_POST && is_object($ticket) && $ticket->getId()):
}
break;
default:
$errors['err']='Uknown action';
$errors['err']='Unknown action';
}
$ticket->reload();
endif;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment