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.

1211 lines
44 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">
  34. <div class="row">
  35. <div class="card" style="padding: 10px;"><span th:text="${LoginUserId}" style="display:none;" id="userIdSpan"></span>
  36. <form id="newpollingform" enctype="multipart/form-data" >
  37. <div class=" mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  38. <label class="form-label" for="batch_no">Batch No</label>
  39. <input type="text" class="form-control" id="batch_no" readonly>
  40. </div>
  41. <div class=" mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  42. <div class="row" style="row-gap:10px;">
  43. <div id="existing_uniquenum" style="display: none;"></div>
  44. <div class="col-md-8 col-sm-12">
  45. <label class="form-label" for="official_name">Name of the Official<span class="text-danger">*</span></label>
  46. <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">
  47. </div>
  48. <div class="col-md-4 col-sm-12">
  49. <label class="form-label" for="official_age">Age</label>
  50. <input type="number" class="form-control" id="official_age" placeholder="Enter Age">
  51. </div>
  52. <div class="col-md-4 col-sm-12">
  53. <label class="form-label d-block">Sex<span class="text-danger">*</span></label>
  54. <div class="d-flex flex-wrap gap-3">
  55. <div class="form-check me-3">
  56. <input class="form-check-input" type="radio" name="gender" id="genderMale" value="M" required="required">
  57. <label class="form-check-label pr-4" for="genderMale">Male</label>
  58. </div>
  59. <div class="form-check me-3">
  60. <input class="form-check-input" type="radio" name="gender" id="genderFemale" value="F">
  61. <label class="form-check-label pr-4" for="genderFemale">Female</label>
  62. </div>
  63. <div class="form-check">
  64. <input class="form-check-input" type="radio" name="gender" id="genderTransgender" value="T">
  65. <label class="form-check-label pr-4" for="genderTransgender">Transgender</label>
  66. </div>
  67. </div>
  68. </div>
  69. <div class="col-md-4 col-sm-12">
  70. <label class="form-label">Designation<span class="text-danger">*</span></label>
  71. <select id="design_dropdown" class="form-control" required="required">
  72. <option value="">Select</option>
  73. </select>
  74. </div>
  75. <div class="col-md-4 col-sm-12">
  76. <label class="form-label">Upload Photo</label>
  77. <input type="file" class="form-control" id="profileimage" accept=".jpg,.jpeg,image/jpeg" name="profileimage">
  78. <div id="profileimage_preview" class="mt-2" style="cursor:pointer; color:blue; text-decoration:underline;display: none;"></div>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="card-body mb-3" style="border: 1px solid grey;padding: 10px;border-radius: 5px;">
  83. <div class="row" style="row-gap:10px;">
  84. <div class="col-md-4 col-sm-12">
  85. <label class="form-label" for="basic_pay">Basic pay</label>
  86. <input type="text" class="form-control" id="basic_pay" readonly>
  87. </div>
  88. <div class="col-md-4 col-sm-12">
  89. <label class="form-label" for="grade_pay">Grade pay</label>
  90. <input type="text" class="form-control" id="grade_pay" readonly>
  91. </div>
  92. <div class="col-md-4 col-sm-12">
  93. <label class="form-label" for="pay_band">Pay Band</label>
  94. <input type="text" class="form-control" id="pay_band" readonly>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="card-body" style="padding: 10px;">
  99. <div class="row" style="row-gap:10px;">
  100. <div class="col-md-6 col-sm-12">
  101. <div class="card-header bg-dark text-white">
  102. <b>Official Details - Non Editable</b>
  103. </div>
  104. <div class="card-body" style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;">
  105. <label class="form-label" for="off_category">Department</label>
  106. <input type="text" class="form-control mb-3" id="off_category" readonly>
  107. <label class="form-label" for="off_office_name">Office Name</label>
  108. <input type="text" class="form-control mb-3" id="off_office_name" readonly>
  109. <label class="form-label" for="off_address1">Address Line 1</label>
  110. <input type="text" class="form-control mb-3" id="off_address1" readonly>
  111. <label class="form-label" for="off_address2">Address Line 2</label>
  112. <input type="text" class="form-control mb-3" id="off_address2" readonly>
  113. <label class="form-label" for="off_address3">Address Line 3</label>
  114. <input type="text" class="form-control mb-3" id="off_address3" readonly>
  115. <label class="form-label" for="off_pincode">Pincode</label>
  116. <input type="text" class="form-control mb-3" id="off_pincode" readonly>
  117. <label class="form-label" for="off_phoneno">Phone No</label>
  118. <div class="d-flex justify-content-start">
  119. <button class="btn btn-secondary" disabled="disabled" style="height: fit-content">STD</button>
  120. <input type="text" class="form-control mb-3 mx-2" id="off_phoneno" readonly>
  121. </div>
  122. <label class="form-label" for="off_taluk">Taluk Name</label>
  123. <input type="text" class="form-control mb-3" id="off_taluk" readonly>
  124. <label class="form-label" for="off_govt_type">Government Type</label>
  125. <input type="text" class="form-control mb-3" id="off_govt_type" readonly>
  126. <label class="form-label" for="off_pub_sec">Public Sec. Undertaking</label>
  127. <input type="text" class="form-control mb-3" id="off_pub_sec" readonly>
  128. <label class="form-label" for="off_localbody">Local Body</label>
  129. <input type="text" class="form-control mb-3" id="off_localbody" readonly>
  130. <label class="form-label" for="off_edu_ins">Educational Institution</label>
  131. <input type="text" class="form-control mb-3" id="off_edu_ins" readonly>
  132. <label class="form-label" for="off_assembly">Assembly Constituency</label>
  133. <input type="text" class="form-control mb-3" id="off_assembly" readonly>
  134. </div>
  135. </div>
  136. <div class="col-md-6 col-sm-12">
  137. <div class="card-header bg-dark text-white">
  138. <b>Residential Details</b>
  139. </div>
  140. <div class="card-body" style="border: 1px solid grey;border-top-color: white;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;">
  141. <label class="form-label" for="res_address1">House No/ House Name</label>
  142. <input type="text" class="form-control mb-3" id="res_address1">
  143. <label class="form-label" for="res_address2">Street Name/ Area</label>
  144. <input type="text" class="form-control mb-3" id="res_address2">
  145. <label class="form-label" for="res_address3">City</label>
  146. <input type="text" class="form-control mb-3" id="res_address3">
  147. <label class="form-label" for="res_pincode">Pincode</label>
  148. <input type="text" class="form-control mb-3" id="res_pincode">
  149. <label class="form-label" for="res_police">Nearest Police Station</label>
  150. <input type="text" class="form-control mb-3" id="res_police">
  151. <label class="form-label" for="res_phoneno">Phone No</label>
  152. <div class="d-flex justify-content-start">
  153. <button class="btn btn-secondary" disabled="disabled" style="height: fit-content">STD</button>
  154. <input type="text" class="form-control mb-3 mx-2" id="res_phoneno">
  155. </div>
  156. <label class="form-label" for="res_mobile">Mobile</label>
  157. <input type="text" class="form-control mb-3" id="res_mobile">
  158. <div class="mb-3">
  159. <label class="form-label" for="nativetaluk_dropdown">Native Taluk/District</label>
  160. <select id="nativetaluk_dropdown" class="form-control mb-3">
  161. <option value="">Select</option>
  162. </select>
  163. </div>
  164. <div class="mb-3">
  165. <label class="form-label" for="nativeassembly_dropdown">Native Assembly Constituency</label>
  166. <select id="nativeassembly_dropdown" class="form-control mb-3">
  167. <option value="">Select</option>
  168. </select>
  169. </div>
  170. <label class="form-label" for="residentialassembly_dropdown">Residential Assembly Constituency</label>
  171. <select id="residentialassembly_dropdown" class="form-control mb-3">
  172. <option value="">Select</option>
  173. </select>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="card-body mb-3" style="padding: 10px;">
  179. <div style="border: 1px solid grey;border-radius: 5px;">
  180. <div class="row" style="row-gap:10px;">
  181. <div class="col-md-12 col-sm-12">
  182. <div class="card-header">
  183. <b>Enrolled Details</b>
  184. </div>
  185. <div class="card-body">
  186. <div class="row pl-3 pb-2" style="row-gap:10px;">
  187. <span id="epic_verify_link" style="cursor:pointer; color:blue; text-decoration:underline;">
  188. Click here to verify EPIC No <i class="ik ik-external-link"></i>
  189. </span>
  190. </div>
  191. <div class="row" style="row-gap:10px;">
  192. <div class="col-md-6 col-sm-12">
  193. <label class="form-label" for="epic_no">EPIC No</label>
  194. <input type="text" class="form-control" id="epic_no">
  195. </div>
  196. <div class="col-md-6 col-sm-12">
  197. <label class="form-label" for="epic_name">Name</label>
  198. <input type="text" class="form-control" id="epic_name" readonly="readonly">
  199. </div>
  200. <div class="col-md-6 col-sm-12">
  201. <label class="form-label" for="enrolledassembly_dropdown">Enrolled Assembly Constituency</label>
  202. <select id="enrolledassembly_dropdown" class="form-control">
  203. <option value="">Select</option>
  204. </select>
  205. </div>
  206. </div>
  207. <div class="row mt-2" style="row-gap:10px;">
  208. <div class="col-md-6 col-sm-12">
  209. <label class="form-label" for="part_no">Part No</label>
  210. <input type="text" class="form-control" id="part_no">
  211. </div>
  212. <div class="col-md-6 col-sm-12">
  213. <label class="form-label" for="si_no">SI. No</label>
  214. <input type="text" class="form-control" id="si_no">
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. <!-- <div class="col-md-6 col-sm-12">
  220. <div class="card-header">
  221. <b>Experience Questions</b>
  222. </div>
  223. <div class="card-body">
  224. <div class="col-md-12 col-sm-12 mb-2">
  225. <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>
  226. <div class="d-flex flex-wrap gap-3">
  227. <div class="form-check me-3">
  228. <input class="form-check-input" type="radio" name="question1" id="question1" value="Y">
  229. <label class="form-check-label pr-4" for="question1">Yes</label>
  230. </div>
  231. <div class="form-check">
  232. <input class="form-check-input" type="radio" name="question1" id="question1" value="N">
  233. <label class="form-check-label pr-4" for="question1">No</label>
  234. </div>
  235. </div>
  236. <div id="prevElectionDetails" class="mt-2" style="display: none;">
  237. <input type="text" id="previousDetails" class="form-control"
  238. placeholder="Enter PS No, AC No">
  239. </div>
  240. </div>
  241. <div class="col-md-12 col-sm-12 mb-2">
  242. <label class="form-label">Whether the official has previous experience in handling EVMs (Y/N)?</label>
  243. <div class="d-flex flex-wrap gap-3">
  244. <div class="form-check me-3">
  245. <input class="form-check-input" type="radio" name="question2" id="question2" value="Y">
  246. <label class="form-check-label pr-4" for="question2">Yes</label>
  247. </div>
  248. <div class="form-check">
  249. <input class="form-check-input" type="radio" name="question2" id="question2" value="N">
  250. <label class="form-check-label pr-4" for="question2">No</label>
  251. </div>
  252. </div>
  253. </div>
  254. <div class="col-md-12 col-sm-12">
  255. <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>
  256. <div class="d-flex flex-wrap gap-3">
  257. <div class="form-check me-3">
  258. <input class="form-check-input" type="radio" name="question3" id="question3" value="Y">
  259. <label class="form-check-label pr-4" for="question3">Yes</label>
  260. </div>
  261. <div class="form-check">
  262. <input class="form-check-input" type="radio" name="question3" id="question3" value="N">
  263. <label class="form-check-label pr-4" for="question3">No</label>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. </div> -->
  269. </div>
  270. </div>
  271. </div>
  272. <div class="card-body" style="padding: 10px;">
  273. <div class="row" id="btn_container">
  274. <div class="col-12 d-flex justify-content-center">
  275. <button type="button" class="btn btn-secondary mx-2" onclick="goback()">Back</button>
  276. <button type="submit" class="btn btn-primary mx-2" id="saveBtn">Update</button>
  277. </div>
  278. </div>
  279. </div>
  280. </form>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <div class="modal fade" id="profileImageModal" tabindex="-1">
  287. <div class="modal-dialog">
  288. <div class="modal-content">
  289. <div class="modal-header">
  290. <h5 class="modal-title">Profile Photo</h5>
  291. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  292. <span aria-hidden="true">&times;</span>
  293. </button>
  294. </div>
  295. <div class="modal-body text-center">
  296. <img id="modal_profile_image" src="" class="img-fluid rounded" style="max-height:400px;" />
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. <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;">
  302. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  303. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  304. <span class="sr-only">Loading...</span>
  305. </div>
  306. <!-- Add the 'Please wait' text below the spinner -->
  307. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  308. </div>
  309. </div>
  310. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  311. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  312. </div>
  313. </div>
  314. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  315. <script type="text/javascript">
  316. $(document).ready(function() {
  317. let batchId = sessionStorage.getItem("upd_batch_id");
  318. let deptId = sessionStorage.getItem("upd_dept");
  319. let officeId = sessionStorage.getItem("upd_office_id");
  320. let ppn_id = sessionStorage.getItem("upd_id");
  321. // If any ID is missing -> redirect
  322. if (!batchId || !deptId || !officeId || !ppn_id ) {
  323. window.location.href = "/election/dataentryadmin/updation";
  324. }
  325. document.getElementById("batch_no").value = batchId;
  326. // ❗ Remove values IMMEDIATELY so refresh loses them
  327. sessionStorage.removeItem("upd_batch_id");
  328. sessionStorage.removeItem("upd_dept");
  329. sessionStorage.removeItem("upd_office_id");
  330. sessionStorage.removeItem("upd_id");
  331. // Now you can use these values
  332. console.log("Batch:", batchId, "Dept:", deptId, "Office:", officeId);
  333. let designationDropdown = document.getElementById('design_dropdown');
  334. fetch('/election/api/dataentry/batch/getAllDesignations')
  335. .then(response => response.json())
  336. .then(result => {
  337. if (result.status !== "success") {
  338. console.error("API error:", result.message);
  339. return;
  340. }
  341. let list = result.data;
  342. // Clear existing options
  343. designationDropdown.innerHTML = `<option value="">Select</option>`;
  344. // Add options from the API response
  345. list.forEach(design => {
  346. designationDropdown.innerHTML += `
  347. <option value="${design.desig_id}">
  348. ${design.new_designation}
  349. </option>`;
  350. });
  351. // ⭐ Activate Select2 after options added
  352. $('#design_dropdown').select2({
  353. placeholder: "Search designation...",
  354. allowClear: true,
  355. width: "100%"
  356. });
  357. $('#design_dropdown').on('change', function () {
  358. let selectedDesgId = $(this).val();
  359. if (selectedDesgId) {
  360. getDesignationDetails(selectedDesgId);
  361. }
  362. else{
  363. document.getElementById("basic_pay").value = "";
  364. document.getElementById("grade_pay").value = "";
  365. document.getElementById("pay_band").value = "";
  366. }
  367. });
  368. // PRESELECT designation from API (edit mode)
  369. if (window.editDesignationId) {
  370. $('#design_dropdown').val(window.editDesignationId).trigger('change');
  371. }
  372. })
  373. .catch(error => {
  374. console.error('Error fetching designation:', error);
  375. });
  376. let NativeTaulkDropdown = document.getElementById('nativetaluk_dropdown');
  377. fetch('/election/api/dataentry/batch/getAllDistricts')
  378. .then(response => response.json())
  379. .then(result => {
  380. if (result.status !== "success") {
  381. console.error("API error:", result.message);
  382. return;
  383. }
  384. let list = result.data;
  385. NativeTaulkDropdown.innerHTML = `<option value="">Select</option>`;
  386. // Add options from the API response
  387. list.forEach(nativedis => {
  388. NativeTaulkDropdown.innerHTML += `
  389. <option value="${nativedis.dist_no}">
  390. ${nativedis.dist_name}
  391. </option>`;
  392. });
  393. $('#nativetaluk_dropdown').select2({
  394. placeholder: "Search",
  395. allowClear: true,
  396. width: "100%"
  397. });
  398. if (window.editHomeDist) {
  399. $('#nativetaluk_dropdown').val(window.editHomeDist).trigger('change');
  400. }
  401. })
  402. .catch(error => {
  403. console.error('Error fetching in District :', error);
  404. });
  405. let NativeAcDropdown = document.getElementById('nativeassembly_dropdown');
  406. let ResiAcDropdown = document.getElementById('residentialassembly_dropdown');
  407. let EnrollAsDropdown = document.getElementById('enrolledassembly_dropdown');
  408. function loadOptions(dropdown, list) {
  409. dropdown.innerHTML = `<option value="">Select</option>`;
  410. list.forEach(item => {
  411. dropdown.innerHTML += `
  412. <option value="${item.ac_no}">
  413. ${item.ac_name}
  414. </option>`;
  415. });
  416. }
  417. fetch('/election/api/dataentry/batch/getAllAclist')
  418. .then(response => response.json())
  419. .then(result => {
  420. if (result.status !== "success") {
  421. console.error("API error:", result.message);
  422. return;
  423. }
  424. let list = result.data;
  425. // Load all three dropdowns using same function
  426. loadOptions(NativeAcDropdown, list);
  427. loadOptions(ResiAcDropdown, list);
  428. loadOptions(EnrollAsDropdown, list);
  429. $('#nativeassembly_dropdown, #residentialassembly_dropdown, #enrolledassembly_dropdown').select2({
  430. placeholder: "Search",
  431. allowClear: true,
  432. width: "100%"
  433. });
  434. // PRESELECT VALUES (ONLY IF NOT NULL)
  435. if (window.nativeAcNo) {
  436. $('#nativeassembly_dropdown').val(window.nativeAcNo).trigger('change');
  437. }
  438. if (window.resideAcNo) {
  439. $('#residentialassembly_dropdown').val(window.resideAcNo).trigger('change');
  440. }
  441. if (window.enrollAcNo) {
  442. $('#enrolledassembly_dropdown').val(window.enrollAcNo).trigger('change');
  443. }
  444. })
  445. .catch(error => {
  446. console.error('Error fetching Assembly Constituency:', error);
  447. });
  448. /* document.querySelectorAll('input[name="question1"]').forEach(function(radio) {
  449. radio.addEventListener("change", function() {
  450. if (this.value === "Y") {
  451. document.getElementById("prevElectionDetails").style.display = "block";
  452. } else {
  453. document.getElementById("prevElectionDetails").style.display = "none";
  454. document.getElementById("previousDetails").value = ""; // clear text
  455. }
  456. });
  457. }); */
  458. document.getElementById("official_name").addEventListener("input", function () {
  459. document.getElementById("epic_name").value = this.value;
  460. });
  461. document.getElementById("epic_verify_link").addEventListener("click", function () {
  462. window.open("https://electoralsearch.eci.gov.in/", "_blank");
  463. });
  464. getOfficeDetails(officeId);
  465. getPollingDetails(ppn_id);
  466. $('#profileimage').on('input', function () {
  467. let fileInput = this;
  468. let file = fileInput.files[0];
  469. // Allowed extensions
  470. let allowedExtensions = /(\.jpg|\.jpeg)$/i;
  471. // File name
  472. let fileName = file.name;
  473. // File size (10 MB = 10 * 1024 * 1024)
  474. let maxSize = 10 * 1024 * 1024;
  475. // 1) Validate extension
  476. if (!allowedExtensions.test(fileName)) {
  477. Swal.fire({
  478. icon: 'error',
  479. title: 'Invalid File Type',
  480. text: 'Only JPG / JPEG images are allowed!'
  481. });
  482. fileInput.value = ""; // Reset file
  483. return;
  484. }
  485. // 2) Validate MIME type
  486. if (file.type !== "image/jpeg") {
  487. Swal.fire({
  488. icon: 'error',
  489. title: 'Invalid Image Format',
  490. text: 'Only JPEG images are allowed!'
  491. });
  492. fileInput.value = "";
  493. return;
  494. }
  495. // 3) Validate size
  496. if (file.size > maxSize) {
  497. Swal.fire({
  498. icon: 'error',
  499. title: 'File Too Large',
  500. text: 'File size must be 10 MB or less!'
  501. });
  502. fileInput.value = "";
  503. return;
  504. }
  505. });
  506. $('#res_pincode').on('input', function () {
  507. // Remove anything that is not a digit
  508. this.value = this.value.replace(/\D/g, '');
  509. // Limit to max 6 digits
  510. if (this.value.length > 6) {
  511. this.value = this.value.slice(0, 6);
  512. }
  513. });
  514. // PHONE NO: 8 to 10 digits
  515. $('#res_phoneno').on('input', function () {
  516. // Allow only digits
  517. this.value = this.value.replace(/\D/g, '');
  518. // Max 10 digits
  519. if (this.value.length > 10) {
  520. this.value = this.value.slice(0, 10);
  521. }
  522. });
  523. // MOBILE NO: exactly 10 digits
  524. $('#res_mobile').on('input', function () {
  525. // Allow only digits
  526. this.value = this.value.replace(/\D/g, '');
  527. // Max 10 digits
  528. if (this.value.length > 10) {
  529. this.value = this.value.slice(0, 10);
  530. }
  531. });
  532. // PART NO: 6 digits only
  533. $('#part_no').on('input', function () {
  534. this.value = this.value.replace(/\D/g, ''); // allow digits only
  535. if (this.value.length > 6) {
  536. this.value = this.value.slice(0, 6);
  537. }
  538. });
  539. // SI NO: 6 digits only
  540. $('#si_no').on('input', function () {
  541. this.value = this.value.replace(/\D/g, ''); // allow digits only
  542. if (this.value.length > 6) {
  543. this.value = this.value.slice(0, 6); // max 6 digits
  544. }
  545. });
  546. $('#epic_no').on('input', function () {
  547. // Allow only A–Z, a–z, 0–9
  548. this.value = this.value.replace(/[^A-Za-z0-9]/g, '');
  549. // Limit to 16 characters
  550. if (this.value.length > 16) {
  551. this.value = this.value.slice(0, 16);
  552. }
  553. });
  554. $('#newpollingform').submit(function (e) {
  555. e.preventDefault();
  556. let formData = new FormData(this);
  557. $('#saveBtn').prop('disabled', true).text('Updating...');
  558. $('#pageLoader').show();
  559. function setIfPresent(formData, key, value) {
  560. if (value !== undefined && value !== null && value !== "") {
  561. formData.set(key, value);
  562. }
  563. }
  564. function setFileIfPresent(formData, key, fileInput) {
  565. if (fileInput && fileInput.files && fileInput.files.length > 0) {
  566. formData.set(key, fileInput.files[0]);
  567. }
  568. }
  569. let userId = document.getElementById('userIdSpan').textContent;
  570. let batch_no = $('#batch_no').val().trim();
  571. let official_name = $('#official_name').val().trim();
  572. let official_age = $('#official_age').val().trim();
  573. // Convert to number
  574. let ageNum = parseInt(official_age, 10);
  575. // Validate age
  576. if(official_age){
  577. if (isNaN(ageNum) || ageNum < 18 || ageNum > 65) {
  578. $('#pageLoader').hide();
  579. $('#saveBtn').prop('disabled', false).text('Update');
  580. Swal.fire({
  581. icon: 'warning',
  582. title: 'Invalid Age',
  583. text: 'Age must be between 18 and 65'
  584. });
  585. return;
  586. }
  587. }
  588. let gender = $("input[name='gender']:checked").val();
  589. let design_id=$('#design_dropdown').val();
  590. let design_name = $('#design_dropdown option:selected').text();
  591. let respincode=$('#res_pincode').val().trim();
  592. if(respincode){
  593. // Rule 1: Must be exactly 6 digits & should NOT start with 0
  594. if (!/^[1-9][0-9]{5}$/.test(respincode)) {
  595. $('#pageLoader').hide();
  596. $('#saveBtn').prop('disabled', false).text('Update');
  597. Swal.fire({
  598. icon: 'warning',
  599. title: 'Invalid Pincode',
  600. text: 'Pincode must be 6 digits and cannot start with 0.'
  601. });
  602. return;
  603. }
  604. // Rule 2: Reject 123456 (sequential)
  605. if (respincode === "123456") {
  606. $('#pageLoader').hide();
  607. $('#saveBtn').prop('disabled', false).text('Update');
  608. Swal.fire({
  609. icon: 'warning',
  610. title: 'Invalid Pincode',
  611. text: 'Sequential numbers like 123456 are not allowed.'
  612. });
  613. return;
  614. }
  615. // Rule 3: Reject all digits same (111111, 222222, etc.)
  616. if (/^(\d)\1{5}$/.test(respincode)) {
  617. $('#pageLoader').hide();
  618. $('#saveBtn').prop('disabled', false).text('Update');
  619. Swal.fire({
  620. icon: 'warning',
  621. title: 'Invalid Pincode',
  622. text: 'All digits cannot be the same.'
  623. });
  624. return;
  625. }
  626. }
  627. let phnumber=$('#res_phoneno').val().trim();
  628. if(phnumber){
  629. // Validate 8 to 10 digits only
  630. if (!/^\d{8,10}$/.test(phnumber)) {
  631. $('#pageLoader').hide();
  632. $('#saveBtn').prop('disabled', false).text('Update');
  633. Swal.fire({
  634. icon: 'warning',
  635. title: 'Invalid Phone Number',
  636. text: 'Phone number must be 8 to 10 digits.'
  637. });
  638. return;
  639. }
  640. }
  641. let mobnumber=$('#res_mobile').val().trim();
  642. if(mobnumber){
  643. // Rule 1: Must be exactly 10 digits & must not start with 0
  644. if (!/^[1-9][0-9]{9}$/.test(mobnumber)) {
  645. $('#pageLoader').hide();
  646. $('#saveBtn').prop('disabled', false).text('Update');
  647. Swal.fire({
  648. icon: 'warning',
  649. title: 'Invalid Mobile Number',
  650. text: 'Mobile number must be 10 digits and cannot start with 0.'
  651. });
  652. return;
  653. }
  654. // Rule 2: Reject sequential numbers like 1234567890
  655. if (mobnumber === "1234567890") {
  656. $('#pageLoader').hide();
  657. $('#saveBtn').prop('disabled', false).text('Update');
  658. Swal.fire({
  659. icon: 'warning',
  660. title: 'Invalid Mobile Number',
  661. text: 'Sequential numbers like 1234567890 are not allowed.'
  662. });
  663. return;
  664. }
  665. // Rule 3: Reject all digits same (1111111111, 2222222222, etc.)
  666. if (/^(\d)\1{9}$/.test(mobnumber)) {
  667. $('#pageLoader').hide();
  668. $('#saveBtn').prop('disabled', false).text('Update');
  669. Swal.fire({
  670. icon: 'warning',
  671. title: 'Invalid Mobile Number',
  672. text: 'All digits cannot be the same.'
  673. });
  674. return;
  675. }
  676. }
  677. let native_taluk=$('#nativetaluk_dropdown').val();
  678. let native_ac=$('#nativeassembly_dropdown').val();
  679. let res_ac=$('#residentialassembly_dropdown').val();
  680. let enrol_ac=$('#enrolledassembly_dropdown').val();
  681. let epic_no = $('#epic_no').val().trim();
  682. // updated
  683. if (epic_no) {
  684. // Allow 8 to 16 alphanumeric characters
  685. let epicPattern = /^[A-Za-z0-9]{8,16}$/;
  686. if (!epicPattern.test(epic_no)) {
  687. $('#pageLoader').hide();
  688. $('#saveBtn').prop('disabled', false).text('Save');
  689. Swal.fire({
  690. icon: 'warning',
  691. title: 'Invalid EPIC Number',
  692. text: 'EPIC number must be 8 to 16 alphanumeric characters.'
  693. });
  694. return;
  695. }
  696. }
  697. /* if(epic_no){
  698. // Allow only 16 alphanumeric characters
  699. let epicPattern = /^[A-Za-z0-9]{16}$/;
  700. if (!epicPattern.test(epic_no)) {
  701. $('#pageLoader').hide();
  702. $('#saveBtn').prop('disabled', false).text('Update');
  703. Swal.fire({
  704. icon: 'warning',
  705. title: 'Invalid EPIC Number',
  706. text: 'EPIC number must be exactly 16 alphanumeric characters.'
  707. });
  708. return;
  709. }
  710. }*/
  711. let part_no =$('#part_no').val().trim();
  712. let si_no = $('#si_no').val().trim();
  713. if(part_no){
  714. // Validate part_no
  715. if (part_no.length > 6) {
  716. $('#pageLoader').hide();
  717. $('#saveBtn').prop('disabled', false).text('Save');
  718. Swal.fire({
  719. icon: 'warning',
  720. title: 'Invalid Part No',
  721. text: 'Maximum 6 digits allowed for Part No.'
  722. });
  723. return;
  724. }
  725. }
  726. if(si_no){
  727. // Validate si_no
  728. if (si_no.length > 6) {
  729. $('#pageLoader').hide();
  730. $('#saveBtn').prop('disabled', false).text('Save');
  731. Swal.fire({
  732. icon: 'warning',
  733. title: 'Invalid Sl. No',
  734. text: 'Maximum 6 digits allowed for Sl No.'
  735. });
  736. return;
  737. }
  738. }
  739. /* let question1 = $("input[name='question1']:checked").val();
  740. if(question1){
  741. let previousDetails=$('#previousDetails').val().trim();
  742. if(!previousDetails){
  743. $('#pageLoader').hide();
  744. $('#saveBtn').prop('disabled', false).text('Save');
  745. Swal.fire({
  746. icon: 'warning',
  747. title: 'Validation Error',
  748. text: 'Enter PS No,AC No'
  749. });
  750. return;
  751. }
  752. }
  753. let question2 = $("input[name='question2']:checked").val();
  754. let question3 = $("input[name='question3']:checked").val(); */
  755. setFileIfPresent(formData, "pp_image", $('#profileimage')[0]);
  756. setIfPresent(formData, "nppid", ppn_id);
  757. formData.append("userid", userId);
  758. let existing_uniquenum = $('#existing_uniquenum').text();
  759. formData.append("slno", existing_uniquenum);
  760. setIfPresent(formData, "pBatchId", batch_no);
  761. setIfPresent(formData, "DeptId", deptId);
  762. setIfPresent(formData, "officeId", officeId);
  763. setIfPresent(formData, "pName", official_name);
  764. setIfPresent(formData, "pAge", official_age);
  765. setIfPresent(formData, "pGender", gender || "");
  766. setIfPresent(formData, "DesignationId",design_id);
  767. setIfPresent(formData, "Designation", design_name);
  768. setIfPresent(formData, "address1", $('#res_address1').val().trim());
  769. setIfPresent(formData, "address2", $('#res_address2').val().trim());
  770. setIfPresent(formData, "address3", $('#res_address3').val().trim());
  771. setIfPresent(formData, "pincode",respincode);
  772. setIfPresent(formData, "policest", $('#res_police').val().trim());
  773. setIfPresent(formData, "phoneno",phnumber);
  774. setIfPresent(formData, "mobileno",mobnumber);
  775. setIfPresent(formData, "district",native_taluk);
  776. setIfPresent(formData, "nativeac",native_ac);
  777. setIfPresent(formData, "resideac",res_ac);
  778. setIfPresent(formData, "electoracno",enrol_ac);
  779. setIfPresent(formData, "electorpartno",part_no );
  780. setIfPresent(formData, "electorslno", si_no);
  781. setIfPresent(formData, "epicno",epic_no);
  782. /* setIfPresent(formData, "officiated", question1);
  783. setIfPresent(formData, "officiateddet", $('#previousDetails').val().trim());
  784. setIfPresent(formData, "evmexperience", question2);
  785. setIfPresent(formData, "disaqualified", question3); */
  786. $.ajax({
  787. url: '/election/api/dataentry/update/updateppdetailsbyid',
  788. type: 'POST',
  789. data: formData,
  790. enctype: 'multipart/form-data',
  791. processData: false,
  792. contentType: false,
  793. success: function (response) {
  794. $('#pageLoader').hide();
  795. if (response.status) {
  796. Swal.fire({
  797. allowOutsideClick: false,
  798. allowEscapeKey: false,
  799. allowEnterKey: false,
  800. icon: 'success',
  801. title: 'Success',
  802. text:response.description
  803. }).then((result) => {
  804. window.location.href="/election/dataentryadmin/updation";
  805. });
  806. } else {
  807. $('#pageLoader').hide();
  808. Swal.fire({
  809. icon: 'warning',
  810. title: 'Update Failed',
  811. text: response.description || 'Something went wrong!'
  812. });
  813. }
  814. $('#saveBtn').prop('disabled', false).text('Update');
  815. },
  816. error: function () {
  817. $('#pageLoader').hide();
  818. Swal.fire({
  819. icon: 'error',
  820. title: 'Submission Error',
  821. text: 'Something went wrong while submitting the form.'
  822. });
  823. $('#saveBtn').prop('disabled', false).text('Update');
  824. }
  825. });
  826. });
  827. });
  828. function getDesignationDetails(desgId) {
  829. //console.log("desgId="+desgId);
  830. fetch('/election/api/dataentry/batch/getPayDetails?DesgId=' + desgId)
  831. .then(response => response.json())
  832. .then(result => {
  833. if (result.status !== "success") {
  834. console.error("API error:", result.message);
  835. return;
  836. }
  837. let data = result.data; // your pay details row
  838. //console.log("Designation Pay Details:", data);
  839. // Example: set values into input fields
  840. document.getElementById("basic_pay").value = data.basic_pay;
  841. document.getElementById("grade_pay").value = data.grade_pay;
  842. document.getElementById("pay_band").value = data.pay_scale;
  843. })
  844. .catch(error => {
  845. console.error("Error fetching pay details:", error);
  846. });
  847. }
  848. function getOfficeDetails(officeId) {
  849. console.log("officeId="+officeId);
  850. fetch('/election/api/dataentry/batch/getOfficeDetailsById?officeId=' + officeId)
  851. .then(response => response.json())
  852. .then(result => {
  853. if (result.status !== "success") {
  854. console.error("API error:", result.message);
  855. return;
  856. }
  857. let data = result.data[0];
  858. console.log("office Details:", data);
  859. // Example: set values into input fields
  860. document.getElementById("off_office_name").value = data.office_name;
  861. document.getElementById("off_address1").value = data.address1;
  862. document.getElementById("off_address2").value = data.address2;
  863. document.getElementById("off_address3").value = data.address3;
  864. document.getElementById("off_pincode").value = data.pincode;
  865. document.getElementById("off_phoneno").value = data.phone_no;
  866. document.getElementById("off_taluk").value = data.taluk_name;
  867. document.getElementById("off_govt_type").value = data.govt_type;
  868. document.getElementById("off_pub_sec").value = data.public_sector;
  869. document.getElementById("off_localbody").value = data.local_body;
  870. document.getElementById("off_edu_ins").value = data.edu_institution;
  871. document.getElementById("off_category").value = data.office_category;
  872. document.getElementById("off_assembly").value = data.office_assembly;
  873. })
  874. .catch(error => {
  875. console.error("Error fetching Office details:", error);
  876. });
  877. }
  878. function getPollingDetails(ppn_id){
  879. $('#pageLoader').show();
  880. console.log("ppn_id="+ppn_id);
  881. fetch('/election/api/dataentry/update/getPollingDetailsById?id=' + ppn_id)
  882. .then(response => response.json())
  883. .then(result => {
  884. if (result.status !== "success") {
  885. console.error("API error:", result.message);
  886. return;
  887. }
  888. let data = result.data[0];
  889. console.log("Polling Personnel Details:", data);
  890. window.editDesignationId = data.designation_id;
  891. window.editHomeDist = data.home_dist;
  892. window.nativeAcNo = data.native_ac_no;
  893. window.resideAcNo = data.reside_ac_no;
  894. window.enrollAcNo = data.elector_ac_no;
  895. // Example: set values into input fields
  896. document.getElementById("official_name").value = data.name;
  897. document.getElementById("epic_name").value = data.name;
  898. document.getElementById("official_age").value = data.age;
  899. if (data.sex) {
  900. let genderValue = data.sex; // M / F / T
  901. const radio = document.querySelector(`input[name="gender"][value="${genderValue}"]`);
  902. if (radio) radio.checked = true;
  903. }
  904. if (window.editDesignationId) {
  905. $('#design_dropdown').val(window.editDesignationId).trigger('change');
  906. }
  907. $('#existing_uniquenum').text(data.slno);
  908. document.getElementById("res_address1").value = data.r_address1;
  909. document.getElementById("res_address2").value = data.r_address2;
  910. document.getElementById("res_address3").value = data.r_address3;
  911. document.getElementById("res_pincode").value = data.r_pincode;
  912. document.getElementById("res_police").value = data.r_policest;
  913. document.getElementById("res_phoneno").value = data.r_phone_no;
  914. document.getElementById("res_mobile").value = data.r_mobile_no;
  915. if (window.editHomeDist) {
  916. $('#nativetaluk_dropdown').val(window.editHomeDist).trigger('change');
  917. }
  918. if (window.nativeAcNo) {
  919. $('#nativeassembly_dropdown').val(window.nativeAcNo).trigger('change');
  920. }
  921. if (window.resideAcNo) {
  922. $('#residentialassembly_dropdown').val(window.resideAcNo).trigger('change');
  923. }
  924. if (window.enrollAcNo) {
  925. $('#enrolledassembly_dropdown').val(window.enrollAcNo).trigger('change');
  926. }
  927. document.getElementById("epic_no").value = data.elector_epic_no;
  928. document.getElementById("part_no").value = data.elector_part_no;
  929. document.getElementById("si_no").value = data.elector_sl_no;
  930. if (data.img_full_path) {
  931. let url = data.img_full_path;
  932. // Extract full file name (e.g., profile_img_02122025195649_newuser.jpg)
  933. let fullName = url.substring(url.lastIndexOf("/") + 1);
  934. // Extract only the part after the last underscore → newuser.jpg
  935. let filename = fullName.includes("_")
  936. ? fullName.substring(fullName.lastIndexOf("_") + 1)
  937. : fullName;
  938. $("#profileimage_preview")
  939. .text(filename)
  940. .show()
  941. .off("click")
  942. .on("click", function () {
  943. $("#modal_profile_image").attr("src", url);
  944. let modal = new bootstrap.Modal(
  945. document.getElementById('profileImageModal')
  946. );
  947. modal.show();
  948. });
  949. } else {
  950. $("#profileimage_preview").hide().text('');
  951. }
  952. })
  953. .catch(error => {
  954. console.error("Error fetching Office details:", error);
  955. })
  956. .finally(() => {
  957. $('#pageLoader').hide(); // ALWAYS hide loader
  958. });
  959. }
  960. function goback(){
  961. //window.location.href="/election/dataentry/batches";
  962. window.history.back();
  963. }
  964. </script>
  965. </body>
  966. </html>