public function dadosAction()
 {
     $this->_helper->layout->disableLayout();
     $attributeModel = new AttributeModel();
     $attribute = $attributeModel->fetchAll();
     $i = 0;
     foreach ($attribute as $row) {
         $response->rows[$i]['cell'] = array($row->nmattribute, $row->nmattribute);
         $i++;
     }
     $data = '';
     $this->view->dados = $response;
 }
 public function printviewAction()
 {
     require_once 'fpdf/pdf.php';
     $cdrequest = $_GET["cdrequest"];
     $Request = new RequestModel();
     $Attribute = new AttributeModel();
     $AttributeExaminationMaterial = new AppraisalcontrolModel();
     $Factor = new FactorModel();
     $array = array();
     $req = $Request->fetchAll($Request->getAllRequestData($cdrequest));
     if (count($req) <= 0) {
         die;
     }
     foreach ($req as $row) {
         $dtbirth = new Zend_Date($row['dtbirth'], 'dd-MM-YYYY');
         $dtrequest = new Zend_Date($row['dtrequest'], 'dd-MM-YYYY HH:mm:ss');
         $year = $dtbirth->toString('YYYY');
         $month = $dtbirth->toString('MM');
         $day = $dtbirth->toString('dd');
         $today = new Zend_Date();
         $tdYear = $today->toString('YYYY');
         $tdMonth = $today->toString('MM');
         $tdDay = $today->toString('dd');
         $nrage = 0;
         $nrage = GslabUtils::calcAgeDifference($row['dtbirth']);
         $idade = GslabUtils::calcula_idade($row['dtbirth']);
         if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
             $nrage--;
         }
         if ($row['fgsex'] == 1) {
             $fgsex = "Masculino";
         } else {
             $fgsex = "Feminino";
         }
         $array['nmclient'] = $row['nmclient'];
         $array['nmforward'] = $row['nmforward'];
         $array['nmcompany'] = $row['nmcompany'];
         $array['nmbarcodesample'] = $row['nmbarcodesample'];
         $array['nmcovenant'] = $row['nmcovenant'];
         $array['dtrequest'] = $dtrequest;
         $array['idade'] = $nrage;
         $array['sexo'] = $fgsex;
     }
     $GLOBALS = $array;
     $ano = explode(" ", $nrage);
     $pdf = new PDF();
     $pdf->AddPage();
     $pdf->ln(30);
     $pdf->AliasNbPages('{total}');
     $req2 = $Request->fetchAll($Request->getAllRequestData($cdrequest));
     $appraisalCommon = AppraisalCommon::getInstance($this);
     foreach ($req2 as $rows) {
         $fgstatus = true;
         /* NOME DO EXAME */
         $pdf->SetFont('Courier', 'BI', 11);
         $pdf->Cell(0, 10, strtoupper(utf8_decode($rows['nmexamination'])), 0, 2, 'L');
         $pdf->SetFont('Courier', '', 9);
         $pdf->Cell(0, 0, utf8_decode("Material: " . strtoupper($rows['nmmaterial'])), 0, 0, 'L');
         $pdf->Cell(-30, 0, utf8_decode("Método: Automação CELL-DYN 3000/3500"), 0, 2, 'R');
         $pdf->ln(2);
         // $pdf->Cell(250, 5, utf8_decode("Valores referenciais"), 0, 1, 'C');
         $pdf->ln(2);
         $sons = $this->getExamSons($rows['cdexamination']);
         if (count($sons) > 0) {
             for ($aux_i = 0; $aux_i < count($sons); $aux_i++) {
                 $pdf->SetFont('Courier', '', 10);
                 $pdf->Cell(-360, 5, strtoupper(utf8_decode($sons[$aux_i]['nmexamination'])), 0, 0, 'L');
                 /* NOME DO ATRIBUTO E VALOR */
                 $attributes = $appraisalCommon->getExamAttribs($sons[$aux_i]['cdexaminationmaterial']);
                 //print_r($attributes);
                 $fgstatus = true;
                 foreach ($attributes as $attr) {
                     $vlattr = '';
                     $cdattr = '';
                     $obj = new stdClass();
                     $obj->cdexaminationmaterial = $sons[$aux_i]['cdexaminationmaterial'];
                     $obj->cdrequest = $cdrequest;
                     $obj->cdexamination = $rows['cdexamination'];
                     $obj->cdattribute = $attr['cdattribute'];
                     $vlattribute = $appraisalCommon->getAppraisalAttributeValue($obj);
                     foreach ($vlattribute as $kAttr => $vAttr) {
                         if ($kAttr == 'vlattribute') {
                             $vlattr = $vAttr['vlattribute'];
                         }
                         if ($kAttr == 'cdattribute') {
                             $cdattr = $vAttr['cdattribute'];
                         }
                     }
                     $AttributeData = $Attribute->fetchAll($Attribute->getAtributeNotation($cdattr));
                     foreach ($AttributeData as $key => $value) {
                         if ($key == 'idnotation') {
                             $idnotation = $value['idnotation'];
                         }
                     }
                     $pdf->SetFont('Courier', '', 10);
                     $pdf->ln();
                     $pdf->Cell(40, 5, "    " . str_pad(utf8_decode($attr['nmattribute']), 15, "."), 0, 0, 'L');
                     $pdf->SetFont('Courier', 'B', 10);
                     $pdf->Cell(65, 5, str_pad($vlattr . " " . $idnotation, 15, ".", STR_PAD_LEFT), 0, 0, 'L');
                     $ref = $appraisalCommon->getExamFactors($sons[$aux_i]['cdexaminationmaterial'], $cdattr);
                     foreach ($ref as $vlref) {
                         if ($vlref['fgfactor'] == 1) {
                             $fator = "Idade            Valores referenciais";
                         } else {
                             if ($vlref['fgfactor'] == 2) {
                                 $fator = "Masculino                    Feminino";
                             } else {
                                 if ($vlref['fgfactor'] == 3) {
                                     $fator = "Idade       Masculino        Feminino";
                                 }
                             }
                         }
                     }
                     if ($fgstatus == true) {
                         $pdf->Cell(-1);
                         $pdf->Cell(1, -5, $fator, 0, 0, 'L');
                         $fgstatus = false;
                     }
                     /* VALORES DE REFERÊNCIA */
                     foreach ($ref as $vlref) {
                         /*
                          * AQUI SÃO DEFINIDAS AS REGRAS DE EXIBIÇÃO DO PDF, COLUNAS POR IDADE, SEXO OU AMBOS:
                          * 
                          * fgfactor = 1
                          * ATRIBUTO........VALOR        IDADE    REFERÊNCIA
                          * 
                          * fgfactor = 2
                          * ATRIBUTO........VALOR        MASCULINO    FEMININO
                          * 
                          * fgfactor = 3
                          * ATRIBUTO........VALOR        IDADE    MASCULINO    FEMININO
                          * 
                          */
                         $pdf->SetFont('Courier', '', 9);
                         /* DEFINE QUAL CAMPO DA TABELA ESTÁ PREENCHIDO (VALOR OU NUMÉRICO) E ALOCA À UMA VARIÁVEL */
                         if ($vlref['nrminvalue'] == '' && $vlref['nrmaxvalue'] == '' && $vlref['vlminvalue'] != '' && $vlref['vlmaxvalue'] != '') {
                             $minvalue = $vlref['vlminvalue'];
                             $maxvalue = $vlref['vlmaxvalue'];
                         } else {
                             if ($vlref['nrminvalue'] != '' && $vlref['nrmaxvalue'] != '' && $vlref['vlminvalue'] == '' && $vlref['vlmaxvalue'] == '') {
                                 $minvalue = $vlref['nrminvalue'];
                                 $maxvalue = $vlref['nrmaxvalue'];
                             }
                         }
                         if ($vlref['fgfactor'] == 1) {
                             //SEPARADOS PELA IDADE, DEFINE UMA COLUNA DE RESULTADOS
                             if ($vlref['nrminage'] <= $ano[0] && $vlref['nrmaxage'] >= $ano[0]) {
                                 $pdf->Cell(12, 5, utf8_decode($vlref['nrminage'] . " à " . $vlref['nrmaxage'] . " " . $vlref['nmtimetype']), 0, 0, 'R');
                                 $pdf->Cell(67, 5, utf8_decode($minvalue . " à " . $maxvalue), 0, 0, 'R');
                             }
                         } else {
                             if ($vlref['fgfactor'] == 2) {
                                 //SEPARADOS PELO SEXO, DEFINE DUAS COLUNAS DE RESULTADOS
                                 if ($vlref['fggender'] == 1) {
                                     // MASCULINO
                                     $pdf->Cell(20, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 0, 'R');
                                 } else {
                                     if ($vlref['fggender'] == 2) {
                                         // FEMININO
                                         $pdf->Cell(60, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 1, 'R');
                                     }
                                 }
                             } else {
                                 if ($vlref['fgfactor'] == 3) {
                                     //SEPARADOS PELO SEXO E IDADE, DEFINE TRÊS COLUNAS DE RESULTADOS
                                     if ($vlref['fggender'] == 1) {
                                         // MASCULINO
                                         $pdf->Cell(12, 5, utf8_decode($vlref['nrminage'] . " à " . $vlref['nrmaxage'] . " " . $vlref['nmtimetype']), 0, 0, 'R');
                                         $pdf->Cell(33, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 0, 'R');
                                     } else {
                                         if ($vlref['fggender'] == 2) {
                                             // FEMININO
                                             $pdf->Cell(35, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 1, 'R');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     unset($obj);
                 }
                 $pdf->ln();
                 $pdf->ln();
             }
         }
     }
     $pdf->Output();
     //IMPRIME O PDF NA TELA
     $pdf->Output("teste.pdf");
     //IMPRIME O PDF NO ARQUIVO
 }
 public function examinationAction()
 {
     $cdattribute = $this->_request->getParam("cdattribute");
     //die(var_dump($cdattribute));
     $attributeModel = new AttributeModel();
     $attributeData = $attributeModel->fetchAll($attributeModel->getAttributRelatedToTheMaterial($cdattribute));
     $this->_helper->layout->disableLayout();
     $page = $this->_request->getParam("page", 1);
     $responce = new stdClass();
     $responce->page = $page;
     $responce->total = 10;
     $responce->records = 100;
     $i = 0;
     foreach ($attributeData as $row) {
         $responce->rows[$i]['cell'] = array($row->cdexamination, $row->nmexamination, $row->nmmaterial);
         $i++;
     }
     $this->view->examination = $responce;
 }