本文整理汇总了PHP中UserFactory::getNextAvailableEmployeeNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP UserFactory::getNextAvailableEmployeeNumber方法的具体用法?PHP UserFactory::getNextAvailableEmployeeNumber怎么用?PHP UserFactory::getNextAvailableEmployeeNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserFactory
的用法示例。
在下文中一共展示了UserFactory::getNextAvailableEmployeeNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserDefaultData
/**
* Get default user data for creating new users.
* @return array
*/
function getUserDefaultData($tmp_company_id = NULL)
{
//Allow getting default data from other companies, so it makes it easier to create the first employee of a company.
if ($tmp_company_id != '' and $tmp_company_id > 0 and $this->getPermissionObject()->Check('company', 'enabled') and $this->getPermissionObject()->Check('company', 'view')) {
$company_id = $tmp_company_id;
} else {
$company_id = $this->getCurrentCompanyObject()->getId();
}
Debug::Text('Getting user default data for Company ID: ' . $company_id . ' TMP Company ID: ' . $tmp_company_id, __FILE__, __LINE__, __METHOD__, 10);
//Get New Hire Defaults.
$udlf = TTnew('UserDefaultListFactory');
$udlf->getByCompanyId($company_id);
if ($udlf->getRecordCount() > 0) {
Debug::Text('Using User Defaults, as they exist...', __FILE__, __LINE__, __METHOD__, 10);
$udf_obj = $udlf->getCurrent();
$data = array('company_id' => $company_id, 'status_id' => 10, 'title_id' => $udf_obj->getTitle(), 'employee_number' => UserFactory::getNextAvailableEmployeeNumber($company_id), 'city' => $udf_obj->getCity(), 'country' => $udf_obj->getCountry(), 'province' => $udf_obj->getProvince(), 'work_phone' => $udf_obj->getWorkPhone(), 'work_phone_ext' => $udf_obj->getWorkPhoneExt(), 'work_email' => $udf_obj->getWorkEmail(), 'hire_date' => TTDate::getAPIDate('DATE', $udf_obj->getHireDate()), 'sex_id' => 5, 'default_branch_id' => $udf_obj->getDefaultBranch(), 'default_department_id' => $udf_obj->getDefaultDepartment(), 'permission_control_id' => $udf_obj->getPermissionControl(), 'pay_period_schedule_id' => $udf_obj->getPayPeriodSchedule(), 'policy_group_id' => $udf_obj->getPolicyGroup(), 'currency_id' => $udf_obj->getCurrency());
}
if (!isset($data['company_id'])) {
$data['company_id'] = $company_id;
}
if (!isset($data['country'])) {
$data['country'] = 'US';
}
$ulf = TTnew('UserListFactory');
$ulf->getHighestEmployeeNumberByCompanyId($company_id);
if ($ulf->getRecordCount() > 0) {
Debug::Text('Highest Employee Number: ' . $ulf->getCurrent()->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 10);
if (is_numeric($ulf->getCurrent()->getEmployeeNumber()) == TRUE) {
$data['next_available_employee_number'] = $ulf->getCurrent()->getEmployeeNumber() + 1;
} else {
Debug::Text('Highest Employee Number is not an integer.', __FILE__, __LINE__, __METHOD__, 10);
$data['next_available_employee_number'] = NULL;
}
} else {
$data['next_available_employee_number'] = 1;
}
if (!isset($data['hire_date']) or $data['hire_date'] == '') {
$data['hire_date'] = TTDate::getAPIDate('DATE', time());
}
return $this->returnHandler($data);
}