public function updateAction()
 {
     // setting the url to be redirected after create record with success
     // or cancel
     if ($this->_hasParam('id') || $this->_hasParam('person')) {
         $id = $this->_getParam('id') ? $this->_getParam('id') : $this->_getParam('person');
         $urlRedirect = array('action' => 'get', 'controller' => 'volunteer', 'module' => 'staff', 'id' => $id);
         $this->setRedirectActionAfterUpdateSuccess($urlRedirect);
         $this->setRedirectActionAfterUpdateCancel($urlRedirect);
     }
     parent::updateAction();
     // fill the id and name person of the form when is calling with a person's id
     if (($this->_hasParam('id') || $this->_hasParam('person')) && (!$this->getRequest()->isPost() || $this->getRequest()->isPost() && $this->view->form->isErrors())) {
         $id = $this->_getParam('id');
         $f = $this->view->form;
         $elname = $f->getElement('person_name');
         $elid = $f->getElement('id');
         $personDomain = new Persons_Domain_Person();
         $person = $personDomain->getById($id);
         if ($person) {
             $elname->setValue($person->name);
             $elid->setValue($person->id);
         }
     }
 }
 public function createAction()
 {
     parent::createAction();
     // preenche os campos com os dados da pessoa de usuário que
     // está usando o sistema
     $id = Zend_Auth::getInstance()->getIdentity()->id;
     $personDomain = new Persons_Domain_Person();
     $person = $personDomain->getById($id);
     $this->view->person_recorded = $person;
     $this->view->person_performed = $person;
     $this->view->person_helped = new Persons_Model_Person();
     if ($this->getRequest()->isPost()) {
         $phId = $this->getRequest()->getParam('person_helped_id', 0);
         if ($phId > 0) {
             $person = $personDomain->getById($phId);
             $this->view->person_helped = $person;
         }
         $ppId = $this->getRequest()->getParam('person_performed_id', 0);
         if ($ppId > 0) {
             $person = $personDomain->getById($ppId);
             $this->view->person_performed = $person;
         } else {
             $this->view->person_performed = new Persons_Model_Person();
         }
     }
 }
Exemplo n.º 3
0
 public function getPerson()
 {
     if (is_null($this->person) && $this->id) {
         $pd = new Persons_Domain_Person();
         $this->person = $pd->getById($this->id);
     }
     return $this->person;
 }
 public function getPerson()
 {
     if ($this->person == null) {
         $pd = new Persons_Domain_Person();
         $this->person = $pd->getById($this->person_id);
     }
     return $this->person == null ? new Persons_Model_Person() : $this->person;
 }
 public function searchExistRegisterAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $pd = new Persons_Domain_Person();
     $registers = $pd->searchBySimilarity($this->_getParam('name'));
     $res = array('found' => count($registers) > 0, 'registers' => $registers);
     $out = json_encode($res);
     echo $out;
 }
Exemplo n.º 6
0
 private function getPerson($person)
 {
     if (is_numeric($person)) {
         $domain = new Persons_Domain_Person();
         $person = $domain->getById($person);
     }
     if (is_a($person, 'Persons_Model_Person')) {
         return $person;
     } else {
         throw new Exception('No valid person passed to PersonDetailsBox helper');
     }
 }
 public function listAction()
 {
     try {
         if ($this->_isUserAllowed(null, null)) {
             $this->view->assign($this->getViewVarListName(), $this->getDomainClass()->getAll($this->getRequest()->getParam('person')));
             $personDomain = new Persons_Domain_Person();
             $this->view->assign('person', $personDomain->getById($this->getRequest()->getParam('person')));
             $this->view->form = new Persons_Form_PersonFingerprint(Persons_Form_PersonFingerprint::ACTION_ADD);
         }
     } catch (Exception $e) {
         $this->_addExceptionMessage($e);
     }
 }
 public function getAction()
 {
     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;
         }
     }
 }
Exemplo n.º 9
0
 public function getSourceUrl($person, $size = 'medium', $params = null)
 {
     if (is_null($person)) {
         $pic = $this->getNoPicture();
     } else {
         if (is_numeric($person)) {
             $domain = new Persons_Domain_Person();
             $person = $domain->getById($person);
         }
         if (is_a($person, 'Persons_Model_Person')) {
             if ($person->getMedia()->file == null) {
                 $pic = $this->getNoPicture();
             } else {
                 $pic = $this->view->url(array('module' => 'media', 'controller' => 'image', 'action' => 'get', 'file' => $person->getMedia()->getFile(), 'size' => $size), null, true);
             }
         } else {
             $pic = $this->getNoPicture();
         }
     }
     return $pic;
 }
