diff --git a/admin/fundraising.php b/admin/fundraising.php index b28a84d..091aecc 100644 --- a/admin/fundraising.php +++ b/admin/fundraising.php @@ -3,7 +3,7 @@ This file is part of the 'Science Fair In A Box' project SFIAB Website: http://www.sfiab.ca - Copyright (C) 2007 James Grant + Copyright (C) 2008 James Grant This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public @@ -26,12 +26,156 @@ require_once("../user.inc.php"); user_auth_required('committee', 'admin'); +if($_POST['action']=="sponsorshipedit" || $_POST['action']=="sponsorshipadd") { + $sponsors_id=intval($_POST['sponsors_id']); + $sponsorships_id=intval($_POST['sponsorships_id']); + $fundraising_type=mysql_real_escape_string($_POST['fundraising_type']); + $value=intval($_POST['value']); + $status=mysql_real_escape_string($_POST['status']); + $probability=mysql_real_escape_string($_POST['probability']); + + if($status=="confirmed" || $status=="received") $probability="100"; + if($probability==100 && $status=="pending") $status="confirmed"; +} + +if($_POST['action']=="sponsorshipedit") { + if($sponsorships_id && $sponsors_id && $fundraising_type && $value) { + mysql_query("UPDATE sponsorships SET sponsors_id='$sponsors_id', fundraising_type='$fundraising_type', value='$value', status='$status', probability='$probability' WHERE id='$sponsorships_id'"); + if(mysql_error()) + message_push(error(mysql_error())); + else + message_push(happy(i18n("Saved sponsorship changes"))); + } + else + message_push(error(i18n("Required fields were missing, please try again"))); + +} +if($_POST['action']=="sponsorshipadd") { + if($sponsors_id && $fundraising_type && $value) { + mysql_query("INSERT INTO sponsorships (sponsors_id,fundraising_type,value,status,probability,year) VALUES ('$sponsors_id','$fundraising_type','$value','$status','$probability','{$config['FAIRYEAR']}')"); + message_push(happy(i18n("Added new sponsorship"))); + } + else + message_push(error(i18n("Required fields were missing, please try again"))); + if(mysql_error()) + message_push(error(mysql_error())); +} + + send_header("Fundraising", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php'), "fundraising" ); +require_once("../ajax.inc.php"); +?> + + + +"; + echo ""; + /* echo ""; - echo " \n"; + echo " \n"; echo " \n"; echo "\n"; + */ while($r=mysql_fetch_object($q)) { echo ""; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + if($r->type=="general") + $orsql.="OR fundraising_type IS NULL"; + + $typetotal=0; + $sq=mysql_query("SELECT sponsorships.id, sponsors.organization, sponsorships.value, sponsorships.status, sponsorships.probability + FROM sponsorships + JOIN sponsors ON sponsorships.sponsors_id=sponsors.id + WHERE (sponsorships.fundraising_type='$r->type' $orsql) + AND sponsorships.year='{$config['FAIRYEAR']}'"); + while($sr=mysql_fetch_object($sq)) { + echo "id\" class=\"fundraising{$sr->status}\">\n"; + echo ""; + echo ""; + echo ""; + } + else + echo "\n"; + + $probval=$sr->probability/100*$sr->value; + echo ""; + echo "\n"; + echo "\n"; + $typetotal+=$probval; + } + echo ""; + echo ""; + echo "\n"; + echo "\n"; + $typediff=$typetotal-$r->goal; + echo "\n"; + echo "\n"; + $totalgoal+=$r->goal; + $totaldiff+=$typediff; + echo "\n"; } - echo "\n"; + echo "\n"; echo "
".i18n("Fund")."".i18n("Fund")."".i18n("Goal")."
".i18n($r->name)."".format_money($r->goal)."
".i18n($r->name)."".format_money($r->goal)."
id&fundraising_type=$r->type',300,200)\" href=\"#\">edit$sr->organization$sr->status"; + if($sr->status=="pending") + { + echo "$sr->probability%"; + echo "".format_money($sr->value)."".format_money($probval)."
type',300,200)\" href=\"#\">add".i18n("%1 Total",array($r->name),array("Fundraising type total, eg) Award Sponsorship Total"))."".format_money($typetotal)."".format_money($typediff)."
 
