InvoiceTemplatePickerTrait
Invoice template picker that creates an invoice from a template directly in the add form.
After a pick, the JS in edit.latte (event picker:success) clicks a hidden .ajax link that
calls InvoicePresenter::handleUseTemplate. The signal
rebuilds the whole form from the template via buildInvoiceFromTemplate (header, seller and
customer snapshots, line collections) and redraws it. It is a GET on purpose: only then is the
item multiplier filled from defaults (a form submit fills it from httpData only). Has no
submitButton. The modal targets :Admin:Invoicer:InvoiceTemplate.
invoiceTemplateManager comes from the presenter constructor, so there is no #[Inject] here
(it would collide with the private readonly property).
Table of Contents
Methods
- invoiceTemplatePicker() : PickerConfig
- invoiceTemplateLabel() : string
- resolveInvoiceTemplateLabel() : string|null
- suggestInvoiceTemplates() : array<int, array{id: int, label: string}>
Methods
invoiceTemplatePicker()
protected
invoiceTemplatePicker(string $formName, string $targetField[, string|null $submitButton = null ]) : PickerConfig
Parameters
- $formName : string
-
name of the form with the hidden field
- $targetField : string
-
name of the hidden control (invoiceTemplateId)
- $submitButton : string|null = null
-
name of the refresh submit the picker clicks after a pick
Return values
PickerConfiginvoiceTemplateLabel()
private
invoiceTemplateLabel(InvoiceTemplate $template) : string
Parameters
- $template : InvoiceTemplate
Return values
stringresolveInvoiceTemplateLabel()
private
resolveInvoiceTemplateLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullsuggestInvoiceTemplates()
private
suggestInvoiceTemplates(string $query) : array<int, array{id: int, label: string}>
Parameters
- $query : string