ESH/food_handler_canteen_location.php

303 lines
6.7 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?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">Food Handler Canteen Location</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_canteen_location">
<div id="flex1" style="width:100%">
</div>
<input type="hidden" name="flex_canteen_id" id="flex_canteen_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: 'food_handler_canteen_location_script.php',
dataType: 'json',
colModel: [{
display: 'Sr',
name: 'count',
width: w * .04,
sortable: false,
align: 'left'
},
{
display: 'Location',
name: 'canteen_location',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'Location Type',
name: 'type',
width: w * .2,
sortable: true,
align: 'left'
},
{
display: 'location Code',
name: 'canteen_code',
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: 'Location',
name: 'canteen_location',
isdefault: true
},
{
display: 'Location Type',
name: 'type',
isdefault: true
},
{
display: 'Location Code',
name: 'canteen_code',
isdefault: true
},
],
sortname: "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();
$("#canteen_id").val("");
$("#type").val("");
$("#canteen_location").val("");
$("#canteen_code").val("");
$('#modal-add-canteen_location').modal("show");
}
function pdf() {
window.open('canteen_location_pdf.php');
}
function excel() {
window.location = 'canteen_location_excel.php';
}
function delete_canteen_location(canteen_id) {
$("#flex_canteen_id").val(canteen_id);
BootstrapDialog.confirm('Are you sure to delete the Canteen Location?', function(result) {
if (result) {
$.ajax({
url: 'food_handler_canteen_delete.php',
type: "POST",
data: $("#flex_form_canteen_location").serialize(),
success: function(data) {
if (data.indexOf("SUCCESS") != -1) {
BootstrapDialog.alert('Canteen Location Deleted Successfully.');
$("#flex1").flexReload();
} else {
BootstrapDialog.alert('Error Deleting Canteen Location');
}
return;
},
error: function(data) {
BootstrapDialog.alert('Error Deleting Canteen Location');
return;
}
});
}
});
}
function validate() {
var canteen_location = $('#canteen_location').val();
var canteen_code = $('#canteen_code').val();
var type = $('#type').val();
if (canteen_location == '') {
BootstrapDialog.alert('Please Enter Location .!!!');
return false;
}
if (canteen_code == '') {
BootstrapDialog.alert('Please Enter Location Code .!!!');
return false;
}
if (type == '') {
BootstrapDialog.alert('Please Enter location Type .!!!');
return false;
}
for (let i = 0; i < canteen_location.length; i++) {
let result = isValid(canteen_location[i]);
if (!result) {
BootstrapDialog.alert("You can not enter spaces and special characters in column name");
return result;
}
}
for (let i = 0; i < type.length; i++) {
let result = isValid(type[i]);
if (!result) {
BootstrapDialog.alert("You can not enter spaces and special characters in column name");
return result;
}
}
for (let i = 0; i < canteen_code.length; i++) {
let result = isValid(canteen_code[i]);
if (!result) {
BootstrapDialog.alert("You can not enter spaces and special characters in column name");
return result;
}
}
function isValid(str) {
return !/[~`!@#$%\^&*()+=\-\\\[\]\\';,/{}|\\":<>\?]/g.test(str);
}
save_canteen_location();
}
function save_canteen_location() {
$.ajax({
url: 'save_food_handler_canteen_location.php',
type: "POST",
data: $("#canteen_location_form").serialize(),
success: function(data) {
BootstrapDialog.alert('canteen Location Saved Successfully.');
$("#flex1").flexReload();
return;
},
error: function(data) {
BootstrapDialog.alert('Error Saving canteen Location');
return;
}
});
$('.close').click();
}
function open_canteen_location(canteen_id, action) {
console.log("ID is" + canteen_id);
if (action == "V") {
$(".save_button").hide();
} else {
$(".save_button").show();
}
$.ajax({
url: 'select_food_handler_canteen_location.php',
type: 'POST',
data: {
id: canteen_id
},
success: function(data) {
// alert(data);
var data = $.parseJSON(data);
if (data.type == 'canteen') {
$('#type [value="canteen"]').attr('selected', true);
}else{
$('#type [value="kitchen"]').attr('selected', true);
}
// alert(data);
$("#canteen_id").val(data.id);
// alert(data.id);
$("#canteen_location").val(data.canteen_location);
$("#canteen_code").val(data.canteen_code);
console.log("type " + data.type);
$('#modal-add-canteen_location').modal("show");
// $(".save_button").on('click' , function(){
// save_canteen_location();
// })
},
error: function(data) {
BootstrapDialog.alert('Error Canteen Location');
return;
}
});
}
</script>
<?php include('techsyn_footer.php'); ?>
<?php include('form/add_food_handler_canteen_location.php'); ?>