diff --git a/app/Http/Livewire/InvoicesTable.php b/app/Http/Livewire/InvoicesTable.php index a5cf2bd2978a..abc401d7c90a 100644 --- a/app/Http/Livewire/InvoicesTable.php +++ b/app/Http/Livewire/InvoicesTable.php @@ -4,6 +4,7 @@ namespace App\Http\Livewire; use App\Models\Invoice; use App\Traits\WithSorting; +use Carbon\Carbon; use Livewire\Component; use Livewire\WithPagination; @@ -32,17 +33,24 @@ class InvoicesTable extends Component $query = Invoice::query(); $query = $query->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); - // So $status_id will come in three way: - // paid, unpaid & overdue. Need to transform them to real values. + if (in_array('paid', $this->status)) { + $query = $query->orWhere('status_id', Invoice::STATUS_PAID); + } - if (count($this->status)) { - $query = $query->whereIn('status_id', $this->status); + if (in_array('unpaid', $this->status)) { + $query = $query->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]); + } + + if (in_array('overdue', $this->status)) { + $query = $query->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) + ->where('due_date', '<', Carbon::now()) + ->orWhere('partial_due_date', '<', Carbon::now()); } $query = $query->paginate($this->per_page); return render('components.livewire.invoices-table', [ - 'invoices' => $query + 'invoices' => $query, ]); } } diff --git a/app/Http/Livewire/QuotesTable.php b/app/Http/Livewire/QuotesTable.php index ff2f20f9c369..6dcc3214513d 100644 --- a/app/Http/Livewire/QuotesTable.php +++ b/app/Http/Livewire/QuotesTable.php @@ -26,14 +26,23 @@ class QuotesTable extends Component public function render() { - // So $status_id will come in three way: - // draft, sent, approved & expired. Need to transform them to real values. - $query = Quote::query() ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); - if (count($this->status)) { - $query = $query->whereIn('status_id', $this->status); + if (in_array('draft', $this->status)) { + $query = $query->orWhere('status_id', Quote::STATUS_DRAFT); + } + + if (in_array('sent', $this->status)) { + $query = $query->orWhere('status_id', Quote::STATUS_SENT); + } + + if (in_array('approved', $this->status)) { + $query = $query->orWhere('status_id', Quote::STATUS_APPROVED); + } + + if (in_array('expired', $this->status)) { + $query = $query->orWhere('status_id', Quote::STATUS_EXPIRED); } $query = $query->paginate($this->per_page); diff --git a/package.json b/package.json index ae2e21548a0a..03df15e83ffa 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "resolve-url-loader": "^3.1.0", "sass": "^1.15.2", "sass-loader": "^8.0.0", - "tailwindcss": "^1.2.0", + "tailwindcss": "^1.3", "turbolinks": "^5.2.0" } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 1b82f53161b2..63c6ff9a3e6a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3203,4 +3203,6 @@ return [ 'of' => 'Of', 'view_credit' => 'View Credit', 'to_view_entity_password' => 'To view the :entity you need to enter password.', + 'showing_x_of' => 'Showing :first to :last out of :total results', + 'no_results' => 'No results found.' ]; diff --git a/resources/views/portal/ninja2020/components/livewire/credits-table.blade.php b/resources/views/portal/ninja2020/components/livewire/credits-table.blade.php index 03c6d7c53788..30892870fb83 100644 --- a/resources/views/portal/ninja2020/components/livewire/credits-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/credits-table.blade.php @@ -39,33 +39,43 @@ - @foreach($credits as $credit) - - - {{ App\Utils\Number::formatMoney($credit->amount, $credit->client) }} - - - {{ App\Utils\Number::formatMoney($credit->balance, $credit->client) }} - - - {{ $credit->formatDate($credit->date, $credit->client->date_format()) }} - - - {{ empty($credit->public_notes) ? '/' : $credit->public_notes }} - - - - @lang('texts.view') - - - - @endforeach + @forelse($credits as $credit) + + + {{ App\Utils\Number::formatMoney($credit->amount, $credit->client) }} + + + {{ App\Utils\Number::formatMoney($credit->balance, $credit->client) }} + + + {{ $credit->formatDate($credit->date, $credit->client->date_format()) }} + + + {{ empty($credit->public_notes) ? '/' : $credit->public_notes }} + + + + @lang('texts.view') + + + + @empty + + + {{ ctrans('texts.no_results') }} + + + @endforelse
- + @if($credits->total() > 0) + + @endif {{ $credits->links() }}
\ No newline at end of file diff --git a/resources/views/portal/ninja2020/components/livewire/invoices-table.blade.php b/resources/views/portal/ninja2020/components/livewire/invoices-table.blade.php index 4fdd3ff7cf80..1d2eaf2ae848 100644 --- a/resources/views/portal/ninja2020/components/livewire/invoices-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/invoices-table.blade.php @@ -11,15 +11,15 @@
- +
- +
- +
@@ -63,7 +63,7 @@ - @foreach($invoices as $invoice) + @forelse($invoices as $invoice)