public function __construct() { $input = new \Zend\InputFilter\Input('username'); // Validadores $v = new \Zend\Validator\StringLength(array('min' => 3, 'max' => 50)); $v->setMin(3); $v->setMessage('Username Invalid', \Zend\Validator\StringLength::TOO_SHORT); $input->setRequired(true); $input->getValidatorChain()->attach($v); $this->add($input); $input = new \Zend\InputFilter\Input('password'); // Validadores $v = new \Zend\Validator\StringLength(array('min' => 1, 'max' => 50)); $v->setMessage('Clave Invalid', \Zend\Validator\StringLength::TOO_SHORT); $input->setRequired(true); $input->getValidatorChain()->attach($v); $this->add($input); }
$vParent = trim($_GET['parent']); $messageName = 'Parent Değerinde '; $controlMessage1 = $messageName; if (!$validatorAlpha->isValid($vParent)) { $vParent = $filterAlpha->filter($vParent); $controlMessage1 = $controlMessage1 . ' içerisinde alfabetik olmayan değer var!!! // '; $errorcode = 6; $hatasayisi1 = $hatasayisi1 + 1; } if (!$validatorNotEmptyString->isValid($vParent)) { $result = $validatorNotEmptyString->isValid($vParent); $controlMessage1 = $controlMessage1 . ' Boş Değer //'; $errorcode = 5; $hatasayisi1 = $hatasayisi1 + 1; } $validatorStringLength->setMin(1); $validatorStringLength->setMax(20); $validatorStringLength->setMessages(array('stringLengthTooShort' => $controlMessage1 . 'en az ' . $validatorStringLength->getMin() . ' karakter olmak zorunda...', 'stringLengthTooLong' => $controlMessage1 . 'en fazla ' . $validatorStringLength->getMax() . ' karakter olmak zorunda...')); if (!$validatorStringLength->isValid($vParent)) { $messages = $validatorStringLength->getMessages(); $controlMessage1 = $controlMessage1 . current($messages); $errorcode = 4; $hatasayisi1 = $hatasayisi1 + 1; } ////////////////////////////////////////////////////////////////////////// $vRoot = trim($_GET['root']); $messageName = 'Root Değerinde '; $controlMessage2 = $messageName; if (!$validatorAlpha->isValid($vRoot)) { $vRoot = $filterAlpha->filter($vRoot); $controlMessage2 = $controlMessage2 . ' içerisinde alfabetik olmayan değer var!!! // ';
/** * @author KienNN */ public function officeemployeeAction() { list($adapter, $sql) = $this->createOfficeAdapter(); $mathGender = array('1' => \Home\Model\Consts::GENDER_MALE, '2' => \Home\Model\Consts::GENDER_FEMALE); $mathMaritalStatus = array('4' => \Hrm\Model\Employee::RELATIONSHIP_SINGLE, '5' => \Hrm\Model\Employee::RELATIONSHIP_MARRIED, '6' => \Hrm\Model\Employee::RELATIONSHIP_DIVORCED); $mathNation = array('1' => 'Kinh', '2' => 'Dân tộc', '3' => 'Tày'); $mathReligion = array('6' => 'Không', '7' => 'Cơ đốc giáo', '8' => 'Hồi giáo', '9' => 'Phật giáo', '10' => 'Thiên chúa giáo'); $mathWorkingStatus = array('STOP_WORKING' => \Hrm\Model\Employee::WORKING_STATUS_RETIRED, 'WORKING' => \Hrm\Model\Employee::WORKING_STATUS_WORKING, 'NOT_WORKING' => \Hrm\Model\Employee::WORKING_STATUS_PAUSE, 'PRACTICE' => \Hrm\Model\Employee::WORKING_STATUS_TRIAL); $mathQuitReason = array('10' => \Hrm\Model\Employee::QUIT_REASON_WORK_ENVIRONMENT, '11' => \Hrm\Model\Employee::QUIT_REASON_HEALTHY, '12' => \Hrm\Model\Employee::QUIT_REASON_SALARY, '13' => \Hrm\Model\Employee::QUIT_REASON_WORK_PRESSURE, '14' => \Hrm\Model\Employee::QUIT_REASON_WORK_SUITABLE, '15' => \Hrm\Model\Employee::QUIT_REASON_FORCED_TO_RESIGN, '16' => \Hrm\Model\Employee::QUIT_REASON_FAMILY); $mathWorkPlaces = ['4' => 'Hà Nội', '5' => 'Hồ Chí Minh', '6' => 'Đà Nẵng']; $mathWorkCityId = ['4' => '2', '5' => '3', '6' => '65']; $mathWorkPosition = []; $select = $sql->select(['p' => 'positions']); $rows = $adapter->query($sql->buildSqlString($select), Adapter::QUERY_MODE_EXECUTE); if ($rows->count()) { foreach ($rows->toArray() as $row) { $mathWorkPosition[$row['ID']] = $row['title']; } } $mathWorkPositionTitle = ['1' => 'Phó Giám Đốc', '2' => 'Giám Đốc', '3' => 'Cộng tác viên', '4' => 'Nhân viên', '5' => 'Trưởng phòng', '6' => 'Trưởng nhóm', '7' => 'Quản lý', '8' => 'Nhân viên Partime', '9' => 'Tổng giám đốc', '10' => 'Phó tổng giám đốc', '11' => 'Chủ tịch HĐQT']; $select = $sql->select(['p' => 'personnels']); $select->order(['ID ASC']); $paginatorAdapter = new \Zend\Paginator\Adapter\DbSelect($select, $adapter); $paginator = new \Zend\Paginator\Paginator($paginatorAdapter); $paginator->setItemCountPerPage(50); $page = $this->getRequest()->getQuery('page', 1); $totalEmployee = $this->getRequest()->getQuery('totalEmployee', 0); $totalUpdate = $this->getRequest()->getQuery('totalUpdate', 0); $paginator->setCurrentPageNumber($page); $employeeMapper = $this->getServiceLocator()->get('\\Hrm\\Model\\EmployeeMapper'); $departmentMapper = $this->getServiceLocator()->get('\\Company\\Model\\DepartmentMapper'); $companyMapper = $this->getServiceLocator()->get('\\Company\\Model\\CompanyMapper'); $titleMapper = $this->getServiceLocator()->get('\\Company\\Model\\TitleMapper'); $userMapper = $this->getServiceLocator()->get('\\User\\Model\\UserMapper'); $mobileFilter = new \Home\Filter\Mobile(); $mobileValidate = new \Zend\Validator\StringLength(); $mobileValidate->setMin(10); $mobileValidate->setMax(11); $companyIdsInGroup = $this->company()->getCompanyIdsInGroup(); foreach ($paginator as $row) { $row = (array) $row; $employee = new \Hrm\Model\Employee(); $employee->setCode($row['code']); $employee->addOption('companyIds', $companyIdsInGroup); $employeeMapper->isExistedCode($employee); // check nếu employee đã có trong hệ thống sẽ update lại 1 số thông tin $employee->setOneofficeId($row['ID']); if (!$employee->getFirstName() && $row['first_name']) { $employee->setFirstName($row['first_name'] ?: ''); } elseif (!$employee->getFirstName()) { $employee->setFirstName(''); } if (!$employee->getLastName() && $row['last_name']) { $employee->setLastName($row['last_name']); } elseif (!$employee->getLastName()) { $employee->setLastName(''); } //if(!$employee->getFullName()){ if ($row['name']) { $employee->setFullName($row['name']); list($lastName, $middleName, $firstName) = Format::splitFullName($employee->getFullName()); $employee->setFirstName($firstName); $employee->setMiddleName($middleName); $employee->setLastName($lastName); } else { $employee->setFullName(Format::displaySetItems([$employee->getFirstName(), $employee->getMiddleName(), $employee->getLastName()], ' ')); } //} if (!$employee->getGender() && isset($mathGender[$row['gender']])) { $employee->setGender($mathGender[$row['gender']]); } else { $employee->setGender(\Home\Model\Consts::GENDER_MALE); } if (!$employee->getMaritalStatus() && $row['marital_status'] && isset($mathMaritalStatus[$row['marital_status']])) { $employee->setMaritalStatus($mathMaritalStatus[$row['marital_status']]); } else { $employee->setMaritalStatus(\Hrm\Model\Employee::RELATIONSHIP_SINGLE); } if (!$employee->getBirthdate() && $row['birthday']) { $employee->setBirthdate($row['birthday']); } if (!$employee->getBirthplace() && $row['place_of_birth']) { $employee->setBirthplace($this->mathPlace($row['place_of_birth'])); } /* if(!$employee->getHometown() && $row['home_address']){ if(!$row['home_address_state']){ $employee->setHometown($row['home_address']); } else { $home_address_state = $this->mathPlace($row['home_address_state']); $employee->setHometown(Format::displaySetItems( array($row['home_address'], $home_address_state), ', ')); } } */ if (!$employee->getIdentification() && $row['private_code']) { $employee->setIdentification($row['private_code']); } if ($row['private_code_place']) { $employee->setIdentificationPlace($this->mathPlace($row['private_code_place'])); } if (!$employee->getIdentificationDate() && $row['private_code_date']) { $employee->setIdentificationDate($row['private_code_date']); } // fix cứng luôn, bên kia cũng ko có nhân sự nước ngoài if (!$employee->getCountryId()) { $employee->setCountryId(243); } if (!$employee->getNation() && $row['nationality'] && isset($mathNation[$row['nationality']])) { $employee->setNation($mathNation[$row['nationality']]); } if (!$employee->getReligion() && $row['religious'] && isset($mathReligion[$row['religious']])) { $employee->setReligion($mathReligion[$row['religious']]); } if (!$employee->getCreatedDateTime()) { $employee->setCreatedDateTime($row['date_created']); } //@TODO fix đã /* if(!$employee->getStartedDate() && $row['job_date_join']){ $employee->setStartedDate($row['job_date_join']); } */ // Ngày nhập hồ sơ if ($row['job_date_join']) { $employee->setReceiveContractDate($row['job_date_join']); } else { $employee->setReceiveContractDate(null); } // ngày vào thực tế if ($row['job_reldate_join']) { $employee->setStartedDate($row['job_reldate_join']); } else { $employee->setStartedDate(null); } // Nơi làm việc if ($row['work_place'] && isset($mathWorkCityId[$row['work_place']])) { $employee->setWorkingCityId($mathWorkCityId[$row['work_place']]); } // nguyên quán - quê quán if ($row['origin_id']) { $employee->setHometown($this->mathPlace($row['origin_id'])); } if (!$employee->getDepartmentId() && $row['department_id']) { $deparmentInfor = $this->matchDepartment($row['department_id']); if (!$employee->getCompanyId() && isset($deparmentInfor['companyId'])) { $employee->setCompanyId($deparmentInfor['companyId']); } if (!$employee->getDepartmentId() && isset($deparmentInfor['departmentId'])) { $employee->setDepartmentId($deparmentInfor['departmentId']); } } if (!$employee->getCompanyId()) { $employee->setCompanyId(10); } if ($employee->getCompanyId() != 1 && $row['job_title']) { if (isset($mathWorkPositionTitle[$row['job_title']])) { $title = new \Company\Model\Title(); } $title->setCompanyId($employee->getCompanyId()); $title->setName($mathWorkPositionTitle[$row['job_title']]); if (!$titleMapper->isExisted($title)) { $title->setCreatedById($this->user()->getIdentity()); $title->setCreatedDateTime(DateBase::getCurrentDateTime()); $titleMapper->save($title); } $employee->setTitleId($title->getId()); } if (!$employee->getWorkingStatus() && $row['job_status'] && isset($mathWorkingStatus[$row['job_status']])) { $employee->setWorkingStatus($mathWorkingStatus[$row['job_status']]); } if (!$employee->getTaxCode() && $row['job_tax']) { $employee->setTaxCode($row['job_tax']); } if (!$employee->getQuitDate() && $row['job_date_out']) { $employee->setQuitDate($row['job_date_out']); } if (!$employee->getQuitReason() && $row['job_out_reason'] && isset($mathQuitReason[$row['job_out_reason']])) { $employee->setQuitReason($mathQuitReason[$row['job_out_reason']]); } if (!$employee->getEmail() && $row['email'] && strlen($row['email']) < 225) { $employee->setEmail($row['email']); } if (!$employee->getYahoo() && $row['yahoo'] && strlen($row['yahoo']) < 100) { $employee->setYahoo($row['yahoo']); } if (!$employee->getSkype() && $row['skype'] && strlen($row['skype']) < 100) { $employee->setSkype($row['skype']); } if (!$employee->getFacebook() && $row['facebook'] && strlen($row['facebook']) < 100) { $employee->setFacebook($row['facebook']); } if (!$employee->getMobile() && $row['mobile']) { $mobile = $mobileFilter->filter($row['mobile']); if ($mobile && $mobileValidate->isValid($mobile)) { $employee->setMobile($mobile ?: null); } } if (!$employee->getMobile() && $row['phone']) { $phone = $mobileFilter->filter($row['phone']); if ($phone && $mobileValidate->isValid($phone)) { $employee->setMobile($phone ?: null); } } if (!$employee->getPermanentAddress() && $row['home_address']) { if (!$row['home_address_state']) { $employee->setPermanentAddress(substr($row['home_address'], 0, 225)); } else { $home_address_state = $this->mathPlace($row['home_address_state']); $employee->setPermanentAddress(substr(Format::displaySetItems(array($row['home_address'], $home_address_state), ', '), 0, 225)); } } if (!$employee->getTemporateAddress() && $row['current_address']) { if (!$row['current_address_state']) { $employee->setTemporateAddress(substr($row['current_address'], 0, 225)); } else { $home_address_state = $this->mathPlace($row['current_address_state']); $employee->setTemporateAddress(substr(Format::displaySetItems(array($row['current_address'], $home_address_state), ', '), 0, 225)); } } if (!$employee->getBirthCertificate() && $row['birth_certificate']) { $employee->setBirthCertificate(\Hrm\Model\Employee::BIRTH_CERTIFICATE); } if ($employee->getExtraContent()) { $extraContent = json_decode($employee->getExtraContent(), true); if ($row['position_id'] && isset($mathWorkPosition[$row['position_id']])) { $extraContent['workPosition'] = $mathWorkPosition[$row['position_id']]; } $employee->setExtraContent(json_encode($extraContent)); } // check nếu là employee mới mới update các thông tin phía sau, nếu ko save lại chạy tiếp if ($employee->getId()) { $employeeMapper->save($employee); $totalUpdate++; continue; } if (!$employee->getCreatedDateTime() && $row['date_created']) { if ($row['date_created'] != '0000-00-00 00:00:00') { $employee->setCreatedDateTime($row['date_created']); } else { $employee->setCreatedDateTime(DateBase::getCurrentDateTime()); } } else { $employee->setCreatedDateTime(DateBase::getCurrentDateTime()); } if (!$employee->getCreatedById()) { $employee->setCreatedById(1); } if ($row['department_id']) { $deparmentInfor = $this->matchDepartment($row['department_id']); if (!$employee->getCompanyId() && isset($deparmentInfor['companyId'])) { $employee->setCompanyId($deparmentInfor['companyId']); } if (!$employee->getDepartmentId() && isset($deparmentInfor['departmentId'])) { $employee->setDepartmentId($deparmentInfor['departmentId']); } } if (!$employee->getCompanyId()) { $employee->setCompanyId(10); } //tạo mới title nếu chưa có $employeeMapper->save($employee); $totalEmployee++; } $this->getViewModel()->setTerminal(true); $this->getViewModel()->setVariable('paginator', $paginator); $this->getViewModel()->setVariable('page', $page); $this->getViewModel()->setVariable('totalPages', $paginator->count() + 1); $this->getViewModel()->setVariable('totalEmployee', $totalEmployee); $this->getViewModel()->setVariable('totalUpdate', $totalUpdate); if ($page <= $paginator->count()) { $this->getViewModel()->setVariable('redirectUri', Uri::build('/system/tool/officeemployee', ['page' => $page + 1, 'totalEmployee' => $totalEmployee, 'totalUpdate' => $totalUpdate])); } return $this->getViewModel(); }