Work in progress on template_add.php.
authorNik Okuntseff <support@anuko.com>
Fri, 8 Mar 2019 15:50:21 +0000 (15:50 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 8 Mar 2019 15:50:21 +0000 (15:50 +0000)
WEB-INF/resources/en.lang.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/template_add.tpl
template_add.php

index 7fb968f..eddafc9 100644 (file)
@@ -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',
index 0d65482..cb6766d 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.55.4841 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.55.4842 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index fd2983a..2a52cec 100644 (file)
@@ -1,15 +1,19 @@
-{$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>&nbsp;</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}
index 606ea9f..4fed72d 100644 (file)
@@ -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');