コード例 #1
0
 public function dadosAction()
 {
     $this->_helper->layout->disableLayout();
     $page = $this->_request->getParam("page", 1);
     $limit = $this->_request->getParam("rows");
     $sidx = $this->_request->getParam("sidx", 1);
     $sord = $this->_request->getParam("sord");
     $array = $this->_request->getParams();
     $sampleModel = new RequestexaminationsampleModel();
     $sample = $sampleModel->fetchALL();
     $count = count($sample);
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $sampleData = $sampleModel->fetchAll($sampleModel->getSampleRequest($array, $sidx, $sord, $limit, $page, $count));
     $responce = new stdClass();
     $responce->page = $page;
     $responce->total = $total_pages;
     $responce->records = $count;
     $i = 0;
     foreach ($sampleData as $rows) {
         switch ($rows->status) {
             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;
         }
         if ($rows->fgpriority == 2) {
             $fgpriority = "Sim";
         } else {
             $fgpriority = "Não";
         }
         $responce->rows[$i]['cell'] = array($rows->nmbarcodesample, $fgstatus, $rows->nmclient, $fgpriority, $rows->cdclient, $rows->cdrequest);
         $i++;
     }
     $this->view->dados = $responce;
 }
コード例 #2
0
 public function saveAction()
 {
     $values = $this->_request->getParam('search');
     $values = json_decode($values, true);
     $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');
     }
     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)) {
         // Realiza a mesma consulta feita para a Pré-Visualização
         $requestExaminationSampleModel = new RequestexaminationsampleModel();
         $mapdataReturn = $requestExaminationSampleModel->fetchAll($requestExaminationSampleModel->getMapData($arrayDepartment, $arrayCovenant, $arrayCollection, $arrayPriority, $dtstartqry, $dtendqry));
         foreach ($mapdataReturn as $uniqueDepartment) {
             $arrayUniqueDepartment[] = $uniqueDepartment['cddepartment'];
         }
         $arrayUniqueDepartment = array_unique($arrayUniqueDepartment);
         // Salva no Banco como Mapa de Trabalho os dados consultados
         $mapModel = new MapsModel();
         $mapSampleModel = new MapsampleModel();
         $requestionExaminationModel = new RequestExaminationModel();
         $dtGeneric = new Zend_Date();
         $dtNow = $dtGeneric->get('YYYY-MM-dd HH:mm:ss');
         $mapModel->getAdapter()->beginTransaction();
         try {
             foreach ($arrayUniqueDepartment as $singleDepartment) {
                 $arrayMap = array('cddepartment' => $singleDepartment, 'fgmapprinted' => '2', 'dtmaprendering' => $dtNow);
                 $mapModel->insert($arrayMap);
                 $lastMapInserted = $mapModel->getAdapter()->lastInsertId();
                 foreach ($mapdataReturn as $singleSample) {
                     if ($singleSample['cddepartment'] == $singleDepartment) {
                         $arrayMapSample = array('cdmap' => $lastMapInserted, 'cdrequestexaminationsample' => $singleSample['cdrequestexaminationsample'], 'nrmappage' => '1');
                         $mapSampleModel->insert($arrayMapSample);
                         $requestionExaminationModel->update(array("fgstatus" => 3), "cdrequestexamination = " . $singleSample['cdrequestexamination']);
                     }
                 }
             }
             $mapModel->getAdapter()->commit();
             $this->view->msgreturn = 1;
         } catch (Exception $e) {
             $mapModel->getAdapter()->rollback();
             $this->view->msgreturn = 2;
         }
     }
 }
コード例 #3
0
 public function saverequestexaminationAction()
 {
     $values = $this->_request->getParams();
     $array = array();
     $arrayCdExamination = array();
     $valueBarCode = array();
     $requestExaminationModel = new RequestexaminationModel();
     $ExaminationmaterialModel = new ExaminationmaterialModel();
     $examinationmaterialrequestModel = new ExaminationmaterialrequestModel();
     $requestExaminationSampleModel = new RequestexaminationsampleModel();
     $covenantPricingModel = new CovenantpricingModel();
     $columns = $requestExaminationModel->info(Zend_Db_Table_Abstract::COLS);
     //Default status de coleta "2 - Faltante" e data de hoje
     $values["fgstatus"] = 2;
     $values["dtcollection"] = date("Y-m-d h:i:s");
     $requestExaminationModel->getAdapter()->beginTransaction();
     try {
         foreach ($values as $id => $value) {
             if (isset($value) && $value != '' && $value != '0' && in_array($id, $columns)) {
                 $array[$id] = addslashes($value);
             } else {
                 if (in_array($id, $columns)) {
                     $array[$id] = null;
                 }
             }
         }
         if (empty($array)) {
             throw new Exception('Dados Incorretos. Confira seus dados e Tente Novamente.');
         } else {
             $requestExaminationModel->insert($array);
             $lastcdrequestExamination = $requestExaminationModel->getAdapter()->lastInsertId();
             $cdexaminationMaterial = $ExaminationmaterialModel->fetchAll($ExaminationmaterialModel->getCdByMaterial($values['cdmaterial'], $values['cdexamination']));
             $examinationmaterialrequestModel->insert(array('cdexaminationmaterial' => $cdexaminationMaterial[0]['cdexaminationmaterial'], 'cdrequestexamination' => $lastcdrequestExamination));
             $requestExaminationSampleModel->insert(array('cdrequestexamination' => $lastcdrequestExamination, 'cdrequest' => $values['cdrequest']));
             // Criando o código de barras da Amostra
             $lastrequestexaminationsample = $requestExaminationSampleModel->getAdapter()->lastInsertId();
             $cdcompany = $requestExaminationSampleModel->fetchAll($requestExaminationSampleModel->getCompanyBySample($lastrequestexaminationsample));
             $valueBarCode['nmbarcodesample'] = GslabUtils::leadingZerosCode($cdcompany[0]['cdcompany'], 2) . '-' . GslabUtils::leadingZerosCode($cdcompany[0]['cdcompany'] . $values['cdrequest'], 6);
             $requestExaminationSampleModel->update($valueBarCode, "requestexaminationsample.cdrequestexaminationsample = {$lastrequestexaminationsample}");
             $requestExaminationModel->getAdapter()->commit();
         }
     } catch (Exception $e) {
         echo $e;
         $this->_model->getAdapter()->rollBack();
     }
 }