|
|
<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head th:replace="~{fragments/modules/base/head :: head}"></head><style>#btn_container button{ width: 20%;}</style><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>Polling Personnel Updation</h5> <span>Polling Personnel Update form</span> </div> </div> </div> </div> </div> <div class="container">
<div class="row"> <div class="card" style="padding: 10px;"><span th:text="${LoginUserId}" style="display:none;" id="userIdSpan"></span> <form id="newpollingform" enctype="multipart/form-data" > <div class=" mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;"> <label class="form-label" for="batch_no">Batch No</label> <input type="text" class="form-control" id="batch_no" readonly> </div> <div class=" mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;"> <div class="row" style="row-gap:10px;"> <div id="existing_uniquenum" style="display: none;"></div> <div class="col-md-8 col-sm-12"> <label class="form-label" for="official_name">Name of the Official<span class="text-danger">*</span></label> <input type="text" class="form-control" id="official_name" placeholder="Enter Full Name" required="required" pattern="[A-Za-z.\s]+" title="Only alphabets, spaces, and dots are allowed"> </div> <div class="col-md-4 col-sm-12"> <label class="form-label" for="official_age">Age</label> <input type="number" class="form-control" id="official_age" placeholder="Enter Age"> </div> <div class="col-md-4 col-sm-12"> <label class="form-label d-block">Sex<span class="text-danger">*</span></label> <div class="d-flex flex-wrap gap-3"> <div class="form-check me-3"> <input class="form-check-input" type="radio" name="gender" id="genderMale" value="M" required="required"> <label class="form-check-label pr-4" for="genderMale">Male</label> </div> <div class="form-check me-3"> <input class="form-check-input" type="radio" name="gender" id="genderFemale" value="F"> <label class="form-check-label pr-4" for="genderFemale">Female</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="gender" id="genderTransgender" value="T"> <label class="form-check-label pr-4" for="genderTransgender">Transgender</label> </div> </div> </div>
<div class="col-md-4 col-sm-12"> <label class="form-label">Designation<span class="text-danger">*</span></label> <select id="design_dropdown" class="form-control" required="required"> <option value="">Select</option> </select> </div> <div class="col-md-4 col-sm-12"> <label class="form-label">Upload Photo</label> <input type="file" class="form-control" id="profileimage" accept=".jpg,.jpeg,image/jpeg" name="profileimage"> <div id="profileimage_preview" class="mt-2" style="cursor:pointer; color:blue; text-decoration:underline;display: none;"></div> </div> </div> </div> <div class="card-body mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;"> <div class="row" style="row-gap:10px;"> <div class="col-md-4 col-sm-12"> <label class="form-label" for="basic_pay">Basic pay</label> <input type="text" class="form-control" id="basic_pay" readonly> </div> <div class="col-md-4 col-sm-12"> <label class="form-label" for="grade_pay">Grade pay</label> <input type="text" class="form-control" id="grade_pay" readonly> </div> <div class="col-md-4 col-sm-12"> <label class="form-label" for="pay_band">Pay Band</label> <input type="text" class="form-control" id="pay_band" readonly> </div> </div> </div> <div class="card-body" style="padding: 10px;"> <div class="row" style="row-gap:10px;"> <div class="col-md-6 col-sm-12"> <div class="card-header bg-dark text-white"> <b>Official Details - Non Editable</b> </div> <div class="card-body" style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;"> <label class="form-label" for="off_category">Department</label> <input type="text" class="form-control mb-3" id="off_category" readonly> <label class="form-label" for="off_office_name">Office Name</label> <input type="text" class="form-control mb-3" id="off_office_name" readonly> <label class="form-label" for="off_address1">Address Line 1</label> <input type="text" class="form-control mb-3" id="off_address1" readonly> <label class="form-label" for="off_address2">Address Line 2</label> <input type="text" class="form-control mb-3" id="off_address2" readonly> <label class="form-label" for="off_address3">Address Line 3</label> <input type="text" class="form-control mb-3" id="off_address3" readonly> <label class="form-label" for="off_pincode">Pincode</label> <input type="text" class="form-control mb-3" id="off_pincode" readonly> <label class="form-label" for="off_phoneno">Phone No</label> <div class="d-flex justify-content-start"> <button class="btn btn-secondary" disabled="disabled" style="height: fit-content">STD</button> <input type="text" class="form-control mb-3 mx-2" id="off_phoneno" readonly> </div> <label class="form-label" for="off_taluk">Taluk Name</label> <input type="text" class="form-control mb-3" id="off_taluk" readonly> <label class="form-label" for="off_govt_type">Government Type</label> <input type="text" class="form-control mb-3" id="off_govt_type" readonly> <label class="form-label" for="off_pub_sec">Public Sec. Undertaking</label> <input type="text" class="form-control mb-3" id="off_pub_sec" readonly> <label class="form-label" for="off_localbody">Local Body</label> <input type="text" class="form-control mb-3" id="off_localbody" readonly> <label class="form-label" for="off_edu_ins">Educational Institution</label> <input type="text" class="form-control mb-3" id="off_edu_ins" readonly> <label class="form-label" for="off_assembly">Assembly Constituency</label> <input type="text" class="form-control mb-3" id="off_assembly" readonly> </div> </div> <div class="col-md-6 col-sm-12"> <div class="card-header bg-dark text-white"> <b>Residential Details</b> </div> <div class="card-body" style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;"> <label class="form-label" for="res_address1">House No/ House Name</label> <input type="text" class="form-control mb-3" id="res_address1"> <label class="form-label" for="res_address2">Street Name/ Area</label> <input type="text" class="form-control mb-3" id="res_address2"> <label class="form-label" for="res_address3">City</label> <input type="text" class="form-control mb-3" id="res_address3"> <label class="form-label" for="res_pincode">Pincode</label> <input type="text" class="form-control mb-3" id="res_pincode"> <label class="form-label" for="res_police">Nearest Police Station</label> <input type="text" class="form-control mb-3" id="res_police"> <label class="form-label" for="res_phoneno">Phone No</label> <div class="d-flex justify-content-start"> <button class="btn btn-secondary" disabled="disabled" style="height: fit-content">STD</button> <input type="text" class="form-control mb-3 mx-2" id="res_phoneno"> </div> <label class="form-label" for="res_mobile">Mobile</label> <input type="text" class="form-control mb-3" id="res_mobile"> <div class="mb-3"> <label class="form-label" for="nativetaluk_dropdown">Native Taluk/District</label> <select id="nativetaluk_dropdown" class="form-control mb-3"> <option value="">Select</option> </select> </div> <div class="mb-3"> <label class="form-label" for="nativeassembly_dropdown">Native Assembly Constituency</label> <select id="nativeassembly_dropdown" class="form-control mb-3"> <option value="">Select</option> </select> </div> <label class="form-label" for="residentialassembly_dropdown">Residential Assembly Constituency</label> <select id="residentialassembly_dropdown" class="form-control mb-3"> <option value="">Select</option> </select> </div> </div> </div> </div> <div class="card-body mb-3" style="padding: 10px;"> <div style="border: 1px solid grey;border-radius: 5px;"> <div class="row" style="row-gap:10px;"> <div class="col-md-12 col-sm-12"> <div class="card-header"> <b>Enrolled Details</b> </div> <div class="card-body"> <div class="row pl-3 pb-2" style="row-gap:10px;"> <span id="epic_verify_link" style="cursor:pointer; color:blue; text-decoration:underline;"> Click here to verify EPIC No <i class="ik ik-external-link"></i> </span> </div> <div class="row" style="row-gap:10px;"> <div class="col-md-6 col-sm-12"> <label class="form-label" for="epic_no">EPIC No</label> <input type="text" class="form-control" id="epic_no"> </div> <div class="col-md-6 col-sm-12"> <label class="form-label" for="epic_name">Name</label> <input type="text" class="form-control" id="epic_name" readonly="readonly"> </div> <div class="col-md-6 col-sm-12"> <label class="form-label" for="enrolledassembly_dropdown">Enrolled Assembly Constituency</label> <select id="enrolledassembly_dropdown" class="form-control"> <option value="">Select</option> </select> </div> </div> <div class="row mt-2" style="row-gap:10px;"> <div class="col-md-6 col-sm-12"> <label class="form-label" for="part_no">Part No</label> <input type="text" class="form-control" id="part_no"> </div> <div class="col-md-6 col-sm-12"> <label class="form-label" for="si_no">SI. No</label> <input type="text" class="form-control" id="si_no"> </div> </div> </div> </div> <!-- <div class="col-md-6 col-sm-12">
<div class="card-header"> <b>Experience Questions</b> </div> <div class="card-body"> <div class="col-md-12 col-sm-12 mb-2"> <label class="form-label">Whether the official officiated in previous General Election or Bye Election(Y/N)? If Yes, furnished details etc. PS.NO.A.C NO etc.</label> <div class="d-flex flex-wrap gap-3"> <div class="form-check me-3"> <input class="form-check-input" type="radio" name="question1" id="question1" value="Y"> <label class="form-check-label pr-4" for="question1">Yes</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="question1" id="question1" value="N"> <label class="form-check-label pr-4" for="question1">No</label> </div> </div> <div id="prevElectionDetails" class="mt-2" style="display: none;"> <input type="text" id="previousDetails" class="form-control" placeholder="Enter PS No, AC No"> </div> </div> <div class="col-md-12 col-sm-12 mb-2"> <label class="form-label">Whether the official has previous experience in handling EVMs (Y/N)?</label> <div class="d-flex flex-wrap gap-3"> <div class="form-check me-3"> <input class="form-check-input" type="radio" name="question2" id="question2" value="Y"> <label class="form-check-label pr-4" for="question2">Yes</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="question2" id="question2" value="N"> <label class="form-check-label pr-4" for="question2">No</label> </div> </div> </div> <div class="col-md-12 col-sm-12"> <label class="form-label">Whether the official has been disqualified or punished or reprimanded or transferred out by the Election Commission of India (Y/N)?</label> <div class="d-flex flex-wrap gap-3"> <div class="form-check me-3"> <input class="form-check-input" type="radio" name="question3" id="question3" value="Y"> <label class="form-check-label pr-4" for="question3">Yes</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="question3" id="question3" value="N"> <label class="form-check-label pr-4" for="question3">No</label> </div> </div> </div> </div> </div> --> </div> </div> </div> <div class="card-body" style="padding: 10px;"> <div class="row" id="btn_container"> <div class="col-12 d-flex justify-content-center"> <button type="button" class="btn btn-secondary mx-2" onclick="goback()">Back</button> <button type="submit" class="btn btn-primary mx-2" id="saveBtn">Update</button> </div> </div> </div> </form> </div> </div> </div> </div> </div> <div class="modal fade" id="profileImageModal" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Profile Photo</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body text-center"> <img id="modal_profile_image" src="" class="img-fluid rounded" style="max-height:400px;" /> </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).ready(function() {
let batchId = sessionStorage.getItem("upd_batch_id"); let deptId = sessionStorage.getItem("upd_dept"); let officeId = sessionStorage.getItem("upd_office_id"); let ppn_id = sessionStorage.getItem("upd_id");
// If any ID is missing -> redirect if (!batchId || !deptId || !officeId || !ppn_id ) { window.location.href = "/election/dataentryadmin/updation"; } document.getElementById("batch_no").value = batchId;
// ❗ Remove values IMMEDIATELY so refresh loses them sessionStorage.removeItem("upd_batch_id"); sessionStorage.removeItem("upd_dept"); sessionStorage.removeItem("upd_office_id"); sessionStorage.removeItem("upd_id");
// Now you can use these values console.log("Batch:", batchId, "Dept:", deptId, "Office:", officeId); let designationDropdown = document.getElementById('design_dropdown');
fetch('/election/api/dataentry/batch/getAllDesignations') .then(response => response.json()) .then(result => {
if (result.status !== "success") { console.error("API error:", result.message); return; }
let list = result.data;
// Clear existing options designationDropdown.innerHTML = `<option value="">Select</option>`;
// Add options from the API response list.forEach(design => { designationDropdown.innerHTML += ` <option value="${design.desig_id}"> ${design.new_designation} </option>`; });
// ⭐ Activate Select2 after options added $('#design_dropdown').select2({ placeholder: "Search designation...", allowClear: true, width: "100%" }); $('#design_dropdown').on('change', function () { let selectedDesgId = $(this).val(); if (selectedDesgId) { getDesignationDetails(selectedDesgId); } else{ document.getElementById("basic_pay").value = ""; document.getElementById("grade_pay").value = ""; document.getElementById("pay_band").value = ""; } }); // PRESELECT designation from API (edit mode) if (window.editDesignationId) { $('#design_dropdown').val(window.editDesignationId).trigger('change'); }
}) .catch(error => { console.error('Error fetching designation:', error); }); let NativeTaulkDropdown = document.getElementById('nativetaluk_dropdown'); fetch('/election/api/dataentry/batch/getAllDistricts') .then(response => response.json()) .then(result => {
if (result.status !== "success") { console.error("API error:", result.message); return; }
let list = result.data;
NativeTaulkDropdown.innerHTML = `<option value="">Select</option>`;
// Add options from the API response list.forEach(nativedis => { NativeTaulkDropdown.innerHTML += ` <option value="${nativedis.dist_no}"> ${nativedis.dist_name} </option>`; }); $('#nativetaluk_dropdown').select2({ placeholder: "Search", allowClear: true, width: "100%" }); if (window.editHomeDist) { $('#nativetaluk_dropdown').val(window.editHomeDist).trigger('change'); }
}) .catch(error => { console.error('Error fetching in District :', error); });
let NativeAcDropdown = document.getElementById('nativeassembly_dropdown'); let ResiAcDropdown = document.getElementById('residentialassembly_dropdown'); let EnrollAsDropdown = document.getElementById('enrolledassembly_dropdown');
function loadOptions(dropdown, list) { dropdown.innerHTML = `<option value="">Select</option>`; list.forEach(item => { dropdown.innerHTML += ` <option value="${item.ac_no}"> ${item.ac_name} </option>`; }); }
fetch('/election/api/dataentry/batch/getAllAclist') .then(response => response.json()) .then(result => {
if (result.status !== "success") { console.error("API error:", result.message); return; }
let list = result.data;
// Load all three dropdowns using same function loadOptions(NativeAcDropdown, list); loadOptions(ResiAcDropdown, list); loadOptions(EnrollAsDropdown, list); $('#nativeassembly_dropdown, #residentialassembly_dropdown, #enrolledassembly_dropdown').select2({ placeholder: "Search", allowClear: true, width: "100%" }); // PRESELECT VALUES (ONLY IF NOT NULL) if (window.nativeAcNo) { $('#nativeassembly_dropdown').val(window.nativeAcNo).trigger('change'); } if (window.resideAcNo) { $('#residentialassembly_dropdown').val(window.resideAcNo).trigger('change'); } if (window.enrollAcNo) { $('#enrolledassembly_dropdown').val(window.enrollAcNo).trigger('change'); }
}) .catch(error => { console.error('Error fetching Assembly Constituency:', error); });
/* document.querySelectorAll('input[name="question1"]').forEach(function(radio) { radio.addEventListener("change", function() {
if (this.value === "Y") { document.getElementById("prevElectionDetails").style.display = "block"; } else { document.getElementById("prevElectionDetails").style.display = "none"; document.getElementById("previousDetails").value = ""; // clear text }
}); }); */ document.getElementById("official_name").addEventListener("input", function () { document.getElementById("epic_name").value = this.value; }); document.getElementById("epic_verify_link").addEventListener("click", function () { window.open("https://electoralsearch.eci.gov.in/", "_blank"); }); getOfficeDetails(officeId); getPollingDetails(ppn_id); $('#profileimage').on('input', function () {
let fileInput = this; let file = fileInput.files[0];
// Allowed extensions let allowedExtensions = /(\.jpg|\.jpeg)$/i;
// File name let fileName = file.name;
// File size (10 MB = 10 * 1024 * 1024) let maxSize = 10 * 1024 * 1024;
// 1) Validate extension if (!allowedExtensions.test(fileName)) { Swal.fire({ icon: 'error', title: 'Invalid File Type', text: 'Only JPG / JPEG images are allowed!' }); fileInput.value = ""; // Reset file return; }
// 2) Validate MIME type if (file.type !== "image/jpeg") { Swal.fire({ icon: 'error', title: 'Invalid Image Format', text: 'Only JPEG images are allowed!' }); fileInput.value = ""; return; }
// 3) Validate size if (file.size > maxSize) { Swal.fire({ icon: 'error', title: 'File Too Large', text: 'File size must be 10 MB or less!' }); fileInput.value = ""; return; }
});
$('#res_pincode').on('input', function () { // Remove anything that is not a digit this.value = this.value.replace(/\D/g, '');
// Limit to max 6 digits if (this.value.length > 6) { this.value = this.value.slice(0, 6); } }); // PHONE NO: 8 to 10 digits $('#res_phoneno').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); } });
// MOBILE NO: exactly 10 digits $('#res_mobile').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); } }); // PART NO: 6 digits only $('#part_no').on('input', function () { this.value = this.value.replace(/\D/g, ''); // allow digits only
if (this.value.length > 6) { this.value = this.value.slice(0, 6); } });
// SI NO: 6 digits only $('#si_no').on('input', function () { this.value = this.value.replace(/\D/g, ''); // allow digits only
if (this.value.length > 6) { this.value = this.value.slice(0, 6); // max 6 digits } }); $('#epic_no').on('input', function () { // Allow only A–Z, a–z, 0–9 this.value = this.value.replace(/[^A-Za-z0-9]/g, '');
// Limit to 16 characters if (this.value.length > 16) { this.value = this.value.slice(0, 16); } });
$('#newpollingform').submit(function (e) { e.preventDefault(); let formData = new FormData(this); $('#saveBtn').prop('disabled', true).text('Updating...'); $('#pageLoader').show(); function setIfPresent(formData, key, value) { if (value !== undefined && value !== null && value !== "") { formData.set(key, value); } } function setFileIfPresent(formData, key, fileInput) { if (fileInput && fileInput.files && fileInput.files.length > 0) { formData.set(key, fileInput.files[0]); } } let userId = document.getElementById('userIdSpan').textContent; let batch_no = $('#batch_no').val().trim(); let official_name = $('#official_name').val().trim(); let official_age = $('#official_age').val().trim(); // Convert to number let ageNum = parseInt(official_age, 10);
// Validate age if(official_age){ if (isNaN(ageNum) || ageNum < 18 || ageNum > 65) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid Age', text: 'Age must be between 18 and 65' }); return; } } let gender = $("input[name='gender']:checked").val(); let design_id=$('#design_dropdown').val(); let design_name = $('#design_dropdown option:selected').text(); let respincode=$('#res_pincode').val().trim(); if(respincode){ // Rule 1: Must be exactly 6 digits & should NOT start with 0 if (!/^[1-9][0-9]{5}$/.test(respincode)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid Pincode', text: 'Pincode must be 6 digits and cannot start with 0.' }); return; }
// Rule 2: Reject 123456 (sequential) if (respincode === "123456") { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid Pincode', text: 'Sequential numbers like 123456 are not allowed.' }); return; }
// Rule 3: Reject all digits same (111111, 222222, etc.) if (/^(\d)\1{5}$/.test(respincode)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid Pincode', text: 'All digits cannot be the same.' }); return; } } let phnumber=$('#res_phoneno').val().trim(); if(phnumber){ // Validate 8 to 10 digits only if (!/^\d{8,10}$/.test(phnumber)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid Phone Number', text: 'Phone number must be 8 to 10 digits.' }); return; } } let mobnumber=$('#res_mobile').val().trim(); if(mobnumber){ // Rule 1: Must be exactly 10 digits & must not start with 0 if (!/^[1-9][0-9]{9}$/.test(mobnumber)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); 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 (mobnumber === "1234567890") { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); 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(mobnumber)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid Mobile Number', text: 'All digits cannot be the same.' }); return; } } let native_taluk=$('#nativetaluk_dropdown').val(); let native_ac=$('#nativeassembly_dropdown').val(); let res_ac=$('#residentialassembly_dropdown').val(); let enrol_ac=$('#enrolledassembly_dropdown').val(); let epic_no = $('#epic_no').val().trim();
// updated
if (epic_no) {
// Allow 8 to 16 alphanumeric characters let epicPattern = /^[A-Za-z0-9]{8,16}$/;
if (!epicPattern.test(epic_no)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Save');
Swal.fire({ icon: 'warning', title: 'Invalid EPIC Number', text: 'EPIC number must be 8 to 16 alphanumeric characters.' }); return; } }
/* if(epic_no){ // Allow only 16 alphanumeric characters let epicPattern = /^[A-Za-z0-9]{16}$/; if (!epicPattern.test(epic_no)) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Update'); Swal.fire({ icon: 'warning', title: 'Invalid EPIC Number', text: 'EPIC number must be exactly 16 alphanumeric characters.' }); return; } }*/ let part_no =$('#part_no').val().trim(); let si_no = $('#si_no').val().trim(); if(part_no){ // Validate part_no if (part_no.length > 6) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Save'); Swal.fire({ icon: 'warning', title: 'Invalid Part No', text: 'Maximum 6 digits allowed for Part No.' }); return; } }
if(si_no){ // Validate si_no if (si_no.length > 6) { $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Save'); Swal.fire({ icon: 'warning', title: 'Invalid Sl. No', text: 'Maximum 6 digits allowed for Sl No.' }); return; } } /* let question1 = $("input[name='question1']:checked").val(); if(question1){ let previousDetails=$('#previousDetails').val().trim(); if(!previousDetails){ $('#pageLoader').hide(); $('#saveBtn').prop('disabled', false).text('Save'); Swal.fire({ icon: 'warning', title: 'Validation Error', text: 'Enter PS No,AC No' }); return; } } let question2 = $("input[name='question2']:checked").val(); let question3 = $("input[name='question3']:checked").val(); */ setFileIfPresent(formData, "pp_image", $('#profileimage')[0]); setIfPresent(formData, "nppid", ppn_id); formData.append("userid", userId); let existing_uniquenum = $('#existing_uniquenum').text(); formData.append("slno", existing_uniquenum); setIfPresent(formData, "pBatchId", batch_no); setIfPresent(formData, "DeptId", deptId); setIfPresent(formData, "officeId", officeId); setIfPresent(formData, "pName", official_name); setIfPresent(formData, "pAge", official_age); setIfPresent(formData, "pGender", gender || ""); setIfPresent(formData, "DesignationId",design_id); setIfPresent(formData, "Designation", design_name); setIfPresent(formData, "address1", $('#res_address1').val().trim()); setIfPresent(formData, "address2", $('#res_address2').val().trim()); setIfPresent(formData, "address3", $('#res_address3').val().trim()); setIfPresent(formData, "pincode",respincode); setIfPresent(formData, "policest", $('#res_police').val().trim()); setIfPresent(formData, "phoneno",phnumber); setIfPresent(formData, "mobileno",mobnumber); setIfPresent(formData, "district",native_taluk); setIfPresent(formData, "nativeac",native_ac); setIfPresent(formData, "resideac",res_ac); setIfPresent(formData, "electoracno",enrol_ac); setIfPresent(formData, "electorpartno",part_no ); setIfPresent(formData, "electorslno", si_no); setIfPresent(formData, "epicno",epic_no); /* setIfPresent(formData, "officiated", question1); setIfPresent(formData, "officiateddet", $('#previousDetails').val().trim()); setIfPresent(formData, "evmexperience", question2); setIfPresent(formData, "disaqualified", question3); */ $.ajax({ url: '/election/api/dataentry/update/updateppdetailsbyid', type: 'POST', data: formData, enctype: 'multipart/form-data', processData: false, contentType: false, success: function (response) { $('#pageLoader').hide(); if (response.status) { Swal.fire({ allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, icon: 'success', title: 'Success', text:response.description }).then((result) => { window.location.href="/election/dataentryadmin/updation"; }); } else { $('#pageLoader').hide(); Swal.fire({ icon: 'warning', title: 'Update Failed', text: response.description || 'Something went wrong!' }); } $('#saveBtn').prop('disabled', false).text('Update'); }, error: function () { $('#pageLoader').hide(); Swal.fire({ icon: 'error', title: 'Submission Error', text: 'Something went wrong while submitting the form.' }); $('#saveBtn').prop('disabled', false).text('Update'); } }); }); });
function getDesignationDetails(desgId) { //console.log("desgId="+desgId); fetch('/election/api/dataentry/batch/getPayDetails?DesgId=' + desgId) .then(response => response.json()) .then(result => {
if (result.status !== "success") { console.error("API error:", result.message); return; }
let data = result.data; // your pay details row
//console.log("Designation Pay Details:", data);
// Example: set values into input fields document.getElementById("basic_pay").value = data.basic_pay; document.getElementById("grade_pay").value = data.grade_pay; document.getElementById("pay_band").value = data.pay_scale;
}) .catch(error => { console.error("Error fetching pay details:", error); }); }
function getOfficeDetails(officeId) { console.log("officeId="+officeId); fetch('/election/api/dataentry/batch/getOfficeDetailsById?officeId=' + officeId) .then(response => response.json()) .then(result => {
if (result.status !== "success") { console.error("API error:", result.message); return; }
let data = result.data[0]; console.log("office Details:", data); // Example: set values into input fields document.getElementById("off_office_name").value = data.office_name; document.getElementById("off_address1").value = data.address1; document.getElementById("off_address2").value = data.address2; document.getElementById("off_address3").value = data.address3; document.getElementById("off_pincode").value = data.pincode; document.getElementById("off_phoneno").value = data.phone_no; document.getElementById("off_taluk").value = data.taluk_name; document.getElementById("off_govt_type").value = data.govt_type; document.getElementById("off_pub_sec").value = data.public_sector; document.getElementById("off_localbody").value = data.local_body; document.getElementById("off_edu_ins").value = data.edu_institution; document.getElementById("off_category").value = data.office_category; document.getElementById("off_assembly").value = data.office_assembly;
}) .catch(error => { console.error("Error fetching Office details:", error); }); }
function getPollingDetails(ppn_id){ $('#pageLoader').show(); console.log("ppn_id="+ppn_id); fetch('/election/api/dataentry/update/getPollingDetailsById?id=' + ppn_id) .then(response => response.json()) .then(result => {
if (result.status !== "success") { console.error("API error:", result.message); return; }
let data = result.data[0]; console.log("Polling Personnel Details:", data); window.editDesignationId = data.designation_id; window.editHomeDist = data.home_dist; window.nativeAcNo = data.native_ac_no; window.resideAcNo = data.reside_ac_no; window.enrollAcNo = data.elector_ac_no; // Example: set values into input fields document.getElementById("official_name").value = data.name; document.getElementById("epic_name").value = data.name; document.getElementById("official_age").value = data.age; if (data.sex) { let genderValue = data.sex; // M / F / T const radio = document.querySelector(`input[name="gender"][value="${genderValue}"]`); if (radio) radio.checked = true; } if (window.editDesignationId) { $('#design_dropdown').val(window.editDesignationId).trigger('change'); } $('#existing_uniquenum').text(data.slno); document.getElementById("res_address1").value = data.r_address1; document.getElementById("res_address2").value = data.r_address2; document.getElementById("res_address3").value = data.r_address3; document.getElementById("res_pincode").value = data.r_pincode; document.getElementById("res_police").value = data.r_policest; document.getElementById("res_phoneno").value = data.r_phone_no; document.getElementById("res_mobile").value = data.r_mobile_no; if (window.editHomeDist) { $('#nativetaluk_dropdown').val(window.editHomeDist).trigger('change'); } if (window.nativeAcNo) { $('#nativeassembly_dropdown').val(window.nativeAcNo).trigger('change'); } if (window.resideAcNo) { $('#residentialassembly_dropdown').val(window.resideAcNo).trigger('change'); } if (window.enrollAcNo) { $('#enrolledassembly_dropdown').val(window.enrollAcNo).trigger('change'); } document.getElementById("epic_no").value = data.elector_epic_no; document.getElementById("part_no").value = data.elector_part_no; document.getElementById("si_no").value = data.elector_sl_no; if (data.img_full_path) {
let url = data.img_full_path;
// Extract full file name (e.g., profile_img_02122025195649_newuser.jpg) let fullName = url.substring(url.lastIndexOf("/") + 1);
// Extract only the part after the last underscore → newuser.jpg let filename = fullName.includes("_") ? fullName.substring(fullName.lastIndexOf("_") + 1) : fullName;
$("#profileimage_preview") .text(filename) .show() .off("click") .on("click", function () { $("#modal_profile_image").attr("src", url);
let modal = new bootstrap.Modal( document.getElementById('profileImageModal') ); modal.show(); }); } else { $("#profileimage_preview").hide().text(''); }
}) .catch(error => { console.error("Error fetching Office details:", error); }) .finally(() => { $('#pageLoader').hide(); // ALWAYS hide loader });}
function goback(){ //window.location.href="/election/dataentry/batches"; window.history.back();}
</script></body></html>
|