![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: view.php 66 2008-03-02 20:58:57Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/departments/view.php $ */ 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 // load the department types 31 $types = w2PgetSysVal('DepartmentType'); 32 33 if ($dept_id > 0) { 34 // pull data 35 $q = new DBQuery; 36 $q->addTable('companies', 'com'); 37 $q->addTable('departments', 'dep'); 38 $q->addQuery('dep.*, company_name'); 39 $q->addQuery('con.contact_first_name'); 40 $q->addQuery('con.contact_last_name'); 41 $q->addJoin('users', 'u', 'u.user_id = dep.dept_owner'); 42 $q->addJoin('contacts', 'con', 'u.user_contact = con.contact_id'); 43 $q->addWhere('dep.dept_id = ' . (int)$dept_id); 44 $q->addWhere('dep.dept_company = company_id'); 45 $dept = $q->loadHash(); 46 $q->clear(); 47 } 48 if (!$dept) { 49 $titleBlock = new CTitleBlock('Invalid Department ID', 'departments.png', $m, $m . '.' . $a); 50 $titleBlock->addCrumb('?m=companies', 'companies list'); 51 $titleBlock->show(); 52 } elseif ($dept_id <= 0) { 53 echo $AppUI->_('Please choose a Department first!'); 54 } else { 55 $company_id = $dept['dept_company']; 56 if (!$min_view) { 57 // setup the title block 58 $titleBlock = new CTitleBlock('View Department', 'departments.png', $m, $m . '.' . $a); 59 if ($canEdit) { 60 $titleBlock->addCell(); 61 $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>'); 62 } 63 $titleBlock->addCrumb('?m=departments', 'department list'); 64 $titleBlock->addCrumb('?m=companies', 'company list'); 65 $titleBlock->addCrumb('?m=companies&a=view&company_id=' . $company_id, 'view this company'); 66 if ($canEdit) { 67 $titleBlock->addCrumb('?m=departments&a=addedit&dept_id=' . $dept_id, 'edit this department'); 68 69 if ($canDelete) { 70 $titleBlock->addCrumbDelete('delete department', $canDelete, $msg); 71 } 72 } 73 $titleBlock->show(); 74 } 75 ?> 76 <script language="javascript"> 77 <?php 78 // security improvement: 79 // some javascript functions may not appear on client side in case of user not having write permissions 80 // else users would be able to arbitrarily run 'bad' functions 81 if ($canDelete) { 82 ?> 83 function delIt() { 84 if (confirm('<?php echo $AppUI->_('departmentDelete', UI_OUTPUT_JS); ?>')) { 85 document.frmDelete.submit(); 86 } 87 } 88 <?php } ?> 89 </script> 90 91 <form name="frmDelete" action="./index.php?m=departments" method="post"> 92 <input type="hidden" name="dosql" value="do_dept_aed" /> 93 <input type="hidden" name="del" value="1" /> 94 <input type="hidden" name="dept_id" value="<?php echo $dept_id; ?>" /> 95 </form> 96 97 <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std"> 98 <tr valign="top"> 99 <td width="50%"> 100 <strong><?php echo $AppUI->_('Details'); ?></strong> 101 <table cellspacing="1" cellpadding="2" border="0" width="100%"> 102 <tr> 103 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Company'); ?>:</td> 104 <td bgcolor="#ffffff" width="100%"><?php echo $dept['company_name']; ?></td> 105 </tr> 106 <tr> 107 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Department'); ?>:</td> 108 <td bgcolor="#ffffff" width="100%"><?php echo $dept['dept_name']; ?></td> 109 </tr> 110 <tr> 111 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Owner'); ?>:</td> 112 <td bgcolor="#ffffff" width="100%"><?php echo $dept['contact_first_name'] . ' ' . $dept['contact_last_name']; ?></td> 113 </tr> 114 <tr> 115 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Type'); ?>:</td> 116 <td bgcolor="#ffffff" width="100%"><?php echo $types[$dept['dept_type']]; ?></td> 117 </tr> 118 <tr> 119 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Email'); ?>:</td> 120 <td bgcolor="#ffffff" width="100%"><?php echo $dept['dept_email']; ?></td> 121 </tr> 122 <tr> 123 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Phone'); ?>:</td> 124 <td bgcolor="#ffffff" width="100%"><?php echo $dept['dept_phone']; ?></td> 125 </tr> 126 <tr> 127 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Fax'); ?>:</td> 128 <td bgcolor="#ffffff" width="100%"><?php echo $dept['dept_fax']; ?></td> 129 </tr> 130 <tr valign="top"> 131 <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Address'); ?>:</td> 132 <td bgcolor="#ffffff"> 133 <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"> 134 <img align="right" border="0" src="<?php echo w2PfindImage('googlemaps.gif'); ?>" width="55" height="22" alt="Find It on Google" /></a> 135 <?php echo $dept['dept_address1'] . (($dept['dept_address2']) ? '<br />' . $dept['dept_address2'] : '') . '<br />' . $dept['dept_city'] . ' ' . $dept['dept_state'] . ' ' . $dept['dept_zip'] . (($dept['dept_country']) ? '<br />' . $countries[$dept['dept_country']] : '');?> 136 </td> 137 </tr> 138 </table> 139 </td> 140 <td width="50%"> 141 <strong><?php echo $AppUI->_('Description'); ?></strong> 142 <table cellspacing="1" cellpadding="2" border="0" width="100%"> 143 <tr> 144 <td bgcolor="#ffffff" width="100%"><?php echo str_replace(chr(10), '<br />', $dept['dept_desc']); ?> </td> 145 </tr> 146 </table> 147 </td> 148 </tr> 149 </table> 150 <?php 151 152 // tabbed information boxes 153 $tabBox = new CTabBox('?m=departments&a=' . $a . '&dept_id=' . $dept_id, '', $tab); 154 $tabBox->add(W2P_BASE_DIR . '/modules/departments/vw_contacts', 'Contacts'); 155 // include auto-tabs with 'view' explicitly instead of $a, because this view is also included in the main index site 156 $tabBox->show(); 157 } 158 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 7 03:00:01 2009 | Cross-referenced by PHPXref 0.7 |