Files
dev-chiefworks f76abffdcd first commit
2022-05-31 16:21:53 -04:00

169 lines
5.3 KiB
PHP

<div style="width:100%;">
<input type="hidden" id='member_id' name='e_trigger' value="<?= $e_trigger ?>" />
<table class="table">
<tbody>
<tr>
<td colspan="2"><h3><?= $e_trigger ?> </h3></td>
</tr>
<tr>
<td colspan="2">Dynamic Key: <h5><?= $dynamic_key ?> </h5></td>
</tr>
<tr>
<th width="50px;" scope="row">Next Action</th>
<td><?= $category_settings ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Override Card Text</th>
<td><?= $override_text_combo ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Notification Title</th>
<td><input type="text" class="form-control" name="notify_title" id="notify_title" value="<?= $notify_title??'' ?>"></td>
</tr>
<tr>
<th width="50px;" scope="row">Expiration</th>
<td><?= $expiration_combo ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Action Card</th>
<td><?= $card_settings ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Frequency</th>
<td><?= $frequency_combo??'' ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Send Day</th>
<td><?= $send_day_combo??'' ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Send Time</th>
<td><?= $send_time_combo??'' ?></td>
</tr>
<tr>
<th width="50px;" scope="row">Icon</th>
<td><input type="text" class="form-control" name="icon" id="icon" value="<?= $icon??'' ?>"></td>
</tr>
<tr>
<td colspan="2" style="text-align: right;">
<button type="button" id="accb" onclick="updateTriggerItem('<?= $e_trigger ?>'); return true;" class="btn btn-info">Update</button>
</td>
</tr>
<tr>
<td colspan="2"><div id="updt_detail"> </div> </td>
</tr>
</tbody>
</table>
<form name="memberProfile" id="memberProfile" action="#">
</form>
</div>
<script type="text/javascript">
<!--
function updateTriggerItem(e_trigger) {
var e = document.getElementById("category_settings");
var category_settings = e.options[e.selectedIndex].value;
//alert(category_settings);
var f = document.getElementById("card_settings");
var card_settings = f.options[f.selectedIndex].value;
var e1 = document.getElementById("override_text");
var override_text = e1.options[e1.selectedIndex].value;
var e2 = document.getElementById("expiration");
var expiration = e2.options[e2.selectedIndex].value;
var eicon = document.getElementById("icon");
var icon = eicon.value;
var enotify_title = document.getElementById("notify_title");
var notify_title = enotify_title.value;
const frequency = document.getElementById("frequency").value || '';
const send_day = document.getElementById("send_day").value || '';
const send_time = document.getElementById("send_time").value || '';
// alert(card_settings);
if (category_settings == "") {
alert("Please select next action");
return false;
}
if (expiration == "") {
alert("Please select expiration");
return false;
}
if (card_settings == "") {
alert("Please select action card");
return false;
}
/*
//
// alert(category_settings);
*/
$('#accb').prop('disabled', true);
$('#updt_detail').html('Started Processing...');
$.ajax({
url: "/notifications/before_update_trigger?e_trigger=" + e_trigger+"&card_settings="+card_settings
}).done(function (data) {
var data = JSON.parse(data);
var is_used = data.used;
var force_update = false;
if(is_used==true){
var force_update = confirm(data.message);
}
console.log(is_used)
if(force_update==true || is_used==false){
$.ajax({
url: "/notifications/update_trigger",
method: "POST",
data: {
category_settings,
e_trigger,
card_settings,
expiration,
override_text,
icon,
notify_title,
frequency,
send_day,
send_time
},
dataType: "html"
}).done(function (data) {
$('#updt_detail').html(data);
$('#accb').prop('disabled', false);
});
}else{
$('#updt_detail').html('');
$('#accb').prop('disabled', false);
}
});
return false;
}
// -->
</script>