csrtechnew.ohctech.in/upload_excel_enquery_inermed.php
2025-04-14 13:28:09 +05:30

308 lines
17 KiB
PHP

<?php include('techsyn_header.php'); ?>
<?php error_reporting(E_ERROR | E_WARNING | E_PARSE); ?>
<!-- Main Content Container for sidebar 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'); ?>
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
<li class="active">Enquiry List</li>
<li class="active">Upload Excel</li>
</ul>
</div>
<!-- <div class="container"> -->
<form action="" method="post" name="frmExcelImport" id="frmExcelImport" enctype="multipart/form-data">
<div class="panel-heading text-center"><b>Upload Excel For Enquiry List</b></div>
<div class="panel-body">
<div style="overflow-x:auto; width: 100%;" >
<table class="table table-bordered" style="width: 100%;">
<thead>
<tr>
<th>Beneficiary Name</th>
<th>Date Of Enquiry (DD/MM/YYYY)</th>
<th>Course Name</th>
<th>Gender (M/F/O)</th>
<th>Village</th>
<th>Date Of Birth (DD/MM/YYYY)</th>
<th>Beneficiary Phone</th>
<th>Aadhar Linked Phone</th>
<th>Parents Phone</th>
<th>Education</th>
<th>Reference From</th>
<!-- <th>Admission Status</th> -->
<th>Type</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$village_query = "SELECT * FROM village";
$result = mysqli_query($conn, $village_query);
$options = '';
while ($vill = mysqli_fetch_assoc($result)) {
$tehsil = getFieldFromTable('name', 'tehsils', 'id', $vill['tehsil']);
$options .= '<option value="' . $vill['id'] . '">' . htmlspecialchars($vill['village']) . ' / ' . htmlspecialchars($tehsil) . '</option>';
}
$sql = "SELECT * FROM interm_enquiry";
$results_section = mysqli_query($conn, $sql);
$i = 0;
while ($row = mysqli_fetch_assoc($results_section)) {
?>
<tr>
<td>
<input type="hidden" name="interm_enquiry_id<?= $i ?>" value="<?= $row['interm_enquiry_id'] ?>">
<input type="text" name="beneficiary_name<?= $i ?>" value="<?= htmlspecialchars($row['beneficiary_name']) ?>">
</td>
<td>
<input type="date" name="enquiry_date<?= $i ?>" value="<?= $row['enquiry_date'] ?>">
</td>
<td>
<select name="course<?= $i ?>">
<option value="" selected disabled>Please Select Course Name</option>
<?php echo generateOption('courses', 'name', 'id', $row['course_id'], ''); ?>
<!-- <?php
$sql = "SELECT batch_id, batch_name FROM training_batch_master WHERE ohc_type_id= '" . $_SESSION['current_ohcttype'] . "'";
$result = mysqli_query($conn, $sql);
while ($batchRow = mysqli_fetch_assoc($result)) {
$sql2 = "SELECT COUNT(*) FROM beneficiary_enquiry WHERE batch_id='" . $batchRow['batch_id'] . "'";
$result2 = mysqli_query($conn, $sql2);
$total = mysqli_fetch_array($result2)[0];
$selected = ($batchRow['batch_id'] == $row['batch_id']) ? 'selected' : '';
echo "<option value='" . $batchRow['batch_id'] . "' $selected>" . htmlspecialchars($batchRow['batch_name']) . " ($total)</option>";
}
?> -->
</select>
</td>
<td>
<select name="gender<?= $i ?>">
<option value="" disabled <?= empty($row['gender']) ? 'selected' : '' ?>>Select Option</option>
<option value="M" <?= $row['gender'] === 'M' ? 'selected' : '' ?>>Male</option>
<option value="F" <?= $row['gender'] === 'F' ? 'selected' : '' ?>>Female</option>
<option value="O" <?= $row['gender'] === 'O' ? 'selected' : '' ?>>Other</option>
</select>
</td>
<td>
<select id="village<?= $i ?>" name="village<?= $i ?>">
<option value="">Select Village</option>
<?= $options; ?>
</select>
<script>
document.addEventListener('DOMContentLoaded', function() {
$('#village<?= $i ?>').val(<?= json_encode($row['village']) ?>).trigger('change');
});
</script>
</td>
<td>
<input type="date" name="dob<?= $i ?>" value="<?= $row['dob'] ?>">
</td>
<td>
<input type="number" name="trainees_no<?= $i ?>" value="<?= htmlspecialchars($row['trainees_no']) ?>">
</td>
<td>
<input type="number" name="aadhar_phone<?= $i ?>" value="<?= htmlspecialchars($row['aadhar_phone']) ?>">
</td>
<td>
<input type="number" name="parents_no<?= $i ?>" value="<?= htmlspecialchars($row['perents_no']) ?>">
</td>
<td>
<select class="form-control select2" name="education<?= $i ?>">
<option value="" disabled <?= empty($row['education']) ? 'selected' : '' ?>>Select qualification</option>
<?php
$sql_emp_1 = "SELECT id, qualification FROM qualification ORDER BY q_seq";
echo generate_options($sql_emp_1, $row['education'], 'id', 'qualification', '', '');
?>
</select>
<!-- <input type="text" name="education<?= $i ?>" value="<?= htmlspecialchars($row['education']) ?>"> -->
</td>
<td>
<input type="text" name="reference_from<?= $i ?>" value="<?= htmlspecialchars($row['reference_from']) ?>">
</td>
<!-- <td>
<select name="admission_status<?= $i ?>">
<option value="" disabled>Select Option</option>
<option value="BPE" <?= $row['addmission_status'] === 'BPE' ? 'selected' : '' ?>>Interested</option>
<option value="enroll" <?= $row['addmission_status'] === 'enroll' ? 'selected' : '' ?>>Enrolled</option>
</select>
</td> -->
<td>
<select name="type<?= $i ?>">
<option value="VTI" <?= $row['type'] === 'VTI' ? 'selected' : '' ?>>VTI</option>
<option value="CSR" <?= $row['type'] === 'CSR' ? 'selected' : '' ?>>CSR</option>
</select>
</td>
<td align='center'>
<a href="#" onclick="delete_item(<?= $row['interm_enquiry_id'] ?>)" class='btn btn-danger btn-sm' title='Delete'>
<span class='glyphicon glyphicon-trash'></span>
</a>
</td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
<input type="hidden" name="count" value="<?= $i ?>">
</div>
</div>
<div class="text-center">
<button type="button" onclick="finalSaveData();" class="btn btn-success">Update/Approve</button>
<button type="button" onclick="updateData();" class="btn btn-primary" style="margin-left: 10px;">Update</button>
</div>
</form>
<!-- </div> -->
</div>
<?php include('techsyn_footer.php'); ?>
<style>
body {
font-family: Arial, sans-serif;
width: 100%;
}
.outer-container {
background: #F0F0F0;
border: #e0dfdf 1px solid;
padding: 40px 20px;
border-radius: 2px;
}
#response {
padding: 10px;
margin-top: 10px;
border-radius: 2px;
display: none;
}
.success {
background: #c7efd9;
border: #bbe2cd 1px solid;
}
.error {
background: #fbcfcf;
border: #f3c6c7 1px solid;
}
div#response.display-block {
display: block;
}
/* Style for scrollable table */
.table {
min-width: 1200px;
/* Adjust as necessary */
}
</style>
<script>
function updateData() {
$.ajax({
url: "update_excel_enquiry.php",
method: "POST",
dataType: "json",
data: $('#frmExcelImport').serialize(),
success: function(data) {
if (data) {
if (data.success) {
BootstrapDialog.alert("Enquiry's updated successfully.", function() {
location.reload();
});
} else {
let errorMessages = data.errors ? data.errors.join('<br>') : 'An unexpected error occurred.';
BootstrapDialog.alert('Update failed:<br>' + errorMessages);
}
} else {
BootstrapDialog.alert('Unexpected response format. Please try again.');
}
},
error: function(xhr) {
// Improved error handling
let errorMessage = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.status + ': ' + xhr.statusText;
BootstrapDialog.alert('Data uploading failed. Error: ' + errorMessage);
}
});
}
function finalSaveData() {
updateData();
$.ajax({
url: "save_excel_enquiry.php",
method: "POST",
dataType: "json",
success: function(data) {
if (data) {
if (data.success) {
BootstrapDialog.alert("Enquiry's Saved successfully.", function() {
window.location.href = 'beneficiary_enquiry.php';
});
} else {
let errorMessages = data.errors ? data.errors.join('<br>') : 'An unexpected error occurred.';
BootstrapDialog.alert('Update failed:<br>' + errorMessages);
}
} else {
BootstrapDialog.alert('Unexpected response format. Please try again.');
}
},
error: function(xhr) {
// Improved error handling
let errorMessage = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.status + ': ' + xhr.statusText;
BootstrapDialog.alert('Data uploading failed. Error: ' + errorMessage);
}
});
}
function delete_item(id) {
BootstrapDialog.confirm('Are you sure to delete the Enquiry?', function(result) {
if (result) {
$.ajax({
url: 'delete_enquiry_item.php',
type: "POST",
data: {
id: id
},
success: function(data) {
if (data.indexOf("SUCCESS") !== -1) {
BootstrapDialog.alert('Enquiry Deleted Successfully.');
location.reload();
} else {
BootstrapDialog.alert('Error Deleting Enquiry');
}
},
error: function() {
BootstrapDialog.alert('Error Deleting Enquiry');
}
});
}
});
}
</script>
</div>
</div>