Don't allow changing client once task/expense has been invoiced

This commit is contained in:
Hillel Coren 2016-12-19 20:39:48 +02:00
parent db26b169cd
commit f275d1a295
3 changed files with 31 additions and 8 deletions

View File

@ -26,6 +26,11 @@ class TaskPresenter extends EntityPresenter
return substr($this->entity->description, 0, 40) . (strlen($this->entity->description) > 40 ? '...' : ''); return substr($this->entity->description, 0, 40) . (strlen($this->entity->description) > 40 ? '...' : '');
} }
public function project()
{
return $this->entity->project ? $this->entity->project->name : '';
}
/** /**
* @param $account * @param $account
* @return mixed * @return mixed

View File

@ -66,11 +66,17 @@
->addGroupClass('amount') ->addGroupClass('amount')
->append('<span data-bind="html: expenseCurrencyCode"></span>') !!} ->append('<span data-bind="html: expenseCurrencyCode"></span>') !!}
{!! Former::select('client_id') @if ($expense && $expense->invoice_id)
->addOption('', '') {!! Former::plaintext()
->label(trans('texts.client')) ->label('client')
->data_bind('combobox: client_id') ->value($expense->client->getDisplayName()) !!}
->addGroupClass('client-select') !!} @else
{!! Former::select('client_id')
->addOption('', '')
->label(trans('texts.client'))
->data_bind('combobox: client_id')
->addGroupClass('client-select') !!}
@endif
@if (!$expense || ($expense && !$expense->invoice_id && !$expense->client_id)) @if (!$expense || ($expense && !$expense->invoice_id && !$expense->client_id))
{!! Former::checkbox('should_be_invoiced') {!! Former::checkbox('should_be_invoiced')

View File

@ -47,9 +47,21 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
{!! Former::select('client')->addOption('', '')->addGroupClass('client-select') !!} @if ($task && $task->invoice_id)
{!! Former::select('project_id')->addOption('', '')->addGroupClass('project-select') {!! Former::plaintext()
->label(trans('texts.project')) !!} ->label('client')
->value($task->client->getDisplayName()) !!}
@if ($task->project)
{!! Former::plaintext()
->label('project')
->value($task->present()->project) !!}
@endif
@else
{!! Former::select('client')->addOption('', '')->addGroupClass('client-select') !!}
{!! Former::select('project_id')->addOption('', '')->addGroupClass('project-select')
->label(trans('texts.project')) !!}
@endif
{!! Former::textarea('description')->rows(3) !!} {!! Former::textarea('description')->rows(3) !!}
@if ($task) @if ($task)