mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for client portal quote tables
This commit is contained in:
parent
addc10ef4e
commit
959d45f081
@ -31,6 +31,7 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use ZipStream\Option\Archive;
|
||||
use ZipStream\ZipStream;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class QuoteController extends Controller
|
||||
{
|
||||
@ -55,6 +56,8 @@ class QuoteController extends Controller
|
||||
*/
|
||||
public function show(ShowQuoteRequest $request, Quote $quote)
|
||||
{
|
||||
/* If the quote is expired, convert the status here */
|
||||
|
||||
$data = [
|
||||
'quote' => $quote,
|
||||
];
|
||||
|
@ -42,17 +42,45 @@ class QuotesTable extends Component
|
||||
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');
|
||||
|
||||
if (count($this->status) > 0) {
|
||||
$query = $query->whereIn('status_id', $this->status);
|
||||
|
||||
/* Special filter for expired*/
|
||||
if(in_array("-1", $this->status)){
|
||||
// $query->whereDate('due_date', '<=', now()->startOfDay());
|
||||
|
||||
$query->where(function ($query){
|
||||
$query->whereDate('due_date', '<=', now()->startOfDay())
|
||||
->whereNotNull('due_date')
|
||||
->where('status_id', '<>', Quote::STATUS_CONVERTED);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if(in_array("2", $this->status)){
|
||||
|
||||
$query->where(function ($query){
|
||||
$query->whereDate('due_date', '>=', now()->startOfDay())
|
||||
->orWhereNull('due_date');
|
||||
})->where('status_id', Quote::STATUS_SENT);
|
||||
|
||||
}
|
||||
|
||||
if(in_array("3", $this->status)){
|
||||
$query->whereIn('status_id', [Quote::STATUS_APPROVED, Quote::STATUS_CONVERTED]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$query = $query
|
||||
->where('company_id', $this->company->id)
|
||||
->where('client_id', auth('contact')->user()->client->id)
|
||||
->where('status_id', '<>', Quote::STATUS_DRAFT)
|
||||
->where(function ($query){
|
||||
$query->whereDate('due_date', '>=', now())
|
||||
->orWhereNull('due_date');
|
||||
})
|
||||
// ->where(function ($query){
|
||||
// $query->whereDate('due_date', '>=', now())
|
||||
// ->orWhereNull('due_date');
|
||||
// })
|
||||
->where('is_deleted', 0)
|
||||
->withTrashed()
|
||||
->paginate($this->per_page);
|
||||
|
@ -87,6 +87,7 @@ class Quote extends BaseModel
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
'is_deleted' => 'boolean',
|
||||
];
|
||||
|
||||
protected $dates = [];
|
||||
@ -117,6 +118,16 @@ class Quote extends BaseModel
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getStatusIdAttribute($value)
|
||||
{
|
||||
if($this->due_date && !$this->is_deleted && $value == Quote::STATUS_SENT && Carbon::parse($this->due_date)->lte(now()->startOfDay())){
|
||||
return Quote::STATUS_EXPIRED;
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user