Example #1
0
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\FocusGroup
  */
 protected function makeBean($resultset)
 {
     return FocusGroupFactory::createFromArray($resultset);
 }
Example #2
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $id = $this->getRequest()->getParam('id');
         $focusGroup = FocusGroupQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the FocusGroup with id {$id}"));
         try {
             $this->getFocusGroupCatalog()->beginTransaction();
             FocusGroupFactory::populate($focusGroup, $params);
             $this->getFocusGroupCatalog()->update($focusGroup);
             $this->getFocusGroupCatalog()->unlinkAllNpdSheet($focusGroup->getIdFocusGroups());
             $npds = $this->getRequest()->getParam("npd");
             foreach ($npds as $npd) {
                 $this->getFocusGroupCatalog()->linkToNpdSheet($focusGroup->getIdFocusGroups(), $npd);
             }
             $respondents = $this->getRequest()->getParam("respondent");
             $this->getFocusGroupCatalog()->unlinkAllRespondent($focusGroup->getIdFocusGroups());
             foreach ($respondents as $respondent) {
                 if (!empty($respondent)) {
                     $this->getFocusGroupCatalog()->linkToRespondent($focusGroup->getIdFocusGroups(), $respondent);
                 }
             }
             $this->getFocusGroupCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("Se actualizo correctamente el FocusGroup"));
         } catch (Exception $e) {
             $this->getFocusGroupCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->_redirect('focus-group/list');
 }