- }
-
- // Prepare an array of fields for regular insert function.
- $fields4insert = array();
- $fields4insert['user_id'] = $user->getActiveUser();
- $fields4insert['date'] = $entry_date;
- $fields4insert['duration'] = $fields['duration'];
- $fields4insert['client'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'cl');
- $fields4insert['billable'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'bl');
- $fields4insert['project'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'pr');
- $fields4insert['task'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'ts');
- $fields4insert['note'] = $fields['note'];
-
- // Try to insert a record.
- $id = ttTimeHelper::insert($fields4insert);
- if (!$id) return false; // Something failed.
-
- // Insert custom field if we have it.
- $result = true;
- $cf_1 = ttWeekViewHelper::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);
- }