forked from science-ation/science-ation
Fix Awards System
This commit is contained in:
parent
cb2d7b6845
commit
a7558e3ffc
@ -1771,9 +1771,10 @@ CREATE TABLE `projectcategories` (
|
|||||||
LOCK TABLES `projectcategories` WRITE;
|
LOCK TABLES `projectcategories` WRITE;
|
||||||
/*!40000 ALTER TABLE `projectcategories` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `projectcategories` DISABLE KEYS */;
|
||||||
INSERT INTO `projectcategories` VALUES
|
INSERT INTO `projectcategories` VALUES
|
||||||
(1,'junor','',7,8,2025),
|
(1,'Junior','',7,8,2025),
|
||||||
(2,'senior','',11,12,2025),
|
(2,'Intermediate','',9,10,2025),
|
||||||
(3,'int','',9,10,2025);
|
(3,'Senior','',11,12,2025);
|
||||||
|
|
||||||
/*!40000 ALTER TABLE `projectcategories` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `projectcategories` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
@ -3131,7 +3132,7 @@ CREATE TABLE `schools` (
|
|||||||
LOCK TABLES `schools` WRITE;
|
LOCK TABLES `schools` WRITE;
|
||||||
/*!40000 ALTER TABLE `schools` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `schools` DISABLE KEYS */;
|
||||||
INSERT INTO `schools` VALUES
|
INSERT INTO `schools` VALUES
|
||||||
(1,'sd','','','','','','','','','','','','',NULL,NULL,'','','','','',2025,NULL,0,0,0,'',0,'total','no');
|
(1,'Sample School','','','','','','','','','','','','',NULL,NULL,'','','','','',2025,NULL,0,0,0,'',0,'total','no');
|
||||||
/*!40000 ALTER TABLE `schools` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `schools` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
@ -31,16 +31,15 @@ require_once ('awards.inc.php');
|
|||||||
$_GET['action'] = $_GET['action'] ?? '';
|
$_GET['action'] = $_GET['action'] ?? '';
|
||||||
|
|
||||||
switch ($_GET['action']) {
|
switch ($_GET['action']) {
|
||||||
case 'awardinfo_load':
|
case 'awardinfo_load':;
|
||||||
;
|
|
||||||
$id = intval(get_value_from_array($_GET, 'id'));
|
$id = intval(get_value_from_array($_GET, 'id'));
|
||||||
$q = $pdo->prepare("SELECT * FROM award_awards WHERE id=?");
|
$q = $pdo->prepare('SELECT * FROM award_awards WHERE id=?');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
$ret = $q->fetch(PDO::FETCH_ASSOC);
|
$ret = $q->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// json_encode NEEDS UTF8 DATA, but we store it in the database as ISO :(
|
// json_encode NEEDS UTF8 DATA, but we store it in the database as ISO :(
|
||||||
foreach ($ret AS $k => $v) {
|
foreach ($ret AS $k => $v) {
|
||||||
$ret[$k] = iconv('ISO-8859-1', 'UTF-8', $v);
|
$ret[$k] = iconv('ISO-8859-1', 'UTF-8', get_value_or_default($v, ''));
|
||||||
}
|
}
|
||||||
// echo iconv("ISO-8859-1","UTF-8",json_encode($ret));
|
// echo iconv("ISO-8859-1","UTF-8",json_encode($ret));
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
@ -55,17 +54,17 @@ switch ($_GET['action']) {
|
|||||||
/* Scrub the data while we save it */
|
/* Scrub the data while we save it */
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
|
|
||||||
if ($id == -1) {
|
try {
|
||||||
$q = $pdo->prepare("INSERT INTO award_awards (year,self_nominate,schedule_judges)
|
if ($id == -1) {
|
||||||
|
$q = $pdo->prepare("INSERT INTO award_awards (year,self_nominate,schedule_judges)
|
||||||
VALUES (?,'yes','yes')");
|
VALUES (?,'yes','yes')");
|
||||||
$q->execute([$config['FAIRYEAR']]);
|
$q->execute([$config['FAIRYEAR']]);
|
||||||
$id = $pdo->lastInsertId();
|
$id = $pdo->lastInsertId();
|
||||||
happy_('Award Created');
|
/* Set the award_id in the client */
|
||||||
/* Set the award_id in the client */
|
echo "<script type=\"text/javascript\">award_id=$id;</script>";
|
||||||
echo "<script type=\"text/javascript\">award_id=$id;</script>";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$q = "UPDATE award_awards SET
|
$q = "UPDATE award_awards SET
|
||||||
award_types_id='" . intval($_POST['award_types_id']) . "',
|
award_types_id='" . intval($_POST['award_types_id']) . "',
|
||||||
presenter='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['presenter'])) . "',
|
presenter='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['presenter'])) . "',
|
||||||
excludefromac='" . (($_POST['excludefromac'] == 1) ? 1 : 0) . "',
|
excludefromac='" . (($_POST['excludefromac'] == 1) ? 1 : 0) . "',
|
||||||
@ -74,21 +73,32 @@ switch ($_GET['action']) {
|
|||||||
schedule_judges='" . (($_POST['schedule_judges'] == 'yes') ? 'yes' : 'no') . "',
|
schedule_judges='" . (($_POST['schedule_judges'] == 'yes') ? 'yes' : 'no') . "',
|
||||||
description='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['description'])) . "' ";
|
description='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['description'])) . "' ";
|
||||||
|
|
||||||
if (array_key_exists('name', $_POST)) {
|
|
||||||
/*
|
if (array_key_exists('name', $_POST)) {
|
||||||
* These values may be disabled, if they name key exists, assume
|
/*
|
||||||
* they aren't disabled and save them too
|
* These values may be disabled, if they name key exists, assume
|
||||||
*/
|
* they aren't disabled and save them too
|
||||||
$q .= ",name='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['name'])) . "',
|
*/
|
||||||
criteria='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['criteria'])) . "',
|
$q .= ",name=" . $pdo->quote($_POST['name']) . ",
|
||||||
sponsors_id='" . intval($_POST['sponsors_id']) . "' ";
|
criteria='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['criteria'])) . "'";
|
||||||
|
if (intval($_POST['sponsors_id']) != -1) {
|
||||||
|
$q .= "sponsors_id='" . $sponsors_id . "' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$q .= " WHERE id=$id";
|
||||||
|
error_log('query: ' . $q);
|
||||||
|
$q = $pdo->prepare($q);
|
||||||
|
$q->execute();
|
||||||
|
|
||||||
|
happy_('Award Created');
|
||||||
|
happy_('Award information saved');
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_('Award not created');
|
||||||
|
error_('Award information failed to save');
|
||||||
|
error_log("Here");
|
||||||
|
error_log($exception);
|
||||||
}
|
}
|
||||||
$q .= "WHERE id=?";
|
|
||||||
$q = $pdo->prepare($q);
|
|
||||||
$q->execute([$id]);
|
|
||||||
|
|
||||||
show_pdo_errors_if_any($pdo);
|
|
||||||
happy_('Award information saved');
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'eligibility_load':
|
case 'eligibility_load':
|
||||||
@ -96,19 +106,27 @@ switch ($_GET['action']) {
|
|||||||
// select the current categories that this award is linked to
|
// select the current categories that this award is linked to
|
||||||
$ret = array('categories' => array(), 'divisions' => array());
|
$ret = array('categories' => array(), 'divisions' => array());
|
||||||
|
|
||||||
$q = $pdo->prepare("SELECT * FROM award_awards_projectcategories WHERE award_awards_id=?");
|
try {
|
||||||
$q->execute([$id]);
|
$q = $pdo->prepare('SELECT * FROM award_awards_projectcategories WHERE award_awards_id=?');
|
||||||
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
|
$q->execute([$id]);
|
||||||
$ret['categories'][] = $r['projectcategories_id'];
|
|
||||||
|
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
$ret['categories'][] = $r['projectcategories_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// select the current categories that this award is linked to
|
||||||
|
$q = $pdo->prepare('SELECT * FROM award_awards_projectdivisions WHERE award_awards_id=?');
|
||||||
|
$q->execute([$id]);
|
||||||
|
|
||||||
|
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
$ret['divisions'][] = $r['projectdivisions_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($ret);
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_log($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// select the current categories that this award is linked to
|
|
||||||
$q = $pdo->$prepare("SELECT * FROM award_awards_projectdivisions WHERE award_awards_id=?");
|
|
||||||
$q->execute([$id]);
|
|
||||||
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
|
|
||||||
$ret['divisions'][] = $r['projectdivisions_id'];
|
|
||||||
}
|
|
||||||
echo json_encode($ret);
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'eligibility_save':
|
case 'eligibility_save':
|
||||||
@ -119,78 +137,94 @@ switch ($_GET['action']) {
|
|||||||
error_('Invalid data');
|
error_('Invalid data');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
// wipe out any old award-category links
|
// wipe out any old award-category links
|
||||||
$q = $pdo->prepare("DELETE FROM award_awards_projectcategories WHERE award_awards_id=?");
|
$q = $pdo->prepare('DELETE FROM award_awards_projectcategories WHERE award_awards_id=?');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
foreach ($_POST['categories'] AS $key => $cat) {
|
foreach ($_POST['categories'] AS $key => $cat) {
|
||||||
$c = intval($cat);
|
$c = intval($cat);
|
||||||
$q = $pdo->prepare('INSERT INTO award_awards_projectcategories (award_awards_id, projectcategories_id, year)
|
$q = $pdo->prepare('INSERT INTO award_awards_projectcategories (award_awards_id, projectcategories_id, year)
|
||||||
VALUES (:id, :c, :year)');
|
VALUES (:id, :c, :year)');
|
||||||
|
|
||||||
$q->bindParam(':id', $id, PDO::PARAM_INT);
|
$q->bindParam(':id', $id, PDO::PARAM_INT);
|
||||||
$q->bindParam(':c', $c, PDO::PARAM_INT);
|
$q->bindParam(':c', $c, PDO::PARAM_INT);
|
||||||
$q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
|
$q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
|
||||||
|
|
||||||
$q->execute();
|
$q->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
// wipe out any old award-divisions links
|
// wipe out any old award-divisions links
|
||||||
|
|
||||||
$q = $pdo->prepare("DELETE FROM award_awards_projectdivisions WHERE award_awards_id=?");
|
$q = $pdo->prepare('DELETE FROM award_awards_projectdivisions WHERE award_awards_id=?');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
|
|
||||||
// now add the new ones
|
// now add the new ones
|
||||||
foreach ($_POST['divisions'] AS $key => $div) {
|
foreach ($_POST['divisions'] AS $key => $div) {
|
||||||
$d = intval($div);
|
$d = intval($div);
|
||||||
|
|
||||||
$q = $pdo->prepare('INSERT INTO award_awards_projectdivisions (award_awards_id, projectdivisions_id, year)
|
$q = $pdo->prepare('INSERT INTO award_awards_projectdivisions (award_awards_id, projectdivisions_id, year)
|
||||||
VALUES (:id, :d, :year)');
|
VALUES (:id, :d, :year)');
|
||||||
|
|
||||||
$q->bindParam(':id', $id, PDO::PARAM_INT);
|
$q->bindParam(':id', $id, PDO::PARAM_INT);
|
||||||
$q->bindParam(':d', $d, PDO::PARAM_INT);
|
$q->bindParam(':d', $d, PDO::PARAM_INT);
|
||||||
$q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
|
$q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
|
||||||
|
|
||||||
$q->execute();
|
$q->execute();
|
||||||
show_pdo_errors_if_any($pdo);
|
show_pdo_errors_if_any($pdo);
|
||||||
|
}
|
||||||
|
|
||||||
|
happy_('Eligibility information saved');
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_('Eligibility information failed to save');
|
||||||
}
|
}
|
||||||
happy_('Eligibility information saved');
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'prize_order':
|
case 'prize_order':
|
||||||
$order = 0;
|
$order = 0;
|
||||||
foreach ($_GET['prizelist'] as $position => $id) {
|
|
||||||
if ($id == '')
|
|
||||||
continue;
|
|
||||||
$order++;
|
|
||||||
|
|
||||||
$q = $pdo->prepare("UPDATE `award_prizes` SET `order`=? WHERE `id`=?");
|
try {
|
||||||
$q->execute([$order, $id]);
|
foreach ($_GET['prizelist'] as $position => $id) {
|
||||||
|
if ($id == '')
|
||||||
|
continue;
|
||||||
|
$order++;
|
||||||
|
|
||||||
|
$q = $pdo->prepare('UPDATE `award_prizes` SET `order`=? WHERE `id`=?');
|
||||||
|
$q->execute([$order, $id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
happy_('Order Updated.');
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_('Order failed to update');
|
||||||
|
error_log($exception);
|
||||||
}
|
}
|
||||||
// print_r($_GET);
|
|
||||||
happy_('Order Updated.');
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'award_order':
|
case 'award_order':
|
||||||
$order = 0;
|
$order = 0;
|
||||||
foreach ($_GET['awardlist'] as $position => $id) {
|
try {
|
||||||
if ($id == '')
|
foreach ($_GET['awardlist'] as $position => $id) {
|
||||||
continue;
|
if ($id == '')
|
||||||
$order++;
|
continue;
|
||||||
|
$order++;
|
||||||
|
|
||||||
$q = $pdo->prepare("UPDATE `award_awards` SET `order`=? WHERE `id`=?");
|
$q = $pdo->prepare('UPDATE `award_awards` SET `order`=? WHERE `id`=?');
|
||||||
$q->execute([$order, $id]);
|
$q->execute([$order, $id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
happy_('Order updated');
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_('Order failed to update');
|
||||||
|
error_log($exception);
|
||||||
}
|
}
|
||||||
happy_('Order updated');
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'prizeinfo_load':
|
case 'prizeinfo_load':
|
||||||
$id = intval($_GET['id']);
|
$id = intval($_GET['id']);
|
||||||
if ($id == -1) {
|
if ($id == -1) {
|
||||||
$q = $pdo->prepare("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`");
|
$q = $pdo->prepare("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`");
|
||||||
$q->execute();
|
$q->execute();
|
||||||
} else {
|
} else {
|
||||||
$q = $pdo->prepare("SELECT * FROM award_prizes WHERE award_awards_id=? ORDER BY `order`");
|
$q = $pdo->prepare('SELECT * FROM award_prizes WHERE award_awards_id=? ORDER BY `order`');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
}
|
}
|
||||||
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
|
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||||
@ -204,7 +238,7 @@ switch ($_GET['action']) {
|
|||||||
case 'prize_load':
|
case 'prize_load':
|
||||||
$id = intval($_GET['id']);
|
$id = intval($_GET['id']);
|
||||||
|
|
||||||
$q = $pdo->prepare("SELECT * FROM award_prizes WHERE id=?");
|
$q = $pdo->prepare('SELECT * FROM award_prizes WHERE id=?');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
$ret = $q->fetch(PDO::FETCH_ASSOC);
|
$ret = $q->fetch(PDO::FETCH_ASSOC);
|
||||||
foreach ($ret AS $k => $v) {
|
foreach ($ret AS $k => $v) {
|
||||||
@ -221,21 +255,26 @@ switch ($_GET['action']) {
|
|||||||
$year = -1;
|
$year = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = $pdo->prepare('INSERT INTO award_prizes (award_awards_id, year) VALUES (:aaid, :year)');
|
try {
|
||||||
|
$q = $pdo->prepare('INSERT INTO award_prizes (award_awards_id, year) VALUES (:aaid, :year)');
|
||||||
|
|
||||||
$q->bindParam(':aaid', $aaid, PDO::PARAM_INT);
|
$q->bindParam(':aaid', $aaid, PDO::PARAM_INT);
|
||||||
$q->bindParam(':year', $year, PDO::PARAM_INT);
|
$q->bindParam(':year', $year, PDO::PARAM_INT);
|
||||||
|
|
||||||
$q->execute();
|
$q->execute();
|
||||||
|
|
||||||
$ret = array('id' => $pdo->lastInsertId());
|
$ret = array('id' => $pdo->lastInsertId());
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_log($exception);
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'prize_save':
|
case 'prize_save':
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
|
|
||||||
$q = $pdo->prepare('UPDATE award_prizes SET
|
try {
|
||||||
|
$q = $pdo->prepare('UPDATE award_prizes SET
|
||||||
prize = :prize,
|
prize = :prize,
|
||||||
cash = :cash,
|
cash = :cash,
|
||||||
scholarship = :scholarship,
|
scholarship = :scholarship,
|
||||||
@ -248,21 +287,25 @@ switch ($_GET['action']) {
|
|||||||
trophyschoolreturn = :trophyschoolreturn
|
trophyschoolreturn = :trophyschoolreturn
|
||||||
WHERE id = :id');
|
WHERE id = :id');
|
||||||
|
|
||||||
$q->bindParam(':prize', stripslashes(iconv('UTF-8', 'ISO-8859-1', $_POST['prize'])), PDO::PARAM_STR);
|
$q->bindParam(':prize', stripslashes(iconv('UTF-8', 'ISO-8859-1', $_POST['prize'])), PDO::PARAM_STR);
|
||||||
$q->bindValue(':cash', intval($_POST['cash']), PDO::PARAM_INT);
|
$q->bindValue(':cash', intval($_POST['cash']), PDO::PARAM_INT);
|
||||||
$q->bindValue(':scholarship', intval($_POST['scholarship']), PDO::PARAM_INT);
|
$q->bindValue(':scholarship', intval($_POST['scholarship']), PDO::PARAM_INT);
|
||||||
$q->bindValue(':value', intval($_POST['value']), PDO::PARAM_INT);
|
$q->bindValue(':value', intval($_POST['value']), PDO::PARAM_INT);
|
||||||
$q->bindValue(':number', intval($_POST['number']), PDO::PARAM_INT);
|
$q->bindValue(':number', intval($_POST['number']), PDO::PARAM_INT);
|
||||||
$q->bindValue(':excludefromac', ($_POST['excludefromac'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
$q->bindValue(':excludefromac', ($_POST['excludefromac'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
||||||
$q->bindValue(':trophystudentkeeper', ($_POST['trophystudentkeeper'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
$q->bindValue(':trophystudentkeeper', ($_POST['trophystudentkeeper'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
||||||
$q->bindValue(':trophystudentreturn', ($_POST['trophystudentreturn'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
$q->bindValue(':trophystudentreturn', ($_POST['trophystudentreturn'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
||||||
$q->bindValue(':trophyschoolkeeper', ($_POST['trophyschoolkeeper'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
$q->bindValue(':trophyschoolkeeper', ($_POST['trophyschoolkeeper'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
||||||
$q->bindValue(':trophyschoolreturn', ($_POST['trophyschoolreturn'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
$q->bindValue(':trophyschoolreturn', ($_POST['trophyschoolreturn'] == 1) ? 1 : 0, PDO::PARAM_INT);
|
||||||
$q->bindValue(':id', $id, PDO::PARAM_INT);
|
$q->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
|
|
||||||
$q->execute();
|
$q->execute();
|
||||||
|
|
||||||
happy_('Prize saved');
|
happy_('Prize saved');
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_('Prize failed to save');
|
||||||
|
error_log($exception);
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'prize_delete':
|
case 'prize_delete':
|
||||||
@ -275,7 +318,7 @@ switch ($_GET['action']) {
|
|||||||
$id = intval($_GET['id']);
|
$id = intval($_GET['id']);
|
||||||
/* Prepare two lists of fair IDs, for which fairs can upload and download this award */
|
/* Prepare two lists of fair IDs, for which fairs can upload and download this award */
|
||||||
|
|
||||||
$q = $pdo->prepare("SELECT * FROM fairs_awards_link WHERE award_awards_id=?");
|
$q = $pdo->prepare('SELECT * FROM fairs_awards_link WHERE award_awards_id=?');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
$ul = array();
|
$ul = array();
|
||||||
$dl = array();
|
$dl = array();
|
||||||
@ -286,7 +329,7 @@ switch ($_GET['action']) {
|
|||||||
$dl[$r['fairs_id']] = true;
|
$dl[$r['fairs_id']] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = $pdo->prepare("SELECT * FROM award_awards WHERE id=?");
|
$q = $pdo->prepare('SELECT * FROM award_awards WHERE id=?');
|
||||||
$q->execute([$id]);
|
$q->execute([$id]);
|
||||||
$a = $q->fetch(PDO::FETCH_ASSOC);
|
$a = $q->fetch(PDO::FETCH_ASSOC);
|
||||||
?>
|
?>
|
||||||
@ -346,38 +389,46 @@ switch ($_GET['action']) {
|
|||||||
|
|
||||||
/* Prepare a fair-wise list */
|
/* Prepare a fair-wise list */
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($dl AS $fairs_id)
|
foreach ($dl AS $fairs_id) {
|
||||||
$data[$fairs_id]['dl'] = true;
|
$data[$fairs_id]['dl'] = true;
|
||||||
foreach ($ul AS $fairs_id)
|
}
|
||||||
|
|
||||||
|
foreach ($ul AS $fairs_id) {
|
||||||
$data[$fairs_id]['ul'] = true;
|
$data[$fairs_id]['ul'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now save each one */
|
/* Now save each one */
|
||||||
|
|
||||||
$q = $pdo->prepare("DELETE FROM fairs_awards_link WHERE award_awards_id=?");
|
try {
|
||||||
$q->execute([$id]);
|
$q = $pdo->prepare('DELETE FROM fairs_awards_link WHERE award_awards_id=?');
|
||||||
show_pdo_errors_if_any($pdo);
|
$q->execute([$id]);
|
||||||
foreach ($data as $fairs_id => $f) {
|
|
||||||
$dl = ($f['dl'] == true) ? 'yes' : 'no';
|
|
||||||
$ul = ($f['ul'] == true) ? 'yes' : 'no';
|
|
||||||
|
|
||||||
$q = $pdo->prepare("INSERT INTO fairs_awards_link (award_awards_id,fairs_id,download_award,upload_winners)
|
|
||||||
VALUES (?,?,?,?)");
|
|
||||||
$q->execute([$id,$fairs_id,$dl,$ul]);
|
|
||||||
show_pdo_errors_if_any($pdo);
|
show_pdo_errors_if_any($pdo);
|
||||||
}
|
foreach ($data as $fairs_id => $f) {
|
||||||
$ident = stripslashes($_POST['identifier']);
|
$dl = ($f['dl'] == true) ? 'yes' : 'no';
|
||||||
$per_fair = $_POST['per_fair'] == 'yes' ? 'yes' : 'no';
|
$ul = ($f['ul'] == true) ? 'yes' : 'no';
|
||||||
$mat = intval($_POST['additional_materials']);
|
|
||||||
$w = intval($_POST['register_winners']);
|
|
||||||
|
|
||||||
$q = $pdo->prepare("UPDATE award_awards SET external_identifier=?,
|
$q = $pdo->prepare('INSERT INTO fairs_awards_link (award_awards_id,fairs_id,download_award,upload_winners)
|
||||||
|
VALUES (?,?,?,?)');
|
||||||
|
$q->execute([$id, $fairs_id, $dl, $ul]);
|
||||||
|
show_pdo_errors_if_any($pdo);
|
||||||
|
}
|
||||||
|
$ident = stripslashes($_POST['identifier']);
|
||||||
|
$per_fair = $_POST['per_fair'] == 'yes' ? 'yes' : 'no';
|
||||||
|
$mat = intval($_POST['additional_materials']);
|
||||||
|
$w = intval($_POST['register_winners']);
|
||||||
|
|
||||||
|
$q = $pdo->prepare('UPDATE award_awards SET external_identifier=?,
|
||||||
external_additional_materials=?,
|
external_additional_materials=?,
|
||||||
external_register_winners=?,
|
external_register_winners=?,
|
||||||
per_fair=?
|
per_fair=?
|
||||||
WHERE id=?");
|
WHERE id=?');
|
||||||
$q->execute([[$ident, $mat,$w],$per_fair,$id]);
|
$q->execute([$ident, $mat, $w, $per_fair, $id]);
|
||||||
|
|
||||||
happy_('Feeder Fair information saved');
|
happy_('Feeder Fair information saved');
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_('Feeder Fair information failed to save');
|
||||||
|
error_log($exception);
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +438,6 @@ send_header('Awards Management',
|
|||||||
'Awards Main' => 'admin/awards.php'));
|
'Awards Main' => 'admin/awards.php'));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!--<script type="text/javascript" src="../js/jquery.tablednd_0_5.js"></script>-->
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var award_id = 0;
|
var award_id = 0;
|
||||||
@ -396,16 +446,17 @@ var award_tab_update = new Array();
|
|||||||
|
|
||||||
function update_awardinfo()
|
function update_awardinfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(award_tab_update['awardinfo'] == award_id) return;
|
if(award_tab_update['awardinfo'] == award_id) return;
|
||||||
|
|
||||||
award_tab_update['awardinfo'] = award_id;
|
award_tab_update['awardinfo'] = award_id;
|
||||||
|
|
||||||
// alert(award_id);
|
// alert(award_id);
|
||||||
if(award_id == -1) {
|
if(award_id == -1) {
|
||||||
// $("#awardinfo input:text").val('');
|
// $("#awardinfo input:text").val('');
|
||||||
/* New award, set defaults and clear everythign else */
|
/* New award, set defaults and clear everythign else */
|
||||||
$("#awardinfo_id").val(-1);
|
$("#awardinfo_id").val(-1);
|
||||||
$("#awardinfo_name").val("");
|
$("#awardinfo_name").val("");
|
||||||
$("#awardinfo_sponsors_id").val(0);
|
$("#awardinfo_sponsors_id").val(-1);
|
||||||
$("#awardinfo_presenter").val("");
|
$("#awardinfo_presenter").val("");
|
||||||
$("#awardinfo_description").val("");
|
$("#awardinfo_description").val("");
|
||||||
$("#awardinfo_criteria").val("");
|
$("#awardinfo_criteria").val("");
|
||||||
@ -419,9 +470,9 @@ function update_awardinfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Enable all fields */
|
/* Enable all fields */
|
||||||
$("#awardinfo *").removeAttr('disabled');
|
$("#awardinfo *").prop('disabled',false);
|
||||||
|
|
||||||
$.getJSON("<?= $_SERVER['PHP_SELF'] ?>?action=awardinfo_load&id="+award_id,
|
$.getJSON(`<?= $_SERVER['PHP_SELF'] ?>?action=awardinfo_load&id=${award_id}`,
|
||||||
function(json){
|
function(json){
|
||||||
$("#awardinfo_id").val(json.id);
|
$("#awardinfo_id").val(json.id);
|
||||||
$("#awardinfo_name").val(json.name);
|
$("#awardinfo_name").val(json.name);
|
||||||
@ -610,10 +661,10 @@ function update_feeder()
|
|||||||
$("#editor_tab_feeder").load("<?= $_SERVER['PHP_SELF'] ?>?action=feeder_load&id="+award_id, '',
|
$("#editor_tab_feeder").load("<?= $_SERVER['PHP_SELF'] ?>?action=feeder_load&id="+award_id, '',
|
||||||
function(responseText, textStatus, XMLHttpRequest) {
|
function(responseText, textStatus, XMLHttpRequest) {
|
||||||
/* Register buttons and handlers */
|
/* Register buttons and handlers */
|
||||||
$("#feeder_enable").change(function() {
|
$("#feeder_enable").on("change", function() {
|
||||||
update_feeder_enable();
|
update_feeder_enable();
|
||||||
});
|
});
|
||||||
$("#feeder_save").click(function() {
|
$("#feeder_save").on("click", function() {
|
||||||
$("#debug").load("<? $_SERVER['PHP_SELF'] ?>?action=feeder_save", $("#feeder_form").serializeArray());
|
$("#debug").load("<? $_SERVER['PHP_SELF'] ?>?action=feeder_save", $("#feeder_form").serializeArray());
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -664,28 +715,6 @@ $(document).ready(function() {
|
|||||||
},
|
},
|
||||||
active: -1
|
active: -1
|
||||||
});
|
});
|
||||||
|
|
||||||
// $("#editor_tabs").tabs({
|
|
||||||
// show: function(event, ui) {
|
|
||||||
// switch(ui.panel.id) {
|
|
||||||
// case 'editor_tab_awardinfo':
|
|
||||||
// update_awardinfo();
|
|
||||||
// break;
|
|
||||||
// case 'editor_tab_eligibility':
|
|
||||||
// update_eligibility();
|
|
||||||
// break;
|
|
||||||
// case 'editor_tab_prizes':
|
|
||||||
// update_prizeinfo();
|
|
||||||
// break;
|
|
||||||
// case 'editor_tab_feeder':
|
|
||||||
// update_feeder();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// },
|
|
||||||
// collapsible: true,
|
|
||||||
// selected: -1 /* None selected */
|
|
||||||
// });
|
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -725,7 +754,7 @@ $(document).ready(function() {
|
|||||||
$sq = $pdo->prepare('SELECT id,organization FROM sponsors ORDER BY organization');
|
$sq = $pdo->prepare('SELECT id,organization FROM sponsors ORDER BY organization');
|
||||||
$sq->execute();
|
$sq->execute();
|
||||||
echo '<select id="awardinfo_sponsors_id" name="sponsors_id">';
|
echo '<select id="awardinfo_sponsors_id" name="sponsors_id">';
|
||||||
echo '<option value="">' . i18n('Choose a sponsor') . "</option>\n";
|
echo '<option hidden value="-1">' . i18n('Choose a sponsor') . "</option>\n";
|
||||||
while ($sr = $sq->fetch(PDO::FETCH_OBJ)) {
|
while ($sr = $sq->fetch(PDO::FETCH_OBJ)) {
|
||||||
echo "<option value=\"$sr->id\">" . i18n($sr->organization) . '</option>';
|
echo "<option value=\"$sr->id\">" . i18n($sr->organization) . '</option>';
|
||||||
}
|
}
|
||||||
@ -736,7 +765,7 @@ while ($sr = $sq->fetch(PDO::FETCH_OBJ)) {
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td><?= i18n('Type') ?>:</td><td>
|
<tr><td><?= i18n('Type') ?>:</td><td>
|
||||||
<?
|
<?
|
||||||
$tq = $pdo->prepare("SELECT id,type FROM award_types WHERE year=? ORDER BY type");
|
$tq = $pdo->prepare('SELECT id,type FROM award_types WHERE year=? ORDER BY type');
|
||||||
$tq->execute([$config['FAIRYEAR']]);
|
$tq->execute([$config['FAIRYEAR']]);
|
||||||
echo '<select id="awardinfo_award_types_id" name="award_types_id">';
|
echo '<select id="awardinfo_award_types_id" name="award_types_id">';
|
||||||
// only show the "choose a type" option if we are adding,if we are editing, then they must have already chosen one.
|
// only show the "choose a type" option if we are adding,if we are editing, then they must have already chosen one.
|
||||||
@ -833,7 +862,6 @@ while ($dr = $dq->fetch(PDO::FETCH_OBJ)) {
|
|||||||
<th><?= i18n('Actions') ?></th>
|
<th><?= i18n('Actions') ?></th>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<br >
|
<br >
|
||||||
* <?= i18n('Click on the Script Order and drag to re-order the prizes') ?>
|
|
||||||
<br >
|
<br >
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@ -880,7 +908,7 @@ while ($dr = $dq->fetch(PDO::FETCH_OBJ)) {
|
|||||||
<br />
|
<br />
|
||||||
<form>
|
<form>
|
||||||
<input type="submit" onClick="prize_create();return false;" value="<?= i18n('Create New Prize') ?>" />
|
<input type="submit" onClick="prize_create();return false;" value="<?= i18n('Create New Prize') ?>" />
|
||||||
<input type="submit" id="prizeinfo_save" onClick="prize_save();return false;" value="<?= i18n('Save Prize') ?>" disabled="disabled" />
|
<input type="submit" id="prizeinfo_save" onClick="prize_save();" value="<?= i18n('Save Prize') ?>" disabled="disabled" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -1084,13 +1112,6 @@ echo '</table>';
|
|||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<?
|
<?
|
||||||
|
|
||||||
/*
|
|
||||||
* For some reason, this submit button opens the dialog then it closes right away, but it doesn't
|
|
||||||
* if the entry is done through the a href
|
|
||||||
*/
|
|
||||||
// <input type="submit" onClick="award_create();" value="<?=i18n("Create New Award")>" />
|
|
||||||
|
|
||||||
$where_asi = $where_asi ?? '';
|
$where_asi = $where_asi ?? '';
|
||||||
$where_ati = $where_ati ?? '';
|
$where_ati = $where_ati ?? '';
|
||||||
|
|
||||||
@ -1120,16 +1141,16 @@ WHERE
|
|||||||
award_awards.year=?
|
award_awards.year=?
|
||||||
$where_asi
|
$where_asi
|
||||||
$where_ati
|
$where_ati
|
||||||
AND \taward_types.year=?
|
AND award_types.year=?
|
||||||
$orderby
|
$orderby
|
||||||
");
|
");
|
||||||
|
|
||||||
$q->execute([$config['FAIRYEAR'],$config['FAIRYEAR']]);
|
$q->execute([$config['FAIRYEAR'], $config['FAIRYEAR']]);
|
||||||
|
|
||||||
show_pdo_errors_if_any($pdo);
|
show_pdo_errors_if_any($pdo);
|
||||||
|
|
||||||
if ($q->rowCount()) {
|
if ($q->rowCount()) {
|
||||||
echo '* ' . i18n('Click on the Script Order and drag to re-order the awards');
|
//echo '* ' . i18n('Click on the Script Order and drag to re-order the awards');
|
||||||
echo '<table id="awardlist" class="tableview" >';
|
echo '<table id="awardlist" class="tableview" >';
|
||||||
echo '<tr class="nodrop nodrag">';
|
echo '<tr class="nodrop nodrag">';
|
||||||
echo ' <th>' . i18n('Order') . '</th>';
|
echo ' <th>' . i18n('Order') . '</th>';
|
||||||
@ -1154,7 +1175,7 @@ if ($q->rowCount()) {
|
|||||||
echo " <td $eh>{$r->type}</td>\n";
|
echo " <td $eh>{$r->type}</td>\n";
|
||||||
echo " <td $eh>{$r->name}</td>\n";
|
echo " <td $eh>{$r->name}</td>\n";
|
||||||
|
|
||||||
$numq = $pdo->prepare("SELECT SUM(number) AS num FROM award_prizes WHERE award_awards_id=?");
|
$numq = $pdo->prepare('SELECT SUM(number) AS num FROM award_prizes WHERE award_awards_id=?');
|
||||||
$numq->execute([$r->id]);
|
$numq->execute([$r->id]);
|
||||||
$numr = $numq->fetch(PDO::FETCH_ASSOC);
|
$numr = $numq->fetch(PDO::FETCH_ASSOC);
|
||||||
if (!$numr['num'])
|
if (!$numr['num'])
|
||||||
|
@ -42,8 +42,8 @@ echo '<a href="award_awards.php?action=edit_prize_template">' . i18n('Edit prize
|
|||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<a href="award_awardcreatedivisional.php">' . i18n('Create divisional awards for all divisions & categories') . '</a><br />';
|
echo '<a href="award_awardcreatedivisional.php">' . i18n('Create divisional awards for all divisions & categories') . '</a><br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<a href="award_download.php">' . i18n('Download awards from external sources') . '</a><br />';
|
//echo '<a href="award_download.php">' . i18n('Download awards from external sources') . '</a><br />';
|
||||||
echo '<a href="award_upload.php">' . i18n('Upload award winners to external sources') . '</a><br />';
|
//echo '<a href="award_upload.php">' . i18n('Upload award winners to external sources') . '</a><br />';
|
||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ function getLanguagesOfProjectsEligibleForAward($award_id)
|
|||||||
{
|
{
|
||||||
global $config, $pdo;
|
global $config, $pdo;
|
||||||
|
|
||||||
$prjq = $pdo->prepare("SELECT DISTINCT(projects.language) AS language
|
$prjq = $pdo->prepare('SELECT DISTINCT(projects.language) AS language
|
||||||
FROM
|
FROM
|
||||||
award_awards,
|
award_awards,
|
||||||
award_awards_projectcategories,
|
award_awards_projectcategories,
|
||||||
@ -85,7 +85,7 @@ function getLanguagesOfProjectsEligibleForAward($award_id)
|
|||||||
AND projects.year=?
|
AND projects.year=?
|
||||||
ORDER BY
|
ORDER BY
|
||||||
language
|
language
|
||||||
");
|
');
|
||||||
$prjq->execute([$award_id, $config['FAIRYEAR']]);
|
$prjq->execute([$award_id, $config['FAIRYEAR']]);
|
||||||
$languages = array();
|
$languages = array();
|
||||||
while ($r = $prjq->fetch(PDO::FETCH_OBJ)) {
|
while ($r = $prjq->fetch(PDO::FETCH_OBJ)) {
|
||||||
@ -100,7 +100,7 @@ function getProjectsEligibleOrNominatedForAwards($awards_ids_array)
|
|||||||
global $pdo;
|
global $pdo;
|
||||||
$projects = array();
|
$projects = array();
|
||||||
foreach ($awards_ids_array AS $award_id) {
|
foreach ($awards_ids_array AS $award_id) {
|
||||||
$q = $pdo->prepare("SELECT award_types.type FROM award_awards, award_types WHERE award_awards.id=? AND award_awards.award_types_id=award_types.id");
|
$q = $pdo->prepare('SELECT award_types.type FROM award_awards, award_types WHERE award_awards.id=? AND award_awards.award_types_id=award_types.id');
|
||||||
$q->execute([$award_id]);
|
$q->execute([$award_id]);
|
||||||
$r = $q->fetch(PDO::FETCH_OBJ);
|
$r = $q->fetch(PDO::FETCH_OBJ);
|
||||||
|
|
||||||
@ -174,7 +174,8 @@ function getSpecialAwardsNominatedForProject($projectid)
|
|||||||
{
|
{
|
||||||
global $config, $pdo;
|
global $config, $pdo;
|
||||||
|
|
||||||
$awardsq = $pdo->prepare("SELECT
|
try {
|
||||||
|
$awardsq = $pdo->prepare('SELECT
|
||||||
award_awards.id,
|
award_awards.id,
|
||||||
award_awards.name,
|
award_awards.name,
|
||||||
award_awards.criteria,
|
award_awards.criteria,
|
||||||
@ -191,25 +192,29 @@ function getSpecialAwardsNominatedForProject($projectid)
|
|||||||
AND projects.id=?
|
AND projects.id=?
|
||||||
ORDER BY
|
ORDER BY
|
||||||
award_awards.name
|
award_awards.name
|
||||||
");
|
');
|
||||||
$awardsq->execute([$projectid, $config['FAIRYEAR'], $projectid]);
|
$awardsq->execute([$projectid, $config['FAIRYEAR'], $projectid]);
|
||||||
$awards = array();
|
$awards = array();
|
||||||
show_pdo_errors_if_any($pdo);
|
|
||||||
while ($r = $awardsq->fetch(PDO::FETCH_OBJ)) {
|
while ($r = $awardsq->fetch(PDO::FETCH_OBJ)) {
|
||||||
$awards[$r->id] = array(
|
$awards[$r->id] = array(
|
||||||
'id' => $r->id,
|
'id' => $r->id,
|
||||||
'criteria' => $r->criteria,
|
'criteria' => $r->criteria,
|
||||||
'name' => $r->name,
|
'name' => $r->name,
|
||||||
'fairs_id' => $r->fairs_id
|
'fairs_id' => $r->fairs_id
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
return $awards;
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error_log($exception);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return $awards;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNominatedForNoSpecialAwardsForProject($projectid)
|
function getNominatedForNoSpecialAwardsForProject($projectid)
|
||||||
{
|
{
|
||||||
global $config, $pdo;
|
global $config, $pdo;
|
||||||
$awardsq = $pdo->prepare("SELECT
|
$awardsq = $pdo->prepare('SELECT
|
||||||
projects.id AS projects_id
|
projects.id AS projects_id
|
||||||
FROM
|
FROM
|
||||||
project_specialawards_link,
|
project_specialawards_link,
|
||||||
@ -219,7 +224,7 @@ function getNominatedForNoSpecialAwardsForProject($projectid)
|
|||||||
AND projects.year=?
|
AND projects.year=?
|
||||||
AND projects.id=?
|
AND projects.id=?
|
||||||
AND project_specialawards_link.award_awards_id IS NULL
|
AND project_specialawards_link.award_awards_id IS NULL
|
||||||
");
|
');
|
||||||
$awardsq->execute([$projectid, $config['FAIRYEAR'], $projectid]);
|
$awardsq->execute([$projectid, $config['FAIRYEAR'], $projectid]);
|
||||||
if ($awardsq->rowCount() == 1)
|
if ($awardsq->rowCount() == 1)
|
||||||
return true;
|
return true;
|
||||||
@ -233,7 +238,7 @@ function getProjectsNominatedForSpecialAward($award_id)
|
|||||||
// if they dont use special award nominations, then we will instead get all of the projects that
|
// if they dont use special award nominations, then we will instead get all of the projects that
|
||||||
// are eligible for the award, instead of nominated for it.
|
// are eligible for the award, instead of nominated for it.
|
||||||
if ($config['specialawardnomination'] != 'none') {
|
if ($config['specialawardnomination'] != 'none') {
|
||||||
$prjq = $pdo->prepare("SELECT
|
$prjq = $pdo->prepare('SELECT
|
||||||
projects.projectnumber,
|
projects.projectnumber,
|
||||||
projects.title,
|
projects.title,
|
||||||
projects.language,
|
projects.language,
|
||||||
@ -248,7 +253,7 @@ function getProjectsNominatedForSpecialAward($award_id)
|
|||||||
AND projects.year=?
|
AND projects.year=?
|
||||||
ORDER BY
|
ORDER BY
|
||||||
projectsort
|
projectsort
|
||||||
");
|
');
|
||||||
$prjq->execute([$award_id, $config['FAIRYEAR']]);
|
$prjq->execute([$award_id, $config['FAIRYEAR']]);
|
||||||
$projects = array();
|
$projects = array();
|
||||||
while ($prjr = $prjq->fetch(PDO::FETCH_OBJ)) {
|
while ($prjr = $prjq->fetch(PDO::FETCH_OBJ)) {
|
||||||
@ -274,7 +279,7 @@ function getLanguagesOfProjectsNominatedForSpecialAward($award_id)
|
|||||||
// if they dont use special award nominations, then we will instead get all of the projects that
|
// if they dont use special award nominations, then we will instead get all of the projects that
|
||||||
// are eligible for the award, instead of nominated for it.
|
// are eligible for the award, instead of nominated for it.
|
||||||
if ($config['specialawardnomination'] != 'none') {
|
if ($config['specialawardnomination'] != 'none') {
|
||||||
$prjq = $pdo->prepare("SELECT DISTINCT(projects.language) AS language
|
$prjq = $pdo->prepare('SELECT DISTINCT(projects.language) AS language
|
||||||
FROM
|
FROM
|
||||||
project_specialawards_link,
|
project_specialawards_link,
|
||||||
projects
|
projects
|
||||||
@ -284,7 +289,7 @@ function getLanguagesOfProjectsNominatedForSpecialAward($award_id)
|
|||||||
AND projects.projectnumber is not null
|
AND projects.projectnumber is not null
|
||||||
AND projects.year=?
|
AND projects.year=?
|
||||||
ORDER BY language
|
ORDER BY language
|
||||||
");
|
');
|
||||||
$prjq->execute([$award_id, $config['FAIRYEAR']]);
|
$prjq->execute([$award_id, $config['FAIRYEAR']]);
|
||||||
$languages = array();
|
$languages = array();
|
||||||
while ($r = $prjq->fetch(PDO::FETCH_OBJ)) {
|
while ($r = $prjq->fetch(PDO::FETCH_OBJ)) {
|
||||||
@ -304,7 +309,7 @@ function getSpecialAwardsNominatedByRegistrationID($id)
|
|||||||
{
|
{
|
||||||
global $config, $pdo;
|
global $config, $pdo;
|
||||||
|
|
||||||
$awardq = $pdo->prepare("SELECT
|
$awardq = $pdo->prepare('SELECT
|
||||||
award_awards.id,
|
award_awards.id,
|
||||||
award_awards.name,
|
award_awards.name,
|
||||||
award_awards_projectcategories.projectcategories_id,
|
award_awards_projectcategories.projectcategories_id,
|
||||||
@ -325,7 +330,7 @@ function getSpecialAwardsNominatedByRegistrationID($id)
|
|||||||
AND projects.year=?
|
AND projects.year=?
|
||||||
ORDER BY
|
ORDER BY
|
||||||
projectsort
|
projectsort
|
||||||
");
|
');
|
||||||
$awardq->execute([$award_id, $config['FAIRYEAR']]);
|
$awardq->execute([$award_id, $config['FAIRYEAR']]);
|
||||||
$projects = array();
|
$projects = array();
|
||||||
while ($prjr = $awardq->fetch(PDO::FETCH_OBJ)) {
|
while ($prjr = $awardq->fetch(PDO::FETCH_OBJ)) {
|
||||||
@ -342,14 +347,14 @@ function project_load($pid)
|
|||||||
{
|
{
|
||||||
global $pdo;
|
global $pdo;
|
||||||
/* Load this project */
|
/* Load this project */
|
||||||
$q = $pdo->prepare("SELECT * FROM projects WHERE id=?");
|
$q = $pdo->prepare('SELECT * FROM projects WHERE id=?');
|
||||||
$q->execute([$pid]);
|
$q->execute([$pid]);
|
||||||
$proj = $q->fetch();
|
$proj = $q->fetch();
|
||||||
|
|
||||||
/* Load the students */
|
/* Load the students */
|
||||||
$q = $pdo->prepare("SELECT students.*,schools.school FROM students
|
$q = $pdo->prepare('SELECT students.*,schools.school FROM students
|
||||||
LEFT JOIN schools ON schools.id=students.schools_id
|
LEFT JOIN schools ON schools.id=students.schools_id
|
||||||
WHERE registrations_id=? AND students.year=? ORDER BY students.id");
|
WHERE registrations_id=? AND students.year=? ORDER BY students.id');
|
||||||
$q->execute([$proj['registrations_id'], $proj['year']]);
|
$q->execute([$proj['registrations_id'], $proj['year']]);
|
||||||
$proj['num_students'] = 0;
|
$proj['num_students'] = 0;
|
||||||
while ($s = $q->fetch(PDO::FETCH_OBJ)) {
|
while ($s = $q->fetch(PDO::FETCH_OBJ)) {
|
||||||
|
@ -29,7 +29,7 @@ include 'register_participants.inc.php';
|
|||||||
include 'projects.inc.php';
|
include 'projects.inc.php';
|
||||||
|
|
||||||
// authenticate based on email address and registration number from the SESSION
|
// authenticate based on email address and registration number from the SESSION
|
||||||
if (!$_SESSION['email']) {
|
if (!get_value_from_array($_SESSION, 'email')) {
|
||||||
header('Location: register_participants.php');
|
header('Location: register_participants.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -207,25 +207,17 @@ else{
|
|||||||
|
|
||||||
|
|
||||||
// echo i18n("$participationform");
|
// echo i18n("$participationform");
|
||||||
// if ($all_complete == true)
|
if ($all_complete == true)
|
||||||
// echo '</a>';
|
echo '</a>';
|
||||||
// else
|
else
|
||||||
// echo '<br /><font color="red">(' . i18n('Available when ALL above sections are "Complete"') . ')</font>';
|
echo '<br /><font color="red">(' . i18n('Available when ALL above sections are "Complete"') . ')</font>';
|
||||||
|
|
||||||
echo '</td><td>';
|
echo "<td>";
|
||||||
echo i18n('Sign');
|
if (registrationFormsReceived())
|
||||||
// check to see if its complete
|
echo outputStatus('complete');
|
||||||
echo '</td></tr>';
|
else
|
||||||
|
echo outputStatus('incomplete');
|
||||||
// received information
|
echo "</td>";
|
||||||
// echo '<tr><td>' . i18n("$participationform Received") . '</td><td>';
|
|
||||||
// if (registrationFormsReceived())
|
|
||||||
// echo outputStatus('complete');
|
|
||||||
// else
|
|
||||||
// echo outputStatus('incomplete');
|
|
||||||
|
|
||||||
// // check to see if its complete
|
|
||||||
// echo '</td></tr>';
|
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ if (!$_SESSION['registration_number']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$q = $pdo->prepare('SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students '
|
$q = $pdo->prepare('SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students '
|
||||||
. "WHERE students.email=?"
|
. 'WHERE students.email=?'
|
||||||
. "AND registrations.num=?"
|
. 'AND registrations.num=?'
|
||||||
. "AND registrations.id=?"
|
. 'AND registrations.id=?'
|
||||||
. 'AND students.registrations_id=registrations.id '
|
. 'AND students.registrations_id=registrations.id '
|
||||||
. 'AND registrations.year=?'
|
. 'AND registrations.year=?'
|
||||||
. 'AND students.year=?');
|
. 'AND students.year=?');
|
||||||
$q->execute([$_SESSION['email'],$_SESSION['registration_number'],$_SESSION['registration_id'],$config['FAIRYEAR'],$config['FAIRYEAR']]);
|
$q->execute([$_SESSION['email'], $_SESSION['registration_number'], $_SESSION['registration_id'], $config['FAIRYEAR'], $config['FAIRYEAR']]);
|
||||||
show_pdo_errors_if_any($pdo);
|
show_pdo_errors_if_any($pdo);
|
||||||
|
|
||||||
if ($q->rowCount() == 0) {
|
if ($q->rowCount() == 0) {
|
||||||
@ -55,7 +55,7 @@ if ($q->rowCount() == 0) {
|
|||||||
}
|
}
|
||||||
$authinfo = $q->fetch(PDO::FETCH_OBJ);
|
$authinfo = $q->fetch(PDO::FETCH_OBJ);
|
||||||
|
|
||||||
$q = $pdo->prepare("SELECT * FROM projects WHERE registrations_id=?");
|
$q = $pdo->prepare('SELECT * FROM projects WHERE registrations_id=?');
|
||||||
$q->execute([$_SESSION['registration_id']]);
|
$q->execute([$_SESSION['registration_id']]);
|
||||||
$project = $q->fetch(PDO::FETCH_OBJ);
|
$project = $q->fetch(PDO::FETCH_OBJ);
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ echo '<br />';
|
|||||||
|
|
||||||
if ($config['specialawardnomination'] == 'date') {
|
if ($config['specialawardnomination'] == 'date') {
|
||||||
echo notice(i18n('Special award self-nomination is only available from %1 to %2. Please make sure you complete your nominations between these dates.', array($config['dates']['specawardregopen'], $config['dates']['specawardregclose'])));
|
echo notice(i18n('Special award self-nomination is only available from %1 to %2. Please make sure you complete your nominations between these dates.', array($config['dates']['specawardregopen'], $config['dates']['specawardregclose'])));
|
||||||
$q = $pdo->prepare("SELECT (NOW()>? AND NOW()<?) AS datecheck");
|
$q = $pdo->prepare('SELECT (NOW()>? AND NOW()<?) AS datecheck');
|
||||||
$q->execute([$config['dates']['specawardregopen'],$config['dates']['specawardregclose']]);
|
$q->execute([$config['dates']['specawardregopen'], $config['dates']['specawardregclose']]);
|
||||||
$r = $q->fetch(PDO::FETCH_OBJ);
|
$r = $q->fetch(PDO::FETCH_OBJ);
|
||||||
// this will return 1 if its between the dates, 0 otherwise.
|
// this will return 1 if its between the dates, 0 otherwise.
|
||||||
if ($r->datecheck == 1)
|
if ($r->datecheck == 1)
|
||||||
@ -123,22 +123,26 @@ if ($_POST['action'] == 'save') {
|
|||||||
if ($num > $config['maxspecialawardsperproject']) {
|
if ($num > $config['maxspecialawardsperproject']) {
|
||||||
echo error(i18n('You can only apply to %1 special awards. You have selected %2', array($config['maxspecialawardsperproject'], $num)));
|
echo error(i18n('You can only apply to %1 special awards. You have selected %2', array($config['maxspecialawardsperproject'], $num)));
|
||||||
} else {
|
} else {
|
||||||
$stmt = $pdo->prepare("DELETE FROM project_specialawards_link WHERE projects_id=? AND year=?");
|
try {
|
||||||
$stmt->execute([$project->id, $config['FAIRYEAR']]);
|
$stmt = $pdo->prepare('DELETE FROM project_specialawards_link WHERE projects_id=? AND year=?');
|
||||||
foreach ($splist AS $spaward) {
|
$stmt->execute([$project->id, $config['FAIRYEAR']]);
|
||||||
$s = ($spaward == -1) ? 'NULL' : "'$spaward'";
|
foreach ($splist AS $spaward) {
|
||||||
$stmt = $pdo->prepare('INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (
|
$stmt = $pdo->prepare('INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (
|
||||||
?,
|
?,
|
||||||
?,
|
?,
|
||||||
?)');
|
?)');
|
||||||
$stmt->execute([$s,$project->id,$config['FAIRYEAR']]);
|
$stmt->execute([$s, $project->id, $config['FAIRYEAR']]);
|
||||||
show_pdo_errors_if_any($pdo);
|
show_pdo_errors_if_any($pdo);
|
||||||
}
|
}
|
||||||
if ($num) {
|
if ($num) {
|
||||||
if ($noawards == true)
|
if ($noawards == true)
|
||||||
echo happy(i18n('Successfully registered for no special awards'));
|
echo happy(i18n('Successfully registered for no special awards'));
|
||||||
else
|
else
|
||||||
echo happy(i18n('Successfully registered for %1 special awards', array($num)));
|
echo happy(i18n('Successfully registered for %1 special awards', array($num)));
|
||||||
|
}
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
error(happy(i18n('Failed to register your settings for special awards')));
|
||||||
|
error_log($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user