Subversion Repositories SmartDukaan

Rev

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

Rev 35289 Rev 35340
Line 1... Line 1...
1
$(function () {
1
$(function () {
2
    $(document).on('click', ".trial_users", function () {
2
    $(document).on('click', ".trial_users", function () {
3
        loadPendingTrialForms("main-content");
3
        loadPendingTrialForms("main-content");
4
    });
4
    });
-
 
5
    $(document).on('click', ".verified_trial_users", function () {
-
 
6
        loadVerifiedTrialForms("main-content");
-
 
7
    });
5
 
8
 
6
    $(document).on('click', ".mk_trial_create", function () {
9
    $(document).on('click', ".mk_trial_create", function () {
7
        let trialFormId = $(this.closest('tr')).data('id');
10
        let trialFormId = $(this.closest('tr')).data('id');
8
    });
11
    });
9
 
12
 
Line 16... Line 19...
16
        doGetAjaxRequestHandler(context + "/trial/pending", function (response) {
19
        doGetAjaxRequestHandler(context + "/trial/pending", function (response) {
17
            $('#' + domId).html(response);
20
            $('#' + domId).html(response);
18
        });
21
        });
19
    }
22
    }
20
 
23
 
-
 
24
    function loadVerifiedTrialForms(domId) {
-
 
25
        doGetAjaxRequestHandler(context + "/trial/verified", function (response) {
-
 
26
            $('#' + domId).html(response);
-
 
27
        });
-
 
28
    }
-
 
29
 
21
    function trialCreate(trialFormId) {
30
    function trialCreate(trialFormId) {
22
        doAjaxRequestHandler(`${context}/trial/create/${trialFormId}`, "GET", function (response) {
31
        doAjaxRequestHandler(`${context}/trial/create/${trialFormId}`, "GET", function (response) {
23
            $('#main-content').html(response);
32
            $('#main-content').html(response);
24
        });
33
        });
25
    }
34
    }
26
 
35
 
27
    function cancelTrialForm(trialFormId) {
36
    function cancelTrialForm(trialFormId) {
28
        if (confirm("Are you sure you want to cancel this trial?")) {
37
        if (confirm("Are you sure you want to cancel this trial?")) {
29
            doGetAjaxRequestHandler(`${context}/trial/cancel/${trialFormId}`, function (response) {
38
            doPostAjaxRequestHandler(`${context}/trial/cancel/${trialFormId}`, function (response) {
30
                if (response == "true") {
39
                if (response == "true") {
31
                    loadPendingTrialForms("main-content");
40
                    loadPendingTrialForms("main-content");
32
                }
41
                }
33
            });
42
            });
34
        }
43
        }
35
    }
44
    }
36
});
45
});
-
 
46
$(document).on('click', '.openBrandModal', function () {
-
 
47
    let trialFormId = $(this).data('id');
-
 
48
    console.log("trialFormId sent:", trialFormId);
-
 
49
    $('#brandPotentialForm input[name="trialFormId"]').val(trialFormId);
-
 
50
});
-
 
51
 
-
 
52
 
-
 
53
function saveBrandPotential() {
-
 
54
 
-
 
55
    let params = {};
-
 
56
 
-
 
57
    params["trialFormId"] = $('#brandPotentialForm input[name="trialFormId"]').val();
-
 
58
 
-
 
59
    let row = 1;
-
 
60
    $('#brandPotentialRows tr').each(function () {
-
 
61
        let brand = $(this).find('input[name="brand_' + row + '"]').val();
-
 
62
        let potential = $(this).find('input[name="potential_' + row + '"]').val();
-
 
63
 
-
 
64
        if (brand && potential) {
-
 
65
            params["brand_" + row] = brand;
-
 
66
            params["potential_" + row] = potential;
-
 
67
        }
-
 
68
        row++;
-
 
69
    });
-
 
70
 
-
 
71
    console.log("PARAMS SENT:", params);
-
 
72
 
-
 
73
    doPostAjaxRequestWithParamsHandler(
-
 
74
        context + "/trial/brand-Potential",
-
 
75
        params,
-
 
76
        function (response) {
-
 
77
            $('#brandPotentialModal').modal('hide');
-
 
78
            loadPendingTrialForms("main-content");
-
 
79
            alert("Verifed - Brand Potential Saved Successfully");
-
 
80
        }
-
 
81
    );
-
 
82
 
-
 
83
}
-
 
84