/
home
/
sjslayjy
/
public_html
/
assets
/
resources
/
views
/
admin
/
stock
/
Upload File
HOME
@extends('layout.master') @push('plugin-styles') <!-- {!! Html::style('/assets/plugins/plugin.css') !!} --> @endpush @section('content') <div class="row"> <div class="col-lg-12 grid-margin"> <div class="card"> <div class="card-body"> <h3 class="card-title">Material Receiving From Supplier (For Goods Receipt notes)</h3> <div class="row"> <div class="col-lg-3"> <div class="form-group"> <label for="referenceNumber">Reference Number</label> <input type="text" class="form-control" onkeyup="referenceNumber(this)" id="referenceNumber" placeholder=""> </div> </div> <div class="col-lg-3"> <div class="form-group"> <label for="invoiceNumber">Invoice Number</label> <input type="text" class="form-control" onkeyup="invoiceNumber(this)" id="invoiceNumber" placeholder=""> </div> </div> <div class="col-lg-3"> <div class="form-group"> <label for="invoiceDate">Invoice Date</label> <input type="date" class="form-control" onchange="invoiceDate(this)" id="invoiceDate" placeholder=""> </div> </div> <div class="col-lg-3"> <div class="form-group"> <label for="indentNumber">Indent Number</label> <input type="text" class="form-control" onkeyup="indentNumber(this)" id="indentNumber" placeholder=""> </div> </div> </div> <div class="row"> <div class="col-lg-3"> <div class="form-group"> <label for="referenceNumber">Gate Entry Receipt Number</label> <input type="text" class="form-control" onkeyup="gateEntryReceiptNumber(this)" id="gateEntryReceiptNumber" placeholder=""> </div> </div> <div class="col-lg-3"> <div class="form-group"> <label for="invoiceNumber">Gate Entry Date and time</label> <input type="datetime-local" class="form-control" onchange="gateEntryDate(this)" id="gateEntryDate" placeholder=""> </div> </div> <div class="col-lg-3"> <div class="form-group"> <label for="invoiceDate">Entry Name and ATS ID</label> <input type="text" class="form-control" onkeyup="entryName(this)" id="entryName" placeholder=""> </div> </div> <div class="col-lg-3"> <div class="form-group"> <label for="invoiceDate">Phone Number</label> <input type="text" class="form-control" onkeypress="return onlyNumber(event)" onkeyup="phoneNumber(this)" id="phoneNumber" placeholder=""> </div> </div> </div> <div class="row"> <div class="col-lg-3"> <label for="invoiceDate">Freight charges</label> <input type="text" class="form-control" onkeypress="return onlyCurrency(event)" onkeyup="freightCharges(this)" id="freightCharges" placeholder=""> </div> <div class="col-lg-2"> <label>Freight GST</label> <select class="form-control mr" id="freight_gst" onchange="get_freight_gst(this)"> <option value="0"> -- Select GST Slab --</option> @foreach($gst_slabs as $gst_slab) <option value="{{$gst_slab->value}}" >{{$gst_slab->rate}}</option> @endforeach </select> </div> <div class="col-lg-2"> <label>To Ware House</label> <select class="form-control mr" id="ware_house" onchange="get_ware_house(this)"> <option value=""> -- Select Warehouse --</option> @foreach($ware_houses as $ware_house) <option value="{{$ware_house->ware_house}}">{{$ware_house->ware_house}}</option> @endforeach </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">Received Items 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" onclick="addselectedItem()">Add Now</button> </div> </div> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th> Item Code</th> <th> Description</th> <th> UOM</th> <th> Qty</th> <th> Rate</th> <th> GST(%)</th> <th> Amount </th> <th> --- </th> </tr> </thead> <tbody id="tbody"> </tbody> <tfoot class="footer"> <tr> <td colspan="6">Sub Total</td> <td id="sub_total">0.00</td> <td>Rs</td> </tr> <tr> <td colspan="6">GST Total</td> <td id="gst_total">0.00</td> <td>Rs</td> </tr> <tr> <td colspan="6">Freight charges</td> <td id="freight_charges">0.00</td> <td>Rs</td> </tr> <tr> <td colspan="6">Freight GST</td> <td id="freight_gst_charges">0.00</td> <td>Rs</td> </tr> <tr> <td colspan="6">Grand Total</td> <td id="grand_total">0.00</td> <td>Rs</td> </tr> </tfoot> </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-9"></div> <div class="col-lg-3"><button type="button" onclick="material_received()" class="btn btn-warning btn-fw">Stock Received</button></div> </div> </div> </div> </div> </div> @endsection @push('plugin-scripts') {!! Html::script('/assets/plugins/chartjs/chart.min.js') !!} {!! Html::script('/assets/plugins/jquery-sparkline/jquery.sparkline.min.js') !!} @endpush @push('custom-scripts') {!! Html::script('/assets/js/dashboard.js') !!} <script type="text/javascript"> function init_cart(){ var supplierReceiving = {}; supplierReceiving.items = []; supplierReceiving.ware_house = ""; supplierReceiving.reference_number = ""; supplierReceiving.invoice_number = ""; supplierReceiving.invoice_date = ""; supplierReceiving.indentNumber = ""; supplierReceiving.gateEntryReceiptNumber = ""; supplierReceiving.gateEntryDate = ""; supplierReceiving.entryName = ""; supplierReceiving.phoneNumber = ""; supplierReceiving.freightCharges = 0.00; supplierReceiving.freight_gst = 0; localStorage.setItem('supplierReceiving', JSON.stringify(supplierReceiving)); } if(localStorage.getItem('supplierReceiving') != null){ $(document).ready(function(){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); $('#referenceNumber').val(supplierReceiving.reference_number); $('#invoiceNumber').val(supplierReceiving.invoice_number); $('#indentNumber').val(supplierReceiving.indentNumber); if(supplierReceiving.ware_house != ""){ $('#ware_house').val(supplierReceiving.ware_house); } $('#gateEntryReceiptNumber').val(supplierReceiving.gateEntryReceiptNumber); $('#gateEntryDate').val(supplierReceiving.gateEntryDate); $('#entryName').val(supplierReceiving.entryName); $('#phoneNumber').val(supplierReceiving.phoneNumber); $('#freightCharges').val(supplierReceiving.freightCharges); $('#freight_charges').html(supplierReceiving.freightCharges); $('#freight_gst').val(supplierReceiving.freight_gst); if(supplierReceiving.freight_gst != ""){ var freightCharges = parseFloat(supplierReceiving.freightCharges); var freight_gst = parseInt(supplierReceiving.freight_gst); var fgst = (freightCharges*freight_gst)/100; calculate_total(); $('#freight_gst_charges').html(supplierReceiving.freight_gst); } if(supplierReceiving.invoice_date != ""){ $('#invoiceDate').val(supplierReceiving.invoice_date); } showSelectedItems(); calculate_total(); }); }else{ init_cart(); } function removeItem(id){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var items = supplierReceiving.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. } }); supplierReceiving.items = items; localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); showSelectedItems(); calculate_total(); } $('#spareCode').keypress(function(event){ var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ addselectedItem(); } }); function addselectedItem(){ var code = $('#spareCode').val(); if(code != ""){ var url = window.location.origin+"/admin/get-spare-part" var data = {}; data.code = code; data._token = "{{ 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 supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var is_added = false; $.each(supplierReceiving.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.new_rate = sparts.rate; sparts.total = 0; supplierReceiving.items.push(spare_part); } localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); showSelectedItems(); calculate_total(); }else{ swal("Invailid Spare Code !", { 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 supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var html = ''; var n = 0; $.each(supplierReceiving.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><input type="text" name="qty" id="qty_`+spare_part.id+`" onkeyup="calculate(this,`+spare_part.id+`)" style="width: 80px;" onblur="check_zero_qty(`+spare_part.id+`)" onkeypress="return onlyNumber(event)" value="`+spare_part.qty+`"/></td> <td><input type="text" name="rate" style="width: 80px;" id="rate_`+spare_part.id+`" onkeyup="rate_calculate(this,`+spare_part.id+`)" onblur="check_zero_rate(`+spare_part.id+`)" onkeypress="return onlyNumber(event)" value="`+spare_part.new_rate+`"/></td> <td>`+spare_part.gst_slab_rates+`%</td> <td id="total_`+spare_part.id+`">`+spare_part.total+` Rs</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(qty != ""){ var rate = parseInt($('#rate_'+id).val()); var total = qty*rate; $('#total_'+id).text(total+' Rs'); addCartValueInKey(id,'qty',qty); addCartValueInKey(id,'total',total); calculate_total(); } } function rate_calculate(t,id){ var rate = parseInt($(t).val()); if(rate != ""){ var qty = parseInt($('#qty_'+id).val()); var total = qty*rate; $('#total_'+id).text(total+' Rs'); addCartValueInKey(id,'qty',qty); addCartValueInKey(id,'new_rate',rate); addCartValueInKey(id,'total',total); calculate_total(); } } function calculate_total(){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var sub_total = 0; var gst_total = 0; var grand_total = 0; $.each(supplierReceiving.items,function(k,val){ let subtotal = parseFloat(val.total); let gst_rate = parseFloat(val.gst_slab_rates); let gsttotal = (subtotal*gst_rate)/100; sub_total = sub_total + subtotal; gst_total = gst_total + gsttotal; }); var freightCharges = parseFloat(supplierReceiving.freightCharges); var freight_gst = parseInt(supplierReceiving.freight_gst); var fgst = (freightCharges*freight_gst)/100; grand_total = sub_total + gst_total + freightCharges + fgst; $('#sub_total').text(sub_total.toFixed(2)); $('#gst_total').text(gst_total.toFixed(2)); $('#grand_total').text(grand_total.toFixed(2)); $('#loaderAction').hide(); } 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 check_zero_qty(id){ var qty = $('#qty_'+id).val(); if(qty == ""){ qty = 0; $('#qty_'+id).val(0); } calculate_total(); } function check_zero_rate(id){ var rate = $('#rate_'+id).val(); if(rate == ""){ rate = 0; $('#rate_'+id).val(0); } calculate_total(); } function addCartValueInKey(id,key,value){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); $.each(supplierReceiving.items,function(k,val){ if(parseInt(val.id) == id){ supplierReceiving.items[k][key] = value; } }); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function get_freight_gst(t){ var freightCharges = parseFloat($('#freightCharges').val()); var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var freight_gst = parseInt($(t).val()); var total_fgst = (freightCharges*freight_gst)/100; $('#freight_gst_charges').html(total_fgst); supplierReceiving.freight_gst = freight_gst; localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function get_ware_house(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var ware_house = $(t).val(); supplierReceiving.ware_house = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function referenceNumber(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.reference_number = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function invoiceNumber(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.invoice_number = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function invoiceDate(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.invoice_date = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function indentNumber(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.indentNumber = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function gateEntryReceiptNumber(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.gateEntryReceiptNumber = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function gateEntryDate(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.gateEntryDate = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function entryName(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.entryName = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function phoneNumber(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.phoneNumber = $(t).val(); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); } function freightCharges(t){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving.freightCharges = $(t).val(); $('#freight_charges').html($(t).val()); var freightCharges = $(t).val(); var freight_gst = parseInt($('#freight_charges').val()); var total_fgst = (freightCharges*freight_gst)/100; $('#freight_gst_charges').html(total_fgst); localStorage.setItem('supplierReceiving',JSON.stringify(supplierReceiving)); calculate_total(); } function is_valid(){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); var check = true; $.each(supplierReceiving.items,function(key,val){ if(val.qty == 0 ){ check = false; return false; } }); if(check == false){ return false }else{ return true; } } function onlyNumber(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)){ return false; } return true; } function material_received(){ var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); if(supplierReceiving.items.length > 0 && supplierReceiving.ware_house != ""){ if(is_valid()){ swal({ title: "Is Your Material Verified ?", text: "if you verified your materials then press 'Ok',otherwise press 'Cancel' and check again.", icon: "warning", buttons: true, dangerMode: true, }).then((willDelete) => { if (willDelete) { var url = window.location.origin+"/admin/material-receiving" var supplierReceiving = JSON.parse(localStorage.getItem('supplierReceiving')); supplierReceiving._token = "{{ csrf_token() }}"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: supplierReceiving, success:function(res){ console.log(res); if(res.success == true){ swal(res.msg, { icon: "success", }); init_cart(); $('#referenceNumber').val(); $('#invoiceNumber').val(); showSelectedItems(); calculate_total(); }else{ swal(res.msg, { icon: "error", }); } $('#loaderAction').hide(); }, error:function(error){ console.log(error); }, dataType: 'json' }); } }); }else{ swal('Spare Qty can not be zero. !', { icon: "error", }); } }else{ swal('Please add spare Item and select warehouse!', { icon: "error", }); } } $(document).ready(function(){ }); </script> @endpush