2015-03-21 21:30:55 +00:00
|
|
|
<?php
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
$no_refresh = true;
|
2015-03-21 21:30:55 +00:00
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
require_once 'includes/modal/alert_template.inc.php';
|
|
|
|
require_once 'includes/modal/delete_alert_template.inc.php';
|
|
|
|
require_once 'includes/modal/attach_alert_template.inc.php';
|
2014-11-30 17:49:52 +00:00
|
|
|
?>
|
2017-07-19 01:54:14 +03:00
|
|
|
<div class="table-responsive">
|
|
|
|
<table id="templatetable" class="table table-hover table-condensed" width="100%">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th data-column-id="id" data-searchable="false" data-identifier="true" data-type="numeric">#</th>
|
|
|
|
<th data-column-id="templatename">Name</th>
|
|
|
|
<th data-column-id="actions" data-searchable="false" data-formatter="commands">Action</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2017-08-12 22:21:13 +03:00
|
|
|
<tr data-row-id="0">
|
|
|
|
<td>0</td>
|
|
|
|
<td>Default Alert Template</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2014-11-30 17:49:52 +00:00
|
|
|
<?php
|
2017-07-19 01:54:14 +03:00
|
|
|
$full_query = "SELECT id, name from alert_templates";
|
2015-07-13 20:10:26 +02:00
|
|
|
foreach (dbFetchRows($full_query, $param) as $template) {
|
2017-08-12 22:21:13 +03:00
|
|
|
if ($template['name'] == 'Default Alert Template') {
|
|
|
|
$default_tplid = $template['id'];
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-19 01:54:14 +03:00
|
|
|
echo '<tr data-row-id="'.$template['id'].'">
|
|
|
|
<td>'.$template['id'].'</td>
|
2014-11-30 17:49:52 +00:00
|
|
|
<td>'.$template['name'].'</td>
|
2017-07-19 01:54:14 +03:00
|
|
|
<td></td>
|
2014-11-30 17:49:52 +00:00
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
2017-07-19 01:54:14 +03:00
|
|
|
?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
var grid = $('#templatetable').bootgrid({
|
|
|
|
rowCount: [50, 100, 250, -1],
|
|
|
|
templates: {
|
|
|
|
header: '<div id="{{ctx.id}}" class="{{css.header}}"> \
|
|
|
|
<div class="row"> \
|
|
|
|
<?php if ($_SESSION['userlevel'] >= '10') { ?>
|
|
|
|
<div class="col-sm-8 actionBar"> \
|
|
|
|
<span class="pull-left"> \
|
|
|
|
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#alert-template" data-template_id="">Create new alert template</button> \
|
|
|
|
</span> \
|
|
|
|
</div> \
|
|
|
|
<div class="col-sm-4 actionBar"><p class="{{css.search}}"></p><p class="{{css.actions}}"></p></div></div></div>'
|
|
|
|
<?php } else { ?>
|
|
|
|
<div class="actionBar"><p class="{{css.search}}"></p><p class="{{css.actions}}"></p></div></div></div>'
|
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
},
|
|
|
|
formatters: {
|
|
|
|
"commands": function(column, row) {
|
2017-08-12 22:21:13 +03:00
|
|
|
var response = '';
|
|
|
|
if(row.id == 0) {
|
|
|
|
response = "<button type=\"button\" class=\"btn btn-xs btn-primary command-edit\" data-toggle='modal' data-target='#alert-template' data-template_id=\"" + row.id + "\" data-template_action='edit' name='edit-alert-template'><i class=\"fa fa-pencil\" aria-hidden=\"true\"></i></button> " + "<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" disabled=\"disabled\"><i class=\"fa fa-trash-o\" aria-hidden=\"true\"></i></button> " + "<button type='button' class='btn btn-warning btn-xs command-attach' disabled=\"disabled\"><i class='fa fa-th-list' aria-hidden='true'></i></button>";
|
|
|
|
} else {
|
|
|
|
response = "<button type=\"button\" class=\"btn btn-xs btn-primary command-edit\" data-toggle='modal' data-target='#alert-template' data-template_id=\"" + row.id + "\" data-template_action='edit' name='edit-alert-template'><i class=\"fa fa-pencil\" aria-hidden=\"true\"></i></button> " + "<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" data-toggle=\"modal\" data-target='#confirm-delete-alert-template' data-template_id=\"" + row.id + "\" name='delete-alert-template'><i class=\"fa fa-trash-o\" aria-hidden=\"true\"></i></button> " + "<button type='button' class='btn btn-warning btn-xs command-attach' data-toggle='modal' data-target='#attach-alert-template' data-template_id='" + row.id + "' name='attach-alert-template'><i class='fa fa-th-list' aria-hidden='true'></i></button>";
|
|
|
|
}
|
2017-07-19 01:54:14 +03:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}).on("loaded.rs.jquery.bootgrid", function() {
|
|
|
|
/* Executes after data is loaded and rendered */
|
|
|
|
grid.find(".command-edit").on("click", function(e) {
|
2017-08-12 22:21:13 +03:00
|
|
|
var localtmpl_id = $(this).data("template_id");
|
|
|
|
if(localtmpl_id == 0) {
|
|
|
|
$('#default_template').val("1");
|
|
|
|
$('#template_id').val(<?=$default_tplid?>);
|
|
|
|
} else {
|
|
|
|
$('#default_template').val("0");
|
|
|
|
$('#template_id').val(localtmpl_id);
|
|
|
|
}
|
2017-07-19 01:54:14 +03:00
|
|
|
$("#alert-template").modal('show');
|
|
|
|
}).end().find(".command-delete").on("click", function(e) {
|
|
|
|
$('#template_id').val($(this).data("template_id"));
|
|
|
|
$('#confirm-delete-alert-template').modal('show');
|
|
|
|
}).end().find(".command-attach").on("click", function(e) {
|
|
|
|
$('#template_id').val($(this).data("template_id"));
|
|
|
|
$('#attach-alert-template').modal('show');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|