Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2516 nelberth 1
<?php
2
declare(strict_types=1);
3
 
4
namespace LeadersLinked\Controller;
5
 
6
use Laminas\Authentication\AuthenticationService;
7
use Laminas\Authentication\Result as AuthResult;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
10
use Laminas\Mvc\Controller\AbstractActionController;
11
use Laminas\Mvc\I18n\Translator;
12
use Laminas\Log\LoggerInterface;
13
use Laminas\View\Model\ViewModel;
14
use Laminas\View\Model\JsonModel;
15
use LeadersLinked\Model\PlanningObjectivesAndGoalsTask;
16
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
17
use LeadersLinked\Form\PlanningObjectivesAndGoalsTaskForm;
18
 
19
use LeadersLinked\Library\Functions;
20
 
21
use LeadersLinked\Mapper\PlanningObjectivesAndGoalsTaskMapper;
2565 nelberth 22
use LeadersLinked\Mapper\PlanningObjectivesAndGoalsGoalsMapper;
2516 nelberth 23
use LeadersLinked\Mapper\PlanningObjectivesAndGoalsObjectivesMapper;
3398 nelberth 24
use LeadersLinked\Mapper\CompanyUserMapper;
3401 nelberth 25
use LeadersLinked\Mapper\userMapper;
2516 nelberth 26
 
