Subversion Repositories SmartDukaan

Rev

Rev 32311 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<div class="row">
    <div class="col-lg-12">
        <table class="table table-border table-condensed table-bordered" id="invoice-purchase-validate"
               style="width:100%">
            <thead>
            <tr>

                <th>Po Id</th>
                <th>Item Id</th>
                <th>Item</th>
                <th>Type</th>
                <th>Qty</th>
                <th>Excess Qty</th>
                <th>Price Mismatch</th>
                <th>Issues</th>
                <th>Imeis</th>
                <th>Return Imeis</th>


            </tr>
            </thead>
            <tbody>
                #if(!$invoicePurchaseModel.getWarehousePurchaseModel().isEmpty())
                    #foreach($invoicePurchase in $invoicePurchaseModel.getWarehousePurchaseModel())
                    <tr>
                        <td class="purchaseId"> $invoicePurchase.getPoId()</td>
                        <td class="itemId"> $invoicePurchase.getItemId() </td>
                        <td> $invoicePurchase.getItemDescription() </td>
                        #if($invoicePurchase.isSerialized())
                            <td class="itemType">Serialized</td>
                        #else
                            <td class="itemType">Non Serialized</td>
                        #end
                        <td class="qty"> $invoicePurchase.getQty() </td>

                        <td class="excessQty"> $invoicePurchase.getExcessQty() </td>
                        #if($invoicePurchase.getMismatch())
                            <td class="priceMismatch"> $invoicePurchase.getMismatch()</td>
                        #else

                            <td>-</td>

                        #end
                        #if(!$invoicePurchase.getIssues().isEmpty())
                            <td> $invoicePurchase.getIssues()</td>
                        #else
                            <td>Validated</td>

                        #end
                        #if($invoicePurchaseModel.isValidate() && $invoicePurchase.isSerialized())
                            <td width="20%"><input type="text" class="imeis-to-grn" placeholder=""></td>
                        #else
                            <td> -</td>
                        #end

                        #if($invoicePurchaseModel.isValidate() && $invoicePurchase.isSerialized() && $invoicePurchase.getExcessQty() > 0)
                            <td width="20%"><input type="text" class="imeis-to-grn-return" placeholder=""></td>
                        #else
                            <td> -</td>
                        #end
                    </tr>

                    #end
                #end

            </tbody>
        </table>

    </div>
</div>

<div class="row">

    #if($invoicePurchaseModel.getStatus() == "pending")

        <div class="col-lg-2 form-group">
            <input class="form-control btn btn-primary" type="button" value="Grn">
        </div>

    #else
        #if($invoicePurchaseModel.isValidate())

            <div class="col-lg-2 form-group">
                <input class="form-control btn btn-primary purchaseGrn"
                       data-invoiceid="$invoicePurchaseModel.getInvoiceId()" type="button" value="Grn">
            </div>


        #else

            <div class="col-lg-2 form-group">
                <input class="form-control btn btn-primary grnRequest"
                       data-invoiceid="$invoicePurchaseModel.getInvoiceId()" type="button" value="Raise Grn Request">
            </div>


        #end

    #end

</div>


<script>
    $(function () {
        //debugger;
        $("#invoice-purchase-validate > tbody > tr").each(function () {


            var qty = $(this).find(".qty").text();

            imeisToValidate = [];


            let imeiInputElem = $(this).find(".imeis-to-grn");
            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';
                    }
                },
            });
        });

        $("#invoice-purchase-validate > tbody > tr").each(function () {

            var excessQty = $(this).find(".excessQty").text();


            imeisToValidate = [];

            let imeiInputElem = $(this).find(".imeis-to-grn-return");
            imeiInputElem.tagsinput({
                maxTags: excessQty,
                allowDuplicates: false,
                confirmKeys: [13, 44, 188, 32],
                delimiterRegex: /[,\s]/,
                trimValue: true,
                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('beforeItemAdd', (event) => {
                if (event.item.indexOf(' ') > 0) {
                    event.cancel = true;
                    let strItem = event.item.replaceAll(' ', '');
                    imeiInputElem.tagsinput('add', strItem);
                }
            });
            console.log(imeiInputElem);


            console.log(imeisToValidate);

        });

    });

</script>