Re-enable tours management

This commit is contained in:
patrick 2025-02-22 02:29:20 +00:00
parent a7558e3ffc
commit 1e56043b15
13 changed files with 122 additions and 85 deletions

View File

@ -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 '<table>';
$count = $r->rowwCount();
$count = $r->rowCount();
while ($i = $r->fetch(PDO::FETCH_OBJ)) {
echo '<tr><td align="right">';
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 '<tr><td valign="top">';
* (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);

View File

@ -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 '<br /><br />';
echo '<a onclick="return confirmClick(\'Are you sure you re-number ALL the tours?\')" href="tours_manager.php?action=renumber">Renumber ALL Tours</a>';
}
//}
send_footer();
?>

View File

@ -52,6 +52,7 @@ TRACE('<pre>');
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;

View File

@ -121,7 +121,7 @@ if ($config['tours_assigner_percent'] == '-1') {
} else {
echo '<br />';
echo '<b>';
echo i18n('Automatic assignemnts are currently in progress');
echo i18n('Automatic assignments are currently in progress');
echo '</b>';
echo '<br />';
echo '<br />';

View File

@ -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...";
?>
<script type="text/javascript">
var starttime=0;
var startpercent=0;
var deltatime=0;
var deltapercent=0;
var avgtimeperpercent=0;
var remainingpercent=0;
var remainingtime=0;
function updateStatus()
{
document.getElementById('updatestatus').innerHTML="Updating...";
var url="tours_sa_status.php?action=output";
http.open("GET",url,true);
http.onreadystatechange=handleResponse;
@ -65,7 +78,7 @@ function clearUpdatingMessage()
}
function handleResponse()DBHOST
function handleResponse()
{
try {
@ -105,7 +118,7 @@ function handleResponse()DBHOST
}
}
}
catch(e)DBHOST
catch(e)
{
alert('caught error'+e);

View File

@ -219,9 +219,10 @@ function config_editor($category, $year, $array_name, $self)
*/
$var = config_editor_load($category, $year);
if (($category == 'Tours' or $category == 'Volunteer Registration') and ($config['tours_enable'] !== 'yes' or $config['participant_regfee_items_enable'] !== 'yes'))
// FIXME
/*if (($category == 'Tours' or $category == 'Volunteer Registration') and ($config['tours_enable'] !== 'yes' or $config['participant_regfee_items_enable'] !== 'yes'))
echo "<form method=\"post\" style='pointer-events: none; opacity: 0.5;' action=\"$self\">";
*/
echo "<form method=\"post\" action=\"$self\">";
echo '<table cellpadding="3">';

View File

@ -2,10 +2,11 @@
function confirmClick(msg)
{
var okay=confirm(msg);
if(okay)
return true;
else
if(okay) {
return true;
} else {
return false;
}
}
function el(str,domain,name)

View File

@ -157,7 +157,7 @@ $tours = array();
$q = $pdo->prepare('SELECT * FROM tours WHERE year=? ORDER BY id');
$q->execute([$config['FAIRYEAR']]);
if ($q->rowCount() == 0) {
echo notice(i18n('There is not tour information'));
echo notice(i18n('There is no tour information'));
send_footer();
exit;
}

View File

@ -44,6 +44,8 @@
// cfdc
// $icon_path="/phpscripts/images/16";
// sfiab
require_once "helper.inc.php";
global $icon_extension;
$icon_path = "{$config['SFIABDIRECTORY']}/images/16";
@ -500,7 +502,7 @@ class TableEditor
$query .= $field . $n . ',';
}
// rip off the last commaguix-system-vm-image-1.4.0.x86_64-linux.qcow2
// rip off the last comma
$query = substr($query, 0, -1);
if ($insert_mode) {
@ -643,9 +645,9 @@ class TableEditor
}
} else {
if ($this->fieldValidation[$f])
$editdata[$f] = "'" . $pdo->quote(stripslashes(preg_replace($this->fieldValidation[$f], '', $_POST[$f]))) . "'";
$editdata[$f] = $pdo->quote(stripslashes(preg_replace($this->fieldValidation[$f], '', $_POST[$f])));
else
$editdata[$f] = "'" . $pdo->quote(stripslashes($_POST[$f])) . "'";
$editdata[$f] = $pdo->quote(stripslashes($_POST[$f]));
}
}
@ -674,11 +676,11 @@ class TableEditor
$text_happy = 'saved';
}
if ($pdo->errorInfo()) {
/*if (pdo_failed($pdo)) {
echo error(i18n("Error $text_error %1: %2", array($this->recordType, $pdo->errorInfo())));
} else {
echo happy(i18n("Successfully $text_happy %1", array($this->recordType)));
}
}*/
}
if (get_value_from_array($_GET, 'TableEditorAction') == 'add' || (get_value_from_array($_GET, 'TableEditorAction') == 'edit' && get_value_from_array($_GET, 'edit'))) {
@ -748,17 +750,17 @@ class TableEditor
switch ($inputtype) {
case 'text':
if ($this->fieldInputOptions[$f])
echo '<input type="text" ' . $this->fieldInputOptions[$f] . " id=\"$f\" name=\"$f\" value=\"" . htmlspecialchars($editdata[$f]) . '"/>';
echo '<input type="text" ' . $this->fieldInputOptions[$f] . " id=\"$f\" name=\"$f\" value=\"" . htmlspecialchars(get_value_from_array($editdata, $f, '')) . '"/>';
else
echo "<input type=\"text\" size=\"$inputsize\" maxlength=\"$inputmaxlen\" id=\"$f\" name=\"$f\" value=\"" . htmlspecialchars($editdata[$f]) . '"/>';
echo "<input type=\"text\" size=\"$inputsize\" maxlength=\"$inputmaxlen\" id=\"$f\" name=\"$f\" value=\"" . htmlspecialchars(get_value_from_array($editdata, $f, '')) . '"/>';
break;
case 'textarea':
$maxlen = ($inputmaxlen > 0) ? " onkeypress=\"return do_maxlength(this, $inputmaxlen);\" " : '';
if ($this->fieldInputOptions[$f])
echo "<textarea id=\"$f\" name=\"$f\" $maxlen" . $this->fieldInputOptions[$f] . '>' . htmlspecialchars($editdata[$f]) . '</textarea>';
echo "<textarea id=\"$f\" name=\"$f\" $maxlen" . $this->fieldInputOptions[$f] . '>' . htmlspecialchars(get_value_from_array($editdata, $f, '')) . '</textarea>';
else
echo "<textarea id=\"$f\" name=\"$f\" $maxlen rows=\"5\" cols=\"50\">" . htmlspecialchars($editdata[$f]) . '</textarea>';
echo "<textarea id=\"$f\" name=\"$f\" $maxlen rows=\"5\" cols=\"50\">" . htmlspecialchars(get_value_from_array($editdata, $f, '')) . '</textarea>';
break;
case 'select':
if ($this->fieldInputOptions[$f])

View File

@ -42,7 +42,7 @@
$theme_icons['icons']['translations_management']="kwordquiz.png";
$theme_icons['icons']['report_management']="document-multiple.png";
$theme_icons['icons']['volunteer_management']="user-group-new.png";
$theme_icons['icons']['tour_management']="preferences-system-performance.png";
$theme_icons['icons']['tour_management']="tours.png";
$theme_icons['icons']['internal_document_management']="application-vnd.oasis.opendocument.text.png";
$theme_icons['icons']['registration_fee_items_management']="transfers_list.png";
$theme_icons['icons']['judging_score_entry']="transfers_list.png";

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

View File

@ -14,7 +14,7 @@ $tours_fields = array('name' => 'Tour Name',
class tours
{
/* Static members for the table editor */
function tableEditorSetup($editor)
static function tableEditorSetup($editor)
{
global $tours_fields;
global $config;
@ -66,7 +66,7 @@ class tours
/* Functions for $this */
function tours($tour_id = NULL)
function __construct($tour_id = NULL)
{
if ($tour_id == NULL) {
$this->id = FALSE;
@ -77,7 +77,7 @@ class tours
function tableEditorLoad()
{
global $config;
global $config, $pdo;
$id = $this->id;
@ -106,49 +106,64 @@ class tours
* if it's a number, then we want an UPDATE statement
*/
global $tours_fields;
global $config;
global $config, $pdo;
$query = '';
/* Construct an insert query if we have to */
if ($this->id == false) {
$query = "INSERT INTO tours (id) VALUES ('')";
// $query = "INSERT INTO tours (id, name, num, description, contact, location) VALUES ('', '', '', '', '', '')";
$query = 'INSERT INTO tours (year, name, num, description, capacity, grade_min, grade_max, contact, location) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
$stmt = $pdo->prepare($query);
$stmt->execute();
$stmt->execute([
str_replace("'", ' ', $data['year']),
str_replace("'", ' ', $data['name']),
str_replace("'", ' ', $data['num']),
str_replace("'", ' ', $data['description']),
str_replace("'", ' ', $data['capacity']),
str_replace("'", ' ', $data['grade_min']),
str_replace("'", ' ', $data['grade_max']),
str_replace("'", ' ', $data['contact']),
str_replace("'", ' ', $data['location'])
]);
$this->id = $pdo->lastInsertId();
} else {
/* Give it a proper year when saving */
/* Now just update the record */
$query = 'UPDATE `tours` SET ';
foreach ($tours_fields AS $f => $n) {
$n = $data[$f];
$query .= "`$f`=$n,";
}
// rip off the last comma
$query = substr($query, 0, -1);
$query .= ' WHERE id=?';
// echo $query;
$stmt = $pdo->prepare($query);
$stmt->execute([$this->id]);
}
/* Give it a proper year when saving */
/* Now just update the record */
$query = 'UPDATE `tours` SET ';
foreach ($tours_fields AS $f => $n) {
$n = $data[$f];
$query .= "`$f`=$n,";
}
// rip off the last comma
$query = substr($query, 0, -1);
$query .= " WHERE id=?";
// echo $query;
$stmt = $pdo->prepare($query);
$stmt->execute([$this->id]);
}
function tableEditorDelete()
{
global $config;
global $config, $pdo;
$id = $this->id;
$stmt = $pdo->prepare("DELETE FROM tours_choice WHERE tour_id=? AND year=?");
$stmt->execute([$id, $config['FAIRYEAR']]);
$stmt = $pdo->prepare("DELETE FROM tours WHERE id=? AND year=?");
$stmt->execute([$id, $config['FAIRYEAR']]);
echo happy(i18n("Successfully removed tour from this year's fair"));
try {
$stmt = $pdo->prepare('DELETE FROM tours_choice WHERE tour_id=? AND year=?');
$stmt->execute([$id, $config['FAIRYEAR']]);
$stmt = $pdo->prepare('DELETE FROM tours WHERE id=? AND year=?');
$stmt->execute([$id, $config['FAIRYEAR']]);
echo happy(i18n("Successfully removed tour from this year's fair"));
} catch (PDOException $exception) {
echo error(i18n("Failed to remove tour from this year's fair"));
error_log($exception);
}
}
};

View File

@ -26,7 +26,7 @@
* Boston, MA 02111-1307, USA.
*/
?>
<script type="text/javascript" src="<?= $config['SFIABDIRECTORY'] ?>/translationseditor.js.php"></script>
<script src="<?= $config['SFIABDIRECTORY'] ?>/translationseditor.js.php"></script>
<div style="display: none" title="<?= i18n('Translation Editor') ?>" id="translation_editor">
<form id="translationform" onsubmit="return save_translations()">
<input type="hidden" id="translate_str_hidden" name="translate_str_hidden">