home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / departments / view.php < prev    next >
Encoding:
PHP Script  |  2003-12-10  |  4.2 KB  |  126 lines

  1. <?php /* DEPARTMENTS $Id: view.php,v 1.14 2003/12/10 01:07:29 jcgonz Exp $ */
  2. $dept_id = isset($_GET['dept_id']) ? $_GET['dept_id'] : 0;
  3.  
  4. // check permissions
  5. $canRead = !getDenyRead( $m, $dept_id );
  6. $canEdit = !getDenyEdit( $m, $dept_id );
  7.  
  8. if (!$canRead) {
  9.     $AppUI->redirect( "m=public&a=access_denied" );
  10. }
  11. $AppUI->savePlace();
  12.  
  13. if (isset( $_GET['tab'] )) {
  14.     $AppUI->setState( 'DeptVwTab', $_GET['tab'] );
  15. }
  16. $tab = $AppUI->getState( 'DeptVwTab' ) !== NULL ? $AppUI->getState( 'DeptVwTab' ) : 0;
  17.  
  18. // pull data
  19. $sql = "
  20. SELECT departments.*,company_name, user_first_name, user_last_name
  21. FROM departments, companies
  22. LEFT JOIN users ON user_id = dept_owner
  23. WHERE dept_id = $dept_id
  24.     AND dept_company = company_id
  25. ";
  26. if (!db_loadHash( $sql, $dept )) {
  27.     $titleBlock = new CTitleBlock( 'Invalid Department ID', 'users.gif', $m, "$m.$a" );
  28.     $titleBlock->addCrumb( "?m=companies", "companies list" );
  29.     $titleBlock->show();
  30. } else {
  31.     $company_id = $dept['dept_company'];
  32.  
  33.     // setup the title block
  34.     $titleBlock = new CTitleBlock( 'View Department', 'users.gif', $m, "$m.$a" );
  35.     if ($canEdit) {
  36.         $titleBlock->addCell();
  37.         $titleBlock->addCell(
  38.             '<input type="submit" class="button" value="'.$AppUI->_('new department').'">', '',
  39.             '<form action="?m=departments&a=addedit&company_id='.$company_id.'&dept_parent='.$dept_id.'" method="post">', '</form>'
  40.         );
  41.     }
  42.     $titleBlock->addCrumb( "?m=companies", "company list" );
  43.     $titleBlock->addCrumb( "?m=companies&a=view&company_id=$company_id", "view this company" );
  44.     if ($canEdit) {
  45.         $titleBlock->addCrumb( "?m=departments&a=addedit&dept_id=$dept_id", "edit this department" );
  46.  
  47.         if ($canDelete) {
  48.             $titleBlock->addCrumbRight(
  49.                 '<a href="javascript:delIt()">'
  50.                     . '<img align="absmiddle" src="' . dPfindImage( 'trash.gif', $m ) . '" width="16" height="16" alt="" border="0" /> '
  51.                     . $AppUI->_('delete department') . '</a>'
  52.             );
  53.         }
  54.     }
  55.     $titleBlock->show();
  56. ?>
  57. <script language="javascript">
  58. function delIt() {
  59.     if (confirm( "<?php echo $AppUI->_('departmentDelete');?>" )) {
  60.         document.frmDelete.submit();
  61.     }
  62. }
  63. </script>
  64.  
  65. <form name="frmDelete" action="./index.php?m=departments" method="post">
  66.     <input type="hidden" name="dosql" value="do_dept_aed" />
  67.     <input type="hidden" name="del" value="1" />
  68.     <input type="hidden" name="dept_id" value="<?php echo $dept_id;?>" />
  69. </form>
  70.  
  71. <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
  72. <tr valign="top">
  73.     <td width="50%">
  74.         <strong><?php echo $AppUI->_('Details'); ?></strong>
  75.         <table cellspacing="1" cellpadding="2" border="0" width="100%">
  76.         <tr>
  77.             <td align="right" nowrap><?php echo $AppUI->_('Company'); ?>:</td>
  78.             <td bgcolor="#ffffff" width="100%"><?php echo $dept["company_name"];?></td>
  79.         </tr>
  80.         <tr>
  81.             <td align="right" nowrap><?php echo $AppUI->_('Department'); ?>:</td>
  82.             <td bgcolor="#ffffff" width="100%"><?php echo $dept["dept_name"];?></td>
  83.         </tr>
  84.         <tr>
  85.             <td align="right" nowrap><?php echo $AppUI->_('Owner'); ?>:</td>
  86.             <td bgcolor="#ffffff" width="100%"><?php echo @$dept["user_first_name"].' '.@$dept["user_last_name"];?></td>
  87.         </tr>
  88.         <tr>
  89.             <td align="right" nowrap><?php echo $AppUI->_('Phone'); ?>:</td>
  90.             <td bgcolor="#ffffff" width="100%"><?php echo @$dept["dept_phone"];?></td>
  91.         </tr>
  92.         <tr>
  93.             <td align="right" nowrap><?php echo $AppUI->_('Fax'); ?>:</td>
  94.             <td bgcolor="#ffffff" width="100%"><?php echo @$dept["dept_fax"];?></td>
  95.         </tr>
  96.         <tr valign=top>
  97.             <td align="right" nowrap><?php echo $AppUI->_('Address'); ?>:</td>
  98.             <td bgcolor="#ffffff"><?php
  99.                 echo @$dept["dept_address1"]
  100.                     .( ($dept["dept_address2"]) ? '<br />'.$dept["dept_address2"] : '' )
  101.                     .'<br />'.$dept["dept_city"]
  102.                     .'  '.$dept["dept_state"]
  103.                     .'  '.$dept["dept_zip"]
  104.                     ;
  105.             ?></td>
  106.         </tr>
  107.         </table>
  108.     </td>
  109.     <td width="50%">
  110.         <strong><?php echo $AppUI->_('Description'); ?></strong>
  111.         <table cellspacing="1" cellpadding="2" border="0" width="100%">
  112.         <tr>
  113.             <td bgcolor="#ffffff" width="100%"><?php echo str_replace( chr(10), "<br />", $dept["dept_desc"]);?> </td>
  114.         </tr>
  115.         </table>
  116.     </td>
  117. </tr>
  118. </table>
  119. <?php
  120.     // tabbed information boxes
  121.     $tabBox = new CTabBox( "?m=departments&a=view&dept_id=$dept_id", "{$AppUI->cfg['root_dir']}/modules/departments/", $tab );
  122.     $tabBox->add("vw_contacts", "Contacts");
  123.     $tabBox->show();
  124. }
  125. ?>
  126.