Subversion Repositories SmartDukaan

Rev

Rev 32912 | Rev 33729 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
32352 amit.gupta 1
$(function () {
2
    $(document).on('click', ".warehouse-create-purchase-order", function () {
3
        loadCreatePurchase("main-content");
4
    });
32145 tejbeer 5
 
32352 amit.gupta 6
    $(document).on('click', ".warehouse-receive-new-invoice", function () {
7
        loadNewReceiveInvoice("main-content");
8
    });
32145 tejbeer 9
 
32192 tejbeer 10
 
32352 amit.gupta 11
    $(document).on('click', ".warehouse-grn-request", function () {
12
        loadGrnRequest("main-content");
13
    });
32192 tejbeer 14
 
32300 tejbeer 15
 
32352 amit.gupta 16
    $(document).on('click', ".warehouse-debit-note", function () {
17
        loadDebitNote("main-content");
18
    });
32192 tejbeer 19
 
20
 
32352 amit.gupta 21
    $(document).on('click', ".warehouse-invoices", function () {
22
        loadWarehouseInvoices("main-content");
23
    });
32256 tejbeer 24
 
32300 tejbeer 25
 
32352 amit.gupta 26
    $(document).on('click', '.dateWiseInvoices', function () {
32300 tejbeer 27
 
32352 amit.gupta 28
        var startDate = getDatesFromPicker('input[name="invoice-duration"]').startDate;
29
        var endDate = getDatesFromPicker('input[name="invoice-duration"]').endDate
32300 tejbeer 30
 
32352 amit.gupta 31
        var vendorId = $('#vendorId').val();
32300 tejbeer 32
 
32686 shampa 33
       // doGetAjaxRequestHandler(context + "/getWarehouseInvoicesByVendor?vendorId=" + vendorId + "&startDate=" + startDate + "&endDate=" + endDate, function (response) {
34
           // $('.invoicesviewcontainer').html(response);
35
            doGetAjaxRequestHandler(context + "/getWarehouseInvoicesBydateWise?dateWiseInvoices="  + "&startDate=" + startDate + "&endDate=" + endDate, function (response) {
36
                        $('.invoicesviewcontainer').html(response);
32300 tejbeer 37
 
32352 amit.gupta 38
        });
32300 tejbeer 39
 
40
 
32352 amit.gupta 41
    });
32300 tejbeer 42
 
43
 
32352 amit.gupta 44
    $(document)
45
        .on(
46
            'input',
47
            '#invoice',
48
            function () {
49
                if (confirm('Document has been selected, Do you want to upload ?')) {
50
                    var fileSelector = $('#invoice')[0];
51
                    if (fileSelector != undefined
52
                        && fileSelector.files[0] != undefined) {
53
                        var url = context + '/document-upload';
32300 tejbeer 54
 
32352 amit.gupta 55
                        console.log(url);
56
                        var file = this.files[0];
57
                        doAjaxUploadRequestHandler(
58
                            url,
59
                            'POST',
60
                            file,
61
                            function (response) {
62
                                console.log(response);
63
                                var documentId = response.response.document_id;
64
                                console.log("documentId : "
65
                                    + documentId);
66
                                localStorage.setItem("invoiceDocument",
67
                                    documentId);
32192 tejbeer 68
 
32295 tejbeer 69
 
32352 amit.gupta 70
                            });
32300 tejbeer 71
 
32352 amit.gupta 72
                    }
73
                } else {
74
                    // Do nothing!
75
                }
76
            });
32192 tejbeer 77
 
32352 amit.gupta 78
    $(document).on('click', ".createReceiveInvoice", function () {
32192 tejbeer 79
 
32352 amit.gupta 80
        var invoiceDate = $('#actualDate').val();
32192 tejbeer 81
 
32352 amit.gupta 82
        var warehouseId = $('#warehouseMap').val();
32192 tejbeer 83
 
32352 amit.gupta 84
        var numItems = $('#numberofItems').val();
32192 tejbeer 85
 
32352 amit.gupta 86
        var supplierId = $('#vendorId').val();
32192 tejbeer 87
 
32352 amit.gupta 88
        var totalValue = $('#totalValue').val();
32192 tejbeer 89
 
32352 amit.gupta 90
        var invoiceNumber = $('#invoiceNumber').val();
32642 raveendra. 91
        //var invoiceDoc  =  $('#invoiceDoc').val();
32192 tejbeer 92
 
32642 raveendra. 93
       var invoice=$('#invoice').val();
94
        var invoiceDoc = localStorage
95
            .getItem("invoiceDocument");
32638 raveendra. 96
       console.log(invoiceDoc)
32192 tejbeer 97
 
32629 amit.gupta 98
        if (invoiceDate === "" && warehouseId === "" && numItems === "" && supplierId === "" && totalValue === "" && invoiceNumber === "" && invoiceDoc === "") {
32352 amit.gupta 99
            alert("Field can't be empty");
100
            return false;
101
        }
32192 tejbeer 102
 
32629 amit.gupta 103
        if (invoiceDate === "") {
32638 raveendra. 104
            alert("Please select date");
32629 amit.gupta 105
            return false;
106
        }
32638 raveendra. 107
         if (supplierId === "") {
108
             alert("Please choose supplier/Vendor");
109
              return false;
110
                }
111
 
112
        if (invoiceNumber === "") {
113
            alert("Please fill Invoice Number.");
114
            return false;
115
        }
32629 amit.gupta 116
        if (warehouseId === "") {
32638 raveendra. 117
            alert("Please choose warehouse");
32629 amit.gupta 118
            return false;
119
        }
120
 
121
        if (numItems === "") {
32638 raveendra. 122
            alert("Please fill number of items.");
32629 amit.gupta 123
            return false;
124
        }
125
        if (totalValue === "") {
32638 raveendra. 126
            alert("Please fill Total Value.");
32629 amit.gupta 127
            return false;
128
        }
32638 raveendra. 129
        console.log('invoice doc', invoiceDoc);
32643 raveendra. 130
         if (invoiceDoc === "" ) {
32638 raveendra. 131
            alert("Please upload invoice.");
32629 amit.gupta 132
            return false;
133
        }
32352 amit.gupta 134
        var newReceiveInvoice = {};
32192 tejbeer 135
 
32352 amit.gupta 136
        newReceiveInvoice['invoiceDate'] = invoiceDate;
32629 amit.gupta 137
        newReceiveInvoice['warehouseId'] = warehouseId;
138
        newReceiveInvoice['numItems'] = numItems;
139
        newReceiveInvoice['supplierId'] = supplierId;
140
        newReceiveInvoice['totalValue'] = totalValue;
141
        newReceiveInvoice['invoiceNumber'] = invoiceNumber;
142
        newReceiveInvoice['invoiceDoc'] = invoiceDoc;
32192 tejbeer 143
 
32629 amit.gupta 144
        if (confirm("Are you sure you want to add new Invoice")) {
32192 tejbeer 145
 
32390 amit.gupta 146
            doPostAjaxRequestWithJsonHandler(`${context}/newReceiveInvoice`, JSON
32352 amit.gupta 147
                .stringify(newReceiveInvoice), function (response) {
148
                if (response == 'true') {
32638 raveendra. 149
                    alert("Successfully added");
32352 amit.gupta 150
                    localStorage.removeItem("invoiceDocument");
151
                    loadNewReceiveInvoice("main-content");
152
                }
153
            });
154
        }
32295 tejbeer 155
 
32192 tejbeer 156
 
32352 amit.gupta 157
    });
32192 tejbeer 158
 
159
 
32352 amit.gupta 160
    var purchaseItemIds;
161
    $(document).on('click', ".purchaseorderitemview", function () {
162
        purchaseItemIds = [];
163
        var vendorId = $('#vendorId').val();
164
        var warehouseId = $('#warehouseMap').val();
32390 amit.gupta 165
        var poDate = $('#poDate').val();
32192 tejbeer 166
 
32352 amit.gupta 167
        console.log(warehouseId);
32192 tejbeer 168
 
32352 amit.gupta 169
        if (warehouseId === null && vendorId === "") {
170
            alert("Field can't be empty");
171
            return;
172
        }
32192 tejbeer 173
 
32390 amit.gupta 174
        if (poDate === '') {
175
            alert("PO Date is required");
176
            return;
177
        }
178
 
179
        if (warehouseId === null && vendorId === "") {
180
            alert("Field can't be empty");
181
            return;
182
        }
183
 
32352 amit.gupta 184
        if (warehouseId === null) {
185
            alert("please select warehouse");
186
            return;
187
        }
188
        if (vendorId === "") {
189
            alert("please select vendor");
190
            return;
191
        }
192
        doGetAjaxRequestHandler(context + "/addPurchaseItemView?warehouseId=" + warehouseId + "&vendorId=" + vendorId, function (response) {
193
            $(".createpurchaseordercontainer").html(response);
194
        });
195
    });
32192 tejbeer 196
 
32145 tejbeer 197
 
32352 amit.gupta 198
    $(document).on('click', ".addRowInPurchaseOrder", function () {
199
        var totalQty = 0;
33727 ranu 200
        var totalValue = 0;
32145 tejbeer 201
 
32358 amit.gupta 202
        $("table > tbody > tr").each(function () {
32352 amit.gupta 203
            var itemId = $(this).find(".transferPrice").data('itemid');
204
            var qty = $(this).find(".qty").val();
33727 ranu 205
            var transferPrice = $(this).find(".transferPrice").val();
32145 tejbeer 206
 
33727 ranu 207
            if (qty !== undefined && qty !== "") {
208
                qty = parseInt(qty);
209
                totalQty += qty;
210
                if (transferPrice !== undefined && transferPrice !== "") {
211
                    transferPrice = parseFloat(transferPrice);
212
                    totalValue += qty * transferPrice;
213
                }
32352 amit.gupta 214
            }
32358 amit.gupta 215
        });
32145 tejbeer 216
 
32603 raveendra. 217
        var $html = $(`<tr>
33727 ranu 218
        <td><input type="text" class="form-control typeaheaditem" autocomplete="off" placeholder="Search Model"/></td>
219
        <td><input type="number" class="form-control qty" name="qty" placeholder="Quantity"/></td>
220
        <td><input type="number" class="form-control transferPrice" readonly tabindex="-1" placeholder="Transfer Price"/></td>
221
        <td><input type="number" class="form-control totalValue" tabindex="-1" readonly placeholder="Total Value"/></td>
222
        <td><input class="form-control btn btn-primary removeInPurchaseOrder" tabindex="-1" type="button" value="Remove"></td>
223
    </tr>`);
32192 tejbeer 224
 
32352 amit.gupta 225
        var vendorId = $('#vendorId').val();
32192 tejbeer 226
 
32352 amit.gupta 227
        $('tbody').append($html);
33727 ranu 228
        getVendorItemAheadOptions($html.find('.typeaheaditem'), vendorId, function (selectedItem) {
32488 amit.gupta 229
            let poDate = $('#poDate').val();
32352 amit.gupta 230
            var itemId = selectedItem.itemId;
32360 amit.gupta 231
            if (addItem($html, itemId)) {
32488 amit.gupta 232
                doGetAjaxRequestHandler(`${context}/getPricing?vendorId=${vendorId}&itemId=${itemId}&onDate=${poDate}`, function (response) {
32360 amit.gupta 233
                    if (response !== "null") {
234
                        var jsonObj = JSON.parse(response);
235
                        $html.find('.transferPrice').val(jsonObj.transferPrice);
236
                        $html.find('input.qty').focus();
33727 ranu 237
 
238
                        // Update the total value for this row
239
                        let qty = $html.find('.qty').val();
240
                        let transferPrice = jsonObj.transferPrice;
241
                        if (qty && transferPrice) {
242
                            let total = qty * transferPrice;
243
                            $html.find('.totalValue').val(total);
244
                            updateTotalValue();
245
                        }
32360 amit.gupta 246
                    } else {
247
                        $html.find('.typeaheaditem').val("");
248
                    }
249
                });
250
            } else {
32352 amit.gupta 251
                return false;
252
            }
253
        });
33727 ranu 254
    });
32145 tejbeer 255
 
33727 ranu 256
    $(document).on('input', '.qty', function () {
257
        var $row = $(this).closest('tr');
258
        var qty = parseInt($(this).val());
259
        var transferPrice = parseFloat($row.find('.transferPrice').val());
260
        if (!isNaN(qty) && !isNaN(transferPrice)) {
261
            let total = qty * transferPrice;
262
            $row.find('.totalValue').val(total);
263
        }
264
        updateTotalValue();
32352 amit.gupta 265
    });
32145 tejbeer 266
 
33727 ranu 267
    function updateTotalValue() {
268
        var grandTotal = 0;
269
        $('tbody > tr').each(function () {
270
            var rowTotal = parseFloat($(this).find('.totalValue').val());
271
            if (!isNaN(rowTotal)) {
272
                grandTotal += rowTotal;
273
            }
274
        });
275
        $('#grandTotal').text(grandTotal.toFixed(2));
276
    }
277
 
32355 amit.gupta 278
    function addItem(container, itemId) {
32361 amit.gupta 279
        oldItemId = container.find('.transferPrice').data('itemid');
32360 amit.gupta 280
        if (typeof (oldItemId) === "undefined") {
281
            let itemIndex = purchaseItemIds.indexOf(itemId);
282
            if (itemIndex >= 0) {
283
                alert("Item already added");
32376 amit.gupta 284
                container.find('.typeaheaditem').val("");
32360 amit.gupta 285
                return false;
286
            } else {
287
                purchaseItemIds.push(itemId);
32361 amit.gupta 288
                container.find('.transferPrice').data('itemid', itemId);
32360 amit.gupta 289
                $('.addRowInPurchaseOrder').click();
290
            }
32352 amit.gupta 291
        } else {
32360 amit.gupta 292
            if (oldItemId !== itemId) {
293
                let oldIndex = purchaseItemIds.indexOf(oldItemId);
294
                if (oldIndex > -1) {
295
                    purchaseItemIds.splice(oldIndex, 1);
296
                }
297
                purchaseItemIds.push(itemId);
32361 amit.gupta 298
                container.find('.transferPrice').data('itemid', itemId);
32358 amit.gupta 299
            } else {
32360 amit.gupta 300
                return false;
32352 amit.gupta 301
            }
302
        }
32360 amit.gupta 303
        return true;
32352 amit.gupta 304
    }
32145 tejbeer 305
 
33727 ranu 306
 
32352 amit.gupta 307
    $(document).on('click', '.createSendPurchaseOrder', function () {
32145 tejbeer 308
 
32390 amit.gupta 309
        createPO(true);
32145 tejbeer 310
 
32352 amit.gupta 311
    });
32145 tejbeer 312
 
313
 
32352 amit.gupta 314
    $(document).on('click', '.createPurchaseOrder', function () {
32145 tejbeer 315
 
316
 
32390 amit.gupta 317
        createPO(false);
32352 amit.gupta 318
    });
32145 tejbeer 319
 
320
 
32352 amit.gupta 321
    $(document).on('change', '.qty', function () {
32145 tejbeer 322
 
323
 
32352 amit.gupta 324
        var row = $(this).closest("tr");
325
        var qty = $(row).find(".qty").val();
326
        var transferPrice = $(row).find(".transferPrice").val();
32145 tejbeer 327
 
32352 amit.gupta 328
        var totalVal = transferPrice * qty;
32145 tejbeer 329
 
32352 amit.gupta 330
        var totalValue = $(row).find(".totalValue").val(totalVal);
32145 tejbeer 331
 
32352 amit.gupta 332
        var purchaseOrderValue = 0;
32145 tejbeer 333
 
32352 amit.gupta 334
        $("table > tbody > tr").each(function () {
32145 tejbeer 335
 
32352 amit.gupta 336
            var totalValue = $(this).find(".totalValue").val();
32358 amit.gupta 337
            purchaseOrderValue += totalValue;
32145 tejbeer 338
 
32352 amit.gupta 339
        });
32145 tejbeer 340
 
32352 amit.gupta 341
    });
32145 tejbeer 342
 
343
 
32352 amit.gupta 344
    $(document).on('click', '.warehouse-open-purchase-order', function () {
345
        loadOpenPurchase("main-content");
346
    });
32145 tejbeer 347
 
348
 
32352 amit.gupta 349
    $(document).on('click', '.editViewPurchaseOrder', function () {
350
        var purchaseOrderId = $(this).data('poid');
351
        doGetAjaxRequestHandler(context + "/getEditPOByPurchaseId?purchaseId=" + purchaseOrderId, function (response) {
352
            $('#warehouseEditPurchaseContainer .modal-content').html(response);
353
        });
32145 tejbeer 354
 
32352 amit.gupta 355
    });
32145 tejbeer 356
 
32352 amit.gupta 357
    $(document).on('click', '.editPurchaseOrder', function () {
358
        var purchaseOrderId = $(this).data('poid');
32145 tejbeer 359
 
32352 amit.gupta 360
        editPurchase(false, purchaseOrderId);
32145 tejbeer 361
 
32352 amit.gupta 362
    });
32145 tejbeer 363
 
364
 
32352 amit.gupta 365
    $(document).on('click', '.editSendPurchaseOrder', function () {
366
        var purchaseOrderId = $(this).data('poid');
32145 tejbeer 367
 
368
 
32352 amit.gupta 369
        editPurchase(true, purchaseOrderId);
370
    });
32145 tejbeer 371
 
32352 amit.gupta 372
    $(document).on('click', '.closePurchaseOrder', function () {
373
        var purchaseOrderId = $(this).data('poid');
374
        if (confirm("Are you sure you want to close the PO") == true) {
375
            doPostAjaxRequestHandler(context + "/closePuchaseOrder?purchaseId=" + purchaseOrderId,
376
                function (response) {
32145 tejbeer 377
 
32352 amit.gupta 378
                    console.log(response);
379
                    if (response == 'true') {
380
                        alert("successfully closed");
381
                        loadOpenPurchase("main-content")
382
                    }
383
                });
384
        }
385
    });
32145 tejbeer 386
 
387
 
32352 amit.gupta 388
    $(document).on('click', '.warehouse-view-purchase-order', function () {
389
        doGetAjaxRequestHandler(context + "/viewPurchaseOrder", function (response) {
390
            $('#' + 'main-content').html(response);
391
        });
392
    });
32145 tejbeer 393
 
394
 
32352 amit.gupta 395
    $(document).on('click', '.dateWisePo', function () {
32145 tejbeer 396
 
32352 amit.gupta 397
        var startDate = getDatesFromPicker('input[name="duration"]').startDate;
398
        var endDate = getDatesFromPicker('input[name="duration"]').endDate
32145 tejbeer 399
 
400
 
32352 amit.gupta 401
        doGetAjaxRequestHandler(context + "/getPurchaseOrders?startDate=" + startDate + "&endDate=" + endDate, function (response) {
402
            $('.purchaseorderviewcontainer').html(response);
32145 tejbeer 403
 
32352 amit.gupta 404
        });
32145 tejbeer 405
 
406
 
32352 amit.gupta 407
    });
32145 tejbeer 408
 
409
 
32352 amit.gupta 410
    $(document).on('click', '.viewPurchaseOrderlineItem', function () {
411
        var purchaseOrderId = $(this).data('poid');
32145 tejbeer 412
 
32352 amit.gupta 413
        doGetAjaxRequestHandler(context + "/getWarehouseLineItemByPurchaseId?purchaseId=" + purchaseOrderId, function (response) {
414
            $('#warehouseLineItem .modal-content').html(response);
32145 tejbeer 415
 
32352 amit.gupta 416
        });
417
    });
32145 tejbeer 418
 
419
 
32352 amit.gupta 420
    $(document).on("click", '.removeInPurchaseOrder', function () {
421
        var row = $(this).closest("tr");
32361 amit.gupta 422
        let itemId = row.find('.transferPrice').data('itemid');
32360 amit.gupta 423
        let itemIndex = purchaseItemIds.indexOf(itemId);
32352 amit.gupta 424
        if (itemIndex > -1) { // only splice array when item is found
425
            purchaseItemIds.splice(itemIndex, 1); // 2nd parameter means remove one item only
426
        }
427
        row.remove();
428
    });
32192 tejbeer 429
 
430
 
32352 amit.gupta 431
    $(document).on('click', ".addRowForInvoiceItem", function () {
32145 tejbeer 432
 
32352 amit.gupta 433
        var numitems = $(this).data("numitems");
434
        var invoiceId = $(this).data("invoiceid");
435
        var invoiceItemIds = [];
32360 amit.gupta 436
        var totalQty = 0;
32145 tejbeer 437
 
32352 amit.gupta 438
        $("#invoice-order-table > tbody > tr").each(function () {
439
            var itemId = $(this).find(".rate").data('itemid');
440
            var qty = $(this).find(".qty").val();
32145 tejbeer 441
 
32360 amit.gupta 442
            if (qty !== undefined) {
443
                totalQty += qty;
32352 amit.gupta 444
            }
32145 tejbeer 445
 
32360 amit.gupta 446
            if (itemId !== undefined) {
447
                invoiceItemIds.push(itemId);
32352 amit.gupta 448
            }
449
        });
32145 tejbeer 450
 
32352 amit.gupta 451
        var $html = $('<tr>  <td>  <input type="text" class="form-control typeaheaditem"   autocomplete="off"  placeholder="Search Model"/> </td>' +
452
            '<td>  <input type="number" class="form-control qty"  name = "qty" placeholder="Quantity"/> </td>' +
32364 amit.gupta 453
            '<td>  <input type="number" class="form-control rate" placeholder="Rate"/> </td>' +
32352 amit.gupta 454
            '<td> <input class="form-control btn btn-primary removeInInvoiceItem" type="button" value="Remove"></td>  </tr> ');
32145 tejbeer 455
 
456
 
32352 amit.gupta 457
        getItemAheadOptions($html.find('.typeaheaditem'), true, function (
458
            selectedItem) {
459
            var itemId = selectedItem.itemId;
460
            if (invoiceItemIds.indexOf(itemId) > -1) {
461
                alert("Item already added");
462
                $html.find('.typeaheaditem').val("")
32145 tejbeer 463
 
32352 amit.gupta 464
                return false;
465
            }
466
            $html.find('.rate').data('itemid', itemId)
32145 tejbeer 467
 
32352 amit.gupta 468
            $html.find('.removeInInvoiceItem').data('invoiceid', invoiceId)
469
            $html.find('.removeInInvoiceItem').data('itemid', itemId)
32145 tejbeer 470
 
32352 amit.gupta 471
        });
32145 tejbeer 472
 
32192 tejbeer 473
 
32352 amit.gupta 474
        if (totalQty < numitems) {
32192 tejbeer 475
 
32352 amit.gupta 476
            $('#invoice-order-table tbody').append($html);
477
        }
32192 tejbeer 478
 
32352 amit.gupta 479
    });
32256 tejbeer 480
 
32192 tejbeer 481
 
32352 amit.gupta 482
    $(document).on('click', '.saveInvoiceDetail', function () {
32192 tejbeer 483
 
32352 amit.gupta 484
        var numItems = $(this).data("numitems");
485
        var invoiceId = $(this).data("invoiceid");
486
        var warehouseId = $(this).data("warehouseid");
487
        var supplierId = $(this).data("supplierid");
488
        getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, false);
32192 tejbeer 489
 
32352 amit.gupta 490
    });
32192 tejbeer 491
 
492
 
32352 amit.gupta 493
    $(document).on('click', '.validateInvoiceDetail', function () {
494
        var numItems = $(this).data("numitems");
495
        var invoiceId = $(this).data("invoiceid");
496
        var warehouseId = $(this).data("warehouseid");
497
        var supplierId = $(this).data("supplierid");
32192 tejbeer 498
 
32352 amit.gupta 499
        getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, true);
32192 tejbeer 500
 
32352 amit.gupta 501
    });
