/[libdata]/branches/paul_xx/admin/include/assign.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /branches/paul_xx/admin/include/assign.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 67 - (hide annotations)
Thu Mar 18 19:24:54 2004 UTC (20 years, 2 months ago) by dpavlin
Original Path: branches/paul/admin/include/assign.php
File size: 14556 byte(s)
updated to libdata 2.00

1 dpavlin 1 <?php
2     /**********************************************************
3     Function Library: assign.php
4 dpavlin 67 Original Author: Paul Bramscher <brams006@umn.edu>
5     Last Modified: 03.10.2004 by Paul Bramscher
6 dpavlin 1 ***********************************************************
7     Comments:
8     This library brings together all SQL assignment type
9     functions.
10     ***********************************************************
11     Table of Contents:
12 dpavlin 67 assignLibunitStaff
13 dpavlin 1 assignResFeature
14     assignResLoc
15     assignResMastersubject
16     assignServLoc
17     assignServServtype
18 dpavlin 67 assignStaffLibunit
19     assignStaffSub
20 dpavlin 1 assignSubCoursesub
21     assignSubLoc
22     assignSubMaster
23     assignSubStaff
24 dpavlin 67 **********************************************************/
25 dpavlin 1
26    
27 dpavlin 67 /**********************************************************
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 dpavlin 1
38 dpavlin 67 // 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 dpavlin 1
57 dpavlin 67 } // array of staff id's
58 dpavlin 1
59 dpavlin 67 // Call the Libunit form back
60     formLibunit($libunit_id);
61 dpavlin 1
62 dpavlin 67 } // function
63    
64    
65 dpavlin 1 /**********************************************************
66     Function: assignResFeature
67     Author: Paul Bramscher
68 dpavlin 67 Last Modified: 03.03.2004
69 dpavlin 1 ***********************************************************
70     Purpose:
71     Assigns features (possibly multiple) to a given resource
72     and calls formResource back again.
73     **********************************************************/
74 dpavlin 67 function assignResFeature($feature_id_array, $resource_id) {
75 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
86 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
95 dpavlin 1
96     } // feature not already assigned
97    
98     } // array of feature id's
99    
100     // Call the resource form back
101 dpavlin 67 formResource($resource_id, 0, 0, '');
102 dpavlin 1
103     } // function
104    
105    
106     /**********************************************************
107     Function: assignResLoc
108     Author: Paul Bramscher
109 dpavlin 67 Last Modified: 03.02.2004
110 dpavlin 1 ***********************************************************
111     Purpose:
112     Assigns locations (possibly multiple) to a given resource
113     and calls formResource back again.
114     **********************************************************/
115 dpavlin 67 function assignResLoc($location_id_array, $resource_id) {
116 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
127 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
136    
137 dpavlin 1 } // location not already assigned
138    
139     } // array of location id's
140    
141     // Call the resource form back
142 dpavlin 67 formResource($resource_id, 0, 0, '');
143 dpavlin 1
144     } // function
145    
146    
147     /**********************************************************
148     Function: assignResMastersubject
149     Author: Paul Bramscher
150 dpavlin 67 Last Modified: 03.02.2004
151 dpavlin 1 ***********************************************************
152     Purpose:
153     Assigns master subjects (possibly multiple) to a given
154     resource and calls formResource back again.
155     **********************************************************/
156 dpavlin 67 function assignResMastersubject($mastersubject_id_array, $resource_id) {
157 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
168 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
177    
178 dpavlin 1 } // mastersubject not already assigned
179    
180     } // array of mastersubject id's
181    
182     // Call the resource form back
183 dpavlin 67 formResource($resource_id, 0, 0, '');
184 dpavlin 1
185     } // function
186    
187    
188     /**********************************************************
189     Function: assignServLoc
190     Author: Paul Bramscher
191 dpavlin 67 Last Modified: 03.02.2004
192 dpavlin 1 ***********************************************************
193     Purpose:
194     Assigns locations (possibly multiple) to a given service
195     and calls formService back again.
196     **********************************************************/
197 dpavlin 67 function assignServLoc($location_id_array, $service_id) {
198 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
209 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
218 dpavlin 1
219     } // location not already assigned
220    
221     } // array of location id's
222    
223     // Call the service form back
224 dpavlin 67 formService($service_id);
225 dpavlin 1
226     } // function
227    
228    
229     /**********************************************************
230     Function: assignServServtype
231     Author: Paul Bramscher
232 dpavlin 67 Last Modified: 03.02.2004
233 dpavlin 1 ***********************************************************
234     Purpose:
235     Assigns service types (possibly multiple) to a given
236     service and calls formService back again.
237     **********************************************************/
238 dpavlin 67 function assignServServtype($servicetype_id_array, $service_id) {
239 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
250 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
259 dpavlin 1
260     } // servicetype not already assigned
261    
262     } // array of servicetype id's
263    
264     // Call the service form back
265 dpavlin 67 formService($service_id);
266 dpavlin 1
267     } // function
268    
269    
270     /**********************************************************
271 dpavlin 67 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 dpavlin 1 Function: assignSubCoursesub
356     Author: Paul Bramscher
357 dpavlin 67 Last Modified: 03.02.2004
358 dpavlin 1 ***********************************************************
359     Purpose:
360     Assigns course subjects (possibly multiple) to a given subject
361     and calls formSubject back again.
362     **********************************************************/
363 dpavlin 67 function assignSubCoursesub($coursesub_id_array, $subject_id) {
364 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
375 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
384 dpavlin 1
385     } // coursesub not already assigned
386    
387     } // array of coursesub id's
388    
389     // Call the subject form back
390 dpavlin 67 formSubject($subject_id);
391 dpavlin 1
392     } // function
393    
394    
395     /**********************************************************
396     Function: assignSubLoc
397     Author: Paul Bramscher
398 dpavlin 67 Last Modified: 03.02.2004
399 dpavlin 1 ***********************************************************
400     Purpose:
401     Assigns locations (possibly multiple) to a given subject
402     and calls formSubject back again.
403     **********************************************************/
404 dpavlin 67 function assignSubLoc($location_id_array, $subject_id) {
405 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
416 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
425 dpavlin 1
426     } // location not already assigned
427    
428     } // array of location id's
429    
430     // Call the subject form back
431 dpavlin 67 formSubject($subject_id);
432 dpavlin 1
433     } // function
434    
435    
436     /**********************************************************
437     Function: assignSubMaster
438     Author: Paul Bramscher
439 dpavlin 67 Last Modified: 03.02.2004
440 dpavlin 1 ***********************************************************
441     Purpose:
442     Assigns master subjects (possibly multiple) to a given
443     subject and calls formSubject back again.
444     **********************************************************/
445 dpavlin 67 function assignSubMaster($mastersubject_id_array, $subject_id) {
446 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
457 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
466 dpavlin 1
467     } // location not already assigned
468    
469     } // array of mastersubject id's
470    
471     // Call the subject form back
472 dpavlin 67 formSubject($subject_id);
473 dpavlin 1
474     } // function
475    
476    
477     /**********************************************************
478     Function: assignSubStaff
479     Author: Paul Bramscher
480 dpavlin 67 Last Modified: 03.02.2004
481 dpavlin 1 ***********************************************************
482     Purpose:
483     Assigns staff specialists (possibly multiple) to a given
484     subject and calls formSubject back again.
485     **********************************************************/
486 dpavlin 67 function assignSubStaff($staff_id_array, $subject_id) {
487 dpavlin 1
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 dpavlin 67 $rs = mysql_tryquery($sql);
498 dpavlin 1 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 dpavlin 67 mysql_tryquery($sql);
507 dpavlin 1 }
508    
509     } // array of staff id's
510    
511     // Call the subject form back
512 dpavlin 67 formSubject($subject_id);
513 dpavlin 1
514     } // function
515 dpavlin 67 ?>

  ViewVC Help
Powered by ViewVC 1.1.26