Subversion Repositories SmartDukaan

Rev

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

<style>
        .pointer {
                cursor:pointer;
        }
        .modal-content{
                background : white;
        }
        .modelHeaderCustom{
                font-size:14px;
                font-weight:bold;
        }
        .border-highlight{
                border : 3px solid red;
        }
        hr{
                background-color:#dddddd;
                border:none;
                height:1px;
                background:#dddddd;
        }
        .control-label {
                margin-top: 0;
        margin-bottom: 0;
        padding-top: 7px;
        font-weight:bold;
        font-size:14px;
        }
        .right{
                float:right;
        }
        .form-control{
                color:black;
                text-transform:uppercase;
        }
        .bold-details {
                text-transform:capitalize;
                font-weight:600;
                color:#212121;
        }
        .normal-details{
                font-weight:400;
                text-transform:capitalize;
                color:#797979;
        }
        
}
</style>
#set($options="{ weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute:'numeric' }")
<section class="wrapper">
<div class="row" style="background:white;font-size:14px;">
        <div class="col-lg-4" style="border-left:1px solid #f0f0f0;">
                <h4>ORDER DETAILS</h4>
                <div class="row">
                        <div class="col-lg-4">
                                <p class="bold-details">Order ID</p>
                        </div>
                        <div class="col-lg-6">
                                <p class="normal-details">#$fofoOrder.getId() ($fofoOrderItems.size() item)</p>
                        </div>
                </div>
                <div class="row">
                        <div class="col-lg-4">
                                <p class="bold-details">Order Date</p>
                        </div>
                        <div class="col-lg-6">
                                <script>document.getElementById('createTimestamp').appendChild(document.createTextNode(new Date('$fofoOrder.getCreateTimestamp()').toLocaleString("en-US",$options)))</script>
                                <p class="normal-details" id="createTimestamp"></p>
                        </div>
                </div>
                <div class="row">
                        <div class="col-lg-4">
                                <p class="bold-details">Amount Paid</p>
                        </div>
                        <div class="col-lg-6">
                                <p class="normal-details"><span class="normal-details">&#8377; </span>$fofoOrder.getTotalAmount()</p>
                        </div>
                </div>
        </div>
        
        <div class="col-lg-4" style="border-left:1px solid #f0f0f0;">
                <h4>BILLING DETAILS</h4>
                <p class="bold-details">$customerBillingAddressObj.getName()</p>
                <p class="normal-details">$customerBillingAddress</p>
                #if($fofoOrder.getCustomerGstNumber() && $fofoOrder.getCustomerGstNumber() != "")
                        <p class="bold-details">GST Number <span class="normal-details extra-margin">$fofoOrder.getCustomerGstNumber()</span></p>
                #end
                <p class="bold-details">Phone <span class="normal-details extra-margin">$customerBillingAddressObj.getPhoneNumber()</span></p>
        </div>
        
        <div class="col-lg-4" style="border-left:1px solid #f0f0f0;">
                <h4>INVOICE DETAILS</h4>
                <p class="bold-details">Invoice Number <span class="normal-details extra-margin">$fofoOrder.getInvoiceNumber()</span></p>
                <p class="invoice_download_option"><i class="fa fa-print" aria-hidden="true"></i><a target="_blank" href="generateInvoice?orderId=$fofoOrder.getId()" class="extra-margin" style="font-size:18px">Print Invoice</a      ></i></p>
        </div>

</div>

