Some more work on attachments
This commit is contained in:
parent
87f6093138
commit
056e85d9ea
@ -224,7 +224,7 @@ function display_dropzone_field($url) {
|
|||||||
file['databaseId'] = response;
|
file['databaseId'] = response;
|
||||||
});
|
});
|
||||||
this.on('removedfile', function(file) {
|
this.on('removedfile', function(file) {
|
||||||
console.log(file);
|
removeAttachment(file['databaseId']);
|
||||||
});
|
});
|
||||||
this.on('queuecomplete', function(progress) {
|
this.on('queuecomplete', function(progress) {
|
||||||
$('#total-progress').removeClass('active');
|
$('#total-progress').removeClass('active');
|
||||||
|
@ -716,6 +716,7 @@ function execute260Scripts()
|
|||||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (
|
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (
|
||||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
`file_name` VARCHAR(255) NOT NULL,
|
`file_name` VARCHAR(255) NOT NULL,
|
||||||
|
`saved_name` VARCHAR(255) NOT NULL,
|
||||||
`size` INT(10) UNSIGNED NOT NULL,
|
`size` INT(10) UNSIGNED NOT NULL,
|
||||||
`type` ENUM('0','1') NOT NULL,
|
`type` ENUM('0','1') NOT NULL,
|
||||||
`date_uploaded` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
|
`date_uploaded` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
|
||||||
|
@ -9,3 +9,14 @@ function upload_temp_attachment($i, $isTicket) {
|
|||||||
|
|
||||||
return hesk_dbInsertID();
|
return hesk_dbInsertID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete_temp_attachment($id, $isTicket) {
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
$attachment_rs = hesk_dbQuery("SELECT `saved_name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` WHERE `id` = " . intval($id));
|
||||||
|
$attachment = hesk_dbFetchAssoc($attachment_rs);
|
||||||
|
|
||||||
|
if (hesk_removeAttachments(array($attachment), $isTicket)) {
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` WHERE `id` = " . intval($id));
|
||||||
|
}
|
||||||
|
}
|
24
internal-api/ticket/delete-attachment.php
Normal file
24
internal-api/ticket/delete-attachment.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
define('IN_SCRIPT', 1);
|
||||||
|
define('HESK_PATH', '../../');
|
||||||
|
define('INTERNAL_API_PATH', '../');
|
||||||
|
require_once(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
require_once(HESK_PATH . 'inc/common.inc.php');
|
||||||
|
require_once(HESK_PATH . 'inc/attachments.inc.php');
|
||||||
|
require_once(HESK_PATH . 'inc/posting_functions.inc.php');
|
||||||
|
require_once(INTERNAL_API_PATH . 'core/output.php');
|
||||||
|
require_once(INTERNAL_API_PATH . 'dao/attachment_dao.php');
|
||||||
|
|
||||||
|
hesk_load_internal_api_database_functions();
|
||||||
|
hesk_dbConnect();
|
||||||
|
|
||||||
|
$modsForHesk_settings = mfh_getSettings();
|
||||||
|
|
||||||
|
if (isset($_GET['id'])) {
|
||||||
|
$id = $_GET['id'];
|
||||||
|
|
||||||
|
$id = delete_temp_attachment($id, true);
|
||||||
|
return http_response_code(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return http_response_code(400);
|
@ -34,7 +34,6 @@ var loadJquery = function()
|
|||||||
todayBtn: "linked",
|
todayBtn: "linked",
|
||||||
clearBtn: true,
|
clearBtn: true,
|
||||||
autoclose: true,
|
autoclose: true,
|
||||||
autoclose: true,
|
|
||||||
todayHighlight: true,
|
todayHighlight: true,
|
||||||
format: "yyyy-mm-dd"
|
format: "yyyy-mm-dd"
|
||||||
});
|
});
|
||||||
@ -210,4 +209,18 @@ function outputAttachmentIdHolder(value) {
|
|||||||
$('#attachment-holder').append('<input type="hidden" name="attachment-ids[]" value="' + value + '">');
|
$('#attachment-holder').append('<input type="hidden" name="attachment-ids[]" value="' + value + '">');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeAttachment(id) {
|
||||||
|
$('input[name="attachment-ids[]"][value="' + id + '"]').remove();
|
||||||
|
$.ajax({
|
||||||
|
url: getHelpdeskUrl() + '/internal-api/ticket/delete-attachment.php?id=' + id,
|
||||||
|
method: 'GET',
|
||||||
|
success: function() {
|
||||||
|
console.info('Removed attachment ' + id);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
console.error('Error removing attachment ' + id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(document).ready(loadJquery);
|
jQuery(document).ready(loadJquery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user