예제 #1
0
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         /** @var \User\Service\User $userService */
         $userService = $this->getServiceLocator()->get('User\\Service\\User');
         $data = parent::getData();
         $user = new User();
         $user->setEmail($data['email']);
         /** @var \User\Model\UserMapper $userMapper */
         $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
         if ($userMapper->isActive($user) && !$data['password']) {
             $this->get('email')->setMessages(['Bạn đã đăng ký, vui lòng chọn đăng nhập để tiếp tục']);
             return false;
         }
         if (!$userService->isAvailableEmail($data['email'])) {
             return true;
         }
         if ($data['password'] != '' && !$userService->authenticate($data['email'], $data['password'])) {
             $this->get('email')->setMessages([\User\Form\Signin::ERROR_INVALID]);
             return false;
         }
     }
     return $isValid;
 }
예제 #2
0
파일: Signin.php 프로젝트: projectHN/mentor
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         $userService = $this->getServiceLocator()->get('User\\Service\\User');
         $data = parent::getData();
         if (!$userService->authenticate($data['mail'], $data['password'])) {
             $this->get('mail')->setMessages([self::ERROR_INVALID]);
             return false;
         }
         /* @var $user \User\Model\User */
         $user = $userService->getUser();
         //            if(!$user->getActive()){
         //            	$this->get('username')->setMessages([self::ERROR_INACTIVE]);
         //            	$userService->getAuthService()->clearIdentity();
         //            	return false;
         //            }
         //            if($user->getLocked()){
         //            	$this->get('username')->setMessages([self::ERROR_LOCKED]);
         //            	$userService->getAuthService()->clearIdentity();
         //            	return false;
         //            }
     }
     return $isValid;
 }
예제 #3
0
 public function isValid()
 {
     $isVaild = parent::isValid();
     if ($isVaild) {
         $data = parent::getData();
         $expenseCategory = new \Accounting\Model\ExpenseCategory();
         if ($data['id']) {
             $expenseCategory->setId($data['id']);
         }
         if ($data['companyId']) {
             $expenseCategory->setCompanyId($data['companyId']);
         }
         if ($data['code']) {
             $expenseCategory->setCode($data['code']);
         }
         if ($data['name']) {
             $expenseCategory->setName($data['name']);
         }
         $expenseCategoryMapper = $this->getServiceLocator()->get('Accounting\\Model\\ExpenseCategoryMapper');
         $result = $expenseCategoryMapper->checkunique($expenseCategory);
         if ($result && $result == 'code') {
             $this->get('code')->setMessages(['Mã code này đã tồn tại']);
             $isVaild = false;
         }
         if ($result && $result == 'name') {
             $this->get('name')->setMessages(['tên này đã tồn tại']);
             $isVaild = false;
         }
         return $isVaild;
     }
 }
예제 #4
0
 public function isValid()
 {
     $isVaild = parent::isValid();
     if ($isVaild) {
         $data = $this->getData();
         $contract = new \Crm\Model\Contract();
         $contract->setId($data['contractId']);
         $contractMapper = $this->getServiceLocator()->get('\\Crm\\Model\\ContractMapper');
         if (!$contractMapper->get($contract)) {
             $this->get('contractId')->setMessages(['Không tìm thấy hợp đồng']);
             $isVaild = false;
         }
     }
     return $isVaild;
 }
예제 #5
0
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         $data = parent::getData();
         $file = new \Idea\Model\File();
         $file->setFileName($data['fileUpload']['name']);
         $file->setIdeaId($data['ideaId']);
         $date = new \DateTime();
         $file->setFilePath($date->format('dmY'));
         $fileMapper = $this->getServiceLocator()->get('\\Idea\\Model\\FileMapper');
         if ($fileMapper->isExisted($file)) {
             $this->get('fileUpload')->setMessages(['file đã tồn tại trên hệ thống, không thể ghi đè']);
             $isValid = false;
         }
     }
     return $isValid;
 }
예제 #6
0
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         $data = parent::getData();
         if ($data['mainCompanyId'] == $data['toDeleteCompanyId']) {
             $this->get('mainCompanyId')->setMessages(['Không thể hợp nhất 2 sp cùng cty']);
             $this->get('toDeleteCompanyId')->setMessages(['Không thể hợp nhất 2 sp cùng cty']);
             $isValid = false;
         }
         if ($data['mainProductId'] == $data['toDeleteProductId']) {
             $this->get('mainProductId')->setMessages(['Sp trùng']);
             $this->get('toDeleteProductId')->setMessages(['Sp trùng']);
             $isValid = false;
         }
     }
     return $isValid;
 }
