mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #5412 from beganovich/v5-1004-billing-portal
(v5) Billing portal
This commit is contained in:
commit
9a0417c1ba
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoice Ninja (https://invoiceninja.com).
|
|
||||||
*
|
|
||||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
||||||
*
|
|
||||||
* @license https://opensource.org/licenses/AAL
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Livewire;
|
|
||||||
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Utils\Traits\WithSorting;
|
|
||||||
use Livewire\Component;
|
|
||||||
use Livewire\WithPagination;
|
|
||||||
|
|
||||||
class SubscriptionInvoicesTable extends Component
|
|
||||||
{
|
|
||||||
use WithPagination;
|
|
||||||
use WithSorting;
|
|
||||||
|
|
||||||
public $per_page = 10;
|
|
||||||
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
$query = Invoice::query()
|
|
||||||
->where('client_id', auth('contact')->user()->client->id)
|
|
||||||
->whereNotNull('subscription_id')
|
|
||||||
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
|
|
||||||
->where('balance', '=', 0)
|
|
||||||
->paginate($this->per_page);
|
|
||||||
|
|
||||||
return render('components.livewire.subscriptions-invoices-table', [
|
|
||||||
'invoices' => $query,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
<div>
|
|
||||||
<p class="mb-4 uppercase leading-4 tracking-wide inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-primary text-white">
|
|
||||||
One-time payments
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-between mt-4">
|
|
||||||
<div class="flex items-center">
|
|
||||||
<span class="mr-2 text-sm hidden md:block">{{ ctrans('texts.per_page') }}</span>
|
|
||||||
<select wire:model="per_page" class="form-select py-1 text-sm">
|
|
||||||
<option>5</option>
|
|
||||||
<option selected>10</option>
|
|
||||||
<option>15</option>
|
|
||||||
<option>20</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="-my-2 py-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
|
|
||||||
<div class="align-middle inline-block min-w-full overflow-hidden rounded">
|
|
||||||
<table class="min-w-full shadow rounded border border-gray-200 mt-4 credits-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="px-6 py-3 text-xs font-medium leading-4 tracking-wider text-left text-white uppercase border-b border-gray-200 bg-primary">
|
|
||||||
<p role="button" wire:click="sortBy('number')" class="cursor-pointer">
|
|
||||||
{{ ctrans('texts.subscription') }}
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th class="px-6 py-3 text-xs font-medium leading-4 tracking-wider text-left text-white uppercase border-b border-gray-200 bg-primary">
|
|
||||||
<p role="button" wire:click="sortBy('number')" class="cursor-pointer">
|
|
||||||
{{ ctrans('texts.invoice') }}
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th class="px-6 py-3 border-b border-gray-200 bg-primary text-left text-xs leading-4 font-medium text-white uppercase tracking-wider">
|
|
||||||
<p role="button" wire:click="sortBy('amount')" class="cursor-pointer">
|
|
||||||
{{ ctrans('texts.amount') }}
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th class="px-6 py-3 border-b border-gray-200 bg-primary text-left text-xs leading-4 font-medium text-white uppercase tracking-wider">
|
|
||||||
<p role="button" wire:click="sortBy('date')" class="cursor-pointer">
|
|
||||||
{{ ctrans('texts.date') }}
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@forelse($invoices as $invoice)
|
|
||||||
<tr class="bg-white group hover:bg-gray-100">
|
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
|
||||||
{{ $invoice->subscription->name }}
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
|
||||||
<a href="{{ route('client.invoice.show', $invoice->hashed_id) }}"
|
|
||||||
class="button-link text-primary">
|
|
||||||
{{ $invoice->number }}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
|
||||||
{{ App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
|
||||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@empty
|
|
||||||
<tr class="bg-white group hover:bg-gray-100">
|
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500" colspan="100%">
|
|
||||||
{{ ctrans('texts.no_results') }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endforelse
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex justify-center md:justify-between mt-6 mb-6">
|
|
||||||
@if($invoices->total() > 0)
|
|
||||||
<span class="text-gray-700 text-sm hidden md:block">
|
|
||||||
{{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }}
|
|
||||||
</span>
|
|
||||||
@endif
|
|
||||||
{{ $invoices->links('portal/ninja2020/vendor/pagination') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,9 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<p class="mb-4 uppercase leading-4 tracking-wide inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-primary text-white">
|
<div class="flex items-center justify-between">
|
||||||
Subscriptions
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-between mt-4">
|
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="mr-2 text-sm hidden md:block">{{ ctrans('texts.per_page') }}</span>
|
<span class="mr-2 text-sm hidden md:block">{{ ctrans('texts.per_page') }}</span>
|
||||||
<select wire:model="per_page" class="form-select py-1 text-sm">
|
<select wire:model="per_page" class="form-select py-1 text-sm">
|
||||||
@ -24,6 +20,11 @@
|
|||||||
{{ ctrans('texts.subscription') }}
|
{{ ctrans('texts.subscription') }}
|
||||||
</p>
|
</p>
|
||||||
</th>
|
</th>
|
||||||
|
<th class="px-6 py-3 text-xs font-medium leading-4 tracking-wider text-left text-white uppercase border-b border-gray-200 bg-primary">
|
||||||
|
<p role="button" wire:click="sortBy('number')" class="cursor-pointer">
|
||||||
|
{{ ctrans('texts.frequency') }}
|
||||||
|
</p>
|
||||||
|
</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium leading-4 tracking-wider text-left text-white uppercase border-b border-gray-200 bg-primary">
|
<th class="px-6 py-3 text-xs font-medium leading-4 tracking-wider text-left text-white uppercase border-b border-gray-200 bg-primary">
|
||||||
<p role="button" wire:click="sortBy('number')" class="cursor-pointer">
|
<p role="button" wire:click="sortBy('number')" class="cursor-pointer">
|
||||||
{{ ctrans('texts.invoice') }}
|
{{ ctrans('texts.invoice') }}
|
||||||
@ -47,6 +48,9 @@
|
|||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
||||||
{{ $recurring_invoice->subscription->name }}
|
{{ $recurring_invoice->subscription->name }}
|
||||||
</td>
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
||||||
|
{{ \App\Models\RecurringInvoice::frequencyForKey($recurring_invoice->frequency_id) }}
|
||||||
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
||||||
<a href="{{ route('client.recurring_invoice.show', $recurring_invoice->hashed_id) }}"
|
<a href="{{ route('client.recurring_invoice.show', $recurring_invoice->hashed_id) }}"
|
||||||
class="button-link text-primary">
|
class="button-link text-primary">
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(is_null($invoice->subscription_id) || optional($invoice->subscription)->allow_cancellation)
|
@if(is_null($invoice->subscription_id) || optional($invoice->subscription)->allow_cancellation)
|
||||||
<div class="bg-white shadow sm:rounded-lg mb-4 mt-4">
|
<div class="bg-white shadow sm:rounded-lg mt-4">
|
||||||
<div class="px-4 py-5 sm:p-6">
|
<div class="px-4 py-5 sm:p-6">
|
||||||
<div class="sm:flex sm:items-start sm:justify-between">
|
<div class="sm:flex sm:items-start sm:justify-between">
|
||||||
<div>
|
<div>
|
||||||
@ -86,11 +86,11 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($invoice->subscription && $invoice->subscription->allow_plan_changes)
|
@if($invoice->subscription && $invoice->subscription->allow_plan_changes)
|
||||||
<div class="bg-white shadow overflow-hidden px-4 py-5 lg:rounded-lg">
|
<div class="bg-white shadow overflow-hidden px-4 py-5 lg:rounded-lg mt-4">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900">Switch Plans:</h3>
|
<h3 class="text-lg leading-6 font-medium text-gray-900">Switch Plans:</h3>
|
||||||
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">Upgrade or downgrade your current plan.</p>
|
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">Upgrade or downgrade your current plan.</p>
|
||||||
|
|
||||||
<div class="flex mt-4">
|
<div class="flex mt-4 space-x-2">
|
||||||
@foreach($invoice->subscription->service()->getPlans() as $subscription)
|
@foreach($invoice->subscription->service()->getPlans() as $subscription)
|
||||||
<a href="{{ route('client.subscription.plan_switch', ['recurring_invoice' => $invoice->hashed_id, 'target' => $subscription->hashed_id]) }}" class="border rounded px-5 py-2 hover:border-gray-800 text-sm cursor-pointer">{{ $subscription->name }}</a>
|
<a href="{{ route('client.subscription.plan_switch', ['recurring_invoice' => $invoice->hashed_id, 'target' => $subscription->hashed_id]) }}" class="border rounded px-5 py-2 hover:border-gray-800 text-sm cursor-pointer">{{ $subscription->name }}</a>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
@livewire('subscription-invoices-table')
|
|
||||||
@livewire('subscription-recurring-invoices-table')
|
@livewire('subscription-recurring-invoices-table')
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user