<div class="row" style="font-size:14px;color:#688a7e;">
        <div class="col-lg-12">
                <table class="table table-striped table-advance table-hover">
                        <tbody>
                                <tr>
                                        <th>Item Code</th>
                                        <th>Description</th>
                                        <th>Unit Price</th>
                                        <th>Quantity</th>
                                        <th>Total Price</th>
                                        <th>Prebooking Quantity</th>
                                        <th>Prebooking Amount</th>
                                </tr>
                                 <script type="text/javascript">
                                        fofoLineItemsMap = $fofoOrderItemIdLineItemsMap;
                                        foiIdCustomerReturnInventoryItemsMap = $foiIdCustomerReturnInventoryItemsMap;
                                        inventoryItemBilledQtyMap = $inventoryItemBilledQtyMap;
                                 </script>
                                 #foreach( $fofoOrderItem in $fofoOrderItems )
                                 #set ($total = $fofoOrderItem.getSellingPrice() * $fofoOrderItem.getQuantity())
                                        <tr>
                                                <td>$fofoOrderItem.getItemId()</td>
                                                <td>
                                                        $fofoOrderItem.getBrand() $fofoOrderItem.getModelName() $fofoOrderItem.getModelNumber() $fofoOrderItem.getColor()
                                                </td>
                                                <td>$fofoOrderItem.getSellingPrice()</td>
                                                <td>$fofoOrderItem.getQuantity()</td>
                                                <td>$total</td>
                                                #if($itemIdPrebookingOrderItemMap.get($fofoOrderItem.getItemId()))
                                                        <td>$itemIdPrebookingOrderItemMap.get($fofoOrderItem.getItemId()).getQuantity()</td>
                                                        <td>$itemIdPrebookingOrderItemMap.get($fofoOrderItem.getItemId()).getAdvanceAmount()</td>
                                                #else
                                                        <td>0</td>
                                                        <td>0</td>
                                                #end
                                                #if($itemsMap.get($fofoOrderItem.getItemId()).getCategoryId()==10006)
                                                        #if($markDoa)
                                                                <td><a class="pointer" data-foi="$fofoOrderItem.getId()" 
                                                                data-itemdesc="$itemsMap.get($fofoOrderItem.getItemId()).getItemDescription()" data-target=".bs-example-modal-sm" data-toggle="modal">Mark DOA</a></td>
                                                        #else
                                                                <td></td>
                                                        #end
                                                #else
                                                        #if($markDefective)
                                                                <td><a class="pointer" data-foi="$fofoOrderItem.getId()" 
                                                                data-itemdesc="$itemsMap.get($fofoOrderItem.getItemId()).getItemDescription()" data-target=".bs-example-modal-sm" data-toggle="modal">Mark Defective</a></td>
                                                        #else
                                                                <td></td>
                                                        #end
                                                #end
                                                <td></td>
                                        </tr>
                                 #end
                        </tbody>
                </table>
        </div>
        <!-- Small modal -->
        <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="exampleModal">
          <div class="modal-dialog modal-md" role="document">
            <div class="modal-content">
            <div class="modal-header">
                <p class="modal-title"></p>
            </div>
            <div class="modal-body">
                
            </div>
            <div class="modal-footer">
                <button type="button" class="return-submit btn btn-primary">Submit</button>
            </div>
            </div>
          </div>
        </div>
</div>

<div class="row">
        #if(!$insurancePolicies.isEmpty())
                <div class="col-lg-8">
                        <h4>INSURANCE DETAILS</h4>
                <table class="table table-striped table-advance">
                        <tbody>
                                <tr>
                                        <th>Description</th>
                                        <th>Serial Number</th>
                                        <th>Provider Name</th>
                                        <th>Amount</th>
                                </tr>
                                #if(!$insurancePolicies.isEmpty())
                                        #foreach( $insurancePolicy in $insurancePolicies )
                                                <tr>
                                                        <td>$insurancePolicy.getBrand() $insurancePolicy.getModelName()</td>
                                                        <td>$insurancePolicy.getSerialNumber()</td>
                                                        <td>$insurancePolicy.getInsuranceProvider().getName()</td>
                                                        <td>$insurancePolicy.getSaleAmount()</td>
                                                </tr>
                                        #end
                                #end
                        </tbody>
                </table>
        </div>
        #end
        
        <div class="col-lg-4 right" style="border-left:1px solid #f0f0f0;background:white;font-size:14px;">
                <h4>PAYMENT DETAILS</h4>
                 #foreach( $paymentOptionTransaction in $paymentOptionTransactions )
                        #set($paymentOption = $paymentOptionIdPaymentOptionMap.get($paymentOptionTransaction.getPaymentOptionId()))
                        <div class="row">
                                <div class="col-lg-3">
                                        <p class="bold-details">$paymentOption.getName()</p>
                                </div>
                                <div class="col-lg-3">
                                        <p class="nomal-details">&#8377; $paymentOptionTransaction.getAmount()</p>
                                </div>
                        </div>
                 #end
                 <hr/>
                 <div class="row">
                        <div class="col-lg-3">
                                <p class="bold-details">TOTAL</p>
                        </div>
                        <div class="col-lg-3">
                                <p class="nomal-details">&#8377;$fofoOrder.getTotalAmount() </p>
                        </div>
                 </div>
        </div>
</div>

</section>