예제 #7
0
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         $data = parent::getData();
         $userMapper = $this->getServiceLocator()->get('\\User\\Model\\UserMapper');
         if (!($user = $userMapper->get(null, null, $data['email']))) {
             $this->get('email')->setMessages(['Email không tồn tại trong hệ thống']);
             $isValid = false;
         } else {
             if (!$user->getActive()) {
                 $this->get('email')->setMessages(['Tài khoản chưa được active']);
                 $isValid = false;
             }
             if ($user->getLocked()) {
                 $this->get('email')->setMessages(['Tài khoản chưa được active']);
                 $isValid = false;
             }
         }
     }
     return $isValid;
 }
예제 #8
0
 /**
  * (non-PHPdoc)
  * @see \Zend\Form\Form::isValid()
  */
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         $data = parent::getData();
         // lấy danh sách category
         $expenseCategory = new \Accounting\Model\ExpenseCategory();
         $expenseCategory->setCompanyId($data['companyId']);
         $expenseCategory->addOption('fetchOnlyIds', true);
         $expenseCategoryMapper = $this->getServiceLocator()->get('\\Accounting\\Model\\ExpenseCategoryMapper');
         $expenseCategoryIds = $expenseCategoryMapper->fetchAll($expenseCategory);
         $itemsArray = json_decode($data['items'], true);
         foreach ($itemsArray as $itemDataPopulate) {
             $itemDataPopulate['accountId'] = $data['accountId'];
             $itemValidator = new \Accounting\Form\Transaction\ItemValidate($this->getServiceLocator(), ['expenseCategoryIds' => $expenseCategoryIds]);
             $itemValidator->setData($itemDataPopulate);
             if (!$itemValidator->isValid()) {
                 $this->get('items')->setMessages($itemValidator->getErrorMessagesList());
                 $isValid = false;
             }
         }
     }
     return $isValid;
 }
예제 #9
0
 public function isValid()
 {
     $isVaild = parent::isValid();
     if ($isVaild) {
         $user = new \User\Model\User();
         $user->exchangeArray($this->getData());
         $userMapper = $this->getServiceLocator()->get('\\User\\Model\\UserMapper');
         if ($userMapper->isExisted($user)) {
             $this->get('username')->setMessages(['Tên tài khoản hoặc email này đã được sử dụng']);
             $isVaild = false;
         }
     }
     return $isVaild;
 }
예제 #10
0
 /**
  * (non-PHPdoc)
  * @see \Zend\Form\Form::isValid()
  */
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         $data = parent::getData();
         if (!$data['mobile'] && !$data['mobile2'] && !$data['phone'] && !$data['phone2'] && !$data['email']) {
             $isValid = false;
             $this->get('name')->setMessages(['Bạn phải điền ít nhất số điện thoại hoặc email']);
             return false;
         }
         $token = \Home\Model\Consts::KEY_API_NHANH_ADDLEAD . json_encode(array(0 => isset($data['email']) ? $data['email'] : '', 2 => isset($data['mobile']) ? $data['mobile'] : '', 3 => isset($data['nhanhStoreId']) ? $data['nhanhStoreId'] : ''));
         $token = md5($token);
         if (!isset($data['token']) || $data['token'] != $token) {
             $this->get('token')->setMessages(['Mã bảo mật không chính xác']);
             $isValid = false;
         }
     }
     return $isValid;
 }
예제 #11
0
 public function isValid()
 {
     $isVaild = parent::isValid();
     if ($isVaild) {
         $data = parent::getData();
         if ($data['password']) {
             if ($data['password'] != $data['rePassword']) {
                 $this->get('rePassword')->setMessages(['Password nhập lại phải giống password']);
                 $isVaild = false;
             }
         }
         $userMapper = $this->getServiceLocator()->get('\\User\\Model\\UserMapper');
         if ($data['username']) {
             $user = new \User\Model\User();
             $user->setUsername($data['username']);
             $user->setId($data['id']);
             if ($userMapper->isExistedUserName($user)) {
                 $this->get('username')->setMessages(['Tên tài khoản này đã được sử dụng']);
                 $isVaild = false;
             }
         }
         if ($data['email']) {
             $user = new \User\Model\User();
             $user->setEmail($data['email']);
             $user->setId($data['id']);
             if ($userMapper->isExistedEmail($user)) {
                 $this->get('email')->setMessages(['email này đã được sử dụng']);
                 $isVaild = false;
             }
         }
     }
     return $isVaild;
 }