Split otu campaign management to create/modify, and management

Add tabs for the management
This commit is contained in:
james 2009-10-07 21:22:23 +00:00
parent 087e89248a
commit 7d42f697e7

View File

@ -31,7 +31,7 @@ switch($_GET['action']){
exit;
break;
case "display":
case "modify":
echo "<div id=\"campaignaccordion\" style=\"width: 780px;\">\n";
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
while($r=mysql_fetch_object($q)) {
@ -71,6 +71,92 @@ switch($_GET['action']){
<?
exit;
break;
case "managelist":
echo i18n("Select a campaign");
?>
<table class="tableview">
<tr>
<th><?=i18n("Name")?></th>
<th><?=i18n("Type")?></th>
<th><?=i18n("Start Date")?></th>
<th><?=i18n("End Date")?></th>
<th><?=i18n("Goal")?></th>
<th><?=i18n("Target($)")?></th>
<th><?=i18n("Received")?></th>
<th><?=i18n("% to Budget")?></th>
</tr>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'");
while($r=mysql_fetch_object($q)) {
$goalq=mysql_query("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'");
$goalr=mysql_fetch_object($goalq);
$recq=mysql_query("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_campaigns_id='$r->id' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'");
echo mysql_error();
$recr=mysql_fetch_object($recq);
$received=$recr->received;
if($r->budget)
$percent=round($received/$r->target*100,1);
else
$percent=0;
$col=colour_to_percent($percent);
echo "<tr style=\"cursor:pointer;\" onclick=\"return managecampaign($r->id)\">\n";
echo " <td>$r->name</td>\n";
echo " <td>$r->type</td>\n";
echo " <td>".format_date($r->startdate)."</td>\n";
echo " <td>".format_date($r->enddate)."</td>";
echo " <td>$goalr->name</td>";
echo " <td style=\"text-align: right;\">".format_money($r->target,false)."</td>\n";
echo " <td style=\"text-align: right;\">".format_money($received,false)."</td>\n";
echo " <td style=\"text-align: center; background-color: $col;\">{$percent}%</td>\n";
echo "</tr>\n";
}
?>
</tr>
</table>
<br />
<?
exit;
break;
case "manage":
if(!$_GET['id']) {
error_("Missing campaign to manage");
exit;
}
$id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE id='$id'");
$campaign=mysql_fetch_object($q);
echo "<h3>$campaign->name</h3>\n";
?>
<div id="campaign_tabs">
<ul>
<li><a href="#campaign_tab_overview"><span><?=i18n('Overview')?></span></a></li>
<li><a href="#campaign_tab_donations"><span><?=i18n('Donations/Sponsorships')?></span></a></li>
<li><a href="#campaign_tab_prospects"><span><?=i18n('Prospects')?></span></a></li>
<li><a href="#campaign_tab_communications"><span><?=i18n('Communications')?></span></a></li>
</ul>
<div id="campaign_tab_overview">
overview tab
</div>
<div id="campaign_tab_donations">
donations tab
</div>
<div id="campaign_tab_prospects">
prospects tab
</div>
<div id="campaign_tab_communications">
communications tab
</div>
</div>
<?
exit;
break;
}
function save_campaign_info(){
@ -112,15 +198,26 @@ send_header("Campaign Management",
<script type="text/javascript">
$(document).ready(function() {
loadcampaigns();
managecampaigns();
});
function loadcampaigns() {
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=display", null, function() {loadcampaignsfinish();});
function modifycampaigns() {
$("#campaigndiv").show();
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=modify", null, function() {modifycampaignsfinish();});
}
function managecampaigns() {
$("#campaigndiv").show();
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=managelist", null, function() {managecampaignsfinish();});
}
function managecampaign(id) {
$("#campaigndiv").show();
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=manage&id="+id, null, function() {managecampaignfinish();});
}
function loadcampaignsfinish(){
function modifycampaignsfinish(){
$("#campaignaccordion").accordion();
// create the date pickers for our form
$(".date").datepicker({
@ -128,12 +225,39 @@ function loadcampaignsfinish(){
});
}
function managecampaignsfinish() {
}
function managecampaignfinish() {
$("#campaign_tabs").tabs({
show: function(event, ui) {
switch(ui.panel.id) {
case 'campaign_tab_overview':
// update_organizationinfo();
break;
case 'campaign_tab_donations':
// update_sponsorshipinfo();
break;
case 'campaign_tab_prospects':
// update_contactsinfo();
break;
case 'campaign_tab_communications':
// update_activityinfo();
break;
}
},
selected: 0,
});
}
function campaigninfo_save(id) {
//if we're creating we need to do the post, and get the id it returns, so we can re-open the popup window with that id
if(id==-1) {
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaigninfo_save", $("#campaigninfo_new").serializeArray(), function() { loadcampaigns(); });
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaigninfo_save", $("#campaigninfo_new").serializeArray(), function() { modifycampaigns(); });
} else {
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaigninfo_save&id="+id, $("#campaigninfo_"+id).serializeArray(), function() { loadcampaigns(); });
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaigninfo_save&id="+id, $("#campaigninfo_"+id).serializeArray(), function() { modifycampaigns(); });
}
return false;
}
@ -176,8 +300,15 @@ function display_campaign_form($r=null) {
<?
}
?>
<table cellspacing=2 width=740 border=0>
<tr><td>
<a href="#" onclick="modifycampaigns()">Create/Modify Campaigns</a>
</td><td>
<a href="#" onclick="managecampaigns()">Campaign Management</a>
</td></tr></table>
<hr />
<div id="campaigndiv" style="width: 780px;">
<div id="campaigndiv" style="width: 780px; display: none;">
</div>
<?