-{$forms.predefinedExpenseForm.open}
+{$forms.templateForm.open}
<table cellspacing="4" cellpadding="7" border="0">
<tr>
<td>
<table cellspacing="1" cellpadding="2" border="0">
<tr>
<td align="right">{$i18n.label.thing_name} (*):</td>
- <td>{$forms.predefinedExpenseForm.name.control}</td>
+ <td>{$forms.templateForm.name.control}</td>
</tr>
<tr>
- <td align="right">{$i18n.label.cost} (*):</td>
- <td>{$forms.predefinedExpenseForm.cost.control} {$user->getCurrency()|escape}</td>
+ <td align="right">{$i18n.label.description}:</td>
+ <td>{$forms.templateForm.description.control}</td>
+ </tr>
+ <tr>
+ <td align="right">{$i18n.label.template} (*):</td>
+ <td>{$forms.templateForm.content.control}</td>
</tr>
<tr>
<td height="40"></td>
</tr>
<tr><td> </td></tr>
<tr>
- <td colspan="2" align="center" height="50">{$forms.predefinedExpenseForm.btn_add.control}</td>
+ <td colspan="2" align="center" height="50">{$forms.templateForm.btn_add.control}</td>
</tr>
</table>
</td>
</tr>
</table>
-{$forms.predefinedExpenseForm.close}
+{$forms.templateForm.close}
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'));
$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');