Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 494 Rev 504
Línea 21... Línea 21...
21
use LeadersLinked\Mapper\QueryMapper;
21
use LeadersLinked\Mapper\QueryMapper;
22
use LeadersLinked\Model\CompanySelfEvaluationForm;
22
use LeadersLinked\Model\CompanySelfEvaluationForm;
23
use LeadersLinked\Mapper\CompanySelfEvaluationFormMapper;
23
use LeadersLinked\Mapper\CompanySelfEvaluationFormMapper;
24
use LeadersLinked\Model\CompanySelfEvaluationTest;
24
use LeadersLinked\Model\CompanySelfEvaluationTest;
25
use Laminas\Db\Sql\Select;
25
use Laminas\Db\Sql\Select;
-
 
26
use LeadersLinked\Library\Pdf;
26
use LeadersLinked\Mapper\CompanySelfEvaluationFormUserMapper;
27
use LeadersLinked\Mapper\CompanySelfEvaluationFormUserMapper;
27
use LeadersLinked\Form\SelfEvaluation\SelfEvaluationTestForm;
28
use LeadersLinked\Form\SelfEvaluation\SelfEvaluationTestForm;
28
use LeadersLinked\Library\Functions;
29
use LeadersLinked\Library\Functions;
Línea 29... Línea 30...
29
 
30
 
Línea 381... Línea 382...
381
            ]);
382
            ]);
382
        }
383
        }
Línea 383... Línea 384...
383
 
384
 
-
 
385
 
384
 
386
        $request = $this->getRequest();
385
        $request = $this->getRequest();
-
 
386
        if ($request->isGet()) {
-
 
387
            return new JsonModel([
-
 
388
                'success' => false,
-
 
389
                'data' => [
-
 
390
                    'name' => $companySelfEvaluationForm->name,
-
 
391
                    'description' => $companySelfEvaluationForm->description,
-
 
392
                    'text' => $companySelfEvaluationForm->text,
-
 
393
                    'content' => json_decode($companySelfEvaluationTest->content)
-
 
394
                ]
-
 
Línea -... Línea 387...
-
 
387
 
-
 
388
        if ($request->isGet()) {
Línea 395... Línea 389...
395
            ]);
389
 
396
        }
390
            return  return $this->renderPDF($companySelfEvaluationForm, $companySelfEvaluationTest, $currentUser);
397
 
391
        }
398
 
392
 
399
        return new JsonModel([
393
        return new JsonModel([
Línea -... Línea 394...
-
 
394
            'success' => false,
-
 
395
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
396
        ]);
-
 
397
    }
-
 
398
 
-
 
399
    /**
-
 
400
     * Render Pdf document
-
 
401
     * @param type $companySelfEvaluationForm
-
 
402
     * @param type $companySelfEvaluationTest
-
 
403
     * @param type $userMapper
-
 
404
     * @return type
-
 
405
     */
-
 
406
    public function renderPDF($companySelfEvaluationForm, $companySelfEvaluationTest, $userMapper) {
-
 
407
 
-
 
408
        // Set Data
-
 
409
        $headerFormName = utf8_decode($companySelfEvaluationForm->name);
-
 
410
        $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)));
-
 
411
        $sections = json_decode($companySelfEvaluationTest->content, true);
-
 
412
        $comments = '';
-
 
413
 
-
 
414
 
-
 
415
        //Generate New PDF
-
 
416
        $pdf = new Pdf();
-
 
417
 
-
 
418
        $pdf->AliasNbPages();
-
 
419
        $pdf->AddPage();
-
 
420
        
-
 
421
        // Set header secundary
-
 
422
        $pdf->pageHeader($headerFormName, $headerUserName);
-
 
423
 
-
 
424
        $valueFormSections = 0;
-
 
425
        $valueFormQuestions = 0;
-
 
426
 
-
 
427
        $countSection = 0;
-
 
428
 
-
 
