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.

1024 lines
38 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}"></head>
  4. <style>
  5. #btn_container button{
  6. width: 20%;
  7. }
  8. </style>
  9. <body>
  10. <div class="wrapper">
  11. <!-- header top menu Start -->
  12. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  13. <!-- header top menu end -->
  14. <div class="page-wrap">
  15. <!--=============== Left Menu side Start ================-->
  16. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  17. <!--=============== Left side End ================-->
  18. <div class="main-content">
  19. <div class="container-fluid">
  20. <div class="page-header mb-2">
  21. <div class="row align-items-end">
  22. <div class="col-lg-8">
  23. <div class="page-header-title">
  24. <!-- <i class="far fa-calendar-plus bg-blue"></i> -->
  25. <div class="d-inline">
  26. <h5>Micro-Observer Data Entry</h5>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="container">
  33. <div class="row mt-2 mb-2" style="padding: 10px;border: 1px solid green;background-color: rgba(144, 238, 144, 0.4);">
  34. <div class="col-md-4">
  35. <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>
  36. <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>
  37. </div>
  38. <div class="col-md-4">
  39. </div>
  40. <div class="col-md-4" style="text-align: right;font-weight: bold;font-size:x-large;">
  41. <span id="cc_completed_plus"></span>/<span id="cc_noof_application"></span>
  42. </div>
  43. </div>
  44. <div class="row">
  45. <div class="card" style="padding: 10px;"><span th:text="${LoginUserId}" style="display:none;" id="userIdSpan"></span>
  46. <form id="newpollingform" enctype="multipart/form-data" >
  47. <div class=" mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  48. <label class="form-label" for="batch_no">Micro-observer Batch No</label>
  49. <input type="text" class="form-control" id="batch_no" readonly>
  50. </div>
  51. <div class=" mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  52. <div class="row" style="row-gap:10px;">
  53. <div class="col-md-8 col-sm-12">
  54. <label class="form-label" for="official_name">Name of the Official<span class="text-danger">*</span></label>
  55. <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">
  56. </div>
  57. <div class="col-md-4 col-sm-12">
  58. <label class="form-label" for="official_age">Age</label>
  59. <input type="number" class="form-control" id="official_age" placeholder="Enter Age">
  60. </div>
  61. <div class="col-md-4 col-sm-12">
  62. <label class="form-label d-block">Sex<span class="text-danger">*</span></label>
  63. <div class="d-flex flex-wrap gap-3">
  64. <div class="form-check me-3">
  65. <input class="form-check-input" type="radio" name="gender" id="genderMale" value="M" required="required">
  66. <label class="form-check-label pr-4" for="genderMale">Male</label>
  67. </div>
  68. <div class="form-check me-3">
  69. <input class="form-check-input" type="radio" name="gender" id="genderFemale" value="F">
  70. <label class="form-check-label pr-4" for="genderFemale">Female</label>
  71. </div>
  72. <div class="form-check">
  73. <input class="form-check-input" type="radio" name="gender" id="genderTransgender" value="T">
  74. <label class="form-check-label pr-4" for="genderTransgender">Transgender</label>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="col-md-4 col-sm-12">
  79. <label class="form-label">Designation<span class="text-danger">*</span></label>
  80. <select id="design_dropdown" class="form-control" required="required">
  81. <option value="">Select</option>
  82. </select>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="card-body mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  87. <div class="row" style="row-gap:10px;">
  88. <div class="col-md-4 col-sm-12">
  89. <label class="form-label" for="basic_pay">Basic pay</label>
  90. <input type="text" class="form-control" id="basic_pay" readonly>
  91. </div>
  92. <div class="col-md-4 col-sm-12">
  93. <label class="form-label" for="grade_pay">Grade pay</label>
  94. <input type="text" class="form-control" id="grade_pay" readonly>
  95. </div>
  96. <div class="col-md-4 col-sm-12">
  97. <label class="form-label" for="pay_band">Pay Band</label>
  98. <input type="text" class="form-control" id="pay_band" readonly>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="card-body" style="padding: 10px;">
  103. <div class="row" style="row-gap:10px;">
  104. <div class="col-md-6 col-sm-12">
  105. <div class="card-header bg-dark text-white">
  106. <b>Official Details - Non Editable</b>
  107. </div>
  108. <div class="card-body" style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;">
  109. <label class="form-label" for="off_category">Department</label>
  110. <input type="text" class="form-control mb-3" id="off_category" readonly>
  111. <label class="form-label" for="off_office_name">Office Name</label>
  112. <input type="text" class="form-control mb-3" id="off_office_name" readonly>
  113. <label class="form-label" for="off_address1">Address Line 1</label>
  114. <input type="text" class="form-control mb-3" id="off_address1" readonly>
  115. <label class="form-label" for="off_address2">Address Line 2</label>
  116. <input type="text" class="form-control mb-3" id="off_address2" readonly>
  117. <label class="form-label" for="off_address3">Address Line 3</label>
  118. <input type="text" class="form-control mb-3" id="off_address3" readonly>
  119. <label class="form-label" for="off_pincode">Pincode</label>
  120. <input type="text" class="form-control mb-3" id="off_pincode" readonly>
  121. <label class="form-label" for="off_phoneno">Phone No</label>
  122. <div class="d-flex justify-content-start">
  123. <button class="btn btn-secondary" disabled="disabled" style="height: fit-content">STD</button>
  124. <input type="text" class="form-control mb-3 mx-2" id="off_phoneno" readonly>
  125. </div>
  126. <label class="form-label" for="off_taluk">Taluk Name</label>
  127. <input type="text" class="form-control mb-3" id="off_taluk" readonly>
  128. <label class="form-label" for="off_govt_type">Government Type</label>
  129. <input type="text" class="form-control mb-3" id="off_govt_type" readonly>
  130. <label class="form-label" for="off_pub_sec">Public Sec. Undertaking</label>
  131. <input type="text" class="form-control mb-3" id="off_pub_sec" readonly>
  132. <label class="form-label" for="off_localbody">Local Body</label>
  133. <input type="text" class="form-control mb-3" id="off_localbody" readonly>
  134. <label class="form-label" for="off_edu_ins">Educational Institution</label>
  135. <input type="text" class="form-control mb-3" id="off_edu_ins" readonly>
  136. <label class="form-label" for="off_assembly">Assembly Constituency</label>
  137. <input type="text" class="form-control mb-3" id="off_assembly" readonly>
  138. </div>
  139. </div>
  140. <div class="col-md-6 col-sm-12">
  141. <div class="card-header bg-dark text-white">
  142. <b>Residential Details</b>
  143. </div>
  144. <div class="card-body" style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;">
  145. <label class="form-label" for="res_address1">House No/ House Name</label>
  146. <input type="text" class="form-control mb-3" id="res_address1">
  147. <label class="form-label" for="res_address2">Street Name/ Area</label>
  148. <input type="text" class="form-control mb-3" id="res_address2">
  149. <label class="form-label" for="res_address3">City</label>
  150. <input type="text" class="form-control mb-3" id="res_address3">
  151. <label class="form-label" for="res_pincode">Pincode</label>
  152. <input type="text" class="form-control mb-3" id="res_pincode">
  153. <label class="form-label" for="res_police">Nearest Police Station</label>
  154. <input type="text" class="form-control mb-3" id="res_police">
  155. <label class="form-label" for="res_phoneno">Phone No</label>
  156. <div class="d-flex justify-content-start">
  157. <button class="btn btn-secondary" disabled="disabled" style="height: fit-content">STD</button>
  158. <input type="text" class="form-control mb-3 mx-2" id="res_phoneno">
  159. </div>
  160. <label class="form-label" for="res_mobile">Mobile</label>
  161. <input type="text" class="form-control mb-3" id="res_mobile">
  162. <div class="mb-3">
  163. <label class="form-label" for="nativetaluk_dropdown">Native Taluk/District</label>
  164. <select id="nativetaluk_dropdown" class="form-control mb-3">
  165. <option value="">Select</option>
  166. </select>
  167. </div>
  168. <div class="mb-3">
  169. <label class="form-label" for="nativeassembly_dropdown">Native Assembly Constituency</label>
  170. <select id="nativeassembly_dropdown" class="form-control mb-3">
  171. <option value="">Select</option>
  172. </select>
  173. </div>
  174. <label class="form-label" for="residentialassembly_dropdown">Residential Assembly Constituency</label>
  175. <select id="residentialassembly_dropdown" class="form-control mb-3">
  176. <option value="">Select</option>
  177. </select>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. <div class="card-body mb-3" style="padding: 10px;">
  183. <div style="border: 1px solid grey;border-radius: 5px;">
  184. <div class="row" style="row-gap:10px;">
  185. <div class="col-md-12 col-sm-12">
  186. <div class="card-header">
  187. <b>Enrolled Details</b>
  188. </div>
  189. <div class="card-body">
  190. <div class="row pl-3 pb-2" style="row-gap:10px;">
  191. <span id="epic_verify_link" style="cursor:pointer; color:blue; text-decoration:underline;">
  192. Click here to verify EPIC No <i class="ik ik-external-link"></i>
  193. </span>
  194. </div>
  195. <div class="row" style="row-gap:10px;">
  196. <div class="col-md-6 col-sm-12">
  197. <label class="form-label" for="epic_no">EPIC No</label>
  198. <input type="text" class="form-control" id="epic_no">
  199. </div>
  200. <div class="col-md-6 col-sm-12">
  201. <label class="form-label" for="epic_name">Name</label>
  202. <input type="text" class="form-control" id="epic_name" readonly="readonly">
  203. </div>
  204. <div class="col-md-6 col-sm-12">
  205. <label class="form-label" for="enrolledassembly_dropdown">Enrolled Assembly Constituency</label>
  206. <select id="enrolledassembly_dropdown" class="form-control">
  207. <option value="">Select</option>
  208. </select>
  209. </div>
  210. </div>
  211. <div class="row mt-2" style="row-gap:10px;">
  212. <div class="col-md-6 col-sm-12">
  213. <label class="form-label" for="part_no">Part No</label>
  214. <input type="text" class="form-control" id="part_no">
  215. </div>
  216. <div class="col-md-6 col-sm-12">
  217. <label class="form-label" for="si_no">SI. No</label>
  218. <input type="text" class="form-control" id="si_no">
  219. </div>
  220. </div>
  221. </div>
  222. </div>
  223. <!-- <div class="col-md-6 col-sm-12">
  224. <div class="card-header">
  225. <b>Experience Questions</b>
  226. </div>
  227. <div class="card-body">
  228. <div class="col-md-12 col-sm-12 mb-2">
  229. <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>
  230. <div class="d-flex flex-wrap gap-3">
  231. <div class="form-check me-3">
  232. <input class="form-check-input" type="radio" name="question1" id="question1" value="Y">
  233. <label class="form-check-label pr-4" for="question1">Yes</label>
  234. </div>
  235. <div class="form-check">
  236. <input class="form-check-input" type="radio" name="question1" id="question1" value="N">
  237. <label class="form-check-label pr-4" for="question1">No</label>
  238. </div>
  239. </div>
  240. <div id="prevElectionDetails" class="mt-2" style="display: none;">
  241. <input type="text" id="previousDetails" class="form-control"
  242. placeholder="Enter PS No, AC No">
  243. </div>
  244. </div>
  245. <div class="col-md-12 col-sm-12 mb-2">
  246. <label class="form-label">Whether the official has previous experience in handling EVMs (Y/N)?</label>
  247. <div class="d-flex flex-wrap gap-3">
  248. <div class="form-check me-3">
  249. <input class="form-check-input" type="radio" name="question2" id="question2" value="Y">
  250. <label class="form-check-label pr-4" for="question2">Yes</label>
  251. </div>
  252. <div class="form-check">
  253. <input class="form-check-input" type="radio" name="question2" id="question2" value="N">
  254. <label class="form-check-label pr-4" for="question2">No</label>
  255. </div>
  256. </div>
  257. </div>
  258. <div class="col-md-12 col-sm-12">
  259. <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>
  260. <div class="d-flex flex-wrap gap-3">
  261. <div class="form-check me-3">
  262. <input class="form-check-input" type="radio" name="question3" id="question3" value="Y">
  263. <label class="form-check-label pr-4" for="question3">Yes</label>
  264. </div>
  265. <div class="form-check">
  266. <input class="form-check-input" type="radio" name="question3" id="question3" value="N">
  267. <label class="form-check-label pr-4" for="question3">No</label>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. </div> -->
  273. </div>
  274. </div>
  275. </div>
  276. <div class="card-body" style="padding: 10px;">
  277. <div class="row" id="btn_container">
  278. <div class="col-12 d-flex justify-content-center">
  279. <button type="button" class="btn btn-secondary mx-2" onclick="goback()">Back</button>
  280. <button type="submit" class="btn btn-primary mx-2" id="saveBtn">Save</button>
  281. </div>
  282. </div>
  283. </div>
  284. </form>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. <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;">
  291. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  292. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  293. <span class="sr-only">Loading...</span>
  294. </div>
  295. <!-- Add the 'Please wait' text below the spinner -->
  296. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  297. </div>
  298. </div>
  299. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  300. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  301. </div>
  302. </div>
  303. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  304. <script type="text/javascript">
  305. $(document).ready(function() {
  306. let batchId = sessionStorage.getItem("batchId");
  307. let deptId = sessionStorage.getItem("deptId");
  308. let officeId = sessionStorage.getItem("officeId");
  309. // If any ID is missing -> redirect
  310. if (!batchId || !deptId || !officeId) {
  311. window.location.href = "/election/dataentry_mob/batches";
  312. }
  313. document.getElementById("batch_no").value = batchId;
  314. // ❗ Remove values IMMEDIATELY so refresh loses them
  315. sessionStorage.removeItem("batchId");
  316. sessionStorage.removeItem("deptId");
  317. sessionStorage.removeItem("officeId");
  318. // Now you can use these values
  319. console.log("Batch:", batchId, "Dept:", deptId, "Office:", officeId);
  320. getOfficeDetails(officeId);
  321. getstatuscounts(batchId);
  322. let designationDropdown = document.getElementById('design_dropdown');
  323. fetch('/election/api/dataentry/batch/getAllDesignations')
  324. .then(response => response.json())
  325. .then(result => {
  326. if (result.status !== "success") {
  327. console.error("API error:", result.message);
  328. return;
  329. }
  330. let list = result.data;
  331. // Clear existing options
  332. designationDropdown.innerHTML = `<option value="">Select</option>`;
  333. // Add options from the API response
  334. list.forEach(design => {
  335. designationDropdown.innerHTML += `
  336. <option value="${design.desig_id}">
  337. ${design.new_designation}
  338. </option>`;
  339. });
  340. // ⭐ Activate Select2 after options added
  341. $('#design_dropdown').select2({
  342. placeholder: "Search designation...",
  343. allowClear: true,
  344. width: "100%"
  345. });
  346. $('#design_dropdown').on('change', function () {
  347. let selectedDesgId = $(this).val();
  348. if (selectedDesgId) {
  349. getDesignationDetails(selectedDesgId);
  350. }
  351. else{
  352. document.getElementById("basic_pay").value = "";
  353. document.getElementById("grade_pay").value = "";
  354. document.getElementById("pay_band").value = "";
  355. }
  356. });
  357. })
  358. .catch(error => {
  359. console.error('Error fetching designation:', error);
  360. });
  361. let NativeTaulkDropdown = document.getElementById('nativetaluk_dropdown');
  362. fetch('/election/api/dataentry/batch/getAllDistricts')
  363. .then(response => response.json())
  364. .then(result => {
  365. if (result.status !== "success") {
  366. console.error("API error:", result.message);
  367. return;
  368. }
  369. let list = result.data;
  370. NativeTaulkDropdown.innerHTML = `<option value="">Select</option>`;
  371. // Add options from the API response
  372. list.forEach(nativedis => {
  373. NativeTaulkDropdown.innerHTML += `
  374. <option value="${nativedis.dist_no}">
  375. ${nativedis.dist_name}
  376. </option>`;
  377. });
  378. $('#nativetaluk_dropdown').select2({
  379. placeholder: "Search",
  380. allowClear: true,
  381. width: "100%"
  382. });
  383. })
  384. .catch(error => {
  385. console.error('Error fetching in District :', error);
  386. });
  387. let NativeAcDropdown = document.getElementById('nativeassembly_dropdown');
  388. let ResiAcDropdown = document.getElementById('residentialassembly_dropdown');
  389. let EnrollAsDropdown = document.getElementById('enrolledassembly_dropdown');
  390. function loadOptions(dropdown, list) {
  391. dropdown.innerHTML = `<option value="">Select</option>`;
  392. list.forEach(item => {
  393. dropdown.innerHTML += `
  394. <option value="${item.ac_no}">
  395. ${item.ac_name}
  396. </option>`;
  397. });
  398. }
  399. fetch('/election/api/dataentry/batch/getAllAclist')
  400. .then(response => response.json())
  401. .then(result => {
  402. if (result.status !== "success") {
  403. console.error("API error:", result.message);
  404. return;
  405. }
  406. let list = result.data;
  407. // Load all three dropdowns using same function
  408. loadOptions(NativeAcDropdown, list);
  409. loadOptions(ResiAcDropdown, list);
  410. loadOptions(EnrollAsDropdown, list);
  411. $('#nativeassembly_dropdown, #residentialassembly_dropdown, #enrolledassembly_dropdown').select2({
  412. placeholder: "Search",
  413. allowClear: true,
  414. width: "100%"
  415. });
  416. })
  417. .catch(error => {
  418. console.error('Error fetching Assembly Constituency:', error);
  419. });
  420. /* document.querySelectorAll('input[name="question1"]').forEach(function(radio) {
  421. radio.addEventListener("change", function() {
  422. if (this.value === "Y") {
  423. document.getElementById("prevElectionDetails").style.display = "block";
  424. } else {
  425. document.getElementById("prevElectionDetails").style.display = "none";
  426. document.getElementById("previousDetails").value = ""; // clear text
  427. }
  428. });
  429. }); */
  430. document.getElementById("official_name").addEventListener("input", function () {
  431. document.getElementById("epic_name").value = this.value;
  432. });
  433. document.getElementById("epic_verify_link").addEventListener("click", function () {
  434. window.open("https://electoralsearch.eci.gov.in/", "_blank");
  435. });
  436. $('#res_pincode').on('input', function () {
  437. // Remove anything that is not a digit
  438. this.value = this.value.replace(/\D/g, '');
  439. // Limit to max 6 digits
  440. if (this.value.length > 6) {
  441. this.value = this.value.slice(0, 6);
  442. }
  443. });
  444. // PHONE NO: 8 to 10 digits
  445. $('#res_phoneno').on('input', function () {
  446. // Allow only digits
  447. this.value = this.value.replace(/\D/g, '');
  448. // Max 10 digits
  449. if (this.value.length > 10) {
  450. this.value = this.value.slice(0, 10);
  451. }
  452. });
  453. // MOBILE NO: exactly 10 digits
  454. $('#res_mobile').on('input', function () {
  455. // Allow only digits
  456. this.value = this.value.replace(/\D/g, '');
  457. // Max 10 digits
  458. if (this.value.length > 10) {
  459. this.value = this.value.slice(0, 10);
  460. }
  461. });
  462. // PART NO: 6 digits only
  463. $('#part_no').on('input', function () {
  464. this.value = this.value.replace(/\D/g, ''); // allow digits only
  465. if (this.value.length > 6) {
  466. this.value = this.value.slice(0, 6); // max 6 digits
  467. }
  468. });
  469. // SI NO: 6 digits only
  470. $('#si_no').on('input', function () {
  471. this.value = this.value.replace(/\D/g, ''); // allow digits only
  472. if (this.value.length > 6) {
  473. this.value = this.value.slice(0, 6); // max 6 digits
  474. }
  475. });
  476. $('#epic_no').on('input', function () {
  477. // Allow only A–Z, a–z, 0–9
  478. this.value = this.value.replace(/[^A-Za-z0-9]/g, '');
  479. // Limit to 16 characters
  480. if (this.value.length > 16) {
  481. this.value = this.value.slice(0, 16);
  482. }
  483. });
  484. $('#newpollingform').submit(function (e) {
  485. e.preventDefault();
  486. let formData = new FormData(this);
  487. $('#saveBtn').prop('disabled', true).text('Saving...');
  488. $('#pageLoader').show();
  489. function setIfPresent(formData, key, value) {
  490. if (value !== undefined && value !== null && value !== "") {
  491. formData.set(key, value);
  492. }
  493. }
  494. let userId = document.getElementById('userIdSpan').textContent;
  495. let batch_no = $('#batch_no').val().trim();
  496. let official_name = $('#official_name').val().trim();
  497. let official_age = $('#official_age').val().trim();
  498. // Convert to number
  499. let ageNum = parseInt(official_age, 10);
  500. // Validate age
  501. if(official_age){
  502. if (isNaN(ageNum) || ageNum < 18 || ageNum > 65) {
  503. $('#pageLoader').hide();
  504. $('#saveBtn').prop('disabled', false).text('Save');
  505. Swal.fire({
  506. icon: 'warning',
  507. title: 'Invalid Age',
  508. text: 'Age must be between 18 and 65'
  509. });
  510. return;
  511. }
  512. }
  513. let gender = $("input[name='gender']:checked").val();
  514. let design_id=$('#design_dropdown').val();
  515. let design_name = $('#design_dropdown option:selected').text();
  516. let respincode=$('#res_pincode').val().trim();
  517. if(respincode){
  518. // Rule 1: Must be exactly 6 digits & should NOT start with 0
  519. if (!/^[1-9][0-9]{5}$/.test(respincode)) {
  520. $('#pageLoader').hide();
  521. $('#saveBtn').prop('disabled', false).text('Save');
  522. Swal.fire({
  523. icon: 'warning',
  524. title: 'Invalid Pincode',
  525. text: 'Pincode must be 6 digits and cannot start with 0.'
  526. });
  527. return;
  528. }
  529. // Rule 2: Reject 123456 (sequential)
  530. if (respincode === "123456") {
  531. $('#pageLoader').hide();
  532. $('#saveBtn').prop('disabled', false).text('Save');
  533. Swal.fire({
  534. icon: 'warning',
  535. title: 'Invalid Pincode',
  536. text: 'Sequential numbers like 123456 are not allowed.'
  537. });
  538. return;
  539. }
  540. // Rule 3: Reject all digits same (111111, 222222, etc.)
  541. if (/^(\d)\1{5}$/.test(respincode)) {
  542. $('#pageLoader').hide();
  543. $('#saveBtn').prop('disabled', false).text('Save');
  544. Swal.fire({
  545. icon: 'warning',
  546. title: 'Invalid Pincode',
  547. text: 'All digits cannot be the same.'
  548. });
  549. return;
  550. }
  551. }
  552. let phnumber=$('#res_phoneno').val().trim();
  553. if(phnumber){
  554. // Validate 8 to 10 digits only
  555. if (!/^\d{8,10}$/.test(phnumber)) {
  556. $('#pageLoader').hide();
  557. $('#saveBtn').prop('disabled', false).text('Save');
  558. Swal.fire({
  559. icon: 'warning',
  560. title: 'Invalid Phone Number',
  561. text: 'Phone number must be 8 to 10 digits.'
  562. });
  563. return;
  564. }
  565. }
  566. let mobnumber=$('#res_mobile').val().trim();
  567. if(mobnumber){
  568. // Rule 1: Must be exactly 10 digits & must not start with 0
  569. if (!/^[1-9][0-9]{9}$/.test(mobnumber)) {
  570. $('#pageLoader').hide();
  571. $('#saveBtn').prop('disabled', false).text('Save');
  572. Swal.fire({
  573. icon: 'warning',
  574. title: 'Invalid Mobile Number',
  575. text: 'Mobile number must be 10 digits and cannot start with 0.'
  576. });
  577. return;
  578. }
  579. // Rule 2: Reject sequential numbers like 1234567890
  580. if (mobnumber === "1234567890") {
  581. $('#pageLoader').hide();
  582. $('#saveBtn').prop('disabled', false).text('Save');
  583. Swal.fire({
  584. icon: 'warning',
  585. title: 'Invalid Mobile Number',
  586. text: 'Sequential numbers like 1234567890 are not allowed.'
  587. });
  588. return;
  589. }
  590. // Rule 3: Reject all digits same (1111111111, 2222222222, etc.)
  591. if (/^(\d)\1{9}$/.test(mobnumber)) {
  592. $('#pageLoader').hide();
  593. $('#saveBtn').prop('disabled', false).text('Save');
  594. Swal.fire({
  595. icon: 'warning',
  596. title: 'Invalid Mobile Number',
  597. text: 'All digits cannot be the same.'
  598. });
  599. return;
  600. }
  601. }
  602. let native_taluk=$('#nativetaluk_dropdown').val();
  603. let native_ac=$('#nativeassembly_dropdown').val();
  604. let res_ac=$('#residentialassembly_dropdown').val();
  605. let enrol_ac=$('#enrolledassembly_dropdown').val();
  606. let epic_no = $('#epic_no').val().trim();
  607. if(epic_no){
  608. // Allow only 8 to 16 alphanumeric characters
  609. let epicPattern = /^[A-Za-z0-9]{8,16}$/;
  610. if (!epicPattern.test(epic_no)) {
  611. $('#pageLoader').hide();
  612. $('#saveBtn').prop('disabled', false).text('Save');
  613. Swal.fire({
  614. icon: 'warning',
  615. title: 'Invalid EPIC Number',
  616. text: 'EPIC number must be 8 to 16 alphanumeric characters.'
  617. });
  618. return;
  619. }
  620. }
  621. let part_no =$('#part_no').val().trim();
  622. let si_no = $('#si_no').val().trim();
  623. if(part_no){
  624. // Validate part_no
  625. if (part_no.length > 6) {
  626. $('#pageLoader').hide();
  627. $('#saveBtn').prop('disabled', false).text('Save');
  628. Swal.fire({
  629. icon: 'warning',
  630. title: 'Invalid Part No',
  631. text: 'Maximum 6 digits allowed for Part No.'
  632. });
  633. return;
  634. }
  635. }
  636. if(si_no){
  637. // Validate si_no
  638. if (si_no.length > 6) {
  639. $('#pageLoader').hide();
  640. $('#saveBtn').prop('disabled', false).text('Save');
  641. Swal.fire({
  642. icon: 'warning',
  643. title: 'Invalid Sl. No',
  644. text: 'Maximum 6 digits allowed for Sl No.'
  645. });
  646. return;
  647. }
  648. }
  649. /* let question1 = $("input[name='question1']:checked").val();
  650. if(question1){
  651. let previousDetails=$('#previousDetails').val().trim();
  652. if(!previousDetails){
  653. $('#pageLoader').hide();
  654. $('#saveBtn').prop('disabled', false).text('Save');
  655. Swal.fire({
  656. icon: 'warning',
  657. title: 'Validation Error',
  658. text: 'Enter PS No,AC No'
  659. });
  660. return;
  661. }
  662. }
  663. let question2 = $("input[name='question2']:checked").val();
  664. let question3 = $("input[name='question3']:checked").val(); */
  665. setIfPresent(formData, "userid", userId);
  666. setIfPresent(formData, "pBatchId", batch_no);
  667. setIfPresent(formData, "DeptId", deptId);
  668. setIfPresent(formData, "officeId", officeId);
  669. setIfPresent(formData, "pName", official_name);
  670. setIfPresent(formData, "pAge", official_age);
  671. setIfPresent(formData, "pGender", gender || "");
  672. setIfPresent(formData, "DesignationId",design_id);
  673. setIfPresent(formData, "Designation", design_name);
  674. setIfPresent(formData, "address1", $('#res_address1').val().trim());
  675. setIfPresent(formData, "address2", $('#res_address2').val().trim());
  676. setIfPresent(formData, "address3", $('#res_address3').val().trim());
  677. setIfPresent(formData, "pincode",respincode);
  678. setIfPresent(formData, "policest", $('#res_police').val().trim());
  679. setIfPresent(formData, "phoneno",phnumber);
  680. setIfPresent(formData, "mobileno",mobnumber);
  681. setIfPresent(formData, "district",native_taluk);
  682. setIfPresent(formData, "nativeac",native_ac);
  683. setIfPresent(formData, "resideac",res_ac);
  684. setIfPresent(formData, "electoracno",enrol_ac);
  685. setIfPresent(formData, "electorpartno",part_no );
  686. setIfPresent(formData, "electorslno", si_no);
  687. setIfPresent(formData, "epicno",epic_no);
  688. /* setIfPresent(formData, "officiated", question1);
  689. setIfPresent(formData, "officiateddet", $('#previousDetails').val().trim());
  690. setIfPresent(formData, "evmexperience", question2);
  691. setIfPresent(formData, "disaqualified", question3); */
  692. $.ajax({
  693. url: '/election/api/dataentry_mob/batch/savenewentry',
  694. type: 'POST',
  695. data: formData,
  696. enctype: 'multipart/form-data',
  697. processData: false,
  698. contentType: false,
  699. success: function (response) {
  700. $('#pageLoader').hide();
  701. if (response.status) {
  702. Swal.fire({
  703. allowOutsideClick: false,
  704. allowEscapeKey: false,
  705. allowEnterKey: false,
  706. icon: 'success',
  707. title: 'Success',
  708. text:response.description,
  709. html: 'Unique Number : <b>' + response.unique_no + '</b>'
  710. }).then((result) => {
  711. window.location.href="/election/dataentry_mob/batchbyid?batchid="+batch_no;
  712. });
  713. //$('#newpollingform')[0].reset();
  714. } else {
  715. $('#pageLoader').hide();
  716. Swal.fire({
  717. icon: 'warning',
  718. title: response.message,
  719. text: response.description || 'Something went wrong!'
  720. });
  721. }
  722. $('#saveBtn').prop('disabled', false).text('Save');
  723. },
  724. error: function () {
  725. $('#pageLoader').hide();
  726. Swal.fire({
  727. icon: 'error',
  728. title: 'Submission Error',
  729. text: 'Something went wrong while submitting the form.'
  730. });
  731. $('#saveBtn').prop('disabled', false).text('Save');
  732. }
  733. });
  734. });
  735. });
  736. function getDesignationDetails(desgId) {
  737. //console.log("desgId="+desgId);
  738. fetch('/election/api/dataentry/batch/getPayDetails?DesgId=' + desgId)
  739. .then(response => response.json())
  740. .then(result => {
  741. if (result.status !== "success") {
  742. console.error("API error:", result.message);
  743. return;
  744. }
  745. let data = result.data; // your pay details row
  746. //console.log("Designation Pay Details:", data);
  747. // Example: set values into input fields
  748. document.getElementById("basic_pay").value = data.basic_pay;
  749. document.getElementById("grade_pay").value = data.grade_pay;
  750. document.getElementById("pay_band").value = data.pay_scale;
  751. })
  752. .catch(error => {
  753. console.error("Error fetching pay details:", error);
  754. });
  755. }
  756. function getOfficeDetails(officeId) {
  757. console.log("officeId="+officeId);
  758. fetch('/election/api/dataentry/batch/getOfficeDetailsById?officeId=' + officeId)
  759. .then(response => response.json())
  760. .then(result => {
  761. if (result.status !== "success") {
  762. console.error("API error:", result.message);
  763. return;
  764. }
  765. let data = result.data[0];
  766. console.log("office Details:", data);
  767. // Example: set values into input fields
  768. document.getElementById("off_office_name").value = data.office_name;
  769. document.getElementById("off_address1").value = data.address1;
  770. document.getElementById("off_address2").value = data.address2;
  771. document.getElementById("off_address3").value = data.address3;
  772. document.getElementById("off_pincode").value = data.pincode;
  773. document.getElementById("off_phoneno").value = data.phone_no;
  774. document.getElementById("off_taluk").value = data.taluk_name;
  775. document.getElementById("off_govt_type").value = data.govt_type;
  776. document.getElementById("off_pub_sec").value = data.public_sector;
  777. document.getElementById("off_localbody").value = data.local_body;
  778. document.getElementById("off_edu_ins").value = data.edu_institution;
  779. document.getElementById("off_category").value = data.office_category;
  780. document.getElementById("off_assembly").value = data.office_assembly;
  781. })
  782. .catch(error => {
  783. console.error("Error fetching Office details:", error);
  784. });
  785. }
  786. function getstatuscounts(batchId){
  787. $('#pageLoader').show();
  788. fetch('/election/api/dataentry_mob/batch/getbatchbyId?id=' + batchId)
  789. .then(response => response.json())
  790. .then(result => {
  791. if (result.status !== "success") {
  792. console.error("API error:", result.message);
  793. return;
  794. }
  795. let data = result.data;
  796. console.log("Details:", data);
  797. // Example: set values into input fields
  798. document.getElementById("c_noof_application").textContent = data.noof_application;
  799. document.getElementById("cc_noof_application").textContent = data.noof_application;
  800. document.getElementById("c_completed").textContent = data.completed;
  801. document.getElementById("c_pending").textContent = data.pending;
  802. let completedCount = parseInt(data.completed) || 0;
  803. let completedPlusOne = completedCount + 1;
  804. document.getElementById("c_completed_plus").textContent = completedPlusOne;
  805. document.getElementById("cc_completed_plus").textContent = completedPlusOne;
  806. })
  807. .catch(error => {
  808. console.error("Error fetching batch counts details:", error);
  809. })
  810. .finally(() => {
  811. $('#pageLoader').hide(); // ALWAYS hide loader
  812. });
  813. }
  814. function goback(){
  815. window.location.href="/election/dataentry_mob/batches";
  816. //window.history.back();
  817. }
  818. </script>
  819. </body>
  820. </html>