".i18n("Total")."".format_money($totalgoal)."
".i18n("Total Net Position")."".format_money($totaldiff)."
\n"; echo "".i18n("Edit fund types and goals")."\n"; diff --git a/admin/index.php b/admin/index.php index 32a372c..9fc1542 100644 --- a/admin/index.php +++ b/admin/index.php @@ -90,6 +90,7 @@ echo " ".theme_icon("communication")."
".i18n("Communication (Send Emails)")."
"; echo " ".theme_icon("internal_document_management")."
".i18n("Internal Document Management")."
"; echo " ".theme_icon("website_content_management")."
".i18n("Website Content Management")."
"; + echo " ".theme_icon("fundraising")."
".i18n("Fundraising")."
"; echo " "; echo " \n"; echo "\n"; diff --git a/admin/sponsors.php b/admin/sponsors.php new file mode 100644 index 0000000..499d8cb --- /dev/null +++ b/admin/sponsors.php @@ -0,0 +1,195 @@ + + 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. +*/ +?> + 'committee_main.php', + 'Administration' => 'admin/index.php', + 'Fundraising Main' => 'admin/fundraising.php') + ); + + if($_POST['save']=="edit" || $_POST['save']=="add") + { + if($_POST['save']=="add") + { + $q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')"); + $id=mysql_insert_id(); + } + else + $id=$_POST['id']; + + + $exec="UPDATE sponsors SET ". + "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ". + "address='".mysql_escape_string(stripslashes($_POST['address']))."', ". + "city='".mysql_escape_string(stripslashes($_POST['city']))."', ". + "province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ". + "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ". + "phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ". + "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("Sponsor successfully added"); + else + echo happy("Successfully saved changes to sponsor"); + } + + if($_GET['action']=="delete" && $_GET['delete']) + { + mysql_query("DELETE FROM sponsors WHERE id='".$_GET['delete']."'"); + echo happy("Sponsor successfully deleted"); + } + + if($_GET['action']=="confirm" && $_GET['confirm']) + { + mysql_query("UPDATE sponsors SET confirmed='yes' WHERE id='".$_GET['confirm']."'"); + echo happy("Sponsor successfully confirmed"); + + } + if($_GET['action']=="unconfirm" && $_GET['unconfirm']) + { + mysql_query("UPDATE sponsors SET confirmed='no' WHERE id='".$_GET['unconfirm']."'"); + echo happy("Sponsor successfully unconfirmed"); + } + + if($_GET['action']=="edit" || $_GET['action']=="add") + { + + echo "<< ".i18n("Back to Award Sponsors")."\n"; + if($_GET['action']=="edit") + { + echo "

".i18n("Edit Award Sponsor")."

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

".i18n("Add New Award Sponsor")."

