/[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 42 - (hide annotations)
Thu Mar 4 22:43:50 2004 UTC (20 years, 2 months ago) by dpavlin
File size: 109290 byte(s)
rename all mysql_ functions to xx_ so that wrapper can be used

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

  ViewVC Help
Powered by ViewVC 1.1.26