/** * Update existing route * * @param void * @return null */ function edit() { if ($this->active_tax_rate->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_tax_rate->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->wireframe->addPageMessage(lang('Updating of this tax rate will also update all existing invoices. If that is not an option, consider creating a new tax rate'), 'warning'); $tax_rate_data = $this->request->post('tax_rate'); if (!is_array($tax_rate_data)) { $tax_rate_data = array('name' => $this->active_tax_rate->getName(), 'percentage' => $this->active_tax_rate->getPercentage()); } // if $this->smarty->assign('tax_rate_data', $tax_rate_data); if ($this->request->isSubmitted()) { $this->active_tax_rate->setAttributes($tax_rate_data); $save = $this->active_tax_rate->save(); if ($save && !is_error($save)) { flash_success('Tax rate ":name" has been updated', array('name' => $this->active_tax_rate->getName())); $this->redirectTo('admin_tax_rates'); } else { $this->smarty->assign('errors', $save); } // if } // if }