public function deleteCriterion($criterionRow) { DbTable_Criterion::getInstance()->getAdapter()->beginTransaction(); try { $blockId = $criterionRow->getBlockId(); $query = DbTable_Question::getInstance()->select()->from(array('q' => 'Question'), array('Criterion' => 'q.CriterionId'))->where('q.CriterionId = ?', $criterionRow->getId()); $objResultQuestion = DbTable_Question::getInstance()->fetchRow($query); if (!$objResultQuestion) { $criterionRow->delete(); #var_dump($objResultQuestion); die($blockId); DbTable_Criterion::getInstance()->getAdapter()->commit(); DbTable_Criterion::getInstance()->reorder($blockId); } else { return array('status' => false, 'messageError' => 'Há questões para este Critério.'); } return array('status' => true); } catch (Vtx_UserException $e) { DbTable_Criterion::getInstance()->getAdapter()->rollBack(); return array('status' => false, 'messageError' => $e->getMessage()); } catch (Exception $e) { DbTable_Criterion::getInstance()->getAdapter()->rollBack(); throw new Exception($e); } }
public function setCheckerToEnterprise($data) { $enterpriseId = $data['enterprise_id']; $checkerId = $data['checker_id']; $programaId = $data['programa_id']; $tipo = $data['tipo']; $this->DbChecker->getAdapter()->beginTransaction(); try { $where = array('EnterpriseId=?' => $enterpriseId, 'CheckerTypeId=?' => $tipo, 'ProgramaId=?' => $programaId); if ($checkerId == '0') { $this->DbChecker->delete($where); } else { $obj = $this->DbChecker->fetchRow($where); $checkerEnt = $obj ? $obj : $this->DbChecker->createRow(); $checkerEntRow = $checkerEnt->setUserId($checkerId)->setEnterpriseId($enterpriseId)->setCheckerTypeId($tipo)->setProgramaId($programaId); $checkerEnt->save(); } $this->DbChecker->getAdapter()->commit(); return array('status' => true); } catch (Vtx_UserException $e) { DbTable_Question::getInstance()->getAdapter()->rollBack(); return array('status' => false, 'messageError' => $e->getMessage()); } catch (Exception $e) { DbTable_Question::getInstance()->getAdapter()->rollBack(); throw new Exception($e); } }
public function hasChangeAnswerAnnualResult($answerId, $newAnswer, $alternativeRow) { $oldAnswerAnnualResult = DbTable_Question::getInstance()->getAnswerAnnualResult($answerId, $alternativeRow->getId()); $oldRegs = array(); foreach ($oldAnswerAnnualResult as $oldAnswerAnnualResultRow) { $oldRegs[] = $oldAnswerAnnualResultRow->getValue(); } $newRegs = array(); foreach ($newAnswer['aaresult_value'] as $newAnswerAnnualResultRow) { $newRegs[] = $newAnswerAnnualResultRow; } return $oldRegs == $newRegs ? false : true; }
/** * recupera dados Questionario/Bloco/Questao * * @param int $questionnaireId * @param int $blockId * @return array fetchall */ public function getAllByQuestionnaireIdBlockId($questionnaireId, $blockId) { return DbTable_Question::getInstance()->getAllByQuestionnaireIdBlockId($questionnaireId, $blockId); }
public function deleteUser($userRow) { DbTable_User::getInstance()->getAdapter()->beginTransaction(); try { /* Deleta todos os UserLocality */ $whereDeleteUserLocality = array('UserId = ?' => $userRow->getId()); DbTable_UserLocality::getInstance()->delete($whereDeleteUserLocality); /* Deleta todos as UserRole */ $whereDeleteUserRole = array('UserId = ?' => $userRow->getId()); DbTable_UserRole::getInstance()->delete($whereDeleteUserRole); $queryApE = DbTable_AppraiserEnterprise::getInstance()->select()->from(array('ApE' => 'AppraiserEnterprise'), array('AppraiserEnterprise' => 'ApE.UserId'))->where('ApE.UserId = ?', $userRow->getId()); $objResultApE = DbTable_Question::getInstance()->fetchRow($queryApE); if ($objResultApE) { return array('status' => false, 'messageError' => 'Usuário não pode ser deletado, há empresas relacionadas ao mesmo.'); } $userRow->delete(); DbTable_User::getInstance()->getAdapter()->commit(); return array('status' => true); } catch (Vtx_UserException $e) { DbTable_User::getInstance()->getAdapter()->rollBack(); return array('status' => false, 'messageError' => $e->getMessage()); } catch (Exception $e) { DbTable_User::getInstance()->getAdapter()->rollBack(); throw new Exception($e); } }
public function updateQuestionnaire($questionnaireRow, $data) { DbTable_Questionnaire::getInstance()->getAdapter()->beginTransaction(); try { $data = $this->_filterInputIdentify($data)->getUnescaped(); $verifyQuestionnaire = DbTable_Questionnaire::getInstance()->fetchRow(array('Title = ?' => $data['title'], 'Id <> ?' => $questionnaireRow->getId())); if ($verifyQuestionnaire) { return array('status' => false, 'messageError' => $this->_messagesError['questionnaireExistsReg']); } $questionnaireRow->setTitle($data['title'])->setDescription($data['description'])->setLongDescription($data['long_description'])->setOperationBeginning(Vtx_Util_Date::format_iso($data['operation_beginning']))->setOperationEnding(Vtx_Util_Date::format_iso($data['operation_ending']))->setPublicSubscriptionEndsAt(Vtx_Util_Date::format_iso($data['public_subscription_ends_at']))->setInternalSubscriptionEndsAt(Vtx_Util_Date::format_iso($data['internal_subscription_ends_at']))->setDevolutiveCalcId($data['devolutive_id']); $questionnaireRow->save(); DbTable_Question::getInstance()->getAdapter()->commit(); return array('status' => true); } catch (Vtx_UserException $e) { DbTable_Questionnaire::getInstance()->getAdapter()->rollBack(); return array('status' => false, 'messageError' => $e->getMessage()); } catch (Exception $e) { DbTable_Questionnaire::getInstance()->getAdapter()->rollBack(); throw new Exception($e); } }
/** * * retorna objeto com dados das respostas da QuestaoId * * @param type $QuestionId * @param type $toArrayWithAnnualResult -- OFF * @param type $modeEditShowAllQuestions * @return type */ public function getAllByQuestionId($QuestionId, $modeEditShowAllQuestions = false, $returnType = 'array') { $tbAlternative = new DbTable_Alternative(); $questionType = DbTable_Question::getInstance()->fetchRow(array('Id = ?' => $QuestionId))->getQuestionTypeId(); if (!$modeEditShowAllQuestions and $questionType == Model_QuestionType::YESNO_ID) { $where = array('QuestionId = ?' => $QuestionId, 'Designation <= 3'); } elseif (!$modeEditShowAllQuestions and $questionType == Model_QuestionType::ABCD_ID) { $where = array('QuestionId = ?' => $QuestionId, 'Designation <= 4'); } elseif (!$modeEditShowAllQuestions and $questionType == Model_QuestionType::ALWAYS_ID) { $where = array('QuestionId = ?' => $QuestionId, 'Designation <= 3'); } else { $where = array('QuestionId = ?' => $QuestionId); } if ($returnType == 'array') { return $tbAlternative->fetchAll($where)->toArray(); } return $tbAlternative->fetchAll($where); /* if ($toArrayWithAnnualResult) { $AnnualResult = new Model_AnnualResult(); $AnnualResultData = new Model_AnnualResultData(); $getAllAlternative = $objResultAlternative->toArray(); $getAllAnnualResult = $AnnualResult->getAllByQuestionId($QuestionId)->toArray(); $countGetAlternative = count($getAllAlternative); $countAllAnnualResult = count($getAllAnnualResult); for ($l = 0; $l < $countGetAlternative; $l++) { for ($c = 0; $c < $countAllAnnualResult; $c++) { if ($getAllAlternative[$l]['Id'] == $getAllAnnualResult[$c]['AlternativeId']) { $getAllAlternative[$l]['AnnualResult'] = $getAllAnnualResult[$c]; $getAllAlternative[$l]['AnnualResult']['AnnualResultData'] = $AnnualResultData ->getAllAnnualResultDataByAlternativeId($getAllAlternative[$l]['Id']) ->toArray(); } } } return $getAllAlternative; } */ //return $objResultAlternative; }