本文整理汇总了PHP中UserListFactory::getRecordCount方法的典型用法代码示例。如果您正苦于以下问题:PHP UserListFactory::getRecordCount方法的具体用法?PHP UserListFactory::getRecordCount怎么用?PHP UserListFactory::getRecordCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserListFactory
的用法示例。
在下文中一共展示了UserListFactory::getRecordCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postInstall
function postInstall()
{
Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
$clf = new CompanyListFactory();
$clf->StartTransaction();
$clf->getAll();
if ($clf->getRecordCount() > 0) {
foreach ($clf as $c_obj) {
if ($c_obj->getStatus() == 10) {
$ulf = new UserListFactory();
$ulf->getHighestEmployeeNumberByCompanyId($c_obj->getId());
if ($ulf->getRecordCount() > 0) {
$next_available_employee_number = $ulf->getCurrent()->getEmployeeNumber() + 1;
} else {
$next_available_employee_number = 1;
}
$ulf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('hire_date' => 'asc'));
if ($ulf->getRecordCount() > 0) {
foreach ($ulf as $u_obj) {
if ($u_obj->getEmployeeNumber() == '') {
Debug::text('Setting Employee Number to: ' . $next_available_employee_number . ' for ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 9);
$u_obj->setEmployeeNumber($next_available_employee_number);
if ($u_obj->isValid()) {
$u_obj->Save();
$next_available_employee_number++;
}
} else {
Debug::text('NOT Setting Employee Number for ' . $u_obj->getUserName() . ' already set to: ' . $u_obj->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 9);
}
}
}
}
}
}
//$clf->FailTransaction();
$clf->CommitTransaction();
return TRUE;
}
示例2: getSchedule
//.........这里部分代码省略.........
}
//Debug::Arr($schedule_shift_totals, ' Schedule Shift Totals: ', __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($max_week_data, ' zMaxWeekData: ', __FILE__, __LINE__, __METHOD__,10);
}
}
if (isset($tmp_schedule_shifts)) {
//Sort Branches/Departments first
foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
ksort($day_tmp_schedule_shift);
$tmp_schedule_shifts[$day_epoch] = $day_tmp_schedule_shift;
foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
ksort($tmp_schedule_shifts[$day_epoch][$branch]);
}
}
//Sort each department by start time.
foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
foreach ($department_schedule_shifts as $department => $department_schedule_shift) {
$department_schedule_shift = Sort::multiSort($department_schedule_shift, 'start_time');
$this->schedule_shifts[$day_epoch][$branch][$department] = $department_schedule_shift;
}
}
}
}
unset($day_tmp_schedule_shift, $department_schedule_shifts, $department_schedule_shift, $tmp_schedule_shifts, $branch, $department);
$calendar_array = TTDate::getCalendarArray($filter_data['start_date'], $filter_data['end_date'], $start_week_day);
//var_dump($calendar_array);
if (!is_array($calendar_array) or !isset($this->schedule_shifts) or !is_array($this->schedule_shifts)) {
continue;
//Skip to next user.
}
$ulf = new UserListFactory();
$ulf->getByIdAndCompanyId($user_id, $current_user->getCompany());
if ($ulf->getRecordCount() != 1) {
continue;
} else {
$user_obj = $ulf->getCurrent();
$pdf->AddPage();
$pdf->setXY(670, $top_margin);
$pdf->SetFont('freesans', '', 10);
$pdf->Cell(100, 15, TTDate::getDate('DATE+TIME', $current_epoch), $border, 0, 'R');
$pdf->setXY($left_margin, $top_margin);
$pdf->SetFont('freesans', 'B', 25);
$pdf->Cell(0, 25, $user_obj->getFullName() . ' - ' . TTi18n::getText('Schedule'), $border, 0, 'C');
$pdf->Ln();
}
$pdf->SetFont('freesans', 'B', 16);
$pdf->Cell(0, 15, TTDate::getDate('DATE', $filter_data['start_date']) . ' - ' . TTDate::getDate('DATE', $filter_data['end_date']), $border, 0, 'C');
//$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->SetFont('freesans', '', 8);
$cell_width = floor(($pdf->GetPageWidth() - $left_margin * 2) / 7);
$cell_height = 100;
$i = 0;
$total_days = count($calendar_array) - 1;
$boader = 1;
foreach ($calendar_array as $calendar) {
if ($i == 0) {
//Calendar Header
$pdf->SetFont('freesans', 'B', 8);
$calendar_header = TTDate::getDayOfWeekArrayByStartWeekDay($start_week_day);
foreach ($calendar_header as $header_name) {
$pdf->Cell($cell_width, 15, $header_name, 1, 0, 'C');
}
$pdf->Ln();
示例3: sendCompanyUserLocationData
function sendCompanyUserLocationData($company_id)
{
if ($company_id == '') {
return FALSE;
}
$clf = new CompanyListFactory();
$clf->getById($company_id);
if ($clf->getRecordCount() > 0) {
$location_data['registration_key'] = $this->getLocalRegistrationKey();
$location_data['company_id'] = $company_id;
$ulf = new UserListFactory();
$ulf->getByCompanyId($company_id);
if ($ulf->getRecordCount() > 0) {
foreach ($ulf as $u_obj) {
$key = str_replace(' ', '', strtolower($u_obj->getCity() . $u_obj->getCity() . $u_obj->getCountry()));
$location_data['location_data'][$key] = array('city' => $u_obj->getCity(), 'province' => $u_obj->getProvince(), 'country' => $u_obj->getCountry());
}
if (isset($location_data['location_data'])) {
return $this->getSoapObject()->saveCompanyUserLocationData($location_data);
}
}
}
return FALSE;
}
示例4: UserListFactory
//Save report setup data
$ugdlf->getByCompanyIdAndScriptAndDefault($current_company->getId(), $_SERVER['SCRIPT_NAME']);
if ($ugdlf->getRecordCount() > 0) {
$ugdf->setID($ugdlf->getCurrent()->getID());
}
$ugdf->setCompany($current_company->getId());
$ugdf->setScript($_SERVER['SCRIPT_NAME']);
$ugdf->setName($title);
$ugdf->setData($setup_data);
$ugdf->setDefault(TRUE);
if ($ugdf->isValid()) {
$ugdf->Save();
}
$ulf = new UserListFactory();
$ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
if ($ulf->getRecordCount() > 0) {
foreach ($ulf as $u_obj) {
$filter_data['user_ids'][] = $u_obj->getId();
}
if (isset($filter_data['user_ids']) and isset($filter_data['year'])) {
$pseallf = new PayStubEntryAccountLinkListFactory();
$pseallf->getByCompanyId($current_company->getId());
if ($pseallf->getRecordCount() > 0) {
$pseal_obj = $pseallf->getCurrent();
}
//
//Get all data for the form.
//
foreach ($quarter_dates as $quarter_id => $quarter_dates_arr) {
//Get Pay Periods in date range.
Debug::Text('Start Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['start']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['end']), __FILE__, __LINE__, __METHOD__, 10);
示例5: postInstall
function postInstall()
{
Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
//Go through all pay period schedules and update the annual pay period column
$ppslf = new PayPeriodScheduleListFactory();
$ppslf->getAll();
if ($ppslf->getRecordCount() > 0) {
foreach ($ppslf as $pps_obj) {
$pps_obj->setAnnualPayPeriods($pps_obj->calcAnnualPayPeriods());
if ($pps_obj->isValid()) {
$pps_obj->Save();
}
}
}
//Go through all employee wages and update HourlyRate to the accurate annual hourly rate.
//**Handle this in 1034A postInstall() instead, as it needs to handle incorrect effective_dates properly.
/*
$uwlf = new UserWageListFactory();
$uwlf->getAll();
if ( $uwlf->getRecordCount() > 0 ) {
foreach( $uwlf as $uw_obj ) {
$uw_obj->setHourlyRate( $uw_obj->calcHourlyRate( time(), TRUE ) );
if ( $uw_obj->isValid() ) {
$uw_obj->Save();
}
}
}
*/
//Upgrade to new hierarchy format.
$clf = new CompanyListFactory();
$clf->getAll();
if ($clf->getRecordCount() > 0) {
foreach ($clf as $c_obj) {
if ($c_obj->getStatus() != 30) {
/*
if ( !($c_obj->getId() == 1052) ) { //$c_obj->getId() == 1009 OR $c_obj->getId() == 1087 OR
continue;
}
*/
$company_id = $c_obj->getId();
Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
$hclf = new HierarchyControlListFactory();
$hclf->StartTransaction();
$hclf->getByCompanyId($company_id);
if ($hclf->getRecordCount() > 0) {
foreach ($hclf as $hc_obj) {
$paths_to_root = array();
$hierarchy_id = $hc_obj->getId();
$hlf = new HierarchyListFactory();
$hierarchy_users = $hlf->getByCompanyIdAndHierarchyControlId($company_id, $hierarchy_id);
if (is_array($hierarchy_users) and count($hierarchy_users) > 0) {
$hotlf = new HierarchyObjectTypeListFactory();
$hotlf->getByHierarchyControlId($hierarchy_id);
if ($hotlf->getRecordCount() > 0) {
foreach ($hotlf as $hot_obj) {
$object_types[$hierarchy_id][] = $hot_obj->getObjectType();
}
}
foreach ($hierarchy_users as $hierarchy_user_arr) {
Debug::Text(' Checking User ID: ' . $hierarchy_user_arr['id'], __FILE__, __LINE__, __METHOD__, 10);
$id = $hierarchy_user_arr['id'];
$tmp_id = $id;
$i = 0;
do {
Debug::Text(' Iteration...', __FILE__, __LINE__, __METHOD__, 10);
$hlf_b = new HierarchyListFactory();
$parents = $hlf_b->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $tmp_id);
sort($parents);
$level = $hlf_b->getFastTreeObject()->getLevel($tmp_id) - 1;
if (is_array($parents) and count($parents) > 0) {
$parent_users = array();
foreach ($parents as $user_id) {
$parent_users[] = $user_id;
unset($user);
}
$parent_groups[$level] = $parent_users;
unset($parent_users);
}
if (isset($parents[0])) {
$tmp_id = $parents[0];
}
$i++;
} while (is_array($parents) and count($parents) > 0 and $i < 100);
if (isset($parent_groups)) {
$serialized_path = serialize($parent_groups);
$paths_to_root[$serialized_path][] = $id;
unset($serialized_path);
}
unset($parent_groups, $parents);
}
}
Debug::Arr($paths_to_root, ' Paths To Root: ', __FILE__, __LINE__, __METHOD__, 10);
//Decode path_to_root array
if (isset($paths_to_root) and count($paths_to_root) > 0) {
foreach ($paths_to_root as $serialized_path => $children) {
$path_arr = unserialize($serialized_path);
$decoded_paths[] = array('hierarchy_control_id' => $hierarchy_id, 'path' => $path_arr, 'children' => $children);
}
unset($path_arr, $children);
Debug::Arr($decoded_paths, ' Decoded Paths: ', __FILE__, __LINE__, __METHOD__, 10);
//.........这里部分代码省略.........
示例6: releaseAllAccruals
static function releaseAllAccruals($user_id, $effective_date = NULL)
{
Debug::Text('Release 100% of all accruals!', __FILE__, __LINE__, __METHOD__, 10);
if ($user_id == '') {
return FALSE;
}
if ($effective_date == '') {
$effective_date = TTDate::getTime();
}
Debug::Text('Effective Date: ' . TTDate::getDate('DATE+TIME', $effective_date), __FILE__, __LINE__, __METHOD__, 10);
$ulf = new UserListFactory();
$ulf->getById($user_id);
if ($ulf->getRecordCount() > 0) {
$user_obj = $ulf->getCurrent();
} else {
return FALSE;
}
//Get all PSE acccount accruals
$psealf = new PayStubEntryAccountListFactory();
$psealf->getByCompanyIdAndStatusIdAndTypeId($user_obj->getCompany(), 10, 50);
if ($psealf->getRecordCount() > 0) {
$ulf->StartTransaction();
foreach ($psealf as $psea_obj) {
//Get PSE account that affects this accrual.
$psealf_tmp = new PayStubEntryAccountListFactory();
$psealf_tmp->getByCompanyIdAndAccrualId($user_obj->getCompany(), $psea_obj->getId());
if ($psealf_tmp->getRecordCount() > 0) {
$release_account_id = $psealf_tmp->getCurrent()->getId();
$psaf = new PayStubAmendmentFactory();
$psaf->setStatus(50);
//Active
$psaf->setType(20);
//Percent
$psaf->setUser($user_obj->getId());
$psaf->setPayStubEntryNameId($release_account_id);
$psaf->setPercentAmount(100);
$psaf->setPercentAmountEntryNameId($psea_obj->getId());
$psaf->setEffectiveDate($effective_date);
$psaf->setDescription('Release Accrual Balance');
if ($psaf->isValid()) {
Debug::Text('Release Accrual Is Valid!!: ', __FILE__, __LINE__, __METHOD__, 10);
$psaf->Save();
}
} else {
Debug::Text('No Release Account for this Accrual!!', __FILE__, __LINE__, __METHOD__, 10);
}
}
//$ulf->FailTransaction();
$ulf->CommitTransaction();
} else {
Debug::Text('No Accruals to release...', __FILE__, __LINE__, __METHOD__, 10);
}
return FALSE;
}
示例7: postSave
function postSave()
{
$this->removeCache($this->getId());
$this->remoteSave();
if ($this->getDeleted() == FALSE) {
//Add base currency for this new company.
if ($this->getEnableAddCurrency() == TRUE) {
$clf = new CurrencyListFactory();
$clf->getByCompanyId($this->getId());
if ($clf->getRecordCount() == 0) {
Debug::text('Adding Default Currency', __FILE__, __LINE__, __METHOD__, 9);
$cf = new CurrencyFactory();
$country_to_currency_map_arr = $cf->getOptions('country_currency');
if (isset($country_to_currency_map_arr[$this->getCountry()])) {
$base_currency = $country_to_currency_map_arr[$this->getCountry()];
Debug::text('Found Base Currency For Country: ' . $this->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9);
} else {
Debug::text('DID NOT Find Base Currency For Country: ' . $this->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9);
$base_currency = 'USD';
}
$cf->setCompany($this->getId());
$cf->setStatus(10);
$cf->setName($base_currency);
$cf->setISOCode($base_currency);
$cf->setConversionRate('1.000000000');
$cf->setAutoUpdate(FALSE);
$cf->setBase(TRUE);
$cf->setDefault(TRUE);
if ($cf->isValid()) {
$cf->Save();
}
}
}
if ($this->getEnableAddPermissionGroupPreset() == TRUE) {
Debug::text('Adding Preset Permission Groups', __FILE__, __LINE__, __METHOD__, 9);
$pf = new PermissionFactory();
$pf->StartTransaction();
if ($this->getProductEdition() == 20) {
$preset_flags = array('job' => 1, 'invoice' => 1, 'document' => 1);
} else {
$preset_flags = array();
}
$preset_options = $pf->getOptions('preset');
foreach ($preset_options as $preset_id => $preset_name) {
$pcf = new PermissionControlFactory();
$pcf->setCompany($this->getId());
$pcf->setName($preset_name);
$pcf->setDescription('');
if ($pcf->isValid()) {
$pcf_id = $pcf->Save(FALSE);
$pf->applyPreset($pcf_id, $preset_id, $preset_flags);
}
}
//$pf->FailTransaction();
$pf->CommitTransaction();
}
if ($this->getEnableAddStation() == TRUE) {
Debug::text('Adding Default Station', __FILE__, __LINE__, __METHOD__, 9);
//Enable punching in from all stations
$sf = new StationFactory();
$sf->setCompany($this->getId());
$sf->setStatus(20);
$sf->setType(10);
$sf->setSource('ANY');
$sf->setStation('ANY');
$sf->setDescription('All stations');
$sf->setGroupSelectionType(10);
$sf->setBranchSelectionType(10);
$sf->setDepartmentSelectionType(10);
if ($sf->isValid()) {
$sf->Save();
}
}
if ($this->getEnableAddPayStubEntryAccountPreset() == TRUE) {
Debug::text('Adding Pay Stub Entry Account Presets', __FILE__, __LINE__, __METHOD__, 9);
PayStubEntryAccountFactory::addPresets($this->getId());
}
if ($this->getEnableAddCompanyDeductionPreset() == TRUE) {
Debug::text('Adding Company Deduction Presets', __FILE__, __LINE__, __METHOD__, 9);
CompanyDeductionFactory::addPresets($this->getId());
}
if ($this->getEnableAddRecurringHolidayPreset() == TRUE) {
Debug::text('Adding Recurring Holiday Presets', __FILE__, __LINE__, __METHOD__, 9);
RecurringHolidayFactory::addPresets($this->getId(), $this->getCountry());
}
}
if ($this->getDeleted() == TRUE) {
$ulf = new UserListFactory();
$ulf->getByCompanyId($this->getID());
if ($ulf->getRecordCount() > 0) {
$ulf->StartTransaction();
foreach ($ulf as $u_obj) {
Debug::text('Deleting User ID: ' . $u_obj->getId(), __FILE__, __LINE__, __METHOD__, 9);
$u_obj->setDeleted(TRUE);
if ($u_obj->isValid()) {
$u_obj->Save();
}
}
$ulf->CommitTransaction();
}
//.........这里部分代码省略.........
示例8: setUser
function setUser($id)
{
$id = trim($id);
$ulf = new UserListFactory();
$hulf = new HierarchyUserListFactory();
if ($this->getHierarchyControl() == FALSE) {
return FALSE;
}
//Get user object so we can get the users full name to display as an error message.
$ulf->getById($id);
if ($id == 0 or $ulf->getRecordCount() > 0 and $this->Validator->isResultSetWithRows('user', $ulf->getByID($id), TTi18n::gettext('Invalid Employee')) and $this->Validator->isNotResultSetWithRows('user', $hulf->getByHierarchyControlAndUserId($this->getHierarchyControl(), $id), TTi18n::gettext($ulf->getCurrent()->getFullName() . ' is assigned as both a superior and subordinate'))) {
$this->data['user_id'] = $id;
return TRUE;
}
return FALSE;
}
示例9: getEmailExceptionAddresses
function getEmailExceptionAddresses($u_obj = NULL, $ep_obj = NULL)
{
Debug::text(' Attempting to Email Notification...', __FILE__, __LINE__, __METHOD__, 10);
//Make sure type is not pre-mature.
if ($this->getType() > 5) {
if (!is_object($ep_obj)) {
$ep_obj = $this->getExceptionPolicyObject();
}
//Make sure exception policy email notifications are enabled.
if ($ep_obj->getEmailNotification() > 0) {
if (!is_object($u_obj)) {
$u_obj = $this->getUserDateObject()->getUserObject();
}
$up_obj = $this->getUserDateObject()->getUserObject()->getUserPreferenceObject();
//Make sure user email notifications are enabled.
if (($ep_obj->getEmailNotification() == 10 or $ep_obj->getEmailNotification() == 100) and $up_obj->getEnableEmailNotificationException() == TRUE) {
Debug::Text(' Emailing exception to user!', __FILE__, __LINE__, __METHOD__, 10);
if ($u_obj->getWorkEmail() != '') {
$retarr[] = $u_obj->getWorkEmail();
}
if ($up_obj->getEnableEmailNotificationHome() == TRUE and $u_obj->getHomeEmail() != '') {
$retarr[] = $u_obj->getHomeEmail();
}
} else {
Debug::Text(' Skipping email to user.', __FILE__, __LINE__, __METHOD__, 10);
}
//Make sure supervisor email notifcations are enabled
if ($ep_obj->getEmailNotification() == 20 or $ep_obj->getEmailNotification() == 100) {
//Find supervisor
$hlf = new HierarchyListFactory();
$parent_user_id = $hlf->getHierarchyParentByCompanyIdAndUserIdAndObjectTypeID($u_obj->getCompany(), $u_obj->getId(), 80);
if ($parent_user_id != FALSE) {
$ulf = new UserListFactory();
$ulf->getById($parent_user_id);
if ($ulf->getRecordCount() > 0) {
$parent_user_obj = $ulf->getCurrent();
if (is_object($parent_user_obj->getUserPreferenceObject()) and $parent_user_obj->getUserPreferenceObject()->getEnableEmailNotificationException() == TRUE) {
Debug::Text(' Emailing exception to supervisor!', __FILE__, __LINE__, __METHOD__, 10);
if ($parent_user_obj->getWorkEmail() != '') {
$retarr[] = $parent_user_obj->getWorkEmail();
}
if ($up_obj->getEnableEmailNotificationHome() == TRUE and $parent_user_obj->getHomeEmail() != '') {
$retarr[] = $parent_user_obj->getHomeEmail();
}
} else {
Debug::Text(' Skipping email to supervisor.', __FILE__, __LINE__, __METHOD__, 10);
}
}
} else {
Debug::Text(' No Hierarchy Parent Found, skipping email to supervisor.', __FILE__, __LINE__, __METHOD__, 10);
}
}
if (isset($retarr) and is_array($retarr)) {
return $retarr;
} else {
Debug::text(' No user objects to email too...', __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::text(' Exception Policy Email Exceptions are disabled, skipping email...', __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::text(' Pre-Mature exception, or not in production mode, skipping email...', __FILE__, __LINE__, __METHOD__, 10);
}
return FALSE;
}
示例10: postInstall
function postInstall()
{
global $cache;
Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
//Configure currencies for Standard Edition.
if ($this->getIsUpgrade() == TRUE) {
$clf = new CompanyListFactory();
$clf->StartTransaction();
$clf->getAll();
if ($clf->getRecordCount() > 0) {
foreach ($clf as $c_obj) {
if ($c_obj->getStatus() == 10) {
//Converting to new Accrual Policy table.
Debug::text('Converting to new Accrual Policy Table: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9);
$pglf = new PolicyGroupListFactory();
$pglf->getByCompanyId($c_obj->getId());
if ($pglf->getRecordCount() > 0) {
foreach ($pglf as $pg_obj) {
Debug::text('Accrual Policy ID: ' . $pg_obj->getColumn('accrual_policy_id'), __FILE__, __LINE__, __METHOD__, 9);
if ($pg_obj->getColumn('accrual_policy_id') != '' and $pg_obj->getColumn('accrual_policy_id') != 0) {
$pg_obj->setAccrualPolicy(array($pg_obj->getColumn('accrual_policy_id')));
if ($pg_obj->isValid()) {
$pg_obj->Save();
}
}
}
}
Debug::text('Adding Currency Information to Company: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9);
$crlf = new CurrencyListFactory();
$crlf->getByCompanyId($c_obj->getId());
if ($crlf->getRecordCount() == 0) {
$cf = new CurrencyFactory();
$country_to_currency_map_arr = $cf->getOptions('country_currency');
if (isset($country_to_currency_map_arr[$c_obj->getCountry()])) {
$base_currency = $country_to_currency_map_arr[$c_obj->getCountry()];
Debug::text('Found Base Currency For Country: ' . $c_obj->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9);
} else {
Debug::text('DID NOT Find Base Currency For Country: ' . $c_obj->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9);
$base_currency = 'USD';
}
$cf->setCompany($c_obj->getId());
$cf->setStatus(10);
$cf->setName($base_currency);
$cf->setISOCode($base_currency);
$cf->setConversionRate('1.000000000');
$cf->setAutoUpdate(FALSE);
$cf->setBase(TRUE);
$cf->setDefault(TRUE);
if ($cf->isValid()) {
$base_currency_id = $cf->Save();
Debug::text('Base Currency ID: ' . $base_currency_id, __FILE__, __LINE__, __METHOD__, 10);
//Set Employee Hire Defaults.
$udlf = new UserDefaultListFactory();
$udlf->getByCompanyId($c_obj->getId());
if ($udlf->getRecordCount() > 0) {
$ud_obj = $udlf->getCurrent();
$ud_obj->setCurrency($base_currency_id);
$ud_obj->setLanguage('en');
if ($ud_obj->isValid()) {
$ud_obj->Save();
}
}
unset($udlf, $ud_obj);
if (is_numeric($base_currency_id)) {
$ulf = new UserListFactory();
$ulf->getByCompanyId($c_obj->getId());
if ($ulf->getRecordCount() > 0) {
foreach ($ulf as $u_obj) {
$user_id = $u_obj->getID();
Debug::text('Setting Base Currency For User: ' . $u_obj->getUserName() . ' ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
$u_obj->setCurrency($base_currency_id);
if ($u_obj->isValid()) {
if ($u_obj->Save() == TRUE) {
//Set User Default Language
$uplf = new UserPreferenceListFactory();
$uplf->getByUserIDAndCompanyID($user_id, $c_obj->getId());
if ($uplf->getRecordCount() > 0) {
$up_obj = $uplf->getCurrent();
$up_obj->setLanguage('en');
//Englist
if ($up_obj->isValid()) {
$up_obj->Save();
}
}
unset($uplf, $up_obj);
Debug::text(' Setting Base Currency for Pay Stubs, User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//Change all pay stubs for this user to the base currency.
//Do this in a single query for speed purposes.
$ph = array('currency_id' => $base_currency_id, 'currency_rate' => '1.000000000', 'user_id' => $user_id);
$query = 'update pay_stub set currency_id = ?, currency_rate = ? where user_id = ?';
Debug::text(' Pay Stub Currency Query: ' . $query, __FILE__, __LINE__, __METHOD__, 10);
$u_obj->db->Execute($query, $ph);
/*
$pslf = new PayStubListFactory();
$pslf->getByUserIdAndCompanyId( $user_id, $c_obj->getId() );
if ( $pslf->getRecordCount() > 0 ) {
foreach( $pslf as $ps_obj ) {
//Debug::text(' Setting Base Currency for Pay Stub ID: '. $ps_obj->getId(), __FILE__, __LINE__, __METHOD__,10);
$ps_obj->setCurrency( $base_currency_id );
//.........这里部分代码省略.........
示例11: addAccrualPolicyTime
function addAccrualPolicyTime($epoch = NULL, $offset = 79200, $daily_total_time = NULL)
{
//22hr offset
if ($epoch == '') {
$epoch = TTDate::getTime();
}
Debug::Text('Accrual Policy ID: ' . $this->getId() . ' Current EPOCH: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
$pglf = new PolicyGroupListFactory();
$pglf->StartTransaction();
$pglf->getSearchByCompanyIdAndArrayCriteria($this->getCompany(), array('accrual_policy_id' => array($this->getId())));
if ($pglf->getRecordCount() > 0) {
Debug::Text('Found Policy Group...', __FILE__, __LINE__, __METHOD__, 10);
foreach ($pglf as $pg_obj) {
//Get all users assigned to this policy group.
$policy_group_users = $pg_obj->getUser();
if (is_array($policy_group_users) and count($policy_group_users) > 0) {
Debug::Text('Found Policy Group Users: ' . count($policy_group_users), __FILE__, __LINE__, __METHOD__, 10);
foreach ($policy_group_users as $user_id) {
Debug::Text('Policy Group User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//Get User Object
$ulf = new UserListFactory();
$ulf->getByIDAndCompanyID($user_id, $this->getCompany());
if ($ulf->getRecordCount() == 1) {
$u_obj = $ulf->getCurrent();
Debug::Text('User: ' . $u_obj->getFullName() . ' Status: ' . $u_obj->getStatus(), __FILE__, __LINE__, __METHOD__, 10);
//Make sure only active employees accrue time. Will this negative affect
//Employees who may be on leave?
if ($u_obj->getStatus() == 10 and ($this->getMinimumEmployedDays() == 0 or TTDate::getDays($epoch - $u_obj->getHireDate()) >= $this->getMinimumEmployedDays())) {
Debug::Text(' User is active and has been employed long enough.', __FILE__, __LINE__, __METHOD__, 10);
$annual_pay_periods = 0;
$in_apply_frequency_window = FALSE;
$accrual_balance = 0;
$accrual_amount = 0;
if ($this->getType() == 30) {
Debug::Text(' Accrual policy is hour based, real-time window.', __FILE__, __LINE__, __METHOD__, 10);
//Hour based, apply frequency is real-time.
$in_apply_frequency_window = TRUE;
} else {
if ($this->getApplyFrequency() == 10) {
//Because of pay period frequencies, and users being assigned to different
//pay period schedules we need to get the last pay period of each user individually.
//This will return the pay period that just ended in the offset time.
$pplf = new PayPeriodListFactory();
$pplf->getByUserIdAndEndDate($user_id, $epoch - $offset);
if ($pplf->getRecordCount() > 0) {
foreach ($pplf as $pp_obj) {
Debug::Text(' Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $pp_obj->getEndDate()), __FILE__, __LINE__, __METHOD__, 10);
if ($this->inApplyFrequencyWindow($epoch, $offset, $pp_obj->getEndDate()) == TRUE) {
$in_apply_frequency_window = TRUE;
$annual_pay_periods = $pp_obj->getPayPeriodScheduleObject()->getAnnualPayPeriods();
break;
} else {
Debug::Text(' User not in Apply Frequency Window: ', __FILE__, __LINE__, __METHOD__, 10);
}
}
} else {
Debug::Text(' No Pay Period Found.', __FILE__, __LINE__, __METHOD__, 10);
}
} elseif ($this->inApplyFrequencyWindow($epoch, $offset) == TRUE) {
Debug::Text(' User IS in NON-PayPeriod Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
$in_apply_frequency_window = TRUE;
} else {
Debug::Text(' User is not in Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
$in_apply_frequency_window = FALSE;
}
}
if ($in_apply_frequency_window == TRUE) {
$milestone_obj = $this->getActiveMilestoneObject($u_obj, $epoch);
if (isset($milestone_obj) and is_object($milestone_obj)) {
Debug::Text(' Found Matching Milestone, Accrual Rate: (ID: ' . $milestone_obj->getId() . ') ' . $milestone_obj->getAccrualRate() . '/year', __FILE__, __LINE__, __METHOD__, 10);
$accrual_balance = $this->getCurrentAccrualBalance($user_id, $this->getId());
if ($accrual_balance < $milestone_obj->getMaximumTime()) {
$accrual_amount = $this->calcAccrualAmount($milestone_obj, 0, $annual_pay_periods);
if ($accrual_amount > 0) {
$new_accrual_balance = bcadd($accrual_balance, $accrual_amount);
//If Maximum time is set to 0, make that unlimited.
if ($milestone_obj->getMaximumTime() > 0 and $new_accrual_balance > $milestone_obj->getMaximumTime()) {
$accrual_amount = bcsub($milestone_obj->getMaximumTime(), $accrual_balance, 0);
}
Debug::Text(' Min/Max Adjusted Accrual Amount: ' . $accrual_amount . ' Limits: Min: ' . $milestone_obj->getMinimumTime() . ' Max: ' . $milestone_obj->getMaximumTime(), __FILE__, __LINE__, __METHOD__, 10);
//Check to make sure there isn't an identical entry already made.
$alf = new AccrualListFactory();
$alf->getByCompanyIdAndUserIdAndAccrualPolicyIDAndTimeStampAndAmount($u_obj->getCompany(), $user_id, $this->getId(), TTDate::getMiddleDayEpoch($epoch), $accrual_amount);
if ($alf->getRecordCount() == 0) {
//Round to nearest 1min
$af = new AccrualFactory();
$af->setUser($user_id);
$af->setType(75);
//Accrual Policy
$af->setAccrualPolicyID($this->getId());
$af->setAmount($accrual_amount);
$af->setTimeStamp(TTDate::getMiddleDayEpoch($epoch));
$af->setEnableCalcBalance(TRUE);
if ($af->isValid()) {
$af->Save();
}
} else {
Debug::Text(' Found duplicate accrual entry, skipping...', __FILE__, __LINE__, __METHOD__, 10);
}
unset($accrual_amount, $accrual_balance, $new_accrual_balance);
//.........这里部分代码省略.........
示例12: setUser
function setUser($ids)
{
Debug::text('Setting User IDs : ', __FILE__, __LINE__, __METHOD__, 10);
if (is_array($ids)) {
if (!$this->isNew()) {
//If needed, delete mappings first.
$hulf = new HierarchyUserListFactory();
$hulf->getByHierarchyControlID($this->getId());
$tmp_ids = array();
foreach ($hulf as $obj) {
$id = $obj->getUser();
Debug::text('HierarchyControl ID: ' . $obj->getHierarchyControl() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
//Delete users that are not selected.
if (!in_array($id, $ids)) {
Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
$obj->Delete();
} else {
//Save ID's that need to be updated.
Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10);
$tmp_ids[] = $id;
}
}
unset($id, $obj);
}
//Insert new mappings.
$ulf = new UserListFactory();
foreach ($ids as $id) {
if (isset($ids) and !in_array($id, $tmp_ids)) {
$huf = new HierarchyUserFactory();
$huf->setHierarchyControl($this->getId());
$huf->setUser($id);
$ulf->getById($id);
if ($ulf->getRecordCount() > 0) {
$obj = $ulf->getCurrent();
if ($this->Validator->isTrue('user', $huf->Validator->isValid(), TTi18n::gettext('Selected subordinate is invalid or already assigned to another hierarchy with the same objects ') . ' (' . $obj->getFullName() . ')')) {
$huf->save();
}
}
}
}
return TRUE;
}
Debug::text('No User IDs to set.', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
示例13: postInstall
function postInstall()
{
Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
//Copy iButton,Fingerprint,EmployeeNumber (barcode/proximity) fields to new UserIdentification table.
//Find out if they have both TimeClocks and FingerPrint stations. If they do
//we need to copy the fingerprint data to both types of UserIdentification rows.
$clf = new CompanyListFactory();
$clf->getAll();
$clf->StartTransaction();
foreach ($clf as $c_obj) {
Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
$max_templates = 4;
$slf = new StationListFactory();
$slf->getByCompanyIdAndTypeId($c_obj->getId(), array(30, 40, 50, 100, 110));
if ($slf->getRecordCount() > 0) {
$slf_tmp1 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(50));
$griaule_stations = $slf_tmp1->getRecordCount();
Debug::text(' Found Griaule Stations: ' . $griaule_stations, __FILE__, __LINE__, __METHOD__, 9);
unset($slf_tmp1);
$slf_tmp2 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(100, 110));
$zk_stations = $slf_tmp2->getRecordCount();
Debug::text(' Found ZK Stations: ' . $zk_stations, __FILE__, __LINE__, __METHOD__, 9);
unset($slf_tmp2);
$slf_tmp3 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(40));
$barcode_stations = $slf_tmp3->getRecordCount();
Debug::text(' Found Barcode Stations: ' . $barcode_stations, __FILE__, __LINE__, __METHOD__, 9);
unset($slf_tmp3);
//Loop through each user copying their data to the UserIdenfification Table.
$ulf = new UserListFactory();
$ulf->getByCompanyID($c_obj->getId());
if ($ulf->getRecordCount() > 0) {
foreach ($ulf as $u_obj) {
Debug::text(' User: ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 9);
if ($u_obj->getIButtonID() != '') {
Debug::text(' Converting iButton...', __FILE__, __LINE__, __METHOD__, 9);
$uif = new UserIdentificationFactory();
$uif->setUser($u_obj->getId());
$uif->setType(10);
//10=iButton
$uif->setNumber(0);
$uif->setValue($u_obj->getIButtonID());
if ($uif->isValid() == TRUE) {
$uif->Save();
$u_obj->getIButtonID('');
}
}
if ($u_obj->getRFID() != '') {
Debug::text(' Converting RFID...', __FILE__, __LINE__, __METHOD__, 9);
$uif = new UserIdentificationFactory();
$uif->setUser($u_obj->getId());
$uif->setType(40);
//40=Proximity
$uif->setNumber(0);
$uif->setValue($u_obj->getRFID());
if ($uif->isValid() == TRUE) {
$uif->Save();
$u_obj->getRFID('');
}
}
if ($barcode_stations > 0 and $u_obj->getEmployeeNumber() != '') {
Debug::text(' Converting EmployeeNumber...', __FILE__, __LINE__, __METHOD__, 9);
$uif = new UserIdentificationFactory();
$uif->setUser($u_obj->getId());
$uif->setType(30);
//30=Barcode
$uif->setNumber(0);
$uif->setValue($u_obj->getEmployeeNumber());
if ($uif->isValid() == TRUE) {
$uif->Save();
}
}
if ($griaule_stations > 0) {
for ($t = 1; $t <= $max_templates; $t++) {
$set_fingerprint_function = 'setFingerPrint' . $t;
$get_fingerprint_function = 'getFingerPrint' . $t;
//Griaule fingerprint templates start with: "p/8B"
if ($u_obj->{$get_fingerprint_function}() != '' and substr($u_obj->{$get_fingerprint_function}(), 0, 4) == 'p/8B') {
Debug::text(' Converting Griaule FingerPrint: ' . $t, __FILE__, __LINE__, __METHOD__, 9);
$uif = new UserIdentificationFactory();
$uif->setUser($u_obj->getId());
$uif->setType(20);
//20=Griaule, 100=ZK
$uif->setNumber($t * 10);
$uif->setValue($u_obj->{$get_fingerprint_function}());
if ($uif->isValid() == TRUE) {
$uif->Save();
$u_obj->{$set_fingerprint_function}('');
}
}
}
}
if ($zk_stations > 0) {
for ($t = 1; $t <= $max_templates; $t++) {
$set_fingerprint_function = 'setFingerPrint' . $t;
$get_fingerprint_function = 'getFingerPrint' . $t;
//ZK fingerprint templates start with: "oco"
if ($u_obj->{$get_fingerprint_function}() != '' and substr($u_obj->{$get_fingerprint_function}(), 0, 3) == 'oco') {
Debug::text(' Converting ZK FingerPrint: ' . $t, __FILE__, __LINE__, __METHOD__, 9);
$uif = new UserIdentificationFactory();
$uif->setUser($u_obj->getId());
//.........这里部分代码省略.........
示例14: Validate
function Validate()
{
if ($this->getDeleted() == TRUE) {
//CHeck to make sure currency isnt in-use by paystubs/employees/wages, if so, don't delete.
$invalid = FALSE;
$pslf = new PayStubListFactory();
$pslf->getByCurrencyId($this->getId());
if ($pslf->getRecordCount() > 0) {
$invalid = TRUE;
}
if ($invalid == FALSE) {
$ulf = new UserListFactory();
$ulf->getByCurrencyId($this->getId());
if ($ulf->getRecordCount() > 0) {
$invalid = TRUE;
}
}
if ($invalid == TRUE) {
$this->Validator->isTRUE('in_use', FALSE, TTi18n::gettext('This currency is in use'));
}
}
return TRUE;
}
示例15: postSave
function postSave()
{
$this->StartTransaction();
$this->getFastTreeObject()->setTree($this->getCompany());
if ($this->getDeleted() == TRUE) {
//FIXME: Get parent of this object, and re-parent all groups to it.
$parent_id = $this->getFastTreeObject()->getParentId($this->getId());
//Get items by group id.
$ulf = new UserListFactory();
$ulf->getByCompanyIdAndGroupId($this->getCompany(), $this->getId());
if ($ulf->getRecordCount() > 0) {
foreach ($ulf as $obj) {
Debug::Text(' Re-Grouping Item: ' . $obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
$obj->setGroup($parent_id);
$obj->Save();
}
}
$this->getFastTreeObject()->delete($this->getId());
$this->CommitTransaction();
return TRUE;
} else {
$retval = TRUE;
//if ( $this->getId() === FALSE ) {
if ($this->insert_tree === TRUE) {
Debug::Text(' Adding Node ', __FILE__, __LINE__, __METHOD__, 10);
//echo "Current ID: ". $this->getID() ."<br>\n";
//echo "Parent ID: ". $this->getParent() ."<br>\n";
//Add node to tree
if ($this->getFastTreeObject()->add($this->getID(), $this->getParent()) === FALSE) {
Debug::Text(' Failed adding Node ', __FILE__, __LINE__, __METHOD__, 10);
$this->Validator->isTrue('name', FALSE, TTi18n::gettext('Name is already in use'));
$retval = FALSE;
}
} else {
Debug::Text(' Editing Node ', __FILE__, __LINE__, __METHOD__, 10);
//Edit node.
$retval = $this->getFastTreeObject()->move($this->getID(), $this->getParent());
}
if ($retval === TRUE) {
$this->CommitTransaction();
} else {
$this->FailTransaction();
}
return $retval;
}
}