/
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"> <div class="col-lg-9"> <h3 class="card-title">PT Stock Moved To Main Stock</h3> </div> <div class="col-lg-3"> <select class="form-control mr" id="warehouse"> <option value=""> -- Select Warehouse --</option> <?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(); ?> <?php if($userInfo->fieldUserCodes == 'PNT'): ?> <option value="SUPPNT">SUPPNT</option> <?php endif; ?> </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">PT Stock 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="ptBtn" 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> Fresh Qty</th> <th> Repaired 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">Move To Stock</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 ptStockMovetoStock = {}; ptStockMovetoStock.items = []; localStorage.setItem('ptStockMovetoStock', JSON.stringify(ptStockMovetoStock)); } if(localStorage.getItem('ptStockMovetoStock') != null){ $(document).ready(function(){ var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); showSelectedItems(); }); }else{ init_cart(); } function removeItem(id){ var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); var items = ptStockMovetoStock.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. } }); ptStockMovetoStock.items = items; localStorage.setItem('ptStockMovetoStock',JSON.stringify(ptStockMovetoStock)); showSelectedItems(); } function addselectedItem(){ var code = $('#spareCode').val(); var warehouse = $('#warehouse').val(); if(code != "" && warehouse !=""){ var url = window.location.origin+"/circle-store/check-spare-part-from-pt-stock" var data = {}; data.code = code; data._token = "<?php echo e(csrf_token()); ?>"; data.warehouse = warehouse; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: data, success:function(res){ if(res.success == true){ var spare_part = res.spare_part; var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); var is_added = false; $.each(ptStockMovetoStock.items,function(key,val){ if(parseInt(val.id) == spare_part.id){ is_added = true; } }); if(is_added == false){ var sparts = res.pt_tocks; // var pt_tocks = res.pt_tocks; sparts.qty = 0; sparts.rqty = 0; ptStockMovetoStock.items.push(sparts); } localStorage.setItem('ptStockMovetoStock',JSON.stringify(ptStockMovetoStock)); 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 And Select warehouse !", { icon: "error", }); } } function showSelectedItems(){ var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); var html = ''; var n = 0; $.each(ptStockMovetoStock.items,function(key,spare_part){ html +=`<tr class="row_`+spare_part.id+`"> <td class="font-weight-medium">`+spare_part.spare_code+`</td> <td>`+spare_part.description+`</td> <td>`+spare_part.uom+`</td> <td>`+spare_part.category+`</td> <td><input type="text" name="qty" onblur="check_zero(this)" onkeyup="calculate(this,`+spare_part.id+`)" style="width: 80px;" value="`+spare_part.qty+`"/></td> <td><input type="text" name="qty" onblur="check_zero(this)" onkeyup="flcalculate(this,`+spare_part.id+`)" style="width: 80px;" value="`+spare_part.rqty+`"/></td> <td><a href="#" onclick="removeItem(`+spare_part.id+`)"><i class="mdi mdi-delete-forever"></i></a></td> </tr>`; }); $('#tbody').html(html); } function check_zero(t){ var qty = $(t).val(); if(qty == "" || qty == null){ $(t).val(0); } } function calculate(t,id){ var qty = $(t).val(); if(qty != "" && qty != null){ qty = parseInt(qty); addCartValueInKey(id,'qty',qty); }else{ addCartValueInKey(id,'qty',0); } } function flcalculate(t,id){ var flqty = $(t).val(); if(flqty != "" && flqty != null){ flqty = parseInt(flqty); addCartValueInKey(id,'rqty',flqty); }else{ addCartValueInKey(id,'rqty',0); } } function addCartValueInKey(id,key,value){ var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); $.each(ptStockMovetoStock.items,function(k,val){ if(parseInt(val.id) == id){ ptStockMovetoStock.items[k][key] = value; } }); localStorage.setItem('ptStockMovetoStock',JSON.stringify(ptStockMovetoStock)); } function getEngineer(t){ var eng_id = $(t).val(); if(eng_id !=""){ var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); ptStockMovetoStock.engineer_id = eng_id; localStorage.setItem('ptStockMovetoStock',JSON.stringify(ptStockMovetoStock)); }else{ swal('Please Select Engineer !!', { icon: "error", }); } } function is_valid(){ var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); var check = true; $.each(ptStockMovetoStock.items,function(key,val){ if(val.qty == 0 && val.rqty == 0 ){ check = false; return false; } }); if(check == false){ return false }else{ return true; } } function assign_now(){ var warehouse = $('#warehouse').val(); if(warehouse !=""){ if(is_valid()){ var url = window.location.origin+"/circle-store/pt-stock-move-to-stock" var ptStockMovetoStock = JSON.parse(localStorage.getItem('ptStockMovetoStock')); //ptStockMovetoStock._token = "<?php echo e(csrf_token()); ?>"; ptStockMovetoStock.warehouse = warehouse; $('#loaderAction').show(); var requestTimeout; var ajaxRequest = $.ajax({ type: "POST", url: url, data: {_token: '<?php echo e(csrf_token()); ?>', ptStockMovetoStock: JSON.stringify(ptStockMovetoStock)}, 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 ptBtn.disabled = false; // Reset the button text ptBtn.innerHTML = 'Move To Stock'; }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); ptBtn.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); ptBtn.disabled = true; ptBtn.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 ptBtn.disabled = false; // Reset the button text ptBtn.innerHTML = 'Move To Stock'; }, 20000); }else{ swal('Fresh and Repaired spare qty will not zero in both.', { icon: "error", }); } }else{ swal('Please Select Warehouse', { 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/pt-stock-moved-to-main-stock.blade.php ENDPATH**/ ?>