public function __construct($organisationId, $invoiceId = null) { parent::__construct($organisationId); $this->invoices = OrganisationInvoice::getByOrganisationId($this->organisation->id); if ($invoiceId !== null) { $this->invoice = OrganisationInvoice::getById($invoiceId); } if ($this->isPostBack()) { if ($this->invoice && $this->invoice->hasRow()) { $this->update(); } else { $this->save(); } } }