$q=mysql_query("SELECT * FROM fundraising WHERE year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q)){
$q=mysql_query("SELECT * FROM fundraising WHERE year='-1'");
while($r=mysql_fetch_object($q)){
mysql_query("INSERT INTO fundraising (`type`,`name`,`description`,`system`,`goal`,`year`) VALUES ('$r->type','".mysql_real_escape_string($r->name)."','".mysql_real_escape_string($r->description)."','$r->system','$r->goal','".$config['FAIRYEAR']."')");
}
}
//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 DESC,type");
echo"<table class=\"fundraisingtable\">";
while($r=mysql_fetch_object($q)){
echo"<tr>";
echo"<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
if($r->system=="no"){
echo"<a title=\"".i18n("Remove Fund")."\" onclick=\"return confirmClick('Are you sure you want to remove this fund and all sponsorships inside it?')\" href=\"fundraising.php?action=funddelete&delete=$r->id\"><imgborder=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo"<a title=\"".i18n("Remove sponsorship")."\" onclick=\"return confirmClick('Are you sure you want to remove this sponsorship?')\" href=\"fundraising.php?action=sponsorshipdelete&delete=$sr->id\"><imgborder=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a></nobr>";
//only user emails can be deleted, system ones are required and cannot be removed
if($r->type=="user")
{
echo" ";
echo"<a onclick=\"return confirmClick('Are you sure you want to remove email?')\" href=\"communication.php?action=delete&delete=$r->id\"><imgborder=0src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";