Subversion Repositories SmartDukaan

Rev

Rev 33253 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<style>
    .tdInput .bootstrap-tagsinput {
        width: 100%;
    }
</style>
<div class="well" style="padding: 10px;">
    <p><b>#<span id="selectedTransactionId"></span> - Order List</b></p>
    <input type="hidden" id="selectedWarehouseId">
    <h4>In Stock </h4>
    <table id="wareHouseTransactionTable" class="table table-striped table-advance table-hover" style="width:100%">
        <thead>
        <tr>
            <th>Id</th>
            <th>Product Desc</th>
            <th>Scanned Qty</th>
            <th>U.Price</th>
            <th>Imeis/Quantity to Bill</th>
        </tr>
        </thead>
        <tbody>
            #if(!$inStockOrdersSerialized.isEmpty())
                #foreach($order in $inStockOrdersSerialized)
                <tr class="main-tr">
                    <td class="orderId">$order.getId()</td>
                    <td>$order.getLineItem().getItemDescription()</td>
                    <td><span class="remainQty">0</span> / <span class="qty">$order.getLineItem().getQuantity()</span>
                    </td>
                    <td>$order.getLineItem().getUnitPrice()</td>
                    #if($order.getLineItem().getItem().getType()=="SERIALIZED")
                        <td style="width: 35%;" class="tdInput"><input type="text" class="imeis-to-grn form-control"
                                                                       placeholder=""></td>
                    #end
                </tr>
                    #foreach($agingModelEntry in $allOrderSerialNumberMap.entrySet())
                        #if($agingModelEntry.getKey() == $order.getId())
                            #set($agingModelMap = $agingModelEntry.getValue())
                            #foreach($agingModel in $agingModelMap.entrySet())
                                #set($agingModelValueMap = $agingModel.getValue())
                                #foreach ($aging in $agingModelValueMap.entrySet())
                                    #if($agingModelValueMap)
                                    <tr>
                                        <td colspan="5">
                                            <table class="table table-responsive table-bordered"
                                                   style="margin-bottom: 0;">
                                                <tbody>

                                                <tr>
                                                    <td style="width: 20%;"><span><b>Age : </b></span>$aging.getKey()
                                                        Days Old
                                                    </td>
                                                    <td>

                                                        #foreach ($value in $aging.getValue())
                                                            <input type="hidden" class="agingserialNumber"
                                                                   value="$value.getSerialNumber()">
                                                            <span>$value.getMofSerialNumber(),</span>
                                                        #end
                                                    </td>
                                                </tr>

                                                </tbody>

                                            </table>
                                        </td>
                                    </tr>
                                    #end

                                #end

                            #end
                        #end
                    #end
                #end
            #end
            #if(!$inStockOrdersNonSerialized.isEmpty())
                #foreach($order in $inStockOrdersNonSerialized)
                <tr class="main-tr">
                    <td class="orderId">$order.getId()</td>
                    <td>$order.getLineItem().getItemDescription()</td>
                    <td><span class="remainQty">0</span> / <span class="qty">$order.getLineItem().getQuantity()</span>
                    </td>
                    <td>$order.getLineItem().getUnitPrice()</td>
                    <td><input type="text" class="form-control filledQty" placeholder="Fill Qty"></td>
                </tr>
                <tr>
                    <td colspan="5">Available Quantity :
                        - $orderIdStockAvailabilityMap.getOrDefault($order.getId(),0)</td>
                </tr>
                #end
            #end
            #if($inStockOrdersSerialized.isEmpty() && $inStockOrdersNonSerialized.isEmpty())
            <tr>
                <td colspan="5"> No Order Found</td>
            </tr>
            #end
        </tbody>
    </table>
    <div class="row">
        <div class="col-md-12">
            <button type="button" class="btn btn-info pull-right order_accepted">Generate Bill</button>
        </div>
    </div>
</div>
<div class="clearfix"></div><br>
<div class="well" style="padding: 10px;">
    <h4>Out of Stock </h4>
    <table id="wareHouseTransactionTable" class="table table-striped table-advance table-hover" style="width:100%">
        <thead>
        <tr>
            <th>Id</th>
            <th>Product Desc</th>
            <th>Scanned Qty</th>
            <th>U.Price</th>
        </tr>
        </thead>
        <tbody>
            #if(!$oOSOrdersSerialized.isEmpty())
                #foreach($order in $oOSOrdersSerialized)
                <tr class="main-tr">
                    <td class="orderId">$order.getId()</td>
                    <td>$order.getLineItem().getItemDescription()</td>
                    <td><span class="remainQty">0</span> / <span class="qty">$order.getLineItem().getQuantity()</span>
                    </td>
                    <td>$order.getLineItem().getUnitPrice()</td>
                </tr>
                #end
            #end
            #if(!$outOfStockOrdersNonSerialized.isEmpty())
                #foreach($order in $outOfStockOrdersNonSerialized)
                <tr class="main-tr">
                    <td class="orderId">$order.getId()</td>
                    <td>$order.getLineItem().getItemDescription()</td>
                    <td><span class="remainQty">0</span> / <span class="qty">$order.getLineItem().getQuantity()</span>
                    </td>
                    <td>$order.getLineItem().getUnitPrice()</td>
                </tr>
                #end
            #end
            #if($outOfStockOrders.isEmpty() && $outOfStockOrdersNonSerialized.isEmpty())
            <tr>
                <td colspan="4"> No Order Found</td>
            </tr>
            #end
        </tbody>
    </table>
</div>
<script>
    $(document).ready(function () {
        $("#wareHouseTransactionTable > tbody > tr").each(function () {
            var qtyElem = $(this).find(".qty");
            var remainQtyElem = $(this).find(".remainQty");
            var qty = parseInt(qtyElem.text()); // Get initial quantity
            var imeiInputElem = $(this).find(".imeis-to-grn");

            imeiInputElem.on('itemAdded itemRemoved', function () {
                remainQtyElem.text(imeiInputElem.tagsinput('items').length); // Update displayed quantity
            });

            imeiInputElem.tagsinput({
                maxTags: qty,
                trimValue: true,
                allowDuplicates: false,
                confirmKeys: [13, 44, 188, 32],
                delimiterRegex: /[,\s]/,
                tagClass: function (item) {
                    if (item.valid == null) return 'label label-primary';
                    if (item.valid) {
                        return 'label label-success';
                    } else {
                        return 'label label-danger';
                    }
                },
            });

            imeiInputElem.on('itemAdded', function (event) {
                var enteredValue = event.item;
                var serialNumbers = []; // Array to store all aging serial numbers within this row

                // Collect all aging serial numbers within this row
                imeiInputElem.closest("tr").nextUntil('.main-tr').find(".agingserialNumber").each(function () {
                    // $(".agingserialNumber").each(function() {
                    serialNumbers.push($(this).val());
                });
                console.log("serial number {}", serialNumbers);

                // Check if entered value exists in any aging serial number within this row
                if (!serialNumbers.includes(enteredValue)) {
                    $('.bootstrap-tagsinput').find('.tag').last().removeClass('label-primary');
                    $('.bootstrap-tagsinput').find('.tag').last().addClass('label-danger');
                }
            });


        });
    });
</script>