public function saveAction()
 {
     $this->_helper->layout->disableLayout();
     $array = $this->_request->getParams();
     $arrayRequest = array();
     if ($array['campo'] == 'dsobservation') {
         $arrayRequest['dsobservation'] = $array['valor'];
     } else {
         $arrayRequest['nmpassword'] = $array['valor'];
     }
     $requestModel = new RequestModel();
     $requestModel->update($arrayRequest, 'cdrequest =' . $array['cdrequest']);
 }
 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;
 }
Esempio n. 3
0
 public function __construct()
 {
     $this->request = RequestModel::currentRequest();
     // provide all controllers with access to the request data
     $this->session = SessionModel::currentSession();
     // provide all controllers with access to the session data
 }
Esempio n. 4
0
 public static function redirect($url, $query_parameters = array())
 {
     $request = RequestModel::currentRequest();
     $redirect_host = parse_url($url, PHP_URL_HOST);
     // Check that we're redirecting to our own domain, avoids potential security issues...
     if (!isValidURL($url)) {
         $url = '/';
         // fallback
     } else {
         if ($redirect_host !== HOSTNAME) {
             // Remote Domain!
             (new Log(SECURITY_LOG))->logMessage("Attempted redirect to external URL: {$url}");
             $url = '/';
             // fallback
         } else {
             // URL is OK, modify the existing URL if parameters were specified...
             if (!empty($query_parameters)) {
                 $url = addQueryParams($url, $query_parameters);
             }
         }
     }
     // OK to Redirect User?
     if (headers_sent($file, $line)) {
         // Log Error
         (new Log(ERROR_LOG))->logMessage("Unable to redirect, headers already sent in {$file} on line {$line}");
         // Ask user for manual redirection...
         echo "Unable to redirect automatically, please click this link: <a href=\"{$url}\">{$url}</a>";
     } else {
         // We're OK to Redirect
         header("Location: {$url}");
     }
     exit;
     // terminate
 }
 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;
 }
Esempio n. 6
0
 public function __construct()
 {
     $this->request = RequestModel::currentRequest();
     // Cookie Provided?
     if (!empty($_COOKIE[self::COOKIE_NAME])) {
         $this->cookie_token = $_COOKIE[self::COOKIE_NAME];
     }
     // Make sure the cookie is good, generate a new token if not (or missing)...
     $this->cookie_token = $this->token();
 }
 function execute(Mpass_Request $client)
 {
     try {
         $header = '';
         $header = $client->read(1024);
         $request = new RequestModel($header);
         $handle = HandleFactory::getResponseHandle($request->isStatic());
         $response = $handle->handle($header);
         $client->write($response);
         Mpass_Log::record($header, __METHOD__);
         return true;
     } catch (Exception $e) {
         $EResponse = 'HTTP/1.0 ' . $e->getCode() . ' ' . $e->getMessage() . chr(13) . chr(10);
         $EResponse .= 'Date:' . date("D, d M Y G:i:s \\G\\M\\T") . chr(13) . chr(10) . chr(13) . chr(10);
         $client->write($EResponse);
         Mpass_Log::record($EResponse, __METHOD__);
         return true;
     }
 }
 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();
     }
 }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
 public function isUserAuthenticated($auth_required = true)
 {
     // Cached Result... (if checked before, return the result)
     if ($this->authentication != self::AUTH_UNKNOWN) {
         return $this->authentication == self::AUTH_PASSED;
     }
     // Check Token Validity -- Avoid DB Overhead
     if (self::isSessionIDValid($this->id)) {
         $db = Database::getConnection();
         $query = $db->query("SELECT user_id, update_timestamp, persistent FROM " . self::TABLE_NAME . " WHERE (id=:id) AND (expiry_timestamp > :now)", array(":id" => $this->id, ":now" => Carbon::now()));
     } else {
         if (!$auth_required) {
             return false;
         }
     }
     // Check Query Result (and that it was executed)
     if (isset($query) && $query && $query->rowCount()) {
         $db_row = $query->fetch(PDO::FETCH_ASSOC);
         $this->user_id = $db_row['user_id'];
         // only set here, force people to call this function first before being allowed to look at the ID
         // We need to renew sessions on a regular basis in order for us to determine when sessions become inactive...
         if (Carbon::parse($db_row['update_timestamp'])->diffInSeconds(Carbon::now()) > self::SESSION_RENEWAL_PERIOD_SECONDS) {
             $this->create($db_row['user_id'], isTrue($db_row['persistent']));
         }
         // renew
         $this->authentication = self::AUTH_PASSED;
         return true;
     } else {
         if ($auth_required) {
             // Determine the Current Target/Action
             $request = RequestModel::currentRequest();
             $router = RouteController::getController();
             $route = $router->findRouteForURL($request->url());
             // Add Query Params?
             $url = $router->urlForAction($route->action(), $route->extractArgs($request->url()));
             if (count($request->queryArgArray())) {
                 $url = addQueryParams($url, $request->queryArgArray());
             }
             // Request a Login
             AppController::requestUserLogin($url);
             // we need to extract and re-inject any args or we lose context...
         } else {
             $this->authentication = self::AUTH_FAILED;
             return false;
         }
     }
 }
