![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: links_tasks.php 187 2008-07-21 10:17:07Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/calendar/links_tasks.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 /** 7 * Sub-function to collect tasks within a period 8 * 9 * @param Date the starting date of the period 10 * @param Date the ending date of the period 11 * @param array by-ref an array of links to append new items to 12 * @param int the length to truncate entries by 13 * @param int the company id to filter by 14 * @author Andrew Eddie <eddieajau@users.sourceforge.net> 15 */ 16 function getTaskLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $company_id = 0, $minical = false) { 17 global $a, $AppUI, $w2Pconfig; 18 $tasks = CTask::getTasksForPeriod($startPeriod, $endPeriod, $company_id, 0); 19 20 $durnTypes = w2PgetSysVal('TaskDurationType'); 21 $df = $AppUI->getPref('SHDATEFORMAT'); 22 $tf = $AppUI->getPref('TIMEFORMAT'); 23 24 $link = array(); 25 $sid = 3600 * 24; 26 // assemble the links for the tasks 27 28 foreach ($tasks as $row) { 29 // the link 30 $link['href'] = '?m=tasks&a=view&task_id=' . $row['task_id']; 31 //$link['alt'] = $row['project_name'].":\n".$row['task_name']; 32 $link['task'] = true; 33 34 // the link text 35 if (strlen($row['task_name']) > $strMaxLen) { 36 $row['short_name'] = substr($row['task_name'], 0, $strMaxLen) . '...'; 37 } else { 38 $row['short_name'] = $row['task_name']; 39 } 40 41 $link['text'] = '<span style="color:' . bestColor($row['color']) . ';background-color:#' . $row['color'] . '">' . $row['short_name'] . ($row['task_milestone'] ? ' ' . w2PshowImage('icons/milestone.gif') : '') . '</span>'; 42 43 // determine which day(s) to display the task 44 $start = new CDate($row['task_start_date']); 45 $end = $row['task_end_date'] ? new CDate($row['task_end_date']) : null; 46 $durn = $row['task_duration']; 47 $durnType = $row['task_duration_type']; 48 49 if (($start->after($startPeriod) || $start->equals($startPeriod)) && ($start->before($endPeriod) || $start->equals($endPeriod)) && ($start->dateDiff($end))) { 50 if ($minical) { 51 $temp = array('task' => true); 52 } else { 53 $temp = $link; 54 //$temp['alt'] = "START [".$row['task_duration'].' '.$AppUI->_( $durnTypes[$row['task_duration_type']] )."]\n".$link['alt']; 55 if ($a != 'day_view') { 56 $temp['text'] = w2PtoolTip($row['task_name'], getTaskTooltip($row['task_id'], true, false), true) . w2PshowImage('block-start-16.png') . $start->format($tf) . ' ' . $temp['text'] . w2PendTip(); 57 } 58 } 59 $links[$start->format(FMT_TIMESTAMP_DATE)][] = $temp; 60 } 61 if ($end && $end->after($startPeriod) && $end->before($endPeriod) && $start->before($end) && ($start->dateDiff($end))) { 62 if ($minical) { 63 $temp = array('task' => true); 64 } else { 65 $temp = $link; 66 //$temp['alt'] = "FINISH\n".$link['alt']; 67 if ($a != 'day_view') { 68 $temp['text'] = w2PtoolTip($row['task_name'], getTaskTooltip($row['task_id'], false, true), true) . ' ' . $temp['text'] . ' ' . $end->format($tf) . w2PshowImage('block-end-16.png') . w2PendTip(); 69 } 70 } 71 $links[$end->format(FMT_TIMESTAMP_DATE)][] = $temp; 72 73 } 74 if (($start->after($startPeriod) || $start->equals($startPeriod)) && ($end && $end->after($startPeriod) && $end->before($endPeriod) && !($start->dateDiff($end)))) { 75 if ($minical) { 76 $temp = array('task' => true); 77 } else { 78 $temp = $link; 79 //$temp['alt'] = "START [".$row['task_duration'].' '.$AppUI->_( $durnTypes[$row['task_duration_type']] )."]\nFINISH\n".$link['alt']; 80 if ($a != 'day_view') { 81 $temp['text'] = w2PtoolTip($row['task_name'], getTaskTooltip($row['task_id'], true, true), true) . w2PshowImage('block-start-16.png') . $start->format($tf) . ' ' . $temp['text'] . ' ' . $end->format($tf) . w2PshowImage('block-end-16.png') . w2PendTip(); 82 } 83 } 84 $links[$start->format(FMT_TIMESTAMP_DATE)][] = $temp; 85 } 86 // convert duration to days 87 if ($durnType < 24.0) { 88 if ($durn > $w2Pconfig['daily_working_hours']) { 89 $durn /= $w2Pconfig['daily_working_hours']; 90 } else { 91 $durn = 0.0; 92 } 93 } else { 94 $durn *= ($durnType / 24.0); 95 } 96 // fill in between start and finish based on duration 97 // notes: 98 // start date is not in a future month, must be this or past month 99 // start date is counted as one days work 100 // business days are not taken into account 101 $target = $start; 102 $target->addSeconds($durn * $sid); 103 104 if (Date::compare($target, $startPeriod) < 0) { 105 continue; 106 } 107 if (Date::compare($start, $startPeriod) > 0) { 108 $temp = $start; 109 $temp->addSeconds($sid); 110 } else { 111 $temp = $startPeriod; 112 } 113 114 // Optimised for speed, AJD. 115 while (Date::compare($endPeriod, $temp) > 0 && Date::compare($target, $temp) > 0 && ($end == null || $temp->before($end))) { 116 $links[$temp->format(FMT_TIMESTAMP_DATE)][] = $link; 117 $temp->addSeconds($sid); 118 } 119 } 120 } 121 122 function getTaskTooltip($task_id, $starts = false, $ends = false) { 123 global $AppUI; 124 125 if (!$task_id) { 126 return ''; 127 } 128 129 $df = $AppUI->getPref('SHDATEFORMAT'); 130 $tf = $AppUI->getPref('TIMEFORMAT'); 131 132 $obj = new CTask(); 133 134 // load the record data 135 $q = new DBQuery; 136 $q->addTable('tasks', 't'); 137 $q->addQuery('task_start_date, task_end_date, task_project, task_type, task_description, task_percent_complete, project_name, company_name'); 138 $q->addJoin('projects', 'p', 'task_project = project_id', 'inner'); 139 $q->addJoin('companies', 'c', 'project_company = company_id', 'inner'); 140 $q->addWhere('task_id = ' . (int)$task_id); 141 $row = $q->loadHash(); 142 $q->clear(); 143 144 // load the event types 145 $types = w2PgetSysVal('TaskType'); 146 147 $obj->task_id = $task_id; 148 $assigned = $obj->getAssigned(); 149 150 $start_date = $row['task_start_date'] ? new CDate($row['task_start_date']) : null; 151 $end_date = $row['task_end_date'] ? new CDate($row['task_end_date']) : null; 152 // load the record data 153 $task_project = $row['project_name']; 154 $task_company = $row['company_name']; 155 156 $tt = '<table border="0" cellpadding="0" cellspacing="0" width="96%">'; 157 $tt .= '<tr>'; 158 $tt .= ' <td valign="top" width="50%">'; 159 $tt .= ' <strong>' . $AppUI->_('Details') . '</strong>'; 160 $tt .= ' <table cellspacing="3" cellpadding="2" width="100%">'; 161 $tt .= ' <tr>'; 162 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Company') . '</td>'; 163 $tt .= ' <td width="100%">' . $task_company . '</td>'; 164 $tt .= ' </tr>'; 165 $tt .= ' <tr>'; 166 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Project') . '</td>'; 167 $tt .= ' <td width="100%">' . $task_project . '</td>'; 168 $tt .= ' </tr>'; 169 $tt .= ' <tr>'; 170 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Type') . '</td>'; 171 $tt .= ' <td width="100%" nowrap="nowrap">' . $AppUI->_($types[$row['task_type']]) . '</td>'; 172 $tt .= ' </tr> '; 173 $tt .= ' <tr>'; 174 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Progress') . '</td>'; 175 $tt .= ' <td width="100%" nowrap="nowrap"><strong>' . sprintf("%.1f%%", $row['task_percent_complete']) . '</strong></td>'; 176 $tt .= ' </tr> '; 177 $tt .= ' <tr>'; 178 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Starts') . '</td>'; 179 $tt .= ' <td nowrap="nowrap">' . ($starts ? '<strong>' : '') . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . ($starts ? '</strong>' : '') . '</td>'; 180 $tt .= ' </tr>'; 181 $tt .= ' <tr>'; 182 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Ends') . '</td>'; 183 $tt .= ' <td nowrap="nowrap">' . ($ends ? '<strong>' : '') . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . ($ends ? '</strong>' : '') . '</td>'; 184 $tt .= ' </tr>'; 185 $tt .= ' <tr>'; 186 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Assignees') . '</td>'; 187 $tt .= ' <td nowrap="nowrap">'; 188 if (is_array($assigned)) { 189 $start = false; 190 foreach ($assigned as $user) { 191 if ($start) 192 $tt .= '<br/>'; 193 else 194 $start = true; 195 $tt .= $user; 196 } 197 } 198 $tt .= ' </tr>'; 199 $tt .= ' </table>'; 200 $tt .= ' </td>'; 201 $tt .= ' <td width="50%" valign="top">'; 202 $tt .= ' <strong>' . $AppUI->_('Description') . '</strong>'; 203 $tt .= ' <table cellspacing="0" cellpadding="2" border="0" width="100%">'; 204 $tt .= ' <tr>'; 205 $tt .= ' <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;">'; 206 $tt .= ' ' . w2Phtmlspecialchars($row['task_description']); 207 $tt .= ' </td>'; 208 $tt .= ' </tr>'; 209 $tt .= ' </table>'; 210 $tt .= ' </td>'; 211 $tt .= '</tr>'; 212 $tt .= '</table>'; 213 return $tt; 214 } 215 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 7 03:00:01 2009 | Cross-referenced by PHPXref 0.7 |