3 * Skills support functions.
5 * Copyright 2002 (c) Silicon and Software Systems (S3)
6 * http://fusionforge.org/
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 function displayUserSkills($user_id, $allowEdit) {
26 $result=db_query_params("SELECT * FROM skills_data_types ORDER BY type_id ASC", array());
27 $rows = db_numrows($result);
29 /* obtain the types keywords... */
30 for($i = 0; $i < $rows; $i++) {
31 $typesDescs[$i] = db_result($result, $i, 'type_name');
35 $result= db_query_params("SELECT * FROM skills_data WHERE user_id=$1 ORDER BY finish DESC, start ASC, skills_data_id DESC",array($user_id));
36 $rows = db_numrows($result);
37 if (!$result || $rows < 1) {
39 $feedback = 'No skills listed ';
40 echo '<tr><td>This user has not entered any skills.</td></tr>';
43 echo '<tr class="tableheading">'; /* headings for the columns */
45 echo '<td>'._('Edit').'</td>'.
46 '<td>'._('Delete').'</td>';
48 echo '<td>'._('Type').'</td>'.
49 '<td>'._('Title').'</td>'.
50 '<td>'._('Start Date').'</td>'.
51 '<td>'._('End Date').'</td>'.
52 '<td>'._('Keywords').'</td>'.
55 for ($i = 0; $i < $rows; $i++) /* for each entry in the database */ {
56 /* set up some variables to make things easier.... */
57 $typeID = db_result($result, $i, 'type');
58 $start = db_result($result, $i, 'start');
59 $finish = db_result($result, $i, 'finish');
61 $startY = substr($start, 0, 4);
62 $startM = substr($start, 4, 2);
64 $finishY = substr($finish, 0, 4);
65 $finishM = substr($finish, 4, 2);
67 if($startM > 0 && $startM < 13) {
68 $startStr = date ("M Y", mktime(0,0,0,$startM,1,$startY));
72 if (!(isset($finishtM))){
75 if($finishM > 0 && $finishtM < 13) {
76 $finishStr = date ("M Y", mktime(0,0,0,$finishM,1,$finishY));
78 $finishStr = $finishY;
81 /* now print out the row, formatted nicely */
82 echo '<tr '. $HTML->boxGetAltRowStyle($i+1) . '>';
84 echo '<td><input type="checkbox" name="skill_edit[]" value="'.db_result($result, $i, 'skills_data_id').'" /></td>';
85 echo '<td><input type="checkbox" name="skill_delete[]" value="'.db_result($result, $i, 'skills_data_id').'" /></td>';
87 if($typesDescs[$typeID]) {
88 echo '<td>'.$typesDescs[$typeID]."</td>\n";
90 echo '<td>'.$typeID ."</td>\n";
93 echo '<td>'.db_result($result, $i, 'title') ."</td>\n";
94 echo '<td>'.$startStr."</td>\n";
95 echo '<td>'.$finishStr."</td>\n";
96 echo '<td>'.db_result($result, $i, 'keywords') ."</td>\n";
103 echo '<td><input type="submit" name="MultiEdit" value="'._('Edit').'" /></td>';
104 echo '<td><input type="submit" name="MultiDelete" value="'._('Delete').'" /></td>';
111 function handle_multi_edit($skill_ids = array()) {
113 $result = db_query_params ('SELECT * FROM skills_data WHERE skills_data_id = ANY ($1)',
114 array (db_int_array_to_any_clause ($skill_ids)));
115 $rows = db_numrows($result);
116 if (!$result || $rows < 1) {
119 $skills=db_query_params("SELECT * FROM skills_data_types WHERE type_id > 0", array());
120 if (!$skills || db_numrows($skills) < 1) {
122 $feedback .= _('User fetch FAILED');
123 echo '<h2>'._('No Such User').'<h2>';
126 $yearArray = array();
127 for($years = date("Y"); $years >= 1980; $years--) {
128 array_push($yearArray,$years);
131 $monthArray = array();
132 $monthArrayVals = array();
133 for($i = 1; $i <= 12; $i++) {
134 array_push($monthArrayVals,($i<10?"0".$i:$i));
135 array_push($monthArray,date("M", mktime(0,0,0,$i,1,1980)));
140 for($i = 0; $i < $rows; $i++) {
141 $start = db_result($result, $i, 'start');
142 $finish = db_result($result, $i, 'finish');
144 $startY = substr($start, 0, 4);
145 $startM = substr($start, 4, 2);
147 $finishY = substr($finish, 0, 4);
148 $finishM = substr($finish, 4, 2);
151 '<tr '.$HTML->boxGetAltRowStyle($i+1).'>'.
152 '<td><h3>'.db_result($result, $i,'title').'</h3></td></tr>'.
155 '<tr class="tableheading">'.
156 '<td >'._('Type').'</td>'.
157 '<td >'._('Start Date').'</td>'.
158 '<td >'._('End Date').'</td>'.
160 echo '<tr '.$HTML->boxGetAltRowStyle($i+1).'>'.
161 '<td>'.html_build_select_box($skills, 'type[]',db_result($result, $i,'type') , false, '').'</td>'.
162 '<td>'.html_build_select_box_from_arrays($monthArrayVals,$monthArray, 'startM[]', $startM, false, '').
163 html_build_select_box_from_arrays($yearArray,$yearArray, 'startY[]', $startY, false, '').'</td>'.
164 '<td>'.html_build_select_box_from_arrays($monthArrayVals,$monthArray, 'endM[]', $finishM, false, '').
165 html_build_select_box_from_arrays($yearArray,$yearArray, 'endY[]', $finishY, false, '').'</td>'.
170 '<tr '.$HTML->boxGetAltRowStyle($i+1).'><td>'.
172 '<tr class="tableheading">'.
173 '<td>'._('Title (max 100 characters)').'</td>'.
176 '<td><input type="hidden" name="skill_edit[]" value="'.db_result($result, $i,'skills_data_id').'" />'.
177 '<input type="text" name="title[]" size="100" value="'.db_result($result, $i,'title').'" /></td>'.
180 '<td class="tableheading">'._('Keywords (max 255 characters)').'</td>'.
183 '<td><textarea name="keywords[]" rows="3" cols="85">'.db_result($result, $i,'keywords').'</textarea></td>'.
188 echo '</table><br />';
195 // c-file-style: "bsd"