[ Index ]

Source Code Reference for V1.00

title

Body

[close]

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

   1  <?php /* $Id: vw_contacts.php 101 2008-03-18 18:42:31Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/companies/vw_contacts.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, $obj;
  11  
  12  // assemble the sql statement

  13  require_once $AppUI->getModuleClass('contacts');
  14  require_once $AppUI->getModuleClass('departments');
  15  $department = &new CDepartment;
  16  $allowedDepartments = $department->getAllowedSQL($AppUI->user_id);
  17  $q = new DBQuery;
  18  $q->addQuery('a.*');
  19  $q->addQuery('dept_name');
  20  $q->addTable('contacts', 'a');
  21  $q->leftJoin('companies', 'b', 'a.contact_company = b.company_id');
  22  $q->leftJoin('departments', '', 'contact_department = dept_id');
  23  $q->addWhere('contact_company = ' . (int)$obj->company_id);
  24  $q->addWhere('
  25      (contact_private=0
  26          OR (contact_private=1 AND contact_owner=' . $AppUI->user_id . ')
  27          OR contact_owner IS NULL OR contact_owner = 0
  28      )');
  29  if (count($allowedDepartments)) {
  30      $dpt_where = implode(' AND ', $allowedDepartments);
  31      $q->addWhere('( (' . $dpt_where . ') OR contact_department = 0 )');
  32  }
  33  $q->addOrder('contact_first_name');
  34  $q->addOrder('contact_last_name');
  35  
  36  $s = '';
  37  if (!($rows = $q->loadList())) {
  38      echo '<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">';
  39      echo $AppUI->_('No data available') . '<br />' . $AppUI->getMsg();
  40  } else {
  41  ?>
  42  <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
  43  <tr>
  44      <th><?php echo $AppUI->_('Name'); ?></td>
  45      <th><?php echo $AppUI->_('e-mail'); ?></td>
  46      <th><?php echo $AppUI->_('Phone'); ?></td>
  47      <th><?php echo $AppUI->_('Department'); ?></td>
  48  </tr>
  49  <?php
  50      foreach ($rows as $row) {
  51          $contact = &new CContact;
  52          $contact->bind($row);
  53          $dept_detail = $contact->getDepartmentDetails();
  54  
  55          $s .= '<tr><td>';
  56          $s .= '<a href="./index.php?m=contacts&a=view&contact_id=' . $row['contact_id'] . '">' . $row['contact_first_name'] . ' ' . $row['contact_last_name'] . '</a>';
  57          $s .= '<td><a href="mailto:' . $row['contact_email'] . '">' . $row['contact_email'] . '</a></td>';
  58          $s .= '<td>' . $row['contact_phone'] . '</td>';
  59          $s .= '<td>' . $dept_detail['dept_name'] . '</td>';
  60          $s .= '</tr>';
  61      }
  62  }
  63  
  64  $s .= '<tr><td colspan="4" align="right" valign="top" style="background-color:#ffffff">';
  65  $s .= '<input type="button" class=button value="' . $AppUI->_('new contact') . '" onClick="javascript:window.location=\'./index.php?m=contacts&a=addedit&company_id=' . $company_id . '&company_name=' . $obj->company_name . '\'">';
  66  $s .= '</td></tr>';
  67  $s .= '</table>';
  68  echo $s;
  69  ?>


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