/[libdata]/trunk/admin/include/forms.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 /trunk/admin/include/forms.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (hide annotations)
Thu Mar 18 20:33:37 2004 UTC (20 years, 1 month ago) by dpavlin
File size: 115821 byte(s)
changes made in version 2.00

1 dpavlin 1 <?php
2     /**********************************************************
3     Function Library: forms.php
4 dpavlin 72 Original Author: Paul Bramscher <brams006@umn.edu>
5     Last Modified: 03.16.2004 by Paul Bramscher
6 dpavlin 1 ***********************************************************
7     Comments:
8     Functions here include most data-entry forms. Note that
9     the same form controls both "new" and "edit" functionality.
10     The standard convention used is to call a form with a
11     zero "0" if it is a new record, or a positive integer
12     corresponding to the primary key of the row to edit an
13     existing record.
14    
15     Assignment-type forms are those which build a composite
16     primary key to a bridging table. These allow for both the
17     creation of new associations and the deletion of existing
18     associations, depending on which transaction the user
19     selects. Boxes are mutually exclusive, with available
20     options in one box, selected options in another. These
21     combo boxes allow multiple selections (or deselections).
22     ***********************************************************
23     Table of Contents:
24     formAssignLibunitStaff
25     formAssignResFeature
26     formAssignResLoc
27     formAssignResMastersubject
28     formAssignServLoc
29     formAssignServServtype
30     formAssignStaffLibunit
31     formAssignStaffSub
32     formAssignSubCoursesub
33     formAssignSubLoc
34     formAssignSubMaster
35     formAssignSubOtherSub
36     formAssignSubPage
37     formAssignSubStaff
38 dpavlin 72 formCoursesub
39 dpavlin 1 formEditSingleField
40     formFaculty
41     formFeature
42     formInfotype
43     formLibunit
44     formLocation
45     formNewSingleField
46     formPassword
47     formResource
48     formService
49     formStaff
50     formStyle
51     formSubject
52 dpavlin 72 formVendor
53 dpavlin 1 **********************************************************/
54    
55    
56     /**********************************************************
57 dpavlin 72 Function: formAssignLibunitStaff
58     Author: Paul Bramscher
59     Last Modified: 03.10.2004
60     ***********************************************************
61     Purpose:
62     Assigns staff (possibly multiple) to a given library unit.
63     **********************************************************/
64     function formAssignLibunitStaff($libunit_id){
65    
66     // Table definition
67     printf("<br><table width=\"60%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
68    
69     // Form
70     printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
71     printf("<input type = \"Hidden\" name = \"libunit_id\" value = \"%d\" >\n", $libunit_id);
72     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignLibunitStaff\" >\n");
73    
74     // Available staff
75     // Omit the '(N/A)' staff
76     $omit_string = "WHERE staff_id > 1";
77    
78     // Omit any pre-selected staff in libunit_staff
79     $in_string = getNotIn("staff_id", "libunit_id", $libunit_id, "libunit_staff");
80     if (strlen($in_string) > 0) $omit_string .= " AND staff_id NOT IN " . $in_string;
81    
82     // Draw the box
83     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
84     printf("Assign Staff to Library Unit");
85     printf("</td></tr>\n");
86     printf("<tr><td valign = \"top\" >\n");
87     printf("<br><b>Available Staff:<br></b>\n");
88     printf("<select name = \"staff_id_array[]\" multiple size = \"5\" >\n");
89     dropDownStaffOmit($omit_string);
90     printf("</select><br><br>\n");
91    
92     // Close off form
93     printf("<center>\n");
94     printf("<input type = \"Submit\" value = \" >> \" >\n");
95     printf("</form>\n");
96     printf("</center>\n");
97     printf("</td>\n");
98    
99     // Current staff
100     printf("<td valign = \"top\" >\n");
101     printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
102     printf("<input type = \"Hidden\" name = \"libunit_id\" value = \"%d\" >\n", $libunit_id);
103     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteLibunitStaff\" >\n");
104     printf("<br><b>Selected Staff:</b><br>\n");
105     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
106    
107     $sql = "SELECT s.staff_id, s.last_name, s.first_name FROM
108     staff s,
109     libunit_staff ls
110     WHERE
111     ls.libunit_id = " . $libunit_id . " AND
112     s.staff_id = ls.staff_id
113     ORDER BY last_name, first_name";
114     $rs = xx_tryquery($sql);
115    
116     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
117     $first_name = $row["first_name"];
118     $last_name = $row["last_name"];
119     $staff_id = $row["staff_id"];
120     printf("<option value = \"%d\">%s, %s</option>\n", $staff_id, $last_name, $first_name);
121     }
122    
123     printf("</select><br><br>\n");
124     printf("<center>\n");
125     printf("<input type = \"Submit\" value =\" << \">\n");
126     printf("</center>\n");
127     printf("</form>\n");
128     printf("</td></tr>\n");
129    
130     // Close off table
131     printf("</td></tr></table>\n");
132    
133     }
134    
135    
136     /**********************************************************
137 dpavlin 1 Function: formAssignResFeature
138     Author: Paul Bramscher
139 dpavlin 72 Last Modified: 03.10.2004
140 dpavlin 1 ***********************************************************
141     Purpose:
142     Draws an HTML combo box with multiple selection capability
143     to assign features to the supplied resource id.
144     **********************************************************/
145 dpavlin 72 function formAssignResFeature($resource_id){
146 dpavlin 1
147     // Table definition
148 dpavlin 72 printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\" >\n");
149 dpavlin 1
150     // Form of available features to select
151 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml#ResFea\" >\n");
152     printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id);
153     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignResFeature\" >\n");
154 dpavlin 1
155     // Omit the '(N/A)' feature
156     $omit_string = "WHERE feature_id > 1";
157    
158     // Omit any pre-selected features in res_feature
159 dpavlin 72 $in_string = getNotIn("feature_id", "resource_id", $resource_id, "res_feature");
160 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND feature_id NOT IN " . $in_string;
161    
162     // Draw the combo box
163     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
164     printf("Assign Features");
165     printf("</td></tr>\n");
166     printf("<tr><td valign = \"top\" >\n");
167 dpavlin 72 printf("<br><b>Available Features(s):<br></b>\n");
168     printf("<select name = \"feature_id_array[]\" multiple size = \"5\" >\n");
169     dropDownFieldOmit("feature", "feature", "feature_id", $omit_string);
170     printf("</select><br><br>\n");
171 dpavlin 1
172     // Close things
173 dpavlin 72 printf("<center>\n");
174     printf("<input type = \"Submit\" value = \" >> \" >\n");
175     printf("</form>\n");
176     printf("</center>\n");
177     printf("</td>\n");
178 dpavlin 1
179     // Form of current features to deselect
180     printf("<td valign = \"top\" >\n");
181 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
182     printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id);
183     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteResFeature\" >\n");
184     printf("<br><b>Selected feature(s):</b><br>\n");
185     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
186 dpavlin 1
187     $sql = "SELECT f.feature, f.feature_id FROM
188     feature f,
189     res_feature rf,
190     resource r
191     WHERE
192     r.resource_id = " . $resource_id . " AND
193     rf.resource_id = r.resource_id AND
194     rf.feature_id = f.feature_id ORDER BY feature";
195 dpavlin 72 $rs = xx_tryquery($sql);
196    
197     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
198 dpavlin 1 $feature = $row["feature"];
199     $feature_id = $row["feature_id"];
200 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $feature_id, $feature);
201 dpavlin 1 }
202    
203     // Close things
204 dpavlin 72 printf("</select><br><br>\n");
205     printf("<center>\n");
206     printf("<input type = \"Submit\" value =\" << \">\n");
207     printf("</center>\n");
208     printf("</form>\n");
209     printf("</td></tr>\n");
210 dpavlin 1
211     // Close off table
212 dpavlin 72 printf("</td></tr></table>\n");
213 dpavlin 1 }
214    
215    
216     /**********************************************************
217     Function: formAssignResLoc
218     Author: Paul Bramscher
219 dpavlin 72 Last Modified: 03.10.2004
220 dpavlin 1 ***********************************************************
221     Purpose:
222     Draws an HTML combo box with multiple selection capability
223     to assign locations to the supplied resource id.
224     **********************************************************/
225 dpavlin 72 function formAssignResLoc($resource_id){
226 dpavlin 1
227     // Table definition
228 dpavlin 72 printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\" >\n");
229 dpavlin 1
230     // Form of available locations to select
231 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml#ResLoc\" >\n");
232     printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id);
233     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignResLoc\" >\n");
234 dpavlin 1
235     // Omit the '(N/A)' location
236     $omit_string = "WHERE location_id > 1";
237    
238     // Omit any pre-selected locations in res_loc
239 dpavlin 72 $in_string = getNotIn("location_id", "resource_id", $resource_id, "res_loc");
240 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND location_id NOT IN " . $in_string;
241    
242     // Draw the combo box
243     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
244     printf("Assign Locations");
245     printf("</td></tr>\n");
246     printf("<tr><td valign = \"top\" >\n");
247 dpavlin 72 printf("<br><b>Available Location(s):<br></b>\n");
248     printf("<select name = \"location_id_array[]\" multiple size = \"5\" >\n");
249     dropDownFieldOmit("location", "location", "location_id", $omit_string);
250     printf("</select><br><br>\n");
251 dpavlin 1
252     // Close things
253 dpavlin 72 printf("<center>\n");
254     printf("<input type = \"Submit\" value = \" >> \" >\n");
255     printf("</center>\n");
256     printf("</form>\n");
257     printf("</td>\n");
258 dpavlin 1
259     // Current locations to deselect
260     printf("<td valign = \"top\" >\n");
261 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
262     printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id);
263     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteResLoc\" >\n");
264     printf("<br><b>Selected Location(s):</b><br>\n");
265     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
266 dpavlin 1
267     $sql = "SELECT l.location, l.location_id FROM
268     location l,
269     res_loc rl,
270     resource r
271     WHERE
272     r.resource_id = " . $resource_id . " AND
273     rl.resource_id = r.resource_id AND
274     rl.location_id = l.location_id ORDER BY location";
275 dpavlin 72 $rs = xx_tryquery($sql);
276    
277     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
278 dpavlin 1 $location = $row["location"];
279     $location_id = $row["location_id"];
280 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $location_id, $location);
281 dpavlin 1 }
282    
283     // Close things
284 dpavlin 72 printf("</select><br><br>\n");
285     printf("<center>\n");
286     printf("<input type = \"Submit\" value =\" << \">\n");
287     printf("</center>\n");
288     printf("</form>\n");
289     printf("</td></tr>\n");
290 dpavlin 1
291     // Close off table
292 dpavlin 72 printf("</td></tr></table>\n");
293 dpavlin 1 }
294    
295    
296     /**********************************************************
297     Function: formAssignResMastersubject
298     Author: Paul Bramscher
299 dpavlin 72 Last Modified: 03.10.2004
300 dpavlin 1 ***********************************************************
301     Purpose:
302     Draws an HTML combo box with multiple selection capability
303     to assign master subjects to the supplied resource id.
304     **********************************************************/
305 dpavlin 72 function formAssignResMastersubject($resource_id){
306 dpavlin 1
307     // Table definition
308 dpavlin 72 printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\" >\n");
309 dpavlin 1
310     // Form of available master subjects to select
311 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml#ResMaster\" >\n");
312     printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id);
313     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignResMastersubject\" >\n");
314 dpavlin 1
315     // Omit the '(N/A)' mastersubjects
316     $omit_string = "WHERE mastersubject_id > 2";
317    
318     // Omit any pre-selected locations in res_mastersubject
319 dpavlin 72 $in_string = getNotIn("mastersubject_id", "resource_id", $resource_id, "res_mastersubject");
320 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND mastersubject_id NOT IN " . $in_string;
321    
322     // Draw the combo box
323     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
324     printf("Assign Master Subjects");
325     printf("</td></tr>\n");
326     printf("<tr><td valign = \"top\" >\n");
327 dpavlin 72 printf("<br><b>Available Mastersubjects(s):<br></b>\n");
328     printf("<select name = \"mastersubject_id_array[]\" multiple size = \"5\" >\n");
329     dropDownFieldOmit("mastersubject", "mastersubject", "mastersubject_id", $omit_string);
330     printf("</select><br><br>\n");
331 dpavlin 1
332     // Close things
333 dpavlin 72 printf("<center>\n");
334 dpavlin 1 printf("<input type = \"Submit\" value = \" >> \" >");
335     printf("</center>");
336     printf("</form>");
337     printf("</td>");
338    
339     // Current master subjects to deselect
340     printf("<td valign = \"top\" >\n");
341 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
342     printf("<input type = \"Hidden\" name = \"resource_id\" value = \"%d\" >\n", $resource_id);
343     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteResMastersubject\" >\n");
344     printf("<br><b>Selected Mastersubjects(s):</b><br>\n");
345     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
346 dpavlin 1
347     $sql = "SELECT m.mastersubject, m.mastersubject_id FROM
348     mastersubject m,
349     res_mastersubject rm,
350     resource r
351     WHERE
352     r.resource_id = " . $resource_id . " AND
353     rm.resource_id = r.resource_id AND
354     rm.mastersubject_id = m.mastersubject_id ORDER BY mastersubject";
355 dpavlin 72 $rs = xx_tryquery($sql);
356    
357     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
358 dpavlin 1 $mastersubject = $row["mastersubject"];
359     $mastersubject_id = $row["mastersubject_id"];
360 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $mastersubject_id, $mastersubject);
361 dpavlin 1 }
362    
363     // Close things
364 dpavlin 72 printf("</select><br><br>\n");
365     printf("<center>\n");
366     printf("<input type = \"Submit\" value =\" << \">\n");
367     printf("</center>\n");
368     printf("</form>\n");
369     printf("</td></tr>\n");
370 dpavlin 1
371     // Close off table
372 dpavlin 72 printf("</td></tr></table>\n");
373 dpavlin 1 }
374    
375    
376     /**********************************************************
377     Function: formAssignServLoc
378     Author: Paul Bramscher
379 dpavlin 72 Last Modified: 03.10.2004
380 dpavlin 1 ***********************************************************
381     Purpose:
382     Draws an HTML combo box with multiple selection capability
383     to assign locations to the supplied service id.
384     **********************************************************/
385 dpavlin 72 function formAssignServLoc($service_id){
386 dpavlin 1
387     // Table definition
388 dpavlin 72 printf("<br><br><table width=\"60%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
389 dpavlin 1
390     // Form of available locations to select
391 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
392     printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id);
393     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignServLoc\" >\n");
394 dpavlin 1
395     // Box header
396     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
397     printf("Assign Service Locations");
398     printf("</td></tr>\n");
399    
400     // Omit the '(N/A)' location
401     $omit_string = "WHERE location_id > 1";
402    
403     // Omit any pre-selected locations in service_location
404 dpavlin 72 $in_string = getNotIn("location_id", "service_id", $service_id, "serv_loc");
405 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND location_id NOT IN " . $in_string;
406    
407     // Draw the combo box
408     printf("<tr><td valign = \"top\" >\n");
409 dpavlin 72 printf("<br><b>Available Location(s):<br></b>\n");
410     printf("<select name = \"location_id_array[]\" multiple size = \"5\" >\n");
411     dropDownFieldOmit("location", "location", "location_id", $omit_string);
412     printf("</select><br><br>\n");
413 dpavlin 1
414     // Close things
415 dpavlin 72 printf("<center>\n");
416     printf("<input type = \"Submit\" value = \" >> \" >\n");
417     printf("</form>\n");
418     printf("</center>\n");
419     printf("</td>\n");
420 dpavlin 1
421     // Current locations to deselect
422     printf("<td valign = \"top\" >\n");
423 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
424     printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id);
425     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteServLoc\" >\n");
426     printf("<br><b>Selected Location(s):</b><br>\n");
427     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
428 dpavlin 1
429     $sql = "SELECT l.location, l.location_id FROM
430     location l,
431     serv_loc sl,
432     service s
433     WHERE
434     s.service_id = " . $service_id . " AND
435     sl.service_id = s.service_id AND
436     sl.location_id = l.location_id ORDER BY location";
437 dpavlin 72 $rs = xx_tryquery($sql);
438 dpavlin 1
439 dpavlin 72 while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
440 dpavlin 1 $location = $row["location"];
441     $location_id = $row["location_id"];
442 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $location_id, $location);
443 dpavlin 1 }
444    
445     // Close things
446 dpavlin 72 printf("</select><br><br>\n");
447     printf("<center>\n");
448     printf("<input type = \"Submit\" value =\" << \">\n");
449     printf("</center>\n");
450     printf("</form>\n");
451     printf("</td></tr>\n");
452 dpavlin 1
453     // Close off the table
454 dpavlin 72 printf("</td></tr></table>\n");
455 dpavlin 1 }
456    
457    
458     /**********************************************************
459     Function: formAssignServServtype
460     Author: Paul Bramscher
461 dpavlin 72 Last Modified: 03.10.2004
462 dpavlin 1 ***********************************************************
463     Purpose:
464     Draws an HTML combo box with multiple selection capability
465     to assign service types to the supplied service id.
466     **********************************************************/
467 dpavlin 72 function formAssignServServtype($service_id){
468 dpavlin 1
469     // Table definition
470 dpavlin 72 printf("<br><br><table width=\"60%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
471 dpavlin 1
472     // Form of available service types to select
473 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
474     printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id);
475     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignServServtype\" >\n");
476 dpavlin 1
477     // Box header
478     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
479     printf("Assign Service Types");
480     printf("</td></tr>\n");
481    
482     // Omit the '(N/A)' type
483     $omit_string = "WHERE servicetype_id > 1";
484    
485     // Omit any pre-selected servive types in serv_servtype
486 dpavlin 72 $in_string = getNotIn("servicetype_id", "service_id", $service_id, "serv_servtype");
487 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND servicetype_id NOT IN " . $in_string;
488    
489     // Draw the combo box
490     printf("<tr><td valign = \"top\" >\n");
491 dpavlin 72 printf("<br><b>Available Service Types(s):<br></b>\n");
492     printf("<select name = \"servicetype_id_array[]\" multiple size = \"5\" >\n");
493     dropDownFieldOmit("servicetype", "servicetype", "servicetype_id", $omit_string);
494     printf("</select><br><br>\n");
495 dpavlin 1
496     // Close things
497 dpavlin 72 printf("<center>\n");
498     printf("<input type = \"Submit\" value = \" >> \" >\n");
499     printf("</form>\n");
500     printf("</center>\n");
501     printf("</td>\n");
502 dpavlin 1
503     // Current servicetypes to deselect
504     printf("<td valign = \"top\" >\n");
505 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
506     printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id);
507     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteServServtype\" >\n");
508     printf("<br><b>Selected Service Types(s):</b><br>\n");
509     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
510 dpavlin 1
511     $sql = "SELECT t.servicetype, t.servicetype_id FROM
512     servicetype t,
513     serv_servtype st,
514     service s
515     WHERE
516     s.service_id = " . $service_id . " AND
517     st.service_id = s.service_id AND
518     st.servicetype_id = t.servicetype_id ORDER BY servicetype";
519 dpavlin 72 $rs = xx_tryquery($sql);
520 dpavlin 1
521 dpavlin 72 while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
522 dpavlin 1 $servicetype = $row["servicetype"];
523     $servicetype_id = $row["servicetype_id"];
524 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $servicetype_id, $servicetype);
525 dpavlin 1 }
526    
527     // Close things
528 dpavlin 72 printf("</select><br><br>\n");
529     printf("<center>\n");
530     printf("<input type = \"Submit\" value =\" << \">\n");
531     printf("</center>\n");
532     printf("</form>\n");
533     printf("</td></tr>\n");
534 dpavlin 1
535     // Close off the table
536 dpavlin 72 printf("</td></tr></table>\n");
537 dpavlin 1 }
538    
539    
540     /**********************************************************
541 dpavlin 72 Function: formAssignStaffLibunit
542     Author: Paul Bramscher
543     Last Modified: 03.10.2004
544     ***********************************************************
545     Purpose:
546     Assigns library units (possibly multiple) to a given
547     staffperson.
548     **********************************************************/
549     function formAssignStaffLibunit($staff_id){
550    
551     // Table definition
552     printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\" >\n");
553    
554     // Form
555     printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
556     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id);
557     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignStaffLibunit\" >\n");
558    
559     // Available libunits
560     // Omit the '(N/A)' libunit
561     $omit_string = "WHERE libunit_id > 1";
562    
563     // Omit any pre-selected libunits in libunit_staff
564     $in_string = getNotIn("libunit_id", "staff_id", $staff_id, "libunit_staff");
565     if (strlen($in_string) > 0) $omit_string .= " AND libunit_id NOT IN " . $in_string;
566    
567     // Draw the box
568     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
569     printf("Assign Library Unit to Staff");
570     printf("</td></tr>\n");
571     printf("<tr><td valign = \"top\" >\n");
572     printf("<br><b>Available Library Unit(s):<br></b>\n");
573     printf("<select name = \"libunit_id_array[]\" multiple size = \"5\" >\n");
574     dropDownFieldOmit("libunit", "libunit", "libunit_id", $omit_string);
575     printf("</select><br><br>\n");
576    
577     // Close off form
578     printf("<center>\n");
579     printf("<input type = \"Submit\" value = \" >> \" >\n");
580     printf("</form>\n");
581     printf("</center>\n");
582     printf("</td>\n");
583    
584     // Current libunits
585     printf("<td valign = \"top\" >\n");
586     printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
587     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id);
588     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStaffLibunit\" >\n");
589     printf("<br><b>Selected Library Unit(s):</b><br>\n");
590     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
591    
592     $sql = "SELECT l.libunit, l.libunit_id FROM
593     staff s,
594     libunit_staff ls,
595     libunit l
596     WHERE
597     s.staff_id = " . $staff_id . " AND
598     ls.staff_id = s.staff_id AND
599     ls.libunit_id = l.libunit_id
600     ORDER BY l.libunit";
601     $rs = xx_tryquery($sql);
602    
603     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
604     $libunit = $row["libunit"];
605     $libunit_id = $row["libunit_id"];
606     printf("<option value = \"%s\">%s</option>\n", $libunit_id, $libunit);
607     }
608    
609     printf("</select><br><br>\n");
610     printf("<center>\n");
611     printf("<input type = \"Submit\" value =\" << \">\n");
612     printf("</center>\n");
613     printf("</form>\n");
614     printf("</td></tr>\n");
615    
616     // Close off table
617     printf("</td></tr></table>\n");
618    
619     }
620    
621    
622     /**********************************************************
623     Function: formAssignStaffSub
624     Author: Paul Bramscher
625     Last Modified: 03.10.2004
626     ***********************************************************
627     Purpose:
628     Assigns subjects (possibly multiple) to a given
629     staffperson.
630     **********************************************************/
631     function formAssignStaffSub($staff_id){
632    
633     // Table definition
634     printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\" >\n");
635    
636     // Form
637     printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
638     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id);
639     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignStaffSub\" >\n");
640    
641     // Available subjects
642     // Omit the '(N/A)' subject
643     $omit_string = "WHERE subject_id > 1";
644    
645     // Omit any pre-selected subjects in sub_staff
646     $in_string = getNotIn("subject_id", "staff_id", $staff_id, "sub_staff");
647     if (strlen($in_string) > 0) $omit_string .= " AND subject_id NOT IN " . $in_string;
648    
649     // Draw the box
650     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
651     printf("Assign Subjects");
652     printf("</td></tr>\n");
653     printf("<tr><td valign = \"top\" >\n");
654     printf("<br><b>Available Subject(s):<br></b>\n");
655     printf("<select name = \"subject_id_array[]\" multiple size = \"5\" >\n");
656     dropDownFieldOmit("subject", "subject", "subject_id", $omit_string);
657     printf("</select><br><br>\n");
658    
659     // Close off form
660     printf("<center>\n");
661     printf("<input type = \"Submit\" value = \" >> \" >\n");
662     printf("</form>\n");
663     printf("</center>\n");
664     printf("</td>\n");
665    
666     // Current subjects
667     printf("<td valign = \"top\" >\n");
668     printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
669     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >", $staff_id);
670     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteStaffSub\" >\n");
671     printf("<br><b>Selected Subject(s):</b><br>\n");
672     printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
673    
674     $sql = "SELECT s.subject, s.subject_id FROM
675     staff t,
676     sub_staff st,
677     subject s
678     WHERE
679     t.staff_id = " . $staff_id . " AND
680     st.staff_id = t.staff_id AND
681     st.subject_id = s.subject_id
682     ORDER BY s.subject";
683     $rs = xx_tryquery($sql);
684    
685     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
686     $subject = $row["subject"];
687     $subject_id = $row["subject_id"];
688     printf("<option value = \"%s\">%s</option>\n", $subject_id, $subject);
689     }
690    
691     printf("</select><br><br>\n");
692     printf("<center>\n");
693     printf("<input type = \"Submit\" value =\" << \">\n");
694     printf("</center>\n");
695     printf("</form>\n");
696     printf("</td></tr>\n");
697    
698     // Close off table
699     printf("</td></tr></table>\n");
700    
701     }
702    
703    
704     /**********************************************************
705 dpavlin 1 Function: formAssignSubCoursesub
706     Author: Paul Bramscher
707 dpavlin 72 Last Modified: 03.10.2004
708 dpavlin 1 ***********************************************************
709     Purpose:
710     Draws an HTML combo box with multiple selection capability
711     to assign course subjects (with cip codes) to the supplied
712     subject id.
713     **********************************************************/
714 dpavlin 72 function formAssignSubCoursesub($subject_id){
715 dpavlin 1
716     // Table definition
717     printf("<br><br>\n");
718 dpavlin 72 printf("<table width=\"90%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\" >\n");
719 dpavlin 1
720     // Form of available course subjects to select
721 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
722 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
723     printf("Map to Course Subjects / CIP Codes");
724     printf("</td></tr>\n");
725    
726 dpavlin 72 printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
727     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignSubCoursesub\" >\n");
728 dpavlin 1
729     // Omit the '(N/A)' course subject
730     $omit_string = "WHERE coursesub_id > 1";
731    
732     // Omit any pre-selected locations in sub_coursesub
733 dpavlin 72 $in_string = getNotIn("coursesub_id", "subject_id", $subject_id, "sub_coursesub");
734 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND coursesub_id NOT IN " . $in_string;
735    
736     // Draw the combo box
737     printf("<tr><td valign = \"top\" >\n");
738     printf("<br><b>Available Course Subjects(s):<br></b>\n");
739 dpavlin 72 printf("<select name = \"coursesub_id_array[]\" multiple size = \"20\" >\n");
740     dropDownCoursesubOmit($omit_string);
741     printf("</select><br><br>\n");
742 dpavlin 1
743     // Close things
744 dpavlin 72 printf("<center>\n");
745     printf("<input type = \"Submit\" value = \" >> \" >\n");
746     printf("</form>\n");
747     printf("</center>\n");
748     printf("</td>\n");
749 dpavlin 1
750     // Current coursesubs to deselect
751     printf("<td valign = \"top\" >\n");
752 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
753     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
754     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubCoursesub\" >\n");
755 dpavlin 1 printf("<br><b>Selected Course Subject(s):</b><br>\n");
756 dpavlin 72 printf("<select name =\"key_list_array[]\" multiple size = \"20\">\n");
757 dpavlin 1
758     $sql = "SELECT c.coursesub, c.coursesub_descr, c.coursesub_id, c.cip_code FROM
759     coursesub c,
760     sub_coursesub sc,
761     subject s
762     WHERE
763     s.subject_id = " . $subject_id . " AND
764     sc.subject_id = s.subject_id AND
765     sc.coursesub_id = c.coursesub_id ORDER BY coursesub_descr";
766 dpavlin 72 $rs = xx_tryquery($sql);
767    
768     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
769 dpavlin 1 $coursesub = $row["coursesub"];
770     $coursesub_id = $row["coursesub_id"];
771     $coursesub_descr = $row["coursesub_descr"];
772     $cip_code = $row["cip_code"];
773    
774     // Limit length
775     if (strlen($coursesub_descr) > 30) $coursesub_descr = substr($coursesub_descr, 0, 30) . "...";
776    
777 dpavlin 72 printf("<option value = \"%s\">%s | %s [%s]</option>\n", $coursesub_id, $coursesub, $coursesub_descr, $cip_code);
778 dpavlin 1 }
779    
780     // Close things
781 dpavlin 72 printf("</select><br><br>\n");
782     printf("<center>\n");
783     printf("<input type = \"Submit\" value =\" << \">\n");
784     printf("</center>\n");
785     printf("</form>\n");
786     printf("</td></tr>\n");
787 dpavlin 1
788     // Close off the table
789 dpavlin 72 printf("</td></tr></table>\n");
790 dpavlin 1 }
791    
792    
793     /**********************************************************
794     Function: formAssignSubLoc
795     Author: Paul Bramscher
796 dpavlin 72 Last Modified: 03.10.2004
797 dpavlin 1 ***********************************************************
798     Purpose:
799     Draws an HTML combo box with multiple selection capability
800     to assign locations to the supplied subject id.
801     **********************************************************/
802 dpavlin 72 function formAssignSubLoc($subject_id){
803 dpavlin 1
804     // Table definition
805     printf("<br><br>\n");
806 dpavlin 72 printf("<table width=\"60%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
807 dpavlin 1
808     // Form of available locations to select
809 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
810 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
811     printf("Assign Secondary Locations");
812     printf("</td></tr>\n");
813    
814 dpavlin 72 printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
815     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignSubLoc\" >\n");
816 dpavlin 1
817     // Omit the '(N/A)' location
818     $omit_string = "WHERE location_id > 1";
819    
820     // Omit any pre-selected locations in sub_loc
821 dpavlin 72 $in_string = getNotIn("location_id", "subject_id", $subject_id, "sub_loc");
822 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND location_id NOT IN " . $in_string;
823    
824     // Draw the combo box
825     printf("<tr><td valign = \"top\" >\n");
826     printf("<br><b>Available Location(s):<br></b>\n");
827     printf("<select name = \"location_id_array[]\" multiple size = \"5\" >");
828 dpavlin 72 dropDownFieldOmit("location", "location", "location_id", $omit_string);
829     printf("</select><br><br>\n");
830 dpavlin 1
831     // Close things
832 dpavlin 72 printf("<center>\n");
833     printf("<input type = \"Submit\" value = \" >> \" >\n");
834     printf("</form>\n");
835     printf("</center>\n");
836     printf("</td>\n");
837 dpavlin 1
838     // Current locations to deselect
839     printf("<td valign = \"top\" >\n");
840 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
841     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
842     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubLoc\" >\n");
843 dpavlin 1 printf("<br><b>Selected Location(s):</b><br>\n");
844 dpavlin 72 printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
845 dpavlin 1
846     $sql = "SELECT l.location, l.location_id FROM
847     location l,
848     sub_loc sl,
849     subject s
850     WHERE
851     s.subject_id = " . $subject_id . " AND
852     sl.subject_id = s.subject_id AND
853     sl.location_id = l.location_id ORDER BY location";
854 dpavlin 72 $rs = xx_tryquery($sql);
855    
856     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
857 dpavlin 1 $location = $row["location"];
858     $location_id = $row["location_id"];
859 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $location_id, $location);
860 dpavlin 1 }
861    
862     // Close things
863 dpavlin 72 printf("</select><br><br>\n");
864     printf("<center>\n");
865     printf("<input type = \"Submit\" value =\" << \">\n");
866     printf("</center>\n");
867     printf("</form>\n");
868     printf("</td></tr>\n");
869 dpavlin 1
870     // Close off the table
871 dpavlin 72 printf("</td></tr></table>\n");
872 dpavlin 1 }
873    
874    
875     /**********************************************************
876     Function: formAssignSubMaster
877     Author: Paul Bramscher
878 dpavlin 72 Last Modified: 03.10.2004
879 dpavlin 1 ***********************************************************
880     Purpose:
881     Draws an HTML combo box with multiple selection capability
882     to assign master subjects to the supplied subject id.
883     **********************************************************/
884 dpavlin 72 function formAssignSubMaster($subject_id){
885 dpavlin 1
886     // Table definition
887     printf("<br><br>\n");
888 dpavlin 72 printf("<table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\" >\n");
889 dpavlin 1
890     // Form of available master subjects to select
891 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
892 dpavlin 1
893     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
894     printf("Assign Master Subjects");
895     printf("</td></tr>\n");
896 dpavlin 72 printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
897     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignSubMaster\" >\n");
898 dpavlin 1
899     // Omit the '(N/A)' location
900     $omit_string = "WHERE mastersubject_id > 1";
901    
902     // Omit any pre-selected locations in sub_mastersubject
903 dpavlin 72 $in_string = getNotIn("mastersubject_id", "subject_id", $subject_id, "sub_mastersubject");
904 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND mastersubject_id NOT IN " . $in_string;
905    
906     // Draw the combo box
907     printf("<tr><td valign = \"top\" >\n");
908     printf("<br><b>Available Master Subjects(s):<br></b>\n");
909 dpavlin 72 printf("<select name = \"mastersubject_id_array[]\" multiple size = \"5\" >\n");
910     dropDownFieldOmit("mastersubject", "mastersubject", "mastersubject_id", $omit_string);
911     printf("</select><br><br>\n");
912 dpavlin 1
913     // Close things
914 dpavlin 72 printf("<center>\n");
915     printf("<input type = \"Submit\" value = \" >> \" >\n");
916     printf("</form>\n");
917     printf("</center>\n");
918     printf("</td>\n");
919 dpavlin 1
920     // Current mastersubjects to deselect
921     printf("<td valign = \"top\" >\n");
922 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
923     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
924     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubMaster\" >\n");
925 dpavlin 1 printf("<br><b>Selected Master Subject(s):</b><br>\n");
926 dpavlin 72 printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
927 dpavlin 1
928     $sql = "SELECT m.mastersubject, m.mastersubject_id FROM
929     mastersubject m,
930     sub_mastersubject sm,
931     subject s
932     WHERE
933     s.subject_id = " . $subject_id . " AND
934     sm.subject_id = s.subject_id AND
935     sm.mastersubject_id = m.mastersubject_id ORDER BY mastersubject";
936 dpavlin 72 $rs = xx_tryquery($sql);
937    
938     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
939 dpavlin 1 $mastersubject = $row["mastersubject"];
940     $mastersubject_id = $row["mastersubject_id"];
941 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $mastersubject_id, $mastersubject);
942 dpavlin 1 }
943    
944     // Close things
945 dpavlin 72 printf("</select><br><br>\n");
946     printf("<center>\n");
947     printf("<input type = \"Submit\" value =\" << \">\n");
948     printf("</center>\n");
949     printf("</form>\n");
950     printf("</td></tr>\n");
951 dpavlin 1
952     // Close off the table
953 dpavlin 72 printf("</td></tr></table>\n");
954 dpavlin 1 }
955    
956    
957     /**********************************************************
958     Function: formAssignSubOtherSub
959     Author: Paul Bramscher
960 dpavlin 72 Last Modified: 03.10.2004
961 dpavlin 1 ***********************************************************
962     Purpose:
963     Draws an HTML combo box with multiple selection capability
964     to assign other subject pages to the supplied subject id.
965     **********************************************************/
966 dpavlin 72 function formAssignSubOtherSub($subject_id){
967 dpavlin 1
968     // Table definition
969 dpavlin 72 printf("<table width=\"75%%\" border=\"2\" class=\"backLight\" cellpadding=\"4\" >\n");
970 dpavlin 1
971     // Form of available master subjects to select
972 dpavlin 72 printf("<form method = \"POST\" action = \"subject_transaction.phtml\" >\n");
973     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
974     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignSubOtherSub\" >\n");
975 dpavlin 1
976     // Free-form pages only
977     $omit_string = "WHERE subject_id > 1 AND subject_id <> " . $subject_id;
978    
979     // Omit any pre-selected other subjects in sub_othersub
980 dpavlin 72 $in_string = getNotIn("othersub_id", "subject_id", $subject_id, "sub_othersub");
981 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND subject_id NOT IN " . $in_string;
982    
983     // Draw the combo box
984     // Header
985     printf("<tr><td class=\"cellPlain\" colspan=\"2\">Related RQS Subjects</td></tr>\n");
986    
987    
988     printf("<tr><td valign = \"top\" >\n");
989 dpavlin 72 printf("<br><b>Available Subject(s):<br></b>\n");
990     printf("<select name = \"subject_id_array[]\" multiple size = \"5\" >\n");
991     dropDownFieldOmit("subject", "subject", "subject_id", $omit_string);
992     printf("</select><br><br>\n");
993 dpavlin 1
994     // Close things
995 dpavlin 72 printf("<center>\n");
996     printf("<input type = \"Submit\" value = \" Add \" >\n");
997     printf("</form>\n");
998     printf("</center>\n");
999     printf("</td></tr>\n");
1000 dpavlin 1
1001     // Current rqs subjects to deselect
1002     printf("<tr><td valign = \"top\" >\n");
1003 dpavlin 72 printf("<form method = \"POST\" action = \"subject_transaction.phtml\" >\n");
1004 dpavlin 1 printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >", $subject_id);
1005 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubOtherSub\" >\n");
1006     printf("<br><b>Selected Subject(s):</b><br>\n");
1007     printf("<select name =\"key_list_array[]\" multiple size = \"3\">\n");
1008 dpavlin 1
1009     $sql = "SELECT so.othersub_id, s.subject FROM
1010     subject s,
1011     sub_othersub so
1012     WHERE
1013     so.subject_id = " . $subject_id . " AND
1014     so.othersub_id = s.subject_id
1015     ORDER BY s.subject";
1016 dpavlin 72 $rs = xx_tryquery($sql);
1017    
1018     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
1019 dpavlin 1 $othersub = $row["subject"];
1020     $othersub_id = $row["othersub_id"];
1021    
1022 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $othersub_id, $othersub);
1023 dpavlin 1 }
1024    
1025     // Close things
1026 dpavlin 72 printf("</select><br><br>\n");
1027     printf("<center>\n");
1028     printf("<input type = \"Submit\" value =\" Remove \">\n");
1029     printf("</center>\n");
1030     printf("</form>\n");
1031     printf("</td></tr>\n");
1032 dpavlin 1
1033     // Close off the table
1034 dpavlin 72 printf("</td></tr></table>\n");
1035 dpavlin 1 }
1036    
1037    
1038     /**********************************************************
1039     Function: formAssignSubPage
1040     Author: Paul Bramscher
1041 dpavlin 72 Last Modified: 03.10.2004
1042 dpavlin 1 ***********************************************************
1043     Purpose:
1044     Draws an HTML combo box with multiple selection capability
1045     to assign PageScribe Pages to the supplied subject id.
1046     **********************************************************/
1047 dpavlin 72 function formAssignSubPage($subject_id){
1048 dpavlin 1
1049     // Table definition
1050 dpavlin 72 printf("<table width=\"75%%\" border=\"2\" class=\"backLight\" cellpadding=\"4\" >\n");
1051 dpavlin 1
1052     // Form of available master subjects to select
1053 dpavlin 72 printf("<form method = \"POST\" action = \"subject_transaction.phtml\" >\n");
1054     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
1055     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignSubPage\" >\n");
1056 dpavlin 1
1057     // Free-form pages only
1058     $omit_string = "WHERE pagetype_id = 2";
1059    
1060     // Omit any pre-selected pages in sub_page
1061 dpavlin 72 $in_string = getNotIn("page_id", "subject_id", $subject_id, "sub_page");
1062 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND page_id NOT IN " . $in_string;
1063    
1064     // Draw the combo box
1065     // Header
1066     printf("<tr><td class=\"cellPlain\" colspan=\"2\">Related PageScribe Pages</td></tr>\n");
1067    
1068    
1069     printf("<tr><td valign = \"top\" >\n");
1070 dpavlin 72 printf("<br><b>Available Page(s):<br></b>\n");
1071     printf("<select name = \"page_id_array[]\" multiple size = \"5\" >\n");
1072     dropDownFieldOmit("page", "page_title", "page_id", $omit_string);
1073     printf("</select><br><br>\n");
1074 dpavlin 1
1075     // Close things
1076 dpavlin 72 printf("<center>\n");
1077     printf("<input type = \"Submit\" value = \" Add \" >\n");
1078     printf("</form>\n");
1079     printf("</center>\n");
1080     printf("</td></tr>\n");
1081 dpavlin 1
1082     // Current mastersubjects to deselect
1083     printf("<tr><td valign = \"top\" >\n");
1084 dpavlin 72 printf("<form method = \"POST\" action = \"subject_transaction.phtml\" >\n");
1085     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
1086     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubPage\" >\n");
1087     printf("<br><b>Selected Page(s):</b><br>\n");
1088     printf("<select name =\"key_list_array[]\" multiple size = \"3\">\n");
1089 dpavlin 1
1090     $sql = "SELECT p.page_title, p.page_id FROM
1091     page p,
1092     sub_page sp
1093     WHERE
1094     sp.subject_id = " . $subject_id . " AND
1095     sp.page_id = p.page_id
1096     ORDER BY p.page_title";
1097 dpavlin 72 $rs = xx_tryquery($sql);
1098    
1099     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
1100 dpavlin 1 $page_title = $row["page_title"];
1101     $page_id = $row["page_id"];
1102    
1103     // Pull out any HTML
1104     $page_title = strip_tags($page_title);
1105    
1106 dpavlin 72 printf("<option value = \"%s\">%s</option>\n", $page_id, $page_title);
1107 dpavlin 1 }
1108    
1109     // Close things
1110 dpavlin 72 printf("</select><br><br>\n");
1111     printf("<center>\n");
1112     printf("<input type = \"Submit\" value =\" Remove \">\n");
1113     printf("</center>\n");
1114     printf("</form>\n");
1115     printf("</td></tr>\n");
1116 dpavlin 1
1117     // Close off the table
1118 dpavlin 72 printf("</td></tr></table>\n");
1119 dpavlin 1 }
1120    
1121    
1122     /**********************************************************
1123     Function: formAssignSubStaff
1124     Author: Paul Bramscher
1125 dpavlin 72 Last Modified: 03.10.2004
1126 dpavlin 1 ***********************************************************
1127     Purpose:
1128     Draws an HTML combo box with multiple selection capability
1129     to assign staffpersons to the supplied subject id.
1130     **********************************************************/
1131 dpavlin 72 function formAssignSubStaff($subject_id){
1132 dpavlin 1
1133     // Table definition
1134     printf("<br><br>\n");
1135     printf("<table width=\"60%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
1136    
1137     // Form of available staff to select
1138 dpavlin 72 printf("<form method = \"POST\" action = \"assign.phtml\" >\n");
1139 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1140     printf("Assign Staff");
1141     printf("</td></tr>\n");
1142    
1143 dpavlin 72 printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
1144     printf("<input type = \"Hidden\" name = \"transaction\" value = \"assignSubStaff\" >\n");
1145 dpavlin 1
1146     // Omit the '(N/A)' staff
1147     $omit_string = "WHERE staff_id > 1";
1148    
1149     // Omit any pre-selected staff in sub_staff
1150 dpavlin 72 $in_string = getNotIn("staff_id", "subject_id", $subject_id, "sub_staff");
1151 dpavlin 1 if (strlen($in_string) > 0) $omit_string .= " AND staff_id NOT IN " . $in_string;
1152    
1153     // Draw the combo box
1154     printf("<tr><td valign = \"top\" >\n");
1155     printf("<br><b>Available Staff:<br></b>\n");
1156 dpavlin 72 printf("<select name = \"staff_id_array[]\" multiple size = \"5\" >\n");
1157     dropDownStaffOmit($omit_string);
1158     printf("</select><br><br>\n");
1159 dpavlin 1
1160     // Close things
1161 dpavlin 72 printf("<center>\n");
1162     printf("<input type = \"Submit\" value = \" >> \" >\n");
1163     printf("</form>\n");
1164     printf("</center>\n");
1165     printf("</td>\n");
1166 dpavlin 1
1167     // Current staff to deselect
1168     printf("<td valign = \"top\" >\n");
1169 dpavlin 72 printf("<form method = \"POST\" action = \"delete.phtml\" >\n");
1170     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
1171     printf("<input type = \"Hidden\" name = \"transaction\" value = \"deleteSubStaff\" >\n");
1172 dpavlin 1 printf("<br><b>Selected Staff:</b><br>\n");
1173 dpavlin 72 printf("<select name =\"key_list_array[]\" multiple size = \"5\">\n");
1174 dpavlin 1
1175     $sql = "SELECT t.staff_id, t.last_name, t.first_name FROM
1176     staff t,
1177     sub_staff st,
1178     subject s
1179     WHERE
1180     s.subject_id = " . $subject_id . " AND
1181     st.subject_id = s.subject_id AND
1182     st.staff_id = t.staff_id ORDER BY last_name, first_name";
1183 dpavlin 72 $rs = xx_tryquery($sql);
1184    
1185     while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
1186 dpavlin 1 $first_name = $row["first_name"];
1187     $last_name = $row["last_name"];
1188     $staff_id = $row["staff_id"];
1189 dpavlin 72 printf("<option value = \"%d\">%s, %s</option>\n", $staff_id, $last_name, $first_name);
1190 dpavlin 1 }
1191    
1192     // Close things
1193 dpavlin 72 printf("</select><br><br>\n");
1194     printf("<center>\n");
1195     printf("<input type = \"Submit\" value =\" << \">\n");
1196     printf("</center>\n");
1197     printf("</form>\n");
1198     printf("</td></tr>\n");
1199 dpavlin 1
1200     // Close off table
1201 dpavlin 72 printf("</td></tr></table>\n");
1202 dpavlin 1 }
1203    
1204    
1205     /**********************************************************
1206     Function: formCoursesub
1207     Author: Paul Bramscher
1208 dpavlin 72 Last Modified: 03.16.2004
1209 dpavlin 1 ***********************************************************
1210     Purpose:
1211 dpavlin 72 Draws an HTML form to edit the supplied course subject id,
1212     or to create a new course subject if the incoming id is
1213     less than 1.
1214 dpavlin 1 **********************************************************/
1215 dpavlin 72 function formCoursesub($coursesub_id) {
1216 dpavlin 1
1217     // Cast as integer to be sure
1218     $coursesub_id = (int) $coursesub_id;
1219    
1220     // Get descriptive title
1221 dpavlin 72 $coursesub = lookupField("coursesub", "coursesub_id", $coursesub_id, "coursesub");
1222 dpavlin 1
1223     // Check to see if coursesub actually exists
1224 dpavlin 72 $exists = existsRow("coursesub", "coursesub_id", $coursesub_id);
1225 dpavlin 1
1226     // Houston, we have a problem
1227     if ($key_id > 0 && $exists == 0) {
1228     $problem = 1;
1229 dpavlin 72 printf("<h3>Course Subject (ID# %d) Not Found</h3>\n", $coursesub_id);
1230 dpavlin 1 }
1231    
1232     // Check to see if there are affected courselib pages
1233 dpavlin 72 $exists_courselib = existsRow("course", "coursesub_id", $coursesub_id);
1234 dpavlin 1 if ($exists_courselib > 0) {
1235    
1236     $problem = 1;
1237    
1238     // Table definition
1239 dpavlin 72 msgTableOpen(1, "Edit Course Subject (ID# " . $coursesub_id . ")");
1240     printf("<b>Messages:</b><br>\n");
1241 dpavlin 1 printf("This course subject is currently used on one or more course pages. ");
1242     printf("It may not be edited or deleted until all affected courses are moved to ");
1243     printf("an alternate course subject. Follow the link below for a list of ");
1244     printf("affected pages. Course titles are composed, in part, based on this ");
1245 dpavlin 72 printf("value.<br><br>\n");
1246 dpavlin 1 printf("<a href=\"page_results_brief.phtml?coursesub_id=%s\">", $coursesub_id);
1247 dpavlin 72 printf("page_results_brief.phtml?coursesub_id=%s</a>", $coursesub_id);
1248     printf("<br><br>\n");
1249     msgTableClose();
1250    
1251 dpavlin 1 }
1252    
1253     // If no problems, then go for landing
1254     if ($problem != 1) {
1255    
1256     // Initialization
1257     $coursesub = "";
1258     $coursesub_descr = "";
1259     $campus_id = "";
1260     $cip_code = "";
1261    
1262     // If the user is editing an existing record, fetch previous values
1263     if ($coursesub_id > 0 && $exists == 1) {
1264     $sql = "SELECT * FROM coursesub WHERE coursesub_id = " . $coursesub_id;
1265 dpavlin 72 $rs = xx_tryquery($sql);
1266     $row = xx_fetch_array ($rs, xx_ASSOC);
1267 dpavlin 1
1268     // Fetch existing values
1269     $coursesub_id = $row["coursesub_id"];
1270     $coursesub = $row["coursesub"];
1271     $coursesub_descr = $row["coursesub_descr"];
1272     $cip_code = $row["cip_code"];
1273     $campus_id = $row["campus_id"];
1274    
1275     // Run strings through the HTML cleaner for output
1276     $coursesub = textOutHTML($coursesub);
1277     $coursesub_descr = textOutHTML($coursesub_descr);
1278     $cip_code = textOutHTML($cip_code);
1279    
1280     };
1281    
1282     // Table definition
1283     printf("<center><table width=\"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
1284    
1285     // If new insert
1286     if ($coursesub_id <1) {
1287 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
1288 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1289     printf("Enter New Course Subject");
1290     printf("</td></tr>\n");
1291     }
1292    
1293     // Else update
1294     else {
1295 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1296 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1297 dpavlin 72 printf("Edit Course Subject: %s (ID# %d)", $coursesub, $coursesub_id);
1298 dpavlin 1 printf("</td></tr>\n");
1299     }
1300    
1301     // Coursesub abbrev.
1302     printf("<tr>\n");
1303     printf("<td><b>Course Subject Abbrev:</b></td>\n");
1304     printf("<td><input type = \"text\" name = \"coursesub\" size = \"10\" value = \"%s\" ></td>\n", $coursesub);
1305     printf("</tr>\n");
1306    
1307     // Coursesub descr
1308     printf("<tr>\n");
1309     printf("<td><b>Course Subject Description:</b></td>\n");
1310     printf("<td><input type = \"text\" name = \"coursesub_descr\" size = \"60\" value = \"%s\" ></td>\n", $coursesub_descr);
1311     printf("</tr>\n");
1312    
1313     // Campus
1314     printf("<tr>\n");
1315     printf("<td><b>Campus:</b></td>\n");
1316     printf("<td><select name =\"campus_id\">");
1317 dpavlin 72 dropDownFieldSelected("campus", "campus", "campus_id", "WHERE campus_id >= 0", $campus_id);
1318 dpavlin 1 printf("</select></td>\n");
1319     printf("</tr>\n");
1320    
1321     // CIP code
1322     printf("<tr>\n");
1323     printf("<td><b>CIP Code:</b></td>\n");
1324     printf("<td><input type = \"text\" name = \"cip_code\" size = \"25\" value = \"%s\" ></td>\n", $cip_code);
1325     printf("</tr>\n");
1326    
1327     // Buttons
1328     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
1329    
1330     // If this is an existing course subject
1331     if ($coursesub_id > 0) {
1332 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateCoursesub\" >\n");
1333     printf("<input type = \"Submit\" value = \"Update Course Subject\" >\n");
1334     printf("<input type = \"Hidden\" name = \"coursesub_id\" value = \"%d\" >\n", $coursesub_id);
1335 dpavlin 1 }
1336     // Editing a new course subject
1337     else {
1338 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertCoursesub\" >\n");
1339     printf("<input type = \"Submit\" value = \"Save New Course Subject\">\n");
1340 dpavlin 1 }
1341    
1342     // Common button
1343     printf("<input type = \"Reset\" value = \"Reset\" >\n");
1344    
1345     // Close things
1346     printf("</form>\n");
1347     printf("</td></tr></table></center>\n");
1348    
1349     } // No problems
1350     }
1351    
1352    
1353     /**********************************************************
1354 dpavlin 72 Function: formEditSingleField($display, $display_field,
1355 dpavlin 1 $key_field, $key_id, $table);
1356     Author: Paul Bramscher
1357 dpavlin 72 Last Modified: 03.15.2004
1358 dpavlin 1 ***********************************************************
1359     Incoming:
1360     $display A display to the user, typically
1361     similar to $display_field
1362     $display_field Field name within $table to generate
1363     displayed values from
1364     $key_field Name of primary key field in $table
1365     $key_id Value of $key_field
1366 dpavlin 72 $table Table name to operate against
1367 dpavlin 1 ***********************************************************
1368     Outgoing:
1369     None
1370     ***********************************************************
1371     Purpose:
1372     This is a generic form function to create a new entry in a
1373     table. The table's primary key must not involve a
1374     composite key -- since this form won't handle that.
1375     **********************************************************/
1376 dpavlin 72 function formEditSingleField($display, $display_field, $key_field, $key_id,
1377 dpavlin 1 $size, $table) {
1378    
1379     // Make sure we have a positive integer to work with
1380     if ($key_id > 1){
1381    
1382     // Fetch previous value
1383     $sql = "SELECT "
1384     . $display_field
1385     . " FROM "
1386     . $table
1387     . " WHERE "
1388     . $key_field
1389     . " = "
1390     . $key_id;
1391    
1392 dpavlin 72 $rs = xx_tryquery($sql);
1393     $row = xx_fetch_array($rs, xx_ASSOC);
1394 dpavlin 1 $oldValue = Trim($row[$display_field]);
1395    
1396     // Table definition
1397     printf("<center>\n");
1398 dpavlin 72 printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">\n");
1399 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1400 dpavlin 72 printf("Edit %s: %s (ID# %d)", $display, $oldValue, $key_id);
1401 dpavlin 1 printf("</td></tr>\n");
1402    
1403     // Form to handle any single field
1404 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1405     printf("<tr><td>\n");
1406     printf("<b>%s:</b>\n", $display);
1407 dpavlin 1 printf("</td>\n");
1408     printf("<td>\n");
1409 dpavlin 72 printf("<input type = \"text\" name = \"newValue\" size=\"%d\" value =\"%s\" >\n", $size, $oldValue);
1410     printf("<input type = \"Hidden\" name = \"display\" value = \"%s\" >\n", $display);
1411     printf("<input type = \"Hidden\" name = \"display_field\" value = \"%s\" >\n", $display_field);
1412     printf("<input type = \"Hidden\" name = \"key_field\" value = \"%s\" >\n", $key_field);
1413     printf("<input type = \"Hidden\" name = \"key_id\" value = \"%s\" >\n", $key_id);
1414     printf("<input type = \"Hidden\" name = \"table\" value = \"%s\" >\n", $table);
1415     printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateSingleField\" >\n");
1416 dpavlin 1 printf("</td></tr>\n");
1417     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
1418 dpavlin 72 printf("<input type = \"Submit\" value = \"Save Changes To %s\" >\n", $display);
1419     printf("<input type = \"Reset\" value = \"Reset\" >\n");
1420 dpavlin 1
1421     // Close things
1422 dpavlin 72 printf("</form><br>\n");
1423     printf("</td></tr>\n");
1424     printf("</table></center>\n");
1425 dpavlin 1
1426     }
1427    
1428     else printf("Nothing selected. Operation cancelled.");
1429     }
1430    
1431    
1432     /**********************************************************
1433     Function: formFaculty
1434     Author: Paul Bramscher
1435 dpavlin 72 Last Modified: 03.16.2004
1436 dpavlin 1 ***********************************************************
1437     Purpose:
1438     Draws an HTML form to edit the supplied faculty id, or to
1439     create a new faculty person if the incoming id is less than
1440     1.
1441     **********************************************************/
1442 dpavlin 72 function formFaculty($faculty_id){
1443 dpavlin 1
1444     // Initialize variables
1445     $faculty_id = (int) $faculty_id;
1446     $faculty_lastname ="";
1447     $faculty_firstname = "";
1448     $faculty_account = "";
1449     $faculty_email = "";
1450    
1451     // If editing an existing faculty member load previous values
1452     if ($faculty_id > 1){
1453     $sql = "SELECT
1454     f.faculty_firstname,
1455     f.faculty_lastname,
1456     f.faculty_account,
1457     f.faculty_email
1458     FROM faculty f
1459     WHERE
1460     faculty_id = " . $faculty_id;
1461 dpavlin 72 $rs = xx_tryquery($sql);
1462     $row = xx_fetch_array($rs, xx_ASSOC);
1463 dpavlin 1
1464     // Fetch results
1465     $faculty_firstname = Trim($row["faculty_firstname"]);
1466     $faculty_lastname = Trim($row["faculty_lastname"]);
1467     $faculty_account = Trim($row["faculty_account"]);
1468     $faculty_email = Trim($row["faculty_email"]);
1469    
1470     // Run strings through the HTML cleaner for output
1471     $faculty_lastname = textOutHTML($faculty_lastname);
1472     $faculty_firstname = textOutHTML($faculty_firstname);
1473     }
1474    
1475     // Table definition
1476     printf("<center><table width=\"75%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
1477    
1478     // If new faculty
1479     if ($faculty_id < 1) {
1480 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
1481 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1482     printf("Enter New Faculty");
1483     printf("</td></tr>\n");
1484     }
1485    
1486     // Else update
1487     else {
1488 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1489 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1490 dpavlin 72 printf("Edit Faculty: %s %s (ID# %d)", $faculty_firstname, $faculty_lastname, $faculty_id);
1491 dpavlin 1 printf("</td></tr>\n");
1492     }
1493    
1494     // Last name
1495     printf("<tr>\n");
1496     printf("<td width=\"40%%\"><b>Last Name:</b></td>\n");
1497     printf("<td><input type = \"text\" name = \"faculty_lastname\" size = \"40\" value = \"%s\" ></td>\n", $faculty_lastname);
1498     printf("</tr>\n");
1499    
1500     // First name
1501     printf("<tr>\n");
1502     printf("<td><b>First Name:</b></td>\n");
1503     printf("<td><input type = \"text\" name = \"faculty_firstname\" size = \"40\" value = \"%s\"></td>\n", $faculty_firstname);
1504     printf("</tr>\n");
1505    
1506     // Faculty account (x500 if applicable)
1507     printf("<tr>\n");
1508     printf("<td><b>Faculty account (x500 if applicable):</b></td>\n");
1509     printf("<td><input type = \"text\" name = \"faculty_account\" size = \"15\" value =\"%s\"></td>\n", $faculty_account);
1510     printf("</tr>\n");
1511    
1512     // Email
1513     printf("<tr>\n");
1514     printf("<td><b>Email:</b></td>\n");
1515     printf("<td><input type = \"text\" name = \"faculty_email\" size = \"40\" value =\"%s\"></td>\n", $faculty_email);
1516     printf("</tr>\n");
1517    
1518     // Buttons
1519     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
1520     // If new faculty
1521     if ($faculty_id < 1) {
1522 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertFaculty\" >\n");
1523     printf("<input type = \"Submit\" value = \"Save New Faculty\" >\n");
1524 dpavlin 1 }
1525     // Editing an existing faculty person
1526     else {
1527 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateFaculty\" >\n");
1528     printf("<input type = \"Hidden\" name = \"faculty_id\" value = \"%d\" >\n", $faculty_id);
1529     printf("<input type = \"Submit\" value = \"Save Faculty Changes\" >\n");
1530 dpavlin 1 }
1531 dpavlin 72 printf("<input type = \"Reset\" value = \"Reset\" >\n");
1532 dpavlin 1
1533     // Close things
1534 dpavlin 72 printf("</form>\n");
1535     printf("</td></tr></table>\n");
1536     printf("</center><br>\n");
1537 dpavlin 1 }
1538    
1539    
1540     /**********************************************************
1541     Function: formFeature
1542     Author: Paul Bramscher
1543 dpavlin 72 Last Modified: 03.15.2004
1544 dpavlin 1 ***********************************************************
1545     Purpose:
1546     Draws an HTML form to edit the supplied feature id, or to
1547     create a new feature if the incoming id is less than 1.
1548     **********************************************************/
1549 dpavlin 72 function formFeature($key_id) {
1550 dpavlin 1
1551     // Cast as integer to be sure
1552     $key_id = (int) $key_id;
1553    
1554     // Check to see if feature actually exists
1555 dpavlin 72 $exists = existsRow("feature", "feature_id", $key_id);
1556 dpavlin 1
1557     // Header
1558     printf("<center>");
1559     if ($key_id > 0 && $exists == 1) {
1560    
1561     // Initialization
1562     $feature = "";
1563     $feature_id = "";
1564    
1565     // Fetch existing values
1566     $sql = "SELECT * FROM feature WHERE feature_id = " . $key_id;
1567 dpavlin 72 $rs = xx_tryquery($sql);
1568     $row = xx_fetch_array ($rs, xx_ASSOC);
1569 dpavlin 1 $feature_id = $row["feature_id"];
1570     $feature = $row["feature"];
1571     $image_path = $row["image_path"];
1572     $image_alt = $row["image_alt"];
1573    
1574     // Run strings through the HTML cleaner for output
1575     $feature = textOutHTML($feature);
1576     $image_path = textOutHTML($image_path);
1577     $image_alt = textOutHTML($image_alt);
1578     }
1579    
1580     // Houston, we have a problem
1581     if ($key_id > 0 && $exists == 0) {
1582     $problem = 1;
1583 dpavlin 72 printf("<h3>Feature (ID# %d) Not Found</h3>\n", $key_id);
1584 dpavlin 1 }
1585    
1586     // If no problems, then go for landing
1587     if ($problem != 1) {
1588    
1589     // Table definition
1590     printf("<center><table width=\"75%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
1591    
1592     // Form to handle feature
1593     // If new insert
1594     if ($key_id <1) {
1595 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
1596 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1597     printf("Enter New Feature");
1598     printf("</td></tr>\n");
1599     }
1600    
1601     // Else update
1602     else {
1603 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1604 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1605 dpavlin 72 printf("Edit Feature: %s (ID# %d)", $feature, $feature_id);
1606 dpavlin 1 printf("</td></tr>\n");
1607     }
1608    
1609     // Feature name
1610     printf("<tr>\n");
1611 dpavlin 72 printf("<td><b>Feature:</b></td>\n");
1612 dpavlin 1 printf("<td><input type = \"text\" name = \"feature\" size = \"40\" value = \"%s\" ></td>\n", $feature);
1613     printf("</tr>\n");
1614    
1615     // Image path
1616     printf("<tr>\n");
1617     printf("<td><b>Image Path:</b></td>\n");
1618     printf("<td><input type = \"text\" name = \"image_path\" size = \"50\" value = \"%s\" ></td>\n", $image_path);
1619     printf("</tr>\n");
1620    
1621     // Image alt text
1622     printf("<tr>\n");
1623     printf("<td><b>Image Alt Text:</b></td>\n");
1624     printf("<td><input type = \"text\" name = \"image_alt\" size = \"50\" value = \"%s\" ></td>\n", $image_alt);
1625    
1626     // Buttons
1627     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
1628     // If this is an existing feature
1629     if ($key_id > 0) {
1630 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateFeature\" >\n");
1631     printf("<input type = \"Submit\" value = \"Update Feature\" >\n");
1632     printf("<input type = \"Hidden\" name = \"feature_id\" value = \"%d\" >\n", $feature_id);
1633 dpavlin 1 }
1634     // Editing a new feature
1635     else {
1636 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertFeature\" >\n");
1637     printf("<input type = \"Submit\" value = \"Save New Feature\">\n");
1638 dpavlin 1 }
1639    
1640     // Common button
1641     printf("<input type = \"Reset\" value = \"Reset\" >\n");
1642    
1643     // Close things
1644     printf("</form>\n");
1645     printf("</td></tr></table></center>\n");
1646    
1647     } // No problems
1648     }
1649    
1650    
1651     /**********************************************************
1652     Function: formInfotype
1653     Author: Paul Bramscher
1654 dpavlin 72 Last Modified: 03.15.2004
1655 dpavlin 1 ***********************************************************
1656     Purpose:
1657     Draws an HTML form to edit the supplied information type id,
1658     or to create a new information type if the incoming id is
1659     less than 1.
1660     **********************************************************/
1661 dpavlin 72 function formInfotype($key_id) {
1662 dpavlin 1
1663     // Cast as integer to be sure
1664     $key_id = (int) $key_id;
1665    
1666     // Check to see if infotype actually exists
1667 dpavlin 72 $exists = existsRow("infotype", "infotype_id", $key_id);
1668 dpavlin 1
1669     // Header
1670 dpavlin 72 printf("<center>\n");
1671 dpavlin 1 if ($key_id > 0 && $exists == 1) {
1672    
1673     // Initialization
1674     $infotype = "";
1675     $infotype_id = "";
1676     $masterinfotype_id = "";
1677     $mastersubject_id = "";
1678    
1679     // Fetch existing values
1680     $sql = "SELECT * from infotype where infotype_id = " . $key_id;
1681 dpavlin 72 $rs = xx_tryquery($sql);
1682     $row = xx_fetch_array ($rs, xx_ASSOC);
1683 dpavlin 1 $infotype_id = $row["infotype_id"];
1684     $infotype = $row["infotype"];
1685     $masterinfotype_id = $row["masterinfotype_id"];
1686     $mastersubject_id = $row["mastersubject_id"];
1687    
1688     // Run strings through the HTML cleaner for output
1689     $infotype = textOutHTML($infotype);
1690    
1691     }
1692    
1693     // Houston, we have a problem
1694     if ($key_id > 0 && $exists == 0) {
1695     $problem = 1;
1696 dpavlin 72 printf("<h3>Information Type (ID# %d) Not Found</h3>\n", $key_id);
1697 dpavlin 1 }
1698    
1699     // If no problems, then go for landing
1700     if ($problem != 1) {
1701    
1702     // Table
1703     printf("<center><table width=\"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
1704    
1705     // If new insert
1706     if ($key_id < 1) {
1707 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
1708 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1709     printf("Enter New Information Type");
1710     printf("</td></tr>\n");
1711    
1712     }
1713    
1714     // Else update
1715     else {
1716 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1717 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1718 dpavlin 72 printf("Edit Information Type: %s (ID# %d)", $infotype, $infotype_id);
1719 dpavlin 1 printf("</td></tr>\n");
1720     }
1721    
1722     // Infotype
1723     printf("<tr>\n");
1724     printf("<td><b>Information Type:</b></td>\n");
1725     printf("<td><input type = \"text\" name = \"infotype\" size = \"60\" value = \"%s\" ></td>\n", $infotype);
1726     printf("</tr>\n");
1727    
1728     // Masterinfotype
1729     printf("<tr>\n");
1730     printf("<td><b>Master Information Type:</b></td>\n");
1731     printf("<td>\n");
1732 dpavlin 72 printf("<select name =\"masterinfotype_id\">\n");
1733     dropDownFieldSelected("masterinfotype", "masterinfotype", "masterinfotype_id", "WHERE masterinfotype_id >= 0", $masterinfotype_id);
1734 dpavlin 1 printf("</select>\n");
1735     printf("</td></tr>\n");
1736    
1737     // Mastersubject
1738     printf("<tr>\n");
1739 dpavlin 72 printf("<td><b>Master Subject:</b></td>\n");
1740 dpavlin 1 printf("<td>\n");
1741 dpavlin 72 printf("<select name =\"mastersubject_id\">\n");
1742     dropDownFieldSelected("mastersubject", "mastersubject", "mastersubject_id", "WHERE mastersubject_id >= 0", $mastersubject_id);
1743 dpavlin 1 printf("</select>\n");
1744     printf("</td></tr>\n");
1745    
1746     // Buttons
1747     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
1748    
1749     // If this is an existing infotype
1750     if ($key_id > 0) {
1751 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateInfotype\" >\n");
1752     printf("<input type = \"Submit\" value = \"Update Info Type\" >\n");
1753     printf("<input type = \"Hidden\" name = \"infotype_id\" value = \"%d\" >\n", $infotype_id);
1754 dpavlin 1 }
1755     // Editing a new infotype
1756     else {
1757 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertInfotype\" >\n");
1758     printf("<input type = \"Submit\" value = \"Save New Info Type\">\n");
1759 dpavlin 1 }
1760    
1761     // Common button
1762     printf("<input type = \"Reset\" value = \"Reset\" >\n");
1763    
1764     // Close things
1765     printf("</form>\n");
1766     printf("</td></tr></table></center>\n");
1767    
1768    
1769     } // No problems
1770     }
1771    
1772    
1773     /**********************************************************
1774 dpavlin 72 Function: formLibunit
1775     Author: Paul Bramscher
1776     Last Modified: 03.16.2004
1777     ***********************************************************
1778     Purpose:
1779     Handles the creation of new (or editing of existing)
1780     library units.
1781     **********************************************************/
1782     function formLibunit($key_id){
1783    
1784     // Initialize variables
1785     $libunit_id = (int) $key_id;
1786     $libunit ="";
1787     $libunit_abbrev = "";
1788    
1789     // If editing an existing library unit load previous values
1790     if ($libunit_id > 1){
1791     $sql = "SELECT
1792     l.libunit,
1793     l.libunit_abbrev,
1794     l.head_staff_id
1795     FROM libunit l
1796     WHERE
1797     libunit_id = " . $libunit_id;
1798     $rs = xx_tryquery($sql);
1799     $row = xx_fetch_array($rs, xx_ASSOC);
1800    
1801     // Fetch values
1802     $libunit = Trim($row["libunit"]);
1803     $libunit_abbrev = Trim($row["libunit_abbrev"]);
1804     $head_staff_id = $row["head_staff_id"];
1805    
1806     // Run strings through the HTML cleaner for output
1807     $libunit = textOutHTML($libunit);
1808     $libunit_abbrev = textOutHTML($libunit_abbrev);
1809    
1810     }
1811    
1812     // Table definition
1813     printf("<center><table width=\"75%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
1814    
1815     // If new insert
1816     if ($key_id <1) {
1817     printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
1818     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1819     printf("Enter New Library Unit");
1820     printf("</td></tr>\n");
1821     }
1822    
1823     // Else update
1824     else {
1825     printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1826     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1827     printf("Edit Library Unit: %s (ID# %d)", $libunit, $libunit_id);
1828     printf("</td></tr>\n");
1829     }
1830    
1831     // Libunit
1832     printf("<td><b>Library Unit:</b></td>\n");
1833     printf("<td><input type = \"text\" name = \"libunit\" size = \"60\" value = \"%s\" ></td>\n", $libunit);
1834     printf("</td></tr>\n");
1835    
1836     // Libunit abbrev.
1837     printf("<tr>\n");
1838     printf("<td><b>Abbreviation:</b></td>\n");
1839     printf("<td><input type = \"text\" name = \"libunit_abbrev\" size = \"20\" value = \"%s\"></td>\n", $libunit_abbrev);
1840     printf("</tr>\n");
1841    
1842     // Libunit lead
1843     printf("<tr>\n");
1844     printf("<td><b>Unit Lead:</b></td>\n");
1845     printf("<td><select name = \"head_staff_id\" >\n");
1846     dropDownStaffSelected($head_staff_id);
1847     printf("</select></td>\n");
1848     printf("</tr>\n");
1849    
1850     // Buttons
1851     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
1852    
1853     // If new libunit
1854     if ($libunit_id < 2) {
1855     printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertLibunit\" >\n");
1856     printf("<input type = \"Submit\" value = \"Save New Library Unit\" >\n");
1857     }
1858     // Editing an existing libunit
1859     else {
1860     printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateLibunit\" >\n");
1861     printf("<input type = \"Hidden\" name = \"libunit_id\" value = \"%d\" >\n", $libunit_id);
1862     printf("<input type = \"Submit\" value = \"Save Library Unit Changes\" >\n");
1863     }
1864     printf("<input type = \"Reset\" value = \"Reset\" >\n");
1865    
1866     // Close the form and table
1867     printf("</form>\n");
1868     printf("</td></tr></table>\n");
1869    
1870     // Other forms - only if editing an existing libunit
1871    
1872     if ($libunit_id > 0) {
1873     formAssignLibunitStaff($libunit_id);
1874     }
1875    
1876     printf("</center><br>\n");
1877     }
1878    
1879    
1880     /**********************************************************
1881 dpavlin 1 Function: formLocation
1882     Author: Paul Bramscher
1883 dpavlin 72 Last Modified: 03.15.2004
1884 dpavlin 1 ***********************************************************
1885     Draws an HTML form to edit the supplied location id, or to
1886     create a new location if the incoming id is less than 1.
1887     **********************************************************/
1888 dpavlin 72 function formLocation($key_id) {
1889 dpavlin 1
1890     // Cast as integer to be sure
1891     $key_id = (int) $key_id;
1892    
1893     // Check to see if location actually exists
1894 dpavlin 72 $exists = existsRow("location", "location_id", $key_id);
1895 dpavlin 1
1896     // Header
1897     printf("<center>");
1898     if ($key_id > 0 && $exists == 1) {
1899    
1900     // Initialization
1901     $location = "";
1902     $location_descr = "";
1903     $campus = "";
1904     $address1 = "";
1905     $address2 = "";
1906     $address3 = "";
1907     $address4 = "";
1908     $mainURL = "";
1909     $referenceURL = "";
1910     $mapURL = "";
1911     $hoursURL = "";
1912     $telephone = "";
1913    
1914     // Fetch existing values
1915     $sql = "SELECT * from location where location_id = " . $key_id;
1916 dpavlin 72 $rs = xx_tryquery($sql);
1917     $row = xx_fetch_array ($rs, xx_ASSOC);
1918 dpavlin 1 $location_id = $row["location_id"];
1919     $location = $row["location"];
1920     $location_descr = $row["location_descr"];
1921     $campus = $row["campus"];
1922     $address1 = $row["address1"];
1923     $address2 = $row["address2"];
1924     $address3 = $row["address3"];
1925     $address4 = $row["address4"];
1926     $mainURL = $row["mainURL"];
1927     $referenceURL = $row["referenceURL"];
1928     $mapURL = $row["mapURL"];
1929     $hoursURL = $row["hoursURL"];
1930     $telephone = $row["telephone"];
1931    
1932     // Run strings through the HTML cleaner for output
1933     $location = textOutHTML($location);
1934     $location_descr = textOutHTML($location_descr);
1935     $campus = textOutHTML($campus);
1936     $address1 = textOutHTML($address1);
1937     $address2 = textOutHTML($address2);
1938     $address3 = textOutHTML($address3);
1939     $address4 = textOutHTML($address4);
1940    
1941     }
1942    
1943     // Houston, we have a problem
1944     if ($key_id > 0 && $exists == 0) {
1945     $problem = 1;
1946 dpavlin 72 printf("<h3>Location (ID# %d) Not Found</h3>\n", $key_id);
1947 dpavlin 1 }
1948    
1949     // If no problems, then go for landing
1950     if ($problem != 1) {
1951    
1952     // Table definition
1953     printf("<center><table width=\"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
1954    
1955     // If new insert
1956     if ($key_id <1) {
1957 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
1958 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1959     printf("Enter New Location");
1960     printf("</td></tr>\n");
1961     }
1962    
1963     // Else update
1964     else {
1965 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
1966 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
1967 dpavlin 72 printf("Edit Location: %s (ID# %d)", $location, $location_id);
1968 dpavlin 1 printf("</td></tr>\n");
1969     }
1970    
1971     // Location/Library
1972     printf("<tr>\n");
1973 dpavlin 72 printf("<td><b>Location/Library:</b></td>\n");
1974 dpavlin 1 printf("<td>\n");
1975 dpavlin 72 printf("<input type = \"text\" name = \"location\" size = \"60\" value = \"%s\" >\n", $location);
1976 dpavlin 1 printf("</td></tr>\n");
1977    
1978     // Description
1979     printf("<tr><td colspan=\"2\"><br>\n");
1980     printf("<b>Description:</b><br>\n");
1981     printf("<textarea name = \"location_descr\" rows = \"5\" cols = \"70\" >\n");
1982     printf("%s", $location_descr);
1983     printf("</textarea><br><br><br>\n");
1984     printf("</td></tr>\n");
1985    
1986     // Campus
1987     printf("<tr>\n");
1988     printf("<td><b>Campus:</b></td>\n");
1989     printf("<td>\n");
1990 dpavlin 72 printf("<input type = \"text\" name = \"campus\" size = \"50\" value = \"%s\" >\n", $campus);
1991 dpavlin 1 printf("</td></tr>\n");
1992    
1993     // Address1
1994     printf("<tr>\n");
1995     printf("<td><b>Address Line 1:</b></td>\n");
1996     printf("<td>\n");
1997 dpavlin 72 printf("<input type = \"text\" name = \"address1\" size = \"50\" value = \"%s\" >\n", $address1);
1998 dpavlin 1 printf("</td></tr>\n");
1999    
2000     // Address2
2001     printf("<tr>\n");
2002     printf("<td><b>Address Line 2:</b></td>\n");
2003     printf("<td>\n");
2004 dpavlin 72 printf("<input type = \"text\" name = \"address2\" size = \"50\" value = \"%s\" >\n", $address2);
2005 dpavlin 1 printf("</td></tr>\n");
2006    
2007     // Address3
2008     printf("<tr>\n");
2009     printf("<td><b>Address Line 3:</b></td>\n");
2010     printf("<td>\n");
2011 dpavlin 72 printf("<input type = \"text\" name = \"address3\" size = \"50\" value = \"%s\" >\n", $address3);
2012 dpavlin 1 printf("</td></tr>\n");
2013    
2014     // Address4
2015     printf("<tr>\n");
2016     printf("<td><b>Address Line 4:</b></td>\n");
2017     printf("<td>\n");
2018 dpavlin 72 printf("<input type = \"text\" name = \"address4\" size = \"50\" value = \"%s\" >\n", $address4);
2019 dpavlin 1 printf("</td></tr>\n");
2020    
2021     // Telephone
2022     printf("<tr>\n");
2023     printf("<td><b>Telephone:</b></td>\n");
2024     printf("<td>\n");
2025 dpavlin 72 printf("<input type = \"text\" name = \"telephone\" size = \"25\" value = \"%s\" >\n", $telephone);
2026 dpavlin 1 printf("</td></tr>\n");
2027    
2028     // mainURL
2029     printf("<tr>\n");
2030     printf("<td><b>Main URL:</b></td>\n");
2031     printf("<td>\n");
2032 dpavlin 72 printf("<input type = \"text\" name = \"mainURL\" size = \"70\" value = \"%s\" >\n", $mainURL);
2033 dpavlin 1 printf("</td></tr>\n");
2034    
2035     // referenceURL
2036     printf("<tr>\n");
2037     printf("<td><b>Reference URL:</b></td>\n");
2038     printf("<td>\n");
2039 dpavlin 72 printf("<input type = \"text\" name = \"referenceURL\" size = \"70\" value = \"%s\" >\n",
2040 dpavlin 1 $referenceURL);
2041     printf("</td></tr>\n");
2042    
2043     // hoursURL
2044     printf("<tr>\n");
2045     printf("<td><b>Hours URL:</b></td>\n");
2046     printf("<td>\n");
2047 dpavlin 72 printf("<input type = \"text\" name = \"hoursURL\" size = \"70\" value = \"%s\" >\n",
2048 dpavlin 1 $hoursURL);
2049     printf("</td></tr>\n");
2050    
2051     // mapURL
2052     printf("<tr>\n");
2053     printf("<td><b>Map URL:</b></td>\n");
2054     printf("<td>\n");
2055 dpavlin 72 printf("<input type = \"text\" name = \"mapURL\" size = \"70\" value = \"%s\" >\n", $mapURL);
2056 dpavlin 1 printf("</td></tr>\n");
2057    
2058     // Buttons
2059     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
2060    
2061     // If this is an existing location
2062     if ($key_id > 0) {
2063 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateLocation\" >\n");
2064     printf("<input type = \"Submit\" value = \"Update Location\" >\n");
2065     printf("<input type = \"Hidden\" name = \"location_id\" value = \"%d\" >\n", $location_id);
2066 dpavlin 1 }
2067     // Editing a new location
2068     else {
2069 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertLocation\" >\n");
2070     printf("<input type = \"Submit\" value = \"Save New Location\" >\n");
2071 dpavlin 1 }
2072    
2073     // Common button
2074     printf("<input type = \"Reset\" value = \"Reset\" >\n");
2075    
2076     // Close things
2077     printf("</form>\n");
2078     printf("</td></tr></table></center>\n");
2079    
2080     } // No problems
2081     }
2082    
2083    
2084     /**********************************************************
2085 dpavlin 72 Function: formNewSingleField($display, $field,
2086 dpavlin 1 $size, $table);
2087     Author: Paul Bramscher
2088 dpavlin 72 Last Modified: 03.11.2004
2089 dpavlin 1 ***********************************************************
2090     Incoming:
2091     $field Field name within $table
2092     $display A display to the user, typically
2093     identical to $field
2094     $size The size of the HTML input box
2095 dpavlin 72 $table Table name to operate against
2096 dpavlin 1 ***********************************************************
2097     Outgoing:
2098     None
2099     ***********************************************************
2100     Purpose:
2101     This is a generic form function to create a new entry in a
2102     table. The table's primary key must not involve a
2103     composite key since this form won't handle that.
2104     **********************************************************/
2105 dpavlin 72 function formNewSingleField($display, $field, $size, $table) {
2106 dpavlin 1
2107     // Draw Box
2108     printf("<center>\n");
2109 dpavlin 72 printf("<table width = \"60%%\" border = \"1\" cellpadding =\"4\" class=\"backLight\">\n");
2110 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
2111     printf("Enter New %s", $display);
2112     printf("</td></tr>\n");
2113    
2114     // Form for the new field value
2115 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
2116 dpavlin 1 printf("<tr>\n");
2117     printf("<td><b>%s:</b></td>\n", $display);
2118 dpavlin 72 printf("<td>\n");
2119     printf("<input type = \"text\" name = \"newValue\" size = \"%d\" >\n", $size);
2120     printf("<input type = \"Hidden\" name = \"table\" value = \"%s\" >\n", $table);
2121     printf("<input type = \"Hidden\" name = \"field\" value = \"%s\" >\n", $field);
2122     printf("<input type = \"Hidden\" name = \"display\" value = \"%s\" >\n", $display);
2123     printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertSingleField\" >\n");
2124 dpavlin 1 printf("</td></tr>\n");
2125     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
2126 dpavlin 72 printf("<input type = \"Submit\" value = \"Save New %s\" >\n", $display);
2127     printf("<input type = \"Reset\" value = \"Reset\" >\n");
2128 dpavlin 1
2129     // Close things
2130 dpavlin 72 printf("</form><br>\n");
2131     printf("</td></tr>\n");
2132     printf("</table><br></center>\n");
2133 dpavlin 1 }
2134    
2135    
2136     /**********************************************************
2137 dpavlin 72 Function: formPassword
2138     Author: Paul Bramscher
2139     Last Modified: 03.11.2004
2140     ***********************************************************
2141     Purpose:
2142     Creates a new password for the supplied staff id. Note
2143     that this is a locally stored (in mySQL) and encrypted
2144     password. It is never visible in plaintext, nor is it
2145     ever brought to an HTML form, neither in plaintext nor
2146     in a "password" type HTML form field.
2147     **********************************************************/
2148     function formPassword($staff_id){
2149    
2150     /*****************************************
2151     ** If using native mySQL authentication **
2152     *****************************************/
2153    
2154     // Table definition
2155     printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
2156    
2157     // Form
2158     printf("<form method = \"POST\" action = \"update.phtml\" >\n");
2159     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
2160     printf("Local Authentication Password - See Note Below");
2161     printf("</td></tr>\n");
2162    
2163     // Staff password - for mySQL authentication only. Ignored if x500 account is present.
2164     printf("<tr><td colspan=\"2\">\n");
2165     printf("<b>Note:</b> Supply if utilizing mySQL authentication, otherwise leave blank. ");
2166     printf("This will replace the password (if any) currently assigned to this account.");
2167     printf("</td></tr>\n");
2168    
2169     // First type
2170     printf("<tr>\n");
2171     printf("<td><b>New Password (6 char. minimum):</b></td>\n");
2172     printf("<td><input type = \"password\" name = \"password\" size = \"25\"></td>\n");
2173     printf("</tr>\n");
2174    
2175     // Confirm type
2176     printf("<tr>\n");
2177     printf("<td><b>Confirm password (type again):</b></td>\n");
2178     printf("<td><input type = \"password\" name = \"password_confirm\" size = \"25\"></td>\n");
2179     printf("</tr>\n");
2180    
2181     // Buttons
2182     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
2183     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id);
2184     printf("<input type = \"Hidden\" name = \"transaction\" value = \"updatePassword\" >\n");
2185     printf("<input type = \"Submit\" value = \"Save Local Password\" >\n");
2186    
2187     // Close the form and table
2188     printf("</form>\n");
2189     printf("</td></tr></table>\n");
2190    
2191    
2192     /*******************************************
2193     ** Determine if a password already exists **
2194     *******************************************/
2195    
2196    
2197     // Initialize variables
2198     $pass_set = 0;
2199    
2200     // Determine whether a password exists
2201     $sql = "SELECT COUNT(*) as pass_set
2202     FROM staff s
2203     WHERE (s.password <> NULL OR s.password <> '') and s.staff_id = " . $staff_id;
2204    
2205     $rs = xx_tryquery($sql);
2206     $row = xx_fetch_array($rs, xx_ASSOC);
2207    
2208     // Fetch values
2209     $pass_set = $row["pass_set"];
2210    
2211     // If some password already exists, offer this form
2212     if ($pass_set > 0) {
2213    
2214     // Table definition
2215     printf("<br><table width=\"60%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
2216    
2217     // Form
2218     printf("<tr><td class=\"cellPlain\">\n");
2219     printf("Local Password Found");
2220     printf("</td></tr>\n");
2221     printf("<form method = \"POST\" action = \"update.phtml\" >\n");
2222    
2223     // Purge existing password
2224     printf("<tr><td>\n");
2225     printf("<br><b>Purge password to null?</b><br><br>\n");
2226     printf("<b>Note:</b> It appears that this account currently has a password assigned to it.");
2227     printf("This option will clear out any existing password, and leave the value NULL.");
2228     printf("The staffperson may not login until a new password is supplied.<br><br>\n");
2229    
2230     // Buttons
2231     printf("<center>\n");
2232     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id);
2233     printf("<input type = \"Hidden\" name = \"transaction\" value = \"purgePassword\" >\n");
2234     printf("<input type = \"Submit\" value = \"Purge Password!\" >\n");
2235    
2236     // Close the form and table
2237     printf("</form>\n");
2238     printf("</center></td></tr></table><br>\n");
2239    
2240     } // end password purge form
2241    
2242     } // end function
2243    
2244    
2245     /**********************************************************
2246 dpavlin 1 Function: formResource
2247     Author: Paul Bramscher
2248 dpavlin 72 Last Modified: 03.16.2004 by Paul Bramscher
2249 dpavlin 1 ***********************************************************
2250     Draws an HTML form to edit the supplied resource id, or to
2251     create a new resource if the incoming id is less than 1.
2252     Note also that there are incoming masterinfotype id,
2253     mastersubject id, an title parameters.
2254     **********************************************************/
2255 dpavlin 72 function formResource($key_id, $masterinfotype_id, $mastersubject_id, $title) {
2256 dpavlin 1
2257     // Cast as integer to be sure
2258     $key_id = (int) $key_id;
2259    
2260     // Check to see if record actually exists
2261 dpavlin 72 $exists = existsRow("resource", "resource_id", $key_id);
2262 dpavlin 1
2263     // Houston, we have a problem
2264     if ($key_id > 0 && $exists == 0) {
2265     $problem = 1;
2266 dpavlin 72 msgTableOpen(1, "Edit Resource (ID# " . $key_id . ")");
2267     printf("<b>Messages:</b><br>\n");
2268     printf("Resource not found. Operation cancelled.");
2269     printf("<br><br>\n");
2270     msgTableClose();
2271 dpavlin 1 }
2272    
2273    
2274     // If no problems, then go for landing
2275     if ($problem != 1) {
2276     // Initialization
2277     if (strlen($title) > 0) {
2278     // Decode the title and strip slashes -- twice to be sure
2279     $title = urldecode($title);
2280     $title = stripslashes($title);
2281     $title = stripslashes($title);
2282     }
2283     $other_title = "";
2284     $coverage_detail = "";
2285     $sources_indexed = "";
2286     $location_id = "";
2287     $author = "";
2288     $format_id = 0;
2289     $pub_loc = "";
2290     $publisher = "";
2291     $pub_date = "";
2292     $edition = "";
2293     $call_no = "";
2294     $cat_num = "";
2295     $site_title = "";
2296     $url = "";
2297     $visited = "";
2298     $annotation ="";
2299 dpavlin 72 $vendor_id = 0;
2300 dpavlin 1
2301     // If the user is editing an existing record, fetch previous values
2302     if ($key_id > 0 && $exists == 1) {
2303    
2304     $sql = "SELECT * from resource where resource_id = " . $key_id;
2305 dpavlin 72 $rs = xx_tryquery($sql);
2306     $row = xx_fetch_array ($rs, xx_ASSOC);
2307 dpavlin 1
2308     // Fetch existing values
2309     $resource_id = $row["resource_id"];
2310     $date_created = $row["date_created"];
2311     $date_modified = $row["date_modified"];
2312     $account_created = $row["account_created"];
2313     $account_modified = $row["account_modified"];
2314     $title = $row["title"];
2315     $author = $row["author"];
2316     $format_id = $row["format_id"];
2317     $pub_loc = $row["pub_loc"];
2318     $publisher = $row["publisher"];
2319     $pub_date = $row["pub_date"];
2320     $edition = $row["edition"];
2321     $call_no = $row["call_no"];
2322     $cat_num = $row["cat_num"];
2323     $site_title = $row["site_title"];
2324     $url = $row["url"];
2325 dpavlin 72 $guide_url = $row["guide_url"];
2326 dpavlin 1 $visited = $row["visited"];
2327     $annotation = $row["annotation"];
2328     $infotype_id = $row["infotype_id"];
2329     $other_title = $row["other_title"];
2330     $coverage_detail = $row["coverage_detail"];
2331     $sources_indexed = $row["sources_indexed"];
2332     $location_id = $row["location_id"];
2333 dpavlin 72 $vendor_id = $row["vendor_id"];
2334     $resource_status = $row["resource_status"];
2335     $resource_message = $row["resource_message"];
2336 dpavlin 1
2337     // Run strings through the HTML cleaner for output
2338     $title = textOutHTML($title);
2339     $author = textOutHTML($author);
2340     $publisher = textOutHTML($publisher);
2341     $pub_date = textOutHTML($pub_date);
2342     $edition = textOutHTML($edition);
2343     $call_no = textOutHTML($call_no);
2344     $cat_num = textOutHTML($cat_num);
2345     $site_title = textOutHTML($site_title);
2346     $other_title = textOutHTML($other_title);
2347     $coverage_detail = textOutHTML($coverage_detail);
2348     $sources_indexed = textOutHTML($sources_indexed);
2349     };
2350    
2351     // Display feedback to the user if resource was entered today
2352    
2353     // Fetch today's date
2354     $today = getdate();
2355     $mon = $today[mon];
2356     $mday = $today[mday];
2357     $year = $today[year];
2358    
2359     // Back-fill in case we have single-digits.
2360     if (strlen($mday) < 2) $mday = "0" . $mday;
2361     if (strlen($mon) < 2) $mon = "0" . $mon;
2362    
2363     // Generate a mySQL-friendly datetime for today's stamp
2364     $today_stamp = $year . "-" . $mon . "-" . $mday;
2365    
2366     if (substr($date_created, 0, 10) == $today_stamp) {
2367     printf("<center>\n");
2368     printf("Resource <b>'%s'</b> successfully added today by <b>%s</b>.<br>\n", $title, $account_created);
2369     printf("Scroll <a href=\"#additional\">down</a> to edit further attributes for this resource.<br><br>\n");
2370     printf("</center><br>\n");
2371     }
2372    
2373    
2374     // Exterior table for border
2375     printf("<center><table width=\"75%%\" border=\"1\" class=\"backLight\" cellspacing=\"2\" cellpadding=\"0\" ><tr><td>\n");
2376    
2377     // Table definition
2378     printf("<table width=\"100%%\" border=\"0\" cellspacing =\"2\" cellpadding=\"2\">\n");
2379    
2380     // Form header
2381 dpavlin 72 printf("<tr><td colspan=\"4\" class=\"cellPlain\" >\n");
2382     if ($key_id > 0 && $exists == 1) printf("Edit Resource (ID# %d)", $key_id);
2383 dpavlin 1 if ($key_id <= 0) printf("Enter New Resource\n");
2384     printf("</td></tr>\n");
2385    
2386     // If new insert
2387 dpavlin 72 if ($key_id <1) printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
2388 dpavlin 1
2389     // Else update
2390 dpavlin 72 else printf("<form method = \"POST\" action = \"update.phtml\" >\n");
2391 dpavlin 1
2392     // Account & Time/date information if this is not a new resource
2393     if ($key_id > 0) {
2394     printf("<tr>\n<td colspan = \"1\">\n");
2395 dpavlin 72 printf("<br><B>Date Created:</b>\n");
2396 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2397     printf("<BR>%s</td></tr>", $date_created);
2398     printf("<tr>\n<td colspan = \"1\">\n");
2399 dpavlin 72 printf("<B>Date Modified:</b>\n");
2400 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2401 dpavlin 72 printf("%s</td></tr>\n", $date_modified);
2402 dpavlin 1
2403     printf("<tr>\n<td colspan = \"1\">\n");
2404 dpavlin 72 printf("<br><B>Creator:</b>\n");
2405 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2406 dpavlin 72 printf("<BR>%s</td></tr>\n", $account_created);
2407 dpavlin 1 printf("<tr>\n<td colspan = \"1\">\n");
2408 dpavlin 72 printf("<B>Last Modified by:</b>\n");
2409 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2410 dpavlin 72 printf("%s</td></tr>\n", $account_modified);
2411 dpavlin 1 }
2412    
2413     // Title
2414     printf("<tr><td colspan =\"1\" >\n");
2415 dpavlin 72 printf("<br><b>Title:</b>\n");
2416 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2417 dpavlin 72 printf("<br><input type = \"text\" name = \"title\" size = \"60\" value =\"%s\" >\n", $title);
2418 dpavlin 1 printf("</td></tr>\n");
2419    
2420     // Other Title
2421     printf("<tr><td colspan =\"1\" >\n");
2422 dpavlin 72 printf("<b>Other Title:</b>\n");
2423 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2424 dpavlin 72 printf("<input type = \"text\" name = \"other_title\" size = \"60\" value =\"%s\" >\n", $other_title);
2425 dpavlin 1 printf("</td></tr>\n");
2426    
2427     // Author(s)
2428     printf("<tr><td colspan =\"1\" >\n");
2429 dpavlin 72 printf("<br><b>Author(s):</b>\n");
2430 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2431 dpavlin 72 printf("<br><input type = \"text\" name = \"author\" size = \"60\" value =\"%s\" >\n", $author);
2432 dpavlin 1 printf("<br><i>(if applicable)</i></td></tr>\n");
2433    
2434     // Coverage detail
2435     printf("<tr><td colspan = \"1\" valign=\"top\">\n");
2436 dpavlin 72 printf("<b>Coverage Detail:</b>\n");
2437 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2438 dpavlin 72 printf("<textarea name = \"coverage_detail\" cols = \"40\" rows = \"2\">\n");
2439 dpavlin 1 printf("%s", $coverage_detail);
2440 dpavlin 72 printf("</textarea>\n");
2441     printf("<br><i>(enter year, i.e. 1966 - 1985, or 1984 - present)</i>\n");
2442 dpavlin 1 printf("<br><br></td></tr>\n");
2443    
2444     // Sources Indexed
2445     printf("<tr><td colspan =\"1\" valign=\"top\">\n");
2446 dpavlin 72 printf("<b>Sources Indexed:</b>\n");
2447 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2448 dpavlin 72 printf("<input type = \"text\" name = \"sources_indexed\" size = \"60\" value =\"%s\" >\n", $sources_indexed);
2449     printf("<br><i>(enter link to vendor page)</i>\n");
2450 dpavlin 1 printf("</td></tr>\n");
2451    
2452     // URL
2453     printf("<tr><td colspan = \"1\" valign=\"top\">\n");
2454 dpavlin 72 printf("<b>URL</a>:</b>\n");
2455 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2456 dpavlin 72 printf("<textarea name = \"url\" rows = \"4\" cols = \"51\" >\n");
2457 dpavlin 1 printf("%s", $url);
2458 dpavlin 72 printf("</textarea><br>\n");
2459 dpavlin 1 printf("</td></tr>\n");
2460    
2461 dpavlin 72 // Guide/Help URL
2462     printf("<tr><td colspan = \"1\" valign=\"top\">\n");
2463     printf("<b>Guide/Help URL</a>:</b>\n");
2464     printf("</td><td colspan =\"3\">\n");
2465     printf("<textarea name = \"guide_url\" rows = \"4\" cols = \"51\" >\n");
2466     printf("%s", $guide_url);
2467     printf("</textarea><br>\n");
2468     printf("</td></tr>\n");
2469    
2470 dpavlin 1 // Publisher
2471     printf("<tr><td colspan = \"1\" >\n");
2472 dpavlin 72 printf("<b>Publisher:</b>\n");
2473 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2474 dpavlin 72 printf("<input type = \"text\" name = \"publisher\" size = \"50\" value =\"%s\" >\n", $publisher);
2475 dpavlin 1 printf("</td></tr>\n");
2476    
2477     // Publish date
2478     printf("<td colspan = \"1\" >\n");
2479 dpavlin 72 printf("<b>Publish Date:</b>\n");
2480 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2481 dpavlin 72 printf("<input type = \"text\" name = \"pub_date\" size = \"50\" value = \"%s\" >\n", $pub_date);
2482 dpavlin 1 printf("</td></tr>\n");
2483    
2484     // Edition
2485     printf("<tr><td colspan = \"1\" >\n");
2486 dpavlin 72 printf("<b>Edition:</b>\n");
2487 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2488 dpavlin 72 printf("<input type = \"text\" name = \"edition\" size = \"20\" value = \"%s\" >\n", $edition);
2489     printf("</td></tr>\n");
2490 dpavlin 1
2491     // Library Location / Call number
2492     printf("<td colspan = \"1\" valign=\"top\">\n");
2493 dpavlin 72 printf("<b>Library Location and Call No.:</b>\n");
2494 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2495     printf("<textarea rows=\"4\" cols = \"50\" name = \"call_no\">\n");
2496     printf($call_no);
2497 dpavlin 72 printf("</textarea></td></tr>\n");
2498 dpavlin 1
2499     // Catalog Number
2500     printf("<tr><td colspan = \"1\" >\n");
2501 dpavlin 72 printf("<b>Catalog No.:</b>\n");
2502 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2503 dpavlin 72 printf("<input type = \"text\" name = \"cat_num\" size = \"25\" value = \"%s\" >\n", $cat_num);
2504     printf("</td></tr>\n");
2505 dpavlin 1
2506     // Master subject
2507     if ($mastersubject_id > 1 && $mastersubject_id != 2) {
2508 dpavlin 72 $mastersubject = lookupField("mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject");
2509 dpavlin 1 printf("<tr><td colspan =\"1\" >\n");
2510 dpavlin 72 printf("<b>Master subject:</b>\n");
2511 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2512     printf("%s", $mastersubject);
2513     printf("</td></tr>\n");
2514     }
2515    
2516     // Masterinfotype
2517     if ($masterinfotype_id > 1) {
2518     printf("<tr><td colspan = \"1\" >\n");
2519 dpavlin 72 printf("<b>Master Information Type:</b>\n");
2520 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2521 dpavlin 72 $masterinfotype = lookupField("masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype");
2522 dpavlin 1 printf("%s", $masterinfotype);
2523     printf("</td></tr>\n");
2524     }
2525    
2526     // Drop down box for default information type
2527 dpavlin 72 printf("<td colspan = \"1\" >\n");
2528     printf("<b>Base Information Type:</b>\n");
2529 dpavlin 1 printf("</td><td colspan =\"3\">\n");
2530 dpavlin 72 printf("<select name = \"infotype_id\" >\n");
2531 dpavlin 1
2532     $limit = " WHERE infotype_id >= 0 ";
2533    
2534     // Limit to a mastersubject's information types
2535     if ($mastersubject_id > 0 && $mastersubject_id != 2) {
2536     $limit .= " AND (mastersubject_id < 3 OR mastersubject_id = " . $mastersubject_id . ")";
2537     }
2538    
2539     // Limit to a master information type's information types
2540     if ($masterinfotype_id > 1) {
2541     $limit .= " AND (masterinfotype_id < 2 OR masterinfotype_id = " . $masterinfotype_id . ")";
2542     }
2543    
2544 dpavlin 72 dropDownFieldSelected("infotype", "infotype", "infotype_id", $limit, $infotype_id);
2545 dpavlin 1 printf("</select>");
2546     printf("</td></tr>\n");
2547    
2548 dpavlin 72 // Vendor
2549     printf("<tr><td colspan=\"1\">\n");
2550     printf("<b>Vendor:</b>\n");
2551     printf("</td>\n");
2552     printf("<td colspan=\"2\">\n");
2553     printf("<select name = \"vendor_id\" >\n");
2554     dropDownFieldSelected("vendor", "vendor", "vendor_id", " WHERE vendor_id > 0", $vendor_id);
2555     printf("</select>\n");
2556     printf("</td></tr>\n");
2557 dpavlin 1
2558 dpavlin 72 // Status toggle
2559     $up_toggle = "";
2560     $down_toggle = "";
2561     $alert_toggle = "";
2562     if ($resource_status < 1) $up_toggle = " CHECKED ";
2563     else if ($resource_status == 1) $down_toggle = " CHECKED ";
2564     else if ($resource_status == 2) $alert_toggle = " CHECKED ";
2565     printf("<tr><td colspan=\"1\">\n");
2566     printf("<b>Resource Status:</b>\n");
2567     printf("</td>\n");
2568     printf("<td colspan=\"3\">\n");
2569     printf("<b>Up</b> <input type=\"radio\" name =\"resource_status\" value=\"0\" %s>\n", $up_toggle);
2570     printf("<b>Down</b> <input type=\"radio\" name =\"resource_status\" value=\"1\" %s>\n", $down_toggle);
2571     printf("<b>Alert</b> <input type=\"radio\" name =\"resource_status\" value=\"2\" %s>\n", $alert_toggle);
2572     printf("</td></tr>\n");
2573    
2574     // Down/alert message
2575     printf("<tr><td colspan=\"1\">\n");
2576     printf("<b>Down/Alert Message:</b>\n");
2577     printf("</td>\n");
2578     printf("<td colspan=\"3\">\n");
2579     printf("<input type =\"text\" size=\"60\" name =\"resource_message\" value=\"%s\">\n", $resource_message);
2580     printf("</td></tr>\n");
2581    
2582 dpavlin 1 // Annotation
2583     printf("<tr><td colspan = \"4\">\n");
2584 dpavlin 72 printf("<br><b><a name=\"additional\">Annotation</a>:</b><br>\n");
2585     printf("<textarea name = \"annotation\" rows = \"6\" cols = \"70\" >\n");
2586 dpavlin 1 printf("%s", $annotation);
2587     printf("</textarea><br><br><br>\n");
2588    
2589     // Buttons
2590    
2591     // If this is an existing resource
2592     if ($key_id > 0) {
2593 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateResource\" >\n");
2594     printf("<input type = \"Submit\" value = \"Update Resource\" >\n");
2595     printf("<input type = \"Hidden\" name = \"key_id\" value = \"%d\" >\n", $key_id);
2596 dpavlin 1 }
2597     // A new resource
2598     else {
2599 dpavlin 72 printf("<input type = \"Hidden\" name = \"mastersubject_id\" value = \"%d\" >\n", $mastersubject_id);
2600     printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertResource\" >\n");
2601     printf("<input type = \"Submit\" value = \"Save New Resource\" >\n");
2602 dpavlin 1 }
2603    
2604     // Common button
2605     printf("<input type = \"Reset\" value = \"Reset\" >\n");
2606    
2607     // Close things
2608     printf("</form><br>\n");
2609     printf("</td></tr></table>\n");
2610    
2611     // Exterior table
2612     printf("</td></tr></table>\n");
2613    
2614     // Other forms - only if editing an existing resource
2615     if ($key_id > 0) {
2616    
2617 dpavlin 72 formAssignResLoc($key_id);
2618     formAssignResFeature($key_id);
2619     formAssignResMastersubject($key_id);
2620 dpavlin 1
2621     // Offer a delete resource button
2622 dpavlin 72 printf("<BR>\n");
2623 dpavlin 1 printf("<form method=\"POST\" action=\"delete.phtml\">\n");
2624     printf("<input type=\"Hidden\" name=\"transaction\" value=\"deleteResourceConfirm\">\n");
2625     printf("<input type=\"Hidden\" name=\"resource_id\" value=\"%d\">\n", $key_id);
2626     printf("<input type=\"submit\" value=\"Delete Resource!\">\n");
2627     printf("</form>\n");
2628     }
2629    
2630     } // No problems
2631     }
2632    
2633    
2634     /**********************************************************
2635     Function: formService
2636     Author: Paul Bramscher
2637 dpavlin 72 Last Modified: 03.16.2004
2638 dpavlin 1 ***********************************************************
2639     Draws an HTML form to edit the supplied service id, or to
2640     create a new service if the incoming id is less than 1.
2641     **********************************************************/
2642 dpavlin 72 function formService($key_id) {
2643 dpavlin 1
2644     // Cast as integer to be sure
2645     $key_id = (int) $key_id;
2646    
2647     // Check to see if service actually exists
2648 dpavlin 72 $exists = existsRow("service", "service_id", $key_id);
2649 dpavlin 1
2650     // Header
2651     printf("<center>");
2652     if ($key_id > 0 && $exists == 1) {
2653    
2654     // Initialization
2655     $service = "";
2656     $serviceURL = "";
2657     $serviceDescr = "";
2658     $address1 = "";
2659     $address2 = "";
2660     $address3 = "";
2661     $address4 = "";
2662     $telephone = "";
2663     $fax = "";
2664     $email = "";
2665     $nonaff = "";
2666    
2667     // Fetch existing values
2668     $sql = "SELECT * from service where service_id = " . $key_id;
2669 dpavlin 72 $rs = xx_tryquery($sql);
2670     $row = xx_fetch_array ($rs, xx_ASSOC);
2671 dpavlin 1 $service_id = $row["service_id"];
2672     $service = $row["service"];
2673     $serviceURL = $row["serviceURL"];
2674     $serviceDescr = $row["serviceDescr"];
2675     $address1 = $row["address1"];
2676     $address2 = $row["address2"];
2677     $address3 = $row["address3"];
2678     $address4 = $row["address4"];
2679     $telephone = $row["telephone"];
2680     $fax = $row["fax"];
2681     $email = $row["email"];
2682     $nonaff = $row["nonaff"];
2683    
2684     // Run strings through the HTML cleaner for output
2685     $service = textOutHTML($service);
2686     $serviceDescr = textOutHTML($serviceDescr);
2687     $address1 = textOutHTML($address1);
2688     $address2 = textOutHTML($address2);
2689     $address3 = textOutHTML($address3);
2690     $address4 = textOutHTML($address4);
2691    
2692     }
2693    
2694     // Houston, we have a problem
2695     if ($key_id > 0 && $exists == 0) {
2696     $problem = 1;
2697 dpavlin 72 printf("<h3>Service (ID# %d) Not Found</h3>\n", $key_id);
2698 dpavlin 1 }
2699    
2700     // If no problems, then go for landing
2701     if ($problem != 1) {
2702    
2703     // Table definition
2704     printf("<center><table width=\"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
2705    
2706     // If new insert
2707     if ($key_id <1) {
2708 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
2709 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
2710     printf("Enter New Service");
2711     printf("</td></tr>\n");
2712     }
2713    
2714     // Else update
2715     else {
2716 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
2717 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
2718 dpavlin 72 printf("Edit Service: %s (ID# %d)", $service, $service_id);
2719 dpavlin 1 printf("</td></tr>\n");
2720     }
2721    
2722    
2723     // Service Name
2724     printf("<tr>\n");
2725     printf("<td><b>Service Name:</b></td>\n");
2726     printf("<td><input type = \"text\" name = \"service\" size = \"40\" value = \"%s\" ></td>\n", $service);
2727     printf("</tr>\n");
2728    
2729     // Description
2730     printf("<tr>\n");
2731     printf("<td colspan=\"2\"><b>Description:</b><br>\n");
2732 dpavlin 72 printf("<textarea name = \"serviceDescr\" rows = \"5\" cols = \"70\" >\n");
2733 dpavlin 1 printf("%s", $serviceDescr);
2734     printf("</textarea><br>\n");
2735     printf("</td></tr>\n");
2736    
2737     // URL
2738     printf("<tr>\n");
2739     printf("<td><b>Service URL:</b></td>\n");
2740 dpavlin 72 printf("<td><input type = \"text\" name = \"serviceURL\" size = \"50\" value = \"%s\" ></td>\n",
2741 dpavlin 1 $serviceURL);
2742     printf("</tr>\n");
2743    
2744     // Address1
2745     printf("<tr>\n");
2746     printf("<td><b>Address Line 1:</b></td>\n");
2747     printf("<td><input type = \"text\" name = \"address1\" size = \"35\" value = \"%s\" ></td>\n", $address1);
2748     printf("</tr>\n");
2749    
2750     // Address2
2751     printf("<tr>\n");
2752     printf("<td><b>Address Line 2:</b></td>\n");
2753     printf("<td><input type = \"text\" name = \"address2\" size = \"35\" value = \"%s\" ></td>\n", $address2);
2754     printf("</tr>\n");
2755    
2756     // Address3
2757     printf("<tr>\n");
2758     printf("<td><b>Address Line 3:</b></td>\n");
2759     printf("<td><input type = \"text\" name = \"address3\" size = \"35\" value = \"%s\" ></td>\n", $address3);
2760     printf("</tr>\n");
2761    
2762     // Address4
2763     printf("<tr>\n");
2764     printf("<td><b>Address Line 4:</b></td>\n");
2765     printf("<td><input type = \"text\" name = \"address4\" size = \"35\" value = \"%s\" ></td>\n", $address4);
2766     printf("</tr>\n");
2767    
2768     // Telephone
2769     printf("<tr>\n");
2770     printf("<td><b>Telephone:</b></td>\n");
2771     printf("<td><input type = \"text\" name = \"telephone\" size = \"25\" value = \"%s\" ></td>\n", $telephone);
2772     printf("</tr>\n");
2773    
2774     // Fax
2775     printf("<tr>\n");
2776     printf("<td><b>Fax:</b></td>\n");
2777     printf("<td><input type = \"text\" name = \"fax\" size = \"25\" value = \"%s\" ></td>\n", $fax);
2778     printf("</tr>\n");
2779    
2780     // Email
2781     printf("<tr>\n");
2782     printf("<td><b>E-mail Address:</b></td>\n");
2783     printf("<td><input type = \"text\" name = \"email\" size = \"25\" value = \"%s\" ></td>\n",
2784     $email);
2785     printf("</tr>\n");
2786    
2787     // Nonaffil
2788     $nonaff_yes = "";
2789     $nonadd_no = "";
2790     if ($nonaff == 1) $nonaff_yes = " CHECKED ";
2791     else $nonaff_no = " CHECKED ";
2792    
2793     printf("<tr>\n");
2794     printf("<td><b>Open to Nonaffiliated Users?</b></td>\n");
2795 dpavlin 72 printf("<td>Yes <input type = \"radio\" name = \"nonaff\" value = \"1\" %s>\n", $nonaff_yes);
2796 dpavlin 1 printf("No <input type = \"radio\" name = \"nonaff\" value = \"0\" %s></td>\n", $nonaff_no);
2797     printf("</tr>\n");
2798    
2799     // Buttons
2800     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
2801     // If this is an existing service
2802     if ($key_id > 0) {
2803 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateService\" >\n");
2804     printf("<input type = \"Submit\" value = \"Update Service\" >\n");
2805     printf("<input type = \"Hidden\" name = \"service_id\" value = \"%d\" >\n", $service_id);
2806 dpavlin 1 }
2807     // Editing a new service
2808     else {
2809 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertService\" >\n");
2810     printf("<input type = \"Submit\" value = \"Save New Service\" >\n");
2811 dpavlin 1 }
2812    
2813     // Common button
2814     printf("<input type = \"Reset\" value = \"Reset\" >\n");
2815    
2816     // Close things
2817     printf("</form>\n");
2818     printf("</td></tr></table></center>\n");
2819    
2820     // Change service-location assignments
2821    
2822     if ($service_id > 0) {
2823 dpavlin 72 formAssignServServtype($service_id);
2824     formAssignServLoc($service_id);
2825 dpavlin 1 }
2826    
2827     printf("<BR>\n");
2828    
2829     } // No problems
2830     }
2831    
2832    
2833     /**********************************************************
2834     Function: formStyle
2835     Author: Paul Bramscher
2836 dpavlin 72 Last Modified: 03.16.2004
2837 dpavlin 1 ***********************************************************
2838     Draws an HTML form to edit the supplied style id, or to
2839     create a new style if the incoming id is less than 1.
2840    
2841     Note that neither this form, nor the SQL insert/update
2842     counterpart functions, do any error checking to see
2843     whether the supplied values for filenames exist, or have
2844     proper permissions. This must be done separately by
2845     someone with OS access.
2846     **********************************************************/
2847 dpavlin 72 function formStyle($key_id) {
2848 dpavlin 1
2849     // Cast as integer to be sure
2850     $key_id = (int) $key_id;
2851    
2852     // Check to see if feature actually exists
2853 dpavlin 72 $exists = existsRow("style", "style_id", $key_id);
2854 dpavlin 1
2855     // Header
2856     printf("<center>");
2857     if ($key_id > 0 && $exists == 1) {
2858    
2859     // Initialization
2860     $style_title = "";
2861     $style_id = "";
2862    
2863     // Fetch existing values
2864     $sql = "SELECT * from style where style_id = " . $key_id;
2865 dpavlin 72 $rs = xx_tryquery($sql);
2866     $row = xx_fetch_array ($rs, xx_ASSOC);
2867 dpavlin 1 $style_id = $row["style_id"];
2868     $style_title = $row["style_title"];
2869     $header_file = $row["header_file"];
2870     $footer_file = $row["footer_file"];
2871     $css_file = $row["css_file"];
2872    
2873     // Run strings through the HTML cleaner for output
2874     $style_title = textOutHTML($style_title);
2875     $header_file = textOutHTML($header_file);
2876     $footer_file = textOutHTML($footer_file);
2877     $css_file = textOutHTML($css_file);
2878     }
2879    
2880     // Houston, we have a problem
2881     if ($key_id > 0 && $exists == 0) {
2882     $problem = 1;
2883 dpavlin 72 printf("<h3>Style (ID# %d) Not Found</h3>\n", $key_id);
2884 dpavlin 1 }
2885    
2886     // If no problems, then go for landing
2887     if ($problem != 1) {
2888    
2889     // Table definition
2890     printf("<center><table width=\"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
2891    
2892     // If new insert
2893     if ($key_id <1) {
2894 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
2895 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
2896     printf("Enter New Style");
2897     printf("</td></tr>\n");
2898     }
2899    
2900     // Else update
2901     else {
2902 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
2903 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
2904 dpavlin 72 printf("Edit Style: %s (ID# %d)", $style_title, $style_id);
2905 dpavlin 1 printf("</td></tr>\n");
2906     }
2907    
2908     // Style Title
2909     printf("<tr>\n");
2910     printf("<td><b>Style Title:</b></td>\n");
2911     printf("<td><input type = \"text\" name = \"style_title\" size = \"40\" value = \"%s\" ></td>\n", $style_title);
2912     printf("</tr>\n");
2913    
2914     // Header File
2915     printf("<tr>\n");
2916     printf("<td><b>Header File:</b></td>\n");
2917     printf("<td><input type = \"text\" name = \"header_file\" size = \"60\" value = \"%s\" ></td>\n", $header_file);
2918     printf("</tr>\n");
2919    
2920     // Footer File
2921     printf("<tr>\n");
2922     printf("<td><b>Footer File:</td>\n");
2923     printf("<td><input type = \"text\" name = \"footer_file\" size = \"60\" value = \"%s\" ></td>\n", $footer_file);
2924     printf("</tr>\n");
2925    
2926     // CSS File
2927     printf("<tr>\n");
2928     printf("<td><b>CSS File:</b></td>\n");
2929     printf("<td><input type = \"text\" name = \"css_file\" size = \"60\" value = \"%s\" ></td>\n", $css_file);
2930     printf("</tr>\n");
2931    
2932     // Buttons
2933     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
2934     // If this is an existing style
2935     if ($key_id > 0) {
2936 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateStyle\" >\n");
2937     printf("<input type = \"Submit\" value = \"Update Style\" >\n");
2938     printf("<input type = \"Hidden\" name = \"style_id\" value = \"%d\" >\n", $style_id);
2939 dpavlin 1 }
2940     // Editing a new style
2941     else {
2942 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertStyle\" >\n");
2943     printf("<input type = \"Submit\" value = \"Save New Style\">\n");
2944 dpavlin 1 }
2945    
2946     // Common button
2947     printf("<input type = \"Reset\" value = \"Reset\" >\n");
2948    
2949     // Close things
2950     printf("</form>\n");
2951     printf("<br></td></tr></table></center>\n");
2952    
2953     } // No problems
2954     }
2955    
2956    
2957     /**********************************************************
2958 dpavlin 72 Function: formStaff
2959     Author: Paul Bramscher
2960     Last Modified: 03.16.2004
2961     ***********************************************************
2962     Purpose:
2963     Form to create a new staff person, or update the existing
2964     staff id.
2965     **********************************************************/
2966     function formStaff($staff_id){
2967    
2968     // Initialize variables
2969     $staff_id = (int) $staff_id;
2970     $last_name ="";
2971     $first_name = "";
2972     $staff_account = "";
2973     $staff_email = "";
2974     $password = "";
2975     $access = "";
2976     $access_id = 1;
2977    
2978     // If editing an existing staff member load previous values
2979     if ($staff_id > 1){
2980     $sql = "SELECT
2981     s.first_name,
2982     s.last_name,
2983     s.staff_account,
2984     s.staff_email,
2985     s.access_id,
2986     t.stafftitle,
2987     t.stafftitle_id,
2988     a.access_id,
2989     a.access_level,
2990     a.access
2991     FROM staff s, access a, stafftitle t
2992     WHERE
2993     s.access_id = a.access_id AND
2994     s.stafftitle_id = t.stafftitle_id AND
2995     staff_id=" . $staff_id;
2996    
2997     $rs = xx_tryquery($sql);
2998     $row = xx_fetch_array($rs, xx_ASSOC);
2999    
3000     // Fetch results
3001     $first_name = Trim($row["first_name"]);
3002     $last_name = Trim($row["last_name"]);
3003     $staff_account = Trim($row["staff_account"]);
3004     $staff_email = Trim($row["staff_email"]);
3005     $access = Trim($row["access"]);
3006     $access_id = Trim($row["access_id"]);
3007     $stafftitle = Trim($row["stafftitle"]);
3008     $stafftitle_id = Trim($row["stafftitle_id"]);
3009    
3010     // Run strings through the HTML cleaner for output
3011     $first_name = textOutHTML($first_name);
3012     $last_name = textOutHTML($last_name);
3013     $staff_account = textOutHTML($staff_account);
3014    
3015     }
3016    
3017    
3018     // Table definition
3019     printf("<center><table width=\"75%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
3020    
3021     // If new insert
3022     if ($staff_id <1) {
3023     printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
3024     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
3025     printf("Enter New Staff Person");
3026     printf("</td></tr>\n");
3027     }
3028    
3029     // Else update
3030     else {
3031     printf("<form method = \"POST\" action = \"update.phtml\" >\n");
3032     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
3033     printf("Edit Staff Person: %s %s (ID# %d)", $first_name, $last_name, $staff_id);
3034     printf("</td></tr>\n");
3035     }
3036    
3037     // Last name
3038     printf("<tr>\n");
3039     printf("<td><b>Last Name:</b></td>\n");
3040     printf("<td><input type = \"text\" name = \"last_name\" size = \"40\" value = \"%s\" ></td>\n", $last_name);
3041     printf("</tr>\n");
3042    
3043     // First name
3044     printf("<tr>\n");
3045     printf("<td><b>First Name:</b></td>\n");
3046     printf("<td><input type = \"text\" name = \"first_name\" size = \"30\" value = \"%s\"></td>\n", $first_name);
3047     printf("</tr>\n");
3048    
3049     // staff account - must be unique, may match against staff_account
3050     printf("<tr>\n");
3051     printf("<td><b>Staff Account (x500 if applicable, 20 char max.):</b></td>\n");
3052     printf("<td><input type = \"text\" name = \"staff_account\" size = \"20\" value =\"%s\"></td>\n", $staff_account);
3053     printf("</tr>\n");
3054    
3055     // Staff email - whether or not x500 authentication is used
3056     printf("<tr>\n");
3057     printf("<td><b>Staff E-Mail:</b></td>\n");
3058     printf("<td><input type = \"text\" name = \"staff_email\" size = \"50\" value =\"%s\"></td>\n", $staff_email);
3059     printf("</tr>\n");
3060    
3061     // Title
3062     printf("<tr>\n");
3063     printf("<td><b>Job Title:</b></td>\n");
3064     printf("<td><select name = \"stafftitle_id\">\n");
3065     dropDownFieldSelected("stafftitle", "stafftitle", "stafftitle_id", "WHERE stafftitle_id > 0", $stafftitle_id);
3066     printf("</select></td>\n");
3067     printf("</tr>\n");
3068    
3069     // Access
3070     printf("<tr>\n");
3071     printf("<td><b>Access Level:</b></td>\n");
3072     printf("<td><select name = \"access_id\">\n");
3073     dropDownFieldSelected("access", "access", "access_id", "WHERE access_id > 0", $access_id);
3074     printf("</select></td>\n");
3075     printf("</tr>\n");
3076    
3077     // Buttons
3078     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
3079    
3080     // If new staff
3081     if ($staff_id < 2) {
3082     printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertStaff\" >\n");
3083     printf("<input type = \"Submit\" value = \"Save New Staff\" >\n");
3084     }
3085     // Editing an existing staffperson
3086     else {
3087     printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateStaff\" >\n");
3088     printf("<input type = \"Hidden\" name = \"staff_id\" value = \"%d\" >\n", $staff_id);
3089     printf("<input type = \"Submit\" value = \"Save Staff Changes\" >\n");
3090     }
3091     printf("<input type = \"Reset\" value = \"Reset\" >\n");
3092    
3093     // Close the form and table
3094     printf("</form>\n");
3095    
3096     printf("</td></tr></table>\n");
3097    
3098     // If editing existing staff, draw other forms
3099     if ($staff_id > 0) {
3100     formPassword($staff_id);
3101     formAssignStaffLibunit($staff_id);
3102     formAssignStaffSub($staff_id);
3103     }
3104    
3105     printf("</center><br>\n");
3106     }
3107    
3108    
3109     /**********************************************************
3110 dpavlin 1 Function: formSubject
3111     Author: Paul Bramscher
3112 dpavlin 72 Last Modified: 03.15.2004
3113 dpavlin 1 ***********************************************************
3114     Draws an HTML form to edit the supplied subject id, or to
3115     create a new subject if the incoming id is less than 1.
3116     **********************************************************/
3117 dpavlin 72 function formSubject($key_id) {
3118 dpavlin 1
3119     // Cast as integer to be sure
3120     $key_id = (int) $key_id;
3121    
3122     // Check to see if location actually exists
3123 dpavlin 72 $exists = existsRow("subject", "subject_id", $key_id);
3124 dpavlin 1
3125     // Header
3126     printf("<center>");
3127     if ($key_id > 0 && $exists == 1) {
3128    
3129     // Initialization
3130     $subject = "";
3131     $subject_id = "";
3132     $sublocation_id = "";
3133    
3134     // If the user is editing an existing record, fetch previous values
3135     $sql = "SELECT * from subject where subject_id = " . $key_id;
3136 dpavlin 72 $rs = xx_tryquery($sql);
3137     $row = xx_fetch_array ($rs, xx_ASSOC);
3138 dpavlin 1
3139     // Fetch existing values
3140     $subject_id = $row["subject_id"];
3141     $subject = $row["subject"];
3142     $sublocation_id = $row["sublocation_id"];
3143     $subject_descr = $row["subject_descr"];
3144    
3145     // Run strings through the HTML cleaner for output
3146     $subject = textOutHTML($subject);
3147     }
3148    
3149     // Houston, we have a problem
3150     if ($key_id > 0 && $exists == 0) {
3151     $problem = 1;
3152 dpavlin 72 printf("<h3>Subject (ID# %d) Not Found</h3>\n", $key_id);
3153 dpavlin 1 }
3154    
3155     // If no problems, then go for landing
3156     if ($problem != 1) {
3157    
3158     // Table definition
3159     printf("<center><table width=\"75%%\" border=\"1\" cellpadding=\"4\" class=\"backLight\">\n");
3160    
3161     // If new insert
3162     if ($key_id <1) {
3163 dpavlin 72 printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
3164 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
3165     printf("Enter New Subject");
3166     printf("</td></tr>\n");
3167     }
3168    
3169     // Else update
3170     else {
3171 dpavlin 72 printf("<form method = \"POST\" action = \"update.phtml\" >\n");
3172 dpavlin 1 printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
3173 dpavlin 72 printf("Edit Subject: %s (ID# %d)", $subject, $subject_id);
3174 dpavlin 1 printf("</td></tr>\n");
3175     }
3176    
3177     // Subject
3178     printf("<tr><td>\n");
3179 dpavlin 72 printf("<b>Subject:</b>\n");
3180 dpavlin 1 printf("</td>\n");
3181     printf("<td>\n");
3182 dpavlin 72 printf("<input type = \"text\" name = \"subject\" size = \"65\" value = \"%s\" >\n", $subject);
3183 dpavlin 1 printf("</td></tr>\n");
3184    
3185     // Primary location
3186     printf("<tr>\n");
3187     printf("<td><b>Primary Location:</b></td>\n");
3188     printf("<td>\n");
3189 dpavlin 72 printf("<select name = \"sublocation_id\">\n");
3190     dropDownFieldSelected("location", "location", "location_id", "WHERE location_id > 0", $sublocation_id);
3191 dpavlin 1 printf("</select>\n");
3192     printf("</td></tr>\n");
3193    
3194     // Description
3195     printf("<tr>\n");
3196     printf("<td colspan=\"2\">\n");
3197     printf("<b>Description:</b><br>");
3198 dpavlin 72 printf("<textarea name = \"subject_descr\" rows = \"5\" cols = \"65\" >\n");
3199 dpavlin 1 printf("%s", $subject_descr);
3200     printf("</textarea></td></tr>\n");
3201    
3202     // Buttons
3203     printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
3204    
3205     // If this is an existing subject
3206     if ($key_id > 0) {
3207 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateSubject\" >\n");
3208     printf("<input type = \"Submit\" value = \"Update Subject\" >\n");
3209     printf("<input type = \"Hidden\" name = \"subject_id\" value = \"%d\" >\n", $subject_id);
3210 dpavlin 1 }
3211     // Editing a new subject
3212     else {
3213 dpavlin 72 printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertSubject\" >\n");
3214     printf("<input type = \"Submit\" value = \"Save New Subject\" >\n");
3215 dpavlin 1 }
3216    
3217     // Common button
3218     printf("<input type = \"Reset\" value = \"Reset\" >\n");
3219    
3220     // Close things
3221     printf("</form>\n");
3222     printf("</td></tr></table></center>\n");
3223    
3224     // Change subject-location assignments
3225    
3226     if ($subject_id > 0) {
3227 dpavlin 72 formAssignSubMaster($subject_id);
3228     formAssignSubLoc($subject_id);
3229     formAssignSubStaff($subject_id);
3230     formAssignSubCoursesub($subject_id);
3231 dpavlin 1 }
3232    
3233     } // No problems
3234    
3235     printf("<BR>\n");
3236     }
3237    
3238    
3239     /**********************************************************
3240 dpavlin 72 Function: formVendor
3241 dpavlin 1 Author: Paul Bramscher
3242 dpavlin 72 Last Modified: 03.16.2004
3243 dpavlin 1 ***********************************************************
3244     Purpose:
3245 dpavlin 72 Draws an HTML form to edit the supplied vendor id, or to
3246     create a new vendor if the incoming id is less than 1.
3247     **********************************************************/
3248     function formVendor($key_id) {
3249 dpavlin 1
3250 dpavlin 72 // Cast as integer to be sure
3251     $key_id = (int) $key_id;
3252 dpavlin 1
3253 dpavlin 72 // Check to see if vendor actually exists
3254     $exists = existsRow("vendor", "vendor_id", $key_id);
3255 dpavlin 1
3256 dpavlin 72 // Header
3257 dpavlin 1 printf("<center>");
3258 dpavlin 72 if ($key_id > 0 && $exists == 1) {
3259 dpavlin 1
3260 dpavlin 72 // Initialization
3261     $vendor_id = "";
3262     $vendor = "";
3263     $vendor_descr = "";
3264     $vendor_status = "";
3265     $vendor_message = "";
3266    
3267 dpavlin 1
3268 dpavlin 72 // Fetch existing values
3269     $sql = "SELECT * FROM vendor WHERE vendor_id = " . $key_id;
3270     $rs = xx_tryquery($sql);
3271     $row = xx_fetch_array ($rs, xx_ASSOC);
3272     $vendor_id = $row["vendor_id"];
3273     $vendor = $row["vendor"];
3274     $vendor_descr = $row["vendor_descr"];
3275     $vendor_status = $row["vendor_status"];
3276     $vendor_message = $row["vendor_message"];
3277 dpavlin 1 }
3278    
3279 dpavlin 72 // Houston, we have a problem
3280     if ($key_id > 0 && $exists == 0) {
3281     $problem = 1;
3282     printf("<h3>Vendor (ID# %d) Not Found</h3>\n", $key_id);
3283 dpavlin 1 }
3284    
3285 dpavlin 72 // If no problems, then go for landing
3286     if ($problem != 1) {
3287 dpavlin 1
3288 dpavlin 72 // Table definition
3289     printf("<center><table width=\"75%%\" border=\"1\" class=\"backLight\" cellpadding=\"4\">\n");
3290 dpavlin 1
3291 dpavlin 72 // Form to handle vendor
3292     // If new insert
3293     if ($key_id <1) {
3294     printf("<form method = \"POST\" action = \"insert.phtml\" >\n");
3295     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
3296     printf("Enter New Vendor");
3297     printf("</td></tr>\n");
3298     }
3299 dpavlin 1
3300 dpavlin 72 // Else update
3301     else {
3302     printf("<form method = \"POST\" action = \"update.phtml\" >\n");
3303     printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n");
3304     printf("Edit Vendor: %s (ID# %d)", $vendor, $vendor_id);
3305     printf("</td></tr>\n");
3306     }
3307 dpavlin 1
3308 dpavlin 72 // Vendor name
3309     printf("<tr>\n");
3310     printf("<td><b>Vendor:</b></td>\n");
3311     printf("<td><input type = \"text\" name = \"vendor\" size = \"40\" value = \"%s\" ></td>\n", $vendor);
3312     printf("</tr>\n");
3313 dpavlin 1
3314 dpavlin 72 // Vendor description
3315     printf("<tr>\n");
3316     printf("<td colspan=\"2\"><b>Description:</b><br>\n");
3317     printf("<textarea name =\"vendor_descr\" rows =\"5\" cols=\"60\">\n");
3318     printf("%s", $vendor_descr);
3319     printf("</textarea>\n");
3320     printf("</td></tr>\n");
3321    
3322     // Down toggle
3323     $up_toggle = "";
3324     $down_toggle = "";
3325     $alert_toggle = "";
3326     if ($vendor_status < 1) $up_toggle = " CHECKED ";
3327     else if ($vendor_status == 1) $down_toggle = " CHECKED ";
3328     else if ($vendor_status == 2) $alert_toggle = " CHECKED ";
3329     printf("<tr><td>\n");
3330     printf("<b>Vendor Status:</b>\n");
3331     printf("</td>\n");
3332     printf("<td>\n");
3333     printf("<b>Up</b> <input type=\"radio\" name =\"vendor_status\" value=\"0\" %s>\n", $up_toggle);
3334     printf("<b>Down</b> <input type=\"radio\" name =\"vendor_status\" value=\"1\" %s>\n", $down_toggle);
3335     printf("<b>Alert</b> <input type=\"radio\" name =\"vendor_status\" value=\"2\" %s>\n", $alert_toggle);
3336 dpavlin 1
3337 dpavlin 72 printf("</td></tr>\n");
3338    
3339     // Message
3340     printf("<tr><td>\n");
3341     printf("<b>Down/Alert Message:</b>\n");
3342     printf("</td>\n");
3343     printf("<td>\n");
3344     printf("<input type =\"text\" size=\"60\" name =\"vendor_message\" value=\"%s\">\n", $vendor_message);
3345     printf("</td></tr>\n");
3346 dpavlin 1
3347     // Buttons
3348 dpavlin 72 printf("<tr><td colspan=\"2\" align=\"center\"><br>\n");
3349     // If this is an existing vendor
3350     if ($key_id > 0) {
3351     printf("<input type = \"Hidden\" name = \"transaction\" value = \"updateVendor\" >\n");
3352     printf("<input type = \"Submit\" value = \"Update Vendor\" >\n");
3353     printf("<input type = \"Hidden\" name = \"vendor_id\" value = \"%d\" >\n", $vendor_id);
3354     }
3355     // Editing a new vendor
3356     else {
3357     printf("<input type = \"Hidden\" name = \"transaction\" value = \"insertVendor\" >\n");
3358     printf("<input type = \"Submit\" value = \"Save New Vendor\">\n");
3359     }
3360 dpavlin 1
3361 dpavlin 72 // Common button
3362     printf("<input type = \"Reset\" value = \"Reset\" >\n");
3363 dpavlin 1
3364 dpavlin 72 // Close things
3365     printf("</form>\n");
3366     printf("</td></tr></table></center>\n");
3367 dpavlin 1
3368 dpavlin 72 } // No problems
3369 dpavlin 1 }
3370 dpavlin 72 ?>

  ViewVC Help
Powered by ViewVC 1.1.26