Added more custom fields

This commit is contained in:
Hillel Coren 2018-04-04 22:21:15 +03:00
parent 9fe4339066
commit 9834adc0a5
2 changed files with 42 additions and 2 deletions

View File

@ -23,6 +23,16 @@ class ExpenseReport extends AbstractReport
'user' => ['columnSelector-false'],
];
$user = auth()->user();
$account = $user->account;
if ($account->customLabel('expense1')) {
$columns[$account->present()->customLabel('expense1')] = ['columnSelector-false', 'custom'];
}
if ($account->customLabel('expense2')) {
$columns[$account->present()->customLabel('expense2')] = ['columnSelector-false', 'custom'];
}
if (TaxRate::scope()->count()) {
$columns['tax'] = ['columnSelector-false'];
}
@ -85,6 +95,13 @@ class ExpenseReport extends AbstractReport
$expense->user->getDisplayName(),
];
if ($account->customLabel('expense1')) {
$row[] = $expense->custom_value1;
}
if ($account->customLabel('expense2')) {
$row[] = $expense->custom_value2;
}
if ($hasTaxRates) {
$row[] = $expense->present()->taxAmount;
}

View File

@ -4,12 +4,13 @@ namespace App\Ninja\Reports;
use App\Models\Task;
use Utils;
use Auth;
class TaskReport extends AbstractReport
{
public function getColumns()
{
return [
$columns = [
'client' => [],
'start_date' => [],
'project' => [],
@ -18,10 +19,23 @@ class TaskReport extends AbstractReport
'amount' => [],
'user' => ['columnSelector-false'],
];
$user = auth()->user();
$account = $user->account;
if ($account->customLabel('task1')) {
$columns[$account->present()->customLabel('task1')] = ['columnSelector-false', 'custom'];
}
if ($account->customLabel('task2')) {
$columns[$account->present()->customLabel('task2')] = ['columnSelector-false', 'custom'];
}
return $columns;
}
public function run()
{
$account = Auth::user()->account;
$startDate = date_create($this->startDate);
$endDate = date_create($this->endDate);
$subgroup = $this->options['subgroup'];
@ -41,7 +55,7 @@ class TaskReport extends AbstractReport
$currencyId = auth()->user()->account->getCurrencyId();
}
$this->data[] = [
$row = [
$task->client ? ($this->isExport ? $task->client->getDisplayName() : $task->client->present()->link) : trans('texts.unassigned'),
$this->isExport ? $task->getStartTime() : link_to($task->present()->url, $task->getStartTime()),
$task->present()->project,
@ -51,6 +65,15 @@ class TaskReport extends AbstractReport
$task->user->getDisplayName(),
];
if ($account->customLabel('task1')) {
$row[] = $task->custom_value1;
}
if ($account->customLabel('task2')) {
$row[] = $task->custom_value2;
}
$this->data[] = $row;
$this->addToTotals($currencyId, 'duration', $duration);
$this->addToTotals($currencyId, 'amount', $amount);