X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/b8d9247f09f3dfbd35a724ba5ac1b8e433dc1fd1..e35084bc1a01504480461fef87e6a6e4eff6880d:/reports.php diff --git a/reports.php b/reports.php index 7c7ac011..f938872b 100644 --- a/reports.php +++ b/reports.php @@ -30,7 +30,6 @@ require_once('initialize.php'); import('form.Form'); import('form.ActionForm'); import('DateAndTime'); -import('ttTeamHelper'); import('ttGroupHelper'); import('Period'); import('ttProjectHelper'); @@ -50,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'); @@ -75,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. @@ -89,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. @@ -152,6 +154,16 @@ if ($user->can('manage_invoices') && $user->isPluginEnabled('ps')) { )); } +// TODO: check rights. +if ($user->isPluginEnabled('ts')) { + $form->addInput(array('type'=>'combobox', + 'name'=>'timesheet', + 'style'=>'width: 250px;', + 'data'=>array('1'=>$i18n->get('form.reports.include_assigned'),'2'=>$i18n->get('form.reports.include_not_assigned')), + 'empty'=>array(''=>$i18n->get('dropdown.all')) + )); +} + $user_list = array(); if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) { // Prepare user and assigned projects arrays. @@ -165,7 +177,7 @@ if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isCli $users = $user->getUsers($options); // Active and inactive users. } elseif ($user->isClient()) - $users = ttTeamHelper::getUsersForClient(); // Active and inactive users for clients. + $users = ttGroupHelper::getUsersForClient(); // Active and inactive users for clients. foreach ($users as $single_user) { $user_list[$single_user['id']] = $single_user['name']; @@ -201,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')); @@ -332,12 +344,12 @@ if ($request->isPost()) { } else { // Generate button pressed. Check some values. if (!$bean->getAttribute('period')) { - $start_date = new DateAndTime($user->date_format, $bean->getAttribute('start_date')); + $start_date = new DateAndTime($user->getDateFormat(), $bean->getAttribute('start_date')); if ($start_date->isError() || !$bean->getAttribute('start_date')) $err->add($i18n->get('error.field'), $i18n->get('label.start_date')); - $end_date = new DateAndTime($user->date_format, $bean->getAttribute('end_date')); + $end_date = new DateAndTime($user->getDateFormat(), $bean->getAttribute('end_date')); if ($end_date->isError() || !$bean->getAttribute('end_date')) $err->add($i18n->get('error.field'), $i18n->get('label.end_date')); @@ -363,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);