Subversion Repositories SmartDukaan

Rev

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

Rev 34373 Rev 36532
Line 62... Line 62...
62
    $(document).on('click', ".mk_moveToBill", function () {
62
    $(document).on('click', ".mk_moveToBill", function () {
63
        var warehouseId = $(this).data("warehouseid");
63
        var warehouseId = $(this).data("warehouseid");
64
        var transactionId = $(this).data("transactionid");
64
        var transactionId = $(this).data("transactionid");
65
        var orderId = $(this).data("orderid");
65
        var orderId = $(this).data("orderid");
66
        doGetAjaxRequestHandler(`${context}/om/moveToBill?warehouseId=${warehouseId}&orderId=${orderId}`, function (response) {
66
        doGetAjaxRequestHandler(`${context}/om/moveToBill?warehouseId=${warehouseId}&orderId=${orderId}`, function (response) {
-
 
67
            var result = typeof response === 'string' ? JSON.parse(response) : response;
-
 
68
            if (result.moved === true) {
-
 
69
                alert("Order moved successfully");
67
            loadTransactionDetail(transactionId, warehouseId, "transaction-detail-container");
70
                loadTransactionDetail(transactionId, warehouseId, "transaction-detail-container");
-
 
71
                return;
-
 
72
            }
-
 
73
            if (result.needsInput) {
-
 
74
                var msg = "Order Qty: " + result.orderQty +
-
 
75
                    "\nNet Available (free stock): " + result.netAvailability +
-
 
76
                    "\nMax Available (includes reserved): " + result.maxAvailability +
-
 
77
                    "\n\nWarehouses:";
-
 
78
                for (var i = 0; i < result.warehouses.length; i++) {
-
 
79
                    var wh = result.warehouses[i];
-
 
80
                    msg += "\n  WH " + wh.warehouseId + " - Available: " + wh.availability + ", Reserved: " + wh.reserved + ", Net: " + wh.netAvailability;
-
 
81
                }
-
 
82
                msg += "\n\nEnter qty to move and warehouse ID (e.g. 5,3 for qty=5 to warehouse 3):";
-
 
83
                var input = prompt(msg);
-
 
84
                if (input) {
-
 
85
                    var parts = input.split(",");
-
 
86
                    var qty = parseInt(parts[0].trim());
-
 
87
                    var fWhId = parseInt(parts[1].trim());
-
 
88
                    if (isNaN(qty) || isNaN(fWhId)) {
-
 
89
                        alert("Invalid input");
-
 
90
                        return;
-
 
91
                    }
-
 
92
                    doGetAjaxRequestHandler(`${context}/om/moveToBillWithQty?orderId=${orderId}&qty=${qty}&fulfilmentWarehouseId=${fWhId}`, function () {
-
 
93
                        alert("Order moved successfully");
-
 
94
                        loadTransactionDetail(transactionId, warehouseId, "transaction-detail-container");
-
 
95
                    });
-
 
96
                }
-
 
97
            } else {
-
 
98
                alert(result.message || "Could not move order");
-
 
99
            }
68
        });
100
        });
69
    });
101
    });
70
    $(document).on('click', ".changeWarehouse-mk", function () {
102
    $(document).on('click', ".changeWarehouse-mk", function () {
71
        var itemId = $(this).data("itemid");
103
        var itemId = $(this).data("itemid");
72
        var warehouseId = $(this).data("warehouseid");
104
        var warehouseId = $(this).data("warehouseid");