Locations can be added to service messages

master
Mike Koch 7 years ago
parent d04b40c925
commit 6a763593ee
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -214,6 +214,48 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
</div>
</div>
</div>
<div class="form-group">
<label for="location" class="col-md-2 control-label">[!] Location</label>
<div class="col-sm-4" style="margin-left:20px">
<h5 style="text-decoration: underline;">Customer Pages</h5>
<div class="checkbox">
<input type="checkbox" name="location[]" value="CUSTOMER_HOME"> Homepage
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="CUSTOMER_KB_HOME"> Knowledgebase Home
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="CUSTOMER_VIEW_KB_ARTICLE"> View Knowledgebase Article
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="CUSTOMER_SUBMIT_TICKET"> Submit Ticket
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="CUSTOMER_VIEW_TICKET"> View Ticket
</div>
</div>
<div class="col-sm-4" style="margin-left:20px">
<h5 style="text-decoration: underline;">Staff Pages</h5>
<div class="checkbox">
<input type="checkbox" name="location[]" value="STAFF_LOGIN"> Login Page
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="STAFF_HOME"> Homepage
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="STAFF_KB_HOME"> Knowledgebase Home
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="STAFF_VIEW_KB_ARTICLE"> View Knowledgebase Article
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="STAFF_SUBMIT_TICKET"> Submit Ticket
</div>
<div class="checkbox">
<input type="checkbox" name="location[]" value="STAFF_VIEW_TICKET"> View Ticket
</div>
</div>
</div>
<div class="form-group">
<label for="title"
class="col-md-2 control-label"><?php echo $hesklang['sm_mtitle']; ?></label>

@ -0,0 +1,19 @@
<?php
namespace v330;
use BusinessLogic\ServiceMessages\ServiceMessageLocation;
class UpdateExistingServiceMessagesLocations extends \AbstractUpdatableMigration {
function innerUp($hesk_settings) {
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location` (`service_message_id`, `location`)
SELECT `id`, '" . hesk_dbEscape(ServiceMessageLocation::CUSTOMER_HOME) . "' FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`");
}
function innerDown($hesk_settings) {
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`
WHERE `service_message_id` IN (SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`)");
}
}

@ -137,7 +137,8 @@ function bindEditModal() {
$(document).on('click', '[data-action="edit"]', function() {
var element = serviceMessages[$(this).parent().parent().find('[data-property="id"]').data('value')];
var $modal = $('#service-message-modal');
$modal.find('#preview-pane').html('');
$modal.find('#preview-pane').html('').end()
.find('input[name="location[]"]').prop('checked', false);
$modal.find('#edit-label').show();
$modal.find('#create-label').hide();
@ -150,6 +151,10 @@ function bindEditModal() {
.find('input[name="order"]').val(element.order).end();
setIcon(element.icon);
$.each(element.locations, function() {
$modal.find('input[name="location[]"][value="' + this + '"]').prop('checked', 'checked');
});
if ($('input[name="kb_wysiwyg"]').val() === "1") {
tinyMCE.get('content').setContent(element.message);
} else {
@ -171,7 +176,8 @@ function bindCreateModal() {
.find('input[name="title"]').val('').end()
.find('input[name="id"]').val(-1).end()
.find('input[name="order"]').val('').end()
.find('#preview-pane').html('').end();
.find('#preview-pane').html('').end()
.find('input[name="location[]"]').prop('checked', false);
setIcon('');
if ($('input[name="kb_wysiwyg"]').val() === "1") {
@ -198,13 +204,21 @@ function bindFormSubmit() {
styles[3] = "NOTICE";
styles[4] = "ERROR";
var domLocations = $modal.find('input[name="location[]"]:checked');
var locations = [];
$.each(domLocations, function() {
locations.push($(this).val());
});
var data = {
icon: $modal.find('input[name="icon"]').val(),
title: $modal.find('input[name="title"]').val(),
message: getMessage(),
published: $modal.find('input[name="type"]:checked').val() === "0",
style: styles[$modal.find('input[name="style"]:checked').val()],
order: $modal.find('input[name="order"]').val()
order: $modal.find('input[name="order"]').val(),
locations: locations
};
var url = heskUrl + 'api/index.php/v1/service-messages/';

Loading…
Cancel
Save