From 4a3754f39ede85db41f93f31bd82c516ce23e01a Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 8 Mar 2019 15:50:21 +0000 Subject: [PATCH] Work in progress on template_add.php. --- WEB-INF/resources/en.lang.php | 1 + WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/template_add.tpl | 16 ++++++++++------ template_add.php | 22 ++++++++++++++-------- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 7fb968f9..eddafc93 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -237,6 +237,7 @@ $i18n_key_words = array( 'label.approved' => 'Approved', 'label.approval' => 'Report approval', 'label.mark_approved' => 'Mark approved', +'label.template' => 'Template', // Form titles. 'title.error' => 'Error', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 0d65482e..cb6766dd 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.55.4841 | Copyright © Anuko | +  Anuko Time Tracker 1.18.55.4842 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/template_add.tpl b/WEB-INF/templates/template_add.tpl index fd2983a7..2a52cec3 100644 --- a/WEB-INF/templates/template_add.tpl +++ b/WEB-INF/templates/template_add.tpl @@ -1,15 +1,19 @@ -{$forms.predefinedExpenseForm.open} +{$forms.templateForm.open}
- + - - + + + + + + @@ -17,10 +21,10 @@ - +
{$i18n.label.thing_name} (*):{$forms.predefinedExpenseForm.name.control}{$forms.templateForm.name.control}
{$i18n.label.cost} (*):{$forms.predefinedExpenseForm.cost.control} {$user->getCurrency()|escape}{$i18n.label.description}:{$forms.templateForm.description.control}
{$i18n.label.template} (*):{$forms.templateForm.content.control}
 
{$forms.predefinedExpenseForm.btn_add.control}{$forms.templateForm.btn_add.control}
-{$forms.predefinedExpenseForm.close} +{$forms.templateForm.close} diff --git a/template_add.php b/template_add.php index 606ea9f7..4fed72d5 100644 --- a/template_add.php +++ b/template_add.php @@ -43,23 +43,29 @@ if (!$user->isPluginEnabled('tp')) { if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); - $cl_cost = trim($request->getParameter('cost')); + $cl_description = trim($request->getParameter('description')); + $cl_content = trim($request->getParameter('content')); } -$form = new Form('predefinedExpenseForm'); +$form = new Form('templateForm'); $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','style'=>'width: 250px;','value'=>$cl_name)); -$form->addInput(array('type'=>'text','maxlength'=>'40','name'=>'cost','style'=>'width: 100px;','value'=>$cl_cost)); +$form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); +$form->addInput(array('type'=>'textarea','name'=>'content','style'=>'width: 250px; height: 80px;','value'=>$cl_content)); $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); if ($request->isPost()) { // Validate user input. if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); - if (!ttValidFloat($cl_cost)) $err->add($i18n->get('error.field'), $i18n->get('label.cost')); + if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); + if (!ttValidString($cl_content)) $err->add($i18n->get('error.field'), $i18n->get('label.template')); + // Finished validating user input. + if ($err->no()) { - if (ttPredefinedExpenseHelper::insert(array( + if (ttTemplateHelper::insert(array( 'name' => $cl_name, - 'cost' => $cl_cost))) { - header('Location: predefined_expenses.php'); + 'description' => $cl_description, + 'coontent' => $cl_content))) { + header('Location: templates.php'); exit(); } else $err->add($i18n->get('error.db')); @@ -68,5 +74,5 @@ if ($request->isPost()) { $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('title', $i18n->get('title.add_template')); -$smarty->assign('content_page_name', 'predefined_expense_add.tpl'); +$smarty->assign('content_page_name', 'template_add.tpl'); $smarty->display('index.tpl'); -- 2.20.1