function post_handler() { global $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_OP_DB); try { $desc = $this->form->desc; $rate = $this->form->rate; $account = $this->form->account; $delete_flag = isset($this->form->del) ? $this->form->del : array(); $tax_id = 1; $trun = $dbc->query("TRUNCATE TABLE taxrates"); $model = new TaxRatesModel($dbc); for ($j = 0; $j < count($desc); $j++) { if (empty($desc[$j]) || empty($rate[$j])) { continue; } if (in_array($tax_id, $delete_flag)) { continue; } $model->id($tax_id); $model->rate($rate[$j]); $model->description($desc[$j]); $model->salesCode($account[$j]); $saved = $model->save(); if ($saved) { $this->add_onload_command("showBootstrapAlert('#alert-area', 'success', 'Saved {$desc[$j]}');"); } else { $this->add_onload_command("showBootstrapAlert('#alert-area', 'success', 'Error saving {$desc[$j]}');"); } $tax_id++; } } catch (Exception $e) { $this->add_onload_command("showBootstrapAlert('#alert-area', 'danger', 'Invalid values submitted');"); } return true; }