本文整理汇总了PHP中DateTimeValue::FormatTimeDiff方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue::FormatTimeDiff方法的具体用法?PHP DateTimeValue::FormatTimeDiff怎么用?PHP DateTimeValue::FormatTimeDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeValue
的用法示例。
在下文中一共展示了DateTimeValue::FormatTimeDiff方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cvs_total_task_times_table
function cvs_total_task_times_table($objects, $pad_str, $options, $group_name, &$sub_total = 0) {
echo lang('date') . ';';
echo lang('title') . ';';
echo lang('description') . ';';
echo lang('person') . ';';
echo lang('time') .'('.lang('hours').')'. ';';
echo "\n";
$sub_total = 0;
foreach ($objects as $ts) {
echo $pad_str . format_date($ts->getStartTime()) . ';';
$name = ($ts->getRelObjectId() == 0 ? $ts->getObjectName() : $ts->getRelObject()->getObjectName());
$name = str_replace("\r", " ", str_replace("\n", " ", str_replace("\r\n", " ", $name)));
echo $name . ';';
$desc = $ts->getDescription();
$desc = str_replace("\r", " ", str_replace("\n", " ", str_replace("\r\n", " ", $desc)));
$desc = '"'.$desc.'"';
echo $desc .';';
echo ($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') .';';
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
$mystring = DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "m", 60, $ts->getSubtract());
$resultado = ereg_replace("[^0-9]", "", $mystring);
$resultado = round(($resultado/60),5);
echo $resultado;
$sub_total += $resultado;
echo "\n";
}
}
示例2: total_task_times_print_table
function total_task_times_print_table($objects, $left, $options, $group_name, &$sub_total = 0, &$sub_total_billing = 0) {
echo '<div style="padding-left:'. $left .'px;">';
echo '<table class="reporting-table"><tr class="reporting-table-heading">';
echo '<th>' . lang('date') . '</th>';
echo '<th>' . lang('title') . '</th>';
echo '<th>' . lang('description') . '</th>';
echo '<th>' . lang('person') . '</th>';
if (array_var($options, 'show_billing') == 'checked') {
echo '<th class="right">' . lang('billing') . '</th>';
}
echo '<th class="right">' . lang('time') . '</th>';
echo '</tr>';
$sub_total = 0;
$alt_cls = "";
foreach ($objects as $ts) { /* @var $ts Timeslot */
echo "<tr $alt_cls>";
echo "<td class='date'>" . format_date($ts->getStartTime()) . "</td>";
echo "<td class='name'>" . ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) ."</td>";
echo "<td class='name'>" . clean($ts->getDescription()) ."</td>";
echo "<td class='person'>" . clean($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') ."</td>";
if (array_var($options, 'show_billing') == 'checked') {
if($ts->getIsFixedBilling()){
echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format($ts->getFixedBilling(), 2) . "</td>";
$sub_total_billing += $ts->getFixedBilling();
}else{
$min = $ts->getMinutes();
echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format(($ts->getHourlyBilling()/60) * $min, 2) . "</td>";
$sub_total_billing += ($ts->getHourlyBilling()/60) * $min;
}
}
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
echo "<td class='time nobr right'>" . DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) ."</td>";
echo "</tr>";
$sub_total += $ts->getMinutes();
$alt_cls = $alt_cls == "" ? 'class="alt-row"' : "";
}
echo '</table></div>';
}
示例3: cvs_total_task_times_table
function cvs_total_task_times_table($objects, $pad_str, $options, $group_name, &$sub_total = 0)
{
echo lang('date') . ';';
echo lang('title') . ';';
echo lang('description') . ';';
echo lang('person') . ';';
echo lang('time') . ';';
echo "\n";
$sub_total = 0;
foreach ($objects as $ts) {
echo $pad_str . format_date($ts->getStartTime()) . ';';
echo ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) . ';';
echo clean($ts->getDescription()) . ';';
echo clean($ts->getUser()->getObjectName()) . ';';
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
echo DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) . ';';
$sub_total += $ts->getMinutes();
echo "\n";
}
}
示例4: if
<tr class="timeslot <?php echo $counter % 2 ? 'even' : 'odd'; echo $timeslot->isOpen() ? ' openTimeslot' : '' ?>" id="timeslot<?php echo $timeslot->getId() ?>">
<td style="padding-right:10px"><b><?php echo $counter ?>.</b></td>
<?php if ($timeslot->getUser() instanceof Contact) { ?>
<td style="padding-right:10px"><b><a class="internalLink" href="<?php echo $timeslot->getUser()->getCardUserUrl()?>" title=" <?php echo lang('user card of', clean($timeslot->getUser()->getObjectName())) ?>"><?php echo clean($timeslot->getUser()->getObjectName()) ?></a></b></td>
<?php } else {?>
<td style="padding-right:10px"><b><?php echo lang("n/a") ?></b></td>
<?php } ?>
<td style="padding-right:10px"><?php echo format_datetime($timeslot->getStartTime())?>
- <?php echo $timeslot->isOpen() ? ('<b>' . lang('work in progress') . '</b>') :
( (format_date($timeslot->getEndTime()) != format_date($timeslot->getStartTime()))? format_datetime($timeslot->getEndTime()): format_time($timeslot->getEndTime())) ?></td>
<td style="padding-right:10px">
<?php
echo DateTimeValue::FormatTimeDiff($timeslot->getStartTime(), $timeslot->getEndTime(), "hm", 60, $timeslot->getSubtract());
if ($timeslot->getSubtract() > 0) {
$now = DateTimeValueLib::now();
echo " <span class='desc'>(" . lang('paused time') . ": " . DateTimeValue::FormatTimeDiff($now, $now, "hm", 60, $timeslot->getSubtract()) .")</span>";
}
?>
</td>
<td align="right">
<?php if(count($options)) { ?>
<?php echo implode(' | ', $options) ?>
<?php } // if ?>
</td>
</tr>
<?php if ($timeslot->getDescription() != '') {?>
<tr class="timeslot <?php echo $counter % 2 ? 'even' : 'odd'; echo $timeslot->isOpen() ? ' openTimeslot' : '' ?>" ><td></td>
<td colspan=6 style="color:#666666"><?php echo clean($timeslot->getDescription()) ?></td></tr>
<?php } //if ?>
<?php } //if
示例5: total_task_times_csv
function total_task_times_csv($report_data, $columns, $timeslotsArray, $skip_ws = false)
{
//$types = self::get_report_column_types($report->getId());
$filename = str_replace(' ', '_', lang('task time report')) . date('_YmdHis');
header('Expires: 0');
header('Cache-control: private');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header('Content-disposition: attachment; filename=' . $filename . '.csv');
// titles
$titles = lang('date') . ";" . lang('title') . ";" . lang('description') . ";" . lang('user') . ";" . lang('time') . ";";
if (array_var($report_data, 'show_billing', false)) {
$titles .= lang('billing') . ";";
}
foreach ($columns as $id => $pos) {
if ($pos == 0) {
continue;
}
if (!is_numeric($id)) {
$col_name = lang("field ProjectTasks " . $id);
} else {
$cp = CustomProperties::getCustomProperty($id);
$col_name = $cp->getName();
}
$titles .= $col_name . ";";
}
$titles = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($titles, ENT_COMPAT));
echo "{$titles}\n";
// data
foreach ($timeslotsArray as $tsRow) {
$ts = $tsRow["ts"];
if ($skip_ws && $ts->getObjectManager() == 'Projects') {
continue;
}
$to_print = format_date($ts->getStartTime()) . ";";
if ($ts->getObject() instanceof ProjectTask) {
$to_print .= $ts->getObject()->getTitle() . ";";
$to_print .= $ts->getObject()->getText() . ";";
} else {
if ($ts->getObject() instanceof Project) {
$ws_name = lang('workspace') . ' ' . clean($ts->getObject()->getName());
$to_print .= "{$ws_name};;";
} else {
$to_print .= ";;";
}
}
$to_print .= clean(Users::getUserDisplayName($ts->getUserId())) . ";";
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now()) . ";";
$to_print .= DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) . ";";
if (array_var($report_data, 'show_billing', false)) {
$to_print .= config_option('currency_code', '$') . " " . $ts->getFixedBilling();
}
// other columns
foreach ($columns as $id => $pos) {
if ($pos == 0) {
continue;
}
if ($ts->getObject() instanceof ProjectTask) {
if (!is_numeric($id)) {
$col_value = self::format_value_to_print($id, $ts->getObject()->getColumnValue($id), $ts->getObject()->manager()->getColumnType($id), $ts->getObject()->getObjectManagerName());
} else {
$cp = CustomProperties::getCustomProperty($id);
$cpv = CustomPropertyValues::getCustomPropertyValue($ts->getObject()->getId(), $cp->getId());
if ($cpv instanceof CustomPropertyValue) {
$col_value = self::format_value_to_print($cp->getName(), $cpv->getValue(), $cp->getOgType(), $ts->getObject()->getObjectManagerName());
} else {
$col_value = "";
}
}
} else {
$col_value = "";
}
$to_print .= $col_value . ";";
}
$to_print = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($to_print, ENT_COMPAT));
echo "{$to_print}\n";
}
die;
}
示例6: getArrayInfo
static function getArrayInfo($raw_data, $full = false){
if(config_option("wysiwyg_tasks")){
if($raw_data['type_content'] == "text"){
$desc = nl2br(htmlspecialchars($raw_data['text']));
}else{
$desc = purify_html(nl2br($raw_data['text']));
}
}else{
if($raw_data['type_content'] == "text"){
$desc = htmlspecialchars($raw_data['text']);
}else{
$desc = html_to_text(html_entity_decode(nl2br($raw_data['text']), null, "UTF-8"));
}
}
$member_ids = ObjectMembers::instance()->getCachedObjectMembers($raw_data['id']);
$tmp_task = new ProjectTask();
$tmp_task->setObjectId($raw_data['id']);
$tmp_task->setId($raw_data['id']);
$tmp_task->setAssignedToContactId($raw_data['assigned_to_contact_id']);
$result = array(
'id' => $raw_data['id'],
't' => $raw_data['name'],
'desc' => $desc,
'members' => $member_ids,
'c' => strtotime($raw_data['created_on']),
'cid' => (int)$raw_data['created_by_id'],
'otype' => $raw_data['object_subtype'],
'pc' => (int)$raw_data['percent_completed'],
'memPath' => str_replace('"',"'", str_replace("'", "\'", json_encode($tmp_task->getMembersToDisplayPath($member_ids))))
);
if ($full) {
$result['description'] = $raw_data['text'];
}
$result['mas'] = (int)array_var($raw_data, 'multi_assignment');
if ($raw_data['completed_by_id'] > 0) {
$result['s'] = 1;
}
if ($raw_data['parent_id'] > 0) {
$result['pid'] = (int)$raw_data['parent_id'];
}
//if ($this->getPriority() != 200)
$result['pr'] = (int)$raw_data['priority'];
if ($raw_data['milestone_id'] > 0) {
$result['mid'] = (int)$raw_data['milestone_id'];
}
if ($raw_data['assigned_to_contact_id'] > 0) {
$result['atid'] = (int)$raw_data['assigned_to_contact_id'];
}
$result['atName'] = $tmp_task->getAssignedToName();
if ($raw_data['completed_by_id'] > 0) {
$result['cbid'] = (int)$raw_data['completed_by_id'];
$result['con'] = strtotime($raw_data['completed_on']);;
}
if ($raw_data['due_date'] != EMPTY_DATETIME) {
$result['dd'] = strtotime($raw_data['due_date']) + logged_user()->getTimezone() * 3600;
$result['udt'] = $raw_data['use_due_time'] ? 1 : 0;
}
if ($raw_data['start_date'] != EMPTY_DATETIME) {
$result['sd'] = strtotime($raw_data['start_date']) + logged_user()->getTimezone() * 3600;
$result['ust'] = $raw_data['use_start_time'] ? 1 : 0;
}
$time_estimate = $raw_data['time_estimate'];
$result['te'] = $raw_data['time_estimate'];
if ($time_estimate > 0) $result['et'] = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60) ;
$result['tz'] = logged_user()->getTimezone() * 3600;
$ot = $tmp_task->getOpenTimeslots();
if ($ot){
$users = array();
$time = array();
$paused = array();
foreach ($ot as $t){
if (!$t instanceof Timeslot) continue;
$time[] = $t->getSeconds();
$users[] = $t->getContactId();
$paused[] = $t->isPaused()?1:0;
if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) {
$result['wpt'] = $t->getPausedOn()->getTimestamp();
}
}
$result['wt'] = $time;
$result['wid'] = $users;
$result['wp'] = $paused;
}
if ($raw_data['repeat_forever'] > 0 || $raw_data['repeat_num'] > 0 || $raw_data['repeat_end'] != EMPTY_DATETIME) {
//.........这里部分代码省略.........
示例7: lang
<table>
<tr>
<td><div style="font-weight:bold"><?php echo lang('percent completed'). ': '?></div></td>
<td><?php echo taskPercentCompletedBar($task_list) //$task_list->getPercentCompleted() . "%"; ?></td>
</tr>
<?php if ($time_estimate > 0) {?>
<tr><td>
<div style="font-weight:bold"><?php echo lang('estimated time'). ': '?></div></td><td>
<?php echo DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60) ?></td></tr>
<?php } ?>
<?php if ($total_minutes > 0 && can_manage_time(logged_user())) {?>
<tr><td><div style="font-weight:bold"><?php echo lang('total time worked'). ': ' ?></div></td><td>
<span style="font-size:120%;font-weight:bold;<?php echo ($time_estimate > 0 && $total_minutes > $time_estimate) ? 'color:#FF0000':'' ?>">
<?php echo DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($total_minutes * 60), 'hm', 60) ?>
</span></td></tr>
<?php } ?>
</table>
<div class="desc"><?php echo lang('percent completed detail', isset($counter) ? $counter : '0') ?></div>
<?php } ?>
<?php if ($task_list->isRepetitive()) { ?>
<div style="font-weight:bold">
<?php
echo '<br>' . lang('this task repeats'). ' ';
if ($task_list->getRepeatForever()) echo lang('forever');
else if ($task_list->getRepeatNum()) echo lang('n times', $task_list->getRepeatNum());
else if ($task_list->getRepeatEnd()) echo lang('until x', format_date($task_list->getRepeatEnd()));
示例8: getDimensionGroups
private function getDimensionGroups($dim_id, $conditions, $show_more_conditions, $list_subtasks_cond)
{
$groupId = $show_more_conditions['groupId'];
$start = $show_more_conditions['start'];
$limit = $show_more_conditions['limit'];
$join_params['join_type'] = "INNER ";
$join_params['table'] = TABLE_PREFIX . "object_members";
$join_params['jt_field'] = "object_id";
$join_params['e_field'] = "object_id";
//this condition is used when we want show more task for a member
$member_more_cond = "";
if (!is_null($groupId) && $groupId > 0) {
$member_more_cond = " AND `jt`.`member_id` = {$groupId}";
}
$join_params['on_extra'] = " INNER JOIN `" . TABLE_PREFIX . "members` `jtm` ON `jt`.`member_id` = `jtm`.`id` AND `jtm`.`dimension_id` = {$dim_id} AND `jt`.`is_optimization` = 0 {$member_more_cond}";
if (is_null($groupId) || $groupId > 0) {
$groups = ProjectTasks::instance()->listing(array("select_columns" => array("`jtm`.`id` AS group_id ", "`jtm`.`name` AS group_name ", "`jtm`.`color` AS group_icon ", "SUM(time_estimate) AS group_time_estimate ", "COUNT(`e`.`object_id`) AS total"), "extra_conditions" => $conditions . $list_subtasks_cond, "group_by" => " `jtm`.`id`", "join_params" => $join_params, "count_results" => false, "raw_data" => true))->objects;
foreach ($groups as $key => $group) {
if (!is_null($groupId) && $group['group_id'] != $groupId) {
continue;
}
$group_conditions = " AND `jtm`.`id` = " . $group['group_id'];
$tasks_in_group = $this->getTasksInGroup($conditions . $group_conditions . $list_subtasks_cond, $start, $limit, $join_params);
$groups[$key]['root_total'] = $tasks_in_group['total_roots_tasks'];
$groups[$key]['group_tasks'] = $tasks_in_group['tasks'];
//group totals
$group_time_estimate = ProjectTasks::instance()->listing(array("select_columns" => array("SUM(time_estimate) AS group_time_estimate "), "extra_conditions" => $conditions . $group_conditions, "join_params" => $join_params, "count_results" => false, "raw_data" => true))->objects;
$group_time_estimate = $group_time_estimate[0]['group_time_estimate'];
$join_on_extra = " INNER JOIN `" . TABLE_PREFIX . "object_members` `jtom` ON `e`.`object_id` = `jtom`.`object_id` ";
$join_on_extra .= " INNER JOIN `" . TABLE_PREFIX . "members` `jtm` ON `jtom`.`member_id` = `jtm`.`id` AND `jtm`.`dimension_id` = {$dim_id} AND `jtom`.`is_optimization` = 0";
$totals = $this->getGroupTotals($conditions . $group_conditions, $group_time_estimate, $join_on_extra);
foreach ($totals as $total_key => $total) {
$groups[$key][$total_key] = $total;
}
$groups[$key]['group_icon'] = "ico-color" . $group['group_icon'];
}
}
//START unknown group
if (is_null($groupId) || $groupId == 0) {
$unknown_group['group_id'] = 0;
$dimension = Dimensions::getDimensionById($dim_id);
$unknown_group['group_name'] = lang('without a member') . " " . lang($dimension->getCode());
$join_params['join_type'] = "LEFT ";
$join_params['on_extra'] = " LEFT JOIN `" . TABLE_PREFIX . "members` `jtm` ON `jt`.`member_id` = `jtm`.`id` AND `jtm`.`dimension_id` = {$dim_id} AND `jt`.`is_optimization` = 0";
$tasks_in_group = $this->getTasksInGroup($conditions . $list_subtasks_cond, $start, $limit, $join_params, " `e`.`object_id` HAVING SUM(`jtm`.`dimension_id`) is null");
$unknown_group['root_total'] = $tasks_in_group['total_roots_tasks'];
$unknown_group['group_tasks'] = $tasks_in_group['tasks'];
$unknown_group_totals = ProjectTasks::instance()->listing(array("select_columns" => array("time_estimate"), "extra_conditions" => $conditions, "group_by" => " `e`.`object_id` HAVING SUM(`jtm`.`dimension_id`) is null", "join_params" => $join_params, "count_results" => false, "raw_data" => true, "query_wraper_start" => "SELECT count(*) AS total , SUM(time_estimate) AS group_time_estimate FROM (", "query_wraper_end" => " ) AS temporal "))->objects;
$unknown_group['total'] = $unknown_group_totals[0]['total'];
$unknown_group['group_time_estimate'] = $unknown_group_totals[0]['group_time_estimate'];
$unknown_group['estimatedTime'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($unknown_group['group_time_estimate'] * 60), 'hm', 60));
if (count($unknown_group['tasks']) > 0) {
$groups[] = $unknown_group;
}
}
//END unknown group
return $groups;
}
示例9: gen_id
<?php $genid = gen_id();
?>
<form class="internalForm" action="<?php echo $timeslot_form_timeslot->getCloseUrl() ?>" method="post" enctype="multipart/form-data">
<?php if ($timeslot_form_timeslot->isPaused()){ ?>
<div class="og-timeslot-work-paused" style="margin-top:6px;">
<?php echo lang('paused timeslot message', DateTimeValue::FormatTimeDiff($timeslot_form_timeslot->getStartTime(), $timeslot_form_timeslot->getPausedOn(), "hm", 60, $timeslot_form_timeslot->getSubtract())) ?>
<span style="padding-left:15px;"><?php echo lang('time since pause') ?>: <span id="<?php echo $genid ?>timespan"></span></span></div>
<script>
og.startClock('<?php echo $genid ?>', <?php echo $timeslot_form_timeslot->getSecondsSincePause() ?>);
</script>
<?php } else { ?>
<div class="og-timeslot-work-started" style="margin-top:6px;"><?php echo lang('open timeslot message') ?> <span id="<?php echo $genid ?>timespan"></span></div>
<script>
og.startClock('<?php echo $genid ?>', <?php echo $timeslot_form_timeslot->getSeconds() ?>);
</script>
<?php } ?>
<div class="formAddCommentText">
<?php echo label_tag(lang("end work description"),"closeTimeslotDescription",false) ?>
<?php echo textarea_field("timeslot[description]", '', array('class' => 'short', 'id' => 'closeTimeslotDescription')) ?>
</div>
<?php
if ($timeslot_form_timeslot->isPaused())
echo submit_button(lang('resume work'), '',array('style' => 'margin-right:15px', 'onclick' => 'javascript:this.form.action = "' . $timeslot_form_timeslot->getResumeUrl() . '"'));
else
echo submit_button(lang('pause work'), '',array('style' => 'margin-right:15px', 'onclick' => 'javascript:this.form.action = "' . $timeslot_form_timeslot->getPauseUrl() . '"'));
echo submit_button(lang('end work'));?>
示例10: foreach
foreach ($timeslotsArray as $ts) {
$t = $ts['ts'];
if (isset($has_conditions) && $has_conditions && $t->getObjectManager() == 'Projects') {
continue;
}
$sumTime += $t->getMinutes();
$sumBilling += $t->getFixedBilling();
}
}
?>
<tr><td style="text-align: right; border-top: 1px solid #AAA; padding: 10px 0; font-weight: bold;" colspan=<?php
echo $showBillingCol ? $totCols - 1 : $totCols;
?>
>
<div ><?php
echo strtoupper(lang("total")) . ": " . DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($sumTime * 60), "hm", 60);
?>
</div>
</td><?php
if ($showBillingCol) {
?>
<td style="width:30px;padding-left:8px;border-top: 1px solid #AAA;"><div style="text-align: right;padding: 10px 0; font-weight: bold;"><?php
echo config_option('currency_code', '$');
?>
<?php
echo $sumBilling;
?>
</div></td><?php
}
?>
</tr>
示例11: getArrayInfo
static function getArrayInfo($raw_data, $full = false)
{
$desc = "";
if ($full) {
if (config_option("wysiwyg_tasks")) {
if ($raw_data['type_content'] == "text") {
$desc = nl2br(htmlspecialchars($raw_data['text']));
} else {
$desc = purify_html(nl2br($raw_data['text']));
}
} else {
if ($raw_data['type_content'] == "text") {
$desc = htmlspecialchars($raw_data['text']);
} else {
$desc = html_to_text(html_entity_decode(nl2br($raw_data['text']), null, "UTF-8"));
}
}
}
$member_ids = ObjectMembers::instance()->getCachedObjectMembers($raw_data['id']);
$tmp_task = new ProjectTask();
$tmp_task->setObjectId($raw_data['id']);
$tmp_task->setId($raw_data['id']);
$tmp_task->setAssignedToContactId($raw_data['assigned_to_contact_id']);
$result = array('id' => (int) $raw_data['id'], 'name' => $raw_data['name'], 'description' => $desc, 'members' => $member_ids, 'createdOn' => strtotime($raw_data['created_on']), 'createdById' => (int) $raw_data['created_by_id'], 'otype' => $raw_data['object_subtype'], 'percentCompleted' => (int) $raw_data['percent_completed'], 'memPath' => str_replace('"', "'", escape_character(json_encode($tmp_task->getMembersIdsToDisplayPath()))));
if (isset($raw_data['isread'])) {
$result['isread'] = $raw_data['isread'];
}
$result['multiAssignment'] = (int) array_var($raw_data, 'multi_assignment');
if ($raw_data['completed_by_id'] > 0) {
$result['status'] = 1;
}
if ($raw_data['parent_id'] > 0) {
$result['parentId'] = (int) $raw_data['parent_id'];
}
$result['subtasksIds'] = $tmp_task->getSubTasksIds();
//if ($this->getPriority() != 200)
$result['priority'] = (int) $raw_data['priority'];
if ($raw_data['milestone_id'] > 0) {
$result['milestoneId'] = (int) $raw_data['milestone_id'];
}
if ($raw_data['assigned_by_id'] > 0) {
$result['assignedById'] = (int) $raw_data['assigned_by_id'];
}
if ($raw_data['assigned_to_contact_id'] > 0) {
$result['assignedToContactId'] = (int) $raw_data['assigned_to_contact_id'];
}
$result['atName'] = $tmp_task->getAssignedToName();
if ($raw_data['completed_by_id'] > 0) {
$result['completedById'] = (int) $raw_data['completed_by_id'];
$result['completedOn'] = strtotime($raw_data['completed_on']);
}
if ($raw_data['due_date'] != EMPTY_DATETIME) {
$result['useDueTime'] = $raw_data['use_due_time'] ? 1 : 0;
if ($result['useDueTime']) {
$result['dueDate'] = strtotime($raw_data['due_date']) + logged_user()->getTimezone() * 3600;
} else {
$result['dueDate'] = strtotime($raw_data['due_date']);
}
}
if ($raw_data['start_date'] != EMPTY_DATETIME) {
$result['useStartTime'] = $raw_data['use_start_time'] ? 1 : 0;
if ($result['useStartTime']) {
$result['startDate'] = strtotime($raw_data['start_date']) + logged_user()->getTimezone() * 3600;
} else {
$result['startDate'] = strtotime($raw_data['start_date']);
}
}
$time_estimate = $raw_data['time_estimate'];
$result['timeEstimate'] = $raw_data['time_estimate'];
if ($time_estimate > 0) {
$result['timeEstimateString'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60));
}
$result['timeZone'] = logged_user()->getTimezone() * 3600;
$ot = $tmp_task->getOpenTimeslots();
if ($ot) {
$users = array();
$time = array();
$paused = array();
foreach ($ot as $t) {
if (!$t instanceof Timeslot) {
continue;
}
$time[] = $t->getSeconds();
$users[] = $t->getContactId();
$paused[] = $t->isPaused() ? 1 : 0;
if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) {
$result['pauseTime'] = $t->getPausedOn()->getTimestamp();
}
}
$result['workingOnTimes'] = $time;
$result['workingOnIds'] = $users;
$result['workingOnPauses'] = $paused;
}
$total_minutes = $tmp_task->getTotalMinutes();
if ($total_minutes > 0) {
$result['worked_time'] = $total_minutes;
$result['worked_time_string'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($total_minutes * 60), 'hm', 60));
} else {
$result['worked_time'] = 0;
}
//.........这里部分代码省略.........
示例12: getArrayInfo
/**
* End task templates
*/
function getArrayInfo($full = false)
{
if (config_option("wysiwyg_tasks")) {
if ($this->getTypeContent() == "text") {
$desc = nl2br(htmlspecialchars($this->getText()));
} else {
$desc = purify_html(nl2br($this->getText()));
}
} else {
if ($this->getTypeContent() == "text") {
$desc = htmlspecialchars($this->getText());
} else {
$desc = html_to_text(html_entity_decode(nl2br($this->getText()), null, "UTF-8"));
}
}
$result = array('id' => $this->getId(), 't' => $this->getObjectName(), 'desc' => $desc, 'members' => $this->getMemberIds(), 'c' => $this->getCreatedOn() instanceof DateTimeValue ? $this->getCreatedOn()->getTimestamp() : 0, 'cid' => $this->getCreatedById(), 'otype' => $this->getObjectSubtype(), 'percentCompleted' => $this->getPercentCompleted(), 'memPath' => str_replace('"', "'", str_replace("'", "\\'", json_encode($this->getMembersToDisplayPath()))));
if ($full) {
$result['description'] = $this->getText();
}
$result['multiAssignment'] = $this->getColumnValue('multi_assignment', 0);
if ($this->isCompleted()) {
$result['s'] = 1;
}
if ($this->getParentId() > 0) {
$result['pid'] = $this->getParentId();
}
//if ($this->getPriority() != 200)
$result['pr'] = $this->getPriority();
if ($this->getMilestoneId() > 0) {
$result['mid'] = $this->getMilestoneId();
}
if ($this->getAssignedToContactId() > 0) {
$result['atid'] = $this->getAssignedToContactId();
}
$result['atName'] = $this->getAssignedToName();
if ($this->getCompletedById() > 0) {
$result['cbid'] = $this->getCompletedById();
$result['con'] = $this->getCompletedOn()->getTimestamp();
}
if ($this->getDueDate() instanceof DateTimeValue) {
$result['dd'] = $this->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600;
$result['udt'] = $this->getUseDueTime() ? 1 : 0;
}
if ($this->getStartDate() instanceof DateTimeValue) {
$result['sd'] = $this->getStartDate()->getTimestamp() + logged_user()->getTimezone() * 3600;
$result['ust'] = $this->getUseStartTime() ? 1 : 0;
}
$time_estimate = $this->getTimeEstimate();
$result['TimeEstimate'] = $this->getTimeEstimate();
if ($time_estimate > 0) {
$result['estimatedTime'] = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60);
}
$result['tz'] = logged_user()->getTimezone() * 3600;
$ot = $this->getOpenTimeslots();
if ($ot) {
$users = array();
$time = array();
$paused = array();
foreach ($ot as $t) {
$time[] = $t->getSeconds();
$users[] = $t->getContactId();
$paused[] = $t->isPaused() ? 1 : 0;
if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) {
$result['wpt'] = $t->getPausedOn()->getTimestamp();
}
}
$result['wt'] = $time;
$result['wid'] = $users;
$result['wp'] = $paused;
}
if ($this->isRepetitive()) {
$result['rep'] = 1;
} else {
//I find all those related to the task to find out if the original
$task_related = ProjectTasks::findByRelated($this->getObjectId());
if (!$task_related) {
//is not the original as the original look plus other related
if ($this->getOriginalTaskId() != "0") {
$task_related = ProjectTasks::findByTaskAndRelated($this->getObjectId(), $this->getOriginalTaskId());
}
}
if ($task_related) {
$result['rep'] = 1;
}
}
return $result;
}
示例13: DateTimeValue
">
<?php
echo DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($total_minutes * 60), 'hm', 60);
?>
</span></td></tr>
<?php
}
?>
<tr>
<td><div style="font-weight:bold"><?php
echo lang('pending time') . ': ';
?>
</div></td>
<td><?php
echo DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($pending_time * 60), 'hm', 60);
?>
</td>
</tr>
</table>
<div class="desc"><?php
echo lang('percent completed detail', isset($counter) ? $counter : '0');
?>
</div>
<?php
}
?>
示例14: format_value_to_print
function format_value_to_print($col, $value, $type, $obj_type_id, $textWrapper = '', $dateformat = 'Y-m-d')
{
switch ($type) {
case DATA_TYPE_STRING:
if (preg_match(EMAIL_FORMAT, strip_tags($value))) {
$formatted = strip_tags($value);
} else {
if ($col == 'is_user') {
$formatted = $value == 1 ? lang('yes') : lang('no');
} else {
if (strpos($value, "�") !== false) {
$value = preg_replace('/\\xA0/s', ' ', $value);
}
$value = utf8_safe($value);
$formatted = $textWrapper . $value . $textWrapper;
}
}
break;
case DATA_TYPE_INTEGER:
if ($col == 'priority') {
switch ($value) {
case 100:
$formatted = lang('low priority');
break;
case 200:
$formatted = lang('normal priority');
break;
case 300:
$formatted = lang('high priority');
break;
case 400:
$formatted = lang('urgent priority');
break;
default:
$formatted = clean($value);
}
} elseif ($col == 'time_estimate') {
if ($value > 0) {
$formatted = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($value * 60), 'hm', 60);
} else {
$formatted = clean($value);
}
} else {
$formatted = clean($value);
}
break;
case DATA_TYPE_BOOLEAN:
$formatted = $value == 1 ? lang('yes') : lang('no');
break;
case DATA_TYPE_DATE:
if ($value != 0) {
if (str_ends_with($value, "00:00:00")) {
$dateformat .= " H:i:s";
}
try {
$dtVal = DateTimeValueLib::dateFromFormatAndString($dateformat, $value);
} catch (Exception $e) {
$formatted = $value;
}
if (!isset($formatted)) {
$formatted = format_date($dtVal, null, 0);
}
} else {
$formatted = '';
}
break;
case DATA_TYPE_DATETIME:
if ($value != 0) {
try {
$dtVal = DateTimeValueLib::dateFromFormatAndString("{$dateformat} H:i:s", $value);
} catch (Exception $e) {
$formatted = $value;
}
if ($dtVal instanceof DateTimeValue) {
if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() || $obj_type_id == ProjectTasks::instance()->getObjectTypeId()) {
$dtVal->advance(logged_user()->getTimezone() * 3600, true);
}
if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() && ($col == 'start' || $col == 'duration')) {
$formatted = format_datetime($dtVal);
} else {
$formatted = format_date($dtVal, null, 0);
}
}
} else {
$formatted = '';
}
break;
default:
$formatted = $value;
}
if ($formatted == '') {
$formatted = '--';
}
return $formatted;
}
示例15: getArrayInfo
/**
* End task templates
*/
function getArrayInfo($full = false)
{
if (config_option("wysiwyg_tasks")) {
if ($this->getTypeContent() == "text") {
$desc = nl2br(htmlspecialchars($this->getText()));
} else {
$desc = purify_html(nl2br($this->getText()));
}
} else {
if ($this->getTypeContent() == "text") {
$desc = htmlspecialchars($this->getText());
} else {
$desc = html_to_text(html_entity_decode(nl2br($this->getText()), null, "UTF-8"));
}
}
$member_ids = ObjectMembers::instance()->getCachedObjectMembers($this->getId());
$result = array('id' => $this->getId(), 't' => $this->getObjectName(), 'desc' => $desc, 'members' => $member_ids, 'c' => $this->getCreatedOn() instanceof DateTimeValue ? $this->getCreatedOn()->getTimestamp() : 0, 'cid' => $this->getCreatedById(), 'otype' => $this->getObjectSubtype(), 'pc' => $this->getPercentCompleted(), 'memPath' => str_replace('"', "'", escape_character(json_encode($this->getMembersIdsToDisplayPath()))));
if ($full) {
$result['description'] = $this->getText();
}
$result['mas'] = $this->getColumnValue('multi_assignment', 0);
if ($this->isCompleted()) {
$result['s'] = 1;
}
if ($this->getParentId() > 0) {
$result['pid'] = $this->getParentId();
}
//if ($this->getPriority() != 200)
$result['pr'] = $this->getPriority();
if ($this->getMilestoneId() > 0) {
$result['mid'] = $this->getMilestoneId();
}
if ($this->getAssignedToContactId() > 0) {
$result['atid'] = $this->getAssignedToContactId();
}
$result['atName'] = $this->getAssignedToName();
if ($this->getCompletedById() > 0) {
$result['cbid'] = $this->getCompletedById();
$result['con'] = $this->getCompletedOn()->getTimestamp();
}
if ($this->getDueDate() instanceof DateTimeValue) {
$result['dd'] = $this->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600;
$result['udt'] = $this->getUseDueTime() ? 1 : 0;
}
if ($this->getStartDate() instanceof DateTimeValue) {
$result['sd'] = $this->getStartDate()->getTimestamp() + logged_user()->getTimezone() * 3600;
$result['ust'] = $this->getUseStartTime() ? 1 : 0;
}
$time_estimate = $this->getTimeEstimate();
$result['te'] = $this->getTimeEstimate();
if ($time_estimate > 0) {
$result['et'] = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60);
}
$result['tz'] = logged_user()->getTimezone() * 3600;
$ot = $this->getOpenTimeslots();
if ($ot) {
$users = array();
$time = array();
$paused = array();
foreach ($ot as $t) {
if (!$t instanceof Timeslot) {
continue;
}
$time[] = $t->getSeconds();
$users[] = $t->getContactId();
$paused[] = $t->isPaused() ? 1 : 0;
if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) {
$result['wpt'] = $t->getPausedOn()->getTimestamp();
}
}
$result['wt'] = $time;
$result['wid'] = $users;
$result['wp'] = $paused;
}
if ($this->isRepetitive()) {
$result['rep'] = 1;
}
return $result;
}