InitTrait
Setters and data preparation for {@see \App\UI\Admin\Company\Components\WorkGridComponent\WorkGrid}.
The caller fills the state through setters before render(); the component loads nothing
from a manager (it injects none, see WorkGridFactory).
Table of Contents
Properties
- $defaultVatPercents : string|null
- Effective default VAT rate (customer, then company, see {@see \App\UI\Admin\Company\Presenters\Traits\Forms\WorkListSheetsFormTrait::resolveDefaultVatPercents()}).
- $items : array<string|int, WorkItem>
- $readOnly : bool
- The work sheet is locked (closing, closed or invoiced) or the job is archived.
- $rowNamePrefix : string
- Input name prefix, for example `sheets[42][items]`; the template appends the row index and field.
- $serviceOptions : array<int, string>
- $sheet : WorkSheet|null
- Edited work sheet; `null` only outside the normal flow (the grid is never mounted without one).
- $statusOptions : array<string, string>
- $supplyKindOptions : array<int, string>
- `supplyKindId => name` for the supply kind select of a row (the empty option means the default supply kind of the company). Supplied by the presenter, because the component has no manager.
- $unreadComments : array<int, int>
- Unread client comment counts as `workItemId => count`; work items without unread comments have no key. The presenter precomputes them in one query so the grid bubble does not become an N+1.
Methods
- setDefaultVatPercents() : self
- See the docblock of {@see $defaultVatPercents}.
- setItems() : self
- setReadOnly() : self
- setRowNamePrefix() : self
- setServices() : self
- setSheet() : self
- setStatuses() : self
- setSupplyKinds() : self
- setUnreadComments() : self
- computeHoursSum() : string
- Initial hours total; JS keeps recomputing it live while editing.
- computePriceSum() : string
- Initial price total: the server value from the entity ({@see WorkItem::getPrice()}), not a recomputation.
- prepareGrid() : void
- Fills `$this->template`; called from `render()` without arguments (AJAX snippet phase pitfall, see {@see \App\UI\Admin\Company\Components\WorkGridComponent\WorkGrid}).
- resolveStatusOptions() : array<string, string>
- Returns the work item status options.
Properties
$defaultVatPercents
Effective default VAT rate (customer, then company, see {@see \App\UI\Admin\Company\Presenters\Traits\Forms\WorkListSheetsFormTrait::resolveDefaultVatPercents()}).
private
string|null
$defaultVatPercents
= null
Used only as the placeholder of the vatPercents field in the money zone of a row; null
means neither the customer nor the company has a VAT rate, so the field has no placeholder.
$items
private
array<string|int, WorkItem>
$items
= []
work items of the current work sheet, ordered by order
$readOnly
The work sheet is locked (closing, closed or invoiced) or the job is archived.
private
bool
$readOnly
= false
$rowNamePrefix
Input name prefix, for example `sheets[42][items]`; the template appends the row index and field.
private
string
$rowNamePrefix
= ''
$serviceOptions
private
array<int, string>
$serviceOptions
= []
companyServiceId => name for the service select
$sheet
Edited work sheet; `null` only outside the normal flow (the grid is never mounted without one).
private
WorkSheet|null
$sheet
= null
$statusOptions
private
array<string, string>
$statusOptions
= []
WorkItemStatus::value => label for the status select
$supplyKindOptions
`supplyKindId => name` for the supply kind select of a row (the empty option means the default supply kind of the company). Supplied by the presenter, because the component has no manager.
private
array<int, string>
$supplyKindOptions
= []
$unreadComments
Unread client comment counts as `workItemId => count`; work items without unread comments have no key. The presenter precomputes them in one query so the grid bubble does not become an N+1.
private
array<int, int>
$unreadComments
= []
Methods
setDefaultVatPercents()
See the docblock of {@see $defaultVatPercents}.
public
setDefaultVatPercents(string|null $defaultVatPercents) : self
Parameters
- $defaultVatPercents : string|null
Return values
selfsetItems()
public
setItems(array<string|int, WorkItem> $items) : self
Parameters
- $items : array<string|int, WorkItem>
Return values
selfsetReadOnly()
public
setReadOnly(bool $readOnly) : self
Parameters
- $readOnly : bool
Return values
selfsetRowNamePrefix()
public
setRowNamePrefix(string $rowNamePrefix) : self
Parameters
- $rowNamePrefix : string
Return values
selfsetServices()
public
setServices(array<int, string> $serviceOptions) : self
Parameters
- $serviceOptions : array<int, string>
Return values
selfsetSheet()
public
setSheet(WorkSheet $sheet) : self
Parameters
- $sheet : WorkSheet
Return values
selfsetStatuses()
public
setStatuses(array<string, string> $statusOptions) : self
Parameters
- $statusOptions : array<string, string>
Return values
selfsetSupplyKinds()
public
setSupplyKinds(array<int, string> $supplyKindOptions) : self
Parameters
- $supplyKindOptions : array<int, string>
Return values
selfsetUnreadComments()
public
setUnreadComments(array<int, int> $unreadComments) : self
Parameters
- $unreadComments : array<int, int>
-
workItemId => unread count
Return values
selfcomputeHoursSum()
Initial hours total; JS keeps recomputing it live while editing.
private
computeHoursSum() : string
Return values
stringcomputePriceSum()
Initial price total: the server value from the entity ({@see WorkItem::getPrice()}), not a recomputation.
private
computePriceSum() : string
IMPORTANT: counts only work items with billable = 1, like
WorkListSheetsFormTrait::summarizeItemsRaw()
and the live recomputation in work-grid.js. An unchecked work item keeps its price but
must not enter the total, because it will not go on the invoice.
Return values
stringprepareGrid()
Fills `$this->template`; called from `render()` without arguments (AJAX snippet phase pitfall, see {@see \App\UI\Admin\Company\Components\WorkGridComponent\WorkGrid}).
private
prepareGrid() : void
resolveStatusOptions()
Returns the work item status options.
private
resolveStatusOptions() : array<string, string>
Uses the options supplied through setStatuses(); only when the caller supplied none does it fall back to translating the enum directly, so the grid never lacks options.