32192 tejbeer 502
 
503
 
32352 amit.gupta 504
    $(document).on("click", '.removeInInvoiceItem', function () {
32192 tejbeer 505
 
32352 amit.gupta 506
        var row = $(this).closest("tr");
507
        var invoiceId = $(this).data("invoiceid");
508
        var itemId = $(this).data("itemid");
509
        if (invoiceId != undefined && itemId != undefined) {
510
            doDeleteAjaxRequestHandler(context + "/removeInvoiceItem?invoiceId="
511
                + invoiceId + "&itemId=" + itemId, function (response) {
512
                if (response == "true") {
513
                    alert("Item removed successfully");
32192 tejbeer 514
 
32352 amit.gupta 515
                }
516
            });
517
        }
32192 tejbeer 518
 
32352 amit.gupta 519
        row.remove();
32192 tejbeer 520
 
32352 amit.gupta 521
    });
32192 tejbeer 522
 
523
 
32352 amit.gupta 524
    $(document).on('click', '.purchaseGrn', function () {
32192 tejbeer 525
 
32352 amit.gupta 526
        var grnItemArray = [];
32192 tejbeer 527
 
32352 amit.gupta 528
        var invoiceId = $(this).data("invoiceid");
32192 tejbeer 529
 
530
 
32352 amit.gupta 531
        $("#invoice-purchase-validate > tbody > tr").each(function () {
532
            var grnItemJson = {};
32192 tejbeer 533
 
32352 amit.gupta 534
            var itemId = $(this).find(".itemId").text();
535
            var qty = $(this).find(".qty").text();
536
            var poId = $(this).find(".purchaseId").text();
537
            var excessQty = $(this).find(".excessQty").text();
538
            var itemType = $(this).find(".itemType").text();
32192 tejbeer 539
 
32352 amit.gupta 540
            console.log(itemType);
32192 tejbeer 541
 
32352 amit.gupta 542
            if (itemType == "Serialized") {
543
                var serialNumbers = $(this).find(".imeis-to-grn").tagsinput('items');
32366 amit.gupta 544
                grnItemJson['serialNumbers'] = serialNumbers;
32192 tejbeer 545
 
32352 amit.gupta 546
                if (excessQty > 0) {
547
                    var returnSerialNumbers = $(this).find(".imeis-to-grn-return").tagsinput('items');
548
                    grnItemJson['returnSerialNumbers'] = returnSerialNumbers
549
                }
550
            }
32366 amit.gupta 551
            console.log(serialNumbers);
32352 amit.gupta 552
            grnItemJson['itemId'] = itemId;
553
            grnItemJson['serialNumbers'] = serialNumbers
554
            grnItemJson['qty'] = qty
555
            grnItemJson['poId'] = poId
556
            grnItemJson['invoiceId'] = invoiceId
557
            grnItemJson['itemType'] = itemType
558
            grnItemJson['excessQty'] = excessQty
32192 tejbeer 559
 
32352 amit.gupta 560
            grnItemJson['returnSerialNumbers'] = returnSerialNumbers
32192 tejbeer 561
 
32352 amit.gupta 562
            grnItemArray.push(grnItemJson)
32192 tejbeer 563
 
32352 amit.gupta 564
            console.log(grnItemArray)
32192 tejbeer 565
 
32352 amit.gupta 566
        });
32192 tejbeer 567
 
32352 amit.gupta 568
        for (var i = 0; i < grnItemArray.length; i++) {
32366 amit.gupta 569
            var itemType = grnItemArray[i].itemType;
32192 tejbeer 570
 
32352 amit.gupta 571
            if (itemType == "Serialized") {
572
                var excessQty = grnItemArray[i].excessQty
32192 tejbeer 573
 
574
 
32352 amit.gupta 575
                var serialNumbers = grnItemArray[i].serialNumbers.length
576
                var qty = grnItemArray[i].qty
32192 tejbeer 577
 
32352 amit.gupta 578
                if (serialNumbers != qty) {
579
                    alert("serial number is not matched with qty")
580
                    return false;
581
                }
32192 tejbeer 582
 
32352 amit.gupta 583
                if (excessQty > 0) {
32192 tejbeer 584
 
32352 amit.gupta 585
                    var returnSerialNumbers = grnItemArray[i].returnSerialNumbers.length
32192 tejbeer 586
 
32352 amit.gupta 587
                    if (returnSerialNumbers != excessQty) {
588
                        alert("Return serial number is not matched with excess qty")
589
                        return false;
590
                    }
32192 tejbeer 591
 
32352 amit.gupta 592
                }
593
            }
32192 tejbeer 594
 
32352 amit.gupta 595
        }
32192 tejbeer 596
 
597
 
32352 amit.gupta 598
        console.log(JSON.stringify(grnItemArray))
599
        if (confirm("Are you sure you want to grn purchase order") == true) {
32192 tejbeer 600
 
32352 amit.gupta 601
            doPostAjaxRequestWithJsonHandler(context
602
                + "/createGrn", JSON
603
                .stringify(grnItemArray), function (response) {
604
                if (response == 'true') {
605
                    alert("successfully done");
606
                    loadNewReceiveInvoice("main-content");
607
                }
608
            });
609
        }
32192 tejbeer 610
 
611
 
32352 amit.gupta 612
    });
