/
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"> <div class="row grid-margin"> <div class="col-lg-8"> <h3 class="card-title">Spare -33Assigned To Testing Repairing Center (TRC)</h3> </div> <div class="col-lg-4"> <select class="form-control mr" id="ware_house"> <?php $__currentLoopData = $warehouses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $warehouse): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($warehouse); ?>"><?php echo e($warehouse); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </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">Faulty Parts List</h4> </div> <div class="col-lg-6"> <input type="text" class="form-control" id="spareCode" placeholder="Enter Spare Code"> </div> <div class="col-lg-2"> <button type="button" class="btn btn-success btn-fw" id="spareBtn" onclick="addselectedItem()">Add Spare</button> </div> </div> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th> Spare Code</th> <th> Description</th> <th> UOM</th> <th> Category</th> <th> Rate</th> <th> Total Faulty Qty</th> <th> Faulty Qty</th> <th> --- </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-6"></div> <div class="col-lg-3"></div> <div class="col-lg-3"><button type="button" onclick="assign_now()" class="btn btn-warning btn-fw">Assign TRC Now</button></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 assignedSpareTrc = {}; assignedSpareTrc.items = []; localStorage.setItem('assignedSpareTrc', JSON.stringify(assignedSpareTrc)); } if(localStorage.getItem('assignedSpareTrc') != null){ $(document).ready(function(){ var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); showSelectedItems(); }); }else{ init_cart(); } function removeItem(id){ var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); var items = assignedSpareTrc.items; $(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. } }); assignedSpareTrc.items = items; localStorage.setItem('assignedSpareTrc',JSON.stringify(assignedSpareTrc)); showSelectedItems(); } function addselectedItem(){ var code = $('#spareCode').val(); var warehouse = $('#ware_house').val(); if(code != "" && warehouse !=""){ var url = window.location.origin+"/circle-store/get-spare-part-to-circle-store-for-trc" var data = {}; data.code = code; data.warehouse = warehouse; data._token = "<?php echo e(csrf_token()); ?>"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success:function(res){ if(res.success == true){ var spare_part = res.spare_part; var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); var is_added = false; $.each(assignedSpareTrc.items,function(key,val){ if(parseInt(val.id) == spare_part.id){ is_added = true; } }); if(is_added == false){ var sparts = spare_part; sparts.qty = 0; sparts.total_qty = res.circle_spare_info.faulty_qty; assignedSpareTrc.items.push(spare_part); } localStorage.setItem('assignedSpareTrc',JSON.stringify(assignedSpareTrc)); showSelectedItems(); }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); }, error:function(error){ console.log(error); }, dataType: 'json' }); }else{ swal("Please Enter Spare Code in Textbox !", { icon: "error", }); } } function showSelectedItems(){ var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); var html = ''; var n = 0; $.each(assignedSpareTrc.items,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.uom+`</td> <td>`+spare_part.category+`</td> <td>`+spare_part.rate+`</td> <td>`+spare_part.total_qty+`</td> <td><input type="text" name="qty" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" onkeyup="calculate(this,`+spare_part.id+`)" style="width: 80px;" value="`+spare_part.qty+`"/></td> <td><a href="#" onclick="removeItem(`+spare_part.id+`)"><i class="mdi mdi-delete-forever"></i></a></td> </tr>`; }); $('#tbody').html(html); } function calculate(t,id){ var qty = parseInt($(t).val()); if(!isNaN(qty)){ addCartValueInKey(id,'qty',qty); }else{ addCartValueInKey(id,'qty',0); } } function check_zero(t){ var qty = $(t).val(); if(qty == "" || qty == null){ $(t).val(0); } } function onlyNumber(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)){ return false; } return true; } function addCartValueInKey(id,key,value){ var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); $.each(assignedSpareTrc.items,function(k,val){ if(parseInt(val.id) == id){ assignedSpareTrc.items[k][key] = value; } }); localStorage.setItem('assignedSpareTrc',JSON.stringify(assignedSpareTrc)); } function getEngineer(t){ var eng_id = $(t).val(); if(eng_id !=""){ var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); assignedSpareTrc.engineer_id = eng_id; localStorage.setItem('assignedSpareTrc',JSON.stringify(assignedSpareTrc)); }else{ swal('Please Select Engineer !!', { icon: "error", }); } } function is_valid(){ var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); var check = true; $.each(assignedSpareTrc.items,function(key,val){ if(val.total_qty < val.qty || val.qty == 0 ){ check = false; return false; } }); if(check == false){ return false }else{ return true; } } function assign_now(){ var warehouse = $('#ware_house').val(); if(is_valid()){ var url = window.location.origin+"/circle-store/assign-spare-to-trc" var assignedSpareTrc = JSON.parse(localStorage.getItem('assignedSpareTrc')); assignedSpareTrc._token = "<?php echo e(csrf_token()); ?>"; assignedSpareTrc.warehouse = warehouse; $('#loaderAction').show(); var requestTimeout; var ajaxRequest = $.ajax({ type: "POST", url: url, data: assignedSpareTrc, timeout: 20000, // 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 spareBtn.disabled = false; // Reset the button text spareBtn.innerHTML = 'Assign TRC Now'; }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); spareBtn.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(); }, 20000); console.log(error); spareBtn.disabled = true; spareBtn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="animated-text">Please wait, 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 spareBtn.disabled = false; // Reset the button text spareBtn.innerHTML = 'Assign TRC Now'; }, 15000); }else{ swal('spare qty will not greater than total qty of item and not zero.', { 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/circle-store/spare-assigned-to-trc.blade.php ENDPATH**/ ?>