[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/companies/ -> vw_users.php (source)

   1  <?php /* $Id: vw_users.php 56 2008-02-19 18:39:18Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/companies/vw_users.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  ##

   7  ##    Companies: View User sub-table

   8  ##

   9  
  10  global $AppUI, $company_id;
  11  
  12  $q = new DBQuery;
  13  $q->addTable('users');
  14  $q->addQuery('user_id, user_username, contact_first_name, contact_last_name');
  15  $q->addJoin('contacts', 'c', 'users.user_contact = contact_id', 'inner');
  16  $q->addJoin('departments', 'd', 'd.dept_id = contact_department');
  17  $q->addWhere('contact_company = ' . (int)$company_id);
  18  $q->addOrder('contact_last_name');
  19  $oDpt = new CDepartment();
  20  $aDptsAllowed = $oDpt->getAllowedRecords($AppUI->user_id, 'dept_id, dept_name');
  21  if (count($aDptsAllowed)) {
  22      $q->addWhere('(dept_id IN (' . implode(',', array_keys($aDptsAllowed)) . ') OR dept_id IS NULL OR dept_id=0 OR dept_id=\'\')');
  23  }
  24  
  25  if (!($rows = $q->loadList())) {
  26      echo $AppUI->_('No data available') . '<br />' . $AppUI->getMsg();
  27  } else {
  28  ?>
  29  <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
  30  <tr>
  31      <th><?php echo $AppUI->_('Username'); ?></td>
  32      <th><?php echo $AppUI->_('Name'); ?></td>
  33  </tr>
  34  <?php
  35      $s = '';
  36      foreach ($rows as $row) {
  37          $s .= '<tr><td>';
  38          $s .= '<a href="./index.php?m=admin&a=viewuser&user_id=' . $row['user_id'] . '">' . $row['user_username'] . '</a>';
  39          $s .= '<td>' . $row['contact_first_name'] . ' ' . $row['contact_last_name'] . '</td>';
  40          $s .= '</tr>';
  41      }
  42      echo $s;
  43  ?>
  44  </table>
  45  <?php } ?>


Generated: Wed Jan 7 03:00:01 2009 Cross-referenced by PHPXref 0.7