]> wagnertech.de Git - timetracker.git/blobdiff - week.php
More progress on week view. Implemented adding records to existing rows without custo...
[timetracker.git] / week.php
index a015e85dd028d6ac08ba91e1601b03c3f96b63b3..34efd56e5d1afe98007c2081dc18846f27e676c0 100644 (file)
--- a/week.php
+++ b/week.php
@@ -146,6 +146,12 @@ class TimeCellRenderer extends DefaultCellRenderer {
     $field->setFormName($table->getFormName());
     $field->setSize(2);
     $field->setValue($table->getValueAt($row,$column)['duration']);
+    // Disable control when time entry mode is TYPE_START_FINISH and there is no value in control
+    // because we can't supply start and finish times in week view - there are no fields for them.
+    global $user;
+    if (!$field->getValue() && TYPE_START_FINISH == $user->record_type) {
+        $field->setEnabled(false);
+    }
     $this->setValue($field->getHtml());
     return $this->toString();
   }
@@ -266,7 +272,7 @@ $form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 600px;
 $form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date)); // calendar
 if ($user->isPluginEnabled('iv'))
   $form->addInput(array('type'=>'checkbox','name'=>'billable','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'=>'hidden','name'=>'browser_today','value'=>'get_date()')); // 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.
@@ -383,11 +389,12 @@ if ($request->isPost()) {
         if ($existingDuration == null) {
           // Insert a new record here.
           $fields = array();
+          $fields['row_id'] = $dataArray[$rowNumber]['row_id'];
+          $fields['day_header'] = $dayHeader;
+          $fields['start_date'] = $startDate->toString(DB_DATEFORMAT); // To be able to determine date for the entry using $dayHeader.
+          $fields['duration'] = $postedDuration;
+          $fields['browser_today'] = $request->getParameter('browser_today', null);
           $result = ttTimeHelper::insertDurationFromWeekView($fields, $err);
-            //$dataArray[$rowNumber]['row_id'],
-            //$dayHeader,
-            //$postedDuration,
-            //$startDate->toString(DB_DATEFORMAT));
         } elseif ($postedDuration == null || 0 == ttTimeHelper::toMinutes($postedDuration)) {
           // Delete an already existing record here.
           $result = ttTimeHelper::delete($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $user->getActiveUser());