32256 tejbeer 613
 
614
 
32352 amit.gupta 615
    $(document).on('click', '.grnRequest', function () {
32192 tejbeer 616
 
32352 amit.gupta 617
        var grnRequestJson = {};
618
        var grnRequestItemArray = [];
32192 tejbeer 619
 
32352 amit.gupta 620
        var invoiceId = $(this).data("invoiceid");
32192 tejbeer 621
 
622
 
32352 amit.gupta 623
        $("#invoice-purchase-validate > tbody > tr").each(function () {
624
            var grnItemJson = {};
32192 tejbeer 625
 
32352 amit.gupta 626
            var itemId = $.trim($(this).find(".itemId").text());
627
            var poId = $.trim($(this).find(".purchaseId").text());
32192 tejbeer 628
 
32352 amit.gupta 629
            var qty = parseInt($(this).find(".qty").text());
32256 tejbeer 630
 
32352 amit.gupta 631
            var excessQty = parseInt($(this).find(".excessQty").text());
32256 tejbeer 632
 
32352 amit.gupta 633
            var priceMismatch = $.trim($(this).find(".priceMismatch").text());
634
            console.log(priceMismatch)
32256 tejbeer 635
 
636
 
32354 amit.gupta 637
            if (priceMismatch !== "" || excessQty > 0) {
32352 amit.gupta 638
                console.log(typeof priceMismatch)
639
                console.log(excessQty)
640
                grnItemJson['itemId'] = itemId;
641
                grnItemJson['qty'] = qty;
642
                grnItemJson['excessQty'] = excessQty
32376 amit.gupta 643
                if (priceMismatch === '') {
644
                    grnItemJson['mismatch'] = 'QtyMismatch';
645
                } else {
646
                    grnItemJson['mismatch'] = priceMismatch
647
                }
32352 amit.gupta 648
                grnItemJson['poId'] = poId
32192 tejbeer 649
 
32352 amit.gupta 650
                grnRequestItemArray.push(grnItemJson)
651
            }
652
        });
32256 tejbeer 653
 
32352 amit.gupta 654
        console.log(grnRequestItemArray)
32256 tejbeer 655
 
656
 
32352 amit.gupta 657
        grnRequestJson['invoiceId'] = invoiceId;
658
        grnRequestJson['warehousePurchaseModel'] = grnRequestItemArray
32256 tejbeer 659
 
32366 amit.gupta 660
        if (confirm("Are you sure you want to raise grn request")) {
32192 tejbeer 661
 
32352 amit.gupta 662
            doPostAjaxRequestWithJsonHandler(context
663
                + "/grnRequest", JSON
664
                .stringify(grnRequestJson), function (response) {
665
                if (response == 'true') {
666
                    alert("successfully done");
667
                    loadNewReceiveInvoice("main-content");
668
                }
669
            });
670
        }
32192 tejbeer 671
 
672
 
32352 amit.gupta 673
    });
