[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/forums/ -> view.php (source)

   1  <?php /* DEPARTMENTS $Id: view.php,v 1.21.6.7 2007/09/12 23:22:58 merlinyoda Exp $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  global $department, $min_view;
   7  $dept_id = isset($_GET['dept_id']) ? w2PgetParam($_GET, 'dept_id', 0) : (isset($department) ? $department : 0);
   8  $department = $dept_id;
   9  
  10  // check permissions
  11  $canRead = !getDenyRead($m, $dept_id);
  12  $canEdit = !getDenyEdit($m, $dept_id);
  13  
  14  if (!$canRead) {
  15      $AppUI->redirect('m=public&a=access_denied');
  16  }
  17  $AppUI->savePlace();
  18  
  19  if (isset($dept_id) && $dept_id > 0) {
  20      $AppUI->setState('DeptIdxDepartment', $dept_id);
  21  }
  22  $dept_id = $AppUI->getState('DeptIdxDepartment') !== null ? $AppUI->getState('DeptIdxDepartment') : ($AppUI->user_department > 0 ? $AppUI->user_department : $company_prefix . $AppUI->user_company);
  23  
  24  if (isset($_GET['tab'])) {
  25      $AppUI->setState('DeptVwTab', w2PgetParam($_GET, 'tab', null));
  26  }
  27  $tab = $AppUI->getState('DeptVwTab') !== null ? $AppUI->getState('DeptVwTab') : 0;
  28  
  29  $countries = w2PgetSysVal('GlobalCountries');
  30  
  31  if ($dept_id > 0) {
  32      // pull data
  33      $q = new DBQuery;
  34      $q->addTable('companies', 'com');
  35      $q->addTable('departments', 'dep');
  36      $q->addQuery('dep.*, company_name');
  37      $q->addQuery('con.contact_first_name');
  38      $q->addQuery('con.contact_last_name');
  39      $q->addJoin('users', 'u', 'u.user_id = dep.dept_owner');
  40      $q->addJoin('contacts', 'con', 'u.user_contact = con.contact_id');
  41      $q->addWhere('dep.dept_id = ' . $dept_id);
  42      $q->addWhere('dep.dept_company = company_id');
  43      $dept = $q->loadHash();
  44      $q->clear();
  45  }
  46  if (!$dept) {
  47      $titleBlock = new CTitleBlock('Invalid Department ID', 'departments.png', $m, $m . '.' . $a);
  48      $titleBlock->addCrumb('?m=companies', 'companies list');
  49      $titleBlock->show();
  50  } elseif ($dept_id <= 0) {
  51      echo $AppUI->_('Please choose a Department first!');
  52  } else {
  53      $company_id = $dept['dept_company'];
  54      if (!$min_view) {
  55          // setup the title block
  56          $titleBlock = new CTitleBlock('View Department', 'departments.png', $m, $m . '.' . $a);
  57          if ($canEdit) {
  58              $titleBlock->addCell();
  59              $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new department') . '">', '', '<form action="?m=departments&a=addedit&company_id=' . $company_id . '&dept_parent=' . $dept_id . '" method="post">', '</form>');
  60          }
  61          $titleBlock->addCrumb('?m=companies', 'company list');
  62          $titleBlock->addCrumb('?m=companies&a=view&company_id=' . $company_id, 'view this company');
  63          if ($canEdit) {
  64              $titleBlock->addCrumb('?m=departments&a=addedit&dept_id=' . $dept_id, 'edit this department');
  65  
  66              if ($canDelete) {
  67                  $titleBlock->addCrumbDelete('delete department', $canDelete, $msg);
  68              }
  69          }
  70          $titleBlock->show();
  71      }
  72  ?>
  73  <script language="javascript">
  74  <?php
  75      // security improvement:
  76      // some javascript functions may not appear on client side in case of user not having write permissions
  77      // else users would be able to arbitrarily run 'bad' functions
  78      if ($canDelete) {
  79  ?>
  80  function delIt() {
  81      if (confirm('<?php echo $AppUI->_('departmentDelete', UI_OUTPUT_JS); ?>')) {
  82          document.frmDelete.submit();
  83      }
  84  }
  85  <?php } ?>
  86  </script>
  87  
  88  <form name="frmDelete" action="./index.php?m=departments" method="post">
  89      <input type="hidden" name="dosql" value="do_dept_aed" />
  90      <input type="hidden" name="del" value="1" />
  91      <input type="hidden" name="dept_id" value="<?php echo $dept_id; ?>" />
  92  </form>
  93  
  94  <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
  95  <tr valign="top">
  96      <td width="50%">
  97          <strong><?php echo $AppUI->_('Details'); ?></strong>
  98          <table cellspacing="1" cellpadding="2" border="0" width="100%">
  99          <tr>
 100              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Company'); ?>:</td>
 101              <td bgcolor="#ffffff" width="100%"><?php echo $dept['company_name']; ?></td>
 102          </tr>
 103          <tr>
 104              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Department'); ?>:</td>
 105              <td bgcolor="#ffffff" width="100%"><?php echo $dept['dept_name']; ?></td>
 106          </tr>
 107          <tr>
 108              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Owner'); ?>:</td>
 109              <td bgcolor="#ffffff" width="100%"><?php echo @$dept['contact_first_name'] . ' ' . @$dept['contact_last_name']; ?></td>
 110          </tr>
 111          <tr>
 112              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Phone'); ?>:</td>
 113              <td bgcolor="#ffffff" width="100%"><?php echo @$dept['dept_phone']; ?></td>
 114          </tr>
 115          <tr>
 116              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Fax'); ?>:</td>
 117              <td bgcolor="#ffffff" width="100%"><?php echo @$dept['dept_fax']; ?></td>
 118          </tr>
 119          <tr valign="top">
 120              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Address'); ?>:</td>
 121              <td bgcolor="#ffffff">
 122              <a href="http://maps.google.com/maps?q=<?php echo $dept['dept_address1']; ?>+<?php echo $dept['dept_address2']; ?>+<?php echo $dept['dept_city']; ?>+<?php echo $dept['dept_state']; ?>+<?php echo $dept['dept_zip']; ?>+<?php echo $dept['dept_country']; ?>" target="_blank">
 123              <img align="right" border="0" src="<?php echo w2PfindImage('googlemaps.gif'); ?>" width="55" height="22" alt="Find It on Google" /></a>
 124  <?php        echo @$dept['dept_address1'] . (($dept['dept_address2']) ? '<br />' . $dept['dept_address2'] : '') . '<br />' . $dept['dept_city'] . '&nbsp;&nbsp;' . $dept['dept_state'] . '&nbsp;&nbsp;' . $dept['dept_zip'] . (($dept['dept_country']) ? '<br />' . $countries[$dept['dept_country']] : '');?>
 125          </td>
 126          </tr>
 127          </table>
 128      </td>
 129      <td width="50%">
 130          <strong><?php echo $AppUI->_('Description'); ?></strong>
 131          <table cellspacing="1" cellpadding="2" border="0" width="100%">
 132          <tr>
 133              <td bgcolor="#ffffff" width="100%"><?php echo str_replace(chr(10), '<br />', $dept['dept_desc']); ?>&nbsp;</td>
 134          </tr>
 135          </table>
 136      </td>
 137  </tr>
 138  </table>
 139  <?php
 140  
 141      // tabbed information boxes
 142      $tabBox = new CTabBox('?m=departments&a=' . $a . '&dept_id=' . $dept_id, '', $tab);
 143      $tabBox->add(W2P_BASE_DIR . '/modules/departments/vw_contacts', 'Contacts');
 144      // include auto-tabs with 'view' explicitly instead of $a, because this view is also included in the main index site
 145      $tabBox->show();
 146  }
 147  ?>


Generated: Fri Jan 9 03:00:02 2009 Cross-referenced by PHPXref 0.7