From e35084bc1a01504480461fef87e6a6e4eff6880d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 16 Feb 2019 14:00:21 +0000 Subject: [PATCH] Started refactoring reports.php for timesheets. --- WEB-INF/templates/footer.tpl | 2 +- reports.php | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9cb2a052..03db7b7c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.37.4727 | Copyright © Anuko | +  Anuko Time Tracker 1.18.37.4728 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/reports.php b/reports.php index 1e7b4b99..f938872b 100644 --- a/reports.php +++ b/reports.php @@ -49,12 +49,15 @@ if (!$user->exists()) { // End of access checks. $trackingMode = $user->getTrackingMode(); +$showClient = $user->isPluginEnabled('cl') && !$user->isClient(); // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); $custom_fields = new CustomFields(); $smarty->assign('custom_fields', $custom_fields); + $showCustomFieldCheckbox = $custom_fields->fields[0]; + $showCustomFieldDropdown = $custom_fields->fields[0] && $custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN; } $form = new Form('reportForm'); @@ -74,7 +77,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_generate','value'=>$i18n->ge $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('label.delete'),'onclick'=>"return confirm('".$i18n->get('form.reports.confirm_delete')."')")); // Dropdown for clients if the clients plugin is enabled. -if ($user->isPluginEnabled('cl') && !$user->isClient()) { +if ($showClient) { if ($user->can('view_reports') || $user->can('view_all_reports')) { $client_list = ttClientHelper::getClients(); // TODO: improve getClients for "view_reports" // by filtering out not relevant clients. @@ -88,13 +91,13 @@ if ($user->isPluginEnabled('cl') && !$user->isClient()) { 'empty'=>array(''=>$i18n->get('dropdown.all')))); } -// If we have a TYPE_DROPDOWN custom field - add control to select an option. -if ($custom_fields && $custom_fields->fields[0] && $custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) { - $form->addInput(array('type'=>'combobox','name'=>'option', - 'style'=>'width: 250px;', - 'value'=>$cl_cf_1, - 'data'=>$custom_fields->options, - 'empty'=>array(''=>$i18n->get('dropdown.all')))); +// If we have a TYPE_DROPDOWN custom field - add a control to select an option. +if ($showCustomFieldDropdown) { + $form->addInput(array('type'=>'combobox','name'=>'option', + 'style'=>'width: 250px;', + 'value'=>$cl_cf_1, + 'data'=>$custom_fields->options, + 'empty'=>array(''=>$i18n->get('dropdown.all')))); } // Add controls for projects and tasks. @@ -210,7 +213,7 @@ $form->addInput(array('type'=>'datefield','maxlength'=>'20','name'=>'start_date' $form->addInput(array('type'=>'datefield','maxlength'=>'20','name'=>'end_date')); // Add checkboxes for fields. -if ($user->isPluginEnabled('cl')) +if ($showClient) $form->addInput(array('type'=>'checkbox','name'=>'chclient')); if (($user->can('manage_invoices') || $user->isClient()) && $user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'chinvoice')); @@ -372,6 +375,7 @@ if ($request->isPost()) { } } // isPost +$smarty->assign('show_client', $showClient); $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); $smarty->assign('assigned_projects', $assigned_projects); -- 2.20.1