Exemplo n.º 10
0
 /**
  * Manipula uma chamada para relatório, mostrando o formulário correto,
  * executando a classe e operação de domínio que levanta os dados e renderizando
  * a view/partial correta
  * <br/>
  * $renderViews são um array onde o índice é o nome de um parâmetro que pode ser
  * recebido no request e o valor é a view a ser renderizada.<br/>
  * O índice 'report' deve ser usado com a view de relatório padrão. 'form'
  * deve ser utilizado para a view de interface para renderizar o formulário.
  * <br/>
  *  ['report'] => 'view-padrao'<br/>
  *  ['form'] => 'view-form'<br/>
  *  ['summarized'] => 'view-summarized'<br/>
  * 
  * @param String $domainClass
  * @param String $domainAction
  * @param String $formClass name of the form class
  * @param ArrayObject $renderViews
  * @param String $viewFolder é o nome do diretório onde estão as views, para ser renderizada com retorno, em geral para o pdf
  * @param Zend_View $view o objeto view
  * @param Zend_Request $request o objeto request
  * @return String
  */
 public function handleRequest($domainClass, $domainAction, $formClass, array $renderViews, $viewFolder, Agana_Print_Meta $metaReport, Zend_Controller_Action $controller)
 {
     //        die(Zend_Debug::dump($controller->view));
     $controller->view->records = null;
     if ($controller->getRequest()->getParam('format')) {
         $layout = Zend_Layout::getMvcInstance();
         $layout->setLayout('report.layout');
         $domain = new $domainClass();
         $controller->view->records = $domain->{$domainAction}(Zend_Auth::getInstance()->getIdentity()->appaccount_id, $controller->getRequest()->getParams());
         $viewToRender = $this->viewToRender($controller->getRequest()->getParams(), $renderViews);
         $controller->view->format = $controller->getParam('format');
         $personDomain = new Persons_Domain_Person();
         $person = $personDomain->getById(Zend_Auth::getInstance()->getIdentity()->person_id);
         $appAccount = $person->getAppaccount();
         $metaReport->setAccountName($appAccount->getName());
         if ($controller->getParam('format') == 'pdf') {
             $report = new Agana_Print_Pdf_Report($metaReport, $controller->view->theme_path);
             $controller->view->assign('report', $report);
             $layout->disableLayout();
             $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
             $viewRenderer->setNoRender(true);
             $content = $controller->view->render($viewFolder . '/' . $viewToRender . '.phtml');
             $report->addPage($content);
             $report->download();
         } else {
             $report = new Agana_Print_Html_Report($metaReport, '');
             $controller->view->assign('report', $report);
             return $controller->render($viewToRender);
         }
     } else {
         $form = new $formClass();
         $controller->view->assign('form', $form);
         $viewToRender = $renderViews['form'];
         return $controller->render($viewToRender);
     }
 }
Exemplo n.º 11
0
 public function pdfFullRecordAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     //$content = $this->view->action('get', 'person', 'persons', $this->_getAllParams());
     $personDomain = new Persons_Domain_Person();
     $person = $personDomain->getById($this->_getParam('id'));
     $appAccount = $person->getAppaccount();
     $pdf = new Agana_Print_Pdf_Report('FICHA PESSOAL', $appAccount->getName(), 'ONG ONLINE', $this->view->theme_path);
     $content = '';
     $allModules = Zend_Registry::getInstance()->get('Person-Dependency-Domain');
     foreach ($allModules as $module) {
         /**
          * get class and method to call to verifie person record reference
          */
         $domain = new $module['domain']['class']();
         $method = isset($module['domain']['method']) ? $module['domain']['method'] : 'getById';
         /**
          * if there is at least a record  for this module
          * builds the get navigation menu entry
          */
         $params = $this->_getAllParams();
         $params['person'] = $this->_getParam('id');
         $hasReference = $domain->{$method}($this->_getParam('id'));
         if ($hasReference) {
             if (isset($module['pdf']['action'])) {
                 $content .= $this->view->action($module['pdf']['action'], $module['pdf']['controller'], $module['pdf']['module'], $params);
             }
         }
     }
     $pdf->addPage($content);
     $pdf->download();
 }
 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_PersonDocs();
             $docs = $domain->getById($id);
             $this->view->docs = $docs;
         }
     }
 }