27
class PlanningObjectivesAndGoalsTaskController extends AbstractActionController
28
{
29
    /**
30
     *
31
     * @var AdapterInterface
32
     */
33
    private $adapter;
34
 
35
 
36
    /**
37
     *
38
     * @var AbstractAdapter
39
     */
40
    private $cache;
41
 
42
    /**
43
     *
44
     * @var  LoggerInterface
45
     */
46
    private $logger;
47
 
48
    /**
49
     *
50
     * @var array
51
     */
52
    private $config;
53
 
54
 
55
 
56
    /**
57
     *
58
     * @param AdapterInterface $adapter
59
     * @param AbstractAdapter $cache
60
     * @param LoggerInterface $logger
61
     * @param array $config
62
     */
63
    public function __construct($adapter, $cache , $logger, $config)
64
    {
65
        $this->adapter      = $adapter;
66
        $this->cache        = $cache;
67
        $this->logger       = $logger;
68
        $this->config       = $config;
69
 
70
 
71
    }
72
 
2565 nelberth 73
 
2516 nelberth 74
 
75
    public function indexAction()
76
    {
2781 nelberth 77
        $uuidObjective = $this->params()->fromRoute('uuid_objective');
78
        $uuidGoals= $this->params()->fromRoute('uuid_goals');
2516 nelberth 79
        $request = $this->getRequest();
80
 
81
        if($request->isGet()) {
82
 
83
 
84
            $headers  = $request->getHeaders();
85
 
86
            $isJson = false;
87
            if($headers->has('Accept')) {
88
                $accept = $headers->get('Accept');
89
 
90
                $prioritized = $accept->getPrioritized();
91
 
92
                foreach($prioritized as $key => $value) {
93
                    $raw = trim($value->getRaw());
94
 
95
                    if(!$isJson) {
96
                        $isJson = strpos($raw, 'json');
97
                    }
98
 
99
                }
100
            }
101
 
102
            if($isJson) {
2826 nelberth 103
                $currentUserPlugin = $this->plugin('currentUserPlugin');
104
                $currentUser = $currentUserPlugin->getUser();
2825 nelberth 105
                $currentCompany = $currentUserPlugin->getCompany();
2824 nelberth 106
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
2823 nelberth 107
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'planning-objectives-and-goals/objectives/goals/task/edit');
108
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'planning-objectives-and-goals/objectives/goals/task/delete');
109
                $allowView = $acl->isAllowed($currentUser->usertype_id, 'planning-objectives-and-goals/objectives/goals/task/view');
2516 nelberth 110
 
111
                $search = $this->params()->fromQuery('search', []);
112
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
113
 
114
                $records_x_page     = intval($this->params()->fromQuery('length', 10), 10);
3335 nelberth 115
                $page               = (intval($this->params()->fromQuery('start', 1), 10)/$records_x_page)+1;
2516 nelberth 116
                $order =  $this->params()->fromQuery('order', []);
117
                $order_field        = empty($order[0]['column']) ? 99 :  intval($order[0]['column'], 10);
118
                $order_direction    = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var( $order[0]['dir'], FILTER_SANITIZE_STRING));
119
 
120
                $fields =  ['title'];
121
                $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'title';
122
 
123
                if(!in_array($order_direction, ['ASC', 'DESC'])) {
124
                    $order_direction = 'ASC';
125
                }
2825 nelberth 126
 
2781 nelberth 127
                $planningObjectivesAndGoalsObjectivesMapper = PlanningObjectivesAndGoalsObjectivesMapper::getInstance($this->adapter);
128
                $objective = $planningObjectivesAndGoalsObjectivesMapper->fetchOneByUuid($uuidObjective);
129
 
130
                if (!$objective) {
2516 nelberth 131
                    $data = [
132
                        'success' => false,
2781 nelberth 133
                        'data' => 'ERROR_RECORD_NOT_FOUND'
2516 nelberth 134
                    ];
2781 nelberth 135
 
2516 nelberth 136
 
137
                        return new JsonModel($data);
2781 nelberth 138
 
139
                }else{
140
                    if($objective->id_company==$currentCompany->id){
141
                        $planningObjectivesAndGoalsGoalsMapper = PlanningObjectivesAndGoalsGoalsMapper::getInstance($this->adapter);
142
                        $goals = $planningObjectivesAndGoalsGoalsMapper->fetchOneByUuid($uuidGoals);
143
 
144
                        if(!$goals){
145
                            $data = [
146
                                'success' => false,
147
                                'data' => 'ERROR_RECORD_NOT_FOUND'
148
                            ];
149
 
150
 
151
                                return new JsonModel($data);
152
                        }
153
                    }else{
154
                        $data = [
155
                            'success' => false,
156
                            'data' => 'ERROR_UNAUTHORIZED',
157
                        ];
158
 
159
                            return new JsonModel($data);
160
                    }
161
 
162
 
163
 
2516 nelberth 164
                }
2781 nelberth 165
 
2516 nelberth 166
 
167
                $planningObjectivesAndGoalsTaskMapper = PlanningObjectivesAndGoalsTaskMapper::getInstance($this->adapter);
2565 nelberth 168
                $paginator = $planningObjectivesAndGoalsTaskMapper->fetchAllDataTable($search, $page, $records_x_page, $order_field, $order_direction, $goals->id);
2516 nelberth 169
 
170
                $items = [];
171
 
172
                $records = $paginator->getCurrentItems();
3030 nelberth 173
 
3058 nelberth 174
 
2516 nelberth 175
                foreach($records as $record)
176
                {
177
 
178
                    $item = [
179
                        'title' => $record->title,
180
                        'description' => $record->description,
2884 nelberth 181
                        'progress'=> $record->indicator,
2846 nelberth 182
                        'cost'=> $record->cost,
3045 nelberth 183
                        'status' => $record->status,
2516 nelberth 184
                        'actions' => [
2828 nelberth 185
                            'link_edit' => $allowEdit ? $this->url()->fromRoute('planning-objectives-and-goals/objectives/goals/task/edit', ['uuid_objective' => $uuidObjective,'uuid_goals' => $uuidGoals,'id' => $record->uuid]) : '',
3003 nelberth 186
                            'link_delete' => $allowDelete ? $this->url()->fromRoute('planning-objectives-and-goals/objectives/goals/task/delete', ['uuid_objective' => $uuidObjective,'uuid_goals' => $uuidGoals,'id' => $record->uuid]) : ''
187
                            ]
2516 nelberth 188
 
189
                    ];
3058 nelberth 190
                    array_push($items, $item);
191
                }
3065 nelberth 192
 
3303 nelberth 193
                $recordsTask = $planningObjectivesAndGoalsTaskMapper->fetchAll($goals->id);
194
 
3070 nelberth 195
 
3058 nelberth 196
                $costGoals=0;
197
                $indicatorGoals=0;
3311 nelberth 198
 
3171 nelberth 199
                foreach($recordsTask as $record)
3058 nelberth 200
                {
3030 nelberth 201
                    $indicatorGoals=$indicatorGoals+$record->indicator;
202
                    $costGoals=$costGoals+$record->cost;
2516 nelberth 203
                }
3317 nelberth 204
                $countRecordsTask = count($recordsTask);
205
                if($countRecordsTask >0){
3301 nelberth 206
 
3333 nelberth 207
                    $indicatorGoals=round($indicatorGoals/$countRecordsTask, 2);
3193 nelberth 208
                }else{
209
                    $indicatorGoals=-1;
210
                }
3407 nelberth 211
 
212
 
3400 nelberth 213
 
2516 nelberth 214
                return new JsonModel([
215
                    'success' => true,
216
                    'data' => [
217
                        'items' => $items,
218
                        'total' => $paginator->getTotalItemCount(),
3030 nelberth 219
                        'goals' => [
220
                            'titleGoals' =>$goals->title,
221
                            'descriptionGoals' =>$goals->description,
222
                            'costGoals'=>'$'.$costGoals,
3193 nelberth 223
                            'indicatorGoals'=> $indicatorGoals,
3049 nelberth 224
                            'statusGoals'=> $goals->status=='a'?'LABEL_ACTIVE':'LABEL_INACTIVE',
2516 nelberth 225
 
226
                        ]
227
                    ]
228
                ]);
229
            } else  {
230
                $formAdd = new PlanningObjectivesAndGoalsTaskForm();
231
                $this->layout()->setTemplate('layout/layout-backend');
232
                $viewModel = new ViewModel();
2547 nelberth 233
                $viewModel->setTemplate('leaders-linked/planning-objectives-and-goals-task/index.phtml');
2516 nelberth 234
                $viewModel->setVariables([
235
                    'formAdd' => $formAdd,
2781 nelberth 236
                    'uuid_objective'=> $uuidObjective,
237
                    'uuid_goals'=> $uuidGoals,
2516 nelberth 238
 
2530 nelberth 239
 
2516 nelberth 240
                ]);
241
                return $viewModel ;
242
            }