<script type="text/javascript">
        $('#exampleModal').on('show.bs.modal', function (event) {
                var link = $(event.relatedTarget); // Button that triggered the modal
                var itemDesc = link.data('itemdesc'); // Extract info from data-* attributes
                var foitem = link.data('foi'); // Extract info from data-* attributes
                li = fofoLineItemsMap[foitem]
                returnedItems = foiIdCustomerReturnInventoryItemsMap[foitem];
                var modal = $(this);
                modal.find(".modal-title").html(link.html() + "-" + itemDesc);
                htmlArr = [];
                htmlArr.push('<div> <ul data-foi="' + foitem + '">');
                var i;
                for( i=0;i<li.length;i++) {
                        var counter = 0;
                        while(inventoryItemBilledQtyMap[li[i].inventoryItemId] > counter) {
                                if(link.html()=="Mark Defective"){
                                        htmlArr.push('<li class="row">');
                                        htmlArr.push('<div class="col-sm-6 checkbox"><label><input type="checkbox" value="' + li[i].inventoryItemId +'">Defective</label></div>');
                                        htmlArr.push('<div class="col-sm-6 form-group"><label for="comment">Remarks</label><textarea class="form-control" rows="2" id="comment"></textarea></div>');
                                        htmlArr.push('</li>');
                                } else {
                                        htmlArr.push('<li class="row">');
                                        htmlArr.push('<div class="checkbox col-sm-6"><label><input type="checkbox" value="' + li[i].inventoryItemId +'">DOA Certificate Valid for IMEI - ' + li[i].serialNumber + '</label></div>');
                                        htmlArr.push('<div class="form-group col-sm-6"><label for="comment">Remarks</label><textarea class="form-control" rows="2" id="comment"></textarea></div>');
                                        htmlArr.push('</li>');
                                }
                                counter = counter + 1;
                                
                        }
                        var counter = 0;         
                        while(li[i].quantity - inventoryItemBilledQtyMap[li[i].inventoryItemId] > counter) {
                                if(link.html()=="Mark Defective"){
                                        htmlArr.push('<li class="row">');
                                        htmlArr.push('<div class="checkbox col-sm-6"><label><input type="checkbox" checked disabled value="' + li[i].inventoryItemId +'">Defective</label></div>');
                                        htmlArr.push('<div class="form-group col-sm-6"><label for="comment">Remarks</label><textarea disabled class="form-control" rows="2" id="comment">' + returnedItems[counter].remarks + '</textarea></div>');
                                        htmlArr.push('</li>');
                                } else {
                                        htmlArr.push('<li class="row">');
                                        htmlArr.push('<div class="checkbox col-sm-6"><label><input type="checkbox" checked disabled value="' + li[i].inventoryItemId +'">DOA Certificate Valid for IMEI - ' + li[i].serialNumber + '</label></div>');
                                        htmlArr.push('<div class="form-group col-sm-6"><label for="comment">Remarks</label><textarea disabled class="form-control" rows="2" id="comment">' + returnedItems[counter].remarks + '</textarea></div>');
                                        htmlArr.push('</li>');
                                }
                                counter = counter + 1;
                        }
                }       
                modal.find(".modal-body").html(htmlArr.join(""));
        });
                
        $(".return-submit").on('click', function(){
                var showAlert = false;
                var checkedInventory = $('.modal-body').find('input:checked:enabled');
                if(checkedInventory.length==0){
                        alert("Check the defective and provide remarks");
                        return;
                }
                checkedInventory.each(function(i,v){
                        if($(v).closest('li').find('textarea').val()==''){
                                showAlert = true;
                        }
                });
                if(showAlert) {
                        alert('Please add remarks');
                        return;
                } else {
                        var foi = $(checkedInventory).closest('ul').data('foi');
                        var markedBadArr = [];
                        checkedInventory.each(function(i,v){
                                markedBadArr.push({"remarks" : $(v).closest('li').find('textarea').val(), 
                                                                        "inventoryItemId":$(v).val()});
                        });
                        var json = {"fofoOrderItemId":foi, "markedBadArr":markedBadArr};
                        doPostAjaxRequestWithJsonHandler('${rc.contextPath}/order/bad_return', JSON.stringify(json), function(data){
                                alert('Credit Note generated');
                                window.open('${rc.contextPath}/credit-note/' + data.response, '_blank');
                                loadSaleDetails(orderId,"sale-details-container");
                                $('#exampleModal').modal('hide');
                                
                        });
                }
        });     
</script>