Add prize value, and the trophy stuff to the generic prize template divisional awards creator

When creating divisional awards using the generic prize template, obey config option to filter divisions by category
When managing jdivs, obey config option to filter divisions by category
Add an option to the jdivs (at the bottom) to completely whipe out all jdivs so they can be recreated (eg if age categories / divisions are deleted or changed, or if ones were created that shouldnt have been due to the filter divisions by category not being obeyed
This commit is contained in:
james 2007-12-20 20:45:18 +00:00
parent 0db1467da7
commit e4fb689d58
3 changed files with 62 additions and 14 deletions

View File

@ -56,6 +56,26 @@
while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category;
$dkeys = array_keys($div);
$ckeys = array_keys($cat);
if($config['filterdivisionbycategory']=="yes") {
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY projectdivisions_id,projectcategories_id");
$divcat=array();
while($r=mysql_fetch_object($q)) {
$divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id);
}
}
else {
$divcat=array();
foreach($dkeys AS $d) {
foreach($ckeys AS $c) {
$divcat[]=array("c"=>$c,"d"=>$d);
}
}
}
if($_GET['action']=="create" && $_GET['award_sponsors_id'])
{
@ -66,17 +86,24 @@
$prizes[]=array(
"cash"=>$r->cash,
"scholarship"=>$r->scholarship,
"value"=>$r->value,
"prize"=>$r->prize,
"number"=>$r->number,
"excludefromac"=>$r->excludefromac,
"trophystudentkeeper"=>$r->trophystudentkeeper,
"trophystudentreturn"=>$r->trophystudentreturn,
"trophyschoolkeeper"=>$r->trophyschoolkeeper,
"trophyschoolreturn"=>$r->trophyschoolreturn,
"order"=>$r->order);
}
$ord=1;
echo "<br />";
foreach($div AS $d_id=>$d_division)
{
foreach($cat AS $c_id=>$c_category)
{
foreach($divcat AS $dc) {
$d_id=$dc['d'];
$c_id=$dc['c'];
$d_division=$div[$d_id];
$c_category=$cat[$c_id];
echo i18n("Creating %1 - %2",array($c_category,$d_division))."<br />";
mysql_query("INSERT INTO award_awards (award_sponsors_id,award_types_id,name,criteria,`order`,year) VALUES (
@ -99,19 +126,24 @@
echo "&nbsp;&nbsp;".i18n("Prizes: ");
foreach($prizes AS $prize)
{
mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,prize,number,`order`,year) VALUES (
mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,value,prize,number,`order`,excludefromac,trophystudentkeeper,trophystudentreturn,trophyschoolkeeper,trophyschoolreturn,year) VALUES (
'$award_awards_id',
'{$prize['cash']}',
'{$prize['scholarship']}',
'{$prize['value']}',
'{$prize['prize']}',
'{$prize['number']}',
'{$prize['order']}',
'{$prize['excludefromac']}',
'{$prize['trophystudentkeeper']}',
'{$prize['trophystudentreturn']}',
'{$prize['trophyschoolkeeper']}',
'{$prize['trophyschoolreturn']}',
'{$config['FAIRYEAR']}'
)");
echo $prize['prize'].",";
}
echo "<br />";
}
}
echo happy(i18n("All divisional awards and prizes successfully created"));
echo "<a href=\"award_awards.php\">".i18n("Go to awards manager")."</a>\n";
@ -159,6 +191,7 @@
echo " <th>".i18n("Prize Description")."</th>";
echo " <th>".i18n("Cash Amount")."</th>";
echo " <th>".i18n("Scholarship Amount")."</th>";
echo " <th>".i18n("Value")."</th>";
echo " <th>".i18n("# of Prizes")."</th>";
// echo " <th>Actions</th>";
echo "</tr>\n";
@ -176,6 +209,10 @@
if($r->scholarship) echo "\$$r->scholarship";
else echo "&nbsp;";
echo " </td>";
echo " <td align=\"right\">";
if($r->value) echo "\$$r->value";
else echo "&nbsp;";
echo " </td>";
echo " <td align=\"center\">$r->number</td>\n";
echo "</tr>\n";
}
@ -189,12 +226,13 @@
echo "<b>".i18n("We will create the following awards with the prizes listed above").":</b>";
echo "<br />";
foreach($div AS $d_id=>$d_division)
{
foreach($cat AS $c_id=>$c_category)
{
echo i18n($c_category)." - ".i18n($d_division)."<br />";
}
foreach($divcat AS $dc) {
$d_id=$dc['d'];
$c_id=$dc['c'];
$d_division=$div[$d_id];
$c_category=$cat[$c_id];
echo i18n($c_category)." - ".i18n($d_division)."<br />";
}
echo "<input type=\"hidden\" name=\"action\" value=\"create\">";

View File

@ -166,7 +166,6 @@
else
{
echo "<br />";
echo "<br />";
echo "<a href=\"award_prizes.php?award_awards_id=$award_awards_id&action=add\">".i18n("Add New Prize to %1",array($award->name))."</a>\n";
echo "<br />";

View File

@ -191,6 +191,12 @@ function get_all_divs()
echo happy(i18n("Emptied all divisions from Judging Division Group %1",array($_GET['jdiv_id'])));
}
if($_GET['action']=="recreate") {
//just delete them all, they'll be recreated automagically
mysql_query("TRUNCATE TABLE judges_jdiv");
echo happy(i18n("Recreated all division/category/language options"));
}
/* Sort out all the judging divisions */
$cdl = get_all_divs();
@ -265,7 +271,7 @@ function get_all_divs()
$p += $cdl[$id]['projects'];
}
echo "<table width=\"100%\">\n";
echo "<table class=\"tableedit\">\n";
echo "<tr><th colspan=\"2\" align=\"left\">Judging Division $jdiv ($p project".($p==1?'':'s').")";
echo "</th></tr>\n";
@ -309,6 +315,11 @@ function get_all_divs()
echo "</table>";
echo "</form>";
echo "<br />";
echo "<a onclick=\"return confirmClick('".i18n("Are you sure you want to empty all groupings and re-create the options")."')\" href=\"judges_jdiv.php?action=recreate\">".i18n("Re-create all division/category/language options")."</a>. ".i18n("This will completely empty ALL of your groupings and recreate all the possibly division/category/language options. Do this if for example you end up with a division/category that should not exist (due to the config option to filter divisions by category, or due to changing your divisions/categories alltogether)");
echo "<br />";
echo "<br />";
send_footer();