Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 518 Rev 519
Línea 351... Línea 351...
351
            //get user data
351
            //get user data
352
            $CompanyUserMapper = UserMapper::getInstance($this->adapter);
352
            $CompanyUserMapper = UserMapper::getInstance($this->adapter);
353
            $userMapper = $CompanyUserMapper->fetchOne($companySelfEvaluationTest->user_id);
353
            $userMapper = $CompanyUserMapper->fetchOne($companySelfEvaluationTest->user_id);
Línea 354... Línea 354...
354
 
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)));
-
 
Línea -... Línea 355...
-
 
355
            if ($companySelfEvaluationForm && $userMapper) {
-
 
356
 
Línea 361... Línea 357...
361
                $sections = json_decode($companySelfEvaluationTest->content, true);
357
                return $this->renderPDF($companySelfEvaluationForm, $companySelfEvaluationTest, $userMapper);
362
 
358
            } else {
-
 
359
 
-
 
360
                $data = [
Línea 363... Línea 361...
363
 
361
                    'success' => false,
-
 
362
                    'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
363
                ];
-
 
364
 
364
                //generate PDF document
365
                return new JsonModel($data);
365
                $pdf = new Pdf();
366
            }
-
 
367
        } else {
Línea 366... Línea 368...
366
 
368
            $data = [
367
                $pdf->AliasNbPages();
369
                'success' => false,
Línea 368... Línea 370...
368
                $pdf->AddPage();
370
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
371
            ];
369
                $pdf->pageHeader($headerFormName, $headerUserName);
372
 
370
 
-
 
-
 
373
            return new JsonModel($data);
371
                $valueFormSections = 0;
374
        }
372
                $valueFormQuestions = 0;
375
 
373
 
376
        return new JsonModel($data);
374
                $countSection = 0;
377
    }
375
                
378
 
376
                for ($i = 0, $maxSection = count($sections); $i < $maxSection; $i++) {
379
    /**
377
                    if ($countSection > 1) {
380
     * Render Pdf document
378
                        $countSection = 0;
-
 
379
                        $pdf->AddPage();
381
     * @param type $companySelfEvaluationForm
380
                        $pdf->pageHeader($headerFormName, $headerUserName);
382
     * @param type $companySelfEvaluationTest
381
                    }
383
     * @param type $userMapper
382
 
-
 
383
                    $pdf->SetY(70 + (92 * $countSection));
384
     * @return type
384
                    $totalQuestion = 0;
385
     */
385
 
-
 
386
                    $valueSection = floatval($sections[$i]['value']);
386
    public function renderPDF($companySelfEvaluationForm, $companySelfEvaluationTest, $userMapper) {
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
                    }
387
 
392
 
388
        // set Data
393
                    $labels = [
-
 
394
                        'Total',
-
 
395
                        'Logrado'
389
        $headerFormName = utf8_decode($companySelfEvaluationForm->name);
396
                    ];
-
 
397
 
-
 
398
                    $values = [
390
        $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)));
399
                        $valueSection,
391
        $sections = json_decode($companySelfEvaluationTest->content, true);
400
                        $totalQuestion
-
 
401
                    ];
-
 
402
 
392
 
403
                    $valueFormQuestions = $valueFormQuestions + $totalQuestion;
-
 
404
 
393
 
405
                    $title = '';
-
 
Línea 406... Línea 394...
406
                    //$filename = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . $sections[$i]['slug_section'] . '.png';
394
        //generate PDF document
407
                    //$pdf->barChart($labels, $values, $title, $filename);
395
        $pdf = new Pdf();
Línea 408... Línea 396...
408
                    $pdf->SetFont('Arial', '', 8);
396
 
409
                    $pdf->Cell(190, 10, utf8_decode($sections[$i]['name']), 0, 0, 'C');
-
 
Línea -... Línea 397...
-
 
397
        $pdf->AliasNbPages();
-
 
398
        $pdf->AddPage();
-
 
399
        $pdf->pageHeader($headerFormName, $headerUserName);
410
                    $pdf->setY($pdf->getY() + 10);
400
 
411
                    // Salto de línea
