1/* 2* Common JS is used to write code which is generally used for all the UI components 3* Specific component related code won't be written here 4*/ 5 6"use strict"; 7$(document).ready(function () { 8 // $('#toolbar').parent().addClass('col-12 col-md-7 col-lg-7 p-0'); 9 $('#table_list').on('all.bs.table', function () { 10 $('#toolbar').parent().addClass('col-12 col-md-7 col-lg-7 p-0'); 11 }) 12 // $('#table_list').on('load-success.bs.table', function () { 13 // 14 // $('#toolbar').parent().addClass('col-12 col-md-7 col-lg-7 p-0'); 15 // }) 16 17 $(function () { 18 $('[data-toggle="tooltip"]').tooltip() 19 }) 20}) 21 22//Setup CSRF Token default in AJAX Request 23$.ajaxSetup({ 24 headers: { 25 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 26 } 27}); 28 29$('#create-form,.create-form,.create-form-without-reset').on('submit', function (e) { 30 e.preventDefault(); 31 let formElement = $(this); 32 let formReset = $(this); 33 let submitButtonElement = $(this).find(':submit'); 34 let url = $(this).attr('action'); 35 36 if ($(formElement).hasClass('attendance-table') && $('.search-input').val()) { 37 Swal.fire({icon: 'error', text: window.trans['Kindly clear the data from the search field']}); 38 return 0; 39 } 40 var school_prefix = ''; 41 var school_code = ''; 42 if ($(formElement).hasClass('school-registration-form')) { 43 showLoading(); 44 school_prefix = $('#school_code_prefix').val(); 45 school_code = $('.school_code').val(); 46 } 47 48 let submitButtonText = submitButtonElement.val(); 49 submitButtonElement.val('Please Wait...').attr('disabled', true); 50 51 setTimeout(() => { 52 let data = new FormData(this); 53 let preSubmitFunction = $(this).data('pre-submit-function'); 54 if (preSubmitFunction) { 55 //If custom function name is set in the Form tag then call that function using eval 56 eval(preSubmitFunction + "()"); 57 } 58 let customSuccessFunction = $(this).data('success-function'); 59 let customErrorFunction = $(this).data('error-function'); 60 // noinspection JSUnusedLocalSymbols 61 function errorCallback(response) { 62 if (customErrorFunction) { 63 //If custom function name is set in the Form tag then call that function using eval 64 eval(customErrorFunction + "(response)"); 65 } 66 } 67 // noinspection JSUnusedLocalSymbols 68 function successCallback(response) { 69 if (customErrorFunction) { 70 //Clear any previously shown error list on a fresh success 71 eval(customErrorFunction + "(null)"); 72 } 73 74 if (response.warning) { 75 $('#editModal').modal('hide'); 76 $('#table_list').bootstrapTable('refresh'); 77 $('#reset').trigger('click'); 78 } 79 80 if ($(formElement).hasClass('reload-window')) { 81 82 try { 83 setTimeout(() => { 84 location.reload(); 85 }, 2000); 86 } catch (error) { 87 88 } 89 } 90 91 if (!$(formElement).hasClass('create-form-without-reset')) { 92 93 try { 94 formElement[0].reset(); 95 } catch (error) { 96 97 } 98 $(".select2-dropdown").val("").trigger('change').trigger('unselect'); 99 $('.stream-divs').slideUp(500); 100 $('[data-repeater-item]').slice(1).remove(); 101 } 102 setTimeout(() => { 103 $('#tags').removeTag(); 104 $('#editModal').modal('hide'); 105 $('#application-status-options').hide(500); 106 $('#enable-features').modal('hide'); 107 }, 500); 108 109 $('#table_list').bootstrapTable('refresh'); 110 if (customSuccessFunction) { 111 //If custom function name is set in the Form tag then call that function using eval 112 eval(customSuccessFunction + "(response)"); 113 } 114 115 // School registration 116 if ($(formElement).hasClass('school-registration-form')) { 117 closeLoading(); 118 $('#school_code_prefix').val(school_prefix); 119 $('.school_code').val(parseInt(school_code) + 1); 120 } 121 122 } 123 submitButtonElement.val(submitButtonText ? submitButtonText : 'Submit').attr('disabled', false); 124 formAjaxRequest('POST', url, data, formElement, submitButtonElement, successCallback, errorCallback); 125 126 }, 300); 127}) 128 129$('.online-admission-form,.create-form-with-captcha').on('submit', function (e) { 130 e.preventDefault(); 131 let formElement = $(this); 132 let formReset = $(this); 133 let submitButtonElement = $(this).find(':submit'); 134 let url = $(this).attr('action'); 135 let submitButtonText = submitButtonElement.val(); 136 submitButtonElement.val('Please Wait...').attr('disabled', true); 137 setTimeout(() => { 138 let data = new FormData(this); 139 let preSubmitFunction = $(this).data('pre-submit-function'); 140 if (preSubmitFunction) { 141 //If custom function name is set in the Form tag then call that function using eval 142 eval(preSubmitFunction + "()"); 143 } 144 // noinspection JSUnusedLocalSymbols 145 function successCallback(response) { 146 if ($(formElement).hasClass('reload-window')) { 147 148 try { 149 setTimeout(() => { 150 location.reload(); 151 }, 2000); 152 } catch (error) { 153 154 } 155 } 156 if ($(formElement).hasClass('online-admission-form')) { 157 var url = window.location.origin; 158 $('.default-image').attr('src', url+'/assets/school/images/Image Preview.png'); 159 } 160 161 formElement[0].reset(); 162 try { 163 grecaptcha.reset(); 164 } catch (error) { 165 166 } 167 } 168 submitButtonElement.val(submitButtonText ? submitButtonText : 'Submit').attr('disabled', false); 169 formAjaxRequest('POST', url, data, formElement, submitButtonElement, successCallback); 170 171 }, 300); 172}) 173 174$('.school-registration').on('submit', function (e) { 175 e.preventDefault(); 176 let formElement = $(this); 177 let formReset = $(this); 178 let submitButtonElement = $(this).find(':submit'); 179 let url = $(this).attr('action'); 180 let submitButtonText = submitButtonElement.val(); 181 submitButtonElement.val('Please Wait...').attr('disabled', true); 182 showLoading(); 183 184 setTimeout(() => { 185 let data = new FormData(this); 186 let preSubmitFunction = $(this).data('pre-submit-function'); 187 if (preSubmitFunction) { 188 //If custom function name is set in the Form tag then call that function using eval 189 eval(preSubmitFunction + "()"); 190 } 191 let customSuccessFunction = $(this).data('success-function'); 192 // noinspection JSUnusedLocalSymbols 193 function successCallback(response) { 194 195 // Reset the form 196 formReset[0].reset(); 197 198 if (response.warning) { 199 $('#staticBackdrop').modal('hide'); 200 $('#reset').trigger('click'); 201 } 202 203 if ($(formElement).hasClass('reload-window')) { 204 205 try { 206 closeLoading(); 207 setTimeout(() => { 208 location.reload(); 209 }, 2000); 210 } catch (error) { 211 212 } 213 } 214 215 $('#staticBackdrop').modal('hide'); 216 217 if (customSuccessFunction) { 218 //If custom function name is set in the Form tag then call that function using eval 219 eval(customSuccessFunction + "(response)"); 220 } 221 222 try { 223 224 } catch (error) { 225 grecaptcha.reset(); 226 } 227 228 closeLoading(); 229 230 } 231 submitButtonElement.val(submitButtonText).attr('disabled', false); 232 formAjaxRequest('POST', url, data, formElement, submitButtonElement, successCallback); 233 234 }, 300); 235}) 236 237function showLoading() { 238 Swal.fire({ 239 title: please_wait, 240 text: processing_your_request, 241 allowOutsideClick: false, // Disable clicking outside to close
242 showConfirmButton: false, // Hide the confirm button 243 didOpen: () => { 244 Swal.showLoading(); // Show loading spinner 245 } 246 }); 247} 248 249// Close the alert manually 250function closeLoading() { 251 Swal.close(); // Close the alert 252} 253 254// create-form-without-reset-text-editor 255$('.create-form-without-reset-text-editor').on('submit', function (e) { 256 e.preventDefault(); 257 setTimeout(() => { 258 let request_data = new FormData(this); 259 // let data = request_data.get('data'); 260 let formElement = $(this); 261 let submitButtonElement = $(this).find(':submit'); 262 let url = $(this).attr('action'); 263 formAjaxRequest('POST', url, request_data, formElement, submitButtonElement); 264 }, 1000); 265 266}) 267 268$('#edit-form,.edit-form,.edit-form-without-reset,.edit-form-staff-payroll-setting').on('submit', function (e) { 269 270 271 272 e.preventDefault(); 273 let formElement = $(this); 274 let submitButtonElement = $(this).find(':submit'); 275 276 let submitButtonText = submitButtonElement.val(); 277 submitButtonElement.val('Please Wait...').attr('disabled', true); 278 let status = 1; 279 if ($(formElement).hasClass('edit-form-staff-payroll-setting')) { 280 let allowance_id = []; 281 let deduction_id = []; 282 $('.allowance_id').each(function() { 283 if ($(this).val()) { 284 allowance_id.push($(this).val()); 285 } 286 }); 287 288 $('.deduction_id').each(function() { 289 if ($(this).val()) { 290 deduction_id.push($(this).val()); 291 } 292 }); 293 294 if (hasDuplicates(allowance_id) || hasDuplicates(deduction_id)) { 295 status = 0; 296 } 297 } 298 if (status) { 299 setTimeout(() => { 300 let data = new FormData(this); 301 data.append("_method", "PUT"); 302 // let url = $(this).attr('action') + "/" + data.get('edit_id'); 303 let url = $(this).attr('action'); 304 let preSubmitFunction = $(this).data('pre-submit-function'); 305 if (preSubmitFunction) { 306 //If custom function name is set in the Form tag then call that function using eval 307 eval(preSubmitFunction + "()"); 308 } 309 let customSuccessFunction = $(this).data('success-function'); 310 311 // noinspection JSUnusedLocalSymbols 312 function successCallback(response) { 313 314 if ($(formElement).data('success-reload')) { 315 window.location.reload(); 316 return; 317 } 318 319 $('#table_list').bootstrapTable('refresh'); 320 setTimeout(function () { 321 $('#editModal').modal('hide'); 322 $('#change-bill').modal('hide'); 323 $('#viewModal').modal('hide'); 324 325 $('#update-current-plan').modal('hide'); 326 $('#tags').removeTag(); 327 328 if (!$(formElement).hasClass('edit-form-without-reset')) { 329 formElement[0].reset(); 330 } 331 332 }, 1000) 333 if (customSuccessFunction) { 334 //If custom function name is set in the Form tag then call that function using eval 335 eval(customSuccessFunction + "(response)"); 336 } 337 } 338 submitButtonElement.val(submitButtonText).attr('disabled', false); 339 formAjaxRequest('POST', url, data, formElement, submitButtonElement, successCallback); 340 }, 300); 341 } else { 342 Swal.fire({icon: 'error', text: window.trans['Duplicate values are not allowed']}); 343 submitButtonElement.val(submitButtonText).attr('disabled', false); 344 } 345 346 347}) 348 349function hasDuplicates(array) { 350 let uniqueValues = new Set(array); 351 return uniqueValues.size !== array.length; 352} 353 354$(document).on('click', '.delete-form', function (e) { 355 e.preventDefault(); 356 showDeletePopupModal($(this).attr('href'), { 357 successCallBack: function () { 358 $('#table_list').bootstrapTable('refresh'); 359 $('#subject_table_list').bootstrapTable('refresh'); 360 361 }, errorCallBack: function (response) { 362 // showErrorToast(response.message); 363 } 364 }) 365}) 366 367$(document).on('click', '.restore-data', function (e) { 368 e.preventDefault(); 369 showRestorePopupModal($(this).attr('href'), { 370 successCallBack: function () { 371 $('#table_list').bootstrapTable('refresh'); 372 } 373 }) 374}) 375 376$(document).on('click', '.trash-data', function (e) { 377 e.preventDefault(); 378 showPermanentlyDeletePopupModal($(this).attr('href'), { 379 successCallBack: function () { 380 $('#table_list').bootstrapTable('refresh'); 381 } 382 }) 383}) 384 385$(document).on('click', '.set-form-url', function (e) { 386 //This event will be called when user clicks on the edit button of the bootstrap table 387 e.preventDefault(); 388 $('#edit-form,.edit-form').attr('action', $(this).attr('href')); 389 390}) 391 392$(document).on('click', '.delete-form-reload', function (e) { 393 e.preventDefault(); 394 showDeletePopupModal($(this).attr('href'), { 395 successCallBack: function () { 396 setTimeout(() => { 397 window.location.reload(); 398 }, 1000); 399 } 400 }) 401}) 402 403$(document).on('click', '.change-school-status', function (e) { 404 e.preventDefault(); 405 let school_id = $(this).data('id'); 406 Swal.fire({ 407 title: window.trans["Are you sure"], 408 text: window.trans["change_school_status"], 409 icon: 'warning', 410 showCancelButton: true, 411 confirmButtonColor: '#3085d6', 412 cancelButtonColor: '#d33', 413 confirmButtonText: window.trans["Yes, Change it"], 414 cancelButtonText: window.trans["Cancel"] 415 }).then((result) => { 416 if (result.isConfirmed) { 417 let url = baseUrl + '/schools/change/status/' + school_id; 418 let data = null; 419 420 function successCallback(response) { 421 $('#table_list').bootstrapTable('refresh'); 422 showSuccessToast(response.message); 423 } 424 425 function errorCallback(response) { 426 showErrorToast(response.message); 427 } 428 429 ajaxRequest('PUT', url, data, null, successCallback, errorCallback); 430 } 431 }) 432}) 433 434$(document).on('click', '.change-package-status', function (e) { 435 e.preventDefault(); 436 let package_id = $(this).data('id'); 437 Swal.fire({ 438 title: window.trans["Are you sure"], 439 text: window.trans["change_package_status"], 440 icon: 'warning', 441 showCancelButton: true, 442 confirmButtonColor: '#3085d6', 443 cancelButtonColor: '#d33', 444 confirmButtonText: window.trans["Yes, Change it"], 445 cancelButtonText: window.trans["Cancel"] 446 }).then((result) => { 447 if (result.isConfirmed) { 448 let url = baseUrl + '/package/status/' + package_id; 449 let data = null; 450 451 function successCallback(response) { 452 $('#table_list').bootstrapTable('refresh'); 453 showSuccessToast(response.message); 454 } 455 456 function errorCallback(response) { 457 showErrorToast(response.message); 458 } 459 460 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 461 } 462 }) 463}) 464 465 466$(document).on('click', '.delete-class-timetable', function (e) { 467 e.preventDefault();
468 let class_section_id = $(this).data('id'); 469 Swal.fire({ 470 title: window.trans["Are you sure"], 471 text: window.trans["Delete Class Timetable"], 472 icon: 'warning', 473 showCancelButton: true, 474 confirmButtonColor: '#3085d6', 475 cancelButtonColor: '#d33', 476 confirmButtonText: window.trans["Yes, Change it"], 477 cancelButtonText: window.trans["Cancel"] 478 }).then((result) => { 479 if (result.isConfirmed) { 480 let url = baseUrl + '/timetable/delete/' + class_section_id; 481 let data = null; 482 483 function successCallback(response) { 484 $('#table_list').bootstrapTable('refresh'); 485 showSuccessToast(response.message); 486 } 487 488 function errorCallback(response) { 489 showErrorToast(response.message); 490 } 491 492 ajaxRequest('delete', url, data, null, successCallback, errorCallback); 493 } 494 }) 495}) 496 497 498 499$(document).on('click', '.change-addon-status', function (e) { 500 e.preventDefault(); 501 let addon_id = $(this).data('id'); 502 Swal.fire({ 503 title: window.trans["Are you sure"], 504 text: window.trans["change_addon_status"], 505 icon: 'warning', 506 showCancelButton: true, 507 confirmButtonColor: '#3085d6', 508 cancelButtonColor: '#d33', 509 confirmButtonText: window.trans["Yes, Change it"], 510 cancelButtonText: window.trans["Cancel"] 511 }).then((result) => { 512 if (result.isConfirmed) { 513 let url = baseUrl + '/addons/status/' + addon_id; 514 let data = null; 515 516 function successCallback(response) { 517 $('#table_list').bootstrapTable('refresh'); 518 showSuccessToast(response.message); 519 } 520 521 function errorCallback(response) { 522 showErrorToast(response.message); 523 } 524 525 ajaxRequest('PUT', url, data, null, successCallback, errorCallback); 526 } 527 }) 528}) 529 530$(document).on('click', '.delete-payroll-setting', function (e) { 531 e.preventDefault(); 532 let $this = $(this); 533 let id = $(this).data('id'); 534 Swal.fire({ 535 title: window.trans["Are you sure"], 536 text: window.trans["Delete this item"], 537 icon: 'warning', 538 showCancelButton: true, 539 confirmButtonColor: '#3085d6', 540 cancelButtonColor: '#d33', 541 confirmButtonText: window.trans["Yes"], 542 cancelButtonText: window.trans["Cancel"] 543 }).then((result) => { 544 if (result.isConfirmed) { 545 let url = baseUrl + '/staff/payroll-setting/' + id; 546 let data = null; 547 548 function successCallback(response) { 549 showSuccessToast(response.message); 550 $this.parent().parent().remove(); 551 setTimeout(() => { 552 calculate_net_salary(); 553 }, 1000); 554 } 555 556 function errorCallback(response) { 557 showErrorToast(response.message); 558 } 559 560 ajaxRequest('DELETE', url, data, null, successCallback, errorCallback); 561 } 562 }) 563}) 564 565 566$(document).on('click', '.cancel-upcoming-plan', function (e) { 567 e.preventDefault(); 568 let id = $(this).data('id'); 569 Swal.fire({ 570 title: window.trans["Are you sure"], 571 text: window.trans["Cancel This Plan"], 572 icon: 'warning', 573 showCancelButton: true, 574 confirmButtonColor: '#3085d6', 575 cancelButtonColor: '#d33', 576 confirmButtonText: window.trans["Yes"], 577 cancelButtonText: window.trans["Cancel"] 578 }).then((result) => { 579 if (result.isConfirmed) { 580 let url = baseUrl + '/subscriptions/cancel-upcoming/' + id; 581 let data = null; 582 583 function successCallback(response) { 584 showSuccessToast(response.message); 585 setTimeout(() => { 586 location.reload(); 587 }, 2000); 588 } 589 590 function errorCallback(response) { 591 showErrorToast(response.message); 592 } 593 594 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 595 } 596 }) 597}) 598 599$(document).on('click', '.select-plan', function (e) { 600 e.preventDefault(); 601 let id = $(this).data('id'); 602 let type = $(this).data('type'); 603 let iscurrentplan = $(this).data('iscurrentplan'); 604 605 let link = baseUrl + '/school-terms-condition'; 606 607 Swal.fire({ 608 title: window.trans["Are you sure"], 609 html: window.trans["Agree to This Subscription"], 610 icon: 'warning', 611 showCancelButton: true, 612 confirmButtonColor: '#3085d6', 613 cancelButtonColor: '#d33', 614 confirmButtonText: window.trans["Yes"], 615 cancelButtonText: window.trans["Cancel"], 616 input: 'checkbox', 617 inputPlaceholder: '<div class="m-2">'+ window.trans['I accept the provided'] + '<a href="'+ link +'" target="_blank"> '+window.trans['terms_condition']+' </a></div>', 618 619 620 }).then((result) => { 621 if (result.isConfirmed) { 622 if (result.value) { 623 let url = baseUrl + '/subscriptions/plan/' + id +'/type/'+type+'/current-plan/'+iscurrentplan; 624 let data = null; 625 626 function successCallback(response) { 627 // If currently active package 628 if (response.data) { 629 let package_id = response.data.package_id; 630 let package_type = response.data.plan 631 confirm_upcoming_plan(package_id, package_type); 632 } else { 633 if (response.type == 'prepaid') { 634 window.location.href = response.url; 635 } else { 636 showSuccessToast(response.message); 637 } 638 setTimeout(() => { 639 location.reload(); 640 }, 2000); 641 } 642 643 } 644 645 function errorCallback(response) { 646 showErrorToast(response.message); 647 } 648 649 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 650 } else { 651 Swal.fire({icon: 'error', text: window.trans['please_confirm_terms_condition']}); 652 } 653 654 } 655 }) 656 657}) 658 659 660$(document).on('click', '.id-card-settings', function (e) { 661 e.preventDefault(); 662 let type = $(this).data('type'); 663 let link = baseUrl + '/school-settings/id-card/remove/'; 664 665 Swal.fire({ 666 title: window.trans["Are you sure"], 667 html: window.trans["You wont be able to revert this"], 668 icon: 'warning', 669 showCancelButton: true, 670 confirmButtonColor: '#3085d6', 671 cancelButtonColor: '#d33', 672 confirmButtonText: window.trans["Yes"], 673 cancelButtonText: window.trans["Cancel"], 674 675 }).then((result) => { 676 if (result.isConfirmed) { 677 let url = link + type; 678 let data = null; 679 680 function successCallback(response) { 681 $('#'+type).hide(500); 682 showSuccessToast(response.message); 683 } 684 685 function errorCallback(response) { 686 showErrorToast(response.message); 687 } 688 689 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 690 } 691 }) 692 693}) 694 695function confirm_upcoming_plan(package_id, package_type = null) { 696 let id = package_id; 697 let type = package_type; 698 let message = window.trans["Accept Upcoming Billing Cycle Subscription"]; 699 if (type == 'Trial') { 700 message = window.trans["You want to go ahead with this plan?"]; 701 } 702 Swal.fire({ 703 title: window.trans["Are you sure"], 704 text: message, 705 icon: 'warning', 706 showCancelButton: true, 707 confirmButtonColor: '#3085d6', 708 cancelButtonColor: '#d33', 709 confirmButtonText: window.trans["Yes"], 710 cancelButtonText: window.trans["Cancel"] 711 }).then((result) => { 712 if (result.isConfirmed) { 713 let url = baseUrl + '/subscriptions/confirm-upcoming-plan/' + id; 714 let data = null; 715 716 function successCallback(response) { 717 showSuccessToast(response.message); 718 setTimeout(() => { 719 window.location.href = baseUrl + '/subscriptions/history'; 720 }, 2000); 721 } 722 723 function errorCallback(response) { 724 let message = window.trans["You have already selected an upcoming billing cycle plan If you want to change your upcoming billing cycle plan please ensure to remove the previously selected plan before making any alterations"]; 725 726 if (response.data == 0) { 727 message = response.message; 728 } 729 already_added_upcoming_plan(message); 730 } 731 732 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 733 } 734 }) 735} 736 737function already_added_upcoming_plan(message) { 738 Swal.fire({ 739 text: message, 740 icon: 'error', 741 }) 742} 743 744// Start immediate plan if currently working on another plan 745$(document).on('click', '.start-immediate-plan', function (e) { 746 e.preventDefault(); 747 let id = $(this).data('id'); 748 let type = $(this).data('type'); 749 let link = baseUrl + '/school-terms-condition'; 750 Swal.fire({ 751 title: window.trans["Are you sure"], 752 text: window.trans["start_immediate_this_plan"], 753 icon: 'warning', 754 showCancelButton: true, 755 confirmButtonColor: '#3085d6', 756 cancelButtonColor: '#d33', 757 confirmButtonText: window.trans["Yes"], 758 cancelButtonText: window.trans["Cancel"], 759 input: 'checkbox', 760 inputPlaceholder: '<div class="m-2">'+ window.trans['I accept the provided'] + '<a href="'+ link +'" target="_blank"> '+window.trans['terms_condition']+' </a></div>', 761 }).then((result) => { 762 if (result.isConfirmed) { 763 if (result.value) { 764 let url = baseUrl + '/subscriptions/start-immediate-plan/' + id + '/type/'+type; 765 let data = null; 766 767 function successCallback(response) { 768 if (response.data.type == 0) { 769 window.location.href = response.data.url; 770 } else { 771 showSuccessToast(response.message); 772 setTimeout(() => { 773 location.reload(); 774 }, 2000); 775 } 776 } 777 778 function errorCallback(response) { 779 showErrorToast(response.message); 780 } 781 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 782 } else { 783 Swal.fire({icon: 'error', text: window.trans['please_confirm_terms_condition']}); 784 } 785 } 786 }) 787}) 788 789// add-addon 790$(document).on('click', '.add-addon', function (e) { 791 e.preventDefault(); 792 let id = $(this).data('id'); 793 let type = $(this).data('type'); 794 let link = baseUrl + '/school-terms-condition'; 795 Swal.fire({ 796 title: window.trans["Are you sure you want to add this add-on"], 797 text: window.trans["This add-on will be added into your current subscribed package and will expire when your current subscription expires"], 798 icon: 'warning', 799 showCancelButton: true, 800 confirmButtonColor: '#3085d6', 801 cancelButtonColor: '#d33', 802 confirmButtonText: window.trans["Yes"], 803 cancelButtonText: window.trans["Cancel"], 804 input: 'checkbox', 805 inputPlaceholder: '<div class="m-2">'+ window.trans['I accept the provided'] + '<a href="'+ link +'" target="_blank"> '+window.trans['terms_condition']+' </a></div>', 806 }).then((result) => { 807 if (result.isConfirmed) { 808 if (result.value) { 809 let url = baseUrl + '/addons/subscribe/' + id + '/'+'package-type/' + type; 810 let data = null; 811 812 function successCallback(response) { 813 if (response.type == 'prepaid') { 814 window.location.href = response.url; 815 } else { 816 showSuccessToast(response.message); 817 } 818 setTimeout(() => { 819 location.reload(); 820 }, 2000); 821 } 822 823 function errorCallback(response) { 824 showErrorToast(response.message); 825 } 826 827 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 828 } else { 829 Swal.fire({icon: 'error', text: window.trans['please_confirm_terms_condition']}); 830 } 831 832 } 833 }) 834}) 835 836// discontinue_addon 837$(document).on('click', '.discontinue_addon', function (e) { 838 e.preventDefault(); 839 let id = $(this).data('id'); 840 Swal.fire({ 841 title: window.trans["Are you sure"], 842 text: window.trans["discontinue_upcoming_billing_cycle"],
843 icon: 'warning', 844 showCancelButton: true, 845 confirmButtonColor: '#3085d6', 846 cancelButtonColor: '#d33', 847 confirmButtonText: window.trans["Yes"], 848 cancelButtonText: window.trans["Cancel"] 849 }).then((result) => { 850 if (result.isConfirmed) { 851 let url = baseUrl + '/addons/discontinue/' + id; 852 let data = null; 853 854 function successCallback(response) { 855 showSuccessToast(response.message); 856 } 857 858 function errorCallback(response) { 859 showErrorToast(response.message); 860 } 861 862 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 863 } 864 }) 865}) 866 867 868$(document).on('click', '.no-feature-lock-menu,.no-feature-lock-menu-sub-item', function (e) { 869 e.preventDefault(); 870 let link = baseUrl + '/addons/plan'; 871 let role = $(this).data('name'); 872 873 if (role == 'School Admin') { 874 Swal.fire({ 875 title: window.trans["no_permission"], 876 icon: 'warning',
877 showCancelButton: false, 878 confirmButtonColor: '#3085d6', 879 confirmButtonText: window.trans["ok"], 880 html: '<div class="mb-2">' + window.trans["no_permission_upgrade_plan"] + '</div><a href="' + link + '">' + window.trans["click_here_to_buy_addon"] + '</a>', 881 }) 882 } else if (role == 'basic-features') { 883 Swal.fire({ 884 title: window.trans["Your License Has Expired"], 885 icon: 'warning', 886 showCancelButton: false, 887 confirmButtonColor: '#3085d6', 888 confirmButtonText: window.trans["ok"], 889 }) 890 } else { 891 Swal.fire({ 892 title: window.trans["no_permission"], 893 icon: 'warning', 894 showCancelButton: false, 895 confirmButtonColor: '#3085d6', 896 confirmButtonText: window.trans["ok"], 897 }) 898 } 899 900}) 901 902$(document).ready(function () { 903 $('.sidebar .nav-link').each(function (index, value) { 904 if (typeof $(value).data('access') != "undefined" && !$(value).data('access')) { 905 if ($(value).data('toggle') == "collapse") { 906 $(value).addClass('no-feature-lock-menu-without-alert'); 907 } else { 908 if ($(value).parents('.collapse').length) { 909 $(value).addClass('no-feature-lock-menu-sub-item'); 910 } else { 911 $(value).addClass('no-feature-lock-menu'); 912 } 913 $(value).attr('href', '#'); 914 } 915 916 } 917 }) 918}) 919 920// Drop down menu 921$(document).ready(function(){ 922 $('.dropdown-toggle').click(function(){ 923 var buttonId = $(this).attr('id'); 924 var menuId = $(this).next('.custom-dropdown-menu').attr('id'); 925 926 // Toggle the visibility of the dropdown menu
927 $('#' + menuId).toggleClass('show-custom-dropdown'); 928 }); 929 930 // Hide the dropdown menu when clicking outside of it 931 $(document).click(function(event) { 932 if (!$(event.target).closest('.dropdown').length) { 933 $('.custom-dropdown-menu').removeClass('show-custom-dropdown'); 934 } 935 }); 936 937 // Hide the dropdown menu when an item is selected 938 $('.dropdown-item').click(function() { 939 $(this).closest('.custom-dropdown-menu').removeClass('show-custom-dropdown'); 940 }); 941}); 942 943$(document).on('click', '.restore-database', function (e) { 944 e.preventDefault(); 945 let database_id = $(this).data('id'); 946 Swal.fire({ 947 title: window.trans["Are you sure"], 948 text: window.trans["restore_this_databse"], 949 icon: 'warning', 950 showCancelButton: true, 951 confirmButtonColor: '#3085d6', 952 cancelButtonColor: '#d33', 953 confirmButtonText: window.trans["Yes"], 954 cancelButtonText: window.trans["Cancel"] 955 }).then((result) => { 956 if (result.isConfirmed) { 957 let url = baseUrl + '/database-backup/restore/' + database_id; 958 let data = null; 959 960 function successCallback(response) { 961 $('#table_list').bootstrapTable('refresh'); 962 showSuccessToast(response.message); 963 } 964 965 function errorCallback(response) { 966 showErrorToast(response.message); 967 } 968 969 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 970 } 971 }) 972}) 973 974// create-backup 975$(document).on('click', '.create-backup', function (e) { 976 e.preventDefault(); 977 Swal.fire({ 978 title: window.trans["Are you sure"], 979 text: window.trans["want_to_create_a_backup"], 980 icon: 'warning', 981 showCancelButton: true, 982 confirmButtonColor: '#3085d6', 983 cancelButtonColor: '#d33', 984 confirmButtonText: window.trans["Yes"], 985 cancelButtonText: window.trans["Cancel"] 986 }).then((result) => { 987 if (result.isConfirmed) { 988 let url = baseUrl + '/database-backup/store/'; 989 let data = null; 990 991 function successCallback(response) { 992 // download the file 993 if(response.data) { 994 995 const aTag = document.createElement('a'); 996 aTag.href = response.data; 997 // a.download = fileName; 998 document.body.appendChild(aTag); 999 aTag.click(); 1000 aTag.remove(); 1001 1002 window.URL.revokeObjectURL(objectUrl); // Clean up the object URL after download 1003 } 1004 1005 $('#table_list').bootstrapTable('refresh'); 1006 showSuccessToast(response.message); 1007 1008 } 1009 function errorCallback(response) { 1010 showErrorToast(response.message); 1011 } 1012 1013 ajaxRequest('GET', url, data, null, successCallback, errorCallback); 1014 } 1015 }) 1016})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.