diff --git a/include/staff/groups.inc.php b/include/staff/groups.inc.php index ed5e3638a8d0528908584ddfad5320d885a38e4d..5c8393e994fae65d38599c52ed02fa7e991226cf 100644 --- a/include/staff/groups.inc.php +++ b/include/staff/groups.inc.php @@ -3,10 +3,13 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access $qstr=''; -$sql='SELECT grp.*,count(staff.staff_id) as users ' - .' FROM '.GROUP_TABLE.' grp LEFT JOIN '.STAFF_TABLE.' staff USING(group_id) '; -$sql.=' WHERE 1'; -$sortOptions=array('name'=>'grp.group_name','status'=>'grp.group_enabled','users'=>'users','created'=>'grp.created','updated'=>'grp.updated'); +$sql='SELECT grp.*,count(staff.staff_id) as users, count(dept.dept_id) as depts ' + .' FROM '.GROUP_TABLE.' grp ' + .' LEFT JOIN '.STAFF_TABLE.' staff ON(staff.group_id=grp.group_id) ' + .' LEFT JOIN '.GROUP_DEPT_TABLE.' dept ON(dept.group_id=grp.group_id) ' + .' WHERE 1'; +$sortOptions=array('name'=>'grp.group_name','status'=>'grp.group_enabled', + 'users'=>'users', 'depts'=>'depts', 'created'=>'grp.created','updated'=>'grp.updated'); $orderWays=array('DESC'=>'DESC','ASC'=>'ASC'); $sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name'; //Sorting options... @@ -49,9 +52,10 @@ else <thead> <tr> <th width="7px"> </th> - <th width="250"><a <?php echo $name_sort; ?> href="groups.php?<?php echo $qstr; ?>&sort=name">Group Name</a></th> - <th width="80"><a <?php echo $status_sort; ?> href="groups.php?<?php echo $qstr; ?>&sort=status">Group Status</a></th> + <th width="200"><a <?php echo $name_sort; ?> href="groups.php?<?php echo $qstr; ?>&sort=name">Group Name</a></th> + <th width="80"><a <?php echo $status_sort; ?> href="groups.php?<?php echo $qstr; ?>&sort=status">Status</a></th> <th width="80" style="text-align:center;"><a <?php echo $users_sort; ?>href="groups.php?<?php echo $qstr; ?>&sort=users">Members</a></th> + <th width="80" style="text-align:center;"><a <?php echo $depts_sort; ?>href="groups.php?<?php echo $qstr; ?>&sort=depts">Departments</a></th> <th width="100"><a <?php echo $created_sort; ?> href="groups.php?<?php echo $qstr; ?>&sort=created">Created On</a></th> <th width="120"><a <?php echo $updated_sort; ?> href="groups.php?<?php echo $qstr; ?>&sort=updated">Last Updated</a></th> </tr> @@ -81,6 +85,9 @@ else <?php } ?> </td> + <td style="text-align:right;padding-right:30px"> + <?php echo $row['depts']; ?> + </td> <td><?php echo Format::db_date($row['created']); ?> </td> <td><?php echo Format::db_datetime($row['updated']); ?> </td> </tr>