This portal only for GCC Officers. Based on there roles and Group ID they can view there module`s Like PGR, QR Public Asset Feedback, Makkalai Thedi Mayor,etc...
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.

704 lines
31 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}"></head>
  4. <style>
  5. .required{
  6. color: red;
  7. }
  8. /* Mobile screens - targeting devices with a max width of 767px */
  9. @media (max-width: 767px)
  10. {
  11. #campaignrequestform label{
  12. margin-top: 10px;
  13. }
  14. }
  15. </style>
  16. <body>
  17. <!--[if lt IE 8]>
  18. <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  19. <![endif]-->
  20. <div class="wrapper">
  21. <!-- header top menu Start -->
  22. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  23. <!-- header top menu end -->
  24. <div class="page-wrap">
  25. <!--=============== Left Menu side Start ================-->
  26. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  27. <!--=============== Left side End ================-->
  28. <div class="main-content">
  29. <div class="container-fluid">
  30. <div class="page-header mb-2">
  31. <div class="row align-items-end">
  32. <div class="col-lg-8">
  33. <div class="page-header-title">
  34. <i class="far fa-calendar-plus bg-blue"></i>
  35. <div class="d-inline">
  36. <h5>Create Campaign</h5>
  37. <span>1913 Campaign creation</span>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="col-lg-4">
  42. <nav class="breadcrumb-container" aria-label="breadcrumb">
  43. <ol class="breadcrumb">
  44. <li class="breadcrumb-item"><a href="index"><i
  45. class="ik ik-home"></i></a></li>
  46. <li class="breadcrumb-item" aria-current="page">1913 Campaign</li>
  47. <li class="breadcrumb-item active" aria-current="page">Create Campaign</li>
  48. </ol>
  49. </nav>
  50. </div>
  51. </div>
  52. </div>
  53. <h4 class="h4 text-right text-mute" style="font-size: 12px;">
  54. Auot refresh in <font id="refresh-countdown">00</font> seconds
  55. </h4>
  56. <div class="row">
  57. <div class="col-md-12">
  58. <div class="card" style="margin-top: 0px;">
  59. <div class="card-header justify-content-between align-items-center">
  60. <h3><b>Campaign Request Form</b></h3>
  61. <button type="button" class="btn btn-warning btn-sm" id="downloadExcel"><i class="ik ik-download f-16 mr-2"></i>Template Download</button>
  62. </div>
  63. <div class="card-body">
  64. <form id="campaignrequestform">
  65. <div class="form-group">
  66. <div class="row">
  67. <div class="col-sm-12 col-md-6">
  68. <label for="name">Name<span class="required">*</span></label>
  69. <input type="text" class="form-control" id="name" placeholder="Enter Name">
  70. </div>
  71. <div class="col-sm-12 col-md-6">
  72. <label for="category">Category<span class="required">*</span></label>
  73. <select class="form-control" id="category">
  74. <option selected value="0">Select category</option>
  75. </select>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="form-group">
  80. <label><b><u>Event Date:</u></b></label>
  81. <div class="row">
  82. <div class="col-sm-12 col-md-6">
  83. <label for="eventstartdate">From Date<span class="required">*</span></label>
  84. <input type="date" class="form-control" id="eventstartdate">
  85. </div>
  86. <div class="col-sm-12 col-md-6">
  87. <label for="eventenddate">To Date<span class="required">*</span></label>
  88. <input type="date" class="form-control" id="eventenddate">
  89. </div>
  90. </div>
  91. </div>
  92. <div class="form-group">
  93. <div class="row">
  94. <div class="col-sm-12 col-md-6">
  95. <label for="no_of_agent">No of Agents to be Assigned<span class="required">*</span></label>
  96. <input type="number" class="form-control" id="no_of_agent">
  97. </div>
  98. <div class="col-sm-12 col-md-6">
  99. <label for="no_of_calls">No of Calls to be Assigned (per Person)<span class="required">*</span></label>
  100. <input type="number" class="form-control" id="no_of_calls">
  101. </div>
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <label for="description">Description<span class="required">*</span></label>
  106. <textarea class="form-control" id="description" rows="2"></textarea>
  107. </div>
  108. <div class="form-group">
  109. <label for="upload">Upload Excelsheet:<span class="required">*</span></label>
  110. <input type="file" class="form-control" id="fileInput">
  111. <small id="fileError" class="text-danger" style="display:none;">Only Excel files (.xlsx, .xls) are allowed.</small>
  112. </div>
  113. <div class="form-group text-center">
  114. <button type="submit" class="btn btn-primary " id="requestsubmit">Submit</button>
  115. <button type="reset" class="btn btn-secondary ml-2" onclick="resetForm()">Reset</button>
  116. </div>
  117. </form>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="col-md-12">
  122. <div class="card">
  123. <div class="card-block">
  124. <div class="page-header-title" >
  125. <h5 style="margin: 0;font-weight: bold;">Campaign Details</h5><hr>
  126. </div>
  127. <div>
  128. <table id="CampaignDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid">
  129. <thead class="thead-dark">
  130. <tr role="row">
  131. <th class="text-center">S.No</th>
  132. <th class="text-center">Name</th>
  133. <th class="text-center">Event Date</th>
  134. <th class="text-center">Description</th>
  135. <th class="text-center">Agents Assigned</th>
  136. <th class="text-center">Calls per Person</th>
  137. <th class="text-center">Total Calls</th>
  138. <th class="text-center no-sort" width="%2">Action</th>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. <tr th:each="campaign, i: ${campaigns}">
  143. <td th:text="${i.count}">0</td>
  144. <td th:text="${campaign.campaign_name}"></td>
  145. <td th:text="${campaign.event_dates}"></td>
  146. <td th:text="${campaign.description}"></td>
  147. <td th:text="${campaign.no_of_agents}" class="text-center"></td>
  148. <td th:text="${campaign.calls_per_agent}" class="text-center"></td>
  149. <td th:text="${campaign.total_calls}" class="text-center"></td>
  150. <td class="text-center">
  151. <a href="#" th:onclick="return callEdit([[${campaign.campaign_id}]])" data-animation="true" data-toggle="tooltip" data-placement="top" title="Edit" data-original-title="Edit">
  152. <i class="ik ik-edit f-16 mr-15 text-green"></i>
  153. </a>
  154. </td>
  155. </tr>
  156. </tbody>
  157. <tfoot class="thead-dark">
  158. <tr>
  159. <th class="text-center">S.No</th>
  160. <th class="text-center">Name</th>
  161. <th class="text-center">Event Date</th>
  162. <th class="text-center">Description</th>
  163. <th class="text-center">Agents Assigned</th>
  164. <th class="text-center">Calls per Person</th>
  165. <th class="text-center">Total Calls</th>
  166. <th class="text-center no-sort" width="%2">Action</th>
  167. </tr>
  168. </tfoot>
  169. </table>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  178. </div>
  179. </div>
  180. <!-- The Modal -->
  181. <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
  182. <div class="modal-dialog modal-lg" role="document">
  183. <div class="modal-content">
  184. <div class="modal-header">
  185. <h5 class="modal-title" id="editModalLabel">Edit Campaign</h5>
  186. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  187. <span aria-hidden="true">&times;</span>
  188. </button>
  189. </div>
  190. <div class="modal-body">
  191. <!-- Your form or content for editing can go here -->
  192. <form id="editForm" onsubmit="submitForm(event)" >
  193. <input type="hidden" name="campaign_id" id="campaign_id" />
  194. <div class="form-group">
  195. <label for="campaign_name">Name<span class="required">*</span></label>
  196. <input type="text" class="form-control" id="campaign_name" placeholder="Enter Name" readonly="readonly">
  197. </div>
  198. <div class="form-group">
  199. <label><b><u>Event Date:</u></b></label>
  200. <div class="row">
  201. <div class="col">
  202. <label for="start_date">From Date<span class="required">*</span></label>
  203. <input type="date" class="form-control" id="start_date" onchange="setEndDateMin()" readonly="readonly" >
  204. </div>
  205. <div class="col">
  206. <label for="end_date">To Date<span class="required">*</span></label>
  207. <input type="date" class="form-control" id="end_date" required>
  208. </div>
  209. </div>
  210. </div>
  211. <div class="form-group">
  212. <div class="row">
  213. <div class="col">
  214. <label for="no_of_agents">No of Agents to be Assigned<span class="required">*</span></label>
  215. <input type="number" class="form-control" id="no_of_agents" required>
  216. </div>
  217. <div class="col">
  218. <label for="calls_per_agent">No of Calls to be Assigned (per Person)<span class="required">*</span></label>
  219. <input type="number" class="form-control" id="calls_per_agent" required>
  220. </div>
  221. </div>
  222. </div>
  223. <div class="form-group">
  224. <label for="description_modal">Description<span class="required">*</span></label>
  225. <textarea class="form-control" id="description_modal" rows="2" readonly="readonly"></textarea>
  226. </div>
  227. <div class="form-group text-center">
  228. <button type="submit" class="btn btn-primary" id="editsubmit">Save changes</button>
  229. </div>
  230. </form>
  231. </div>
  232. </div>
  233. </div>
  234. </div>
  235. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  236. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  237. <script src="node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script>
  238. <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
  239. <script type="text/javascript">
  240. $(document).ready(function() {
  241. var table = $('#CampaignDatatable').DataTable({
  242. dom: 'Bftip',
  243. columnDefs: [
  244. { targets: 'no-sort', orderable: false }
  245. ],
  246. lengthMenu: [
  247. [50, 100, 200, 500, -1],
  248. ['50 rows', '100 rows', '200 rows', 'Show all']
  249. ],
  250. scrollY: '50vh',
  251. fixedColumns: {
  252. left: 1,
  253. right: 1
  254. },
  255. buttons: [
  256. {
  257. extend: 'pageLength',
  258. className: 'btn btn-warning'
  259. },
  260. {
  261. title: 'Data export',
  262. extend: 'copyHtml5',
  263. text: 'Copy',
  264. className: 'btn btn-secondary',
  265. id: 'copyBtn'
  266. },
  267. {
  268. extend: 'excelHtml5',
  269. text: 'Excel',
  270. className: 'btn btn-secondary',
  271. id: 'excelBtn'
  272. },
  273. {
  274. extend: 'csvHtml5',
  275. text: 'CSV',
  276. className: 'btn btn-secondary',
  277. id: 'csvBtn'
  278. },
  279. {
  280. extend: 'pdfHtml5',
  281. text: 'PDF',
  282. className: 'btn btn-secondary',
  283. id: 'pdfBtn'
  284. }
  285. ],
  286. fixedHeader: true,
  287. autoWidth: true,
  288. responsive: true,
  289. searching: false,
  290. select: false,
  291. processing: false
  292. });
  293. });
  294. document.addEventListener('DOMContentLoaded', function() {
  295. const fromDate = document.getElementById('eventstartdate');
  296. const toDate = document.getElementById('eventenddate');
  297. // Initially disable the "To Date" field
  298. toDate.disabled = true;
  299. fromDate.addEventListener('change', function() {
  300. if (fromDate.value) {
  301. // Enable the "To Date" field when "From Date" is selected
  302. toDate.disabled = false;
  303. // Get the selected "From Date"
  304. const selectedFromDate = new Date(fromDate.value);
  305. // Set the "To Date" minimum to the same day as the "From Date"
  306. const sameDayString = selectedFromDate.toISOString().split('T')[0];
  307. toDate.setAttribute('min', sameDayString);
  308. // Set the "To Date" value to the next day by default
  309. toDate.value = sameDayString;
  310. } else {
  311. // Disable the "To Date" field if "From Date" is cleared
  312. toDate.disabled = true;
  313. toDate.value = ''; // Clear the "To Date" input
  314. }
  315. });
  316. });
  317. function resetForm() {
  318. document.getElementById('campaignrequestform').reset(); // Built-in reset functionality
  319. }
  320. function setEndDateMin() {
  321. var fromDate = document.getElementById('start_date').value;
  322. document.getElementById('end_date').min = fromDate;
  323. }
  324. // excel format to download
  325. document.getElementById('downloadExcel').addEventListener('click', function() {
  326. // Create a new workbook
  327. var wb = XLSX.utils.book_new();
  328. // Define the data for the worksheet
  329. var ws_data = [
  330. // Headers
  331. ["ID","NAME","ADDRESS","BALANCE AMOUNT","MOBILE NUMBER","TINY_URL"],
  332. // Add more data rows here as needed
  333. ];
  334. // Create the worksheet from the data
  335. var ws = XLSX.utils.aoa_to_sheet(ws_data);
  336. // Optional: Set column widths for better readability
  337. ws['!cols'] = [
  338. { wch: 10 }, // ID
  339. { wch: 10 }, // NAME
  340. { wch: 20 }, // ADDRESS
  341. { wch: 15 }, // MOBILE NUMBER
  342. { wch: 20 }, // BALANCE AMOUNT
  343. { wch: 25 }, // TINY URL
  344. ];
  345. // Append the worksheet to the workbook
  346. XLSX.utils.book_append_sheet(wb, ws, 'Property Tax');
  347. // Export the workbook to an Excel file
  348. XLSX.writeFile(wb, 'PropertyTaxTemp.xlsx');
  349. });
  350. $(document).ready(function() {
  351. $('#requestsubmit').on('click', function(event) {
  352. event.preventDefault(); // Prevent form from submitting the traditional way
  353. $('#requestsubmit').attr('disabled', true).text('Submitting...');
  354. // Get form values
  355. var name = $('#name').val();
  356. var category = $('#category').val();
  357. var eventStartDate = $('#eventstartdate').val();
  358. var eventEndDate = $('#eventenddate').val();
  359. var noOfAgent = $('#no_of_agent').val();
  360. var noOfCalls = $('#no_of_calls').val();
  361. var description = $('#description').val();
  362. var fileInput = $('#fileInput')[0].files[0]; // Get the file from the input
  363. // Check for empty values and trigger Swal error
  364. if (!name || !category || !eventStartDate || !eventEndDate || !noOfAgent || !noOfCalls || !description || !fileInput) {
  365. Swal.fire({
  366. icon: 'info',
  367. title: 'Info',
  368. text: 'Please fill in all fields and upload a file before submitting.',
  369. });
  370. $('#requestsubmit').attr('disabled', false).text('Submit');
  371. return; // Stop form submission if any field is empty
  372. }
  373. // Create a FormData object to hold all form data, including the file
  374. var formData = new FormData();
  375. formData.append('name', name);
  376. formData.append('category', category);
  377. formData.append('eventstartdate', eventStartDate);
  378. formData.append('eventenddate', eventEndDate);
  379. formData.append('no_of_agent', noOfAgent);
  380. formData.append('no_of_calls', noOfCalls);
  381. formData.append('description', description);
  382. formData.append('file', fileInput); // Append the file to formData
  383. // Make an AJAX request to submit the form data
  384. $.ajax({
  385. url: '/gcc/api/campaign/save', // API endpoint to save form data
  386. type: 'POST',
  387. data: formData,
  388. processData: false, // Don't process the data (needed for FormData)
  389. contentType: false, // Don't set content type (needed for FormData)
  390. success: function(response) {
  391. if (response.status === 'success') {
  392. Swal.fire({
  393. icon: 'success',
  394. title: 'Success',
  395. text: response.message
  396. }).then((result) => {
  397. $('#requestsubmit').attr('disabled', false).text('Submit');
  398. // Reload the page after the SweetAlert is closed
  399. if (result.isConfirmed) {
  400. // Optional: Reset the form
  401. $('#campaignrequestform')[0].reset();
  402. // Send the categoryId to another AJAX call
  403. let categoryId = parseInt(response.category_id, 10); // Extract the category_id from the response
  404. // Make the second AJAX call with the categoryId
  405. $.ajax({
  406. url: `/gcc/api/campaign/getlastCampaignid`, // Replace with your actual endpoint
  407. type: 'GET', // Or POST depending on your use case
  408. success: function(response) {
  409. console.log("Second AJAX call successful. Data: ", response);
  410. // Handle the success of the second AJAX call here
  411. $('#requestsubmit').attr('disabled', false).text('Submit');
  412. let campaignId = response[0].campaign_id;
  413. console.log('categoryId:', categoryId, 'campaignId:', campaignId); // Log values before AJAX call
  414. // Make the third AJAX call with both categoryId and campaignId
  415. $.ajax({
  416. url: '/gcc/api/agents/excel?categoryId='+categoryId+'&campaignId='+campaignId,
  417. type: 'GET',// Or POST depending on your use case
  418. success: function(response) {
  419. //alert("third_ajax");
  420. console.log("Third AJAX call successful. Data: ", response);
  421. $('#requestsubmit').attr('disabled', false).text('Submit');
  422. // Handle the success of the third AJAX call here
  423. },
  424. error: function(xhr, status, error) {
  425. console.error('Error in third AJAX call:', error);
  426. $('#requestsubmit').attr('disabled', false).text('Submit');
  427. }
  428. });
  429. },
  430. error: function(xhr, status, error) {
  431. console.error('Error in second AJAX call:', error);
  432. $('#requestsubmit').attr('disabled', false).text('Submit');
  433. }
  434. });
  435. // Reload the page after SweetAlert is closed
  436. location.reload();
  437. }
  438. });
  439. $('#requestsubmit').attr('disabled', false).text('Submit');
  440. // Optionally reset the form
  441. $('#campaignrequestform')[0].reset();
  442. } else {
  443. Swal.fire({
  444. icon: 'error',
  445. title: 'Error',
  446. text: 'Something went wrong. Please try again.'
  447. });
  448. $('#requestsubmit').attr('disabled', false).text('Submit');
  449. }
  450. },
  451. error: function(xhr, status, error) {
  452. Swal.fire({
  453. icon: 'error',
  454. title: 'Error',
  455. text: 'An error occurred: ' + error
  456. });
  457. $('#requestsubmit').attr('disabled', false).text('Submit');
  458. }
  459. });
  460. //upload file data
  461. });
  462. });
  463. //Update request form details
  464. $(document).ready(function () {
  465. // Function to open the edit modal and populate data
  466. window.callEdit = function (campaignId) {
  467. fetchCampaignDetails(campaignId);
  468. return false; // Prevent default anchor click behavior
  469. };
  470. function fetchCampaignDetails(campaignId) {
  471. $.ajax({
  472. url: `/gcc/api/campaign/getCampaignDetailsbyId?campaign_id=${campaignId}`,
  473. type: 'GET',
  474. success: function (response) {
  475. console.log(response);
  476. if (response) {
  477. // Populate modal fields with data
  478. $('#campaign_id').val(response.campaign_id);
  479. $('#campaign_name').val(response.campaign_name); // Assuming the key in the response is 'campaign_name'
  480. $('#start_date').val(response.start_date);
  481. $('#end_date').val(response.end_date);
  482. $('#no_of_agents').val(response.no_of_agents);
  483. $('#calls_per_agent').val(response.calls_per_agent);
  484. $('#description_modal').val(response.description);
  485. setEndDateMin();
  486. // Open the modal
  487. $('#editModal').modal('show');
  488. } else {
  489. alert('Campaign details not found.');
  490. }
  491. },
  492. error: function (xhr, status, error) {
  493. console.error('Error fetching campaign details:', error);
  494. alert('An error occurred while fetching campaign details.');
  495. }
  496. });
  497. }
  498. window.submitForm = function (event) {
  499. event.preventDefault(); // Prevent the default form submission
  500. var campaignId = $('#campaign_id').val();
  501. var campaignName = $('#campaign_name').val();
  502. var startDate = $('#start_date').val();
  503. var endDate = $('#end_date').val();
  504. var noOfAgents = $('#no_of_agents').val();
  505. var callsPerAgent = $('#calls_per_agent').val();
  506. var description = $('#description_modal').val();
  507. $.ajax({
  508. url: '/gcc/api/campaign/updateCampaign', // Endpoint without query parameters
  509. type: 'POST',
  510. data: {
  511. campaign_id: campaignId,
  512. campaign_name: campaignName,
  513. start_date: startDate,
  514. end_date: endDate,
  515. no_of_agents: noOfAgents,
  516. calls_per_agent: callsPerAgent,
  517. description: description
  518. }, // Send all data as JSON
  519. success: function (response) {
  520. console.log('Campaign ID:',campaign_id);
  521. Swal.fire({
  522. title: 'Success!',
  523. text: response, // Show the success message from the API response
  524. icon: 'success',
  525. confirmButtonText: 'OK'
  526. }).then((result) => {
  527. if (result.isConfirmed) {
  528. $('#editModal').modal('hide'); // Hide the modal
  529. location.reload(); // Optionally reload the page to refresh the data
  530. }
  531. });
  532. },
  533. error: function (xhr, status, error) {
  534. console.error('Error updating campaign details:', error);
  535. Swal.fire({
  536. title: 'Error!',
  537. text: 'An error occurred while updating campaign details.',
  538. icon: 'error',
  539. confirmButtonText: 'OK'
  540. });
  541. }
  542. });
  543. }
  544. });
  545. //hari category populate api
  546. // Fetch category dropdown from the server
  547. $(document).ready(function() {
  548. // Make an AJAX request to the API
  549. $.ajax({
  550. url: '/gcc/api/category/getcategory',
  551. method: 'GET',
  552. success: function(response) {
  553. // Check if the response has data
  554. if (response && response.length > 0) {
  555. // Populate the select dropdown with options
  556. var $categorySelect = $('#category');
  557. $.each(response, function(index, category) {
  558. $categorySelect.append(
  559. $('<option>', {
  560. value: category.category_id,
  561. text: category.category_name
  562. })
  563. );
  564. });
  565. }
  566. },
  567. error: function(xhr, status, error) {
  568. console.error('Error fetching categories:', error);
  569. }
  570. });
  571. });
  572. document.getElementById('fileInput').addEventListener('change', function (event) {
  573. var fileInput = event.target;
  574. var filePath = fileInput.value;
  575. var allowedExtensions = /(\.xlsx|\.xls)$/i;
  576. if (!allowedExtensions.exec(filePath)) {
  577. document.getElementById('fileError').style.display = 'block'; // Show error message
  578. fileInput.value = ''; // Clear the input
  579. } else {
  580. document.getElementById('fileError').style.display = 'none'; // Hide error message
  581. }
  582. });
  583. </script>
  584. </body>
  585. </html>