mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor to support include deleted record logic for exports
This commit is contained in:
parent
e967373f85
commit
f8316f879a
@ -125,8 +125,10 @@ class ClientExport extends BaseExport
|
|||||||
|
|
||||||
$query = Client::query()->with('contacts')
|
$query = Client::query()->with('contacts')
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted'])
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -82,8 +82,12 @@ class ExpenseExport extends BaseExport
|
|||||||
$query = Expense::query()
|
$query = Expense::query()
|
||||||
->with('client')
|
->with('client')
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -60,8 +60,11 @@ class InvoiceExport extends BaseExport
|
|||||||
->whereHas('client', function ($q){
|
->whereHas('client', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -73,8 +73,11 @@ class InvoiceItemExport extends BaseExport
|
|||||||
->whereHas('client', function ($q){
|
->whereHas('client', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -73,8 +73,12 @@ class ProductExport extends BaseExport
|
|||||||
|
|
||||||
$query = Product::query()
|
$query = Product::query()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', 0);
|
|
||||||
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -61,8 +61,11 @@ class PurchaseOrderExport extends BaseExport
|
|||||||
->whereHas('vendor', function ($q){
|
->whereHas('vendor', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -65,8 +65,11 @@ class PurchaseOrderItemExport extends BaseExport
|
|||||||
->whereHas('vendor', function ($q){
|
->whereHas('vendor', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->with('vendor')->where('company_id', $this->company->id)
|
->with('vendor')->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -67,8 +67,11 @@ class QuoteExport extends BaseExport
|
|||||||
->whereHas('client', function ($q){
|
->whereHas('client', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -68,8 +68,11 @@ class QuoteItemExport extends BaseExport
|
|||||||
->whereHas('client', function ($q){
|
->whereHas('client', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->with('client')->where('company_id', $this->company->id)
|
->with('client')->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -59,8 +59,11 @@ class RecurringInvoiceExport extends BaseExport
|
|||||||
->whereHas('client', function ($q){
|
->whereHas('client', function ($q){
|
||||||
$q->where('is_deleted', false);
|
$q->where('is_deleted', false);
|
||||||
})
|
})
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -68,8 +68,11 @@ class TaskExport extends BaseExport
|
|||||||
|
|
||||||
$query = Task::query()
|
$query = Task::query()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -62,8 +62,11 @@ class VendorExport extends BaseExport
|
|||||||
|
|
||||||
$query = Vendor::query()->with('contacts')
|
$query = Vendor::query()->with('contacts')
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('company_id', $this->company->id)
|
->where('company_id', $this->company->id);
|
||||||
->where('is_deleted', $this->input['include_deleted'] ?? false);
|
|
||||||
|
if(!$this->input['include_deleted']) {
|
||||||
|
$query->where('is_deleted', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->addDateRange($query);
|
$query = $this->addDateRange($query);
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ class GenericReportRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return $this->checkAuthority();
|
return true;
|
||||||
|
// return $this->checkAuthority();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
@ -68,6 +69,15 @@ class GenericReportRequest extends Request
|
|||||||
|
|
||||||
$input['user_id'] = auth()->user()->id;
|
$input['user_id'] = auth()->user()->id;
|
||||||
|
|
||||||
|
if(!$this->checkAuthority()){
|
||||||
|
$input['date_range'] = '';
|
||||||
|
$input['start_date'] = '';
|
||||||
|
$input['end_date'] = '';
|
||||||
|
$input['send_email'] = true;
|
||||||
|
$input['report_keys'] = [];
|
||||||
|
$input['document_email_attachment'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user