ESH/communication_item_master.php
2024-10-23 18:28:06 +05:30

239 lines
5.0 KiB
PHP

<?php include('techsyn_header.php'); ?>
<!-- Main Content Container for side bar and body-->
<div class="main-container ace-save-state" id="main-container">
<script type="text/javascript">
try {
ace.settings.loadState('main-container')
} catch (e) {}
</script>
<?php include('techsyn_sidebar.php'); ?>
<!--breadcrumb-->
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
<li class="#">Data Setup</li>
<li class="#">Masters</li>
<li class="active">communication item master</li>
</ul>
</div>
<!-- End of breadcrumb -->
<div class="page-content">
<div id="flexigridDiv" class="table-responsive">
<form name="f1" method="post" action="" id="flex_form_health_advice">
<div id="flex1" style="width:100%">
</div>
<input type="hidden" name="flex_health_advice_id" id="flex_health_advice_id" />
</form>
</div>
</div>
</div><!-- /.page-content -->
</div>
</div><!-- /.main-content -->
<script type="text/javascript">
$(function() {
var w = screen.width * .90;
var h = 0;
h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .75;
$("#flex1").flexigrid({
url: 'communication_master_script.php',
dataType: 'json',
colModel: [{
display: 'Sr',
name: 'count',
width: w * .04,
sortable: false,
align: 'left'
},
{
display: 'Communication Item Name',
name: 'com_item',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: '',
name: '',
width: w * .3,
sortable: false,
align: 'left'
},
],
buttons: [
{
name: 'Add',
bclass: 'add',
onpress: add
},
{
separator: true
},
{
name: 'PDF',
bclass: 'print',
onpress: pdf
},
{
separator: true
},
{
name: 'Excel',
bclass: 'print_excel',
onpress: excel
},
{
separator: true
}
],
searchitems: [
{
display: 'Health Advice Name',
name: 'health_advice_name',
isdefault: true
},
{
display: 'Health Advice Desc',
name: 'health_advice_cat'
}
],
sortname: "communication_id",
sortorder: "asc",
usepager: true, //pagination
useRp: true,
rp: 50, //records per page
showTableToggleBtn: false, //toggle button for the whole table
resizable: true,
//width: w,
height: h,
singleSelect: true
});
});
function add() {
$(".save_button").show();
$("#communication_id").val("");
$("#com_item").val("");
$('#modal-add-health_advice').modal("show");
}
function pdf() {
window.open('communication_item_pdf.php');
}
function excel() {
window.location = 'communication_item_excel.php';
}
function delete_health_advice(health_advice_id) {
$("#flex_health_advice_id").val(health_advice_id );
BootstrapDialog.confirm('Are you sure to delete the communication item?', function(result) {
if (result) {
$.ajax({
url: 'delete_communication_item.php',
type: "POST",
data: $("#flex_form_health_advice").serialize(),
success: function(data) {
if (data.indexOf("SUCCESS") != -1) {
BootstrapDialog.alert('communication item Deleted Successfully.');
$("#flex1").flexReload();
} else {
BootstrapDialog.alert('Error Deleting communication item');
}
return;
},
error: function(data) {
BootstrapDialog.alert('Error Deleting communication item');
return;
}
});
}
});
}
function validate() {
var com_item = $('#com_item').val();
if (com_item == '') {
BootstrapDialog.alert('Please Enter Communication Item Name.!!!');
return false;
}
save_health_advice();
function isValid(str) {
return !/[~`!@#$%\^&*()+=\-\\\[\]\\';,/{}|\\":<>\?]/g.test(str);
}
}
function save_health_advice() {
$.ajax({
url: 'save_communication_item.php ',
type: "POST",
data: $("#communication_master_form").serialize(),
success: function(data) {
BootstrapDialog.alert('communication item Saved Successfully.');
$("#flex1").flexReload();
return;
},
error: function(data) {
BootstrapDialog.alert('Error Saving communication item');
return;
}
});
$('.close').click();
}
function open_health_advice(health_adviceId, action) {
var health_advice_id = "";
if (action == "V") {
$(".save_button").hide();
} else {
$(".save_button").show();
}
$.ajax({
url: 'select_communication_item.php?health_adviceId=' + health_adviceId + ' ',
type: 'POST',
success: function(data) {
var data = $.parseJSON(data);
$("#communication_id").val(data.communication_id);
$("#com_item").val(data.com_item);
$('#modal-add-health_advice').modal("show");
},
error: function(data) {
BootstrapDialog.alert('Error Populating Health Advice');
return;
}
});
}
</script>
<?php include('techsyn_footer.php'); ?>
<?php include('add_communication_item.php'); ?>