当前位置: 首页>>代码示例>>PHP>>正文


PHP TTDate::getDays方法代码示例

本文整理汇总了PHP中TTDate::getDays方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getDays方法的具体用法?PHP TTDate::getDays怎么用?PHP TTDate::getDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TTDate的用法示例。


在下文中一共展示了TTDate::getDays方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isActiveLengthOfService

 function isActiveLengthOfService($u_obj, $epoch)
 {
     if ($this->getMinimumLengthOfServiceUnit() == 50 or $this->getMaximumLengthOfServiceUnit() == 50) {
         //Hour based length of service, get users hours up until this period.
         $worked_time = TTDate::getHours($this->getWorkedTimeByUserIdAndEndDate($u_obj->getId(), $epoch));
         Debug::Text('  Worked Time: ' . $worked_time . 'hrs', __FILE__, __LINE__, __METHOD__, 10);
     }
     $employed_days = TTDate::getDays($epoch - $u_obj->getHireDate());
     Debug::Text('  Employed Days: ' . $employed_days, __FILE__, __LINE__, __METHOD__, 10);
     $minimum_length_of_service_result = FALSE;
     $maximum_length_of_service_result = FALSE;
     //Check minimum length of service
     if ($this->getMinimumLengthOfService() == 0 or $this->getMinimumLengthOfServiceUnit() == 50 and $worked_time >= $this->getMinimumLengthOfService() or $this->getMinimumLengthOfServiceUnit() != 50 and $employed_days >= $this->getMinimumLengthOfServiceDays()) {
         $minimum_length_of_service_result = TRUE;
     }
     //Check maximum length of service.
     if ($this->getMaximumLengthOfService() == 0 or $this->getMaximumLengthOfServiceUnit() == 50 and $worked_time <= $this->getMaximumLengthOfService() or $this->getMaximumLengthOfServiceUnit() != 50 and $employed_days <= $this->getMaximumLengthOfServiceDays()) {
         $maximum_length_of_service_result = TRUE;
     }
     Debug::Text('&nbsp;&nbsp; Min Result: : ' . (int) $minimum_length_of_service_result . ' Max Result: ' . (int) $maximum_length_of_service_result, __FILE__, __LINE__, __METHOD__, 10);
     if ($minimum_length_of_service_result == TRUE and $maximum_length_of_service_result == TRUE) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:25,代码来源:CompanyDeductionFactory.class.php

示例2: getNextPayPeriod


//.........这里部分代码省略.........
                     Debug::text('Right on day boundary, minus an additional second to account for difference...', __FILE__, __LINE__, __METHOD__, 10);
                     $tmp_pay_period_end_date--;
                 }
             }
             Debug::text('aTmp Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $tmp_pay_period_end_date) . ' (' . $tmp_pay_period_end_date . ')', __FILE__, __LINE__, __METHOD__, 10);
             $start_date = $tmp_pay_period_end_date + 1;
             if ($this->getType() == 10) {
                 //Weekly
                 $tmp_pay_period_end_date = TTDate::getMiddleDayEpoch($start_date) + 86400 * 7;
                 //Add one week
             } elseif ($this->getType() == 20) {
                 //Bi-Weekly
                 $tmp_pay_period_end_date = TTDate::getMiddleDayEpoch($start_date) + 86400 * 14;
                 //Add two weeks
             }
             //Use Begin Day Epoch to nullify DST issues.
             $end_date = TTDate::getBeginDayEpoch($tmp_pay_period_end_date) - 1;
             $transaction_date = TTDate::getMiddleDayEpoch(TTDate::getMiddleDayEpoch($end_date) + $this->getTransactionDate() * 86400);
             break;
         case 30:
             //Semi-monthly
             $tmp_last_pay_period_end_day_of_month = TTDate::getDayOfMonth($last_pay_period_end_date + 1);
             Debug::text('bLast Pay Period End Day Of Month: ' . $tmp_last_pay_period_end_day_of_month, __FILE__, __LINE__, __METHOD__, 10);
             if ($tmp_last_pay_period_end_day_of_month == $this->convertLastDayOfMonth($this->getPrimaryDayOfMonth())) {
                 $insert_pay_period = 1;
                 $primary = TRUE;
             } elseif ($tmp_last_pay_period_end_day_of_month == $this->convertLastDayOfMonth($this->getSecondaryDayOfMonth())) {
                 $insert_pay_period = 2;
                 $primary = FALSE;
             } else {
                 Debug::text('Finding if Primary or Secondary is closest...', __FILE__, __LINE__, __METHOD__, 10);
                 $primary_date_offset = TTDate::getDateOfNextDayOfMonth($last_pay_period_end_date, NULL, $this->convertLastDayOfMonth($this->getPrimaryDayOfMonth())) - $last_pay_period_end_date;
                 $secondary_date_offset = TTDate::getDateOfNextDayOfMonth($last_pay_period_end_date, NULL, $this->convertLastDayOfMonth($this->getSecondaryDayOfMonth())) - $last_pay_period_end_date;
                 Debug::text('Primary Date Offset: ' . TTDate::getDays($primary_date_offset) . ' Secondary Date Offset: ' . TTDate::getDays($secondary_date_offset), __FILE__, __LINE__, __METHOD__, 10);
                 if ($primary_date_offset <= $secondary_date_offset) {
                     $insert_pay_period = 1;
                     $primary = TRUE;
                     $last_pay_period_end_date = TTDate::getDateOfNextDayOfMonth($last_pay_period_end_date, NULL, $this->convertLastDayOfMonth($this->getPrimaryDayOfMonth()));
                 } else {
                     $insert_pay_period = 2;
                     $primary = FALSE;
                     $last_pay_period_end_date = TTDate::getDateOfNextDayOfMonth($last_pay_period_end_date, NULL, $this->convertLastDayOfMonth($this->getSecondaryDayOfMonth()));
                 }
                 $last_pay_period_end_date = TTDate::getBeginDayEpoch($last_pay_period_end_date);
             }
             unset($tmp_last_pay_period_end_day_of_month);
             Debug::text('cLast Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $last_pay_period_end_date) . ' (' . $last_pay_period_end_date . ') Primary: ' . (int) $primary, __FILE__, __LINE__, __METHOD__, 10);
             $start_date = $last_pay_period_end_date + 1;
             if ($primary == TRUE) {
                 $end_date = TTDate::getBeginDayEpoch(TTDate::getDateOfNextDayOfMonth($start_date, NULL, $this->convertLastDayOfMonth($this->getSecondaryDayOfMonth()))) - 1;
                 $transaction_date = TTDate::getMiddleDayEpoch(TTDate::getDateOfNextDayOfMonth(TTDate::getMiddleDayEpoch($end_date), NULL, $this->convertLastDayOfMonth($this->getPrimaryTransactionDayOfMonth())));
             } else {
                 $end_date = TTDate::getBeginDayEpoch(TTDate::getDateOfNextDayOfMonth($start_date, NULL, $this->convertLastDayOfMonth($this->getPrimaryDayOfMonth()))) - 1;
                 $transaction_date = TTDate::getMiddleDayEpoch(TTDate::getDateOfNextDayOfMonth(TTDate::getMiddleDayEpoch($end_date), NULL, $this->convertLastDayOfMonth($this->getSecondaryTransactionDayOfMonth())));
             }
             break;
         case 50:
             //Monthly
             $start_date = $last_pay_period_end_date + 1;
             $end_date = TTDate::getDateOfNextDayOfMonth($start_date + 86400, NULL, $this->convertLastDayOfMonth($this->getPrimaryDayOfMonth()));
             //Use Begin Day Epoch to nullify DST issues.
             $end_date = TTDate::getBeginDayEpoch(TTDate::getBeginMinuteEpoch($end_date)) - 1;
             $transaction_date = TTDate::getMiddleDayEpoch(TTDate::getDateOfNextDayOfMonth($end_date, NULL, $this->convertLastDayOfMonth($this->getPrimaryTransactionDayOfMonth())));
             break;
     }
     if ($this->getDayStartTime() != 0) {
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:67,代码来源:PayPeriodScheduleFactory.class.php

示例3: urlencode

         $ugsf->setUser($current_user->getId());
         $ugsf->setBatchID($ugsf->getNextBatchId());
         $ugsf->setQueue(UserGenericStatusFactory::getStaticQueue());
         $ugsf->saveQueue();
         $progress_bar->setValue(100);
         $progress_bar->display();
         $next_page = URLBuilder::getURL(array('batch_id' => $ugsf->getBatchID(), 'batch_title' => 'Mass Schedule', 'batch_next_page' => urlencode(URLBuilder::getURL(array('data' => $data, 'filter_user_id' => $filter_user_id), '../schedule/AddMassSchedule.php'))), '../users/UserGenericStatusList.php');
     }
     break;
 case 'recalculate_accrual_policy':
     //Debug::setVerbosity(11);
     if (isset($data['accrual_policy_id']) and isset($data['start_date']) and isset($data['end_date'])) {
         if ($data['start_date'] <= $data['end_date']) {
             $start_date = TTDate::getMiddleDayEpoch($data['start_date']);
             $end_date = TTDate::getMiddleDayEpoch($data['end_date']);
             $total_days = TTDate::getDays($end_date - $start_date);
             $offset = 86400 / 2;
             $init_progress_bar = TRUE;
             if ($init_progress_bar == TRUE) {
                 InitProgressBar();
                 $init_progress_bar = FALSE;
             }
             $progress_bar->setValue(0);
             $progress_bar->display();
             $apf = TTnew('AccrualPolicyFactory');
             $aplf = TTnew('AccrualPolicyListFactory');
             $aplf->getByIdAndCompanyId((int) $data['accrual_policy_id'], $current_company->getId());
             if ($aplf->getRecordCount() > 0) {
                 foreach ($aplf as $ap_obj) {
                     $aplf->StartTransaction();
                     TTLog::addEntry($current_user->getId(), 500, 'Recalculate Accrual Policy: ' . $ap_obj->getName() . ' Start Date: ' . TTDate::getDate('TIME', $data['start_date']) . ' End Date: ' . TTDate::getDate('TIME', $data['end_date']) . ' Total Days: ' . round($total_days), $current_user->getId(), $ap_obj->getTable());
开发者ID:alachaum,项目名称:timetrex,代码行数:31,代码来源:ProgressBar.php

示例4: detectPayPeriodScheduleSettings

 function detectPayPeriodScheduleSettings($type_id, $example_dates)
 {
     Debug::Arr($example_dates, 'Pay Period Type: ' . $type_id . ' Example Dates: ', __FILE__, __LINE__, __METHOD__, 10);
     if ($type_id == '') {
         $type_id = $this->getType();
     }
     if (!is_array($example_dates)) {
         $example_dates = array();
     }
     if (!isset($example_dates[0]['start_date']) or isset($example_dates[0]['start_date']) and $example_dates[0]['start_date'] == '') {
         Debug::Text('Example dates not specified properly, skipping...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $this->setType($type_id);
     if (isset($example_dates[0]['start_date'])) {
         $this->setAnchorDate(TTDate::parseDateTime($example_dates[0]['start_date']) - 86400);
         //Anchor date one day before first start date.
     }
     $annual_pay_periods = $this->calcAnnualPayPeriods($type_id);
     switch ($type_id) {
         case 5:
             //Manual
             break;
         case 10:
             //Weekly
         //Weekly
         case 20:
             //BiWeekly
             //Need at least one example.
             foreach ($example_dates as $example_date) {
                 $start_dow[] = TTDate::getDayOfWeek(TTDate::parseDateTime($example_date['start_date']));
                 $transaction_days[] = (int) round(TTDate::getDays(TTDate::parseDateTime($example_date['transaction_date']) - TTDate::parseDateTime($example_date['end_date'])));
             }
             Debug::Arr($start_dow, 'Start DOW: ', __FILE__, __LINE__, __METHOD__, 10);
             Debug::Arr($transaction_days, 'Transaction Days: ', __FILE__, __LINE__, __METHOD__, 10);
             //Get the most common values from arrays.
             $start_day_of_week = Misc::arrayCommonValue($start_dow);
             Debug::Arr($start_dow, 'Start Day Of Week: ' . $start_day_of_week . ' Start DOW Count: ', __FILE__, __LINE__, __METHOD__, 10);
             $transaction_date = Misc::arrayCommonValue($transaction_days);
             Debug::Arr($transaction_days, 'Transaction Date: ' . $transaction_date . ' Transaction Days Count: ', __FILE__, __LINE__, __METHOD__, 10);
             $this->setStartDayOfWeek($start_day_of_week);
             $this->setTransactionDate($transaction_date);
             break;
         case 30:
             //Semi-monthly
             //Need at least three examples?
             $i = 0;
             foreach ($example_dates as $example_date) {
                 if ($i % 2 == 0) {
                     $primary_start_dom[] = TTDate::getDayOfMonth(TTDate::parseDateTime($example_date['start_date']));
                     $primary_transaction_dom[] = TTDate::getDayOfMonth(TTDate::parseDateTime($example_date['transaction_date']));
                 } else {
                     $secondary_start_dom[] = TTDate::getDayOfMonth(TTDate::parseDateTime($example_date['start_date']));
                     $secondary_transaction_dom[] = TTDate::getDayOfMonth(TTDate::parseDateTime($example_date['transaction_date']));
                 }
                 $i++;
             }
             Debug::Arr($primary_start_dom, 'Primary Start DOM: ', __FILE__, __LINE__, __METHOD__, 10);
             Debug::Arr($primary_transaction_dom, 'Primary Transaction DOM: ', __FILE__, __LINE__, __METHOD__, 10);
             Debug::Arr($secondary_start_dom, 'Secondary Start DOM: ', __FILE__, __LINE__, __METHOD__, 10);
             Debug::Arr($secondary_transaction_dom, 'Secondary Transaction DOM: ', __FILE__, __LINE__, __METHOD__, 10);
             $primary_dom = Misc::arrayCommonValue($primary_start_dom);
             $primary_transaction_dom = Misc::arrayCommonValue($primary_transaction_dom);
             $secondary_dom = Misc::arrayCommonValue($secondary_start_dom);
             $secondary_transaction_dom = Misc::arrayCommonValue($secondary_transaction_dom);
             Debug::Text('Primary: ' . $primary_dom . ' Trans: ' . $primary_transaction_dom . ' Secondary: ' . $secondary_dom . ' Trans: ' . $secondary_transaction_dom, __FILE__, __LINE__, __METHOD__, 10);
             $this->setPrimaryDayOfMonth($primary_dom);
             $this->setSecondaryDayOfMonth($secondary_dom);
             $this->setPrimaryTransactionDayOfMonth($primary_transaction_dom);
             $this->setSecondaryTransactionDayOfMonth($secondary_transaction_dom);
             break;
         case 50:
             //Monthly
             //Need at least one example.
             foreach ($example_dates as $example_date) {
                 $primary_start_dom[] = TTDate::getDayOfMonth(TTDate::parseDateTime($example_date['start_date']));
                 $primary_transaction_dom[] = TTDate::getDayOfMonth(TTDate::parseDateTime($example_date['transaction_date']));
             }
             Debug::Arr($primary_start_dom, 'Primary Start DOM: ', __FILE__, __LINE__, __METHOD__, 10);
             Debug::Arr($primary_transaction_dom, 'Primary Transaction DOM: ', __FILE__, __LINE__, __METHOD__, 10);
             $primary_dom = Misc::arrayCommonValue($primary_start_dom);
             $primary_transaction_dom = Misc::arrayCommonValue($primary_transaction_dom);
             $this->setPrimaryDayOfMonth($primary_dom);
             $this->setPrimaryTransactionDayOfMonth($primary_transaction_dom);
             break;
         default:
             return FALSE;
             break;
     }
     Debug::Arr($this->data, 'PP Schedule Data: ', __FILE__, __LINE__, __METHOD__, 10);
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:92,代码来源:PayPeriodScheduleFactory.class.php

示例5: calcAccrualTime

 function calcAccrualTime($company_id, $accrual_policy_id, $start_date, $end_date)
 {
     $start_date = TTDate::getMiddleDayEpoch($start_date);
     $end_date = TTDate::getMiddleDayEpoch($end_date);
     $total_days = TTDate::getDays($end_date - $start_date);
     $offset = 79200;
     $apf = TTnew('AccrualPolicyFactory');
     $aplf = TTnew('AccrualPolicyListFactory');
     $aplf->getByIdAndCompanyId((int) $accrual_policy_id, $company_id);
     if ($aplf->getRecordCount() > 0) {
         foreach ($aplf as $ap_obj) {
             $aplf->StartTransaction();
             $x = 0;
             for ($i = $start_date; $i < $end_date; $i += 86400) {
                 Debug::Text('Recalculating Accruals for Date: ' . TTDate::getDate('DATE+TIME', TTDate::getBeginDayEpoch($i)), __FILE__, __LINE__, __METHOD__, 10);
                 $ap_obj->addAccrualPolicyTime(TTDate::getBeginDayEpoch($i) + 7201, $offset);
                 Debug::Text('----------------------------------', __FILE__, __LINE__, __METHOD__, 10);
                 $x++;
             }
             $aplf->CommitTransaction();
         }
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:24,代码来源:AccrualPolicyTest.php

示例6: calcAccrualPolicyTime

 function calcAccrualPolicyTime($u_obj, $epoch, $offset, $pps_obj, $pay_period_arr, $accrual_balance, $update_records = TRUE)
 {
     $retval = 0;
     Debug::Text('User: ' . $u_obj->getFullName() . ' Status: ' . $u_obj->getStatus() . ' Epoch: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
     //Make sure only active employees accrue time *after* their hire date.
     //Will this negative affect Employees who may be on leave?
     if ($u_obj->getStatus() == 10 and $epoch >= $u_obj->getHireDate() and ($this->getMinimumEmployedDays() == 0 or TTDate::getDays($epoch - $u_obj->getHireDate()) >= $this->getMinimumEmployedDays())) {
         Debug::Text('&nbsp;&nbsp;User is active and has been employed long enough.', __FILE__, __LINE__, __METHOD__, 10);
         $annual_pay_periods = $pps_obj->getAnnualPayPeriods();
         $in_apply_frequency_window = FALSE;
         $in_apply_rollover_window = FALSE;
         $pay_period_start_date = NULL;
         $accrual_amount = 0;
         if ($this->getType() == 30) {
             Debug::Text('&nbsp;&nbsp;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) {
                 $pay_period_dates = $this->getPayPeriodDatesFromArray($pay_period_arr, $epoch - $offset);
                 if (is_array($pay_period_dates)) {
                     Debug::Text('&nbsp;&nbsp; Pay Period Start Date: ' . TTDate::getDate('DATE+TIME', $pay_period_dates['start_date']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $pay_period_dates['end_date']), __FILE__, __LINE__, __METHOD__, 10);
                     if ($this->inApplyFrequencyWindow($epoch, $offset, $pay_period_dates['end_date']) == TRUE) {
                         $in_apply_frequency_window = TRUE;
                         $pay_period_start_date = $pay_period_dates['start_date'];
                         //Used for inRolloverFrequencyWindow
                     } else {
                         Debug::Text('&nbsp;&nbsp;User not in Apply Frequency Window: ', __FILE__, __LINE__, __METHOD__, 10);
                     }
                 } else {
                     Debug::Arr($pay_period_dates, '&nbsp;&nbsp; No Pay Period Dates Found.', __FILE__, __LINE__, __METHOD__, 10);
                 }
             } elseif ($this->inApplyFrequencyWindow($epoch, $offset, NULL, $u_obj->getHireDate()) == TRUE) {
                 Debug::Text('&nbsp;&nbsp;User IS in NON-PayPeriod Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
                 $in_apply_frequency_window = TRUE;
             } else {
                 Debug::Text('&nbsp;&nbsp;User is not in Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
                 $in_apply_frequency_window = FALSE;
             }
         }
         if ($this->inRolloverFrequencyWindow($epoch, $offset, $u_obj->getHireDate(), $pay_period_start_date)) {
             Debug::Text('&nbsp;&nbsp; In rollover window...', __FILE__, __LINE__, __METHOD__, 10);
             $in_apply_rollover_window = TRUE;
         }
         if ($in_apply_frequency_window == TRUE or $in_apply_rollover_window == TRUE) {
             $milestone_obj = $this->getActiveMilestoneObject($u_obj, $epoch);
         }
         if ($in_apply_rollover_window == TRUE and (isset($milestone_obj) and is_object($milestone_obj))) {
             //Have accrual balance passed in for optimization
             //$accrual_balance = $this->getCurrentAccrualBalance( $u_obj->getID(), $this->getId() );
             //Handle maximum rollover adjustments before continuing.
             if ($accrual_balance > $milestone_obj->getRolloverTime()) {
                 $rollover_accrual_adjustment = bcsub($milestone_obj->getRolloverTime(), $accrual_balance, 0);
                 Debug::Text('&nbsp;&nbsp; Adding rollover adjustment of: ' . $rollover_accrual_adjustment, __FILE__, __LINE__, __METHOD__, 10);
                 //Check to make sure there isn't an identical entry already made.
                 //Ignore rollover adjustment is another adjustment of any amount has been made on the same day.
                 $alf = TTnew('AccrualListFactory');
                 if ($update_records == TRUE) {
                     $alf->getByCompanyIdAndUserIdAndAccrualPolicyIDAndTypeIDAndTimeStamp($u_obj->getCompany(), $u_obj->getID(), $this->getId(), 60, TTDate::getMiddleDayEpoch($epoch));
                 }
                 if ($alf->getRecordCount() == 0) {
                     //Get effective date, try to use the current milestone rollover date to make things more clear.
                     $current_milestone_rollover_date = $this->getCurrentMilestoneRolloverDate($epoch, $u_obj->getHireDate());
                     //If milestone rollover date comes after the current epoch, back date it by one year.
                     if ($current_milestone_rollover_date > $epoch) {
                         $current_milestone_rollover_date = mktime(0, 0, 0, TTDate::getMonth($current_milestone_rollover_date), TTDate::getDayOfMonth($current_milestone_rollover_date), TTDate::getYear($epoch) - 1);
                     }
                     if ($update_records == TRUE) {
                         //Don't round to the nearest minute, as that can cause too much error on weekly frequencies.
                         $af = TTnew('AccrualFactory');
                         $af->setUser($u_obj->getID());
                         $af->setType(60);
                         //Rollover Adjustment
                         $af->setAccrualPolicyID($this->getId());
                         $af->setAmount($rollover_accrual_adjustment);
                         $af->setTimeStamp(TTDate::getMiddleDayEpoch($current_milestone_rollover_date));
                         $af->setEnableCalcBalance(TRUE);
                         if ($af->isValid()) {
                             $af->Save();
                         }
                     } else {
                         Debug::Text('&nbsp;&nbsp; NOT UPDATING RECORDS...', __FILE__, __LINE__, __METHOD__, 10);
                         $retval = $rollover_accrual_adjustment;
                     }
                     //Make sure we get updated balance after rollover adjustment was made.
                     $accrual_balance += $rollover_accrual_adjustment;
                     unset($current_milestone_rollover_date);
                 } else {
                     Debug::Text('&nbsp;&nbsp; Found duplicate rollover accrual entry, skipping...', __FILE__, __LINE__, __METHOD__, 10);
                 }
             } else {
                 Debug::Text('&nbsp;&nbsp; Balance hasnt exceeded rollover adjustment...', __FILE__, __LINE__, __METHOD__, 10);
             }
             unset($rollover_accrual_adjustment, $alf, $af);
         }
         if ($in_apply_frequency_window === TRUE) {
             if (isset($milestone_obj) and is_object($milestone_obj)) {
                 Debug::Text('&nbsp;&nbsp;Found Matching Milestone, Accrual Rate: (ID: ' . $milestone_obj->getId() . ') ' . $milestone_obj->getAccrualRate() . '/year', __FILE__, __LINE__, __METHOD__, 10);
                 //Make sure we get updated balance after rollover adjustment was made.
                 //Have accrual balance passed in for optimization
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:AccrualPolicyFactory.class.php

示例7: calcAccrualPolicy


//.........这里部分代码省略.........
                     $af->Save();
                 }
                 unset($accrual_amount);
             }
         }
         if ($this->getAbsencePolicyID() != FALSE) {
             $accrual_policy_id = $this->getAbsencePolicyObject()->getAccrualPolicyID();
             Debug::text('Absence Accrual Policy ID: ' . $accrual_policy_id . ' Absence Policy ID: ' . $this->getAbsencePolicyObject()->getID() . ' Absence Policy IDb: ' . $this->getAbsencePolicyID(), __FILE__, __LINE__, __METHOD__, 10);
             //Absence entry was modified, delete previous accrual entry and re-create it.
             $alf = TTnew('AccrualListFactory');
             $alf->getByUserIdAndUserDateTotalID($this->getUserDateObject()->getUser(), $this->getID());
             if ($alf->getRecordCount() > 0) {
                 foreach ($alf as $af_obj) {
                     Debug::text('Found existing accrual!! ID: ' . $af_obj->getID() . ' UserDateTotalID: ' . $this->getID(), __FILE__, __LINE__, __METHOD__, 10);
                     $af_obj->setDeleted(TRUE);
                     $af_obj->setEnableCalcBalance(TRUE);
                     if ($af_obj->isValid()) {
                         $af_obj->Save();
                     }
                 }
             }
             unset($alf, $af_obj);
             if ($accrual_policy_id > 0) {
                 $af = TTnew('AccrualFactory');
                 $af->setUser($this->getUserDateObject()->getUser());
                 $af->setAccrualPolicyID($accrual_policy_id);
                 $af->setTimeStamp($this->getUserDateObject()->getDateStamp());
                 $af->setUserDateTotalID($this->getID());
                 //By default we withdraw from accrual policy, so if there is a negative rate, deposit instead.
                 $accrual_amount = bcmul($this->getTotalTime(), bcmul($this->getAbsencePolicyObject()->getAccrualRate(), -1));
                 if ($accrual_amount > 0) {
                     $af->setType(10);
                     //Banked
                 } else {
                     $af->setType(20);
                     //Used
                 }
                 $af->setAmount($accrual_amount);
                 $af->setEnableCalcBalance(TRUE);
                 if ($af->isValid()) {
                     $af->Save();
                 }
             }
         }
         unset($af, $accrual_policy_id);
         //Calculate any hour based accrual policies.
         //if ( $this->getType() == 10 AND $this->getStatus() == 10 ) {
         if ($this->getStatus() == 10 and in_array($this->getType(), array(20, 30))) {
             //Calculate hour based accruals on regular/overtime only.
             $aplf = TTnew('AccrualPolicyListFactory');
             $aplf->getByPolicyGroupUserIdAndType($this->getUserDateObject()->getUser(), 30);
             if ($aplf->getRecordCount() > 0) {
                 Debug::text('Found Hour Based Accrual Policies to apply.', __FILE__, __LINE__, __METHOD__, 10);
                 foreach ($aplf as $ap_obj) {
                     if ($ap_obj->getMinimumEmployedDays() == 0 or TTDate::getDays($this->getUserDateObject()->getDateStamp() - $this->getUserDateObject()->getUserObject()->getHireDate()) >= $ap_obj->getMinimumEmployedDays()) {
                         Debug::Text('  User has been employed long enough.', __FILE__, __LINE__, __METHOD__, 10);
                         $milestone_obj = $ap_obj->getActiveMilestoneObject($this->getUserDateObject()->getUserObject(), $this->getUserDateObject()->getDateStamp());
                         $accrual_balance = $ap_obj->getCurrentAccrualBalance($this->getUserDateObject()->getUserObject()->getId(), $ap_obj->getId());
                         //If Maximum time is set to 0, make that unlimited.
                         if (is_object($milestone_obj) and ($milestone_obj->getMaximumTime() == 0 or $accrual_balance < $milestone_obj->getMaximumTime())) {
                             $accrual_amount = $ap_obj->calcAccrualAmount($milestone_obj, $this->getTotalTime(), 0);
                             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, 4);
                                 }
                                 Debug::Text('   Min/Max Adjusted Accrual Amount: ' . $accrual_amount . ' Limits: Min: ' . $milestone_obj->getMinimumTime() . ' Max: ' . $milestone_obj->getMaximumTime(), __FILE__, __LINE__, __METHOD__, 10);
                                 $af = TTnew('AccrualFactory');
                                 $af->setUser($this->getUserDateObject()->getUserObject()->getId());
                                 $af->setType(75);
                                 //Accrual Policy
                                 $af->setAccrualPolicyID($ap_obj->getId());
                                 $af->setUserDateTotalID($this->getID());
                                 $af->setAmount($accrual_amount);
                                 $af->setTimeStamp($this->getUserDateObject()->getDateStamp());
                                 $af->setEnableCalcBalance(TRUE);
                                 if ($af->isValid()) {
                                     $af->Save();
                                 }
                                 unset($accrual_amount, $accrual_balance, $new_accrual_balance);
                             } else {
                                 Debug::Text('   Accrual Amount is 0...', __FILE__, __LINE__, __METHOD__, 10);
                             }
                         } else {
                             Debug::Text('   Accrual Balance is outside Milestone Range. Or no milestone found. Skipping...', __FILE__, __LINE__, __METHOD__, 10);
                         }
                     } else {
                         Debug::Text('  User has only been employed: ' . TTDate::getDays($this->getUserDateObject()->getDateStamp() - $this->getUserDateObject()->getUserObject()->getHireDate()) . ' Days, not enough.', __FILE__, __LINE__, __METHOD__, 10);
                     }
                 }
             } else {
                 Debug::text('No Hour Based Accrual Policies to apply.', __FILE__, __LINE__, __METHOD__, 10);
             }
         } else {
             Debug::text('No worked time on this day or not proper type/status, skipping hour based accrual policies...', __FILE__, __LINE__, __METHOD__, 10);
         }
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:UserDateTotalFactory.class.php

示例8: 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('&nbsp;&nbsp;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('&nbsp;&nbsp;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('&nbsp;&nbsp;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('&nbsp;&nbsp;User not in Apply Frequency Window: ', __FILE__, __LINE__, __METHOD__, 10);
                                             }
                                         }
                                     } else {
                                         Debug::Text('&nbsp;&nbsp; No Pay Period Found.', __FILE__, __LINE__, __METHOD__, 10);
                                     }
                                 } elseif ($this->inApplyFrequencyWindow($epoch, $offset) == TRUE) {
                                     Debug::Text('&nbsp;&nbsp;User IS in NON-PayPeriod Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
                                     $in_apply_frequency_window = TRUE;
                                 } else {
                                     Debug::Text('&nbsp;&nbsp;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('&nbsp;&nbsp;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('&nbsp;&nbsp; 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('&nbsp;&nbsp; Found duplicate accrual entry, skipping...', __FILE__, __LINE__, __METHOD__, 10);
                                             }
                                             unset($accrual_amount, $accrual_balance, $new_accrual_balance);
//.........这里部分代码省略.........
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:101,代码来源:AccrualPolicyFactory.class.php

示例9: checkPasswordAge

 function checkPasswordAge()
 {
     $c_obj = $this->getCompanyObject();
     //Always add 1 to the PasswordMaximumAge so if its set to 0 by mistake it will still allow the user to login after changing their password.
     Debug::Text('Password Policy: Type: ' . $c_obj->getPasswordPolicyType() . '(' . $c_obj->getProductEdition() . ') Current Age: ' . TTDate::getDays(time() - $this->getPasswordUpdatedDate()) . '(' . $this->getPasswordUpdatedDate() . ') Maximum Age: ' . $c_obj->getPasswordMaximumAge() . ' days', __FILE__, __LINE__, __METHOD__, 10);
     if (PRODUCTION == TRUE and is_object($c_obj) and $c_obj->getPasswordPolicyType() == 1 and (int) $this->getPasswordUpdatedDate() < time() - ($c_obj->getPasswordMaximumAge() + 1) * 86400 and $c_obj->getProductEdition() > 10) {
         Debug::Text('Password Policy: Password exceeds maximum age, denying access...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:11,代码来源:UserFactory.class.php

示例10: getObjectAsArray

 function getObjectAsArray($include_columns = NULL)
 {
     $variable_function_map = $this->getVariableToFunctionMap();
     if (is_array($variable_function_map)) {
         foreach ($variable_function_map as $variable => $function_stub) {
             if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) {
                 $function = 'get' . $function_stub;
                 switch ($variable) {
                     case 'status':
                     case 'ldap_authentication_type':
                     case 'password_policy_type':
                         $function = 'get' . $variable;
                         if (method_exists($this, $function)) {
                             $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable));
                         }
                         break;
                     case 'product_edition':
                         $data[$variable] = Option::getByKey($this->getProductEdition(), $this->getOptions($variable));
                         break;
                     case 'industry':
                         $data[$variable] = Option::getByKey($this->getIndustry(), $this->getOptions($variable));
                         break;
                     case 'last_login_date':
                         $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->getColumn($variable));
                         break;
                     case 'total_active_days':
                     case 'last_login_days':
                         $data[$variable] = (int) TTDate::getDays((int) $this->getColumn($variable));
                         break;
                     case 'this_month_min_active_users':
                     case 'this_month_avg_active_users':
                     case 'this_month_max_active_users':
                     case 'last_month_min_active_users':
                     case 'last_month_avg_active_users':
                     case 'last_month_max_active_users':
                         $data[$variable] = (int) $this->getColumn($variable);
                         break;
                     case 'name_metaphone':
                         break;
                     default:
                         if (method_exists($this, $function)) {
                             $data[$variable] = $this->{$function}();
                         }
                         break;
                 }
             }
         }
         $this->getCreatedAndUpdatedColumns($data, $include_columns);
     }
     return $data;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:51,代码来源:CompanyFactory.class.php


注:本文中的TTDate::getDays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。