/
home
/
sjslayjy
/
public_html
/
mosaram
/
resources
/
views
/
dashboard
/
test
/
Upload File
HOME
@extends('dashboard.layouts.app') @section('title','Freight Payment') @section('content') <div class="main-content"> <div class="main-content-inner"> <div class="breadcrumbs ace-save-state" id="breadcrumbs"> <ul class="breadcrumb"> <li> <i class="ace-icon fa fa-home home-icon"></i> <a href="#">{{__('messages.Home')}}</a> </li> <li><a href="{{'/get-voucher-update'}}"> Voucher no Update</a></li> <li class="active">Voucher No Update</li> </ul> </div> <div class="page-content"> @if (session('success')) <div class="alert alert-success"> {{ session('success') }} </div> @endif @if (session('error')) <div class="alert alert-danger"> {{ session('error') }} </div> @endif <div class="page-header"> <h1> Voucher No Update </h1> </div><!-- /.page-header --> <form action="{{url('/update-voucher-no')}}" method="post" role="form" id="voucherNoForm" onsubmit="return validateForm()"> {{ csrf_field() }} <div class="container"> <div class="row"> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title"> Voucher No Update Form </h3> </div> <div class="panel-body"> <div class="col-md-4"> <div class="form-group"> <label for="qr_data">Voucher No </label> <input type="text" class="form-control" name="qr_data" id="qr_data" onchange="getLoadingSlipDetails(this.value)"> </div> </div> <div class="col-md-8"> <div class="update-voucherNo-freight-error" style="display: none;"> <div class="col-md-offset-4"> <span id="update_voucherNo_error_span" style="font-size: 30px; color: red; text-align: center;"></span> </div> </div> </div> <div class="clearfix"></div> <div id="details" style="display: none;"> <input type="hidden" name="voucher_no" id="voucher_no"> <div class="col-md-4"> <div class="form-group"> <label for="transfer_type">Amount</label> <input type="text" class="form-control" name="transfer_type" id="transfer_type" readonly=""> <input type="hidden" class="form-control" name="amount" id="amount" readonly=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="to_dealer">Dealer</label> <input type="text" class="form-control" name="to_dealer" id="to_dealer" readonly=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="warehouse">Retailer</label> <input type="text" class="form-control" name="warehouse" id="warehouse" readonly=""> </div> </div> <div class="clearfix"></div> <!-- <div class="col-md-4"> <div class="form-group"> <label for="account_from">Account From</label> <input type="text" class="form-control" name="account_from" id="account_from" readonly=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="quantity"> {{__('messages.Quantity')}}</label> <input type="text" class="form-control" name="quantity" id="quantity" readonly=""> </div> </div> --> <div class="clearfix"></div> <!-- <div class="col-md-4"> <div class="form-group"> <label for="from_stock"> From Stock</label> <input type="text" class="form-control" name="from_stock" id="from_stock" readonly=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="dealer_stock">Dealer Stock</label> <input type="text" class="form-control" name="dealer_stock" id="dealer_stock" readonly=""> </div> </div> --> <div class="clearfix"></div> <div class="col-md-4"> <div class="form-group"> <label for="product_and_company">Reference Number</label> <input type="text" class="form-control" name="product_and_company" id="product_and_company" readonly=""> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="update_dealer">Update Dealer</label> <select class="form-control select2" name="update_dealer" id="update_dealer" onchange="getRetailerDealer()"> <option value=""> Dealer Select</option> @foreach($dealers as $dealer) <option value="{{$dealer->id}}">{{$dealer->name}} ({{$dealer->id}})</option> @endforeach </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="update_retailer">Update Retailer</label> <select class="form-control select2" name="update_retailer" id="update_retailer" onchange="getRetailerDealer()"> <option value=""> Retailer Select</option> @foreach($retailers as $retailer) <option value="{{$retailer->id}}">{{$retailer->name}} ({{$retailer->id}})</option> @endforeach </select> </div> </div> <div class="clearfix"></div> <div class="panel panel-primary" id="invoice_div" style="display:none"> <div class="panel-body"> <input type="hidden" name="dealer_id" value="30"> <input type="hidden" name="retailer_id" value="6"> <input type="hidden" name="retailer_advance_balance" id="retailer_advance_balance" value=""> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="">Dealer</label> <input type="text" class="form-control" id="dealer_name" value="" readonly="readonly"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="">Party</label> <input type="text" class="form-control" id="retailer_name" value="" readonly="readonly"> </div> </div> </div> <div class="row"> <div class="col-md-2"> <div class="form-group"> <label for="">Party Balance</label> <span></span> <input type="text" class="form-control " name="party_advance_blance" id="party_advance_blance" placeholder="Party Advance Blance" value=" 0 " readonly="readonly"> <span class="label label-danger" style="display: none;"></span> </div> </div> </div> <div class="row"> <div class="col-md-12"> <h4>Invoice List Of Party</h4> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>SNo</th> <th>Invoice No</th> <th>Invoice Date</th> <th>Invoice Amount</th> <th>Remaining invoice Amount</th> <th>Amount Adjust in Invoice</th> <th>--</th> </tr> </thead> <tbody id="tbl_invoice"> </tbody> </table> </div> </div> </div> <div class="pull-right"> <!-- <a href="{{URL('/get-voucher-update')}}" class="btn btn-default" >Reset</a> --> <button type="button" id="updateVoucherNo" name="saveVoucherNoForm" class="btn btn-primary">Update Warehouse Di</button> </div> </div> <div class="clearfix"></div> <div class="freight-error" style="display: none;"> <div class="col-md-offset-4"> <span id="freight_error_span" style="font-size: 30px; color: red; text-align: center;"></span> </div> </div> </div> </div> </div> </div> </form> </div> </div><!-- /.page-content --> </div><!-- /.main-content --> @section('script') {{ Html::script("assets/js/ace-elements.min.js")}} {{ Html::script("assets/js/ace.min.js")}} {{ Html::script("assets/js/bootstrap-datepicker.min.js")}} <script type="text/javascript"> $(document).ready(function() { $("#qr_data").focus(); $('.date-picker').datepicker({ format: 'dd/mm/yyyy', endDate: '+0d', autoclose: true }); // $("#update_warehouse").change(function(event) { // event.preventDefault(); // var update_warehouse_freight = $("#update_warehouse").val(); // var quantity = $("#quantity").val(); // if (update_warehouse_freight == "00") { // swal('Error','Please Select update_warehouse','error'); // $("#freight").val(''); // } else { // var freight = parseFloat(update_warehouse_freight) * parseInt(quantity); // $("#freight").val(freight); // } // }); $("#updateVoucherNo").click(function(event) { event.preventDefault(); // $(".loading-bg").show(); $.ajax({ url: $("#voucherNoForm").attr('action'), type: 'POST', data: $("#voucherNoForm").serialize(), success:function(data){ console.log(data); // $(".loading-bg").show(); if (data.flag) { $(".loading-bg").show(); swal({ title : "Success", text : data.message, type : "success" }, function(){ window.location.reload(); }); } else { // $("#update_voucherNo_error_span").text(' '); // $("#update_voucherNo_error_span").text(data.message); // $(".update-voucherNo-freight-error").show(); // console.log(data.errors); // var msg=''; // if(data.errors){ // // $.each(data.errors, function(key,val) { // // msg+='Please All Require -> <br>'; // // msg+='<br>'; // // msg= // } swal({ title : "Error", text : data.message, type : "error" }, function(){ // window.location.reload(); }); } } }) .done(function() { console.log("success"); }) .fail(function() { console.log("error"); }) .always(function() { console.log("complete"); }); }); }); function validateForm(){ if($('#update_warehouse').val() == ""){ swal({ title : 'Error', text : 'Please Select update_warehouse', type : 'error' }, function(){ $("#update_warehouse").select2('open'); }); return false; }else{ return true; } } function getLoadingSlipDetails(qr_value){ var url ="{{url('get-voucher-details')}}"; if (qr_value == "") { swal({ title : 'Loading Slip Missing!', text : 'Please Scan Loading Slip QR Code', type : 'error' }, function(){ $("#qr_data").focus(); $("#voucher_no").val(''); $("#transfer_type").val(''); $("#account_from").val(''); $("#amount").val(''); $("#to_dealer").val(''); $("#product_and_company").val(''); $("#warehouse").val(''); $("#quantity").val(''); $("#update_warehouse").select2("val", ""); $("#dealer_stock").val(''); $("#from_stock").val(''); $('#party_advance_blance').val(); }); } else { $(".loading-bg").show(); $.ajax({ url: url+"/"+qr_value, type: 'GET', success:function(data){ console.log(data); $(".loading-bg").hide(); if (data.flag) { $("#qr_data").attr('readonly', true); $("#voucher_no").val(data.bankTransactionDetails.series); $("#transfer_type").val(data.amount); $("#amount").val(data.amount); $("#product_and_company").val(data.bankTransactionDetails.reference_number); $("#to_dealer").val(data.dealer); $("#warehouse").val(data.retailer); $("#details").show(); } else { $("#freight_error_span").text(data.message); $(".freight-error").show(); } } }); } $('.date-picker').datepicker({ format: 'dd/mm/yyyy', endDate: '+0d', autoclose: true }); } function getRetailerDealer(){ var dealer_id=$("#update_dealer").val(); var retailer_id= $("#update_retailer").val(); if(dealer_id!='' && retailer_id!=''){ console.log(`Del- ${dealer_id} Ret- ${retailer_id}`); // $(".loading-bg").show(); var url ="{{url('get-party-invoice-details')}}"; $.ajax({ url: url+"/"+dealer_id+"/"+retailer_id, type: 'GET', success:function(data){ $("#party_advance_blance").val(data.party_balance); console.log(data); var amount= parseFloat($("#amount").val()); var partyAdvance = parseFloat($('#party_advance_blance').val()); console.log(amount); console.log(partyAdvance); $("#dealer_name").val(data.dealer); $("#retailer_name").val(data.retailer); $("#tbl_invoice").html(''); var invoices=''; // invoices +='<tr>'; var t_remainingAmt=0; $.each(data.invoices, function (i) { invoices+=`<tr><td>${i+1}</td>`; invoices+=`<td>${data.invoices[i]['invoice_number']}</td>`; invoices+=`<td>${data.invoices[i]['invoice_date']}</td>`; invoices+=`<td>${data.invoices[i]['total']}</td>`; invoices+=`<td class="remaining_amount" data-id="${data.invoices[i]['id']}">${data.invoices[i]['remaining_amount']}</td>`; invoices+=`<td><input type="text" class="invoice_payment" name="invoice_payment[${data.invoices[i]['id']}]" id="invoice_id_${data.invoices[i]['id']}" value=""/></td>`; invoices+=`<td></td>`; invoices +='</tr>'; t_remainingAmt+=data.invoices[i]['remaining_amount']; }) invoices +='<tr>'; invoices +=`<td colspan="3" id="invoices_complete">Total Remailning Invoice Amount</td> <td id="totalRemaining">${t_remainingAmt}</td> <td id="current_payments"></td> <td></td> </tr> <tr> <td colspan="3">Party Balance In Advance</td> <td id="partyAdvance"></td> </tr>`; $("#tbl_invoice").html(invoices); if(!isNaN(amount)){ let myamount = amount + partyAdvance; console.log(`MyAmount ${myamount}`); $('.remaining_amount').each(function(k,v){ var invoice_amount = parseFloat($(v).text()); console.log(`InvoiceAmt ${invoice_amount}`); var invoice_id = $(v).data('id'); if(invoice_amount <= myamount && myamount != 0){ $('#invoice_id_'+invoice_id).val(invoice_amount); myamount = myamount - invoice_amount; $('#invoice_id_'+invoice_id).attr('readonly',true); }else if(invoice_amount > myamount && myamount != 0){ $('#invoice_id_'+invoice_id).val(myamount); myamount = 0; }else if(myamount == 0){ $('#invoice_id_'+invoice_id).val(''); $('#invoice_id_'+invoice_id).attr('readonly',false); } var remaining_amount = parseFloat($('#totalRemaining').text()); let all_amount = amount + partyAdvance ; if(all_amount >= remaining_amount){ var advance = all_amount - remaining_amount; $('#partyAdvance').text(advance); $('#retailer_advance_balance').val(advance); }else{ $('#partyAdvance').text(0); $('#retailer_advance_balance').val(0); } }); }else{ $('.remaining_amount').each(function(k,v){ var invoice_id = $(v).data('id'); $('#invoice_id_'+invoice_id).val(''); $('#invoice_id_'+invoice_id).attr('disabled',false); }); } $("#invoice_div").show(); // console.log(invoices); } }); }else{ console.log(`Please Select Both`); } } function reCalculateFreight(value){ if(value == ""){ var toll_tax = 0; }else{ var toll_tax = parseFloat(value); var freight = parseFloat($("#freight_rate").val()) * parseInt($("#quantity").val()); $("#freight").val(freight + toll_tax); } } </script> @endsection @endsection