1 |
<?php |
2 |
/********************************************************** |
3 |
Function Library: assign.php |
4 |
Original Author: Paul Bramscher <brams006@umn.edu> |
5 |
Last Modified: 03.10.2004 by Paul Bramscher |
6 |
*********************************************************** |
7 |
Comments: |
8 |
This library brings together all SQL assignment type |
9 |
functions. |
10 |
*********************************************************** |
11 |
Table of Contents: |
12 |
assignLibunitStaff |
13 |
assignResFeature |
14 |
assignResLoc |
15 |
assignResMastersubject |
16 |
assignServLoc |
17 |
assignServServtype |
18 |
assignStaffLibunit |
19 |
assignStaffSub |
20 |
assignSubCoursesub |
21 |
assignSubLoc |
22 |
assignSubMaster |
23 |
assignSubStaff |
24 |
**********************************************************/ |
25 |
|
26 |
|
27 |
/********************************************************** |
28 |
Function: assignLibunitStaff |
29 |
Author: Paul Bramscher |
30 |
Last Modified: 03.02.2004 |
31 |
*********************************************************** |
32 |
Purpose: |
33 |
Assigns staff (possibly multiple) to a given library unit |
34 |
and calls formLibunit back again. |
35 |
**********************************************************/ |
36 |
function assignLibunitStaff($staff_id_array, $libunit_id) { |
37 |
|
38 |
// For all staff in the array |
39 |
for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) { |
40 |
|
41 |
// Check to make sure that the staff isn't already assigned |
42 |
$sql = "SELECT * FROM libunit_staff WHERE libunit_id = " . $libunit_id . |
43 |
" AND staff_id = " . $staff_id_array[$subscript]; |
44 |
$rs = mysql_tryquery($sql); |
45 |
if (mysql_num_rows($rs) == 0) { |
46 |
|
47 |
$sql = "INSERT INTO libunit_staff (libunit_id, staff_id) VALUES (" |
48 |
. $libunit_id |
49 |
. ", " |
50 |
. $staff_id_array[$subscript] |
51 |
. ")"; |
52 |
|
53 |
mysql_tryquery($sql); |
54 |
|
55 |
} // staff not already assigned |
56 |
|
57 |
} // array of staff id's |
58 |
|
59 |
// Call the Libunit form back |
60 |
formLibunit($libunit_id); |
61 |
|
62 |
} // function |
63 |
|
64 |
|
65 |
/********************************************************** |
66 |
Function: assignResFeature |
67 |
Author: Paul Bramscher |
68 |
Last Modified: 03.03.2004 |
69 |
*********************************************************** |
70 |
Purpose: |
71 |
Assigns features (possibly multiple) to a given resource |
72 |
and calls formResource back again. |
73 |
**********************************************************/ |
74 |
function assignResFeature($feature_id_array, $resource_id) { |
75 |
|
76 |
// For all features in the array |
77 |
for ($subscript = 0; $subscript < sizeof($feature_id_array); $subscript++ ) { |
78 |
|
79 |
// Check to make sure that the feature isn't already assigned |
80 |
$sql = "SELECT * FROM res_feature WHERE resource_id = " |
81 |
. $resource_id |
82 |
. " AND feature_id = " |
83 |
. $feature_id_array[$subscript]; |
84 |
|
85 |
$rs = mysql_tryquery($sql); |
86 |
if (mysql_num_rows($rs) == 0) { |
87 |
|
88 |
$sql = "INSERT INTO res_feature (resource_id, feature_id) VALUES (" |
89 |
. $resource_id |
90 |
. ", " |
91 |
. $feature_id_array[$subscript] |
92 |
. ")"; |
93 |
|
94 |
mysql_tryquery($sql); |
95 |
|
96 |
} // feature not already assigned |
97 |
|
98 |
} // array of feature id's |
99 |
|
100 |
// Call the resource form back |
101 |
formResource($resource_id, 0, 0, ''); |
102 |
|
103 |
} // function |
104 |
|
105 |
|
106 |
/********************************************************** |
107 |
Function: assignResLoc |
108 |
Author: Paul Bramscher |
109 |
Last Modified: 03.02.2004 |
110 |
*********************************************************** |
111 |
Purpose: |
112 |
Assigns locations (possibly multiple) to a given resource |
113 |
and calls formResource back again. |
114 |
**********************************************************/ |
115 |
function assignResLoc($location_id_array, $resource_id) { |
116 |
|
117 |
// For every location in the array |
118 |
for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) { |
119 |
|
120 |
// Check to make sure that the location isn't already assigned |
121 |
$sql = "SELECT * FROM res_loc WHERE resource_id = " |
122 |
. $resource_id |
123 |
. " AND location_id = " |
124 |
. $location_id_array[$subscript]; |
125 |
|
126 |
$rs = mysql_tryquery($sql); |
127 |
if (mysql_num_rows($rs) == 0) { |
128 |
|
129 |
$sql = "INSERT INTO res_loc (resource_id, location_id) VALUES (" |
130 |
. $resource_id |
131 |
. ", " |
132 |
. $location_id_array[$subscript] |
133 |
. ")"; |
134 |
|
135 |
mysql_tryquery($sql); |
136 |
|
137 |
} // location not already assigned |
138 |
|
139 |
} // array of location id's |
140 |
|
141 |
// Call the resource form back |
142 |
formResource($resource_id, 0, 0, ''); |
143 |
|
144 |
} // function |
145 |
|
146 |
|
147 |
/********************************************************** |
148 |
Function: assignResMastersubject |
149 |
Author: Paul Bramscher |
150 |
Last Modified: 03.02.2004 |
151 |
*********************************************************** |
152 |
Purpose: |
153 |
Assigns master subjects (possibly multiple) to a given |
154 |
resource and calls formResource back again. |
155 |
**********************************************************/ |
156 |
function assignResMastersubject($mastersubject_id_array, $resource_id) { |
157 |
|
158 |
// For every location in the array |
159 |
for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) { |
160 |
|
161 |
// Check to make sure that the masterinfotype isn't already assigned |
162 |
$sql = "SELECT * FROM res_mastersubject WHERE resource_id = " |
163 |
. $resource_id |
164 |
. " AND mastersubject_id = " |
165 |
. $mastersubject_id_array[$subscript]; |
166 |
|
167 |
$rs = mysql_tryquery($sql); |
168 |
if (mysql_num_rows($rs) == 0) { |
169 |
|
170 |
$sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES (" |
171 |
. $resource_id |
172 |
. ", " |
173 |
. $mastersubject_id_array[$subscript] |
174 |
. ")"; |
175 |
|
176 |
mysql_tryquery($sql); |
177 |
|
178 |
} // mastersubject not already assigned |
179 |
|
180 |
} // array of mastersubject id's |
181 |
|
182 |
// Call the resource form back |
183 |
formResource($resource_id, 0, 0, ''); |
184 |
|
185 |
} // function |
186 |
|
187 |
|
188 |
/********************************************************** |
189 |
Function: assignServLoc |
190 |
Author: Paul Bramscher |
191 |
Last Modified: 03.02.2004 |
192 |
*********************************************************** |
193 |
Purpose: |
194 |
Assigns locations (possibly multiple) to a given service |
195 |
and calls formService back again. |
196 |
**********************************************************/ |
197 |
function assignServLoc($location_id_array, $service_id) { |
198 |
|
199 |
// For every location, assign it to the selected service |
200 |
for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) { |
201 |
|
202 |
// Check to make sure that the location isn't already assigned |
203 |
$sql = "SELECT * FROM serv_loc where service_id = " |
204 |
. $service_id |
205 |
. " AND location_id = " |
206 |
. $location_id_array[$subscript]; |
207 |
|
208 |
$rs = mysql_tryquery($sql); |
209 |
if (mysql_num_rows($rs) == 0) { |
210 |
|
211 |
$sql = "INSERT INTO serv_loc (service_id, location_id) VALUES (" |
212 |
. $service_id |
213 |
. ", " |
214 |
. $location_id_array[$subscript] |
215 |
. ")"; |
216 |
|
217 |
mysql_tryquery($sql); |
218 |
|
219 |
} // location not already assigned |
220 |
|
221 |
} // array of location id's |
222 |
|
223 |
// Call the service form back |
224 |
formService($service_id); |
225 |
|
226 |
} // function |
227 |
|
228 |
|
229 |
/********************************************************** |
230 |
Function: assignServServtype |
231 |
Author: Paul Bramscher |
232 |
Last Modified: 03.02.2004 |
233 |
*********************************************************** |
234 |
Purpose: |
235 |
Assigns service types (possibly multiple) to a given |
236 |
service and calls formService back again. |
237 |
**********************************************************/ |
238 |
function assignServServtype($servicetype_id_array, $service_id) { |
239 |
|
240 |
// For every servicetype, assign it to the selected service |
241 |
for ($subscript = 0; $subscript < sizeof($servicetype_id_array); $subscript++ ) { |
242 |
|
243 |
// Check to make sure that the servicetype isn't already assigned |
244 |
$sql = "SELECT * FROM serv_servtype WHERE service_id = " |
245 |
. $service_id |
246 |
. " AND servicetype_id = " |
247 |
. $servicetype_id_array[$subscript]; |
248 |
|
249 |
$rs = mysql_tryquery($sql); |
250 |
if (mysql_num_rows($rs) == 0) { |
251 |
|
252 |
$sql = "INSERT INTO serv_servtype (service_id, servicetype_id) VALUES (" |
253 |
. $service_id |
254 |
. ", " |
255 |
. $servicetype_id_array[$subscript] |
256 |
. ")"; |
257 |
|
258 |
mysql_tryquery($sql); |
259 |
|
260 |
} // servicetype not already assigned |
261 |
|
262 |
} // array of servicetype id's |
263 |
|
264 |
// Call the service form back |
265 |
formService($service_id); |
266 |
|
267 |
} // function |
268 |
|
269 |
|
270 |
/********************************************************** |
271 |
Function: assignStaffLibunit |
272 |
Author: Paul Bramscher |
273 |
Last Modified: 03.02.2004 |
274 |
*********************************************************** |
275 |
Purpose: |
276 |
Assigns library units (possibly multiple) to a given |
277 |
staffperson and calls formStaff back again. This handles |
278 |
the same bridging table as assignLibunitStaff, but from |
279 |
the other side of the multiple pick list relationship. |
280 |
**********************************************************/ |
281 |
function assignStaffLibunit($libunit_id_array, $staff_id) { |
282 |
|
283 |
// This function assigns library units to a selected staff person |
284 |
for ($subscript = 0; $subscript < sizeof($libunit_id_array); $subscript++ ) { |
285 |
|
286 |
// Check to make sure that the libunit isn't already assigned |
287 |
$sql = "SELECT * FROM libunit_staff WHERE staff_id = " |
288 |
. $staff_id |
289 |
. " AND libunit_id = " |
290 |
. $libunit_id_array[$subscript]; |
291 |
|
292 |
$rs = mysql_tryquery($sql); |
293 |
if (mysql_num_rows($rs) == 0) { |
294 |
|
295 |
$sql = "INSERT INTO libunit_staff (libunit_id, staff_id) VALUES (" |
296 |
. $libunit_id_array[$subscript] |
297 |
. ", " |
298 |
. $staff_id |
299 |
. ")"; |
300 |
|
301 |
mysql_tryquery($sql); |
302 |
|
303 |
} // assignment didn't already exist |
304 |
|
305 |
} // array of libunit id's |
306 |
|
307 |
// Call the staff form back |
308 |
formStaff($staff_id); |
309 |
|
310 |
} // function |
311 |
|
312 |
|
313 |
/********************************************************** |
314 |
Function: assignStaffSub |
315 |
Author: Paul Bramscher |
316 |
Last Modified: 03.02.2004 |
317 |
*********************************************************** |
318 |
Purpose: |
319 |
Assigns subjects (possibly multiple) to a given staffperson |
320 |
and calls formStaff back again. |
321 |
**********************************************************/ |
322 |
function assignStaffSub($staff_id, $subject_id_array) { |
323 |
|
324 |
// This function assigns subjects to a selected staff person |
325 |
for ($subscript = 0; $subscript < sizeof($subject_id_array); $subscript++ ) { |
326 |
|
327 |
// Check to make sure that the subject isn't already assigned |
328 |
$sql = "SELECT * FROM sub_staff WHERE staff_id = " |
329 |
. $staff_id |
330 |
. " AND subject_id = " |
331 |
. $subject_id_array[$subscript]; |
332 |
|
333 |
$rs = mysql_tryquery($sql); |
334 |
if (mysql_num_rows($rs) == 0) { |
335 |
|
336 |
$sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES (" |
337 |
. $subject_id_array[$subscript] |
338 |
. ", " |
339 |
. $staff_id |
340 |
. ")"; |
341 |
|
342 |
mysql_tryquery($sql); |
343 |
|
344 |
} // assignment didn't already exist |
345 |
|
346 |
} // array of subject id's |
347 |
|
348 |
// Call the staff form back |
349 |
formStaff($staff_id); |
350 |
|
351 |
} // function |
352 |
|
353 |
|
354 |
/********************************************************** |
355 |
Function: assignSubCoursesub |
356 |
Author: Paul Bramscher |
357 |
Last Modified: 03.02.2004 |
358 |
*********************************************************** |
359 |
Purpose: |
360 |
Assigns course subjects (possibly multiple) to a given subject |
361 |
and calls formSubject back again. |
362 |
**********************************************************/ |
363 |
function assignSubCoursesub($coursesub_id_array, $subject_id) { |
364 |
|
365 |
// For every coursesub, assign it to the selected subject |
366 |
for ($subscript = 0; $subscript < sizeof($coursesub_id_array); $subscript++ ) { |
367 |
|
368 |
// Check to make sure that the coursesub isn't already assigned |
369 |
$sql = "SELECT * FROM sub_coursesub WHERE subject_id = " |
370 |
. $subject_id |
371 |
. " AND coursesub_id = " |
372 |
. $coursesub_id_array[$subscript]; |
373 |
|
374 |
$rs = mysql_tryquery($sql); |
375 |
if (mysql_num_rows($rs) == 0) { |
376 |
|
377 |
$sql = "INSERT INTO sub_coursesub (subject_id, coursesub_id) VALUES (" |
378 |
. $subject_id |
379 |
. ", " |
380 |
. $coursesub_id_array[$subscript] |
381 |
. ")"; |
382 |
|
383 |
mysql_tryquery($sql); |
384 |
|
385 |
} // coursesub not already assigned |
386 |
|
387 |
} // array of coursesub id's |
388 |
|
389 |
// Call the subject form back |
390 |
formSubject($subject_id); |
391 |
|
392 |
} // function |
393 |
|
394 |
|
395 |
/********************************************************** |
396 |
Function: assignSubLoc |
397 |
Author: Paul Bramscher |
398 |
Last Modified: 03.02.2004 |
399 |
*********************************************************** |
400 |
Purpose: |
401 |
Assigns locations (possibly multiple) to a given subject |
402 |
and calls formSubject back again. |
403 |
**********************************************************/ |
404 |
function assignSubLoc($location_id_array, $subject_id) { |
405 |
|
406 |
// For every location, assign it to the selected subject |
407 |
for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) { |
408 |
|
409 |
// Check to make sure that the location isn't already assigned |
410 |
$sql = "SELECT * FROM sub_loc WHERE subject_id = " |
411 |
. $subject_id |
412 |
. " AND location_id = " |
413 |
. $location_id_array[$subscript]; |
414 |
|
415 |
$rs = mysql_tryquery($sql); |
416 |
if (mysql_num_rows($rs) == 0) { |
417 |
|
418 |
$sql = "INSERT INTO sub_loc (subject_id, location_id) VALUES (" |
419 |
. $subject_id |
420 |
. ", " |
421 |
. $location_id_array[$subscript] |
422 |
. ")"; |
423 |
|
424 |
mysql_tryquery($sql); |
425 |
|
426 |
} // location not already assigned |
427 |
|
428 |
} // array of location id's |
429 |
|
430 |
// Call the subject form back |
431 |
formSubject($subject_id); |
432 |
|
433 |
} // function |
434 |
|
435 |
|
436 |
/********************************************************** |
437 |
Function: assignSubMaster |
438 |
Author: Paul Bramscher |
439 |
Last Modified: 03.02.2004 |
440 |
*********************************************************** |
441 |
Purpose: |
442 |
Assigns master subjects (possibly multiple) to a given |
443 |
subject and calls formSubject back again. |
444 |
**********************************************************/ |
445 |
function assignSubMaster($mastersubject_id_array, $subject_id) { |
446 |
|
447 |
// For every mastersubject, assign it to the selected subject |
448 |
for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) { |
449 |
|
450 |
// Check to make sure that the mastersubject isn't already assigned |
451 |
$sql = "SELECT * FROM sub_mastersubject WHERE subject_id = " |
452 |
. $subject_id |
453 |
. " AND mastersubject_id = " |
454 |
. $mastersubject_id_array[$subscript]; |
455 |
|
456 |
$rs = mysql_tryquery($sql); |
457 |
if (mysql_num_rows($rs) == 0) { |
458 |
|
459 |
$sql = "INSERT INTO sub_mastersubject (subject_id, mastersubject_id) VALUES (" |
460 |
. $subject_id |
461 |
. ", " |
462 |
. $mastersubject_id_array[$subscript] |
463 |
. ")"; |
464 |
|
465 |
mysql_tryquery($sql); |
466 |
|
467 |
} // location not already assigned |
468 |
|
469 |
} // array of mastersubject id's |
470 |
|
471 |
// Call the subject form back |
472 |
formSubject($subject_id); |
473 |
|
474 |
} // function |
475 |
|
476 |
|
477 |
/********************************************************** |
478 |
Function: assignSubStaff |
479 |
Author: Paul Bramscher |
480 |
Last Modified: 03.02.2004 |
481 |
*********************************************************** |
482 |
Purpose: |
483 |
Assigns staff specialists (possibly multiple) to a given |
484 |
subject and calls formSubject back again. |
485 |
**********************************************************/ |
486 |
function assignSubStaff($staff_id_array, $subject_id) { |
487 |
|
488 |
// For every staff person selected |
489 |
for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) { |
490 |
|
491 |
// Check to make sure that the specialist isn't already assigned |
492 |
$sql = "SELECT * FROM sub_staff WHERE subject_id = " |
493 |
. $subject_id |
494 |
. " AND staff_id = " |
495 |
. $staff_id_array[$subscript]; |
496 |
|
497 |
$rs = mysql_tryquery($sql); |
498 |
if (mysql_num_rows($rs) == 0) { |
499 |
|
500 |
$sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES (" |
501 |
. $subject_id |
502 |
. ", " |
503 |
. $staff_id_array[$subscript] |
504 |
. ")"; |
505 |
|
506 |
mysql_tryquery($sql); |
507 |
} |
508 |
|
509 |
} // array of staff id's |
510 |
|
511 |
// Call the subject form back |
512 |
formSubject($subject_id); |
513 |
|
514 |
} // function |
515 |
?> |