forked from science-ation/science-ation
900dab702d
- Admin can use the tour manager to add tours - Admin can use the config variables to enable tours, and select the min/max number of tour choices. - Students will see a "Tour Selection" section of registration, which is incomplete until the student has selected at least a minimum number of tours.... actually, this may be broken.. Need to look at it further..
144 lines
3.3 KiB
PHP
144 lines
3.3 KiB
PHP
<?
|
|
|
|
/* Just the fields in the tours table, we use this twice */
|
|
$tours_fields = array( 'name' => 'Tour Name',
|
|
'description' => 'Description',
|
|
'capacity' => 'Capacity',
|
|
'grade_min' => 'Minimum Grade',
|
|
'grade_max' => 'Maximum Grade',
|
|
'year' => 'Year');
|
|
|
|
class tours {
|
|
|
|
/* Static members for the table editor */
|
|
function tableEditorSetup($editor)
|
|
{
|
|
global $tours_fields;
|
|
global $config;
|
|
|
|
/* Setup the table editor with the fields we want to display
|
|
* when displaying a list of tours, and also the type of each
|
|
* field where required */
|
|
$l = array( 'id' => 'ID',
|
|
'name' => 'Tour Name',
|
|
'capacity' => 'Capacity',
|
|
'grade_min' => 'Minimum Grade',
|
|
'grade_max' => 'Maximum Grade',
|
|
'year' => 'Year',
|
|
);
|
|
|
|
/* Most of these should be moved to the base class, as they
|
|
* will be the same for all person groups */
|
|
|
|
$editor->setTable('tours');
|
|
$editor->setRecordType('Tour');
|
|
$editor->setListFields($l);
|
|
$editor->setEditFields($tours_fields);
|
|
|
|
$editor->setFieldOptions('year', array(
|
|
array('key' => 'NULL', 'val' => 'Inactive'),
|
|
array('key' => $config['FAIRYEAR'], 'val' => $config['FAIRYEAR'])));
|
|
|
|
// print_r($e);
|
|
print("<br>\n");
|
|
/* Build an array of langauges that we support */
|
|
|
|
$gradechoices=array(
|
|
array('key' => 7, 'val' => "Grade 7"),
|
|
array('key' => 8, 'val' => "Grade 8"),
|
|
array('key' => 9, 'val' => "Grade 9"),
|
|
array('key' => 10, 'val' => "Grade 10"),
|
|
array('key' => 11, 'val' => "Grade 11"),
|
|
array('key' => 12, 'val' => "Grade 12") );
|
|
|
|
$editor->setFieldOptions("grade_min", $gradechoices);
|
|
$editor->setFieldInputType("grade_min", 'select');
|
|
$editor->setFieldOptions("grade_max", $gradechoices);
|
|
$editor->setFieldInputType("grade_max", 'select');
|
|
}
|
|
|
|
/* Functions for $this */
|
|
|
|
|
|
function tours($tour_id=NULL)
|
|
{
|
|
if($tour_id == NULL) {
|
|
$this->id = FALSE;
|
|
} else {
|
|
$this->id = $tour_id;
|
|
}
|
|
}
|
|
|
|
function tableEditorLoad()
|
|
{
|
|
global $config;
|
|
|
|
$id = $this->id;
|
|
|
|
// print("Loading Judge ID $id\n");
|
|
|
|
$q=mysql_query("SELECT tours.*
|
|
FROM tours
|
|
WHERE tours.id='$id'");
|
|
echo mysql_error();
|
|
|
|
|
|
/* We assume that the field names in the array we want to return
|
|
* are the same as those in the database, so we'll turn the entire
|
|
* query into a single associative array */
|
|
$j = mysql_fetch_assoc($q);
|
|
|
|
return $j;
|
|
}
|
|
|
|
function tableEditorSave($data)
|
|
{
|
|
/* If $this->id == false, then we need to INSERT a new record.
|
|
* if it's a number, then we want an UPDATE statement */
|
|
global $tours_fields;
|
|
global $config;
|
|
|
|
$query = "";
|
|
|
|
/* Construct an insert query if we have to */
|
|
if($this->id == false) {
|
|
$query = "INSERT INTO tours (id) VALUES ('')";
|
|
mysql_query($query);
|
|
$this->id = mysql_insert_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='{$this->id}'";
|
|
|
|
// echo $query;
|
|
mysql_query($query);
|
|
|
|
}
|
|
|
|
function tableEditorDelete()
|
|
{
|
|
global $config;
|
|
|
|
$id = $this->id;
|
|
|
|
mysql_query("DELETE FROM tours_choice WHERE tour_id='$id' AND year=".$config['FAIRYEAR']."'");
|
|
mysql_query("DELETE FROM tours WHERE id='$id' AND year='".$config['FAIRYEAR']."'");
|
|
|
|
echo happy(i18n("Successfully removed tour from this year's fair"));
|
|
}
|
|
|
|
};
|
|
|
|
?>
|