From: Nik Okuntseff Date: Mon, 21 Mar 2016 22:43:25 +0000 (-0700) Subject: Refactoring white space X-Git-Tag: timetracker_1.19-1~1801 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3705caa8680d82736ab1a1d21e8829bed1226341;p=timetracker.git Refactoring white space --- diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 1b8f4dc8..67cb9391 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.9.16.3428 | Copyright © Anuko | +  Anuko Time Tracker 1.9.16.3429 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/access_denied.php b/mobile/access_denied.php index 1454fae3..5325a342 100644 --- a/mobile/access_denied.php +++ b/mobile/access_denied.php @@ -28,7 +28,7 @@ require_once('../initialize.php'); -$errors->add($i18n->getKey('error.access_denied')); +$errors->add($i18n->getKey('error.access_denied')); if ($auth->isAuthenticated()) $GLOBALS['SMARTY']->assign('authenticated', true); // Used in header.tpl for menu display. $smarty->assign('title', $i18n->getKey('label.error')); diff --git a/mobile/index.php b/mobile/index.php index de48595c..a2836654 100644 --- a/mobile/index.php +++ b/mobile/index.php @@ -36,7 +36,7 @@ if ($auth->isAuthenticated()) { } else if ($user->isClient()) { header('Location: ../reports.php'); - exit(); + exit(); } } // Redirect to time.php or mobile/time.php for other roles. diff --git a/mobile/login.php b/mobile/login.php index 180f0115..d92ff5b3 100644 --- a/mobile/login.php +++ b/mobile/login.php @@ -48,13 +48,13 @@ if ($request->getMethod() == 'POST') { // Validate user input. if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); if (!ttValidString($cl_password)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password')); - + if ($errors->isEmpty()) { // Use the "limit" plugin if we have one. Ignore include errors. // The "limit" plugin is not required for normal operation of the Time Tracker. @include('../plugins/limit/access_check.php'); - + if ($auth->doLogin($cl_login, $cl_password)) { // Set current user date (as determined by user browser) into session. @@ -64,7 +64,7 @@ if ($request->getMethod() == 'POST') { // Remember user login in a cookie. setcookie('tt_login', $cl_login, time() + COOKIE_EXPIRE, '/'); - + $user = new ttUser(null, $auth->getUserId()); // Redirect, depending on user role. if ($user->isAdmin()) { @@ -73,7 +73,7 @@ if ($request->getMethod() == 'POST') { } else if ($user->isClient()) { header('Location: ../reports.php'); - exit(); + exit(); } else { header('Location: time.php'); @@ -82,7 +82,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/mobile/time.php b/mobile/time.php index dda3767c..8d2f7079 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -48,7 +48,7 @@ if($selected_date->isError()) if(!$cl_date) $cl_date = $selected_date->toString(DB_DATEFORMAT); $_SESSION['date'] = $cl_date; - + // Determine previous and next dates for simple navigation. $prev_date = date('Y-m-d', strtotime('-1 day', strtotime($cl_date))); $next_date = date('Y-m-d', strtotime('+1 day', strtotime($cl_date))); @@ -97,8 +97,7 @@ if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plug 'value'=>$cl_client, 'data'=>$active_clients, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Note: in other modes the client list is filtered to relevant clients only. See below. } @@ -112,8 +111,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_project, 'data'=>$project_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. if (in_array('cl', explode(',', $user->plugins))) { @@ -140,8 +138,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_client, 'data'=>$client_list, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } } @@ -153,8 +150,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { 'value'=>$cl_task, 'data'=>$task_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');")); @@ -163,7 +159,7 @@ if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READONLY_START_FINISH)) { // Make the start and finish fields read-only. $form->getElement('start')->setEnable(false); - $form->getElement('finish')->setEnable(false); + $form->getElement('finish')->setEnable(false); } if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) $form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');")); @@ -172,19 +168,18 @@ if (in_array('iv', explode(',', $user->plugins))) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_submit click. $form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.submit'))); - + // If we have custom fields - add controls for them. if ($custom_fields && $custom_fields->fields[0]) { // Only one custom field is supported at this time. if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) { - $form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1)); + $form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1)); } else if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) { $form->addInput(array('type'=>'combobox','name'=>'cf_1', 'style'=>'width: 250px;', 'value'=>$cl_cf_1, 'data'=>$custom_fields->options, - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } } @@ -225,10 +220,10 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.interval'), $i18n->getKey('label.finish'), $i18n->getKey('label.start')); } } else { - if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { + if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { $errors->add($i18n->getKey('error.empty'), $i18n->getKey('label.start')); $errors->add($i18n->getKey('error.empty'), $i18n->getKey('label.finish')); - } + } if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) $errors->add($i18n->getKey('error.empty'), $i18n->getKey('label.duration')); } @@ -238,30 +233,30 @@ if ($request->getMethod() == 'POST') { } if (!ttValidString($cl_note, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.note')); // Finished validating user input. - + // Prohibit creating entries in future. if (defined('FUTURE_ENTRIES') && !isTrue(FUTURE_ENTRIES)) { $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null)); if ($selected_date->after($browser_today)) $errors->add($i18n->getKey('error.future_date')); } - + // Prohibit creating time entries in locked interval. if($lockdate && $selected_date->before($lockdate)) $errors->add($i18n->getKey('error.period_locked')); - + // Prohibit creating another uncompleted record. if ($errors->isEmpty()) { if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getActiveUser())) && (($cl_finish == '') && ($cl_duration == ''))) $errors->add($i18n->getKey('error.uncompleted_exists')." ".$i18n->getKey('error.goto_uncompleted').""); } - + // Prohibit creating an overlapping record. if ($errors->isEmpty()) { if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish)) $errors->add($i18n->getKey('error.overlap')); - } - + } + if ($errors->isEmpty()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, @@ -274,7 +269,7 @@ if ($request->getMethod() == 'POST') { 'duration' => $cl_duration, 'note' => $cl_note, 'billable' => $cl_billable)); - + // Insert a custom field if we have it. $result = true; if ($id && $custom_fields && $cl_cf_1) { @@ -291,7 +286,7 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.db')); } } -} +} // POST $smarty->assign('next_date', $next_date); $smarty->assign('prev_date', $prev_date); @@ -306,4 +301,3 @@ $smarty->assign('timestring', $selected_date->toString($user->date_format)); $smarty->assign('title', $i18n->getKey('title.time')); $smarty->assign('content_page_name', 'mobile/time.tpl'); $smarty->display('mobile/index.tpl'); -?> \ No newline at end of file diff --git a/mobile/time_delete.php b/mobile/time_delete.php index ef955e9a..be9d498c 100644 --- a/mobile/time_delete.php +++ b/mobile/time_delete.php @@ -49,13 +49,13 @@ $time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser()); // Prohibit deleting invoiced records. if ($time_rec['invoice_id']) die($i18n->getKey('error.sys')); - + // Escape comment for presentation. $time_rec['comment'] = htmlspecialchars($time_rec['comment']); - + if ($request->getMethod() == 'POST') { if ($request->getParameter('delete_button')) { // Delete button pressed. - + // Determine if it's okay to delete the record. $item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']); @@ -68,13 +68,13 @@ if ($request->getMethod() == 'POST') { } // Determine if the record is uncompleted. $uncompleted = ($time_rec['duration'] == '0:00'); - + if($lockdate && $item_date->before($lockdate) && !$uncompleted) { $errors->add($i18n->getKey('error.period_locked')); } - + if ($errors->isEmpty()) { - + // Delete the record. $result = ttTimeHelper::delete($cl_id, $user->getActiveUser()); @@ -87,11 +87,11 @@ if ($request->getMethod() == 'POST') { } } if ($request->getParameter('cancel_button')) { // Cancel button pressed. - header('Location: time.php'); - exit(); + header('Location: time.php'); + exit(); } -} - +} // POST + $form = new Form('timeRecordForm'); $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id)); $form->addInput(array('type'=>'submit','name'=>'delete_button','value'=>$i18n->getKey('label.delete'))); diff --git a/mobile/time_edit.php b/mobile/time_edit.php index b961d1f7..d6dc7d1e 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -56,7 +56,7 @@ $time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser()); if ($time_rec['invoice_id']) die($i18n->getKey('error.sys')); $item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']); - + // Initialize variables. $cl_start = $cl_finish = $cl_duration = $cl_date = $cl_note = $cl_project = $cl_task = $cl_billable = null; if ($request->getMethod() == 'POST') { @@ -79,21 +79,21 @@ if ($request->getMethod() == 'POST') { $cl_start = $time_rec['start']; $cl_finish = $time_rec['finish']; $cl_duration = $time_rec['duration']; - $cl_date = $item_date->toString($user->date_format); + $cl_date = $item_date->toString($user->date_format); $cl_note = $time_rec['comment']; - + // If we have custom fields - obtain values for them. if ($custom_fields) { // Get custom field value for time record. - $fields = $custom_fields->get($time_rec['id']); - if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) + $fields = $custom_fields->get($time_rec['id']); + if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) $cl_cf_1 = $fields[0]['value']; else if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) $cl_cf_1 = $fields[0]['option_id']; } - + $cl_billable = $time_rec['billable']; - + // Add an info message to the form if we are editing an uncompleted record. if (($cl_start == $cl_finish) && ($cl_duration == '0:00')) { $cl_finish = ''; @@ -101,7 +101,7 @@ if ($request->getMethod() == 'POST') { $messages->add($i18n->getKey('form.time_edit.uncompleted')); } } - + // Initialize elements of 'timeRecordForm'. $form = new Form('timeRecordForm'); @@ -115,8 +115,7 @@ if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plug 'value'=>$cl_client, 'data'=>$active_clients, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Note: in other modes the client list is filtered to relevant clients only. See below. } @@ -130,13 +129,12 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_project, 'data'=>$project_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. if (in_array('cl', explode(',', $user->plugins))) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); - // We need an array of assigned project ids to do some trimming. + // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -158,8 +156,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_client, 'data'=>$client_list, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } } @@ -171,10 +168,9 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { 'value'=>$cl_task, 'data'=>$task_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } - + // Add other controls. if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');")); @@ -183,7 +179,7 @@ if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READONLY_START_FINISH)) { // Make the start and finish fields read-only. $form->getElement('start')->setEnable(false); - $form->getElement('finish')->setEnable(false); + $form->getElement('finish')->setEnable(false); } if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) $form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');")); @@ -193,15 +189,14 @@ $form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 250px; if ($custom_fields && $custom_fields->fields[0]) { // Only one custom field is supported at this time. if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) { - $form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1)); + $form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1)); } else if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) { $form->addInput(array('type'=>'combobox', 'name'=>'cf_1', 'style'=>'width: 250px;', 'value'=>$cl_cf_1, 'data'=>$custom_fields->options, - 'empty' => array('' => $i18n->getKey('dropdown.select')) - )); + 'empty' => array('' => $i18n->getKey('dropdown.select')))); } } // Hidden control for record id. @@ -221,7 +216,7 @@ if ($request->getMethod() == 'POST') { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $errors->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); } if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - if (!$cl_project) $errors->add($i18n->getKey('error.project')); + if (!$cl_project) $errors->add($i18n->getKey('error.project')); } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { if (!$cl_task) $errors->add($i18n->getKey('error.task')); @@ -253,7 +248,7 @@ if ($request->getMethod() == 'POST') { if (!ttValidDate($cl_date)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.date')); if (!ttValidString($cl_note, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.note')); // Finished validating user input. - + // Determine lock date. $lock_interval = $user->lock_interval; $lockdate = 0; @@ -264,7 +259,7 @@ if ($request->getMethod() == 'POST') { // This is a new date for the time record. $new_date = new DateAndTime($user->date_format, $cl_date); - + // Prohibit creating entries in future. if (defined('FUTURE_ENTRIES') && !isTrue(FUTURE_ENTRIES)) { $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null)); @@ -278,15 +273,15 @@ if ($request->getMethod() == 'POST') { // 1) Prohibit saving locked time entries in any form. // 2) Prohibit saving completed unlocked entries into locked interval. // 3) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists. - + // Now, step by step. if ($errors->isEmpty()) { // 1) Prohibit saving locked time entries in any form. if($lockdate && $item_date->before($lockdate)) - $errors->add($i18n->getKey('error.period_locked')); + $errors->add($i18n->getKey('error.period_locked')); // 2) Prohibit saving completed unlocked entries into locked interval. if($errors->isEmpty() && $lockdate && $new_date->before($lockdate)) - $errors->add($i18n->getKey('error.period_locked')); + $errors->add($i18n->getKey('error.period_locked')); // 3) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists. $uncompleted = ($cl_finish == '' && $cl_duration == ''); if ($uncompleted) { @@ -297,7 +292,7 @@ if ($request->getMethod() == 'POST') { } } } - + // Prohibit creating an overlapping record. if ($errors->isEmpty()) { if (ttTimeHelper::overlaps($user->getActiveUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id)) @@ -318,7 +313,7 @@ if ($request->getMethod() == 'POST') { 'duration'=>$cl_duration, 'note'=>$cl_note, 'billable'=>$cl_billable)); - + // If we have custom fields - update values. if ($res && $custom_fields) { if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) @@ -333,12 +328,12 @@ if ($request->getMethod() == 'POST') { } } } - + if ($request->getParameter('btn_delete')) { header("Location: time_delete.php?id=$cl_id"); exit(); } -} // End of if ($request->getMethod() == 'POST') +} // POST $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); @@ -348,4 +343,3 @@ $smarty->assign('onload', 'onLoad="fillDropdowns()"'); $smarty->assign('title', $i18n->getKey('title.edit_time_record')); $smarty->assign('content_page_name', 'mobile/time_edit.tpl'); $smarty->display('mobile/index.tpl'); -?> \ No newline at end of file diff --git a/mobile/timer.php b/mobile/timer.php index 63bf258d..fa00ced2 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -49,7 +49,7 @@ if(!$cl_date) $cl_date = $selected_date->toString(DB_DATEFORMAT); $_SESSION['date'] = $cl_date; // TODO: for time page we may limit the day to today only. - + // Use custom fields plugin if it is enabled. if (in_array('cf', explode(',', $user->plugins))) { require_once('../plugins/CustomFields.class.php'); @@ -97,8 +97,7 @@ if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plug 'value'=>$cl_client, 'data'=>$active_clients, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Note: in other modes the client list is filtered to relevant clients only. See below. } @@ -113,8 +112,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_project, 'data'=>$project_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. if (in_array('cl', explode(',', $user->plugins))) { @@ -126,12 +124,12 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Build a client list out of active clients. Use only clients that are relevant to user. // Also trim their associated project list to only assigned projects (to user). foreach($active_clients as $client) { - $projects_assigned_to_client = explode(',', $client['projects']); - $intersection = array_intersect($projects_assigned_to_client, $projects_assigned_to_user); - if ($intersection) { - $client['projects'] = implode(',', $intersection); - $client_list[] = $client; - } + $projects_assigned_to_client = explode(',', $client['projects']); + $intersection = array_intersect($projects_assigned_to_client, $projects_assigned_to_user); + if ($intersection) { + $client['projects'] = implode(',', $intersection); + $client_list[] = $client; + } } $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -141,8 +139,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_client, 'data'=>$client_list, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } } @@ -155,20 +152,18 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { 'value'=>$cl_task, 'data'=>$task_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) - )); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } if (in_array('iv', explode(',', $user->plugins))) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable,'enable'=>$enable_controls)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click. $form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>'')); // User current time, which gets filled in on button click. $enable_start = $uncompleted ? false : true; -$enable_stop = $uncompleted ? true : false; if (!$uncompleted) $form->addInput(array('type'=>'submit','name'=>'btn_start','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.start'),'enable'=>$enable_start)); else - $form->addInput(array('type'=>'submit','name'=>'btn_stop','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.finish'),'enable'=>$enable_stop)); - + $form->addInput(array('type'=>'submit','name'=>'btn_stop','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.finish'),'enable'=>!$enable_start)); + // If we have custom fields - add controls for them. if ($custom_fields && $custom_fields->fields[0]) { // Only one custom field is supported at this time. @@ -184,7 +179,7 @@ if ($custom_fields && $custom_fields->fields[0]) { } } -// Determine lock date. Time entries earlier than lock date cannot be created or modified. +// Determine lock date. Time entries earlier than lock date cannot be created or modified. $lock_interval = $user->lock_interval; $lockdate = 0; if ($lock_interval > 0) { @@ -211,14 +206,14 @@ if ($request->getMethod() == 'POST') { if (!$cl_task) $errors->add($i18n->getKey('error.task')); } // Finished validating user input. - + // Prohibit creating entries in future. if (defined('FUTURE_ENTRIES') && !isTrue(FUTURE_ENTRIES)) { $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null)); if ($selected_date->after($browser_today)) $errors->add($i18n->getKey('error.future_date')); } - + // Prohibit creating time entries in locked interval. if($lockdate && $selected_date->before($lockdate)) $errors->add($i18n->getKey('error.period_locked')); @@ -227,13 +222,13 @@ if ($request->getMethod() == 'POST') { if ($errors->isEmpty() && $uncompleted) { $errors->add($i18n->getKey('error.uncompleted_exists')." ".$i18n->getKey('error.goto_uncompleted').""); } - + // Prohibit creating an overlapping record. if ($errors->isEmpty()) { if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish)) $errors->add($i18n->getKey('error.overlap')); - } - + } + if ($errors->isEmpty()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, @@ -246,7 +241,7 @@ if ($request->getMethod() == 'POST') { 'duration' => $cl_duration, 'note' => $cl_note, 'billable' => $cl_billable)); - + // Insert a custom field if we have it. $result = true; if ($id && $custom_fields && $cl_cf_1) { @@ -271,13 +266,13 @@ if ($request->getMethod() == 'POST') { if (ttTimeHelper::isValidInterval($record['start'], $cl_finish) // finish time is greater than start time && !ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap $res = ttTimeHelper::update(array( - 'id'=>$record['id'], - 'date'=>$cl_date, + 'id'=>$record['id'], + 'date'=>$cl_date, 'user_id'=>$user->getActiveUser(), - 'client'=>$record['client_id'], - 'project'=>$record['project_id'], - 'task'=>$record['task_id'], - 'start'=>$record['start'], + 'client'=>$record['client_id'], + 'project'=>$record['project_id'], + 'task'=>$record['task_id'], + 'start'=>$record['start'], 'finish'=>$cl_finish, 'note'=>$record['comment'], 'billable'=>$record['billable'])); @@ -289,10 +284,10 @@ if ($request->getMethod() == 'POST') { } else { // Cannot complete, redirect for manual edit. header('Location: time_edit.php?id='.$record['id']); - exit(); + exit(); } } -} +} // POST $week_total = ttTimeHelper::getTimeForWeek($user->getActiveUser(), $cl_date); $smarty->assign('week_total', $week_total); @@ -312,4 +307,3 @@ $smarty->assign('timestring', $selected_date->toString($user->date_format)); $smarty->assign('title', $i18n->getKey('title.time')); $smarty->assign('content_page_name', 'mobile/timer.tpl'); $smarty->display('mobile/index.tpl'); -?> \ No newline at end of file