32192 tejbeer 674
 
32256 tejbeer 675
 
32352 amit.gupta 676
    $(document).on('click', '.resolvedPriceMismatchRequest', function () {
677
        var id = $(this).data("id");
32256 tejbeer 678
 
32352 amit.gupta 679
        var invoiceId = $(this).data("invoiceid");
32256 tejbeer 680
 
32352 amit.gupta 681
        var requestId = $(this).data("requestid");
32256 tejbeer 682
 
32352 amit.gupta 683
        var mismatch = $(this).data("mismatch");
32256 tejbeer 684
 
32352 amit.gupta 685
        if (mismatch == "InvoiceMismatch") {
32485 amit.gupta 686
            if (confirm("Are you sure you want to resolve invoice mismatch")) {
32352 amit.gupta 687
                doGetAjaxRequestHandler(context + "/resolvedMismatchRequest?id=" + id, function (response) {
688
                    if (response == 'true') {
689
                        getGrnRequestItems(requestId, invoiceId)
690
                    }
691
                });
32256 tejbeer 692
 
32352 amit.gupta 693
            }
694
        } else if (mismatch == "PoMismatch") {
695
            if (confirm("Are you sure you want to resolve Po Mismatch. Discard the current PoLineItem new Po will generate on the invoice date.") == true) {
32256 tejbeer 696
 
32352 amit.gupta 697
                doGetAjaxRequestHandler(context + "/resolvedMismatchRequest?id=" + id, function (response) {
698
                    if (response == 'true') {
699
                        getGrnRequestItems(requestId, invoiceId)
700
                    }
701
                });
32256 tejbeer 702
 
32352 amit.gupta 703
            }
704
        }
32256 tejbeer 705
 
32352 amit.gupta 706
    });