429
        for ($i = 0, $maxSection = count($sections); $i < $maxSection; $i++) {
-
 
430
            if ($countSection > 1) {
-
 
431
                $countSection = 0;
-
 
432
                $pdf->AddPage();
-
 
433
                $pdf->pageHeader($headerFormName, $headerUserName);
-
 
434
            }
-
 
435
 
-
 
436
            $pdf->SetY(70 + (92 * $countSection));
-
 
437
            $totalQuestion = 0;
-
 
438
 
-
 
439
            $valueSection = floatval($sections[$i]['value']);
-
 
440
            $valueFormSections = $valueFormSections + $valueSection;
-
 
441
 
-
 
442
            for ($j = 0; $j < count($sections[$i]['questions']); $j++) {
-
 
443
                $totalQuestion = $totalQuestion + $this->getPtosAnswer($sections[$i]['questions'][$j]);
-
 
444
                if(isset($sections[$i]['questions'][$j]['comment'])){
-
 
445
                    $comments += $sections[$i]['questions'][$j]['comment'].'\n';
-
 
446
                }
-
 
447
            }
-
 
448
 
-
 
449
            $labels = ['Total', 'Logrado'];
-
 
450
            $values = [$valueSection, $totalQuestion];
-
 
451
            $valueFormQuestions = $valueFormQuestions + $totalQuestion;
-
 
452
 
-
 
453
 
-
 
454
            $filename = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . $sections[$i]['slug_section'] . '.png';
-
 
455
            //$pdf->barChart($labels, $values,'',$filename);
-
 
456
            $pdf->SetFont('Arial', '', 8);
-
 
457
            $pdf->Cell(190, 10, utf8_decode($sections[$i]['name']), 0, 0, 'C');
-
 
458
            $pdf->setY($pdf->getY() + 10);
-
 
459
            // Salto de línea
-
 
460
            //$pdf->Image($filename, 60, $pdf->getY(), 90);
-
 
461
            $pdf->setY($pdf->getY() + 60);
-
 
462
 
-
 
463
            $countSection++;
-
 
464
        }
-
 
465
 
-
 
466
        $pdf->AddPage();
-
 
467
        $pdf->pageHeader($headerFormName, $headerUserName);
-
 
468
 
-
 
469
        $pdf->SetFont('Arial', 'B', 10);
-
 
470
        $pdf->Cell(190, 10, utf8_decode('Desempeño General'), 0, 0, 'C');
-
 
471
        $pdf->setY($pdf->getY() + 10);
-
 
472
 
-
 
473
 
-
 
474
        $labels = ['Total', 'Logrado'];
-
 
475
        $values = [$valueFormSections, $valueFormQuestions];
-
 
476
 
-
 
477
        $filenameGeneral = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . uniqid() . '.png';
-
 
478
        //$pdf->barChart($labels, $values, $title, $filenameGeneral);
-
 
479
        //$pdf->Image($filenameGeneral, 60, $pdf->getY(), 90);
-
 
480
        $pdf->setY($pdf->getY() + 60);
-
 
481
 
-
 
482
        $pdf->SetFont('Arial','B', 10);
-
 
483
        $pdf->Cell(190,10, utf8_decode('Comentarios finales'),0,0,'C');
-
 
484
        $pdf->setY($pdf->getY() + 10);
-
 
485
        
-
 
486
        $pdf->SetFont('Arial','', 8);
-
 
487
        $pdf->MultiCell(180,  8, $comments);
-
 
488
        $pdf->setY(60);
-
 
489
 
-
 
490
        return $pdf->Output();
-
 
491
    }
-
 
492
 
-
 
493
    /**
-
 
494
     * get total ptos Answer
-
 
495
     * @param type $question
-
 
496
     * @return type
-
 
497
     */
-
 
498
    public function getPtosAnswer($question) {
-
 
499
 
-
 
500
        $ptos = 0;
-
 
501
 
-
 
502
        if ($question['type'] == "open" || $question['type'] == "rating-open" || $question['type'] == "rating-range") {
-
 
503
 
-
 
504
            $ptos = isset($question['question_value']) ? $question['question_value'] : 0;
-
 
505
        } else {
-
 
506
            if ($question['type'] == 'multiple') {
-
 
507
 
-
 
508
                for ($o = 0; $o < count($question['options']); $o++) {
-
 
509
                    if (in_array($question['options'][$o]['slug_option'], $question['answer'])) {
-
 
510
                        $ptos = $ptos + $question['options'][$o]['value'];
-
 
511
                    }
-
 
512
                }
-
 
513
            } else {
-
 
514
 
-
 
515
                for ($o = 0; $o < count($question['options']); $o++) {
-
 
516
                    if ($question['options'][$o]['slug_option'] == $question['answer']) {
-
 
517
                        $ptos = $question['options'][$o]['value'];
-
 
518
                    }
-
 
519
                }
-
 
520
            }
400
            'success' => false,
521
        }