close #799 Fixed: Customer Login - Invoice Sorting not working
This commit is contained in:
parent
575557d879
commit
b6da292201
@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Events\InvoicePrinting;
|
use App\Events\InvoicePrinting;
|
||||||
use App\Models\Banking\Account;
|
use App\Models\Banking\Account;
|
||||||
use App\Models\Income\Customer;
|
use App\Models\Income\Customer;
|
||||||
use App\Models\Income\Revenue;
|
|
||||||
use App\Models\Income\Invoice;
|
use App\Models\Income\Invoice;
|
||||||
use App\Models\Income\InvoiceStatus;
|
use App\Models\Income\InvoiceStatus;
|
||||||
use App\Models\Setting\Category;
|
use App\Models\Setting\Category;
|
||||||
@ -33,12 +32,18 @@ class Invoices extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$invoices = Invoice::with('status')->accrued()->where('customer_id', auth()->user()->customer->id)->paginate();
|
$invoices = Invoice::with(['customer', 'status', 'items', 'payments', 'histories'])
|
||||||
|
->accrued()->where('customer_id', auth()->user()->customer->id)
|
||||||
|
->collect(['invoice_number'=> 'desc']);
|
||||||
|
|
||||||
$status = collect(InvoiceStatus::all()->pluck('name', 'code'))
|
$categories = collect(Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id'));
|
||||||
->prepend(trans('general.all_type', ['type' => trans_choice('general.statuses', 2)]), '');
|
|
||||||
|
|
||||||
return view('customers.invoices.index', compact('invoices', 'status'));
|
$statuses = collect(InvoiceStatus::get()->each(function ($item) {
|
||||||
|
$item->name = trans('invoices.status.' . $item->code);
|
||||||
|
return $item;
|
||||||
|
})->pluck('name', 'code'));
|
||||||
|
|
||||||
|
return view('customers.invoices.index', compact('invoices', 'categories', 'statuses'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,31 +55,15 @@ class Invoices extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(Invoice $invoice)
|
public function show(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$paid = 0;
|
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
foreach ($invoice->payments as $item) {
|
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
|
||||||
$amount = $item->amount;
|
|
||||||
|
|
||||||
if ($invoice->currency_code != $item->currency_code) {
|
|
||||||
$item->default_currency_code = $invoice->currency_code;
|
|
||||||
|
|
||||||
$amount = $item->getDynamicConvertedAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
$paid += $amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
$invoice->paid = $paid;
|
|
||||||
|
|
||||||
$accounts = Account::enabled()->pluck('name', 'id');
|
|
||||||
|
|
||||||
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
|
||||||
|
|
||||||
$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();
|
$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();
|
||||||
|
|
||||||
$customers = Customer::enabled()->pluck('name', 'id');
|
$customers = Customer::enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
$categories = Category::enabled()->type('income')->pluck('name', 'id');
|
$categories = Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
$payment_methods = Modules::getPaymentMethods();
|
$payment_methods = Modules::getPaymentMethods();
|
||||||
|
|
||||||
@ -106,7 +95,9 @@ class Invoices extends Controller
|
|||||||
{
|
{
|
||||||
$invoice = $this->prepareInvoice($invoice);
|
$invoice = $this->prepareInvoice($invoice);
|
||||||
|
|
||||||
$view = view($invoice->template_path, compact('invoice'))->render();
|
$currency_style = true;
|
||||||
|
|
||||||
|
$view = view($invoice->template_path, compact('invoice', 'currency_style'))->render();
|
||||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES');
|
$html = mb_convert_encoding($view, 'HTML-ENTITIES');
|
||||||
|
|
||||||
$pdf = \App::make('dompdf.wrapper');
|
$pdf = \App::make('dompdf.wrapper');
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
<div class="box box-success">
|
<div class="box box-success">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
{!! Form::open(['url' => 'customers/invoices', 'role' => 'form', 'method' => 'GET']) !!}
|
{!! Form::open(['url' => 'customers/invoices', 'role' => 'form', 'method' => 'GET']) !!}
|
||||||
<div class="pull-left">
|
<div id="items" class="pull-left box-filter">
|
||||||
<span class="title-filter hidden-xs">{{ trans('general.search') }}:</span>
|
<span class="title-filter hidden-xs">{{ trans('general.search') }}:</span>
|
||||||
{!! Form::text('search', request('search'), ['class' => 'form-control input-filter input-sm', 'placeholder' => trans('general.search_placeholder')]) !!}
|
{!! Form::text('search', request('search'), ['class' => 'form-control input-filter input-sm', 'placeholder' => trans('general.search_placeholder')]) !!}
|
||||||
{!! Form::select('status', $status, request('status'), ['class' => 'form-control input-filter input-sm']) !!}
|
{!! Form::select('categories[]', $categories, request('categories'), ['id' => 'filter-categories', 'class' => 'form-control input-filter input-lg', 'multiple' => 'multiple']) !!}
|
||||||
|
{!! Form::dateRange('invoice_date', trans('invoices.invoice_date'), 'calendar', []) !!}
|
||||||
|
{!! Form::select('statuses[]', $statuses, request('statuses'), ['id' => 'filter-statuses', 'class' => 'form-control input-filter input-lg', 'multiple' => 'multiple']) !!}
|
||||||
{!! Form::button('<span class="fa fa-filter"></span> ' . trans('general.filter'), ['type' => 'submit', 'class' => 'btn btn-sm btn-default btn-filter']) !!}
|
{!! Form::button('<span class="fa fa-filter"></span> ' . trans('general.filter'), ['type' => 'submit', 'class' => 'btn btn-sm btn-default btn-filter']) !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@ -24,22 +26,23 @@
|
|||||||
<div class="table table-responsive">
|
<div class="table table-responsive">
|
||||||
<table class="table table-striped table-hover" id="tbl-invoices">
|
<table class="table table-striped table-hover" id="tbl-invoices">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-md-2">@sortablelink('invoice_number', trans('invoices.invoice_number'))</th>
|
<th class="col-md-2">@sortablelink('invoice_number', trans_choice('general.numbers', 1))</th>
|
||||||
<th class="col-md-2 text-right">@sortablelink('amount', trans('general.amount'))</th>
|
<th class="col-md-2 text-right amount-space">@sortablelink('amount', trans('general.amount'))</th>
|
||||||
<th class="col-md-3 text-right">@sortablelink('invoiced_at', trans('invoices.invoice_date'))</th>
|
<th class="col-md-3">@sortablelink('invoiced_at', trans('invoices.invoice_date'))</th>
|
||||||
<th class="col-md-3 text-right">@sortablelink('due_at', trans('invoices.due_date'))</th>
|
<th class="col-md-3">@sortablelink('due_at', trans('invoices.due_date'))</th>
|
||||||
<th class="col-md-2 text-center">@sortablelink('status.name', trans_choice('general.statuses', 1))</th>
|
<th class="col-md-2">@sortablelink('invoice_status_code', trans_choice('general.statuses', 1))</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($invoices as $item)
|
@foreach($invoices as $item)
|
||||||
|
@php $paid = $item->paid; @endphp
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url('customers/invoices/' . $item->id) }}">{{ $item->invoice_number }}</a></td>
|
<td><a href="{{ url('customers/invoices/' . $item->id) }}">{{ $item->invoice_number }}</a></td>
|
||||||
<td class="text-right">@money($item->amount, $item->currency_code, true)</td>
|
<td class="text-right amount-space">@money($item->amount, $item->currency_code, true)</td>
|
||||||
<td class="text-right">{{ Date::parse($item->invoiced_at)->format($date_format) }}</td>
|
<td>{{ Date::parse($item->invoiced_at)->format($date_format) }}</td>
|
||||||
<td class="text-right">{{ Date::parse($item->due_at)->format($date_format) }}</td>
|
<td>{{ Date::parse($item->due_at)->format($date_format) }}</td>
|
||||||
<td class="text-center"><span class="label {{ $item->status->label }}">{{ trans('invoices.status.' . $item->status->code) }}</span></td>
|
<td><span class="label {{ $item->status->label }}">{{ trans('invoices.status.' . $item->status->code) }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -54,3 +57,31 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- /.box -->
|
<!-- /.box -->
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/daterangepicker/moment.js') }}"></script>
|
||||||
|
<script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/daterangepicker/daterangepicker.js') }}"></script>
|
||||||
|
<script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/bootstrap-datepicker.js') }}"></script>
|
||||||
|
@if (language()->getShortCode() != 'en')
|
||||||
|
<script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/locales/bootstrap-datepicker.' . language()->getShortCode() . '.js') }}"></script>
|
||||||
|
@endif
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('css')
|
||||||
|
<link rel="stylesheet" href="{{ asset('vendor/almasaeed2010/adminlte/plugins/daterangepicker/daterangepicker.css') }}">
|
||||||
|
<link rel="stylesheet" href="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/datepicker3.css') }}">
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#filter-categories").select2({
|
||||||
|
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#filter-statuses").select2({
|
||||||
|
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.statuses', 1)]) }}"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
Loading…
x
Reference in New Issue
Block a user