Greek translation improved.
[timetracker.git] / mobile / timer.php
index 949d585..9579031 100644 (file)
@@ -51,7 +51,7 @@ $_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))) {
+if ($user->isPluginEnabled('cf')) {
   require_once('../plugins/CustomFields.class.php');
   $custom_fields = new CustomFields($user->team_id);
   $smarty->assign('custom_fields', $custom_fields);
@@ -61,7 +61,7 @@ if (in_array('cf', explode(',', $user->plugins))) {
 $cl_start = trim($request->getParameter('browser_time'));
 $cl_finish = trim($request->getParameter('browser_time'));
 // Custom field.
-$cl_cf_1 = trim($request->getParameter('cf_1', ($request->getMethod()=='POST'? null : @$_SESSION['cf_1'])));
+$cl_cf_1 = trim($request->getParameter('cf_1', ($request->isPost() ? null : @$_SESSION['cf_1'])));
 $_SESSION['cf_1'] = $cl_cf_1;
 $cl_billable = 1;
 if ($user->isPluginEnabled('iv')) {
@@ -84,7 +84,7 @@ $uncompleted = ttTimeHelper::getUncompleted($user->getActiveUser());
 $enable_controls = ($uncompleted == null);
 
 // Elements of timeRecordForm.
-$form = new Form('timerRecordForm');
+$form = new Form('timeRecordForm');
 
 // Dropdown for clients in MODE_TIME. Use all active clients.
 if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
@@ -155,7 +155,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
     'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
 }
 if ($user->isPluginEnabled('iv'))
-  $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable,'enable'=>$enable_controls));
+  $form->addInput(array('type'=>'checkbox','name'=>'billable','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;
@@ -179,14 +179,6 @@ if ($custom_fields && $custom_fields->fields[0]) {
   }
 }
 
-// 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) {
-  $lockdate = new DateAndTime();
-  $lockdate->decDay($lock_interval);
-}
-
 // Submit.
 if ($request->isPost()) {
   if ($request->getParameter('btn_start')) {
@@ -208,15 +200,15 @@ if ($request->isPost()) {
     // Finished validating user input.
 
     // Prohibit creating entries in future.
-    if (defined('FUTURE_ENTRIES') && !isTrue(FUTURE_ENTRIES)) {
+    if (!$user->future_entries) {
       $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
       if ($selected_date->after($browser_today))
         $err->add($i18n->getKey('error.future_date'));
     }
 
     // Prohibit creating time entries in locked interval.
-    if($lockdate && $selected_date->before($lockdate))
-      $err->add($i18n->getKey('error.period_locked'));
+    if ($user->isDateLocked($selected_date))
+      $err->add($i18n->getKey('error.range_locked'));
 
     // Prohibit creating another uncompleted record.
     if ($err->no() && $uncompleted) {