コード例 #1
0
 public function indexAction()
 {
     $fFilter = new \System\Form\User\Filter($this->getServiceLocator());
     $fFilter->setData($this->params()->fromQuery());
     $this->getViewModel()->setVariable('fFilter', $fFilter);
     if ($fFilter->isValid()) {
         $user = new User();
         $user->exchangeArray($fFilter->getData());
         if ($this->params()->fromQuery('companyId')) {
             $user->addOption('companyId', $this->params()->fromQuery('companyId'));
         }
         $user->addOption('companyIds', $this->company()->getManageabaleIds());
         if ($this->params()->fromQuery('roleCompany')) {
             $user->addOption('roleCompany', $this->params()->fromQuery('roleCompany'));
         }
         if ($this->params()->fromQuery('hasPrivateRole')) {
             $user->addOption('hasPrivateRole', $this->params()->fromQuery('hasPrivateRole'));
         }
         if ($this->params()->fromQuery('departmentId')) {
             $user->addOption('departmentId', $this->params()->fromQuery('departmentId'));
         }
         $userMapper = $this->getServiceLocator()->get('\\User\\Model\\UserMapper');
         $paginator = $userMapper->search($user, $this->getPagingParams(null, 50));
         $this->getViewModel()->setVariable('paginator', $paginator);
     }
     return $this->getViewModel();
 }
コード例 #2
0
ファイル: UserMapper.php プロジェクト: NguyenQuiDuong/Funix
 /**
  * @return array|null
  * @param \User\Model\User $user
  */
 public function getUser($user)
 {
     if (!$user->getId()) {
         return null;
     }
     $select = $this->getDbSql()->select(array('u' => self::TABLE_NAME));
     if ($user->getId()) {
         $select->where(['u.id' => $user->getId()]);
     }
     if ($user->getRole()) {
         $select->where(['u.role' => $user->getRole()]);
     }
     $select->limit(1);
     $query = $this->getDbSql()->buildSqlString($select);
     $results = $this->getDbAdapter()->query($query, Adapter::QUERY_MODE_EXECUTE);
     if ($results->count()) {
         $data = $results->current();
         $user->exchangeArray((array) $results->current());
         $select1 = clone $select;
         if ($user->getCityId()) {
             $select1->join(array('c' => CityMapper::TABLE_NAME), 'u.cityId = c.id', ['cityName' => 'nativeName'], 'left');
         }
         if ($user->getDistrictId()) {
             $select1->join(array('d' => DistrictMapper::TABLE_NAME), 'u.districtId = d.id', ['districtName' => 'name'], 'left');
         }
         $query1 = $this->getDbSql()->buildSqlString($select1);
         $results1 = $this->getDbAdapter()->query($query1, Adapter::QUERY_MODE_EXECUTE);
         $data1 = $results1->current();
         if (isset($data1['cityName']) && $data1['cityName']) {
             $user->addOption('cityName', $data1['cityName']);
         }
         if (isset($data1['districtName']) && $data1['districtName']) {
             $user->addOption('districtName', $data1['districtName']);
         }
         return $user;
     }
     return null;
 }