public function dadosAction()
 {
     $this->_helper->layout->disableLayout();
     $page = $this->_request->getParam("page", 1);
     $array = $this->_request->getParams();
     $requestModel = new RequestModel();
     $total_pages = 0;
     $requestData = $requestModel->fetchAll($requestModel->getControlRequest($array));
     $count = count($requestData);
     if ($page > $total_pages) {
         $page = $total_pages;
     } else {
         $total_pages = 0;
     }
     $responce = new stdClass();
     $responce->page = $page;
     $responce->total = $total_pages;
     $responce->records = $count;
     $i = 0;
     foreach ($requestData as $rows) {
         $responce->rows[$i]['cell'] = array($rows->cdrequest, $rows->nmclient);
         $i++;
     }
     $this->view->dados = $responce;
 }
 public function dadosAction()
 {
     $this->_helper->layout->disableLayout();
     $page = $this->_request->getParam("page", 1);
     $array = $this->_request->getParams();
     $sampleModel = new RequestModel();
     $total_pages = 0;
     $sampleData = $sampleModel->fetchAll($sampleModel->getControlRequest($array));
     $count = count($sampleData);
     if ($page > $total_pages) {
         $page = $total_pages;
     } else {
         $total_pages = 0;
     }
     $responce = new stdClass();
     $responce->page = $page;
     $responce->total = $total_pages;
     $responce->records = $count;
     $i = 0;
     foreach ($sampleData as $rows) {
         switch ($rows->fgstatus) {
             case 1:
                 $fgstatus = "Coletada";
                 break;
             case 2:
                 $fgstatus = "Faltante";
                 break;
             case 3:
                 $fgstatus = "Em Mapa";
                 break;
             case 4:
                 $fgstatus = "Lançada";
                 break;
             case 5:
                 $fgstatus = "Conferida";
                 break;
             case 6:
                 $fgstatus = "Impressa";
                 break;
             case 7:
                 $fgstatus = "Entregue";
                 break;
         }
         $responce->rows[$i]['id'] = $rows->cdrequest;
         $responce->rows[$i]['cell'] = array($rows->cdrequest, $rows->nmclient, $rows->dtrequest, isset($fgstatus) ? $fgstatus : '');
         $i++;
     }
     $this->view->dados = $responce;
 }
 public function dadosAction()
 {
     $array = $this->_request->getParams();
     $requestModel = new RequestModel();
     $requestData = $requestModel->fetchAll($requestModel->getRequestGrid($array));
     $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->cdattribute, $row->nmattribute, $row->fgdatatype, $row->nmmeasurementunit);
         $i++;
     }
     $this->view->attribute = $responce;
 }
 public function modalsamplesaveAction()
 {
     $var = $this->_request->getParams();
     $requestModel = new RequestModel();
     $cdrequest = $this->_request->getParam("code");
     $array = array();
     $requestModel->getAdapter()->beginTransaction();
     try {
         if (isset($cdrequest) && $cdrequest != null) {
             $array['code'] = $cdrequest;
         } else {
             $array['code'] = null;
         }
         $datamodalGrid = $requestModel->fetchAll($requestModel->getDataRequestGridSample($array['code']));
         $page = $this->_request->getParam("page", 1);
         $limit = $this->_request->getParam("rows");
         $count = count($datamodalGrid);
         $responce = new stdClass();
         /* Manipulação de dados para a grid */
         $index = 0;
         foreach ($datamodalGrid as $row) {
             $date = new Zend_Date($row['dtcollection'], 'YYYY-MM-dd HH:mm:ss');
             $date = $date->toString('dd-MM-YYYY');
             $dateresult = new Zend_Date($row['dtresult'], 'YYYY-MM-dd HH:mm:ss');
             $dateresult = $dateresult->toString('dd-MM-YYYY');
             // $responce->rows[$index]['id'] = $row->request;
             $responce->rows[$index]['cell'] = array($row->dtcollection, $row->dtresult, $row->fgstatus, $row->nmbarcodesample, $row->idmaterial, $row->nmexamination);
         }
         $this->view->modalsamplesave = $responce;
         // print_r($responce);
     } catch (Exception $e) {
         $requestModel->getAdapter()->rollback();
         echo $e->getMessage();
     }
 }
 public function indexAction()
 {
     $mapsForm = new MapsForm();
     $mapsForm->addElementsForm();
     $mapsForm->setDecorators(array('FormElements', 'Form'));
     $mapsForm->removeDecorator('form');
     $this->view->fieldsetinputs = $mapsForm;
     $values = $this->_request->getParams();
     $arrayDepartment = array();
     $arrayUniqueDepartment = array();
     $arrayCovenant = array();
     $arrayCollection = array();
     $arrayPriorityexploded = array();
     $arrayPriority = array();
     $dtstartqry = null;
     $dtendqry = null;
     if (isset($values['cddepartment']) && ($values['cddepartment'] != '0' && $values['cddepartment'] != '')) {
         $arrayDepartment = explode(',', $values['cddepartment']);
     }
     if (isset($values['cdcovenant']) && ($values['cdcovenant'] != '0' && $values['cdcovenant'] != '')) {
         $arrayCovenant = explode(',', $values['cdcovenant']);
     }
     if (isset($values['collection']) && ($values['collection'] != '0' && $values['collection'] != '')) {
         $arrayCollection = explode(',', $values['collection']);
     }
     if (isset($values['fgpriority']) && ($values['fgpriority'] != '0' && $values['fgpriority'] != '')) {
         $arrayPriorityexploded = explode(',', $values['fgpriority']);
         foreach ($arrayPriorityexploded as $priority) {
             if ($priority == 'Normal') {
                 $arrayPriority[] = 0;
             } else {
                 if ($priority == 'Urgente') {
                     $arrayPriority[] = 1;
                 }
             }
         }
     }
     if (isset($values['dtstartqry']) && ($values['dtstartqry'] != '0' && $values['dtstartqry'] != '')) {
         $dtstartqry = new Zend_Date($values['dtstartqry'], 'dd-MM-YYYY');
         $dtstartqry = $dtstartqry->toString('YYYY-MM-dd');
     } else {
         $dtstartqry = date("Y-m-d");
     }
     if (isset($values['dtendqry']) && ($values['dtendqry'] != '0' && $values['dtendqry'] != '')) {
         $dtendqry = new Zend_Date($values['dtendqry'], 'dd-MM-YYYY');
         $dtendqry = $dtendqry->toString('YYYY-MM-dd');
     }
     if (!($arrayDepartment == null && $arrayCovenant == null && $arrayCollection == null && $arrayPriorityexploded == null && $arrayPriority == null && $dtstartqry == null && $dtendqry == null)) {
         $requestExaminationSampleModel = new RequestexaminationsampleModel();
         $requestModel = new RequestModel();
         $mapdataReturn = $requestExaminationSampleModel->fetchAll($requestExaminationSampleModel->getMapData($arrayDepartment, $arrayCovenant, $arrayCollection, $arrayPriority, $dtstartqry, $dtendqry));
         foreach ($mapdataReturn as $maprequests) {
             $departments = $requestModel->fetchAll($requestModel->getRequestDepartments($maprequests['cdrequest']));
             foreach ($departments as $uniqueDepartment) {
                 $arrayUniqueDepartment[] = $uniqueDepartment['cddepartment'];
             }
         }
         $arrayUniqueDepartment = array_unique($arrayUniqueDepartment);
         $this->view->mapdata = $mapdataReturn;
         $this->view->departments = $arrayUniqueDepartment;
         $this->view->searchparams = json_encode($values);
     }
 }
 public function searchAction()
 {
     //Parâmetros da pesquisa em comum
     $searchDataArray = array();
     $searchDataArray['startDate'] = $this->_request->getParam("startDate");
     $searchDataArray['endDate'] = $this->_request->getParam("endDate");
     $searchDataArray['sector'] = $this->_request->getParam("cddepartment");
     //paciente
     $searchDataArray['nrsample'] = $this->_request->getParam("nrsample");
     $searchDataArray['cdrequest'] = $this->_request->getParam("cdrequest");
     $searchDataArray['cdpatient'] = $this->_request->getParam("cdpatient");
     //ficha - mapa de trabalho
     $searchDataArray['cdmap'] = $this->_request->getParam("nrplug");
     $searchDataArray['startPage'] = $this->_request->getParam("nrhomepage");
     $searchDataArray['endPage'] = $this->_request->getParam("nrlastpage");
     //ultimos resultados
     $searchDataArray['startTime'] = $this->_request->getParam("startTime");
     $searchDataArray['endTime'] = $this->_request->getParam("endTime");
     $request = new RequestModel();
     $dados = $request->fetchAll($request->getRequestsData($searchDataArray, array(4)));
     $response = new stdClass();
     $index = 0;
     foreach ($dados as $row) {
         switch ($row['fgstatus']) {
             case 4:
                 $fgstatus = "Lançada";
                 break;
             default:
                 $fgstatus = "ERRO!";
                 // Não deve cair aqui pois ainda não está lançado, logo nãpo há conferência
                 break;
         }
         $response->rows[$index]['cell'] = array($row['nmbarcodesample'], $fgstatus, $row['idexamination'], $row['idmaterial'], $row['nmclient'], $row['nmdepartment'], $row['cdrequest']);
         $index++;
     }
     $response = json_encode($response);
     print_r($response);
     return $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 searchAction()
 {
     $var = $this->_request->getParams();
     $controlbillingModel = new RequestModel();
     // <- Instanciando a classe Request
     $cdcovenant = $this->_request->getParam("cdcovenant");
     $nmcolectionplace = $this->_request->getParam("nmcolectionplace");
     $nmdepartament = $this->_request->getParam("nmdepartament");
     $fgstatus = $this->_request->getParam("fgstatus");
     $nmpacient = $this->_request->getParam("nmpacient");
     $responsible = $this->_request->getParam("responsible");
     $dtbegindate = $this->_request->getParam("dtbegindate");
     $dtenddate = $this->_request->getParam("dtenddate");
     $timebeginhour = $this->_request->getParam("timebeginhour");
     $timeendhour = $this->_request->getParam("timeendhour");
     $nrlot = $this->_request->getParam("nrlot");
     $dtmaturity = $this->_request->getParam("dtmaturity");
     $array = array();
     $controlbillingModel->getAdapter()->beginTransaction();
     try {
         if (isset($cdcovenant) && $cdcovenant != '') {
             $array['cdcovenant'] = $cdcovenant;
         } else {
             $array['cdcovenant'] = '';
         }
         if (isset($nmcolectionplace) && $nmcolectionplace != '') {
             $array['nmcolectionplace'] = $nmcolectionplace;
         } else {
             $array['nmcolectionplace'] = '';
         }
         if (isset($nmdepartament) && $nmdepartament != '') {
             $array['nmdepartament'] = $nmdepartament;
         } else {
             $array['nmdepartament'] = '';
         }
         if (isset($fgstatus) && $fgstatus != '') {
             $array['fgstatus'] = $fgstatus;
         } else {
             $array['fgstatus'] = '';
         }
         if (isset($nmpacient) && $nmpacient != '') {
             $array['nmpacient'] = $nmpacient;
         } else {
             $array['nmpacient'] = '';
         }
         if (isset($responsible) && $responsible != '') {
             $array['responsible'] = $responsible;
         } else {
             $array['responsible'] = '';
         }
         if (isset($dtbegindate) && $dtbegindate != '') {
             $array['dtbegindate'] = $dtbegindate;
         } else {
             $array['dtbegindate'] = '';
         }
         if (isset($dtenddate) && $dtenddate != '') {
             $array['dtenddate'] = $dtenddate;
         } else {
             $array['dtenddate'] = '';
         }
         if (isset($timebeginhour) && $timebeginhour != '') {
             $array['timebeginhour'] = $timebeginhour;
         } else {
             $array['timebeginhour'] = '';
         }
         if (isset($timeendhour) && $timeendhour != '') {
             $array['timeendhour'] = $timeendhour;
         } else {
             $array['timeendhour'] = '';
         }
         if (isset($nrlot) && $nrlot != '') {
             $array['nrlot'] = $nrlot;
         } else {
             $array['nrlot'] = '';
         }
         if (isset($dtmaturity) && $dtmaturity != '') {
             $array['dtmaturity'] = $dtmaturity;
         } else {
             $array['dtmaturity'] = '';
         }
         $dados = $controlbillingModel->fetchAll($controlbillingModel->getControlbillingRequest($array['cdcovenant'], $array['dtbegindate'], $array['dtenddate'], $array['timebeginhour'], $array['timeendhour']));
         print_r($dados);
         $dadoscontrol = $controlbillingModel->fetchAll($controlbillingModel->getBillingdadosRequest($array['nmpacient']));
     } catch (Exception $e) {
         $controlbillingModel->getAdapter()->rollback();
         echo $e->getMessage();
     }
 }
 public function printviewAction()
 {
     require_once 'fpdf/pdf.php';
     $cdrequest = $_GET["cdrequest"];
     $Request = new RequestModel();
     $Factor = new FactorModel();
     $Method = new MethodModel();
     $Comment = new AppraisalcommentModel();
     $Patterntext = new PatterntextModel();
     $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));
     foreach ($req2 as $rows) {
         $comentario_text = '';
         /* COMENTÁRIO DOS EXAMES */
         $comments = $Comment->fetchRow($Comment->getAppraisalComments($rows['cdrequestexamination']));
         if (count($comments) > 0) {
             $dscomment = explode(',', $comments->dscomment);
             foreach ($dscomment as $comm) {
                 $comentario = $Patterntext->fetchRow($Patterntext->getPatterntextById($comm));
                 $comentario_text .= utf8_decode($comentario->dspatterntext) . "\n";
             }
         } else {
             $comentario_text = '';
         }
         /* MÉTODO DOS EXAMES */
         $method = $Method->fetchRow($Method->getMethodByCd($rows['cdmethod']));
         $metodo = utf8_decode("Método: " . $method->nmmethod);
         $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, $metodo, 0, 1, 'R');
         $pdf->ln(2);
         $pdf->ln(2);
         $sons = $this->getExamSons($rows['cdexamination'], $cdrequest);
         if (count($sons) > 0) {
             for ($aux_i = 0; $aux_i < count($sons); $aux_i++) {
                 $pdf->SetFont('Courier', '', 9);
                 $pdf->Cell(-15, 5, strtoupper(utf8_decode($sons[$aux_i]['nmexamination'])), 0, 0, 'L');
                 /* NOME DO ATRIBUTO E VALOR */
                 $attributes = $this->getAttrValues($sons[$aux_i]['cdrequestexamination'], $sons[$aux_i]['cdexaminationmaterial']);
                 if ($sons[$aux_i]['fgpercentage'] == 1) {
                     $soma = 0;
                     foreach ($attributes as $sum) {
                         $soma = $soma + $sum['vlattribute'];
                     }
                     $valor_calc = $soma / 100;
                     $pdf->SetFont('Courier', 'B', 9);
                     $pdf->Cell(100, 5, "%", 0, 0, 'R');
                 }
                 $fgstatus = true;
                 foreach ($attributes as $attr) {
                     if ($sons[$aux_i]['fgpercentage'] == 1) {
                         $valor = round($attr['vlattribute'] / $valor_calc, 1);
                         $n = explode(".", $valor);
                         if ($n[1] < 5 && $n[1] != 5) {
                             $vl_at = floor($valor);
                         } else {
                             if ($n[1] > 5 && $n[1] != 5) {
                                 $vl_at = ceil($valor);
                             } else {
                                 if ($n[1] == 5) {
                                     $vl_at = $valor;
                                 }
                             }
                         }
                     } else {
                         $vl_at = '';
                         $valor = '';
                     }
                     $pdf->SetFont('Courier', '', 9);
                     $pdf->ln();
                     $pdf->Cell(40, 5, "    " . str_pad(utf8_decode($attr['nmattribute']), 18, "."), 0, 0, 'L');
                     $pdf->SetFont('Courier', 'B', 9);
                     $pdf->Cell(65, 5, str_pad(utf8_decode($attr['vlattribute']) . " " . utf8_decode($attr['idnotation']), 15, ".", STR_PAD_LEFT) . "     " . $vl_at, 0, 0, 'L');
                     $ref = $Factor->fetchAll($Factor->getAllFactors($attr['cdattribute']));
                     //                        var_dump($ref);die;
                     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', '', 8);
                         /* 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, 0, '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, 0, 'R');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $pdf->ln();
                 $pdf->ln();
             }
         } else {
             $examination = $this->getExam($rows['cdexamination'], $cdrequest);
             for ($aux_i = 0; $aux_i < count($examination); $aux_i++) {
                 /* NOME DO ATRIBUTO E VALOR */
                 $attributes = $this->getAttrValues($examination[$aux_i]['cdrequestexamination'], $examination[$aux_i]['cdexaminationmaterial']);
                 if ($examination[$aux_i]['fgpercentage'] == 1) {
                     $soma = 0;
                     foreach ($attributes as $sum) {
                         $soma = $soma + $sum['vlattribute'];
                     }
                     $valor_calc = $soma / 100;
                     $pdf->SetFont('Courier', 'B', 9);
                     $pdf->Cell(83, 5, "%", 0, 0, 'R');
                 }
                 $rangeruleCount = count($attributes);
                 $fgstatus = true;
                 foreach ($attributes as $attr) {
                     if ($examination[$aux_i]['fgpercentage'] == 1) {
                         $valor = round($attr['vlattribute'] / $valor_calc, 1);
                         $n = explode(".", $valor);
                         if ($n[1] < 5 && $n[1] != 5) {
                             $vl_at = floor($valor);
                         } else {
                             if ($n[1] > 5 && $n[1] != 5) {
                                 $vl_at = ceil($valor);
                             } else {
                                 if ($n[1] == 5) {
                                     $vl_at = $valor;
                                 }
                             }
                         }
                     } else {
                         $vl_at = '';
                         $valor = '';
                     }
                     $pdf->SetFont('Courier', '', 9);
                     $pdf->ln();
                     $pdf->Cell(40, 15, "    " . str_pad(utf8_decode($attr['nmattribute']), 18, "."), 0, 0, 'L');
                     $pdf->SetFont('Courier', 'B', 9);
                     $pdf->Cell(65, 15, str_pad($attr['vlattribute'] . " " . $attr['idnotation'], 15, ".", STR_PAD_LEFT) . "     " . $vl_at, 0, 0, 'L');
                     $ref = $Factor->fetchAll($Factor->getAllFactors($attr['cdattribute']));
                     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', '', 8);
                         $imgRR = "./images/result/rangerule_img-" . $attr['cdrequestexamination'] . "_" . $rows['cdexamination'] . "_" . $attr['cdattribute'] . "_" . $examination[$aux_i]['cdexaminationmaterial'] . ".png";
                         /* 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, 15, utf8_decode($vlref['nrminage'] . " à " . $vlref['nrmaxage'] . " " . $vlref['nmtimetype']), 0, 0, 'R');
                                 if ($rangeruleCount == 1) {
                                     $pdf->Cell(40, 50, $pdf->Image($imgRR, $pdf->GetX() + 5, $pdf->GetY() + 6, 70), 0, 0, 'L', false);
                                 }
                                 $pdf->Cell(67, 8, 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');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $pdf->ln();
                 $pdf->ln();
             }
         }
         if (count($comments) > 0) {
             $pdf->SetFont('Courier', 'B', 9);
             $pdf->Cell(5, 2, utf8_decode("Observações: "), 0, 1, 'L');
             $pdf->ln();
             $pdf->SetFont('Courier', '', 7);
             $pdf->Multicell(0, 3, $comentario_text);
             $pdf->ln();
         }
     }
     $pdf->Output();
     //IMPRIME O PDF NA TELA
     $pdf->Output('teste.pdf', "D");
     //IMPRIME O PDF NO ARQUIVO
 }
 public function covenantbillingdataAction()
 {
     // FUNÇÃO QUE REALIZA A PESQUISA / FILTROS
     $cdcovenant = $this->_request->getParam('cdcovenant');
     $cdcompanyparent = $this->_request->getParam('cdcompanyparent');
     $dtstart = $this->_request->getParam('dtstart');
     $dtend = $this->_request->getParam('dtend');
     if (isset($dtstart) && $dtstart != '') {
         $dtstart = new Zend_Date($dtstart, 'dd-MM-YYYY HH:mm:ss');
         $dtstart = $dtstart->toString('YYYY-MM-dd HH:mm:ss');
     }
     if (isset($dtend) && $dtend != '') {
         $dtend = new Zend_Date($dtend, 'dd-MM-YYYY HH:mm:ss');
         $dtend = $dtend->toString('YYYY-MM-dd HH:mm:ss');
     }
     $responce = 0;
     $convenantModel = new CovenantModel();
     $clientModel = new ClientModel();
     $requestModel = new RequestModel();
     $covenantbillingData = $requestModel->fetchAll($requestModel->getRequestsUnbilled($cdcovenant, $cdcompanyparent, $dtstart, $dtend));
     $responce = new stdClass();
     if (count($covenantbillingData) > 0) {
         $i = 0;
         foreach ($covenantbillingData as $rows) {
             $nmclient = '';
             $cdclient = '';
             $nmconvenant = '';
             $cdcovenant = '';
             $rows['dtrequest'] = new Zend_Date($rows['dtrequest'], 'YYYY-MM-dd HH:mm:ss');
             $rows['dtrequest'] = $rows['dtrequest']->toString('dd/MM/yyyy');
             if ($rows['cdclient'] != null) {
                 $clientData = $clientModel->fetchRow('cdclient=' . $rows['cdclient']);
                 $nmclient = $clientData['nmclient'];
                 $cdclient = $clientData['cdclient'];
             }
             if ($rows['cdcovenant'] != null) {
                 $convenantData = $convenantModel->fetchRow('cdcovenant=' . $rows['cdcovenant']);
                 $nmconvenant = $convenantData->nmcovenant;
                 $cdcovenant = $convenantData['cdcovenant'];
             }
             $responce->rows[$i]['cdrequest'] = $rows['cdrequest'];
             $responce->rows[$i]['cell'] = array($rows['cdrequest'], $rows['dtrequest'], $nmclient, $nmconvenant, $rows['nrguide'], $cdclient, $cdcovenant);
             $i++;
         }
         $this->view->covenantbillingdata = $responce;
     } else {
         $this->view->covenantbillingdata = 'vazio';
     }
 }
 public function searchAction()
 {
     //funcao para realizar busca ao BD
     $var = $this->_request->getParams();
     //Passando os parâmetros para vetores... através do método Request
     $patientsituationModel = new RequestModel();
     // <- Instanciando a classe Request
     $cdpatient = $this->_request->getParam("cdpacient");
     // passando o valor dos parâmetros para as variaveis
     $requisicion = $this->_request->getParam("requisicion");
     $cdagemin = $this->_request->getParam("nrminage");
     $cdagemax = $this->_request->getParam("nrmaxage");
     $fgvip = $this->_request->getParam("vip");
     $maladireta = $this->_request->getParam("maladireta");
     $amostra = $this->_request->getParam("amostra");
     $urgente = $this->_request->getParam("urgente");
     $convenio = $this->_request->getParam("convenio");
     $historicexamination = $this->_request->getParam("historicexamination");
     $cdclientrequest = $this->_request->getParam("cdclientrequest");
     $cdexamination = $this->_request->getParam("cdexamination");
     ////O metodo FetchAll, faz a consulta ao banco de dados(RequestModel) buscando todos os valores da classe instanciada
     // print_r($_POST);die;
     //O metodo beginTransaction inicia uma transaçao com o banco de dados
     $array = array();
     $patientsituationModel->getAdapter()->beginTransaction();
     try {
         if (isset($cdpatient) && $cdpatient != '') {
             $array['cdpacient'] = $cdpatient;
         } else {
             $array['cdpacient'] = '';
         }
         if (isset($requisicion) && $requisicion != '') {
             $array['requisicion'] = $requisicion;
         } else {
             $array['requisicion'] = '';
         }
         if (isset($amostra) && $amostra != '') {
             $array['amostra'] = $amostra;
         } else {
             $array['amostra'] = '';
         }
         if (isset($urgente) && $urgente != '') {
             $array['urgente'] = $urgente;
         } else {
             $array['urgente'] = '';
         }
         if (isset($fgvip) && $fgvip != '') {
             $array['vip'] = $fgvip;
         } else {
             $array['vip'] = '';
         }
         if (isset($maladireta) && $maladireta != '') {
             $array['maladireta'] = $maladireta;
         } else {
             $array['maladireta'] = '';
         }
         if (isset($cdagemax) && $cdagemax != '') {
             $array['nrmaxage'] = $cdagemax;
         } else {
             $array['nrmaxage'] = '';
         }
         if (isset($cdagemin) && $cdagemin != '') {
             $array['nrminage'] = $cdagemin;
         } else {
             $array['nrminage'] = '';
         }
         if (isset($convenio) && $convenio != '') {
             $array['convenio'] = $convenio;
         } else {
             $array['convenio'] = '';
         }
         if (isset($historicexamination) && $historicexamination != '') {
             $array['historicexamination'] = $historicexamination;
         } else {
             $array['historicexamination'] = '';
         }
         if (isset($cdclientrequest) && $cdclientrequest != '') {
             $array['cdclientrequest'] = $cdclientrequest;
         } else {
             $array['cdclientrequest'] = '';
         }
         if (isset($cdexamination) && $cdexamination != '') {
             $array['cdexamination'] = $cdexamination;
         } else {
             $array['cdexamination'] = '';
         }
         /*$dadospatient = $patientsituationModel->fetchAll($patientsituationModel->getPatientSituationCdRequest($array['cdpacient'], $array['requisicion'],
                       $array['amostra'], $array['vip'], $array['maladireta'], $array['urgente'], $array['convenio'], $array['historicexamination']));
         
                      $dadosnmrequest = $patientsituationModel->fetchAll($patientsituationModel->getPatientSituationNmRequest($array['cdclientrequest']));*/
         $dadosnmexamination = $patientsituationModel->fetchAll($patientsituationModel->getNmexaminationTotal($array['cdexamination']));
         print_r($dadosnmexamination);
         die;
     } catch (Exception $e) {
         /* O método rollBack()faz o oposto: ele descarta as alterações feitas durante sua transação. As mudanças são efetivamente desfeitas, e o estado dos dados retorna a como
            ele era antes de você começar sua transação. Entretanto, descartar sua transação não tem efeito sobre mudanças feitas por outras transações rodando concorrentemente. */
         $patientsituationModel->getAdapter()->rollback();
         echo $e->getMessage();
     }
     /*   $index = 0;
                 foreach ($dados as $l) {
                     $responce->rows[$index]['cdexamination'] = $row->cdexamination;
                     $responce->rows[$index]['cell'] = array(
                         $row->cdseqexamination,
                         $row->nmsynonymous,
                         $row->cdexamination,
                         $row->nmexamination
                             //$row->cdsupply
                             //$row->nmsupply
                             //$row->dtcollect
                             //$row->dtresult
     
     /*foreach($dados as $linha){
                               echo " {
                               nmclient:".$linha['nmclient'].",
                               idade:".$linha['age'].",
                               cdclientrequest:".$linha['cdclientrequest'].",
                               cdexamination:".$linha['cdexamination'].",
                               cdcovenante:".$linha['cdcovenant'].",
                               vip:".$linha['vip'].",
                               }";
                              } 
                               
     
                              
     
     
     //enviar para index o resultado da consulta*/
 }
 public function searchAction()
 {
     $var = $this->_request->getParams();
     //        var_dump($var); die;
     //PESQUISA POR PACIENTE
     $cdpatient = null;
     $nrsample = null;
     $cdrequest = null;
     $sector = null;
     $startdate = null;
     $enddate = null;
     //PESQUISA POR MAPA
     $sector2 = null;
     $cdmap = null;
     $homepage = null;
     $lastpage = null;
     $dtfirstmaps = null;
     $dtendmaps = null;
     $page = $this->_request->getParam("page", 1);
     $limit = $this->_request->getParam("rows");
     $sidx = $this->_request->getParam("sidx", 1);
     $sord = $this->_request->getParam("sord");
     //Pesquisa por Paciente
     $requestModel = new RequestModel();
     // <- Instanciando a classe Request
     $cdpatient = $this->_request->getParam("cdpatient");
     // passando o valor dos parâmetros para as variaveis
     $nrsample = $this->_request->getParam("nrsample");
     $cdrequest = $this->_request->getParam("cdrequest");
     $sector = $this->_request->getParam("sector");
     if ($sector == 'Nenhuma opção selecionada') {
         $sector = null;
     }
     $startdate = $this->_request->getParam("startdate");
     $enddate = $this->_request->getParam("enddate");
     //PESQUISA POR MAPA
     $sector2 = $this->_request->getParam("sector2");
     if ($sector2 == 'Nenhuma opção selecionada') {
         $sector2 = null;
     }
     $cdmap = $this->_request->getParam("cdmap");
     $homepage = $this->_request->getParam("homepage");
     $lastpage = $this->_request->getParam("lastpage");
     $dtfirstmaps = $this->_request->getParam("dtfirstmaps");
     $dtendmaps = $this->_request->getParam("dtendmaps");
     $array = array();
     $requestModel->getAdapter()->beginTransaction();
     try {
         //PESQUISA POR PACIENTE
         if (isset($cdpatient) && $cdpatient != null) {
             $array['cdpatient'] = $cdpatient;
         } else {
             $array['cdpatient'] = null;
         }
         if (isset($cdrequest) && $cdrequest != null) {
             $array['cdrequest'] = $cdrequest;
         } else {
             $array['cdrequest'] = null;
         }
         if (isset($nrsample) && $nrsample != null) {
             $array['nrsample'] = $nrsample;
         } else {
             $array['nrsample'] = null;
         }
         if (isset($sector) && $sector != null) {
             $array['sector'] = $sector;
         } else {
             $array['sector'] = null;
         }
         if (isset($startdate) && $startdate != null) {
             $startdate = new Zend_Date($startdate, 'YYYY-MM-dd HH:mm:ss');
             $array['startdate'] = $startdate->toString('YYYY-MM-dd HH:mm:ss');
         } else {
             $array['startdate'] = null;
         }
         if (isset($enddate) && $enddate != null) {
             $enddate = new Zend_Date($enddate, 'YYYY-MM-dd HH:mm:ss');
             $array['enddate'] = $enddate->toString('YYYY-MM-dd HH:mm:ss');
         } else {
             $array['enddate'] = null;
         }
         //PESQUISA POR MAPA DE TRABALHO
         if (isset($sector2) && $sector2 != null) {
             $array['sector2'] = $sector2;
         } else {
             $array['sector2'] = null;
         }
         if (isset($cdmap) && $cdmap != null) {
             $array['cdmap'] = $cdmap;
         } else {
             $array['cdmap'] = null;
         }
         if (isset($homepage) && $homepage != null) {
             $array['homepage'] = $homepage;
         } else {
             $array['homepage'] = null;
         }
         if (isset($lastpage) && $lastpage != null) {
             $array['lastpage'] = $lastpage;
         } else {
             $array['lastpage'] = null;
         }
         if (isset($dtfirstmaps) && $dtfirstmaps != null) {
             $dtfirstmaps = new Zend_Date($dtfirstmaps, 'YYYY-MM-dd HH:mm:ss');
             $array['dtfirstmaps'] = $dtfirstmaps->toString('YYYY-MM-dd HH:mm:ss');
         } else {
             $array['dtfirstmaps'] = null;
         }
         if (isset($dtendmaps) && $dtendmaps != null) {
             $dtendmaps = new Zend_Date($dtendmaps, 'YYYY-MM-dd HH:mm:ss');
             $array['dtendmaps'] = $dtendmaps->toString('YYYY-MM-dd HH:mm:ss');
         } else {
             $array['dtendmaps'] = null;
         }
         // $array['cdpatient'], $array['cdrequest'], $array['nrsample'], $array['sector'], $array['startdate'], $array['enddate'], $array['sector2'], $array['cdplug'], $array['homepage'], $array['lastpage'], $array['dtfirstmaps'], $array['dtendmaps']
         if ($array['cdpatient'] == null && $array['cdrequest'] == null && $array['nrsample'] == null && $array['sector'] == null && $array['startdate'] == null && $array['enddate'] == null && $array['sector2'] == null && $array['cdmap'] == null && $array['homepage'] == null && $array['lastpage'] == null && $array['dtfirstmaps'] == null && $array['dtendmaps'] == null) {
             $dados = null;
             $count = count($dados);
         } else {
             $dados = $requestModel->fetchAll($requestModel->getRequestsData($array, array(3)));
             $count = count($dados);
             $array['rows'] = $this->_request->getParam('rows');
             $array['page'] = $this->_request->getParam('page');
             $array['sidx'] = $this->_request->getParam('sidx');
             $array['sord'] = $this->_request->getParam('sord');
             $dados = $requestModel->fetchAll($requestModel->getRequestsData($array, array(3)));
         }
         if ($count > 0 && $limit > 0) {
             $total_pages = ceil($count / $limit);
         } else {
             $total_pages = 0;
         }
         if ($page > $total_pages) {
             $page = $total_pages;
         }
         $response = new stdClass();
         $response->page = $page;
         $response->total = $total_pages;
         $response->records = $count;
         $index = 0;
         foreach ($dados as $row) {
             switch ($row->fgstatus) {
                 case '1':
                     $fgcollection = "Coletado";
                     break;
                 case '2':
                     $fgcollection = "Faltante";
                     break;
                 case '3':
                     $fgcollection = "Em Mapa";
                     break;
                 case '4':
                     $fgcollection = "Lançada";
                     break;
                 case '5':
                     $fgcollection = "Conferida";
                     break;
             }
             $response->rows[$index]['cell'] = array($row['nmbarcodesample'], $fgcollection, $row['nmexamination'], $row['nmmaterial'], $row['nmclient'], $row['nmdepartment'], $row['cdrequest'], $row['cddepartment']);
             $index++;
         }
         $this->view->dados = $response;
     } catch (Exception $e) {
         $requestModel->getAdapter()->rollback();
         echo $e->getMessage();
     }
 }