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.

1448 lines
47 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>Polling Personnel Updation</h5>
  27. <span>Polling Personnel Update form</span>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="container-fluid" style="padding-left: 15px; padding-right: 15px;">
  34. <div class="row m-0 w-100">
  35. <div class="col-md-6" id="left_col">
  36. <div class="card" style="padding: 10px; height: 100%;">
  37. <h5 class="text-center text-primary mb-3">Original Details</h5>
  38. <!-- Cloned form will be appended here -->
  39. </div>
  40. </div>
  41. <div class="col-md-6" id="right_col">
  42. <div class="card" style="padding: 10px; height: 100%;">
  43. <span th:text="${LoginUserId}" style="display:none;" id="userIdSpan"></span>
  44. <h5 class="text-center text-success mb-3">Update Request Details</h5>
  45. <form id="newpollingform" enctype="multipart/form-data">
  46. <div class=" mb-3"
  47. style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  48. <label class="form-label" for="batch_no">Batch No</label>
  49. <input type="text" class="form-control" id="batch_no" readonly>
  50. </div>
  51. <div class=" mb-3"
  52. style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  53. <div class="row" style="row-gap:10px;">
  54. <div id="existing_uniquenum" style="display: none;"></div>
  55. <div class="col-md-8 col-sm-12">
  56. <label class="form-label" for="official_name"><input type="checkbox"
  57. class="update-check" name="update_flags" value="name"
  58. data-label="Name"> Name of the
  59. Official<span class="text-danger">*</span></label>
  60. <input type="text" class="form-control" id="official_name"
  61. placeholder="Enter Full Name" required="required"
  62. pattern="[A-Za-z.\s]+"
  63. title="Only alphabets, spaces, and dots are allowed">
  64. </div>
  65. <div class="col-md-4 col-sm-12">
  66. <label class="form-label" for="official_age">Age</label>
  67. <input type="number" class="form-control" id="official_age"
  68. placeholder="Enter Age">
  69. </div>
  70. <div class="col-md-4 col-sm-12">
  71. <label class="form-label d-block"><input type="checkbox"
  72. class="update-check" name="update_flags" value="gender"
  73. data-label="Sex"> Sex<span
  74. class="text-danger">*</span></label>
  75. <div class="d-flex flex-wrap gap-3">
  76. <div class="form-check me-3">
  77. <input class="form-check-input" type="radio" name="gender"
  78. id="genderMale" value="M" required="required">
  79. <label class="form-check-label pr-4"
  80. for="genderMale">Male</label>
  81. </div>
  82. <div class="form-check me-3">
  83. <input class="form-check-input" type="radio" name="gender"
  84. id="genderFemale" value="F">
  85. <label class="form-check-label pr-4"
  86. for="genderFemale">Female</label>
  87. </div>
  88. <div class="form-check">
  89. <input class="form-check-input" type="radio" name="gender"
  90. id="genderTransgender" value="T">
  91. <label class="form-check-label pr-4"
  92. for="genderTransgender">Transgender</label>
  93. </div>
  94. </div>
  95. </div>
  96. <div class="col-md-4 col-sm-12">
  97. <label class="form-label"><input type="checkbox"
  98. class="update-check" name="update_flags" value="designation"
  99. data-label="Designation"> Designation</label>
  100. <select id="design_dropdown" class="form-control">
  101. <option value="">Select</option>
  102. </select>
  103. </div>
  104. <div class="col-md-4 col-sm-12">
  105. <label class="form-label"><input type="checkbox"
  106. class="update-check" name="update_flags" value="image"
  107. data-label="Upload Photo"> Update Photo</label>
  108. <!-- Replaced file input with just the preview link as requested -->
  109. <div id="profileimage_preview" class="mt-2"
  110. style="cursor:pointer; color:blue; text-decoration:underline;display: none;">
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <div class="card-body" style="padding: 10px;">
  116. <div class="row" style="row-gap:10px;">
  117. <div class="col-md-12 col-sm-12">
  118. <div class="card-header bg-dark text-white">
  119. <b>Residential Details</b>
  120. </div>
  121. <div class="card-body"
  122. style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;">
  123. <label class="form-label" for="res_address1">House No/ House
  124. Name</label>
  125. <input type="text" class="form-control mb-3" id="res_address1">
  126. <label class="form-label" for="res_address2">Street Name/
  127. Area</label>
  128. <input type="text" class="form-control mb-3" id="res_address2">
  129. <label class="form-label" for="res_address3">City</label>
  130. <input type="text" class="form-control mb-3" id="res_address3">
  131. <label class="form-label" for="res_pincode">Pincode</label>
  132. <input type="text" class="form-control mb-3" id="res_pincode">
  133. <label class="form-label" for="res_police">Nearest Police
  134. Station</label>
  135. <input type="text" class="form-control mb-3" id="res_police">
  136. <label class="form-label" for="res_phoneno">Phone No</label>
  137. <div class="d-flex justify-content-start">
  138. <button class="btn btn-secondary" disabled="disabled"
  139. style="height: fit-content">STD</button>
  140. <input type="text" class="form-control mb-3 mx-2"
  141. id="res_phoneno">
  142. </div>
  143. <label class="form-label" for="res_mobile"><input
  144. type="checkbox" class="update-check" name="update_flags"
  145. value="mobno" data-label="Mobile"> Mobile</label>
  146. <input type="text" class="form-control mb-3" id="res_mobile">
  147. <div class="mb-3">
  148. <label class="form-label" for="nativetaluk_dropdown">Native
  149. Taluk/District</label>
  150. <select id="nativetaluk_dropdown" class="form-control mb-3">
  151. <option value="">Select</option>
  152. </select>
  153. </div>
  154. <div class="mb-3">
  155. <label class="form-label"
  156. for="nativeassembly_dropdown"><input type="checkbox"
  157. class="update-check" name="update_flags"
  158. value="native_ac" data-label="Native Assembly">
  159. Native
  160. Assembly Constituency</label>
  161. <select id="nativeassembly_dropdown"
  162. class="form-control mb-3">
  163. <option value="">Select</option>
  164. </select>
  165. </div>
  166. <label class="form-label"
  167. for="residentialassembly_dropdown"><input type="checkbox"
  168. class="update-check" name="update_flags"
  169. value="residential_ac"
  170. data-label="Residential Assembly"> Residential Assembly
  171. Constituency</label>
  172. <select id="residentialassembly_dropdown"
  173. class="form-control mb-3">
  174. <option value="">Select</option>
  175. </select>
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. <div class="card-body mb-3" style="padding: 10px;">
  181. <div style="border: 1px solid grey;border-radius: 5px;">
  182. <div class="row" style="row-gap:10px;">
  183. <div class="col-md-12 col-sm-12">
  184. <div class="card-header">
  185. <b>Enrolled Details</b>
  186. </div>
  187. <div class="card-body">
  188. <div class="row pl-3 pb-2" style="row-gap:10px;">
  189. <span id="epic_verify_link"
  190. style="cursor:pointer; color:blue; text-decoration:underline;">
  191. Click here to verify EPIC No <i
  192. 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"><input
  198. type="checkbox" class="update-check"
  199. name="update_flags" value="epic_no"
  200. data-label="EPIC No"> EPIC
  201. No</label>
  202. <input type="text" class="form-control"
  203. id="epic_no">
  204. </div>
  205. <div class="col-md-6 col-sm-12">
  206. <label class="form-label"
  207. for="epic_name">Name</label>
  208. <input type="text" class="form-control"
  209. id="epic_name" readonly="readonly">
  210. </div>
  211. <div class="col-md-6 col-sm-12">
  212. <label class="form-label"
  213. for="enrolledassembly_dropdown"><input
  214. type="checkbox" class="update-check"
  215. name="update_flags" value="electoral_ac"
  216. data-label="Enrolled Assembly"> Enrolled
  217. Assembly
  218. Constituency</label>
  219. <select id="enrolledassembly_dropdown"
  220. class="form-control">
  221. <option value="">Select</option>
  222. </select>
  223. </div>
  224. </div>
  225. <div class="row mt-2" style="row-gap:10px;">
  226. <div class="col-md-6 col-sm-12">
  227. <label class="form-label" for="part_no"><input
  228. type="checkbox" class="update-check"
  229. name="update_flags" value="part_no"
  230. data-label="Part No"> Part
  231. No</label>
  232. <input type="text" class="form-control"
  233. id="part_no">
  234. </div>
  235. <div class="col-md-6 col-sm-12">
  236. <label class="form-label" for="si_no"><input
  237. type="checkbox" class="update-check"
  238. name="update_flags" value="serial_no"
  239. data-label="SI. No"> SI. No</label>
  240. <input type="text" class="form-control" id="si_no">
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <!-- <div class="col-md-6 col-sm-12">
  246. <div class="card-header">
  247. <b>Experience Questions</b>
  248. </div>
  249. <div class="card-body">
  250. <div class="col-md-12 col-sm-12 mb-2">
  251. <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>
  252. <div class="d-flex flex-wrap gap-3">
  253. <div class="form-check me-3">
  254. <input class="form-check-input" type="radio" name="question1" id="question1" value="Y">
  255. <label class="form-check-label pr-4" for="question1">Yes</label>
  256. </div>
  257. <div class="form-check">
  258. <input class="form-check-input" type="radio" name="question1" id="question1" value="N">
  259. <label class="form-check-label pr-4" for="question1">No</label>
  260. </div>
  261. </div>
  262. <div id="prevElectionDetails" class="mt-2" style="display: none;">
  263. <input type="text" id="previousDetails" class="form-control"
  264. placeholder="Enter PS No, AC No">
  265. </div>
  266. </div>
  267. <div class="col-md-12 col-sm-12 mb-2">
  268. <label class="form-label">Whether the official has previous experience in handling EVMs (Y/N)?</label>
  269. <div class="d-flex flex-wrap gap-3">
  270. <div class="form-check me-3">
  271. <input class="form-check-input" type="radio" name="question2" id="question2" value="Y">
  272. <label class="form-check-label pr-4" for="question2">Yes</label>
  273. </div>
  274. <div class="form-check">
  275. <input class="form-check-input" type="radio" name="question2" id="question2" value="N">
  276. <label class="form-check-label pr-4" for="question2">No</label>
  277. </div>
  278. </div>
  279. </div>
  280. <div class="col-md-12 col-sm-12">
  281. <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>
  282. <div class="d-flex flex-wrap gap-3">
  283. <div class="form-check me-3">
  284. <input class="form-check-input" type="radio" name="question3" id="question3" value="Y">
  285. <label class="form-check-label pr-4" for="question3">Yes</label>
  286. </div>
  287. <div class="form-check">
  288. <input class="form-check-input" type="radio" name="question3" id="question3" value="N">
  289. <label class="form-check-label pr-4" for="question3">No</label>
  290. </div>
  291. </div>
  292. </div>
  293. </div>
  294. </div> -->
  295. </div>
  296. </div>
  297. <!-- old btn container was here -->
  298. <div class="card-body" style="padding: 10px;">
  299. <div class="row" id="btn_container">
  300. <div class="col-12 d-flex justify-content-center">
  301. <button type="submit" class="btn btn-primary mx-2"
  302. id="saveBtn">Update</button>
  303. </div>
  304. </div>
  305. </div>
  306. </form>
  307. </div>
  308. </div>
  309. </div>
  310. <div class="row w-100 m-0 mt-4 mb-4">
  311. <div class="col-12 d-flex justify-content-center">
  312. <button type="button" class="btn btn-secondary btn-lg"
  313. onclick="window.history.back()">Back</button>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. <div class="modal fade" id="profileImageModal" tabindex="-1">
  320. <div class="modal-dialog">
  321. <div class="modal-content">
  322. <div class="modal-header">
  323. <h5 class="modal-title">Profile Photo</h5>
  324. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  325. <span aria-hidden="true">&times;</span>
  326. </button>
  327. </div>
  328. <div class="modal-body text-center">
  329. <img id="modal_profile_image" src="" class="img-fluid rounded" style="max-height:400px;" />
  330. </div>
  331. </div>
  332. </div>
  333. </div>
  334. <div id="pageLoader"
  335. 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;">
  336. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  337. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  338. <span class="sr-only">Loading...</span>
  339. </div>
  340. <!-- Add the 'Please wait' text below the spinner -->
  341. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  342. </div>
  343. </div>
  344. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  345. </div>
  346. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  347. </div>
  348. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  349. <script type="text/javascript">
  350. $(document).ready(function () {
  351. let batchId = sessionStorage.getItem("upd_batch_id");
  352. let deptId = sessionStorage.getItem("upd_dept");
  353. let officeId = sessionStorage.getItem("upd_office_id");
  354. let ppn_id = sessionStorage.getItem("upd_id");
  355. // If any ID is missing -> redirect
  356. // if (!batchId || !deptId || !officeId || !ppn_id) {
  357. // window.location.href = "/election/dataentryadmin/updatepollperson";
  358. // }
  359. document.getElementById("batch_no").value = batchId;
  360. // Values are maintained in session storage to allow page refreshes
  361. // Now you can use these values
  362. console.log("Batch:", batchId, "Dept:", deptId, "Office:", officeId);
  363. let slno = sessionStorage.getItem("upd_slno");
  364. getOriginalPollingDetails(slno);
  365. // Clone form for left side read-only view SYNCHRONOUSLY before select2 or anything initialize
  366. let $formClone = $('#newpollingform').clone();
  367. $formClone.attr('id', 'readonlyform');
  368. $formClone.find('.update-check').remove();
  369. $formClone.find('*').each(function () {
  370. if (this.id) {
  371. // Special handling for the profile image preview
  372. if (this.id === 'profileimage_preview') {
  373. this.id = 'ro_' + this.id;
  374. } else {
  375. this.id = 'ro_' + this.id;
  376. }
  377. }
  378. if (this.name) {
  379. this.name = 'ro_' + this.name;
  380. }
  381. // Disable inputs
  382. if ($(this).is('input, select, textarea, button')) {
  383. $(this).prop('disabled', true);
  384. }
  385. });
  386. $formClone.find('#ro_btn_container').hide();
  387. $('#left_col .card').append($formClone);
  388. getPollingDetails(slno);
  389. let designationDropdown = document.getElementById('design_dropdown');
  390. fetch('/election/api/dataentry/batch/getAllDesignations')
  391. .then(response => response.json())
  392. .then(result => {
  393. if (result.status !== "success") {
  394. console.error("API error:", result.message);
  395. return;
  396. }
  397. let list = result.data;
  398. let roDesignationDropdown = document.getElementById('ro_design_dropdown');
  399. // Clear existing options
  400. designationDropdown.innerHTML = `<option value="">Select</option>`;
  401. if (roDesignationDropdown) roDesignationDropdown.innerHTML = `<option value="">Select</option>`;
  402. // Add options from the API response
  403. list.forEach(design => {
  404. designationDropdown.innerHTML += `
  405. <option value="${design.desig_id}">
  406. ${design.new_designation}
  407. </option>`;
  408. if (roDesignationDropdown) {
  409. roDesignationDropdown.innerHTML += `
  410. <option value="${design.desig_id}">
  411. ${design.new_designation}
  412. </option>`;
  413. }
  414. });
  415. // ⭐ Activate Select2 after options added
  416. $('#design_dropdown').select2({
  417. placeholder: "Search designation...",
  418. allowClear: true,
  419. width: "100%"
  420. });
  421. $('#design_dropdown').on('change', function () {
  422. let selectedDesgId = $(this).val();
  423. if (selectedDesgId) {
  424. getDesignationDetails(selectedDesgId);
  425. }
  426. else {
  427. document.getElementById("basic_pay").value = "";
  428. document.getElementById("grade_pay").value = "";
  429. document.getElementById("pay_band").value = "";
  430. }
  431. });
  432. // PRESELECT designation from API (edit mode)
  433. if (window.editDesignationId) {
  434. $('#design_dropdown').val(window.editDesignationId).trigger('change');
  435. }
  436. })
  437. .catch(error => {
  438. console.error('Error fetching designation:', error);
  439. });
  440. let NativeTaulkDropdown = document.getElementById('nativetaluk_dropdown');
  441. fetch('/election/api/dataentry/batch/getAllDistricts')
  442. .then(response => response.json())
  443. .then(result => {
  444. if (result.status !== "success") {
  445. console.error("API error:", result.message);
  446. return;
  447. }
  448. let list = result.data;
  449. let RoNativeTaulkDropdown = document.getElementById('ro_nativetaluk_dropdown');
  450. NativeTaulkDropdown.innerHTML = `<option value="">Select</option>`;
  451. if (RoNativeTaulkDropdown) RoNativeTaulkDropdown.innerHTML = `<option value="">Select</option>`;
  452. // Add options from the API response
  453. list.forEach(nativedis => {
  454. NativeTaulkDropdown.innerHTML += `
  455. <option value="${nativedis.dist_no}">
  456. ${nativedis.dist_name}
  457. </option>`;
  458. if (RoNativeTaulkDropdown) {
  459. RoNativeTaulkDropdown.innerHTML += `
  460. <option value="${nativedis.dist_no}">
  461. ${nativedis.dist_name}
  462. </option>`;
  463. }
  464. });
  465. $('#nativetaluk_dropdown').select2({
  466. placeholder: "Search",
  467. allowClear: true,
  468. width: "100%"
  469. });
  470. if (window.editHomeDist) {
  471. $('#nativetaluk_dropdown').val(window.editHomeDist).trigger('change');
  472. }
  473. })
  474. .catch(error => {
  475. console.error('Error fetching in District :', error);
  476. });
  477. let NativeAcDropdown = document.getElementById('nativeassembly_dropdown');
  478. let ResiAcDropdown = document.getElementById('residentialassembly_dropdown');
  479. let EnrollAsDropdown = document.getElementById('enrolledassembly_dropdown');
  480. function loadOptions(dropdown, list) {
  481. dropdown.innerHTML = `<option value="">Select</option>`;
  482. list.forEach(item => {
  483. dropdown.innerHTML += `
  484. <option value="${item.ac_no}">
  485. ${item.ac_name}
  486. </option>`;
  487. });
  488. }
  489. fetch('/election/api/dataentry/batch/getAllAclist')
  490. .then(response => response.json())
  491. .then(result => {
  492. if (result.status !== "success") {
  493. console.error("API error:", result.message);
  494. return;
  495. }
  496. let list = result.data;
  497. let roNativeAcDropdown = document.getElementById('ro_nativeassembly_dropdown');
  498. let roResiAcDropdown = document.getElementById('ro_residentialassembly_dropdown');
  499. let roEnrollAsDropdown = document.getElementById('ro_enrolledassembly_dropdown');
  500. // Load all three dropdowns using same function
  501. loadOptions(NativeAcDropdown, list);
  502. loadOptions(ResiAcDropdown, list);
  503. loadOptions(EnrollAsDropdown, list);
  504. if (roNativeAcDropdown) loadOptions(roNativeAcDropdown, list);
  505. if (roResiAcDropdown) loadOptions(roResiAcDropdown, list);
  506. if (roEnrollAsDropdown) loadOptions(roEnrollAsDropdown, list);
  507. $('#nativeassembly_dropdown, #residentialassembly_dropdown, #enrolledassembly_dropdown').select2({
  508. placeholder: "Search",
  509. allowClear: true,
  510. width: "100%"
  511. });
  512. // PRESELECT VALUES (ONLY IF NOT NULL)
  513. if (window.nativeAcNo) {
  514. $('#nativeassembly_dropdown').val(window.nativeAcNo).trigger('change');
  515. }
  516. if (window.resideAcNo) {
  517. $('#residentialassembly_dropdown').val(window.resideAcNo).trigger('change');
  518. }
  519. if (window.enrollAcNo) {
  520. $('#enrolledassembly_dropdown').val(window.enrollAcNo).trigger('change');
  521. }
  522. })
  523. .catch(error => {
  524. console.error('Error fetching Assembly Constituency:', error);
  525. });
  526. /* document.querySelectorAll('input[name="question1"]').forEach(function(radio) {
  527. radio.addEventListener("change", function() {
  528. if (this.value === "Y") {
  529. document.getElementById("prevElectionDetails").style.display = "block";
  530. } else {
  531. document.getElementById("prevElectionDetails").style.display = "none";
  532. document.getElementById("previousDetails").value = ""; // clear text
  533. }
  534. });
  535. }); */
  536. document.getElementById("official_name").addEventListener("input", function () {
  537. document.getElementById("epic_name").value = this.value;
  538. });
  539. document.getElementById("epic_verify_link").addEventListener("click", function () {
  540. window.open("https://electoralsearch.eci.gov.in/", "_blank");
  541. });
  542. getOfficeDetails(officeId);
  543. getOfficeDetails(officeId);
  544. $('#profileimage').on('input', function () {
  545. let fileInput = this;
  546. let file = fileInput.files[0];
  547. // Allowed extensions
  548. let allowedExtensions = /(\.jpg|\.jpeg)$/i;
  549. // File name
  550. let fileName = file.name;
  551. // File size (10 MB = 10 * 1024 * 1024)
  552. let maxSize = 10 * 1024 * 1024;
  553. // 1) Validate extension
  554. if (!allowedExtensions.test(fileName)) {
  555. Swal.fire({
  556. icon: 'error',
  557. title: 'Invalid File Type',
  558. text: 'Only JPG / JPEG images are allowed!'
  559. });
  560. fileInput.value = ""; // Reset file
  561. return;
  562. }
  563. // 2) Validate MIME type
  564. if (file.type !== "image/jpeg") {
  565. Swal.fire({
  566. icon: 'error',
  567. title: 'Invalid Image Format',
  568. text: 'Only JPEG images are allowed!'
  569. });
  570. fileInput.value = "";
  571. return;
  572. }
  573. // 3) Validate size
  574. if (file.size > maxSize) {
  575. Swal.fire({
  576. icon: 'error',
  577. title: 'File Too Large',
  578. text: 'File size must be 10 MB or less!'
  579. });
  580. fileInput.value = "";
  581. return;
  582. }
  583. });
  584. $('#res_pincode').on('input', function () {
  585. // Remove anything that is not a digit
  586. this.value = this.value.replace(/\D/g, '');
  587. // Limit to max 6 digits
  588. if (this.value.length > 6) {
  589. this.value = this.value.slice(0, 6);
  590. }
  591. });
  592. // PHONE NO: 8 to 10 digits
  593. $('#res_phoneno').on('input', function () {
  594. // Allow only digits
  595. this.value = this.value.replace(/\D/g, '');
  596. // Max 10 digits
  597. if (this.value.length > 10) {
  598. this.value = this.value.slice(0, 10);
  599. }
  600. });
  601. // MOBILE NO: exactly 10 digits
  602. $('#res_mobile').on('input', function () {
  603. // Allow only digits
  604. this.value = this.value.replace(/\D/g, '');
  605. // Max 10 digits
  606. if (this.value.length > 10) {
  607. this.value = this.value.slice(0, 10);
  608. }
  609. });
  610. // PART NO: 6 digits only
  611. $('#part_no').on('input', function () {
  612. this.value = this.value.replace(/\D/g, ''); // allow digits only
  613. if (this.value.length > 6) {
  614. this.value = this.value.slice(0, 6);
  615. }
  616. });
  617. // SI NO: 6 digits only
  618. $('#si_no').on('input', function () {
  619. this.value = this.value.replace(/\D/g, ''); // allow digits only
  620. if (this.value.length > 6) {
  621. this.value = this.value.slice(0, 6); // max 6 digits
  622. }
  623. });
  624. $('#epic_no').on('input', function () {
  625. // Allow only A–Z, a–z, 0–9
  626. this.value = this.value.replace(/[^A-Za-z0-9]/g, '');
  627. // Limit to 16 characters
  628. if (this.value.length > 16) {
  629. this.value = this.value.slice(0, 16);
  630. }
  631. });
  632. $('#newpollingform').submit(function (e) {
  633. e.preventDefault();
  634. let formData = new FormData(this);
  635. $('#saveBtn').prop('disabled', true).text('Updating...');
  636. $('#pageLoader').show();
  637. function setIfPresent(formData, key, value) {
  638. if (value !== undefined && value !== null && value !== "") {
  639. formData.set(key, value);
  640. }
  641. }
  642. function setFileIfPresent(formData, key, fileInput) {
  643. if (fileInput && fileInput.files && fileInput.files.length > 0) {
  644. formData.set(key, fileInput.files[0]);
  645. }
  646. }
  647. let userId = document.getElementById('userIdSpan').textContent;
  648. let batch_no = $('#batch_no').val().trim();
  649. let official_name = $('#official_name').val().trim();
  650. let official_age = $('#official_age').val().trim();
  651. // Convert to number
  652. let ageNum = parseInt(official_age, 10);
  653. // Validate age
  654. if (official_age) {
  655. if (isNaN(ageNum) || ageNum < 18 || ageNum > 65) {
  656. $('#pageLoader').hide();
  657. $('#saveBtn').prop('disabled', false).text('Update');
  658. Swal.fire({
  659. icon: 'warning',
  660. title: 'Invalid Age',
  661. text: 'Age must be between 18 and 65'
  662. });
  663. return;
  664. }
  665. }
  666. let gender = $("input[name='gender']:checked").val();
  667. let design_id = $('#design_dropdown').val();
  668. let design_name = design_id ? $('#design_dropdown option:selected').text().trim() : "";
  669. let respincode = $('#res_pincode').val().trim();
  670. if (respincode) {
  671. // Rule 1: Must be exactly 6 digits & should NOT start with 0
  672. if (!/^[1-9][0-9]{5}$/.test(respincode)) {
  673. $('#pageLoader').hide();
  674. $('#saveBtn').prop('disabled', false).text('Update');
  675. Swal.fire({
  676. icon: 'warning',
  677. title: 'Invalid Pincode',
  678. text: 'Pincode must be 6 digits and cannot start with 0.'
  679. });
  680. return;
  681. }
  682. // Rule 2: Reject 123456 (sequential)
  683. if (respincode === "123456") {
  684. $('#pageLoader').hide();
  685. $('#saveBtn').prop('disabled', false).text('Update');
  686. Swal.fire({
  687. icon: 'warning',
  688. title: 'Invalid Pincode',
  689. text: 'Sequential numbers like 123456 are not allowed.'
  690. });
  691. return;
  692. }
  693. // Rule 3: Reject all digits same (111111, 222222, etc.)
  694. if (/^(\d)\1{5}$/.test(respincode)) {
  695. $('#pageLoader').hide();
  696. $('#saveBtn').prop('disabled', false).text('Update');
  697. Swal.fire({
  698. icon: 'warning',
  699. title: 'Invalid Pincode',
  700. text: 'All digits cannot be the same.'
  701. });
  702. return;
  703. }
  704. }
  705. let phnumber = $('#res_phoneno').val().trim();
  706. if (phnumber) {
  707. // Validate 8 to 10 digits only
  708. if (!/^\d{8,10}$/.test(phnumber)) {
  709. $('#pageLoader').hide();
  710. $('#saveBtn').prop('disabled', false).text('Update');
  711. Swal.fire({
  712. icon: 'warning',
  713. title: 'Invalid Phone Number',
  714. text: 'Phone number must be 8 to 10 digits.'
  715. });
  716. return;
  717. }
  718. }
  719. let mobnumber = $('#res_mobile').val().trim();
  720. if (mobnumber) {
  721. // Rule 1: Must be exactly 10 digits & must not start with 0
  722. if (!/^[1-9][0-9]{9}$/.test(mobnumber)) {
  723. $('#pageLoader').hide();
  724. $('#saveBtn').prop('disabled', false).text('Update');
  725. Swal.fire({
  726. icon: 'warning',
  727. title: 'Invalid Mobile Number',
  728. text: 'Mobile number must be 10 digits and cannot start with 0.'
  729. });
  730. return;
  731. }
  732. // Rule 2: Reject sequential numbers like 1234567890
  733. if (mobnumber === "1234567890") {
  734. $('#pageLoader').hide();
  735. $('#saveBtn').prop('disabled', false).text('Update');
  736. Swal.fire({
  737. icon: 'warning',
  738. title: 'Invalid Mobile Number',
  739. text: 'Sequential numbers like 1234567890 are not allowed.'
  740. });
  741. return;
  742. }
  743. // Rule 3: Reject all digits same (1111111111, 2222222222, etc.)
  744. if (/^(\d)\1{9}$/.test(mobnumber)) {
  745. $('#pageLoader').hide();
  746. $('#saveBtn').prop('disabled', false).text('Update');
  747. Swal.fire({
  748. icon: 'warning',
  749. title: 'Invalid Mobile Number',
  750. text: 'All digits cannot be the same.'
  751. });
  752. return;
  753. }
  754. }
  755. let native_taluk = $('#nativetaluk_dropdown').val();
  756. let native_ac = $('#nativeassembly_dropdown').val();
  757. let res_ac = $('#residentialassembly_dropdown').val();
  758. let enrol_ac = $('#enrolledassembly_dropdown').val();
  759. let epic_no = $('#epic_no').val().trim();
  760. // updated
  761. if (epic_no) {
  762. // Allow 8 to 16 alphanumeric characters
  763. let epicPattern = /^[A-Za-z0-9]{8,16}$/;
  764. if (!epicPattern.test(epic_no)) {
  765. $('#pageLoader').hide();
  766. $('#saveBtn').prop('disabled', false).text('Save');
  767. Swal.fire({
  768. icon: 'warning',
  769. title: 'Invalid EPIC Number',
  770. text: 'EPIC number must be 8 to 16 alphanumeric characters.'
  771. });
  772. return;
  773. }
  774. }
  775. /* if(epic_no){
  776. // Allow only 16 alphanumeric characters
  777. let epicPattern = /^[A-Za-z0-9]{16}$/;
  778. if (!epicPattern.test(epic_no)) {
  779. $('#pageLoader').hide();
  780. $('#saveBtn').prop('disabled', false).text('Update');
  781. Swal.fire({
  782. icon: 'warning',
  783. title: 'Invalid EPIC Number',
  784. text: 'EPIC number must be exactly 16 alphanumeric characters.'
  785. });
  786. return;
  787. }
  788. }*/
  789. let part_no = $('#part_no').val().trim();
  790. let si_no = $('#si_no').val().trim();
  791. if (part_no) {
  792. // Validate part_no
  793. if (part_no.length > 6) {
  794. $('#pageLoader').hide();
  795. $('#saveBtn').prop('disabled', false).text('Save');
  796. Swal.fire({
  797. icon: 'warning',
  798. title: 'Invalid Part No',
  799. text: 'Maximum 6 digits allowed for Part No.'
  800. });
  801. return;
  802. }
  803. }
  804. if (si_no) {
  805. // Validate si_no
  806. if (si_no.length > 6) {
  807. $('#pageLoader').hide();
  808. $('#saveBtn').prop('disabled', false).text('Save');
  809. Swal.fire({
  810. icon: 'warning',
  811. title: 'Invalid Sl. No',
  812. text: 'Maximum 6 digits allowed for Sl No.'
  813. });
  814. return;
  815. }
  816. }
  817. /* let question1 = $("input[name='question1']:checked").val();
  818. if(question1){
  819. let previousDetails=$('#previousDetails').val().trim();
  820. if(!previousDetails){
  821. $('#pageLoader').hide();
  822. $('#saveBtn').prop('disabled', false).text('Save');
  823. Swal.fire({
  824. icon: 'warning',
  825. title: 'Validation Error',
  826. text: 'Enter PS No,AC No'
  827. });
  828. return;
  829. }
  830. }
  831. let question2 = $("input[name='question2']:checked").val();
  832. let question3 = $("input[name='question3']:checked").val(); */
  833. setFileIfPresent(formData, "pp_image", $('#profileimage')[0]);
  834. setIfPresent(formData, "nppid", ppn_id);
  835. formData.append("userid", userId);
  836. let existing_uniquenum = $('#existing_uniquenum').text();
  837. formData.append("slno", existing_uniquenum);
  838. setIfPresent(formData, "pBatchId", batch_no);
  839. setIfPresent(formData, "DeptId", deptId);
  840. setIfPresent(formData, "officeId", officeId);
  841. setIfPresent(formData, "pName", official_name);
  842. setIfPresent(formData, "pAge", official_age);
  843. setIfPresent(formData, "pGender", gender || "");
  844. setIfPresent(formData, "DesignationId", design_id);
  845. setIfPresent(formData, "Designation", design_name);
  846. setIfPresent(formData, "address1", $('#res_address1').val().trim());
  847. setIfPresent(formData, "address2", $('#res_address2').val().trim());
  848. setIfPresent(formData, "address3", $('#res_address3').val().trim());
  849. setIfPresent(formData, "pincode", respincode);
  850. setIfPresent(formData, "policest", $('#res_police').val().trim());
  851. setIfPresent(formData, "phoneno", phnumber);
  852. setIfPresent(formData, "mobileno", mobnumber);
  853. setIfPresent(formData, "district", native_taluk);
  854. setIfPresent(formData, "nativeac", native_ac);
  855. setIfPresent(formData, "resideac", res_ac);
  856. setIfPresent(formData, "electoracno", enrol_ac);
  857. setIfPresent(formData, "electorpartno", part_no);
  858. setIfPresent(formData, "electorslno", si_no);
  859. setIfPresent(formData, "epicno", epic_no);
  860. /* setIfPresent(formData, "officiated", question1);
  861. setIfPresent(formData, "officiateddet", $('#previousDetails').val().trim());
  862. setIfPresent(formData, "evmexperience", question2);
  863. setIfPresent(formData, "disaqualified", question3); */
  864. let updateFlags = [];
  865. let updateLabels = [];
  866. $('.update-check:checked').each(function () {
  867. updateFlags.push($(this).val());
  868. updateLabels.push($(this).attr('data-label'));
  869. });
  870. if (updateFlags.length === 0) {
  871. $('#pageLoader').hide();
  872. $('#saveBtn').prop('disabled', false).text('Update');
  873. Swal.fire({
  874. icon: 'warning',
  875. title: 'No Fields Selected',
  876. text: 'Please check at least one field to update.'
  877. });
  878. return;
  879. }
  880. formData.append("updateFlags", updateFlags.join(','));
  881. // Hide loader while swal is showing
  882. $('#pageLoader').hide();
  883. Swal.fire({
  884. title: 'Confirm Update',
  885. html: 'You are about to update the following fields:<br><b>' + updateLabels.join(', ') + '</b><br><br>Are you sure?',
  886. icon: 'question',
  887. showCancelButton: true,
  888. confirmButtonText: 'Yes, update it!',
  889. cancelButtonText: 'No, cancel',
  890. allowOutsideClick: false
  891. }).then((result) => {
  892. if (result.isConfirmed) {
  893. $('#pageLoader').show();
  894. $.ajax({
  895. url: '/election/api/pollpersonupdateadmin/selectiveUpdateDetails',
  896. type: 'POST',
  897. data: formData,
  898. enctype: 'multipart/form-data',
  899. processData: false,
  900. contentType: false,
  901. success: function (response) {
  902. $('#pageLoader').hide();
  903. if (response.status) {
  904. Swal.fire({
  905. allowOutsideClick: false,
  906. allowEscapeKey: false,
  907. allowEnterKey: false,
  908. icon: 'success',
  909. title: 'Success',
  910. text: response.description || 'Updated successfully!'
  911. }).then((result) => {
  912. window.location.href = "/election/dataentryadmin/updatepollperson";
  913. });
  914. } else {
  915. $('#pageLoader').hide();
  916. Swal.fire({
  917. icon: 'warning',
  918. title: 'Update Failed',
  919. text: response.description || 'Something went wrong!'
  920. });
  921. }
  922. $('#saveBtn').prop('disabled', false).text('Update');
  923. },
  924. error: function () {
  925. $('#pageLoader').hide();
  926. Swal.fire({
  927. icon: 'error',
  928. title: 'Submission Error',
  929. text: 'Something went wrong while submitting the form.'
  930. });
  931. $('#saveBtn').prop('disabled', false).text('Update');
  932. }
  933. });
  934. } else {
  935. $('#saveBtn').prop('disabled', false).text('Update');
  936. }
  937. });
  938. });
  939. });
  940. function getDesignationDetails(desgId) {
  941. //console.log("desgId="+desgId);
  942. fetch('/election/api/dataentry/batch/getPayDetails?DesgId=' + desgId)
  943. .then(response => response.json())
  944. .then(result => {
  945. if (result.status !== "success") {
  946. console.error("API error:", result.message);
  947. return;
  948. }
  949. let data = result.data; // your pay details row
  950. //console.log("Designation Pay Details:", data);
  951. // Example: set values into input fields
  952. document.getElementById("basic_pay").value = data.basic_pay;
  953. document.getElementById("grade_pay").value = data.grade_pay;
  954. document.getElementById("pay_band").value = data.pay_scale;
  955. })
  956. .catch(error => {
  957. console.error("Error fetching pay details:", error);
  958. });
  959. }
  960. function getOfficeDetails(officeId) {
  961. console.log("officeId=" + officeId);
  962. fetch('/election/api/dataentry/batch/getOfficeDetailsById?officeId=' + officeId)
  963. .then(response => response.json())
  964. .then(result => {
  965. if (result.status !== "success") {
  966. console.error("API error:", result.message);
  967. return;
  968. }
  969. let data = result.data[0];
  970. console.log("office Details:", data);
  971. // Example: set values into input fields
  972. document.getElementById("off_office_name").value = data.office_name;
  973. document.getElementById("off_address1").value = data.address1;
  974. document.getElementById("off_address2").value = data.address2;
  975. document.getElementById("off_address3").value = data.address3;
  976. document.getElementById("off_pincode").value = data.pincode;
  977. document.getElementById("off_phoneno").value = data.phone_no;
  978. document.getElementById("off_taluk").value = data.taluk_name;
  979. document.getElementById("off_govt_type").value = data.govt_type;
  980. document.getElementById("off_pub_sec").value = data.public_sector;
  981. document.getElementById("off_localbody").value = data.local_body;
  982. document.getElementById("off_edu_ins").value = data.edu_institution;
  983. document.getElementById("off_category").value = data.office_category;
  984. document.getElementById("off_assembly").value = data.office_assembly;
  985. })
  986. .catch(error => {
  987. console.error("Error fetching Office details:", error);
  988. });
  989. }
  990. let isRightLoaded = false;
  991. let isLeftLoaded = false;
  992. function hideLoaderIfReady() {
  993. if (isRightLoaded && isLeftLoaded) {
  994. $('#pageLoader').hide();
  995. }
  996. }
  997. function getPollingDetails(slno) {
  998. $('#pageLoader').show();
  999. console.log("slno=" + slno);
  1000. fetch('/election/api/pollpersonupdateadmin/getPollPersonUpdateRequestByReqId?slno=' + slno)
  1001. .then(response => response.json())
  1002. .then(result => {
  1003. if (!result || result.length === 0) {
  1004. console.error("No data found");
  1005. return;
  1006. }
  1007. let data = result[0];
  1008. console.log("Polling Personnel Details:", data);
  1009. window.editDesignationId = data.designation_id;
  1010. window.editHomeDist = data.home_dist;
  1011. window.nativeAcNo = data.native_ac_no;
  1012. window.resideAcNo = data.reside_ac_no;
  1013. window.enrollAcNo = data.elector_ac_no;
  1014. // Example: set values into input fields
  1015. document.getElementById("official_name").value = data.name;
  1016. document.getElementById("epic_name").value = data.name;
  1017. document.getElementById("official_age").value = data.age;
  1018. if (data.sex) {
  1019. let genderValue = data.sex.length > 1 ? data.sex.charAt(0).toUpperCase() : data.sex; // "Male" -> "M"
  1020. const radio = document.querySelector(`input[name="gender"][value="${genderValue}"]`);
  1021. if (radio) radio.checked = true;
  1022. }
  1023. if (window.editDesignationId) {
  1024. $('#design_dropdown').val(window.editDesignationId).trigger('change');
  1025. }
  1026. $('#existing_uniquenum').text(data.slno);
  1027. document.getElementById("res_address1").value = data.address1 ? data.address1 : '';
  1028. document.getElementById("res_address2").value = data.address2 ? data.address2 : '';
  1029. document.getElementById("res_address3").value = data.address3 ? data.address3 : '';
  1030. document.getElementById("res_pincode").value = data.pincode ? data.pincode : '';
  1031. document.getElementById("res_police").value = data.near_policesta ? data.near_policesta : '';
  1032. document.getElementById("res_phoneno").value = data.phone_no ? data.phone_no : '';
  1033. document.getElementById("res_mobile").value = data.mobile_no ? data.mobile_no : '';
  1034. if (window.editHomeDist) {
  1035. $('#nativetaluk_dropdown').val(window.editHomeDist).trigger('change');
  1036. }
  1037. if (window.nativeAcNo) {
  1038. $('#nativeassembly_dropdown').val(window.nativeAcNo).trigger('change');
  1039. }
  1040. if (window.resideAcNo) {
  1041. $('#residentialassembly_dropdown').val(window.resideAcNo).trigger('change');
  1042. }
  1043. if (window.enrollAcNo) {
  1044. $('#enrolledassembly_dropdown').val(window.enrollAcNo).trigger('change');
  1045. }
  1046. document.getElementById("epic_no").value = data.elector_epic_no;
  1047. document.getElementById("part_no").value = data.elector_part_no;
  1048. document.getElementById("si_no").value = data.elector_sl_no;
  1049. if (data.img_full_path) {
  1050. let url = data.img_full_path;
  1051. // Extract full file name (e.g., profile_img_02122025195649_newuser.jpg)
  1052. let fullName = url.substring(url.lastIndexOf("/") + 1);
  1053. // Extract only the part after the last underscore → newuser.jpg
  1054. let filename = fullName.includes("_")
  1055. ? fullName.substring(fullName.lastIndexOf("_") + 1)
  1056. : fullName;
  1057. $("#profileimage_preview")
  1058. .text(filename)
  1059. .show()
  1060. .off("click")
  1061. .on("click", function () {
  1062. $("#modal_profile_image").attr("src", url);
  1063. let modal = new bootstrap.Modal(
  1064. document.getElementById('profileImageModal')
  1065. );
  1066. modal.show();
  1067. });
  1068. } else {
  1069. $("#profileimage_preview").hide().text('');
  1070. }
  1071. })
  1072. .catch(error => {
  1073. console.error("Error fetching Office details:", error);
  1074. })
  1075. .finally(() => {
  1076. isRightLoaded = true;
  1077. hideLoaderIfReady();
  1078. });
  1079. }
  1080. function goback() {
  1081. //window.location.href="/election/dataentry/batches";
  1082. window.history.back();
  1083. }
  1084. function getOriginalPollingDetails(slno) {
  1085. console.log("slno=" + slno);
  1086. fetch('/election/api/pollpersonupdateadmin/getPollPersonUpdateRequestById?slno=' + slno)
  1087. .then(response => response.json())
  1088. .then(result => {
  1089. // Note: the backend returns List<Map<...>> so result is just the array
  1090. // Note: the backend returns List<Map<...>> so result is just the array
  1091. if (!result || result.length === 0) {
  1092. console.error("No data found for original details");
  1093. isLeftLoaded = true;
  1094. hideLoaderIfReady();
  1095. return;
  1096. }
  1097. let data = result[0];
  1098. console.log("Original Polling Personnel Details:", data);
  1099. // Helper function to set values if elements exist
  1100. const setVal = (id, val) => {
  1101. const el = document.getElementById(id);
  1102. if (el) el.value = val !== null ? val : '';
  1103. };
  1104. // Wait slightly for DOM clone to be ready
  1105. setTimeout(() => {
  1106. setVal("ro_batch_no", data.batch_no);
  1107. setVal("ro_official_name", data.name);
  1108. setVal("ro_epic_name", data.name);
  1109. setVal("ro_official_age", data.age);
  1110. if (data.sex) {
  1111. let genderValue = data.sex.length > 1 ? data.sex.charAt(0).toUpperCase() : data.sex; // M / F / T
  1112. const radio = document.querySelector(`input[name="ro_gender"][value="${genderValue}"]`);
  1113. if (radio) radio.checked = true;
  1114. }
  1115. if (data.designation) {
  1116. if ($('#ro_design_dropdown').is('select')) {
  1117. let val = data.designation || '';
  1118. $('#ro_design_dropdown').replaceWith('<input type="text" class="form-control" id="ro_design_dropdown" disabled="disabled" value="' + val + '">');
  1119. } else {
  1120. $('#ro_design_dropdown').val(data.designation);
  1121. }
  1122. }
  1123. setVal("ro_res_address1", data.r_address1);
  1124. setVal("ro_res_address2", data.r_address2);
  1125. setVal("ro_res_address3", data.r_address3);
  1126. setVal("ro_res_pincode", data.r_pincode);
  1127. setVal("ro_res_police", data.r_policest);
  1128. setVal("ro_res_phoneno", data.r_phone_no);
  1129. setVal("ro_res_mobile", data.r_mobile_no);
  1130. if (data.home_dist) {
  1131. $('#ro_nativetaluk_dropdown').val(data.home_dist).trigger('change');
  1132. }
  1133. if (data.native_ac_no) {
  1134. $('#ro_nativeassembly_dropdown').val(data.native_ac_no).trigger('change');
  1135. }
  1136. if (data.reside_ac_no) {
  1137. $('#ro_residentialassembly_dropdown').val(data.reside_ac_no).trigger('change');
  1138. }
  1139. if (data.elector_ac_no) {
  1140. $('#ro_enrolledassembly_dropdown').val(data.elector_ac_no).trigger('change');
  1141. }
  1142. setVal("ro_epic_no", data.elector_epic_no);
  1143. setVal("ro_part_no", data.elector_part_no);
  1144. setVal("ro_si_no", data.elector_sl_no);
  1145. // Populating Office read-only section
  1146. setVal("ro_off_office_name", data.office_name || '');
  1147. setVal("ro_off_address1", data.address1 || '');
  1148. setVal("ro_off_address2", data.address2 || '');
  1149. setVal("ro_off_address3", data.address3 || '');
  1150. setVal("ro_off_pincode", data.pincode || '');
  1151. setVal("ro_off_phoneno", data.phone_no || '');
  1152. if (data.img_full_path) {
  1153. let url = data.img_full_path;
  1154. let fullName = url.substring(url.lastIndexOf("/") + 1);
  1155. let filename = fullName.includes("_")
  1156. ? fullName.substring(fullName.lastIndexOf("_") + 1)
  1157. : fullName;
  1158. $("#ro_profileimage_preview")
  1159. .text(filename)
  1160. .show()
  1161. .off("click")
  1162. .on("click", function () {
  1163. $("#modal_profile_image").attr("src", url);
  1164. let modal = new bootstrap.Modal(
  1165. document.getElementById('profileImageModal')
  1166. );
  1167. modal.show();
  1168. });
  1169. } else {
  1170. $("#ro_profileimage_preview").hide().text('');
  1171. }
  1172. isLeftLoaded = true;
  1173. hideLoaderIfReady();
  1174. }, 800);
  1175. })
  1176. .catch(error => {
  1177. console.error("Error fetching Original details:", error);
  1178. isLeftLoaded = true;
  1179. hideLoaderIfReady();
  1180. });
  1181. }
  1182. </script>
  1183. </body>
  1184. </html>