Created ttDebugTracer class to hopefully help to address blank screen issues.
[timetracker.git] / WEB-INF / templates / time_script.tpl
index 624ff0e..3e8a020 100644 (file)
@@ -1,5 +1,9 @@
 <script>
-// This script is shared by time.tpl and time_edit.tpl (both regular and mobile).
+// This script is shared by time.tpl, time_edit.tpl (both regular and mobile),
+// and also by WEB-INF/templates/mobile/timer.tpl.
+// This creates certain restrictions, such as the form name being "timeRecordForm",
+// variables such as $client_list, $project_list and others to be assigned in php files
+// for all pages. Things need to be tested together for all involved files.
 
 // We need a few arrays to populate project and task dropdowns.
 // When client selection changes, the project dropdown must be re-populated with only relevant projects.
@@ -39,6 +43,21 @@ var task_names = new Array();
   task_names[{$task.id}] = "{$task.name|escape:'javascript'}";
 {/foreach}
 
+{if $template_dropdown}
+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;
+}
+{/if}
+
 // Mandatory top options for project and task dropdowns.
 var empty_label_project = "{$i18n.dropdown.select|escape:'javascript'}";
 var empty_label_task = "{$i18n.dropdown.select|escape:'javascript'}";
@@ -139,6 +158,11 @@ function fillTaskDropdown(id) {
         }
       }
     }
+
+    // Select a task if user is required to do so and there is only one task available.
+    if ({$user->task_required} && dropdown.options.length == 2) { // 2 because of mandatory top option.
+      dropdown.options[1].selected = true;
+    }
   }
 }