forked from science-ation/science-ation
enable deleting of fundraising campaigns under certain conditions
This commit is contained in:
parent
54b258e793
commit
8c12e443b0
@ -36,19 +36,29 @@ switch($_GET['action']){
|
||||
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)) {
|
||||
echo "<h3><a href=\"#\">".htmlspecialchars($r->name)."</a></h3>\n";
|
||||
echo "<h3 id=\"campaigntitle_{$r->id}\"><a href=\"#\">".htmlspecialchars($r->name)."</a></h3>\n";
|
||||
echo "<div id=\"campaign_{$r->id}\">\n";
|
||||
echo "<table>\n";
|
||||
echo "<form id=\"campaigninfo_{$r->id}\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" onsubmit=\"return campaigninfo_save($r->id)\">\n";
|
||||
echo "<input type=\"hidden\" name=\"campaign_id\" value=\"{$r->id}\" />\n";
|
||||
echo "<table>\n";
|
||||
display_campaign_form($r);
|
||||
?>
|
||||
<tr><td colspan="6" style="text-align: center;">
|
||||
<br />
|
||||
<input type="submit" value="<?=i18n("Save Appeal")?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<tr><td colspan="6" style="text-align: center;">
|
||||
<br />
|
||||
<?php
|
||||
echo "<form id=\"campaignremove_{$r->id}\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" onsubmit=\"return campaigninfo_remove($r->id)\">\n";
|
||||
echo "<input type=\"hidden\" name=\"campaign_id\" value=\"{$r->id}\" />\n";
|
||||
?>
|
||||
<br />
|
||||
<input type="submit" value="<?=i18n("Delete Appeal")?>"></td>
|
||||
</form>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
@ -493,8 +503,35 @@ switch($_GET['action']){
|
||||
mysql_query("DELETE FROM emails WHERE id='$emails_id'");
|
||||
happy_("Communicaton removed");
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
|
||||
case "campaign_remove":
|
||||
$campaign_id = $_POST['campaign_id'];
|
||||
if(is_numeric($campaign_id)) {
|
||||
mysql_query("DELETE FROM fundraising_campaigns WHERE
|
||||
(SELECT COUNT(*) FROM fundraising_donations WHERE fundraising_campaigns_id = $campaign_id) = 0 AND
|
||||
(SELECT count(*) FROM emails WHERE fundraising_campaigns_id = $campaign_id) = 0 AND
|
||||
id = $campaign_id");
|
||||
if(mysql_affected_rows() == 0) {
|
||||
error_("Cannot delete campaign. It is in use.");
|
||||
} else {
|
||||
mysql_query("DELETE FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id = $campaign_id");
|
||||
mysql_query("DELETE FROM fundraising_donations WHERE fundraising_campaigns_id = $campaign_id");
|
||||
mysql_query("DELETE FROM fundraising_donor_logs WHERE fundraising_campaigns_id = $campaign_id");
|
||||
mysql_query("DELETE FROM emailqueue WHERE fundraising_campaigns_id = $campaign_id");
|
||||
mysql_query("DELETE FROM emails WHERE fundraising_campaigns_id = $campaign_id");
|
||||
happy_("Campaign removed");
|
||||
echo "<script type=\"text/javascript\">";
|
||||
echo " $('#campaigntitle_$campaign_id').remove();";
|
||||
echo " $('#campaign_$campaign_id').remove();";
|
||||
echo "</script>";
|
||||
}
|
||||
} else {
|
||||
error_("Invalid Campaign ID");
|
||||
}
|
||||
|
||||
exit;
|
||||
break;
|
||||
|
||||
}
|
||||
@ -612,6 +649,11 @@ function campaigninfo_save(id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function campaigninfo_remove(id) {
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaign_remove", $("#campaignremove_"+id).serializeArray());
|
||||
return false;
|
||||
}
|
||||
|
||||
function update_tab_overview() {
|
||||
$("#campaign_tab_overview").load("<?$_SERVER['PHP_SELF']?>?action=manage_tab_overview&id="+currentcampaignid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user