You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

563 lines
15 KiB

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/modules/base/head :: head}">
<style>
</style>
</head>
<body>
<div class="wrapper">
<!-- header top menu Start -->
<header th:replace="~{fragments/modules/base/header :: header}"></header>
<!-- header top menu end -->
<div class="page-wrap">
<!--=============== Left Menu side Start ================-->
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
<!--=============== Left side End ================-->
<div class="main-content">
<div class="container-fluid">
<div class="page-header mb-2">
<div class="row align-items-end">
<div class="col-lg-8">
<div class="page-header-title">
<!-- <i class="far fa-calendar-plus bg-blue"></i> -->
<div class="d-inline">
<h5>Updation</h5>
<span>View and manage application Entries </span>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<span>Fill in the details </span>
</div>
<div class="card-body">
<div class="row align-items-end">
<div class="col-md-3 col-sm-12">
<label class="form-label" for="unique_num">Unique No</label>
<input type="text" class="form-control" id="unique_num">
</div>
<div class="col-md-1 col-sm-12 text-center pt-4">
<span style="font-weight: bold;">OR</span>
</div>
<div class="col-md-3 col-sm-12">
<label class="form-label" for="mobile_num">Mobile No</label>
<input type="text" class="form-control" id="mobile_num">
</div>
<div class="col-md-3 col-sm-12 d-flex align-items-end">
<button type="submit" id="searchBtn"
class="btn btn-primary mx-2">Search</button>
<button class="btn btn-danger mx-2" id="resetBtn"
name="reset">Reset</button>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
<!-- data table -->
<div class="row" id="detailscard">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table id="DetailsDatatable"
class="table table-striped table-bordered table-hover dataTable"
role="grid">
<thead class="thead-dark">
<tr role="row">
<th class="text-center">S.No</th>
<th class="text-center">Unique No</th>
<th class="text-center width1">Name / Pay Scale / Cur.Basic / Grade Pay</th>
<th class="text-center">Sex</th>
<th class="text-center">Designation</th>
<th class="text-center">State / Central</th>
<th class="text-center">Mobile Number</th>
<th class="text-center">Residential Address</th>
<th class="text-center">Native Constituency</th>
<th class="text-center">Residential Constituency</th>
<th class="text-center">Working Constituency</th>
<th class="text-center">Enrolled - Part / Sl.No / EPIC / Assembly Constituency</th>
<th class="text-center">Photo</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
<div style="position: relative; top: 50%; transform: translateY(-50%);">
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
<span class="sr-only">Loading...</span>
</div>
<!-- Add the 'Please wait' text below the spinner -->
<p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
</div>
</div>
<div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div>
</div>
<script th:replace="~{fragments/modules/base/script :: script}"></script>
<script type="text/javascript">
document.getElementById('resetBtn').addEventListener('click', function (e) {
location.reload();
});
$(document).ready(function() {
// MOBILE NO: exactly 10 digits
$('#mobile_num').on('input', function () {
// Allow only digits
this.value = this.value.replace(/\D/g, '');
// Max 10 digits
if (this.value.length > 10) {
this.value = this.value.slice(0, 10);
}
});
$('#unique_num').on('input', function () {
// Allow only digits
this.value = this.value.replace(/\D/g, '');
});
var table = $('#DetailsDatatable').DataTable({
dom: 'Bftip',
columnDefs: [
{ width: "150px", targets: 2 }, // Name / Pay Scale column
{ width: "150px", targets: 6 }, // Office Address column
{ width: "150px", targets: 8 },
{ width: "150px", targets: 12 }
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: '50vh',
scrollX: true,
buttons: [
{
extend: 'pageLength',
className: 'btn btn-warning'
},
{
title: 'Data export',
extend: 'copyHtml5',
text: 'Copy',
className: 'btn btn-secondary',
id: 'copyBtn'
},
{
extend: 'excelHtml5',
text: 'Excel',
className: 'btn btn-secondary',
id: 'excelBtn'
},
{
extend: 'csvHtml5',
text: 'CSV',
className: 'btn btn-secondary',
id: 'csvBtn'
},
{
extend: 'pdfHtml5',
text: 'PDF',
className: 'btn btn-secondary',
id: 'pdfBtn'
}
],
fixedHeader: true,
autoWidth: true,
responsive: false,
searching: true,
select: false,
processing: false
});
});
document.getElementById('searchBtn').addEventListener('click', function (e) {
$('#pageLoader').show();
let unique_num = document.getElementById('unique_num').value;
let mobile_num = document.getElementById('mobile_num').value;
console.log(unique_num,",",mobile_num);
if(!unique_num && !mobile_num && !batch_num){
$('#pageLoader').hide();
Swal.fire({
icon: 'warning',
title: 'For Search, Any One Is Required ',
text: 'Please Enter required details',
showConfirmButton: true,
timer: 3000
});
e.preventDefault();
return;
}
if(mobile_num){
// Rule 1: Must be exactly 10 digits & must not start with 0
if (!/^[1-9][0-9]{9}$/.test(mobile_num)) {
$('#pageLoader').hide();
Swal.fire({
icon: 'warning',
title: 'Invalid Mobile Number',
text: 'Mobile number must be 10 digits and cannot start with 0.'
});
return;
}
// Rule 2: Reject sequential numbers like 1234567890
if (mobile_num === "1234567890") {
$('#pageLoader').hide();
Swal.fire({
icon: 'warning',
title: 'Invalid Mobile Number',
text: 'Sequential numbers like 1234567890 are not allowed.'
});
return;
}
// Rule 3: Reject all digits same (1111111111, 2222222222, etc.)
if (/^(\d)\1{9}$/.test(mobile_num)) {
$('#pageLoader').hide();
Swal.fire({
icon: 'warning',
title: 'Invalid Mobile Number',
text: 'All digits cannot be the same.'
});
return;
}
}
$.ajax({
type: "GET",
url: `/election/api/updatepollperson/getbymobandslno`,
data:{
mobileNo:mobile_num,
slNo:unique_num
},
contentType: "application/json",
success: function (response) {
console.log("API Response:", response);
$('#pageLoader').hide();
if (response.status === "success") {
console.log("Details Array:", response.data);
// Convert object → array
let records = response.data || [];
console.log("Table Records:", records);
let table = $('#DetailsDatatable').DataTable({
destroy: true,
searching: true,
autoWidth: true,
paging: true,
info: true,
data: records,
columns: [
{
data: null,
render: (data, type, row, meta) => meta.row + 1,
className: 'text-center'
},
{ data: null,
className: 'text-center' ,
render: r => `${r.slno || '-'}`
},
{ data: null,
className: 'text-center width1' ,
render: r => `
${r.name || '-'}<br>
<small>
${r.pay_scale || '-'} /
${r.curr_basic }
</small>`
},
{ data: 'sex',className: 'text-center' },
{ data: 'designation',className: 'text-center' },
{ data: 'govt_type',className: 'text-center' },
{ data: 'r_mobile_no' ,className: 'text-center' },
{ data: 'res_address', className: 'text-center' },
{ data: null,
className: 'text-center' ,
render: r => `${r.native_ac_no || '-'} - ${r.native_assembly || '-'}`
},
{ data: null,
className: 'text-center' ,
render: r => `${r.reside_ac_no || '-'} - ${r.res_assembly || '-'}`
},
{ data: null,
className: 'text-center' ,
render: r => `${r.work_ac_no || '-'} - ${r.work_assembly || '-'}`
},
{
data: null,
className: 'text-center',
render: {
display: r => `
Part: ${r.elector_part_no }<br>
Sl: ${r.elector_sl_no }<br>
${r.epic_no }<br>
${r.elector_ac_no } - ${r.enrolled_assembly }
`,
export: r =>
`Part: ${r.elector_part_no }\n` +
`Sl: ${r.elector_sl_no }\n` +
`${r.elector_epic_no }\n` +
`${r.elector_ac_no } - ${r.enrolled_assembly }`
}
},
{
data: 'img_full_path',
className: 'text-center',
render: function (url, type, row) {
if (!url) {
return `<span style="color:red;">No Image</span>`;
}
return `
<img src="${url}"
style="height: 100px; width: 100px; object-fit: cover; border:1px solid #ccc;"
alt="Photo">
`;
}
},
{
data: null,
className: 'text-center',
render: function (data) {
let slno=data.slno;
return `
<button class="btn btn-primary btn-sm"
onclick="goToUpdateForm('${slno}')">
Update
</button>
`;
}
}
],
dom: 'Bfrtip',
buttons: [
{
extend: 'pageLength',
className: 'btn btn-warning'
},
{
title: 'Data export',
extend: 'copyHtml5',
text: 'Copy',
className: 'btn btn-secondary',
id: 'copyBtn'
},
{
extend: 'excelHtml5',
text: 'Excel',
className: 'btn btn-secondary',
id: 'excelBtn',
filename: function () {
return 'polling_personnel_details_' + getTimestamp();
}
},
{
extend: 'csvHtml5',
text: 'CSV',
className: 'btn btn-secondary',
id: 'csvBtn',
filename: function () {
return 'polling_personnel_details_' + getTimestamp();
}
},
{
extend: 'pdfHtml5',
text: 'PDF',
className: 'btn btn-secondary',
id: 'pdfBtn',
title:'Polling Personnel Details',
filename: function () {
return 'polling_personnel_details_' + getTimestamp();
},
orientation: 'landscape', // ⭐ important line
pageSize: 'A4',
customize: function (doc) {
doc.pageOrientation = 'landscape';
// Reduce page margins to use full width
doc.pageMargins = [10, 10, 10, 10];
// Reduce default font size so columns fit
doc.defaultStyle.fontSize = 7;
doc.styles.tableHeader.fontSize = 8;
// ⭐ Force table to shrink inside page
doc.content[1].table.widths = [
20, // S.No
30, // Unique/Batch
60, // Name / Pay Scale
20, // Sex
60, // Designation
30, // State / Central
100, // Office Address
50, // Mobile
90, // Residence Address
40, // Native
40, // Reside
40, // Work
70, // Enrolled
50, // Photo
30 // action
];
// ⭐ Remove large default paddings
var objLayout = {};
objLayout['hLineWidth'] = function(i) { return 0.3; };
objLayout['vLineWidth'] = function(i) { return 0.3; };
objLayout['hLineColor'] = function(i) { return '#000'; };
objLayout['vLineColor'] = function(i) { return '#000'; };
objLayout['paddingLeft'] = function(i) { return 2; };
objLayout['paddingRight'] = function(i) { return 2; };
objLayout['paddingTop'] = function(i) { return 2; };
objLayout['paddingBottom'] = function(i) { return 2; };
doc.content[1].layout = objLayout;
}
}
],
columnDefs: [
{ width: "150px", targets: 2},
{ width: "150px", targets: 6},
{ width: "120px", targets: 8},
{ width: "150px", targets: 12} ,
{ width: "150px", targets: 12}
],
lengthMenu: [
[50, 100, 200, 500, -1],
['50 rows', '100 rows', '200 rows', 'Show all']
],
scrollY: '80vh',
scrollX: true,
responsive: false,
searching: true
});
}
else if (response.status === "no_data") {
$('#pageLoader').hide();
Swal.fire({
icon: 'info',
title: 'No Data',
text: response.data || 'Something went wrong!'
});
}
else if (response.status === "error") {
$('#pageLoader').hide();
Swal.fire({
icon: 'error',
title: 'Error',
text: response.message || 'Something went wrong!'
});
}
else {
$('#pageLoader').hide();
Swal.fire({
icon: 'error',
title: 'Error',
text: response.message || 'Something went wrong!'
});
}
},
error: function (error) {
$('#pageLoader').hide();
Swal.fire({
icon: 'error',
title: 'Error',
text: response.message || 'Something went wrong!'
});
}
});
});
function goToUpdateForm(slno) {
// Save values in sessionStorage
sessionStorage.setItem("slno", slno);
// Redirect to form page
window.location.href = "/election/update_pollingperson/updateform";
}
</script>
</body>
</html>