本文整理汇总了PHP中TTDate::getEndDayEpoch方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getEndDayEpoch方法的具体用法?PHP TTDate::getEndDayEpoch怎么用?PHP TTDate::getEndDayEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::getEndDayEpoch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMaximumShiftTimeD
function testMaximumShiftTimeD()
{
global $dd;
$this->createPayPeriodSchedule(10);
$this->createPayPeriods();
$this->getAllPayPeriods();
$date_epoch = TTDate::getBeginWeekEpoch(time());
$date_stamp = TTDate::getDate('DATE', $date_epoch);
$date_epoch2 = TTDate::getBeginDayEpoch(TTDate::getBeginWeekEpoch(time()) + 86400 + 3600);
$date_stamp2 = TTDate::getDate('DATE', $date_epoch2);
//Create two punch pairs with LESS than the minimum time between shifts, so they both fall on the same day, but are considered ONE shift and therefore fails.
//However the last punch must be more than 16hrs away from the previous OUT punch (2:30PM)
$dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 1:00AM'), strtotime($date_stamp . ' 2:30PM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
$dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 6:15PM'), strtotime($date_stamp2 . ' 8:00AM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
$punch_arr = $this->getPunchDataArray(TTDate::getBeginDayEpoch($date_epoch), TTDate::getEndDayEpoch($date_epoch2));
//print_r($punch_arr);
$this->assertEquals(2, count($punch_arr[$date_epoch][0]['shift_data']['punches']));
$this->assertEquals(1, count($punch_arr[$date_epoch][0]['shift_data']['punch_control_ids']));
//$this->assertEquals( $date_epoch, $punch_arr[$date_epoch][0]['date_stamp'] );
$udt_arr = $this->getUserDateTotalArray($date_epoch, $date_epoch2);
//Total Time
$this->assertEquals(10, $udt_arr[$date_epoch][0]['status_id']);
$this->assertEquals(10, $udt_arr[$date_epoch][0]['type_id']);
$this->assertEquals(13.5 * 3600, $udt_arr[$date_epoch][0]['total_time']);
return TRUE;
}
示例2: TTnew
$pay_period_ids[] = $pay_period_obj->getId();
$pay_period_end_dates[$pay_period_obj->getId()] = $pay_period_obj->getEndDate();
if ($pp == 0) {
$default_start_date = $pay_period_obj->getStartDate();
$default_end_date = $pay_period_obj->getEndDate();
}
$pp++;
}
$pplf = TTnew('PayPeriodListFactory');
$pay_period_options = $pplf->getByIdListArray($pay_period_ids, NULL, array('start_date' => 'desc'));
}
if (isset($filter_data['start_date'])) {
$filter_data['start_date'] = TTDate::getBeginDayEpoch(TTDate::parseDateTime($filter_data['start_date']));
}
if (isset($filter_data['end_date'])) {
$filter_data['end_date'] = TTDate::getEndDayEpoch(TTDate::parseDateTime($filter_data['end_date']));
}
$filter_data = Misc::preSetArrayValues($filter_data, array('include_user_ids', 'exclude_user_ids', 'user_status_ids', 'group_ids', 'branch_ids', 'department_ids', 'schedule_branch_ids', 'schedule_department_ids', 'user_title_ids', 'pay_period_ids', 'include_job_ids', 'exclude_job_ids', 'job_branch_ids', 'job_department_ids', 'job_group_ids', 'client_ids', 'job_item_ids', 'job_item_group_ids', 'column_ids'), array());
//Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
$permission_children_ids = array();
$wage_permission_children_ids = array();
if ($permission->Check('user', 'view') == FALSE) {
$hlf = TTnew('HierarchyListFactory');
$permission_children_ids = $wage_permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($current_company->getId(), $current_user->getId());
Debug::Arr($permission_children_ids, 'Permission Children Ids:', __FILE__, __LINE__, __METHOD__, 10);
if ($permission->Check('user', 'view_child') == FALSE) {
$permission_children_ids = array();
}
if ($permission->Check('user', 'view_own')) {
$permission_children_ids[] = $current_user->getId();
}
示例3: Validate
function Validate()
{
Debug::Text('User Date ID: ' . $this->getUserDateID(), __FILE__, __LINE__, __METHOD__, 10);
$this->handleDayBoundary();
$this->findUserDate();
Debug::text('User Date Id: ' . $this->getUserDateID(), __FILE__, __LINE__, __METHOD__, 10);
//Check to make sure EnableOverwrite isn't enabled when editing an existing record.
if ($this->isNew() == FALSE and $this->getEnableOverwrite() == TRUE) {
Debug::Text('Overwrite enabled when editing existing record, disabling overwrite.', __FILE__, __LINE__, __METHOD__, 10);
$this->setEnableOverwrite(FALSE);
}
if ($this->getUserDateObject() == FALSE or !is_object($this->getUserDateObject())) {
Debug::Text('UserDateID is INVALID! ID: ' . $this->getUserDateID(), __FILE__, __LINE__, __METHOD__, 10);
$this->Validator->isTrue('date_stamp', FALSE, TTi18n::gettext('Date/Time is incorrect, or pay period does not exist for this date. Please create a pay period schedule and assign this employee to it if you have not done so already'));
}
if (is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()) and $this->getUserDateObject()->getPayPeriodObject()->getIsLocked() == TRUE) {
$this->Validator->isTrue('date_stamp', FALSE, TTi18n::gettext('Pay Period is Currently Locked'));
}
if ($this->getCompany() == FALSE) {
$this->Validator->isTrue('company_id', FALSE, TTi18n::gettext('Company is invalid'));
}
if ($this->getDeleted() == FALSE and is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getUserObject())) {
if ($this->getUserDateObject()->getUserObject()->getHireDate() != '' and TTDate::getBeginDayEpoch($this->getUserDateObject()->getDateStamp()) < TTDate::getBeginDayEpoch($this->getUserDateObject()->getUserObject()->getHireDate())) {
$this->Validator->isTRUE('date_stamp', FALSE, TTi18n::gettext('Shift is before employees hire date'));
}
if ($this->getUserDateObject()->getUserObject()->getTerminationDate() != '' and TTDate::getEndDayEpoch($this->getUserDateObject()->getDateStamp()) > TTDate::getEndDayEpoch($this->getUserDateObject()->getUserObject()->getTerminationDate())) {
$this->Validator->isTRUE('date_stamp', FALSE, TTi18n::gettext('Shift is after employees termination date'));
}
}
//Ignore conflicting time check when EnableOverwrite is set, as we will just be deleting any conflicting shift anyways.
//Also ignore when setting OPEN shifts to allow for multiple.
if ($this->getEnableOverwrite() == FALSE and $this->getDeleted() == FALSE and (is_object($this->getUserDateObject()) and $this->getUserDateObject()->getUser() > 0)) {
$this->Validator->isTrue('start_time', !$this->isConflicting(), TTi18n::gettext('Conflicting start/end time, schedule already exists for this employee'));
} else {
Debug::text('Not checking for conflicts... UserDateObject: ' . (int) is_object($this->getUserDateObject()), __FILE__, __LINE__, __METHOD__, 10);
}
if ($this->isNew() == TRUE) {
$obj_class = "TTLicense";
$obj_function = "validateLicense";
$obj_error_msg_function = "getFullErrorMessage";
@($obj = new $obj_class());
$retval = $obj->{$obj_function}();
if ($retval !== TRUE) {
$this->Validator->isTrue('lic_obj', FALSE, $obj->{$obj_error_msg_function}($retval));
}
}
return TRUE;
}
示例4: _outputPDFForm
function _outputPDFForm($format = NULL)
{
$show_background = TRUE;
if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government' or $format == 'efile') {
$show_background = FALSE;
}
Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
$setup_data = $this->getFormConfig();
$filter_data = $this->getFilterConfig();
//Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10);
$current_company = $this->getUserObject()->getCompanyObject();
if (!is_object($current_company)) {
Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
$current_user = $this->getUserObject();
if (!is_object($current_user)) {
Debug::Text('Invalid user object...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
if ($format == 'efile_xml') {
$return1040 = $this->getRETURN1040Object();
// Ceate the all needed data for Return1040.xsd at here.
$return1040->return_created_timestamp = TTDate::getDBTimeStamp(TTDate::getTime(), FALSE);
$return1040->year = TTDate::getYear($filter_data['end_date']);
$return1040->tax_period_begin_date = TTDate::getDate('Y-m-d', TTDate::getBeginDayEpoch($filter_data['start_date']));
$return1040->tax_period_end__date = TTDate::getDate('Y-m-d', TTDate::getEndDayEpoch($filter_data['end_date']));
$return1040->software_id = '';
$return1040->originator_efin = '';
$return1040->originator_type_code = '';
$return1040->pin_type_code = '';
$return1040->jurat_disclosure_code = '';
$return1040->pin_entered_by = '';
$return1040->signature_date = TTDate::getDate('Y-m-d', TTDate::getTime());
$return1040->return_type = '';
$return1040->ssn = '';
$return1040->name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
$return1040->name_control = '';
$return1040->address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2();
$return1040->city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
$return1040->state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
$return1040->zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
$return1040->ip_address = '';
$return1040->ip_date = TTDate::getDate('Y-m-d', TTDate::getTime());
$return1040->ip_time = TTDate::getDate('H:i:s', TTDate::getTime());
$return1040->timezone = TTDate::getTimeZone();
$this->getFormObject()->addForm($return1040);
}
$this->sortFormData();
//Make sure forms are sorted.
$fw2 = $this->getFW2Object();
$fw2->setDebug(FALSE);
//if ( $format == 'efile' ) {
// $fw2->setDebug(TRUE);
//}
$fw2->setShowBackground($show_background);
if (stristr($format, 'government')) {
$form_type = 'government';
} else {
$form_type = 'employee';
}
Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10);
$fw2->setType($form_type);
$fw2->year = TTDate::getYear($filter_data['end_date']);
//Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually.
$fw2->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber();
$fw2->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName();
$fw2->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
$fw2->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2();
$fw2->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
$fw2->company_state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
$fw2->company_zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
$fw2->efile_user_id = (isset($setup_data['efile_user_id']) and $setup_data['efile_user_id'] != '') ? $setup_data['efile_user_id'] : NULL;
$fw2->efile_state = (isset($setup_data['efile_state']) and $setup_data['efile_state'] != '') ? $setup_data['efile_state'] : 0;
$fw2->contact_name = $current_user->getFullName();
$fw2->contact_phone = $current_user->getWorkPhone();
$fw2->contact_phone_ext = $current_user->getWorkPhoneExt();
$fw2->contact_email = $current_user->getWorkEmail();
if (isset($this->form_data) and count($this->form_data) > 0) {
$i = 0;
$n = 1;
foreach ((array) $this->form_data as $row) {
if (!isset($row['user_id'])) {
Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10);
continue;
}
$ulf = TTnew('UserListFactory');
$ulf->getById((int) $row['user_id']);
if ($ulf->getRecordCount() == 1) {
$user_obj = $ulf->getCurrent();
$ee_data = array('control_number' => $n, 'first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'state' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'zip_code' => $user_obj->getPostalCode(), 'ssn' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l1' => $row['l1'], 'l2' => $row['l2'], 'l3' => $row['l3'], 'l4' => $row['l4'], 'l5' => $row['l5'], 'l6' => $row['l6'], 'l7' => $row['l7'], 'l8' => $row['l8'], 'l10' => $row['l10'], 'l11' => $row['l11'], 'l12a_code' => NULL, 'l12a' => NULL, 'l12b_code' => NULL, 'l12b' => NULL, 'l12c_code' => NULL, 'l12c' => NULL, 'l12d_code' => NULL, 'l12d' => NULL, 'l14a_name' => NULL, 'l14a' => NULL, 'l14b_name' => NULL, 'l14b' => NULL, 'l14c_name' => NULL, 'l14c' => NULL, 'l14d_name' => NULL, 'l14d' => NULL);
if ($row['l12a'] > 0 and isset($setup_data['l12a_code']) and $setup_data['l12a_code'] != '') {
$ee_data['l12a_code'] = $setup_data['l12a_code'];
$ee_data['l12a'] = $row['l12a'];
}
if ($row['l12b'] > 0 and isset($setup_data['l12b_code']) and $setup_data['l12b_code'] != '') {
$ee_data['l12b_code'] = $setup_data['l12b_code'];
$ee_data['l12b'] = $row['l12b'];
}
if ($row['l12c'] > 0 and isset($setup_data['l12c_code']) and $setup_data['l12c_code'] != '') {
//.........这里部分代码省略.........
示例5: getScheduleDates
/**
* Get all necessary dates for building the schedule in a single call, this is mainly as a performance optimization.
* @param array $data filter data
* @return array
*/
function getScheduleDates($base_date, $type, $strict = TRUE)
{
$epoch = TTDate::parseDateTime($base_date);
if ($epoch == '') {
$epoch = TTDate::getTime();
}
if ($type == '') {
$type = 'week';
}
switch (strtolower($type)) {
case 'day':
if ($strict == TRUE) {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getEndDayEpoch($epoch);
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 86400);
}
break;
case 'week':
if ($strict == TRUE) {
$start_date = TTDate::getBeginWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay());
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 7 * 86400);
}
break;
case 'month':
if ($strict == TRUE) {
$start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch(TTDate::getEndMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 30 * 86400);
}
break;
case 'year':
if ($strict == TRUE) {
$start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch(TTDate::getEndMonthEpoch(TTDate::getEndMonthEpoch($epoch) + 86400 * 2), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 62 * 86400);
}
break;
}
$retarr = array('base_date' => $epoch, 'start_date' => $start_date, 'end_date' => $end_date, 'base_display_date' => TTDate::getAPIDate('DATE', $epoch), 'start_display_date' => TTDate::getAPIDate('DATE', $start_date), 'end_display_date' => TTDate::getAPIDate('DATE', $end_date));
Debug::Arr($retarr, 'Schedule Dates: Base Date: ' . $base_date . ' Type: ' . $type . ' Strict: ' . (int) $strict, __FILE__, __LINE__, __METHOD__, 10);
return $retarr;
}
示例6: _outputPDFForm
function _outputPDFForm($format = NULL)
{
$show_background = TRUE;
if ($format == 'pdf_form_print') {
$show_background = FALSE;
}
Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
$setup_data = $this->getFormConfig();
$filter_data = $this->getFilterConfig();
//Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10);
$current_company = $this->getUserObject()->getCompanyObject();
if (!is_object($current_company)) {
Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
if ($format == 'efile_xml') {
$return940 = $this->getRETURN940Object();
$return940->TaxPeriodEndDate = TTDate::getDate('Y-m-d', TTDate::getEndDayEpoch($filter_data['end_date']));
$return940->ReturnType = '';
$return940->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber();
$return940->BusinessName1 = '';
$return940->BusinessNameControl = '';
$return940->AddressLine = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2();
$return940->City = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
$return940->State = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
$return940->ZIPCode = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
$this->getFormObject()->addForm($return940);
}
$f940 = $this->getF940Object();
$f940->setDebug(FALSE);
$f940->setShowBackground($show_background);
$f940->year = TTDate::getYear($filter_data['end_date']);
//Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually.
$f940->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber();
$f940->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName();
$f940->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
$f940->address = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2();
$f940->city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
$f940->state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
$f940->zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
if (isset($setup_data['return_type']) and is_array($setup_data['return_type'])) {
$return_type_arr = array();
foreach ($setup_data['return_type'] as $return_type) {
switch ($return_type) {
case 10:
//Amended
$return_type_arr[] = 'a';
break;
case 20:
//Successor
$return_type_arr[] = 'b';
break;
case 30:
//No Payments
$return_type_arr[] = 'c';
break;
case 40:
//Final
$return_type_arr[] = 'd';
break;
}
}
$f940->return_type = $return_type_arr;
}
if (isset($setup_data['state_id'])) {
if ($setup_data['state_id'] === 0 or $setup_data['state_id'] == '00' or $setup_data['state_id'] == '') {
$f940->l1b = TRUE;
//Let them set this manually.
} else {
if (strlen($setup_data['state_id']) == 2) {
$f940->l1a = $setup_data['state_id'];
}
}
}
//Exempt payment check boxes
if (isset($setup_data['exempt_payment']) and is_array($setup_data['exempt_payment'])) {
foreach ($setup_data['exempt_payment'] as $return_type) {
switch ($return_type) {
case 10:
//Fringe
$f940->l4a = TRUE;
break;
case 20:
//Group life insurance
$f940->l4b = TRUE;
break;
case 30:
//Retirement/Pension
$f940->l4c = TRUE;
break;
case 40:
//Dependant care
$f940->l4d = TRUE;
break;
case 50:
//Other
$f940->l4e = TRUE;
break;
}
}
//.........这里部分代码省略.........
示例7: createPayStubAmendments
//.........这里部分代码省略.........
if ($this->getType() == 10) {
$psaf->setRate($this->getRate());
$psaf->setUnits($this->getUnits());
$psaf->setAmount($this->getAmount());
} else {
$psaf->setPercentAmount($this->getPercentAmount());
$psaf->setPercentAmountEntryNameID($this->getPercentAmountEntryNameId());
}
$psaf->setDescription($this->getPayStubAmendmentDescription());
$psaf->setEffectiveDate(TTDate::getBeginDayEpoch($pay_period_obj->getEndDate()));
if ($psaf->isValid()) {
$psaf->Save();
}
} else {
//Amendment already inserted!
Debug::text('Recurring PS Amendment already inserted for User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::text('Skipping User because they are INACTIVE or are not on the Recurring PS Amendment User List - ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//continue;
}
}
} else {
Debug::text('Not in TimeFrame, not inserting amendments: Epoch: ' . $epoch . ' Pay Period End Date: ' . $pay_period_obj->getEndDate(), __FILE__, __LINE__, __METHOD__, 10);
}
}
break;
case 30:
//Weekly
//Weekly
case 40:
//Monthly
//Monthly
case 70:
//Annually
switch ($this->getFrequency()) {
case 30:
$trigger_date = TTDate::getDateOfNextDayOfWeek(TTDate::getBeginWeekEpoch($epoch), $this->getStartDate());
$start_date = TTDate::getBeginWeekEpoch($epoch);
$end_date = TTDate::getEndWeekEpoch($epoch);
break;
case 40:
$trigger_date = TTDate::getDateOfNextDayOfMonth(TTDate::getBeginMonthEpoch($epoch), $this->getStartDate());
//$monthly_date = TTDate::getDateOfNextDayOfMonth( TTDate::getBeginMonthEpoch($epoch), $this->getStartDate() );
$start_date = TTDate::getBeginMonthEpoch($epoch);
$end_date = TTDate::getEndMonthEpoch($epoch);
break;
case 70:
$trigger_date = TTDate::getDateOfNextYear($this->getStartDate(), $epoch);
//$start_date = TTDate::getBeginYearEpoch($epoch);
//$end_date = TTDate::getEndYearEpoch($epoch);
$start_date = TTDate::getBeginDayEpoch($epoch - 86400 * 365);
$end_date = TTDate::getEndDayEpoch($epoch);
break;
}
Debug::text('Trigger Date: ' . TTDate::getDate('DATE', $trigger_date), __FILE__, __LINE__, __METHOD__, 10);
if ($epoch >= $trigger_date and $this->checkTimeFrame($epoch)) {
Debug::text('Within timeframe... Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
foreach ($user_ids as $user_id) {
//Make sure schedule user is in the PS amendment user list and user is active.
if ($ulf->getById($user_id)->getCurrent()->getStatus() != 10 and !in_array($user_id, $user_ids)) {
Debug::text('Skipping User because they are INACTIVE or are not on the Recurring PS Amendment User List - ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
continue;
}
$psalf = TTnew('PayStubAmendmentListFactory');
if ($psalf->getByUserIdAndRecurringPayStubAmendmentIdAndStartDateAndEndDate($user_id, $this->getId(), $start_date, $end_date)->getRecordCount() == 0) {
//No amendment, good to insert one
Debug::text('Inserting Recurring PS Amendment for User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
$psaf = TTnew('PayStubAmendmentFactory');
$psaf->setUser($user_id);
$psaf->setStatus(50);
$psaf->setType($this->getType());
$psaf->setRecurringPayStubAmendmentId($this->getId());
$psaf->setPayStubEntryNameId($this->getPayStubEntryNameId());
if ($this->getType() == 10) {
$psaf->setRate($this->getRate());
$psaf->setUnits($this->getUnits());
$psaf->setAmount($this->getAmount());
} else {
$psaf->setPercentAmount($this->getPercentAmount());
$psaf->setPercentAmountEntryNameID($this->getPercentAmountEntryNameId());
}
$psaf->setDescription($this->getDescription());
$psaf->setEffectiveDate(TTDate::getBeginDayEpoch($trigger_date));
if ($psaf->isValid()) {
$psaf->Save();
}
} else {
//Amendment already inserted!
Debug::text('Recurring PS Amendment already inserted for User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
}
}
}
break;
}
}
//$this->FailTransaction();
$this->CommitTransaction();
return TRUE;
}
示例8: Validate
function Validate()
{
Debug::text('Validating...', __FILE__, __LINE__, __METHOD__, 10);
//Call this here so getShiftData can get the correct total time, before we call findUserDate.
if ($this->getEnableCalcTotalTime() == TRUE) {
$this->calcTotalTime();
}
if (is_object($this->getPunchObject())) {
$this->findUserDate();
}
Debug::text('User Date Id: ' . $this->getUserDateID(), __FILE__, __LINE__, __METHOD__, 10);
//Don't check for a valid pay period here, do that in PunchFactory->Validate(), as we need to allow users to delete punches that were created outside pay periods in legacy versions.
if ($this->getDeleted() == FALSE and $this->getUserDateObject() == FALSE) {
$this->Validator->isTRUE('date_stamp', FALSE, TTi18n::gettext('Date/Time is incorrect, or pay period does not exist for this date. Please create a pay period schedule and assign this employee to it if you have not done so already'));
} elseif (is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()) and $this->getUserDateObject()->getPayPeriodObject()->getIsLocked() == TRUE) {
$this->Validator->isTRUE('date_stamp', FALSE, TTi18n::gettext('Pay Period is Currently Locked'));
}
//Make sure the user isn't entering punches before the employees hire or after termination date, as its likely they wouldn't have a wage
//set for that anyways and wouldn't get paid for it.
if ($this->getDeleted() == FALSE and (is_object($this->getPunchObject()) and $this->getPunchObject()->getDeleted() == FALSE) and is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getUserObject())) {
if ($this->getUserDateObject()->getUserObject()->getHireDate() != '' and TTDate::getBeginDayEpoch($this->getUserDateObject()->getDateStamp()) < TTDate::getBeginDayEpoch($this->getUserDateObject()->getUserObject()->getHireDate())) {
$this->Validator->isTRUE('date_stamp', FALSE, TTi18n::gettext('Punch is before employees hire date'));
}
if ($this->getUserDateObject()->getUserObject()->getTerminationDate() != '' and TTDate::getEndDayEpoch($this->getUserDateObject()->getDateStamp()) > TTDate::getEndDayEpoch($this->getUserDateObject()->getUserObject()->getTerminationDate())) {
$this->Validator->isTRUE('date_stamp', FALSE, TTi18n::gettext('Punch is after employees termination date'));
}
}
//Skip these checks if they are deleting a punch.
if (is_object($this->getPunchObject()) and $this->getPunchObject()->getDeleted() == FALSE) {
$plf = $this->getPLFByPunchControlID();
if ($plf !== NULL and ($this->isNew() and $plf->getRecordCount() == 2 or $plf->getRecordCount() > 2)) {
//TTi18n::gettext('Punch Control can not have more than two punches. Please use the Add Punch button instead')
//They might be trying to insert a punch inbetween two others?
$this->Validator->isTRUE('punch_control', FALSE, TTi18n::gettext('Time conflicts with another punch on this day (c)'));
}
//Sometimes shift data won't return all the punches to proper check for conflicting punches.
//So we need to make sure other punches assigned to this punch_control record are proper.
//This fixes the bug of having shifts: 2:00AM Lunch Out, 2:30AM Lunch In, 6:00AM Out, 10:00PM In (in that order), then trying to move the 10PM punch to the open IN slot before the 2AM punch.
if ($plf->getRecordCount() > 0) {
foreach ($plf as $p_obj) {
if ($p_obj->getID() != $this->getPunchObject()->getID()) {
if ($this->getPunchObject()->getStatus() == 10 and $p_obj->getStatus() == 10 and $this->getPunchObject()->getTimeStamp() > $p_obj->getTimeStamp()) {
//Make sure we match on status==10 for both sides, otherwise this fails to catch the problem case.
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('In punches cannot occur after an out punch, in the same punch pair (a)'));
} elseif ($this->getPunchObject()->getStatus() == 20 and $p_obj->getStatus() == 10 and $this->getPunchObject()->getTimeStamp() < $p_obj->getTimeStamp()) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Out punches cannot occur before an in punch, in the same punch pair (a)'));
}
}
}
}
unset($p_obj);
if ($this->Validator->isValid() == TRUE) {
//Don't bother checking these resource intensive issues if there are already validation errors.
$shift_data = $this->getShiftData();
if (is_array($shift_data) and $this->Validator->hasError('time_stamp') == FALSE) {
foreach ($shift_data['punches'] as $punch_data) {
//Make sure there aren't two In punches, or two Out punches in the same pair.
//This fixes the bug where if you have an In punch, then click the blank cell below it
//to add a new punch, but change the status from Out to In instead.
if (isset($punches[$punch_data['punch_control_id']][$punch_data['status_id']])) {
if ($punch_data['status_id'] == 10) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('In punches cannot occur twice in the same punch pair, you may want to make this an out punch instead'));
} else {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Out punches cannot occur twice in the same punch pair, you may want to make this an in punch instead'));
}
}
//Debug::text(' Current Punch Object: ID: '. $this->getPunchObject()->getId() .' TimeStamp: '. $this->getPunchObject()->getTimeStamp() .' Status: '. $this->getPunchObject()->getStatus(), __FILE__, __LINE__, __METHOD__,10);
//Debug::text(' Looping Punch Object: ID: '. $punch_data['id'] .' TimeStamp: '. $punch_data['time_stamp'] .' Status: '.$punch_data['status_id'], __FILE__, __LINE__, __METHOD__,10);
//Check for another punch that matches the timestamp and status.
if ($this->getPunchObject()->getID() != $punch_data['id']) {
if ($this->getPunchObject()->getTimeStamp() == $punch_data['time_stamp'] and $this->getPunchObject()->getStatus() == $punch_data['status_id']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time and status match that of another punch, this could be due to rounding') . ' (' . TTDate::getDate('DATE+TIME', $punch_data['time_stamp']) . ')');
break;
//Break the loop on validation error, so we don't get multiple errors that may be confusing.
}
}
//Check for another punch that matches the timestamp and NOT status in the SAME punch pair.
if ($this->getPunchObject()->getID() != $punch_data['id'] and $this->getID() == $punch_data['punch_control_id']) {
if ($this->getPunchObject()->getTimeStamp() == $punch_data['time_stamp'] and $this->getPunchObject()->getStatus() != $punch_data['status_id']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time matches another punch in the same punch pair, this could be due to rounding') . ' (' . TTDate::getDate('DATE+TIME', $punch_data['time_stamp']) . ')');
break;
//Break the loop on validation error, so we don't get multiple errors that may be confusing.
}
}
$punches[$punch_data['punch_control_id']][$punch_data['status_id']] = $punch_data;
}
unset($punch_data);
if (isset($punches[$this->getID()])) {
Debug::text('Current Punch ID: ' . $this->getPunchObject()->getId() . ' Punch Control ID: ' . $this->getID() . ' Status: ' . $this->getPunchObject()->getStatus(), __FILE__, __LINE__, __METHOD__, 10);
//Debug::Arr($punches, 'Punches Arr: ', __FILE__, __LINE__, __METHOD__,10);
if ($this->getPunchObject()->getStatus() == 10 and isset($punches[$this->getID()][20]) and $this->getPunchObject()->getTimeStamp() > $punches[$this->getID()][20]['time_stamp']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('In punches cannot occur after an out punch, in the same punch pair'));
} elseif ($this->getPunchObject()->getStatus() == 20 and isset($punches[$this->getID()][10]) and $this->getPunchObject()->getTimeStamp() < $punches[$this->getID()][10]['time_stamp']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Out punches cannot occur before an in punch, in the same punch pair'));
} else {
Debug::text('bPunch does not match any other punch pair.', __FILE__, __LINE__, __METHOD__, 10);
$punch_neighbors = Misc::getArrayNeighbors($punches, $this->getID(), 'both');
//Debug::Arr($punch_neighbors, ' Punch Neighbors: ', __FILE__, __LINE__, __METHOD__,10);
if (isset($punch_neighbors['next']) and isset($punches[$punch_neighbors['next']])) {
Debug::text('Found Next Punch...', __FILE__, __LINE__, __METHOD__, 10);
//.........这里部分代码省略.........
示例9: _outputPDFForm
function _outputPDFForm($format = NULL)
{
$show_background = TRUE;
if ($format == 'pdf_form_print') {
$show_background = FALSE;
}
Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
$setup_data = $this->getFormConfig();
$filter_data = $this->getFilterConfig();
//Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10);
$current_company = $this->getUserObject()->getCompanyObject();
if (!is_object($current_company)) {
Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
if ($format == 'efile_xml') {
$return941 = $this->getRETURN941Object();
$return941->TaxPeriodEndDate = TTDate::getDate('Y-m-d', TTDate::getEndDayEpoch($filter_data['end_date']));
$return941->ReturnType = '';
$return941->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber();
$return941->BusinessName1 = '';
$return941->BusinessNameControl = '';
$return941->AddressLine = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2();
$return941->City = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
$return941->State = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
$return941->ZIPCode = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
$this->getFormObject()->addForm($return941);
}
$f941 = $this->getF941Object();
$f941->setDebug(FALSE);
$f941->setShowBackground($show_background);
$f941->year = TTDate::getYear($filter_data['end_date']);
//Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually.
$f941->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber();
$f941->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName();
$f941->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
$f941->address = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2();
$f941->city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
$f941->state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
$f941->zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
$f941->quarter = TTDate::getYearQuarter($filter_data['end_date']);
//Debug::Arr($this->form_data, 'Final Data for Form: ', __FILE__, __LINE__, __METHOD__,10);
if (isset($this->form_data) and count($this->form_data) == 3) {
$f941->l1 = count($this->user_ids);
$f941->l2 = $this->form_data['total']['l2'];
$f941->l3 = $this->form_data['total']['l3'];
$f941->l5a = $this->form_data['total']['l5a'];
$f941->l5b = $this->form_data['total']['l5b'];
$f941->l5c = $this->form_data['total']['l5c'];
$f941->l5d = $this->form_data['total']['l5d'];
if (isset($setup_data['quarter_deposit']) and $setup_data['quarter_deposit'] != '') {
$f941->l11 = Misc::MoneyFormat($setup_data['quarter_deposit'], FALSE);
}
//Debug::Text('L11: '. $f941->l11 .' L6: '. $f941->calcL6() .' - '. $this->form_data['total']['l10'] , __FILE__, __LINE__, __METHOD__,10);
$f941->l15b = TRUE;
if (isset($setup_data['deposit_schedule']) and $setup_data['deposit_schedule'] == 10) {
if (isset($this->form_data['quarter'][1]['l10'])) {
$f941->l16_month1 = $this->form_data['quarter'][1]['l10'];
}
if (isset($this->form_data['quarter'][2]['l10'])) {
$f941->l16_month2 = $this->form_data['quarter'][2]['l10'];
}
if (isset($this->form_data['quarter'][3]['l10'])) {
$f941->l16_month3 = $this->form_data['quarter'][3]['l10'];
}
} elseif (isset($setup_data['deposit_schedule']) and $setup_data['deposit_schedule'] == 20) {
$f941sb = $this->getFormObject()->getFormObject('941sb', 'US');
$f941sb->setShowBackground($show_background);
$f941sb->year = $f941->year;
$f941sb->ein = $f941->ein;
$f941sb->name = $f941->name;
$f941sb->quarter = $f941->quarter;
for ($i = 1; $i <= 3; $i++) {
if (isset($this->form_data['pay_period'][$i])) {
foreach ($this->form_data['pay_period'][$i] as $pay_period_epoch => $data) {
//Debug::Text('SB: Month: '. $i .' Pay Period Date: '. TTDate::getDate('DATE', $pay_period_epoch) .' DOM: '. TTDate::getDayOfMonth($pay_period_epoch) .' Amount: '. $data['l10'], __FILE__, __LINE__, __METHOD__,10);
$f941sb_data[$i][TTDate::getDayOfMonth($pay_period_epoch)] = $data['l10'];
//Don't round this as it can cause mismatches in the totals.
}
}
}
if (isset($f941sb_data[1])) {
$f941sb->month1 = $f941sb_data[1];
}
if (isset($f941sb_data[2])) {
$f941sb->month2 = $f941sb_data[2];
}
if (isset($f941sb_data[3])) {
$f941sb->month3 = $f941sb_data[3];
}
unset($i, $d, $f941sb_data);
}
} else {
Debug::Arr($this->data, 'Invalid Form Data: ', __FILE__, __LINE__, __METHOD__, 10);
}
$this->getFormObject()->addForm($f941);
if (isset($f941sb) and is_object($f941sb)) {
$this->getFormObject()->addForm($f941sb);
}
if ($format == 'efile_xml') {
//.........这里部分代码省略.........
示例10: convertTimePeriodToStartEndDate
function convertTimePeriodToStartEndDate($time_period_arr, $prefix = NULL)
{
Debug::Arr($time_period_arr, 'Input: Time Period Array: ', __FILE__, __LINE__, __METHOD__, 10);
//Convert time_period into start/end date, with pay_period_schedule_ids if necessary.
if (isset($time_period_arr['time_period']) and ($time_period_arr['time_period'] == 'custom_date' or $time_period_arr['time_period'] == 'custom_time')) {
Debug::Text('Found Custom dates...', __FILE__, __LINE__, __METHOD__, 10);
$retarr[$prefix . 'time_period']['time_period'] = $time_period_arr['time_period'];
if (isset($time_period_arr['start_date'])) {
$retarr[$prefix . 'start_date'] = TTDate::getBeginDayEpoch(TTDate::parseDateTime($time_period_arr['start_date']));
}
if (isset($time_period_arr['end_date'])) {
$retarr[$prefix . 'end_date'] = TTDate::getEndDayEpoch(TTDate::parseDateTime($time_period_arr['end_date']));
}
} elseif (isset($time_period_arr['time_period'])) {
$params = array();
if (isset($time_period_arr['pay_period_schedule_id'])) {
$params = array('pay_period_schedule_id' => $time_period_arr['pay_period_schedule_id']);
//Make sure we keep the original array intact so we if this function is run more than once it will work each time.
$retarr[$prefix . 'time_period']['pay_period_schedule_id'] = $time_period_arr['pay_period_schedule_id'];
} elseif (isset($time_period_arr['pay_period_id'])) {
$params = array('pay_period_id' => $time_period_arr['pay_period_id']);
//Make sure we keep the original array intact so we if this function is run more than once it will work each time.
$retarr[$prefix . 'time_period']['pay_period_id'] = $time_period_arr['pay_period_id'];
}
if (!isset($time_period_arr['time_period'])) {
Debug::Text('ERROR: Time Period idenfier not specified!', __FILE__, __LINE__, __METHOD__, 10);
$retarr[$prefix . 'time_period'] = NULL;
} else {
$retarr[$prefix . 'time_period']['time_period'] = $time_period_arr['time_period'];
}
//Debug::Arr($params, 'Time Period: '.$time_period_arr['time_period'] .' Params: ', __FILE__, __LINE__, __METHOD__,10);
$time_period_dates = TTDate::getTimePeriodDates($time_period_arr['time_period'], NULL, $this->getUserObject(), $params);
if ($time_period_dates != FALSE) {
if (isset($time_period_dates['start_date'])) {
$retarr[$prefix . 'start_date'] = $time_period_dates['start_date'];
}
if (isset($time_period_dates['end_date'])) {
$retarr[$prefix . 'end_date'] = $time_period_dates['end_date'];
}
if (isset($time_period_dates['pay_period_id'])) {
$retarr[$prefix . 'pay_period_id'] = $time_period_dates['pay_period_id'];
}
} else {
//No pay period find default to no time period, otherwise the report can take forever to finish.
Debug::Text('No pay periods found, defaulting to none (0)...', __FILE__, __LINE__, __METHOD__, 10);
$retarr[$prefix . 'pay_period_id'] = 0;
//This can actually find data not assigned to a pay period.
}
} else {
Debug::Text('Invalid TimePeriod filter...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
Debug::Arr($retarr, 'Output: Time Period Array: ', __FILE__, __LINE__, __METHOD__, 10);
return $retarr;
}
示例11: getPartialPunchTotalTime
function getPartialPunchTotalTime($in_epoch, $out_epoch, $total_time, $user_id)
{
$retval = $total_time;
if ($this->isActiveTime($in_epoch, $out_epoch, $user_id) and $this->getIncludePartialPunch() == TRUE and ($this->getStartTime() > 0 or $this->getEndTime() > 0)) {
Debug::text(' Checking for Active Time with: In: ' . TTDate::getDate('DATE+TIME', $in_epoch) . ' Out: ' . TTDate::getDate('DATE+TIME', $out_epoch), __FILE__, __LINE__, __METHOD__, 10);
Debug::text(' Raw Start TimeStamp(' . $this->getStartTime(TRUE) . '): ' . TTDate::getDate('DATE+TIME', $this->getStartTime()) . ' Raw End TimeStamp(' . $this->getEndTime(TRUE) . '): ' . TTDate::getDate('DATE+TIME', $this->getEndTime()), __FILE__, __LINE__, __METHOD__, 10);
$start_time_stamp = TTDate::getTimeLockedDate($this->getStartTime(), $in_epoch);
$end_time_stamp = TTDate::getTimeLockedDate($this->getEndTime(), $in_epoch);
//Check if end timestamp is before start, if it is, move end timestamp to next day.
if ($end_time_stamp < $start_time_stamp) {
Debug::text(' Moving End TimeStamp to next day.', __FILE__, __LINE__, __METHOD__, 10);
$end_time_stamp = TTDate::getTimeLockedDate($this->getEndTime(), $end_time_stamp + 86400);
}
//Handle the last second of the day, so punches that span midnight like 11:00PM to 6:00AM get a full 1 hour for the time before midnight, rather than 59mins and 59secs.
if (TTDate::getHour($end_time_stamp) == 23 and TTDate::getMinute($end_time_stamp) == 59) {
$end_time_stamp = TTDate::getEndDayEpoch($end_time_stamp) + 1;
Debug::text(' End time stamp is within the last minute of day, make sure we include the last second of the day as well.', __FILE__, __LINE__, __METHOD__, 10);
}
$retval = 0;
for ($i = $start_time_stamp - 86400; $i <= $end_time_stamp + 86400; $i += 86400) {
//Due to DST, we need to make sure we always lock time of day so its the exact same. Without this it can walk by one hour either way.
$tmp_start_time_stamp = TTDate::getTimeLockedDate($this->getStartTime(), $i);
$tmp_end_time_stamp = TTDate::getTimeLockedDate($end_time_stamp, $tmp_start_time_stamp + ($end_time_stamp - $start_time_stamp));
//Use $end_time_stamp as it can be modified above due to being near midnight
if ($this->isActiveTime($tmp_start_time_stamp, $tmp_end_time_stamp, $user_id) == TRUE) {
$retval += TTDate::getTimeOverLapDifference($tmp_start_time_stamp, $tmp_end_time_stamp, $in_epoch, $out_epoch);
Debug::text(' Calculating partial time against Start TimeStamp: ' . TTDate::getDate('DATE+TIME', $tmp_start_time_stamp) . ' End TimeStamp: ' . TTDate::getDate('DATE+TIME', $tmp_end_time_stamp) . ' Total: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text(' Not Active on this day: ' . TTDate::getDate('DATE+TIME', $i), __FILE__, __LINE__, __METHOD__, 10);
}
}
}
Debug::text(' Partial Punch Total Time: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
return $retval;
}
示例12: calculate
function calculate($epoch = NULL)
{
if ($this->getUserObject() == FALSE) {
return FALSE;
}
if ($this->getPayPeriodObject() == FALSE) {
return FALSE;
}
if ($epoch == NULL or $epoch == '') {
$epoch = TTDate::getTime();
}
//Use User Termination Date instead of ROE.
if ($this->getUserObject()->getTerminationDate() != '' and $this->getUserObject()->getTerminationDate() >= $this->getPayPeriodObject()->getStartDate() and $this->getUserObject()->getTerminationDate() <= $this->getPayPeriodObject()->getEndDate()) {
Debug::text('User has been terminated in this pay period!', __FILE__, __LINE__, __METHOD__, 10);
$is_terminated = TRUE;
} else {
$is_terminated = FALSE;
}
//Allow generating pay stubs for employees who have any status, but if its not ID=10
//Then the termination date must fall within the start/end date of the pay period, or after the end date (if its the current pay period)
//The idea here is to allow employees to be marked terminated (or on leave) and still get their previous or final pay stub generated.
//Also allow pay stubs to be generated in pay periods *before* their termination date.
if ($this->getUserObject()->getStatus() != 10 and ($is_terminated == FALSE and ($this->getUserObject()->getTerminationDate() == '' or $this->getUserObject()->getTerminationDate() < $this->getPayPeriodObject()->getStartDate()))) {
Debug::text('Pay Period is after users termination date (' . $this->getUserObject()->getTerminationDate() . '), or no termination date is set...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
Debug::text('User Id: ' . $this->getUser() . ' Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $this->getPayPeriodObject()->getEndDate()), __FILE__, __LINE__, __METHOD__, 10);
$generic_queue_status_label = $this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Pay Stub');
$pay_stub = TTnew('PayStubFactory');
$pay_stub->StartTransaction();
$old_pay_stub_id = NULL;
if ($this->getEnableCorrection() == TRUE) {
Debug::text('Correction Enabled!', __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setTemp(TRUE);
//Check for current pay stub ID so we can compare against it.
$pslf = TTnew('PayStubListFactory');
$pslf->getByUserIdAndPayPeriodId($this->getUser(), $this->getPayPeriod());
if ($pslf->getRecordCount() > 0) {
$old_pay_stub_id = $pslf->getCurrent()->getId();
Debug::text('Comparing Against Pay Stub ID: ' . $old_pay_stub_id, __FILE__, __LINE__, __METHOD__, 10);
}
}
$pay_stub->setUser($this->getUser());
$pay_stub->setPayPeriod($this->getPayPeriod());
$pay_stub->setCurrency($this->getUserObject()->getCurrency());
$pay_stub->setStatus(10);
//New
if ($is_terminated == TRUE) {
Debug::text('User is Terminated, assuming final pay, setting End Date to terminated date: ' . TTDate::getDate('DATE+TIME', $this->getUserObject()->getTerminationDate()), __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setStartDate($pay_stub->getPayPeriodObject()->getStartDate());
$pay_stub->setEndDate($this->getUserObject()->getTerminationDate());
//Use the PS generation date instead of terminated date...
//Unlikely they would pay someone before the pay stub is generated.
//Perhaps still use the pay period transaction date for this too?
//Anything we set won't be correct for everyone. Maybe a later date is better though?
//Perhaps add to the user factory under Termination Date a: "Final Transaction Date" for this purpose?
//Use the end of the current date for the transaction date, as if the employee is terminated
//on the same day they are generating the pay stub, the transaction date could be before the end date
//as the end date is at 11:59PM
//For now make sure that the transaction date for a terminated employee is never before their termination date.
if (TTDate::getEndDayEpoch(TTDate::getTime()) < $this->getUserObject()->getTerminationDate()) {
$pay_stub->setTransactionDate($this->getUserObject()->getTerminationDate());
} else {
$pay_stub->setTransactionDate(TTDate::getEndDayEpoch(TTDate::getTime()));
}
} else {
Debug::text('User Termination Date is NOT set, assuming normal pay.', __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setDefaultDates();
}
//This must go after setting advance
if ($this->getEnableCorrection() == FALSE and $pay_stub->IsUniquePayStub() == FALSE) {
Debug::text('Pay Stub already exists', __FILE__, __LINE__, __METHOD__, 10);
$this->CommitTransaction();
UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 20, TTi18n::gettext('Pay Stub for this employee already exists, skipping...'), NULL);
return FALSE;
}
if ($pay_stub->isValid() == TRUE) {
$pay_stub->Save(FALSE);
$pay_stub->setStatus(25);
//Open
} else {
Debug::text('Pay Stub isValid failed!', __FILE__, __LINE__, __METHOD__, 10);
UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 10, $pay_stub->Validator->getTextErrors(), NULL);
$this->FailTransaction();
$this->CommitTransaction();
return FALSE;
}
$pay_stub->loadPreviousPayStub();
$user_date_total_arr = $this->getWageObject()->getUserDateTotalArray();
if (isset($user_date_total_arr['entries']) and is_array($user_date_total_arr['entries'])) {
foreach ($user_date_total_arr['entries'] as $udt_arr) {
//Allow negative amounts so flat rate premium policies can reduce an employees wage if need be.
if ($udt_arr['amount'] != 0) {
Debug::text('Adding Pay Stub Entry: ' . $udt_arr['pay_stub_entry'] . ' Amount: ' . $udt_arr['amount'], __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->addEntry($udt_arr['pay_stub_entry'], $udt_arr['amount'], TTDate::getHours($udt_arr['total_time']), $udt_arr['rate']);
} else {
Debug::text('NOT Adding ($0 amount) Pay Stub Entry: ' . $udt_arr['pay_stub_entry'] . ' Amount: ' . $udt_arr['amount'], __FILE__, __LINE__, __METHOD__, 10);
}
}
} else {
//.........这里部分代码省略.........
示例13: testRoundingD
function testRoundingD()
{
global $dd;
$this->createPayPeriodSchedule(10);
$this->createPayPeriods();
$this->getAllPayPeriods();
$policy_ids['round'][] = $dd->createRoundingPolicy($this->company_id, 30);
//Day Total
$policy_ids['round'][] = $dd->createRoundingPolicy($this->company_id, 40);
//Lunch Total
$policy_ids['round'][] = $dd->createRoundingPolicy($this->company_id, 50);
//Break Total
//Create Policy Group
$dd->createPolicyGroup($this->company_id, NULL, NULL, NULL, NULL, NULL, $policy_ids['round'], array($this->user_id));
$date_epoch = TTDate::getBeginWeekEpoch(time());
$date_stamp = TTDate::getDate('DATE', $date_epoch);
$dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 8:03AM'), NULL, array('in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
$dd->createPunchPair($this->user_id, NULL, strtotime($date_stamp . ' 12:06PM'), array('in_type_id' => 10, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
$dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 1:12PM'), NULL, array('in_type_id' => 30, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
$dd->createPunchPair($this->user_id, NULL, strtotime($date_stamp . ' 5:07PM'), array('in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
$punch_arr = $this->getPunchDataArray(TTDate::getBeginDayEpoch($date_epoch), TTDate::getEndDayEpoch($date_epoch));
//print_r($punch_arr);
$this->assertEquals(2, count($punch_arr[$date_epoch]));
$this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][0]['time_stamp'], strtotime($date_stamp . ' 8:03AM'));
$this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][1]['time_stamp'], strtotime($date_stamp . ' 12:06PM'));
$this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][2]['time_stamp'], strtotime($date_stamp . ' 1:06PM'));
$this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][3]['time_stamp'], strtotime($date_stamp . ' 5:03PM'));
$udt_arr = $this->getUserDateTotalArray($date_epoch, $date_epoch);
//Total Time
$this->assertEquals(10, $udt_arr[$date_epoch][0]['status_id']);
$this->assertEquals(10, $udt_arr[$date_epoch][0]['type_id']);
$this->assertEquals(8 * 3600, $udt_arr[$date_epoch][0]['total_time']);
return TRUE;
}
示例14: getHolidayUserDateIDs
function getHolidayUserDateIDs()
{
Debug::text('reCalculating Holiday...', __FILE__, __LINE__, __METHOD__, 10);
//Get Holiday policies and determine how many days we need to look ahead/behind in order
//to recalculate the holiday eligilibility/time.
$holiday_before_days = 0;
$holiday_after_days = 0;
$hplf = new HolidayPolicyListFactory();
$hplf->getByCompanyId($this->getUserDateObject()->getUserObject()->getCompany());
if ($hplf->getRecordCount() > 0) {
foreach ($hplf as $hp_obj) {
if ($hp_obj->getMinimumWorkedPeriodDays() > $holiday_before_days) {
$holiday_before_days = $hp_obj->getMinimumWorkedPeriodDays();
}
if ($hp_obj->getAverageTimeDays() > $holiday_before_days) {
$holiday_before_days = $hp_obj->getAverageTimeDays();
}
if ($hp_obj->getMinimumWorkedAfterPeriodDays() > $holiday_after_days) {
$holiday_after_days = $hp_obj->getMinimumWorkedAfterPeriodDays();
}
}
}
Debug::text('Holiday Before Days: ' . $holiday_before_days . ' Holiday After Days: ' . $holiday_after_days, __FILE__, __LINE__, __METHOD__, 10);
if ($holiday_before_days > 0 or $holiday_after_days > 0) {
$retarr = array();
$search_start_date = TTDate::getBeginWeekEpoch($this->getUserDateObject()->getDateStamp() - $holiday_after_days * 86400);
$search_end_date = TTDate::getEndWeekEpoch(TTDate::getEndDayEpoch($this->getUserDateObject()->getDateStamp()) + $holiday_before_days * 86400 + 3601);
Debug::text('Holiday search start date: ' . TTDate::getDate('DATE', $search_start_date) . ' End date: ' . TTDate::getDate('DATE', $search_end_date) . ' Current Date: ' . TTDate::getDate('DATE', $this->getUserDateObject()->getDateStamp()), __FILE__, __LINE__, __METHOD__, 10);
$hlf = new HolidayListFactory();
//$hlf->getByPolicyGroupUserIdAndStartDateAndEndDate( $this->getUserDateObject()->getUser(), TTDate::getEndWeekEpoch( $this->getUserDateObject()->getDateStamp() )+86400, TTDate::getEndDayEpoch()+($max_average_time_days*86400)+3601 );
$hlf->getByPolicyGroupUserIdAndStartDateAndEndDate($this->getUserDateObject()->getUser(), $search_start_date, $search_end_date);
if ($hlf->getRecordCount() > 0) {
Debug::text('Found Holidays within range: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
$udlf = new UserDateListFactory();
foreach ($hlf as $h_obj) {
Debug::text('ReCalculating Day due to Holiday: ' . TTDate::getDate('DATE', $h_obj->getDateStamp()), __FILE__, __LINE__, __METHOD__, 10);
$user_date_ids = $udlf->getArrayByListFactory($udlf->getByUserIdAndDate($this->getUserDateObject()->getUser(), $h_obj->getDateStamp()));
if (is_array($user_date_ids)) {
$retarr = array_merge($retarr, $user_date_ids);
}
unset($user_date_ids);
}
}
}
if (isset($retarr) and is_array($retarr) and count($retarr) > 0) {
//Debug::Arr($retarr, 'Holiday UserDateIDs: ', __FILE__, __LINE__, __METHOD__, 10);
return $retarr;
}
Debug::text('No Holidays within range...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
示例15: getScheduleArray
function getScheduleArray($filter_data)
{
global $current_user, $current_user_prefs;
//Get all schedule data by general filter criteria.
Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__, 10);
if (!isset($filter_data['start_date']) or $filter_data['start_date'] == '') {
return FALSE;
}
if (!isset($filter_data['end_date']) or $filter_data['end_date'] == '') {
return FALSE;
}
$filter_data['start_date'] = TTDate::getBeginDayEpoch($filter_data['start_date']);
$filter_data['end_date'] = TTDate::getEndDayEpoch($filter_data['end_date']);
$blf = new BranchListFactory();
$branch_options = $blf->getByCompanyIdArray($current_user->getCompany(), FALSE);
$dlf = new DepartmentListFactory();
$department_options = $dlf->getByCompanyIdArray($current_user->getCompany(), FALSE);
$slf = new ScheduleListFactory();
$slf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data);
Debug::text('Found Scheduled Rows: ' . $slf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
if ($slf->getRecordCount() > 0) {
foreach ($slf as $s_obj) {
Debug::text('Schedule ID: ' . $s_obj->getId() . ' User ID: ' . $s_obj->getColumn('user_id') . ' Start Time: ' . $s_obj->getStartTime(), __FILE__, __LINE__, __METHOD__, 10);
if (is_object($s_obj->getAbsencePolicyObject())) {
$absence_policy_name = (string) $s_obj->getAbsencePolicyObject()->getName();
} else {
$absence_policy_name = 'N/A';
}
$iso_date_stamp = TTDate::getISODateStamp($s_obj->getStartTime());
$schedule_shifts[$iso_date_stamp][$s_obj->getColumn('user_id') . $s_obj->getStartTime()] = array('id' => (int) $s_obj->getID(), 'user_id' => (int) $s_obj->getColumn('user_id'), 'user_created_by' => (int) $s_obj->getColumn('user_created_by'), 'user_full_name' => Misc::getFullName($s_obj->getColumn('first_name'), NULL, $s_obj->getColumn('last_name'), FALSE, FALSE), 'first_name' => $s_obj->getColumn('first_name'), 'last_name' => $s_obj->getColumn('last_name'), 'status_id' => (int) $s_obj->getStatus(), 'date_stamp' => TTDate::getAPIDate('DATE', TTDate::parseDateTime($s_obj->getColumn('date_stamp'))), 'start_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'start_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'total_time' => $s_obj->getTotalTime(), 'schedule_policy_id' => (int) $s_obj->getSchedulePolicyID(), 'absence_policy_id' => (int) $s_obj->getAbsencePolicyID(), 'absence_policy' => $absence_policy_name, 'branch_id' => (int) $s_obj->getBranch(), 'branch' => Option::getByKey($s_obj->getBranch(), $branch_options, NULL), 'department_id' => (int) $s_obj->getDepartment(), 'department' => Option::getByKey($s_obj->getDepartment(), $department_options, NULL));
$schedule_shifts_index[$iso_date_stamp][$s_obj->getColumn('user_id')][] = $s_obj->getColumn('user_id') . $s_obj->getStartTime();
unset($absence_policy_name);
}
//Debug::Arr($schedule_shifts, 'Committed Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10);
//Debug::Arr($schedule_shifts_index, 'Committed Schedule Shifts Index: ', __FILE__, __LINE__, __METHOD__, 10);
} else {
$schedule_shifts = array();
}
unset($slf);
//Get holidays
//FIXME: What if there are two holiday policies, one that defaults to working, and another that defaults to not working, and they are assigned
//to two different groups of employees? For that matter what if the holiday policy isn't assigned to a specific user at all.
$holiday_data = array();
$hlf = new HolidayListFactory();
$hlf->getByCompanyIdAndStartDateAndEndDate($current_user->getCompany(), $filter_data['start_date'], $filter_data['end_date']);
Debug::text('Found Holiday Rows: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
foreach ($hlf as $h_obj) {
if (is_object($h_obj->getHolidayPolicyObject()) and is_object($h_obj->getHolidayPolicyObject()->getAbsencePolicyObject())) {
$holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => (int) $h_obj->getHolidayPolicyObject()->getDefaultScheduleStatus(), 'absence_policy_id' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyID(), 'absence_policy' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyObject()->getName());
} else {
$holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => 10);
//Working
}
}
unset($hlf);
$recurring_schedule_shifts = array();
$recurring_schedule_shifts_index = array();
$rstlf = new RecurringScheduleTemplateListFactory();
$rstlf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data);
Debug::text('Found Recurring Schedule Template Rows: ' . $rstlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
if ($rstlf->getRecordCount() > 0) {
foreach ($rstlf as $rst_obj) {
//Debug::text('Recurring Schedule Template ID: '. $rst_obj->getID() , __FILE__, __LINE__, __METHOD__, 10);
$rst_obj->getShifts($filter_data['start_date'], $filter_data['end_date'], $holiday_data, $branch_options, $department_options, &$schedule_shifts, &$schedule_shifts_index);
}
} else {
Debug::text('DID NOT find Recurring Schedule for this time period: ', __FILE__, __LINE__, __METHOD__, 10);
}
//Debug::Arr($schedule_shifts, 'Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10);
unset($schedule_shifts_index, $recurring_schedule_shifts_index);
if (isset($schedule_shifts)) {
return $schedule_shifts;
}
return FALSE;
}