Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1320 | Rev 1337 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1320 Rev 1336
Línea 24... Línea 24...
24
use LeadersLinked\Mapper\BehaviorCompetencyMapper;
24
use LeadersLinked\Mapper\BehaviorCompetencyMapper;
25
use LeadersLinked\Mapper\BehaviorMapper;
25
use LeadersLinked\Mapper\BehaviorMapper;
26
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
26
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
27
use LeadersLinked\Mapper\CompanyPerformanceEvaluationFormUserMapper;
27
use LeadersLinked\Mapper\CompanyPerformanceEvaluationFormUserMapper;
28
use LeadersLinked\Mapper\CompanyMapper;
28
use LeadersLinked\Mapper\CompanyMapper;
-
 
29
use LeadersLinked\Model\Company;
Línea 29... Línea 30...
29
 
30
 
Línea 30... Línea 31...
30
class PerformanceEvaluationFormController extends AbstractActionController {
31
class PerformanceEvaluationFormController extends AbstractActionController {
31
 
32
 
Línea 92... Línea 93...
92
                        $isJson = strpos($raw, 'json');
93
                        $isJson = strpos($raw, 'json');
93
                    }
94
                    }
94
                }
95
                }
95
            }
96
            }
Línea -... Línea 97...
-
 
97
 
96
 
98
            //$isJson = true;
97
            if ($isJson) {
99
            if ($isJson) {
98
                $search = $this->params()->fromQuery('search', []);
100
                $search = $this->params()->fromQuery('search', []);
Línea 99... Línea 101...
99
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
101
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
Línea 375... Línea 377...
375
                    'id' => $companyPerformanceEvaluation->uuid,
377
                    'id' => $companyPerformanceEvaluation->uuid,
376
                    'name' => $companyPerformanceEvaluation->name,
378
                    'name' => $companyPerformanceEvaluation->name,
377
                    'job_description_id' => $jobDescription->uuid,
379
                    'job_description_id' => $jobDescription->uuid,
378
                    'status' => $companyPerformanceEvaluation->status,
380
                    'status' => $companyPerformanceEvaluation->status,
379
                    'description' => $companyPerformanceEvaluation->description,
381
                    'description' => $companyPerformanceEvaluation->description,
380
                    'text' => $companyPerformanceEvaluation->text,
382
                    //'text' => $companyPerformanceEvaluation->text,
381
                    'content' => $companyPerformanceEvaluation->content ? json_decode($companyPerformanceEvaluation->content) : [],
383
                    'content' => $companyPerformanceEvaluation->content ? json_decode($companyPerformanceEvaluation->content) : [],
382
                ]
384
                ]
383
            ];
385
            ];
Línea 384... Línea 386...
384
 
386
 
Línea 482... Línea 484...
482
                'success' => false,
484
                'success' => false,
483
                'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
485
                'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
484
            ]);
486
            ]);
485
        }
487
        }
Línea -... Línea 488...
-
 
488
 
486
 
489
        /*
487
        if ($companyPerformanceEvaluationForm->status == CompanyPerformanceEvaluationForm::STATUS_INACTIVE) {
490
        if ($companyPerformanceEvaluationForm->status == CompanyPerformanceEvaluationForm::STATUS_INACTIVE) {
488
            return new JsonModel([
491
            return new JsonModel([
489
                'success' => false,
492
                'success' => false,
490
                'data' => 'ERROR_FORM_EVALUATION_IS_INACTIVE'
493
                'data' => 'ERROR_FORM_EVALUATION_IS_INACTIVE'
491
            ]);
494
            ]);
Línea 492... Línea 495...
492
        }
495
        }
493
 
496
 
494
 
497
/*
495
        $companyPerformanceEvaluationFormUserMapper = CompanyPerformanceEvaluationFormUserMapper::getInstance($this->adapter);
498
        $companyPerformanceEvaluationFormUserMapper = CompanyPerformanceEvaluationFormUserMapper::getInstance($this->adapter);
496
        $companyPerformanceEvaluationFormUser = $companyPerformanceEvaluationFormUserMapper->fetchOneByFormIdAndUserId($companyPerformanceEvaluationForm->id, $currentUser->id);
499
        $companyPerformanceEvaluationFormUser = $companyPerformanceEvaluationFormUserMapper->fetchOneByFormIdAndUserId($companyPerformanceEvaluationForm->id, $currentUser->id);
497
        if (!$companyPerformanceEvaluationFormUser) {
500
        if (!$companyPerformanceEvaluationFormUser) {
Línea 509... Línea 512...
509
            return new JsonModel([
512
            return new JsonModel([
510
                'success' => false,
513
                'success' => false,
511
                'data' => 'ERROR_FORM_EVALUATION_ALREADY_YOUR_APPLICATION_IN_THIS_TEST'
514
                'data' => 'ERROR_FORM_EVALUATION_ALREADY_YOUR_APPLICATION_IN_THIS_TEST'
512
            ]);
515
            ]);
513
        }
516
        }
-
 
517
        */