32256 tejbeer 707
 
708
 
32352 amit.gupta 709
    $(document).on('click', '.resolvedQtyMismatchRequest', function () {
710
        var id = $(this).data("id");
711
        var invoiceId = $(this).data("invoiceid");
712
        var requestId = $(this).data("requestid");
32256 tejbeer 713
 
714
 
32352 amit.gupta 715
        var mismatch = $(this).data("mismatch");
32256 tejbeer 716
 
32352 amit.gupta 717
        var $row = $(this).closest("tr");
718
        var requiredQty = $row.find(".requiredQty").val();
32256 tejbeer 719
 
32352 amit.gupta 720
        console.log(requiredQty);
32256 tejbeer 721
 
32352 amit.gupta 722
        if (mismatch == "QtyMismatch") {
723
            if (confirm("Are you sure you want to resolve qty mismatch") == true) {
32256 tejbeer 724
 
32352 amit.gupta 725
                doGetAjaxRequestHandler(context + "/resolvedMismatchRequest?id=" + id + "&requiredQty=" + requiredQty, function (response) {
726
                    if (response == 'true') {
727
                        getGrnRequestItems(requestId, invoiceId)
728
                    }
729
                });
32256 tejbeer 730
 
32352 amit.gupta 731
            }
732
        }
32256 tejbeer 733
 
32352 amit.gupta 734
    });