Esempio n. 11
0
 public static function assetURL($asset)
 {
     return RequestModel::currentRequest()->protocol() . "://" . HOSTNAME . '/assets/' . $asset;
 }
 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 generateprotocolAction($cdrequest = 1)
    {
        require_once 'fpdf/pdf_protocol.php';
        $gslabSession = Zend_Session::namespaceGet('Gslab_Session');
        $cdcompany = $gslabSession['user']->cdcompany;
        $companyModel = new CompanyModel();
        $requestModel = new RequestModel();
        $sampleModel = new RequestexaminationsampleModel();
        $clientModel = new ClientModel();
        $covenantModel = new CovenantModel();
        $forwardModel = new ForwardModel();
        $examinationModel = new RequestexaminationModel();
        $companyData = $companyModel->fetchRow('cdcompany = ' . $cdcompany);
        $requestData = $requestModel->fetchRow('cdrequest = ' . $cdrequest);
        $sampleData = $sampleModel->fetchRow('cdrequest = ' . $cdrequest);
        $clientData = $clientModel->fetchRow('cdclient = ' . $requestData->cdclient);
        $covenantData = $covenantModel->fetchRow('cdcovenant = ' . $requestData->cdcovenant);
        $forwardData = $forwardModel->fetchRow('cdforward = ' . $requestData->cdforward);
        $dtbirth = new Zend_Date($clientData->dtbirth, 'dd-MM-YYYY');
        $dtrequest = new Zend_Date($requestData->dtrequest, 'dd-MM-YYYY HH:mm');
        $dtdeadline = new Zend_Date($requestData->dtdeadline, 'dd-MM-YYYY HH:mm');
        $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::calcAgeDifferenceShort($clientData->dtbirth);
        $idade = GslabUtils::calcula_idade($clientData->dtbirth);
        if ($clientData->fgsex == 1) {
            $sexo = 'M';
        } else {
            $sexo = 'F';
        }
        if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
            $nrage--;
        }
        $pdf = new PDF_PROTOCOL();
        $pdf->AddPage();
        $pdf->SetFont('Courier', 'B', 11);
        $pdf->ln(55);
        $pdf->Cell(0, 0, utf8_decode(strtoupper($companyData->nmcompany)), 0, 1, 'C');
        $pdf->Cell(0, 8, utf8_decode('LABORATÓRIO DE ANÁLISES CLÍNICAS'), 0, 2, 'C');
        $pdf->Cell(0, -5, str_repeat('_', 81), 0, 1, 'L');
        $pdf->ln(8);
        $pdf->SetFont('Helvetica', '', 9);
        $pdf->Cell(0, 0, utf8_decode(strtoupper($companyData->nmstreet) . ', ' . $companyData->nrnumber), 0, 1, 'L');
        $pdf->ln(4);
        $pdf->Cell(0, 0, 'COMPROVANTE DE COLETA', 0, 1, 'L');
        $pdf->Cell(0, 0, utf8_decode(strtoupper($companyData->nmneighborhood)) . ' - Fone: (47) 3427-3668', 0, 1, 'R');
        //ADICIONAR TELEFONE NA BASE
        $pdf->ln(4);
        $pdf->Cell(0, 0, utf8_decode('Ficha: ') . $requestData->cdcompany . "-" . $requestData->cdrequest, 0, 1, 'L');
        $pdf->Cell(0, 0, 'Senha: 2301', 0, 1, 'R');
        $pdf->ln(8);
        $pdf->Cell(0, 0, utf8_decode('PRONTUÁRIO'), 0, 1, 'L');
        $pdf->ln(4);
        $pdf->SetFont('Helvetica', '', 10);
        $pdf->Cell(15, 5, utf8_decode('Amostra: '), 0, 0, 'L');
        $pdf->Cell(0, 5, $pdf->SetFont('Helvetica', 'BU', 10) . $sampleData->nmbarcodesample, 0, 1, 'L');
        $pdf->ln(4);
        $pdf->SetFont('Helvetica', 'BU', 10);
        $pdf->Write(0, utf8_decode(strtoupper($clientData->nmclient)));
        $pdf->SetFont('Helvetica', '', 10);
        $pdf->ln(8);
        $pdf->Write(0, utf8_decode('Idade: ' . $nrage));
        $pdf->Write(0, utf8_decode(' Sexo: ' . $sexo));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Convênio: ' . $covenantData->nmcovenant));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Médico: ' . $forwardData->idmaincrm . ' - ' . $forwardData->nmforward));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Coleta: ' . strtoupper($companyData->cdcompany . ' - ' . $companyData->nmfantasyname)));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Data e Hora: ') . $dtrequest);
        $pdf->ln(4);
        $pdf->SetFont('Courier', 'B', 11);
        $pdf->Cell(0, 0, str_repeat('_', 81), 0, 1, 'L');
        /* CAIXA LATERAL */
        $pdf->SetFont('Helvetica', '', 10);
        $pdf->SetY(89);
        $pdf->SetX(90);
        $pdf->drawTextBox(utf8_decode('Provável local e data da entrega:
Local: ' . strtoupper($companyData->nmfantasyname) . '
Data: ' . $dtdeadline . '
Salvo quando ocorrer:
    1-	Imprevistos técnicos
    2-	Bloqueio de resultado pelo controle de qualidade
    3-	Atraso no fornecimento de reagentes
Autorizo a coleta do(s) exame(s) acima citado(s) e declaro estar ciente dos riscos quanto ao surgimento de possíveis hematomas no local da punção.
Assinatura do cliente e/ou responsável:__________________________________________'), 109, 50, 'L', 'M');
        /* doze exames */
        $Exames = $examinationModel->fetchAll($examinationModel->getExaminationProtocol($cdrequest));
        $pdf->ln(13);
        // Exames
        $pdf->SetFont('Helvetica', 'B', 9);
        $pdf->SetWidths(array(50, 23, 18));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('Exames'), utf8_decode('Material'), utf8_decode('Status')));
        $pdf->SetFont('Helvetica', '', 9);
        $i = 0;
        foreach ($Exames as $examination) {
            if ($examination['nmmaterial'] == 2) {
                $status = 'Faltante';
            } else {
                $status = 'OK';
            }
            if ($i == 11) {
                $pdf->SetY(148);
            }
            $pdf->SetX(10);
            $pdf->Row(array(utf8_decode($examination['nmexamination']), utf8_decode($examination['nmmaterial']), $status));
            $i++;
        }
        $pdf->ln(5);
        /* -------------------------------------------------------------- */
        /* PESQUISA DE SATISFAÇÃO */
        $pdf->SetFont('Helvetica', '', 7);
        $pdf->SetY(205);
        $pdf->Cell(0, 0, str_repeat(' -', 125), 0, 1, 'L');
        $pdf->SetX(10);
        $pdf->Write(5, utf8_decode('Prezado cliente: com o objetivo de melhorarmos cada vez mais a'));
        $pdf->ln(3);
        $pdf->SetX(10);
        $pdf->Write(5, utf8_decode('qualidade dos nossos serviços e o atendimento à você, solicitamos'));
        $pdf->ln(3);
        $pdf->SetX(10);
        $pdf->Write(5, utf8_decode('a sua gentileza preenchendo o formulário abaixo.'));
        $pdf->ln(5);
        $pdf->SetFont('Helvetica', 'B', 7);
        $pdf->SetWidths(array(30, 13, 13, 13, 13));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('Assinale sua opinião'), utf8_decode('Ótimo'), 'Bom', 'Regular', 'Ruim'));
        $pdf->SetFont('Helvetica', '', 7);
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('1. Como foi o atendimento ao telefone?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('2. Como foi o atendimento da recepção?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('3. Quanto ao conforto e bem estar na sala de espera?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('4. Quanto à coleta do material para o exame?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('5. Quanto ao prazo e entrega dos resultados?'), '', '', '', ''));
        $pdf->SetY(215);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('6. Como conheceu o Laboratório? _______________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('7. Você indicaria o laboratório para outras pessoas?  (  ) Sim   (  ) Não'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('Se NÃO, por quê?____________________________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('8. Conhece nosso '));
        $pdf->SetFont('Helvetica', 'BU', 7);
        $pdf->Write(5, utf8_decode('Programa de Coleta Domiciliar'));
        $pdf->SetFont('Helvetica', '', 7);
        $pdf->Write(5, utf8_decode(' (tel: 3433-2127)?'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('(  ) Sim   (  ) Não'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('9. Sugestões e críticas:_______________________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('__________________________________________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('__________________________________________________________'));
        $pdf->Output();
        //IMPRIME O PDF NA TELA
        $pdf->Output('teste_pro.pdf', "D");
        //IMPRIME O PDF NO ARQUIVO
    }
 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();
     }
 }
 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
 }
Esempio n. 16
0
 protected function initValidators()
 {
     parent::addValidator('name', 'StringEmpty', self::ERROR_NAME_IS_REQUIRED);
     parent::addValidator('email', 'Email', self::ERROR_EMAIL_IS_NOT_VALID);
     parent::addValidator('message', 'StringLength', self::ERROR_MESSAGE_IS_WRONG_FORMAT);
 }
 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 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;
 }
Esempio n. 20
0
 protected function initValidators()
 {
     parent::addValidator('name', 'StringEmpty', self::ERROR_NAME_IS_REQUIRED);
     parent::addValidator('password', 'StringEmpty', self::ERROR_PASSWORD_IS_REQUIRED);
 }
 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*/
 }