From 3315b8b73c5c7309ed49b1ec7b30913f2015aef5 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 20 Dec 2004 18:31:42 +0000 Subject: [PATCH] Implement subdivisions editor --- config/divisions.php | 3 +- config/index.php | 1 + config/subdivisions.php | 152 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 config/subdivisions.php diff --git a/config/divisions.php b/config/divisions.php index 2a9a435..6bd9d70 100644 --- a/config/divisions.php +++ b/config/divisions.php @@ -58,7 +58,8 @@ } echo "
"; - echo "

".i18n("Divisions")."

"; + + echo "

".i18n("Project Divisions")."

"; if(! ($_GET['action']=="edit" || $_GET['action']=="new") ) echo "".i18n("Add new division")."\n"; diff --git a/config/index.php b/config/index.php index 4307b57..429baa3 100644 --- a/config/index.php +++ b/config/index.php @@ -6,6 +6,7 @@ echo "Configuration Variables
"; echo "Project Age Categories
"; echo "Project Divisons
"; + echo "Project Sub-Divisons
"; send_footer(); ?> diff --git a/config/subdivisions.php b/config/subdivisions.php new file mode 100644 index 0000000..550df42 --- /dev/null +++ b/config/subdivisions.php @@ -0,0 +1,152 @@ +<< ".i18n("Back to Configuration")."
"; + + if($_POST['action']=="edit") + { + if($_POST['id'] && $_POST['projectdivisions_id'] && $_POST['subdivision'] ) + { + $q=mysql_query("SELECT id FROM projectsubdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'"); + if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id']) + { + echo error(i18n("Sub-Division ID %1 already exists",array($_POST['id']))); + } + else + { + mysql_query("UPDATE projectsubdivisions SET ". + "id='".$_POST['id']."', ". + "projectdivisions_id='".$_POST['projectdivisions_id']."', ". + "subdivision='".mysql_escape_string(stripslashes($_POST['subdivision']))."' ". + "WHERE id='".$_POST['saveid']."'"); + echo happy(i18n("Sub-Division successfully saved")); + } + } + else + { + echo error(i18n("All fields are required")); + } + } + + if($_POST['action']=="new") + { + if($_POST['projectdivisions_id'] && $_POST['subdivision']) + { + if(!$_POST['id']) + { + $idq=mysql_query("SELECT MAX(id) AS id FROM projectsubdivisions"); + $idr=mysql_fetch_object($idq); + $newid=$idr->id+1; + + } + else + $newid=$_POST['id']; + + $q=mysql_query("SELECT id FROM projectsubdivisions WHERE id='$newid' AND year='".$config['FAIRYEAR']."'"); + if(mysql_num_rows($q)) + { + echo error(i18n("Sub-Division ID %1 already exists",array($newid))); + } + else + { + mysql_query("INSERT INTO projectsubdivisions (id,projectdivisions_id,subdivision,year) VALUES ( ". + "'$newid', ". + "'".$_POST['projectdivisions_id']."', ". + "'".mysql_escape_string(stripslashes($_POST['subdivision']))."', ". + "'".$config['FAIRYEAR']."') "); + echo happy(i18n("Sub-Division successfully added")); + } + } + else + { + echo error(i18n("All fields except ID are required")); + } + } + + if($_GET['action']=="remove" && $_GET['remove']) + { + mysql_query("DELETE FROM projectsubdivisions WHERE id='".$_GET['remove']."'"); + echo happy(i18n("Sub-Division successfully removed")); + } + + echo ""; + + echo "

".i18n("Project Sub-Divisions")."

"; + + if(! ($_GET['action']=="edit" || $_GET['action']=="new") ) + echo "".i18n("Add new sub-division")."\n"; + + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + + if($_GET['action']=="edit" || $_GET['action']=="new") + { + echo "\n"; + if($_GET['action']=="edit") + { + echo "\n"; + $q=mysql_query("SELECT * FROM projectsubdivisions WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'"); + $divisionr=mysql_fetch_object($q); + $buttontext="Save"; + } + else if($_GET['action']=="new") + { + $buttontext="Add"; + } + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + } + else + { + $q=mysql_query("SELECT projectsubdivisions.id, + projectsubdivisions.projectdivisions_id, + projectsubdivisions.subdivision, + projectdivisions.division + FROM + projectsubdivisions, + projectdivisions + WHERE + projectsubdivisions.year='".$config['FAIRYEAR']."' + AND projectsubdivisions.projectdivisions_id=projectdivisions.id + ORDER BY + division,subdivision"); +echo mysql_error(); + while($r=mysql_fetch_object($q)) + { + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + } + } + echo "
".i18n("Parent Division")."".i18n("ID")."".i18n("Sub-Division")."".i18n("Actions")."
"; + echo ""; + echo "id\">subdivision\">
$r->id$r->division$r->subdivision"; + echo "id\">"; + echo "   "; + echo "id\">"; + echo "
"; +if($_GET['action']=="new") + echo "         ".i18n("Leave ID field blank to auto-assign next available ID"); + echo "
"; + + send_footer(); +?>