X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=template_add.php;h=6fb0238e49c719aa94d45e9aa92d7309e0fb492b;hb=ce2df23479c88d1bc9db04a68164af3feb6346e1;hp=606ea9f71bf465a611f672ac7a3f33ec464bb7cd;hpb=fc92f9cd36dcaeb96da37c699a61331805d9e2fc;p=timetracker.git diff --git a/template_add.php b/template_add.php index 606ea9f7..6fb0238e 100644 --- a/template_add.php +++ b/template_add.php @@ -28,7 +28,7 @@ require_once('initialize.php'); import('form.Form'); -// import('ttTemplateHelper'); +import('ttTemplateHelper'); // Access checks. if (!ttAccessAllowed('manage_advanced_settings')) { @@ -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, + 'content' => $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');