/
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'); ?> <form action="<?php echo e(url('circle-store/update-stn')); ?>" method="POST"> <?php echo csrf_field(); ?> <input type="hidden" name="id" value="<?php echo e($get_stn->id); ?>"> <div class="row"> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <div class="row"> <div class="col-lg-6"> <h3 class="card-title">Edit Stock Transfer Note Generate for Plant</h3> </div> </div> <div class="row"> <div class="col-lg-3"> <small>From Warehouse</small> <select class="form-control mr" id="warehouse"name="fwarehouse" onchange="get_ware_house(this)"> <?php $__currentLoopData = $warehouses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $warehouse): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($warehouse->warehouseCode); ?>"><?php echo e($warehouse->warehouseCode); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </div> <div class="col-lg-3"> <small>To Warehouse</small> <select class="form-control mr" name="twarehouse" id="to_warehouse"> <option value=""> -- Select To Warehouse --</option> <?php $__currentLoopData = $to_warehouses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $to_warehouse): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($to_warehouse->ware_house); ?>"><?php echo e($to_warehouse->ware_house); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </div> <div class="col-lg-2"> <small>Invoice No</small> <input type="text" id="invoice_no" name="invoice_no" onkeyup="get_invoice_no(this)" class="form-control mr" value="<?php echo e($all_stn['invoice_no']); ?>"> </div> <div class="col-lg-4"> <small>Name & Address Of Consignee/Site</small> <textarea class="form-control" id="consignee_address" name="consignee_address" onkeyup="get_consignee_address(this)"><?php echo e($all_stn['consignee_address']); ?></textarea> </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">Spare Parts List</h4> </div> <!--<div class="col-lg-6">--> <!--<input type="text" value="" class="form-control" placeholder="Enter Spare Code" id="spareCode">--> <!--</div>--> <!-- <div class="col-lg-2">--> <!-- <button type="button" class="btn btn-success btn-fw" 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> Faulty qty</th> <th> --- </th> </tr> </thead> <tbody id="tbody"> </tbody> </table> <table class="table table-striped table-bordered"><tbody id="tbody"> <?php $__currentLoopData = $get_stn_items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $get_stn_item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <tr class="row_531"> <td class="font-weight-medium" name="spare_code"><?php echo e($get_stn_item->spare_code); ?></td> <td>ASSY PCB GR 1 B/C NEW MODIFIED</td> <td>PCS</td> <td>Spare</td> <td><input type="text" name="qty" onkeyup="calculate(this,<?php echo e($get_stn_item->id); ?>)" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" style="width: 80px;" value="<?php echo e($get_stn_item->fresh_qty); ?>"></td><td><input type="text" name="rqty" onkeyup="rcalculate(this,<?php echo e($get_stn_item->id); ?>)" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" style="width: 80px;" value="<?php echo e($get_stn_item->repaired_qty); ?>"></td><td><input type="text" name="fqty" onkeyup="flcalculate(this,<?php echo e($get_stn_item->id); ?>)" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" style="width: 80px;" value="<?php echo e($get_stn_item->faulty_qty); ?>"></td><td><a href="#" onclick="removeItem(531)"><i class="mdi mdi-delete-forever"></i></a></td> </tr> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </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-4"></div> <div class="col-lg-3"></div> <div style="display:flex; flex-direction:row;" class="col-lg-3"><button style="margin-left:150px;" type="button" id="updated" onclick="update_now()" class="btn btn-warning btn-fw">Update Now</button> <!--<button style="margin:5px;" type="button" id="generated" onclick="generate_now()" class="btn btn-warning btn-fw">Generate Now</button>--> </div> </div> </div> </div> </div> </div> </form> <?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 generateStn = {}; generateStn.items = []; generateStn.engineer_id = ''; generateStn.warehouse = ''; generateStn.consignee_address = ''; generateStn.invoice_no = ''; localStorage.setItem('generateStn', JSON.stringify(generateStn)); //-----------------------------Defining our localstorage------------ var editStn = {}; editStn.id = ''; editStn.items = []; editStn.consignee_address=''; editStn.invoice_no = ''; localStorage.setItem('editStn', JSON.stringify(editStn)); } //-----Getting the value sent from backend & assignning them in a variable-- function edit_str() { var spare_part = <?php echo json_encode($get_stn_items, 15, 512) ?>; var id = <?php echo json_encode($id, 15, 512) ?>; console.log("id is "+id); var invoice_no = <?php echo json_encode($get_stn->invoice_no, 15, 512) ?>; var consignee_address = <?php echo json_encode($get_stn->consignee_address, 15, 512) ?>; var is_added = false; var editStn = JSON.parse(localStorage.getItem('editStn')); editStn.id = id; editStn.invoice_no = invoice_no; editStn.consignee_address = consignee_address; if(localStorage.getItem('editStn') != null){ $.each(editStn.items,function(key,val){ if(parseInt(val.id) == spare_part.id){ is_added = true; } }); } if(is_added == false){ var sparts = spare_part; $.each(sparts,function(key,val){ val.qty = 0; val.rqty = 0; val.fqty = 0; editStn.items.push(val); }); } else{ console.log("is added"); } //--------Setting them into the localStorage----------------------- localStorage.setItem('editStn',JSON.stringify(editStn)); } init_cart(); edit_str(); if(localStorage.getItem('generateStn') != null){ $(document).ready(function(){ var generateStn = JSON.parse(localStorage.getItem('generateStn')); if(generateStn.engineer_id != ""){ $('#engineer').val(generateStn.engineer_id); } if(generateStn.warehouse != ""){ if(generateStn.items.length > 0){ $('#warehouse').attr('disabled',true); } $('#warehouse').val(generateStn.warehouse); $('#consignee_address').val(generateStn.consignee_address); $('#invoice_no').val(generateStn.invoice_no); } showSelectedItems(); }); }else{ init_cart(); } function removeItem(id){ var editStn = JSON.parse(localStorage.getItem('editStn')); var items = editStn.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. } }); editStn.items = items; localStorage.setItem('editStn',JSON.stringify(editStn)); showSelectedItems(); } function addselectedItem(){ var code = $('#spareCode').val(); var warehouse = $('#warehouse').val(); if(code != "" && warehouse !=""){ var url = window.location.origin+"/circle-store/get-spare-part-for-stn-generation" 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){ $('#warehouse').attr('disabled',true); var spare_part = res.spare_part; var generateStn = JSON.parse(localStorage.getItem('generateStn')); var is_added = false; $.each(generateStn.items,function(key,val){ if(parseInt(val.id) == spare_part.id){ is_added = true; } }); if(is_added == false){ var sparts = spare_part; var circle_spare = res.circle_spare_info; sparts.qty = circle_spare.fresh_qty; sparts.rqty = circle_spare.repaired_qty; sparts.flqty = circle_spare.faulty_qty; if(sparts.qty == 0 && sparts.rqty == 0 && sparts.flqty == 0){ swal('Spare not in stock.', { icon: "error", }); }else{ generateStn.items.push(spare_part); } } else{ console.log("is added"); } localStorage.setItem('generateStn',JSON.stringify(generateStn)); 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 generateStn = JSON.parse(localStorage.getItem('generateStn')); var html = ''; var n = 0; $.each(generateStn.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>`; if(spare_part.qty == 0){ html +=`<td><input type="text" name="qty" onkeyup="calculate(this,`+spare_part.id+`)" onkeypress="return onlyNumber(event)" style="width: 80px;" value="`+spare_part.qty+`" disabled/></td>`; }else{ html +=`<td><input type="text" name="qty" onkeyup="calculate(this,`+spare_part.id+`)" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" style="width: 80px;" value="`+spare_part.qty+`"/></td>`; } if(spare_part.rqty == 0){ html +=`<td><input type="text" name="qty" onkeyup="rcalculate(this,`+spare_part.id+`)" onkeypress="return onlyNumber(event)" style="width: 80px;" value="`+spare_part.rqty+`" disabled/></td>`; }else{ html +=`<td><input type="text" name="qty" onkeyup="rcalculate(this,`+spare_part.id+`)" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" style="width: 80px;" value="`+spare_part.rqty+`"/></td>`; } if(spare_part.flqty == 0){ html +=`<td><input type="text" name="qty" onkeyup="flcalculate(this,`+spare_part.id+`)" onkeypress="return onlyNumber(event)" style="width: 80px;" value="`+spare_part.flqty+`" disabled/></td>`; }else{ html +=`<td><input type="text" name="qty" onkeyup="flcalculate(this,`+spare_part.id+`)" onkeypress="return onlyNumber(event)" onblur="check_zero(this)" style="width: 80px;" value="`+spare_part.flqty+`"/></td>`; } html +=`<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 = parseInt($(t).val()); if(!isNaN(qty)){ addCartValueInKey(id,'qty',qty); }else{ addCartValueInKey(id,'qty',0); } } function rcalculate(t,id){ var rqty = parseInt($(t).val()); if(!isNaN(rqty)){ addCartValueInKey(id,'rqty',rqty); }else{ addCartValueInKey(id,'rqty',0); } } function onlyNumber(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)){ return false; } return true; } //-------------------Functions to set the value in localStorage------------- function flcalculate(t,id){ var fqty = parseInt($(t).val()); if(!isNaN(fqty)){ addCartValueInKey(id,'fqty',fqty); }else{ addCartValueInKey(id,'fqty',0); } } function get_invoice_no(t){ var editStn = JSON.parse(localStorage.getItem('editStn')); editStn.invoice_no = $(t).val(); localStorage.setItem('editStn',JSON.stringify(editStn)); } function get_consignee_address(t){ var editStn = JSON.parse(localStorage.getItem('editStn')); editStn.consignee_address = $(t).val(); localStorage.setItem('editStn',JSON.stringify(editStn)); } function get_ware_house(t){ var editStn = JSON.parse(localStorage.getItem('editStn')); editStn.warehouse = $('#warehouse').val(); localStorage.setItem('editStn',JSON.stringify(editStn)); } function addCartValueInKey(id,key,value){ var editStn = JSON.parse(localStorage.getItem('editStn')); $.each(editStn.items,function(k,val){ if(parseInt(val.id) == id){ editStn.items[k][key] = value; } }); localStorage.setItem('editStn',JSON.stringify(editStn)); } function getEngineer(t){ var eng_id = $(t).val(); if(eng_id !=""){ var generateStn = JSON.parse(localStorage.getItem('generateStn')); generateStn.engineer_id = eng_id; localStorage.setItem('generateStn',JSON.stringify(generateStn)); }else{ swal('Please Select Engineer !!', { icon: "error", }); } } function is_valid(){ var generateStn = JSON.parse(localStorage.getItem('generateStn')); var check = true; $.each(generateStn.items,function(key,val){ if(val.qty == 0 && val.rqty == 0 && val.flqty == 0){ check = false; return false; } }); if(check == false){ return false }else{ return true; } } function generate_now(){ var warehouse = $('#warehouse').val(); var to_warehouse = $('#to_warehouse').val(); var invoice_no = $('#invoice_no').val(); var generateStn = JSON.parse(localStorage.getItem('generateStn')); if(warehouse =="" || to_warehouse =="" || invoice_no ==""){ swal('Please Select From warehouse, To warehouse and Invoice No!!', { icon: "error", }); }else if(generateStn.items.length < 1){ swal('Please add atleat one item', { icon: "error", }); }else if(!is_valid()){ swal("Zero quantity is not allowed for the Item.", { icon: "error", }); }else{ swal({ title: "Is Your Spare Parts Verified ?", text: "if you verified your items then press 'Ok',otherwise press 'Cancel' and check again.", icon: "warning", buttons: true, dangerMode: true, }).then((willDelete) => { if (willDelete) { var url = window.location.origin+"/circle-store/generate-stn-now" token = "<?php echo e(csrf_token()); ?>"; //generateStn._token = "<?php echo e(csrf_token()); ?>"; generateStn.warehouse = warehouse; generateStn.to_warehouse = to_warehouse; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, //data: generateStn, data: {_token: token, generateStn: JSON.stringify(generateStn)}, success:function(res){ const button = document.getElementById('generated'); button.disabled = true; // Change the text of the button button.innerHTML = 'Generated'; // console.log("this is response :".res); if(res.success == true){ swal(res.msg, { icon: "success", }); init_cart(); showSelectedItems(); }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); }, error:function(error){ console.log(error); }, dataType: 'json' }); } }); } } function update_now(){ var warehouse = $('#warehouse').val(); var to_warehouse = $('#to_warehouse').val(); var invoice_no = $('#invoice_no').val(); var generateStn = JSON.parse(localStorage.getItem('editStn')); if(warehouse =="" || to_warehouse =="" || invoice_no ==""){ swal('Please Select From warehouse, To warehouse and Invoice No!!', { icon: "error", }); }else if(generateStn.items.length < 1){ swal('Please add atleat one item', { icon: "error", }); }else if(!is_valid()){ swal("Zero quantity is not allowed for the Item.", { icon: "error", }); }else{ swal({ title: "Is Your Spare Parts Verified ?", text: "if you verified your items then press 'Ok',otherwise press 'Cancel' and check again.", icon: "warning", buttons: true, dangerMode: true, }).then((willDelete) => { if (willDelete) { var url = window.location.origin+"/circle-store/update-stn" token = "<?php echo e(csrf_token()); ?>"; //generateStn._token = "<?php echo e(csrf_token()); ?>"; generateStn.warehouse = warehouse; generateStn.to_warehouse = to_warehouse; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, //data: generateStn, data: {_token: token, generateStn: JSON.stringify(generateStn)}, success:function(res){ const button = document.getElementById('updated'); button.disabled = true; // Change the text of the button button.innerHTML = 'Updated'; // console.log("this is response :".res); if(res.success == true){ swal(res.msg, { icon: "success", }); init_cart(); showSelectedItems(); }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); }, error:function(error){ console.log(error); }, dataType: 'json' }); } }); } } $(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/edit-str.blade.php ENDPATH**/ ?>