--- trunk/admin/include/forms.php 2004/03/18 20:21:08 71 +++ trunk/admin/include/forms.php 2004/03/18 20:33:37 72 @@ -1,8 +1,8 @@ -Last Modified: 11.06.2003 by Paul Bramscher +Original Author: Paul Bramscher +Last Modified: 03.16.2004 by Paul Bramscher *********************************************************** Comments: Functions here include most data-entry forms. Note that @@ -35,8 +35,8 @@ formAssignSubOtherSub formAssignSubPage formAssignSubStaff -formEditSingleField formCoursesub +formEditSingleField formFaculty formFeature formInfotype @@ -49,33 +49,114 @@ formStaff formStyle formSubject +formVendor **********************************************************/ /********************************************************** +Function: formAssignLibunitStaff +Author: Paul Bramscher +Last Modified: 03.10.2004 +*********************************************************** +Purpose: +Assigns staff (possibly multiple) to a given library unit. +**********************************************************/ +function formAssignLibunitStaff($libunit_id){ + + // Table definition + printf("
\n"); + + // Form + printf("\n"); + printf("\n", $libunit_id); + printf("\n"); + + // Available staff + // Omit the '(N/A)' staff + $omit_string = "WHERE staff_id > 1"; + + // Omit any pre-selected staff in libunit_staff + $in_string = getNotIn("staff_id", "libunit_id", $libunit_id, "libunit_staff"); + if (strlen($in_string) > 0) $omit_string .= " AND staff_id NOT IN " . $in_string; + + // Draw the box + printf("\n"); + printf("\n"); + + // Current staff + printf("\n"); + + // Close off table + printf("
\n"); + printf("Assign Staff to Library Unit"); + printf("
\n"); + printf("
Available Staff:
\n"); + printf("

\n"); + + // Close off form + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + printf("
\n"); + printf("\n", $libunit_id); + printf("\n"); + printf("
Selected Staff:
\n"); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + printf("
\n"); + +} + + +/********************************************************** Function: formAssignResFeature Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign features to the supplied resource id. **********************************************************/ -function formAssignResFeature($con, $resource_id){ +function formAssignResFeature($resource_id){ // Table definition - printf("
"); + printf("
\n"); // Form of available features to select - printf(""); - printf("", $resource_id); - printf(""); + printf("\n"); + printf("\n", $resource_id); + printf("\n"); // Omit the '(N/A)' feature $omit_string = "WHERE feature_id > 1"; // Omit any pre-selected features in res_feature - $in_string = getNotIn($con, "feature_id", "resource_id", $resource_id, "res_feature"); + $in_string = getNotIn("feature_id", "resource_id", $resource_id, "res_feature"); if (strlen($in_string) > 0) $omit_string .= " AND feature_id NOT IN " . $in_string; // Draw the combo box @@ -83,25 +164,25 @@ printf("Assign Features"); printf("\n"); printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Form of current features to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off table - printf("
\n"); - printf("
Available Features(s):
\n"); - printf("

"); + printf("
Available Features(s):
\n"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $resource_id); - printf(""); - printf("
Selected feature(s):
\n"); - printf("\n", $resource_id); + printf("\n"); + printf("
Selected feature(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignResLoc Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign locations to the supplied resource id. **********************************************************/ -function formAssignResLoc($con, $resource_id){ +function formAssignResLoc($resource_id){ // Table definition - printf("
"); + printf("
\n"); // Form of available locations to select - printf(""); - printf("", $resource_id); - printf(""); + printf("\n"); + printf("\n", $resource_id); + printf("\n"); // Omit the '(N/A)' location $omit_string = "WHERE location_id > 1"; // Omit any pre-selected locations in res_loc - $in_string = getNotIn($con, "location_id", "resource_id", $resource_id, "res_loc"); + $in_string = getNotIn("location_id", "resource_id", $resource_id, "res_loc"); if (strlen($in_string) > 0) $omit_string .= " AND location_id NOT IN " . $in_string; // Draw the combo box @@ -164,25 +244,25 @@ printf("Assign Locations"); printf("\n"); printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Current locations to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off table - printf("
\n"); - printf("
Available Location(s):
\n"); - printf("

"); + printf("
Available Location(s):
\n"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf("
"); - printf(""); - printf("
\n"); - printf("
"); - printf("", $resource_id); - printf(""); - printf("
Selected Location(s):
\n"); - printf("\n", $resource_id); + printf("\n"); + printf("
Selected Location(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignResMastersubject Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign master subjects to the supplied resource id. **********************************************************/ -function formAssignResMastersubject($con, $resource_id){ +function formAssignResMastersubject($resource_id){ // Table definition - printf("
"); + printf("
\n"); // Form of available master subjects to select - printf(""); - printf("", $resource_id); - printf(""); + printf("\n"); + printf("\n", $resource_id); + printf("\n"); // Omit the '(N/A)' mastersubjects $omit_string = "WHERE mastersubject_id > 2"; // Omit any pre-selected locations in res_mastersubject - $in_string = getNotIn($con, "mastersubject_id", "resource_id", $resource_id, "res_mastersubject"); + $in_string = getNotIn("mastersubject_id", "resource_id", $resource_id, "res_mastersubject"); if (strlen($in_string) > 0) $omit_string .= " AND mastersubject_id NOT IN " . $in_string; // Draw the combo box @@ -245,13 +324,13 @@ printf("Assign Master Subjects"); printf("\n"); printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off table - printf("
\n"); - printf("
Available Mastersubjects(s):
\n"); - printf("

"); + printf("
Available Mastersubjects(s):
\n"); + printf("

\n"); // Close things - printf("
"); + printf("
\n"); printf("> \" >"); printf("
"); printf(""); @@ -259,11 +338,11 @@ // Current master subjects to deselect printf("
\n"); - printf("
"); - printf("", $resource_id); - printf(""); - printf("
Selected Mastersubjects(s):
\n"); - printf("\n", $resource_id); + printf("\n"); + printf("
Selected Mastersubjects(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignServLoc Author: Paul Bramscher -Last Modified: 07.02.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign locations to the supplied service id. **********************************************************/ -function formAssignServLoc($con, $service_id){ +function formAssignServLoc($service_id){ // Table definition - printf("

"); + printf("

\n"); // Form of available locations to select - printf(""); - printf("", $service_id); - printf(""); + printf("\n"); + printf("\n", $service_id); + printf("\n"); // Box header printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current locations to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); @@ -323,30 +401,30 @@ $omit_string = "WHERE location_id > 1"; // Omit any pre-selected locations in service_location - $in_string = getNotIn($con, "location_id", "service_id", $service_id, "serv_loc"); + $in_string = getNotIn("location_id", "service_id", $service_id, "serv_loc"); if (strlen($in_string) > 0) $omit_string .= " AND location_id NOT IN " . $in_string; // Draw the combo box printf("
\n"); - printf("
Available Location(s):
\n"); - printf("

"); + printf("
Available Location(s):
\n"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $service_id); - printf(""); - printf("
Selected Location(s):
\n"); - printf("\n", $service_id); + printf("\n"); + printf("
Selected Location(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignServServtype Author: Paul Bramscher -Last Modified: 07.02.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign service types to the supplied service id. **********************************************************/ -function formAssignServServtype($con, $service_id){ +function formAssignServServtype($service_id){ // Table definition - printf("

"); + printf("

\n"); // Form of available service types to select - printf(""); - printf("", $service_id); - printf(""); + printf("\n"); + printf("\n", $service_id); + printf("\n"); // Box header printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current servicetypes to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); @@ -406,30 +483,30 @@ $omit_string = "WHERE servicetype_id > 1"; // Omit any pre-selected servive types in serv_servtype - $in_string = getNotIn($con, "servicetype_id", "service_id", $service_id, "serv_servtype"); + $in_string = getNotIn("servicetype_id", "service_id", $service_id, "serv_servtype"); if (strlen($in_string) > 0) $omit_string .= " AND servicetype_id NOT IN " . $in_string; // Draw the combo box printf("
\n"); - printf("
Available Service Types(s):
\n"); - printf("

"); + printf("
Available Service Types(s):
\n"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $service_id); - printf(""); - printf("
Selected Service Types(s):
\n"); - printf("\n", $service_id); + printf("\n"); + printf("
Selected Service Types(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); +} + + +/********************************************************** +Function: formAssignStaffLibunit +Author: Paul Bramscher +Last Modified: 03.10.2004 +*********************************************************** +Purpose: +Assigns library units (possibly multiple) to a given +staffperson. +**********************************************************/ +function formAssignStaffLibunit($staff_id){ + + // Table definition + printf("
\n"); + + // Form + printf("\n"); + printf("\n", $staff_id); + printf("\n"); + + // Available libunits + // Omit the '(N/A)' libunit + $omit_string = "WHERE libunit_id > 1"; + + // Omit any pre-selected libunits in libunit_staff + $in_string = getNotIn("libunit_id", "staff_id", $staff_id, "libunit_staff"); + if (strlen($in_string) > 0) $omit_string .= " AND libunit_id NOT IN " . $in_string; + + // Draw the box + printf("\n"); + printf("\n"); + + // Current libunits + printf("\n"); + + // Close off table + printf("
\n"); + printf("Assign Library Unit to Staff"); + printf("
\n"); + printf("
Available Library Unit(s):
\n"); + printf("

\n"); + + // Close off form + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + printf("
\n"); + printf("\n", $staff_id); + printf("\n"); + printf("
Selected Library Unit(s):
\n"); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + printf("
\n"); + +} + + +/********************************************************** +Function: formAssignStaffSub +Author: Paul Bramscher +Last Modified: 03.10.2004 +*********************************************************** +Purpose: +Assigns subjects (possibly multiple) to a given +staffperson. +**********************************************************/ +function formAssignStaffSub($staff_id){ + + // Table definition + printf("
\n"); + + // Form + printf("\n"); + printf("\n", $staff_id); + printf("\n"); + + // Available subjects + // Omit the '(N/A)' subject + $omit_string = "WHERE subject_id > 1"; + + // Omit any pre-selected subjects in sub_staff + $in_string = getNotIn("subject_id", "staff_id", $staff_id, "sub_staff"); + if (strlen($in_string) > 0) $omit_string .= " AND subject_id NOT IN " . $in_string; + + // Draw the box + printf("\n"); + printf("\n"); + + // Current subjects + printf("\n"); + + // Close off table + printf("
\n"); + printf("Assign Subjects"); + printf("
\n"); + printf("
Available Subject(s):
\n"); + printf("

\n"); + + // Close off form + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + printf("
\n"); + printf("", $staff_id); + printf("\n"); + printf("
Selected Subject(s):
\n"); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + printf("
\n"); + } /********************************************************** Function: formAssignSubCoursesub Author: Paul Bramscher -Last Modified: 06.26.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign course subjects (with cip codes) to the supplied subject id. **********************************************************/ -function formAssignSubCoursesub($con, $subject_id){ +function formAssignSubCoursesub($subject_id){ // Table definition printf("

\n"); - printf(""); + printf("
\n"); // Form of available course subjects to select - printf(""); + printf("\n"); printf("\n"); - printf("", $subject_id); - printf(""); + printf("\n", $subject_id); + printf("\n"); // Omit the '(N/A)' course subject $omit_string = "WHERE coursesub_id > 1"; // Omit any pre-selected locations in sub_coursesub - $in_string = getNotIn($con, "coursesub_id", "subject_id", $subject_id, "sub_coursesub"); + $in_string = getNotIn("coursesub_id", "subject_id", $subject_id, "sub_coursesub"); if (strlen($in_string) > 0) $omit_string .= " AND coursesub_id NOT IN " . $in_string; // Draw the combo box printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current coursesubs to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); printf("Map to Course Subjects / CIP Codes"); printf("
\n"); printf("
Available Course Subjects(s):
\n"); - printf("

"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $subject_id); - printf(""); + printf("\n"); + printf("\n", $subject_id); + printf("\n"); printf("
Selected Course Subject(s):
\n"); - printf("\n"); $sql = "SELECT c.coursesub, c.coursesub_descr, c.coursesub_id, c.cip_code FROM coursesub c, @@ -523,10 +763,9 @@ s.subject_id = " . $subject_id . " AND sc.subject_id = s.subject_id AND sc.coursesub_id = c.coursesub_id ORDER BY coursesub_descr"; - - // Fetch the values - $rs = xx_query($sql, $con); - while ($row = xx_fetch_array ($rs)) { + $rs = xx_tryquery($sql); + + while ($row = xx_fetch_array ($rs, xx_ASSOC)) { $coursesub = $row["coursesub"]; $coursesub_id = $row["coursesub_id"]; $coursesub_descr = $row["coursesub_descr"]; @@ -535,74 +774,74 @@ // Limit length if (strlen($coursesub_descr) > 30) $coursesub_descr = substr($coursesub_descr, 0, 30) . "..."; - printf("", $coursesub_id, $coursesub, $coursesub_descr, $cip_code); + printf("\n", $coursesub_id, $coursesub, $coursesub_descr, $cip_code); } // Close things - printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignSubLoc Author: Paul Bramscher -Last Modified: 06.26.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign locations to the supplied subject id. **********************************************************/ -function formAssignSubLoc($con, $subject_id){ +function formAssignSubLoc($subject_id){ // Table definition printf("

\n"); - printf(""); + printf("
\n"); // Form of available locations to select - printf(""); + printf("\n"); printf("\n"); - printf("", $subject_id); - printf(""); + printf("\n", $subject_id); + printf("\n"); // Omit the '(N/A)' location $omit_string = "WHERE location_id > 1"; // Omit any pre-selected locations in sub_loc - $in_string = getNotIn($con, "location_id", "subject_id", $subject_id, "sub_loc"); + $in_string = getNotIn("location_id", "subject_id", $subject_id, "sub_loc"); if (strlen($in_string) > 0) $omit_string .= " AND location_id NOT IN " . $in_string; // Draw the combo box printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current locations to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); printf("Assign Secondary Locations"); printf("
\n"); printf("
Available Location(s):
\n"); printf("

"); + dropDownFieldOmit("location", "location", "location_id", $omit_string); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $subject_id); - printf(""); + printf("\n"); + printf("\n", $subject_id); + printf("\n"); printf("
Selected Location(s):
\n"); - printf("\n"); $sql = "SELECT l.location, l.location_id FROM location l, @@ -612,80 +851,79 @@ s.subject_id = " . $subject_id . " AND sl.subject_id = s.subject_id AND sl.location_id = l.location_id ORDER BY location"; - - // Fetch the values - $rs = xx_query($sql, $con); - while ($row = xx_fetch_array ($rs)) { + $rs = xx_tryquery($sql); + + while ($row = xx_fetch_array ($rs, xx_ASSOC)) { $location = $row["location"]; $location_id = $row["location_id"]; - printf("", $location_id, $location); + printf("\n", $location_id, $location); } // Close things - printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignSubMaster Author: Paul Bramscher -Last Modified: 06.26.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign master subjects to the supplied subject id. **********************************************************/ -function formAssignSubMaster($con, $subject_id){ +function formAssignSubMaster($subject_id){ // Table definition printf("

\n"); - printf(""); + printf("
\n"); // Form of available master subjects to select - printf(""); + printf("\n"); printf("\n"); - printf("", $subject_id); - printf(""); + printf("\n", $subject_id); + printf("\n"); // Omit the '(N/A)' location $omit_string = "WHERE mastersubject_id > 1"; // Omit any pre-selected locations in sub_mastersubject - $in_string = getNotIn($con, "mastersubject_id", "subject_id", $subject_id, "sub_mastersubject"); + $in_string = getNotIn("mastersubject_id", "subject_id", $subject_id, "sub_mastersubject"); if (strlen($in_string) > 0) $omit_string .= " AND mastersubject_id NOT IN " . $in_string; // Draw the combo box printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current mastersubjects to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); printf("Assign Master Subjects"); printf("
\n"); printf("
Available Master Subjects(s):
\n"); - printf("

"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $subject_id); - printf(""); + printf("\n"); + printf("\n", $subject_id); + printf("\n"); printf("
Selected Master Subject(s):
\n"); - printf("\n"); $sql = "SELECT m.mastersubject, m.mastersubject_id FROM mastersubject m, @@ -695,52 +933,51 @@ s.subject_id = " . $subject_id . " AND sm.subject_id = s.subject_id AND sm.mastersubject_id = m.mastersubject_id ORDER BY mastersubject"; - - // Fetch the values - $rs = xx_query($sql, $con); - while ($row = xx_fetch_array ($rs)) { + $rs = xx_tryquery($sql); + + while ($row = xx_fetch_array ($rs, xx_ASSOC)) { $mastersubject = $row["mastersubject"]; $mastersubject_id = $row["mastersubject_id"]; - printf("", $mastersubject_id, $mastersubject); + printf("\n", $mastersubject_id, $mastersubject); } // Close things - printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignSubOtherSub Author: Paul Bramscher -Last Modified: 11.06.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign other subject pages to the supplied subject id. **********************************************************/ -function formAssignSubOtherSub($con, $subject_id){ +function formAssignSubOtherSub($subject_id){ // Table definition - printf(""); + printf("
\n"); // Form of available master subjects to select - printf(""); - printf("", $subject_id); - printf(""); + printf("\n"); + printf("\n", $subject_id); + printf("\n"); // Free-form pages only $omit_string = "WHERE subject_id > 1 AND subject_id <> " . $subject_id; // Omit any pre-selected other subjects in sub_othersub - $in_string = getNotIn($con, "othersub_id", "subject_id", $subject_id, "sub_othersub"); + $in_string = getNotIn("othersub_id", "subject_id", $subject_id, "sub_othersub"); if (strlen($in_string) > 0) $omit_string .= " AND subject_id NOT IN " . $in_string; // Draw the combo box @@ -749,25 +986,25 @@ printf(""); + printf("
\n"); + printf("\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current rqs subjects to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); - printf("
Available Subject(s):
\n"); - printf("

"); + printf("
Available Subject(s):
\n"); + printf("

\n"); // Close things - printf("
"); - printf(""); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); + printf("\n"); printf("", $subject_id); - printf(""); - printf("
Selected Subject(s):
\n"); - printf("\n"); + printf("
Selected Subject(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignSubPage Author: Paul Bramscher -Last Modified: 11.06.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign PageScribe Pages to the supplied subject id. **********************************************************/ -function formAssignSubPage($con, $subject_id){ +function formAssignSubPage($subject_id){ // Table definition - printf(""); + printf("
\n"); // Form of available master subjects to select - printf(""); - printf("", $subject_id); - printf(""); + printf("\n"); + printf("\n", $subject_id); + printf("\n"); // Free-form pages only $omit_string = "WHERE pagetype_id = 2"; // Omit any pre-selected pages in sub_page - $in_string = getNotIn($con, "page_id", "subject_id", $subject_id, "sub_page"); + $in_string = getNotIn("page_id", "subject_id", $subject_id, "sub_page"); if (strlen($in_string) > 0) $omit_string .= " AND page_id NOT IN " . $in_string; // Draw the combo box @@ -831,25 +1067,25 @@ printf(""); + printf("
\n"); + printf("\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current mastersubjects to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off the table - printf("
\n"); - printf("
Available Page(s):
\n"); - printf("

"); + printf("
Available Page(s):
\n"); + printf("

\n"); // Close things - printf("
"); - printf(""); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $subject_id); - printf(""); - printf("
Selected Page(s):
\n"); - printf("\n", $subject_id); + printf("\n"); + printf("
Selected Page(s):
\n"); + printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formAssignSubStaff Author: Paul Bramscher -Last Modified: 06.26.2003 +Last Modified: 03.10.2004 *********************************************************** Purpose: Draws an HTML combo box with multiple selection capability to assign staffpersons to the supplied subject id. **********************************************************/ -function formAssignSubStaff($con, $subject_id){ +function formAssignSubStaff($subject_id){ // Table definition printf("

\n"); printf("\n"); // Form of available staff to select - printf(""); + printf("\n"); printf("\n"); - printf("", $subject_id); - printf(""); + printf("\n", $subject_id); + printf("\n"); // Omit the '(N/A)' staff $omit_string = "WHERE staff_id > 1"; // Omit any pre-selected staff in sub_staff - $in_string = getNotIn($con, "staff_id", "subject_id", $subject_id, "sub_staff"); + $in_string = getNotIn("staff_id", "subject_id", $subject_id, "sub_staff"); if (strlen($in_string) > 0) $omit_string .= " AND staff_id NOT IN " . $in_string; // Draw the combo box printf(""); + printf("
\n"); + printf("> \" >\n"); + printf("\n"); + printf("
\n"); + printf("\n"); // Current staff to deselect printf(""); + printf("

\n"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + printf("\n"); // Close off table - printf("
\n"); printf("Assign Staff"); printf("
\n"); printf("
Available Staff:
\n"); - printf("

"); + printf("

\n"); // Close things - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $subject_id); - printf(""); + printf("\n"); + printf("\n", $subject_id); + printf("\n"); printf("
Selected Staff:
\n"); - printf("\n"); $sql = "SELECT t.staff_id, t.last_name, t.first_name FROM staff t, @@ -945,79 +1180,76 @@ s.subject_id = " . $subject_id . " AND st.subject_id = s.subject_id AND st.staff_id = t.staff_id ORDER BY last_name, first_name"; - - // Fetch the values - $rs = xx_query($sql, $con); - while ($row = xx_fetch_array ($rs)) { + $rs = xx_tryquery($sql); + + while ($row = xx_fetch_array ($rs, xx_ASSOC)) { $first_name = $row["first_name"]; $last_name = $row["last_name"]; $staff_id = $row["staff_id"]; - printf("", $staff_id, $last_name, $first_name); + printf("\n", $staff_id, $last_name, $first_name); } // Close things - printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); + printf("\n"); } /********************************************************** Function: formCoursesub Author: Paul Bramscher -Last Modified: 07.02.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: -Draws an HTML form to edit the supplied feature id, or to -create a new feature if the incoming id is less than 1. +Draws an HTML form to edit the supplied course subject id, +or to create a new course subject if the incoming id is +less than 1. **********************************************************/ -function formCoursesub($con, $coursesub_id) { +function formCoursesub($coursesub_id) { // Cast as integer to be sure $coursesub_id = (int) $coursesub_id; // Get descriptive title - $coursesub = lookupField($con, "coursesub", "coursesub_id", $coursesub_id, "coursesub"); + $coursesub = lookupField("coursesub", "coursesub_id", $coursesub_id, "coursesub"); // Check to see if coursesub actually exists - $exists = existsRow($con, "coursesub", "coursesub_id", $coursesub_id); + $exists = existsRow("coursesub", "coursesub_id", $coursesub_id); // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Course Subject #%d Not Found

", $coursesub_id); + printf("

Course Subject (ID# %d) Not Found

\n", $coursesub_id); } // Check to see if there are affected courselib pages - $exists_courselib = existsRow($con, "course", "coursesub_id", $coursesub_id); + $exists_courselib = existsRow("course", "coursesub_id", $coursesub_id); if ($exists_courselib > 0) { $problem = 1; // Table definition - printf("
\n"); - printf("

\n"); - printf("Messages:
"); + msgTableOpen(1, "Edit Course Subject (ID# " . $coursesub_id . ")"); + printf("Messages:
\n"); printf("This course subject is currently used on one or more course pages. "); printf("It may not be edited or deleted until all affected courses are moved to "); printf("an alternate course subject. Follow the link below for a list of "); printf("affected pages. Course titles are composed, in part, based on this "); - printf("value.

"); + printf("value.

\n"); printf("", $coursesub_id); - printf("page_results_brief.phtml?coursesub_id=%s", $coursesub_id); - printf("

"); - printf("
\n"); + printf("page_results_brief.phtml?coursesub_id=%s", $coursesub_id); + printf("

\n"); + msgTableClose(); + } - - - // If no problems, then go for landing if ($problem != 1) { @@ -1030,8 +1262,8 @@ // If the user is editing an existing record, fetch previous values if ($coursesub_id > 0 && $exists == 1) { $sql = "SELECT * FROM coursesub WHERE coursesub_id = " . $coursesub_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); // Fetch existing values $coursesub_id = $row["coursesub_id"]; @@ -1052,7 +1284,7 @@ // If new insert if ($coursesub_id <1) { - printf("
"); + printf("\n"); printf("\n"); printf("Enter New Course Subject"); printf("\n"); @@ -1060,13 +1292,12 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); - printf("Edit Course Subject: %s (#%d)", $coursesub, $coursesub_id); + printf("Edit Course Subject: %s (ID# %d)", $coursesub, $coursesub_id); printf("\n"); } - // Coursesub abbrev. printf("\n"); printf("Course Subject Abbrev:\n"); @@ -1083,7 +1314,7 @@ printf("\n"); printf("Campus:\n"); printf("\n"); printf("\n"); @@ -1098,14 +1329,14 @@ // If this is an existing course subject if ($coursesub_id > 0) { - printf(" "); - printf(" "); - printf(" ", $coursesub_id); + printf("\n"); + printf("\n"); + printf("\n", $coursesub_id); } // Editing a new course subject else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -1120,20 +1351,19 @@ /********************************************************** -Function: formEditSingleField($con, $display, $display_field, +Function: formEditSingleField($display, $display_field, $key_field, $key_id, $table); Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.15.2004 *********************************************************** Incoming: -$con Database connection string -$table Table name to operate against $display A display to the user, typically similar to $display_field $display_field Field name within $table to generate displayed values from $key_field Name of primary key field in $table $key_id Value of $key_field +$table Table name to operate against *********************************************************** Outgoing: None @@ -1143,7 +1373,7 @@ table. The table's primary key must not involve a composite key -- since this form won't handle that. **********************************************************/ -function formEditSingleField($con, $display, $display_field, $key_field, $key_id, +function formEditSingleField($display, $display_field, $key_field, $key_id, $size, $table) { // Make sure we have a positive integer to work with @@ -1159,39 +1389,39 @@ . " = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array($rs, xx_ASSOC); $oldValue = Trim($row[$display_field]); // Table definition printf("
\n"); - printf("\n"); printf("\n"); // Form to handle any single field - printf(""); - printf("\n"); printf("\n"); printf(""); - printf("
\n"); - printf("Edit %s: %s (#%d)", $display, $oldValue, $key_id); + printf("Edit %s: %s (ID# %d)", $display, $oldValue, $key_id); printf("
"); - printf("%s: ", $display); + printf("\n"); + printf("
\n"); + printf("%s:\n", $display); printf("\n"); - printf("", $size, $oldValue); - printf("", $display); - printf("", $display_field); - printf("", $key_field); - printf("", $key_id); - printf("", $table); - printf(""); + printf("\n", $size, $oldValue); + printf("\n", $display); + printf("\n", $display_field); + printf("\n", $key_field); + printf("\n", $key_id); + printf("\n", $table); + printf("\n"); printf("

\n"); - printf(" ", $display); - printf(""); + printf("\n", $display); + printf("\n"); // Close things - printf("
"); - printf("
"); + printf("
\n"); + printf("\n"); + printf("\n"); } @@ -1202,14 +1432,14 @@ /********************************************************** Function: formFaculty Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Draws an HTML form to edit the supplied faculty id, or to create a new faculty person if the incoming id is less than 1. **********************************************************/ -function formFaculty($con, $faculty_id){ +function formFaculty($faculty_id){ // Initialize variables $faculty_id = (int) $faculty_id; @@ -1228,9 +1458,8 @@ FROM faculty f WHERE faculty_id = " . $faculty_id; - - $rs = xx_query($sql, $con); - $row = xx_fetch_array($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array($rs, xx_ASSOC); // Fetch results $faculty_firstname = Trim($row["faculty_firstname"]); @@ -1248,7 +1477,7 @@ // If new faculty if ($faculty_id < 1) { - printf("
"); + printf("\n"); printf("\n"); printf("Enter New Faculty"); printf("\n"); @@ -1256,9 +1485,9 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); - printf("Edit Faculty: %s %s (#%d)", $faculty_firstname, $faculty_lastname, $faculty_id); + printf("Edit Faculty: %s %s (ID# %d)", $faculty_firstname, $faculty_lastname, $faculty_id); printf("\n"); } @@ -1290,40 +1519,40 @@ printf("
\n"); // If new faculty if ($faculty_id < 1) { - printf(""); - printf(" "); + printf("\n"); + printf("\n"); } // Editing an existing faculty person else { - printf(""); - printf("", $faculty_id); - printf(" "); + printf("\n"); + printf("\n", $faculty_id); + printf("\n"); } - printf(""); + printf("\n"); // Close things - printf("
"); - printf(""); - printf("
"); + printf("\n"); + printf("\n"); + printf("
\n"); } /********************************************************** Function: formFeature Author: Paul Bramscher -Last Modified: 07.01.2003 +Last Modified: 03.15.2004 *********************************************************** Purpose: Draws an HTML form to edit the supplied feature id, or to create a new feature if the incoming id is less than 1. **********************************************************/ -function formFeature($con, $key_id) { +function formFeature($key_id) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if feature actually exists - $exists = existsRow($con, "feature", "feature_id", $key_id); + $exists = existsRow("feature", "feature_id", $key_id); // Header printf("
"); @@ -1335,8 +1564,8 @@ // Fetch existing values $sql = "SELECT * FROM feature WHERE feature_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $feature_id = $row["feature_id"]; $feature = $row["feature"]; $image_path = $row["image_path"]; @@ -1351,7 +1580,7 @@ // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Feature #%d Not Found

", $key_id); + printf("

Feature (ID# %d) Not Found

\n", $key_id); } // If no problems, then go for landing @@ -1363,7 +1592,7 @@ // Form to handle feature // If new insert if ($key_id <1) { - printf("
"); + printf("\n"); printf("\n"); printf("Enter New Feature"); printf("\n"); @@ -1371,15 +1600,15 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); - printf("Edit Feature: %s (#%d)", $feature, $feature_id); + printf("Edit Feature: %s (ID# %d)", $feature, $feature_id); printf("\n"); } // Feature name printf("\n"); - printf("Feature:"); + printf("Feature:\n"); printf("\n", $feature); printf("\n"); @@ -1398,14 +1627,14 @@ printf("
\n"); // If this is an existing feature if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $feature_id); + printf("\n"); + printf("\n"); + printf("\n", $feature_id); } // Editing a new feature else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -1422,23 +1651,23 @@ /********************************************************** Function: formInfotype Author: Paul Bramscher -Last Modified: 06.26.2003 +Last Modified: 03.15.2004 *********************************************************** Purpose: Draws an HTML form to edit the supplied information type id, or to create a new information type if the incoming id is less than 1. **********************************************************/ -function formInfotype($con, $key_id) { +function formInfotype($key_id) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if infotype actually exists - $exists = existsRow($con, "infotype", "infotype_id", $key_id); + $exists = existsRow("infotype", "infotype_id", $key_id); // Header - printf("
"); + printf("
\n"); if ($key_id > 0 && $exists == 1) { // Initialization @@ -1449,8 +1678,8 @@ // Fetch existing values $sql = "SELECT * from infotype where infotype_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $infotype_id = $row["infotype_id"]; $infotype = $row["infotype"]; $masterinfotype_id = $row["masterinfotype_id"]; @@ -1464,7 +1693,7 @@ // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Information Type #%d Not Found

", $key_id); + printf("

Information Type (ID# %d) Not Found

\n", $key_id); } // If no problems, then go for landing @@ -1475,7 +1704,7 @@ // If new insert if ($key_id < 1) { - printf(""); + printf("\n"); printf("\n"); printf("Enter New Information Type"); printf("\n"); @@ -1484,9 +1713,9 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); - printf("Edit Information Type: %s (#%d)", $infotype, $infotype_id); + printf("Edit Information Type: %s (ID# %d)", $infotype, $infotype_id); printf("\n"); } @@ -1500,17 +1729,17 @@ printf("\n"); printf("Master Information Type:\n"); printf("\n"); - printf("\n"); + dropDownFieldSelected("masterinfotype", "masterinfotype", "masterinfotype_id", "WHERE masterinfotype_id >= 0", $masterinfotype_id); printf("\n"); printf("\n"); // Mastersubject printf("\n"); - printf("Master Subject:"); + printf("Master Subject:\n"); printf("\n"); - printf("\n"); + dropDownFieldSelected("mastersubject", "mastersubject", "mastersubject_id", "WHERE mastersubject_id >= 0", $mastersubject_id); printf("\n"); printf("\n"); @@ -1519,14 +1748,14 @@ // If this is an existing infotype if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $infotype_id); + printf("\n"); + printf("\n"); + printf("\n", $infotype_id); } // Editing a new infotype else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -1542,20 +1771,127 @@ /********************************************************** +Function: formLibunit +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Handles the creation of new (or editing of existing) +library units. +**********************************************************/ +function formLibunit($key_id){ + + // Initialize variables + $libunit_id = (int) $key_id; + $libunit =""; + $libunit_abbrev = ""; + + // If editing an existing library unit load previous values + if ($libunit_id > 1){ + $sql = "SELECT + l.libunit, + l.libunit_abbrev, + l.head_staff_id + FROM libunit l + WHERE + libunit_id = " . $libunit_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array($rs, xx_ASSOC); + + // Fetch values + $libunit = Trim($row["libunit"]); + $libunit_abbrev = Trim($row["libunit_abbrev"]); + $head_staff_id = $row["head_staff_id"]; + + // Run strings through the HTML cleaner for output + $libunit = textOutHTML($libunit); + $libunit_abbrev = textOutHTML($libunit_abbrev); + + } + + // Table definition + printf("
\n"); + + // If new insert + if ($key_id <1) { + printf("\n"); + printf("\n"); + } + + // Else update + else { + printf("\n"); + printf("\n"); + } + + // Libunit + printf("\n"); + printf("\n", $libunit); + printf("\n"); + + // Libunit abbrev. + printf("\n"); + printf("\n"); + printf("\n", $libunit_abbrev); + printf("\n"); + + // Libunit lead + printf("\n"); + printf("\n"); + printf("\n"); + printf("\n"); + + // Buttons + printf("
\n"); + printf("Enter New Library Unit"); + printf("
\n"); + printf("Edit Library Unit: %s (ID# %d)", $libunit, $libunit_id); + printf("
Library Unit:
Abbreviation:
Unit Lead:

\n"); + + // If new libunit + if ($libunit_id < 2) { + printf("\n"); + printf("\n"); + } + // Editing an existing libunit + else { + printf("\n"); + printf("\n", $libunit_id); + printf("\n"); + } + printf("\n"); + + // Close the form and table + printf("\n"); + printf("
\n"); + + // Other forms - only if editing an existing libunit + + if ($libunit_id > 0) { + formAssignLibunitStaff($libunit_id); + } + + printf("

\n"); +} + + +/********************************************************** Function: formLocation Author: Paul Bramscher -Last Modified: 06.26.2003 +Last Modified: 03.15.2004 *********************************************************** Draws an HTML form to edit the supplied location id, or to create a new location if the incoming id is less than 1. **********************************************************/ -function formLocation($con, $key_id) { +function formLocation($key_id) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if location actually exists - $exists = existsRow($con, "location", "location_id", $key_id); + $exists = existsRow("location", "location_id", $key_id); // Header printf("
"); @@ -1577,8 +1913,8 @@ // Fetch existing values $sql = "SELECT * from location where location_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $location_id = $row["location_id"]; $location = $row["location"]; $location_descr = $row["location_descr"]; @@ -1607,7 +1943,7 @@ // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Location #%d Not Found

", $key_id); + printf("

Location (ID# %d) Not Found

\n", $key_id); } // If no problems, then go for landing @@ -1618,7 +1954,7 @@ // If new insert if ($key_id <1) { - printf("
"); + printf("\n"); printf("\n"); printf("Enter New Location"); printf("\n"); @@ -1626,17 +1962,17 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); - printf("Edit Location: %s (#%d)", $location, $location_id); + printf("Edit Location: %s (ID# %d)", $location, $location_id); printf("\n"); } // Location/Library printf("\n"); - printf("Location/Library:"); + printf("Location/Library:\n"); printf("\n"); - printf("", $location); + printf("\n", $location); printf("\n"); // Description @@ -1651,56 +1987,56 @@ printf("\n"); printf("Campus:\n"); printf("\n"); - printf("", $campus); + printf("\n", $campus); printf("\n"); // Address1 printf("\n"); printf("Address Line 1:\n"); printf("\n"); - printf("", $address1); + printf("\n", $address1); printf("\n"); // Address2 printf("\n"); printf("Address Line 2:\n"); printf("\n"); - printf("", $address2); + printf("\n", $address2); printf("\n"); // Address3 printf("\n"); printf("Address Line 3:\n"); printf("\n"); - printf("", $address3); + printf("\n", $address3); printf("\n"); // Address4 printf("\n"); printf("Address Line 4:\n"); printf("\n"); - printf("", $address4); + printf("\n", $address4); printf("\n"); // Telephone printf("\n"); printf("Telephone:\n"); printf("\n"); - printf("", $telephone); + printf("\n", $telephone); printf("\n"); // mainURL printf("\n"); printf("Main URL:\n"); printf("\n"); - printf("", $mainURL); + printf("\n", $mainURL); printf("\n"); // referenceURL printf("\n"); printf("Reference URL:\n"); printf("\n"); - printf("", + printf("\n", $referenceURL); printf("\n"); @@ -1708,7 +2044,7 @@ printf("\n"); printf("Hours URL:\n"); printf("\n"); - printf("", + printf("\n", $hoursURL); printf("\n"); @@ -1716,7 +2052,7 @@ printf("\n"); printf("Map URL:\n"); printf("\n"); - printf("", $mapURL); + printf("\n", $mapURL); printf("\n"); // Buttons @@ -1724,14 +2060,14 @@ // If this is an existing location if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $location_id); + printf("\n"); + printf("\n"); + printf("\n", $location_id); } // Editing a new location else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -1746,18 +2082,17 @@ /********************************************************** -Function: formNewSingleField($con, $display, $field, +Function: formNewSingleField($display, $field, $size, $table); Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.11.2004 *********************************************************** Incoming: -$con Database connection string -$table Table name to operate against $field Field name within $table $display A display to the user, typically identical to $field $size The size of the HTML input box +$table Table name to operate against *********************************************************** Outgoing: None @@ -1767,59 +2102,172 @@ table. The table's primary key must not involve a composite key since this form won't handle that. **********************************************************/ -function formNewSingleField($con, $display, $field, $size, $table) { +function formNewSingleField($display, $field, $size, $table) { // Draw Box printf("
\n"); - printf(""); + printf("
\n"); printf("\n"); // Form for the new field value - printf(""); + printf("\n"); printf("\n"); printf("\n", $display); - printf("\n"); printf(""); - printf("
\n"); printf("Enter New %s", $display); printf("
%s:"); - printf("", $size); - printf("", $table); - printf("", $field); - printf("", $display); - printf(""); + printf("\n"); + printf("\n", $size); + printf("\n", $table); + printf("\n", $field); + printf("\n", $display); + printf("\n"); printf("

\n"); - printf(" ", $display); - printf(""); + printf("\n", $display); + printf("\n"); // Close things - printf("
"); - printf("

"); + printf("
\n"); + printf("\n"); + printf("
\n"); } /********************************************************** +Function: formPassword +Author: Paul Bramscher +Last Modified: 03.11.2004 +*********************************************************** +Purpose: +Creates a new password for the supplied staff id. Note +that this is a locally stored (in mySQL) and encrypted +password. It is never visible in plaintext, nor is it +ever brought to an HTML form, neither in plaintext nor +in a "password" type HTML form field. +**********************************************************/ +function formPassword($staff_id){ + + /***************************************** + ** If using native mySQL authentication ** + *****************************************/ + + // Table definition + printf("
\n"); + + // Form + printf("\n"); + printf("\n"); + + // Staff password - for mySQL authentication only. Ignored if x500 account is present. + printf("\n"); + + // First type + printf("\n"); + printf("\n"); + printf("\n"); + printf("\n"); + + // Confirm type + printf("\n"); + printf("\n"); + printf("\n"); + printf("\n"); + + // Buttons + printf("
\n"); + printf("Local Authentication Password - See Note Below"); + printf("
\n"); + printf("Note: Supply if utilizing mySQL authentication, otherwise leave blank. "); + printf("This will replace the password (if any) currently assigned to this account."); + printf("
New Password (6 char. minimum):
Confirm password (type again):

\n"); + printf("\n", $staff_id); + printf("\n"); + printf("\n"); + + // Close the form and table + printf("\n"); + printf("
\n"); + + + /******************************************* + ** Determine if a password already exists ** + *******************************************/ + + + // Initialize variables + $pass_set = 0; + + // Determine whether a password exists + $sql = "SELECT COUNT(*) as pass_set + FROM staff s + WHERE (s.password <> NULL OR s.password <> '') and s.staff_id = " . $staff_id; + + $rs = xx_tryquery($sql); + $row = xx_fetch_array($rs, xx_ASSOC); + + // Fetch values + $pass_set = $row["pass_set"]; + + // If some password already exists, offer this form + if ($pass_set > 0) { + + // Table definition + printf("
\n"); + + // Form + printf("\n"); + printf("\n"); + + // Purge existing password + printf("
\n"); + printf("Local Password Found"); + printf("
\n"); + printf("
Purge password to null?

\n"); + printf("Note: It appears that this account currently has a password assigned to it."); + printf("This option will clear out any existing password, and leave the value NULL."); + printf("The staffperson may not login until a new password is supplied.

\n"); + + // Buttons + printf("
\n"); + printf("\n", $staff_id); + printf("\n"); + printf("\n"); + + // Close the form and table + printf("\n"); + printf("

\n"); + + } // end password purge form + +} // end function + + +/********************************************************** Function: formResource Author: Paul Bramscher -Last Modified: 06.19.2003 by Paul Bramscher +Last Modified: 03.16.2004 by Paul Bramscher *********************************************************** Draws an HTML form to edit the supplied resource id, or to create a new resource if the incoming id is less than 1. Note also that there are incoming masterinfotype id, mastersubject id, an title parameters. **********************************************************/ -function formResource($con, $key_id, $masterinfotype_id, $mastersubject_id, $title) { +function formResource($key_id, $masterinfotype_id, $mastersubject_id, $title) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if record actually exists - $exists = existsRow($con, "resource", "resource_id", $key_id); + $exists = existsRow("resource", "resource_id", $key_id); // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Resource #%d Not Found

", $key_id); + msgTableOpen(1, "Edit Resource (ID# " . $key_id . ")"); + printf("Messages:
\n"); + printf("Resource not found. Operation cancelled."); + printf("

\n"); + msgTableClose(); } @@ -1848,13 +2296,14 @@ $url = ""; $visited = ""; $annotation =""; + $vendor_id = 0; // If the user is editing an existing record, fetch previous values if ($key_id > 0 && $exists == 1) { $sql = "SELECT * from resource where resource_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); // Fetch existing values $resource_id = $row["resource_id"]; @@ -1873,6 +2322,7 @@ $cat_num = $row["cat_num"]; $site_title = $row["site_title"]; $url = $row["url"]; + $guide_url = $row["guide_url"]; $visited = $row["visited"]; $annotation = $row["annotation"]; $infotype_id = $row["infotype_id"]; @@ -1880,6 +2330,9 @@ $coverage_detail = $row["coverage_detail"]; $sources_indexed = $row["sources_indexed"]; $location_id = $row["location_id"]; + $vendor_id = $row["vendor_id"]; + $resource_status = $row["resource_status"]; + $resource_message = $row["resource_message"]; // Run strings through the HTML cleaner for output $title = textOutHTML($title); @@ -1925,127 +2378,136 @@ printf("\n"); // Form header - printf("\n"); // If new insert - if ($key_id <1) printf(""); + if ($key_id <1) printf("\n"); // Else update - else printf(""); + else printf("\n"); // Account & Time/date information if this is not a new resource if ($key_id > 0) { printf("\n", $date_created); printf("\n", $date_modified); + printf("%s\n", $date_modified); printf("\n", $account_created); + printf("
%s\n", $account_created); printf("\n", $account_modified); + printf("%s\n", $account_modified); } // Title printf("\n"); // Other Title printf("\n"); // Author(s) printf("\n"); // Coverage detail printf("\n"); // Sources Indexed printf("\n"); // URL printf("\n"); + // Guide/Help URL + printf("\n"); + // Publisher printf("\n"); // Publish date printf("\n"); // Edition printf("\n"); + printf("\n", $edition); + printf("\n"); // Library Location / Call number printf("\n"); + printf("\n"); // Catalog Number printf("\n"); + printf("\n", $cat_num); + printf("\n"); // Master subject if ($mastersubject_id > 1 && $mastersubject_id != 2) { - $mastersubject = lookupField($con, "mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); + $mastersubject = lookupField("mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); printf("\n"); @@ -2054,18 +2516,18 @@ // Masterinfotype if ($masterinfotype_id > 1) { printf("\n"); } // Drop down box for default information type - printf("\n"); + // Vendor + printf("\n"); + printf("\n"); + + // Status toggle + $up_toggle = ""; + $down_toggle = ""; + $alert_toggle = ""; + if ($resource_status < 1) $up_toggle = " CHECKED "; + else if ($resource_status == 1) $down_toggle = " CHECKED "; + else if ($resource_status == 2) $alert_toggle = " CHECKED "; + printf("\n"); + printf("\n"); + + // Down/alert message + printf("\n"); + printf("\n"); // Annotation printf("\n"); @@ -2218,9 +2713,9 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); } @@ -2234,7 +2729,7 @@ // Description printf("\n"); printf("\n"); @@ -2242,7 +2737,7 @@ // URL printf("\n"); printf("\n"); - printf("", + printf("\n", $serviceURL); printf("\n"); @@ -2297,7 +2792,7 @@ printf("\n"); printf("\n"); - printf("\n", $nonaff_no); printf("\n"); @@ -2305,14 +2800,14 @@ printf("\n"); @@ -2404,9 +2899,9 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); } @@ -2438,14 +2933,14 @@ printf("\n"); @@ -2521,26 +3168,26 @@ // Else update else { - printf(""); + printf("\n"); printf("\n"); } // Subject printf("\n"); printf("\n"); // Primary location printf("\n"); printf("\n"); printf("\n"); @@ -2548,7 +3195,7 @@ printf("\n"); printf("\n"); @@ -2557,14 +3204,14 @@ // If this is an existing subject if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $subject_id); + printf("\n"); + printf("\n"); + printf("\n", $subject_id); } // Editing a new subject else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -2577,10 +3224,10 @@ // Change subject-location assignments if ($subject_id > 0) { - formAssignSubMaster($con, $subject_id); - formAssignSubLoc($con, $subject_id); - formAssignSubStaff($con, $subject_id); - formAssignSubCoursesub($con, $subject_id); + formAssignSubMaster($subject_id); + formAssignSubLoc($subject_id); + formAssignSubStaff($subject_id); + formAssignSubCoursesub($subject_id); } } // No problems @@ -2589,620 +3236,135 @@ } - /********************************************************** -Function: formAssignLibunitStaff +Function: formVendor Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: -Assigns staff (possibly multiple) to a given library unit. -**********************************************************/ -function formAssignLibunitStaff($con, $libunit_id){ - - // Table definition - printf("
"); - if ($key_id > 0 && $exists == 1) printf("Edit Resource #%d", $key_id); + printf("
\n"); + if ($key_id > 0 && $exists == 1) printf("Edit Resource (ID# %d)", $key_id); if ($key_id <= 0) printf("Enter New Resource\n"); printf("
\n"); - printf("
Date Created:"); + printf("
Date Created:\n"); printf("
\n"); printf("
%s
\n"); - printf("Date Modified:"); + printf("Date Modified:\n"); printf("\n"); - printf("%s
\n"); - printf("
Creator:"); + printf("
Creator:\n"); printf("
\n"); - printf("
%s
\n"); - printf("Last Modified by:"); + printf("Last Modified by:\n"); printf("\n"); - printf("%s
\n"); - printf("
Title: "); + printf("
Title:\n"); printf("
\n"); - printf("
", $title); + printf("
\n", $title); printf("
\n"); - printf("Other Title: "); + printf("Other Title:\n"); printf("\n"); - printf("", $other_title); + printf("\n", $other_title); printf("
\n"); - printf("
Author(s): "); + printf("
Author(s):\n"); printf("
\n"); - printf("
", $author); + printf("
\n", $author); printf("
(if applicable)
\n"); - printf("Coverage Detail:"); + printf("Coverage Detail:\n"); printf("\n"); - printf(""); - printf("
(enter year, i.e. 1966 - 1985, or 1984 - present)"); + printf("\n"); + printf("
(enter year, i.e. 1966 - 1985, or 1984 - present)\n"); printf("

\n"); - printf("Sources Indexed: "); + printf("Sources Indexed:\n"); printf("\n"); - printf("", $sources_indexed); - printf("
(enter link to vendor page)"); + printf("\n", $sources_indexed); + printf("
(enter link to vendor page)\n"); printf("
\n"); - printf("URL:"); + printf("URL:\n"); printf("\n"); - printf("


\n"); + printf("
\n"); printf("
\n"); + printf("Guide/Help URL:\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); - printf("Publisher: "); + printf("Publisher:\n"); printf("\n"); - printf("", $publisher); + printf("\n", $publisher); printf("
\n"); - printf("Publish Date: "); + printf("Publish Date:\n"); printf("\n"); - printf("", $pub_date); + printf("\n", $pub_date); printf("
\n"); - printf("Edition: "); + printf("Edition:\n"); printf("\n"); - printf("", $edition); - printf("
\n"); - printf("Library Location and Call No.: "); + printf("Library Location and Call No.:\n"); printf("\n"); printf("
\n"); - printf("Aleph No.: "); + printf("Catalog No.:\n"); printf("\n"); - printf("", $cat_num); - printf("
\n"); - printf("Master subject: "); + printf("Master subject:\n"); printf("\n"); printf("%s", $mastersubject); printf("
\n"); - printf("Master Information Type: "); + printf("Master Information Type:\n"); printf("\n"); - $masterinfotype = lookupField($con, "masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype"); + $masterinfotype = lookupField("masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype"); printf("%s", $masterinfotype); printf("
\n"); - printf("Base Information Type:"); + printf("\n"); + printf("Base Information Type:\n"); printf("\n"); - printf("\n"); $limit = " WHERE infotype_id >= 0 "; @@ -2079,15 +2541,48 @@ $limit .= " AND (masterinfotype_id < 2 OR masterinfotype_id = " . $masterinfotype_id . ")"; } - dropDownFieldSelected($con, "infotype", "infotype", "infotype_id", $limit, $infotype_id); + dropDownFieldSelected("infotype", "infotype", "infotype_id", $limit, $infotype_id); printf(""); printf("
\n"); + printf("Vendor:\n"); + printf("\n"); + printf("\n"); + printf("
\n"); + printf("Resource Status:\n"); + printf("\n"); + printf("Up \n", $up_toggle); + printf("Down \n", $down_toggle); + printf("Alert \n", $alert_toggle); + printf("
\n"); + printf("Down/Alert Message:\n"); + printf("\n"); + printf("\n", $resource_message); + printf("
\n"); - printf("
Annotation:
"); - printf("


\n"); @@ -2095,15 +2590,15 @@ // If this is an existing resource if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $key_id); + printf("\n"); + printf("\n"); + printf("\n", $key_id); } // A new resource else { - printf(" ", $mastersubject_id); - printf(" "); - printf(" "); + printf("\n", $mastersubject_id); + printf("\n"); + printf("\n"); } // Common button @@ -2119,12 +2614,12 @@ // Other forms - only if editing an existing resource if ($key_id > 0) { - formAssignResLoc($con, $key_id); - formAssignResFeature($con, $key_id); - formAssignResMastersubject($con, $key_id); + formAssignResLoc($key_id); + formAssignResFeature($key_id); + formAssignResMastersubject($key_id); // Offer a delete resource button - printf("
"); + printf("
\n"); printf("\n"); printf("\n"); printf("\n", $key_id); @@ -2139,18 +2634,18 @@ /********************************************************** Function: formService Author: Paul Bramscher -Last Modified: 07.02.2003 +Last Modified: 03.16.2004 *********************************************************** Draws an HTML form to edit the supplied service id, or to create a new service if the incoming id is less than 1. **********************************************************/ -function formService($con, $key_id) { +function formService($key_id) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if service actually exists - $exists = existsRow($con, "service", "service_id", $key_id); + $exists = existsRow("service", "service_id", $key_id); // Header printf("
"); @@ -2171,8 +2666,8 @@ // Fetch existing values $sql = "SELECT * from service where service_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $service_id = $row["service_id"]; $service = $row["service"]; $serviceURL = $row["serviceURL"]; @@ -2199,7 +2694,7 @@ // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Service #%d Not Found

", $key_id); + printf("

Service (ID# %d) Not Found

\n", $key_id); } // If no problems, then go for landing @@ -2210,7 +2705,7 @@ // If new insert if ($key_id <1) { - printf(""); + printf("\n"); printf("
\n"); printf("Enter New Service"); printf("
\n"); - printf("Edit Service: %s (#%d)", $service, $service_id); + printf("Edit Service: %s (ID# %d)", $service, $service_id); printf("
Description:
\n"); - printf("
\n"); printf("
Service URL:
Open to Nonaffiliated Users?Yes ", $nonaff_yes); + printf("Yes \n", $nonaff_yes); printf("No

\n"); // If this is an existing service if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $service_id); + printf("\n"); + printf("\n"); + printf("\n", $service_id); } // Editing a new service else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -2325,8 +2820,8 @@ // Change service-location assignments if ($service_id > 0) { - formAssignServServtype($con, $service_id); - formAssignServLoc($con, $service_id); + formAssignServServtype($service_id); + formAssignServLoc($service_id); } printf("
\n"); @@ -2338,7 +2833,7 @@ /********************************************************** Function: formStyle Author: Paul Bramscher -Last Modified: 07.03.2003 +Last Modified: 03.16.2004 *********************************************************** Draws an HTML form to edit the supplied style id, or to create a new style if the incoming id is less than 1. @@ -2349,13 +2844,13 @@ proper permissions. This must be done separately by someone with OS access. **********************************************************/ -function formStyle($con, $key_id) { +function formStyle($key_id) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if feature actually exists - $exists = existsRow($con, "style", "style_id", $key_id); + $exists = existsRow("style", "style_id", $key_id); // Header printf("
"); @@ -2367,8 +2862,8 @@ // Fetch existing values $sql = "SELECT * from style where style_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $style_id = $row["style_id"]; $style_title = $row["style_title"]; $header_file = $row["header_file"]; @@ -2385,7 +2880,7 @@ // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Style #%d Not Found

", $key_id); + printf("

Style (ID# %d) Not Found

\n", $key_id); } // If no problems, then go for landing @@ -2396,7 +2891,7 @@ // If new insert if ($key_id <1) { - printf(""); + printf("\n"); printf("
\n"); printf("Enter New Style"); printf("
\n"); - printf("Edit Style: %s (#%d)", $style, $style_id); + printf("Edit Style: %s (ID# %d)", $style_title, $style_id); printf("

\n"); // If this is an existing style if ($key_id > 0) { - printf(" "); - printf(" "); - printf(" ", $style_id); + printf("\n"); + printf("\n"); + printf("\n", $style_id); } // Editing a new style else { - printf(" "); - printf(" "); + printf("\n"); + printf("\n"); } // Common button @@ -2460,20 +2955,172 @@ /********************************************************** +Function: formStaff +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Form to create a new staff person, or update the existing +staff id. +**********************************************************/ +function formStaff($staff_id){ + + // Initialize variables + $staff_id = (int) $staff_id; + $last_name =""; + $first_name = ""; + $staff_account = ""; + $staff_email = ""; + $password = ""; + $access = ""; + $access_id = 1; + + // If editing an existing staff member load previous values + if ($staff_id > 1){ + $sql = "SELECT + s.first_name, + s.last_name, + s.staff_account, + s.staff_email, + s.access_id, + t.stafftitle, + t.stafftitle_id, + a.access_id, + a.access_level, + a.access + FROM staff s, access a, stafftitle t + WHERE + s.access_id = a.access_id AND + s.stafftitle_id = t.stafftitle_id AND + staff_id=" . $staff_id; + + $rs = xx_tryquery($sql); + $row = xx_fetch_array($rs, xx_ASSOC); + + // Fetch results + $first_name = Trim($row["first_name"]); + $last_name = Trim($row["last_name"]); + $staff_account = Trim($row["staff_account"]); + $staff_email = Trim($row["staff_email"]); + $access = Trim($row["access"]); + $access_id = Trim($row["access_id"]); + $stafftitle = Trim($row["stafftitle"]); + $stafftitle_id = Trim($row["stafftitle_id"]); + + // Run strings through the HTML cleaner for output + $first_name = textOutHTML($first_name); + $last_name = textOutHTML($last_name); + $staff_account = textOutHTML($staff_account); + + } + + + // Table definition + printf("
\n"); + + // If new insert + if ($staff_id <1) { + printf("\n"); + printf("\n"); + } + + // Else update + else { + printf("\n"); + printf("\n"); + } + + // Last name + printf("\n"); + printf("\n"); + printf("\n", $last_name); + printf("\n"); + + // First name + printf("\n"); + printf("\n"); + printf("\n", $first_name); + printf("\n"); + + // staff account - must be unique, may match against staff_account + printf("\n"); + printf("\n"); + printf("\n", $staff_account); + printf("\n"); + + // Staff email - whether or not x500 authentication is used + printf("\n"); + printf("\n"); + printf("\n", $staff_email); + printf("\n"); + + // Title + printf("\n"); + printf("\n"); + printf("\n"); + printf("\n"); + + // Access + printf("\n"); + printf("\n"); + printf("\n"); + printf("\n"); + + // Buttons + printf("
\n"); + printf("Enter New Staff Person"); + printf("
\n"); + printf("Edit Staff Person: %s %s (ID# %d)", $first_name, $last_name, $staff_id); + printf("
Last Name:
First Name:
Staff Account (x500 if applicable, 20 char max.):
Staff E-Mail:
Job Title:
Access Level:

\n"); + + // If new staff + if ($staff_id < 2) { + printf("\n"); + printf("\n"); + } + // Editing an existing staffperson + else { + printf("\n"); + printf("\n", $staff_id); + printf("\n"); + } + printf("\n"); + + // Close the form and table + printf("\n"); + + printf("
\n"); + + // If editing existing staff, draw other forms + if ($staff_id > 0) { + formPassword($staff_id); + formAssignStaffLibunit($staff_id); + formAssignStaffSub($staff_id); + } + + printf("

\n"); +} + + +/********************************************************** Function: formSubject Author: Paul Bramscher -Last Modified: 06.25.2003 +Last Modified: 03.15.2004 *********************************************************** Draws an HTML form to edit the supplied subject id, or to create a new subject if the incoming id is less than 1. **********************************************************/ -function formSubject($con, $key_id) { +function formSubject($key_id) { // Cast as integer to be sure $key_id = (int) $key_id; // Check to see if location actually exists - $exists = existsRow($con, "subject", "subject_id", $key_id); + $exists = existsRow("subject", "subject_id", $key_id); // Header printf("
"); @@ -2486,8 +3133,8 @@ // If the user is editing an existing record, fetch previous values $sql = "SELECT * from subject where subject_id = " . $key_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); // Fetch existing values $subject_id = $row["subject_id"]; @@ -2502,7 +3149,7 @@ // Houston, we have a problem if ($key_id > 0 && $exists == 0) { $problem = 1; - printf("

Subject #%d Not Found

", $key_id); + printf("

Subject (ID# %d) Not Found

\n", $key_id); } // If no problems, then go for landing @@ -2513,7 +3160,7 @@ // If new insert if ($key_id <1) { - printf("
"); + printf("\n"); printf("
\n"); printf("Enter New Subject"); printf("
\n"); - printf("Update Subject: %s (#%d)", $subject, $subject_id); + printf("Edit Subject: %s (ID# %d)", $subject, $subject_id); printf("
\n"); - printf("Subject:"); + printf("Subject:\n"); printf("\n"); - printf("", $subject); + printf("\n", $subject); printf("
Primary Location:\n"); - printf("\n"); + dropDownFieldSelected("location", "location", "location_id", "WHERE location_id > 0", $sublocation_id); printf("\n"); printf("
\n"); printf("Description:
"); - printf("
"); - - // Form - printf(""); - printf("", $libunit_id); - printf(""); - - // Available staff - // Omit the '(N/A)' staff - $omit_string = "WHERE staff_id > 1"; - - // Omit any pre-selected staff in libunit_staff - $in_string = getNotIn($con, "staff_id", "libunit_id", $libunit_id, "libunit_staff"); - if (strlen($in_string) > 0) $omit_string .= " AND staff_id NOT IN " . $in_string; - - // Draw the box - printf("\n"); - printf(""); - - // Current staff - printf(""); - - // Close off table - printf("
\n"); - printf("Assign Staff to Library Unit"); - printf("
\n"); - printf("
Available Staff:
\n"); - printf("

"); - - // Close off form - printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $libunit_id); - printf(""); - printf("
Selected Staff:
\n"); - printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); +Draws an HTML form to edit the supplied vendor id, or to +create a new vendor if the incoming id is less than 1. +**********************************************************/ +function formVendor($key_id) { -} + // Cast as integer to be sure + $key_id = (int) $key_id; + // Check to see if vendor actually exists + $exists = existsRow("vendor", "vendor_id", $key_id); -/********************************************************** -Function: formAssignStaffLibunit -Author: Paul Bramscher -Last Modified: 07.03.2003 -*********************************************************** -Purpose: -Assigns library units (possibly multiple) to a given -staffperson. -**********************************************************/ -function formAssignStaffLibunit($con, $staff_id){ - - // Table definition - printf("
"); - - // Form - printf(""); - printf("", $staff_id); - printf(""); - - // Available libunits - // Omit the '(N/A)' libunit - $omit_string = "WHERE libunit_id > 1"; - - // Omit any pre-selected libunits in libunit_staff - $in_string = getNotIn($con, "libunit_id", "staff_id", $staff_id, "libunit_staff"); - if (strlen($in_string) > 0) $omit_string .= " AND libunit_id NOT IN " . $in_string; - - // Draw the box - printf("\n"); - printf(""); - - // Current libunits - printf(""); - - // Close off table - printf("
\n"); - printf("Assign Library Unit to Staff"); - printf("
\n"); - printf("
Available Library Unit(s):
\n"); - printf("

"); - - // Close off form + // Header printf("
"); - printf("> \" >"); - printf(""); - printf("
"); - printf("
\n"); - printf("
"); - printf("", $staff_id); - printf(""); - printf("
Selected Library Unit(s):
\n"); - printf("

"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - printf("
"); - -} - - -/********************************************************** -Function: formAssignStaffSub -Author: Paul Bramscher -Last Modified: 08.26.2003 -*********************************************************** -Purpose: -Assigns subjects (possibly multiple) to a given -staffperson. -**********************************************************/ -function formAssignStaffSub($con, $staff_id){ - - // Table definition - printf("
\n"); - - // Form - printf("\n"); - printf("\n", $staff_id); - printf("\n"); - - // Available subjects - // Omit the '(N/A)' subject - $omit_string = "WHERE subject_id > 1"; - - // Omit any pre-selected subjects in sub_staff - $in_string = getNotIn($con, "subject_id", "staff_id", $staff_id, "sub_staff"); - if (strlen($in_string) > 0) $omit_string .= " AND subject_id NOT IN " . $in_string; - - // Draw the box - printf("\n"); - printf("\n"); - - // Current subjects - printf("\n"); - - // Close off table - printf("
\n"); - printf("Assign Subjects"); - printf("
\n"); - printf("
Available Subject(s):
\n"); - printf("

\n"); - - // Close off form - printf("
\n"); - printf("> \" >\n"); - printf("\n"); - printf("
\n"); - printf("
\n"); - printf("
\n"); - printf("", $staff_id); - printf("\n"); - printf("
Selected Subject(s):
\n"); - printf("

\n"); - printf("
\n"); - printf("\n"); - printf("
\n"); - printf("
\n"); - printf("
\n"); - -} - - -/********************************************************** -Function: formLibunit -Author: Paul Bramscher -Last Modified: 07.03.2003 -*********************************************************** -Purpose: -Handles the creation of new (or editing of existing) -library units. -**********************************************************/ -function formLibunit($con, $key_id){ - - // Initialize variables - $libunit_id = (int) $key_id; - $libunit =""; - $libunit_abbrev = ""; - - // If editing an existing library unit load previous values - if ($libunit_id > 1){ - $sql = "SELECT - l.libunit, - l.libunit_abbrev, - l.head_staff_id - FROM libunit l - WHERE - libunit_id = " . $libunit_id; - - $rs = xx_query($sql, $con); - $row = xx_fetch_array($rs); + if ($key_id > 0 && $exists == 1) { - // Fetch values - $libunit = Trim($row["libunit"]); - $libunit_abbrev = Trim($row["libunit_abbrev"]); - $head_staff_id = $row["head_staff_id"]; + // Initialization + $vendor_id = ""; + $vendor = ""; + $vendor_descr = ""; + $vendor_status = ""; + $vendor_message = ""; - // Run strings through the HTML cleaner for output - $libunit = textOutHTML($libunit); - $libunit_abbrev = textOutHTML($libunit_abbrev); - - } - - // Table definition - printf("
\n"); - - // If new insert - if ($key_id <1) { - printf(""); - printf("\n"); - } - - // Else update - else { - printf(""); - printf("\n"); - } - - // Libunit - printf("\n"); - printf("\n", $libunit); - printf(""); - - // Libunit abbrev. - printf("\n"); - printf("\n"); - printf("\n", $libunit_abbrev); - printf("\n"); - - // Libunit lead - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - - // Buttons - printf("
\n"); - printf("Enter New Library Unit"); - printf("
\n"); - printf("Edit Library Unit: %s (#%d)", $libunit, $libunit_id); - printf("
Library Unit:
Abbreviation:
Unit Lead:

\n"); - // If new libunit - if ($libunit_id < 2) { - printf(""); - printf(" "); - } - // Editing an existing libunit - else { - printf(""); - printf("", $libunit_id); - printf(" "); - } - printf(""); - - // Close the form and table - printf(""); - printf("
"); - - // Other forms - only if editing an existing libunit - - if ($libunit_id > 0) { - formAssignLibunitStaff($con, $libunit_id); - } - - printf("

"); -} - - -/********************************************************** -Function: formPassword -Author: Paul Bramscher -Last Modified: 07.03.2003 -*********************************************************** -Purpose: -Creates a new password for the supplied staff id. Note -that this is a locally stored (in mySQL) and encrypted -password. It is never visible in plaintext, nor is it -ever brought to an HTML form, neither in plaintext nor -in a "password" type HTML form field. -**********************************************************/ -function formPassword($con, $staff_id){ - - /***************************************** - ** If using native mySQL authentication ** - *****************************************/ - - // Table definition - printf("
"); - - // Form - printf(""); - printf("\n"); - - // Staff password - for mySQL authentication only. Ignored if x500 account is present. - printf("\n"); - - // First type - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - - // Confirm type - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - - // Buttons - printf("
\n"); - printf("Local Authentication Password - See Note Below"); - printf("
\n"); - printf("Note: Supply if utilizing mySQL authentication, otherwise leave blank. "); - printf("This will replace the password (if any) currently assigned to this account."); - printf("
New Password (6 char. minimum):
Confirm password (type again):

\n"); - printf("\n", $staff_id); - printf("\n"); - printf(" "); - - // Close the form and table - printf("\n"); - printf("
\n"); - - - /******************************************* - ** Determine if a password already exists ** - *******************************************/ - - - // Initialize variables - $pass_set = 0; - - // Determine whether a password exists - $sql = "SELECT COUNT(*) as pass_set - FROM staff s - WHERE s.password IS NOT NULL and staff_id = " . $staff_id; - - $rs = xx_query($sql, $con); - $row = xx_fetch_array($rs); - - // Fetch values - $pass_set = Trim($row["pass_set"]); - - - // If some password already exists, offer this form - if ($pass_set > 0) { - - // Table definition - printf("
"); - - // Form - printf("\n"); - printf(""); - - // Purge existing password - printf("
"); - printf("Local Password Found"); - printf("
\n"); - printf("
Purge password to null?

\n"); - printf("Note: It appears that this account currently has a password assigned to it."); - printf("This option will clear out any existing password, and leave the value NULL."); - printf("The staffperson may not login until a new password is supplied.

\n"); - - // Buttons - printf("
\n"); - printf("", $staff_id); - printf(""); - printf(" "); - - // Close the form and table - printf(""); - printf("

\n"); - - } // end password purge form - -} // end function - - -/********************************************************** -Function: formStaff -Author: Paul Bramscher -Last Modified: 07.03.2003 -*********************************************************** -Purpose: -Form to create a new staff person, or update the existing -staff id. -**********************************************************/ -function formStaff($con, $staff_id){ - - // Initialize variables - $staff_id = (int) $staff_id; - $last_name =""; - $first_name = ""; - $staff_account = ""; - $staff_email = ""; - $password = ""; - $access = ""; - $access_id = 1; - - // If editing an existing staff member load previous values - if ($staff_id > 1){ - $sql = "SELECT - s.first_name, - s.last_name, - s.staff_account, - s.staff_email, - s.access_id, - t.stafftitle, - t.stafftitle_id, - a.access_id, - a.access_level, - a.access - FROM staff s, access a, stafftitle t - WHERE - s.access_id = a.access_id AND - s.stafftitle_id = t.stafftitle_id AND - staff_id=" . $staff_id; - - $rs = xx_query($sql, $con); - $row = xx_fetch_array($rs); - - // Fetch results - $first_name = Trim($row["first_name"]); - $last_name = Trim($row["last_name"]); - $staff_account = Trim($row["staff_account"]); - $staff_email = Trim($row["staff_email"]); - $access = Trim($row["access"]); - $access_id = Trim($row["access_id"]); - $stafftitle = Trim($row["stafftitle"]); - $stafftitle_id = Trim($row["stafftitle_id"]); - - // Run strings through the HTML cleaner for output - $first_name = textOutHTML($first_name); - $last_name = textOutHTML($last_name); - $staff_account = textOutHTML($staff_account); - - } - - - // Table definition - printf("
\n"); - - // If new insert - if ($staff_id <1) { - printf(""); - printf("\n"); + // Fetch existing values + $sql = "SELECT * FROM vendor WHERE vendor_id = " . $key_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); + $vendor_id = $row["vendor_id"]; + $vendor = $row["vendor"]; + $vendor_descr = $row["vendor_descr"]; + $vendor_status = $row["vendor_status"]; + $vendor_message = $row["vendor_message"]; } - // Else update - else { - printf(""); - printf("\n"); + // Houston, we have a problem + if ($key_id > 0 && $exists == 0) { + $problem = 1; + printf("

Vendor (ID# %d) Not Found

\n", $key_id); } - // Last name - printf("\n"); - printf("\n"); - printf("\n", $last_name); - printf("\n"); + // If no problems, then go for landing + if ($problem != 1) { - // First name - printf("\n"); - printf("\n"); - printf("\n", $first_name); - printf("\n"); + // Table definition + printf("
\n"); - printf("Enter New Staff Person"); - printf("
\n"); - printf("Edit Staff Person: %s %s (#%d)", $first_name, $last_name, $staff_id); - printf("
Last Name:
First Name:
\n"); - // staff account - must be unique, may match against staff_account - printf("\n"); - printf(""); - printf("\n", $staff_account); - printf("\n"); - - // Staff email - whether or not x500 authentication is used - printf("\n"); - printf("\n"); - printf("\n", $staff_email); - printf("\n"); + // Form to handle vendor + // If new insert + if ($key_id <1) { + printf("\n"); + printf("\n"); + } - // Title - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); + // Else update + else { + printf("\n"); + printf("\n"); + } - // Access - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); + // Vendor name + printf("\n"); + printf("\n"); + printf("\n", $vendor); + printf("\n"); - // Buttons - printf("\n"); + printf("\n"); + + // Down toggle + $up_toggle = ""; + $down_toggle = ""; + $alert_toggle = ""; + if ($vendor_status < 1) $up_toggle = " CHECKED "; + else if ($vendor_status == 1) $down_toggle = " CHECKED "; + else if ($vendor_status == 2) $alert_toggle = " CHECKED "; + printf("\n"); + printf("\n"); + + // Message + printf("\n"); + printf("\n"); - // Close the form and table - printf("\n"); + // Buttons + printf("
Staff Account (x500 if applicable, 20 char max.):
Staff E-Mail:
\n"); + printf("Enter New Vendor"); + printf("
Job Title:
\n"); + printf("Edit Vendor: %s (ID# %d)", $vendor, $vendor_id); + printf("
Access Level:
Vendor:

\n"); + // Vendor description + printf("
Description:
\n"); + printf("\n"); + printf("
\n"); + printf("Vendor Status:\n"); + printf("\n"); + printf("Up \n", $up_toggle); + printf("Down \n", $down_toggle); + printf("Alert \n", $alert_toggle); - // If new staff - if ($staff_id < 2) { - printf(""); - printf(" "); - } - // Editing an existing staffperson - else { - printf(""); - printf("", $staff_id); - printf(" "); - } - printf("\n"); + printf("
\n"); + printf("Down/Alert Message:\n"); + printf("\n"); + printf("\n", $vendor_message); + printf("

\n"); + // If this is an existing vendor + if ($key_id > 0) { + printf("\n"); + printf("\n"); + printf("\n", $vendor_id); + } + // Editing a new vendor + else { + printf("\n"); + printf("\n"); + } - printf("
\n"); + // Common button + printf("\n"); - // If editing existing staff, draw other forms - if ($staff_id > 0) { - formPassword($con, $staff_id); - formAssignStaffLibunit($con, $staff_id); - formAssignStaffSub($con, $staff_id); - } + // Close things + printf("\n"); + printf("
\n"); - printf("

\n"); + } // No problems } -?> +?> \ No newline at end of file