184 lines
7.7 KiB
PHP
184 lines
7.7 KiB
PHP
<div class="row">
|
|
<div class="col-lg-9">
|
|
<div class="panel panel-flat">
|
|
<div class="jumbotron" style="background-color:#F3DFE5; padding:10px;">
|
|
<h3>Notification Trigger Settings</h3>
|
|
</div>
|
|
<div class="col-lg-12" style="border-radius:5px;background-color:#f2f2f2">
|
|
<form class="search-block" action="?" method="GET">
|
|
<div class="form-group">
|
|
<label for="trigger_id">Trigger ID</label>
|
|
<input type="search" class="form-control" id="trigger_id" name="trigger_id" value='<?= isset($trigger_id) ? $trigger_id : '' ?>'>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="next_action">Next Action</label>
|
|
<input type="search" class="form-control" id="next_action" name="next_action" value='<?= isset($next_action) ? $next_action : '' ?>'>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="card_key">Card Key</label>
|
|
<input type="search" class="form-control" id="card_key" name="card_key" value='<?= isset($card_key) ? $card_key : '' ?>'>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email_template">Email Template</label>
|
|
<input type="search" class="form-control" id="email_template" name="email_template" value='<?= isset($email_template) ? $email_template : '' ?>'>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="search_text">Send Email</label>
|
|
<?= $card_send_mail ?>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="search_text">Send Notification</label>
|
|
<?= $card_send_notification ?>
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
<label for="search_text">Status</label>
|
|
<?= $card_status ?>
|
|
</div>
|
|
|
|
<div class="form-group" style="display: flex; align-self: center; margin-bottom: unset;">
|
|
<button class="btn btn-primary btn-search" type="submit">Search</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<?= $link ?>
|
|
<div class="panel panel-white">
|
|
<table style="max-width:100%" id="trigger-list" class="table table-striped table-hover table-bordered table-condensed">
|
|
<thead class="bg-indigo">
|
|
<th>ID</th>
|
|
<th>Trigger ID</th>
|
|
<th>Details</th>
|
|
<th>Description</th>
|
|
<th>Update</th>
|
|
<th>Edit</th>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($trigger_table as $value) { ?>
|
|
<tr>
|
|
<td><?= $value['id'] ?></td>
|
|
<td><?= $value['trigger_id'] ?></td>
|
|
<td>
|
|
<b>Next Action:</b> <?= $value['next_action'] ?><br>
|
|
<b>Default Message:</b> <?= $value['message'] ?><br>
|
|
<b>Card Key:</b> <?= $value['card_key'] ?><br>
|
|
<b>Send Notification:</b> <?= $value['send_notification_text'] ?><br>
|
|
<b>Send Email:</b> <?= $value['send_mail_text'] ?><br>
|
|
<b>Email Template:</b> <?= $value['email_template'] ?><br>
|
|
<b>Icon:</b> <?= $value['icon'] ?><br>
|
|
<b>Notification Title:</b> <?= $value['notify_title']??'' ?><br>
|
|
<hr>
|
|
<b>Status:</b> <?= $value['status_text'] ?><br>
|
|
</td>
|
|
<td><?= $this->ckeditor->editor('index' . $value['id'], $value['action_detail']); ?></td>
|
|
<td>
|
|
<button type="button" id="index<?= $value['id'] ?>" class="btn btn-primary btn-update disable-pointer disabled">Update</button>
|
|
<p class="messages text-center" id="message<?= $value['id'] ?>"></p>
|
|
</td>
|
|
<td>
|
|
<button type="button" id="edit_trig<?= $value['id'] ?>" onclick="editTriggerItem('<?= $value['trigger_id'] ?>'); return true;" class="btn btn-danger btn-edit">Edit</button>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-3">
|
|
<!-- Media library -->
|
|
<div class="panel panel-white" id="set_detail">
|
|
|
|
</div>
|
|
<!-- /media library -->
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript" src="/assets/ckeditor/ckeditor.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
$('.btn-update').click(function (e) {
|
|
let $this = $(this);
|
|
$('.messages').text("");
|
|
|
|
e.preventDefault();
|
|
$this.button("loading");
|
|
|
|
let id = $this.closest('tr').find('td:eq(0)').html();
|
|
let description = CKEDITOR.instances['index' + id].getData();
|
|
|
|
$.ajax({
|
|
url: '/notifications/update',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: {
|
|
'id': id,
|
|
'description': description
|
|
},
|
|
success: function (response) {
|
|
$('#message' + id).text(response.message);
|
|
|
|
if (response.code) {
|
|
$('#message' + id).addClass('text-success');
|
|
} else {
|
|
$('#message' + id).addClass('text-danger');
|
|
}
|
|
},
|
|
complete: function () {
|
|
$this.button("reset")
|
|
.addClass('disable-pointer')
|
|
.addClass('disabled');
|
|
}
|
|
});
|
|
});
|
|
|
|
Object.values(CKEDITOR.instances).forEach((item, idx) => {
|
|
item.on('change', () => {
|
|
$(`button[id="index${idx + 1}"]`)
|
|
.removeClass('disable-pointer')
|
|
.removeClass('disabled');
|
|
})
|
|
})
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.disable-pointer {
|
|
pointer-events: none;
|
|
}
|
|
|
|
.search-block {
|
|
display: flex;
|
|
justify-content: space-around;
|
|
flex-wrap: wrap;
|
|
}
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
|
<!--
|
|
function editTriggerItem(trigger_id) {
|
|
|
|
// var e = document.getElementById("points_settings");
|
|
// var points_settings = e.options[e.selectedIndex].value;
|
|
|
|
// alert(trigger_id);
|
|
|
|
// if (points_settings == "") {
|
|
// alert("Please select a points settings");
|
|
// return false;
|
|
// }
|
|
|
|
$('#edit_trig').prop('disabled', true);
|
|
$('#set_detail').html('Processing...');
|
|
$.ajax({
|
|
url: "/notifications/editTrigger?trigger_id=" + trigger_id + "&member_id=0"
|
|
}).done(function (data) {
|
|
$('#set_detail').html(data);
|
|
$('#edit_trig').prop('disabled', false);
|
|
});
|
|
return false;
|
|
}
|
|
|
|
// -->
|
|
</script>
|