\n"; + $buttontext="Add Sponsor"; + } + $buttontext=i18n($buttontext); + + 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 "\n"; + + echo "
".i18n("Organization Name")."organization)."\" size=\"60\" maxlength=\"128\" />
".i18n("Address")."address)."\" size=\"60\" maxlength=\"64\" />
".i18n("City")."city)."\" size=\"32\" maxlength=\"32\" />
".i18n($config['provincestate']).""; + emit_province_selector("province_code",$r->province_code); + echo "
".i18n($config['postalzip'])."postalcode\" size=\"8\" maxlength=\"7\" />
".i18n("Phone")."phone)."\" size=\"16\" maxlength=\"32\" />
".i18n("Fax")."fax)."\" size=\"16\" maxlength=\"32\" />
".i18n("Email")."email)."\" size=\"60\" maxlength=\"128\" />
".i18n("Notes")."
\n"; + echo "
\n"; + + + + } + else + { + + + echo "
"; + echo "Add New Sponsor\n"; + echo "
"; + echo ""; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "\n"; + + //$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization"); + //we want to show all years, infact that year field probably shouldnt even be there. + $q=mysql_query("SELECT * FROM sponsors ORDER BY organization"); + while($r=mysql_fetch_object($q)) + { + echo "\n"; + echo "\n"; + echo " \n"; + + $numq=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE year='".$config['FAIRYEAR']."' AND sponsors_id='$r->id'"); + $numr=mysql_fetch_object($numq); + $numawards=$numr->num; + + $numq=mysql_query("SELECT COUNT(users_id) AS num FROM users_sponsor WHERE sponsors_id='$r->id'"); + $numr=mysql_fetch_object($numq); + $numcontacts=$numr->num; + + + echo " "; + echo " "; + echo " \n"; + echo "\n"; + } + + echo "
Confirmed?Organization# of Awards# of ContactsAction
\n"; + if($r->confirmed=='yes') + { + echo "id\">\"ok_alt\"\n"; + } + else + { + echo "id\">confirm"; + } + echo "$r->organization"; + echo "$numawards  "; + echo "id\">\"view\""; + echo ""; + echo "$numcontacts  "; + echo "id\">\"view\""; + echo ""; + echo "id\">"; + echo " "; + echo "id\">"; + + + echo "
\n"; + + + } + + send_footer(); + +?> diff --git a/admin/sponsorship.php b/admin/sponsorship.php new file mode 100644 index 0000000..2156e53 --- /dev/null +++ b/admin/sponsorship.php @@ -0,0 +1,107 @@ + + + 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. +*/ +?> +Edit Sponsorship"; + $sponsorship=mysql_fetch_object($q); + $formaction="sponsorshipedit"; + } + else + { + echo "

Create New Sponsorship

"; + $formaction="sponsorshipadd"; + $fundraising_type=$_GET['fundraising_type']; + } + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + echo ""; + echo "\n"; + echo "\n"; + + echo ""; + echo "\n"; + + echo ""; + echo "\n"; + + echo "\n"; + + echo "
".i18n("Sponsor").""; + + $q=mysql_query("SELECT * FROM sponsors ORDER BY organization"); + echo mysql_error(); + echo "\n"; + echo "
".i18n("Type").""; + $q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY name"); + echo mysql_error(); + echo "\n"; + echo "
".i18n("Amount")."value\">
".i18n("Status").""; + echo "\n"; + echo "
".i18n("Probability").""; + echo "\n"; + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + +?> diff --git a/common.inc.php b/common.inc.php index f15e5cb..f45630f 100644 --- a/common.inc.php +++ b/common.inc.php @@ -605,12 +605,7 @@ if($icon && theme_icon($icon)) { else echo ""; -/* Dump any messages in the queue */ -if(is_array($_SESSION['messages'])) { - foreach($_SESSION['messages'] as $m) echo $m; -} -$_SESSION['messages'] = array(); - + if($title) echo "

".i18n($title)."

