5 * Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 function people_header($params) {
27 global $group_id,$job_id,$HTML;
30 $params['toptab']='people';
31 $params['group']=$group_id;
32 echo site_project_header($params);
34 echo $HTML->header($params);
37 if ($group_id && $job_id) {
38 echo ' | '.util_make_link ('/people/editjob.php?group_id='. $group_id .'&job_id='. $job_id,_('Edit Job'));
42 function people_footer($params) {
43 global $feedback, $HTML;
44 html_feedback_bottom($feedback);
45 $HTML->footer($params);
48 function people_skill_box($name='skill_id',$checked='xyxy') {
51 //will be used many times potentially on a single page
52 $PEOPLE_SKILL=db_query_params("SELECT * FROM people_skill ORDER BY name ASC", array());
54 return html_build_select_box($PEOPLE_SKILL,$name,$checked);
57 function people_skill_level_box($name='skill_level_id',$checked='xyxy') {
58 global $PEOPLE_SKILL_LEVEL;
59 if (!$PEOPLE_SKILL_LEVEL) {
60 //will be used many times potentially on a single page
61 $PEOPLE_SKILL_LEVEL=db_query_params("SELECT * FROM people_skill_level", array());
63 return html_build_select_box ($PEOPLE_SKILL_LEVEL,$name,$checked);
66 function people_skill_year_box($name='skill_year_id',$checked='xyxy') {
67 global $PEOPLE_SKILL_YEAR;
68 if (!$PEOPLE_SKILL_YEAR) {
69 //will be used many times potentially on a single page
70 $PEOPLE_SKILL_YEAR=db_query_params("SELECT * FROM people_skill_year", array());
72 return html_build_select_box ($PEOPLE_SKILL_YEAR,$name,$checked);
75 function people_job_status_box($name='status_id',$checked='xyxy') {
76 $result=db_query_params("SELECT * FROM people_job_status", array());
77 return html_build_select_box ($result,$name,$checked);
80 function people_job_category_box($name='category_id',$checked='xyxy') {
81 $result=db_query_params("SELECT category_id,name FROM people_job_category WHERE private_flag=0", array());
82 return html_build_select_box ($result,$name,$checked);
85 function people_add_to_skill_inventory($skill_id,$skill_level_id,$skill_year_id) {
87 if (session_loggedin()) {
88 // check required fields
89 if (!$skill_id || $skill_id == "xyxy") {
90 $feedback .= _('Must select a skill ID');
92 //check if they've already added this skill
93 $result=db_query_prams("SELECT * FROM people_skill_inventory WHERE user_id=$1 AND skill_id=$2", array(user_getid(), $skill_id));
94 if (!$result || db_numrows($result) < 1) {
95 //skill not already in inventory
96 $result = db_query_params("INSERT INTO people_skill_inventory (user_id,skill_id,skill_level_id,skill_year_id)
97 VALUES ($1, $2, $3, $4)", array(user_getid() ,$skill_id, $skill_level_id, $skill_year_id));
98 if (!$result || db_affected_rows($result) < 1) {
99 $feedback .= _('ERROR inserting into skill inventory');
102 $feedback .= _('Added to skill inventory');
105 $feedback .= _('ERROR - skill already in your inventory');
109 echo '<h1>'._('You must be logged in first').'</h1>';
113 function people_show_skill_inventory($user_id) {
114 $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
115 FROM people_skill_year,people_skill_level,people_skill,people_skill_inventory
116 WHERE people_skill_year.skill_year_id=people_skill_inventory.skill_year_id
117 AND people_skill_level.skill_level_id=people_skill_inventory.skill_level_id
118 AND people_skill.skill_id=people_skill_inventory.skill_id
119 AND people_skill_inventory.user_id=$1", array($user_id));
122 $title_arr[]=_('Skill');
123 $title_arr[]=_('Level');
124 $title_arr[]=_('Experience');
127 echo $GLOBALS['HTML']->listTableTop ($title_arr);
129 $rows=db_numrows($result);
130 if (!$result || $rows < 1) {
132 <h2>'._('No Skill Inventory Set Up').'</h2>';
135 for ($i=0; $i < $rows; $i++) {
137 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
138 <td>'.db_result($result,$i,'skill_name').'</td>
139 <td>'.db_result($result,$i,'level_name').'</td>
140 <td>'.db_result($result,$i,'year_name').'</td></tr>';
145 echo $GLOBALS['HTML']->listTableBottom();
148 function people_edit_skill_inventory($user_id) {
149 $result=db_query_params('SELECT * FROM people_skill_inventory WHERE user_id=$1', array($user_id));
152 $title_arr[]=_('Skill');
153 $title_arr[]=_('Level');
154 $title_arr[]=_('Experience');
155 $title_arr[]=_('Action');
157 echo $GLOBALS['HTML']->listTableTop ($title_arr);
159 $rows=db_numrows($result);
160 if (!$result || $rows < 1) {
162 <tr><td colspan="4">'._('No skill setup').'</h2></td></tr>';
165 for ($i=0; $i < $rows; $i++) {
167 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
168 <input type="hidden" name="skill_inventory_id" value="'.db_result($result,$i,'skill_inventory_id').'" />
169 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
170 <td>'. people_get_skill_name(db_result($result,$i,'skill_id')) .'</td>
171 <td>'. people_skill_level_box('skill_level_id',db_result($result,$i,'skill_level_id')). '</td>
172 <td>'. people_skill_year_box('skill_year_id',db_result($result,$i,'skill_year_id')). '</td>
173 <td nowrap="nowrap"><input type="submit" name="update_skill_inventory" value="'._('Update').'" />
174 <input type="submit" name="delete_from_skill_inventory" value="'._('Delete').'" /></td>
180 $i++; //for row coloring
183 <tr class="tableheading"><td colspan="4">'._('Add a new skill').'/td></tr>
184 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
185 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
186 <td>'. people_skill_box('skill_id'). '</td>
187 <td>'. people_skill_level_box('skill_level_id'). '</td>
188 <td>'. people_skill_year_box('skill_year_id'). '</td>
189 <td nowrap="nowrap"><input type="submit" name="add_to_skill_inventory" value="'._('Add Skill').'" /></td>
192 echo $GLOBALS['HTML']->listTableBottom();
197 function people_add_to_job_inventory($job_id,$skill_id,$skill_level_id,$skill_year_id) {
199 if (session_loggedin()) {
200 //check if they've already added this skill
201 $result=db_query_params('SELECT * FROM people_job_inventory WHERE job_id=$1 AND skill_id=$2', array($job_id, $skill_id));
202 if (!$result || db_numrows($result) < 1) {
203 //skill isn't already in this inventory
204 $result=db_query_params('INSERT INTO people_job_inventory (job_id,skill_id,skill_level_id,skill_year_id)
205 VALUES ($1, $2, $3, $4)', array($job_id, $skill_id, $skill_level_id, $skill_year_id));
206 if (!$result || db_affected_rows($result) < 1) {
207 $feedback .= _('ERROR inserting into skill inventory');
210 $feedback .= _('Added to skill inventory');
213 $feedback .= _('ERROR - skill already in your inventory');
217 echo '<h1>'._('You must be logged in first').'</h1>';
221 function people_show_job_inventory($job_id) {
222 $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
223 FROM people_skill_year,people_skill_level,people_skill,people_job_inventory
224 WHERE people_skill_year.skill_year_id=people_job_inventory.skill_year_id
225 AND people_skill_level.skill_level_id=people_job_inventory.skill_level_id
226 AND people_skill.skill_id=people_job_inventory.skill_id
227 AND people_job_inventory.job_id=$1', array($job_id));
231 $title_arr[]=_('Skill');
232 $title_arr[]=_('Level');
233 $title_arr[]=_('Experience');
235 echo $GLOBALS['HTML']->listTableTop ($title_arr);
237 $rows=db_numrows($result);
238 if (!$result || $rows < 1) {
240 <tr><td><h2>'._('No Skill Inventory Set Up').'</h2></td></tr>';
243 for ($i=0; $i < $rows; $i++) {
245 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>
246 <td>'.db_result($result,$i,'skill_name').'</td>
247 <td>'.db_result($result,$i,'level_name').'</td>
248 <td>'.db_result($result,$i,'year_name').'</td></tr>';
253 echo $GLOBALS['HTML']->listTableBottom();
257 function people_verify_job_group($job_id,$group_id) {
258 $result=db_query_params('SELECT * FROM people_job WHERE job_id=$1 AND group_id=$2', array($job_id, $group_id));
259 if (!$result || db_numrows($result) < 1) {
266 function people_get_skill_name($skill_id) {
267 $result=db_query_params('SELECT name FROM people_skill WHERE skill_id=$1', array($skill_id));
268 if (!$result || db_numrows($result) < 1) {
269 return _('Invalid ID');
271 return db_result($result,0,'name');
275 function people_get_category_name($category_id) {
276 $result=db_query_params('SELECT name FROM people_job_category WHERE category_id=$1', array($category_id));
277 if (!$result || db_numrows($result) < 1) {
280 return db_result($result,0,'name');
285 // This function does not produce valid XHTML; however, I could not
286 // think of a way of turning into valid XHTML without the resulting
287 // table looking like poo.
288 function people_edit_job_inventory($job_id,$group_id) {
290 $result=db_query_params('SELECT * FROM people_job_inventory WHERE job_id=$1', array($job_id));
293 $title_arr[]=_('Skill').utils_requiredField();
294 $title_arr[]=_('Level').utils_requiredField();
295 $title_arr[]=_('Experience').utils_requiredField();
296 $title_arr[]=_('Action');
298 echo $HTML->listTableTop ($title_arr);
300 $rows=db_numrows($result);
301 if (!$result || $rows < 1) {
303 <tr><td colspan="4"><h2>'._('No Skill Inventory Set Up').'</h2></td></tr>';
306 for ($i=0; $i < $rows; $i++) {
308 <tr '. $HTML->boxGetAltRowStyle($i) . '>
309 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
310 <input type="hidden" name="job_inventory_id" value="'. db_result($result,$i,'job_inventory_id') .'" />
311 <input type="hidden" name="job_id" value="'. db_result($result,$i,'job_id') .'" />
312 <input type="hidden" name="group_id" value="'.$group_id.'" />
313 <td width="25%">'. people_get_skill_name(db_result($result,$i,'skill_id')) . '</td>
314 <td width="25%">'. people_skill_level_box('skill_level_id',db_result($result,$i,'skill_level_id')). '</td>
315 <td width="25%">'. people_skill_year_box('skill_year_id',db_result($result,$i,'skill_year_id')). '</td>
316 <td width="25%" nowrap="nowrap"><input type="submit" name="update_job_inventory" value="'._('Update').'" />
317 <input type="submit" name="delete_from_job_inventory" value="'._('Delete').'" /></td>
323 $i++; //for row coloring
326 <tr><td colspan="4"><h3>'._('Add a new skill').'</h3></td></tr>
327 <tr '. $HTML->boxGetAltRowStyle($i) . '>
328 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
329 <input type="hidden" name="job_id" value="'. $job_id .'" />
330 <input type="hidden" name="group_id" value="'.$group_id.'" />
331 <td width="25%">'. people_skill_box('skill_id'). '</td>
332 <td width="25%">'. people_skill_level_box('skill_level_id'). '</td>
333 <td width="25%">'. people_skill_year_box('skill_year_id'). '</td>
334 <td width="25%" nowrap="nowrap"><input type="submit" name="add_to_job_inventory" value="'._('Add Skill').'" /></td>
337 echo $HTML->listTableBottom();
340 function people_show_category_table() {
341 //show a list of categories in a table
342 //provide links to drill into a detail page that shows these categories
345 $title_arr[]=_('Category');;
347 $return = $GLOBALS['HTML']->listTableTop ($title_arr);
349 $result= db_query_params('SELECT pjc.category_id, pjc.name, COUNT(pj.category_id) AS total
350 FROM people_job_category pjc LEFT JOIN people_job pj
351 ON pjc.category_id=pj.category_id
352 WHERE pjc.private_flag=0
353 AND (pj.status_id=1 OR pj.status_id IS NULL)
354 GROUP BY pjc.category_id, pjc.name', array());
356 $rows=db_numrows($result);
357 if (!$result || $rows < 1) {
358 $return .= '<tr><td><h2>'._('No Categories Found').'</h2></td></tr>';
360 for ($i=0; $i<$rows; $i++) {
362 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'
363 .util_make_link ('/people/?category_id='. db_result($result,$i,'category_id'), db_result($result,$i,'name')) .' ('. db_result($result,$i,'total') .')</td></tr>';
366 $return .= $GLOBALS['HTML']->listTableBottom();
370 function people_show_project_jobs($group_id) {
371 //show open jobs for this project
372 $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
373 FROM people_job,people_job_category,groups
374 WHERE people_job.group_id=$1
375 AND people_job.group_id=groups.group_id
376 AND people_job.category_id=people_job_category.category_id
377 AND people_job.status_id=1 ORDER BY post_date DESC', array($group_id));
379 return people_show_job_list($result);
382 function people_show_category_jobs($category_id) {
383 //show open jobs for this category
384 $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
385 FROM people_job,people_job_category,groups
386 WHERE people_job.category_id=$1
387 AND people_job.group_id=groups.group_id
388 AND people_job.category_id=people_job_category.category_id
389 AND people_job.status_id=1 ORDER BY post_date DESC', array($category_id));
391 return people_show_job_list($result);
394 function people_show_job_list($result) {
395 //takes a result set from a query and shows the jobs
397 //query must contain 'group_id', 'job_id', 'title', 'category_name' and 'status_name'
400 $title_arr[]=_('Title');
401 $title_arr[]=_('Category');
402 $title_arr[]=_('Date Opened');
403 $title_arr[]= sprintf(_('%1$s project'), forge_get_config ('forge_name'));
405 $return = $GLOBALS['HTML']->listTableTop ($title_arr);
407 $rows=db_numrows($result);
408 if (!isset($i)){$i=1;}
410 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td class="error" colspan="4">'._('None Found'). db_error() .'</td></tr>';
412 for ($i=0; $i < $rows; $i++) {
414 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .
415 '><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>'.
416 db_result($result,$i,'category_name') .'</td><td>'.
417 date(_('Y-m-d H:i'),db_result($result,$i,'post_date')) .
418 '</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>';
422 $return .= $GLOBALS['HTML']->listTableBottom();
429 // c-file-style: "bsd"