From 4426ed3bc8e53d5013d356505283c916e3826392 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 20 Mar 2016 18:35:20 -0700 Subject: [PATCH] Cleanup of white space and comment improvement --- WEB-INF/templates/footer.tpl | 2 +- invoice_add.php | 2 +- invoice_delete.php | 2 +- invoice_send.php | 2 +- login.php | 2 +- password_change.php | 2 +- password_reset.php | 2 +- profile_edit.php | 38 +++++++++---------- project_add.php | 6 +-- project_delete.php | 10 ++--- project_edit.php | 10 ++--- register.php | 14 +++---- report.php | 16 ++++---- report_send.php | 16 ++++---- reports.php | 73 ++++++++++++++++-------------------- 15 files changed, 93 insertions(+), 104 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 1d0fc0e9..a1ae5fc2 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.9.16.3425 | Copyright © Anuko | +  Anuko Time Tracker 1.9.16.3426 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/invoice_add.php b/invoice_add.php index 67ae8c14..9074ce2a 100644 --- a/invoice_add.php +++ b/invoice_add.php @@ -89,7 +89,7 @@ if ($request->getMethod() == 'POST') { } $errors->add($i18n->getKey('error.db')); } -} // post +} // POST $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.invoiceForm.number.focus()"'); diff --git a/invoice_delete.php b/invoice_delete.php index b688335a..4f9ed242 100644 --- a/invoice_delete.php +++ b/invoice_delete.php @@ -63,7 +63,7 @@ if ($request->getMethod() == 'POST') { header('Location: invoices.php'); exit(); } -} // post +} // POST $smarty->assign('invoice_to_delete', $invoice_to_delete); $smarty->assign('forms', array($form->getName()=>$form->toArray())); diff --git a/invoice_send.php b/invoice_send.php index a013bdf7..399e08cb 100644 --- a/invoice_send.php +++ b/invoice_send.php @@ -92,7 +92,7 @@ if ($request->getMethod() == 'POST') { else $errors->add($i18n->getKey('error.mail_send')); } -} +} // POST $smarty->assign('title', $i18n->getKey('title.send_invoice')); $smarty->assign('forms', array($form->getName()=>$form->toArray())); diff --git a/login.php b/login.php index 20499a6f..f193aa2e 100644 --- a/login.php +++ b/login.php @@ -78,7 +78,7 @@ if ($request->getMethod() == 'POST') { } else $errors->add($i18n->getKey('error.auth')); } -} +} // POST if(!isTrue(MULTITEAM_MODE) && !ttTeamHelper::getTeams()) $errors->add($i18n->getKey('error.no_teams')); diff --git a/password_change.php b/password_change.php index 8e565212..e7d27505 100644 --- a/password_change.php +++ b/password_change.php @@ -87,7 +87,7 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.auth')); } } -} +} // POST $smarty->assign('forms', array($form->getName() => $form->toArray())); $smarty->assign('title', $i18n->getKey('title.change_password')); diff --git a/password_reset.php b/password_reset.php index de0a02c1..52e268ca 100644 --- a/password_reset.php +++ b/password_reset.php @@ -110,7 +110,7 @@ if ($request->getMethod() == 'POST') { $smarty->assign('result_message', $res ? $i18n->getKey('form.reset_password.message') : $i18n->getKey('error.mail_send')); } } -} +} // POST $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.resetPasswordForm.login.focus()"'); diff --git a/profile_edit.php b/profile_edit.php index d5670101..3ef146ed 100644 --- a/profile_edit.php +++ b/profile_edit.php @@ -47,9 +47,9 @@ if ($request->getMethod() == 'POST') { $cl_password2 = $request->getParameter('password2'); } $cl_email = trim($request->getParameter('email')); - + if ($user->canManageTeam()) { - $cl_team = trim($request->getParameter('team_name')); + $cl_team = trim($request->getParameter('team_name')); $cl_address = trim($request->getParameter('address')); $cl_currency = trim($request->getParameter('currency')); if (!$cl_currency) $cl_currency = CURRENCY_DEFAULT; @@ -76,12 +76,12 @@ if ($request->getMethod() == 'POST') { $cl_email = $user->email; if ($user->canManageTeam()) { $cl_team = $user->team; - $cl_address = $user->address; + $cl_address = $user->address; $cl_currency = ($user->currency == ''? CURRENCY_DEFAULT : $user->currency); $cl_lock_interval = $user->lock_interval; $cl_lang = $user->lang; $cl_decimal_mark = $user->decimal_mark; - $cl_custom_format_date = $user->date_format; + $cl_custom_format_date = $user->date_format; $cl_custom_format_time = $user->time_format; $cl_start_week = $user->week_start; $cl_tracking_mode = $user->tracking_mode; @@ -112,13 +112,11 @@ if ($user->canManageTeam()) { $form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'team_name','value'=>$cl_team)); $form->addInput(array('type'=>'textarea','name'=>'address','maxlength'=>'255','style'=>'width: 350px;','cols'=>'55','rows'=>'4','value'=>$cl_address)); $form->addInput(array('type'=>'text','maxlength'=>'7','name'=>'currency','value'=>$cl_currency)); - $DECIMAL_MARK_OPTIONS = array( - array('id'=>'.','name'=>'.'), - array('id'=>',','name'=>',')); + $DECIMAL_MARK_OPTIONS = array(array('id'=>'.','name'=>'.'),array('id'=>',','name'=>',')); $form->addInput(array('type'=>'combobox','name'=>'decimal_mark','style'=>'width: 150px','data'=>$DECIMAL_MARK_OPTIONS,'datakeys'=>array('id','name'),'value'=>$cl_decimal_mark, 'onchange'=>'adjustDecimalPreview()')); $form->addInput(array('type'=>'text','maxlength'=>'10','name'=>'lock_interval','value'=>$cl_lock_interval)); - // Prepare an array of available languages. + // Prepare an array of available languages. $lang_files = I18n::getLangFileList(); foreach ($lang_files as $lfile) { $content = file(RESOURCE_DIR."/".$lfile); @@ -161,18 +159,18 @@ if ($user->canManageTeam()) { $tracking_mode_options[MODE_PROJECTS] = $i18n->getKey('form.profile.mode_projects'); $tracking_mode_options[MODE_PROJECTS_AND_TASKS] = $i18n->getKey('form.profile.mode_projects_and_tasks'); $form->addInput(array('type'=>'combobox','name'=>'tracking_mode','style'=>'width: 150px;','data'=>$tracking_mode_options,'value'=>$cl_tracking_mode)); - + // Prepare record type choices. $record_type_options = array(); $record_type_options[TYPE_ALL] = $i18n->getKey('form.profile.type_all'); $record_type_options[TYPE_START_FINISH] = $i18n->getKey('form.profile.type_start_finish'); $record_type_options[TYPE_DURATION] = $i18n->getKey('form.profile.type_duration'); $form->addInput(array('type'=>'combobox','name'=>'record_type','style'=>'width: 150px;','data'=>$record_type_options,'value'=>$cl_record_type)); - + $form->addInput(array('type'=>'checkbox','name'=>'charts','data'=>1,'value'=>$cl_charts)); $form->addInput(array('type'=>'checkbox','name'=>'clients','data'=>1,'value'=>$cl_clients,'onchange'=>'handlePluginCheckboxes()')); $form->addInput(array('type'=>'checkbox','name'=>'client_required','data'=>1,'value'=>$cl_client_required)); - + $form->addInput(array('type'=>'checkbox','name'=>'invoices','data'=>1,'value'=>$cl_invoices)); $form->addInput(array('type'=>'checkbox','name'=>'custom_fields','data'=>1,'value'=>$cl_custom_fields,'onchange'=>'handlePluginCheckboxes()')); $form->addInput(array('type'=>'checkbox','name'=>'expenses','data'=>1,'value'=>$cl_expenses,'onchange'=>'handlePluginCheckboxes()')); @@ -185,8 +183,8 @@ if ($request->getMethod() == 'POST') { // Validate user input. if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name')); if ($can_change_login) { - if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); - + if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); + // New login must be unique. if ($cl_login != $user->login && ttUserHelper::getUserByLogin($cl_login)) $errors->add($i18n->getKey('error.user_exists')); @@ -199,13 +197,13 @@ if ($request->getMethod() == 'POST') { } if (!ttValidEmail($cl_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email')); if ($user->canManageTeam()) { - if (!ttValidString($cl_team, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.team_name')); - if (!ttValidString($cl_address, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.address')); - if (!ttValidString($cl_currency, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.currency')); - if (!ttValidInteger($cl_lock_interval, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.lock_interval')); + if (!ttValidString($cl_team, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.team_name')); + if (!ttValidString($cl_address, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.address')); + if (!ttValidString($cl_currency, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.currency')); + if (!ttValidInteger($cl_lock_interval, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.lock_interval')); } // Finished validating user input. - + if ($errors->isEmpty()) { if ($cl_lock_interval == null || trim($cl_lock_interval) == '') $cl_lock_interval = 0; @@ -221,7 +219,7 @@ if ($request->getMethod() == 'POST') { if ($cl_client_required) $plugins .= ',cm'; if ($cl_invoices) - $plugins .= ',iv'; + $plugins .= ',iv'; if ($cl_custom_fields) $plugins .= ',cf'; if ($cl_expenses) @@ -231,7 +229,7 @@ if ($request->getMethod() == 'POST') { if ($cl_notifications) $plugins .= ',no'; $plugins = trim($plugins, ','); - + $update_result = ttTeamHelper::update($user->team_id, array( 'name' => $cl_team, 'address' => $cl_address, diff --git a/project_add.php b/project_add.php index 97ccd434..d799044c 100644 --- a/project_add.php +++ b/project_add.php @@ -69,9 +69,9 @@ if ($request->getMethod() == 'POST') { // Validate user input. if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name')); if (!ttValidString($cl_description, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.description')); - + if ($errors->isEmpty()) { - if (!ttProjectHelper::getProjectByName($cl_name)) { + if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( 'team_id' => $user->team_id, 'name' => $cl_name, @@ -86,7 +86,7 @@ if ($request->getMethod() == 'POST') { } else $errors->add($i18n->getKey('error.project_exists')); } -} // post +} // POST $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.projectForm.project_name.focus()"'); diff --git a/project_delete.php b/project_delete.php index f9f388c9..68c51b82 100644 --- a/project_delete.php +++ b/project_delete.php @@ -47,7 +47,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getK if ($request->getMethod() == 'POST') { if ($request->getParameter('btn_delete')) { - if(ttProjectHelper::get($cl_project_id)) { + if(ttProjectHelper::get($cl_project_id)) { if (ttProjectHelper::delete($cl_project_id)) { header('Location: projects.php'); exit(); @@ -56,11 +56,11 @@ if ($request->getMethod() == 'POST') { } else $errors->add($i18n->getKey('error.db')); } else if ($request->getParameter('btn_cancel')) { - header('Location: projects.php'); - exit(); + header('Location: projects.php'); + exit(); } -} // post - +} // POST + $smarty->assign('project_to_delete', $project_to_delete); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.projectDeleteForm.btn_cancel.focus()"'); diff --git a/project_edit.php b/project_edit.php index d43b6a86..10d142f7 100644 --- a/project_edit.php +++ b/project_edit.php @@ -58,7 +58,7 @@ if ($request->getMethod() == 'POST') { $cl_name = $project['name']; $cl_description = $project['description']; $cl_status = $project['status']; - + $mdb2 = getConnection(); $sql = "select user_id from tt_user_project_binds where status = 1 and project_id = $cl_project_id"; $res = $mdb2->query($sql); @@ -66,7 +66,7 @@ if ($request->getMethod() == 'POST') { die($res->getMessage()); while ($row = $res->fetchRow()) $cl_users[] = $row['user_id']; - + $cl_tasks = explode(',', $project['tasks']); } @@ -81,12 +81,12 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $form->addInput(array('type'=>'checkboxgroup','name'=>'tasks','data'=>$all_tasks,'layout'=>'H','value'=>$cl_tasks)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save'))); $form->addInput(array('type'=>'submit','name'=>'btn_copy','value'=>$i18n->getKey('button.copy'))); - + if ($request->getMethod() == 'POST') { // Validate user input. if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name')); if (!ttValidString($cl_description, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.description')); - + if ($errors->isEmpty()) { if ($request->getParameter('btn_save')) { $existing_project = ttProjectHelper::getProjectByName($cl_name); @@ -124,7 +124,7 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.project_exists')); } } -} // post +} // POST $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.projectForm.name.focus()"'); diff --git a/register.php b/register.php index 1b3038fc..23217181 100644 --- a/register.php +++ b/register.php @@ -48,7 +48,7 @@ if ($request->getMethod() == 'POST') { $cl_password1 = $request->getParameter('password1'); $cl_password2 = $request->getParameter('password2'); $cl_manager_email = trim($request->getParameter('manager_email')); -} else +} else $cl_currency = CURRENCY_DEFAULT; $form = new Form('profileForm'); @@ -78,14 +78,14 @@ if ($request->getMethod() == 'POST') { // Create a new team. $team_id = ttTeamHelper::insert(array('name'=>$cl_team_name,'currency'=>$cl_currency)); if ($team_id) { - // Team created, now create a team manager. - $user_id = ttUserHelper::insert(array( - 'team_id' => $team_id, - 'role' => ROLE_MANAGER, + // Team created, now create a team manager. + $user_id = ttUserHelper::insert(array( + 'team_id' => $team_id, + 'role' => ROLE_MANAGER, 'name' => $cl_manager_name, 'login' => $cl_manager_login, 'password' => $cl_password1, - 'email' => $cl_manager_email)); + 'email' => $cl_manager_email)); } if ($team_id && $user_id) { if ($auth->doLogin($cl_manager_login, $cl_password1)) { @@ -100,7 +100,7 @@ if ($request->getMethod() == 'POST') { } else $errors->add($i18n->getKey('error.user_exists')); } -} +} // POST $smarty->assign('title', $i18n->getKey('title.create_team')); $smarty->assign('forms', array($form->getName()=>$form->toArray())); diff --git a/report.php b/report.php index 6e68c179..775a5dd8 100644 --- a/report.php +++ b/report.php @@ -66,21 +66,21 @@ if ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->g if ($request->getMethod() == 'POST') { foreach($_POST as $key => $val) { - if ('log_id_' == substr($key, 0, 7)) - $time_log_ids[] = substr($key, 7); + if ('log_id_' == substr($key, 0, 7)) + $time_log_ids[] = substr($key, 7); if ('item_id_' == substr($key, 0, 8)) - $expense_item_ids[] = substr($key, 8); - if ('recent_invoice' == $key) - $invoice_id = $val; + $expense_item_ids[] = substr($key, 8); + if ('recent_invoice' == $key) + $invoice_id = $val; } if ($time_log_ids || $expense_item_ids) { - // Some records are checked for invoice editing... Adjust their invoice accordingly. - ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids); + // Some records are checked for invoice editing. Adjust their invoice accordingly. + ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids); } // Re-display this form. header('Location: report.php'); exit(); -} // post +} // POST $group_by = $bean->getAttribute('group_by'); diff --git a/report_send.php b/report_send.php index ce698e3c..d8a0690d 100644 --- a/report_send.php +++ b/report_send.php @@ -64,17 +64,17 @@ if ($request->getMethod() == 'POST') { if (!ttValidEmailList($cl_cc, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.cc')); if (!ttValidString($cl_subject)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.subject')); if (!ttValidString($cl_comment, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.comment')); - + if ($errors->isEmpty()) { // Save last report emails for future use. $sc->setValue(SYSC_LAST_REPORT_EMAIL, $cl_receiver); - $sc->setValue(SYSC_LAST_REPORT_CC, $cl_cc); - - // Obtain session bean with report attributes. - $bean = new ActionForm('reportBean', new Form('reportForm')); - // Prepare report body. - $body = ttReportHelper::prepareReportBody($bean, $cl_comment); - + $sc->setValue(SYSC_LAST_REPORT_CC, $cl_cc); + + // Obtain session bean with report attributes. + $bean = new ActionForm('reportBean', new Form('reportForm')); + // Prepare report body. + $body = ttReportHelper::prepareReportBody($bean, $cl_comment); + import('mail.Mailer'); $mailer = new Mailer(); $mailer->setCharSet(CHARSET); diff --git a/reports.php b/reports.php index 03dbb9be..c22bf25c 100644 --- a/reports.php +++ b/reports.php @@ -59,8 +59,7 @@ $form->addInput(array('type'=>'combobox', 'style'=>'width: 250px;', 'data'=>$report_list, 'datakeys'=>array('id','name'), - 'empty'=>array('-1'=>$i18n->getKey('dropdown.no')) -)); + 'empty'=>array('-1'=>$i18n->getKey('dropdown.no')))); $form->addInput(array('type'=>'hidden','name'=>'fav_report_changed')); // Generate and Delete buttons. $form->addInput(array('type'=>'submit','name'=>'btn_generate','value'=>$i18n->getKey('button.generate'))); @@ -77,8 +76,7 @@ if (in_array('cl', explode(',', $user->plugins)) && !($user->isClient() && $user 'style'=>'width: 250px;', 'data'=>$client_list, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.all')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.all')))); } // If we have a TYPE_DROPDOWN custom field - add control to select an option. @@ -87,8 +85,7 @@ if ($custom_fields && $custom_fields->fields[0] && $custom_fields->fields[0]['ty 'style'=>'width: 250px;', 'value'=>$cl_cf_1, 'data'=>$custom_fields->options, - 'empty'=>array(''=>$i18n->getKey('dropdown.all')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.all')))); } // Add controls for projects and tasks. @@ -105,8 +102,7 @@ $form->addInput(array('type'=>'combobox', 'style'=>'width: 250px;', 'data'=>$project_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.all')) -)); + 'empty'=>array(''=>$i18n->getKey('dropdown.all')))); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { $task_list = ttTeamHelper::getActiveTasks($user->team_id); $form->addInput(array('type'=>'combobox', @@ -114,29 +110,26 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { 'style'=>'width: 250px;', 'data'=>$task_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.all')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.all')))); } -// Add include records control. +// Add include records control. $include_options = array('1'=>$i18n->getKey('form.reports.include_billable'), '2'=>$i18n->getKey('form.reports.include_not_billable')); $form->addInput(array('type'=>'combobox', 'name'=>'include_records', 'style'=>'width: 250px;', 'data'=>$include_options, - 'empty'=>array(''=>$i18n->getKey('dropdown.all')) -)); + 'empty'=>array(''=>$i18n->getKey('dropdown.all')))); -// Add invoiced / not invoiced selector. +// Add invoiced / not invoiced selector. $invoice_options = array('1'=>$i18n->getKey('form.reports.include_invoiced'), '2'=>$i18n->getKey('form.reports.include_not_invoiced')); $form->addInput(array('type'=>'combobox', 'name'=>'invoice', 'style'=>'width: 250px;', 'data'=>$invoice_options, - 'empty'=>array(''=>$i18n->getKey('dropdown.all')) -)); + 'empty'=>array(''=>$i18n->getKey('dropdown.all')))); $user_list = array(); if ($user->canManageTeam() || $user->isClient()) { @@ -161,8 +154,7 @@ if ($user->canManageTeam() || $user->isClient()) { 'data'=>$user_list, 'layout'=>'V', 'groupin'=>$row_count, - 'style'=>'width: 100%;' - )); + 'style'=>'width: 100%;')); } // Add control for time period. @@ -173,17 +165,16 @@ $form->addInput(array('type'=>'combobox', INTERVAL_LAST_MONTH=>$i18n->getKey('dropdown.last_month'), INTERVAL_THIS_WEEK=>$i18n->getKey('dropdown.this_week'), INTERVAL_LAST_WEEK=>$i18n->getKey('dropdown.last_week')), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) -)); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Add controls for start and end dates. $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 (in_array('cl', explode(',', $user->plugins))) - $form->addInput(array('type'=>'checkbox','name'=>'chclient','data'=>1)); + $form->addInput(array('type'=>'checkbox','name'=>'chclient','data'=>1)); if (($user->canManageTeam() || $user->isClient()) && in_array('iv', explode(',', $user->plugins))) - $form->addInput(array('type'=>'checkbox','name'=>'chinvoice','data'=>1)); + $form->addInput(array('type'=>'checkbox','name'=>'chinvoice','data'=>1)); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $form->addInput(array('type'=>'checkbox','name'=>'chproject','data'=>1)); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) @@ -206,7 +197,7 @@ $group_by_options['date'] = $i18n->getKey('form.reports.group_by_date'); if ($user->canManageTeam() || $user->isClient()) $group_by_options['user'] = $i18n->getKey('form.reports.group_by_user'); if (in_array('cl', explode(',', $user->plugins)) && !($user->isClient() && $user->client_id)) - $group_by_options['client'] = $i18n->getKey('form.reports.group_by_client'); + $group_by_options['client'] = $i18n->getKey('form.reports.group_by_client'); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $group_by_options['project'] = $i18n->getKey('form.reports.group_by_project'); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) @@ -221,12 +212,12 @@ $form->addInput(array('type'=>'checkbox','name'=>'chtotalsonly','data'=>1)); $form->addInput(array('type'=>'text','name'=>'new_fav_report','maxlength'=>'30','style'=>'width: 250px;')); // Save button. $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save'))); - + $form->addInput(array('type'=>'submit','name'=>'btn_generate','value'=>$i18n->getKey('button.generate'))); // Create a bean (which is a mechanism to remember form values in session). $bean = new ActionForm('reportBean', $form, $request); -// At this point form values are obtained from session if they are there... +// At this point form values are obtained from session if they are there. if (($request->getMethod() == 'GET') && !$bean->isSaved()) { // No previous form data were found in session. Use the following default values. @@ -239,7 +230,7 @@ if (($request->getMethod() == 'GET') && !$bean->isSaved()) { $form->setValueByElement('chproject', 1); $form->setValueByElement('chstart', 1); $form->setValueByElement('chduration', 1); - $form->setValueByElement('chcost', 0); + $form->setValueByElement('chcost', 0); $form->setValueByElement('chtask', 1); $form->setValueByElement('chfinish', 1); $form->setValueByElement('chnote', 1); @@ -259,20 +250,20 @@ if ($request->getMethod() == 'POST') { if ($bean->getAttribute('favorite_report')) { // This loads new favorite report options into the bean (into our form). ttFavReportHelper::loadReport($user->id, $bean); - + // If user selected no favorite report - mark all user checkboxes (most probable scenario). if ($bean->getAttribute('favorite_report') == -1) $form->setValueByElement('users', array_keys($user_list)); - + // Save form data in session for future use. $bean->saveBean(); header('Location: reports.php'); - exit(); - } + exit(); + } } elseif ($bean->getAttribute('btn_save')) { - // User clicked the Save button. We need to save form options as new favorite report. - if (!ttValidString($bean->getAttribute('new_fav_report'))) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.reports.save_as_favorite')); - + // User clicked the Save button. We need to save form options as new favorite report. + if (!ttValidString($bean->getAttribute('new_fav_report'))) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.reports.save_as_favorite')); + if ($errors->isEmpty()) { $id = ttFavReportHelper::saveReport($user->id, $bean); if (!$id) @@ -295,33 +286,33 @@ if ($request->getMethod() == 'POST') { $form->setValueByElement('users', array_keys($user_list)); $bean->saveBean(); header('Location: reports.php'); - exit(); - } + exit(); + } } else { // Generate button pressed. Check some values. if (!$bean->getAttribute('period')) { $start_date = new DateAndTime($user->date_format, $bean->getAttribute('start_date')); - + if ($start_date->isError() || !$bean->getAttribute('start_date')) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.start_date')); - + $end_date = new DateAndTime($user->date_format, $bean->getAttribute('end_date')); if ($end_date->isError() || !$bean->getAttribute('end_date')) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.end_date')); - + if ($start_date->compare($end_date) > 0) $errors->add($i18n->getKey('error.interval'), $i18n->getKey('label.end_date'), $i18n->getKey('label.start_date')); } - + $bean->saveBean(); - + if ($errors->isEmpty()) { // Now we can go ahead and create a report. header('Location: report.php'); exit(); } } -} +} // POST $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); -- 2.20.1