Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 515 Rev 516
Línea 95... Línea 95...
95
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
95
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
Línea 96... Línea 96...
96
 
96
 
Línea 97... Línea 97...
97
                $queryMapper = QueryMapper::getInstance($this->adapter);
97
                $queryMapper = QueryMapper::getInstance($this->adapter);
98
 
98
 
99
                $select = $queryMapper->getSql()->select();
99
                $select = $queryMapper->getSql()->select();
100
                $select->columns(['uuid', 'status', 'user_id','added_on']);
100
                $select->columns(['uuid', 'status', 'user_id', 'added_on']);
101
                $select->from(['test' => CompanySelfEvaluationTestMapper::_TABLE]);
101
                $select->from(['test' => CompanySelfEvaluationTestMapper::_TABLE]);
Línea 102... Línea 102...
102
                $select->join(['form' => CompanySelfEvaluationFormMapper::_TABLE], 'test.form_id = form.id', ['name', 'language']);
102
                $select->join(['form' => CompanySelfEvaluationFormMapper::_TABLE], 'test.form_id = form.id', ['name', 'language']);
Línea 158... Línea 158...
158
                    $item = [
158
                    $item = [
159
                        'name' => $record['name'],
159
                        'name' => $record['name'],
160
                        'user' => $record['first_name'] . ' ' . $record['last_name'],
160
                        'user' => $record['first_name'] . ' ' . $record['last_name'],
161
                        'language' => $language,
161
                        'language' => $language,
162
                        'status' => $status,
162
                        'status' => $status,
163
                        'added_on'=>$record['added_on'],
163
                        'added_on' => $record['added_on'],
164
                        'actions'=>[
164
                        'actions' => [
165
                            'link_edit' => $record['status'] != CompanySelfEvaluationTest::STATUS_COMPLETED ? $this->url()->fromRoute('self-evaluation/reviews/edit', ['id' => $record['uuid']]) : '',
165
                            'link_edit' => $record['status'] != CompanySelfEvaluationTest::STATUS_COMPLETED ? $this->url()->fromRoute('self-evaluation/reviews/edit', ['id' => $record['uuid']]) : '',
166
                            'link_report' => $record['status'] == CompanySelfEvaluationTest::STATUS_COMPLETED ? $this->url()->fromRoute('self-evaluation/reviews/report', ['id' => $record['uuid']]) : '',
166
                            'link_report' => $record['status'] == CompanySelfEvaluationTest::STATUS_COMPLETED ? $this->url()->fromRoute('self-evaluation/reviews/report', ['id' => $record['uuid']]) : '',
167
                        ]
167
                        ]
168
                       
-
 
169
                    ];
168
                    ];
Línea 170... Línea 169...
170
 
169
 
171
                    array_push($items, $item);
170
                    array_push($items, $item);
Línea 310... Línea 309...
310
        }
309
        }
Línea 311... Línea 310...
311
 
310
 
312
        return new JsonModel($data);
311
        return new JsonModel($data);
Línea 313... Línea -...
313
    }
-
 
314
 
312
    }
315
 
313
 
