public function saveAction()
 {
     $this->_model->getAdapter()->beginTransaction();
     $paramSample = $this->_request->getParam('data');
     //    print_r($paramSample); die;
     $date = $this->_request->getParam('date');
     $time = $this->_request->getParam('time');
     $delivery = $this->_request->getParam('delivery');
     $cdusergslab = $this->_request->getParam('cdusergslab');
     $paramSampleArray = array();
     $RequestArray = array();
     $modelRequest = new RequestexaminationModel();
     try {
         $date = new Zend_Date($date, 'dd-MM-YY');
         $date = $date->toString('YYYY-MM-dd');
         foreach ($paramSample as $row) {
             $paramSampleArray = array('cdrequestexaminationsample' => $row['cdreqexasam'], 'cdusergslab' => $cdusergslab, 'dtsamplereceivingdate' => $date, 'nmsamplereceivingperson' => $delivery);
             $RequestArray = array('fgstatus' => 1);
             $this->_model->insert($paramSampleArray);
             $modelRequest->update($RequestArray, "cdrequestexamination = " . $row['cdrequestexamination']);
             $fgstatus = 1;
         }
         $message = 'Cadastro efetuado com sucesso';
         $this->_model->getAdapter()->commit();
     } catch (Exception $e) {
         $message = "Erro na inserção dos dados." + $e->getMessage();
         $this->_model->getAdapter()->rollBack();
     }
     $this->view->fgstatus = $fgstatus;
 }
 public function saveallAction()
 {
     $AppraisalData = $this->_request->getParam('allAppraisalData');
     $dscomment = $this->_request->getParam('dscomment');
     $userSession = Zend_Session::namespaceGet('Gslab_Session');
     $dateAppraisalTyping = date('Y-m-d');
     $bootstrap = $this->getInvokeArg('bootstrap');
     $gslab_db = $bootstrap->getResource('db');
     $cdappraisalArray = array();
     $appraisalModel = new AppraisalModel();
     $appraisalcommentModel = new AppraisalcommentModel();
     $appraisalattributeModel = new AppraisalattributeModel();
     $requestexaminationModel = new RequestexaminationModel();
     $gslab_db->beginTransaction();
     try {
         foreach ($AppraisalData as $appr) {
             $arrayAppraisal = array();
             $arrayAppraisal['cdrequest'] = $appr[1];
             $arrayAppraisal['cdusergslab'] = $userSession['user']->cdusergslab;
             $arrayAppraisal['dtappraisaltyping'] = $dateAppraisalTyping;
             $cdappraisal = $appraisalModel->insert($arrayAppraisal);
             if (strlen($appr[0]) == 0) {
                 // Insere Observação
                 $arrayAppraisalComment = array();
                 $arrayAppraisalComment['cdappraisal'] = $cdappraisal;
                 $arrayAppraisalComment['dscomment'] = $dscomment;
                 $appraisalcommentModel->insert($arrayAppraisalComment);
                 foreach ($appr[3] as $appAttr) {
                     if ($appAttr['name'] != 'cdappraisaltyping') {
                         // Explode a string em um Array onde as posições:
                         //      0 - CdRequestExamination;  1 - CdExamination;  2 - CdAttribute; 3 - CdExaminationMaterial
                         $txtidentifier = "appraisal_input_";
                         $identifierAppraisal = str_replace($txtidentifier, "", $appAttr['name']);
                         $arrayIdent = explode("_", $identifierAppraisal);
                         $arrayAppraisalAttribute = array();
                         $arrayAppraisalAttribute['cdrequestexamination'] = $arrayIdent[0];
                         $arrayAppraisalAttribute['cdappraisal'] = $cdappraisal;
                         $arrayAppraisalAttribute['cdattribute'] = $arrayIdent[2];
                         $arrayAppraisalAttribute['cdexaminationmaterial'] = $arrayIdent[3];
                         $arrayAppraisalAttribute['vlattribute'] = $appAttr['value'];
                         $appraisalattributeModel->insert($arrayAppraisalAttribute);
                         $requestexaminationModel->update(array("fgstatus" => 5), "cdrequestexamination = {$appr['2']}");
                     }
                 }
                 $cdappraisalArray[] = $cdappraisal;
             } else {
                 $appraisalattributeModel->delete("cdappraisal = {$appr['0']}");
                 $appraisalcommentModel->delete("cdappraisal = {$appr['0']}");
                 if (strlen($appr[4]) > 0) {
                     // Insere Observação
                     $arrayAppraisalComment = array();
                     $arrayAppraisalComment['cdappraisal'] = $appr[0];
                     $arrayAppraisalComment['dscomment'] = $appr[4];
                     $appraisalcommentModel->insert($arrayAppraisalComment);
                 }
                 foreach ($appr[3] as $appAttr) {
                     if ($appAttr['name'] != 'cdappraisaltyping') {
                         // Explode a string em um Array onde as posições:
                         //      0 - CdRequestExamination;  1 - CdExamination;  2 - CdAttribute; 3 - CdExaminationMaterial
                         $txtidentifier = "appraisal_input_";
                         $identifierAppraisal = str_replace($txtidentifier, "", $appAttr['name']);
                         $arrayIdent = explode("_", $identifierAppraisal);
                         $arrayAppraisalAttribute = array();
                         $arrayAppraisalAttribute['cdrequestexamination'] = $arrayIdent[0];
                         $arrayAppraisalAttribute['cdappraisal'] = $appr[0];
                         $arrayAppraisalAttribute['cdattribute'] = $arrayIdent[2];
                         $arrayAppraisalAttribute['cdexaminationmaterial'] = $arrayIdent[3];
                         $arrayAppraisalAttribute['vlattribute'] = $appAttr['value'];
                         $appraisalattributeModel->insert($arrayAppraisalAttribute);
                         $requestexaminationModel->update(array("fgstatus" => 5), "cdrequestexamination = {$appr['2']}");
                     }
                 }
                 $cdappraisalArray[] = $appr[0];
             }
         }
         $gslab_db->commit();
         $return[0] = 1;
         $return[1] = "Todas os resultados digitados foram salvos com sucesso!";
         $return[2] = $cdappraisalArray;
         $this->view->saveall = $return;
     } catch (Exception $e) {
         $gslab_db->rollback();
         $return[0] = 0;
         $return[1] = "Os resultados digitados não puderam ser salvos!";
         $return[2] = '';
         $this->view->saveall = $return;
     }
 }
 public function editexaminationdataAction()
 {
     $values = $this->_request->getParams();
     if (isset($values['dtcollection']) != '') {
         $values['dtcollection'] = GslabUtils::dateToDatabaseFormat($values['dtcollection']);
         $values['fgstatus'] = 1;
     } else {
         $values['fgstatus'] = 2;
     }
     if (isset($values['dtresult']) != '') {
         $values['dtresult'] = GslabUtils::dateToDatabaseFormat($values['dtresult']);
     }
     $array = array();
     $requestExaminationModel = new RequestexaminationModel();
     $examinationMaterialRequestModel = new ExaminationmaterialrequestModel();
     $columns = $requestExaminationModel->info(Zend_Db_Table_Abstract::COLS);
     $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 (isset($values['fgpriority'])) {
             if ($values['fgpriority'] == 'Sim') {
                 $array['fgpriority'] = 1;
             } else {
                 $array['fgpriority'] = 2;
             }
         }
         if (empty($array) && $values['oper'] != 'del') {
             throw new Exception('Dados Incorretos. Confira seus dados e Tente Novamente.');
         } else {
             if ($values['oper'] != 'del') {
                 $requestExaminationModel->update($array, "cdrequestexamination = " . $values['cdrequestexamination']);
             } else {
                 // Apenas altera o status da amostra para "Inativo" no lugar de DELETA-LO do banco de dados
                 $requestExaminationModel->update(array("fgstatus" => 0), "cdrequestexamination = " . $values['id']);
                 //                $examinationMaterialRequestModel->delete("cdrequestexamination = ".$values['id']);
                 //                $requestExaminationModel->delete("cdrequestexamination = ".$values['id']);
             }
         }
         $requestExaminationModel->getAdapter()->commit();
     } catch (exception $e) {
         $requestExaminationModel->getAdapter()->rollback();
         $this->addMessage($e->getMessage());
     }
 }
 public function saveAction()
 {
     //print_r($_POST);die;
     $this->_model->getAdapter()->beginTransaction();
     $paramApp = $this->_request->getParam('data');
     $request = $this->_request->getParam('request');
     $delivery = $this->_request->getParam('delivery');
     $date = $this->_request->getParam('date');
     $time = $this->_request->getParam('time');
     //$RequestArray = array();
     try {
         $date = new Zend_Date($date, 'dd-MM-YY');
         $date = $date->toString('YYYY-MM-dd');
         $date = $date . " " . $time . ":00";
         $paramAppArray = array('cdrequest' => $request, 'nmdeliveryperson' => $delivery, 'dtappraisaldelivery' => $date);
         $this->_model->insert($paramAppArray);
         $message = 'Cadastro efetuado com sucesso';
         $this->_model->getAdapter()->commit();
     } catch (Exception $e) {
         $message = "Erro na inserção dos dados." + $e->getMessage();
         $this->_model->getAdapter()->rollBack();
     }
     $this->view->message = $message;
     $modelRequest = new RequestexaminationModel();
     $RequestArray = array('fgstatus' => 6);
     $modelRequest->update($RequestArray, "fgstatus = 5");
 }
 public function saveAction()
 {
     $bootstrap = $this->getInvokeArg('bootstrap');
     $gslab_db = $bootstrap->getResource('db');
     $deliveryModel = new AppraisaldeliveryModel();
     $modelRequest = new RequestexaminationModel();
     $gslab_db->beginTransaction();
     $paramApp = $this->_request->getParam('data');
     $request = $this->_request->getParam('request');
     $delivery = $this->_request->getParam('delivery');
     $date = $this->_request->getParam('date');
     $time = $this->_request->getParam('time');
     $dtdelivery = GslabUtils::dateToDatabaseFormat($date);
     $datahora = substr($dtdelivery, 0, -8);
     try {
         $paramAppArray = array('cdrequest' => $request, 'nmdeliveryperson' => $delivery, 'dtappraisaldelivery' => $datahora . $time . ":00");
         $deliveryModel->insert($paramAppArray);
         $message = 'Cadastro efetuado com sucesso';
         $gslab_db->commit();
     } catch (Exception $e) {
         $message = "Erro na inserção dos dados." + $e->getMessage();
         $this->_model->getAdapter()->rollBack();
     }
     $this->view->message = $message;
     $RequestArray = array('fgstatus' => 6);
     $modelRequest->update($RequestArray, "cdrequest = " . $request . " AND fgstatus = 5");
 }
 public function saveAction()
 {
     $AppraisalData = $this->_request->getParam('AppraisalData');
     $cdRequest = $this->_request->getParam('cdrequest');
     $cdRequestExamination = $this->_request->getParam('cdrequestexamination');
     $dscomment = $this->_request->getParam('dscomment');
     $userSession = Zend_Session::namespaceGet('Gslab_Session');
     $dateAppraisalTyping = date('Y-m-d');
     $bootstrap = $this->getInvokeArg('bootstrap');
     $gslab_db = $bootstrap->getResource('db');
     $appraisalModel = new AppraisalModel();
     $appraisalattributeModel = new AppraisalattributeModel();
     $appraisalcommentModel = new AppraisalcommentModel();
     $requestexaminationModel = new RequestexaminationModel();
     $gslab_db->beginTransaction();
     try {
         $arrayAppraisal = array();
         $arrayAppraisal['cdrequest'] = $cdRequest;
         $arrayAppraisal['cdusergslab'] = $userSession['user']->cdusergslab;
         $arrayAppraisal['dtappraisaltyping'] = $dateAppraisalTyping;
         $appraisalModel->insert($arrayAppraisal);
         $cdappraisal = $appraisalModel->getAdapter()->lastInsertId();
         // Insere Observação
         $arrayAppraisalComment = array();
         $arrayAppraisalComment['cdappraisal'] = $cdappraisal;
         $arrayAppraisalComment['dscomment'] = $dscomment;
         $appraisalcommentModel->insert($arrayAppraisalComment);
         foreach ($AppraisalData as $appAttr) {
             if ($appAttr['name'] != 'cdappraisaltyping') {
                 // Explode a string em um Array onde as posições:
                 //      0 - CdRequestExamination;  1 - CdExamination;  2 - CdAttribute; 3 - CdExaminationMaterial
                 $txtidentifier = "appraisal_input_";
                 $identifierAppraisal = str_replace($txtidentifier, "", $appAttr['name']);
                 $arrayIdent = explode("_", $identifierAppraisal);
                 $arrayAppraisalAttribute = array();
                 $arrayAppraisalAttribute['cdrequestexamination'] = $arrayIdent[0];
                 $arrayAppraisalAttribute['cdappraisal'] = $cdappraisal;
                 $arrayAppraisalAttribute['cdattribute'] = $arrayIdent[2];
                 $arrayAppraisalAttribute['cdexaminationmaterial'] = $arrayIdent[3];
                 $arrayAppraisalAttribute['vlattribute'] = $appAttr['value'];
                 $appraisalattributeModel->insert($arrayAppraisalAttribute);
             }
         }
         $requestexaminationModel->update(array("fgstatus" => 4), "cdrequestexamination = {$cdRequestExamination}");
         $gslab_db->commit();
         $return[0] = 1;
         $return[1] = "Digitação salva com sucesso!";
         $return[2] = $cdappraisal;
         $this->view->save = $return;
     } catch (Exception $e) {
         $gslab_db->rollback();
         $return[0] = 0;
         $return[1] = "A Digitação não pode ser salva!";
         $return[2] = null;
         $this->view->save = $return;
     }
 }