diff --git a/admin/award_awards.php b/admin/award_awards.php index 33f2455..fb27a43 100644 --- a/admin/award_awards.php +++ b/admin/award_awards.php @@ -139,7 +139,11 @@ case 'award_create': case 'prizeinfo_load': $id = intval($_GET['id']); - $q = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$id' ORDER BY `order`"); + if($id == -1) { + $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); + } else { + $q = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$id' ORDER BY `order`"); + } while($r=mysql_fetch_assoc($q)) { $ret[] = $r; } @@ -152,15 +156,21 @@ case 'award_create': echo json_encode($ret); exit; + case 'prize_create': + $aaid = intval($_GET['award_awards_id']); + $year = $config['FAIRYEAR']; + if($aaid == -1) { + $aaid = 0; + $year = -1; + } + mysql_query("INSERT INTO award_prizes(award_awards_id,year) VALUES ('$aaid','$year');"); + $ret = array('id' => mysql_insert_id() ); + echo json_encode($ret); + exit; + case 'prize_save': print_R($_GET); $id = intval($_GET['id']); - if($id == -1) { - $aaid = intval($_GET['award_awards_id']); - mysql_query("INSERT INTO award_prizes(award_awards_id,year) VALUES ('$aaid','{$config['FAIRYEAR']}');"); - $id = mysql_insert_id(); - echo happy(i18n("Created new prize")); - } $q="UPDATE award_prizes SET prize='".mysql_escape_string(stripslashes($_GET['prize']))."', cash='".intval($_GET['cash'])."', @@ -255,6 +265,7 @@ function prizelist_refresh() dragHandle: "drag_handle", }); } + function update_prizeinfo() { var id = award_id; @@ -328,12 +339,15 @@ function prize_delete(id) function prize_create() { var id = award_id; - $(".prizeinfo").val(""); - $("#prizeinfo_id").val("-1"); - $("#prizeinfo_award_awards_id").val(id); - $("#prizeinfo_edit_header").html("=i18n("New Prize")?>"); - $(".prizeinfo").removeAttr("disabled"); - $("#prizeinfo_save").removeAttr("disabled"); + $.getJSON("=$_SERVER['PHP_SELF']?>?action=prize_create&award_awards_id="+id, + function(json){ + $(".prizeinfo").val(""); + $("#prizeinfo_id").val(json.id); + $("#prizeinfo_edit_header").html("=i18n("New Prize")?>"); + $(".prizeinfo").removeAttr("disabled"); + $("#prizeinfo_save").removeAttr("disabled"); + update_prizeinfo(); + }); } @@ -534,6 +548,8 @@ htabs_end(); echo ''; + + /* Here's all the code for the award list, except for the AJAX queries which are * at the top of this file */ ?> @@ -549,7 +565,11 @@ function popup_editor(id) $("#popup_editor").dialog('open'); award_id = id; - htabs_open("editortabs"); + if(id == -1) { + htabs_open('prizes'); + } else { + htabs_open("editortabs"); + } return 0; } @@ -581,7 +601,7 @@ function award_create() popup_editor(json.id); /* Ensure we open on the first tab */ $("#htabs_awardinfo_tab").click(); - /* FUIXME: insert data into the list */ + /* FIXME: insert data into the list */ awardlist_refresh(); }); // alert("ok"); @@ -604,6 +624,15 @@ function award_delete(id) } +function popup_edit_prize_template() +{ + $("#htabs_editortabs_awardinfo").remove(); + $("#htabs_editortabs_eligibility").remove(); + $("#htabs_editortabs_prizes").html("=i18n("Generic Prize Template")?>"); + popup_editor(-1); + $("#htabs_editortabs_prizes").click(); +} + $(document).ready(function() { awardlist_refresh(); // $(".awardlist_tr#166").css('background-color','red'); @@ -612,10 +641,12 @@ $(document).ready(function() { +
+ /* List filtering */ if($_GET['sponsors_id'] && $_GET['sponsors_id']!="all") @@ -698,6 +729,9 @@ echo ""; ?>