本文整理汇总了PHP中TTDate::getTimeUnit方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getTimeUnit方法的具体用法?PHP TTDate::getTimeUnit怎么用?PHP TTDate::getTimeUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::getTimeUnit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_gettimeunit
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
function smarty_function_gettimeunit($params, &$smarty)
{
$value = $params['value'];
$default = $params['default'];
$abs = $params['abs'];
//var_dump($default);
if ($default == 'TRUE') {
$default = 'N/A';
} elseif ($default == '0') {
if ($value === FALSE or $value === NULL) {
$value = 0;
}
} else {
$default = NULL;
}
if ($abs == 'TRUE') {
$value = abs($value);
}
//var_dump($value);
//Make sure the default is set to TRUE to get "N/A"
if ($value === FALSE or $value === NULL) {
return $default;
}
$retval = TTDate::getTimeUnit($value);
return $retval;
}
示例2: count
$rows = Sort::Multisort($tmp_rows, Misc::trimSortPrefix($filter_data['primary_sort']), Misc::trimSortPrefix($filter_data['secondary_sort']), $filter_data['primary_sort_dir'], $filter_data['secondary_sort_dir']);
$total_row = Misc::ArrayAssocSum($rows, NULL, 2);
$last_row = count($rows);
$rows[$last_row] = $total_row;
foreach ($static_columns as $static_column_key => $static_column_val) {
$rows[$last_row][Misc::trimSortPrefix($static_column_key)] = NULL;
}
unset($static_column_key, $static_column_val);
//Convert units
$tmp_rows = $rows;
unset($rows);
$trimmed_static_columns = array_keys(Misc::trimSortPrefix($static_columns));
foreach ($tmp_rows as $row) {
foreach ($row as $column => $column_data) {
if (!strstr($column, 'wage') and !strstr($column, 'worked_days') and !in_array($column, $trimmed_static_columns)) {
$column_data = TTDate::getTimeUnit($column_data);
}
$row_columns[$column] = $column_data;
unset($column, $column_data);
}
$rows[] = $row_columns;
unset($row_columns);
}
}
}
//var_dump($rows);
foreach ($filter_data['column_ids'] as $column_key) {
$filter_columns[Misc::trimSortPrefix($column_key)] = $columns[$column_key];
}
if ($action == 'export') {
if (isset($rows) and isset($filter_columns)) {
示例3: 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);
if ($this->getUserDateObject() == FALSE or $this->getUserDateObject()->getPayPeriodObject() == FALSE) {
$this->Validator->isTRUE('pay_period', FALSE, TTi18n::gettext('Date/Time is incorrect, or pay period does not exist for this date. Please create a pay period schedule if you have not done so already'));
} elseif ($this->getUserDateObject() == FALSE or $this->getUserDateObject()->getPayPeriodObject()->getIsLocked() == TRUE) {
$this->Validator->isTRUE('pay_period', FALSE, TTi18n::gettext('Pay Period is Currently Locked'));
}
$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)'));
}
//Skip these checks if they are deleting a punch.
if (is_object($this->getPunchObject()) and $this->getPunchObject()->getDeleted() == FALSE) {
$shift_data = $this->getShiftData();
if (is_array($shift_data)) {
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 (a)'));
}
}
//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 (b)'));
}
}
$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 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);
if (isset($punches[$punch_neighbors['next']][10]) and $this->getPunchObject()->getTimeStamp() > $punches[$punch_neighbors['next']][10]['time_stamp'] or isset($punches[$punch_neighbors['next']][20]) and $this->getPunchObject()->getTimeStamp() > $punches[$punch_neighbors['next']][20]['time_stamp']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time conflicts with another punch on this day') . ' (a)');
}
}
if (isset($punch_neighbors['prev']) and isset($punches[$punch_neighbors['prev']])) {
Debug::text('Found prev Punch...', __FILE__, __LINE__, __METHOD__, 10);
if (isset($punches[$punch_neighbors['prev']][10]) and $this->getPunchObject()->getTimeStamp() < $punches[$punch_neighbors['prev']][10]['time_stamp'] or isset($punches[$punch_neighbors['prev']][20]) and $this->getPunchObject()->getTimeStamp() < $punches[$punch_neighbors['prev']][20]['time_stamp']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time conflicts with another punch on this day') . ' (b)');
}
}
}
//Check to make sure punches don't exceed maximum shift time.
$maximum_shift_time = $plf->getPayPeriodMaximumShiftTime($this->getPunchObject()->getUser());
Debug::text('aaaMaximum shift time: ' . $maximum_shift_time, __FILE__, __LINE__, __METHOD__, 10);
if ($shift_data['total_time'] > $maximum_shift_time) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Punch exceeds maximum shift time of') . ' ' . TTDate::getTimeUnit($maximum_shift_time) . ' ' . TTi18n::getText('hrs set for this pay period schedule'));
}
}
unset($punches);
}
}
if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL and $this->getEnableStrictJobValidation() == TRUE) {
if ($this->getJob() > 0) {
$jlf = new JobListFactory();
$jlf->getById($this->getJob());
if ($jlf->getRecordCount() > 0) {
$j_obj = $jlf->getCurrent();
if (is_object($this->getUserDateObject()) and $j_obj->isAllowedUser($this->getUserDateObject()->getUser()) == FALSE) {
$this->Validator->isTRUE('job', FALSE, TTi18n::gettext('Employee is not assigned to this job'));
}
if ($j_obj->isAllowedItem($this->getJobItem()) == FALSE) {
$this->Validator->isTRUE('job_item', FALSE, TTi18n::gettext('Task is not assigned to this job'));
}
//.........这里部分代码省略.........
示例4: unset
$x++;
}
unset($data);
}
if (isset($totals) and is_array($totals)) {
//Display overall totals.
$pdf->Ln(4);
$total_cell_width = $column_widths['line'] + $column_widths['date_stamp'] + $column_widths['dow'] + $column_widths['in_punch_time_stamp'];
$pdf->SetFont('', 'B', 9);
$pdf->Cell($total_cell_width, 6, '', 0, 0, 'R', 0);
$pdf->Cell($column_widths['out_punch_time_stamp'], 6, TTi18n::gettext('Overall Total:') . ' ', 'T', 0, 'R', 0);
$pdf->Cell($column_widths['worked_time'], 6, TTDate::getTimeUnit($totals['worked_time']), 'T', 0, 'C', 0);
$pdf->Cell($column_widths['paid_time'], 6, TTDate::getTimeUnit($totals['paid_time']), 'T', 0, 'C', 0);
$pdf->Cell($column_widths['regular_time'], 6, TTDate::getTimeUnit($totals['regular_time']), 'T', 0, 'C', 0);
$pdf->Cell($column_widths['over_time'], 6, TTDate::getTimeUnit($totals['over_time']), 'T', 0, 'C', 0);
$pdf->Cell($column_widths['absence_time'], 6, TTDate::getTimeUnit($totals['absence_time']), 'T', 0, 'C', 0);
$pdf->Ln();
unset($totals);
}
$pdf->SetFont('', '', 10);
$pdf->setFillColor(255, 255, 255);
$pdf->Ln();
//Signature lines
$pdf->MultiCell(200, 5, TTi18n::gettext('By signing this timesheet I hereby certify that the above time accurately and fully reflects the time that') . ' ' . $user_data['first_name'] . ' ' . $user_data['last_name'] . ' ' . TTi18n::gettext('worked during the designated period.'), $border, 'L');
$pdf->Ln(5);
$border = 0;
$pdf->Cell(40, 5, TTi18n::gettext('Employee Signature:'), $border, 0, 'L');
$pdf->Cell(60, 5, '_____________________________', $border, 0, 'C');
$pdf->Cell(40, 5, TTi18n::gettext('Supervisor Signature:'), $border, 0, 'R');
$pdf->Cell(60, 5, '_____________________________', $border, 0, 'C');
$pdf->Ln();
示例5: addLog
function addLog($log_action)
{
$u_obj = $this->getUserObject();
if (is_object($u_obj)) {
return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Accrual') . ' - ' . TTi18n::getText('Employee') . ': ' . $u_obj->getFullName(FALSE, TRUE) . ' ' . TTi18n::getText('Type') . ': ' . Option::getByKey($this->getType(), $this->getOptions('type')) . ' ' . TTi18n::getText('Date') . ': ' . TTDate::getDate('DATE', $this->getTimeStamp()) . ' ' . TTi18n::getText('Total Time') . ': ' . TTDate::getTimeUnit($this->getAmount()), NULL, $this->getTable(), $this);
}
return FALSE;
}
示例6: _outputPayrollExport
function _outputPayrollExport($format = NULL)
{
$setup_data = $this->getFormConfig();
Debug::Text('Generating Payroll Export... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
if (isset($setup_data['export_type'])) {
Debug::Text('Export Type: ' . $setup_data['export_type'], __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::Text('No Export Type defined!', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
Debug::Arr($setup_data, 'Setup Data: ', __FILE__, __LINE__, __METHOD__, 10);
$rows = $this->data;
//Debug::Arr($rows, 'PreData: ', __FILE__, __LINE__, __METHOD__,10);
$file_name = strtolower(trim($setup_data['export_type'])) . '_' . date('Y_m_d') . '.txt';
$mime_type = 'application/text';
$data = NULL;
switch (strtolower(trim($setup_data['export_type']))) {
case 'adp':
//ADP export format.
//File format supports multiple rows per employee (file #) all using the same columns. No need to jump through nasty hoops to fit everything on row.
$export_column_map = array('company_code' => 'Co Code', 'batch_id' => 'Batch ID', 'temp_dept' => 'Temp Dept', 'employee_number' => 'File #', 'regular_time' => 'Reg Hours', 'overtime' => 'O/T Hours', '3_code' => 'Hours 3 Code', '3_amount' => 'Hours 3 Amount', '4_code' => 'Hours 4 Code', '4_amount' => 'Hours 4 Amount');
ksort($setup_data['adp']['columns']);
$setup_data['adp']['columns'] = Misc::trimSortPrefix($setup_data['adp']['columns']);
foreach ($setup_data['adp']['columns'] as $column_id => $column_data) {
$column_name = NULL;
if ($column_data['hour_column'] == 'regular_time') {
$export_data_map[$column_id] = 'regular_time';
} elseif ($column_data['hour_column'] == 'overtime') {
$export_data_map[$column_id] = 'overtime';
} elseif ($column_data['hour_column'] >= 3) {
$export_data_map[$column_id] = $column_data;
}
}
if (!isset($setup_data['adp']['company_code_value'])) {
$setup_data['adp']['company_code_value'] = NULL;
}
if (!isset($setup_data['adp']['batch_id_value'])) {
$setup_data['adp']['batch_id_value'] = NULL;
}
if (!isset($setup_data['adp']['temp_dept_value'])) {
$setup_data['adp']['temp_dept_value'] = NULL;
}
$company_code_column = Misc::trimSortPrefix($setup_data['adp']['company_code']);
$batch_id_column = Misc::trimSortPrefix($setup_data['adp']['batch_id']);
$temp_dept_column = Misc::trimSortPrefix($setup_data['adp']['temp_dept']);
foreach ($rows as $row) {
$static_columns = array('company_code' => isset($row[$company_code_column]) ? $row[$company_code_column] : $setup_data['adp']['company_code_value'], 'batch_id' => isset($row[$batch_id_column]) ? $row[$batch_id_column] : $setup_data['adp']['batch_id_value'], 'temp_dept' => isset($row[$temp_dept_column]) ? $row[$temp_dept_column] : $setup_data['adp']['temp_dept_value'], 'employee_number' => str_pad($row['employee_number'], 6, 0, STR_PAD_LEFT));
foreach ($setup_data['adp']['columns'] as $column_id => $column_data) {
$column_data = Misc::trimSortPrefix($column_data, TRUE);
Debug::Text('ADP Column ID: ' . $column_id . ' Hour Column: ' . $column_data['hour_column'] . ' Code: ' . $column_data['hour_code'], __FILE__, __LINE__, __METHOD__, 10);
if (isset($row[$column_id]) and $column_data['hour_column'] != '0') {
foreach ($export_column_map as $export_column_id => $export_column_name) {
Debug::Arr($row, 'Row: Column ID: ' . $column_id . ' Export Column ID: ' . $export_column_id . ' Name: ' . $export_column_name, __FILE__, __LINE__, __METHOD__, 10);
if (($column_data['hour_column'] == $export_column_id or $column_data['hour_column'] . '_code' == $export_column_id) and !in_array($export_column_id, array('company_code', 'batch_id', 'temp_dept', 'employee_number'))) {
if ((int) substr($export_column_id, 0, 1) > 0) {
$tmp_row[$column_data['hour_column'] . '_code'] = $column_data['hour_code'];
$tmp_row[$column_data['hour_column'] . '_amount'] = TTDate::getTimeUnit($row[$column_id], 20);
} else {
$tmp_row[$export_column_id] = TTDate::getTimeUnit($row[$column_id], 20);
}
//Break out every column onto its own row, that way its easier to handle multiple columns of the same type.
$tmp_rows[] = array_merge($static_columns, $tmp_row);
unset($tmp_row);
}
}
}
}
}
$file_name = 'EPI000000.csv';
if (isset($tmp_rows)) {
//File format supports multiple entries per employee (file #) all using the same columns. No need to jump through nasty hoops to fit everyone one row.
$file_name = 'EPI' . $tmp_rows[0]['company_code'] . $tmp_rows[0]['batch_id'] . '.csv';
$data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE);
}
unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row);
break;
case 'adp_old':
//ADP export format.
$file_name = 'EPI' . $setup_data['adp']['company_code'] . $setup_data['adp']['batch_id'] . '.csv';
$export_column_map = array();
$static_export_column_map = array('company_code' => 'Co Code', 'batch_id' => 'Batch ID', 'employee_number' => 'File #');
$static_export_data_map = array('company_code' => $setup_data['adp']['company_code'], 'batch_id' => $setup_data['adp']['batch_id']);
//
//Format allows for multiple duplicate columns.
//ie: Hours 3 Code, Hours 3 Amount, Hours 3 Code, Hours 3 Amount, ...
//However, we can only have a SINGLE O/T Hours column.
//We also need to combine hours with the same code together.
//
ksort($setup_data['adp']['columns']);
$setup_data['adp']['columns'] = Misc::trimSortPrefix($setup_data['adp']['columns']);
foreach ($setup_data['adp']['columns'] as $column_id => $column_data) {
$column_name = NULL;
if ($column_data['hour_column'] == 'regular_time') {
$column_name = 'Reg Hours';
$export_data_map[$column_id] = trim($setup_data['adp']['columns'][$column_id]['hour_code']);
} elseif ($column_data['hour_column'] == 'overtime') {
$column_name = 'O/T Hours';
$export_data_map[$column_id] = trim($setup_data['adp']['columns'][$column_id]['hour_code']);
} elseif ($column_data['hour_column'] >= 3) {
$column_name = 'Hours ' . $column_data['hour_column'] . ' Amount';
//.........这里部分代码省略.........
示例7: TTnew
$utlf->getByCompanyId($current_company->getId());
$title_options = $utlf->getArrayByListFactory($utlf, FALSE, TRUE);
$blf = TTnew('BranchListFactory');
$blf->getByCompanyId($current_company->getId());
$branch_options = $blf->getArrayByListFactory($blf, FALSE, TRUE);
$dlf = TTnew('DepartmentListFactory');
$dlf->getByCompanyId($current_company->getId());
$department_options = $dlf->getArrayByListFactory($dlf, FALSE, TRUE);
$uglf = TTnew('UserGroupListFactory');
$group_options = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE));
$ulf = TTnew('UserListFactory');
$user_options = $ulf->getByCompanyIdArray($current_company->getID(), FALSE);
foreach ($slf as $s_obj) {
//Debug::Text('Status ID: '. $r_obj->getStatus() .' Status: '. $status_options[$r_obj->getStatus()], __FILE__, __LINE__, __METHOD__,10);
$user_obj = $ulf->getById($s_obj->getColumn('user_id'))->getCurrent();
$rows[] = array('id' => $s_obj->getColumn('schedule_id'), 'user_id' => $s_obj->getColumn('user_id'), 'first_name' => $user_obj->getFirstName(), 'last_name' => $user_obj->getLastName(), 'title' => Option::getByKey($user_obj->getTitle(), $title_options), 'group' => Option::getByKey($user_obj->getGroup(), $group_options), 'default_branch' => Option::getByKey($user_obj->getDefaultBranch(), $branch_options), 'default_department' => Option::getByKey($user_obj->getDefaultDepartment(), $department_options), 'branch_id' => Option::getByKey($s_obj->getBranch(), $branch_options), 'department_id' => Option::getByKey($s_obj->getDepartment(), $department_options), 'status_id' => Option::getByKey($s_obj->getStatus(), $schedule_status_options), 'start_time' => TTDate::getDate('DATE+TIME', $s_obj->getStartTime()), 'end_time' => TTDate::getDate('DATE+TIME', $s_obj->getEndTime()), 'total_time' => TTDate::getTimeUnit($s_obj->getTotalTime()), 'is_owner' => $permission->isOwner($s_obj->getCreatedBy(), $current_user->getId()), 'is_child' => $permission->isChild($s_obj->getColumn('user_id'), $permission_children_ids));
}
$smarty->assign_by_ref('rows', $rows);
$all_array_option = array('-1' => TTi18n::gettext('-- Any --'));
$ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
$filter_data['user_options'] = Misc::prependArray($all_array_option, UserListFactory::getArrayByListFactory($ulf, FALSE, TRUE));
//Select box options;
$filter_data['branch_options'] = Misc::prependArray($all_array_option, $branch_options);
$filter_data['department_options'] = Misc::prependArray($all_array_option, $department_options);
$filter_data['title_options'] = Misc::prependArray($all_array_option, $title_options);
$filter_data['group_options'] = Misc::prependArray($all_array_option, $group_options);
$filter_data['status_options'] = Misc::prependArray($all_array_option, $ulf->getOptions('status'));
$filter_data['pay_period_options'] = Misc::prependArray($all_array_option, $pay_period_options);
$filter_data['schedule_status_options'] = Misc::prependArray($all_array_option, $schedule_status_options);
$filter_data['schedule_policy_options'] = Misc::prependArray($all_array_option, $schedule_policy_options);
$filter_data['saved_search_options'] = $ugdlf->getArrayByListFactory($ugdlf->getByUserIdAndScript($current_user->getId(), $_SERVER['SCRIPT_NAME']), FALSE);
示例8: parseTimeUnit
public static function parseTimeUnit($time_unit, $format = NULL)
{
/*
10 => 'hh:mm (2:15)',
12 => 'hh:mm:ss (2:15:59)',
20 => 'Hours (2.25)',
22 => 'Hours (2.241)',
30 => 'Minutes (135)'
*/
if ($format == '') {
$format = self::$time_unit_format;
}
$enable_rounding = TRUE;
if (strpos($time_unit, '"') !== FALSE) {
$enable_rounding = FALSE;
}
//Get rid of any spaces or commas.
//ie: 1,100 :10 should still parse correctly
$time_unit = trim(str_replace(array(',', ' ', '"'), '', $time_unit));
//Debug::text('Time Unit: '. $time_unit .' Enable Rounding: '. (int)$enable_rounding, __FILE__, __LINE__, __METHOD__, 10);
//Debug::text('Time Unit Format: '. self::$time_unit_format, __FILE__, __LINE__, __METHOD__, 10);
//Convert string to seconds.
switch ($format) {
case 10:
//hh:mm
//hh:mm
case 12:
//hh:mm:ss
if (strpos($time_unit, '.') !== FALSE and strpos($time_unit, ':') === FALSE) {
//Hybrid mode, they passed a decimal format HH:MM, try to handle properly.
$time_unit = TTDate::getTimeUnit(self::parseTimeUnit($time_unit, 20), $format);
}
$time_units = explode(':', $time_unit);
if (!isset($time_units[0])) {
$time_units[0] = 0;
}
if (!isset($time_units[1])) {
$time_units[1] = 0;
}
if (!isset($time_units[2])) {
$time_units[2] = 0;
}
//Check if the first character is '-', or thre are any negative integers.
if (strncmp($time_units[0], '-', 1) == 0 or $time_units[0] < 0 or $time_units[1] < 0 or $time_units[2] < 0) {
$negative_number = TRUE;
}
$seconds = abs((int) $time_units[0]) * 3600 + abs((int) $time_units[1]) * 60 + abs((int) $time_units[2]);
if (isset($negative_number)) {
$seconds = $seconds * -1;
}
break;
case 20:
//hours
//hours
case 22:
//hours [Precise]
if (strpos($time_unit, ':') !== FALSE and strpos($time_unit, '.') === FALSE) {
//Hybrid mode, they passed a HH:MM format as a decimal, try to handle properly.
$time_unit = TTDate::getTimeUnit(self::parseTimeUnit($time_unit, 10), $format);
}
//Round to the nearest minute when entering decimal format to avoid issues with 0.33 (19.8 minutes) or 0.333 (19.98 minutes) or 0.33333...
//This is only for input, for things like absence time, or meal/break policies, its rare they need sub-minute resolution, and if they
//do they can use hh:mm:ss instead.
//However accrual policies have to be second accurate (weekly accruals rounded to 1 minute can result in 52minute differences in a year),
//so we need a way to disable this rounding as well so the user can properly zero out an accrual balance if needed.
$seconds = $time_unit * 3600;
if ($enable_rounding == TRUE) {
$seconds = self::roundTime($seconds, 60);
}
break;
case 30:
//minutes
$seconds = $time_unit * 60;
break;
}
if (isset($seconds)) {
if ($seconds > 2147483646) {
Debug::text('ERROR: Parsing time unit format exceeds maximum 4 byte integer!', __FILE__, __LINE__, __METHOD__, 10);
$seconds = 2147483646;
}
return $seconds;
}
return FALSE;
}
示例9: addLog
function addLog($log_action)
{
if ($this->getOverride() == TRUE and $this->getStatus() == 30 and is_object($this->getUserDateObject())) {
//Absence
return TTLog::addEntry($this->getId(), $log_action, TTi18n::getText('Absence') . ' - ' . TTi18n::getText('Date') . ': ' . TTDate::getDate('DATE', $this->getUserDateObject()->getDateStamp()) . ' ' . TTi18n::getText('Total Time') . ': ' . TTDate::getTimeUnit($this->getTotalTime()), NULL, $this->getTable(), $this);
}
}
示例10: getAccrualBalance
function getAccrualBalance($accrual_policy_id, $user_id)
{
if ($accrual_policy_id == '') {
return FALSE;
}
if ($user_id == '') {
return FALSE;
}
$ablf = TTnew('AccrualBalanceListFactory');
$ablf->getByUserIdAndAccrualPolicyId($user_id, $accrual_policy_id);
if ($ablf->getRecordCount() > 0) {
$accrual_balance = $ablf->getCurrent()->getBalance();
} else {
$accrual_balance = 0;
}
return TTDate::getTimeUnit($accrual_balance);
}
示例11: ksort
break;
case 'surepayroll':
//SurePayroll Export format.
ksort($setup_data['surepayroll']['columns']);
$setup_data['surepayroll']['columns'] = Misc::trimSortPrefix($setup_data['surepayroll']['columns']);
//
//header
//
$data = 'TC' . "\n";
$data .= '00001' . "\n";
$export_column_map = array('pay_period_end_date' => 'Entry Date', 'employee_number' => 'Employee Number', 'last_name' => 'Last Name', 'first_name' => 'First Name', 'hour_code' => 'Payroll Code', 'value' => 'Hours');
foreach ($rows as $row) {
foreach ($setup_data['surepayroll']['columns'] as $column_id => $column_data) {
if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') {
Debug::Arr($column_data, 'Output2', __FILE__, __LINE__, __METHOD__, 10);
$tmp_rows[] = array('pay_period_end_date' => date('m/d/Y', $row['pay_period_end_date']), 'employee_number' => $row['employee_number'], 'last_name' => $row['last_name'], 'first_name' => $row['first_name'], 'hour_code' => trim($column_data['hour_code']), 'value' => TTDate::getTimeUnit($row[$column_id], 20));
}
}
}
if (isset($tmp_rows)) {
$data .= Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE);
$data = str_replace('"', '', $data);
}
unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row);
break;
default:
break;
}
}
}
if (Debug::getVerbosity() == 11) {
示例12: Validate
//.........这里部分代码省略.........
$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);
if (isset($punches[$punch_neighbors['next']][10]) and $this->getPunchObject()->getTimeStamp() > $punches[$punch_neighbors['next']][10]['time_stamp'] or isset($punches[$punch_neighbors['next']][20]) and $this->getPunchObject()->getTimeStamp() > $punches[$punch_neighbors['next']][20]['time_stamp']) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time conflicts with another punch on this day') . ' (a)');
}
}
if (isset($punch_neighbors['prev']) and isset($punches[$punch_neighbors['prev']])) {
Debug::text('Found prev Punch...', __FILE__, __LINE__, __METHOD__, 10);
//This needs to take into account DST. Specifically if punches are like this:
//03-Nov-12: IN: 10:00PM
//04-Nov-12: OUT: 1:00AM L
//04-Nov-12: IN: 1:30AM L
//04-Nov-12: OUT: 6:30AM L
//Since the 1AM to 2AM occur twice due to the "fall back" DST change, we need to allow those punches to be entered.
if (isset($punches[$punch_neighbors['prev']][10]) and ($this->getPunchObject()->getTimeStamp() < $punches[$punch_neighbors['prev']][10]['time_stamp'] and TTDate::doesRangeSpanDST($this->getPunchObject()->getTimeStamp(), $punches[$punch_neighbors['prev']][10]['time_stamp']) == FALSE) or isset($punches[$punch_neighbors['prev']][20]) and ($this->getPunchObject()->getTimeStamp() < $punches[$punch_neighbors['prev']][20]['time_stamp'] and TTDate::doesRangeSpanDST($this->getPunchObject()->getTimeStamp(), $punches[$punch_neighbors['prev']][20]['time_stamp']) == FALSE)) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time conflicts with another punch on this day') . ' (b)');
}
}
}
//Check to make sure punches don't exceed maximum shift time.
$maximum_shift_time = $plf->getPayPeriodMaximumShiftTime($this->getPunchObject()->getUser());
Debug::text('Maximum shift time: ' . $maximum_shift_time, __FILE__, __LINE__, __METHOD__, 10);
if ($shift_data['total_time'] > $maximum_shift_time) {
$this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Punch exceeds maximum shift time of') . ' ' . TTDate::getTimeUnit($maximum_shift_time) . ' ' . TTi18n::getText('hrs set for this pay period schedule'));
}
}
unset($punches);
}
}
}
if (getTTProductEdition() >= TT_PRODUCT_CORPORATE and $this->getEnableStrictJobValidation() == TRUE) {
if ($this->getJob() > 0) {
$jlf = TTnew('JobListFactory');
$jlf->getById($this->getJob());
if ($jlf->getRecordCount() > 0) {
$j_obj = $jlf->getCurrent();
if (is_object($this->getUserDateObject()) and $j_obj->isAllowedUser($this->getUserDateObject()->getUser()) == FALSE) {
$this->Validator->isTRUE('job', FALSE, TTi18n::gettext('Employee is not assigned to this job'));
}
if ($j_obj->isAllowedItem($this->getJobItem()) == FALSE) {
$this->Validator->isTRUE('job_item', FALSE, TTi18n::gettext('Task is not assigned to this job'));
}
}
}
}
return TRUE;
}
示例13: columnFormatter
function columnFormatter($type, $column, $value, $format = NULL)
{
if (is_array($value) and isset($value['display'])) {
//Found sorting array, use display column.
return $value['display'];
} else {
$retval = $value;
if ($format == 'csv' or $format == 'raw') {
//Force specific field formats for exporting to CSV format.
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
case 'percent':
case 'numeric':
//Don't format above types.
break;
case 'time_unit':
$retval = TTDate::getHours($value);
//Force to hours always.
break;
case 'date_stamp':
$retval = TTDate::getDate('DATE', $value);
break;
case 'time':
$retval = TTDate::getDate('TIME', $value);
break;
case 'time_stamp':
$retval = TTDate::getDate('DATE+TIME', $value);
break;
case 'boolean':
if ($value == TRUE) {
$retval = TTi18n::getText('Yes');
} else {
$retval = TTi18n::getText('No');
}
default:
break;
}
} elseif ($format == 'xml') {
//Use standard XML formats whenever possible.
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
case 'percent':
case 'numeric':
//Don't format above types.
break;
case 'time_unit':
$retval = TTDate::getHours($value);
//Force to hours always.
break;
case 'date_stamp':
$retval = date('Y-m-d', $value);
////type="xs:date"
break;
case 'time':
$retval = date('H:i:s', $value);
//type="xs:time"
break;
case 'time_stamp':
$retval = date('c', $value);
//type="xs:dateTime"
break;
case 'boolean':
if ($value == TRUE) {
$retval = TTi18n::getText('Yes');
} else {
$retval = TTi18n::getText('No');
}
default:
break;
}
} else {
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
if (is_object($this->getCurrencyObject())) {
//Set MIN decimals to 2 and max to the currency rounding.
$retval = $this->getCurrencyObject()->getSymbol() . TTi18n::formatNumber($value, TRUE, 2, $this->getCurrencyObject()->getRoundDecimalPlaces());
} else {
$retval = TTi18n::formatCurrency($value);
}
break;
case 'percent':
$retval = TTi18n::formatNumber($value, TRUE) . '%';
break;
case 'numeric':
$retval = TTi18n::formatNumber($value, TRUE);
break;
case 'time_unit':
$retval = TTDate::getTimeUnit($value);
//.........这里部分代码省略.........
示例14: timesheetTotal
function timesheetTotal($column_widths, $totals)
{
$margins = $this->pdf->getMargins();
$total_width = $this->pdf->getPageWidth() - $margins['left'] - $margins['right'];
$buffer = ($total_width - 200) / 10;
$line_h = $this->_pdf_scaleSize(6);
$total_cell_width = $column_widths['line'] + $column_widths['date_stamp'] + $column_widths['dow'] + $column_widths['in_punch_time_stamp'] + $buffer * 4;
$this->pdf->SetFont($this->config['other']['default_font'], 'B', $this->_pdf_fontSize(9));
$this->pdf->Cell($total_cell_width, $line_h, '', 0, 0, 'R', 0);
$this->pdf->Cell($column_widths['out_punch_time_stamp'] + $buffer, $line_h, TTi18n::gettext('Overall Total') . ': ', 'T', 0, 'R', 0);
$this->pdf->Cell($column_widths['worked_time'] + $buffer, $line_h, TTDate::getTimeUnit($totals['worked_time']), 'T', 0, 'C', 0);
$this->pdf->Cell($column_widths['regular_time'] + $buffer, $line_h, TTDate::getTimeUnit($totals['regular_time']), 'T', 0, 'C', 0);
$this->pdf->Cell($column_widths['over_time'] + $buffer, $line_h, TTDate::getTimeUnit($totals['over_time']), 'T', 0, 'C', 0);
$this->pdf->Cell($column_widths['absence_time'] + $buffer, $line_h, TTDate::getTimeUnit($totals['absence_time']), 'T', 0, 'C', 0);
$this->pdf->Ln();
return TRUE;
}