Skip to content

Commit a9e7850

Browse files
committed
Inserting new cells from already existing week view rows should now work with custom field.
1 parent 88134e6 commit a9e7850

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

WEB-INF/lib/ttTimeHelper.class.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ static function dateFromDayHeader($start_date, $day_header) {
977977
}
978978

979979
// insertDurationFromWeekView - inserts a new record in log tables from a week view post.
980-
static function insertDurationFromWeekView($fields, $err) {
980+
static function insertDurationFromWeekView($fields, $custom_fields, $err) {
981981
global $i18n;
982982
global $user;
983983

@@ -994,13 +994,6 @@ static function insertDurationFromWeekView($fields, $err) {
994994
}
995995
}
996996

997-
// Temporary check for custom field and exit if one is found, as this is not yet implemented.
998-
$temp = ttTimeHelper::parseFromWeekViewRow($fields['row_id'], 'cf_1');
999-
if ($temp) {
1000-
$err->add("Week view is work in progress. Inserting records with custom fields is not yet implemented. Try again later.");
1001-
return false;
1002-
}
1003-
1004997
// Prepare an array of fields for regular insert function.
1005998
$fields4insert = array();
1006999
$fields4insert['user_id'] = $user->getActiveUser();
@@ -1015,15 +1008,26 @@ static function insertDurationFromWeekView($fields, $err) {
10151008
$id = ttTimeHelper::insert($fields4insert);
10161009
if (!$id) return false; // Something failed.
10171010

1018-
// TODO: Deal with custom fieeld log here. Currently not implemented.
1011+
// Insert custom field if we have it.
1012+
$result = true;
1013+
$cf_1 = ttTimeHelper::parseFromWeekViewRow($fields['row_id'], 'cf_1');
1014+
if ($custom_fields && $cf_1) {
1015+
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
1016+
$result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], null, $cf_1);
1017+
elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN)
1018+
$result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], $cf_1, null);
1019+
}
10191020

1020-
return true; // Not implemented.
1021+
return $result;
10211022
}
10221023

10231024

10241025
// modifyFromWeekView - modifies a duration of an existing record from a week view post.
10251026
static function modifyDurationFromWeekView($fields, $err) {
1026-
$err->add("Week view is work in progress. Editing records is not yet implemented. Try again later.");
1027+
1028+
// Possible error conditions. Overlap? What else?
1029+
1030+
$err->add("Week view is work in progress. Editing records is not yet implemented. Try deleting and then inserting a record instead.");
10271031
return false;
10281032

10291033
// static function modifyDurationFromWeekView($tt_log_id, $new_duration, $user_id) {

WEB-INF/templates/footer.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<br>
1313
<table cellspacing="0" cellpadding="4" width="100%" border="0">
1414
<tr>
15-
<td align="center">&nbsp;Anuko Time Tracker 1.13.0.3704| Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
15+
<td align="center">&nbsp;Anuko Time Tracker 1.13.0.3705| Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
1616
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
1717
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
1818
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>

week.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,15 @@ function render(&$table, $value, $row, $column, $selected = false) {
394394
$fields['start_date'] = $startDate->toString(DB_DATEFORMAT); // To be able to determine date for the entry using $dayHeader.
395395
$fields['duration'] = $postedDuration;
396396
$fields['browser_today'] = $request->getParameter('browser_today', null);
397-
$result = ttTimeHelper::insertDurationFromWeekView($fields, $err);
397+
$result = ttTimeHelper::insertDurationFromWeekView($fields, $custom_fields, $err);
398398
} elseif ($postedDuration == null || 0 == ttTimeHelper::toMinutes($postedDuration)) {
399399
// Delete an already existing record here.
400400
$result = ttTimeHelper::delete($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $user->getActiveUser());
401401
} else {
402402
$fields = array();
403+
$fields['tt_log_id'] = $dataArray[$rowNumber][$dayHeader]['tt_log_id'];
404+
$fields['duration'] = $postedDuration;
403405
$result = ttTimeHelper::modifyDurationFromWeekView($fields, $err);
404-
//$result = ttTimeHelper::modifyDurationFromWeekView($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $postedDuration, $user->getActiveUser());
405406
}
406407
if (!$result) break; // Break out of the loop in case of first error.
407408
}
@@ -412,7 +413,7 @@ function render(&$table, $value, $row, $column, $selected = false) {
412413
header('Location: week.php'); // Normal exit.
413414
exit();
414415
}
415-
$err->add($i18n->getKey('error.db'));
416+
// $err->add($i18n->getKey('error.db'));
416417
/*
417418
//
418419
//

0 commit comments

Comments
 (0)