/
home
/
sjslayjy
/
public_html
/
mosaram
/
resources
/
views
/
dashboard
/
invoice
/
Upload File
HOME
@extends('dashboard.layouts.app') @section('title','Party Invoice Payment') @section('style') {{Html::style("assets/css/bootstrap-datepicker3.min.css")}} @endsection @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 class="active"> Credit Note</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="row"> <div class="col-xs-12"> <h3 class="header smaller lighter blue">Credit Note</h3> <form action="" method="POST" role="form" id="FilterForm"> <div class="row"> {{csrf_field()}} <div class="col-md-3"> <div class="form-group"> <label for="dealer_id"> {{__('messages.Dealer')}}</label> <select class="form-control select2" name="dealer_id" id="dealer_id" > <option value=""> Select Dealer</option> @foreach($dealers as $dealer) <option value="{{$dealer->id}}" {{isset($dealer_id) && $dealer_id==$dealer->id ? "selected":""}}>{{$dealer->name}} ({{$dealer->address1}})</option> @endforeach() </select> @if ($errors->has('dealer_id')) <span class="label label-danger">{{ $errors->first('dealer_id') }}</span> @endif </div> </div> <div class="col-md-3"> <div class="form-group"> <label for="retailer_id"> {{__('messages.Retailers')}}</label> <select class="form-control select2" name="retailer_id" id="retailer_id" > <option value=""> Select retailer </option> @foreach($retailers as $retailer) <option value="{{$retailer->id}}" {{isset($retailer_id) && $retailer_id==$retailer->id ? "selected":""}}>{{$retailer->name}} ({{$retailer->address}})</option> @endforeach() </select> @if ($errors->has('retailer_id')) <span class="label label-danger">{{ $errors->first('retailer_id') }}</span> @endif </div> </div> <div class="col-md-3"> <div class="form-group"> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> </form> </div> </div> <div class="clearfix"> <div class="pull-right tableTools-container"> </div> </div> <div class="table-header"> Loading Slip Invoice Payment </div> @if( (isset($dealer_id) && !is_null($dealer_id)) && (isset($retailer_id) && !is_null($retailer_id))) <div class="panel panel-primary"> <div class="panel-body"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="">Party</label> <input type="text" class="form-control" value="{{$retailerInfo->name}} ({{$retailerInfo->address}})" 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="@if($party_balance < 0){{abs($party_balance)}} @else 0 @endif" 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>Paid Status</th> <th>Amount Adjust in Invoice</th> <th>--</th> </tr> </thead> <tbody> @foreach($invoices as $key => $invoice) @if($invoice->cn_qty < $invoice->quantity) <tr> <td>{{$key+1}}</td> <td>{{$invoice->invoice_number}}</td> <td>{{$invoice->invoice_date}}</td> <td>{{$invoice->total}}</td> <td class="remaining_amount" data-id="{{$invoice->id}}">{{$invoice->remaining_amount}}</td> <td>@if($invoice->remaining_amount == 0) <span class="bg-success text-success">Paid</span> @elseif($invoice->remaining_amount == $invoice->total) <span class="bg-success text-danger">Unpaid</span> @else <span class="bg-success text-warning">Partial Paid</span> @endif </td> <td> <div class="widget-toolbar no-border"> <a class="btn btn-xs bigger btn-success" data-toggle="modal" onclick="getInvoiceDetail({{$invoice->id}})"> Credit Note <i class="ace-icon fa fa-eye icon-on-right"></i> </a> </div> <td></td> </tr> @endif @endforeach </tbody> </table> </div> </div> </div> </div> @endif </div> </div><!-- /.page-content --> </div> </div><!-- /.main-content --> <div class="modal fade" id="creditModel"> @if ($errors->any()) <ul> @foreach ($errors->all() as $message) <li>{{$message}}</li> @endforeach </ul> @endif </div> @section('script') {{ Html::script("assets/js/jquery.dataTables.min.js")}} {{ Html::script("assets/js/jquery.dataTables.bootstrap.min.js")}} {{ Html::script("assets/js/dataTables.buttons.min.js")}} {{ Html::script("assets/js/buttons.flash.min.js")}} {{ Html::script("assets/js/buttons.html5.min.js")}} {{ Html::script("assets/js/buttons.print.min.js")}} {{ Html::script("assets/js/buttons.colVis.min.js")}} {{ Html::script("assets/js/dataTables.select.min.js")}} {{ 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"> function getInvoiceDetail(id) { $.ajax({ url: '/user/invoice-detail', method: 'POST', data: {_token:"{{ csrf_token()}}", invoice_id:id}, success: function(res) { var session = ''; $.each(res.sessions, function(index, value){ session += `<option value="`+value.id+`">`+value.session+`</option>`; }); console.log("total return quantity :"+res.total_returned_qty); var html = `<div class="modal-dialog modal-md"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Credit Note</h4> </div> <div class="modal-body"> <form action="{{URL('/user/save-credit-note')}}" id="reciveCreditNote" method="POST"> @csrf <div class="row"> <div class="col-md-6"> <label>Company Name</label> <p>`+res.credit_company.name+`</p> <input type="text" name="company_id" value="`+res.credit_company.id+`" hidden="true"> <input type="text" name="dealer_id" value="`+res.credit_invoice.dealer_id+`" hidden="true"> </div> <div class="col-md-6"> <label>Product Name</label> <p>`+res.credit_invoice.product+`</p> </div> </div> <hr> <div class="row"> <div class="col-md-6"> <label>Party Name</label> <p>`+res.credit_retailer.name+`</p> <input type="text" name="retailer_id" value="`+res.credit_retailer.id+`" hidden="true"> </div> <div class="col-md-6"> <label>Invoice Number</label> <p>`+res.credit_invoice.invoice_number+`</p> <input type="text" name="invoice_id" value="`+res.credit_invoice.id+`" hidden="true"> <input type="text" name="invoice_number" value="`+res.credit_invoice.invoice_number+`" hidden="true"> </div> </div> <hr> <div class="row"> <div class="col-md-6"> <label>Rate</label> <p id="credit_rate">`+(res.credit_invoice.rate - res.credit_invoice.freight_discount)+`</p> </div> <div class="col-md-6"> <label>Session</label> <div class="form-group"> <select name="session" id="session"> <option value="">Select Session</option> `+session+` </select> <span class="label label-danger" id="add_session_error"></span> </div> </div> </div> <div class="row"> <div class="col-md-6"> <label>Total Quantity</label> <p id="total_quantity">`+res.credit_invoice.quantity+`</p> <input type="text" name="total_quantity" value="`+res.credit_invoice.quantity+`" hidden="true"> </div> <div class="col-md-6"> <div class="form-group"> <label for="quantity">Return Quantity</label> <input type="text" class="form-control" name="return_quantity" onkeypress="return onlyCurrency(event)" onkeyup="calculateAmount()" id="return_quantity" placeholder="return quantity"> <span class="label label-danger" id="add_quantity_error"></span> </div> </div> </div> <div class="row"> <div class="col-md-6"> <label>Amount</label> <p id="credit_amount">`+res.credit_invoice.total+`</p> <input type="text" value="`+res.credit_invoice.total+`" name="total_amount" hidden="true"> </div> <div class="col-md-6"> <div class="form-group"> <label for="amount">Credit Note Amount</label> <input type="text" class="form-control" name="credit_note_amount" id="credit_note_amount" placeholder="credit note amount" readonly> <span class="label label-danger"></span> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" id="addBankBtn" onclick="submit_now(`+res.total_returned_qty+`)" class="btn btn-primary">Submit</button> </div> </form> </div> </div> </div>`; $('#creditModel').html(html); $("#creditModel").modal('show'); }, }); } 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 calculateAmount(event) { var return_quantity = $('#return_quantity').val(); if(return_quantity !="" && return_quantity != null) { return_quantity = parseInt(return_quantity); var total_quantity = parseInt($('#total_quantity').text()); var credit_rate = $('#credit_rate').text(); if(return_quantity == 'NaN') { $('#return_quantity').val('0'); $('#credit_note_amount').val('0'); }else if(return_quantity > total_quantity) { $('#return_quantity').val('0'); $('#credit_note_amount').val('0'); } else { $('#credit_note_amount').val(return_quantity*credit_rate); } } } function submit_now(total_returned_qty) { var return_qty = parseInt($('#return_quantity').val()); var total_quantity = parseInt($('#total_quantity').text()); $('#add_quantity_error').text(''); $('#add_session_error').text(''); if((total_returned_qty + return_qty) > total_quantity) { $('#add_quantity_error').text('Return Quantity is greater than available Quantity.'); } else if(return_qty <= 0) { $('#add_quantity_error').text('Return Quantity can\'t be zero.'); } else { $.ajax({ url: $('#reciveCreditNote').attr('action'), method: 'POST', data: $('#reciveCreditNote').serialize(), success: function(res){ if(res.error) { $('#add_quantity_error').text(res.error.return_quantity); $('#add_session_error').text(res.error.session); } else { if(res.success == true) { swal({ title: "Success!", text: res.msg, type: "success" }, function() { window.location.reload(); }); } else { swal(res.msg, { icon: "error", }); } } } }); } } </script> @endsection @endsection