From acd436b6c7d3bc585bb3841d4d69dbe15cd8d140 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 8 Mar 2019 16:54:19 +0000 Subject: [PATCH] Work in progress on templates.php. --- WEB-INF/lib/ttGroupHelper.class.php | 42 +++++++++++++++++++++++++++++ WEB-INF/resources/en.lang.php | 4 +++ WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/templates.tpl | 7 +++-- templates.php | 6 +++-- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 762fffb6..251fb9e7 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -518,6 +518,48 @@ class ttGroupHelper { return $result; } + // getActiveTemplates - returns an array of active templates for a group. + static function getActiveTemplates() + { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description 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(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } + + // getInactiveTemplates - returns an array of active templates for a group. + static function getInactiveTemplates() + { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description from tt_templates". + " where group_id = $group_id and org_id = $org_id and status = 0 order by upper(name)"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } + // validateCheckboxGroupInput - validates user input in a group of checkboxes // in context of a specific database table. // diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index eddafc93..db04f818 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -425,6 +425,10 @@ $i18n_key_words = array( 'form.timesheets.active_timesheets' => 'Active Timesheets', 'form.timesheets.inactive_timesheets' => 'Inactive Timesheets', + // Templates form. See example at https://timetracker.anuko.com/templates.php +'form.templates.active_templates' => 'Active Templates', +'form.templates.inactive_templates' => 'Inactive Templates', + // Invoice form. See example at https://timetracker.anuko.com/invoice.php // (you can get to this form after generating a report). 'form.invoice.number' => 'Invoice number', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 11597100..e693b467 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.55.4843 | Copyright © Anuko | +  Anuko Time Tracker 1.18.55.4844 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/templates.tpl b/WEB-INF/templates/templates.tpl index 177f32cf..0e8f220a 100644 --- a/WEB-INF/templates/templates.tpl +++ b/WEB-INF/templates/templates.tpl @@ -3,14 +3,17 @@
+{if $inactive_templates} + +{/if} - {if $templates} - {foreach $templates as $template} + {if $active_templates} + {foreach $active_templates as $template} diff --git a/templates.php b/templates.php index e2d0e779..6bf6ae39 100644 --- a/templates.php +++ b/templates.php @@ -51,11 +51,13 @@ if ($request->isPost()) { } } else { $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); - $predefinedExpenses = ttGroupHelper::getPredefinedExpenses(); + $activeTemplates = ttGroupHelper::getActiveTemplates(); + $inactiveTemplates = ttGroupHelper::getInactiveTemplates(); } $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('predefined_expenses', $predefinedExpenses); +$smarty->assign('active_templates', $activeTemplates); +$smarty->assign('inactive_templates', $inactiveTemplates); $smarty->assign('title', $i18n->get('title.templates')); $smarty->assign('content_page_name', 'templates.tpl'); $smarty->display('index.tpl'); -- 2.20.1
{$i18n.form.templates.active_templates}
{$i18n.label.thing_name} {$i18n.label.description} {$i18n.label.edit} {$i18n.label.delete}
{$template['name']|escape} {$template['description']|escape}