Subversion Repositories SmartDukaan

Rev

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

Rev 34387 Rev 34405
Line 37... Line 37...
37
}
37
}
38
 
38
 
39
$(document).on('click', ".liquidation-list", function () {
39
$(document).on('click', ".liquidation-list", function () {
40
    doGetAjaxRequestHandler(context + "/liquidation", (response) => {
40
    doGetAjaxRequestHandler(context + "/liquidation", (response) => {
41
            $('#main-content').html(response);
41
            $('#main-content').html(response);
42
            initializeSelect('#warehouseId, #catalogId, #status')
42
            initializeSelect('#catalogId, #status')
43
            $('#liquidation-table').DataTable();
43
            $('#liquidation-table').DataTable();
44
 
44
 
45
        });
45
        });
46
});
46
});
47
 
47
 
48
$(document).on('click', ".save-liquidation", function () {
48
$(document).on('click', ".save-liquidation", function () {
49
    const params = serializeFormToJson('form#biddingForm');
49
    const params = serializeFormToJson('form#biddingForm');
-
 
50
    params.restricted = $('#restricted:checked').length
50
    doAjaxRequestWithJsonHandler(context + "/liquidation", "POST", JSON.stringify(params), (response) => {
51
    doAjaxRequestWithJsonHandler(context + "/liquidation", "POST", JSON.stringify(params), (response) => {
51
        if (response) {
52
        if (response) {
52
            $('.liquidation-list').trigger('click');
53
            $('.liquidation-list').trigger('click');
53
            $('#manageLiquidationModal').modal('hide');
54
            $('#manageLiquidationModal').modal('hide');
54
            alert("Saved successfully");
55
            alert("Saved successfully");
Line 56... Line 57...
56
            alert("Something went wrong!");
57
            alert("Something went wrong!");
57
        }
58
        }
58
    });
59
    });
59
});
60
});
60
 
61
 
-
 
62
function editLiquidation(id) {
61
$(document).on('click', ".delete-liquidation", function() {
63
    doGetAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
62
    const id = parseInt($(this).data('id')) || 0;
64
        if (response.statusCode == 200){
-
 
65
            $('#manageLiquidationModal').modal('show');
-
 
66
            let names = Object.keys(response.response);
-
 
67
            if (names.length){
-
 
68
                names.forEach(name => {
-
 
69
                    if (name == 'catalogId' || name == 'status') {
-
 
70
                        $(`#${name}`).val(response.response[name]);
-
 
71
                        $(`#${name}`).multiselect('refresh');
-
 
72
                    } else {
-
 
73
                        if(name == 'restricted') $(`#restricted`).prop('checked', response.response['restricted']);
-
 
74
                        $(`#${name}`).val(response.response[name]);
-
 
75
                    }
-
 
76
                })
-
 
77
            }
-
 
78
        }
-
 
79
    });
-
 
80
}
-
 
81
 
-
 
82
function deleteLiquidation(id) {
63
    if (confirm("Are you sure you want to delete this record")) {
83
    if (confirm("Are you sure you want to delete this record")) {
64
        if (id > 0) {
84
        if (id > 0) {
65
            doDeleteAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
85
            doDeleteAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
66
                if (response) {
86
                if (response) {
67
                    $(this).parent('td').closest('tr').remove();
87
                    $(this).parent('td').closest('tr').remove();
Line 70... Line 90...
70
                } else {
90
                } else {
71
                    alert("Something went wrong!");
91
                    alert("Something went wrong!");
72
                }
92
                }
73
            });
93
            });
74
        } else {
94
        } else {
75
            $(this).parent('td').closest('tr').remove();
95
            alert("Liquidation not found");
76
        }
96
        }
77
    }
97
    }
78
});
-
 
79
 
-
 
80
 
-
 
81
$(document).on('change', "#warehouseId", function() {
-
 
82
    doAjaxRequestWithJsonHandler(`${context}/liquidation/warehouse/${$(this).val()}`, "GET", null, (response) => {
-
 
83
        if (response) {
-
 
84
            $('#catalogId').html("");
-
 
85
            let options = `<option value="">Select</option>`;
-
 
86
            if (response.products.length){
-
 
87
                response.products.forEach(product => {
-
 
88
                    options+= `<option value="${product.catalogId}">${product.brand + ' ' +product.modelNumber + ' ('+product.shaholicNetAvailability+')'}</option>`;
-
 
89
                });
-
 
90
            }
-
 
91
            $('#catalogId').html(options);
-
 
92
            initializeSelect('#catalogId');
-
 
93
            console.log("Warehouse response: ",response)
-
 
94
        } else {
-
 
95
            alert("Something went wrong!");
-
 
96
        }
-
 
97
    });
-
 
98
    loadCatalogOptions($(this).val(), 'select#super_catalog_name', 'superCatalogs');
-
 
99
});
-
 
100
 
-
 
101
function editLiquidation(id) {
-
 
102
    doGetAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
-
 
103
        if (response){
-
 
104
            $('#manageLiquidationModal').modal('show');
-
 
105
            let names = Object.keys(response);
-
 
106
            if (names.length){
-
 
107
                names.forEach(name => {
-
 
108
                    console.log("map",$(`#${name}`).val(response[name]))
-
 
109
                    $(`#${name}`).val(response[name]);
-
 
110
                })
-
 
111
            }
-
 
112
        }
-
 
113
        //initializeSelect('#warehouseId, #catalogId, #status')
-
 
114
    });
-
 
115
}
-
 
116
 
-
 
117
function deleteLiquidation(id) {
-
 
118
 if (confirm("Are you sure want to delete this?")){
-
 
119
     console.log(`${id} Call delete method here`);
-
 
120
 }
-
 
121
}
98
}
122
99