csrtechnew.ohctech.in/hariyali_sub_center.php

308 lines
10 KiB
PHP
Raw Permalink Normal View History

2025-04-14 13:28:09 +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="#">Master</li>
<li class="active">Sub-Centers</li>
</ul>
</div>
<!-- End of breadcrumb -->
<div class="page-content">
<div id="flexigridDiv" class="table-responsive">
<form name="export_form" method="post" id="export_form" action="">
<input type="hidden" name="pdf_action" id="pdf_action" value="pdf_State_Master_list.php" />
<input type="hidden" name="excel_action" id="excel_action" value="excel_State_Master_list.php" />
</form>
<form name="f1" method="post" action="" id="flex_form_State_Master">
<div id="flex1" style="width:100%">
</div>
<input type="hidden" name="flex_State_Master_id" id="flex_State_Master_id" />
</form>
</div>
</div>
</div><!-- /.page-content -->
</div>
</div><!-- /.main-content -->
<script type="text/javascript">
$(function() {
var w = screen.width * 0.90;
var h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * 0.75;
$("#flex1").flexigrid({
url: 'hariyali_sub_center_script.php',
dataType: 'json',
colModel: [{
display: 'Actions',
name: 'actions',
width: w * 0.1,
sortable: false,
align: 'center'
},
{
display: 'Sr no.',
name: 'count',
width: w * 0.04,
sortable: false,
align: 'center'
},
{
display: 'Sub Center Category',
name: 'sub_center_category',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Sub Center Name',
name: 'sub_center_name',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Sub Center Code',
name: 'sub_center_code',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Parent Center Name',
name: 'parent_center_name',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Sub Center Owner',
name: 'shg_owner',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Mobile No',
name: 'mobile_no',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Verification Status',
name: 'otp_verified',
width: w * 0.15,
sortable: true,
align: 'left'
},
{
display: 'Address',
name: 'address',
width: w * 0.15,
sortable: true,
align: 'left'
},
],
buttons: [{
name: 'Add',
bclass: 'add',
onpress: add
},
{
separator: true
},
{
name: 'PDF',
bclass: 'print',
onpress: function() {
pdf('pdf'); // Pass 'pdf' to the pdf function
}
},
{
separator: true
},
{
name: 'Excel',
bclass: 'print_excel',
onpress: function() {
pdf('excel'); // Pass 'excel' to the pdf function
}
},
{
separator: true
}
],
searchitems: [
{
display: 'Center Name',
name: 'sub_center_name',
isdefault: true
},
{
display: 'Center Category',
name: 'sub_center_category',
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,
height: h,
singleSelect: true
});
});
// function excel() {
// window.open('excel_State.php', 'State List');
// }
function pdf(type) {
// Construct the URL with the type parameter
var url = 'pdf_sub_center.php?type=' + encodeURIComponent(type);
window.open(url, 'Sub Center List');
}
function add() {
$(".save_button").show();
// Clear input fields
$("#send_otp_btn").hide();
$("#otp_status").text("").css('color', 'red');
$("#state_id").val("");
$("#state_name").val("");
$("#shg_owner").val("");
$("#mobile_no").val("");
$("#address").val("").select2();
$("#village").val("").select2();
$("#district").val("").select2();
$("#tehsil").val("").select2();
$('#modal-add-state').modal("show");
}
function delete_section(state_id) {
$("#state_id").val(state_id);
BootstrapDialog.confirm('Are you sure to delete the Sub Center?', function(result) {
if (result) {
$.ajax({
url: 'delete_sub_center.php',
type: "POST",
data: $("#flex_form_state").serialize(),
success: function(data) {
if (data.indexOf("SUCCESS") != -1) {
BootstrapDialog.alert('State Deleted Successfully.');
$("#flex1").flexReload();
} else {
BootstrapDialog.alert('Error Deleting Role');
}
return;
},
error: function(data) {
BootstrapDialog.alert('Error Deleting Role');
return;
}
});
}
});
}
function save_section() {
$.ajax({
url: 'save_sub_center.php',
type: "POST",
data: $("#flex_form_state").serialize(),
success: function(data) {
BootstrapDialog.alert('Sub Center Saved Successfully.');
$("#flex1").flexReload();
return;
},
error: function(data) {
BootstrapDialog.alert('Error Saving Sub Center');
return;
}
});
$('.close').click();
}
function open_section(state_id, action) {
console.log('Opening state with id:', state_id, 'and action:', action); // Add this line
if (action == "V") {
$(".save_button").hide();
$("#state_name").prop('disabled', true);
} else {
$("#state_name").prop('disabled', false);
$(".save_button").show();
}
$.ajax({
url: 'select_sub_center.php?id=' + state_id,
type: 'POST',
success: function(data) {
var data = $.parseJSON(data);
console.log(data); // Log the data for debugging
if (data.message !== "Data not found!") {
$("#state_id").val(data.id);
$("#sub_center_name").val(data.sub_center_name);
$("#sub_center_category").val(data.sub_center_category);
$("#parent_center_name").val(data.parent_center_name);
$("#shg_owner").val(data.shg_owner);
$("#mobile_no").val(data.mobile_no);
$("#sub_center_code").val(data.sub_center_code);
// $("#address").val(data.village).select2();
// $("#village").val(data.state).select2();
// $("#district").val(data.district).select2();
// $("#tehsil").val(data.tehsil).select2();
if (data.otp_verified == 1) {
$("#send_otp_btn").hide();
$("#mobile_no").prop('readonly', true);
$("#otp_status").text('Verification Completed').css('color', 'green');
} else {
$("#send_otp_btn").show();
$("#mobile_no").prop('readonly', false);
$("#otp_status").text("Verification Pending").css('color', 'red');
}
if (data.village > 0) {
getAddress(data.village);
}
$('#modal-add-state').modal("show");
} else {
BootstrapDialog.alert(data.message);
}
},
error: function(data) {
BootstrapDialog.alert('Error Populating State Details');
return;
}
});
}
</script>
<?php include('techsyn_footer.php'); ?>
<?php include('add_sub_center.php'); ?>