Use the happy_ and error_ functions and load the ajax into the debug div

This commit is contained in:
james 2009-09-18 19:25:26 +00:00
parent c1d7b8fc24
commit 8aabd98fe0
3 changed files with 35 additions and 31 deletions

View File

@ -75,12 +75,12 @@ function popup_sponsorship_editor(url) {
} }
function save_sponsorship() { function save_sponsorship() {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php", $('#debug').load("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
$("#fundraisingsponsorship").serialize(), $("#fundraisingsponsorship").serializeArray(),
function(data) { function() {
$('#sponsorship_editor').dialog('close'); $('#sponsorship_editor').dialog('close');
refresh_fundraising_table();
}); });
refresh_fundraising_table();
return false; return false;
} }
@ -102,31 +102,35 @@ function popup_fund_editor(url) {
} }
function save_fund() { function save_fund() {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php", $("#debug").load("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
$("#fundraisingfundraising").serialize(), $("#fundraisingfundraising").serializeArray(),
function(data) { function(data) {
$('#fund_editor').dialog('close'); $('#fund_editor').dialog('close');
refresh_fundraising_table();
}); });
refresh_fundraising_table();
return false; return false;
} }
function delete_fund(id) { function delete_fund(id) {
if(confirmClick('Are you sure you want to remove this fund?')) { if(confirmClick('Are you sure you want to remove this fund?')) {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php", $('#debug').load("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
{ action: 'funddelete', delete: id } { action: 'funddelete', delete: id },
function() {
refresh_fundraising_table();
}
); );
refresh_fundraising_table();
} }
return false; return false;
} }
function delete_sponsorship(id) { function delete_sponsorship(id) {
if(confirmClick('Are you sure you want to remove this sponsorship?')) { if(confirmClick('Are you sure you want to remove this sponsorship?')) {
$.post("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php", $('#debug').load("<?=$config['SFIABDIRECTORY']?>/admin/fundraising.php",
{ action: 'sponsorshipdelete', delete: id } { action: 'sponsorshipdelete', delete: id },
function() {
refresh_fundraising_table();
}
); );
refresh_fundraising_table();
} }
return false; return false;
} }

View File

@ -2,7 +2,7 @@
if($_POST['action']=="sponsorshipdelete") { if($_POST['action']=="sponsorshipdelete") {
mysql_query("DELETE FROM sponsorships WHERE id='".intval($_POST['delete'])."'"); mysql_query("DELETE FROM sponsorships WHERE id='".intval($_POST['delete'])."'");
if(mysql_affected_rows()) if(mysql_affected_rows())
message_push(happy(i18n("Successfully removed sponsorship"))); happy_("Successfully removed sponsorship");
exit; exit;
} }
@ -50,15 +50,15 @@ if($_POST['action']=="sponsorshipedit") {
} }
if(mysql_error()) if(mysql_error())
message_push(error(mysql_error())); echo error_(mysql_error());
else else
message_push(happy(i18n("Saved sponsorship changes"))); echo happy_("Saved sponsorship changes");
} }
else else
message_push(happy(i18n("No changes were made"))); echo error_("No changes were made");
} }
else { else {
message_push(error(i18n("Required fields were missing, please try again"))); echo error_("Required fields were missing, please try again");
} }
exit; exit;
} }
@ -70,12 +70,12 @@ if($_POST['action']=="sponsorshipadd") {
NOW(), NOW(),
'".$_SESSION['users_id']."', '".$_SESSION['users_id']."',
'".mysql_real_escape_string("Created sponsorship: type=$fundraising_type, value=\$$value, status=$status, probability=$probability%")."')"); '".mysql_real_escape_string("Created sponsorship: type=$fundraising_type, value=\$$value, status=$status, probability=$probability%")."')");
message_push(happy(i18n("Added new sponsorship"))); happy_("Added new sponsorship");
} }
else else
message_push(error(i18n("Required fields were missing, please try again"))); error_("Required fields were missing, please try again");
if(mysql_error()) if(mysql_error())
message_push(error(mysql_error())); error_(mysql_error());
exit; exit;
} }

View File

@ -10,10 +10,10 @@ if($_POST['action']=="funddelete" && $_POST['delete']) {
mysql_query("DELETE FROM sponsorships WHERE fundraising_type='".mysql_real_escape_string($f->type)."' AND year='".$config['FAIRYEAR']."'"); mysql_query("DELETE FROM sponsorships WHERE fundraising_type='".mysql_real_escape_string($f->type)."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM fundraising WHERE id='$id'"); mysql_query("DELETE FROM fundraising WHERE id='$id'");
if(mysql_affected_rows()) if(mysql_affected_rows())
message_push(happy(i18n("Successfully removed fund %1",array($f->name)))); happy_("Successfully removed fund %1",array($f->name));
} }
else { else {
message_push(error(i18n("Cannot remove system fund"))); error_("Cannot remove system fund");
} }
} }
exit; exit;
@ -40,12 +40,12 @@ if($_POST['action']=="fundedit") {
mysql_query("UPDATE fundraising SET goal='$goal', description='$description', type='$type', name='$name' WHERE id='$fundraising_id'"); mysql_query("UPDATE fundraising SET goal='$goal', description='$description', type='$type', name='$name' WHERE id='$fundraising_id'");
} }
if(mysql_error()) if(mysql_error())
message_push(error(mysql_error())); error_("MySQL Error: %1",array(mysql_error()));
else else
message_push(happy(i18n("Saved fund changes"))); happy_("Saved fund changes");
} }
else { else {
message_push(error(i18n("Required fields were missing, please try again"))); error_("Required fields were missing, please try again");
} }
exit; exit;
@ -53,12 +53,12 @@ if($_POST['action']=="fundedit") {
if($_POST['action']=="fundadd") { if($_POST['action']=="fundadd") {
if( $goal && $type && $name) { if( $goal && $type && $name) {
mysql_query("INSERT INTO fundraising (type,name,description,system,goal,year) VALUES ('$type','$name','$description','no','$goal','{$config['FAIRYEAR']}')"); mysql_query("INSERT INTO fundraising (type,name,description,system,goal,year) VALUES ('$type','$name','$description','no','$goal','{$config['FAIRYEAR']}')");
message_push(happy(i18n("Added new fund"))); happy_("Added new fund");
} }
else else
message_push(error(i18n("Required fields were missing, please try again"))); error_("Required fields were missing, please try again");
if(mysql_error()) if(mysql_error())
message_push(error(mysql_error())); error_("MySQL Error: %1",array(mysql_error()));
exit; exit;
} }