From bf5e56bc4052b478cca323386c7a71845a91989d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 9 Mar 2019 16:01:12 +0000 Subject: [PATCH] Added template selector on mobile pages. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/mobile/time.tpl | 4 ++++ WEB-INF/templates/mobile/time_edit.tpl | 4 ++++ mobile/time.php | 20 ++++++++++++++++++++ mobile/time_edit.php | 22 ++++++++++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 29660bf9..5c320f1c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {/if} +{if $template_dropdown} + + +{/if} diff --git a/WEB-INF/templates/mobile/time_edit.tpl b/WEB-INF/templates/mobile/time_edit.tpl index 79c5c03c..472d0dd3 100644 --- a/WEB-INF/templates/mobile/time_edit.tpl +++ b/WEB-INF/templates/mobile/time_edit.tpl @@ -53,6 +53,10 @@ function confirmSave() { {/if} +{if $template_dropdown} + + +{/if} diff --git a/mobile/time.php b/mobile/time.php index fe723da5..b9ee3bce 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -228,6 +228,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')) { @@ -267,6 +283,10 @@ if ($request->isPost()) { $err->add($i18n->get('error.field'), $i18n->get('label.duration')); } if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note')); + if ($user->isPluginEnabled('tp') && strpos($cl_note, '%req%') !== false) { + // A %req% element is found in note. They have to be replaced by user. + $err->add($i18n->get('error.field'), $i18n->get('label.note')); + } if (!ttTimeHelper::canAdd()) $err->add($i18n->get('error.expired')); // Finished validating user input. diff --git a/mobile/time_edit.php b/mobile/time_edit.php index e81f693c..c3699d53 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -188,6 +188,7 @@ if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) $form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');")); $form->addInput(array('type'=>'datefield','name'=>'date','maxlength'=>'20','value'=>$cl_date)); $form->addInput(array('type'=>'textarea','name'=>'note','class'=>'mobile-textarea','value'=>$cl_note)); + // If we have custom fields - add controls for them. if ($custom_fields && $custom_fields->fields[0]) { // Only one custom field is supported at this time. @@ -202,6 +203,23 @@ if ($custom_fields && $custom_fields->fields[0]) { 'empty' => array('' => $i18n->get('dropdown.select')))); } } + +// 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); + } +} + // Hidden control for record id. $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id)); if ($user->isPluginEnabled('iv')) @@ -253,6 +271,10 @@ if ($request->isPost()) { } if (!ttValidDate($cl_date)) $err->add($i18n->get('error.field'), $i18n->get('label.date')); if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note')); + if ($user->isPluginEnabled('tp') && strpos($cl_note, '%req%') !== false) { + // A %req% element is found in note. They have to be replaced by user. + $err->add($i18n->get('error.field'), $i18n->get('label.note')); + } if (!ttTimeHelper::canAdd()) $err->add($i18n->get('error.expired')); // Finished validating user input. -- 2.20.1
 Anuko Time Tracker 1.18.56.4850 | Copyright © Anuko | +  Anuko Time Tracker 1.18.56.4851 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/mobile/time.tpl b/WEB-INF/templates/mobile/time.tpl index a342c764..7fea1777 100644 --- a/WEB-INF/templates/mobile/time.tpl +++ b/WEB-INF/templates/mobile/time.tpl @@ -82,6 +82,10 @@
{$i18n.label.duration}:
{$forms.timeRecordForm.duration.control}
{$i18n.label.template}:
{$forms.timeRecordForm.template.control}
{$i18n.label.note}:
{$forms.timeRecordForm.note.control}
{$i18n.label.date}:
{$forms.timeRecordForm.date.control}
{$i18n.label.template}:
{$forms.timeRecordForm.template.control}
{$i18n.label.note}:
{$forms.timeRecordForm.note.control}
{$forms.timeRecordForm.btn_save.control} {$forms.timeRecordForm.btn_copy.control} {$forms.timeRecordForm.btn_delete.control}