forked from science-ation/science-ation
- Make eligibility saving work.
This commit is contained in:
parent
74ec5fdcfb
commit
2270593d65
@ -100,7 +100,7 @@ case 'award_create':
|
|||||||
//wipe out any old award-category links
|
//wipe out any old award-category links
|
||||||
mysql_query("DELETE FROM award_awards_projectcategories WHERE award_awards_id='$id'");
|
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)
|
mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year)
|
||||||
VALUES ('$id','$cat','{$config['FAIRYEAR']}')");
|
VALUES ('$id','$cat','{$config['FAIRYEAR']}')");
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ case 'award_create':
|
|||||||
mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$id'");
|
mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$id'");
|
||||||
|
|
||||||
//now add the new ones
|
//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)
|
mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year)
|
||||||
VALUES ('$id','$div','{$config['FAIRYEAR']}')");
|
VALUES ('$id','$div','{$config['FAIRYEAR']}')");
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ function update_awardinfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function save_awardinfo()
|
function awardinfo_save()
|
||||||
{
|
{
|
||||||
$("#awardinfo_info").load("<?$_SERVER['PHP_SELF']?>?action=awardinfo_save", $("#awardinfo").serialize());
|
$("#awardinfo_info").load("<?$_SERVER['PHP_SELF']?>?action=awardinfo_save", $("#awardinfo").serialize());
|
||||||
return 0;
|
return 0;
|
||||||
@ -234,15 +234,30 @@ function update_eligibility()
|
|||||||
var id = award_id;
|
var id = award_id;
|
||||||
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=eligibilty_load&id="+id,
|
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=eligibilty_load&id="+id,
|
||||||
function(json){
|
function(json){
|
||||||
$("[name=eligiblecategories]").val(json.categories);
|
$("#eligibility_id").val(json.id);
|
||||||
$("[name=eligibledivisions]").val(json.divisions);
|
$("[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("<?=$_SERVER['PHP_SELF']?>?action=prize_order&"+order);
|
||||||
|
/* Change the order */
|
||||||
|
var rows = table.tBodies[0].rows;
|
||||||
|
for (var i=0; i<rows.length; i++) {
|
||||||
|
$("#prizelist_order_"+rows[i].id).html(i);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dragHandle: "drag_handle",
|
||||||
|
});
|
||||||
|
}
|
||||||
function update_prizeinfo()
|
function update_prizeinfo()
|
||||||
{
|
{
|
||||||
var id = award_id;
|
var id = award_id;
|
||||||
/* This is wasteful, but it saves inlining the code below */
|
|
||||||
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=prizeinfo_load&id="+id,
|
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=prizeinfo_load&id="+id,
|
||||||
function(json) {
|
function(json) {
|
||||||
$(".prizelist_tr").remove();
|
$(".prizelist_tr").remove();
|
||||||
@ -260,18 +275,7 @@ function update_prizeinfo()
|
|||||||
"<a onclick=\"prize_delete("+p.id+");\" href=\"#\" ><img border=0 src=\"<?=$config['SFIABDIRECTORY']?>/images/16/button_cancel.<?=$config['icon_extension']?>\"></a>"+
|
"<a onclick=\"prize_delete("+p.id+");\" href=\"#\" ><img border=0 src=\"<?=$config['SFIABDIRECTORY']?>/images/16/button_cancel.<?=$config['icon_extension']?>\"></a>"+
|
||||||
"</td></tr>");
|
"</td></tr>");
|
||||||
}
|
}
|
||||||
$("#prizelist").tableDnD({
|
prizelist_refresh();
|
||||||
onDrop: function(table, row) {
|
|
||||||
var order = $.tableDnD.serialize();
|
|
||||||
$("#prizeinfo_info").load("<?=$_SERVER['PHP_SELF']?>?action=prize_order&"+order);
|
|
||||||
/* Change the order */
|
|
||||||
var rows = table.tBodies[0].rows;
|
|
||||||
for (var i=0; i<rows.length; i++) {
|
|
||||||
$("#prizelist_order_"+rows[i].id).html(i);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dragHandle: "drag_handle",
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,6 +300,12 @@ function edit_prize(id)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function eligibility_save()
|
||||||
|
{
|
||||||
|
$("#eligibility_info").load("<?$_SERVER['PHP_SELF']?>?action=eligibility_save", $("#eligibility").serialize());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
function prize_save()
|
function prize_save()
|
||||||
{
|
{
|
||||||
$("#prizeinfo_info").load("<?$_SERVER['PHP_SELF']?>?action=prize_save", $("#prizeinfo").serialize());
|
$("#prizeinfo_info").load("<?$_SERVER['PHP_SELF']?>?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?');
|
var confirm = confirmClick('Are you sure you want to delete this prize?');
|
||||||
if(confirm == true) {
|
if(confirm == true) {
|
||||||
$("#prizeinfo_info").load("<?$_SERVER['PHP_SELF']?>?action=prize_delete&id="+id);
|
$("#prizeinfo_info").load("<?$_SERVER['PHP_SELF']?>?action=prize_delete&id="+id);
|
||||||
update_prizeinfo();
|
$(".prizelist_tr#"+id).fadeTo('slow', 0);
|
||||||
|
$(".prizelist_tr#"+id).remove();
|
||||||
|
prizelist_refresh();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -408,13 +420,16 @@ htabs_tab_begin('awardinfo');
|
|||||||
<input type="checkbox" id="awardinfo_schedulejudges" name="schedule_judges" value="yes"></td>
|
<input type="checkbox" id="awardinfo_schedulejudges" name="schedule_judges" value="yes"></td>
|
||||||
<td class="right"><?=i18n("Allow the Automatic Judge Scheduler to assign judges to this award (usually checked)")?></td></tr>
|
<td class="right"><?=i18n("Allow the Automatic Judge Scheduler to assign judges to this award (usually checked)")?></td></tr>
|
||||||
</table></form>
|
</table></form>
|
||||||
<input type="submit" onClick="save_awardinfo();" value="Save" />
|
<input type="submit" onClick="awardinfo_save();" value="Save" />
|
||||||
<?
|
<?
|
||||||
htabs_tab_end();
|
htabs_tab_end();
|
||||||
|
|
||||||
htabs_tab_begin('eligibility');
|
htabs_tab_begin('eligibility');
|
||||||
?>
|
?>
|
||||||
<h2><?=i18n("Award Info")?></h2>
|
<h2><?=i18n("Award Info")?></h2>
|
||||||
|
<div id="eligibility_info"></div>
|
||||||
|
<form id="eligibility">
|
||||||
|
<input type="hidden" id="eligibility_id" name="id" value="" />
|
||||||
<table class="tableedit">
|
<table class="tableedit">
|
||||||
<tr><td class="left"><?=i18n("Age Categories")?>:</td><td class="right">
|
<tr><td class="left"><?=i18n("Age Categories")?>:</td><td class="right">
|
||||||
<?
|
<?
|
||||||
@ -424,22 +439,26 @@ htabs_tab_begin('eligibility');
|
|||||||
$cq=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY mingrade");
|
$cq=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY mingrade");
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
while($cr=mysql_fetch_object($cq)) {
|
while($cr=mysql_fetch_object($cq)) {
|
||||||
echo "<input type=\"checkbox\" id=\"eligibility_categories_{$cr->id}\" name=\"eligiblecategories\" value=\"$cr->id\" />".i18n($cr->category)."<br />";
|
echo "<input type=\"checkbox\" id=\"eligibility_categories_{$cr->id}\" name=\"categories[]\" value=\"$cr->id\" />".i18n($cr->category)."<br />";
|
||||||
}
|
}
|
||||||
echo "</td></tr>";
|
?>
|
||||||
|
</td></tr>
|
||||||
|
|
||||||
echo "<tr><td class=\"left\">".i18n("Divisions").":</td><td class=\"right\">";
|
<tr><td class="left"><?=i18n("Divisions")?>:</td><td class="right">
|
||||||
|
<?
|
||||||
$dq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
|
$dq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
while($dr=mysql_fetch_object($dq)) {
|
while($dr=mysql_fetch_object($dq)) {
|
||||||
echo "<input type=\"checkbox\" id=\"eligibility_divisions_{$dr->id}\" name=\"eligibledivisions\" value=\"$dr->id\" />".i18n($dr->division)."<br />";
|
echo "<input type=\"checkbox\" id=\"eligibility_divisions_{$dr->id}\" name=\"divisions[]\" value=\"$dr->id\" />".i18n($dr->division)."<br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</td>";
|
|
||||||
echo "</tr>";
|
|
||||||
// if(count($currentcategories)==0 || count($currentdivisions)==0)
|
// if(count($currentcategories)==0 || count($currentdivisions)==0)
|
||||||
// echo "<tr><td colspan=\"2\" class=\"error\">".i18n("At least one age category and one division must be selected")."</td></tr>";
|
// echo "<tr><td colspan=\"2\" class=\"error\">".i18n("At least one age category and one division must be selected")."</td></tr>";
|
||||||
echo "</table>";
|
|
||||||
|
?>
|
||||||
|
</td></tr></table>
|
||||||
|
</form>
|
||||||
|
<input type="submit" onClick="eligibility_save();" value="Save" />
|
||||||
|
<?
|
||||||
htabs_tab_end();
|
htabs_tab_end();
|
||||||
|
|
||||||
htabs_tab_begin('prizes');
|
htabs_tab_begin('prizes');
|
||||||
@ -534,32 +553,8 @@ function popup_editor(id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function award_create()
|
function awardlist_refresh()
|
||||||
{
|
{
|
||||||
$.getJSON("<?=$_SERVER['PHP_SELF']?>?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('<?=i18n("Are you sure you want to remove this award?")?>');
|
|
||||||
if(conf == true) {
|
|
||||||
$("#info_info").load("<?$_SERVER['PHP_SELF']?>?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({
|
$("#awardlist").tableDnD({
|
||||||
onDrop: function(table, row) {
|
onDrop: function(table, row) {
|
||||||
var order = $.tableDnD.serialize();
|
var order = $.tableDnD.serialize();
|
||||||
@ -577,7 +572,40 @@ $(document).ready(function() {
|
|||||||
},
|
},
|
||||||
dragHandle: "drag_handle"
|
dragHandle: "drag_handle"
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function award_create()
|
||||||
|
{
|
||||||
|
$.getJSON("<?=$_SERVER['PHP_SELF']?>?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('<?=i18n("Are you sure you want to remove this award?")?>');
|
||||||
|
if(conf == true) {
|
||||||
|
$("#info_info").load("<?$_SERVER['PHP_SELF']?>?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');
|
// $(".awardlist_tr#166").css('background-color','red');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user