$this->name = $name;
}
- // TODO: refactoring ongoing down from here.
- function getHtml() {
- if (!$this->isEnabled()) {
- $html = "<input name=\"$this->name\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n";
- } else {
-
- if ($this->id=="") $this->id = $this->name;
-
- $html = "\n\t<input type=\"text\"";
- $html .= " name=\"$this->name\" id=\"$this->id\"";
-
- if ($this->size!="")
- $html .= " size=\"$this->size\"";
-
- if ($this->style!="")
- $html .= " style=\"$this->style\"";
-
- if ($this->max_length!="")
- $html .= " maxlength=\"$this->max_length\"";
-
- if ($this->on_change!="")
- $html .= " onchange=\"$this->on_change\"";
+ function getHtml() {
+ if (empty($this->id)) $this->id = $this->name;
+ $html = "\n\t<input type=\"text\"";
+ $html .= " id=\"$this->id\" name=\"$this->name\"";
+ if (!empty($this->size)) $html .= " size=\"$this->size\"";
+ if (!empty($this->style)) $html .= " style=\"$this->style\"";
- $html .= " value=\"".htmlspecialchars($this->getValue())."\"";
- $html .= ">";
- }
-
- return $html;
- }
+ if($this->isEnabled()) {
+ if (!empty($this->max_length)) $html .= " maxlength=\"$this->max_length\"";
+ if (!empty($this->on_change)) $html .= " onchange=\"$this->on_change\"";
+ }
+
+ $html .= " value=\"".htmlspecialchars($this->getValue())."\"";
+
+ if(!$this->isEnabled()) $html .= " readonly";
+ $html .= ">\n";
+ return $html;
+ }
}
// array( // Row 0.
// 'row_id' => 'cl:546,bl:1,pr:23456,ts:27464,cf_1:7623_0', // Row identifier. See ttTimeHelper::makeRecordIdentifier().
// 'label' => 'Anuko - Time Tracker - Coding', // Human readable label for the row describing what this time entry is for.
- // 'day_0' => array('control_id' => '0_day_0', 'duration' => '00:00'), // control_id is row_id plus day header for column.
- // 'day_1' => array('control_id' => '0_day_1', 'duration' => '01:00'),
- // 'day_2' => array('control_id' => '0_day_2', 'duration' => '02:00'),
- // 'day_3' => array('control_id' => '0_day_3', 'duration' => null),
- // 'day_4' => array('control_id' => '0_day_4', 'duration' => '04:00'),
- // 'day_5' => array('control_id' => '0_day_5', 'duration' => '04:00'),
- // 'day_6' => array('control_id' => '0_day_6', 'duration' => null)
+ // 'day_0' => array('control_id' => '0_day_0', 'tt_log_id' => 12345, 'duration' => '00:00'), // control_id is row_id plus day header for column.
+ // 'day_1' => array('control_id' => '0_day_1', 'tt_log_id' => 12346, 'duration' => '01:00'),
+ // 'day_2' => array('control_id' => '0_day_2', 'tt_log_id' => 12347, 'duration' => '02:00'),
+ // 'day_3' => array('control_id' => '0_day_3', 'tt_log_id' => null, 'duration' => null),
+ // 'day_4' => array('control_id' => '0_day_4', 'tt_log_id' => 12348, 'duration' => '04:00'),
+ // 'day_5' => array('control_id' => '0_day_5', 'tt_log_id' => 12349, 'duration' => '04:00'),
+ // 'day_6' => array('control_id' => '0_day_6', 'tt_log_id' => null, 'duration' => null)
// ),
// array( // Row 1.
// 'row_id' => 'bl:0_0',
// 'label' => '', // In this case the label is empty as we don't have anything to put into it, as we only have billable flag.
- // 'day_0' => array('control_id' => '1_day_0', 'duration' => null),
- // 'day_1' => array('control_id' => '1_day_1', 'duration' => '01:30'),
- // 'day_2' => array('control_id' => '1_day_2', 'duration' => null),
- // 'day_3' => array('control_id' => '1_day_3', 'duration' => '02:30'),
- // 'day_4' => array('control_id' => '1_day_4', 'duration' => '04:00'),
- // 'day_5' => array('control_id' => '1_day_5', 'duration' => null),
- // 'day_6' => array('control_id' => '1_day_6', 'duration' => null)
+ // 'day_0' => array('control_id' => '1_day_0', 'tt_log_id' => null, 'duration' => null),
+ // 'day_1' => array('control_id' => '1_day_1', 'tt_log_id' => 12350, 'duration' => '01:30'),
+ // 'day_2' => array('control_id' => '1_day_2', 'tt_log_id' => null, 'duration' => null),
+ // 'day_3' => array('control_id' => '1_day_3', 'tt_log_id' => 12351,'duration' => '02:30'),
+ // 'day_4' => array('control_id' => '1_day_4', 'tt_log_id' => 12352, 'duration' => '04:00'),
+ // 'day_5' => array('control_id' => '1_day_5', 'tt_log_id' => null, 'duration' => null),
+ // 'day_6' => array('control_id' => '1_day_6', 'tt_log_id' => null, 'duration' => null)
// )
// );
static function getDataForWeekView($user_id, $start_date, $end_date, $dayHeaders) {
return $dayHeaders;
}
+ // getLockedDaysForWeek - builds an arrays of locked days in week.
+ static function getLockedDaysForWeek($start_date) {
+ global $user;
+ $lockedDays = array();
+ $objDate = new DateAndTime(DB_DATEFORMAT, $start_date);
+ $lockedDays[] = $user->isDateLocked($objDate);
+ $objDate->incDay();
+ $lockedDays[] = $user->isDateLocked($objDate);
+ $objDate->incDay();
+ $lockedDays[] = $user->isDateLocked($objDate);
+ $objDate->incDay();
+ $lockedDays[] = $user->isDateLocked($objDate);
+ $objDate->incDay();
+ $lockedDays[] = $user->isDateLocked($objDate);
+ $objDate->incDay();
+ $lockedDays[] = $user->isDateLocked($objDate);
+ $objDate->incDay();
+ $lockedDays[] = $user->isDateLocked($objDate);
+ unset($objDate);
+ return $lockedDays;
+ }
+
// getDayTotals calculates total durations for each day from the existing data in $dataArray.
static function getDayTotals($dataArray, $dayHeaders) {
$dayTotals = array();
// Get the data we need to display week view.
// Get column headers, which are day numbers in month.
$dayHeaders = ttTimeHelper::getDayHeadersForWeek($startDate->toString(DB_DATEFORMAT));
+$lockedDays = ttTimeHelper::getLockedDaysForWeek($startDate->toString(DB_DATEFORMAT));
// Build data array for the table. Format is described in the function..
$dataArray = ttTimeHelper::getDataForWeekView($user->getActiveUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT), $dayHeaders);
// Build day totals (total durations for each day in week).
// TODO: refactoring ongoing down from here.
-// 1) Start coding modification of existing records.
-// 2) Then adding new records for existing rows.
-// 3) Then add code and UI for adding a new row.
+// 1) Handle editable - not editable records properly meaning that UI should reflect this.
+// 2) Start coding modification of existing records.
+// 3) Then adding new records for existing rows.
+// 4) Then add code and UI for adding a new row.
// Actually this is work in progress at this point, even documenting the array, as we still miss control IDs, and
// editing entries is not yet implemented. When this is done, we will have to re-document the above.
function render(&$table, $value, $row, $column, $selected = false) {
$field_name = $table->getValueAt($row,$column)['control_id']; // Our text field names (and ids) are like x_y (row_column).
$field = new TextField($field_name);
+ // Disable control if the date is locked.
+ global $lockedDays;
+ if ($lockedDays[$column-1])
+ $field->setEnabled(false);
$field->setFormName($table->getFormName());
$field->setSize(2);
$field->setValue($table->getValueAt($row,$column)['duration']);