diff --git a/admin/sponsors.php b/admin/sponsors.php index 4bc7bc1f..fada89e2 100644 --- a/admin/sponsors.php +++ b/admin/sponsors.php @@ -35,7 +35,13 @@ break; case 'organizationinfo_save': - $id=$_POST['sponsor_id']; + $id=intval($_POST['sponsor_id']); + if($id==-1) { + $q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')"); + $id=mysql_insert_id(); + echo json_encode(array("id"=>$id)); + } + if($id) { $exec="UPDATE sponsors SET ". "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ". @@ -59,7 +65,6 @@ //FIXME accept the logo //"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ". - happy_("Organization Info Saved"); } exit; break; @@ -126,8 +131,15 @@ function popup_editor(id) $('#popup_editor').dialog('option', 'height', h); $("#popup_editor").dialog('open'); - $('#editor_tabs').tabs('option', 'disabled', []); - $('#editor_tabs').tabs('option', 'selected', 0); + if(id==-1) { + $('#editor_tabs').tabs('option', 'selected', 0); + $('#editor_tabs').tabs('option', 'disabled', [1,2,3]); + + } + else { + $('#editor_tabs').tabs('option', 'selected', 0); + $('#editor_tabs').tabs('option', 'disabled', []); + } update_organizationinfo(); return false; @@ -136,7 +148,12 @@ function popup_editor(id) function update_organizationinfo() { var id=sponsor_id; - if(!sponsor_id) return false; + if(!sponsor_id) + return false; + if(sponsor_id==-1) { + $("#sponsor_id").val(-1); + return false; + } $.getJSON("=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id, function(json){ @@ -161,7 +178,18 @@ function update_organizationinfo() } function organizationinfo_save() { - $("#debug").load("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray()); + + //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($("#sponsor_id").val()==-1) { + $.post("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray(), + function(json) { + $("#popup_editor").dialog('close'); + popup_editor(json.id); + }, + "json"); + } + else + $("#debug").load("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray()); return false; } @@ -269,43 +297,6 @@ function activityinfo_save() { - if($_POST['save']=="edit" || $_POST['save']=="add") - { - if($_POST['save']=="add") - { - $q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')"); - $id=mysql_insert_id(); - } - else - $id=$_POST['id']; - - - $exec="UPDATE sponsors SET ". - "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ". - "address='".mysql_escape_string(stripslashes($_POST['address']))."', ". - "city='".mysql_escape_string(stripslashes($_POST['city']))."', ". - "province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ". - "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ". - "phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ". - "tollfree='".mysql_escape_string(stripslashes($_POST['tollfree']))."', ". - "fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ". - "email='".mysql_escape_string(stripslashes($_POST['email']))."', ". - "website='".mysql_escape_string(stripslashes($_POST['website']))."', ". - "notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ". - "donationpolicyurl='".mysql_escape_string(stripslashes($_POST['donationpolicyurl']))."', ". - "fundingselectiondate='".mysql_escape_string(stripslashes($_POST['fundingselectiondate']))."', ". - "logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ". - "waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."', ". - "taxreceiptrequired='".mysql_escape_string(stripslashes($_POST['taxreceiptrequired']))."' ". - "WHERE id='$id'"; - mysql_query($exec); - - if($_POST['save']=="add") - echo happy("Sponsor successfully added"); - else - echo happy("Successfully saved changes to sponsor"); - } - if($_GET['action']=="delete" && $_GET['delete']) { //dont allow any deleting until we figure out what we need to do, infact, i think we never should hard delete @@ -314,73 +305,7 @@ function activityinfo_save() { // echo happy("Sponsors cannot be deleted"); } - if($_GET['action']=="edit" || $_GET['action']=="add") - { - - echo "<< ".i18n("Back to Award Sponsors")."\n"; - if($_GET['action']=="edit") - { - echo "
# of Sponsorships | "; echo "# of Awards | "; echo "# of Contacts | "; - echo "Action | "; +// echo "Action | "; echo "";
- echo "id\"> | \n";
echo "\n";
}
echo "
---|