401
        $valueFormSections = 0;
-
 
402
        $valueFormQuestions = 0;
Línea 412... Línea 403...
412
 
403
 
413
                    //$pdf->Image($filename, 60, $pdf->getY(), 90);
-
 
414
                    $pdf->setY($pdf->getY() + 60);
404
        $countSection = 0;
Línea -... Línea 405...
-
 
405
 
-
 
406
        for ($i = 0, $maxSection = count($sections); $i < $maxSection; $i++) {
Línea 415... Línea -...
415
 
-
 
416
                    $countSection++;
407
            if ($countSection > 1) {
417
                }
408
                $countSection = 0;
418
 
409
                $pdf->AddPage();
Línea 419... Línea 410...
419
                $pdf->AddPage();
410
                $pdf->pageHeader($headerFormName, $headerUserName);
420
                $pdf->pageHeader($headerFormName, $headerUserName);
411
            }
421
 
412
 
422
                $pdf->SetFont('Arial', 'B', 10);
-
 
Línea 423... Línea -...
423
                $pdf->Cell(190, 10, utf8_decode('Desempeño General'), 0, 0, 'C');
-
 
424
                $pdf->setY($pdf->getY() + 10);
-
 
425
 
-
 
426
 
-
 
Línea -... Línea 413...
-
 
413
            $pdf->SetY(70 + (92 * $countSection));
-
 
414
            $totalQuestion = 0;
427
                $labels = [
415
 
-
 
416
            $valueSection = floatval($sections[$i]['value']);
-
 
417
            $valueFormSections = $valueFormSections + $valueSection;
-
 
418
 
-
 
419
            for ($j = 0; $j < count($sections[$i]['questions']); $j++) {
428
                    'Total',
420
                $totalQuestion = $totalQuestion + $this->getPtosAnswer($sections[$i]['questions'][$j]);
Línea 429... Línea 421...
429
                    'Logrado'
421
            }
430
                ];
422
 
Línea 431... Línea 423...
431
 
423
            $labels = ['Total', 'Logrado'];
432
                $values = [
-
 
433
                    $valueFormSections,
424
            $values = [$valueSection, $totalQuestion];
434
                    $valueFormQuestions
-
 
Línea 435... Línea 425...
435
                ];
425
            $valueFormQuestions = $valueFormQuestions + $totalQuestion;
436
 
-
 
437
                //$filenameGeneral = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . uniqid() . '.png';
-
 
438
                //$pdf->barChart($labels, $values, $title, $filenameGeneral);
-
 
439
                //$pdf->Image($filenameGeneral, 60, $pdf->getY(), 90);
426
 
440
                $pdf->setY($pdf->getY() + 60);
427
 
441
 
-
 
Línea 442... Línea -...
442
                $pdf->SetFont('Arial', '', 8);
-
 
443
                $pdf->setY(60);
-
 
Línea -... Línea 428...
-
 
428
            //$filename = $_SERVER['DOCUMENT_ROOT'] . '/../public/pdf/tmp/' . $sections[$i]['slug_section'] . '.png';
-
 
429
            //$pdf->barChart($labels, $values,'',$filename);
-
 
430
            $pdf->SetFont('Arial', '', 8);
-
 
431
            $pdf->Cell(190, 10, utf8_decode($sections[$i]['name']), 0, 0, 'C');
-
 
432
            $pdf->setY($pdf->getY() + 10);
-
 
433
            // Salto de línea
-
 
434
            //$pdf->Image($filename, 60, $pdf->getY(), 90);
-
 
435
            $pdf->setY($pdf->getY() + 60);
-
 
436
 
-
 
437
            $countSection++;
-
 
438
        }
-
 
439
 
444
 
440
        $pdf->AddPage();
445
                return $pdf->Output();
441
        $pdf->pageHeader($headerFormName, $headerUserName);
Línea 446... Línea 442...
446
            } else {
442
 
447
 
443
        $pdf->SetFont('Arial', 'B', 10);
448
                $data = [
444
        $pdf->Cell(190, 10, utf8_decode('Desempeño General'), 0, 0, 'C');