/**
  * Form to edit an object
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $this->view->notificationType = NotificationTypeQuery::create()->findByPK($id);
     $this->view->notificationTypeAccessRoles = NotificationTypeQuery::create()->innerJoinAccessRole()->whereAdd('NotificationType.' . NotificationType::ID_NOTIFICATION_TYPE, $id)->addColumn('AccessRole.' . AccessRole::ID_ACCESS_ROLE)->fetchCol();
     $this->view->contentTitle = $this->i18n->_('Edit Notification Type');
     $this->view->accessRoles = AccessRoleQuery::create()->find()->toCombo();
 }
Beispiel #2
0
 /**
  *
  */
 protected function initIdAccessRoleElement()
 {
     $element = new \Zend_Form_Element_Select('id_access_role');
     $options = \Application\Query\AccessRoleQuery::create()->find()->toCombo();
     $element->addMultiOptions($options);
     $element->setLabel($this->getTranslator()->_('IdAccessRole'));
     $element->addValidator($this->validator->getFor('id_access_role'));
     $element->addFilter($this->filter->getFor('id_access_role'));
     $element->setRequired(true);
     $this->addElement($element);
     $this->elements['id_access_role'] = $element;
 }
Beispiel #3
0
 public function exportToExcelAction()
 {
     $params = $this->getRequest()->getParams();
     if (!empty($params['username'])) {
         $params['username'] = '******' . $params['username'] . '%';
     }
     $query = UserQuery::create()->filter($params)->find();
     $headers = array('ID', 'Access Role', 'Username', 'Name', 'Second Name', 'Last Name', 'Status');
     foreach ($query as $key => $object) {
         $content[$key][] = $object->getIdUser();
         $content[$key][] = AccessRoleQuery::create()->findByPK($object->getIdAccessRole())->getName();
         $content[$key][] = utf8_encode($object->getUsername());
         $content[$key][] = utf8_encode($object->getName());
         $content[$key][] = utf8_encode($object->getSecondName());
         $content[$key][] = utf8_encode($object->getLastName());
         $content[$key][] = $object->getStatusName();
     }
     $title = $this->i18n->_('Users Report');
     $filename = 'users_report';
     $report = new SimpleListReport();
     $report->setTableHeaders($headers);
     $report->setTableContent($content);
     $report->setTableTitle($title);
     $report->setFilename($filename);
     // 		$report->setTableColumnsWidth($columsWidth);
     $report->createSpreadsheet();
 }
Beispiel #4
0
 /**
  *
  * @param NotificationType $notificationType
  * @return array
  */
 private function getEmails(NotificationType $notificationType)
 {
     $emails = new EmailCollection();
     $regexp = self::EMAIL_REGEXP;
     $notificationTypeCatalog = $this->getCatalog('NotificationTypeCatalog');
     $accessRoles = AccessRoleQuery::create()->whereAdd(AccessRole::ID_ACCESS_ROLE, $notificationTypeCatalog->getAllAccessRoles($notificationType->getIdNotificationType()), AccessRoleQuery::IN)->find();
     while ($accessRoles->valid()) {
         $accessRole = $accessRoles->read();
         $users = UserQuery::create()->whereAdd(User::ID_ACCESS_ROLE, $accessRole->getIdAccessRole())->whereAdd(User::NOTIFICATIONS, User::$ReceiveNotifications['Yes'])->actives()->find();
         while ($users->valid()) {
             $user = $users->read();
             $email = EmailQuery::create()->innerJoinPerson()->whereAdd('Person.id_person', $user->getIdPerson())->findOne();
             if (!$email instanceof Email) {
                 $eventDispatcher = $this->getEventDispatcherService();
                 $eventDispatcher->createUserMissingEmailNotification($user, ErrorEvent::MISSING_USER_EMAIL, $notificationType);
                 continue;
             } elseif (!preg_match($regexp, $email->getEmail())) {
                 // 					$eventDispatcher->createIncorectUserEmailNotification($user, ErrorEvent::INCORRECT_USER_EMAIL, $notificationType);
             } else {
                 $emails->append($email);
             }
         }
     }
     $emailsArray = array_values($emails->filter(function (Email $email) use($regexp) {
         return preg_match($regexp, $email->getEmail());
     })->toCombo());
     return array_unique($emailsArray);
 }
 /**
  * @author Erick Guevara Martínez
  */
 public function getAccessRoleCountriesAction()
 {
     $idAccesRole = $this->getRequest()->getParam("id_access_role");
     $accessRoleCountries = AccessRoleQuery::create()->innerJoinAccesRoleCountry()->addColumn("AccessRole2Country.id_country")->whereAdd("AccessRole2Country.id_access_role", $idAccesRole)->fetchCol();
     if (count($accessRoleCountries) > 0) {
         $countries = CountryQuery::create()->whereAdd(Country::CODE, $accessRoleCountries)->find();
     } else {
         $countries = new CountryCollection();
     }
     die(Zend_Json::encode(array("accessRoleCountries" => $countries->toCombo())));
 }
