Work in progress on templates plugin.
authorNik Okuntseff <support@anuko.com>
Thu, 7 Mar 2019 22:34:56 +0000 (22:34 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 7 Mar 2019 22:34:56 +0000 (22:34 +0000)
WEB-INF/lib/ttOrgHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/plugins.tpl
WEB-INF/templates/predefined_expenses.tpl
WEB-INF/templates/templates.tpl [new file with mode: 0644]
dbinstall.php
plugins.php
templates.php [new file with mode: 0644]

index 461c751..3145d1d 100644 (file)
@@ -94,6 +94,7 @@ class ttOrgHelper {
       'tt_config',
       'tt_cron',
       'tt_fav_reports',
+      'tt_templates',
       'tt_monthly_quotas',
       'tt_predefined_expenses',
       'tt_expense_items',
index 7d6e220..c607176 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.54.4837 | 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.54.4838 | 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 005c2e5..affbcc1 100644 (file)
@@ -82,6 +82,16 @@ function handlePluginCheckboxes() {
   } else {
     configureLabel.style.visibility = "hidden";
   }
+
+  var templatesCheckbox = document.getElementById("templates");
+  configureLabel = document.getElementById("templates_config");
+  if (templatesCheckbox.checked){
+    configureLabel.style.display = "";
+    //configureLabel.style.visibility = "visible";
+  } else {
+    configureLabel.style.display = "none";
+    //configureLabel.style.visibility = "hidden";
+  }
 }
 </script>
 
@@ -145,7 +155,7 @@ function handlePluginCheckboxes() {
 {if isTrue('TEMPLATES_DEBUG')}
           <tr>
             <td align="right" nowrap>{$forms.pluginsForm.templates.control}</td>
-            <td><label for="templates">{$i18n.title.templates}</label> <a href="https://www.anuko.com/lp/tt_29.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
+            <td><label for="templates">{$i18n.title.templates}</label> <span id="templates_config"><a href="templates.php">{$i18n.label.configure}</a></span> <a href="https://www.anuko.com/lp/tt_29.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
           </tr>
 {/if}
           <tr>
index 147230d..9c8625c 100644 (file)
@@ -2,7 +2,6 @@
 <table cellspacing="0" cellpadding="7" border="0" width="720">
   <tr>
     <td valign="top">
-{if $user->can('manage_advanced_settings')}
       <table cellspacing="1" cellpadding="3" border="0" width="100%">
         <tr>
           <td class="tableHeader">{$i18n.label.thing_name}</td>
@@ -25,7 +24,6 @@
       <table width="100%">
         <tr><td align="center"><br>{$forms.predefinedExpensesForm.btn_add.control}</td></tr>
       </table>
-{/if}
     </td>
   </tr>
 </table>
diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl
new file mode 100644 (file)
index 0000000..a1ea349
--- /dev/null
@@ -0,0 +1,28 @@
+{$forms.templatesForm.open}
+<table cellspacing="0" cellpadding="7" border="0" width="720">
+  <tr>
+    <td valign="top">
+      <table cellspacing="1" cellpadding="3" border="0" width="100%">
+        <tr>
+          <td class="tableHeader">{$i18n.label.thing_name}</td>
+          <td class="tableHeader">{$i18n.label.edit}</td>
+          <td class="tableHeader">{$i18n.label.delete}</td>
+        </tr>
+  {if $templates}
+    {foreach $templates as $template}
+        <tr bgcolor="{cycle values="#f5f5f5,#ffffff"}">
+          <td>{$template_expense['name']|escape}</td>
+          <td><a href="template_edit.php?id={$template['id']}">{$i18n.label.edit}</a></td>
+          <td><a href="template_delete.php?id={$template['id']}">{$i18n.label.delete}</a></td>
+        </tr>
+    {/foreach}
+  {/if}
+      </table>
+
+      <table width="100%">
+        <tr><td align="center"><br>{$forms.templatesForm.btn_add.control}</td></tr>
+      </table>
+    </td>
+  </tr>
+</table>
+{$forms.templatesForm.close}
index c4eb1be..358f6f0 100644 (file)
@@ -1152,6 +1152,7 @@ if ($_POST) {
     ttExecute("OPTIMIZE TABLE tt_invoices");
     ttExecute("OPTIMIZE TABLE tt_log");
     ttExecute("OPTIMIZE TABLE tt_monthly_quotas");
+    ttExecute("OPTIMIZE TABLE tt_templates");
     ttExecute("OPTIMIZE TABLE tt_predefined_expenses");
     ttExecute("OPTIMIZE TABLE tt_project_task_binds");
     ttExecute("OPTIMIZE TABLE tt_projects");
index bf0e527..e20bb96 100644 (file)
@@ -95,7 +95,7 @@ $form->addInput(array('type'=>'checkbox','name'=>'work_units','value'=>$cl_work_
 $form->addInput(array('type'=>'checkbox','name'=>'approval','value'=>$cl_approval));
 $form->addInput(array('type'=>'checkbox','name'=>'timesheets','value'=>$cl_timesheets));
 if (isTrue('TEMPLATES_DEBUG')) {
-  $form->addInput(array('type'=>'checkbox','name'=>'templates','value'=>$cl_templates));
+  $form->addInput(array('type'=>'checkbox','name'=>'templates','value'=>$cl_templates,'onchange'=>'handlePluginCheckboxes()'));
 }
 // Submit button.
 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
diff --git a/templates.php b/templates.php
new file mode 100644 (file)
index 0000000..e2d0e77
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttGroupHelper');
+
+// Access checks.
+if (!ttAccessAllowed('manage_advanced_settings')) {
+  header('Location: access_denied.php');
+  exit();
+}
+if (!$user->isPluginEnabled('tp')) {
+  header('Location: feature_disabled.php');
+  exit();
+}
+// End of access checks.
+
+$form = new Form('templatesForm');
+
+if ($request->isPost()) {
+  if ($request->getParameter('btn_add')) {
+    // The Add button clicked. Redirect to template_add.php page.
+    header('Location: template_add.php');
+    exit();
+  }
+} else {
+  $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add')));
+  $predefinedExpenses = ttGroupHelper::getPredefinedExpenses();
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('predefined_expenses', $predefinedExpenses);
+$smarty->assign('title', $i18n->get('title.templates'));
+$smarty->assign('content_page_name', 'templates.tpl');
+$smarty->display('index.tpl');