![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: vw_logs.php 136 2008-04-04 14:24:17Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/projects/vw_logs.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 global $AppUI, $project_id, $df, $canEdit, $m, $tab; 7 8 // Lets check which cost codes have been used before 9 $q = new DBQuery; 10 $q->addQuery('project_company'); 11 $q->addTable('projects'); 12 $q->addWhere('project_id = ' . (int)$project_id); 13 $company_id = $q->loadResult(); 14 15 $q->addTable('billingcode'); 16 $q->addQuery('billingcode_id, billingcode_name'); 17 $q->addOrder('billingcode_name'); 18 $q->addWhere('billingcode_status = 0'); 19 $q->addWhere('(company_id = 0 OR company_id = ' . (int)$company_id . ')'); 20 $task_log_costcodes = $q->loadHashList(); 21 array_unshift($task_log_costcodes, ''); 22 23 // Show deleted codes separately (at the end) 24 $q->addTable('billingcode'); 25 $q->addQuery('billingcode_id, billingcode_name'); 26 $q->addOrder('billingcode_name'); 27 $q->addWhere('billingcode_status = 1'); 28 $q->addWhere('(company_id = 0 OR company_id = ' . (int)$company_id . ')'); 29 $task_log_costcodes = array_merge($task_log_costcodes, $q->loadHashList()); 30 31 $users = w2PgetUsers(); 32 33 $cost_code = w2PgetParam($_GET, 'cost_code', '0'); 34 35 if (isset($_GET['user_id'])) { 36 $AppUI->setState('ProjectsTaskLogsUserFilter', w2PgetParam($_GET, 'user_id', 0)); 37 } 38 $user_id = $AppUI->getState('ProjectsTaskLogsUserFilter') ? $AppUI->getState('ProjectsTaskLogsUserFilter') : 0; 39 40 if (isset($_GET['hide_inactive'])) { 41 $AppUI->setState('ProjectsTaskLogsHideArchived', true); 42 } else { 43 $AppUI->setState('ProjectsTaskLogsHideArchived', false); 44 } 45 $hide_inactive = $AppUI->getState('ProjectsTaskLogsHideArchived'); 46 47 if (isset($_GET['hide_complete'])) { 48 $AppUI->setState('ProjectsTaskLogsHideComplete', true); 49 } else { 50 $AppUI->setState('ProjectsTaskLogsHideComplete', false); 51 } 52 $hide_complete = $AppUI->getState('ProjectsTaskLogsHideComplete'); 53 54 ?> 55 <script language="JavaScript"> 56 <?php 57 // security improvement: 58 // some javascript functions may not appear on client side in case of user not having write permissions 59 // else users would be able to arbitrarily run 'bad' functions 60 if ($canEdit) { 61 ?> 62 function delIt2(id) { 63 if (confirm( '<?php echo $AppUI->_('doDelete', UI_OUTPUT_JS) . ' ' . $AppUI->_('Task Log', UI_OUTPUT_JS) . '?'; ?>' )) { 64 document.frmDelete2.task_log_id.value = id; 65 document.frmDelete2.submit(); 66 } 67 } 68 <?php } ?> 69 </script> 70 <table border="0" cellpadding="2" cellspacing="1" width="100%" class="std"> 71 <form name="frmFilter" action="./index.php" method="get"> 72 <tr> 73 <td width="98%"> </td> 74 <td width="1%" nowrap="nowrap"><input type="checkbox" name="hide_inactive" id="hide_inactive" <?php echo $hide_inactive ? 'checked="checked"' : '' ?> onchange="document.frmFilter.submit()" /></td><td width="1%" nowrap="nowrap"><label for="hide_inactive"><?php echo $AppUI->_('Hide Inactive') ?></label></td> 75 <td width="1%" nowrap="nowrap"><input type="checkbox" name="hide_complete" id="hide_complete" <?php echo $hide_complete ? 'checked="checked"' : '' ?> onchange="document.frmFilter.submit()" /></td><td width="1%" nowrap="nowrap"><label for="hide_complete"><?php echo $AppUI->_('Hide 100% Complete') ?></label></td> 76 <td width="1%" nowrap="nowrap"><?php echo $AppUI->_('User Filter') ?></td> 77 <td width="1%"><?php echo arraySelect($users, 'user_id', 'size="1" class="text" id="medium" onchange="document.frmFilter.submit()"', $user_id) ?></td> 78 <td width="1%" nowrap="nowrap"><?php echo $AppUI->_('Cost Code Filter') ?></td> 79 <td width="1%"><?php echo arraySelect($task_log_costcodes, 'cost_code', 'size="1" class="text" onchange="document.frmFilter.submit()"', $cost_code) ?></td> 80 </tr> 81 <input type="hidden" name="m" value="projects"/> 82 <input type="hidden" name="a" value="view"/> 83 <input type="hidden" name="project_id" value="<?php echo $project_id ?>"/> 84 <input type="hidden" name="tab" value="<?php echo $tab ?>"/> 85 </form> 86 </table> 87 <table border="0" cellpadding="2" cellspacing="1" width="100%" class="tbl"> 88 <form name="frmDelete2" action="./index.php?m=tasks" method="post"> 89 <input type="hidden" name="dosql" value="do_updatetask" /> 90 <input type="hidden" name="del" value="1" /> 91 <input type="hidden" name="task_log_id" value="0" /> 92 </form> 93 <tr> 94 <th></th> 95 <th><?php echo $AppUI->_('Date'); ?></th> 96 <th width="100"><?php echo $AppUI->_('Summary'); ?></th> 97 <th width="100"><?php echo $AppUI->_('User'); ?></th> 98 <th width="100"><?php echo $AppUI->_('Hours'); ?></th> 99 <th width="100"><?php echo $AppUI->_('Cost Code'); ?></th> 100 <th width="100%"><?php echo $AppUI->_('Comments'); ?></th> 101 <th></th> 102 </tr> 103 <?php 104 // Winnow out the tasks we are not allowed to view. 105 $perms = &$AppUI->acl(); 106 $canDelete = $perms->checkModule('task_log', 'delete'); 107 $project = &new CProject; 108 109 // Pull the task comments 110 $q = new DBQuery; 111 $q->addTable('task_log'); 112 $q->addQuery('task_log.*, user_username, task_id'); 113 $q->addQuery('billingcode_name as task_log_costcode'); 114 $q->addQuery('CONCAT(contact_first_name, \' \', contact_last_name) AS real_name'); 115 $q->addJoin('users', 'u', 'user_id = task_log_creator'); 116 $q->addJoin('tasks', 't', 'task_log_task = t.task_id'); 117 $q->addJoin('contacts', 'ct', 'contact_id = user_contact'); 118 $q->addJoin('billingcode', 'b', 'task_log.task_log_costcode = billingcode_id'); 119 //already included bY the setAllowedSQL function 120 //$q->addJoin('projects', 'p', 'task_project = p.project_id'); 121 $q->addWhere('task_project = ' . (int)$project_id); 122 if ($user_id > 0) { 123 $q->addWhere('task_log_creator=' . $user_id); 124 } 125 if ($hide_inactive) { 126 $q->addWhere('task_status>=0'); 127 } 128 if ($hide_complete) { 129 $q->addWhere('task_percent_complete < 100'); 130 } 131 if ($cost_code != '0') { 132 $q->addWhere('task_log_costcode = \'' . $cost_code . '\''); 133 } 134 $q->addOrder('task_log_date'); 135 $project->setAllowedSQL($AppUI->user_id, $q, 'task_project'); 136 $logs = $q->loadList(); 137 138 $s = ''; 139 $hrs = 0; 140 $canEdit = $perms->checkModule('task_log', 'edit'); 141 foreach ($logs as $row) { 142 $task_log_date = intval($row['task_log_date']) ? new CDate($row['task_log_date']) : null; 143 144 $s .= '<tr bgcolor="white" valign="top"><td>'; 145 if ($canEdit) { 146 $s .= '<a href="?m=tasks&a=view&task_id=' . $row['task_id'] . '&tab=1&task_log_id=' . $row['task_log_id'] . '">' . w2PshowImage('icons/stock_edit-16.png', 16, 16, '') . "\n\t\t</a>"; 147 } 148 $s .= '</td><td nowrap="nowrap">' . ($task_log_date ? $task_log_date->format($df) : '-') . '</td>'; 149 $s .= '<td width="30%"><a href="?m=tasks&a=view&task_id=' . $row['task_id'] . '&tab=0">' . $row['task_log_name'] . '</a></td>'; 150 $s .= '<td width="100">' . $row['real_name'] . '</td>'; 151 $s .= '<td width="100" align="right">' . sprintf('%.2f', $row['task_log_hours']) . '</td>'; 152 $s .= '<td width="100">' . $row['task_log_costcode'] . '</td><td>'; 153 154 // dylan_cuthbert: auto-transation system in-progress, leave these lines 155 $transbrk = "\n[translation]\n"; 156 $descrip = str_replace("\n", '<br />', $row['task_log_description']); 157 $tranpos = strpos($descrip, str_replace("\n", '<br />', $transbrk)); 158 if ($tranpos === false) { 159 $s .= $descrip; 160 } else { 161 $descrip = substr($descrip, 0, $tranpos); 162 $tranpos = strpos($row['task_log_description'], $transbrk); 163 $transla = substr($row['task_log_description'], $tranpos + strlen($transbrk)); 164 $transla = trim(str_replace("'", '"', $transla)); 165 $s .= $descrip . '<div style="font-weight: bold; text-align: right"><a title="' . $transla . '" class="hilite">[' . $AppUI->_('translation') . ']</a></div>'; 166 } 167 // end auto-translation code 168 169 $s .= '</td><td>'; 170 if ($canDelete) { 171 $s .= '<a href="javascript:delIt2(' . $row['task_log_id'] . ');" title="' . $AppUI->_('delete log') . '">' . w2PshowImage('icons/stock_delete-16.png', 16, 16, '') . '</a>'; 172 } 173 $s .= '</td></tr>'; 174 $hrs += (float)$row['task_log_hours']; 175 } 176 $s .= '<tr bgcolor="white" valign="top">'; 177 $s .= '<td colspan="4" align="right">' . $AppUI->_('Total Hours') . ' =</td>'; 178 $s .= '<td align="right">' . sprintf('%.2f', $hrs) . '</td>'; 179 $s .= '</tr>'; 180 echo $s; 181 ?> 182 </table>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |