Flash message

This commit is contained in:
David Bomba 2019-10-08 12:03:40 +10:00
parent 091673a7ac
commit accbbcf67b
5 changed files with 56 additions and 39 deletions

View File

@ -120,9 +120,14 @@ class InvoiceController extends Controller
$total = $invoices->sum('balance'); $total = $invoices->sum('balance');
$invoices->filter(function ($invoice){ $invoices = $invoices->filter(function ($invoice){
return $invoice->isPayable(); return $invoice->isPayable();
})->map(function ($invoice){ });
if($invoices->count() == 0)
return back()->with(['warning' => 'No payable invoices selected']);
$invoices->map(function ($invoice){
$invoice->balance = Number::formatMoney($invoice->balance, $invoice->client); $invoice->balance = Number::formatMoney($invoice->balance, $invoice->client);
$invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format()); $invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format());
return $invoice; return $invoice;

View File

@ -192,14 +192,25 @@ class Invoice extends BaseModel
return strtotime($this->createClientDate(date(), $this->client->timezone()->name)) > (strtotime($due_date) + (60 * 60 * 24)); return strtotime($this->createClientDate(date(), $this->client->timezone()->name)) > (strtotime($due_date) + (60 * 60 * 24));
} }
public function markViewed() public function markViewed() :void
{ {
$this->last_viewed = Carbon::now()->format('Y-m-d H:i'); $this->last_viewed = Carbon::now()->format('Y-m-d H:i');
$this->save();
} }
public function isPayable() public function isPayable() : bool
{ {
return ($this->status === Invoice::STATUS_UNPAID || $this->status === Invoice::STATUS_OVERDUE);
if($this->status_id == Invoice::STATUS_SENT && $this->due_date > Carbon::now())
return true;
else if($this->status_id == Invoice::STATUS_PARTIAL && $this->partial_due_date > Carbon::now())
return true;
else if($this->status_id == Invoice::STATUS_SENT && $this->due_date < Carbon::now())
return true;
else if($this->status_id == Invoice::STATUS_PARTIAL && $this->partial_due_date < Carbon::now())
return true;
else
return false;
} }
public static function badgeForStatus(int $status) public static function badgeForStatus(int $status)

View File

@ -1,38 +1,40 @@
@if ($message = Session::get('success')) <div class="justify-content-center align-items-center pd-10 pm-10">
<div class="alert alert-success alert-block"> @if ($message = Session::get('success'))
<button type="button" class="close" data-dismiss="alert">×</button> <div class="alert alert-success alert-block">
<strong>{{ $message }}</strong> <button type="button" class="close" data-dismiss="alert">×</button>
</div> <strong>{{ $message }}</strong>
@endif </div>
@endif
@if ($message = Session::get('error')) @if ($message = Session::get('error'))
<div class="alert alert-danger alert-block"> <div class="alert alert-danger alert-block">
<button type="button" class="close" data-dismiss="alert">×</button> <button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong> <strong>{{ $message }}</strong>
</div> </div>
@endif @endif
@if ($message = Session::get('warning')) @if ($message = Session::get('warning'))
<div class="alert alert-warning alert-block"> <div class="alert alert-warning alert-block">
<button type="button" class="close" data-dismiss="alert">×</button> <button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong> <strong>{{ $message }}</strong>
</div> </div>
@endif @endif
@if ($message = Session::get('info')) @if ($message = Session::get('info'))
<div class="alert alert-info alert-block"> <div class="alert alert-info alert-block">
<button type="button" class="close" data-dismiss="alert">×</button> <button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong> <strong>{{ $message }}</strong>
</div> </div>
@endif @endif
@if ($errors->any()) @if ($errors->any())
<div class="alert alert-danger"> <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button> <button type="button" class="close" data-dismiss="alert">×</button>
Please check the form below for errors Please check the form below for errors
</div> </div>
@endif @endif
</div>

View File

@ -21,7 +21,8 @@
{!! Former::close() !!} {!! Former::close() !!}
<div class="row" style="padding-top: 30px;"> <div class="row" style="padding-top: 30px;">
@include('portal.default.flash-message')
<div class="col-lg-12" style="padding-bottom: 10px;"> <div class="col-lg-12" style="padding-bottom: 10px;">
<div class="pull-left"> <div class="pull-left">

View File

@ -46,12 +46,10 @@
.nav {min-height: calc(100% - 55px);} .nav {min-height: calc(100% - 55px);}
</style> </style>
@stack('css') @stack('css')
@yield('head')
@yield('head')
</head> </head>
@include('portal.default.header') @include('portal.default.header')
@yield('header') @yield('header')
@include('portal.default.flash-message')
@include('portal.default.sidebar') @include('portal.default.sidebar')
@yield('sidebar') @yield('sidebar')
@section('body') @section('body')