From: anuko Date: Sun, 12 Feb 2017 15:29:53 +0000 (+0000) Subject: Added a delete form for predefined expenses. X-Git-Tag: timetracker_1.19-1~1577 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e2ac6192ba07b02c08cd0697a62983259ff73b78;p=timetracker.git Added a delete form for predefined expenses. --- 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');