Fixes for product_key exports
This commit is contained in:
parent
fe5c04954d
commit
1f92b8ff16
|
|
@ -864,7 +864,12 @@ class BaseExport
|
||||||
|
|
||||||
if (isset($this->input['product_key'])) {
|
if (isset($this->input['product_key'])) {
|
||||||
|
|
||||||
$products = explode(",", $this->input['product_key']);
|
$products = str_getcsv($this->input['product_key'], ',', "'");
|
||||||
|
|
||||||
|
$products = array_map(function ($product) {
|
||||||
|
return trim($product, "'");
|
||||||
|
}, $products);
|
||||||
|
|
||||||
$query->where(function ($q) use ($products) {
|
$query->where(function ($q) use ($products) {
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$q->orWhereJsonContains('line_items', ['product_key' => $product]);
|
$q->orWhereJsonContains('line_items', ['product_key' => $product]);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ class InvoiceItemExport extends BaseExport
|
||||||
if (count($this->input['report_keys']) == 0) {
|
if (count($this->input['report_keys']) == 0) {
|
||||||
$this->force_keys = true;
|
$this->force_keys = true;
|
||||||
$this->input['report_keys'] = array_values($this->mergeItemsKeys('invoice_report_keys'));
|
$this->input['report_keys'] = array_values($this->mergeItemsKeys('invoice_report_keys'));
|
||||||
nlog($this->input['report_keys']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->input['report_keys'] = array_merge($this->input['report_keys'], array_diff($this->forced_client_fields, $this->input['report_keys']));
|
$this->input['report_keys'] = array_merge($this->input['report_keys'], array_diff($this->forced_client_fields, $this->input['report_keys']));
|
||||||
|
|
@ -161,7 +160,13 @@ class InvoiceItemExport extends BaseExport
|
||||||
|
|
||||||
//if we have product filters in place, we will also need to filter the items at this level:
|
//if we have product filters in place, we will also need to filter the items at this level:
|
||||||
if (isset($this->input['product_key'])) {
|
if (isset($this->input['product_key'])) {
|
||||||
$products = explode(",", $this->input['product_key']);
|
|
||||||
|
$products = str_getcsv($this->input['product_key'], ',', "'");
|
||||||
|
|
||||||
|
$products = array_map(function($product) {
|
||||||
|
return trim($product, "'");
|
||||||
|
}, $products);
|
||||||
|
|
||||||
$items = array_filter($items, function ($item) use ($products) {
|
$items = array_filter($items, function ($item) use ($products) {
|
||||||
return in_array($item->product_key, $products);
|
return in_array($item->product_key, $products);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class GenericReportRequest extends Request
|
||||||
'document_email_attachment' => 'sometimes|bool',
|
'document_email_attachment' => 'sometimes|bool',
|
||||||
'pdf_email_attachment' => 'sometimes|bool',
|
'pdf_email_attachment' => 'sometimes|bool',
|
||||||
'include_deleted' => 'required|bool',
|
'include_deleted' => 'required|bool',
|
||||||
|
'product_key' => 'sometimes|string|nullable',
|
||||||
// 'status' => 'sometimes|string|nullable|in:all,draft,sent,viewed,paid,unpaid,overdue',
|
// 'status' => 'sometimes|string|nullable|in:all,draft,sent,viewed,paid,unpaid,overdue',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +70,7 @@ class GenericReportRequest extends Request
|
||||||
$input['user_id'] = auth()->user()->id;
|
$input['user_id'] = auth()->user()->id;
|
||||||
|
|
||||||
if (!$this->checkAuthority()) {
|
if (!$this->checkAuthority()) {
|
||||||
|
$input['product_key'] = '';
|
||||||
$input['date_range'] = '';
|
$input['date_range'] = '';
|
||||||
$input['start_date'] = '';
|
$input['start_date'] = '';
|
||||||
$input['end_date'] = '';
|
$input['end_date'] = '';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue