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.
 
 
 
 
 

1025 lines
38 KiB

<!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>Micro-Observer Data Entry</h5>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row mt-2 mb-2" style="padding: 10px;border: 1px solid green;background-color: rgba(144, 238, 144, 0.4);">
<div class="col-md-4">
<p style="margin-bottom: 2px;font-size: medium;font-weight: bold;">Application <span id="c_completed_plus"></span> of <span id="c_noof_application"></span></p>
<p style="margin-bottom: 2px;font-size: 12px;"><span id="c_completed"></span>&nbsp;saved&nbsp;.&nbsp;<span id="c_pending"></span>&nbsp;remaining</p>
</div>
<div class="col-md-4">
</div>
<div class="col-md-4" style="text-align: right;font-weight: bold;font-size:x-large;">
<span id="cc_completed_plus"></span>/<span id="cc_noof_application"></span>
</div>
</div>
<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">Micro-observer 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 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>
</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">Save</button>
</div>
</div>
</div>
</form>
</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).ready(function() {
let batchId = sessionStorage.getItem("batchId");
let deptId = sessionStorage.getItem("deptId");
let officeId = sessionStorage.getItem("officeId");
// If any ID is missing -> redirect
if (!batchId || !deptId || !officeId) {
window.location.href = "/election/dataentry_mob/batches";
}
document.getElementById("batch_no").value = batchId;
// ❗ Remove values IMMEDIATELY so refresh loses them
sessionStorage.removeItem("batchId");
sessionStorage.removeItem("deptId");
sessionStorage.removeItem("officeId");
// Now you can use these values
console.log("Batch:", batchId, "Dept:", deptId, "Office:", officeId);
getOfficeDetails(officeId);
getstatuscounts(batchId);
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 = "";
}
});
})
.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%"
});
})
.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%"
});
})
.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");
});
$('#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); // max 6 digits
}
});
// 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('Saving...');
$('#pageLoader').show();
function setIfPresent(formData, key, value) {
if (value !== undefined && value !== null && value !== "") {
formData.set(key, value);
}
}
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('Save');
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('Save');
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('Save');
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('Save');
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('Save');
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('Save');
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('Save');
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('Save');
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();
if(epic_no){
// Allow only 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;
}
}
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(); */
setIfPresent(formData, "userid", userId);
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_mob/batch/savenewentry',
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,
html: 'Unique Number : <b>' + response.unique_no + '</b>'
}).then((result) => {
window.location.href="/election/dataentry_mob/batchbyid?batchid="+batch_no;
});
//$('#newpollingform')[0].reset();
} else {
$('#pageLoader').hide();
Swal.fire({
icon: 'warning',
title: response.message,
text: response.description || 'Something went wrong!'
});
}
$('#saveBtn').prop('disabled', false).text('Save');
},
error: function () {
$('#pageLoader').hide();
Swal.fire({
icon: 'error',
title: 'Submission Error',
text: 'Something went wrong while submitting the form.'
});
$('#saveBtn').prop('disabled', false).text('Save');
}
});
});
});
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 getstatuscounts(batchId){
$('#pageLoader').show();
fetch('/election/api/dataentry_mob/batch/getbatchbyId?id=' + batchId)
.then(response => response.json())
.then(result => {
if (result.status !== "success") {
console.error("API error:", result.message);
return;
}
let data = result.data;
console.log("Details:", data);
// Example: set values into input fields
document.getElementById("c_noof_application").textContent = data.noof_application;
document.getElementById("cc_noof_application").textContent = data.noof_application;
document.getElementById("c_completed").textContent = data.completed;
document.getElementById("c_pending").textContent = data.pending;
let completedCount = parseInt(data.completed) || 0;
let completedPlusOne = completedCount + 1;
document.getElementById("c_completed_plus").textContent = completedPlusOne;
document.getElementById("cc_completed_plus").textContent = completedPlusOne;
})
.catch(error => {
console.error("Error fetching batch counts details:", error);
})
.finally(() => {
$('#pageLoader').hide(); // ALWAYS hide loader
});
}
function goback(){
window.location.href="/election/dataentry_mob/batches";
//window.history.back();
}
</script>
</body>
</html>