316
    public function reportAction() {
314
    public function reportAction() {
317
        $request = $this->getRequest();
315
        $request = $this->getRequest();
318
        $currentUserPlugin = $this->plugin('currentUserPlugin');
316
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 353... Línea 351...
353
            //get user data
351
            //get user data
354
            $CompanyUserMapper = UserMapper::getInstance($this->adapter);
352
            $CompanyUserMapper = UserMapper::getInstance($this->adapter);
355
            $userMapper = $CompanyUserMapper->fetchOne($companySelfEvaluationTest->user_id);
353
            $userMapper = $CompanyUserMapper->fetchOne($companySelfEvaluationTest->user_id);
Línea 356... Línea 354...
356
 
354
 
-
 
355
            if ($companySelfEvaluationForm && $userMapper) {
-
 
356
                
-
 
357
                
-
 
358
                // set Data
-
 
359
                $headerFormName = utf8_decode($companySelfEvaluationForm->name);
-
 
360
                $headerUserName = utf8_decode('Informe de Auto-evaluación: ' . trim($userMapper->first_name . ' ' . $userMapper->last_name) . ' al ' . date("m-d-Y H:i:s", strtotime($companySelfEvaluationTest->added_on)));
-
 
361
                $sections = json_decode($companySelfEvaluationTest->content, true);
-
 
362
 
-
 
363
 
-
 
364
                //generate PDF document
-
 
365
                $pdf = new Pdf();
-
 
366
 
-
 
367
                $pdf->AliasNbPages();
-
 
368
                $pdf->AddPage();
-
 
369
                $pdf->pageHeader($headerFormName, $headerUserName);
-
 
370
 
-
 
371
                $valueFormSections = 0;
-
 
372
                $valueFormQuestions = 0;
-
 
373
 
-
 
374
                $countSection = 0;
-
 
375
                
-
 
376
                for ($i = 0, $maxSection = count($sections); $i < $maxSection; $i++) {
-
 
377
                    if ($countSection > 1) {
-
 
378
                        $countSection = 0;
-
 
379
                        $pdf->AddPage();
-
 
380
                        $pdf->pageHeader($headerFormName, $headerUserName);
Línea -... Línea 381...
-
 
381
                    }
-
 
382
 
-
 
383
                    $pdf->SetY(70 + (92 * $countSection));
-
 
384
                    $totalQuestion = 0;
-
 
385
 
-
 
386
                    $valueSection = floatval($sections[$i]['value']);
-
 
387
                    $valueFormSections = $valueFormSections + $valueSection;
-
 
388
 
-
 
389
                    for ($j = 0; $j < count($sections[$i]['questions']); $j++) {
-
 
390
                        $totalQuestion = $totalQuestion + $this->getPtosAnswer($sections[$i]['questions'][$j]);
-
 
391
                    }
-
 
392
 
357
            if ($companySelfEvaluationForm && $userMapper) {
393
                    $labels = [
-
 
394
                        'Total',
-
 
395
                        'Logrado'
-
 
396
                    ];
-
 
397
 
-
 
398
                    $values = [
-
 
399
                        $valueSection,
-
 
400
                        $totalQuestion
-
 
401
                    ];
-
 
402
 
-
 
403
                    $valueFormQuestions = $valueFormQuestions + $totalQuestion;
-
 
404
 
-
 
405
                    $title = '';
-
 
406
                    $filename = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . $sections[$i]['slug_section'] . '.png';
-
 
407
                    $pdf->barChart($labels, $values, $title, $filename);
-
 
408
                    $pdf->SetFont('Arial', '', 8);
-
 
409
                    $pdf->Cell(190, 10, utf8_decode($sections[$i]['name']), 0, 0, 'C');
-
 
410
                    $pdf->setY($pdf->getY() + 10);
-
 
411
                    // Salto de línea
358
 
412
 
-
 
413
                    $pdf->Image($filename, 60, $pdf->getY(), 90);
-
 
414
                    $pdf->setY($pdf->getY() + 60);
-
 
415
 
-
 
416
                    $countSection++;
-
 
417
                }
-
 
418
 
-
 
419
                $pdf->AddPage();
-
 
420
                $pdf->pageHeader($headerFormName, $headerUserName);
-
 
421
 
-
 
422
                $pdf->SetFont('Arial', 'B', 10);
-
 
423
                $pdf->Cell(190, 10, utf8_decode('Desempeño General'), 0, 0, 'C');
-
 
424
                $pdf->setY($pdf->getY() + 10);
-
 
425
 
-
 
426
 
-
 
427
                $labels = [
-
 
428
                    'Total',
-
 
429
                    'Logrado'
-
 
430
                ];
-
 
431
 
-
 
432
                $values = [
359
                return new JsonModel([
433
                    $valueFormSections,
-
 
434
                    $valueFormQuestions
-
 
435
                ];
-
 
436
 
-
 
437
                $filenameGeneral = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . uniqid() . '.png';
-
 
438
                $pdf->barChart($labels, $values, $title, $filenameGeneral);
360
                    'data'=>$this->getValueAnswer()
439
                $pdf->Image($filenameGeneral, 60, $pdf->getY(), 90);
-
 
440
                $pdf->setY($pdf->getY() + 60);
-
 
441
 
361
                ]);
442
                $pdf->SetFont('Arial', '', 8);
-
 
443
                $pdf->setY(60);
362
            
444
 
Línea 363... Línea 445...
363
              
445
                return $pdf->Output();
364
            } else {
446
            } else {
365
 
447
 
Línea 380... Línea 462...
380
        }
462
        }
Línea 381... Línea 463...
381
 
463
 
382
        return new JsonModel($data);
464
        return new JsonModel($data);
Línea -... Línea 465...
-
 
465
    }
-
 
466
 
-
 
467
    /**
-
 
468
     * get total ptos Answer
-
 
469
     * @param type $question
-
 
470
     * @return type
-
 
471
     */
-
 
472
    public function getPtosAnswer($question) {
Línea -... Línea 473...
-
 
473
 
-
 
474
        $ptos = 0;
-
 
475
 
-
 
476
        if ($question['type'] == "open" || $question['type'] == "rating-open" || $question['type'] == "rating-range") {
383
    }
477
 
-
 
478
            $ptos = isset($question['question_value']) ? $question['question_value'] : 0;
-
 
479
        } else {
-
 
480
            if ($question['type'] == 'multiple') {
-
 
481
 
-
 
482
                for ($o = 0; $o < count($question['options']); $o++) {
-
 
483
                    if (in_array($question['options'][$o]['slug_option'], $question['answer'])) {
-
 
484
                        $ptos = $ptos + $question['options'][$o]['value'];
-
 
485
                    }
-
 
486
                }
-
 
487
            } else {
-
 
488
 
-
 
489
                for ($o = 0; $o < count($question['options']); $o++) {
-
 
490
                    if ($question['options'][$o]['slug_option'] == $question['answer']) {
-
 
491
                        $ptos = $question['options'][$o]['value'];
-
 
492
                    }
384
 
493
                }
385
 
494
            }
Línea 386... Línea 495...
386
    public function getValueAnswer(){
495
        }