?> <th nowrap="nowrap"> <!-- <a href="?m=departments&orderby=<?php echo $fieldList[$index]; ?> " class="hdr">--> <?php echo $AppUI->_($fieldNames[$index]); ?> <!-- </a>--> </th><?php } ?> </tr> <?php if (count($depts)) { $htmlHelper = new w2p_Output_HTMLHelper($AppUI); foreach ($depts as $row) { echo '<tr>'; $htmlHelper->stageRowData($row); //TODO: how do we tweak this to get the parent/child relationship to display? foreach ($fieldList as $index => $column) { echo $htmlHelper->createCell($fieldList[$index], $row[$fieldList[$index]], $customLookups); } echo '</tr>'; } } else { echo '<tr><td colspan="' . count($fieldNames) . '">' . $AppUI->_('No data available') . '</td></tr>'; } ?> </table>
function showtask_pd_ed(&$arr, $level = 0, $today_view = false) { global $AppUI, $w2Pconfig, $done, $userAlloc, $showEditCheckbox; global $task_access, $PROJDESIGN_CONFIG, $m, $expanded; $durnTypes = w2PgetSysVal('TaskDurationType'); //Check for Tasks Access $tmpTask = new CTask(); $tmpTask->load($arr['task_id']); $canAccess = $tmpTask->canAccess(); if (!$canAccess) { return false; } $htmlHelper = new w2p_Output_HTMLHelper($AppUI); $htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT'); $htmlHelper->stageRowData($arr); $types = w2Pgetsysval('TaskType'); $show_all_assignees = $w2Pconfig['show_all_task_assignees'] ? true : false; $done[] = $arr['task_id']; // prepare coloured highlight of task time information $class = w2pFindTaskComplete($arr['task_start_date'], $arr['task_end_date'], $arr['task_percent_complete']); $jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_'; if ($expanded) { $s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')">'; // edit icon } else { $s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')" ' . ($level ? 'style="display:none"' : '') . '>'; // edit icon } $s .= '<td class="data _edit">'; $canEdit = $arr['task_represents_project'] ? false : true; if ($canEdit) { $s .= '<a href="?m=tasks&a=addedit&task_id=' . $arr['task_id'] . '">' . w2PshowImage('icons/pencil.gif', 12, 12) . '</a>'; } $s .= '</td>'; $s .= $htmlHelper->createCell('task_percent_complete', $arr['task_percent_complete']); $s .= $htmlHelper->createCell('task_priority', $arr['task_priority']); $s .= $htmlHelper->createCell('user_task_priority', $arr['user_task_priority']); $s .= $htmlHelper->createCell('other', mb_substr($task_access[$arr['task_access']], 0, 3)); $s .= $htmlHelper->createCell('other', mb_substr($types[$arr['task_type']], 0, 3)); // reminders set $s .= $htmlHelper->createCell('other', $arr['queue_id'] ? 'Yes' : ''); $s .= $htmlHelper->createCell('other', $arr['task_status'] == -1 ? 'Yes' : ''); // add log $s .= '<td align="center" nowrap="nowrap">'; if ($arr['task_dynamic'] != 1 && 0 == $arr['task_represents_project']) { $s .= '<a href="?m=tasks&a=view&tab=1&project_id=' . $arr['task_project'] . '&task_id=' . $arr['task_id'] . '">' . w2PtoolTip('tasks', 'add work log to this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a>'; } $s .= '</td>'; // dots $s .= '<td style="width: ' . ($today_view ? '20%' : '50%') . '" class="data _name">'; for ($y = 0; $y < $level; $y++) { if ($y + 1 == $level) { $image = w2PfindImage('corner-dots.gif', $m); } else { $image = w2PfindImage('shim.gif', $m); } $s .= '<img src="' . $image . '" width="16" height="12" border="0" alt="" />'; } // name link if ($arr['task_description']) { $s .= w2PtoolTip('Task Description', $arr['task_description'], true); } $jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_'; $open_link = '<a href="javascript: void(0);" onclick="selected_task_' . $arr['task_id'] . '.checked=true"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' alt="" /><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_expand" src="' . w2PfindImage('icons/expand.gif', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></a>'; $taskObj = new CTask(); $taskObj->load($arr['task_id']); if (count($taskObj->getChildren())) { $is_parent = true; } else { $is_parent = false; } if ($arr['task_milestone'] > 0) { $s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b>' . $arr['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" alt="" /></td>'; } elseif ($arr['task_dynamic'] == '1' || $is_parent) { $s .= $open_link; if ($arr['task_dynamic'] == '1') { $s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b><i>' . $arr['task_name'] . '</i></b></a></td>'; } else { $s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>'; } } else { $s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>'; } if ($arr['task_description']) { $s .= w2PendTip(); } // task description if ($PROJDESIGN_CONFIG['show_task_descriptions']) { $s .= '<td align="justified">' . $arr['task_description'] . '</td>'; } // task owner $s .= $htmlHelper->createCell('task_owner', $arr['contact_name']); $s .= $htmlHelper->createCell('task_start_datetime', $arr['task_start_date']); // duration or milestone $s .= $htmlHelper->createCell('task_duration', $arr['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$arr['task_duration_type']]), 0, 1)); $s .= $htmlHelper->createCell('task_end_datetime', $arr['task_end_date']); if (isset($arr['task_assigned_users']) && ($assigned_users = $arr['task_assigned_users'])) { $a_u_tmp_array = array(); if ($show_all_assignees) { $s .= '<td align="left">'; foreach ($assigned_users as $val) { $aInfo = '<a href="?m=users&a=view&user_id=' . $val['user_id'] . '"'; $aInfo .= 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' : '') . '">'; $aInfo .= $val['contact_name'] . ' (' . $val['perc_assignment'] . '%)</a>'; $a_u_tmp_array[] = $aInfo; } $s .= join(', ', $a_u_tmp_array); $s .= '</td>'; } else { $s .= '<td align="left" nowrap="nowrap">'; $s .= '<a href="?m=users&a=view&user_id=' . $assigned_users[0]['user_id'] . '"'; $s .= 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%' : '') . '">'; $s .= $assigned_users[0]['contact_name'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>'; if ($arr['assignee_count'] > 1) { $id = $arr['task_id']; $s .= '<a href="javascript: void(0);" onclick="toggle_users(\'users_' . $id . '\');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($arr['assignee_count'] - 1) . ')</a>'; $s .= '<span style="display: none" id="users_' . $id . '">'; $a_u_tmp_array[] = $assigned_users[0]['user_username']; for ($i = 1, $i_cmp = count($assigned_users); $i < $i_cmp; $i++) { $a_u_tmp_array[] = $assigned_users[$i]['user_username']; $s .= '<br /><a href="?m=users&a=view&user_id='; $s .= $assigned_users[$i]['user_id'] . '" title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%' : '') . '">'; $s .= $assigned_users[$i]['contact_name'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>'; } $s .= '</span>'; } $s .= '</td>'; } } else { // No users asigned to task $s .= '<td class="data">-</td>'; } // Assignment checkbox if ($showEditCheckbox && 0 == $arr['task_represents_project']) { $s .= '<td class="data"><input type="checkbox" onclick="select_box(\'multi_check\', ' . $arr['task_id'] . ',\'project_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_\',\'frm_tasks\')" onfocus="is_check=true;" onblur="is_check=false;" id="selected_task_' . $arr['task_id'] . '" name="selected_task" value="' . $arr['task_id'] . '"/></td>'; } $s .= '</tr>'; return $s; }
function displayFiles($AppUI, $folder_id, $task_id, $project_id, $company_id) { global $m, $tab, $xpg_min, $xpg_pagesize, $showProject, $file_types, $company_id, $current_uri, $canEdit; // SETUP FOR FILE LIST $q = new w2p_Database_Query(); $q->addQuery('f.*, max(f.file_id) as latest_id, count(f.file_version) as file_versions, round(max(file_version), 2) as file_lastversion, file_owner, user_id'); $q->addQuery('ff.*, max(file_version) as file_version, f.file_date as file_datetime'); $q->addTable('files', 'f'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder'); $q->addJoin('projects', 'p', 'p.project_id = file_project'); $q->addJoin('tasks', 't', 't.task_id = file_task'); $q->addJoin('users', 'u', 'u.user_id = file_owner'); $q->leftJoin('project_departments', 'project_departments', 'p.project_id = project_departments.project_id OR project_departments.project_id IS NULL'); $q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL'); //TODO: apply permissions properly $project = new CProject(); $deny1 = $project->getDeniedRecords($AppUI->user_id); if (count($deny1) > 0) { $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')'); } //TODO: apply permissions properly $task = new CTask(); $deny2 = $task->getDeniedRecords($AppUI->user_id); if (count($deny2) > 0) { $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')'); } if ($project_id) { $q->addWhere('file_project = ' . (int) $project_id); } if ($task_id) { $q->addWhere('file_task = ' . (int) $task_id); } if ($company_id) { $q->addWhere('project_company = ' . (int) $company_id); } //$tab = ($m == 'files') ? $tab-1 : -1; $temp_tab = $m == 'files' ? $tab - 1 : -1; if ($temp_tab >= 0 and count($file_types) - 1 > $temp_tab) { //if ($tab >= 0) { $q->addWhere('file_category = ' . (int) $temp_tab); } $q->setLimit($xpg_pagesize, $xpg_min); if ($folder_id > -1) { $q->addWhere('file_folder = ' . (int) $folder_id); } $q->addGroup('file_version_id DESC'); $q->addOrder('project_name ASC, file_parent ASC, file_id DESC'); $qv = new w2p_Database_Query(); $qv->addTable('files'); $qv->addQuery('file_id, file_version, file_project, file_name, file_task, file_description, file_owner, file_size, file_category, task_name, file_version_id, file_date as file_datetime, file_checkout, file_co_reason, file_type, file_date, cu.user_username as co_user, project_name, project_color_identifier, project_owner, u.user_id, con.contact_first_name, con.contact_last_name, con.contact_display_name as contact_name, co.contact_first_name as co_contact_first_name, co.contact_last_name as co_contact_last_name, co.contact_display_name as co_contact_name '); $qv->addJoin('projects', 'p', 'p.project_id = file_project'); $qv->addJoin('users', 'u', 'u.user_id = file_owner'); $qv->addJoin('contacts', 'con', 'con.contact_id = u.user_contact'); $qv->addJoin('tasks', 't', 't.task_id = file_task'); $qv->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder'); if ($project_id) { $qv->addWhere('file_project = ' . (int) $project_id); } if ($task_id) { $qv->addWhere('file_task = ' . (int) $task_id); } if ($company_id) { $qv->addWhere('project_company = ' . (int) $company_id); } if ($temp_tab >= 0 and count($file_types) - 1 > $temp_tab) { //if ($tab >= 0) { $qv->addWhere('file_category = ' . (int) $temp_tab); } $qv->leftJoin('users', 'cu', 'cu.user_id = file_checkout'); $qv->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact'); if ($folder_id > -1) { $qv->addWhere('file_folder = ' . (int) $folder_id); } $files = $q->loadList(); $file_versions = $qv->loadHashList('file_id'); $module = new w2p_System_Module(); $fields = $module->loadSettings('files', 'index_list'); if (count($fields) > 0) { $fieldList = array_keys($fields); $fieldNames = array_values($fields); } else { // TODO: This is only in place to provide an pre-upgrade-safe // state for versions earlier than v3.0 // At some point at/after v4.0, this should be deprecated $fieldList = array('file_name', 'file_description', 'file_version', 'file_category', 'file_folder', 'file_task', 'file_owner', 'file_datetime'); $fieldNames = array('File Name', 'Description', 'Version', 'Category', 'Folder', 'Task Name', 'Owner', 'Date'); $module->storeSettings('files', 'index_list', $fieldList, $fieldNames); } $s = '<tr>'; $s .= '<th></th>'; $s .= '<th>' . $AppUI->_('co') . '</th>'; foreach ($fieldNames as $index => $name) { $s .= '<th>' . $AppUI->_($fieldNames[$index]) . '</th>'; } $s .= '<th></th>'; $s .= '</tr>'; $fp = -1; $htmlHelper = new w2p_Output_HTMLHelper($AppUI); $htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT'); $file_types = w2PgetSysVal('FileType'); $customLookups = array('file_category' => $file_types); foreach ($files as $row) { $latest_file = $file_versions[$row['latest_id']]; if ($fp != $latest_file['file_project']) { if (!$latest_file['file_project']) { $latest_file['project_name'] = $AppUI->_('Not attached to a project'); $latest_file['project_color_identifier'] = 'f4efe3'; } if ($showProject) { $style = 'background-color:#' . $latest_file['project_color_identifier'] . ';color:' . bestColor($latest_file['project_color_identifier']); $s .= '<tr>'; $s .= '<td colspan="20" style="text-align: left; border: outset 2px #eeeeee;' . $style . '">'; if ($latest_file['file_project'] > 0) { $href = './index.php?m=projects&a=view&project_id=' . $latest_file['file_project']; } else { $href = './index.php?m=projects'; } $s .= '<a href="' . $href . '">'; $s .= '<span style="' . $style . '">' . $latest_file['project_name'] . '</span></a>'; $s .= '</td></tr>'; } } $fp = $latest_file['file_project']; $row['file_datetime'] = $latest_file['file_datetime']; $row['file_id'] = $latest_file['file_id']; $htmlHelper->stageRowData($row); $s .= '<tr>'; $s .= '<td class="data">'; if ($canEdit && (empty($latest_file['file_checkout']) || $latest_file['file_checkout'] == 'final' && ($canEdit || $latest_file['project_owner'] == $AppUI->user_id))) { $s .= '<a href="./index.php?m=files&a=addedit&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('kedit.png', '16', '16', 'edit file', 'edit file', 'files') . '</a>'; } $s .= '</td>'; $s .= '<td class="data">'; if ($canEdit && empty($latest_file['file_checkout'])) { $s .= '<a href="?m=files&a=co&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('up.png', '16', '16', 'checkout', 'checkout file', 'files') . '</a>'; } else { if ($latest_file['file_checkout'] == $AppUI->user_id) { $s .= '<a href="?m=files&a=addedit&ci=1&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('down.png', '16', '16', 'checkin', 'checkin file', 'files') . '</a>'; } else { if ($latest_file['file_checkout'] == 'final') { $s .= 'final'; } else { $s .= $latest_file['co_contact_name'] . '<br>(' . $latest_file['co_user'] . ')'; } } } $version_link = ''; $hidden_table = ''; if ($row['file_versions'] > 1) { $version_link = ' <a href="javascript: void(0);" onClick="expand(\'versions_' . $latest_file['file_id'] . '\'); ">(' . $row['file_versions'] . ')</a>'; $hidden_table = '<tr><td colspan="20"> <table style="display: none" id="versions_' . $latest_file['file_id'] . '" class="tbl list"> <tr>'; foreach ($fieldNames as $index => $name) { $hidden_table .= '<th nowrap="nowrap">'; $hidden_table .= $AppUI->_($fieldNames[$index]); $hidden_table .= '</th>'; } $hidden_table .= '</tr>'; $sub_htmlHelper = new w2p_Output_HTMLHelper($AppUI); $sub_htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT'); foreach ($file_versions as $file) { $sub_htmlHelper->stageRowData($file); if ($file['file_version_id'] == $latest_file['file_version_id']) { foreach ($fieldList as $index => $column) { $hidden_table .= $sub_htmlHelper->createCell($fieldList[$index], $file[$fieldList[$index]], $customLookups); } if ($canEdit && w2PgetConfig('files_show_versions_edit')) { $hidden_table .= '<a href="./index.php?m=files&a=addedit&file_id=' . $file['file_id'] . '">' . w2PshowImage('kedit.png', '16', '16', 'edit file', 'edit file', 'files') . "</a>"; } $hidden_table .= '</td><tr>'; } } $hidden_table .= '</table>'; } $s .= '</td>'; foreach ($fieldList as $index => $column) { $cell = $htmlHelper->createCell($fieldList[$index], $row[$fieldList[$index]], $customLookups); if ('file_version' == $fieldList[$index]) { $cell = str_replace('</td>', $version_link . '</td>', $cell); } $s .= $cell; } $s .= '<td>'; $s .= '<form name="frm_remove_file_' . $latest_file['file_id'] . '" action="?m=files" method="post" accept-charset="utf-8"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="del" value="1" /> <input type="hidden" name="file_id" value="' . $latest_file['file_id'] . '" /> <input type="hidden" name="redirect" value="' . $current_uri . '" /> </form>'; $s .= '<a href="javascript: void(0);" onclick="if (confirm(\'' . $AppUI->_('Are you sure you want to delete this file?') . '\')) {document.frm_remove_file_' . $latest_file['file_id'] . '.submit()}">' . w2PshowImage('remove.png', '16', '16', 'delete file', 'delete file', 'files') . '</a>'; $s .= '</td>'; $s .= '</tr>'; $s .= $hidden_table; } if (0 == count($files)) { $s .= '<tr><td colspan="' . (count($fieldNames) + 3) . '">' . $AppUI->_('No data available') . '</td></tr>'; } return $s; }
if ($canEdit) { $titleBlock->addCell(); $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new department') . '">', '', '<form action="?m=departments&a=addedit&company_id=' . $department->dept_company . '&dept_parent=' . $dept_id . '" method="post" accept-charset="utf-8">', '</form>'); } $titleBlock->addCrumb('?m=departments', 'department list'); $titleBlock->addCrumb('?m=companies', 'company list'); $titleBlock->addCrumb('?m=companies&a=view&company_id=' . $department->dept_company, 'view this company'); if ($canEdit) { $titleBlock->addCrumb('?m=departments&a=addedit&dept_id=' . $dept_id, 'edit this department'); if ($canDelete) { $titleBlock->addCrumbDelete('delete department', $canDelete, $msg); } } $titleBlock->show(); $htmlHelper = new w2p_Output_HTMLHelper($AppUI); $htmlHelper->stageRowData((array) $department); ?> <script language="javascript" type="text/javascript"> <?php // security improvement: // some javascript functions may not appear on client side in case of user not having write permissions // else users would be able to arbitrarily run 'bad' functions if ($canDelete) { ?> function delIt() { if (confirm('<?php echo $AppUI->_('departmentDelete', UI_OUTPUT_JS); ?> ')) { document.frmDelete.submit(); }
$s .= $htmlHelper->createCell('perc_assignment', $row['perc_assignment']); $s .= '</tr>'; } echo $s; ?> </table> <strong><?php echo $AppUI->_('Dependencies'); ?> </strong> <table width="100%" cellspacing="1" cellpadding="2" class="tbl list well"> <?php $taskDep = $obj->getDependencyList($task_id); $s = count($taskDep) == 0 ? '<tr><td>' . $AppUI->_('none') . '</td></tr>' : '<tr><th>' . $AppUI->_('Task') . '</th>' . '<th>' . $AppUI->_('Work') . '</th>' . '<th>' . $AppUI->_('Start Date') . '</th>' . '<th>' . $AppUI->_('End Date') . '</th></tr>'; foreach ($taskDep as $key => $array) { $htmlHelper->stageRowData($array); $s .= '<tr>'; $s .= $htmlHelper->createCell('task_name', $array['task_name']); $s .= $htmlHelper->createCell('task_percent_complete', $array['task_percent_complete']); $s .= $htmlHelper->createCell('task_start_date', $array['task_start_date']); $s .= $htmlHelper->createCell('task_end_date', $array['task_end_date']); $s .= '</tr>'; } echo $s; ?> </table> <strong><?php echo $AppUI->_('Tasks depending on this Task'); ?> </strong> <table width="100%" cellspacing="1" cellpadding="2" class="tbl list well">