forked from science-ation/science-ation
Add more fundraising module stuff, the SFIABDialog code will be refactored out into a separate library class eventually
This commit is contained in:
parent
10d71c4b57
commit
c100baef89
@ -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 <james@lightbox.org>
|
||||
Copyright (C) 2008 James Grant <james@lightbox.org>
|
||||
|
||||
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");
|
||||
?>
|
||||
<div class="SFIABDialog" id="SFIABDialog" style="position: absolute; visibility: hidden;">
|
||||
<div class="SFIABDialogInner" id="SFIABDialogInner"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
function SFIABDialogSubmit() {
|
||||
//we let it submit the form, which reloads the page
|
||||
return true;
|
||||
}
|
||||
|
||||
function SFIABDialogCancel() {
|
||||
var d=document.getElementById('SFIABDialog');
|
||||
var di=document.getElementById('SFIABDialogInner');
|
||||
d.style.visibility="hidden";
|
||||
di.style.visibility="hidden";
|
||||
return false;
|
||||
}
|
||||
|
||||
var SFIABDialogGrowWidth=0;
|
||||
var SFIABDialogGrowHeight=0;
|
||||
var SFIABDialogFinalWidth=100;
|
||||
var SFIABDialogFinalHeight=100;
|
||||
var SFIABDialogGrowWidthStep=0;
|
||||
var SFIABDialogGrowHeightStep=0;
|
||||
var SFIABDialogGrowTime=200; //1 second
|
||||
var SFIABDialogGrowSteps=10;
|
||||
|
||||
function SFIABDialog(e, url, width, height) {
|
||||
var posx = 0;
|
||||
var posy = 0;
|
||||
|
||||
//get this going while we do the other stuff
|
||||
SFIABDialogFill(url);
|
||||
|
||||
if(!e) var e = window.event;
|
||||
if (e.pageX || e.pageY) {
|
||||
posx = e.pageX;
|
||||
posy = e.pageY;
|
||||
}
|
||||
else if (e.clientX || e.clientY) {
|
||||
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
||||
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
||||
}
|
||||
|
||||
var d=document.getElementById('SFIABDialog');
|
||||
var di=document.getElementById('SFIABDialogInner');
|
||||
d.style.top=posy+'px';
|
||||
d.style.left=posx+'px';
|
||||
d.style.visibility='visible';
|
||||
di.style.visibility='hidden';
|
||||
SFIABDialogGrowWidth=1;
|
||||
SFIABDialogGrowHeight=1;
|
||||
SFIABDialogFinalWidth=width;
|
||||
SFIABDialogFinalHeight=height;
|
||||
d.style.width=SFIABDialogGrowWidth+"px";
|
||||
d.style.height=SFIABDialogGrowHeight+"px";
|
||||
|
||||
SFIABDialogGrowWidthStep=Math.round(width/SFIABDialogGrowSteps);
|
||||
SFIABDialogGrowHeightStep=Math.round(height/SFIABDialogGrowSteps);
|
||||
setTimeout('growDialog()',Math.round(SFIABDialogGrowTime/SFIABDialogGrowSteps));
|
||||
}
|
||||
|
||||
function growDialog() {
|
||||
SFIABDialogGrowWidth+=SFIABDialogGrowWidthStep;
|
||||
SFIABDialogGrowHeight+=SFIABDialogGrowHeightStep;
|
||||
if(SFIABDialogGrowWidth>SFIABDialogFinalWidth)
|
||||
SFIABDialogGrowWidth=SFIABDialogFinalWidth;
|
||||
if(SFIABDialogGrowHeight>SFIABDialogFinalHeight)
|
||||
SFIABDialogGrowHeight=SFIABDialogFinalHeight;
|
||||
|
||||
var d=document.getElementById('SFIABDialog');
|
||||
d.style.width=SFIABDialogGrowWidth+"px";
|
||||
d.style.height=SFIABDialogGrowHeight+"px";
|
||||
|
||||
if(SFIABDialogGrowWidth<SFIABDialogFinalWidth || SFIABDialogGrowHeight<SFIABDialogFinalHeight)
|
||||
setTimeout('growDialog()',Math.round(SFIABDialogGrowTime/SFIABDialogGrowSteps));
|
||||
else {
|
||||
var di=document.getElementById('SFIABDialogInner');
|
||||
di.style.visibility="visible";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function SFIABDialogFill(url) {
|
||||
var d=document.getElementById('SFIABDialogInner');
|
||||
d.innerHTML="";
|
||||
http.open("GET",url,true);
|
||||
http.onreadystatechange=SFIABDialogFillResponse;
|
||||
http.send(null);
|
||||
}
|
||||
|
||||
function SFIABDialogFillResponse() {
|
||||
try {
|
||||
if(http.readyState==4) {
|
||||
var d=document.getElementById('SFIABDialogInner');
|
||||
var objhtml=http.responseText;
|
||||
d.innerHTML=objhtml;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<?
|
||||
|
||||
//first, insert any defaults
|
||||
$q=mysql_query("SELECT * FROM fundraising WHERE year='".$config['FAIRYEAR']."'");
|
||||
@ -45,19 +189,61 @@
|
||||
|
||||
//this table is eventually going to be massive, and probably not in a tableview format, it'll show goals as well as all ongoing fund pledges, probabilities, etc as well as over/under, etc, all prettily colour coded.. basically a good overview of the total fundraising status of the fair.
|
||||
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY system,type");
|
||||
echo "<table class=\"tableview\">";
|
||||
echo "<table class=\"fundraisingtable\">";
|
||||
/*
|
||||
echo "<tr>";
|
||||
echo " <th>".i18n("Fund")."</th>\n";
|
||||
echo " <th colspan=\"2\">".i18n("Fund")."</th>\n";
|
||||
echo " <th>".i18n("Goal")."</th>\n";
|
||||
echo "</tr>\n";
|
||||
*/
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
echo "<tr>";
|
||||
echo "<td>".i18n($r->name)."</td>\n";
|
||||
echo "<td>".format_money($r->goal)."</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "<th colspan=\"6\">".i18n($r->name)."</th>\n";
|
||||
echo "<th style=\"text-align: right\">".format_money($r->goal)."</th>\n";
|
||||
echo "</tr>\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 "<tr id=\"sponsorships_$sr->id\" class=\"fundraising{$sr->status}\"><td width=\"30\"><a onclick=\"return SFIABDialog(event,'sponsorship.php?id=$sr->id&fundraising_type=$r->type',300,200)\" href=\"#\">edit</a></td><td>$sr->organization</td>\n";
|
||||
echo "<td>$sr->status</td>";
|
||||
echo "<td>";
|
||||
if($sr->status=="pending")
|
||||
{
|
||||
echo "$sr->probability%";
|
||||
echo "</td>";
|
||||
echo "<td>".format_money($sr->value)."</td>";
|
||||
}
|
||||
else
|
||||
echo "</td><td></td>\n";
|
||||
|
||||
$probval=$sr->probability/100*$sr->value;
|
||||
echo "<td style=\"text-align: right\">".format_money($probval)."</td>";
|
||||
echo "<td></td>\n";
|
||||
echo "</tr>\n";
|
||||
$typetotal+=$probval;
|
||||
}
|
||||
echo "<tr>";
|
||||
echo "<td><a onclick=\"return SFIABDialog(event,'sponsorship.php?fundraising_type=$r->type',300,200)\" href=\"#\">add</a></td>";
|
||||
echo "<td colspan=\"4\" style=\"text-align: right; font-weight: bold;\">".i18n("%1 Total",array($r->name),array("Fundraising type total, eg) Award Sponsorship Total"))."</td>\n";
|
||||
echo "<td style=\"font-weight: bold; text-align: right;\">".format_money($typetotal)."</td>\n";
|
||||
$typediff=$typetotal-$r->goal;
|
||||
echo "<td style=\"font-weight: bold; text-align: right;\">".format_money($typediff)."</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
$totalgoal+=$r->goal;
|
||||
$totaldiff+=$typediff;
|
||||
echo "<tr><td colspan=\"7\"> </td></tr>\n";
|
||||
}
|
||||
echo "<tr><td>".i18n("Total")."</td><td>".format_money($totalgoal)."</td></tr>\n";
|
||||
echo "<tr><td colspan=\"6\" style=\"font-weight: bold; text-align: right;\">".i18n("Total Net Position")."</td><td style=\"text-align: right; font-weight: bold;\">".format_money($totaldiff)."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<a href=\"fundraising_types.php\">".i18n("Edit fund types and goals")."</a>\n";
|
||||
|
||||
|
@ -90,6 +90,7 @@
|
||||
echo " <td><a href=\"communication.php\">".theme_icon("communication")."<br />".i18n("Communication (Send Emails)")."</a></td>";
|
||||
echo " <td><a href=\"documents.php\">".theme_icon("internal_document_management")."<br />".i18n("Internal Document Management")."</a></td>";
|
||||
echo " <td><a href=\"cms.php\">".theme_icon("website_content_management")."<br />".i18n("Website Content Management")."</a></td>";
|
||||
echo " <td><a href=\"fundraising.php\">".theme_icon("fundraising")."<br />".i18n("Fundraising")."</a></td>";
|
||||
echo " <td></td>";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
|
195
admin/sponsors.php
Normal file
195
admin/sponsors.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
require_once("../user.inc.php");
|
||||
user_auth_required('committee', 'admin');
|
||||
|
||||
send_header("Sponsors",
|
||||
array('Committee Main' => '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 "<a href=\"sponsors.php\"><< ".i18n("Back to Award Sponsors")."</a>\n";
|
||||
if($_GET['action']=="edit")
|
||||
{
|
||||
echo "<h3>".i18n("Edit Award Sponsor")."</h3>\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 "<h3>".i18n("Add New Award Sponsor")."</h3>\n";
|
||||
$buttontext="Add Sponsor";
|
||||
}
|
||||
$buttontext=i18n($buttontext);
|
||||
|
||||
echo "<form method=\"post\" action=\"sponsors.php\">\n";
|
||||
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
|
||||
|
||||
if($_GET['action']=="edit")
|
||||
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
|
||||
|
||||
echo "<table>\n";
|
||||
echo "<tr><td>".i18n("Organization Name")."</td><td><input type=\"text\" id=\"organization\" name=\"organization\" value=\"".htmlspecialchars($r->organization)."\" size=\"60\" maxlength=\"128\" /><script type=\"text/javascript\">translateButton('organization');</script></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Address")."</td><td><input type=\"text\" name=\"address\" value=\"".htmlspecialchars($r->address)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("City")."</td><td><input type=\"text\" name=\"city\" value=\"".htmlspecialchars($r->city)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n($config['provincestate'])."</td><td>";
|
||||
emit_province_selector("province_code",$r->province_code);
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>".i18n($config['postalzip'])."</td><td><input type=\"text\" name=\"postalcode\" value=\"$r->postalcode\" size=\"8\" maxlength=\"7\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone")."</td><td><input type=\"text\" name=\"phone\" value=\"".htmlspecialchars($r->phone)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Fax")."</td><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($r->fax)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Email")."</td><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($r->email)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Notes")."</td><td><textarea name=\"notes\" rows=\"8\" cols=\"60\">".htmlspecialchars($r->notes)."</textarea></td></tr>\n";
|
||||
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
|
||||
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
echo "<br />";
|
||||
echo "<a href=\"sponsors.php?action=add\">Add New Sponsor</a>\n";
|
||||
echo "<br />";
|
||||
echo "<table class=\"summarytable\">";
|
||||
echo "<tr>";
|
||||
echo " <th>Confirmed?</th>";
|
||||
echo " <th>Organization</th>";
|
||||
echo " <th># of Awards</th>";
|
||||
echo " <th># of Contacts</th>";
|
||||
echo " <th>Action</th>";
|
||||
echo "</tr>\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 "<tr>\n";
|
||||
echo "<td align=\"center\">\n";
|
||||
if($r->confirmed=='yes')
|
||||
{
|
||||
echo "<a href=\"sponsors.php?action=unconfirm&unconfirm=$r->id\"><img border=\"0\" alt=\"ok_alt\" src=\"".$config['SFIABDIRECTORY']."/images/16/ok.".$config['icon_extension']."\"></a>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<a title=\"click here to mark this sponsor as confirmed\" href=\"sponsors.php?action=confirm&confirm=$r->id\">confirm</a>";
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo " <td>$r->organization</td>\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 " <td align=\"center\" valign=\"top\">";
|
||||
echo "$numawards ";
|
||||
echo "<a href=\"award_awards.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
|
||||
echo "</td>";
|
||||
echo " <td align=\"center\" valign=\"top\">";
|
||||
echo "$numcontacts ";
|
||||
echo "<a href=\"award_contacts.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
|
||||
echo "</td>";
|
||||
echo " <td align=\"center\">";
|
||||
echo "<a href=\"sponsors.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
|
||||
echo " ";
|
||||
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this sponsor?')\" href=\"sponsors.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
|
||||
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
send_footer();
|
||||
|
||||
?>
|
107
admin/sponsorship.php
Normal file
107
admin/sponsorship.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2008 James Grant <james@lightbox.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
require_once("../user.inc.php");
|
||||
|
||||
user_auth_required('committee', 'admin');
|
||||
|
||||
if($_GET['id']) {
|
||||
$id=intval($_GET['id']);
|
||||
$q=mysql_query("SELECT * FROM sponsorships WHERE id='$id'");
|
||||
echo "<h2>Edit Sponsorship</h2>";
|
||||
$sponsorship=mysql_fetch_object($q);
|
||||
$formaction="sponsorshipedit";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<h2>Create New Sponsorship</h2>";
|
||||
$formaction="sponsorshipadd";
|
||||
$fundraising_type=$_GET['fundraising_type'];
|
||||
}
|
||||
|
||||
echo "<form method=\"post\" action=\"fundraising.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
|
||||
echo "<input type=\"hidden\" name=\"sponsorships_id\" value=\"$id\">";
|
||||
echo "<table cellspacing=0 cellpadding=0>";
|
||||
echo "<tr><td>".i18n("Sponsor")."</td>";
|
||||
echo "<td>";
|
||||
|
||||
$q=mysql_query("SELECT * FROM sponsors ORDER BY organization");
|
||||
echo mysql_error();
|
||||
echo "<select name=\"sponsors_id\">";
|
||||
echo "<option value=\"\">".i18n("Choose")."</option>\n";
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
if($r->id==$sponsorship->sponsors_id) $sel="selected=\"selected\""; else $sel="";
|
||||
echo "<option $sel value=\"$r->id\">$r->organization</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr><td>".i18n("Type")."</td>";
|
||||
echo "<td>";
|
||||
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY name");
|
||||
echo mysql_error();
|
||||
echo "<select name=\"fundraising_type\">";
|
||||
echo "<option value=\"\">".i18n("Choose")."</option>\n";
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
if($r->type==$sponsorship->fundraising_type || $r->type==$fundraising_type) $sel="selected=\"selected\""; else $sel="";
|
||||
echo "<option $sel value=\"$r->type\">$r->name</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>".i18n("Amount")."</td><td><input type=\"text\" name=\"value\" value=\"$sponsorship->value\"></td></tr>\n";
|
||||
|
||||
echo "<tr><td>".i18n("Status")."</td>";
|
||||
echo "<td>";
|
||||
echo "<select name=\"status\">";
|
||||
echo "<option value=\"\">".i18n("Choose")."</option>\n";
|
||||
$statuses=array("pending","confirmed","received");
|
||||
foreach($statuses AS $status) {
|
||||
if($sponsorship->status==$status) $sel="selected=\"selected\""; else $sel="";
|
||||
echo "<option $sel value=\"$status\">".i18n(ucfirst($status))."</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr><td>".i18n("Probability")."</td>";
|
||||
echo "<td>";
|
||||
echo "<select name=\"probability\">";
|
||||
echo "<option value=\"\">".i18n("Choose")."</option>\n";
|
||||
$probs=array("25","50","75","90","95","99","100");
|
||||
foreach($probs AS $prob) {
|
||||
if($sponsorship->probability==$prob) $sel="selected=\"selected\""; else $sel="";
|
||||
echo "<option $sel value=\"$prob\">$prob%</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr><td colspan=\"2\" style=\"text-align: center;\">";
|
||||
echo "<input onclick=\"return SFIABDialogSubmit()\" type=\"submit\" value=\"".i18n("Save")."\">\n";
|
||||
echo "<input onclick=\"return SFIABDialogCancel()\" type=\"button\" value=\"".i18n("Cancel")."\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
?>
|
@ -605,12 +605,7 @@ if($icon && theme_icon($icon)) {
|
||||
else
|
||||
echo "<td>";
|
||||
|
||||
/* Dump any messages in the queue */
|
||||
if(is_array($_SESSION['messages'])) {
|
||||
foreach($_SESSION['messages'] as $m) echo $m;
|
||||
}
|
||||
$_SESSION['messages'] = array();
|
||||
|
||||
|
||||
if($title)
|
||||
echo "<h2>".i18n($title)."</h2>";
|
||||
|
||||
@ -622,6 +617,12 @@ if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")
|
||||
}
|
||||
"</td></tr>";
|
||||
echo "</table>";
|
||||
/* 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();
|
||||
|
@ -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 ;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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%;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user