/[libdata]/trunk/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

Diff of /trunk/admin/include/assign.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 71 by dpavlin, Thu Mar 4 22:43:50 2004 UTC revision 72 by dpavlin, Thu Mar 18 20:33:37 2004 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /**********************************************************  /**********************************************************
3  Function Library: assign.php  Function Library: assign.php
4  Original Author: Paul Bramscher <brams006@tc.umn.edu>  Original Author: Paul Bramscher <brams006@umn.edu>
5  Last Modified: 06.17.2003 by Paul Bramscher  Last Modified: 03.10.2004 by Paul Bramscher
6  ***********************************************************  ***********************************************************
7  Comments:  Comments:
8  This library brings together all SQL assignment type  This library brings together all SQL assignment type
9  functions.  functions.
10  ***********************************************************  ***********************************************************
11  Table of Contents:  Table of Contents:
12    assignLibunitStaff
 Handling bridging tables  
 ========================  
13  assignResFeature  assignResFeature
14  assignResLoc  assignResLoc
15  assignResMastersubject  assignResMastersubject
16  assignServLoc  assignServLoc
17  assignServServtype  assignServServtype
18    assignStaffLibunit
19    assignStaffSub
20  assignSubCoursesub  assignSubCoursesub
21  assignSubLoc  assignSubLoc
22  assignSubMaster  assignSubMaster
23  assignSubStaff  assignSubStaff
24    **********************************************************/
25    
26    
27  assignLibunitStaff  /**********************************************************
28  assignStaffLibunit  Function: assignLibunitStaff
29  assignStaffSub  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 = xx_tryquery($sql);
45                    if (xx_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                            xx_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  Function: assignResFeature
67  Author: Paul Bramscher  Author: Paul Bramscher
68  Last Modified: 04.21.2003  Last Modified: 03.03.2004
69  ***********************************************************  ***********************************************************
70  Purpose:  Purpose:
71  Assigns features (possibly multiple) to a given resource  Assigns features (possibly multiple) to a given resource
72  and calls formResource back again.  and calls formResource back again.
73  **********************************************************/  **********************************************************/
74  function assignResFeature($con, $feature_id_array, $resource_id) {  function assignResFeature($feature_id_array, $resource_id) {
75    
76          // For all features in the array          // For all features in the array
77          for ($subscript = 0; $subscript < sizeof($feature_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($feature_id_array); $subscript++ ) {
# Line 51  function assignResFeature($con, $feature Line 82  function assignResFeature($con, $feature
82                          . " AND feature_id = "                          . " AND feature_id = "
83                          . $feature_id_array[$subscript];                          . $feature_id_array[$subscript];
84    
85                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
86                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
87                    
88                          $sql = "INSERT INTO res_feature (resource_id, feature_id) VALUES ("                          $sql = "INSERT INTO res_feature (resource_id, feature_id) VALUES ("
# Line 60  function assignResFeature($con, $feature Line 91  function assignResFeature($con, $feature
91                                  . $feature_id_array[$subscript]                                  . $feature_id_array[$subscript]
92                                  . ")";                                  . ")";
93    
94                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
   
                         } // good write of res_feature  
95                                                    
96                  } // feature not already assigned                  } // feature not already assigned
97    
98          } // array of feature id's          } // array of feature id's
99    
100          // Call the resource form back          // Call the resource form back
101          formResource($con, $resource_id, 0, 0, '');          formResource($resource_id, 0, 0, '');
102    
103  } // function  } // function
104    
# Line 83  function assignResFeature($con, $feature Line 106  function assignResFeature($con, $feature
106  /**********************************************************  /**********************************************************
107  Function: assignResLoc  Function: assignResLoc
108  Author: Paul Bramscher  Author: Paul Bramscher
109  Last Modified: 04.21.2003  Last Modified: 03.02.2004
110  ***********************************************************  ***********************************************************
111  Purpose:  Purpose:
112  Assigns locations (possibly multiple) to a given resource  Assigns locations (possibly multiple) to a given resource
113  and calls formResource back again.  and calls formResource back again.
114  **********************************************************/  **********************************************************/
115  function assignResLoc($con, $location_id_array, $resource_id) {  function assignResLoc($location_id_array, $resource_id) {
116    
117          // For every location in the array          // For every location in the array
118          for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {
# Line 100  function assignResLoc($con, $location_id Line 123  function assignResLoc($con, $location_id
123                          . " AND location_id = "                          . " AND location_id = "
124                          . $location_id_array[$subscript];                          . $location_id_array[$subscript];
125    
126                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
127                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
128    
129                          $sql = "INSERT INTO res_loc (resource_id, location_id) VALUES ("                          $sql = "INSERT INTO res_loc (resource_id, location_id) VALUES ("
# Line 109  function assignResLoc($con, $location_id Line 132  function assignResLoc($con, $location_id
132                                  . $location_id_array[$subscript]                                  . $location_id_array[$subscript]
133                                  . ")";                                  . ")";
134    
135                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
136                                  sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                   
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of res_loc  
137                  } // location not already assigned                  } // location not already assigned
138    
139          } // array of location id's          } // array of location id's
140    
141          // Call the resource form back          // Call the resource form back
142          formResource($con, $resource_id, 0, 0, '');          formResource($resource_id, 0, 0, '');
143    
144  } // function  } // function
145    
# Line 132  function assignResLoc($con, $location_id Line 147  function assignResLoc($con, $location_id
147  /**********************************************************  /**********************************************************
148  Function: assignResMastersubject  Function: assignResMastersubject
149  Author: Paul Bramscher  Author: Paul Bramscher
150  Last Modified: 04.21.2003  Last Modified: 03.02.2004
151  ***********************************************************  ***********************************************************
152  Purpose:  Purpose:
153  Assigns master subjects (possibly multiple) to a given  Assigns master subjects (possibly multiple) to a given
154  resource and calls formResource back again.  resource and calls formResource back again.
155  **********************************************************/  **********************************************************/
156  function assignResMastersubject($con, $mastersubject_id_array, $resource_id) {  function assignResMastersubject($mastersubject_id_array, $resource_id) {
157    
158          // For every location in the array          // For every location in the array
159          for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) {
# Line 149  function assignResMastersubject($con, $m Line 164  function assignResMastersubject($con, $m
164                          . " AND mastersubject_id = "                          . " AND mastersubject_id = "
165                          . $mastersubject_id_array[$subscript];                          . $mastersubject_id_array[$subscript];
166                                    
167                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
168                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
169    
170                          $sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES ("                          $sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES ("
# Line 158  function assignResMastersubject($con, $m Line 173  function assignResMastersubject($con, $m
173                                  . $mastersubject_id_array[$subscript]                                  . $mastersubject_id_array[$subscript]
174                                  . ")";                                  . ")";
175                    
176                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
177                                  sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                   
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of res_mastersubject  
178                  } // mastersubject not already assigned                  } // mastersubject not already assigned
179    
180          } // array of mastersubject id's          } // array of mastersubject id's
181    
182          // Call the resource form back          // Call the resource form back
183          formResource($con, $resource_id, 0, 0, '');          formResource($resource_id, 0, 0, '');
184    
185  } // function  } // function
186    
# Line 181  function assignResMastersubject($con, $m Line 188  function assignResMastersubject($con, $m
188  /**********************************************************  /**********************************************************
189  Function: assignServLoc  Function: assignServLoc
190  Author: Paul Bramscher  Author: Paul Bramscher
191  Last Modified: 04.21.2003  Last Modified: 03.02.2004
192  ***********************************************************  ***********************************************************
193  Purpose:  Purpose:
194  Assigns locations (possibly multiple) to a given service  Assigns locations (possibly multiple) to a given service
195  and calls formService back again.  and calls formService back again.
196  **********************************************************/  **********************************************************/
197  function assignServLoc($con, $location_id_array, $service_id) {  function assignServLoc($location_id_array, $service_id) {
198    
199          // For every location, assign it to the selected service          // For every location, assign it to the selected service
200          for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {
# Line 198  function assignServLoc($con, $location_i Line 205  function assignServLoc($con, $location_i
205                          . " AND location_id = "                          . " AND location_id = "
206                          . $location_id_array[$subscript];                          . $location_id_array[$subscript];
207    
208                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
209                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
210                    
211                          $sql = "INSERT INTO serv_loc (service_id, location_id) VALUES ("                          $sql = "INSERT INTO serv_loc (service_id, location_id) VALUES ("
# Line 207  function assignServLoc($con, $location_i Line 214  function assignServLoc($con, $location_i
214                                  . $location_id_array[$subscript]                                  . $location_id_array[$subscript]
215                                  . ")";                                  . ")";
216    
217                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of serv_loc  
218                                                    
219                  } // location not already assigned                  } // location not already assigned
220    
221          } // array of location id's          } // array of location id's
222    
223          // Call the service form back          // Call the service form back
224          formService($con, $service_id);          formService($service_id);
225    
226  } // function  } // function
227    
# Line 230  function assignServLoc($con, $location_i Line 229  function assignServLoc($con, $location_i
229  /**********************************************************  /**********************************************************
230  Function: assignServServtype  Function: assignServServtype
231  Author: Paul Bramscher  Author: Paul Bramscher
232  Last Modified: 04.21.2003  Last Modified: 03.02.2004
233  ***********************************************************  ***********************************************************
234  Purpose:  Purpose:
235  Assigns service types (possibly multiple) to a given  Assigns service types (possibly multiple) to a given
236  service and calls formService back again.  service and calls formService back again.
237  **********************************************************/  **********************************************************/
238  function assignServServtype($con, $servicetype_id_array, $service_id) {  function assignServServtype($servicetype_id_array, $service_id) {
239    
240          // For every servicetype, assign it to the selected service          // For every servicetype, assign it to the selected service
241          for ($subscript = 0; $subscript < sizeof($servicetype_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($servicetype_id_array); $subscript++ ) {
# Line 247  function assignServServtype($con, $servi Line 246  function assignServServtype($con, $servi
246                          . " AND servicetype_id = "                          . " AND servicetype_id = "
247                          . $servicetype_id_array[$subscript];                          . $servicetype_id_array[$subscript];
248    
249                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
250                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
251    
252                          $sql = "INSERT INTO serv_servtype (service_id, servicetype_id) VALUES ("                          $sql = "INSERT INTO serv_servtype (service_id, servicetype_id) VALUES ("
# Line 256  function assignServServtype($con, $servi Line 255  function assignServServtype($con, $servi
255                                  . $servicetype_id_array[$subscript]                                  . $servicetype_id_array[$subscript]
256                                  . ")";                                  . ")";
257    
258                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of serv_servtype  
259                                                    
260                  } // servicetype not already assigned                  } // servicetype not already assigned
261    
262          } // array of servicetype id's          } // array of servicetype id's
263    
264          // Call the service form back          // Call the service form back
265          formService($con, $service_id);          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 = xx_tryquery($sql);
293                    if (xx_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                            xx_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 = xx_tryquery($sql);
334                    if (xx_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                            xx_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  } // function
352    
# Line 279  function assignServServtype($con, $servi Line 354  function assignServServtype($con, $servi
354  /**********************************************************  /**********************************************************
355  Function: assignSubCoursesub  Function: assignSubCoursesub
356  Author: Paul Bramscher  Author: Paul Bramscher
357  Last Modified: 06.04.2003  Last Modified: 03.02.2004
358  ***********************************************************  ***********************************************************
359  Purpose:  Purpose:
360  Assigns course subjects (possibly multiple) to a given subject  Assigns course subjects (possibly multiple) to a given subject
361  and calls formSubject back again.  and calls formSubject back again.
362  **********************************************************/  **********************************************************/
363  function assignSubCoursesub($con, $coursesub_id_array, $subject_id) {  function assignSubCoursesub($coursesub_id_array, $subject_id) {
364    
365          // For every coursesub, assign it to the selected subject          // For every coursesub, assign it to the selected subject
366          for ($subscript = 0; $subscript < sizeof($coursesub_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($coursesub_id_array); $subscript++ ) {
# Line 296  function assignSubCoursesub($con, $cours Line 371  function assignSubCoursesub($con, $cours
371                          . " AND coursesub_id = "                          . " AND coursesub_id = "
372                          . $coursesub_id_array[$subscript];                          . $coursesub_id_array[$subscript];
373    
374                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
375                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
376    
377                          $sql = "INSERT INTO sub_coursesub (subject_id, coursesub_id) VALUES ("                          $sql = "INSERT INTO sub_coursesub (subject_id, coursesub_id) VALUES ("
# Line 305  function assignSubCoursesub($con, $cours Line 380  function assignSubCoursesub($con, $cours
380                                  . $coursesub_id_array[$subscript]                                  . $coursesub_id_array[$subscript]
381                                  . ")";                                  . ")";
382    
383                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of sub_coursesub  
384                                                    
385                  } // coursesub not already assigned                  } // coursesub not already assigned
386    
387          } // array of coursesub id's          } // array of coursesub id's
388    
389          // Call the subject form back          // Call the subject form back
390          formSubject($con, $subject_id);          formSubject($subject_id);
391    
392  } // function  } // function
393    
# Line 328  function assignSubCoursesub($con, $cours Line 395  function assignSubCoursesub($con, $cours
395  /**********************************************************  /**********************************************************
396  Function: assignSubLoc  Function: assignSubLoc
397  Author: Paul Bramscher  Author: Paul Bramscher
398  Last Modified: 04.21.2003  Last Modified: 03.02.2004
399  ***********************************************************  ***********************************************************
400  Purpose:  Purpose:
401  Assigns locations (possibly multiple) to a given subject  Assigns locations (possibly multiple) to a given subject
402  and calls formSubject back again.  and calls formSubject back again.
403  **********************************************************/  **********************************************************/
404  function assignSubLoc($con, $location_id_array, $subject_id) {  function assignSubLoc($location_id_array, $subject_id) {
405    
406          // For every location, assign it to the selected subject          // For every location, assign it to the selected subject
407          for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($location_id_array); $subscript++ ) {
# Line 345  function assignSubLoc($con, $location_id Line 412  function assignSubLoc($con, $location_id
412                          . " AND location_id = "                          . " AND location_id = "
413                          . $location_id_array[$subscript];                          . $location_id_array[$subscript];
414    
415                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
416                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
417    
418                          $sql = "INSERT INTO sub_loc (subject_id, location_id) VALUES ("                          $sql = "INSERT INTO sub_loc (subject_id, location_id) VALUES ("
# Line 354  function assignSubLoc($con, $location_id Line 421  function assignSubLoc($con, $location_id
421                                  . $location_id_array[$subscript]                                  . $location_id_array[$subscript]
422                                  . ")";                                  . ")";
423    
424                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of sub_loc  
425                                                    
426                  } // location not already assigned                  } // location not already assigned
427    
428          } // array of location id's          } // array of location id's
429    
430          // Call the subject form back          // Call the subject form back
431          formSubject($con, $subject_id);          formSubject($subject_id);
432    
433  } // function  } // function
434    
# Line 377  function assignSubLoc($con, $location_id Line 436  function assignSubLoc($con, $location_id
436  /**********************************************************  /**********************************************************
437  Function: assignSubMaster  Function: assignSubMaster
438  Author: Paul Bramscher  Author: Paul Bramscher
439  Last Modified: 04.21.2003  Last Modified: 03.02.2004
440  ***********************************************************  ***********************************************************
441  Purpose:  Purpose:
442  Assigns master subjects (possibly multiple) to a given  Assigns master subjects (possibly multiple) to a given
443  subject and calls formSubject back again.  subject and calls formSubject back again.
444  **********************************************************/  **********************************************************/
445  function assignSubMaster($con, $mastersubject_id_array, $subject_id) {  function assignSubMaster($mastersubject_id_array, $subject_id) {
446    
447          // For every mastersubject, assign it to the selected subject          // For every mastersubject, assign it to the selected subject
448          for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($mastersubject_id_array); $subscript++ ) {
# Line 394  function assignSubMaster($con, $mastersu Line 453  function assignSubMaster($con, $mastersu
453                          . " AND mastersubject_id = "                          . " AND mastersubject_id = "
454                          . $mastersubject_id_array[$subscript];                          . $mastersubject_id_array[$subscript];
455    
456                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
457                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
458    
459                          $sql = "INSERT INTO sub_mastersubject (subject_id, mastersubject_id) VALUES ("                          $sql = "INSERT INTO sub_mastersubject (subject_id, mastersubject_id) VALUES ("
# Line 403  function assignSubMaster($con, $mastersu Line 462  function assignSubMaster($con, $mastersu
462                                  . $mastersubject_id_array[$subscript]                                  . $mastersubject_id_array[$subscript]
463                                  . ")";                                  . ")";
464    
465                          if (!xx_query($sql, $con)){                          xx_tryquery($sql);
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of sub_mastersubject  
466                                                    
467                  } // location not already assigned                  } // location not already assigned
468    
469          } // array of mastersubject id's          } // array of mastersubject id's
470    
471          // Call the subject form back          // Call the subject form back
472          formSubject($con, $subject_id);          formSubject($subject_id);
473    
474  } // function  } // function
475    
# Line 426  function assignSubMaster($con, $mastersu Line 477  function assignSubMaster($con, $mastersu
477  /**********************************************************  /**********************************************************
478  Function: assignSubStaff  Function: assignSubStaff
479  Author: Paul Bramscher  Author: Paul Bramscher
480  Last Modified: 04.21.2003  Last Modified: 03.02.2004
481  ***********************************************************  ***********************************************************
482  Purpose:  Purpose:
483  Assigns staff specialists (possibly multiple) to a given  Assigns staff specialists (possibly multiple) to a given
484  subject and calls formSubject back again.  subject and calls formSubject back again.
485  **********************************************************/  **********************************************************/
486  function assignSubStaff($con, $staff_id_array, $subject_id) {  function assignSubStaff($staff_id_array, $subject_id) {
487    
488          // For every staff person selected          // For every staff person selected
489          for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) {          for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) {
# Line 443  function assignSubStaff($con, $staff_id_ Line 494  function assignSubStaff($con, $staff_id_
494                          . " AND staff_id = "                          . " AND staff_id = "
495                          . $staff_id_array[$subscript];                          . $staff_id_array[$subscript];
496    
497                  $rs = xx_query($sql);                  $rs = xx_tryquery($sql);
498                  if (xx_num_rows($rs) == 0) {                  if (xx_num_rows($rs) == 0) {
499    
500                          $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("                          $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("
# Line 452  function assignSubStaff($con, $staff_id_ Line 503  function assignSubStaff($con, $staff_id_
503                                  . $staff_id_array[$subscript]                                  . $staff_id_array[$subscript]
504                                  . ")";                                  . ")";
505    
506                          //xx_query ("LOCK TABLE sub_staff WRITE", $con);                          xx_tryquery($sql);
                         if (!xx_query($sql, $con)){  
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                         } // good write of sub_staff  
507                  }                  }
508    
509          } // array of staff id's          } // array of staff id's
510    
511          // Call the subject form back          // Call the subject form back
512          formSubject($con, $subject_id);          formSubject($subject_id);
   
 } // function  
   
   
   
   
   
 /**********************************************************  
 Function: assignLibunitStaff  
 Author: Paul Bramscher  
 Last Modified: 04.29.2003  
 ***********************************************************  
 Purpose:  
 Assigns staff (possibly multiple) to a given library unit  
 and calls formLibunit back again.  
 **********************************************************/  
 function assignLibunitStaff($con, $staff_id_array, $libunit_id) {  
   
         // This function assigns staff to a given library unit and calls the formLibunit to display again  
   
         // For all staff in the array  
         for ($subscript = 0; $subscript < sizeof($staff_id_array); $subscript++ ) {  
           
                 // Check to make sure that the staff isn't already assigned  
                 $sql = "SELECT * FROM libunit_staff WHERE libunit_id = " . $libunit_id .  
                 " AND staff_id = " . $staff_id_array[$subscript];  
                 $rs = xx_query($sql);  
                 if (xx_num_rows($rs) == 0) {  
           
                         $sql = "INSERT INTO libunit_staff (libunit_id, staff_id) VALUES ("  
                                 . $libunit_id  
                                 . ", "  
                                 . $staff_id_array[$subscript]  
                                 . ")";  
           
                         if (!xx_query($sql, $con)){  
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
   
                         } // good write of libunit_staff  
                           
                 } // staff not already assigned  
   
         } // array of staff id's  
   
         // Call the Libunit form back  
         formLibunit($con, $libunit_id);  
   
 } // function  
   
   
 /**********************************************************  
 Function: assignStaffLibunit  
 Author: Paul Bramscher  
 Last Modified: 04.29.2003  
 ***********************************************************  
 Purpose:  
 Assigns library units (possibly multiple) to a given  
 staffperson and calls formStaff back again.  This handles  
 the same bridging table as assignLibunitStaff, but from  
 the other side of the multiple pick list relationship.  
 **********************************************************/  
 function assignStaffLibunit($con, $libunit_id_array, $staff_id) {  
   
         // This function assigns library units to a selected staff person  
         for ($subscript = 0; $subscript < sizeof($libunit_id_array); $subscript++ ) {  
           
                 // Check to make sure that the libunit isn't already assigned  
                 $sql = "SELECT * FROM libunit_staff WHERE staff_id = "  
                         . $staff_id  
                         . " AND libunit_id = "  
                         . $libunit_id_array[$subscript];  
   
                 $rs = xx_query($sql);  
                 if (xx_num_rows($rs) == 0) {  
   
                         $sql = "INSERT INTO libunit_staff (libunit_id, staff_id) VALUES ("  
                                 . $libunit_id_array[$subscript]  
                                 . ", "  
                                 . $staff_id  
                                 . ")";  
           
                         if (!xx_query($sql, $con)){  
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of libunit_staff  
                           
                 } // assignment didn't already exist  
   
         } // array of libunit id's  
   
         // Call the staff form back  
         formStaff($con, $staff_id);  
   
 } // function  
   
   
 /**********************************************************  
 Function: assignStaffSub  
 Author: Paul Bramscher  
 Last Modified: 04.29.2003  
 ***********************************************************  
 Purpose:  
 Assigns subjects (possibly multiple) to a given staffperson  
 and calls formStaff back again.  
 **********************************************************/  
 function assignStaffSub($con, $staff_id, $subject_id_array) {  
   
         // This function assigns subjects to a selected staff person  
         for ($subscript = 0; $subscript < sizeof($subject_id_array); $subscript++ ) {  
           
                 // Check to make sure that the subject isn't already assigned  
                 $sql = "SELECT * FROM sub_staff WHERE staff_id = "  
                         . $staff_id  
                         . " AND subject_id = "  
                         . $subject_id_array[$subscript];  
   
                 $rs = xx_query($sql);  
                 if (xx_num_rows($rs) == 0) {  
   
                         $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("  
                                 . $subject_id_array[$subscript]  
                                 . ", "  
                                 . $staff_id  
                                 . ")";  
   
                         if (!xx_query($sql, $con)){  
                                 sql_err($con);  
                                 xx_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         } // bad write  
                         else {  
                                 xx_query("UNLOCK TABLES", $con);  
                           
                         } // good write of sub_staff  
                           
                 } // assignment didn't already exist  
   
         } // array of subject id's  
   
         // Call the staff form back  
         formStaff($con, $staff_id);  
513    
514  } // function  } // function
515  ?>  ?>

Legend:
Removed from v.71  
changed lines
  Added in v.72

  ViewVC Help
Powered by ViewVC 1.1.26