Beispiel #6
0
 /**
  * Obtiene los AccessRole de la Base de Datos
  * @return array
  */
 protected function getAccessRolesFromDatabase()
 {
     return Query\AccessRoleQuery::create()->whereAdd(Bean\AccessRole::STATUS, 1)->fetchIds();
 }
Beispiel #7
0
 public function getAvailableSuppliersAction()
 {
     $string = "%" . $this->getRequest()->getParam("searchString") . "%";
     $accessRole = $this->getUser()->getAccessRole();
     $countries = AccessRoleQuery::create()->innerJoinAccesRoleCountry()->addColumn("AccessRole2Country.id_country")->whereAdd("AccessRole2Country.id_access_role", $accessRole->getIdAccessRole())->fetchCol();
     $sapSupplierQuery = SapSupplierQuery::create()->innerJoinSapSupplierAddress()->whereAdd("CRD1." . SapSupplierAddress::COUNTRY, $countries);
     $sapSupplierQuery->where()->setOR();
     $suppliers = $sapSupplierQuery->whereAdd("OCRD." . SapSupplier::CARDCODE, $string)->whereAdd("OCRD." . SapSupplier::CARDNAME, $string)->find();
     die(json_encode($suppliers->toArray()));
 }
Beispiel #8
0
 /**
  * this function search SapSuppliers associates with the access role  
  * 
  * @author Erick Guevara Martínez
  * @param AccessRole $accessRole
  * @return SapSupplieCollection
  */
 public function getAssociateSuppliers(AccessRole $accessRole)
 {
     $countries = AccessRoleQuery::create()->innerJoinAccesRoleCountry()->addColumn("AccessRole2Country.id_country")->whereAdd("AccessRole2Country.id_access_role", $accessRole->getIdAccessRole())->fetchCol();
     $suppliers = SapSupplierQuery::create()->innerJoinSapSupplierAddress()->whereAdd("CRD1.Country", $countries)->onlySuppliers()->find();
     return $suppliers;
 }
Beispiel #9
0
 /**
  *
  * @throws AuthException
  */
 private function ajaxLogin()
 {
     $username = $this->getRequest()->getParam('username');
     $password = $this->getRequest()->getParam('password');
     $state = array();
     try {
         $user = $this->getContainer()->get('autentication')->authenticate($username, $password);
     } catch (AuthException $e) {
         $state['message'] = $this->i18n->_('Either user or password is incorrect, please, try again.');
         $state['login'] = false;
         die(json_encode($state));
     }
     $this->getUser()->setBean($user);
     $accessRole = Query\AccessRoleQuery::create()->pk($user->getIdAccessRole())->findOne();
     $this->getUser()->setAccessRole($accessRole);
     $state['message'] = $this->i18n->_('Yeah!!');
     $state['login'] = true;
     die(json_encode($state));
 }