/
home
/
sjslayjy
/
public_html
/
assets
/
storage
/
framework
/
views
/
Upload File
HOME
<?php $__env->startPush('plugin-styles'); ?> <!-- <?php echo Html::style('/assets/plugins/plugin.css'); ?> --> <?php $__env->stopPush(); ?> <?php $__env->startSection('content'); ?> <div class="row"> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <h3 class="card-title">Requested Indent</h3> <div class="row"> <div class="col-lg-3"> <label>Indent Number : <br/><strong><?php echo e($indent->indent_no); ?></strong></label> </div> <div class="col-lg-3"> <label>Indent Date : <br/><strong><?php echo e($indent->indent_date); ?></strong></label> </div> <div class="col-lg-3"> <label>Indent Placed By : <br/><strong><?php echo e($indent->addedBy($indent->indent_placed_by)); ?></strong></label> </div> <div class="col-lg-3"> <label>Indent Status : <br/><strong><?php echo e($indent->status); ?></strong></label> </div> </div> <div class="row"> <div class="col-lg-3"> <label>Business Type : <br/><strong><?php echo e($indent->business_type); ?></strong></label> </div> <div class="col-lg-3"> <label>Customer Code : <br/><strong><?php echo e($indent->customer_code); ?></strong></label> </div> <div class="col-lg-3"> <label>Customer Name : <br/><strong><?php echo e($indent->customer_name); ?></strong></label> </div> <div class="col-lg-3"> <label>Customer PO : <br/><strong><?php echo e($indent->customer_po); ?></strong></label> </div> </div> <div class="row"> <div class="col-lg-3"> <label>Cutomer PO Date : <br/><strong><?php echo e($indent->cutomer_po_date); ?></strong></label> </div> <div class="col-lg-3"> <label>Requested From Warehouse : <br/><strong><?php echo e($indent->ware_house); ?></strong></label> </div> <div class="col-lg-3"> <label>Stock Type : <br/><strong><?php echo e($indent->stock_type); ?></strong></label> </div> <div class="col-lg-3"> <?php if($indent->status == 'authorized' || $indent->status == 'request'): ?> <a onclick="short_close_indent()" class="btn btn-small btn-success" style="color:#fff;">Short Close</a> <?php endif; ?> </div> </div> <div class="row"> <div class="col-lg-6"> <label>Remarks: <br/><strong><?php echo e($indent->remarks); ?></strong></label> </div> </div> </div> </div> </div> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <div class="row grid-margin"> <div class="col-lg-4"> <h4 class="card-title">Requested Spare Parts List</h4> </div> </div> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th>Item Code</th> <th>Description</th> <th>Required Qty</th> <th>Fresh Qty</th> <th>Repaird Qty</th> </tr> </thead> <tbody id="tbody"> </tbody> </table> <div id="loaderAction"> <div class="loader"></div> </div> </div> </div> </div> </div> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <div class="row"> <div class="col-lg-8"></div> <div class="col-lg-4"><?php if($indent->status == 'authorized' || $indent->status == 'request'): ?><button type="button" id="stoBtn" onclick="generate_sto_now()" class="btn btn-warning btn-fw">Generate STO Now</button><?php endif; ?></div> </div> </div> </div> </div> </div> <?php $__env->stopSection(); ?> <?php $__env->startPush('plugin-scripts'); ?> <?php echo Html::script('/assets/plugins/chartjs/chart.min.js'); ?> <?php echo Html::script('/assets/plugins/jquery-sparkline/jquery.sparkline.min.js'); ?> <?php $__env->stopPush(); ?> <?php $__env->startPush('custom-scripts'); ?> <?php echo Html::script('/assets/js/dashboard.js'); ?> <script type="text/javascript"> function init_cart(){ var generateSTOdata = {}; generateSTOdata.indentItems = []; generateSTOdata.indent_id = ""; localStorage.setItem('generateSTOdata', JSON.stringify(generateSTOdata)); getItems(); } init_cart(); function short_close_indent(){ swal({ title: "Do you want to short close the Indent?", text: "if yes then press 'OK' button otherwise press 'Cancel' button to cancel it.", icon: "warning", buttons: true, dangerMode: true, }).then((willDelete) => { if(willDelete){ var url = window.location.origin+"/admin/short-close-indent" var data = {}; data.indent_id = "<?php echo e($indent->id); ?>"; data._token = "<?php echo e(csrf_token()); ?>"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success:function(res){ $('#loaderAction').hide(); }, error:function(error){ console.log(error); }, dataType: 'json' }); } }); } function auto_short_close_indent(){ var url = window.location.origin+"/admin/short-close-indent" var data = {}; data.indent_id = "<?php echo e($indent->id); ?>"; data._token = "<?php echo e(csrf_token()); ?>"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success:function(res){ $('#loaderAction').hide(); window.location.href=window.location.origin+'/admin/stock-transfer-orders'; }, error:function(error){ console.log(error); }, dataType: 'json' }); } function getItems(){ var url = window.location.origin+"/admin/get-all-indent-spare-part" var data = {}; data.indent_id = "<?php echo e($indent->id); ?>"; data._token = "<?php echo e(csrf_token()); ?>"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success:function(res){ $('#loaderAction').hide(); if(res.success == true){ var generateSTOdata = JSON.parse(localStorage.getItem('generateSTOdata')); generateSTOdata.indent_id = res.indent_id; var is_item_empty = true; $.each(res.indentItems,function(key,val){ let spare = val; spare.new_spare = 0; spare.final_qty = 0; spare.qty = spare.qty - spare.sto_qty; spare.rqty = 0; if(spare.qty != 0){ generateSTOdata.indentItems.push(spare); is_item_empty = false; } }); if(is_item_empty == true){ auto_short_close_indent(); } localStorage.setItem('generateSTOdata',JSON.stringify(generateSTOdata)); showSelectedItems(); } }, error:function(error){ console.log(error); }, dataType: 'json' }); } function removeItem(id){ var generateSTOdata = JSON.parse(localStorage.getItem('generateSTOdata')); var items = generateSTOdata.indentItems; $(items).each(function (index){ if(items[index].id == id){ items.splice(index,1); // This will remove the object that first name equals to Test1 return false; // This will stop the execution of jQuery each loop. } }); generateSTOdata.indentItems = items; localStorage.setItem('generateSTOdata',JSON.stringify(generateSTOdata)); showSelectedItems(); } function showSelectedItems(){ var generateSTOdata = JSON.parse(localStorage.getItem('generateSTOdata')); var html = ''; var n = 0; $.each(generateSTOdata.indentItems,function(key,spare_part){ html +=`<tr class="row_`+spare_part.id+`"> <td class="font-weight-medium">`+spare_part.code+`</td> <td>`+spare_part.description+`</td> <td >`+spare_part.qty+`</td> <td><input type="text" name="qty" id="qty_`+spare_part.id+`" onkeypress="return onlyCurrency(event)" onkeyup = "calculate(`+spare_part.id+`)" onblur="check_zero_qty(`+spare_part.id+`)" style="width: 80px;" value="`+spare_part.final_qty+`"/></td> <td><input type="text" name="rqty" id="rqty_`+spare_part.id+`" onkeypress="return onlyNumber(event)" onkeyup="rcalculate(`+spare_part.id+`)" onblur="check_zero_rqty(`+spare_part.id+`)" style="width: 80px;" value="`+spare_part.rqty+`"/></td> <td><a onclick="removeItem(`+spare_part.id+`)"><i class="mdi mdi-delete-forever"></i></a></td> </tr>`; }); $('#tbody').html(html); } function onlyNumber(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)){ return false; } return true; } function check_zero_qty(id){ var qty = $('#qty_'+id).val(); if(qty == ""){ qty = 0; $('#qty_'+id).val(0); addCartValueInKey(id,'final_qty',qty); } } function check_zero_rqty(id){ var rqty = $('#rqty_'+id).val(); if(rqty == ""){ rqty = 0; $('#rqty_'+id).val(0); addCartValueInKey(id,'rqty',rqty); } } function calculate(id){ var qty = $('#qty_'+id).val(); if(qty != "" && qty != null){ qty = parseFloat(qty); addCartValueInKey(id,'final_qty',qty); }else{ addCartValueInKey(id,'final_qty',0); } } function rcalculate(id){ var rqty = $('#rqty_'+id).val(); if(rqty != "" && rqty != null){ rqty = parseInt(rqty); addCartValueInKey(id,'rqty',rqty); }else{ addCartValueInKey(id,'rqty',0); } } function addCartValueInKey(id,key,value){ var generateSTOdata = JSON.parse(localStorage.getItem('generateSTOdata')); $.each(generateSTOdata.indentItems,function(k,val){ if(parseInt(val.id) == id){ generateSTOdata.indentItems[k][key] = value; } }); localStorage.setItem('generateSTOdata',JSON.stringify(generateSTOdata)); } function onlyCurrency(event){ if(event.which == 8 || event.which == 0){ return true; } if(event.which < 46 || event.which > 59) { return false; //event.preventDefault(); } // prevent if not number/dot if(event.which == 46 && $(this).val().indexOf('.') != -1) { return false; //event.preventDefault(); } // preven } function is_valid(){ var generateSTOdata = JSON.parse(localStorage.getItem('generateSTOdata')); var check = true; $.each(generateSTOdata.indentItems,function(key,val){ var total_qty = parseInt(val.final_qty)+parseInt(val.rqty); if( (val.final_qty == 0 && val.rqty == 0) || (val.qty < total_qty) ){ check = false; return false; } }); if(check == false){ return false }else{ return true; } } function generate_sto_now(){ if(is_valid()){ var url = window.location.origin+"/admin/generate-sto-now" var generateSTOdata = JSON.parse(localStorage.getItem('generateSTOdata')); generateSTOdata._token = "<?php echo e(csrf_token()); ?>"; $('#loaderAction').show(); var requestTimeout; var ajaxRequest = $.ajax({ type: "POST", url: url, data: generateSTOdata, timeout: 15000, // Set the timeout to 5 seconds (5000 milliseconds) success:function(res){ clearTimeout(requestTimeout); console.log(res); if(res.success == true){ swal(res.msg, { icon: "success", }); init_cart(); showSelectedItems(); // Enable the button for re-submit stoBtn.disabled = false; // Reset the button text stoBtn.innerHTML = 'Generate STO Now'; window.location.href = window.location.origin+"/admin/authorised-indents"; }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); stoBtn.disabled = res.success !== true; // placeAmcButton.innerHTML = 'AMC Request Placed !'; }, error:function(xhr, status, error){ var requestTimeout = setTimeout(function () { $('#loaderAction').hide(); swal("Process has been cancelled due to exceeding the execution time!", { icon: "error" }); ajaxRequest.abort(); }, 15000); console.log(error); stoBtn.disabled = true; stoBtn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="animated-text">Please wait for 15 seconds, request is under process...</span>'; // Clear the timeout on error clearTimeout(requestTimeout); }, dataType: 'json' }); // Set the timeout for the request requestTimeout = setTimeout(function() { $('#loaderAction').hide(); swal("Process has been cancelled due to exceeding the execution time!", { icon: "error" }); ajaxRequest.abort(); // Enable the button for re-submit stoBtn.disabled = false; // Reset the button text stoBtn.innerHTML = 'Generate STO Now'; }, 15000); }else{ swal('Both fresh Qty and Repaired Qty of a item can not be zero and the sum of both can not greater than required qty of a item.', { icon: "error", }); } } $(document).ready(function(){ }); </script> <?php $__env->stopPush(); ?> <?php echo $__env->make('layout.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/assets/resources/views/admin/indent/generate-sto.blade.php ENDPATH**/ ?>