![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: stats.php 114 2008-03-21 16:19:46Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/reports/reports/stats.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $q = new DBQuery; 7 $q->addTable('projects'); 8 $q->addQuery('*'); 9 $q->addJoin('tasks', '', 'task_project = project_id'); 10 11 if (!empty($project_id)) { 12 $q->addWhere('project_id = ' . (int)$project_id); 13 } 14 $obj = &new CTask; 15 $allowedTasks = $obj->getAllowedSQL($AppUI->user_id); 16 if (count($allowedTasks)) { 17 $obj->getAllowedSQL($AppUI->user_id, $q); 18 } 19 $all_tasks = $q->loadList(); 20 $q->clear(); 21 22 $q = new DBQuery; 23 $q->addTable('projects'); 24 $q->addQuery('*, round(sum(task_log_hours),2) as work'); 25 $q->addJoin('tasks', '', 'task_project = project_id'); 26 $q->addJoin('user_tasks', '', 'user_tasks.task_id = tasks.task_id'); 27 $q->addJoin('users', '', 'user_tasks.user_id = users.user_id'); 28 $q->addJoin('contacts', '', 'users.user_contact = contact_id'); 29 $q->addJoin('task_log', '', 'task_log_task = tasks.task_id AND task_log_creator = users.user_id'); 30 $q->addWhere('project_active = 1'); 31 if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { 32 $q->addWhere('project_status <> ' . (int)$template_status); 33 } 34 if (!empty($project_id)) { 35 $q->addWhere('project_id = ' . (int)$project_id); 36 } 37 $q->addGroup('tasks.task_id'); 38 $q->addGroup('users.user_id'); 39 $obj = &new CTask; 40 $allowedTasks = $obj->getAllowedSQL($AppUI->user_id); 41 if (count($allowedTasks)) { 42 $obj->getAllowedSQL($AppUI->user_id, $q); 43 } 44 $users_all = $q->loadList(); 45 $q->clear(); 46 47 foreach ($users_all as $user) { 48 $users_per_task[$user['task_id']][] = $user['user_id']; 49 $users[$user['user_id']]['all'][$user['task_id']] = $user; 50 $users[$user['user_id']]['name'] = (!empty($user['contact_first_name'])) ? $user['contact_first_name'] . ' ' . $user['contact_last_name'] : ((!empty($user['user_username'])) ? $user['user_username'] : $user['user_id']); 51 $users[$user['user_id']]['hours'] = 0; 52 $users[$user['user_id']]['completed'] = array(); 53 $users[$user['user_id']]['inprogress'] = array(); 54 $users[$user['user_id']]['pending'] = array(); 55 $users[$user['user_id']]['overdue'] = array(); 56 } 57 58 $tasks['hours'] = 0; 59 $tasks['inprogress'] = array(); 60 $tasks['completed'] = array(); 61 $tasks['pending'] = array(); 62 $tasks['overdue'] = array(); 63 foreach ($all_tasks as $task) { 64 if ($task['task_percent_complete'] == 100) { 65 $tasks['completed'][] = &$task; 66 } else { 67 if ($task['task_end_date'] < date('Y-m-d')) { 68 $tasks['overdue'][] = &$task; 69 } 70 if ($task['task_percent_complete'] == 0) { 71 $tasks['pending'][] = &$task; 72 } else { 73 $tasks['inprogress'][] = &$task; 74 } 75 } 76 77 if (isset($users_per_task[$task['task_id']])) { 78 foreach ($users_per_task[$task['task_id']] as $user) { 79 if ($task['task_percent_complete'] == 100) { 80 $users[$user]['completed'][] = &$task; 81 } else { 82 if ($task['task_end_date'] < date('Y-m-d')) { 83 $users[$user]['overdue'][] = &$task; 84 } 85 if ($task['task_percent_complete'] == 0) { 86 $users[$user]['pending'][] = &$task; 87 } else { 88 $users[$user]['inprogress'][] = &$task; 89 } 90 } 91 92 $users[$user]['hours'] += $users[$user]['all'][$task['task_id']]['work']; 93 $tasks['hours'] += $users[$user]['all'][$task['task_id']]['work']; 94 } 95 } 96 } 97 98 $q = new DBQuery; 99 $q->addTable('files'); 100 $q->addQuery('sum(file_size)'); 101 if ($project_id) { 102 $q->addWhere('file_project = ' . (int)$project_id); 103 } else { 104 $q->addWhere('file_project = 0'); 105 } 106 $q->addGroup('file_project'); 107 $files = $q->loadResult(); 108 $q->clear(); 109 110 $ontime = round(100 * (1 - (count($tasks['overdue']) / count($all_tasks)) - (count($tasks['completed']) / count($all_tasks)))); 111 ?> 112 113 <table width="100%" border="1" cellpadding="0" cellspacing="0" class="tbl"> 114 <tr> 115 <th colspan="3"><?php echo $AppUI->_('Progress Chart (completed/in progress/pending)'); ?></th> 116 </tr> 117 <tr> 118 <td width="<?php echo round(count($tasks['completed']) / count($all_tasks) * 100); ?>%" style="background: springgreen; text-align: center;"><?php echo $AppUI->_('completed'); ?></td> 119 <td width="<?php echo round(count($tasks['inprogress']) / count($all_tasks) * 100); ?>%" style="background: aquamarine; text-align: center;"><?php echo $AppUI->_('in progress'); ?></td> 120 <td width="<?php echo round(count($tasks['pending']) / count($all_tasks) * 100); ?>%" style="background: gold; text-align: center;"><?php echo $AppUI->_('pending'); ?></td> 121 </tr> 122 </table> 123 <br /> 124 125 <table width="100%" border="1" cellpadding="0" cellspacing="0" class="tbl"> 126 <tr> 127 <th colspan="3"><?php echo $AppUI->_('Time Chart (completed/on time/ocerdue)'); ?></td> 128 </tr> 129 <tr> 130 <td width="<?php echo round(count($tasks['completed']) / count($all_tasks) * 100); ?>%" style="background: springgreen; text-align: center;"><?php echo $AppUI->_('completed'); ?></td> 131 <td width="<?php echo $ontime; ?>%" style="background: aquamarine; text-align: center;"><?php echo $AppUI->_('on time'); ?></td> 132 <td width="<?php echo round(count($tasks['overdue']) / count($all_tasks) * 100); ?>%" style="background: tomato; text-align: center;"><?php echo $AppUI->_('overdue'); ?></td> 133 </tr> 134 </table> 135 <br /> 136 137 <table class="tbl"> 138 <tr> 139 <td> 140 <table width="100%" cellspacing="1" cellpadding="4" border="0" class="tbl"> 141 <tr> 142 <th colspan="3"><?php echo $AppUI->_('Current Project Status'); ?></th> 143 </tr> 144 <tr> 145 <th><?php echo $AppUI->_('Status'); ?></th> 146 <th><?php echo $AppUI->_('Task Details'); ?></th> 147 <th>%</th> 148 </tr> 149 <tr> 150 <td nowrap="nowrap"><?php echo $AppUI->_('Complete'); ?>:</td> 151 <td align="right"><?php echo count($tasks['completed']); ?></td> 152 <td align="right"><?php echo round(count($tasks['completed']) / count($all_tasks) * 100); ?>%</td> 153 </tr> 154 <tr> 155 <td nowrap="nowrap"><?php echo $AppUI->_('In Progress'); ?>:</td> 156 <td align="right"><?php echo count($tasks['inprogress']); ?></td> 157 <td align="right"><?php echo round(count($tasks['inprogress']) / count($all_tasks) * 100); ?>%</td> 158 </tr> 159 <tr> 160 <td nowrap="nowrap"><?php echo $AppUI->_('Not Started'); ?>:</td> 161 <td align="right"><?php echo count($tasks['pending']); ?></td> 162 <td align="right"><?php echo round(count($tasks['pending']) / count($all_tasks) * 100); ?>%</td> 163 </tr> 164 <tr> 165 <td nowrap="nowrap"><?php echo $AppUI->_('Past Due'); ?>:</td> 166 <td align="right"><?php echo count($tasks['overdue']); ?></td> 167 <td align="right"><?php echo round(count($tasks['overdue']) / count($all_tasks) * 100); ?>%</td> 168 </tr> 169 <tr> 170 <td><?php echo $AppUI->_('Total'); ?>:</td> 171 <td align="right"><?php echo count($all_tasks); ?></td> 172 <td align="right">100%</td> 173 </tr> 174 </table> 175 <br /> 176 177 <table width="100%" cellspacing="1" cellpadding="4" border="0" class="tbl"> 178 <tr> 179 <th colspan="2"><?php echo $AppUI->_('Project Assignee Details'); ?></th> 180 </tr> 181 <tr> 182 <td><?php echo $AppUI->_('Team Size'); ?>:</td> 183 <td align="right"><?php echo count($users); ?> <?php echo $AppUI->_('users'); ?></td> 184 </tr> 185 </table> 186 <br /> 187 188 <table width="100%" cellspacing="1" cellpadding="4" border="0" class="tbl"> 189 <tr> 190 <th colspan="2"><?php echo $AppUI->_('Document Space Utilized'); ?></th> 191 </tr> 192 <tr> 193 <td><?php echo $AppUI->_('Space Utilized'); ?>:</td> 194 <td align="right" nowrap="nowrap"><?php echo file_size($files); ?></td> 195 </tr> 196 </table> 197 </td> 198 <td width="100%" valign="top"> 199 <table width="100%" cellspacing="1" cellpadding="4" border="0" class="tbl"> 200 <tr> 201 <th><?php echo $AppUI->_('Task Assignee'); ?></th> 202 <th><?php echo $AppUI->_('Pending Tasks'); ?></th> 203 <th><?php echo $AppUI->_('Overdue Tasks'); ?></th> 204 <th><?php echo $AppUI->_('In progress'); ?></th> 205 <th><?php echo $AppUI->_('Completed Tasks'); ?></th> 206 <th><?php echo $AppUI->_('Total Tasks'); ?></th> 207 <th><?php echo $AppUI->_('Hours worked'); ?></th> 208 </tr> 209 <?php foreach ($users as $user => $stats) { ?> 210 <tr> 211 <td><?php echo $stats['name']; ?></td> 212 <td align="right"><?php echo count($stats['pending']); ?></td> 213 <td align="right"><?php echo count($stats['overdue']); ?></td> 214 <td align="right"><?php echo count($stats['inprogress']); ?></td> 215 <td align="right"><?php echo count($stats['completed']); ?></td> 216 <td align="right"><?php echo count($stats['all']); ?></td> 217 <td align="right"><?php echo $stats['hours']; ?> <?php echo $AppUI->_('hours'); ?></td> 218 </tr> 219 <?php } ?> 220 <tr> 221 <td class="highlight"><?php echo $AppUI->_('Total'); ?>:</td> 222 <td align="right" class="highlight"><?php echo count($tasks['pending']); ?></td> 223 <td align="right" class="highlight"><?php echo count($tasks['pending']); ?></td> 224 <td align="right" class="highlight"><?php echo count($tasks['inprogress']); ?></td> 225 <td align="right" class="highlight"><?php echo count($tasks['completed']); ?></td> 226 <td align="right" class="highlight"><?php echo count($all_tasks); ?></td> 227 <td align="right" class="highlight"><?php echo $tasks['hours']; ?> <?php echo $AppUI->_('hours'); ?></td> 228 </tr> 229 </table> 230 </td> 231 </tr> 232 </table>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 03:00:03 2009 | Cross-referenced by PHPXref 0.7 |