@@ -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) {
0 commit comments