mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Adjustments for activity exports
This commit is contained in:
parent
cee315cf6d
commit
2558c4345f
@ -57,9 +57,11 @@ class ActivityExport extends BaseExport
|
||||
return ['identifier' => $value, 'display_value' => $headerdisplay[$value]];
|
||||
})->toArray();
|
||||
|
||||
$report = $query->cursor()
|
||||
->map(function ($credit) {
|
||||
return $this->buildActivityRow($credit);
|
||||
|
||||
$report = $query->cursor()
|
||||
->map(function ($resource) {
|
||||
$row = $this->buildActivityRow($resource);
|
||||
return $this->processMetaData($row, $resource);
|
||||
})->toArray();
|
||||
|
||||
return array_merge(['columns' => $header], $report);
|
||||
@ -70,6 +72,8 @@ class ActivityExport extends BaseExport
|
||||
return [
|
||||
Carbon::parse($activity->created_at)->format($this->date_format),
|
||||
ctrans("texts.activity_{$activity->activity_type_id}",[
|
||||
'payment_amount' => $activity->payment ? $activity->payment->amount : '',
|
||||
'adjustment' => $activity->payment ? $activity->payment->refunded : '',
|
||||
'client' => $activity->client ? $activity->client->present()->name() : '',
|
||||
'contact' => $activity->contact ? $activity->contact->present()->name() : '',
|
||||
'quote' => $activity->quote ? $activity->quote->number : '',
|
||||
@ -101,7 +105,7 @@ class ActivityExport extends BaseExport
|
||||
|
||||
$this->date_format = DateFormat::find($this->company->settings->date_format_id)->format;
|
||||
|
||||
ksort($this->entity_keys);
|
||||
// ksort($this->entity_keys);
|
||||
|
||||
if (count($this->input['report_keys']) == 0) {
|
||||
$this->input['report_keys'] = array_values($this->entity_keys);
|
||||
@ -146,4 +150,27 @@ class ActivityExport extends BaseExport
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
|
||||
|
||||
public function processMetaData(array $row, $resource): array
|
||||
{
|
||||
|
||||
$clean_row = [];
|
||||
|
||||
foreach (array_values($this->input['report_keys']) as $key => $value) {
|
||||
|
||||
nlog("key: {$key}, value: {$value}");
|
||||
nlog($row);
|
||||
$clean_row[$key]['entity'] = 'activity';
|
||||
$clean_row[$key]['id'] = $key;
|
||||
$clean_row[$key]['hashed_id'] = null;
|
||||
$clean_row[$key]['value'] = $row[$key];
|
||||
$clean_row[$key]['identifier'] = $value;
|
||||
$clean_row[$key]['display_value'] = $row[$key];
|
||||
|
||||
}
|
||||
|
||||
return $clean_row;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Export\CSV;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\Quote;
|
||||
use App\Utils\Number;
|
||||
use App\Models\Client;
|
||||
@ -915,13 +916,13 @@ class BaseExport
|
||||
$helper = new Helpers();
|
||||
|
||||
$header = [];
|
||||
nlog("header");
|
||||
// nlog("header");
|
||||
foreach ($this->input['report_keys'] as $value) {
|
||||
|
||||
$key = array_search($value, $this->entity_keys);
|
||||
$original_key = $key;
|
||||
|
||||
nlog("{$key} => {$value}");
|
||||
// nlog("{$key} => {$value}");
|
||||
$prefix = '';
|
||||
|
||||
if(!$key) {
|
||||
@ -991,7 +992,7 @@ class BaseExport
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
nlog("key => {$key}");
|
||||
// nlog("key => {$key}");
|
||||
|
||||
$key = str_replace('item.', '', $key);
|
||||
$key = str_replace('recurring_invoice.', '', $key);
|
||||
@ -1045,7 +1046,7 @@ class BaseExport
|
||||
}
|
||||
}
|
||||
|
||||
nlog($header);
|
||||
// nlog($header);
|
||||
|
||||
return $header;
|
||||
}
|
||||
@ -1057,6 +1058,7 @@ class BaseExport
|
||||
$entity = '';
|
||||
|
||||
match ($class) {
|
||||
Activity::class => $entity = 'activity',
|
||||
Invoice::class => $entity = 'invoice',
|
||||
RecurringInvoice::class => $entity = 'recurring_invoice',
|
||||
Quote::class => $entity = 'quote',
|
||||
@ -1079,7 +1081,9 @@ class BaseExport
|
||||
$report_keys = explode(".", $value);
|
||||
|
||||
$column_key = $value;
|
||||
|
||||
nlog($value);
|
||||
nlog($report_keys);
|
||||
nlog($row);
|
||||
if($value == 'product_image') {
|
||||
$column_key = 'image';
|
||||
$value = 'image';
|
||||
|
Loading…
x
Reference in New Issue
Block a user