diff --git a/.devcontainer/science-ation-blank-generic.sql b/.devcontainer/science-ation-blank-generic.sql
index f76ac430..fbe2d9b9 100644
--- a/.devcontainer/science-ation-blank-generic.sql
+++ b/.devcontainer/science-ation-blank-generic.sql
@@ -1771,9 +1771,10 @@ CREATE TABLE `projectcategories` (
LOCK TABLES `projectcategories` WRITE;
/*!40000 ALTER TABLE `projectcategories` DISABLE KEYS */;
INSERT INTO `projectcategories` VALUES
-(1,'junor','',7,8,2025),
-(2,'senior','',11,12,2025),
-(3,'int','',9,10,2025);
+(1,'Junior','',7,8,2025),
+(2,'Intermediate','',9,10,2025),
+(3,'Senior','',11,12,2025);
+
/*!40000 ALTER TABLE `projectcategories` ENABLE KEYS */;
UNLOCK TABLES;
@@ -3131,7 +3132,7 @@ CREATE TABLE `schools` (
LOCK TABLES `schools` WRITE;
/*!40000 ALTER TABLE `schools` DISABLE KEYS */;
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 */;
UNLOCK TABLES;
diff --git a/admin/award_awards.php b/admin/award_awards.php
index 27d30c81..5af4f4a4 100644
--- a/admin/award_awards.php
+++ b/admin/award_awards.php
@@ -31,16 +31,15 @@ require_once ('awards.inc.php');
$_GET['action'] = $_GET['action'] ?? '';
switch ($_GET['action']) {
- case 'awardinfo_load':
- ;
+ case 'awardinfo_load':;
$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]);
$ret = $q->fetch(PDO::FETCH_ASSOC);
// json_encode NEEDS UTF8 DATA, but we store it in the database as ISO :(
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 json_encode($ret);
@@ -55,17 +54,17 @@ switch ($_GET['action']) {
/* Scrub the data while we save it */
$id = intval($_POST['id']);
- if ($id == -1) {
- $q = $pdo->prepare("INSERT INTO award_awards (year,self_nominate,schedule_judges)
+ try {
+ if ($id == -1) {
+ $q = $pdo->prepare("INSERT INTO award_awards (year,self_nominate,schedule_judges)
VALUES (?,'yes','yes')");
- $q->execute([$config['FAIRYEAR']]);
- $id = $pdo->lastInsertId();
- happy_('Award Created');
- /* Set the award_id in the client */
- echo "";
- }
+ $q->execute([$config['FAIRYEAR']]);
+ $id = $pdo->lastInsertId();
+ /* Set the award_id in the client */
+ echo "";
+ }
- $q = "UPDATE award_awards SET
+ $q = "UPDATE award_awards SET
award_types_id='" . intval($_POST['award_types_id']) . "',
presenter='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['presenter'])) . "',
excludefromac='" . (($_POST['excludefromac'] == 1) ? 1 : 0) . "',
@@ -74,21 +73,32 @@ switch ($_GET['action']) {
schedule_judges='" . (($_POST['schedule_judges'] == 'yes') ? 'yes' : 'no') . "',
description='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['description'])) . "' ";
- 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
- */
- $q .= ",name='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['name'])) . "',
- criteria='" . iconv('UTF-8', 'ISO-8859-1', stripslashes($_POST['criteria'])) . "',
- sponsors_id='" . intval($_POST['sponsors_id']) . "' ";
+
+ 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
+ */
+ $q .= ",name=" . $pdo->quote($_POST['name']) . ",
+ 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;
case 'eligibility_load':
@@ -96,19 +106,27 @@ switch ($_GET['action']) {
// select the current categories that this award is linked to
$ret = array('categories' => array(), 'divisions' => array());
- $q = $pdo->prepare("SELECT * FROM award_awards_projectcategories WHERE award_awards_id=?");
- $q->execute([$id]);
- while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
- $ret['categories'][] = $r['projectcategories_id'];
+ try {
+ $q = $pdo->prepare('SELECT * FROM award_awards_projectcategories WHERE award_awards_id=?');
+ $q->execute([$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;
case 'eligibility_save':
@@ -119,78 +137,94 @@ switch ($_GET['action']) {
error_('Invalid data');
exit;
}
-
- // wipe out any old award-category links
- $q = $pdo->prepare("DELETE FROM award_awards_projectcategories WHERE award_awards_id=?");
- $q->execute([$id]);
- foreach ($_POST['categories'] AS $key => $cat) {
- $c = intval($cat);
- $q = $pdo->prepare('INSERT INTO award_awards_projectcategories (award_awards_id, projectcategories_id, year)
+ try {
+ // wipe out any old award-category links
+ $q = $pdo->prepare('DELETE FROM award_awards_projectcategories WHERE award_awards_id=?');
+ $q->execute([$id]);
+ foreach ($_POST['categories'] AS $key => $cat) {
+ $c = intval($cat);
+ $q = $pdo->prepare('INSERT INTO award_awards_projectcategories (award_awards_id, projectcategories_id, year)
VALUES (:id, :c, :year)');
- $q->bindParam(':id', $id, PDO::PARAM_INT);
- $q->bindParam(':c', $c, PDO::PARAM_INT);
- $q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
+ $q->bindParam(':id', $id, PDO::PARAM_INT);
+ $q->bindParam(':c', $c, 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->execute([$id]);
+ $q = $pdo->prepare('DELETE FROM award_awards_projectdivisions WHERE award_awards_id=?');
+ $q->execute([$id]);
- // now add the new ones
- foreach ($_POST['divisions'] AS $key => $div) {
- $d = intval($div);
+ // now add the new ones
+ foreach ($_POST['divisions'] AS $key => $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)');
- $q->bindParam(':id', $id, PDO::PARAM_INT);
- $q->bindParam(':d', $d, PDO::PARAM_INT);
- $q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
+ $q->bindParam(':id', $id, PDO::PARAM_INT);
+ $q->bindParam(':d', $d, PDO::PARAM_INT);
+ $q->bindParam(':year', $config['FAIRYEAR'], PDO::PARAM_INT);
- $q->execute();
- show_pdo_errors_if_any($pdo);
+ $q->execute();
+ show_pdo_errors_if_any($pdo);
+ }
+
+ happy_('Eligibility information saved');
+ } catch (PDOException $exception) {
+ error_('Eligibility information failed to save');
}
- happy_('Eligibility information saved');
exit;
case 'prize_order':
$order = 0;
- foreach ($_GET['prizelist'] as $position => $id) {
- if ($id == '')
- continue;
- $order++;
- $q = $pdo->prepare("UPDATE `award_prizes` SET `order`=? WHERE `id`=?");
- $q->execute([$order, $id]);
+ try {
+ 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;
case 'award_order':
$order = 0;
- foreach ($_GET['awardlist'] as $position => $id) {
- if ($id == '')
- continue;
- $order++;
+ try {
+ foreach ($_GET['awardlist'] as $position => $id) {
+ if ($id == '')
+ continue;
+ $order++;
- $q = $pdo->prepare("UPDATE `award_awards` SET `order`=? WHERE `id`=?");
- $q->execute([$order, $id]);
+ $q = $pdo->prepare('UPDATE `award_awards` SET `order`=? WHERE `id`=?');
+ $q->execute([$order, $id]);
+ }
+
+ happy_('Order updated');
+ } catch (PDOException $exception) {
+ error_('Order failed to update');
+ error_log($exception);
}
- happy_('Order updated');
exit;
case 'prizeinfo_load':
$id = intval($_GET['id']);
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();
} 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]);
}
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
@@ -204,7 +238,7 @@ switch ($_GET['action']) {
case 'prize_load':
$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]);
$ret = $q->fetch(PDO::FETCH_ASSOC);
foreach ($ret AS $k => $v) {
@@ -221,21 +255,26 @@ switch ($_GET['action']) {
$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(':year', $year, PDO::PARAM_INT);
+ $q->bindParam(':aaid', $aaid, PDO::PARAM_INT);
+ $q->bindParam(':year', $year, PDO::PARAM_INT);
- $q->execute();
+ $q->execute();
- $ret = array('id' => $pdo->lastInsertId());
- echo json_encode($ret);
+ $ret = array('id' => $pdo->lastInsertId());
+ echo json_encode($ret);
+ } catch (PDOException $exception) {
+ error_log($exception);
+ }
exit;
case 'prize_save':
$id = intval($_POST['id']);
- $q = $pdo->prepare('UPDATE award_prizes SET
+ try {
+ $q = $pdo->prepare('UPDATE award_prizes SET
prize = :prize,
cash = :cash,
scholarship = :scholarship,
@@ -248,21 +287,25 @@ switch ($_GET['action']) {
trophyschoolreturn = :trophyschoolreturn
WHERE id = :id');
- $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(':scholarship', intval($_POST['scholarship']), PDO::PARAM_INT);
- $q->bindValue(':value', intval($_POST['value']), 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(':trophystudentkeeper', ($_POST['trophystudentkeeper'] == 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(':trophyschoolreturn', ($_POST['trophyschoolreturn'] == 1) ? 1 : 0, PDO::PARAM_INT);
- $q->bindValue(':id', $id, PDO::PARAM_INT);
+ $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(':scholarship', intval($_POST['scholarship']), PDO::PARAM_INT);
+ $q->bindValue(':value', intval($_POST['value']), 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(':trophystudentkeeper', ($_POST['trophystudentkeeper'] == 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(':trophyschoolreturn', ($_POST['trophyschoolreturn'] == 1) ? 1 : 0, 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;
case 'prize_delete':
@@ -275,7 +318,7 @@ switch ($_GET['action']) {
$id = intval($_GET['id']);
/* 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]);
$ul = array();
$dl = array();
@@ -286,7 +329,7 @@ switch ($_GET['action']) {
$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]);
$a = $q->fetch(PDO::FETCH_ASSOC);
?>
@@ -346,38 +389,46 @@ switch ($_GET['action']) {
/* Prepare a fair-wise list */
$data = array();
- foreach ($dl AS $fairs_id)
+ foreach ($dl AS $fairs_id) {
$data[$fairs_id]['dl'] = true;
- foreach ($ul AS $fairs_id)
+ }
+
+ foreach ($ul AS $fairs_id) {
$data[$fairs_id]['ul'] = true;
+ }
/* Now save each one */
- $q = $pdo->prepare("DELETE FROM fairs_awards_link WHERE award_awards_id=?");
- $q->execute([$id]);
- show_pdo_errors_if_any($pdo);
- 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]);
+ try {
+ $q = $pdo->prepare('DELETE FROM fairs_awards_link WHERE award_awards_id=?');
+ $q->execute([$id]);
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']);
+ foreach ($data as $fairs_id => $f) {
+ $dl = ($f['dl'] == true) ? 'yes' : 'no';
+ $ul = ($f['ul'] == true) ? 'yes' : 'no';
- $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_register_winners=?,
per_fair=?
- WHERE id=?");
- $q->execute([[$ident, $mat,$w],$per_fair,$id]);
+ WHERE 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;
}
@@ -387,7 +438,6 @@ send_header('Awards Management',
'Awards Main' => 'admin/awards.php'));
?>
-
@@ -725,7 +754,7 @@ $(document).ready(function() {
$sq = $pdo->prepare('SELECT id,organization FROM sponsors ORDER BY organization');
$sq->execute();
echo '