public function listByPersonHelpedAction()
 {
     try {
         if ($this->_isUserAllowed(null, null)) {
             if (!is_null($this->getDomainClass())) {
                 $id = $this->getParam('person');
                 $this->view->assign($this->getViewVarListName(), $this->getDomainClass()->getAllByPersonHelped($id, $this->getViewListOrderBy()));
                 $personHelpedDomain = new Persons_Domain_PersonHelped();
                 $this->view->person_helped = $personHelpedDomain->getById($id);
             } else {
                 throw new Agana_Exception('No domain class defined at list action on ' . __CLASS__);
             }
         }
     } catch (Exception $e) {
         $this->_addExceptionMessage($e);
     }
 }
 public function associateAction()
 {
     $hasException = false;
     // setting the url to be redirected after create record with success
     // or cancel
     if ($this->_hasParam('id') || $this->_hasParam('person')) {
         $id = $this->_hasParam('id') ? $this->_getParam('id') : $this->_getParam('person');
         $urlRedirect = array('action' => 'get', 'controller' => 'person-helped', 'module' => 'persons', 'id' => $this->_getParam('id'));
         $this->setRedirectActionAfterCreateSuccess($urlRedirect);
         $this->setRedirectActionAfterCreateCancel($urlRedirect);
     }
     try {
         if ($this->_isUserAllowed(null, null)) {
             $f = 'Persons_Form_PersonHelpedProject';
             $form = new $f($f::ACTION_ADD);
             $request = $this->getRequest();
             if ($request->isPost()) {
                 $data = $request->getPost();
                 $form->populate($data);
                 if ($form->save->isChecked()) {
                     if ($form->isValid($data)) {
                         try {
                             $id = $this->_associateProject($form->getValues());
                             $urlRedirect = $this->getUrlRedirectionCreateSuccess();
                             if ($this->_useIdCreatedOnUrl && $id) {
                                 $urlRedirect['id'] = $id;
                             }
                             $this->_formSuccess($urlRedirect);
                         } catch (Exception $e) {
                             $this->_addSavingExceptionMessage($e);
                             $hasException = true;
                         }
                     } else {
                         $this->_addFormValidationMessage();
                         $hasException = true;
                     }
                 } else {
                     if ($form->cancel->isChecked()) {
                         $urlRedirect = $this->getUrlRedirectionCreateCancel();
                         $this->_formCancel($urlRedirect);
                     }
                 }
             }
             $this->view->form = $form;
         }
     } catch (Exception $e) {
         $this->_addExceptionMessage($e);
         $hasException = true;
     }
     // fill the id and name person of the form when is calling with a person's id
     $enterIF = $this->_hasParam('id') || $this->_hasParam('person');
     $enterIF = $enterIF && (!$this->getRequest()->isPost() || $this->getRequest()->isPost() && $this->view->form->isErrors());
     if ($enterIF || $hasException) {
         $id = $this->_hasParam('id') ? $this->_getParam('id') : $this->_getParam('person');
         $f = $this->view->form;
         $elname = $f->getElement('person_name');
         $elid = $f->getElement('person_id');
         $ph = new Persons_Domain_PersonHelped();
         $personHelped = $ph->getById($id);
         $person = $personHelped->getPerson();
         if ($person) {
             $elname->setValue($person->name);
             $elid->setValue($person->id);
             $this->view->helped = $personHelped;
         }
     }
 }
 public function pdfRecordAction()
 {
     if ($this->_isUserAllowed(null, null)) {
         if ($this->_hasParam('id') || $this->_hasParam('person')) {
             $id = $this->_hasParam('id') ? $this->_getParam('id') : $this->_getParam('person');
             $domain = new Persons_Domain_Person();
             $person = $domain->getById($id);
             $this->view->person = $person;
             $domain = new Persons_Domain_PersonHelped();
             $reg = $domain->getById($id);
             $this->view->helped = $reg;
         }
     }
 }