![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: vw_depts.php 38 2008-02-11 11:38:51Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/companies/vw_depts.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 ## 7 ## Companies: View Projects sub-table 8 ## 9 10 global $AppUI, $company_id, $canEdit; 11 12 $q = new DBQuery; 13 $q->addTable('departments'); 14 $q->addQuery('departments.*, COUNT(contact_department) dept_users'); 15 $q->addJoin('contacts', 'c', 'c.contact_department = dept_id'); 16 $q->addWhere('dept_company = ' . (int)$company_id); 17 $q->addGroup('dept_id'); 18 $q->addOrder('dept_parent, dept_name'); 19 20 //Department permissions 21 $oDpt = new CDepartment(); 22 $aDptsAllowed = $oDpt->getAllowedRecords($AppUI->user_id, 'dept_id, dept_name'); 23 if (count($aDptsAllowed)) { 24 $q->addWhere('dept_id IN (' . implode(',', array_keys($aDptsAllowed)) . ')'); 25 } 26 27 // function renamed to avoid naming clash 28 function showchilddept_comp(&$a, $level = 0) { 29 global $AppUI; 30 $s = ' 31 <td> 32 <a href="./index.php?m=departments&a=addedit&dept_id=' . $a["dept_id"] . '" title="' . $AppUI->_('edit') . '"> 33 ' . w2PshowImage('icons/stock_edit-16.png', 16, 16, '') . ' 34 </td> 35 <td>'; 36 37 for ($y = 0; $y < $level; $y++) { 38 if ($y + 1 == $level) { 39 $s .= '<img src="' . w2PfindImage('corner-dots.gif') . '" width="16" height="12" border="0">'; 40 } else { 41 $s .= '<img src="' . w2PfindImage('shim.gif') . '" width="16" height="12" border="0">'; 42 } 43 } 44 45 $s .= '<a href="./index.php?m=departments&a=view&dept_id=' . $a['dept_id'] . '">' . $a['dept_name'] . '</a>'; 46 $s .= '</td>'; 47 $s .= '<td align="center">' . ($a['dept_users'] ? $a['dept_users'] : '') . '</td>'; 48 49 echo '<tr>' . $s . '</tr>'; 50 } 51 52 // function renamed to avoid naming clash 53 function findchilddept_comp(&$tarr, $parent, $level = 0) { 54 $level = $level + 1; 55 $n = count($tarr); 56 for ($x = 0; $x < $n; $x++) { 57 if ($tarr[$x]['dept_parent'] == $parent && $tarr[$x]['dept_parent'] != $tarr[$x]['dept_id']) { 58 showchilddept_comp($tarr[$x], $level); 59 findchilddept_comp($tarr, $tarr[$x]['dept_id'], $level); 60 } 61 } 62 } 63 64 $s = '<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">'; 65 $s .= '<tr>'; 66 67 $rows = $q->loadList(); 68 $q->clear(); 69 70 if (count($rows)) { 71 $s .= '<th> </th>'; 72 $s .= '<th width="100%">' . $AppUI->_('Name') . '</th>'; 73 $s .= '<th>' . $AppUI->_('Users') . '</th>'; 74 } else { 75 $s .= '<td>' . $AppUI->_('No data available') . '</td>'; 76 } 77 78 $s .= '</tr>'; 79 echo $s; 80 81 foreach ($rows as $row) { 82 if ($row['dept_parent'] == 0) { 83 showchilddept_comp($row); 84 findchilddept_comp($rows, $row['dept_id']); 85 } 86 } 87 88 echo ' 89 <tr> 90 <td colspan="3" nowrap="nowrap" rowspan="99" align="right" valign="top" style="background-color:#ffffff">'; 91 if ($canEdit) { 92 echo '<input type="button" class=button value="' . $AppUI->_('new department') . '" onclick="javascript:window.location=\'./index.php?m=departments&a=addedit&company_id=' . $company_id . '\';" />'; 93 } 94 echo ' 95 </td> 96 </tr> 97 </table>'; 98 ?>
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 |