/
home
/
sjslayjy
/
public_html
/
assets
/
resources
/
views
/
circle-store
/
indent
/
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">Requested Indent</h3> <div class="row"> <div class="col-lg-3"> <label>Indent Number : <br/><strong>{{$indent->indent_no}}</strong></label> </div> <div class="col-lg-3"> <label>Indent Date : <br/><strong>{{$indent->indent_date}}</strong></label> </div> <div class="col-lg-3"> <label>Indent Placed By : <br/><strong>{{$indent->addedBy($indent->indent_placed_by)}}</strong></label> </div> <div class="col-lg-3"> <label>Indent Status : <br/><strong>{{$indent->status}}</strong></label> </div> </div> <div class="row"> <div class="col-lg-3"> <label>Business Type : <br/><strong>{{$indent->business_type}}</strong></label> </div> <div class="col-lg-3"> <label>Customer Code : <br/><strong>{{$indent->customer_code}}</strong></label> </div> <div class="col-lg-3"> <label>Customer Name : <br/><strong>{{$indent->customer_name}}</strong></label> </div> <div class="col-lg-3"> <label>Customer PO : <br/><strong>{{$indent->customer_po}}</strong></label> </div> </div> <div class="row"> <div class="col-lg-3"> <label>Cutomer PO Date : <br/><strong>{{$indent->cutomer_po_date}}</strong></label> </div> <div class="col-lg-3"> <label>Requested From Warehouse : <br/><strong>{{$indent->ware_house}}</strong></label> </div> <div class="col-lg-6"> <label>Remarks: <br/><strong>{{$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">Spare 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" onclick="addselectedItem()">Add Into Indent</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> Category</th> <th> Qty</th> <th> --- </th> </tr> </thead> <tbody id="tbody"> @foreach($indent->items as $item) <tr class="row_{{$item->id}}"> <td class="font-weight-medium">{{$item->spare_code}}</td> <td>{{$item->spareParts($item->spare_code)->description}}</td> <td>{{$item->spareParts($item->spare_code)->uom}}</td> <td>{{$item->spareParts($item->spare_code)->category}}</td> <td>{{$item->qty}}</td> <td><!--a href="#" onclick="removeItem('{{$item->id}}')"><i class="mdi mdi-delete-forever"></i></a--></td> </tr> @endforeach </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-9"></div> <!--div class="col-lg-3"><button type="button" onclick="place_indent()" class="btn btn-warning btn-fw">Place Indent</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 mydata = {}; mydata.items = []; localStorage.setItem('mydata', JSON.stringify(mydata)); } function removeItem(id){ var mydata = JSON.parse(localStorage.getItem('mydata')); var items = mydata.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. } }); mydata.items = items; localStorage.setItem('mydata',JSON.stringify(mydata)); showSelectedItems(); } 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 mydata = JSON.parse(localStorage.getItem('mydata')); var is_added = false; $.each(mydata.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; mydata.items.push(spare_part); } localStorage.setItem('mydata',JSON.stringify(mydata)); showSelectedItems(); }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 mydata = JSON.parse(localStorage.getItem('mydata')); var html = ''; var n = 0; $.each(mydata.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><input type="text" name="qty" 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(qty != ""){ var rate = parseInt($('#rate_'+id).val()); var total = qty*rate; $('#total_'+id).text(total+' Rs'); addCartValueInKey(id,'qty',qty); } } function addCartValueInKey(id,key,value){ var mydata = JSON.parse(localStorage.getItem('mydata')); $.each(mydata.items,function(k,val){ if(parseInt(val.id) == id){ mydata.items[k][key] = value; } }); localStorage.setItem('mydata',JSON.stringify(mydata)); } function place_indent(){ 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/place-indent" var mydata = JSON.parse(localStorage.getItem('mydata')); mydata._token = "{{ csrf_token() }}"; $('#loaderAction').show(); $.ajax({ type: "POST", url: url, data: mydata, success:function(res){ console.log(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> @endpush