From 79ff112a9db7157ab3c4cc28ad09b719945e984a Mon Sep 17 00:00:00 2001 From: james Date: Wed, 23 Feb 2005 23:00:45 +0000 Subject: [PATCH] add award contacts system link it to awards and award_sponsors --- admin/award_contacts.php | 193 +++++++++++++++++++++++++++++++++++++++ admin/award_sponsors.php | 18 +++- admin/awards.php | 1 + 3 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 admin/award_contacts.php diff --git a/admin/award_contacts.php b/admin/award_contacts.php new file mode 100644 index 0000000..1998035 --- /dev/null +++ b/admin/award_contacts.php @@ -0,0 +1,193 @@ + + Copyright (C) 2005 James Grant + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation, version 2. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +?> + + +<< ".i18n("Back to Administration")."\n"; + echo "<< ".i18n("Back to Awards")."\n"; + + $q=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); + echo "
"; + echo ""; + echo "
"; + + if($award_sponsors_id) + { + + + if($_POST['save']=="edit" || $_POST['save']=="add") + { + if($_POST['save']=="add") + { + $q=mysql_query("INSERT INTO award_contacts (award_sponsors_id,year) VALUES ('$award_sponsors_id','".$config['FAIRYEAR']."')"); + $id=mysql_insert_id(); + } + else + $id=$_POST['id']; + + + $exec="UPDATE award_contacts SET ". + "firstname='".mysql_escape_string(stripslashes($_POST['firstname']))."', ". + "lastname='".mysql_escape_string(stripslashes($_POST['lastname']))."', ". + "phonework='".mysql_escape_string(stripslashes($_POST['phonework']))."', ". + "phonecell='".mysql_escape_string(stripslashes($_POST['phonecell']))."', ". + "phonehome='".mysql_escape_string(stripslashes($_POST['phonehome']))."', ". + "fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ". + "email='".mysql_escape_string(stripslashes($_POST['email']))."', ". + "notes='".mysql_escape_string(stripslashes($_POST['notes']))."' ". + "WHERE id='$id'"; + mysql_query($exec); + + if($_POST['save']=="add") + echo happy("Contact successfully added"); + else + echo happy("Successfully saved changes to contact"); + } + + if($_GET['action']=="delete" && $_GET['delete']) + { + mysql_query("DELETE FROM award_contacts WHERE id='".$_GET['delete']."'"); + echo happy("Contact successfully deleted"); + } + + if($_GET['action']=="edit" || $action=="add") + { + + echo "<< ".i18n("Back to %1 Contacts",array($award_sponsors_organization))."\n"; + if($_GET['action']=="edit") + { + echo "

".i18n("Edit %1 Contact",array($award_sponsors_organization))."

\n"; + $buttontext="Save Contact"; + $q=mysql_query("SELECT * FROM award_contacts WHERE id='".$_GET['edit']."'"); + $r=mysql_fetch_object($q); + } + else if($action=="add") + { + echo "

".i18n("Add %1 Contact",array($award_sponsors_organization))."

\n"; + $buttontext="Add Contact"; + } + $buttontext=i18n($buttontext); + + echo "
\n"; + echo "\n"; + echo "\n"; + + if($_GET['action']=="edit") + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
".i18n("First Name")."firstname)."\" size=\"32\" maxlength=\"32\" />
".i18n("Last Name")."lastname)."\" size=\"32\" maxlength=\"32\" />
".i18n("Phone (Work)")."phonework)."\" size=\"16\" maxlength=\"16\" />
".i18n("Phone (Cell)")."phonecell)."\" size=\"16\" maxlength=\"16\" />
".i18n("Phone (Home)")."phonehome)."\" size=\"16\" maxlength=\"16\" />
".i18n("Fax")."fax)."\" size=\"16\" maxlength=\"16\" />
".i18n("Email")."email)."\" size=\"60\" maxlength=\"128\" />
".i18n("Notes")."
\n"; + echo "
\n"; + } + else + { + + echo "
"; + echo "".i18n("Add New Contact to %1",array($award_sponsors_organization))."\n"; + echo "
"; + + $q=mysql_query("SELECT * FROM award_contacts WHERE year='".$config['FAIRYEAR']."' AND award_sponsors_id='$award_sponsors_id' ORDER BY lastname,firstname"); + + if(mysql_num_rows($q)) + { + echo ""; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "\n"; + + + while($r=mysql_fetch_object($q)) + { + echo "\n"; + echo " \n"; + echo " "; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + + echo "
".i18n("Name")."".i18n("Email")."".i18n("Phone (Work)")."".i18n("Phone (Cell)")."Actions
$r->firstname $r->lastname"; + if($r->email) + { + list($eb,$ea)=split("@",$r->email); + echo ""; + } + else + echo " "; + + echo "$r->phonework$r->phonecell"; + echo "id\">"; + echo " "; + echo "id\">"; + + + echo "
\n"; + } + + } + + + } + + send_footer(); + +?> diff --git a/admin/award_sponsors.php b/admin/award_sponsors.php index aefb148..c7c7fa6 100644 --- a/admin/award_sponsors.php +++ b/admin/award_sponsors.php @@ -136,6 +136,7 @@ echo " Confirmed?"; echo " Organization"; echo " # of Awards"; + echo " # of Contacts"; echo " Action"; echo "\n"; @@ -155,16 +156,23 @@ echo "\n"; echo " $r->organization\n"; - $numq=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE id='$r->id'"); + $numq=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE award_sponsors_id='$r->id'"); $numr=mysql_fetch_object($numq); - $num=$numr->num; - $total=$numr->total; + $numawards=$numr->num; + + $numq=mysql_query("SELECT COUNT(id) AS num FROM award_contacts WHERE award_sponsors_id='$r->id'"); + $numr=mysql_fetch_object($numq); + $numcontacts=$numr->num; - echo " "; - echo "$num  "; + echo " "; + echo "$numawards  "; echo "id\">\"view\""; echo ""; + echo " "; + echo "$numcontacts  "; + echo "id\">\"view\""; + echo ""; echo " "; echo "id\">"; echo " "; diff --git a/admin/awards.php b/admin/awards.php index 35340b5..33c4545 100644 --- a/admin/awards.php +++ b/admin/awards.php @@ -31,6 +31,7 @@ echo "
"; echo "
"; echo "Award Sponsors
"; + echo "Award Contacts
"; send_footer();