diff --git a/admin/award_awards.php b/admin/award_awards.php index f61709d..33f2455 100644 --- a/admin/award_awards.php +++ b/admin/award_awards.php @@ -100,7 +100,7 @@ case 'award_create': //wipe out any old award-category links mysql_query("DELETE FROM award_awards_projectcategories WHERE award_awards_id='$id'"); - foreach($_GET['categories'] AS $cat) { + foreach($_GET['categories'] AS $key=>$cat) { mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES ('$id','$cat','{$config['FAIRYEAR']}')"); } @@ -109,7 +109,7 @@ case 'award_create': mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$id'"); //now add the new ones - foreach($_POST['eligibledivisions'] AS $div) { + foreach($_GET['divisions'] AS $key=>$div) { mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES ('$id','$div','{$config['FAIRYEAR']}')"); } @@ -223,7 +223,7 @@ function update_awardinfo() } -function save_awardinfo() +function awardinfo_save() { $("#awardinfo_info").load("?action=awardinfo_save", $("#awardinfo").serialize()); return 0; @@ -234,15 +234,30 @@ function update_eligibility() var id = award_id; $.getJSON("?action=eligibilty_load&id="+id, function(json){ - $("[name=eligiblecategories]").val(json.categories); - $("[name=eligibledivisions]").val(json.divisions); + $("#eligibility_id").val(json.id); + $("[name=categories\\[\\]]").val(json.categories); + $("[name=divisions\\[\\]]").val(json.divisions); }); } +function prizelist_refresh() +{ + $("#prizelist").tableDnD({ + onDrop: function(table, row) { + var order = $.tableDnD.serialize(); + $("#prizeinfo_info").load("?action=prize_order&"+order); + /* Change the order */ + var rows = table.tBodies[0].rows; + for (var i=0; i?action=prizeinfo_load&id="+id, function(json) { $(".prizelist_tr").remove(); @@ -260,18 +275,7 @@ function update_prizeinfo() "/images/16/button_cancel.\">"+ ""); } - $("#prizelist").tableDnD({ - onDrop: function(table, row) { - var order = $.tableDnD.serialize(); - $("#prizeinfo_info").load("?action=prize_order&"+order); - /* Change the order */ - var rows = table.tBodies[0].rows; - for (var i=0; i?action=eligibility_save", $("#eligibility").serialize()); + return 0; +} + function prize_save() { $("#prizeinfo_info").load("?action=prize_save", $("#prizeinfo").serialize()); @@ -308,7 +318,9 @@ function prize_delete(id) var confirm = confirmClick('Are you sure you want to delete this prize?'); if(confirm == true) { $("#prizeinfo_info").load("?action=prize_delete&id="+id); - update_prizeinfo(); + $(".prizelist_tr#"+id).fadeTo('slow', 0); + $(".prizelist_tr#"+id).remove(); + prizelist_refresh(); } return 0; } @@ -408,13 +420,16 @@ htabs_tab_begin('awardinfo'); - +

+
+
+ "; +?> + - echo ""; - echo ""; // if(count($currentcategories)==0 || count($currentdivisions)==0) // echo ""; - echo "
: id}\" name=\"eligiblecategories\" value=\"$cr->id\" />".i18n($cr->category)."
"; + echo "id}\" name=\"categories[]\" value=\"$cr->id\" />".i18n($cr->category)."
"; } - echo "
".i18n("Divisions").":"; +
: +id}\" name=\"eligibledivisions\" value=\"$dr->id\" />".i18n($dr->division)."
"; + echo "id}\" name=\"divisions[]\" value=\"$dr->id\" />".i18n($dr->division)."
"; } - - echo "
".i18n("At least one age category and one division must be selected")."
"; + +?> + +
+ +?action=award_create", - function(json) { - popup_editor(json.id); - /* Ensure we open on the first tab */ - // $("#htabs_awardinfo_tab").click(); - }); -// alert("ok"); - return 0; -} - -function award_delete(id) -{ - var conf = confirmClick(''); - if(conf == true) { - $("#info_info").load("?action=award_delete&id="+id); - /* The TRs need to have just a numeric ID, which could conflict with other lists, so - * tag each TR with a class too, and select both the class and the ID */ - $(".awardlist_tr#"+id).fadeTo('slow', 0); - $(".awardlist_tr#"+id).remove(); - } - -} - -$(document).ready(function() { $("#awardlist").tableDnD({ onDrop: function(table, row) { var order = $.tableDnD.serialize(); @@ -577,7 +572,40 @@ $(document).ready(function() { }, dragHandle: "drag_handle" }); +} +function award_create() +{ + $.getJSON("?action=award_create", + function(json) { + popup_editor(json.id); + /* Ensure we open on the first tab */ + $("#htabs_awardinfo_tab").click(); + /* FUIXME: insert data into the list */ + awardlist_refresh(); + }); +// alert("ok"); + return 0; +} + + +function award_delete(id) +{ + var conf = confirmClick(''); + if(conf == true) { + $("#info_info").load("?action=award_delete&id="+id); + /* The TRs need to have just a numeric ID, which could conflict with other lists, so + * tag each TR with a class too, and select both the class and the ID */ + $(".awardlist_tr#"+id).fadeTo('slow', 0); + $(".awardlist_tr#"+id).remove(); + /* Rows changed, need to refresh the drag list */ + awardlist_refresh(); + } + +} + +$(document).ready(function() { + awardlist_refresh(); // $(".awardlist_tr#166").css('background-color','red'); });