}
// insertDurationFromWeekView - inserts a new record in log tables from a week view post.
- static function insertDurationFromWeekView($fields, $err) {
+ static function insertDurationFromWeekView($fields, $custom_fields, $err) {
global $i18n;
global $user;
}
}
- // Temporary check for custom field and exit if one is found, as this is not yet implemented.
- $temp = ttTimeHelper::parseFromWeekViewRow($fields['row_id'], 'cf_1');
- if ($temp) {
- $err->add("Week view is work in progress. Inserting records with custom fields is not yet implemented. Try again later.");
- return false;
- }
-
// Prepare an array of fields for regular insert function.
$fields4insert = array();
$fields4insert['user_id'] = $user->getActiveUser();
$id = ttTimeHelper::insert($fields4insert);
if (!$id) return false; // Something failed.
- // TODO: Deal with custom fieeld log here. Currently not implemented.
+ // Insert custom field if we have it.
+ $result = true;
+ $cf_1 = ttTimeHelper::parseFromWeekViewRow($fields['row_id'], 'cf_1');
+ if ($custom_fields && $cf_1) {
+ if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
+ $result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], null, $cf_1);
+ elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN)
+ $result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], $cf_1, null);
+ }
- return true; // Not implemented.
+ return $result;
}
// modifyFromWeekView - modifies a duration of an existing record from a week view post.
static function modifyDurationFromWeekView($fields, $err) {
- $err->add("Week view is work in progress. Editing records is not yet implemented. Try again later.");
+
+ // Possible error conditions. Overlap? What else?
+
+ $err->add("Week view is work in progress. Editing records is not yet implemented. Try deleting and then inserting a record instead.");
return false;
// static function modifyDurationFromWeekView($tt_log_id, $new_duration, $user_id) {
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.13.0.3704| Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.13.0.3705| Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
$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);
+ $result = ttTimeHelper::insertDurationFromWeekView($fields, $custom_fields, $err);
} elseif ($postedDuration == null || 0 == ttTimeHelper::toMinutes($postedDuration)) {
// Delete an already existing record here.
$result = ttTimeHelper::delete($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $user->getActiveUser());
} else {
$fields = array();
+ $fields['tt_log_id'] = $dataArray[$rowNumber][$dayHeader]['tt_log_id'];
+ $fields['duration'] = $postedDuration;
$result = ttTimeHelper::modifyDurationFromWeekView($fields, $err);
- //$result = ttTimeHelper::modifyDurationFromWeekView($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $postedDuration, $user->getActiveUser());
}
if (!$result) break; // Break out of the loop in case of first error.
}
header('Location: week.php'); // Normal exit.
exit();
}
- $err->add($i18n->getKey('error.db'));
+ // $err->add($i18n->getKey('error.db'));
/*
//
//