forked from science-ation/science-ation
Rework the donors search/landing page so it shows top 10 donors if no search is performed yet
Fix a few typo's and make the fundingselection/proposalsubmissiondate save properly
This commit is contained in:
parent
7b4e7cd55f
commit
5d9824a5a6
@ -65,9 +65,11 @@ switch($_GET['action']) {
|
||||
"notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ".
|
||||
"donationpolicyurl='".mysql_escape_string(stripslashes($_POST['donationpolicyurl']))."', ".
|
||||
"fundingselectiondate='".mysql_escape_string(stripslashes($_POST['fundingselectiondate']))."', ".
|
||||
"proposalsubmissiondate='".mysql_escape_string(stripslashes($_POST['proposalsubmissiondate']))."', ".
|
||||
"waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."' ".
|
||||
"WHERE id='$id'";
|
||||
mysql_query($exec);
|
||||
echo mysql_error();
|
||||
|
||||
//FIXME accept the logo
|
||||
//"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
|
||||
@ -132,7 +134,7 @@ switch($_GET['action']) {
|
||||
echo "<table class=\"tableview\">";
|
||||
echo "<tr>";
|
||||
echo " <th>".i18n("Date")."</th>\n";
|
||||
echo " <th>".i18n("Goal")."</th>\n";
|
||||
echo " <th>".i18n("Purpose")."</th>\n";
|
||||
echo " <th>".i18n("Appeal")."</th>\n";
|
||||
echo " <th>".i18n("Value")."</th>\n";
|
||||
echo "</tr>";
|
||||
@ -157,7 +159,7 @@ switch($_GET['action']) {
|
||||
echo "<table class=\"tableview\">";
|
||||
echo "<tr>";
|
||||
echo " <th>".i18n("Date")."</th>\n";
|
||||
echo " <th>".i18n("Goal")."</th>\n";
|
||||
echo " <th>".i18n("Purpose")."</th>\n";
|
||||
echo " <th>".i18n("Appeal")."</th>\n";
|
||||
echo " <th>".i18n("Value")."</th>\n";
|
||||
echo "</tr>";
|
||||
@ -841,9 +843,9 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$("#organizationinfo_fundingselectiondate").datepicker({ dateFormat: 'yy-mm-dd'});
|
||||
$("#organizationinfo_proposalsubmissiondate").datepicker({ dateFormat: 'yy-mm-dd'});
|
||||
//, showOn: 'button', buttonText: "<?=i18n("calendar")?>" });
|
||||
open_search();
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -871,6 +873,7 @@ function open_editor(id) {
|
||||
$("#organizationinfo_website").val("");
|
||||
$("#organizationinfo_donationpolicyurl").val("");
|
||||
$("#organizationinfo_fundingselectiondate").val("");
|
||||
$("#organizationinfo_proposalsubmissiondate").val("");
|
||||
$("#organizationinfo_notes").val("");
|
||||
|
||||
$("#organizationinfo_save_button").attr('disabled','disabled');
|
||||
@ -889,8 +892,7 @@ function open_editor(id) {
|
||||
function open_search() {
|
||||
$("#donor_editor").hide();
|
||||
$("#searchbrowse").show();
|
||||
|
||||
|
||||
donorsearch(false);
|
||||
}
|
||||
function update_organizationinfo()
|
||||
{
|
||||
@ -919,6 +921,7 @@ function update_organizationinfo()
|
||||
$("#organizationinfo_website").val(json.website);
|
||||
$("#organizationinfo_donationpolicyurl").val(json.donationpolicyurl);
|
||||
$("#organizationinfo_fundingselectiondate").val(json.fundingselectiondate);
|
||||
$("#organizationinfo_proposalsubmissiondate").val(json.proposalsubmissiondate);
|
||||
$("#organizationinfo_notes").val(json.notes);
|
||||
// For some reason, with checkboxes, these have to be arrays
|
||||
$("[name=waiveraccepted]").val([json.waiveraccepted]);
|
||||
@ -1011,10 +1014,13 @@ function activityinfo_save() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function donorsearch() {
|
||||
function donorsearch(realsearch) {
|
||||
$("#searchresults").show();
|
||||
$("#searchresults").load("donors_search.php", $("#searchform").serializeArray());
|
||||
return false;
|
||||
if(realsearch)
|
||||
$("#searchresults").load("donors_search.php", $("#searchform").serializeArray());
|
||||
else
|
||||
$("#searchresults").load("donors_search.php"); //, $("#searchform").serializeArray());
|
||||
return false;
|
||||
}
|
||||
|
||||
var searchtimer;
|
||||
@ -1125,8 +1131,8 @@ echo "<hr />";
|
||||
</tr>
|
||||
<tr><td><?=i18n("Donation Policy")?></td><td colspan="5"><input id="organizationinfo_donationpolicyurl" type="file" name="donationpolicyurl" size="30" maxlength="128" /></td></tr>
|
||||
<tr><td><?=i18n("Logo")?></td><td colspan="5"><input type="file" id="organizationinfo_logo" name="logo" size="30" /></td></tr>
|
||||
<tr><td><?=i18n("Funding Selection Date")?></td><td><input id="organizationinfo_fundingselectiondate" type="text" name="fundingselectiondate" size="10" maxlength="10" /></td>
|
||||
<td><?=i18n("Proposal Submission Date")?></td><td colspan="3"><input id="organizationinfo_proposalsubmissiondate" type="text" name="proposalsubmissiondate" size="10" maxlength="10" /></td>
|
||||
<tr><td><?=i18n("Funding Selection Date")?></td><td><input id="organizationinfo_fundingselectiondate" type="text" name="fundingselectiondate" class="date" size="12" maxlength="12" /></td>
|
||||
<td><?=i18n("Proposal Submission Date")?></td><td colspan="3"><input id="organizationinfo_proposalsubmissiondate" type="text" name="proposalsubmissiondate" class="date" size="12" maxlength="12" /></td>
|
||||
</tr>
|
||||
<?
|
||||
/*
|
||||
@ -1164,7 +1170,8 @@ echo "<hr />";
|
||||
|
||||
|
||||
<div id="searchbrowse" style="display: none;">
|
||||
<form id="searchform" method="post" action="donors.php" onsubmit="return donorsearch()">
|
||||
<form id="searchform" method="post" action="donors.php" onsubmit="return donorsearch(true)">
|
||||
<input type="hidden" name="limit" value="-1" />
|
||||
<?=i18n("Search")?>: <input type="text" name="search" />
|
||||
<input id="search_donortype_individual" type="checkbox" name="donortype[]" value="individual" checked="checked" /><label for="search_donortype_individual"><?=i18n("Individual")?></label>
|
||||
<input id="search_donortype_organization" type="checkbox" name="donortype[]" value="organization" checked="checked"/><label for="search_donortype_organization"><?=i18n("Organization")?></label>
|
||||
|
@ -42,54 +42,78 @@
|
||||
// echo "query=$query";
|
||||
$q=mysql_query($query);
|
||||
|
||||
|
||||
echo "<table class=\"tableview\">";
|
||||
echo "<tr>";
|
||||
echo " <th>Organization</th>";
|
||||
// echo " <th># of Sponsorships</th>";
|
||||
// echo " <th># of Awards</th>";
|
||||
echo " <th># of Contacts</th>";
|
||||
// echo " <th>Action</th>";
|
||||
echo "</tr>\n";
|
||||
$thisyear=$config['FISCALYEAR'];
|
||||
$lastyear=$config['FISCALYEAR']-1;
|
||||
$rows=array();
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='$r->id' AND status='received' AND fiscalyear='$thisyear'");
|
||||
$cr=mysql_fetch_object($cq);
|
||||
$thisyeartotal=$cr->total;
|
||||
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='$r->id' AND status='received' AND fiscalyear='$lastyear'");
|
||||
$cr=mysql_fetch_object($cq);
|
||||
$lastyeartotal=$cr->total;
|
||||
if($lastyeartotal)
|
||||
$change=round(($thisyeartotal-$lastyeartotal)/$lastyeartotal*100);
|
||||
else
|
||||
$change="N/A";
|
||||
$rows[]=array("id"=>$r->id, "name"=>$r->organization, "thisyeartotal"=>$thisyeartotal, "lastyeartotal"=>$lastyeartotal, "change"=>$change);
|
||||
}
|
||||
$thisyearsort=array();
|
||||
if(!$_POST['order']) {
|
||||
//if order is not given, lets order by donation amount this year
|
||||
foreach($rows AS $key=>$val) {
|
||||
$thisyearsort[$key]=$val['thisyeartotal'];
|
||||
}
|
||||
array_multisort($thisyearsort,SORT_DESC,$rows);
|
||||
}
|
||||
|
||||
if($_POST['limit']) {
|
||||
$limit=$_POST['limit'];
|
||||
}
|
||||
else {
|
||||
$limit=10;
|
||||
echo "<h4>".i18n("Top 10 donors this year")."</h4>";
|
||||
}
|
||||
|
||||
echo "<table class=\"tableview\">";
|
||||
echo "<tr>";
|
||||
echo " <th>Donor/Sponsor</th>";
|
||||
echo " <th>Total $ this year</th>";
|
||||
echo " <th>Total $ last year</th>";
|
||||
echo " <th>% change</th>";
|
||||
echo "</tr>\n";
|
||||
|
||||
|
||||
$x=0;
|
||||
foreach($rows AS $r) {
|
||||
echo "<tr>\n";
|
||||
$eh="style=\"cursor:pointer;\" onclick=\"open_editor({$r->id});\"";
|
||||
echo " <td $eh>$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(id) AS num FROM fundraising_donations WHERE fiscalyear='".$config['FISCALYEAR']."' AND sponsors_id='$r->id'");
|
||||
$numr=mysql_fetch_object($numq);
|
||||
$numsponsorships=$numr->num;
|
||||
|
||||
$numq=mysql_query("SELECT uid,MAX(year),firstname,lastname,deleted FROM users,users_sponsor WHERE types LIKE '%sponsor%' AND sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.deleted='no' GROUP BY uid ORDER BY firstname");
|
||||
// $numq=mysql_query("SELECT DISTINCT(uid) FROM users_sponsor, users WHERE sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.deleted='no'");
|
||||
$numcontacts=mysql_num_rows($numq);
|
||||
// $numr=mysql_fetch_object($numq);
|
||||
// $numcontacts=$numr->num;
|
||||
|
||||
|
||||
/*
|
||||
echo " <td align=\"center\" valign=\"top\">";
|
||||
echo "$numsponsorships ";
|
||||
echo "<a href=\"fundraising.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 "$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=\"sponsor_contacts.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
|
||||
echo "</td>";
|
||||
$eh="style=\"cursor:pointer;\" onclick=\"open_editor({$r['id']});\"";
|
||||
echo " <td $eh>{$r['name']}</td>\n";
|
||||
echo " <td style=\"text-align: right;\">";
|
||||
echo format_money($r['thisyeartotal']);
|
||||
echo "</td>\n";
|
||||
echo " <td style=\"text-align: right;\">";
|
||||
echo format_money($r['lastyeartotal']);
|
||||
echo "</td>\n";
|
||||
if(is_numeric($r['change'])) {
|
||||
$n=$r['change']/2+50;
|
||||
if($n<0) $n=0;
|
||||
if($n>100) $n=100;
|
||||
$col="color: ".colour_to_percent($n);
|
||||
$sign="%";
|
||||
}
|
||||
else{
|
||||
$col=""; $sign=""; }
|
||||
echo " <td style=\"text-align: center; $col\">";
|
||||
echo $r['change'].$sign;
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
$x++;
|
||||
if($x==$limit)
|
||||
break;
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
|
Loading…
Reference in New Issue
Block a user