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 updatetypingAction() { $AppraisalData = $this->_request->getParam('AppraisalData'); $cdappraisal = $this->_request->getParam('cdappraisal'); $dscomment = $this->_request->getParam('dscomment'); $bootstrap = $this->getInvokeArg('bootstrap'); $gslab_db = $bootstrap->getResource('db'); $appraisalattributeModel = new AppraisalattributeModel(); $appraisalcommentModel = new AppraisalcommentModel(); $gslab_db->beginTransaction(); try { if (strlen($cdappraisal) > 0) { $appraisalattributeModel->delete("cdappraisal = {$cdappraisal}"); if (strlen($dscomment) > 0) { $appraisalcommentModel->update(array('dscomment' => $dscomment), "cdappraisal = {$cdappraisal}"); } else { $appraisalcommentModel->delete("cdappraisal = {$cdappraisal}"); } 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); } } } else { } $gslab_db->commit(); $return[0] = 1; $return[1] = "Digitação atualizada com sucesso!"; $this->view->update = $return; } catch (Exception $e) { $gslab_db->rollback(); $return[0] = 0; $return[1] = "A Digitação não pode ser atualizada!"; $this->view->update = $return; } }