mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 19:04:36 -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\Option\Archive;
|
||||||
use ZipStream\ZipStream;
|
use ZipStream\ZipStream;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class QuoteController extends Controller
|
class QuoteController extends Controller
|
||||||
{
|
{
|
||||||
@ -54,7 +55,9 @@ class QuoteController extends Controller
|
|||||||
* @return Factory|View|BinaryFileResponse
|
* @return Factory|View|BinaryFileResponse
|
||||||
*/
|
*/
|
||||||
public function show(ShowQuoteRequest $request, Quote $quote)
|
public function show(ShowQuoteRequest $request, Quote $quote)
|
||||||
{
|
{
|
||||||
|
/* If the quote is expired, convert the status here */
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'quote' => $quote,
|
'quote' => $quote,
|
||||||
];
|
];
|
||||||
|
@ -42,17 +42,45 @@ class QuotesTable extends Component
|
|||||||
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');
|
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');
|
||||||
|
|
||||||
if (count($this->status) > 0) {
|
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
|
$query = $query
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id)
|
||||||
->where('client_id', auth('contact')->user()->client->id)
|
->where('client_id', auth('contact')->user()->client->id)
|
||||||
->where('status_id', '<>', Quote::STATUS_DRAFT)
|
->where('status_id', '<>', Quote::STATUS_DRAFT)
|
||||||
->where(function ($query){
|
// ->where(function ($query){
|
||||||
$query->whereDate('due_date', '>=', now())
|
// $query->whereDate('due_date', '>=', now())
|
||||||
->orWhereNull('due_date');
|
// ->orWhereNull('due_date');
|
||||||
})
|
// })
|
||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->paginate($this->per_page);
|
->paginate($this->per_page);
|
||||||
|
@ -87,6 +87,7 @@ class Quote extends BaseModel
|
|||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
|
'is_deleted' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [];
|
protected $dates = [];
|
||||||
@ -117,6 +118,16 @@ class Quote extends BaseModel
|
|||||||
return $this->dateMutator($value);
|
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()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user