Example #1
0
/**
 * Display HTML clickable image
 */
function showIconLink($image, $link, $title = '', $extra = '')
{
    echo createIconLink($image, $link, $title, $extra);
}
Example #2
0
function showtask(&$a, $level = 0, $is_opened = true, $today_view = false)
{
    global $AppUI, $dPconfig, $done, $query_string, $isProjectManager;
    $now = new CDate();
    $show_all_assignees = $dPconfig['show_all_task_assignees'] ? true : false;
    $done[] = $id = $a['task_id'];
    $start_date = intval($a['task_start_date']) ? new CDate($a['task_start_date']) : null;
    $end_date = intval($a['task_end_date']) ? new CDate($a['task_end_date']) : null;
    // prepare coloured highlight of task time information
    $sign = 1;
    $style = '';
    if ($start_date) {
        if (!$end_date) {
            /*
             ** end date calc has been moved to calcEndByStartAndDuration()-function
             ** called from array_csort and tasks.php
             ** perhaps this fallback if-clause could be deleted in the future,
             ** didn't want to remove it shortly before the 2.0.2
             */
            $end_date = new CDate('0000-00-00 00:00:00');
        }
        if ($now->after($start_date) && $a['task_percent_complete'] == 0) {
            $style = 'background-color:#ffeebb';
        } else {
            if ($now->after($start_date) && $a['task_percent_complete'] < 100) {
                $style = 'background-color:#e6eedd';
            }
        }
        if ($now->after($end_date)) {
            $sign = -1;
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if ($a['task_percent_complete'] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    $s = '<tr class="second">';
    // edit icon
    $s .= '<td align="center">';
    if ($isProjectManager || $AppUI->user_id == $a['task_owner']) {
        $s .= '<a href="?m=tasks&a=simpleaddedit&task_id=' . $id . '">' . '<img src="images/edit_task.gif" title="' . $AppUI->_('Edit') . '"></a>';
    } else {
        $s .= '<img src="images/noedit_task.gif" title="' . $AppUI->_('No edit') . '">';
    }
    $s .= '</td>';
    // pinned
    if ($a['task_pinned']) {
        $pin_image = 'green.png';
        $pin_text = 'Unpin task';
    } else {
        $pin_image = 'gray.png';
        $pin_text = 'Pin task';
    }
    $s .= '<td align="center">';
    $s .= createIconLink('images/' . $pin_image, 'js:pinTask(this,' . $id . ')', $pin_text);
    $s .= '</td>';
    $mytask = false;
    $members = $a['task_assigned_users'];
    if (!$isProjectManager && isset($members)) {
        foreach ($members as $u) {
            if ($u['user_id'] == $AppUI->user_id) {
                $mytask = true;
                break;
            }
        }
    }
    // New Log
    if ($a['task_log_problem'] > 0) {
        $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $id . '&tab=0&problem=1">';
        $s .= '<img src="images/problem.gif" title="Problem!">';
        $s .= '</a></td>';
    } else {
        if ($isProjectManager || $mytask) {
            $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $id . '&tab=1">';
            $s .= '<img src="images/add_log.gif" title="Add log">';
            $s .= '</a></td>';
        } else {
            $s .= '<td align="center"><a href="?m=tasks&a=view&task_id=' . $id . '&tab=0">' . '<img src="images/log.gif" title="View log">' . '</a></td>';
        }
    }
    // percent complete
    $s .= '<td align="right">' . intval($a['task_percent_complete']) . '%</td>';
    // priority
    $s .= '<td align="center" nowrap="nowrap">';
    if ($a['task_milestone'] > 0) {
        $s .= '<img src="images/milestone.gif" title="Milestone">';
    } else {
        if ($a['task_priority'] < 0) {
            $s .= '<img src="images/icons/priority-' . -$a['task_priority'] . '.gif">';
        } else {
            if ($a['task_priority'] > 0) {
                $s .= '<img src="images/icons/priority+' . $a['task_priority'] . '.gif">';
            }
        }
    }
    $s .= $a['file_count'] > 0 ? '<img src="images/clip.png">' : '';
    $s .= '</td>';
    // dots
    $s .= '<td width="' . ($today_view ? 50 : 90) . '%">';
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $s .= '<img src="images/corner-dots.gif">';
        } else {
            $s .= '<img src="images/blank.gif" width="16" height="12"  border="0">';
        }
    }
    if ($a['task_milestone'] > 0) {
        $task_name = '<b>' . $a['task_name'] . '</b>';
    } else {
        if ($a['task_dynamic'] == '1') {
            if (!$today_view) {
                $s .= $is_opened ? '<a href="index.php' . $query_string . '&close_task_id=' . $id . '">' . '<img src="images/icons/collapse.gif"/></a>' : '<a href="index.php' . $query_string . '&open_task_id=' . $id . '">' . '<img src="images/icons/expand.gif"/></a>';
            }
            $task_name = '<b><i>' . $a['task_name'] . '</i></b>';
        } else {
            $task_name = $a['task_name'];
        }
    }
    $s .= '&nbsp;<a href="javascript:viewTask(' . $id . ')" title="' . $a['task_description'] . '">' . $task_name . '</a></td>';
    // task owner
    if (!$today_view) {
        $s .= '<td align="center"><a href="javascript:User(' . $a['user_id'] . ').show()">' . $a['user_username'] . '</a></td>';
    }
    if (isset($members)) {
        $tmp = array();
        $s .= '<td align="center" nowrap="nowrap">';
        if ($show_all_assignees) {
            foreach ($members as $u) {
                $tmp[] = '<a href="javascript:User(' . $u['user_id'] . ').show()">' . $u['user_username'] . ' (' . $u['perc_assignment'] . '%)</a>';
            }
            $s .= join(', ', $tmp);
        } else {
            $u = array_shift($members);
            $s .= '<a href="javascript:User(' . $u['user_id'] . ').show()">';
            $s .= $u['user_username'] . ' (' . $u['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                foreach ($members as $u) {
                    $tmp[] = $u['user_username'] . ' [' . $u['perc_assignment'] . '%]';
                }
                $sid = "'users_" . $id . "'";
                $s .= '&nbsp;<a href="#" onclick="Control(' . $sid . ').toggle()" title="' . join(",\n", $tmp) . '">' . '(+' . ($a['assignee_count'] - 1) . ')</a>';
                $s .= '<span id=' . $sid . '" style="display: none">';
                foreach ($members as $u) {
                    $s .= '<br/><a href="javascript:User(' . $u['user_id'] . ').show()">';
                    $s .= $u['user_username'] . ' (' . $u['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
        }
        $s .= '</td>';
    } else {
        if (!$today_view) {
            // No users asigned to task
            $s .= '<td align="center">-</td>';
        }
    }
    // duration or milestone
    $duration = intval($a['task_duration']) / intval($dPconfig['daily_working_hours']);
    if ($duration < 3) {
        $duration = $a['task_duration'] . $AppUI->_('h');
        $alt = '';
    } else {
        $duration = ceil($duration) . $AppUI->_('d');
        $alt = ' title="' . $a['task_duration'] . $AppUI->_('h') . '"';
    }
    $s .= '<td align="right" style="' . $style . '; padding-right: 16px"' . $alt . '>' . $duration . '</td>';
    $df = $AppUI->getPref('SHDATEFORMAT') . ' ' . $AppUI->getPref('TIMEFORMAT');
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df) : '-') . '</td>';
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df) : '-') . '</td>';
    if ($today_view) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . $a['task_due_in'] . '</td>';
    }
    echo $s;
}