![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: index.php 136 2008-04-04 14:24:17Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/projects/index.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $AppUI->savePlace(); 7 8 // load the companies class to retrieved denied companies 9 require_once ($AppUI->getModuleClass('companies')); 10 $structprojs = getProjects(); 11 12 // Let's update project status! 13 if (isset($_GET['update_project_status']) && isset($_GET['project_status']) && isset($_GET['project_id'])) { 14 $projects_id = w2PgetParam($_GET, 'project_id', array()); // This must be an array 15 16 foreach ($projects_id as $project_id) { 17 //do the edit checking here, because it will be a lot less and it will be faster 18 if ($perms->checkModuleItem('projects', 'edit', $project_id)) { 19 $r = new DBQuery; 20 $r->addTable('projects'); 21 $r->addUpdate('project_status', '' . w2PgetParam($_GET, 'project_status', null)); 22 $r->addWhere('project_id = ' . (int)$project_id); 23 $r->exec(); 24 $r->clear(); 25 } 26 } 27 } 28 29 if (isset($_POST['projsearchtext'])) { 30 $AppUI->setState('projsearchtext', w2PformSafe($_POST['projsearchtext'], true)); 31 } 32 $search_text = $AppUI->getState('projsearchtext') !== null ? $AppUI->getState('projsearchtext') : ''; 33 34 $projectDesigner = $AppUI->getState('ProjIdxProjectDesigner') !== null ? $AppUI->getState('ProjIdxProjectDesigner') : 0; 35 36 // retrieve any state parameters 37 if (isset($_GET['tab'])) { 38 $AppUI->setState('ProjIdxTab', w2PgetParam($_GET, 'tab', null)); 39 } 40 41 $tab = $AppUI->getState('ProjIdxTab') !== null ? $AppUI->getState('ProjIdxTab') : 1; 42 $currentTabId = $tab; 43 $active = intval(!$AppUI->getState('ProjIdxTab')); 44 45 $oCompany = new CCompany; 46 $allowedCompanies = $oCompany->getAllowedRecords($AppUI->user_id, 'company_id,company_name'); 47 48 if (isset($_POST['company_id'])) { 49 $AppUI->setState('ProjIdxCompany', intval($_POST['company_id'])); 50 } 51 $company_id = $AppUI->getState('ProjIdxCompany') !== null ? $AppUI->getState('ProjIdxCompany') : ((isset($allowedCompanies[$AppUI->user_company])) ? $AppUI->user_company : 0); 52 53 $company_prefix = 'company_'; 54 55 if (isset($_POST['department'])) { 56 $AppUI->setState('ProjIdxDepartment', $_POST['department']); 57 58 //if department is set, ignore the company_id field 59 unset($company_id); 60 } 61 $department = $AppUI->getState('ProjIdxDepartment') !== null ? $AppUI->getState('ProjIdxDepartment') : ((isset($allowedCompanies[$AppUI->user_company])) ? $company_prefix . $AppUI->user_company : $company_prefix . '0'); 62 63 //if $department contains the $company_prefix string that it's requesting a company and not a department. So, clear the 64 // $department variable, and populate the $company_id variable. 65 if (!(strpos($department, $company_prefix) === false)) { 66 $company_id = substr($department, strlen($company_prefix)); 67 $AppUI->setState('ProjIdxCompany', $company_id); 68 unset($department); 69 } 70 71 $orderdir = $AppUI->getState('ProjIdxOrderDir') ? $AppUI->getState('ProjIdxOrderDir') : 'asc'; 72 if (isset($_GET['orderby'])) { 73 if ($AppUI->getState('ProjIdxOrderDir') == 'asc') { 74 $orderdir = 'desc'; 75 } else { 76 $orderdir = 'asc'; 77 } 78 $AppUI->setState('ProjIdxOrderBy', w2PgetParam($_GET, 'orderby', null)); 79 } 80 $orderby = $AppUI->getState('ProjIdxOrderBy') ? $AppUI->getState('ProjIdxOrderBy') : 'project_end_date'; 81 $AppUI->setState('ProjIdxOrderDir', $orderdir); 82 83 // prepare the type filter 84 if (isset($_POST['project_type'])) { 85 $AppUI->setState('ProjIdxType', intval($_POST['project_type'])); 86 } 87 $project_type = $AppUI->getState('ProjIdxType') !== null ? $AppUI->getState('ProjIdxType') : -1; 88 89 // prepare the users filter 90 if (isset($_POST['project_owner'])) { 91 $AppUI->setState('ProjIdxowner', intval($_POST['project_owner'])); 92 } 93 $owner = $AppUI->getState('ProjIdxowner') !== null ? $AppUI->getState('ProjIdxowner') : 0; 94 95 $bufferUser = '<select name="show_owner" onchange="document.pickUser.submit()" class="text">'; 96 $bufferUser .= '<option value="0">' . $AppUI->_('All Users'); 97 98 $q = new DBQuery(); 99 $q->addTable('projects', 'p'); 100 $q->addQuery('user_id, concat(contact_first_name, \' \', contact_last_name)'); 101 $q->leftJoin('users', 'u', 'u.user_id = p.project_owner'); 102 $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact'); 103 $q->addOrder('contact_first_name, contact_last_name'); 104 $q->addWhere('user_id > 0'); 105 $q->addWhere('p.project_owner IS NOT NULL'); 106 $user_list = array(0 => '(all)'); 107 $user_list = $user_list + $q->loadHashList(); 108 109 // collect the full projects list data via function in projects.class.php 110 projects_list_data(); 111 112 $project_types = array(-1 => '(all)') + w2PgetSysVal('ProjectType'); 113 114 //$search_text = ''; 115 $bufferSearch = '<input type="text" class="text" size="20" name="projsearchtext" onChange="document.searchfilter.submit();" value=' . "'$search_text'" . 'title="' . $AppUI->_('Search in name and description fields') . '"/>'; 116 117 // setup the title block 118 $titleBlock = new CTitleBlock('Projects', 'applet3-48.png', $m, $m . '.' . $a); 119 $titleBlock->addCell('<table><tr><form action="?m=projects" method="post" name="searchfilter"><td nowrap="nowrap" align="right">' . $AppUI->_('Search') . ':</td><td nowrap="nowrap" align="left">' . $bufferSearch . '</form></tr><tr><form action="?m=projects" method="post" name="typeIdForm"><td nowrap="nowrap" align="right">' . $AppUI->_('Type') . '</td><td nowrap="nowrap" align="left">' . arraySelect($project_types, 'project_type', 'size="1" class="text" onChange="document.typeIdForm.submit();"', $project_type, false) . '</td></form></tr></table>', '', '', ''); 120 $titleBlock->addCell('<table><tr><form action="?m=projects" method="post" name="pickCompany"><td nowrap="nowrap" align="right">' . $AppUI->_('Company') . '</td><td nowrap="nowrap" align="left">' . $buffer . '</td></form></tr><tr><form action="?m=projects" method="post" name="userIdForm"><td nowrap="nowrap" align="right">' . $AppUI->_('Owner') . '</td><td nowrap="nowrap" align="left">' . arraySelect($user_list, 'project_owner', 'size="1" class="text" onChange="document.userIdForm.submit();"', $owner, false) . '</td></form></tr></table>', '', '', ''); 121 if ($canAuthor) { 122 $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new project') . '">', '', '<form action="?m=projects&a=addedit" method="post">', '</form>'); 123 } 124 $titleBlock->addCell('<span title="' . $AppUI->_('Projects') . '::' . $AppUI->_('Print projects list') . '."><a href="javascript: void(0);" onclick ="window.open(\'index.php?m=projects&a=printprojects&dialog=1&suppressHeaders=1\', \'printprojects\',\'width=1200, height=600, menubar=1, scrollbars=1\')"> 125 <img src="' . w2PfindImage('printer.png') . '" border="0" width="22" heigth"22" /> 126 </a></span> 127 '); 128 129 $titleBlock->show(); 130 131 $project_statuses = w2PgetSysVal('ProjectStatus'); 132 133 $active = 0; 134 $archived = 0; 135 136 foreach ($project_statuses as $key => $value) { 137 $counter[$key] = 0; 138 if (is_array($projects)) { 139 foreach ($projects as $p) { 140 if ($p['project_status'] == $key && $p['project_active'] > 0) { 141 ++$counter[$key]; 142 } 143 } 144 } 145 $project_statuses[$key] = $AppUI->_($project_statuses[$key], UI_OUTPUT_RAW) . ' (' . $counter[$key] . ')'; 146 } 147 148 if (is_array($projects)) { 149 foreach ($projects as $p) { 150 if ($p['project_active'] == 0) { 151 ++$archived; 152 } else { 153 ++$active; 154 } 155 } 156 } 157 158 $project_statuses[] = $AppUI->_('Archived', UI_OUTPUT_RAW) . ' (' . $archived . ')'; 159 160 // Only display the All option in tabbed view, in plain mode it would just repeat everything else 161 // already in the page 162 $tabBox = new CTabBox('?m=projects', W2P_BASE_DIR . '/modules/projects/', $tab); 163 $is_tabbed = $tabBox->isTabbed(); 164 if ($tabBox->isTabbed()) { 165 // This will overwrited the initial tab, so we need to add that separately. 166 $allactive = (int)count($projects) - (int)($archived); 167 array_unshift($project_statuses, $AppUI->_('All Projects', UI_OUTPUT_RAW) . ' (' . count($projects) . ')', $AppUI->_('All Active', UI_OUTPUT_RAW) . ' (' . $allactive . ')'); 168 } 169 170 $project_status_file = array(); 171 172 foreach ($project_statuses as $project_status) { 173 $project_status = trim($project_status); 174 if (isset($fixed_project_status_file[$project_status])) { 175 $project_file_status[$project_status] = $fixed_project_status_file[$project_status]; 176 } else { // if there is no fixed vw_idx file, we will use vw_idx_proposed 177 $project_file_status[$project_status] = 'vw_idx_projects'; 178 } 179 } 180 181 // tabbed information boxes 182 foreach ($project_statuses as $project_status) { 183 $tabBox->add($project_file_status[$project_status], $project_status, true); 184 } 185 $min_view = true; 186 $tabBox->add('viewgantt', 'Gantt'); 187 $tabBox->show(); 188 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |