From: Nik Okuntseff <support@anuko.com> Date: Fri, 8 Mar 2019 22:09:00 +0000 (+0000) Subject: Added a template selector on time.php. X-Git-Tag: timetracker_1.19-1~195 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3d2723cd9a817f59b26a40f5b34281e0586ba1ca;p=timetracker.git Added a template selector on time.php. --- diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 251fb9e7..b77edf21 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -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(); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 8b3fb051..26443eea 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@ <br> <table cellspacing="0" cellpadding="4" width="100%" border="0"> <tr> - <td align="center"> Anuko Time Tracker 1.18.55.4846 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> | + <td align="center"> Anuko Time Tracker 1.18.55.4847 | Copyright © <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> diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index a181b912..fe9c294d 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -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; @@ -68,6 +85,12 @@ <td align="right">{$i18n.label.duration}:</td> <td>{$forms.timeRecordForm.duration.control} {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> diff --git a/time.php b/time.php index f7b1c12e..dd219e8e 100644 --- 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')) {