2008-10-22 21:46:31 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
2008-10-23 21:32:31 +00:00
Copyright ( C ) 2008 James Grant < james @ lightbox . org >
2008-10-22 21:46:31 +00:00
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 ( " ../tableeditor.class.php " );
require_once ( " ../user.inc.php " );
user_auth_required ( 'committee' , 'admin' );
2008-10-24 22:46:35 +00:00
include ( " fundraising_sponsorship_handler.inc.php " );
include ( " fundraising_types_handler.inc.php " );
2008-10-23 21:32:31 +00:00
2008-10-22 21:46:31 +00:00
send_header ( " Fundraising " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ),
" fundraising "
);
2008-10-24 22:29:14 +00:00
require_once ( " ../dialog.inc.php " );
2008-10-22 21:46:31 +00:00
//first, insert any defaults
$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 )) {
2008-11-06 21:06:40 +00:00
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' ] . " ') " );
2008-10-22 21:46:31 +00:00
}
}
//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.
2008-10-25 04:25:38 +00:00
$q = mysql_query ( " SELECT * FROM fundraising WHERE year=' { $config [ 'FAIRYEAR' ] } ' ORDER BY system DESC,type " );
2008-10-23 21:32:31 +00:00
echo " <table class= \" fundraisingtable \" > " ;
2008-10-24 22:46:35 +00:00
2008-10-22 21:46:31 +00:00
while ( $r = mysql_fetch_object ( $q )) {
echo " <tr> " ;
2008-11-06 21:06:40 +00:00
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> " ;
2008-10-25 04:25:38 +00:00
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\ " >< img border = \ " 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
}
echo " </th> \n " ;
2008-10-24 22:29:14 +00:00
echo " <th colspan= \" 5 \" > " . i18n ( $r -> name ) . " </th> \n " ;
2008-10-23 21:32:31 +00:00
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 )
2008-10-25 04:33:18 +00:00
AND sponsorships . year = '{$config[' FAIRYEAR ']}'
ORDER BY status DESC , probability DESC , organization " );
2008-10-23 21:32:31 +00:00
while ( $sr = mysql_fetch_object ( $sq )) {
2008-10-24 22:29:14 +00:00
echo " <tr id= \" sponsorships_ $sr->id\ " class = \ " fundraising { $sr -> status } \" > " ;
2008-10-28 21:19:21 +00:00
echo " <td><a title= \" " . i18n ( " Edit sponsorship details " ) . " \" onclick= \" return SFIABDialog(event,'fundraising_sponsorship.php?id= $sr->id &fundraising_type= $r->type ',400,250) \" href= \" # \" ><img border= \" 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" ></a> " ;
2008-10-25 04:25:38 +00:00
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\ " >< img border = \ " 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " </td> " ;
echo " <td> $sr->organization </td> \n " ;
/*
echo " <a href= \" communication.php?action=edit&edit= $r->id\ " >< img border = \ " 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" ></a> " ;
//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\ " >< img border = 0 src = \ " " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " " ;
echo " <a href= \" communication.php?action=send&send= $r->id\ " > Send </ a > " ;
}
*/
2008-10-23 21:32:31 +00:00
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> " ;
2008-10-28 21:19:21 +00:00
echo " <td><a onclick= \" return SFIABDialog(event,'fundraising_sponsorship.php?fundraising_type= $r->type ',400,250) \" href= \" # \" >add</a></td> " ;
2008-10-23 21:32:31 +00:00
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 " ;
2008-10-22 21:46:31 +00:00
$totalgoal += $r -> goal ;
2008-10-23 21:32:31 +00:00
$totaldiff += $typediff ;
echo " <tr><td colspan= \" 7 \" > </td></tr> \n " ;
2008-10-22 21:46:31 +00:00
}
2008-10-24 22:29:14 +00:00
echo " <tr> " ;
2008-11-07 03:25:43 +00:00
echo " <td colspan= \" 2 \" ><a onclick= \" return SFIABDialog(event,'fundraising_types.php',400,250) \" href= \" # \" >add fund type</a></td> " ;
2008-10-24 22:29:14 +00:00
echo " <td colspan= \" 4 \" 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 " ;
2008-10-22 21:46:31 +00:00
echo " </table> \n " ;
2008-10-25 04:25:38 +00:00
echo " <br /> \n " ;
echo " <br /> \n " ;
2008-11-06 21:06:40 +00:00
echo " <a href= \" sponsorship_levels.php \" >Manage Sponsorship Levels</a> \n " ;
echo " <br /> \n " ;
2008-10-25 04:25:38 +00:00
echo " <a href= \" sponsors.php \" >Manage Sponsors</a> \n " ;
2008-11-06 21:06:40 +00:00
echo " <br /> \n " ;
2008-10-22 21:46:31 +00:00
send_footer ();
?>