From 98f5feaaf9bbf59fcf6e797c6c05978ef13074f6 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 7 Mar 2019 22:34:56 +0000 Subject: [PATCH] Work in progress on templates plugin. --- WEB-INF/lib/ttOrgHelper.class.php | 1 + WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/plugins.tpl | 12 ++++- WEB-INF/templates/predefined_expenses.tpl | 2 - WEB-INF/templates/templates.tpl | 28 +++++++++++ dbinstall.php | 1 + plugins.php | 2 +- templates.php | 61 +++++++++++++++++++++++ 8 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 WEB-INF/templates/templates.tpl create mode 100644 templates.php diff --git a/WEB-INF/lib/ttOrgHelper.class.php b/WEB-INF/lib/ttOrgHelper.class.php index 461c751d..3145d1d7 100644 --- a/WEB-INF/lib/ttOrgHelper.class.php +++ b/WEB-INF/lib/ttOrgHelper.class.php @@ -94,6 +94,7 @@ class ttOrgHelper { 'tt_config', 'tt_cron', 'tt_fav_reports', + 'tt_templates', 'tt_monthly_quotas', 'tt_predefined_expenses', 'tt_expense_items', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 7d6e2200..c6071766 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - + {/if} diff --git a/WEB-INF/templates/predefined_expenses.tpl b/WEB-INF/templates/predefined_expenses.tpl index 147230dc..9c8625c7 100644 --- a/WEB-INF/templates/predefined_expenses.tpl +++ b/WEB-INF/templates/predefined_expenses.tpl @@ -2,7 +2,6 @@
 Anuko Time Tracker 1.18.54.4837 | Copyright © Anuko | +  Anuko Time Tracker 1.18.54.4838 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/plugins.tpl b/WEB-INF/templates/plugins.tpl index 005c2e5f..affbcc19 100644 --- a/WEB-INF/templates/plugins.tpl +++ b/WEB-INF/templates/plugins.tpl @@ -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"; + } } @@ -145,7 +155,7 @@ function handlePluginCheckboxes() { {if isTrue('TEMPLATES_DEBUG')}
{$forms.pluginsForm.templates.control} {$i18n.label.what_is_it} {$i18n.label.configure} {$i18n.label.what_is_it}
-{if $user->can('manage_advanced_settings')} @@ -25,7 +24,6 @@
{$i18n.label.thing_name}

{$forms.predefinedExpensesForm.btn_add.control}
-{/if}
diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl new file mode 100644 index 00000000..a1ea3496 --- /dev/null +++ b/WEB-INF/templates/templates.tpl @@ -0,0 +1,28 @@ +{$forms.templatesForm.open} + + + + +
+ + + + + + + {if $templates} + {foreach $templates as $template} + + + + + + {/foreach} + {/if} +
{$i18n.label.thing_name}{$i18n.label.edit}{$i18n.label.delete}
{$template_expense['name']|escape}{$i18n.label.edit}{$i18n.label.delete}
+ + + +

{$forms.templatesForm.btn_add.control}
+
+{$forms.templatesForm.close} diff --git a/dbinstall.php b/dbinstall.php index c4eb1bec..358f6f02 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -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"); diff --git a/plugins.php b/plugins.php index bf0e527f..e20bb961 100644 --- a/plugins.php +++ b/plugins.php @@ -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 index 00000000..e2d0e779 --- /dev/null +++ b/templates.php @@ -0,0 +1,61 @@ +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'); -- 2.20.1