10
10
use Livewire \WithPagination ;
11
11
use App \Formatter \DateFormatter ;
12
12
use App \Contracts \AddsTimeTrackings ;
13
- use Illuminate \Support \Facades \Auth ;
14
13
use App \Contracts \RemovesTimeTracking ;
15
14
use App \Contracts \UpdatesTimeTracking ;
16
15
use Daybreak \Project \Contracts \AddsTimeTrackingWithProjectInfo ;
17
16
use Daybreak \Project \Contracts \UpdatesTimeTrackingWithProjectInfo ;
18
17
19
- class TimeTracking extends Component
18
+ class TimeTrackingManager extends Component
20
19
{
21
20
use WithPagination, TrimAndNullEmptyStrings;
22
21
@@ -80,7 +79,7 @@ public function mount(User $employee, DateFormatter $dateFormatter)
80
79
$ this ->employeeFilter = collect ($ this ->employeeOptions )
81
80
->filterMultipleSelect (fn ($ item ) => $ item ['id ' ] === $ this ->employee ->id );
82
81
83
- $ this ->timeTrackingForm = array_merge_when (array_merge ($ this ->timeTrackingForm ,[
82
+ $ this ->timeTrackingForm = array_merge_when (array_merge ($ this ->timeTrackingForm , [
84
83
'date ' => $ dateFormatter ->formatDateTimeForView (Carbon::today ())
85
84
]), fn () => $ this ->projectFormFields (), Daybreak::hasProjectBillingFeature ());
86
85
@@ -119,21 +118,41 @@ public function confirmAddTimeTracking(DateFormatter $dateFormatter)
119
118
{
120
119
$ this ->resetErrorBag ();
121
120
122
- $ generatedPauseTimeArray = $ this ->generatePauseTimeArray ($ this ->timeTrackingForm ['date ' ], $ this ->pauseTimeForm , $ dateFormatter );
121
+ $ generatedPauseTimeArray = $ this ->generatePauseTimeArray (
122
+ $ this ->timeTrackingForm ['date ' ],
123
+ $ this ->pauseTimeForm ,
124
+ $ dateFormatter
125
+ );
123
126
124
127
if (Daybreak::hasProjectBillingFeature ()) {
125
128
app (AddsTimeTrackingWithProjectInfo::class)->add (
126
129
$ this ->employee , array_merge ([
127
- 'starts_at ' => $ dateFormatter ->generateTimeStr ($ this ->timeTrackingForm ['date ' ], $ this ->timeTrackingForm ['start_hour ' ], $ this ->timeTrackingForm ['start_minute ' ]),
128
- 'ends_at ' => $ dateFormatter ->generateTimeStr ($ this ->timeTrackingForm ['date ' ], $ this ->timeTrackingForm ['end_hour ' ], $ this ->timeTrackingForm ['end_minute ' ]),
130
+ 'starts_at ' => $ dateFormatter ->generateTimeStr (
131
+ $ this ->timeTrackingForm ['date ' ],
132
+ $ this ->timeTrackingForm ['start_hour ' ],
133
+ $ this ->timeTrackingForm ['start_minute ' ]
134
+ ),
135
+ 'ends_at ' => $ dateFormatter ->generateTimeStr (
136
+ $ this ->timeTrackingForm ['date ' ],
137
+ $ this ->timeTrackingForm ['end_hour ' ],
138
+ $ this ->timeTrackingForm ['end_minute ' ]
139
+ ),
129
140
], $ this ->filteredTimeTrackingFormFields ()),
130
141
$ generatedPauseTimeArray
131
142
);
132
143
} else {
133
144
app (AddsTimeTrackings::class)->add (
134
145
$ this ->employee , array_merge ([
135
- 'starts_at ' => $ dateFormatter ->generateTimeStr ($ this ->timeTrackingForm ['date ' ], $ this ->timeTrackingForm ['start_hour ' ], $ this ->timeTrackingForm ['start_minute ' ]),
136
- 'ends_at ' => $ dateFormatter ->generateTimeStr ($ this ->timeTrackingForm ['date ' ], $ this ->timeTrackingForm ['end_hour ' ], $ this ->timeTrackingForm ['end_minute ' ]),
146
+ 'starts_at ' => $ dateFormatter ->generateTimeStr (
147
+ $ this ->timeTrackingForm ['date ' ],
148
+ $ this ->timeTrackingForm ['start_hour ' ],
149
+ $ this ->timeTrackingForm ['start_minute ' ]
150
+ ),
151
+ 'ends_at ' => $ dateFormatter ->generateTimeStr (
152
+ $ this ->timeTrackingForm ['date ' ],
153
+ $ this ->timeTrackingForm ['end_hour ' ],
154
+ $ this ->timeTrackingForm ['end_minute ' ]
155
+ ),
137
156
], $ this ->filteredTimeTrackingFormFields ()),
138
157
$ generatedPauseTimeArray
139
158
);
@@ -235,7 +254,7 @@ public function updateTimeTracking($index)
235
254
$ this ->timeTrackingIdBeingUpdated = $ index ;
236
255
237
256
$ this ->updateTimeTrackingForm (
238
- $ this ->employee ->timeTrackings ()
257
+ $ this ->employee ->currentLocation -> timeTrackings ()
239
258
->whereKey ($ index )
240
259
->with ('pauseTimes ' )
241
260
->first ()
@@ -271,7 +290,11 @@ public function confirmUpdateTimeTracking(DateFormatter $dateFormatter)
271
290
{
272
291
$ this ->resetErrorBag ();
273
292
274
- $ generatedPauseTimeArray = $ this ->generatePauseTimeArray ($ this ->timeTrackingForm ['date ' ], $ this ->pauseTimeForm , $ dateFormatter );
293
+ $ generatedPauseTimeArray = $ this ->generatePauseTimeArray (
294
+ $ this ->timeTrackingForm ['date ' ],
295
+ $ this ->pauseTimeForm ,
296
+ $ dateFormatter
297
+ );
275
298
276
299
if (Daybreak::hasProjectBillingFeature ()) {
277
300
app (UpdatesTimeTrackingWithProjectInfo::class)->update (
@@ -296,9 +319,16 @@ public function confirmUpdateTimeTracking(DateFormatter $dateFormatter)
296
319
$ this ->employee ,
297
320
$ this ->timeTrackingIdBeingUpdated ,
298
321
array_merge ([
299
- 'starts_at ' => $ dateFormatter ->generateTimeStr ($ this ->timeTrackingForm ['date ' ], $ this ->timeTrackingForm ['start_hour ' ], $ this ->timeTrackingForm ['start_minute ' ]),
300
- 'ends_at ' => $ dateFormatter ->generateTimeStr ($ this ->timeTrackingForm ['date ' ], $ this ->timeTrackingForm ['end_hour ' ], $ this ->timeTrackingForm ['end_minute ' ]),
301
-
322
+ 'starts_at ' => $ dateFormatter ->generateTimeStr (
323
+ $ this ->timeTrackingForm ['date ' ],
324
+ $ this ->timeTrackingForm ['start_hour ' ],
325
+ $ this ->timeTrackingForm ['start_minute ' ]
326
+ ),
327
+ 'ends_at ' => $ dateFormatter ->generateTimeStr (
328
+ $ this ->timeTrackingForm ['date ' ],
329
+ $ this ->timeTrackingForm ['end_hour ' ],
330
+ $ this ->timeTrackingForm ['end_minute ' ]
331
+ ),
302
332
], $ this ->filteredTimeTrackingFormFields ()),
303
333
$ generatedPauseTimeArray
304
334
);
0 commit comments