5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright 2010 (c) Franck Villaume
8 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org/
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 function people_header($params) {
28 global $group_id,$job_id,$HTML;
31 $params['toptab']='people';
32 $params['group']=$group_id;
33 site_project_header($params);
34 } else if (strstr($_SERVER['HTTP_REFERER'],'account')){
35 $params['toptab']='my';
36 site_user_header($params);
38 echo $HTML->header($params);
41 if ($group_id && $job_id) {
42 echo ' | '.util_make_link ('/people/editjob.php?group_id='. $group_id .'&job_id='. $job_id,_('Edit Job'));
46 function people_footer($params) {
48 $HTML->footer($params);
51 function people_skill_box($name='skill_id',$checked='xyxy') {
54 //will be used many times potentially on a single page
55 $PEOPLE_SKILL=db_query_params("SELECT * FROM people_skill ORDER BY name ASC", array());
57 return html_build_select_box($PEOPLE_SKILL,$name,'xzxz',false);
60 function people_skill_level_box($name='skill_level_id',$checked='xyxy') {
61 global $PEOPLE_SKILL_LEVEL;
62 if (!$PEOPLE_SKILL_LEVEL) {
63 //will be used many times potentially on a single page
64 $PEOPLE_SKILL_LEVEL=db_query_params("SELECT * FROM people_skill_level", array());
66 return html_build_select_box ($PEOPLE_SKILL_LEVEL,$name,$checked);
69 function people_skill_year_box($name='skill_year_id',$checked='xyxy') {
70 global $PEOPLE_SKILL_YEAR;
71 if (!$PEOPLE_SKILL_YEAR) {
72 //will be used many times potentially on a single page
73 $PEOPLE_SKILL_YEAR=db_query_params("SELECT * FROM people_skill_year", array());
75 return html_build_select_box ($PEOPLE_SKILL_YEAR,$name,$checked);
78 function people_job_status_box($name='status_id',$checked='xyxy') {
79 $result=db_query_params("SELECT * FROM people_job_status", array());
80 return html_build_select_box ($result,$name,$checked);
83 function people_job_category_box($name='category_id',$checked='xyxy') {
84 $result=db_query_params("SELECT category_id,name FROM people_job_category WHERE private_flag=0", array());
85 return html_build_select_box ($result,$name,$checked);
88 function people_add_to_skill_inventory($skill_id,$skill_level_id,$skill_year_id) {
91 if (session_loggedin()) {
92 // check required fields
93 if (!$skill_id || $skill_id == "xyxy") {
94 $feedback .= _('Must select a skill ID');
96 //check if they've already added this skill
97 $result=db_query_prams("SELECT * FROM people_skill_inventory WHERE user_id=$1 AND skill_id=$2", array(user_getid(), $skill_id));
98 if (!$result || db_numrows($result) < 1) {
99 //skill not already in inventory
100 $result = db_query_params("INSERT INTO people_skill_inventory (user_id,skill_id,skill_level_id,skill_year_id)
101 VALUES ($1, $2, $3, $4)", array(user_getid() ,$skill_id, $skill_level_id, $skill_year_id));
102 if (!$result || db_affected_rows($result) < 1) {
103 $error_msg .= sprintf(_('ERROR inserting into skill inventory: %s'),db_error());
105 $feedback .= _('Added to skill inventory ');
108 $error_msg .= _('ERROR - skill already in your inventory ');
112 echo '<p class="error">You must be logged in first</p>';
116 function people_show_skill_inventory($user_id) {
117 $result = db_query_params("SELECT people_skill.name AS skill_name, people_skill_level.name AS level_name, people_skill_year.name AS year_name
118 FROM people_skill_year,people_skill_level,people_skill,people_skill_inventory
119 WHERE people_skill_year.skill_year_id=people_skill_inventory.skill_year_id
120 AND people_skill_level.skill_level_id=people_skill_inventory.skill_level_id
121 AND people_skill.skill_id=people_skill_inventory.skill_id
122 AND people_skill_inventory.user_id=$1", array($user_id));
125 $title_arr[]=_('Skill');
126 $title_arr[]=_('Level');
127 $title_arr[]=_('Experience');
130 echo $GLOBALS['HTML']->listTableTop ($title_arr);
132 $rows=db_numrows($result);
133 if (!$result || $rows < 1) {
135 <h2>'._('No Skill Inventory Set Up').'</h2>';
138 for ($i=0; $i < $rows; $i++) {
140 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
141 <td>'.db_result($result,$i,'skill_name').'</td>
142 <td>'.db_result($result,$i,'level_name').'</td>
143 <td>'.db_result($result,$i,'year_name').'</td></tr>';
148 echo $GLOBALS['HTML']->listTableBottom();
151 function people_edit_skill_inventory($user_id) {
152 $result=db_query_params('SELECT * FROM people_skill_inventory WHERE user_id=$1', array($user_id));
155 $title_arr[]=_('Skill');
156 $title_arr[]=_('Level');
157 $title_arr[]=_('Experience');
158 $title_arr[]=_('Action');
160 echo $GLOBALS['HTML']->listTableTop ($title_arr);
162 $rows=db_numrows($result);
163 if (!$result || $rows < 1) {
165 <tr><td colspan="4">'._('No skill setup').'</h2></td></tr>';
168 for ($i=0; $i < $rows; $i++) {
170 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
171 <input type="hidden" name="skill_inventory_id" value="'.db_result($result,$i,'skill_inventory_id').'" />
172 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
173 <td>'. people_get_skill_name(db_result($result,$i,'skill_id')) .'</td>
174 <td>'. people_skill_level_box('skill_level_id',db_result($result,$i,'skill_level_id')). '</td>
175 <td>'. people_skill_year_box('skill_year_id',db_result($result,$i,'skill_year_id')). '</td>
176 <td nowrap="nowrap"><input type="submit" name="update_skill_inventory" value="'._('Update').'" />
177 <input type="submit" name="delete_from_skill_inventory" value="'._('Delete').'" /></td>
183 $i++; //for row coloring
186 <tr class="tableheading"><td colspan="4">'._('Add a new skill').'/td></tr>
187 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
188 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
189 <td>'. people_skill_box('skill_id'). '</td>
190 <td>'. people_skill_level_box('skill_level_id'). '</td>
191 <td>'. people_skill_year_box('skill_year_id'). '</td>
192 <td nowrap="nowrap"><input type="submit" name="add_to_skill_inventory" value="'._('Add Skill').'" /></td>
195 echo $GLOBALS['HTML']->listTableBottom();
200 function people_add_to_job_inventory($job_id,$skill_id,$skill_level_id,$skill_year_id) {
202 if (session_loggedin()) {
203 //check if they've already added this skill
204 $result=db_query_params('SELECT * FROM people_job_inventory WHERE job_id=$1 AND skill_id=$2', array($job_id, $skill_id));
205 if (!$result || db_numrows($result) < 1) {
206 //skill isn't already in this inventory
207 $result=db_query_params('INSERT INTO people_job_inventory (job_id,skill_id,skill_level_id,skill_year_id)
208 VALUES ($1, $2, $3, $4)', array($job_id, $skill_id, $skill_level_id, $skill_year_id));
209 if (!$result || db_affected_rows($result) < 1) {
210 $feedback .= _('ERROR inserting into skill inventory');
213 $feedback .= _('Added to skill inventory');
216 $feedback .= _('ERROR - skill already in your inventory');
220 echo '<p class="error">You must be logged in first</p>';
224 function people_show_job_inventory($job_id) {
225 $result=db_query_params('SELECT people_skill.name AS skill_name, people_skill_level.name AS level_name, people_skill_year.name AS year_name
226 FROM people_skill_year,people_skill_level,people_skill,people_job_inventory
227 WHERE people_skill_year.skill_year_id=people_job_inventory.skill_year_id
228 AND people_skill_level.skill_level_id=people_job_inventory.skill_level_id
229 AND people_skill.skill_id=people_job_inventory.skill_id
230 AND people_job_inventory.job_id=$1', array($job_id));
234 $title_arr[]=_('Skill');
235 $title_arr[]=_('Level');
236 $title_arr[]=_('Experience');
238 echo $GLOBALS['HTML']->listTableTop ($title_arr);
240 $rows=db_numrows($result);
241 if (!$result || $rows < 1) {
243 <tr><td><h2>'._('No Skill Inventory Set Up').'</h2></td></tr>';
246 for ($i=0; $i < $rows; $i++) {
248 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
249 <td>'.db_result($result,$i,'skill_name').'</td>
250 <td>'.db_result($result,$i,'level_name').'</td>
251 <td>'.db_result($result,$i,'year_name').'</td></tr>';
256 echo $GLOBALS['HTML']->listTableBottom();
260 function people_verify_job_group($job_id,$group_id) {
261 $result=db_query_params('SELECT * FROM people_job WHERE job_id=$1 AND group_id=$2', array($job_id, $group_id));
262 if (!$result || db_numrows($result) < 1) {
269 function people_get_skill_name($skill_id) {
270 $result=db_query_params('SELECT name FROM people_skill WHERE skill_id=$1', array($skill_id));
271 if (!$result || db_numrows($result) < 1) {
272 return _('Invalid ID');
274 return db_result($result,0,'name');
278 function people_get_category_name($category_id) {
279 $result=db_query_params('SELECT name FROM people_job_category WHERE category_id=$1', array($category_id));
280 if (!$result || db_numrows($result) < 1) {
283 return db_result($result,0,'name');
288 // This function does not produce valid XHTML; however, I could not
289 // think of a way of turning into valid XHTML without the resulting
290 // table looking like poo.
291 function people_edit_job_inventory($job_id,$group_id) {
293 $result=db_query_params('SELECT * FROM people_job_inventory WHERE job_id=$1', array($job_id));
296 $title_arr[]=_('Skill').utils_requiredField();
297 $title_arr[]=_('Level').utils_requiredField();
298 $title_arr[]=_('Experience').utils_requiredField();
299 $title_arr[]=_('Action');
301 echo $HTML->listTableTop ($title_arr);
303 $rows=db_numrows($result);
304 if (!$result || $rows < 1) {
306 exit_error(db_error(),'admin');
308 echo '<tr><td colspan="4"><h2>'._('No Skill Inventory Set Up').'</h2></td></tr>';
311 for ($i=0; $i < $rows; $i++) {
313 <tr '. $HTML->boxGetAltRowStyle($i) . '>
314 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
315 <input type="hidden" name="job_inventory_id" value="'. db_result($result,$i,'job_inventory_id') .'" />
316 <input type="hidden" name="job_id" value="'. db_result($result,$i,'job_id') .'" />
317 <input type="hidden" name="group_id" value="'.$group_id.'" />
318 <td width="25%">'. people_get_skill_name(db_result($result,$i,'skill_id')) . '</td>
319 <td width="25%">'. people_skill_level_box('skill_level_id',db_result($result,$i,'skill_level_id')). '</td>
320 <td width="25%">'. people_skill_year_box('skill_year_id',db_result($result,$i,'skill_year_id')). '</td>
321 <td width="25%" nowrap="nowrap"><input type="submit" name="update_job_inventory" value="'._('Update').'" />
322 <input type="submit" name="delete_from_job_inventory" value="'._('Delete').'" /></td>
328 (isset($i)) ? $i++ : $i = 0; //for row coloring
331 <tr><td colspan="4"><h3>'._('Add a new skill').'</h3></td></tr>
332 <tr '. $HTML->boxGetAltRowStyle($i) . '>
333 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
334 <input type="hidden" name="job_id" value="'. $job_id .'" />
335 <input type="hidden" name="group_id" value="'.$group_id.'" />
336 <td width="25%">'. people_skill_box('skill_id'). '</td>
337 <td width="25%">'. people_skill_level_box('skill_level_id'). '</td>
338 <td width="25%">'. people_skill_year_box('skill_year_id'). '</td>
339 <td width="25%" nowrap="nowrap"><input type="submit" name="add_to_job_inventory" value="'._('Add Skill').'" /></td>
342 echo $HTML->listTableBottom();
345 function people_show_category_table() {
346 //show a list of categories in a table
347 //provide links to drill into a detail page that shows these categories
350 $title_arr[]=_('Category');;
352 $return = $GLOBALS['HTML']->listTableTop ($title_arr);
354 $result= db_query_params('SELECT pjc.category_id, pjc.name, COUNT(pj.category_id) AS total
355 FROM people_job_category pjc LEFT JOIN people_job pj
356 ON pjc.category_id=pj.category_id
357 WHERE pjc.private_flag=0
358 AND (pj.status_id=1 OR pj.status_id IS NULL)
359 GROUP BY pjc.category_id, pjc.name', array());
361 $rows=db_numrows($result);
362 if (!$result || $rows < 1) {
363 $return .= '<tr><td><h2>'._('No Categories Found').'</h2></td></tr>';
365 for ($i=0; $i<$rows; $i++) {
367 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'
368 .util_make_link ('/people/?category_id='. db_result($result,$i,'category_id'), db_result($result,$i,'name')) .' ('. db_result($result,$i,'total') .')</td></tr>';
371 $return .= $GLOBALS['HTML']->listTableBottom();
375 function people_show_project_jobs($group_id) {
376 //show open jobs for this project
377 $result = db_query_params('SELECT people_job.group_id,people_job.job_id,groups.group_name,groups.unix_group_name,people_job.title,people_job.post_date,people_job_category.name AS category_name
378 FROM people_job,people_job_category,groups
379 WHERE people_job.group_id=$1
380 AND people_job.group_id=groups.group_id
381 AND people_job.category_id=people_job_category.category_id
382 AND people_job.status_id=1 ORDER BY post_date DESC', array($group_id));
384 return people_show_job_list($result);
387 function people_show_category_jobs($category_id) {
388 //show open jobs for this category
389 $result=db_query_params('SELECT people_job.group_id,people_job.job_id,groups.unix_group_name,groups.group_name,people_job.title,people_job.post_date,people_job_category.name AS category_name
390 FROM people_job,people_job_category,groups
391 WHERE people_job.category_id=$1
392 AND people_job.group_id=groups.group_id
393 AND people_job.category_id=people_job_category.category_id
394 AND people_job.status_id=1 ORDER BY post_date DESC', array($category_id));
396 return people_show_job_list($result);
399 function people_show_job_list($result) {
400 //takes a result set from a query and shows the jobs
402 //query must contain 'group_id', 'job_id', 'title', 'category_name' and 'status_name'
405 $title_arr[]=_('Title');
406 $title_arr[]=_('Category');
407 $title_arr[]=_('Date Opened');
408 $title_arr[]= sprintf(_('%1$s project'), forge_get_config ('forge_name'));
410 $return = $GLOBALS['HTML']->listTableTop ($title_arr);
412 $rows=db_numrows($result);
413 if (!isset($i)){$i=1;}
415 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td class="warning" colspan="4">'._('None Found'). db_error() .'</td></tr>';
417 for ($i=0; $i < $rows; $i++) {
419 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .
420 '><td>'.util_make_link ('/people/viewjob.php?group_id='. db_result($result,$i,'group_id') .'&job_id='. db_result($result,$i,'job_id'), db_result($result,$i,'title')) .'</td><td>'.
421 db_result($result,$i,'category_name') .'</td><td>'.
422 date(_('Y-m-d H:i'),db_result($result,$i,'post_date')) .
423 '</td><td>'.util_make_link_g (strtolower(db_result($result,$i,'unix_group_name')),db_result($result,$i,'group_id'),db_result($result,$i,'group_name')) .'</td></tr>';
427 $return .= $GLOBALS['HTML']->listTableBottom();
434 // c-file-style: "bsd"