32256 tejbeer 735
 
32192 tejbeer 736
 
32145 tejbeer 737
});
738
 
739
function loadCreatePurchase(domId) {
32352 amit.gupta 740
    doGetAjaxRequestHandler(context + "/warehousePurchaseOrder", function (response) {
741
        $('#' + domId).html(response);
742
    });
32145 tejbeer 743
}
744
 
32192 tejbeer 745
 
32145 tejbeer 746
function loadOpenPurchase(domId) {
747
 
32352 amit.gupta 748
    doGetAjaxRequestHandler(context + "/getOpenPurchaseOrder", function (response) {
749
        $('#' + domId).html(response);
750
    });
32145 tejbeer 751
}
752
 
32192 tejbeer 753
function loadNewReceiveInvoice(domId) {
32352 amit.gupta 754
    doGetAjaxRequestHandler(context + "/newReceiveInvoice", function (response) {
755
        $('#' + domId).html(response);
756
    });
32192 tejbeer 757
}
758
 
32256 tejbeer 759
 
760
function loadGrnRequest(domId) {
32352 amit.gupta 761
    doGetAjaxRequestHandler(context + "/grnRequest", function (response) {
762
        $('#' + domId).html(response);
763
    });
32256 tejbeer 764
}
765
 
766
function loadDebitNote(domId) {
32352 amit.gupta 767
    doGetAjaxRequestHandler(context + "/getDebitNote", function (response) {
768
        $('#' + domId).html(response);
769
    });
32256 tejbeer 770
}
771
 
32300 tejbeer 772
function loadWarehouseInvoices(domId) {
32352 amit.gupta 773
    doGetAjaxRequestHandler(context + "/getWarehouseInvoices", function (response) {
774
        $('#' + domId).html(response);
775
    });
32300 tejbeer 776
}
777
 
32390 amit.gupta 778
function createPO(sendPo) {
32352 amit.gupta 779
    var purchaseOrder = {};
32145 tejbeer 780
 
32352 amit.gupta 781
    var vendorId = $('#vendorId').val();
32145 tejbeer 782
 
32352 amit.gupta 783
    var warehouseId = $('#warehouseMap').val();
32145 tejbeer 784
 
32390 amit.gupta 785
    var poDate = $('#poDate').val();
32145 tejbeer 786
 
32390 amit.gupta 787
 
32352 amit.gupta 788
    var items = []
789
    $("table > tbody > tr").each(function () {
790
        var purchaseOrderJson = {};
32145 tejbeer 791
 
32352 amit.gupta 792
        var itemId = $(this).find(".transferPrice").data('itemid');
793
        var qty = $(this).find(".qty").val();
794
        var transferPrice = $(this).find(".transferPrice").val();
795
        var totalValue = $(this).find(".totalValue").val();
32145 tejbeer 796
 
797
 
32352 amit.gupta 798
        purchaseOrderJson['itemId'] = itemId;
799
        purchaseOrderJson['amendedQty'] = qty
800
        purchaseOrderJson['totalValue'] = totalValue
801
        purchaseOrderJson['transferPrice'] = transferPrice
32145 tejbeer 802
 
32352 amit.gupta 803
        items.push(purchaseOrderJson)
804
    });
32145 tejbeer 805
 
806
 
32352 amit.gupta 807
    for (var i = 0; i < items.length; i++) {
808
        console.log(items[i])
32145 tejbeer 809
 
32352 amit.gupta 810
        var itemId = items[i].itemId
811
        var qty = items[i].amendedQty
812
        var transferPrice = items[i].transferPrice
813
        var totalValue = items[i].totalValue
32145 tejbeer 814
 
32352 amit.gupta 815
        if (itemId === "" && qty === "" && transferPrice === "" && totalValue === "") {
816
            alert("Field can't be empty");
817
            return false;
818
        }
32145 tejbeer 819
 
820
 
32352 amit.gupta 821
        if (itemId === "") {
822
            alert("please select item");
823
            return false;
824
        }
825
        if (qty === "") {
826
            alert("please choose qty");
827
            return false;
828
        }
32145 tejbeer 829
 
32352 amit.gupta 830
        if (transferPrice === "") {
831
            alert("Transfer Price can't be empty");
832
            return false;
833
        }
834
        if (totalValue === "") {
835
            alert("Total value can't be empty");
836
            return false;
837
        }
32145 tejbeer 838
 
32352 amit.gupta 839
        if (qty <= 0) {
840
            alert("Please fill Qty");
841
            return false;
842
        }
32145 tejbeer 843
 
844
 
32352 amit.gupta 845
    }
32261 tejbeer 846
 
32352 amit.gupta 847
    purchaseOrder['vendorId'] = vendorId;
848
    purchaseOrder['warehouseId'] = warehouseId
849
    purchaseOrder['sendPo'] = sendPo
32390 amit.gupta 850
    purchaseOrder['poDate'] = poDate;
32352 amit.gupta 851
    purchaseOrder['items'] = items
32145 tejbeer 852
 
32352 amit.gupta 853
    console.log(purchaseOrder)
32145 tejbeer 854
 
855
 
32352 amit.gupta 856
    if (confirm("Are you sure you want to create purchase order") == true) {
32145 tejbeer 857
 
32352 amit.gupta 858
        doPostAjaxRequestWithJsonHandler(context
859
            + "/createPurchaseOrder", JSON
860
            .stringify(purchaseOrder), function (response) {
861
            if (response == 'true') {
862
                alert("successfully created");
863
                loadCreatePurchase("main-content");
864
            }
865
        });
866
    }
32145 tejbeer 867
 
868
}
869
 
870
 
871
function editPurchase(sendPo, poid) {
32352 amit.gupta 872
    var editpurchaseOrder = {}
873
    var items = []
874
    $("#purchase-edit-lineitem > tbody > tr").each(function () {
875
        var purchaseOrderJson = {};
876
        var itemId = $(this).find("td:eq(0)").text();
32145 tejbeer 877
 
32352 amit.gupta 878
        var qty = $(this).find("td:eq(2)").text();
32145 tejbeer 879
 
32352 amit.gupta 880
        var amendedQty = $(this).find(".editqty").val();
32256 tejbeer 881
 
32352 amit.gupta 882
        var transferPrice = $.trim($(this).find(".transferPrice").html());
32256 tejbeer 883
 
884
 
32352 amit.gupta 885
        purchaseOrderJson['itemId'] = itemId;
886
        purchaseOrderJson['amendedQty'] = parseInt(amendedQty)
887
        purchaseOrderJson['qty'] = parseInt(qty)
888
        purchaseOrderJson['transferPrice'] = transferPrice
32145 tejbeer 889
 
32352 amit.gupta 890
        items.push(purchaseOrderJson)
891
    });
32145 tejbeer 892
 
893
 
32352 amit.gupta 894
    for (var i = 0; i < items.length; i++) {
895
        console.log(items[i])
32145 tejbeer 896
 
32352 amit.gupta 897
        var amendedQty = items[i].amendedQty
898
        var qty = items[i].qty
32145 tejbeer 899
 
32256 tejbeer 900
 
32352 amit.gupta 901
        if (amendedQty === "") {
902
            alert("please choose qty");
903
            return false;
904
        }
32145 tejbeer 905
 
32352 amit.gupta 906
        if (amendedQty < qty) {
907
            alert("Quantity should be greater than existing qty");
908
            return false;
909
        }
32145 tejbeer 910
 
911
 
32352 amit.gupta 912
    }
32145 tejbeer 913
 
32352 amit.gupta 914
    editpurchaseOrder['purchaseOrderId'] = poid;
915
    editpurchaseOrder['sendPo'] = sendPo
916
    editpurchaseOrder['items'] = items
32145 tejbeer 917
 
918
 
32352 amit.gupta 919
    if (confirm("Are you sure you want to edit purchase order") == true) {
32145 tejbeer 920
 
32352 amit.gupta 921
        doPostAjaxRequestWithJsonHandler(context
922
            + "/editPurchaseOrder", JSON
923
            .stringify(editpurchaseOrder), function (response) {
924
            if (response == 'true') {
925
                alert("successfully created");
926
                $('#warehouseEditPurchaseContainer').modal('hide');
927
                $('.modal-backdrop').remove();
32295 tejbeer 928
 
32352 amit.gupta 929
                loadOpenPurchase("main-content")
930
            }
931
        });
932
    }
32145 tejbeer 933
 
934
}
935
 
936
 
