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);
     }
 }
Exemplo n.º 2
0
 public function injectGlobalMenu()
 {
     //TODO ACL
     $menuReg = Agana_Module_Menu_Global::getMenuRegistrations();
     Agana_Module_Menu_Global::navigationHeader('menu-persons-header', 'icon-user', 'Persons', -30, $menuReg);
     Agana_Module_Menu_Global::navigationPageMVC('menu-persons-list', 'icon-user', 'List Persons', 'persons', 'persons', 'list', 'content-container', -20, $menuReg);
     /** PERSON HELPED **/
     if (Persons_Domain_PersonHelped::isControllerEnabled()) {
         Agana_Module_Menu_Global::navigationPageMVC('menu-person-helped-list', 'icon-heart', 'List Helped Persons', 'persons', 'person-helped', 'list', 'content-container', -15, $menuReg);
         $menuReport = Agana_Module_Menu_Global::getMenuReports();
         $url = Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
         $projectReposrtUrl = $url->url(array('module' => 'aganacore', 'controller' => 'gm', 'action' => 'report', 'id' => 'project', 'direction' => 'left-sidebar'));
         Agana_Module_Menu_Global::navigationPageURI('menu-reports-projects', 'icon-folder-close', 'Projects', $projectReposrtUrl, -10, $menuReport);
     }
     Agana_Module_Menu_Global::navigationPageMVC('menu-persons-addnew', 'icon-plus', 'Add new Person', 'persons', 'person', 'create', 'content-container', -10, $menuReg);
     Agana_Module_Menu_Global::navigationDivider(-1, $menuReg);
 }
Exemplo n.º 3
0
 /**
  * Returns total ammount of social projects related to person helped
  * 
  * @return intct
  */
 public function getSocialProjectsTotalCount()
 {
     if (is_null($this->socialProjectsTotalCount)) {
         $pd = new Persons_Domain_PersonHelped();
         $this->socialProjectsTotalCount = $pd->getSocialProjectsTotalCount($this->getId());
     }
     return $this->socialProjectsTotalCount;
 }
 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 listSocialProjectsAction()
 {
     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_PersonHelped();
             $projects = $domain->getSocialProjects($id);
             $this->view->socialProjects = $projects;
         }
     }
 }
Exemplo n.º 6
0
 public function _initReports()
 {
     /**
      * Helped
      */
     if (Persons_Domain_PersonHelped::isControllerEnabled($this->getOptions())) {
         $r = new Agana_Print_Menu_Report();
         $r->setGroup('Project', 'Projects Reports');
         Agana_Print_Menu_Global::saveGroup($r);
         $r = new Agana_Print_Menu_Report();
         $r->setReport('Person-Helped-By-Project', 'Persons helped by project', 'icon-double-angle-right', 'Persons_Domain_PersonHelped', 'persons', 'person-helped-project', 'report-by-project', null, 'Project');
         Agana_Print_Menu_Global::saveGroup($r);
     }
 }