PageSourceSearch

https://oneinfini.com/assets/js/custom/common.js

js oneinfini.com collected 2026-09-24 11:07:27 UTC 34,537 bytes, 1,004 lines download raw bytes

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

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.