import('form.TextField');
import('ttUserHelper');
import('ttTeamHelper');
+import('ttWeekViewHelper');
import('ttClientHelper');
import('ttTimeHelper');
import('DateAndTime');
$smarty->assign('custom_fields', $custom_fields);
}
-// TODO: how is this plugin supposed to work for week view?
+// Use Monthly Quotas plugin, if applicable.
if ($user->isPluginEnabled('mq')){
require_once('plugins/MonthlyQuota.class.php');
$quota = new MonthlyQuota();
$_SESSION['project'] = $cl_project;
$cl_task = $request->getParameter('task', ($request->getMethod()=='POST'? null : @$_SESSION['task']));
$_SESSION['task'] = $cl_task;
+$cl_note = trim($request->getParameter('note'));
// Get the data we need to display week view.
// Get column headers, which are day numbers in month.
$this->setOptions(array('style'=>'text-align: center; font-weight: bold;'));
}
// Special handling for not billable entries.
- /* // TODO: this does not work and should be coded properly.
if ($row > 0) {
- $row_id = $table->getValueAt($row,1+$column)['row_id'];
- $billable = ttTimeHelper::parseFromWeekViewRow($row_id, 'bl');
+ $row_id = $table->getValueAtName($row,'row_id');
+ $billable = ttWeekViewHelper::parseFromWeekViewRow($row_id, 'bl');
if (!$billable) {
- $this->setOptions(array('class'=>'not_billable')); // TODO: Should not we add options instead? How does it work exactly?
+ $this->setOptions(array('style'=>'color: red;')); // TODO: style it properly in CSS.
}
- }*/
+ }
$this->setValue(htmlspecialchars($value)); // This escapes HTML for output.
return $this->toString();
}
if ($lockedDays[$column-1])
$field->setEnabled(false);
$field->setFormName($table->getFormName());
- $field->setSize(2);
+ $field->setStyle('width: 60px;'); // TODO: need to style everything properly, eventually.
$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.
}
// Create week_durations table.
-$table = new Table('week_durations');
-// $table->setIAScript('markModified'); // TODO: write a script to mark table or particular cells as modified.
+$table = new Table('week_durations', 'week_view_table');
$table->setTableOptions(array('width'=>'100%','cellspacing'=>'1','cellpadding'=>'3','border'=>'0'));
$table->setRowOptions(array('class'=>'tableHeaderCentered'));
$table->setData($dataArray);
'datakeys'=>array('id','name'),
'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
}
+$form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 250px; height:'.NOTE_INPUT_HEIGHT.'px;','value'=>$cl_note));
// Add other controls.
$form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date)); // calendar
// Process the table of values.
if ($err->no()) {
- // Obtain values. Perhaps, it's best to iterate throigh posted parameters one by one,
- // see if anything changed, and apply one change at a time until we see an error.
+ // Obtain values. Iterate through posted parameters one by one,
+ // see if value changed, apply one change at a time until we see an error.
$result = true;
$rowNumber = 0;
// Iterate through existing rows.
continue;
// Posted value is different.
if ($existingDuration == null) {
- // Insert a new record here.
+ // Skip inserting 0 duration values.
+ if (0 == ttTimeHelper::toMinutes($postedDuration))
+ continue;
+ // Insert a new record.
$fields = array();
$fields['row_id'] = $dataArray[$rowNumber]['row_id'];
if (!$fields['row_id']) {
- // Special handling for row 0, a new entry. Need to construct row_id.
+ // Special handling for row 0, a new entry. Need to construct new row_id.
$record = array();
$record['client_id'] = $cl_client;
$record['billable'] = $cl_billable ? '1' : '0';
$record['project_id'] = $cl_project;
$record['task_id'] = $cl_task;
$record['cf_1_value'] = $cl_cf_1;
- $fields['row_id'] = ttTimeHelper::makeRecordIdentifier($record).'_0';
+ $fields['row_id'] = ttTimeHelper::makeRecordIdentifier($record).'_0'; // TODO: Handle a possible conflict with already existing row...
+ // We may have to increment the suffix here.
+ $fields['note'] = $cl_note;
}
$fields['day_header'] = $dayHeader;
$fields['start_date'] = $startDate->toString(DB_DATEFORMAT); // To be able to determine date for the entry using $dayHeader.