"; @@ -622,6 +617,12 @@ if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config") } ""; echo ""; +/* Dump any messages in the queue */ +if(is_array($_SESSION['messages'])) { + foreach($_SESSION['messages'] as $m) echo $m; +} +$_SESSION['messages'] = array(); + } function send_footer() @@ -1134,6 +1135,38 @@ function format_datetime($dt) { } } +function format_money($n) +{ + if($n<0){ + $neg=true; + $n=$n*-1; + } + //get the part before the decimal + $before=floor($n); + $out=""; + + //space it out in blocks of three + for($x=strlen($before);$x>3;$x-=3) { + $out=substr($before,$x-3,3)." ".$out; + } + if($x>0) + $out=substr($before,0,$x)." ".$out; + + //trim any leading/trailing space that was added + $out=trim($out); + + if($neg) $negdisp="-"; else $negdisp=""; + + //get everything after the decimal place, and %02f it. + $after=substr(strstr(sprintf("%.02f",$n),"."),1); + + //finally display it with the right language localization + if($_SESSION['lang']=="fr") + return sprintf("%s%s,%s \$",$negdisp,$out,$after); + else + return sprintf("%s\$%s.%s",$negdisp,$out,$after); +} + function message_push($m) { if(!is_array($_SESSION['messages'])) $_SESSION['messages'] = array(); diff --git a/db/db.update.119.sql b/db/db.update.119.sql index f641eea..abcbdd4 100644 --- a/db/db.update.119.sql +++ b/db/db.update.119.sql @@ -1 +1,49 @@ DROP TABLE award_contacts; + +CREATE TABLE `fundraising` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `type` VARCHAR( 32 ) NOT NULL , + `name` VARCHAR( 128 ) NOT NULL , + `system` ENUM( 'no', 'yes' ) DEFAULT 'no' NOT NULL , + `goal` INT UNSIGNED NOT NULL , + `year` INT NOT NULL , + PRIMARY KEY ( `id` ) +) TYPE = MYISAM ; + +ALTER TABLE `fundraising` ADD UNIQUE (type,year); +INSERT INTO `fundraising` ( `id` , `type` , `name` , `system` , `goal` , `year` ) VALUES ( '', 'general', 'General Funds', 'yes', '0', '-1'); +INSERT INTO `fundraising` ( `id` , `type` , `name` , `system` , `goal` , `year` ) VALUES ( '', 'awards', 'Award Sponsorships', 'yes', '0', '-1'); + +ALTER TABLE `award_sponsors` RENAME `sponsors` ; +ALTER TABLE `award_awards` CHANGE `award_sponsors_id` `sponsors_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' + +CREATE TABLE `sponsors_logs` ( + `id` INT NOT NULL AUTO_INCREMENT , + `sponsors_id` INT NOT NULL , + `dt` DATETIME NOT NULL , + `users_id` INT NOT NULL , + `log` TEXT NOT NULL , + PRIMARY KEY ( `id` ) +) TYPE = MYISAM ; + + +CREATE TABLE `sponsorships` ( + `id` INT NOT NULL AUTO_INCREMENT , + `sponsors_id` INT NOT NULL , + `fundraising_type` VARCHAR( 32 ) NOT NULL , + `value` INT NOT NULL , + `status` ENUM( 'pending', 'confirmed', 'received' ) NOT NULL , + `probability` INT NOT NULL , + `year` INT NOT NULL , + PRIMARY KEY ( `id` ) +) TYPE = MYISAM ; + +CREATE TABLE `sponsorships_levels` ( + `id` INT NOT NULL AUTO_INCREMENT , + `level` VARCHAR( 64 ) NOT NULL , + `min` INT NOT NULL , + `max` INT NOT NULL , + `description` TEXT NOT NULL , + `year` INT NOT NULL , + PRIMARY KEY ( `id` ) +) TYPE = MYISAM ; diff --git a/tableeditor.css b/tableeditor.css index f9290cb..2ca93e6 100644 --- a/tableeditor.css +++ b/tableeditor.css @@ -25,7 +25,7 @@ input { margin-left: 20px; margin-right: 20px; border: 0px; - font-size: 12px; + font-size: 0.8em;; } .tableview td { @@ -57,7 +57,7 @@ input { color: black; margin-left: 20px; margin-right: 20px; - font-size: 12px; + font-size: 0.8em; border: 0px; } diff --git a/theme/default/sfiab.css b/theme/default/sfiab.css index bbd6648..d5f3774 100644 --- a/theme/default/sfiab.css +++ b/theme/default/sfiab.css @@ -306,3 +306,74 @@ tr.externalaward { width: 128px; color: #999999; } + +.fundraisingpending { + color: black; + border: 1px solid #FFAAAA; + background: #FFAAAA; +} + +.fundraisingconfirmed { + color: black; + border: 1px solid #FFFFAA; + background: #FFFFAA; +} + + +.fundraisingreceived { + color: black; + border: 1px solid #AAFFAA; + background: #AAFFAA; +} + +.fundraisingtable { + border-collapse: collapse; + border-spacing: 0px; + border: 0px; + margin: 0px; + padding: 0px; + margin-left: 30px; + margin-right: 30px; + font-size: 0.8em; + +} + +.fundraisingtable th { + border: 1px solid black; + background-color: #5C6F90; + padding: 2px; + margin: 0px; + font-size: 1.0em; + color: white; + font-weight: bold; + text-align: left; +} + +.fundraisingtable th a{ + font-size: 1.1em; + color: white; + font-weight: bold; +} + +.fundraisingtable td { + border: 1px solid black; + margin: 0px; + padding: 1px; + +} + + +.SFIABDialog { + font-size: 0.8em; + padding: 5px; + background-color: #5C6F90; +} + +.SFIABDialogInner { + background-color: white; + width: 100%; + height: 100%; + +} + +