243
        } else {
244
            return new JsonModel([
245
                'success' => false,
246
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
247
            ]);
248
        }
249
    }
250
    public function addAction()
251
    {
252
      $currentUserPlugin = $this->plugin('currentUserPlugin');
253
        $currentUser = $currentUserPlugin->getUser();
254
        $currentCompany = $currentUserPlugin->getCompany();
2781 nelberth 255
        $uuidObjective = $this->params()->fromRoute('uuid_objective');
256
        $uuidGoals = $this->params()->fromRoute('uuid_goals');
2516 nelberth 257
        $request = $this->getRequest();
3411 nelberth 258
        $planningObjectivesAndGoalsObjectivesMapper = PlanningObjectivesAndGoalsObjectivesMapper::getInstance($this->adapter);
3407 nelberth 259
        $objective = $planningObjectivesAndGoalsObjectivesMapper->fetchOneByUuid($uuidObjective);
260
 
261
        if (!$objective) {
262
            $data = [
263
                'success' => false,
264
                'data' => 'ERROR_RECORD_NOT_FOUND'
265
            ];
266
 
267
 
268
                return new JsonModel($data);
269
 
270
        }else{
271
            if($objective->id_company==$currentCompany->id){
272
                $planningObjectivesAndGoalsGoalsMapper = PlanningObjectivesAndGoalsGoalsMapper::getInstance($this->adapter);
273
                $goals = $planningObjectivesAndGoalsGoalsMapper->fetchOneByUuid($uuidGoals);
274
 
275
                if(!$goals){
276
                    $data = [
277
                        'success' => false,
278
                        'data' => 'ERROR_RECORD_NOT_FOUND'
279
                    ];
280
 
281
 
282
                        return new JsonModel($data);
283
                }
284
            }else{
285
                $data = [
286
                    'success' => false,
287
                    'data' => 'ERROR_UNAUTHORIZED',
288
                ];
289
 
290
                    return new JsonModel($data);
291
            }
292
 
293
        }
2516 nelberth 294
        if($request->isPost()) {
295
            $form = new  PlanningObjectivesAndGoalsTaskForm();
296
            $dataPost = $request->getPost()->toArray();
2981 nelberth 297
            $dataPost['status'] =  isset($dataPost['status']) ? $dataPost['status'] : PlanningObjectivesAndGoalsTask::STATUS_INACTIVE;
3024 nelberth 298
            if($dataPost['indicator']!=100){
299
                $dataPost['evaluation']='';
300
                $dataPost['detour']='';
301
            }
2516 nelberth 302
            $form->setData($dataPost);
303
 
304
            if($form->isValid()) {
3407 nelberth 305
 
3411 nelberth 306
 
2516 nelberth 307
 
308
                $dataPost = (array) $form->getData();
2776 nelberth 309
                $dataPost['id_goals']=$goals->id;
2516 nelberth 310
 
311
                $hydrator = new ObjectPropertyHydrator();
312
                $planningObjectivesAndGoalsTask = new PlanningObjectivesAndGoalsTask();
313
                $hydrator->hydrate($dataPost, $planningObjectivesAndGoalsTask);
314
 
315
                $planningObjectivesAndGoalsTaskMapper = PlanningObjectivesAndGoalsTaskMapper::getInstance($this->adapter);
316
                $result = $planningObjectivesAndGoalsTaskMapper->insert($planningObjectivesAndGoalsTask);
317
 
318
                if($result) {
2776 nelberth 319
                    $this->logger->info('Se agrego la tarea ' . $planningObjectivesAndGoalsTask->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2516 nelberth 320
 
321
                    $data = [
322
                        'success'   => true,
323
                        'data'   => 'LABEL_RECORD_ADDED'
324
                    ];
325
                } else {
326
                    $data = [
327
                        'success'   => false,
328
                        'data'      => $planningObjectivesAndGoalsTaskMapper->getError()
329
                    ];
330
 
331
                }
332
 
333
                return new JsonModel($data);
334
 
335
            } else {
336
                $messages = [];
337
                $form_messages = (array) $form->getMessages();
338
                foreach($form_messages  as $fieldname => $field_messages)
339
                {
340
 
341
                    $messages[$fieldname] = array_values($field_messages);
342
                }
343
 
344
                return new JsonModel([
345
                    'success'   => false,
346
                    'data'   => $messages
347
                ]);
348
            }
349
 
3407 nelberth 350
        }else if ($request->isGet()) {
351
            $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
352
            $userMapper = UserMapper::getInstance($this->adapter);
353
            $datosCompanyUser = $companyUserMapper->fetchAllByCompanyId($currentCompany->id);
354
 
355
            $users=[];
356
 
357
            foreach($datosCompanyUser as $record){
358
                $datosUser = $userMapper->fetchOne($record->user_id);
3417 nelberth 359
 
3415 nelberth 360
                    $user=[
3417 nelberth 361
                        'uuid'=>$datosUser->uuid,
4305 nelberth 362
                        'email'=>$datosUser->email,
363
                        'first_name'=>$datosUser->first_name,
364
                        'last_name'=>$datosUser->last_name,
365
 
3415 nelberth 366
                    ];
367
                    array_push($users, $user);
3417 nelberth 368
 
3407 nelberth 369
            }
370
 
371
            return new JsonModel([
372
                'success' => true,
3415 nelberth 373
                'data' => $users
374
 
3407 nelberth 375
            ]);
2516 nelberth 376
        } else {
377
            $data = [
378
                'success' => false,
379
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
380
            ];
381
 
382
            return new JsonModel($data);
383
        }
384
 
385
        return new JsonModel($data);
386
 
387
    }
388
 
389
 
390
 
391
     public function editAction(){
392
 
2783 nelberth 393
 
2516 nelberth 394
        $currentUserPlugin = $this->plugin('currentUserPlugin');
395
        $currentUser = $currentUserPlugin->getUser();
396
        $currentCompany = $currentUserPlugin->getCompany();
397
        $request = $this->getRequest();
398
        $uuid = $this->params()->fromRoute('id');
3000 nelberth 399
 
2516 nelberth 400
 
401
        if(!$uuid) {
402
            $data = [
403
                'success'   => false,
404
                'data'   => 'ERROR_INVALID_PARAMETER'
405
            ];
406
 
407
            return new JsonModel($data);
408
        }
409
 
2781 nelberth 410
        $uuidObjective = $this->params()->fromRoute('uuid_objective');
2783 nelberth 411
        $uuidGoals = $this->params()->fromRoute('uuid_goals');
2782 nelberth 412
        $currentUserPlugin = $this->plugin('currentUserPlugin');
413
        $currentCompany = $currentUserPlugin->getCompany();
414
        $planningObjectivesAndGoalsObjectivesMapper = PlanningObjectivesAndGoalsObjectivesMapper::getInstance($this->adapter);
415
        $objective = $planningObjectivesAndGoalsObjectivesMapper->fetchOneByUuid($uuidObjective);
416
 
417
        if (!$objective) {
2516 nelberth 418
            $data = [
419
                'success' => false,
2782 nelberth 420
                'data' => 'ERROR_RECORD_NOT_FOUND'
2516 nelberth 421
            ];
2782 nelberth 422
 
2516 nelberth 423
 
424
                return new JsonModel($data);
2782 nelberth 425
 
426
        }else{
427
            if($objective->id_company==$currentCompany->id){
428
                $planningObjectivesAndGoalsGoalsMapper = PlanningObjectivesAndGoalsGoalsMapper::getInstance($this->adapter);
429
                $goals = $planningObjectivesAndGoalsGoalsMapper->fetchOneByUuid($uuidGoals);
430
 
431
                if(!$goals){
432
                    $data = [
433
                        'success' => false,
434
                        'data' => 'ERROR_RECORD_NOT_FOUND'
435
                    ];
436
 
437
 
438
                        return new JsonModel($data);
439
                }
440
            }else{
441
                $data = [
442
                    'success' => false,
443
                    'data' => 'ERROR_UNAUTHORIZED',
444
                ];
445
 
446
                    return new JsonModel($data);
447
            }
448
 
449
 
450
 
2516 nelberth 451
        }
452
        $planningObjectivesAndGoalsTaskMapper = PlanningObjectivesAndGoalsTaskMapper::getInstance($this->adapter);
2782 nelberth 453
        $task = $planningObjectivesAndGoalsTaskMapper->fetchOneByUuid($uuid);
2516 nelberth 454
 
2782 nelberth 455
        if (!$task) {
2516 nelberth 456
            $data = [
457
                'success' => false,
458
                'data' => 'ERROR_RECORD_NOT_FOUND'
459
            ];
460
 
461
            return new JsonModel($data);
462
        }
463
 
464
 
465
        if($request->isPost()) {
3000 nelberth 466
            $form = new  PlanningObjectivesAndGoalsTaskForm();
467
            $dataPost = $request->getPost()->toArray();
468
            $dataPost['status'] =  isset($dataPost['status']) ? $dataPost['status'] : PlanningObjectivesAndGoalsTask::STATUS_INACTIVE;
2516 nelberth 469
            $form->setData($dataPost);
470
 
471
            if($form->isValid()) {
472
                $dataPost = (array) $form->getData();
473
 
474
                $hydrator = new ObjectPropertyHydrator();
2782 nelberth 475
                $hydrator->hydrate($dataPost, $task);
476
                $result = $planningObjectivesAndGoalsTaskMapper->update($task);
2516 nelberth 477
 
478
                if($result) {
2782 nelberth 479
                    $this->logger->info('Se actualizo la tarea ' . $task->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2516 nelberth 480
 
481
                    $data = [
482
                        'success' => true,
483
                        'data' => 'LABEL_RECORD_UPDATED'
484
                    ];
485
                } else {
486
                    $data = [
487
                        'success'   => false,
488
                        'data'      => $planningObjectivesAndGoalsTaskMapper->getError()
489
                    ];
490
                }
491
 
492
                return new JsonModel($data);
493
 
494
            } else {
495
                $messages = [];
496
                $form_messages = (array) $form->getMessages();
497
                foreach($form_messages  as $fieldname => $field_messages)
498
                {
499
                    $messages[$fieldname] = array_values($field_messages);
500
                }
501
 
502
                return new JsonModel([
503
                    'success'   => false,
504
                    'data'   => $messages
505
                ]);
506
            }
507
        }else if ($request->isGet()) {
508
            $hydrator = new ObjectPropertyHydrator();
509
 
510
            $data = [
511
                'success' => true,
2782 nelberth 512
                'data' => $hydrator->extract($task)
2516 nelberth 513
            ];
514
 
515
            return new JsonModel($data);
516
        } else {
517
            $data = [
518
                'success' => false,
519
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
520
            ];
521
 
522
            return new JsonModel($data);
523
        }
524
 
525
        return new JsonModel($data);
526
 
527
    }
528
 
529
 
530
 
531
 
532
    public function deleteAction(){
533
        $currentUserPlugin = $this->plugin('currentUserPlugin');
534
        $currentCompany = $currentUserPlugin->getCompany();
535
        $currentUser = $currentUserPlugin->getUser();
536
 
537
        $request = $this->getRequest();
538
        $uuid = $this->params()->fromRoute('id');
539
 
540
 
541
        if (!$uuid) {
542
            $data = [
543
                'success' => false,
544
                'data' => 'ERROR_INVALID_PARAMETER'
545
            ];
546
 
547
            return new JsonModel($data);
548
        }
2787 nelberth 549
        $uuidObjective = $this->params()->fromRoute('uuid_objective');
550
        $uuidGoals = $this->params()->fromRoute('uuid_goals');
2782 nelberth 551
        $currentUserPlugin = $this->plugin('currentUserPlugin');
552
        $currentCompany = $currentUserPlugin->getCompany();
553
        $planningObjectivesAndGoalsObjectivesMapper = PlanningObjectivesAndGoalsObjectivesMapper::getInstance($this->adapter);
554
        $objective = $planningObjectivesAndGoalsObjectivesMapper->fetchOneByUuid($uuidObjective);
555
 
556
        if (!$objective) {
2516 nelberth 557
            $data = [
558
                'success' => false,
2782 nelberth 559
                'data' => 'ERROR_RECORD_NOT_FOUND'
2516 nelberth 560
            ];
561
                return new JsonModel($data);
2782 nelberth 562
 
563
        }else{
564
            if($objective->id_company==$currentCompany->id){
565
                $planningObjectivesAndGoalsGoalsMapper = PlanningObjectivesAndGoalsGoalsMapper::getInstance($this->adapter);
566
                $goals = $planningObjectivesAndGoalsGoalsMapper->fetchOneByUuid($uuidGoals);
567
 
568
                if(!$goals){
569
                    $data = [
570
                        'success' => false,
571
                        'data' => 'ERROR_RECORD_NOT_FOUND'
572
                    ];
573
 
574
 
575
                        return new JsonModel($data);
576
                }
577
            }else{
578
                $data = [
579
                    'success' => false,
580
                    'data' => 'ERROR_UNAUTHORIZED',
581
                ];
582
 
583
                    return new JsonModel($data);
3024 nelberth 584
            }
2782 nelberth 585
 
2516 nelberth 586
        }
587
        $planningObjectivesAndGoalsTaskMapper = PlanningObjectivesAndGoalsTaskMapper::getInstance($this->adapter);
2782 nelberth 588
        $task = $planningObjectivesAndGoalsTaskMapper->fetchOneByUuid($uuid);
2516 nelberth 589
 
2782 nelberth 590
        if (!$task) {
2516 nelberth 591
            $data = [
592
                'success' => false,
593
                'data' => 'ERROR_RECORD_NOT_FOUND'
594
            ];
595
 
596
            return new JsonModel($data);
597
        }
598
 
599
 
600
        if ($request->isPost()) {
601
 
602
 
2782 nelberth 603
            $result = $planningObjectivesAndGoalsTaskMapper->delete($task->id);
2516 nelberth 604
            if ($result) {
2782 nelberth 605
                $this->logger->info('Se borro la tarea con el titulo ' . $task->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2516 nelberth 606
 
607
                $data = [
608
                    'success' => true,
609
                    'data' => 'LABEL_RECORD_DELETED'
610
                ];
611
            } else {
612
 
613
                $data = [
614
                    'success' => false,
615
                    'data' => $planningObjectivesAndGoalsTaskMapper->getError()
616
                ];
617
 
618
                return new JsonModel($data);
619
            }
620
        } else {
621
            $data = [
622
                'success' => false,
623
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
624
            ];
625
 
626
            return new JsonModel($data);
627
        }
628
 
629
        return new JsonModel($data);
630
    }
631
 
632
 
633
 
634
 
635
}