Drag and drop attachments now working for admin notes and admin replies
This commit is contained in:
parent
07acdaccb5
commit
ecf0d1a7dc
@ -145,10 +145,24 @@ if (strlen($message)) {
|
|||||||
if ($hesk_settings['attachments']['use']) {
|
if ($hesk_settings['attachments']['use']) {
|
||||||
require(HESK_PATH . 'inc/attachments.inc.php');
|
require(HESK_PATH . 'inc/attachments.inc.php');
|
||||||
$attachments = array();
|
$attachments = array();
|
||||||
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
|
||||||
$att = hesk_uploadFile($i);
|
$use_legacy_attachments = hesk_POST('use-legacy-attachments', 0);
|
||||||
if ($att !== false && !empty($att)) {
|
|
||||||
$attachments[$i] = $att;
|
if ($use_legacy_attachments) {
|
||||||
|
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
||||||
|
$att = hesk_uploadFile($i);
|
||||||
|
if ($att !== false && !empty($att)) {
|
||||||
|
$attachments[$i] = $att;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// The user used the new drag-and-drop system.
|
||||||
|
$temp_attachment_ids = hesk_POST_array('attachment-ids');
|
||||||
|
foreach ($temp_attachment_ids as $temp_attachment_id) {
|
||||||
|
// Simply get the temp info and move it to the attachments table
|
||||||
|
$temp_attachment = mfh_getTemporaryAttachment($temp_attachment_id);
|
||||||
|
$attachments[] = $temp_attachment;
|
||||||
|
mfh_deleteTemporaryAttachment($temp_attachment_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,12 +314,27 @@ if (isset($_POST['notemsg']) && hesk_token_check('POST')) {
|
|||||||
require(HESK_PATH . 'inc/htmLawed.php');
|
require(HESK_PATH . 'inc/htmLawed.php');
|
||||||
require(HESK_PATH . 'inc/attachments.inc.php');
|
require(HESK_PATH . 'inc/attachments.inc.php');
|
||||||
$attachments = array();
|
$attachments = array();
|
||||||
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
|
||||||
$att = hesk_uploadFile($i);
|
$use_legacy_attachments = hesk_POST('use-legacy-attachments', 0);
|
||||||
if ($att !== false && !empty($att)) {
|
|
||||||
$attachments[$i] = $att;
|
if ($use_legacy_attachments) {
|
||||||
|
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
||||||
|
$att = hesk_uploadFile($i);
|
||||||
|
if ($att !== false && !empty($att)) {
|
||||||
|
$attachments[$i] = $att;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// The user used the new drag-and-drop system.
|
||||||
|
$temp_attachment_ids = hesk_POST_array('attachment-ids');
|
||||||
|
foreach ($temp_attachment_ids as $temp_attachment_id) {
|
||||||
|
// Simply get the temp info and move it to the attachments table
|
||||||
|
$temp_attachment = mfh_getTemporaryAttachment($temp_attachment_id);
|
||||||
|
$attachments[] = $temp_attachment;
|
||||||
|
mfh_deleteTemporaryAttachment($temp_attachment_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$myattachments = '';
|
$myattachments = '';
|
||||||
|
|
||||||
@ -1238,23 +1253,32 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div id="notesform" style="display:<?php echo isset($_SESSION['note_message']) ? 'block' : 'none'; ?>">
|
<div id="notesform" style="display:<?php echo isset($_SESSION['note_message']) ? 'block' : 'none'; ?>">
|
||||||
<form data-toggle="validator" method="post" action="admin_ticket.php" style="margin:0px; padding:0px;"
|
<form class="form-horizontal" data-toggle="validator" method="post" action="admin_ticket.php" style="margin:0px; padding:0px;"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
<div class="form-group">
|
<div class="row">
|
||||||
<textarea data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']) ?>" class="form-control" name="notemsg" rows="6"
|
<div class="col-md-6">
|
||||||
cols="60" required><?php echo isset($_SESSION['note_message']) ? stripslashes(hesk_input($_SESSION['note_message'])) : ''; ?></textarea>
|
<div class="form-group">
|
||||||
<div class="help-block with-errors"></div>
|
<textarea style="min-height: 150px" data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']) ?>" class="form-control" name="notemsg" rows="6"
|
||||||
|
cols="60" required><?php echo isset($_SESSION['note_message']) ? stripslashes(hesk_input($_SESSION['note_message'])) : ''; ?></textarea>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="dropzone" id="notesFiledrop">
|
||||||
|
<div class="fallback">
|
||||||
|
<input type="hidden" name="use-legacy-attachments" value="1">
|
||||||
|
<?php
|
||||||
|
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
||||||
|
echo '<input type="file" name="attachment[' . $i . ']" size="50" /><br />';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a href="file_limits.php" target="_blank"
|
||||||
|
onclick="Javascript:hesk_window('file_limits.php',250,500);return false;"><?php echo $hesklang['ful']; ?></a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php display_dropzone_field($hesk_settings['hesk_url'] . '/internal-api/ticket/upload-attachment.php', 'notesFiledrop'); ?>
|
||||||
// attachments
|
|
||||||
if ($hesk_settings['attachments']['use']) {
|
|
||||||
echo '<br />';
|
|
||||||
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
|
||||||
echo '<input type="file" name="attachment[' . $i . ']" size="50" /><br />';
|
|
||||||
}
|
|
||||||
echo '<br />';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<input class="btn btn-default" type="submit" value="<?php echo $hesklang['s']; ?>"/><input
|
<input class="btn btn-default" type="submit" value="<?php echo $hesklang['s']; ?>"/><input
|
||||||
type="hidden" name="track" value="<?php echo $trackingID; ?>"/>
|
type="hidden" name="track" value="<?php echo $trackingID; ?>"/>
|
||||||
<i><?php echo $hesklang['nhid']; ?></i>
|
<i><?php echo $hesklang['nhid']; ?></i>
|
||||||
@ -1806,15 +1830,23 @@ function hesk_printReplyForm()
|
|||||||
<label for="attachments" class="col-sm-3 control-label"><?php echo $hesklang['attachments']; ?>:</label>
|
<label for="attachments" class="col-sm-3 control-label"><?php echo $hesklang['attachments']; ?>:</label>
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<?php for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
<div class="dropzone" id="filedrop">
|
||||||
echo '<input type="file" name="attachment[' . $i . ']" size="50" /><br />';
|
<div class="fallback">
|
||||||
}
|
<input type="hidden" name="use-legacy-attachments" value="1">
|
||||||
|
<?php
|
||||||
echo '<a href="Javascript:void(0)" onclick="Javascript:hesk_window(\'../file_limits.php\',250,500);return false;">' . $hesklang['ful'] . '</a>';
|
for ($i = 1; $i <= $hesk_settings['attachments']['max_number']; $i++) {
|
||||||
?>
|
$cls = ($i == 1 && in_array('attachments', $_SESSION['iserror'])) ? ' class="isError" ' : '';
|
||||||
|
echo '<input type="file" name="attachment[' . $i . ']" size="50" ' . $cls . ' /><br />';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a href="file_limits.php" target="_blank"
|
||||||
|
onclick="Javascript:hesk_window('file_limits.php',250,500);return false;"><?php echo $hesklang['ful']; ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
display_dropzone_field($hesk_settings['hesk_url'] . '/internal-api/ticket/upload-attachment.php');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -200,25 +200,25 @@ function output_dropzone_window() {
|
|||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function output_attachment_id_holder_container() {
|
function output_attachment_id_holder_container($id) {
|
||||||
echo '<div id="attachment-holder" class="hide"></div>';
|
echo '<div id="attachment-holder-' . $id . '" class="hide"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_dropzone_field($url) {
|
function display_dropzone_field($url, $id = 'filedrop') {
|
||||||
global $hesk_settings, $hesklang;
|
global $hesk_settings, $hesklang;
|
||||||
|
|
||||||
output_dropzone_window();
|
output_dropzone_window();
|
||||||
output_attachment_id_holder_container();
|
output_attachment_id_holder_container($id);
|
||||||
|
|
||||||
$acceptedFiles = implode(',', $hesk_settings['attachments']['allowed_types']);
|
$acceptedFiles = implode(',', $hesk_settings['attachments']['allowed_types']);
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<script type=\"text/javascript\">
|
<script type=\"text/javascript\">
|
||||||
Dropzone.options.filedrop = {
|
Dropzone.options.".$id." = {
|
||||||
init: function() {
|
init: function() {
|
||||||
this.on('success', function(file, response) {
|
this.on('success', function(file, response) {
|
||||||
// The response will only be the ID of the attachment in the database
|
// The response will only be the ID of the attachment in the database
|
||||||
outputAttachmentIdHolder(response);
|
outputAttachmentIdHolder(response, '".$id."');
|
||||||
|
|
||||||
// Add the database id to the file
|
// Add the database id to the file
|
||||||
file['databaseId'] = response;
|
file['databaseId'] = response;
|
||||||
|
@ -4,10 +4,11 @@ function upload_temp_attachment($i, $isTicket) {
|
|||||||
global $hesk_settings;
|
global $hesk_settings;
|
||||||
|
|
||||||
$info = hesk_uploadFile($i, $isTicket);
|
$info = hesk_uploadFile($i, $isTicket);
|
||||||
|
$type = $isTicket ? 1 : 0;
|
||||||
|
|
||||||
// `type`: 0: ticket, 1: note
|
// `type`: 0: ticket, 1: kb
|
||||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (`file_name`,`size`, `type`, `date_uploaded`, `saved_name`)
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (`file_name`,`size`, `type`, `date_uploaded`, `saved_name`)
|
||||||
VALUES ('" . hesk_dbEscape($info['real_name']) . "','" . hesk_dbEscape($info['size']) . "','0',
|
VALUES ('" . hesk_dbEscape($info['real_name']) . "','" . hesk_dbEscape($info['size']) . "','" . $type . "',
|
||||||
NOW(), '" . hesk_dbEscape($info['saved_name']) . "')");
|
NOW(), '" . hesk_dbEscape($info['saved_name']) . "')");
|
||||||
|
|
||||||
return hesk_dbInsertID();
|
return hesk_dbInsertID();
|
||||||
|
@ -205,8 +205,8 @@ function getFriendlyLocation(latitude, longitude) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputAttachmentIdHolder(value) {
|
function outputAttachmentIdHolder(value, id) {
|
||||||
$('#attachment-holder').append('<input type="hidden" name="attachment-ids[]" value="' + value + '">');
|
$('#attachment-holder-' + id).append('<input type="hidden" name="attachment-ids[]" value="' + value + '">');
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAttachment(id) {
|
function removeAttachment(id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user