Línea 514... Línea 518...
514
 
518
 
515
        $request = $this->getRequest();
519
        $request = $this->getRequest();
Línea 516... Línea 520...
516
        if ($request->isGet()) {
520
        if ($request->isGet()) {
Línea 517... Línea -...
517
 
-
 
518
 
-
 
519
 
521
 
Línea 520... Línea 522...
520
            // set content 
522
 
Línea 521... Línea 523...
521
 
523
 
Línea 571... Línea 573...
571
            }
573
            }
Línea 572... Línea 574...
572
 
574
 
573
            return $this->renderPDF($currentCompany, $companyPerformanceEvaluationForm, $competencies);
575
            return $this->renderPDF($currentCompany, $companyPerformanceEvaluationForm, $competencies);
Línea 574... Línea -...
574
        }
-
 
575
 
-
 
576
        if ($request->isPost()) {
-
 
577
            $form = new PerformanceEvaluationTestForm();
-
 
578
            $dataPost = $request->getPost()->toArray();
-
 
579
 
-
 
580
            $form->setData($dataPost);
-
 
581
 
-
 
582
            if ($form->isValid()) {
-
 
583
 
-
 
584
 
-
 
585
                $dataPost = (array) $form->getData();
-
 
586
 
-
 
587
                $performanceEvaluationTest = new CompanyPerformanceEvaluationTest();
-
 
588
                $performanceEvaluationTest->company_id = $companyPerformanceEvaluationForm->company_id;
-
 
589
                $performanceEvaluationTest->form_id = $companyPerformanceEvaluationForm->id;
-
 
590
                $performanceEvaluationTest->user_id = $currentUser->id;
-
 
591
                $performanceEvaluationTest->status = $dataPost['status'];
-
 
592
                $performanceEvaluationTest->content = $dataPost['content'];
-
 
593
 
-
 
594
 
-
 
595
                //Check if the form is already registered
-
 
596
                $companyPerformanceEvaluationTest = $companyPerformanceEvaluationTestMapper->fetchOneBy($companyPerformanceEvaluationForm->id, $currentUser->id);
-
 
597
 
-
 
598
 
-
 
599
                $result = $companyPerformanceEvaluationTest ?
-
 
600
                        $companyPerformanceEvaluationTestMapper->update($performanceEvaluationTest, $companyPerformanceEvaluationTest->id) :
-
 
601
                        $companyPerformanceEvaluationTestMapper->insert($performanceEvaluationTest);
-
 
602
 
-
 
603
 
-
 
604
                if ($result) {
-
 
605
                    $this->logger->info('Se agrego un nuevo test de auto-evaluación : ' . $companyPerformanceEvaluationForm->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
-
 
606
 
-
 
607
                    $data = [
-
 
608
                        'success' => true,
-
 
609
                        'data' => $companyPerformanceEvaluationTest ? 'LABEL_RECORD_UPDATED' : 'LABEL_RECORD_ADDED'
-
 
610
                    ];
-
 
611
                } else {
-
 
612
                    $data = [
-
 
613
                        'success' => false,
-
 
614
                        'data' => $companyPerformanceEvaluationTestMapper->getError()
-
 
615
                    ];
-
 
616
                }
-
 
617
 
-
 
618
                return new JsonModel($data);
-
 
619
            } else {
-
 
620
                $messages = [];
-
 
621
                $form_messages = (array) $form->getMessages();
-
 
622
                foreach ($form_messages as $fieldname => $field_messages) {
-
 
623
 
-
 
624
                    $messages[$fieldname] = array_values($field_messages);
-
 
625
                }
-
 
626
 
-
 
627
                return new JsonModel([
-
 
628
                    'success' => false,
-
 
629
                    'data' => $messages
-
 
630
                ]);
-
 
Línea 631... Línea 576...
631
            }
576
        }
632
        }
577
 
633
 
578
 
634
        return new JsonModel([
579
        return new JsonModel([
635
            'success' => false,
580
            'success' => false,
Línea 636... Línea 581...
636
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
581
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
637
        ]);
582
        ]);
638
    }
583
    }
639
 
584
 
-
 
585
    /**
640
    /**
586
     * Render PDF
641
     * Render PDF
587
     * @param Company $currentCompany
642
     * @param type $currentCompany
588
     * @param CompanyPerformanceEvaluationForm $performanceEvaluation
Línea 643... Línea 589...
643
     * @param type $performanceEvaluation
589
     * @param array $competencies
644
     * @return type
590
     * @return mixed