From 90903e84915f9b4e3e809eebbea0872dc440910b Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 26 Jul 2015 22:17:30 -0400 Subject: [PATCH] #209 Start implementing move up/down --- admin/manage_statuses.php | 23 ++++++++++++++++++++--- install/mods-for-hesk/sql/installSql.php | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index ccc496b3..36a5f168 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -22,6 +22,7 @@ if (isset($_REQUEST['a'])) { if ($_POST['a'] == 'create') { createStatus(); } elseif ($_POST['a'] == 'update') { updateStatus(); } elseif ($_GET['a'] == 'delete') { deleteStatus(); } + elseif ($_GET['a'] == 'up') { moveStatus('up'); } } @@ -147,7 +148,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); - + @@ -338,12 +339,14 @@ function buildConfirmDeleteModal($statusId) { '; + echo ' + '; } else { echo ' '; } @@ -619,6 +622,20 @@ function deleteStatus() { hesk_process_messages($hesklang['ticket_status_deleted'],'manage_statuses.php','SUCCESS'); } +function moveStatus($direction) { + die(var_dump($_GET)); + + // Get the current position of the status + $statusId = hesk_GET('id'); + $rs = hesk_dbQuery("SELECT `sort` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `ID` = ".intval($statusId)); + $record = hesk_dbFetchAssoc($rs); + + if ($direction == 'up') { + $newSort = intval($record['sort']) - 1; + } else { + $newSort = intval($record['sort']) + 1; + } +} function save() { global $hesklang, $hesk_settings; diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 71cdcbb7..a11fbd26 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -568,6 +568,8 @@ function execute240Scripts() { `text` VARCHAR(200) NOT NULL, `status_id` INT NOT NULL, PRIMARY KEY (`id`)) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ADD COLUMN `sort` INT"); + executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort` = `ID`"); } function execute240FileUpdate() {