From 1e56043b15a6145d448f16fd3cf3f8d371ba45eb Mon Sep 17 00:00:00 2001 From: patrick Date: Sat, 22 Feb 2025 02:29:20 +0000 Subject: [PATCH] Re-enable tours management --- admin/tours_assignments.php | 51 +++++++++--------- admin/tours_manager.php | 17 +++--- admin/tours_sa.php | 3 +- admin/tours_sa_config.php | 2 +- admin/tours_sa_status.php | 19 +++++-- config_editor.inc.php | 5 +- js/sfiab.js | 7 +-- register_participants_tours.php | 2 +- tableeditor.class.php | 20 ++++---- theme/icons_science_ation/icons.php | 2 +- theme/icons_science_ation/tours.png | Bin 0 -> 504 bytes tours.class.php | 77 +++++++++++++++++----------- translationseditor.inc.php | 2 +- 13 files changed, 122 insertions(+), 85 deletions(-) create mode 100644 theme/icons_science_ation/tours.png diff --git a/admin/tours_assignments.php b/admin/tours_assignments.php index 683f9a45..19aed85f 100644 --- a/admin/tours_assignments.php +++ b/admin/tours_assignments.php @@ -32,8 +32,8 @@ require_once ('../user.inc.php'); user_auth_required('committee', 'admin'); /* Load Tours */ -$query = "SELECT * FROM tours WHERE - year=?"; +$query = 'SELECT * FROM tours WHERE + year=?'; $r = $pdo->prepare($query); $r->execute([$config['FAIRYEAR']]); $tours = array(); @@ -45,22 +45,22 @@ while ($i = $r->fetch(PDO::FETCH_OBJ)) { if (get_value_from_array($_GET, 'action') == 'info') { $sid = intval($_GET['id']); - $query = "SELECT * FROM students WHERE id=? - AND year=?"; + $query = 'SELECT * FROM students WHERE id=? + AND year=?'; $r = $pdo->prepare($query); - $r->execute([$sid,$config['FAIRYEAR']]); + $r->execute([$sid, $config['FAIRYEAR']]); $i = $r->fetch(PDO::FETCH_OBJ); send_popup_header(i18n('Student Tour Rank Information - %1 %2', array($i->firstname, $i->lastname))); - $query = "SELECT * FROM tours_choice + $query = 'SELECT * FROM tours_choice WHERE students_id=? AND year=? - ORDER BY rank"; + ORDER BY rank'; $r = $pdo->prepare($query); - $r->execute([$sid,$config['FAIRYEAR']]); + $r->execute([$sid, $config['FAIRYEAR']]); echo ''; - $count = $r->rowwCount(); + $count = $r->rowCount(); while ($i = $r->fetch(PDO::FETCH_OBJ)) { echo '
'; if ($i->rank == 0) { @@ -156,8 +156,8 @@ if (get_value_from_array($_POST, 'action') == 'add' && $tours_id != 0 && count($ /* Make sure the student exists */ $sid = intval($sid); - $q = $pdo->prepare("SELECT registrations_id FROM students - WHERE id=?"); + $q = $pdo->prepare('SELECT registrations_id FROM students + WHERE id=?'); $q->execute([$sid]); $i = $q->fetch(PDO::FETCH_OBJ); $rid = $i->registrations_id; @@ -167,15 +167,18 @@ if (get_value_from_array($_POST, 'action') == 'add' && $tours_id != 0 && count($ students_id=? AND year=? AND rank='0'"); - $stmt->execute([$sid,$config['FAIRYEAR']]); + $stmt->execute([$sid, $config['FAIRYEAR']]); /* Connect this student to this tour */ $stmt = $pdo->prepare("INSERT INTO tours_choice (`students_id`,`registrations_id`, `tour_id`,`year`,`rank`) VALUES ( - ?,?,?, - ?,'0')"); - $stmt->execute([$sid,$rid,$tours_id,$config['FAIRYEAR']]); + ?, + ?, + ?, + ?, + '0')"); + $stmt->execute([$sid, $rid, $tours_id, $config['FAIRYEAR']]); $added++; } if ($added == 1) @@ -189,6 +192,7 @@ if (get_value_from_array($_POST, 'action') == 'add' && $tours_id != 0 && count($ } $tours_id = intval(get_value_from_array($_GET, 'tours_id')); +error_log("Tours ID: " . $tours_id); $students_id = intval(get_value_from_array($_GET, 'students_id')); if (get_value_from_array($_GET, 'action') == 'del' && $tours_id > 0 && $students_id > 0) { @@ -196,17 +200,17 @@ if (get_value_from_array($_GET, 'action') == 'del' && $tours_id > 0 && $students WHERE students_id=? AND year=? AND rank='0'"); - $stmt->execute([$students_id,$config['FAIRYEAR']]); + $stmt->execute([$students_id, $config['FAIRYEAR']]); echo happy(i18n('Removed student from tour #%1 (%2)', array($tours[$tours_id]['num'], $tours[$tours_id]['name']))); } if (get_value_from_array($_GET, 'action') == 'empty' && $tours_id > 0) { - $stmt = $po->prepare("DELETE FROM tours_choice WHERE + $stmt = $pdo->prepare("DELETE FROM tours_choice WHERE tour_id=? AND year=? AND rank='0'"); - $stmt->execute([$tours_id,$config['FAIRYEAR']]); + $stmt->execute([$tours_id, $config['FAIRYEAR']]); echo happy(i18n('Emptied all students from tour #%1 (%2)', array($tours[$tours_id]['num'], $tours[$tours_id]['name']))); } @@ -235,9 +239,8 @@ echo '
'; * (rank=0), or if there is no selection, make * rank NULL, and tours_id NULL */ -$querystr = "SELECT \tstudents.firstname, students.lastname, - students.id, - tours_choice.tour_id, tours_choice.rank +$querystr = "SELECT students.firstname, students.lastname, + students.id, tours_choice.tour_id, tours_choice.rank FROM students LEFT JOIN tours_choice ON (tours_choice.students_id=students.id AND tours_choice.rank=0) @@ -245,15 +248,15 @@ $querystr = "SELECT \tstudents.firstname, students.lastname, WHERE students.year=? AND (tours_choice.year=? OR - \t tours_choice.year IS NULL) AND - registrations.status='complete' + tours_choice.year IS NULL) AND + registrations.status='complete' OR registrations.status='paymentpending' ORDER BY students.lastname, students.firstname, tours_choice.rank"; $q = $pdo->prepare($querystr); -$q->execute([$config['FAIRYEAR'],$config['FAIRYEAR']]); +$q->execute([$config['FAIRYEAR'], $config['FAIRYEAR']]); show_pdo_errors_if_any($pdo); diff --git a/admin/tours_manager.php b/admin/tours_manager.php index 6c1da4e7..82e65f4a 100644 --- a/admin/tours_manager.php +++ b/admin/tours_manager.php @@ -38,13 +38,13 @@ send_header('Tour Management', 'Administration' => 'admin/index.php', 'Tours' => 'admin/tours.php')); -if ($_GET['action'] == 'renumber') { - $q = $pdo->prepare("SELECT id FROM tours WHERE year=?"); +if (get_value_from_array($_GET, 'action') == 'renumber') { + $q = $pdo->prepare('SELECT id FROM tours WHERE year=?'); $q->execute([$config['FAIRYEAR']]); $x = 1; - while ($i = $q->fetch(PDP::FETCH_OBJ)) { - $stmt = $pdo->prepare("UPDATE tours SET num=? WHERE id=?"); - $stmt->execute([$x,$i->id]); + while ($i = $q->fetch(PDO::FETCH_OBJ)) { + $stmt = $pdo->prepare('UPDATE tours SET num=? WHERE id=?'); + $stmt->execute([$x, $i->id]); $x++; } echo happy(i18n('Tours successfully renumbered')); @@ -73,12 +73,13 @@ $icon_exitension = $config['icon_extension']; $editor = new TableEditor('tours'); -// $editor->setDebug(true); +tours::tableEditorSetup($editor); + $editor->filterList("(tours.year={$config['FAIRYEAR']} OR tours.year IS NULL)"); $editor->execute(); -if ($_GET['TableEditorAction'] == '') { +//if (get_value_from_array($_GET, 'TableEditorAction') == '') { echo i18n('You can automatically erase all the tour numbers and re-number them (starting from 1) by clicking on the link below. This will NOT affect any students who have already specified @@ -90,7 +91,7 @@ if ($_GET['TableEditorAction'] == '') { echo '

'; echo 'Renumber ALL Tours'; -} +//} send_footer(); ?> diff --git a/admin/tours_sa.php b/admin/tours_sa.php index 1a0a4afa..9a053d10 100644 --- a/admin/tours_sa.php +++ b/admin/tours_sa.php @@ -52,6 +52,7 @@ TRACE('
');
 
 function set_status($txt)
 {
+	global $pdo;
 	TRACE("Status: $txt\n");
 	$stmt = $pdo->prepare("UPDATE config SET val=? WHERE 
 			var='tours_assigner_activity' AND year=0");
@@ -62,7 +63,7 @@ $set_percent_last_percent = -1;
 
 function set_percent($n)
 {
-	global $set_percent_last_percent;
+	global $pdo, $set_percent_last_percent;
 	$p = floor($n);
 	if ($p == $set_percent_last_percent)
 		return;
diff --git a/admin/tours_sa_config.php b/admin/tours_sa_config.php
index ac4fc264..69290871 100644
--- a/admin/tours_sa_config.php
+++ b/admin/tours_sa_config.php
@@ -121,7 +121,7 @@ if ($config['tours_assigner_percent'] == '-1') {
 } else {
 	echo '
'; echo ''; - echo i18n('Automatic assignemnts are currently in progress'); + echo i18n('Automatic assignments are currently in progress'); echo ''; echo '
'; echo '
'; diff --git a/admin/tours_sa_status.php b/admin/tours_sa_status.php index 5b095cbc..cb7a8bb1 100644 --- a/admin/tours_sa_status.php +++ b/admin/tours_sa_status.php @@ -52,7 +52,20 @@ send_header('Scheduler Status', 'Administration' => 'admin/index.php', 'Tours' => 'admin/tours.php')); require_once ('../ajax.inc.php'); -?>DBHOST'updatestatus').innerHTML="Updating..."; +?> + + +