![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: vw_depts.php 141 2008-04-05 16:41:20Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/departments/vw_depts.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 global $search_string; 7 global $owner_filter_id; 8 global $currentTabId; 9 global $currentTabName; 10 global $tabbed; 11 global $type_filter; 12 global $orderby; 13 global $orderdir; 14 15 // load the company types 16 17 $types = w2PgetSysVal('DepartmentType'); 18 // get any records denied from viewing 19 20 $obj = new CDepartment(); 21 $allowedDepts = $obj->getAllowedRecords($AppUI->user_id, 'dept_id, dept_name'); 22 23 $dept_type_filter = $currentTabId; 24 //Not Defined 25 $deptsType = true; 26 if ($currentTabName == 'All Departments') { 27 $deptssType = false; 28 } 29 if ($currentTabName == 'Not Defined') { 30 $dept_type_filter = 0; 31 } 32 33 // retrieve list of records 34 $q = new DBQuery; 35 $q->addTable('departments'); 36 $q->addQuery('departments.*, COUNT(ct.contact_department) dept_users, count(distinct p.project_id) as countp, count(distinct p2.project_id) as inactive, con.contact_first_name, con.contact_last_name'); 37 $q->addJoin('project_departments', 'pd', 'pd.department_id = dept_id'); 38 $q->addJoin('projects', 'p', 'pd.project_id = p.project_id AND p.project_active = 1'); 39 $q->leftJoin('users', 'u', 'dept_owner = u.user_id'); 40 $q->leftJoin('contacts', 'con', 'u.user_contact = con.contact_id'); 41 $q->addJoin('projects', 'p2', 'pd.project_id = p2.project_id AND p2.project_active = 0'); 42 $q->addJoin('contacts', 'ct', 'ct.contact_department = dept_id'); 43 $q->addGroup('dept_id'); 44 $q->addOrder('dept_parent, dept_name'); 45 if (count($allowedDepts) > 0) { 46 $q->addWhere('dept_id IN (' . implode(',', array_keys($allowedDepts)) . ')'); 47 } else { 48 $q->addWhere('0=1'); 49 } 50 if (($deptsType && $currentTabId && $tabbed) || (!$tabbed)) { 51 $q->addWhere('dept_type = ' . (int)$dept_type_filter); 52 } 53 if ($search_string != '') { 54 $q->addWhere('dept_name LIKE \'%'.$search_string.'%\''); 55 } 56 if ($owner_filter_id > 0) { 57 $q->addWhere('dept_owner = '.$owner_filter_id); 58 } 59 $q->addGroup('dept_id'); 60 $q->addOrder($orderby . ' ' . $orderdir); 61 $rows = $q->loadList(); 62 ?> 63 64 <?php 65 echo ' 66 <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> 67 <tr> 68 <th nowrap="nowrap"> 69 <a href="?m=companies&orderby=company_name" class="hdr">' . $AppUI->_('Department Name') . '</a> 70 </th> 71 <th nowrap="nowrap"> 72 <a href="?m=companies&orderby=countp" class="hdr">' . $AppUI->_('Active Projects') . '</a> 73 </th> 74 <th nowrap="nowrap"> 75 <a href="?m=companies&orderby=inactive" class="hdr">' . $AppUI->_('Archived Projects') . '</a> 76 </th> 77 <th nowrap="nowrap"> 78 <a href="?m=companies&orderby=company_type" class="hdr">' . $AppUI->_('Type') . '</a> 79 </th> 80 </tr>'; 81 82 if (count($rows)) { 83 foreach ($rows as $row) { 84 if ($row['dept_parent'] == 0) { 85 showchilddept($row); 86 findchilddept($rows, $row['dept_id']); 87 } 88 $none = false; 89 echo '<tr><td>' . (trim($row['dept_description']) ? w2PtoolTip($row['dept_name'], $row['dept_description']) : '') . '<a href="./index.php?m=departments&a=view&dept_id=' . $row['dept_id'] . '" >' . $row['dept_name'] . '</a>' . (trim($row['dept_description']) ? w2PendTip() : '') . '</td>'; 90 echo '<td width="125" align="right" nowrap="nowrap">' . $row['countp'] . '</td>'; 91 echo '<td width="125" align="right" nowrap="nowrap">' . $row['inactive'] . '</td>'; 92 echo '<td align="left" nowrap="nowrap">' . $AppUI->_($types[$row['dept_type']]) . '</td></tr>'; 93 } 94 } else { 95 echo '<td colspan="4">' . $AppUI->_('No data available') . '</td>'; 96 } 97 echo '</tr></td></tr></table>';
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 |