From 83525aabb530d52c5abf7c7938643c6f0b6e302f Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 15 May 2015 22:12:30 -0400 Subject: [PATCH 01/18] #204 Add crosshair to ticket subject to view location --- admin/admin_ticket.php | 11 +++++++++++ install/mods-for-hesk/sql/installSql.php | 1 + install/mods-for-hesk/sql/uninstallSql.php | 7 +++++++ language/en/text.php | 2 ++ 4 files changed, 21 insertions(+) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index d7918c2f..5964e6a2 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -861,6 +861,17 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); { echo ' '; } + $locationText = ''; + if (strpos($ticket['Location'], 'N/A') === false) + { + $locationText = $hesklang['click_for_map']; + } + else + { + $locationText = $hesklang['location_unavailable']; + } + echo ' '; + // TODO ADD LOCATION CROSSHAIR echo $ticket['subject']; ?> diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index e4997607..b39ef049 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -448,6 +448,7 @@ function execute230Scripts() { executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `Key` = `ShortNameContentKey`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` DROP COLUMN `ShortNameContentKey`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` DROP COLUMN `TicketViewContentKey`"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` ADD COLUMN `Location` VARCHAR(100) NOT NULL DEFAULT 'N/A-0'"); executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'"); } diff --git a/install/mods-for-hesk/sql/uninstallSql.php b/install/mods-for-hesk/sql/uninstallSql.php index d76c7728..1c4d7d41 100644 --- a/install/mods-for-hesk/sql/uninstallSql.php +++ b/install/mods-for-hesk/sql/uninstallSql.php @@ -136,6 +136,13 @@ function removeServiceMessageCustomIcon() { executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` DROP COLUMN `icon`"); } +function removeTicketLocation() { + global $hesk_settings; + + hesk_dbConnect(); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `Location`"); +} + function executeMiscellaneousSql() { global $hesk_settings; diff --git a/language/en/text.php b/language/en/text.php index 460a94f5..0810af06 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -44,6 +44,8 @@ $hesklang['show_number_merged_help'] = 'If enabled, the user will be able to see $hesklang['latest_top_on_home'] = 'Latest/Top articles on home page'; $hesklang['latest_top_on_home_help'] = 'Select YES to display the top and latest knowledgebase articles on the home page. Otherwise, a link to the knowledgebase will appear on the home page.'; +$hesklang['location_unavailable'] = "Customer's location is unavailable. Click the crosshair for more information."; +$hesklang['click_for_map'] = "Click the crosshair to see a map of the ticket's location"; // ADDED OR MODIFIED IN Mods for HESK 2.2.1 $hesklang['popart_no_colon']='Top Knowledgebase Articles'; // same as $hesklang['popart'] but without a colon (:) From 4300bf03fd5e65653e11addc29182d1dc2744fcf Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 19 May 2015 20:50:40 -0400 Subject: [PATCH 02/18] #204 Add setting for location tracking --- admin/admin_settings.php | 20 ++++++++++++++++++++ admin/admin_settings_save.php | 6 +++++- install/mods-for-hesk/sql/installSql.php | 7 +++++++ language/en/text.php | 3 +++ modsForHesk_settings.inc.php | 5 ++++- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/admin/admin_settings.php b/admin/admin_settings.php index 4b5cf991..938ed1d2 100644 --- a/admin/admin_settings.php +++ b/admin/admin_settings.php @@ -902,6 +902,26 @@ if ( defined('HESK_DEMO') ) ?> +
+ +
+
    +
'; + ?> +
+
diff --git a/admin/admin_settings_save.php b/admin/admin_settings_save.php index 498dc3f2..52aa1048 100644 --- a/admin/admin_settings_save.php +++ b/admin/admin_settings_save.php @@ -506,6 +506,7 @@ $set['use_bootstrap_theme'] = empty($_POST['use_bootstrap_theme']) ? 0 : 1; $set['new_kb_article_visibility'] = hesk_checkMinMax( intval( hesk_POST('new_kb_article_visibility') ) , 0, 2, 2); $set['mfh_attachments'] = empty($_POST['email_attachments']) ? 0 : 1; $set['show_number_merged'] = empty($_POST['show_number_merged']) ? 0 : 1; +$set['request_location'] = empty($_POST['request_location']) ? 0 : 1; if ($set['customer-email-verification-required']) { @@ -568,7 +569,10 @@ $modsForHesk_settings[\'new_kb_article_visibility\'] = '.$set['new_kb_article_vi $modsForHesk_settings[\'attachments\'] = '.$set['mfh_attachments'].'; //-- Setting for showing number of merged tickets in the ticket search screen. 0 = Disable, 1 = Enable -$modsForHesk_settings[\'show_number_merged\'] = '.$set['show_number_merged'].';'; +$modsForHesk_settings[\'show_number_merged\'] = '.$set['show_number_merged'].'; + +//-- Setting for requesting user\'s location. 0 = Disable, 1 = Enable +$modsForHesk_settings[\'request_location\'] = '.$set['request_location'].';'; // Write the file if ( ! file_put_contents(HESK_PATH . 'modsForHesk_settings.inc.php', $modsForHesk_file_content) ) diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index b39ef049..bd06df5d 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -464,6 +464,13 @@ function execute230FileUpdate() { //-- Setting for showing number of merged tickets in the ticket search screen. 0 = Disable, 1 = Enable $modsForHesk_settings[\'show_number_merged\'] = 1;'; } + if (strpos($file, '$modsForHesk_settings[\'request_location\']') === false) + { + $file .= ' + + //-- Setting for requesting user\'s location. 0 = Disable, 1 = Enable +$modsForHesk_settings[\'request_location\'] = 0'; + } return file_put_contents(HESK_PATH.'modsForHesk_settings.inc.php', $file); } diff --git a/language/en/text.php b/language/en/text.php index 0810af06..f4a598c2 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -46,6 +46,9 @@ $hesklang['latest_top_on_home_help'] = 'Select YES to display the top and latest Otherwise, a link to the knowledgebase will appear on the home page.'; $hesklang['location_unavailable'] = "Customer's location is unavailable. Click the crosshair for more information."; $hesklang['click_for_map'] = "Click the crosshair to see a map of the ticket's location"; +$hesklang['request_user_location'] = "Request Location"; +$hesklang['request_user_location_help'] = "If enabled, the help desk will ask for the customer's location, allowing staff to + see a map of the customer's location when they created the ticket."; // ADDED OR MODIFIED IN Mods for HESK 2.2.1 $hesklang['popart_no_colon']='Top Knowledgebase Articles'; // same as $hesklang['popart'] but without a colon (:) diff --git a/modsForHesk_settings.inc.php b/modsForHesk_settings.inc.php index 8471bd0b..3406ac42 100644 --- a/modsForHesk_settings.inc.php +++ b/modsForHesk_settings.inc.php @@ -43,4 +43,7 @@ $modsForHesk_settings['new_kb_article_visibility'] = 0; $modsForHesk_settings['attachments'] = 0; //-- Setting for showing number of merged tickets in the ticket search screen. 0 = Disable, 1 = Enable -$modsForHesk_settings['show_number_merged'] = 1; \ No newline at end of file +$modsForHesk_settings['show_number_merged'] = 1; + +//-- Setting for requesting user's location. 0 = Disable, 1 = Enable +$modsForHesk_settings['request_location'] = 0; \ No newline at end of file From 1b73d0ec54ad7e8faa21052f37fb3d5b938e1911 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 19 May 2015 22:04:19 -0400 Subject: [PATCH 03/18] #204 Save lat/lon when creating new ticket --- inc/posting_functions.inc.php | 8 ++++++-- index.php | 12 ++++++++++++ install/mods-for-hesk/sql/installSql.php | 5 ++++- submit_ticket.php | 4 ++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/inc/posting_functions.inc.php b/inc/posting_functions.inc.php index bb0b81dd..6a518064 100644 --- a/inc/posting_functions.inc.php +++ b/inc/posting_functions.inc.php @@ -95,7 +95,9 @@ function hesk_newTicket($ticket, $isVerified = true) `custom18`, `custom19`, `custom20`, - `status` + `status`, + `latitude`, + `longitude` ) VALUES ( @@ -136,7 +138,9 @@ function hesk_newTicket($ticket, $isVerified = true) '".hesk_dbEscape($ticket['custom18'])."', '".hesk_dbEscape($ticket['custom19'])."', '".hesk_dbEscape($ticket['custom20'])."', - '".intval($ticket['status'])."' + '".intval($ticket['status'])."', + '".hesk_dbEscape($ticket['latitude'])."', + '".hesk_dbEscape($ticket['longitude'])."' ) "); diff --git a/index.php b/index.php index 408facee..334f0167 100644 --- a/index.php +++ b/index.php @@ -1002,6 +1002,8 @@ if ( ! isset($_SESSION['c_category']) && ! $hesk_settings['select_cat']) ?>
+ +
@@ -1025,6 +1027,16 @@ if ( ! isset($_SESSION['c_category']) && ! $hesk_settings['select_cat']) + requestUserLocation(); + + '; +} + hesk_cleanSessionVars('iserror'); hesk_cleanSessionVars('isnotice'); diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index bd06df5d..97974648 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -448,7 +448,10 @@ function execute230Scripts() { executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `Key` = `ShortNameContentKey`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` DROP COLUMN `ShortNameContentKey`"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` DROP COLUMN `TicketViewContentKey`"); - executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` ADD COLUMN `Location` VARCHAR(100) NOT NULL DEFAULT 'N/A-0'"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'"); } diff --git a/submit_ticket.php b/submit_ticket.php index eea8f368..44e6774f 100644 --- a/submit_ticket.php +++ b/submit_ticket.php @@ -427,6 +427,10 @@ if ($hesk_settings['attachments']['use'] && ! empty($attachments) ) } } +// Set latitude and longitude +$tmpvar['latitude'] = hesk_POST('latitude'); +$tmpvar['longitude'] = hesk_POST('longitude'); + // Should the helpdesk validate emails? $createTicket = true; if ($modsForHesk_settings['customer_email_verification_required']) From 795419e819e80c852f4cf4610b057ee8fbde67d3 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 19 May 2015 22:05:50 -0400 Subject: [PATCH 04/18] #204 Add javascript for obtaining location --- js/modsForHesk-javascript.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/js/modsForHesk-javascript.js b/js/modsForHesk-javascript.js index a8bc674d..70286685 100644 --- a/js/modsForHesk-javascript.js +++ b/js/modsForHesk-javascript.js @@ -106,4 +106,34 @@ function changeText(id, checkedValue, uncheckedValue, object) { } } +function requestUserLocation() { + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(function(position) { + setLatLon(position.coords.latitude, position.coords.longitude); + }, function(error) { + switch(error.code) { + case error.PERMISSION_DENIED: + setLatLon('E-1','E-1'); + break; + case error.POSITION_UNAVAILABLE: + setLatLon('E-2','E-2'); + break; + case error.TIMEOUT: + setLatLon('E-3','E-3'); + break; + case error.UNKNOWN_ERROR: + setLatLon('E-4','E-4'); + break; + } + }); + } else { + setLatLon('E-5','E-5'); + } +} + +function setLatLon(lat, lon) { + $('#latitude').val(lat); + $('#longitude').val(lon); +} + jQuery(document).ready(loadJquery); From 480067381c03e5986fd1a17fdb6b356b45ea23e3 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 19 May 2015 22:18:12 -0400 Subject: [PATCH 05/18] #204 Only show crosshair if location is enabled --- admin/admin_ticket.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index 5964e6a2..2c306a7c 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -870,8 +870,11 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); { $locationText = $hesklang['location_unavailable']; } - echo ' '; - // TODO ADD LOCATION CROSSHAIR + if ($modsForHesk_settings['request_location']) + { + echo ' '; + // TODO ADD LOCATION CROSSHAIR + } echo $ticket['subject']; ?>
From b44884a99e19e96bb947fab8996c40943ae03d7e Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 20 May 2015 00:07:04 -0400 Subject: [PATCH 06/18] #204 Use leaflet to get a basic map displayed. Still needs to be improved though. Also may not use the CDN. --- admin/admin_ticket.php | 41 ++++++++++++++++++++++++++++++----------- inc/header.inc.php | 2 ++ inc/headerAdmin.inc.php | 2 ++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index 2c306a7c..365901a0 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -861,19 +861,38 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); { echo ' '; } - $locationText = ''; - if (strpos($ticket['Location'], 'N/A') === false) - { - $locationText = $hesklang['click_for_map']; - } - else - { - $locationText = $hesklang['location_unavailable']; - } if ($modsForHesk_settings['request_location']) { - echo ' '; - // TODO ADD LOCATION CROSSHAIR + $locationText = ''; + if (strpos($ticket['latitude'], 'E') === false) + { + $locationText = $hesklang['click_for_map']; + } + else + { + $locationText = $hesklang['location_unavailable']; + } + ?> + + + + +
+ + diff --git a/inc/header.inc.php b/inc/header.inc.php index 19fc20ef..656049b5 100644 --- a/inc/header.inc.php +++ b/inc/header.inc.php @@ -60,6 +60,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); + @@ -68,6 +69,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); + css/bootstrap-iconpicker.min.css" rel="stylesheet"> + @@ -68,6 +69,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); + Date: Wed, 20 May 2015 22:02:26 -0400 Subject: [PATCH 07/18] #204 Map is now in a modal and can be obtained via FontAwesome icon --- admin/admin_ticket.php | 30 +++++++++++++++++++++--------- language/en/text.php | 3 ++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index 365901a0..a50d2fcd 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -873,24 +873,36 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $locationText = $hesklang['location_unavailable']; } ?> - - - -
+ diff --git a/language/en/text.php b/language/en/text.php index faea39a8..73c22d75 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -44,12 +44,20 @@ $hesklang['show_number_merged_help'] = 'If enabled, the user will be able to see $hesklang['latest_top_on_home'] = 'Latest/Top articles on home page'; $hesklang['latest_top_on_home_help'] = 'Select YES to display the top and latest knowledgebase articles on the home page. Otherwise, a link to the knowledgebase will appear on the home page.'; -$hesklang['location_unavailable'] = "Customer's location is unavailable. Click the crosshair for more information."; +$hesklang['location_unavailable'] = "Location unavailable. Click for more information."; $hesklang['click_for_map'] = "View map of user's location"; $hesklang['request_user_location'] = "Request Location"; $hesklang['request_user_location_help'] = "If enabled, the help desk will ask for the customer's location, allowing staff to see a map of the customer's location when they created the ticket."; $hesklang['users_location'] = "User's Location"; +$hesklang['location_unavailable_0'] = "User's location is not available because the ticket was created before location tracking was enabled."; +$hesklang['location_unavailable_1'] = "User's location is not available because the user refused to share it."; +$hesklang['location_unavailable_2'] = "User's location is not available because the help desk was unable to determine the user's position."; +$hesklang['location_unavailable_3'] = "User's location is not available because the help desk was not able to determine the user's position in + a reasonable amount of time."; +$hesklang['location_unavailable_4'] = "An unknown error occurred when trying to obtain the user's location."; +$hesklang['location_unavailable_5'] = "User's location is not available because the user's browser did not meet the minimum +requirements for tracking their location when the ticket was submitted."; // ADDED OR MODIFIED IN Mods for HESK 2.2.1 $hesklang['popart_no_colon']='Top Knowledgebase Articles'; // same as $hesklang['popart'] but without a colon (:) From 179ad074dc53ccfb5aca3ff1e5e631f2215b14a7 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 22 May 2015 22:12:25 -0400 Subject: [PATCH 09/18] #204 Switching this to 1 for now so I don't hafta keep changing it --- modsForHesk_settings.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modsForHesk_settings.inc.php b/modsForHesk_settings.inc.php index 3406ac42..fbdec73e 100644 --- a/modsForHesk_settings.inc.php +++ b/modsForHesk_settings.inc.php @@ -46,4 +46,4 @@ $modsForHesk_settings['attachments'] = 0; $modsForHesk_settings['show_number_merged'] = 1; //-- Setting for requesting user's location. 0 = Disable, 1 = Enable -$modsForHesk_settings['request_location'] = 0; \ No newline at end of file +$modsForHesk_settings['request_location'] = 1; \ No newline at end of file From 1efb9b69b5c4d5f33da04e086ff2947dd77861ea Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sat, 23 May 2015 14:53:38 -0400 Subject: [PATCH 10/18] #204 Allow staff to change location if necessary --- admin/admin_ticket.php | 46 +++++++++++++++++++++++++----------- js/modsForHesk-javascript.js | 29 +++++++++++++++++++++++ language/en/text.php | 3 +++ 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index 6c26088a..58a15ba8 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -588,6 +588,15 @@ if (isset($_GET['delatt']) && hesk_token_check()) hesk_process_messages($hesklang['kb_att_rem'],'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999),'SUCCESS'); } +//-- Update location action +if (isset($_POST['latitude']) && isset($_POST['longitude'])) { + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `latitude` = '".hesk_dbEscape($_POST['latitude'])."', + `longitude` = '".hesk_dbEscape($_POST['longitude'])."' WHERE `ID` = ".intval($ticket['id'])); + + //redirect + hesk_process_messages($hesklang['ticket_location_updated'],'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999),'SUCCESS'); +} + /* Print header */ require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); @@ -886,11 +895,32 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');