Added a template selector on time.php.
authorNik Okuntseff <support@anuko.com>
Fri, 8 Mar 2019 22:09:00 +0000 (22:09 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 8 Mar 2019 22:09:00 +0000 (22:09 +0000)
WEB-INF/lib/ttGroupHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/time.tpl
time.php

index 251fb9e..b77edf2 100644 (file)
@@ -527,7 +527,7 @@ class ttGroupHelper {
     $group_id = $user->getGroup();
     $org_id = $user->org_id;
 
-    $sql = "select id, name, description from tt_templates".
+    $sql = "select id, name, description, content from tt_templates".
       " where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)";
     $res = $mdb2->query($sql);
     $result = array();
index 8b3fb05..26443ee 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.4846 | 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.4847 | 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 a181b91..fe9c294 100644 (file)
@@ -1,5 +1,22 @@
 {include file="time_script.tpl"}
 
+{if $template_dropdown}
+<script>
+var templates = new Array();
+{foreach $templates as $template}
+  templates[{$template.id}] = "{$template.content|escape:'javascript'}";
+{/foreach}
+
+// The fillNote function populates the Note field with a selected template body.
+function fillNote(id) {
+  if (!id) return; // Do nothing.
+  var template_body = templates[id];
+  var note = document.getElementById("note");
+  note.value = template_body;
+}
+</script>
+{/if}
+
 <style>
 .not_billable td {
   color: #ff6666;
           <td align="right">{$i18n.label.duration}:</td>
           <td>{$forms.timeRecordForm.duration.control}&nbsp;{if $user->getDecimalMark() == ','}{str_replace('.', ',', $i18n.form.time.duration_format)}{else}{$i18n.form.time.duration_format}{/if}</td>
         </tr>
+{/if}
+{if $template_dropdown}
+        <tr>
+          <td align="right">{$i18n.label.template}:</td>
+          <td>{$forms.timeRecordForm.template.control}</td>
+        </tr>
 {/if}
       </table>
     </td>
index f7b1c12..dd219e8 100644 (file)
--- a/time.php
+++ b/time.php
@@ -249,6 +249,22 @@ if ($custom_fields && $custom_fields->fields[0]) {
   }
 }
 
+// If we have templates, add a dropdown to select one.
+if ($user->isPluginEnabled('tp')){
+  $templates = ttGroupHelper::getActiveTemplates();
+  if (count($templates) >= 1) {
+    $form->addInput(array('type'=>'combobox',
+      'onchange'=>'fillNote(this.value);',
+      'name'=>'template',
+      'style'=>'width: 250px;',
+      'data'=>$templates,
+      'datakeys'=>array('id','name'),
+      'empty'=>array(''=>$i18n->get('dropdown.select'))));
+    $smarty->assign('template_dropdown', 1);
+    $smarty->assign('templates', $templates);
+  }
+}
+
 // Submit.
 if ($request->isPost()) {
   if ($request->getParameter('btn_submit')) {