Exemplo n.º 13
0
 /**
  * Creates a new user based on a person register and associate them
  * 
  * @param int $id The person id with user wil be associated
  */
 public function createForPerson($id)
 {
     $pd = new Persons_Domain_Person();
     $person = $pd->getById($id);
     if ($person && $person->getId()) {
         $user = new User_Model_User();
         $user->setAppaccount_id(Zend_Auth::getInstance()->getIdentity()->appaccount_id);
         $user->setPerson_id($id);
         $user->setStatus(1);
         $name = split(' ', $person->getName());
         $name = array_shift($name);
         $name .= $id;
         $f = new Agana_Filter_Transliterate();
         $name = $f->filter($name);
         $user->setName($name);
         $user->setPwd($name);
         $user->setEmail($person->getEmail() ? $person->getEmail() : $name . '@no.validemail.com');
         $this->setUser($user);
         if ($this->existUser()) {
             throw new Exception('There is already a user in database with one of the key fields: email, name');
         } else {
             return $this->add();
         }
     } else {
         throw new Exception('There is no person with this id');
     }
 }
Exemplo n.º 14
0
 /**
  * @return Persons_Model_Person
  */
 public function getPerson_recorded()
 {
     if (is_null($this->person_recorded) && !is_null($this->person_recorded_id)) {
         $p = new Persons_Domain_Person();
         $this->person_recorded = $p->getById($this->person_recorded_id);
     }
     return $this->person_recorded;
 }
Exemplo n.º 15
0
 /**
  *prepare data to be returned from query
  * @param array
  * @return User_Model_User
  */
 protected function _prepareReturnData($data, $returnArray = true)
 {
     if (is_array($data)) {
         if (!isset($data[0])) {
             $data = array(0 => $data);
         }
         $col = array();
         foreach ($data as $key => $row) {
             if ($row) {
                 $o = new User_Model_User($row);
                 $o->setLastLogin($row['last_login']);
                 $ad = new App_Domain_Account();
                 $app = $ad->getById($row['appaccount_id']);
                 $o->setAppAccount($app);
                 $pd = new Persons_Domain_Person();
                 $person = $pd->getById($row['person_id']);
                 $o->setPerson($person);
                 $col[] = $o;
             }
         }
         if ($returnArray) {
             return $col;
         } else {
             return $col[0];
         }
     } else {
         return null;
     }
 }
Exemplo n.º 16
0
 public function createActivityAction()
 {
     try {
         if ($this->_isUserAllowed(null, null)) {
             if ($this->hasParam('id') == FALSE) {
                 $urlRedirect = $this->getUrlRedirectionCreateCancel();
                 $this->_helper->flashMessenger->addMessage(array('error' => 'Falta id de evento para criar atividade relacionada.'));
                 $this->_formCancel($urlRedirect);
             }
             $form = new Assistance_Form_Activity(Assistance_Form_Activity::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->_createActivityRecord($data);
                             $urlRedirect = array('action' => 'create-activity', 'controller' => 'event', 'module' => 'assistance', 'id' => $data['event_id']);
                             if ($this->_useIdCreatedOnUrl && $id) {
                                 $urlRedirect['id'] = $id;
                             }
                             $this->_formSuccess($urlRedirect);
                         } catch (Exception $e) {
                             $this->_addSavingExceptionMessage($e);
                         }
                     } else {
                         $this->_addFormValidationMessage();
                     }
                 } else {
                     if ($form->cancel->isChecked()) {
                         $urlRedirect = $this->getUrlRedirectionCreateCancel();
                         $this->_formCancel($urlRedirect);
                     }
                 }
             }
             $this->view->form = $form;
             $id = $this->_getParam('id');
             $evDomain = new Assistance_Domain_Event();
             $event = $evDomain->getById($id);
             $this->view->event = $event;
             $activities = $evDomain->getActivities($id, array('orderby' => array('assistance_date DESC', 'assistance_time DESC')));
             $this->view->activities = $activities;
             $id_user = Zend_Auth::getInstance()->getIdentity()->id;
             $personDomain = new Persons_Domain_Person();
             $person = $personDomain->getById($id_user);
             $this->view->person_recorded = $person;
             $this->view->person_performed = $person;
             $this->view->person_helped = new Persons_Model_Person();
             if ($this->getRequest()->isPost()) {
                 $phId = $this->getRequest()->getParam('person_helped_id', 0);
                 if ($phId > 0) {
                     $person = $personDomain->getById($phId);
                     $this->view->person_helped = $person;
                 }
                 $ppId = $this->getRequest()->getParam('person_performed_id', 0);
                 if ($ppId > 0) {
                     $person = $personDomain->getById($ppId);
                     $this->view->person_performed = $person;
                 } else {
                     $this->view->person_performed = new Persons_Model_Person();
                 }
             }
         }
     } catch (Exception $e) {
         $this->_addExceptionMessage($e);
     }
 }
