Subversion Repositories SmartDukaan

Rev

Rev 35485 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35485 Rev 35499
Line 2... Line 2...
2
    doGetAjaxRequestHandler(context + "/trial/pending", function (response) {
2
    doGetAjaxRequestHandler(context + "/trial/pending", function (response) {
3
        $('#' + domId).html(response);
3
        $('#' + domId).html(response);
4
    });
4
    });
5
}
5
}
6
 
6
 
-
 
7
function loadAllTrialForms(domId) {
-
 
8
    doGetAjaxRequestHandler(context + "/trial/all-trial", function (response) {
-
 
9
        $('#' + domId).html(response);
-
 
10
    });
-
 
11
}
-
 
12
 
7
$(function () {
13
$(function () {
8
    $(document).on('click', ".trial_users", function () {
14
    $(document).on('click', ".trial_users", function () {
9
        loadPendingTrialForms("main-content");
15
        loadPendingTrialForms("main-content");
10
    });
16
    });
11
    $(document).on('click', ".verified_trial_users", function () {
17
    $(document).on('click', ".verified_trial_users", function () {
12
        loadVerifiedTrialForms("main-content");
18
        loadVerifiedTrialForms("main-content");
13
    });
19
    });
-
 
20
    $(document).on('click', ".all_trial_users", function () {
-
 
21
        loadAllTrialForms("main-content");
-
 
22
    });
14
 
23
 
15
    $(document).on('click', ".mk_trial_create", function () {
24
    $(document).on('click', ".mk_trial_create", function () {
16
        let trialFormId = $(this).closest('tr').data('id');
25
        let trialFormId = $(this).closest('tr').data('id');
17
    });
26
    });
18
 
27
 
19
    $(document).on('click', ".mk_trial_cancel", function () {
28
    $(document).on('click', ".mk_trial_cancel", function () {
20
        let trialFormId = $(this).closest('tr').data('id');
29
        let trialFormId = $(this).closest('tr').data('id');
21
        cancelTrialForm(trialFormId);
30
        openCancelTrialModal(trialFormId);
22
    });
31
    });
-
 
32
 
-
 
33
 
23
    $(document).on('click', ".approve-trial", function () {
34
    $(document).on('click', ".approve-trial", function () {
24
        let trialFormId = $(this).closest('tr').data('id');
35
        let trialFormId = $(this).closest('tr').data('id');
25
        approveTrialForm(trialFormId);
36
        approveTrialForm(trialFormId);
26
    });
37
    });
27
    $(document).on('click', ".converted", function () {
38
    $(document).on('click', ".converted", function () {
28
        let trialFormId = $(this).closest('tr').data('id');
39
        let trialFormId = $(this).closest('tr').data('id');
29
        convertedToFranchise(trialFormId);
40
        convertedToFranchise(trialFormId);
30
    });
41
    });
-
 
42
    $(document).on('click', '#confirmCancelTrial', function () {
-
 
43
 
-
 
44
        const trialFormId = $('#cancelTrialFormId').val();
-
 
45
        const remark = $('#cancelTrialRemark').val().trim();
-
 
46
 
-
 
47
        if (!remark) {
-
 
48
            alert("Remark is mandatory");
-
 
49
            return;
-
 
50
        }
-
 
51
 
-
 
52
        doPostAjaxRequestWithParamsHandler(
-
 
53
            `${context}/trial/reject`,
-
 
54
            {
-
 
55
                trialFormId: trialFormId,
-
 
56
                remark: remark
-
 
57
            },
-
 
58
            function (response) {
-
 
59
                if (response.statusCode == "200") {
-
 
60
                    $('#cancelTrialModal').modal('hide');
-
 
61
                    cleanupModal();
-
 
62
                } else {
-
 
63
                    alert("Failed to cancel trial");
-
 
64
                }
-
 
65
            }
-
 
66
        );
-
 
67
    });
-
 
68
 
31
 
69
 
32
 
70
 
33
    function loadVerifiedTrialForms(domId) {
71
    function loadVerifiedTrialForms(domId) {
34
        doGetAjaxRequestHandler(context + "/trial/verified", function (response) {
72
        doGetAjaxRequestHandler(context + "/trial/verified", function (response) {
35
            $('#' + domId).html(response);
73
            $('#' + domId).html(response);
Line 40... Line 78...
40
        doAjaxRequestHandler(`${context}/trial/create/${trialFormId}`, "GET", function (response) {
78
        doAjaxRequestHandler(`${context}/trial/create/${trialFormId}`, "GET", function (response) {
41
            $('#main-content').html(response);
79
            $('#main-content').html(response);
42
        });
80
        });
43
    }
81
    }
44
 
82
 
45
    function cancelTrialForm(trialFormId) {
83
    function openCancelTrialModal(trialFormId) {
46
        if (confirm("Are you sure you want to reject this trial?")) {
-
 
47
            doPostAjaxRequestHandler(`${context}/trial/reject/${trialFormId}`, function (response) {
-
 
48
                if (response == "true") {
-
 
49
                    $('.modal-backdrop').remove();
84
        $('#cancelTrialFormId').val(trialFormId);
50
                    $('body').removeClass('modal-open');
85
        $('#cancelTrialRemark').val('');
51
                    $('body').css('padding-right', '');
86
        $('#cancelTrialModal').modal('show');
52
                    loadPendingTrialForms("main-content");
-
 
53
                }
-
 
54
            });
-
 
55
        }
-
 
56
    }
87
    }
57
 
88
 
-
 
89
 
58
    function approveTrialForm(trialFormId) {
90
    function approveTrialForm(trialFormId) {
59
        if (confirm("Are you sure you want to approve this trial?")) {
91
        if (confirm("Are you sure you want to approve this trial?")) {
60
            doPostAjaxRequestHandler(`${context}/trial/approve/${trialFormId}`, function (response) {
92
            doPostAjaxRequestHandler(`${context}/trial/approve/${trialFormId}`, function (response) {
61
                if (response == "true") {
93
                if (response == "true") {
62
                    $('.modal-backdrop').remove();
94
                    $('.modal-backdrop').remove();