Esempio n. 1
0
 public function deleteBlock($blockRow)
 {
     DbTable_Block::getInstance()->getAdapter()->beginTransaction();
     try {
         $questionnaireId = $blockRow->getQuestionnaireId();
         $query = DbTable_Criterion::getInstance()->select()->from(array('c' => 'Criterion'), array('Block' => 'c.BlockId'))->where('c.BlockId = ?', $blockRow->getId());
         $objResultCriterion = DbTable_Criterion::getInstance()->fetchRow($query);
         if (!$objResultCriterion) {
             $blockRow->delete();
             DbTable_Block::getInstance()->getAdapter()->commit();
             DbTable_Block::getInstance()->reorder($questionnaireId);
         } else {
             return array('status' => false, 'messageError' => 'Há critérios para este bloco.');
         }
         return array('status' => true);
     } catch (Vtx_UserException $e) {
         DbTable_Block::getInstance()->getAdapter()->rollBack();
         return array('status' => false, 'messageError' => $e->getMessage());
     } catch (Exception $e) {
         DbTable_Block::getInstance()->getAdapter()->rollBack();
         throw new Exception($e);
     }
 }
Esempio n. 2
0
 public static function getCriterionByPosition($designation, $blockId)
 {
     if (!is_numeric($designation) && !is_numeric($blockId)) {
         return false;
     }
     $select = DbTable_Criterion::getInstance()->select()->from(array('c' => 'Criterion'), array('*'))->where('c.Designation = ?', $designation)->where('c.BlockId = ?', $blockId);
     $objResultCriterion = DbTable_Criterion::getInstance()->fetchRow($select);
     if ($objResultCriterion) {
         return $objResultCriterion;
     }
     return false;
 }