Exemplo n.º 17
0
 /**
  * @return Person_Model_Person
  */
 public function getPerson()
 {
     if (is_null($this->person) || is_null($this->person->getId())) {
         $pd = new Persons_Domain_Person();
         $this->person = $pd->getById($this->person_id);
     }
     if (is_null($this->person)) {
         $this->person = new Persons_Model_Person();
     }
     return $this->person;
 }
Exemplo n.º 18
0
 public function getPerson()
 {
     if (!$this->person) {
         $domain = new Persons_Domain_Person();
         $this->person = $domain->getById($this->id);
     }
     return $this->person;
 }
Exemplo n.º 19
0
 function _initPersonDependency()
 {
     $p = Persons_Domain_Person::getDepencyDomain();
     $dep['domain']['class'] = 'Persons_Domain_Person';
     $dep['menu']['label'] = 'Person';
     $dep['menu']['title'] = 'Person details';
     $dep['menu']['icon'] = 'icon-user-md';
     $dep['menu']['module'] = 'persons';
     $dep['menu']['controller'] = 'person';
     $dep['menu']['action'] = 'get';
     $dep['menu']['order'] = 0;
     // Pdf generation
     $dep['pdf']['module'] = 'persons';
     $dep['pdf']['controller'] = 'person';
     $dep['pdf']['action'] = 'pdf-record';
     array_unshift($p, $dep);
     /**
      * Docs
      */
     unset($dep);
     $dep['domain']['class'] = 'Persons_Domain_PersonDocs';
     $dep['menu']['label'] = 'Docs';
     $dep['menu']['title'] = 'Docs';
     $dep['menu']['icon'] = 'icon-credit-card';
     $dep['menu']['module'] = 'persons';
     $dep['menu']['controller'] = 'person-docs';
     $dep['menu']['action'] = 'get';
     //$dep['menu']['order'] = 1;
     $dep['menu']['new']['title'] = 'Add new Docs';
     $dep['menu']['new']['module'] = 'persons';
     $dep['menu']['new']['controller'] = 'person-docs';
     $dep['menu']['new']['action'] = 'create';
     // Pdf generation
     $dep['pdf']['module'] = 'persons';
     $dep['pdf']['controller'] = 'person-docs';
     $dep['pdf']['action'] = 'pdf-record';
     $p[] = $dep;
     /**
      * Fingerprint
      */
     unset($dep);
     $dep['domain']['class'] = 'Persons_Domain_PersonFingerprint';
     $dep['menu']['label'] = 'Impressão digital';
     $dep['menu']['title'] = 'Impressão digital';
     $dep['menu']['icon'] = 'icon-hand-up';
     $dep['menu']['module'] = 'persons';
     $dep['menu']['controller'] = 'person-fingerprint';
     $dep['menu']['action'] = 'list';
     $dep['menu']['allways-show'] = true;
     //$dep['menu']['order'] = 1;
     $p[] = $dep;
     /**
      * Helped
      */
     if (Persons_Domain_PersonHelped::isControllerEnabled($this->getOptions())) {
         unset($dep);
         $dep['domain']['class'] = 'Persons_Domain_PersonHelped';
         $dep['menu']['label'] = 'Person helped';
         $dep['menu']['title'] = 'Person helped';
         $dep['menu']['icon'] = 'icon-heart';
         $dep['menu']['module'] = 'persons';
         $dep['menu']['controller'] = 'person-helped';
         $dep['menu']['action'] = 'get';
         //$dep['menu']['order'] = 1;
         $dep['menu']['new']['title'] = 'Add new Person helped';
         $dep['menu']['new']['module'] = 'persons';
         $dep['menu']['new']['controller'] = 'person-helped';
         $dep['menu']['new']['action'] = 'create';
         // Pdf generation
         $dep['pdf']['module'] = 'persons';
         $dep['pdf']['controller'] = 'person-helped';
         $dep['pdf']['action'] = 'pdf-record';
         $p[] = $dep;
     }
     Zend_Registry::getInstance()->set('Person-Dependency-Domain', $p);
 }