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

View File

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