32192 tejbeer 937
function getInvoiceItemData(numItems, invoiceId, warehouseId, supplierId, validate) {
938
 
32352 amit.gupta 939
    var invoiceJson = {};
940
    console.log(numItems)
941
    var totalQty = 0;
942
    var invoiceItems = []
943
    $("#invoice-order-table > tbody > tr").each(function () {
944
        var invoiceItemJson = {};
945
        var itemId = $(this).find(".rate").data('itemid');
946
        var qty = $(this).find(".qty").val();
32192 tejbeer 947
 
32352 amit.gupta 948
        if (qty != undefined) {
949
            totalQty += parseInt(qty)
950
        }
951
        var rate = $(this).find(".rate").val();
952
        invoiceItemJson['itemId'] = itemId;
953
        invoiceItemJson['qty'] = qty
954
        invoiceItemJson['rate'] = rate
955
        invoiceItems.push(invoiceItemJson)
956
    });
32192 tejbeer 957
 
958
 
32352 amit.gupta 959
    for (var i = 0; i < invoiceItems.length; i++) {
32192 tejbeer 960
 
32352 amit.gupta 961
        var itemId = invoiceItems[i].itemId
962
        var qty = invoiceItems[i].qty
963
        var rate = invoiceItems[i].rate
964
        if (itemId === "" && qty === "" && rate === "") {
965
            alert("Field can't be empty");
966
            return false;
967
        }
32192 tejbeer 968
 
32352 amit.gupta 969
        if (itemId === "") {
970
            alert("please select item");
971
            return false;
972
        }
973
        if (qty === "") {
974
            alert("please choose qty");
975
            return false;
976
        }
32192 tejbeer 977
 
32352 amit.gupta 978
        if (rate === "") {
979
            alert("Rate can't be empty");
980
            return false;
981
        }
32192 tejbeer 982
 
32352 amit.gupta 983
    }
32192 tejbeer 984
 
32352 amit.gupta 985
    console.log(totalQty)
32192 tejbeer 986
 
32352 amit.gupta 987
    if (totalQty > numItems) {
988
        alert("Qty Should not be more than  Invoice items");
989
        return false;
990
    }
32192 tejbeer 991
 
32352 amit.gupta 992
    if (validate) {
32192 tejbeer 993
 
32352 amit.gupta 994
        if (totalQty != numItems) {
995
            alert("Qty Should not match with Invoice items");
996
            return false;
997
        }
998
    }
32192 tejbeer 999
 
1000
 
32352 amit.gupta 1001
    invoiceJson['invoiceId'] = invoiceId;
1002
    invoiceJson['warehouseId'] = warehouseId;
1003
    invoiceJson['supplierId'] = supplierId;
1004
    invoiceJson['invoiceItems'] = invoiceItems
1005
    if (validate) {
1006
        validateInvoiceItems(invoiceJson);
1007
    } else {
1008
        saveInvoiceItems(invoiceJson)
1009
    }
32192 tejbeer 1010
}
1011
 
1012
 
1013
function saveInvoiceItems(invoiceJson) {
1014
 
1015
 
32352 amit.gupta 1016
    if (confirm("Are you sure you want to save invoice item") == true) {
32192 tejbeer 1017
 
32352 amit.gupta 1018
        doPostAjaxRequestWithJsonHandler(context
1019
            + "/invoiceItemDetail", JSON
1020
            .stringify(invoiceJson), function (response) {
1021
            if (response == 'true') {
1022
                getInvoiceItems(invoiceJson.invoiceId);
1023
            }
1024
        });
1025
    }
32192 tejbeer 1026
 
1027
}
1028
 
1029
 
1030
function validateInvoiceItems(invoiceJson) {
1031
 
1032
 
32352 amit.gupta 1033
    if (confirm("Are you sure you want to validate invoice item") == true) {
32192 tejbeer 1034
 
32352 amit.gupta 1035
        doPostAjaxRequestWithJsonHandler(context
1036
            + "/validateInvoiceItemDetail", JSON
1037
            .stringify(invoiceJson), function (response) {
1038
            $('.invoiceadditemcontainer').html(response);
32192 tejbeer 1039
 
32352 amit.gupta 1040
        });
1041
    }
32192 tejbeer 1042
 
1043
}
1044
 
1045
function getOpenPOFromWarehouse() {
1046
 
32352 amit.gupta 1047
    var warehouseId = $('#warehouseMap').val();
1048
    doGetAjaxRequestHandler(context + "/getOpenPurchaseOrderByWarehouseId?warehouseId=" + warehouseId, function (response) {
1049
        $('#warehouseManagePuchaseContainer').html(response);
1050
    });
32192 tejbeer 1051
 
1052
 
1053
}
1054
 
1055
function getPurchaseLineitem(poId) {
1056
 
1057
 
32352 amit.gupta 1058
    doGetAjaxRequestHandler(context + "/getPurchaseOrderItemByPoId?poId=" + poId, function (response) {
1059
        $('#warehouseManagePuchaseItemContainer').html(response);
1060
        $('#warehousepurchaseitemgrn').hide()
1061
    });
32192 tejbeer 1062
 
1063
 
1064
}
1065
 
1066
 
1067
function getInvoiceItems(invoiceId) {
1068
 
32352 amit.gupta 1069
    doGetAjaxRequestHandler(context + "/getInvoiceItems?invoiceId=" + invoiceId, function (response) {
1070
        $('.invoiceadditemcontainer').html(response);
32192 tejbeer 1071
 
32352 amit.gupta 1072
    });
32192 tejbeer 1073
}
1074
 
1075
 
32256 tejbeer 1076
function getGrnRequestItems(requestId, invoiceId) {
32352 amit.gupta 1077
    doGetAjaxRequestHandler(context + "/grnRequestItem?requestId=" + requestId + "&invoiceId=" + invoiceId, function (response) {
1078
        $('.grnRequestItemContainer').html(response);
32256 tejbeer 1079
 
32352 amit.gupta 1080
    });
32256 tejbeer 1081
}
1082
 
32912 amit.gupta 1083
function removeInvoice(invoiceId) {
1084
    if(confirm(`Are your sure want to delete invoiceId ${invoiceId}`)) {
1085
        doGetAjaxRequestHandler(`${context}/removeInvoice?invoiceId=${invoiceId}`, function (response) {
1086
            $('#open-invoices').DataTable().row("#"+invoiceId).remove().draw();
1087
            alert("Invoice Removed");
1088
        });
1089
    }
1090
}
32256 tejbeer 1091
 
32912 amit.gupta 1092
function removeGrnRequest(invoiceId) {
1093
    if(confirm(`Are your sure want to remove grn request for invoiceId ${invoiceId}`)) {
1094
        doGetAjaxRequestHandler(`${context}/removeGrnRequest?invoiceId=${invoiceId}`, function (response) {
1095
            $('#' + domId).html(response);
1096
            alert("Grn Request Removed");
1097
        });
1098
    }
1099
}
1100
 
1101