ComplaintFormTrait
Add/edit form of a complaint, saved through the generic object-graph `save()`.
Unlike Order, items and attachments are simple admin-editable snapshots with no catalog
calculation. The status is set on this form only on creation (initial status selection); on
edit statusId is not rendered and buildComplaintEntity() leaves the entity status alone.
Every later status change goes only through the status action
(ComplaintStatusChangeFormTrait, api/eshop/complaint/transition,
ComplaintTransitionManager::apply()); otherwise the
generic save() would bypass the stock return and the e-mail.
The order picker triggers the orderPrefill AJAX button (ComplaintOrderPickerTrait),
which prefills the customer and items (one row per piece,
ComplaintManager::getOrderPrefillData()). Bulk creation
of multiplier rows on a submitted (AJAX) form must use addCopy($i) plus Container::setValues();
setDefaults() is a no-op there.
After a stock return (stockDocumentId) the items are locked (the server enforces it in Api
ComplaintManager::beforeSave()): the multiplier is not added at all (the template shows
only a table) and buildComplaintEntity() keeps the item collection as loaded. POST does not
contain the items, so rebuilding from POST would delete them. The note, contact and
attachments are still saved.
Table of Contents
Properties
- $complaintOrderPrefillWarnings : array<int, string>
Methods
- createComponentEditForm() : Form
- addComplaintCustomerFields() : void
- addComplaintDateFields() : void
- addComplaintDescriptionFields() : void
- addComplaintInitialStatusField() : void
- addComplaintItemsMultiplier() : void
- Rows of the claimed items, one piece per row.
- addComplaintOrderField() : void
- addComplaintOrderPrefillButton() : void
- Hidden AJAX button that picker.js clicks after an order is selected.
- addComplaintSolutionFields() : void
- buildComplaintEntity() : Complaint
- buildComplaintItemFromRow() : ComplaintItem|null
- complaintControlValue() : mixed
- complaintFormComponent() : IComponent|null
- complaintItemsLocked() : bool
- Items of the edited complaint are read-only after a stock return.
- complaintSetControlValue() : void
- loadComplaintSelectData() : void
- prefillComplaintFromOrder() : void
- refOrNull() : T|null
- saveComplaintForm() : bool
- setComplaintFormDefaults() : void
- wireComplaintMultiplierButtons() : void
Properties
$complaintOrderPrefillWarnings
private
array<int, string>
$complaintOrderPrefillWarnings
= []
Labels of rows whose AJAX prefill failed (shown as an alert).
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormaddComplaintCustomerFields()
private
addComplaintCustomerFields(Form $form) : void
Parameters
- $form : Form
addComplaintDateFields()
private
addComplaintDateFields(Form $form) : void
Parameters
- $form : Form
addComplaintDescriptionFields()
private
addComplaintDescriptionFields(Form $form) : void
Parameters
- $form : Form
addComplaintInitialStatusField()
private
addComplaintInitialStatusField(Form $form) : void
Parameters
- $form : Form
addComplaintItemsMultiplier()
Rows of the claimed items, one piece per row.
private
addComplaintItemsMultiplier(Form $form) : void
Parameters
- $form : Form
addComplaintOrderField()
private
addComplaintOrderField(Form $form) : void
Parameters
- $form : Form
addComplaintOrderPrefillButton()
Hidden AJAX button that picker.js clicks after an order is selected.
private
addComplaintOrderPrefillButton(Form $form) : void
Parameters
- $form : Form
addComplaintSolutionFields()
private
addComplaintSolutionFields(Form $form) : void
Parameters
- $form : Form
buildComplaintEntity()
private
buildComplaintEntity(ArrayHash<string|int, mixed> $values) : Complaint
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
ComplaintbuildComplaintItemFromRow()
private
buildComplaintItemFromRow(array<string, mixed> $row[, array<int, ComplaintItem> $existingItems = [] ]) : ComplaintItem|null
Parameters
- $row : array<string, mixed>
- $existingItems : array<int, ComplaintItem> = []
-
items of this complaint by id
Return values
ComplaintItem|nullcomplaintControlValue()
private
complaintControlValue(Container $container, string $field) : mixed
Parameters
- $container : Container
- $field : string
complaintFormComponent()
private
complaintFormComponent(Container $container, string $name) : IComponent|null
Parameters
- $container : Container
- $name : string
Return values
IComponent|nullcomplaintItemsLocked()
Items of the edited complaint are read-only after a stock return.
private
complaintItemsLocked() : bool
Return values
boolcomplaintSetControlValue()
private
complaintSetControlValue(Container $container, string $field, mixed $value) : void
Parameters
- $container : Container
- $field : string
- $value : mixed
loadComplaintSelectData()
private
loadComplaintSelectData() : void
prefillComplaintFromOrder()
private
prefillComplaintFromOrder(Form $form) : void
Parameters
- $form : Form
refOrNull()
private
refOrNull(T> $class, int|null $id) : T|null
Parameters
- $class : T>
- $id : int|null
Tags
Return values
T|nullsaveComplaintForm()
private
saveComplaintForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetComplaintFormDefaults()
private
setComplaintFormDefaults(Form $form) : void
Parameters
- $form : Form
wireComplaintMultiplierButtons()
private
wireComplaintMultiplierButtons(Multiplier $multiplier, string $snippet) : void
Parameters
- $multiplier : Multiplier
- $snippet : string