From 2a9219cf2597ffffcf422b514a9f29795fcb48c1 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 28 Nov 2014 22:17:47 -0500 Subject: [PATCH] #67 Partial implementation of adding attachments to the notes view Still has things to fix and need to add deleting attachments --- admin/admin_ticket.php | 76 ++++++++++++++++++++++++++++++++--------- js/nuMods-javascript.js | 8 ----- language/en/text.php | 2 +- 3 files changed, 60 insertions(+), 26 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index cceb1a76..a67594fc 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -39,6 +39,7 @@ define('HESK_PATH','../'); require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php'); +require(HESK_PATH . 'inc/posting_functions.inc.php'); hesk_load_database_functions(); hesk_session_start(); @@ -238,7 +239,32 @@ if (isset($_POST['notemsg']) && hesk_token_check('POST')) { /* Add note to database */ $msg = nl2br(hesk_makeURL($msg)); + hesk_dbInsertID(); hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` (`ticket`,`who`,`dt`,`message`) VALUES ('".intval($ticket['id'])."','".intval($_SESSION['id'])."',NOW(),'".hesk_dbEscape($msg)."')"); + $noteId = hesk_dbInsertID(); + + /* Upload attachments to database */ + if ($hesk_settings['attachments']['use']) + { + require(HESK_PATH . 'inc/attachments.inc.php'); + $attachments = array(); + for ($i=1;$i<=$hesk_settings['attachments']['max_number'];$i++) + { + $att = hesk_uploadFile($i); + if ($att !== false && !empty($att)) + { + $attachments[$i] = $att; + } + } + } + if ($hesk_settings['attachments']['use'] && !empty($attachments)) + { + foreach ($attachments as $myatt) + { + hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` (`note_id`,`saved_name`,`real_name`,`size`) VALUES ('".hesk_dbEscape($noteId)."','".hesk_dbEscape($myatt['saved_name'])."','".hesk_dbEscape($myatt['real_name'])."','".intval($myatt['size'])."')"); + } + } + /* Notify assigned staff that a note has been added if needed */ $users = hesk_dbQuery("SELECT `email`, `notify_note` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE (`id`='".intval($ticket['owner'])."' OR (`isadmin` = '1' AND `notify_note_unassigned` = '1')) AND `id` <> '".intval($_SESSION['id'])."'"); @@ -625,7 +651,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); echo hesk_getAdminButtons(); ?>
- +
@@ -846,16 +872,30 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');

-

-

- +
+
+

+ + +
+
+ + '.$att_name.'
'; + } ?> +
+
0) { ?>

@@ -870,7 +910,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); if ($can_reply) { ?> -   +   @@ -888,12 +928,14 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
- - +
'; + } + + echo '' . $hesklang['ful'] . ''; + ?>
- - -
diff --git a/js/nuMods-javascript.js b/js/nuMods-javascript.js index b3dc615c..f8100465 100644 --- a/js/nuMods-javascript.js +++ b/js/nuMods-javascript.js @@ -61,12 +61,4 @@ function toggleNote(noteId, showForm) { } } -function addFileDialog(id, divId) { - - var nextId = +($('#'+id).text()); - $('#'+divId).append(''); - $('#'+id).text(nextId+1); - -} - jQuery(document).ready(loadJquery); diff --git a/language/en/text.php b/language/en/text.php index 6878f536..bdd1f2c8 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -32,6 +32,7 @@ $hesklang['note_edit_successful'] = 'Note edited'; $hesklang['note_last_edit'] = 'Note last edited on: %s'; // %s: timestamp of last edit $hesklang['total_number_of_edits'] = 'Total number of edits: %s'; // %s: total number of edits $hesklang['add_row'] = 'Add row'; +$hesklang['addnote']='Add note'; // ADDED OR MODIFIED IN NuMods 1.5.0 $hesklang['ticket_auto_refresh'] = 'Ticket Table Auto-Refresh:'; @@ -679,7 +680,6 @@ $hesklang['opt2']='Options for this radio button, enter one option per line (eac $hesklang['opt3']='Options for this select box, enter one option per line (each line will be a choice your customers can choose from). You need to enter at least two options!'; $hesklang['atl2']='Enter at least two options (one per line)!'; $hesklang['notes']='Notes'; -$hesklang['addnote']='+ Add note'; $hesklang['noteby']='Note by'; $hesklang['delnote']='Delete note'; $hesklang['noteerr']='Note already deleted or wrong parameters';