--- trunk/admin/include/delete.php 2004/03/18 20:21:08 71 +++ trunk/admin/include/delete.php 2004/03/18 20:33:37 72 @@ -1,15 +1,15 @@ -Last Modified: 11.04.2003 by Paul Bramscher +Original Author: Paul Bramscher +Last Modified: 03.16.2004 by Paul Bramscher *********************************************************** Comments: This library brings together all SQL delete functions -and "confirm" type promots for LibData general setup -tables. Those pertaining to CLPS and RQS are located in -scribe_application.php and are located in subject_builder.php -respectively. +and confirm delete prompts for LibData general setup +tables. Those pertaining to PageScribe and SubjectBuilder +are located in scribe_application.php and +subject_builder.php respectively. *********************************************************** Table of Contents: deleteCampus @@ -33,6 +33,7 @@ deleteMastersubjectConfirm deleteResFeature deleteResLoc +deleteResMastersubject deleteResource deleteResourceConfirm deleteService @@ -57,652 +58,499 @@ deleteSubStaff deleteTerm deleteTermConfirm +deleteVendor +deleteVendorConfirm **********************************************************/ /********************************************************** Function: deleteCampus Author: Paul Bramscher -Last Modified: 06.04.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes a supplied campus id, sets affected course pages to NULL campus. **********************************************************/ -function deleteCampus($con, $campus_id){ +function deleteCampus($campus_id){ - // Draw form heading - printf("

Deleting Campus...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Campus (ID# " . $campus_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1. if ($campus_id > 1) { // First clear out any coursescribe pages - $sql = "UPDATE course SET campus_id = NULL WHERE campus_id = " - . $campus_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Campus purged from assignments to course pages.
\n"); - } + $sql = "UPDATE course SET campus_id = NULL WHERE campus_id = " . $campus_id; + if (xx_tryquery($sql)) printf("Campus purged from assignments to course pages.
\n"); // Delete from the coursesub table - if ($problem == 0) { - $sql = "UPDATE coursesub SET campus_id = 1 WHERE campus_id =" . $campus_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed from affected Course Subjects.
\n"); - } - } + $sql = "UPDATE coursesub SET campus_id = 1 WHERE campus_id =" . $campus_id; + if (xx_tryquery ($sql)) printf("Removed from affected Course Subjects.
\n"); // Delete from the campus table - if ($problem == 0) { - $sql = "DELETE FROM campus WHERE campus_id =" . $campus_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this campus successfully.

\n"); - } - } + $sql = "DELETE FROM campus WHERE campus_id =" . $campus_id; + if (xx_tryquery ($sql)) printf("Removed this campus successfully."); } - else printf("Cannot delete Campus ID#1, it acts as a system placeholder.

\n"); + else printf("Cannot delete Campus ID# 1, it acts as a system placeholder."); - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteCampusConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the selected campus. **********************************************************/ -function deleteCampusConfirm($con, $key_id){ +function deleteCampusConfirm($key_id){ - // Make sure we have a valid integer type $campus_id = (int) $key_id; - - // Draw page heading - printf("

Delete Campus ID# %s?

", $campus_id); + msgTableOpen(1, "Delete Campus (ID# " . $campus_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "campus", "campus_id", $campus_id); + $exists = existsRow("campus", "campus_id", $campus_id); if ($exists > 0){ - - // Table - printf(""); - printf("
"); - + // Lookup the descriptive title - $campus = lookupField($con, "campus", "campus_id", $campus_id, "campus"); - printf("Campus: %s

\n ", $campus); + $campus = lookupField("campus", "campus_id", $campus_id, "campus"); + printf("Campus: %s

\n ", $campus); + printf("This will permanently remove this campus and its various assignments from the system. Some CourseScribe pages may lose their campus association.

\n"); // Form to draw the delete button - printf("
"); - printf(""); - printf("", $campus_id); - printf("This will permanently remove this campus and its various assignments from the system. Some CourseScribe pages may lose their campus association.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); + printf("
\n"); + printf("\n"); + printf("\n", $campus_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); - // Close table - printf("
"); } + else if ($exists < 1) printf ("Campus not found. Operation cancelled.

\n"); + + msgTableClose(); - // Failed for whatever reason - else if ($exists < 1) printf ("Campus not found. Operation cancelled.
\n"); - - printf("
"); } - - /********************************************************** Function: deleteCoursesub Author: Paul Bramscher -Last Modified: 06.04.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes a supplied course subject id **********************************************************/ -function deleteCoursesub($con, $coursesub_id){ +function deleteCoursesub($coursesub_id){ - // Draw form heading - printf("

Deleting Course Subject...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Course Subject (ID# " . $coursesub_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1. if ($coursesub_id > 1) { // 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) { printf("Cannot delete this Course Subject. There are courses which are currently using it."); } - // Delete from the campus table + // Delete else { - // Delete from the sub_coursesub table $sql = "DELETE FROM sub_coursesub WHERE coursesub_id = " . $coursesub_id; - - if (!xx_query ($sql, $con)){ - $problem = 0; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-Course Subject assignments removed.
\n"); - - } + if (xx_tryquery ($sql)) printf("Subject-Course Subject assignments removed.
\n"); // Delete from the coursesub table - if ($problem == 0) { - - $sql = "DELETE FROM coursesub WHERE coursesub_id =" . $coursesub_id; - - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this Course Subject successfully.

\n"); - } - - } + $sql = "DELETE FROM coursesub WHERE coursesub_id =" . $coursesub_id; + if (xx_tryquery ($sql)) printf("Removed this Course Subject successfully."); } } - else printf("Cannot delete Course Subject ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + else printf ("Cannot delete Course Subject ID# 1, it acts as a system placeholder."); + + printf("

\n"); + msgTableClose(); } - /********************************************************** Function: deleteCoursesubConfirm Author: Paul Bramscher -Last Modified: 05.29.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the selected campus. **********************************************************/ -function deleteCoursesubConfirm($con, $coursesub_id){ +function deleteCoursesubConfirm($coursesub_id){ - // Make sure we have a valid integer type $coursesub_id = (int) $coursesub_id; + msgTableOpen(1, "Delete Course Subject (ID# " . $coursesub_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "coursesub", "coursesub_id", $coursesub_id); + $exists = existsRow("coursesub", "coursesub_id", $coursesub_id); if ($exists > 0){ // Lookup the descriptive title - $coursesub = lookupField($con, "coursesub", "coursesub_id", $coursesub_id, "coursesub"); - - // Draw page heading - printf("

Delete Course Subject '%s'?

", $coursesub); - - // Table - printf(""); - printf("

"); - printf("Messages:
\n"); + $coursesub = lookupField("coursesub", "coursesub_id", $coursesub_id, "coursesub"); // 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) { // Cannot delete, dependencies exist + 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.

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

"); + printf("

\n"); } else { // Form to draw the delete button - printf("
"); - printf(""); - printf("", $coursesub_id); - printf("This will permanently remove this Course Subject.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); + printf("Course Subject: %s

\n ", $coursesub); + printf("This will permanently remove this Course Subject.

\n"); + printf("
\n"); + printf("\n"); + printf("\n", $coursesub_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); } - // Close table - printf("
"); - } + else if ($exists < 1) printf ("Course Subject not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Course Subject not found. Operation cancelled.
\n"); - - printf("
"); + msgTableClose(); } /********************************************************** Function: deleteFaculty Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied faculty id, and removes any relations to affected courses. **********************************************************/ -function deleteFaculty($con, $faculty_id){ - - // Draw form heading - printf("

Deleting Faculty...

"); +function deleteFaculty($faculty_id){ - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Faculty (ID# " . $faculty_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1. if ($faculty_id > 1) { // First clear out the course_personnel assignments - $sql = "DELETE FROM course_personnel WHERE faculty_id = " - . $faculty_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Faculty person purged from assignments to course pages.
\n"); - } + $sql = "DELETE FROM course_personnel WHERE faculty_id = " . $faculty_id; + if (xx_tryquery ($sql)) printf("Faculty person purged from assignments to course pages.
\n"); // Delete from the faculty table - if ($problem == 0) { - $sql = "DELETE FROM faculty WHERE faculty_id =" . $faculty_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this faculty person successfully.

\n"); - } - } + $sql = "DELETE FROM faculty WHERE faculty_id =" . $faculty_id; + if (xx_tryquery ($sql)) printf("Removed this faculty person successfully."); } - else printf("Cannot delete Faculty ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + else printf ("Cannot delete Faculty ID# 1, it acts as a system placeholder."); + + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteFacultyConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the selected faculty person. **********************************************************/ -function deleteFacultyConfirm($con, $faculty_id){ +function deleteFacultyConfirm($faculty_id){ - // Make sure we have a valid integer type $faculty_id = (int) $faculty_id; - - // Draw page heading - printf("

Delete Faculty ID# %s?

", $faculty_id); + msgTableOpen(1, "Delete Faculty (ID# " . $faculty_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "faculty", "faculty_id", $faculty_id); + $exists = existsRow("faculty", "faculty_id", $faculty_id); if ($exists > 0){ - // Table - printf(""); - printf("
"); - // Lookup the descriptive title - $faculty_name = lookupFaculty($con, $faculty_id); - printf("Faculty Person: %s
\n ", $faculty_name); + $faculty_name = lookupFaculty($faculty_id); + printf("Faculty Person: %s

\n ", $faculty_name); + printf("This will permanently remove the faculty person and his/her various assignments from the system. Some CourseScribe pages may have no personnel.

\n"); // Form to draw the delete button - printf("
"); - printf(""); - printf("", $faculty_id); - printf("This will permanently remove the faculty person and his/her various assignments from the system. Some CourseScribe pages may have no personnel.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); - - // Close table - printf("
"); + printf("
\n"); + printf("\n"); + printf("\n", $faculty_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); } + else if ($exists < 1) printf ("Faculty not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Faculty not found. Operation cancelled.
\n"); - - printf("
"); + msgTableClose(); } /********************************************************** Function: deleteFeature Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied feature id, and removes any relations to affected resources. **********************************************************/ -function deleteFeature($con, $feature_id){ - - // Draw form heading - printf("

Deleting Feature...

"); +function deleteFeature($feature_id){ - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Feature (ID# " . $feature_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($feature_id > 1) { // Delete all resource_feature assignments $sql = "DELETE from res_feature WHERE feature_id =" . $feature_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed resource-feature associations.
\n"); - - if ($problem == 0) { + if (xx_tryquery ($sql)) printf("Removed resource-feature associations.
\n"); - // Delete from feature table - $sql = "DELETE FROM feature WHERE feature_id =" . $feature_id; + // Delete from feature table + $sql = "DELETE FROM feature WHERE feature_id =" . $feature_id; + if (xx_tryquery ($sql)) printf("Removed feature successfully."); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed feature successfully.

\n"); - } - } - } } + else printf ("Cannot delete Feature ID# 1, it acts as a system placeholder."); - else printf("Cannot delete Feature ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteFeatureConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.15.2004 *********************************************************** Purpose: Confirm prompt for deleting the supplied feature id. **********************************************************/ -function deleteFeatureConfirm($con, $key_id){ +function deleteFeatureConfirm($key_id){ - // Make sure we have a valid integer type $feature_id = (int) $key_id; - - // Draw page heading - printf("

Delete Feature ID# %s?

", $feature_id); + msgTableOpen(1, "Delete Feature (ID# " . $feature_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "feature", "feature_id", $feature_id); + $exists = existsRow("feature", "feature_id", $feature_id); if ($exists > 0){ - // Table - printf(""); - printf("
"); - // Lookup the descriptive title - $feature = lookupField($con, "feature", "feature_id", $feature_id, "feature"); - printf("Feature: %s
\n ", $feature); + $feature = lookupField("feature", "feature_id", $feature_id, "feature"); + printf("Feature: %s

\n ", $feature); + printf("This will permanently remove the feature and its various assignments from the system. Some resources may no longer have icons.

\n"); // Form to draw the delete button - printf("
"); - printf(""); - printf("", $feature_id); - printf("This will permanently remove the feature and its various assignments from the system. Some resources may no longer have icons.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); - - // Close table - printf("
"); + printf("
\n"); + printf("\n"); + printf("\n", $feature_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); } + else if ($exists < 1) printf ("Feature not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Feature not found. Operation cancelled.
\n"); - - printf("
"); + msgTableClose(); } /********************************************************** Function: deleteInfotype Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied information type id, and removes assocations in the resource and resource-subject-information type tables. **********************************************************/ -function deleteInfotype($con, $infotype_id){ - - // Draw form heading - printf("

Deleting Information Type...

"); +function deleteInfotype($infotype_id){ - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Information Type (ID# " . $infotype_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($infotype_id > 1) { // Delete all res_sub_infotype assignments $sql = "DELETE from res_sub_infotype WHERE infotype_id =" . $infotype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed resource-subject-infotype associations.
\n"); - + if (xx_tryquery ($sql)) printf("Removed resource-subject-infotype associations.
\n"); - if ($problem == 0) { + // Set (N/A) type in resource table + $sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; + if (xx_tryquery ($sql)) printf("Set default information types for affects resources to (N/A).
\n"); - // Set (N/A) type in resource table - $sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Set default information types for affects resources to (N/A).
\n"); - } - } - - - if ($problem == 0) { - - // Delete from infotype table - $sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this information type successfully.

\n"); - } - } - - } + // Delete from infotype table + $sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; + if (xx_tryquery ($sql)) printf("Removed this information type successfully."); } + else printf ("Cannot delete Information Type ID# 1, it acts as a system placeholder."); - else printf("Cannot delete Information Type ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteInfotypeConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied information type id. **********************************************************/ -function deleteInfotypeConfirm($con, $key_id){ +function deleteInfotypeConfirm($key_id){ - // Make sure we have a valid integer type $infotype_id = (int) $key_id; - - // Draw page heading - printf("

Delete Information Type ID# %s?

", $infotype_id); + msgTableOpen(1, "Delete Information Type (ID# " . $infotype_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "infotype", "infotype_id", $infotype_id); + $exists = existsRow("infotype", "infotype_id", $infotype_id); if ($exists > 0){ - // Table - printf(""); - printf("
"); - // Lookup the descriptive title - $infotype = lookupField($con, "infotype", "infotype_id", $infotype_id, "infotype"); - printf("Information Type: %s

\n ", $infotype); + $infotype = lookupField("infotype", "infotype_id", $infotype_id, "infotype"); + printf("Information Type: %s

\n ", $infotype); + printf("This will permanently remove the Information Type and its various assignments from the system. Affected resource-subject-infotype assignments on RQS pages will be broken, and therefore removed! Be sure to re-assign important resources to another information type before deleting this one.

\n"); + printf("Check the Information Type Detail page to display affected RQS pages.", $infotype_id); // Form to draw the delete button - printf("
"); - printf(""); - printf("", $infotype_id); - printf("This will permanently remove the Information Type and its various assignments from the system. Affected resource-subject-infotype assignments on RQS pages will be broken, and therefore removed! Be sure to re-assign important resources to another information type before deleting this one.

"); - printf("Check the
Information Type Detail page to display affected RQS pages.", $infotype_id); + printf("\n"); + printf("\n"); + printf("\n", $infotype_id); printf("

\n"); - printf("
"); - printf(""); - printf("
"); - printf("
"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); + } + else if ($exists < 1) printf ("Information Type not found. Operation cancelled.

\n"); + + msgTableClose(); +} + + +/********************************************************** +Function: deleteLibunit +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Deletes the supplied libunit id, and any staff assignments +in that library unit. +**********************************************************/ +function deleteLibunit($libunit_id){ + + msgTableOpen(1, "Deleting Library Unit (ID# " . $libunit_id . ")"); + printf("Messages:
\n"); + + // First delete from libunit_staff + if ($libunit_id > 1) { + $sql = "DELETE FROM libunit_staff WHERE libunit_id = " . $libunit_id; + if (xx_tryquery ($sql)) printf("Deleted affected Library Unit staff assignments.
\n"); + + // Delete from the libunit table + $sql = "DELETE FROM libunit WHERE libunit_id =" . $libunit_id; + if (xx_tryquery ($sql)) printf("Removed this Library Unit successfully."); - // Close table - printf("
"); } + else printf ("Cannot delete Library Unit ID# 1, it acts as a system placeholder."); - // Failed for whatever reason - else if ($exists < 1) printf ("Information Type not found. Operation cancelled.
\n"); + printf("

\n"); + msgTableClose(); +} + + +/********************************************************** +Function: deleteLibunitConfirm +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Confirm prompt for deleting the supplied libunit id. +**********************************************************/ +function deleteLibunitConfirm($key_id){ + + $libunit_id = (int) $key_id; + msgTableOpen(1, "Delete Library Unit (ID# " . $libunit_id . ")?"); + + // Check to see if its possible + $exists = existsRow("libunit", "libunit_id", $libunit_id); + if ($exists > 0){ + + // Lookup the descriptive title + $libunit = lookupField("libunit", "libunit_id", $libunit_id, "libunit"); + printf("Libunit: %s

\n ", $libunit); + printf("This will permanently remove this Library Unit from the system. This may render some staff without a unit.

"); + + // Form to draw the delete button + printf("
\n"); + printf("\n"); + printf("\n", $libunit_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + } + else if ($exists < 1) printf ("Library Unit not found. Operation cancelled.

\n"); + + msgTableClose(); +} - printf("
"); + +/********************************************************** +Function: deleteLibunitStaff +Author: Paul Bramscher +Last Modified: 03.03.2004 +*********************************************************** +Purpose: +Deletes staffperson assignments (possibly multiple) to the +supplied libunit id and calls formLibunit back again. +**********************************************************/ +function deleteLibunitStaff($key_list_array, $libunit_id){ + + for ($element = 0; $element < sizeof($key_list_array); $element++) { + $sql = "DELETE FROM libunit_staff WHERE libunit_id = " + . $libunit_id + . " AND staff_id = " + . $key_list_array[$element]; + xx_tryquery($sql); + } + // Call the libunit form back + formLibunit($libunit_id); } /********************************************************** Function: deleteLocation Author: Paul Bramscher -Last Modified: 05.27.2003 +Last Modified: 03.15.2004 *********************************************************** Purpose: Deletes the supplied location id, and removes associations @@ -712,246 +560,122 @@ fields (non-relational), as well as all user copy-paste buffers. **********************************************************/ -function deleteLocation($con, $delMessage, $location_id){ +function deleteLocation($delMessage, $location_id){ - // Draw form heading - printf("

Deleting Location...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Location (ID# " . $location_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($location_id > 1) { // First delete from res_loc $sql = "DELETE FROM res_loc WHERE location_id = " . $location_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Affected resource-location assignments removed.
\n"); - } + if (xx_tryquery ($sql)) printf("Affected resource-location assignments removed.
\n"); // Delete from sub_loc - if ($problem == 0) { - $sql = "DELETE FROM sub_loc WHERE location_id =" . $location_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Affected subject-location assignments removed.
\n"); - } - } + $sql = "DELETE FROM sub_loc WHERE location_id =" . $location_id; + if (xx_tryquery ($sql)) printf("Affected subject-location assignments removed.
\n"); // Delete primary subject locations - if ($problem == 0) { - $sql = "UPDATE subject SET sublocation_id = NULL WHERE sublocation_id =" . $location_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Affected primary subject locations set to NULL.
\n"); - } - } + $sql = "UPDATE subject SET sublocation_id = NULL WHERE sublocation_id =" . $location_id; + if (xx_tryquery ($sql)) printf("Affected primary subject locations set to NULL.
\n"); // Delete from serv_loc - if ($problem == 0) { - $sql = "DELETE FROM serv_loc WHERE location_id =" . $location_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Affected service-location assignments removed.
\n"); - } - } + $sql = "DELETE FROM serv_loc WHERE location_id =" . $location_id; + if (xx_tryquery ($sql)) printf("Affected service-location assignments removed.
\n"); - // Update affected PageScribe pages - if ($problem == 0) { + /******************************** + ** Update affected CL/PS pages ** + ********************************/ + + // First, get the default location description and title + $sql = "SELECT location, location_descr FROM location WHERE location_id = " + . $location_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); + $location = $row["location"]; + $location_descr = $row["location_descr"]; - // First, get the default location description and title - $sql = "SELECT location, location_descr FROM location WHERE location_id = " - . $location_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); - $location = $row["location"]; - $location_descr = $row["location_descr"]; - - // Clean up strings - $location_descr = textInmySQL($location_descr); - $location = textInmySQL($location); - $delMessage = textInmySQL($delMessage); - - // Next, append the reason for deletion to the description - if (strlen($location_descr) > 0) $location_descr .= "
" . $delMessage; - else $location_descr = $delMessage; - - // Update all of the elements using this resource with a custom description. - $sql = "UPDATE element SET label = '" - . $location - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), location_id = NULL WHERE location_id =" . $location_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions.
\n"); - } - - - // Next, update all of the elements using this resource without a custom description. - $sql = "UPDATE element SET label = '" - . $location - . "', element_descr = '" - . $location_descr - . "', location_id = NULL WHERE location_id =" . $location_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions.
\n"); - } + // Clean up strings + $location_descr = textInmySQL($location_descr); + $location = textInmySQL($location); + $delMessage = textInmySQL($delMessage); + // Next, append the reason for deletion to the description + if (strlen($location_descr) > 0) $location_descr .= "
" . $delMessage; + else $location_descr = $delMessage; - } - + // Update all of the elements using this resource with a custom description. + $sql = "UPDATE element SET label = '" + . $location + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), location_id = NULL WHERE location_id =" . $location_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.
\n"); - // Update affected PageScribe copy buffers - if ($problem == 0) { + // Next, update all of the elements using this resource without a custom description. + $sql = "UPDATE element SET label = '" + . $location + . "', element_descr = '" + . $location_descr + . "', location_id = NULL WHERE location_id =" . $location_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.
\n"); - // Update all of the elements using this location with a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $location - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), location_id = NULL WHERE location_id =" . $location_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); - } - - - // Next, update all of the elements using this location without a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $location - . "', element_descr = '" - . $location_descr - . "', location_id = NULL WHERE location_id =" . $location_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions (buffers).
\n"); - } + /********************************** + ** Update affected CL/PS buffers ** + **********************************/ + // Update all of the elements using this location with a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $location + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), location_id = NULL WHERE location_id =" . $location_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); - } + // Next, update all of the elements using this location without a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $location + . "', element_descr = '" + . $location_descr + . "', location_id = NULL WHERE location_id =" . $location_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).
\n"); // Delete from location - if ($problem == 0) { - $sql = "DELETE FROM location WHERE location_id =" . $location_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Location successfully removed.

\n"); - } - } + $sql = "DELETE FROM location WHERE location_id =" . $location_id; + if (xx_tryquery ($sql)) printf("Location successfully removed."); } - else printf("Cannot delete Location ID#1, it acts as a system placeholder.

\n"); - - printf("
\n"); - printf("

\n"); + else printf ("Cannot delete Location ID# 1, it acts as a system placeholder."); + + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteLocationConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied location id. **********************************************************/ -function deleteLocationConfirm($con, $key_id){ +function deleteLocationConfirm($key_id){ - // Make sure we have a valid integer type $location_id = (int) $key_id; - - printf("
\n"); + msgTableOpen(1, "Delete Location (ID# " . $location_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "location", "location_id", $location_id); + $exists = existsRow("location", "location_id", $location_id); if ($exists > 0){ - // Table - printf("\n"); - - // Row header - printf("\n"); - printf("
\n"); - printf("Delete Location ID# %s?", $location_id); - printf("
\n"); - // Lookup the name of the location - $location = lookupField($con, "location", "location_id", $location_id, "location"); + $location = lookupField("location", "location_id", $location_id, "location"); printf("Location: %s

\n ", $location); // Form to draw the delete button @@ -964,30 +688,24 @@ printf("

\n"); // Warning - printf("This will permanently remove the location and its various assignments from the system.

\n"); + printf("This will permanently remove the location and its various assignments from the system.

\n"); // Delete button printf("
\n"); printf("\n"); printf("
\n"); - printf("
\n"); - - // Close table - printf("
\n"); - printf("
\n"); - } + printf("\n"); + } + else if ($exists < 1) printf ("Location not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Location #%d not found. Operation cancelled.

\n", $location_id); - - printf("
\n"); + msgTableClose(); } /********************************************************** Function: deleteMasterinfotype Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Delete the supplied master information type id. Note that @@ -997,18 +715,10 @@ well as their resource-subject-information type assignments. This can have potentially large impact. **********************************************************/ -function deleteMasterinfotype($con, $masterinfotype_id){ - - // Draw form heading - printf("

Deleting Master Information Type...

"); +function deleteMasterinfotype($masterinfotype_id){ - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Master Information Type (ID# " . $masterinfotype_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($masterinfotype_id > 1) { @@ -1018,8 +728,8 @@ . $masterinfotype_id; // 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)) { $infotype_id = $row["infotype_id"]; $infotype = $row["infotype"]; @@ -1028,145 +738,77 @@ // Delete all res_sub_infotype assignments $sql = "DELETE from res_sub_infotype WHERE infotype_id =" . $infotype_id; + if (xx_tryquery ($sql)) printf("Removed resource-subject-infotype associations.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed resource-subject-infotype associations.
\n"); - - - if ($problem == 0) { - - // Set (N/A) type in resource table - $sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Set default information types for affects resources to (N/A).
\n"); - } - } - - - if ($problem == 0) { - - // Delete from infotype table - $sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed affected specific information types.
\n"); - } - } // successful delete of a specific information type + // Set (N/A) type in resource table + $sql = "UPDATE resource SET infotype_id = 1 WHERE infotype_id =" . $infotype_id; + if (xx_tryquery ($sql)) printf("Set default information types for affects resources to (N/A).
\n"); - } // end of delete for an affected infotype - - } // all affected infotypes below this masterinfotype - - // Delete the masterinfotype itself + // Delete from infotype table + $sql = "DELETE FROM infotype WHERE infotype_id =" . $infotype_id; + if (xx_tryquery ($sql)) printf("Removed affected specific information types.
\n"); + } - if ($problem == 0) { - - // Delete from masterinfotype table - $sql = "DELETE FROM masterinfotype WHERE masterinfotype_id =" . $masterinfotype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed Master Information Type successfully.

\n"); - } - } // delete masterinfotype itself + // Delete from masterinfotype table + $sql = "DELETE FROM masterinfotype WHERE masterinfotype_id =" . $masterinfotype_id; + if (xx_tryquery ($sql)) printf("Removed Master Information Type successfully."); - } // masterinfotype > 1 (cannot delete N/A). + } + else printf ("Cannot delete Master Information Type ID# 1, it acts as a system placeholder."); - else printf("Cannot delete Master Information Type ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteMasterinfotypeConfirm Author: Paul Bramscher -Last Modified: 05.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the supplied master information type id. Note the dire warning. **********************************************************/ -function deleteMasterinfotypeConfirm($con, $key_id){ +function deleteMasterinfotypeConfirm($key_id){ - // Make sure we have a valid integer type $masterinfotype_id = (int) $key_id; - - // Draw page heading - printf("

Delete Master Information Type ID# %s?

", $masterinfotype_id); + msgTableOpen(1, "Delete Master Information Type (ID# " . $masterinfotype_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "masterinfotype", "masterinfotype_id", $masterinfotype_id); + $exists = existsRow("masterinfotype", "masterinfotype_id", $masterinfotype_id); if ($exists > 0){ - // Table - printf(""); - printf("
"); - // Lookup the descriptive title - $masterinfotype = lookupField($con, "masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype"); - printf("Master Information Type: %s

\n ", $masterinfotype); - - // Form to draw the delete button - printf("
"); - printf(""); - printf("", $masterinfotype_id); - printf("This will permanently remove the Master Information Type and its various assignments from the system. "); + $masterinfotype = lookupField("masterinfotype", "masterinfotype_id", $masterinfotype_id, "masterinfotype"); + printf("Master Information Type: %s

\n ", $masterinfotype); + printf("This will permanently remove the Master Information Type and its various assignments from the system. "); printf("A potentially large deletion cascade may result, since deleting a Master Information Type will delete all Information Types below it. "); printf("All affected resource-subject-infotype assignments on RQS pages will be broken, and therefore removed! "); printf("Be sure to re-assign important resources to another specific Information Type, and assign it to a safe Master Information Type before deleting this one.

"); printf("Do not proceed unless you are VERY sure of what you're doing.

\n"); printf("Check the Master Information Type Detail page to display affected Information Types and drill down further.", $masterinfotype_id); printf("

\n"); - printf("
"); - printf(""); - printf("
"); - printf("
"); - // Close table - printf("
"); + // Form to draw the delete button + printf("
\n"); + printf("\n"); + printf("\n", $masterinfotype_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); } + else if ($exists < 1) printf ("Master Information Type not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Master Information Type not found. Operation cancelled.
\n"); - - printf("
"); + msgTableClose(); } /********************************************************** Function: deleteMastersubject Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Delete the supplied master subject id, and removes @@ -1177,83 +819,38 @@ theoretically, the additional cascades here aren't necessary. **********************************************************/ -function deleteMastersubject($con, $mastersubject_id){ +function deleteMastersubject($mastersubject_id){ - // Draw form heading - printf("

Deleting Master Subject...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Master Subject (ID# " . $mastersubject_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($mastersubject_id > 1) { // Delete from sub_mastersubject - if ($problem == 0) { - $sql = "DELETE FROM sub_mastersubject WHERE mastersubject_id =" . $mastersubject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Affected subject-mastersubject assignments removed.
\n"); - } - } + $sql = "DELETE FROM sub_mastersubject WHERE mastersubject_id =" . $mastersubject_id; + if (xx_tryquery ($sql)) printf("Affected subject-mastersubject assignments removed.
\n"); // Delete from res_mastersubject - if ($problem == 0) { - $sql = "DELETE FROM res_mastersubject WHERE mastersubject_id =" . $mastersubject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Affected resource-mastersubject assignments removed.
\n"); - } - } + $sql = "DELETE FROM res_mastersubject WHERE mastersubject_id =" . $mastersubject_id; + if (xx_tryquery ($sql)) printf("Affected resource-mastersubject assignments removed.
\n"); // Delete from mastersubject table - if ($problem == 0) { - $sql = "DELETE FROM mastersubject WHERE mastersubject_id =" . $mastersubject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed Master Subject successfully.

\n"); - } - } + $sql = "DELETE FROM mastersubject WHERE mastersubject_id =" . $mastersubject_id; + if (xx_tryquery ($sql)) printf("Removed Master Subject successfully."); - } // mastersubject > 1 (cannot delete N/A). + } + else printf ("Cannot delete Master Subject ID# 1, it acts as a system placeholder."); - else printf("Cannot delete Master Subject ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteMastersubjectConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied mastersubject id. @@ -1263,25 +860,18 @@ link to the drilldown page and may not delete this mastersubject. **********************************************************/ -function deleteMastersubjectConfirm($con, $key_id){ +function deleteMastersubjectConfirm($key_id){ - // Make sure we have a valid integer type $mastersubject_id = (int) $key_id; - - // Draw page heading - printf("

Delete Master Subject ID# %s?

", $mastersubject_id); + msgTableOpen(1, "Delete Master Subject (ID# " . $mastersubject_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "mastersubject", "mastersubject_id", $mastersubject_id); + $exists = existsRow("mastersubject", "mastersubject_id", $mastersubject_id); if ($exists > 0 && $mastersubject_id > 2){ - // Table - printf(""); - printf("
"); - // Lookup the descriptive title - $mastersubject = lookupField($con, "mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); - printf("Master Subject: %s

\n ", $mastersubject); + $mastersubject = lookupField("mastersubject", "mastersubject_id", $mastersubject_id, "mastersubject"); + printf("Master Subject: %s

\n ", $mastersubject); // Determine whether any subjects or resources are affected $problem = 0; @@ -1289,69 +879,60 @@ // Check subjects $sql = "SELECT COUNT(sm.subject_id) as num_subjects FROM sub_mastersubject sm WHERE sm.mastersubject_id =" . $mastersubject_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $num_subjects = $row["num_subjects"]; if ($num_subjects > 0) $problem = 1; // Check resources - else { - // Check resources - $sql = "SELECT COUNT(rm.resource_id) as num_resources FROM res_mastersubject rm WHERE rm.mastersubject_id = " - . $mastersubject_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); - $num_resources = $row["num_resources"]; - - if ($num_resources > 1) $problem = 1; - } + $sql = "SELECT COUNT(rm.resource_id) as num_resources FROM res_mastersubject rm WHERE rm.mastersubject_id = " + . $mastersubject_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); + $num_resources = $row["num_resources"]; + if ($num_resources > 0) $problem = 1; // Proceed only if no subjects or resources are affected if ($problem == 0) { // Form to draw the delete button - printf("
"); - printf(""); - printf("", $mastersubject_id); - printf("This will permanently remove the Master Subject from the system. "); + printf("\n"); + printf("\n"); + printf("\n", $mastersubject_id); + printf("This will permanently remove the Master Subject from the system. "); printf("Are you sure you want to proceed?

\n"); - printf("
"); - printf(""); - printf("
"); - printf("

"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("\n"); } // There was a problem of some sort. else { printf("Dependencies were found. Master Subjects may not be deleted if there are resources or "); printf("specific subjects assigned to them. "); - printf("Examine the Master Subject Detail page.\n", $mastersubject_id); + printf("Examine the Master Subject Detail page.\n", $mastersubject_id); printf("

\n"); } - - // Close table - printf("
"); } + else if ($exists < 1) printf ("Master Subject not found. Operation cancelled.

\n"); + else if ($mastersubject_id < 3) printf("Master Subjects ID's #1 and #2 cannot be deleted.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Master Subject not found. Operation cancelled.
\n"); - else if ($mastersubject_id < 3) printf("Master Subjects #1 and #2 cannot be deleted.
\n"); - - printf("
"); + msgTableClose(); } /********************************************************** Function: deleteResFeature Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.02.2004 *********************************************************** Purpose: Deletes resource-feature associations based on the supplied feature id (possibly multiple) and calls formResource back again. **********************************************************/ -function deleteResFeature($con, $key_list_array, $resource_id){ +function deleteResFeature($key_list_array, $resource_id){ for ($element = 0; $element < sizeof($key_list_array); $element++) { @@ -1359,99 +940,66 @@ . $resource_id . " AND feature_id = " . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + xx_tryquery ($sql); } // Call the resource form back - formResource($con, $resource_id, 0, 0, ''); + formResource($resource_id, 0, 0, ''); } /********************************************************** Function: deleteResLoc Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.02.2004 *********************************************************** Purpose: Deletes resource-location associations based on the supplied location id (possibly multiple) and calls formResource back again. **********************************************************/ -function deleteResLoc($con, $key_list_array, $resource_id){ +function deleteResLoc($key_list_array, $resource_id){ for ($element = 0; $element < sizeof($key_list_array); $element++) { $sql = "DELETE FROM res_loc WHERE resource_id = " . $resource_id . " AND location_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + . $key_list_array[$element]; + xx_tryquery ($sql); } // Call the resource form back - formResource($con, $resource_id, 0, 0, ''); + formResource($resource_id, 0, 0, ''); } /********************************************************** Function: deleteResMastersubject Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.02.2004 *********************************************************** Purpose: Deletes resource-mastersubject associations based on the supplied mastersubject id (possibly multiple) and calls formResource back again. **********************************************************/ -function deleteResMastersubject($con, $key_list_array, $resource_id){ +function deleteResMastersubject($key_list_array, $resource_id){ for ($element = 0; $element < sizeof($key_list_array); $element++) { $sql = "DELETE FROM res_mastersubject WHERE resource_id = " . $resource_id . " AND mastersubject_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + . $key_list_array[$element]; + xx_tryquery ($sql); } // Call the resource form back - formResource($con, $resource_id, 0, 0, ''); + formResource($resource_id, 0, 0, ''); } /********************************************************** Function: deleteResource Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied resource id, and removes associations @@ -1461,253 +1009,117 @@ Page/CourseScribe pages to text-type fields (non-relational), as well as all user copy-paste buffers. **********************************************************/ -function deleteResource($con, $delMessage, $resource_id){ - - // Table - printf("
\n"); - printf("\n"); - - // Row header - printf("\n"); +function deleteResource($delMessage, $resource_id){ - // New row - printf("
\n"); - printf("Delete Messages"); - printf("
\n"); - - // Set up a problem flag. - $problem = 0; + msgTableOpen(1, "Deleting Resource (ID# " . $resource_id . ")"); + printf("Messages:
\n"); // First delete all related rows in res_sub_infotype $sql = "DELETE FROM res_sub_infotype WHERE resource_id = " . $resource_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - else { - xx_query ("UNLOCK TABLES", $con); - printf("Resource removed from all resource-subject-infotype assignments.
\n"); - - } + if (xx_tryquery ($sql)) printf("Resource removed from all resource-subject-infotype assignments.
\n"); // Delete from the res_loc table - if ($problem == 0) { - $sql = "DELETE FROM res_loc WHERE resource_id =" . $resource_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed from resource-location table.
\n"); - } - } + $sql = "DELETE FROM res_loc WHERE resource_id =" . $resource_id; + if (xx_tryquery ($sql)) printf("Removed from resource-location table.
\n"); // Delete from the res_mastersubject table - if ($problem == 0) { - - $sql = "DELETE FROM res_mastersubject WHERE resource_id =" . $resource_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed from resource-mastersubject table.
\n"); - } - } + $sql = "DELETE FROM res_mastersubject WHERE resource_id =" . $resource_id; + if (xx_tryquery ($sql)) printf("Removed from resource-mastersubject table.
\n"); // Delete from the res_feature table - if ($problem == 0) { - - $sql = "DELETE FROM res_feature WHERE resource_id =" . $resource_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed from resource-feature table.
\n"); - } - } + $sql = "DELETE FROM res_feature WHERE resource_id =" . $resource_id; + if (xx_tryquery ($sql)) printf("Removed from resource-feature table.
\n"); - // Update affected PageScribe pages - if ($problem == 0) { - - // First, get the default resource description and title - $sql = "SELECT annotation, title FROM resource WHERE resource_id = " - . $resource_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); - $annotation = $row["annotation"]; - $title = $row["title"]; - - // Clean up - $title = textInmySQL($title); - $annotation = textInmySQL($annotation); - $delMessage = textInmySQL($delMessage); - - // Next, append the reason for deletion to the annotation - if (strlen($annotation) > 0) $annotation .= "
" . $delMessage; - else $annotation = $delMessage; - - // Update all of the elements using this resource with a custom description. - $sql = "UPDATE element SET label = '" - . $title - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), resource_id = NULL WHERE resource_id =" . $resource_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions.
\n"); - } - - - // Next, update all of the elements using this resource without a custom description. - $sql = "UPDATE element SET label = '" - . $title - . "', element_descr = '" - . $annotation - . "', resource_id = NULL WHERE resource_id =" . $resource_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions.
\n"); - } - - - } - - - // Update affected PageScribe copy buffers - if ($problem == 0) { - - // Update all of the elements using this resource with a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $title - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), resource_id = NULL WHERE resource_id =" . $resource_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); - } - - - // Next, update all of the elements using this resource without a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $title - . "', element_descr = '" - . $annotation - . "', resource_id = NULL WHERE resource_id =" . $resource_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions (buffers).
\n"); - } - - - } + /******************************** + ** Update affected CL/PS pages ** + ********************************/ + + // First, get the default resource description and title + $sql = "SELECT annotation, title FROM resource WHERE resource_id = " + . $resource_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); + $annotation = $row["annotation"]; + $title = $row["title"]; + + // Clean up + $title = textInmySQL($title); + $annotation = textInmySQL($annotation); + $delMessage = textInmySQL($delMessage); + + // Next, append the reason for deletion to the annotation + if (strlen($annotation) > 0) $annotation .= "
" . $delMessage; + else $annotation = $delMessage; + + // Update all of the elements using this resource with a custom description. + $sql = "UPDATE element SET label = '" + . $title + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), resource_id = NULL WHERE resource_id =" . $resource_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.
\n"); + + // Next, update all of the elements using this resource without a custom description. + $sql = "UPDATE element SET label = '" + . $title + . "', element_descr = '" + . $annotation + . "', resource_id = NULL WHERE resource_id =" . $resource_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.
\n"); + + /*************************************** + ** Update affected CL/PS copy buffers ** + ***************************************/ + + // Update all of the elements using this resource with a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $title + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), resource_id = NULL WHERE resource_id =" . $resource_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); + + // Next, update all of the elements using this resource without a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $title + . "', element_descr = '" + . $annotation + . "', resource_id = NULL WHERE resource_id =" . $resource_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).
\n"); + + // Delete from the resource table + $sql = "DELETE FROM resource WHERE resource_id =" . $resource_id; + if (xx_tryquery ($sql)) printf("Successfully removed from all tables."); - - // Delete from the resource table - if ($problem == 0) { - - $sql = "DELETE FROM resource WHERE resource_id =" . $resource_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - else { - xx_query ("UNLOCK TABLES", $con); - } - } - - if ($problem == 0) printf("Successfully removed from all tables.

\n"); - - printf("
\n"); - printf("

\n"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteResourceConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied resource id. **********************************************************/ -function deleteResourceConfirm($con, $resource_id){ +function deleteResourceConfirm($resource_id){ - // Make sure we have a valid integer type $resource_id = (int) $resource_id; - - printf("
\n"); + msgTableOpen(1, "Delete Resource (ID# " . $resource_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "resource", "resource_id", $resource_id); + $exists = existsRow("resource", "resource_id", $resource_id); if ($exists > 0){ - // Table - printf("\n"); - - // Row header - printf("\n"); - printf("
\n"); - printf("Delete Resource ID# %s?", $resource_id); - printf("
\n"); - // Lookup the title & author - $title = lookupField($con, "resource", "resource_id", $resource_id, "title"); - $author = lookupField($con, "resource", "resource_id", $resource_id, "author"); + $title = lookupField("resource", "resource_id", $resource_id, "title"); + $author = lookupField("resource", "resource_id", $resource_id, "author"); printf("Title: %s
\n ", $title); printf("Author: %s

\n ", $author); @@ -1724,30 +1136,24 @@ printf("

\n"); // Warning - printf("This will permanently remove the resource and its various assignments from the system.

\n"); + printf("This will permanently remove the resource and its various assignments from the system.

\n"); // Delete button printf("
\n"); printf("\n"); printf("
\n"); - printf("
\n"); - - // Close table - printf("
\n"); - printf("
\n"); + printf("\n"); } + else if ($exists < 1) printf ("Resource not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Resource #%d not found. Operation cancelled.

\n", $resource_id); - - printf("
\n"); + msgTableClose(); } /********************************************************** Function: deleteService Author: Paul Bramscher -Last Modified: 05.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied service id, and removes associations @@ -1756,219 +1162,109 @@ Page/CourseScribe pages to text-type fields (non-relational), as well as all user copy-paste buffers. **********************************************************/ -function deleteService($con, $delMessage, $service_id){ - - // Table - printf("
\n"); - printf("\n"); - - // Row header - printf("\n"); - - // New row - printf("
\n"); - printf("Delete Messages"); - printf("
\n"); +function deleteService($delMessage, $service_id){ - // Set up a problem flag. - $problem = 0; + msgTableOpen(1, "Deleting Service (ID# " . $service_id . ")"); + printf("Messages:
\n"); // First delete all related rows in serv_servtype $sql = "DELETE FROM serv_servtype WHERE service_id = " . $service_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - else { - xx_query ("UNLOCK TABLES", $con); - printf("Service removed from all service-servicetype assignments.
\n"); - - } + if (xx_tryquery ($sql)) printf("Service removed from all service-servicetype assignments.
\n"); // Delete from the serv_loc table - if ($problem == 0) { - $sql = "DELETE FROM serv_loc WHERE service_id =" . $service_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed from service-location table.
\n"); - } - } - - - // Update affected PageScribe pages - if ($problem == 0) { - - // First, get the default service description and title - $sql = "SELECT service, serviceDescr FROM service WHERE service_id = " - . $service_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); - $service = $row["service"]; - $serviceDescr = $row["serviceDescr"]; - - // Clean up strings - $service = textInmySQL($service); - $serviceDescr = textInmySQL($serviceDescr); - $delMessage = textInmySQL($delMessage); - - // Next, append the reason for deletion to the annotation - if (strlen($serviceDescr) > 0) $serviceDescr .= "
" . $delMessage; - else $serviceDescr = $delMessage; - - // Update all of the elements using this service with a custom description. - $sql = "UPDATE element SET label = '" - . $service - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), service_id = NULL WHERE service_id =" . $service_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions.
\n"); - } + $sql = "DELETE FROM serv_loc WHERE service_id =" . $service_id; + if (xx_tryquery ($sql)) printf("Removed from service-location table.
\n"); + /******************************** + ** Update affected CL/PS pages ** + ********************************/ + + // First, get the default service description and title + $sql = "SELECT service, serviceDescr FROM service WHERE service_id = " + . $service_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); + $service = $row["service"]; + $serviceDescr = $row["serviceDescr"]; + + // Clean up strings + $service = textInmySQL($service); + $serviceDescr = textInmySQL($serviceDescr); + $delMessage = textInmySQL($delMessage); + + // Next, append the reason for deletion to the annotation + if (strlen($serviceDescr) > 0) $serviceDescr .= "
" . $delMessage; + else $serviceDescr = $delMessage; + + // Update all of the elements using this service with a custom description. + $sql = "UPDATE element SET label = '" + . $service + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), service_id = NULL WHERE service_id =" . $service_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.
\n"); + + // Next, update all of the elements using this service without a custom description. + $sql = "UPDATE element SET label = '" + . $service + . "', element_descr = '" + . $serviceDescr + . "', service_id = NULL WHERE service_id =" . $service_id + . " AND (element_descr IS NULL OR element_descr = '')"; + + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.
\n"); + + /*************************************** + ** Update affected CP/PS copy buffers ** + ***************************************/ + + // Update all of the elements using this service with a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $service + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), service_id = NULL WHERE service_id =" . $service_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); + + // Next, update all of the elements using this service without a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $service + . "', element_descr = '" + . $serviceDescr + . "', service_id = NULL WHERE service_id =" . $service_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).
\n"); + + // Delete from the service table + $sql = "DELETE FROM service WHERE service_id =" . $service_id; + if (xx_tryquery ($sql)) printf("Successfully removed from all tables."); - // Next, update all of the elements using this service without a custom description. - $sql = "UPDATE element SET label = '" - . $service - . "', element_descr = '" - . $serviceDescr - . "', service_id = NULL WHERE service_id =" . $service_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions.
\n"); - } - - - } - - - // Update affected PageScribe copy buffers - if ($problem == 0) { - - // Update all of the elements using this service with a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $service - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), service_id = NULL WHERE service_id =" . $service_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); - } - - - // Next, update all of the elements using this service without a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $service - . "', element_descr = '" - . $serviceDescr - . "', service_id = NULL WHERE service_id =" . $service_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions (buffers).
\n"); - } - - - } - - - // Delete from the service table - if ($problem == 0) { - - $sql = "DELETE FROM service WHERE service_id =" . $service_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - else { - xx_query ("UNLOCK TABLES", $con); - } - } - - if ($problem == 0) printf("Successfully removed from all tables.

\n"); - - printf("
\n"); - printf("

\n"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteServiceConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied service id. **********************************************************/ -function deleteServiceConfirm($con, $key_id){ +function deleteServiceConfirm($key_id){ - // Make sure we have a valid integer type $service_id = (int) $key_id; - - printf("
\n"); + msgTableOpen(1, "Delete Service (ID# " . $service_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "service", "service_id", $service_id); + $exists = existsRow("service", "service_id", $service_id); if ($exists > 0){ - // Table - printf("\n"); - - // Row header - printf("\n"); - printf("
\n"); - printf("Delete Service ID# %s?", $service_id); - printf("
\n"); - // Lookup the descriptive title - $service = lookupField($con, "service", "service_id", $service_id, "service"); + $service = lookupField("service", "service_id", $service_id, "service"); printf("Service: %s

\n ", $service); // Form to draw the delete button @@ -1981,141 +1277,104 @@ printf("

\n"); // Warning - printf("This will permanently remove the service and its various assignments from the system.

\n"); + printf("This will permanently remove the service and its various assignments from the system.

\n"); // Delete button printf("
\n"); printf("\n"); printf("
\n"); - printf("
\n"); - - // Close table - printf("
\n"); - printf("
\n"); + printf("\n"); } + else if ($exists < 1) printf ("Service not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Service #%d not found. Operation cancelled.

\n", $service_id); - - printf("
\n"); + msgTableClose(); } /********************************************************** Function: deleteServicetype Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.15.2004 *********************************************************** Purpose: Delete the supplied service type id. This will render some services without a type, but this does not break anything. **********************************************************/ -function deleteServicetype($con, $servicetype_id){ +function deleteServicetype($servicetype_id){ - // Draw form heading - printf("

Deleting Service Type...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); + msgTableOpen(1, "Deleting Service Type (ID# " . $servicetype_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($servicetype_id > 1) { + + // Delete from serv_servtype table + $sql = "DELETE FROM serv_servtype WHERE servicetype_id =" . $servicetype_id; + if (xx_tryquery ($sql)) printf("Removed Service-Service Type associations.
\n"); // Delete from servicetype table $sql = "DELETE FROM servicetype WHERE servicetype_id =" . $servicetype_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed Service Type successfully.

\n"); - } + if (xx_tryquery ($sql)) printf("Removed Service Type successfully."); } + else printf ("Cannot delete Service Type ID# 1, it acts as a system placeholder."); - else printf("Cannot delete Service Type ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteServicetypeConfirm Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied service type id. **********************************************************/ -function deleteServicetypeConfirm($con, $key_id){ +function deleteServicetypeConfirm($key_id){ - // Make sure we have a valid integer type $servicetype_id = (int) $key_id; - - printf("
\n"); + msgTableOpen(1, "Delete Service Type (ID# " . $servicetype_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "servicetype", "servicetype_id", $servicetype_id); + $exists = existsRow("servicetype", "servicetype_id", $servicetype_id); if ($exists > 0){ - // Table - printf("\n"); - - // Row header - printf("\n"); - printf("
\n"); - printf("Delete Service Type ID# %s?", $servicetype_id); - printf("
\n"); - // Lookup the descriptive title - $servicetype = lookupField($con, "servicetype", "servicetype_id", $servicetype_id, "servicetype"); + $servicetype = lookupField("servicetype", "servicetype_id", $servicetype_id, "servicetype"); printf("Service Type: %s

\n ", $servicetype); + printf("This will permanently remove this Service Type. Note that Services which rely exclusively on this Service Type will be left without a Service Type.

\n"); // Form to draw the delete button printf("
\n"); printf("\n"); printf("\n", $servicetype_id); - // Warning - printf("This will permanently remove this Service Type. Note that Services which rely exlusively on this Service Type will be left without a Service Type.

\n"); - // Delete button printf("
\n"); printf("\n"); printf("
\n"); - printf("

\n"); - - // Close table - printf("
\n"); - printf("
\n"); + printf("\n"); } + else if ($exists < 1) printf ("Service Type not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Service Type #%d not found. Operation cancelled.

\n", $servicetype_id); - - printf("
\n"); + msgTableClose(); } /********************************************************** Function: deleteServLoc Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.02.2004 *********************************************************** Purpose: Deletes service-location associations based on the supplied location id (possibly multiple) and calls formService back again. **********************************************************/ -function deleteServLoc($con, $key_list_array, $service_id){ +function deleteServLoc($key_list_array, $service_id){ for ($element = 0; $element < sizeof($key_list_array); $element++) { @@ -2123,35 +1382,24 @@ . $service_id . " AND location_id = " . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + xx_tryquery ($sql); } // Call the service form back - formService($con, $service_id, 0, 0); + formService($service_id, 0, 0); } /********************************************************** Function: deleteServServtype Author: Paul Bramscher -Last Modified: 04.21.2003 +Last Modified: 03.02.2004 *********************************************************** Purpose: Deletes service-servicetype associations based on the supplied servicetype id (possibly multiple) and calls formService back again. **********************************************************/ -function deleteServServtype($con, $key_list_array, $service_id){ +function deleteServServtype($key_list_array, $service_id){ for ($element = 0; $element < sizeof($key_list_array); $element++) { @@ -2159,650 +1407,17 @@ . $service_id . " AND servicetype_id = " . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + xx_tryquery ($sql); } // Call the service form back - formService($con, $service_id, 0, 0); -} - - -/********************************************************** -Function: deleteSubCoursesub -Author: Paul Bramscher -Last Modified: 06.04.2003 -*********************************************************** -Purpose: -Deletes subject-coursesub associations based on the supplied -coursesub id (possibly multiple) and calls formSubject back -again. -**********************************************************/ -function deleteSubCoursesub($con, $key_list_array, $subject_id){ - - // For the given subject, delete every location in the array - for ($element = 0; $element < sizeof($key_list_array); $element++) { - - $sql = "DELETE FROM sub_coursesub WHERE subject_id = " - . $subject_id - . " AND coursesub_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } - } - // Call the subject form back - formSubject($con, $subject_id); -} - - -/********************************************************** -Function: deleteSubject -Author: Paul Bramscher -Last Modified: 06.17.2003 -*********************************************************** -Purpose: -Deletes a subject, and removes associations in the -resource-subject-informationtype, subject-location, -subject-mastersubject, subject-coursesub, and -subject-staff tables. -**********************************************************/ -function deleteSubject($con, $delMessage, $subject_id){ - - // Draw form heading - printf("

Deleting Subject...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; - - // Cannot delete placeholder #1 - if ($subject_id > 1) { - // First delete all related rows in res_sub_infotype - $sql = "DELETE FROM res_sub_infotype WHERE subject_id = " . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Resource-subject-information type associations removed.
\n"); - } - - // Delete from the sub_loc table - if ($problem == 0) { - $sql = "DELETE FROM sub_loc WHERE subject_id =" . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-location associations removed.
\n"); - } - } - - // Delete from the sub_mastersubject table - if ($problem == 0) { - $sql = "DELETE FROM sub_mastersubject WHERE subject_id =" . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-mastersubject associations removed.
\n"); - - } - } - - // Delete from the sub_staff table - if ($problem == 0) { - $sql = "DELETE FROM sub_staff WHERE subject_id =" . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-staff assignments removed.
\n"); - - } - } - - // Delete from the sub_coursesub table - if ($problem == 0) { - $sql = "DELETE FROM sub_coursesub WHERE subject_id =" . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-Course Subject assignments removed.
\n"); - - } - } - - // Delete from the sub_page table - if ($problem == 0) { - $sql = "DELETE FROM sub_page WHERE subject_id =" . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-Page assignments removed.
\n"); - - } - } - - // Delete from the sub_othersub table - if ($problem == 0) { - $sql = "DELETE FROM sub_othersub WHERE othersub_id =" - . $subject_id - . " OR subject_id = " - . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Subject-Other Subject assignments removed.
\n"); - - } - } - - // Update affected PageScribe pages - if ($problem == 0) { - - // First, get the default subject description and title - $sql = "SELECT subject, subject_descr FROM subject WHERE subject_id = " - . $subject_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); - $subject = $row["subject"]; - $subject_descr = $row["subject_descr"]; - - // Clean up strings - $subject_descr = textInmySQL($subject_descr); - $subject = textInmySQL($subject); - $delMessage = textInmySQL($delMessage); - - // Next, append the reason for deletion to the description - if (strlen($subject_descr) > 0) $subject_descr .= "
" . $delMessage; - else $subject_descr = $delMessage; - - // Update all of the elements using this resource with a custom description. - $sql = "UPDATE element SET label = '" - . $subject - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), subject_id = NULL WHERE subject_id =" . $subject_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions.
\n"); - } - - - // Next, update all of the elements using this resource without a custom description. - $sql = "UPDATE element SET label = '" - . $subject - . "', element_descr = '" - . $subject_descr - . "', subject_id = NULL WHERE subject_id =" . $subject_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions.
\n"); - } - - - } - - - // Update affected PageScribe copy buffers - if ($problem == 0) { - - // Update all of the elements using this location with a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $subject - . "', element_descr = CONCAT(element_descr, '
" - . $delMessage - . "'), subject_id = NULL WHERE subject_id =" . $subject_id - . " AND (element_descr IS NOT NULL OR element_descr != '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); - } - - - // Next, update all of the elements using this location without a custom description. - $sql = "UPDATE pastebuffer SET label = '" - . $subject - . "', element_descr = '" - . $subject_descr - . "', subject_id = NULL WHERE subject_id =" . $subject_id - . " AND (element_descr IS NULL OR element_descr = '')"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to default PageScribe descriptions (buffers).
\n"); - } - - - } - - // Finally delete from the subject table - if ($problem == 0) { - $sql = "DELETE FROM subject WHERE subject_id =" . $subject_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Successfully removed this subject from the system.

\n"); - - } - } - } - else printf("Cannot delete Subject ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); -} - - -/********************************************************** -Function: deleteSubjectConfirm -Author: Paul Bramscher -Last Modified: 06.11.2003 -*********************************************************** -Purpose: -Confirm prompt to delete the supplied subject id. -**********************************************************/ -function deleteSubjectConfirm($con, $key_id){ - - // Make sure we have a valid integer type - $subject_id = (int) $key_id; - - // Draw page heading - printf("

Delete Subject ID# %s?

", $subject_id); - - // Check to see if its possible - $exists = existsRow($con, "subject", "subject_id", $subject_id); - if ($exists > 0){ - - // Table - printf(""); - printf("
"); - - // Lookup the descriptive title - $subject = lookupField($con, "subject", "subject_id", $subject_id, "subject"); - printf("Subject: %s

\n ", $subject); - - // Form to draw the delete button - printf("
"); - printf(""); - printf("", $subject_id); - - // Delete message - printf("Message to appear on affected PageScribe Pages (75 char max.):
\n"); - printf("

\n"); - - printf("This will permanently remove the subject and its various subject assignments from the system. - This includes assignments to resources, master/general subjects, locations and staff specialists.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); - - // Close table - printf("
"); - } - - // Failed for whatever reason - else if ($exists < 1) printf ("Subject not found. Operation cancelled.
\n"); - - printf("
"); -} - - -/********************************************************** -Function: deleteSubLoc -Author: Paul Bramscher -Last Modified: 04.21.2003 -*********************************************************** -Purpose: -Deletes subject-location associations based on the supplied -location id (possibly multiple) and calls formSubject back -again. -**********************************************************/ -function deleteSubLoc($con, $key_list_array, $subject_id){ - - // For the given subject, delete every location in the array - for ($element = 0; $element < sizeof($key_list_array); $element++) { - - $sql = "DELETE FROM sub_loc WHERE subject_id = " - . $subject_id - . " AND location_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } - } - // Call the subject form back - formSubject($con, $subject_id); -} - - -/********************************************************** -Function: deleteSubMaster -Author: Paul Bramscher -Last Modified: 04.21.2003 -*********************************************************** -Purpose: -Deletes subject-mastersubject associations based on the -supplied mastersubject id (possibly multiple) and calls -formSubject back again. -**********************************************************/ -function deleteSubMaster($con, $key_list_array, $subject_id){ - - // For every mastersubject in the array, delete it from the bridging table - for ($element = 0; $element < sizeof($key_list_array); $element++) { - - $sql = "DELETE FROM sub_mastersubject WHERE subject_id = " - . $subject_id - . " AND mastersubject_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } - } - // Call the subject form back - formSubject($con, $subject_id); -} - - -/********************************************************** -Function: deleteSubStaff -Author: Paul Bramscher -Last Modified: 04.21.2003 -*********************************************************** -Purpose: -Deletes staff-subject associations for the supplied staff -id (possibly multiple) and calls formSubject back again. -**********************************************************/ -function deleteSubStaff($con, $key_list_array, $subject_id){ - - // For a given subject, delete all staff in the array - for ($element = 0; $element < sizeof($key_list_array); $element++) { - - $sql = "DELETE FROM sub_staff WHERE subject_id = " - . $subject_id - . " AND staff_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } - } - // Call the subject form back - formSubject($con, $subject_id); -} - - -/********************************************************** -Function: deleteLibunit -Author: Paul Bramscher -Last Modified: 04.29.2003 -*********************************************************** -Purpose: -Deletes the supplied libunit id, and any staff assignments -in that library unit. -**********************************************************/ -function deleteLibunit($con, $libunit_id){ - - // Draw form heading - printf("

Deleting Library Unit...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; - - // First delete from libunit_staff - if ($libunit_id > 1) { - $sql = "DELETE FROM libunit_staff WHERE libunit_id = " . $libunit_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Deleted all Library Unit staff assignments.
\n"); - } - - // Delete from the libunit table - if ($problem == 0) { - $sql = "DELETE FROM libunit WHERE libunit_id =" . $libunit_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this Library Unit successfully.

\n"); - } - } - - } - else printf("Cannot delete Library Unit ID #1. It acts as a system placeholder..

\n"); - - printf("
\n"); - printf("
\n"); -} - - -/********************************************************** -Function: deleteLibunitConfirm -Author: Paul Bramscher -Last Modified: 04.29.2003 -*********************************************************** -Purpose: -Confirm prompt for deleting the supplied libunit id. -**********************************************************/ -function deleteLibunitConfirm($con, $key_id){ - - // Make sure we have a valid integer type - $libunit_id = (int) $key_id; - - // Draw page heading - printf("

Delete Libunit ID# %s?

", $libunit_id); - - // Check to see if its possible - $exists = existsRow($con, "libunit", "libunit_id", $libunit_id); - if ($exists > 0){ - - // Table - printf(""); - printf("
"); - - // Lookup the descriptive title - $libunit = lookupField($con, "libunit", "libunit_id", $libunit_id, "libunit"); - printf("Libunit: %s
\n ", $libunit); - - // Form to draw the delete button - printf("
"); - printf(""); - printf("", $libunit_id); - printf("This will permanently remove this Library Unit from the system. This may render some staff without a unit.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); - - // Close table - printf("
"); - } - - // Failed for whatever reason - else if ($exists < 1) printf ("Unit not found. Operation cancelled.
\n"); - - printf("
"); -} - - -/********************************************************** -Function: deleteLibunitStaff -Author: Paul Bramscher -Last Modified: 12.09.2002 -*********************************************************** -Purpose: -Deletes staffperson assignments (possibly multiple) to the -supplied libunit id and calls formLibunit back again. -**********************************************************/ -function deleteLibunitStaff($con, $key_list_array, $libunit_id){ - - for ($element = 0; $element < sizeof($key_list_array); $element++) { - $sql = "DELETE FROM libunit_staff WHERE libunit_id = " - . $libunit_id - . " AND staff_id = " - . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } - } - // Call the libunit form back - formLibunit($con, $libunit_id); + formService($service_id, 0, 0); } /********************************************************** Function: deleteStaff Author: Paul Bramscher -Last Modified: 04.29.2003 +Last Modified: 03.15.2004 *********************************************************** Purpose: Deletes the supplied staff id. This function purges the @@ -2811,79 +1426,35 @@ intoto text-type fields (non-relational). The same is done across all user copy-paste buffers. **********************************************************/ -function deleteStaff($con, $delMessage, $staff_id){ +function deleteStaff($delMessage, $staff_id){ - // Draw form heading - printf("

Deleting Staff Person...

"); + msgTableOpen(1, "Deleting Staff (ID# " . $staff_id . ")"); + printf("Messages:
\n"); - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Success flag for each delete step - // Can't delete myself (#2) or the '(N/A)' staff (#1) - if ($staff_id < 3) $problem = 2; - else $problem = 0; + // Can't delete admin account (#2) or the '(N/A)' staff (#1) + if ($staff_id > 2) { - // First delete all related rows in sub_staff - if ($problem == 0) { - + // First delete all related rows in sub_staff $sql = "DELETE FROM sub_staff WHERE staff_id = " . $staff_id; + if (xx_tryquery ($sql)) printf("All subject-staff assignments for this staff person removed.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("All subject-staff assignments for this staff person removed.
\n"); - } - } - - // Delete from the course_personnel table - if ($problem == 0) { + // Delete from the course_personnel table $sql = "DELETE FROM course_personnel WHERE staff_id =" . $staff_id; + if (xx_tryquery ($sql)) printf("Removed this staff person from course personnel tables.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this staff person from course personnel tables.
\n"); - } - } // delete from course_personnel table - - // Delete all related rows in page_staff - if ($problem == 0) { - + // Delete all related rows in page_staff $sql = "DELETE FROM page_staff WHERE staff_id = " . $staff_id; + if (xx_tryquery ($sql)) printf("All page-staff assignments for this staff person removed.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("All page-staff assignments for this staff person removed.
\n"); - } - } - - // Update affected PageScribe pages - if ($problem == 0) { + /******************************** + ** Update affected CL/PS pages ** + ********************************/ // First, get the staff fields $sql = "SELECT first_name, last_name FROM staff WHERE staff_id = " . $staff_id; - $rs = xx_query($sql, $con); - $row = xx_fetch_array ($rs); + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); $first_name = $row["first_name"]; $last_name = $row["last_name"]; @@ -2903,44 +1474,20 @@ . $delMessage . "'), staff_id = NULL WHERE staff_id =" . $staff_id . " AND element_descr IS NOT NULL AND element_descr <> ''"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions.
\n"); - } - } - - // Handle blank staff description elements - if ($problem == 0) { - + // Handle blank staff description elements $sql = "UPDATE element SET label = '" . $staff_name . "', element_descr = '" . $delMessage . "', staff_id = NULL WHERE staff_id =" . $staff_id . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to blank PageScribe descriptions.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to blank PageScribe descriptions.
\n"); - } - - } - - // Update affected PageScribe buffers - if ($problem == 0) { + /********************************** + ** Update affected CL/PS buffers ** + **********************************/ // Update all of the elements using this staffperson with a custom description $sql = "UPDATE pastebuffer SET label = '" @@ -2949,63 +1496,25 @@ . $delMessage . "'), staff_id = NULL WHERE staff_id =" . $staff_id . " AND element_descr IS NOT NULL AND element_descr <> ''"; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to custom PageScribe descriptions.
\n"); - } - } + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.
\n"); - // Handle blank staff description pastebuffer elements - if ($problem == 0) { - + // Handle blank staff description pastebuffer elements $sql = "UPDATE pastebuffer SET label = '" . $staff_name . "', element_descr = '" . $delMessage . "', staff_id = NULL WHERE staff_id =" . $staff_id . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to blank PageScribe descriptions.
\n"); - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Added delete message to blank PageScribe descriptions.
\n"); - } - - } - - // Delete from the staff table - if ($problem == 0) { + // Delete from the staff table $sql = "DELETE FROM staff WHERE staff_id =" . $staff_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this staff person successfully.

\n"); - } - } // delete from staff table - - if ($problem == 2) printf("Cannot delete Staff ID's #1-2.

\n"); - - // Close the table - printf("
\n"); - printf("

\n"); + if (xx_tryquery ($sql)) printf("Removed this staff person successfully."); + } + else printf ("Cannot delete Staff ID's #1-2. Operation cancelled."); + + printf("

\n"); + msgTableClose(); } // end function @@ -3013,7 +1522,7 @@ /********************************************************** Function: deleteStaffConfirm Author: Paul Bramscher -Last Modified: 04.29.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt to delete the supplied staff id. This @@ -3022,29 +1531,18 @@ as the staffperson is converted from a relational to a text-type element. **********************************************************/ -function deleteStaffConfirm($con, $staff_id){ +function deleteStaffConfirm($staff_id){ - // Make sure we have a valid integer type $staff_id = (int) $staff_id; - - printf("
\n"); + msgTableOpen(1, "Delete Staff (ID# " . $staff_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "staff", "staff_id", $staff_id); + $exists = existsRow("staff", "staff_id", $staff_id); if ($exists > 0){ - // Table - printf("\n"); - - // Row header - printf("\n"); - printf("
\n"); - printf("Delete Staff ID# %s?", $staff_id); - printf("
\n"); - // Lookup the first and last names - $first_name = lookupField($con, "staff", "staff_id", $staff_id, "first_name"); - $last_name = lookupField($con, "staff", "staff_id", $staff_id, "last_name"); + $first_name = lookupField("staff", "staff_id", $staff_id, "first_name"); + $last_name = lookupField("staff", "staff_id", $staff_id, "last_name"); printf("Staffperson: %s %s

\n ", $first_name, $last_name); // Form to draw the delete button @@ -3057,30 +1555,24 @@ printf("

\n"); // Warning - printf("This will permanently remove this staffperson and his/her various assignments from the system.

\n"); + printf("This will permanently remove this staffperson and his/her various assignments from the system.

\n"); // Delete button printf("
\n"); printf("\n"); printf("
\n"); - printf("
\n"); - - // Close table - printf("
\n"); - printf("
\n"); + printf("\n"); } + else if ($exists < 1) printf ("Staffperson not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Staff #%d not found. Operation cancelled.

\n", $staff_id); - - printf("
\n"); + msgTableClose(); } /********************************************************** Function: deleteStaffLibunit Author: Paul Bramscher -Last Modified: 12.09.2002 +Last Modified: 03.03.2004 *********************************************************** Purpose: Delete the staff-libunit associations (possibly multiple) @@ -3088,7 +1580,7 @@ This works the same table as deleteLibunitStaff, but with emphasis on the other side of the multiple pick list. **********************************************************/ -function deleteStaffLibunit($con, $key_list_array, $staff_id){ +function deleteStaffLibunit($key_list_array, $staff_id){ // For every libunit in the array, delete it from the bridging table for ($element = 0; $element < sizeof($key_list_array); $element++) { @@ -3097,28 +1589,17 @@ . $staff_id . " AND libunit_id = " . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + xx_tryquery($sql); } // Call the staff form back - formStaff($con, $staff_id); + formStaff($staff_id); } /********************************************************** Function: deleteStaffSub Author: Paul Bramscher -Last Modified: 04.29.2003 +Last Modified: 03.03.2004 *********************************************************** Purpose: Deletes the staff-subject associations (possibly multiple) @@ -3127,7 +1608,7 @@ application.php, not this ssl counterpart), but with emphasis on the other side of the multiple pick list. **********************************************************/ -function deleteStaffSub($con, $key_list_array, $staff_id){ +function deleteStaffSub($key_list_array, $staff_id){ // For a given staff person, delete every associated subject in the array for ($element = 0; $element < sizeof($key_list_array); $element++) { @@ -3136,138 +1617,85 @@ . $staff_id . " AND subject_id = " . $key_list_array[$element]; - - // Failed - if (!xx_query ($sql, $con)){ - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - - // Succeeded - else { - xx_query ("UNLOCK TABLES", $con); - } + xx_tryquery($sql); } // Call the staff form back - formStaff($con, $staff_id); + formStaff($staff_id); } /********************************************************** Function: deleteStafftitle Author: Paul Bramscher -Last Modified: 04.29.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied staff job title id. Any staff currently using this title are set to the (N/A) placeholder title. **********************************************************/ -function deleteStafftitle($con, $stafftitle_id){ - - // Draw form heading - printf("

Deleting Job Title...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); +function deleteStafftitle($stafftitle_id){ - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Staff Title (ID# " . $stafftitle_id . ")"); + printf("Messages:
\n"); - // First update all rows in staff to (N/A) if ($stafftitle_id > 1) { + // First update all rows in staff to (N/A) $sql = "UPDATE staff SET stafftitle_id = 1 WHERE stafftitle_id = " . $stafftitle_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Successfully set affected staff person job titles to (N/A).
\n"); - } + if (xx_tryquery ($sql)) printf("Successfully set affected staff titles to (N/A).
\n"); // Delete from the title table - if ($problem == 0) { - $sql = "DELETE FROM stafftitle WHERE stafftitle_id =" . $stafftitle_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this job title successfully.

\n"); - } - } + $sql = "DELETE FROM stafftitle WHERE stafftitle_id =" . $stafftitle_id; + if (xx_tryquery ($sql)) printf("Removed this staff title successfully."); } - else printf("Cannot delete Job Title ID #1. It acts as a system placeholder..

\n"); - - printf("
"); - printf("
"); + else printf ("Cannot delete Staff Title ID# 1, it acts as a system placeholder."); + + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteStafftitleConfirm Author: Paul Bramscher -Last Modified: 04.29.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the supplied staff title id. **********************************************************/ -function deleteStafftitleConfirm($con, $key_id){ +function deleteStafftitleConfirm($key_id){ - // Make sure we have a valid integer type $stafftitle_id = (int) $key_id; - - // Draw page heading - printf("

Delete Job Title ID# %s?

\n", $stafftitle_id); + msgTableOpen(1, "Delete Staff Title (ID# " . $stafftitle_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "stafftitle", "stafftitle_id", $stafftitle_id); + $exists = existsRow("stafftitle", "stafftitle_id", $stafftitle_id); if ($exists > 0){ - // Table - printf("\n"); - printf("
\n"); - // Lookup the descriptive title - $stafftitle = lookupField($con, "stafftitle", "stafftitle_id", $stafftitle_id, "stafftitle"); - printf("Staff Title: %s
\n ", $stafftitle); + $stafftitle = lookupField("stafftitle", "stafftitle_id", $stafftitle_id, "stafftitle"); + printf("Staff Title: %s

\n ", $stafftitle); + printf("This will permanently remove this staff title and its various assignments from the system. Some staff will be set to (N/A).

\n"); // Form to draw the delete button printf("
\n"); printf("\n"); - printf("\n", $stafftitle_id); - printf("
This will permanently remove this job title and its various assignments from the system. Some staff will be set to (N/A).

\n"); + printf("\n", $stafftitle_id); printf("
\n"); printf("\n"); printf("
\n"); - printf("

\n"); - - // Close table - printf("
"); + printf("\n"); } + else if ($exists < 1) printf ("Staff Title not found. Operation cancelled.

\n"); - // Failed for whatever reason - else if ($exists < 1) printf ("Job title not found. Operation cancelled.
\n"); - - printf("
\n"); + msgTableClose(); } /********************************************************** Function: deleteStyle Author: Paul Bramscher -Last Modified: 05.22.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied style id. Any pages currently @@ -3275,226 +1703,477 @@ Note that the actual header, footer, and css files are not deleted -- only the references to them. **********************************************************/ -function deleteStyle($con, $style_id){ - - // Draw form heading - printf("

Deleting Style...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); +function deleteStyle($style_id){ - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Style (ID# " . $style_id . ")"); + printf("Messages:
\n"); - // First update all affected rows in page to (N/A) if ($style_id > 2) { + // First update all affected rows in page to (N/A) $sql = "UPDATE page SET style_id = 1 WHERE style_id = " . $style_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Successfully set affected page styles to (N/A).
\n"); - } + if (xx_tryquery ($sql)) printf("Successfully set affected page styles to (N/A).
\n"); // Delete from the style table - if ($problem == 0) { - $sql = "DELETE FROM style WHERE style_id =" . $style_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this style successfully.

\n"); - } - } + $sql = "DELETE FROM style WHERE style_id =" . $style_id; + if (xx_tryquery ($sql)) printf("Removed this style successfully."); } else { - printf("Cannot delete Style ID #1-2. #1 acts as a system placeholder, #2 "); + printf("Cannot delete Style ID's #1 and #2. #1 acts as a system placeholder, #2 "); printf("is the default style for new pages, but may be renamed or redefined as "); - printf("needed .

\n"); + printf("needed."); } - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteStyleConfirm Author: Paul Bramscher -Last Modified: 05.22.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the supplied style id **********************************************************/ -function deleteStyleConfirm($con, $key_id){ +function deleteStyleConfirm($key_id){ - // Make sure we have a valid integer type $style_id = (int) $key_id; - - // Draw page heading - printf("

Delete Style ID# %s?

\n", $style_id); + msgTableOpen(1, "Delete Style (ID# " . $style_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "style", "style_id", $style_id); + $exists = existsRow("style", "style_id", $style_id); if ($exists > 0){ - // Table - printf("\n"); - printf("
\n"); - // Lookup the descriptive title - $style_title = lookupField($con, "style", "style_id", $style_id, "style_title"); - printf("Style Title: %s
\n ", $style_title); + $style_title = lookupField("style", "style_id", $style_id, "style_title"); + printf("Style Title: %s

\n ", $style_title); + printf("This will permanently remove this style and "); + printf("assign affected pages to the (N/A) style. Note that this function does "); + printf("not actually delete any header, footer or css files -- only the references "); + printf("to them. If a default page style is not properly configured, pages without "); + printf("a style may fail to display properly, and should be assigned a new style.

\n"); // Form to draw the delete button printf("
\n"); printf("\n"); printf("\n", $style_id); - printf("
This will permanently remove this style and "); - printf("assign affected pages to the (N/A) style. Note that this function does "); - printf("not actually delete any header, footer or css files -- only the references "); - printf("to them. If a default page style is not properly configured, pages without "); - printf("a style may fail to display properly, and should be assigned a new style.

\n"); printf("
\n"); printf("\n"); printf("
\n"); - printf("

\n"); + printf("\n"); + } + else if ($exists < 1) printf ("Style not found. Operation cancelled.

\n"); + + msgTableClose(); +} + + +/********************************************************** +Function: deleteSubCoursesub +Author: Paul Bramscher +Last Modified: 03.02.2004 +*********************************************************** +Purpose: +Deletes subject-coursesub associations based on the supplied +coursesub id (possibly multiple) and calls formSubject back +again. +**********************************************************/ +function deleteSubCoursesub($key_list_array, $subject_id){ + + // For the given subject, delete every location in the array + for ($element = 0; $element < sizeof($key_list_array); $element++) { - // Close table - printf("
\n"); + $sql = "DELETE FROM sub_coursesub WHERE subject_id = " + . $subject_id + . " AND coursesub_id = " + . $key_list_array[$element]; + xx_tryquery ($sql); } + // Call the subject form back + formSubject($subject_id); +} + + +/********************************************************** +Function: deleteSubject +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Deletes a subject, and removes associations in the +resource-subject-informationtype, subject-location, +subject-mastersubject, subject-coursesub, and +subject-staff tables. +**********************************************************/ +function deleteSubject($delMessage, $subject_id){ + + msgTableOpen(1, "Deleting Subject (ID# " . $subject_id .")"); + printf("Messages:
\n"); + + // Cannot delete placeholder #1 + if ($subject_id > 1) { - // Failed for whatever reason - else if ($exists < 1) printf ("Job title not found. Operation cancelled.
\n"); + // First delete all related rows in res_sub_infotype + $sql = "DELETE FROM res_sub_infotype WHERE subject_id = " . $subject_id; + if (xx_tryquery ($sql)) printf("Resource-subject-information type associations removed.
\n"); + + // Delete from the sub_loc table + $sql = "DELETE FROM sub_loc WHERE subject_id =" . $subject_id; + if (xx_tryquery ($sql)) printf("Subject-location associations removed.
\n"); + + // Delete from the sub_mastersubject table + $sql = "DELETE FROM sub_mastersubject WHERE subject_id =" . $subject_id; + if (xx_tryquery ($sql)) printf("Subject-mastersubject associations removed.
\n"); + + // Delete from the sub_staff table + $sql = "DELETE FROM sub_staff WHERE subject_id =" . $subject_id; + if (xx_tryquery ($sql)) printf("Subject-staff assignments removed.
\n"); + + // Delete from the sub_coursesub table + $sql = "DELETE FROM sub_coursesub WHERE subject_id =" . $subject_id; + if (xx_tryquery ($sql)) printf("Subject-Course Subject assignments removed.
\n"); + + // Delete from the sub_page table + $sql = "DELETE FROM sub_page WHERE subject_id =" . $subject_id; + if (xx_tryquery ($sql)) printf("Subject-Page assignments removed.
\n"); + + // Delete from the sub_othersub table + $sql = "DELETE FROM sub_othersub WHERE othersub_id =" + . $subject_id + . " OR subject_id = " + . $subject_id; + if (xx_tryquery ($sql)) printf("Subject-Other Subject assignments removed.
\n"); + + /******************************** + ** Update affected CL/PS pages ** + ********************************/ + + // First, get the default subject description and title + $sql = "SELECT subject, subject_descr FROM subject WHERE subject_id = " + . $subject_id; + $rs = xx_tryquery($sql); + $row = xx_fetch_array ($rs, xx_ASSOC); + $subject = $row["subject"]; + $subject_descr = $row["subject_descr"]; + + // Clean up strings + $subject_descr = textInmySQL($subject_descr); + $subject = textInmySQL($subject); + $delMessage = textInmySQL($delMessage); + + // Next, append the reason for deletion to the description + if (strlen($subject_descr) > 0) $subject_descr .= "
" . $delMessage; + else $subject_descr = $delMessage; + + // Update all of the elements using this resource with a custom description. + $sql = "UPDATE element SET label = '" + . $subject + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), subject_id = NULL WHERE subject_id =" . $subject_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions.
\n"); + + // Next, update all of the elements using this resource without a custom description. + $sql = "UPDATE element SET label = '" + . $subject + . "', element_descr = '" + . $subject_descr + . "', subject_id = NULL WHERE subject_id =" . $subject_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions.
\n"); + + /*************************************** + ** Update affected CL/PS copy buffers ** + ***************************************/ + + // Update all of the elements using this location with a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $subject + . "', element_descr = CONCAT(element_descr, '
" + . $delMessage + . "'), subject_id = NULL WHERE subject_id =" . $subject_id + . " AND (element_descr IS NOT NULL OR element_descr != '')"; + if (xx_tryquery ($sql)) printf("Added delete message to custom PageScribe descriptions (buffers).
\n"); - printf("
\n"); + // Next, update all of the elements using this location without a custom description. + $sql = "UPDATE pastebuffer SET label = '" + . $subject + . "', element_descr = '" + . $subject_descr + . "', subject_id = NULL WHERE subject_id =" . $subject_id + . " AND (element_descr IS NULL OR element_descr = '')"; + if (xx_tryquery ($sql)) printf("Added delete message to default PageScribe descriptions (buffers).
\n"); + + // Finally delete from the subject table + $sql = "DELETE FROM subject WHERE subject_id =" . $subject_id; + if (xx_tryquery ($sql)) printf("Successfully removed this subject from the system."); + } + else printf ("Cannot delete Subject ID# 1, it acts as a system placeholder."); + + printf("

\n"); + msgTableClose(); +} + + +/********************************************************** +Function: deleteSubjectConfirm +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Confirm prompt to delete the supplied subject id. +**********************************************************/ +function deleteSubjectConfirm($key_id){ + + $subject_id = (int) $key_id; + msgTableOpen(1, "Delete Subject (ID# " . $subject_id . ")?"); + + // Check to see if its possible + $exists = existsRow("subject", "subject_id", $subject_id); + if ($exists > 0){ + + // Lookup the descriptive title + $subject = lookupField("subject", "subject_id", $subject_id, "subject"); + printf("Subject: %s

\n ", $subject); + + // Form to draw the delete button + printf("
\n"); + printf("\n"); + printf("\n", $subject_id); + + // Delete message + printf("Message to appear on affected PageScribe Pages (75 char max.):
\n"); + printf("

\n"); + + printf("This will permanently remove the subject and its various subject assignments from the system. + This includes assignments to resources, master/general subjects, locations and staff specialists.

"); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + } + else if ($exists < 1) printf ("Subject not found. Operation cancelled.

\n"); + + msgTableClose(); +} + + +/********************************************************** +Function: deleteSubLoc +Author: Paul Bramscher +Last Modified: 03.03.2004 +*********************************************************** +Purpose: +Deletes subject-location associations based on the supplied +location id (possibly multiple) and calls formSubject back +again. +**********************************************************/ +function deleteSubLoc($key_list_array, $subject_id){ + + // For the given subject, delete every location in the array + for ($element = 0; $element < sizeof($key_list_array); $element++) { + + $sql = "DELETE FROM sub_loc WHERE subject_id = " + . $subject_id + . " AND location_id = " + . $key_list_array[$element]; + xx_tryquery($sql); + } + // Call the subject form back + formSubject($subject_id); +} + + +/********************************************************** +Function: deleteSubMaster +Author: Paul Bramscher +Last Modified: 03.03.2004 +*********************************************************** +Purpose: +Deletes subject-mastersubject associations based on the +supplied mastersubject id (possibly multiple) and calls +formSubject back again. +**********************************************************/ +function deleteSubMaster($key_list_array, $subject_id){ + + // For every mastersubject in the array, delete it from the bridging table + for ($element = 0; $element < sizeof($key_list_array); $element++) { + + $sql = "DELETE FROM sub_mastersubject WHERE subject_id = " + . $subject_id + . " AND mastersubject_id = " + . $key_list_array[$element]; + xx_tryquery($sql); + } + // Call the subject form back + formSubject($subject_id); +} + + +/********************************************************** +Function: deleteSubStaff +Author: Paul Bramscher +Last Modified: 03.03.2004 +*********************************************************** +Purpose: +Deletes staff-subject associations for the supplied staff +id (possibly multiple) and calls formSubject back again. +**********************************************************/ +function deleteSubStaff($key_list_array, $subject_id){ + + // For a given subject, delete all staff in the array + for ($element = 0; $element < sizeof($key_list_array); $element++) { + + $sql = "DELETE FROM sub_staff WHERE subject_id = " + . $subject_id + . " AND staff_id = " + . $key_list_array[$element]; + xx_tryquery($sql); + } + // Call the subject form back + formSubject($subject_id); } /********************************************************** Function: deleteTerm Author: Paul Bramscher -Last Modified: 05.07.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Deletes the supplied term id, and removes references in the course table. **********************************************************/ -function deleteTerm($con, $term_id){ +function deleteTerm($term_id){ - // Draw form heading - printf("

Deleting Academic Term...

"); - - // Table - printf(""); - printf("

"); - printf("Messages:
"); - - // Problem flag for each delete step - $problem = 0; + msgTableOpen(1, "Deleting Term (ID# " . $term_id . ")"); + printf("Messages:
\n"); // Cannot delete placeholder #1 if ($term_id > 1) { // Delete all course term assignments $sql = "UPDATE course SET term_id = NULL WHERE term_id =" . $term_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed this term from affected course pages.
\n"); - } - - - if ($problem == 0) { + if (xx_tryquery ($sql)) printf("Removed this term from affected course pages.
\n"); - // Delete from term table - $sql = "DELETE FROM term WHERE term_id =" . $term_id; - - if (!xx_query ($sql, $con)){ - $problem = 1; - sql_err($sql); - xx_query ("UNLOCK TABLES", $con); - bailout(); - } - else { - xx_query ("UNLOCK TABLES", $con); - printf("Removed term successfully.

\n"); - } - } + // Delete from term table + $sql = "DELETE FROM term WHERE term_id =" . $term_id; + if (xx_tryquery ($sql)) printf("Removed term successfully."); } + else printf ("Cannot delete Term ID# 1, it acts as a system placeholder."); - else printf("Cannot delete Term ID#1, it acts as a system placeholder.

\n"); - - printf("
"); - printf("
"); + printf("

\n"); + msgTableClose(); } /********************************************************** Function: deleteTermConfirm Author: Paul Bramscher -Last Modified: 05.07.2003 +Last Modified: 03.16.2004 *********************************************************** Purpose: Confirm prompt for deleting the supplied term id. **********************************************************/ -function deleteTermConfirm($con, $key_id){ +function deleteTermConfirm($key_id){ - // Make sure we have a valid integer type $term_id = (int) $key_id; - - // Draw page heading - printf("

Delete Term ID# %s?

", $term_id); + msgTableOpen(1, "Delete Term (ID# " . $term_id . ")?"); // Check to see if its possible - $exists = existsRow($con, "term", "term_id", $term_id); + $exists = existsRow("term", "term_id", $term_id); if ($exists > 0){ - // Table - printf(""); - printf("
"); - // Lookup the descriptive title - $term = lookupField($con, "term", "term_id", $term_id, "term"); - printf("Term: %s
\n ", $term); + $term = lookupField("term", "term_id", $term_id, "term"); + printf("Term: %s

\n ", $term); + printf("This will permanently remove this academic term. Some courses may no longer have terms.

\n"); // Form to draw the delete button - printf("
"); - printf(""); - printf("", $term_id); - printf("This will permanently remove this academic term. Some courses may no longer have terms.

"); - printf("
"); - printf(""); - printf("
"); - printf("

"); + printf("
\n"); + printf("\n"); + printf("\n", $term_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + } + else if ($exists < 1) printf ("Term not found. Operation cancelled.

\n"); + + msgTableClose(); +} + + +/********************************************************** +Function: deleteVendor +Author: Paul Bramscher +Last Modified: 03.15.2004 +*********************************************************** +Purpose: +Deletes a supplied vendor id, sets affected resources +to (N/A) vendor. +**********************************************************/ +function deleteVendor($vendor_id){ + + msgTableOpen(1, "Deleting Vendor (ID# " . $vendor_id . ")"); + printf("Messages:
\n"); + + // Cannot delete placeholder #1. + if ($vendor_id > 1) { + + // First update affected resources + $sql = "UPDATE resource SET vendor_id = NULL WHERE vendor_id = " + . $vendor_id; + if (xx_tryquery ($sql)) printf("Vendor purged from assignments to resources.
\n"); + + // Delete from the vendor table + $sql = "DELETE FROM vendor WHERE vendor_id =" . $vendor_id; + if (xx_tryquery ($sql)) printf("Removed this vendor successfully."); - // Close table - printf("
"); } + else printf ("Cannot delete Vendor ID# 1, it acts as a system placeholder."); - // Failed for whatever reason - else if ($exists < 1) printf ("Term not found. Operation cancelled.
\n"); + printf("

\n"); + msgTableClose(); +} - printf("
"); + +/********************************************************** +Function: deleteVendorConfirm +Author: Paul Bramscher +Last Modified: 03.16.2004 +*********************************************************** +Purpose: +Confirm prompt for deleting the selected vendor. +**********************************************************/ +function deleteVendorConfirm($key_id){ + + $vendor_id = (int) $key_id; + msgTableOpen(1, "Delete Vendor (ID# " . $vendor_id . ")?"); + + // Check to see if its possible + $exists = existsRow("vendor", "vendor_id", $vendor_id); + if ($exists > 0){ + + // Lookup the descriptive title + $vendor = lookupField("vendor", "vendor_id", $vendor_id, "vendor"); + printf("Vendor: %s

\n ", $vendor); + printf("This will permanently remove this vendor and its various assignments from the system. Some resources may lose their vendor association.

"); + + // Form to draw the delete button + printf("
\n"); + printf("\n"); + printf("\n", $vendor_id); + printf("
\n"); + printf("\n"); + printf("
\n"); + printf("
\n"); + } + else if ($exists < 1) printf ("Vendor not found. Operation cancelled.

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