7
7
use Livewire \Component ;
8
8
use Livewire \WithPagination ;
9
9
use App \Models \Planning \Task ;
10
+ use App \Services \TaskService ;
10
11
use App \Events \TaskChangeStatu ;
11
12
use App \Models \Planning \Status ;
12
13
use App \Models \Products \StockMove ;
13
14
use Illuminate \Support \Facades \App ;
14
15
use Illuminate \Support \Facades \Auth ;
15
16
use App \Services \NotificationService ;
16
17
use App \Models \Planning \TaskActivities ;
17
- use App \Models \Quality \QualityNonConformity ;
18
- use Illuminate \Support \Facades \Notification ;
19
18
use App \Services \QualityNonConformityService ;
20
19
use App \Models \Products \StockLocationProducts ;
21
- use App \Notifications \NonConformityNotification ;
22
20
23
21
class TaskStatu extends Component
24
22
{
@@ -51,12 +49,14 @@ class TaskStatu extends Component
51
49
public $ userSelect ;
52
50
protected $ notificationService ;
53
51
protected $ qualityNonConformityService ;
54
-
52
+ protected $ taskService ;
53
+
55
54
public function __construct ()
56
55
{
57
56
// Résoudre le service via le container Laravel
58
57
$ this ->notificationService = App::make (NotificationService::class);
59
58
$ this ->qualityNonConformityService = App::make (QualityNonConformityService::class);
59
+ $ this ->taskService = App::make (TaskService::class);
60
60
}
61
61
62
62
// Validation Rules
@@ -236,14 +236,8 @@ public function render()
236
236
237
237
public function StartTimeTask ($ taskId )
238
238
{
239
- // Create Line
240
- TaskActivities::create ([
241
- 'task_id ' => $ taskId ,
242
- 'user_id ' =>$ this ->user_id ,
243
- 'type ' =>'1 ' ,
244
- 'timestamp ' =>Carbon::now (),
245
- 'comment ' =>'' ,
246
- ]);
239
+ //create entry qty int task
240
+ $ this ->taskService ->recordTaskActivity ( $ taskId , 1 , 0 , 0 );
247
241
248
242
$ StatusUpdate = Status::select ('id ' )->where ('title ' , 'In progress ' )->first ();
249
243
@@ -261,14 +255,8 @@ public function StartTimeTask($taskId)
261
255
262
256
public function EndTimeTask ($ taskId )
263
257
{
264
- // Create Line
265
- TaskActivities::create ([
266
- 'task_id ' => $ taskId ,
267
- 'user_id ' =>$ this ->user_id ,
268
- 'type ' =>'2 ' ,
269
- 'timestamp ' =>Carbon::now (),
270
- 'comment ' =>'' ,
271
- ]);
258
+ //create entry qty int task
259
+ $ this ->taskService ->recordTaskActivity ( $ taskId , 2 , 0 , 0 );
272
260
273
261
$ this ->render ();
274
262
@@ -278,14 +266,9 @@ public function EndTimeTask($taskId)
278
266
279
267
public function EndTask ($ taskId )
280
268
{
281
- // Create Line
282
- TaskActivities::create ([
283
- 'task_id ' => $ taskId ,
284
- 'user_id ' =>$ this ->user_id ,
285
- 'type ' =>'3 ' ,
286
- 'timestamp ' =>Carbon::now (),
287
- 'comment ' =>'' ,
288
- ]);
269
+ //create entry qty int task
270
+ $ this ->taskService ->recordTaskActivity ( $ taskId , 3 , 0 , 0 );
271
+
289
272
$ StatusUpdate = Status::select ('id ' )->where ('title ' , 'Finished ' )->first ();
290
273
291
274
/* // update task statu on Kanban*/
@@ -303,14 +286,8 @@ public function EndTask($taskId)
303
286
public function addGoodQtFromUser ()
304
287
{
305
288
$ this ->validate ();
306
- // Create Line
307
- TaskActivities::create ([
308
- 'task_id ' => $ this ->search ,
309
- 'user_id ' =>$ this ->user_id ,
310
- 'type ' =>'4 ' ,
311
- 'good_qt ' =>$ this ->addGoodQt ,
312
- 'comment ' =>'' ,
313
- ]);
289
+ //create entry qty int task
290
+ $ this ->taskService ->recordTaskActivity ( $ this ->search , 4 , $ this ->addGoodQt , 0 );
314
291
315
292
$ this ->render ();
316
293
@@ -321,14 +298,8 @@ public function addGoodQtFromUser()
321
298
public function FastaddGoodQt ($ qty )
322
299
{
323
300
$ this ->addGoodQt += $ qty ;
324
- // Create Line
325
- TaskActivities::create ([
326
- 'task_id ' => $ this ->search ,
327
- 'user_id ' =>$ this ->user_id ,
328
- 'type ' =>'4 ' ,
329
- 'good_qt ' =>$ qty ,
330
- 'comment ' =>'' ,
331
- ]);
301
+ //create entry qty int task
302
+ $ this ->taskService ->recordTaskActivity ( $ this ->search , 4 , $ qty , 0 );
332
303
333
304
$ this ->render ();
334
305
@@ -367,14 +338,9 @@ public function addGoodQtFromStock($composantId, $taskId)
367
338
}
368
339
369
340
$ this ->validate ();
370
- // Create Line
371
- TaskActivities::create ([
372
- 'task_id ' => $ this ->search ,
373
- 'user_id ' =>$ this ->user_id ,
374
- 'type ' =>'4 ' ,
375
- 'good_qt ' =>$ this ->addGoodQt ,
376
- 'comment ' =>'' ,
377
- ]);
341
+
342
+ //create entry qty int task
343
+ $ this ->taskService ->recordTaskActivity ( $ this ->search , 4 , $ this ->addGoodQt , 0 );
378
344
379
345
$ this ->render ();
380
346
@@ -390,14 +356,8 @@ public function addGoodQtFromStock($composantId, $taskId)
390
356
public function addRejectedQt ()
391
357
{
392
358
$ this ->validate ();
393
- // Create Line
394
- TaskActivities::create ([
395
- 'task_id ' => $ this ->search ,
396
- 'user_id ' =>$ this ->user_id ,
397
- 'type ' =>'5 ' ,
398
- 'bad_qt ' =>$ this ->addBadQt ,
399
- 'comment ' =>'' ,
400
- ]);
359
+ //create entry qty int task
360
+ $ this ->taskService ->recordTaskActivity ( $ this ->search , 5 , 0 , $ this ->addBadQt );
401
361
402
362
$ this ->render ();
403
363
@@ -408,14 +368,8 @@ public function addRejectedQt()
408
368
public function FastaddBadQt ($ qty )
409
369
{
410
370
$ this ->addGoodQt -= $ qty ;
411
- // Create Line
412
- TaskActivities::create ([
413
- 'task_id ' => $ this ->search ,
414
- 'user_id ' =>$ this ->user_id ,
415
- 'type ' =>'5 ' ,
416
- 'bad_qt ' =>$ qty ,
417
- 'comment ' =>'' ,
418
- ]);
371
+ //create entry qty int task
372
+ $ this ->taskService ->recordTaskActivity ( $ this ->search , 5 , 0 , $ qty );
419
373
420
374
$ this ->render ();
421
375
0 commit comments