From e2ac6192ba07b02c08cd0697a62983259ff73b78 Mon Sep 17 00:00:00 2001 From: anuko Date: Sun, 12 Feb 2017 15:29:53 +0000 Subject: [PATCH] Added a delete form for predefined expenses. --- WEB-INF/templates/footer.tpl | 2 +- .../templates/predefined_expense_delete.tpl | 18 +++++ predefined_expense_delete.php | 69 +++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 WEB-INF/templates/predefined_expense_delete.tpl create mode 100644 predefined_expense_delete.php diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3631de66..a0d2b857 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.9.37.3576 | Copyright © Anuko | +  Anuko Time Tracker 1.9.37.3577 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/predefined_expense_delete.tpl b/WEB-INF/templates/predefined_expense_delete.tpl new file mode 100644 index 00000000..e91692f4 --- /dev/null +++ b/WEB-INF/templates/predefined_expense_delete.tpl @@ -0,0 +1,18 @@ +{$forms.predefinedExpenseDeleteForm.open} + + + + +
+ + + + + + + + + +
{$predefined_expense_to_delete|escape}
 
{$forms.predefinedExpenseDeleteForm.btn_delete.control}  {$forms.predefinedExpenseDeleteForm.btn_cancel.control}
+
+{$forms.predefinedExpenseDeleteForm.close} diff --git a/predefined_expense_delete.php b/predefined_expense_delete.php new file mode 100644 index 00000000..1c8a0fed --- /dev/null +++ b/predefined_expense_delete.php @@ -0,0 +1,69 @@ +isPluginEnabled('ex')) { + header('Location: access_denied.php'); + exit(); +} + +$cl_predefined_expense_id = (int)$request->getParameter('id'); +$predefined_expense = ttPredefinedExpenseHelper::get($cl_predefined_expense_id); +$predefined_expense_to_delete = $predefined_expense['name']; + +$form = new Form('predefinedExpenseDeleteForm'); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_predefined_expense_id)); +$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete'))); +$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel'))); + +if ($request->isPost()) { + if ($request->getParameter('btn_delete')) { + if(ttPredefinedExpenseHelper::get($cl_predefined_expense_id)) { + if (ttPredefinedExpenseHelper::delete($cl_predefined_expense_id)) { + header('Location: predefined_expenses.php'); + exit(); + } else + $err->add($i18n->getKey('error.db')); + } else + $err->add($i18n->getKey('error.db')); + } elseif ($request->getParameter('btn_cancel')) { + header('Location: predefined_expenses.php'); + exit(); + } +} // isPost + +$smarty->assign('predefined_expense_to_delete', $predefined_expense_to_delete); +$smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('onload', 'onLoad="document.predefinedExpenseDeleteForm.btn_cancel.focus()"'); +$smarty->assign('title', $i18n->getKey('title.delete_predefined_expense')); +$smarty->assign('content_page_name', 'predefined_expense_delete.tpl'); +$smarty->display('index.tpl'); -- 2.20.1