function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Tax(); $model->model_uset_id = $this->user->user_id; if ($model->fillFromDbPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('tax_not_deleted')); } else { $countE = AF::get($_POST, 'countE', 100000); // if the delete request came from an update page, we need to redirect if (count($modelsID) >= $countE || stripos($_SERVER['HTTP_REFERER'], 'taxes/update') !== false) { $link = AF::link(array('taxes' => 'view')); Message::echoJsonRedirect($link); } else { Message::echoJsonSuccess(__('tax_deleted')); } } } $this->redirect('view'); //$this->redirect(); }
<?php require_once "util.php"; $tax = new Tax(); if ($action == "new") { $tax->create(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", ""))); } elseif ($action == "edit") { $tax->update(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", ""))); } elseif ($action == "delete") { $tax->delete(var_get("tax_id", "")); } $tax_box = new NTKVBox("tax_box", 0, 0, False); $label = new NTKLabel("tax_label", "<h3>Steuersätze</h3>"); $tax_box->add($label); $taxlist = $tax->get(''); for ($i = 0; $i < count($taxlist); $i++) { $tax_box->add(new NTKETax($taxlist[$i][0], $taxlist[$i][1], $taxlist[$i][2])); } $label = new NTKLabel("tax_label", "<h4>neuer Steuersatz</h4>"); $tax_box->add($label); $tax_box->add(new NTKETax("", "", "", True), -1); $main_box->add($tax_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");