Newer
Older
<?php
if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->canCreateTickets()) die('Access Denied');
$info=array();
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
$form = null;
if ($info['topicId'] && ($topic=Topic::lookup($info['topicId']))) {
$form = $topic->getForm();
if ($_POST && $form) {
$form = $form->instanciate();
$form->isValid();
}
}
?>
<form action="tickets.php?a=open" method="post" id="save" enctype="multipart/form-data">
<input type="hidden" name="do" value="create">
<input type="hidden" name="a" value="open">
<h2>Open New Ticket</h2>
<table class="form_table fixed" width="940" border="0" cellspacing="0" cellpadding="2">
<!-- This looks empty - but beware, with fixed table layout, the user
agent will usually only consult the cells in the first row to
construct the column widths of the entire toable. Therefore, the
first row needs to have two cells -->
<tr><td></td><td></td></tr>
<tr>
<th colspan="2">
<h4>New Ticket</h4>
</th>
</tr>
</thead>
<tbody>
<em><strong>User Information</strong>: </em>
</th>
</tr>
<?php
if ($user) { ?>
<tr><td>User:</td><td>
<div id="user-info">
<input type="hidden" name="uid" id="uid" value="<?php echo $user->getId(); ?>" />
<a href="#" onclick="javascript:
$.userLookup('ajax.php/users/<?php echo $user->getId(); ?>/edit',
function (user) {
$('#user-name').text(user.name);
$('#user-email').text(user.email);
});
return false;
"><i class="icon-user"></i>
<span id="user-name"><?php echo $user->getName(); ?></span>
<<span id="user-email"><?php echo $user->getEmail(); ?></span>>
<a class="action-button" style="float:none;overflow:inherit" href="#"
onclick="javascript:
$.userLookup('ajax.php/users/select/'+$('input#uid').val(),
function(user) {
$('input#uid').val(user.id);
$('#user-name').text(user.name);
$('#user-email').text('<'+user.email+'>');
});
return false;
"><i class="icon-edit"></i> Change</a>
</div>
</td></tr>
<?php
} else { //Fallback: Just ask for email and name
?>
<tr>
<td width="160" class="required"> Email Address: </td>
<td>
<span style="display:inline-block;">
<input type="text" size=45 name="email" id="user-email"
autocomplete="off" autocorrect="off" value="<?php echo $info['email']; ?>" /> </span>
<font class="error">* <?php echo $errors['email']; ?></font>
</td>
<tr>
<td width="160" class="required"> Full Name: </td>
<td>
<span style="display:inline-block;">
<input type="text" size=45 name="name" id="user-name" value="<?php echo $info['name']; ?>" /> </span>
<font class="error">* <?php echo $errors['name']; ?></font>
</td>
<?php
if($cfg->notifyONNewStaffTicket()) { ?>
<td width="160">Ticket Notice:</td>
<input type="checkbox" name="alertuser" <?php echo (!$errors || $info['alertuser'])? 'checked="checked"': ''; ?>>Send alert to user.
<?php
} ?>
</tbody>
<tbody>
<em><strong>Ticket Information & Options</strong>:</em>
</th>
</tr>
<tr>
<td width="160" class="required">
Ticket Source:
</td>
<td>
<select name="source">
<option value="Phone" <?php echo ($info['source']=='Phone')?'selected="selected"':''; ?> selected="selected">Phone</option>
<option value="Email" <?php echo ($info['source']=='Email')?'selected="selected"':''; ?>>Email</option>
<option value="Other" <?php echo ($info['source']=='Other')?'selected="selected"':''; ?>>Other</option>
</select>
<font class="error"><b>*</b> <?php echo $errors['source']; ?></font>
</td>
</tr>
<tr>
<td width="160" class="required">
<select name="topicId" onchange="javascript:
$('#dynamic-form').load(
'ajax.php/form/help-topic/' + this.value);
">
if ($topics=Topic::getHelpTopics()) {
if (count($topics) == 1)
$selected = 'selected="selected"';
else { ?>
<option value="" selected >— Select Help Topic —</option>
<?php }
echo sprintf('<option value="%d" %s %s>%s</option>',
$id, ($info['topicId']==$id)?'selected="selected"':'',
$selected, $name);
}
if (count($topics) == 1 && !$form) {
if (($T = Topic::lookup($id)))
$form = $T->getForm();
<font class="error"><b>*</b> <?php echo $errors['topicId']; ?></font>
<select name="deptId">
<option value="" selected >— Select Department —</option>
if($depts=Dept::getDepartments()) {
foreach($depts as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['deptId']==$id)?'selected="selected"':'',$name);
<font class="error"><?php echo $errors['deptId']; ?></font>
<td>
<select name="slaId">
<option value="0" selected="selected" >— System Default —</option>
if($slas=SLA::getSLAs()) {
foreach($slas as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['slaId']==$id)?'selected="selected"':'',$name);
</select>
<font class="error"> <?php echo $errors['slaId']; ?></font>
<td width="160">
Due Date:
</td>
<td>
<input class="dp" id="duedate" name="duedate" value="<?php echo Format::htmlchars($info['duedate']); ?>" size="12" autocomplete=OFF>
<?php
$min=$hr=null;
if($info['time'])
<font class="error"> <?php echo $errors['duedate']; ?> <?php echo $errors['time']; ?></font>
<em>Time is based on your time zone (GMT <?php echo $thisstaff->getTZoffset(); ?>)</em>
<?php
if($thisstaff->canAssignTickets()) { ?>
<tr>
<td width="160">Assign To:</td>
<td>
<select id="assignId" name="assignId">
<option value="0" selected="selected">— Select Staff Member OR a Team —</option>
<?php
if(($users=Staff::getAvailableStaffMembers())) {
echo '<OPTGROUP label="Staff Members ('.count($users).')">';
foreach($users as $id => $name) {
$k="s$id";
echo sprintf('<option value="%s" %s>%s</option>',
$k,(($info['assignId']==$k)?'selected="selected"':''),$name);
}
echo '</OPTGROUP>';
}
if(($teams=Team::getActiveTeams())) {
echo '<OPTGROUP label="Teams ('.count($teams).')">';
foreach($teams as $id => $name) {
$k="t$id";
echo sprintf('<option value="%s" %s>%s</option>',
$k,(($info['assignId']==$k)?'selected="selected"':''),$name);
}
echo '</OPTGROUP>';
}
?>
</select> <span class='error'> <?php echo $errors['assignId']; ?></span>
</td>
</tr>
if ($form) {
include(STAFFINC_DIR . 'templates/dynamic-form.tmpl.php');
}
<tbody> <?php
$tform = TicketForm::getInstance()->getForm($_POST);
if ($_POST) $tform->isValid();
$tform->render(true);
?>
</tbody>
Peter Rotich
committed
<?php
//is the user allowed to post replies??
if($thisstaff->canPostReply()) { ?>
<th colspan="2">
<em><strong>Response</strong>: Optional response to the above issue.</em>
</th>
</tr>
<tr>
<td colspan=2>
<?php
if(($cannedResponses=Canned::getCannedResponses())) {
<div style="margin-top:0.3em;margin-bottom:0.5em">
Canned Response:
<select id="cannedResp" name="cannedResp">
<option value="0" selected="selected">— Select a canned response —</option>
<?php
foreach($cannedResponses as $id =>$title) {
echo sprintf('<option value="%d">%s</option>',$id,$title);
}
?>
</select>
<label><input type='checkbox' value='1' name="append" id="append" checked="checked">Append</label>
</div>
<?php
}
$signature = '';
if ($thisstaff->getDefaultSignatureType() == 'mine')
$signature = $thisstaff->getSignature(); ?>
<textarea class="richtext ifhtml draft draft-delete"
data-draft-namespace="ticket.staff.response"
data-signature="<?php
echo Format::htmlchars(Format::viewableImages($signature)); ?>"
data-signature-field="signature" data-dept-field="deptId"
placeholder="Intial response for the ticket"
name="response" id="response" cols="21" rows="8"
style="width:80%;"><?php echo $info['response']; ?></textarea>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
if($cfg->allowAttachments()) { ?>
<tr><td width="100" valign="top">Attachments:</td>
<td>
<div class="canned_attachments">
<?php
if($info['cannedattachments']) {
foreach($info['cannedattachments'] as $k=>$id) {
if(!($file=AttachmentFile::lookup($id))) continue;
$hash=$file->getKey().md5($file->getId().session_id().$file->getKey());
echo sprintf('<label><input type="checkbox" name="cannedattachments[]"
id="f%d" value="%d" checked="checked"
<a href="file.php?h=%s">%s</a> </label> ',
$file->getId(), $file->getId() , $hash, $file->getName());
}
}
?>
</div>
<div class="uploads"></div>
<div class="file_input">
<input type="file" class="multifile" name="attachments[]" size="30" value="" />
</div>
</td>
</tr>
Peter Rotich
committed
<?php
} ?>
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<?php
if($thisstaff->canCloseTickets()) { ?>
<tr>
<td width="100">Ticket Status:</td>
<td>
<input type="checkbox" name="ticket_state" value="closed" <?php echo $info['ticket_state']?'checked="checked"':''; ?>>
<b>Close On Response</b> <em>(Only applicable if response is entered)</em>
</td>
</tr>
<?php
} ?>
<tr>
<td width="100">Signature:</td>
<td>
<?php
$info['signature']=$info['signature']?$info['signature']:$thisstaff->getDefaultSignatureType();
?>
<label><input type="radio" name="signature" value="none" checked="checked"> None</label>
<?php
if($thisstaff->getSignature()) { ?>
<label><input type="radio" name="signature" value="mine"
<?php echo ($info['signature']=='mine')?'checked="checked"':''; ?>> My signature</label>
<?php
} ?>
<label><input type="radio" name="signature" value="dept"
<?php echo ($info['signature']=='dept')?'checked="checked"':''; ?>> Dept. Signature (if set)</label>
</td>
</tr>
</table>
</td>
</tr>
Peter Rotich
committed
<?php
} //end canPostReply
?>
<em><strong>Internal Note</strong>
<font class="error"> <?php echo $errors['note']; ?></font></em>
<textarea class="richtext ifhtml draft draft-delete"
placeholder="Optional internal note (recommended on assignment)"
data-draft-namespace="ticket.staff.note" name="note"
cols="21" rows="6" style="width:80%;"
><?php echo $info['note']; ?></textarea>
<input type="submit" name="submit" value="Open">
<input type="reset" name="reset" value="Reset">
<input type="button" name="cancel" value="Cancel" onclick="javascript:
$('.richtext').each(function() {
var redactor = $(this).data('redactor');
if (redactor && redactor.opts.draftDelete)
redactor.deleteDraft();
});
window.location.href='tickets.php';
">
<script type="text/javascript">
$(function() {
$('input#user-email').typeahead({
source: function (typeahead, query) {
$.ajax({
url: "ajax.php/users?q="+query,
dataType: 'json',
success: function (data) {
typeahead.process(data);
}
});
},
onselect: function (obj) {
$('#uid').val(obj.id);
$('#user-name').val(obj.name);
$('#user-email').val(obj.email);
},
property: "/bin/true"
});
<?php
// Popup user lookup on the initial page load (not post) if we don't have a
// user selected
if (!$_POST && !$user) {?>
$.userLookup('ajax.php/users/lookup/form', function (user) {
window.location.href = window.location.href+'&uid='+user.id;
});
<?php
} ?>