Newer
Older
require 'frameworks/environment.php';
require 'view/signups/index.php';
// =====================================================================================================================
// HEADERS
function echo_headers() {
echo index_get_css_includes();
echo index_get_js_includes();
echo index_get_additional_headers();
}
$additional_styles = index_get_dependencies_helper('getCSSDependencies');
$styles = array_merge($base_styles, $additional_styles);
$ret = '';
foreach ($styles as $style) {
$ret .= "<link rel=\"stylesheet\" href=\"" . $basefolder . $style . "\" />\n";
}
return $ret;
$base_js = [
'js/jquery-1.11.1.min.js',
'js/jquery-ui.min.js',
'js/angular.min.js',
'js/api.js'
];
$additional_js = index_get_dependencies_helper('getJSDependencies');
$scripts = array_merge($base_js, $additional_js);
$ret = '';
$currPathLength = strlen(realpath(".")) + 1;
$uniq = array();
$script = substr(realpath($basefolder . $script), $currPathLength);
if (isset($uniq[$script])) continue;
$uniq[$script] = true;
$ret .= "<script type=\"text/javascript\" src=\"" . $script . "\"></script>\n";
}
return $ret;
}
function index_get_dependencies_helper($dependency_function_name) {
$methods_basefolder = 'signups/';
$signup_method = SignupMethods::getInstance();
if ($signup_method->signupMethodExists()) {
return array_map(function ($d) use ($methods_basefolder, $method_folder) {
return $methods_basefolder . $method_folder . '/' . $d;
}, $signup_method->getActiveMethod()->$dependency_function_name());
}
return [];
function index_get_additional_headers() {
$signup_method = SignupMethods::getInstance();
if ($signup_method->signupMethodExists()) {
return $signup_method->getActiveMethod()->getAdditionalHeader();
}

Tim Repke
committed
}
// =====================================================================================================================
// CONTENT
function show_content() {
$environment = Environment::getEnv();
if (!$environment->isSelectedTripIdValid()) {
try {
$opentime = $environment->database->select('fahrten', ['opentime'], ['fahrt_id' => $fid])[0]['opentime'];
} catch (Exception $ex) {
$opentime = 0;
}
// --- Fahrtinfos
index_show_fahrtHeader($fid);
index_show_fahrtHeader_js($fid);
if ($opentime < time()) {
// --- Anmeldebox
index_show_signup();
// --- Liste der Anmeldungen
index_show_signupTable($fid);
} else index_show_countdown($opentime);
// ---------------------------------------------------------------------------------------------------------------------
// SIGNUP AREA
function index_show_signup() {
$fid = $environment->getSelectedTripId();
$openstatus = $environment->getRegistrationState($fid);
$waitlist_confirmed = $environment->isInWaitlistMode();
echo '<div id="signup-container">';
echo '<h2>Anmeldung</h2>';
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Anmeldung war erfolgreich.</div>';
} // Anmeldung fehlgeschlagen, weil voll oder duplikat
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Anmeldung leider fehlgeschlagen.</div>';
echo '<div style="text-align:center; font-size: 16pt; font-weight: bold">Die Anmeldegrenze wurde leider erreicht oder du bist bereits angemeldet.</div>';
echo '<div style="text-align:center; font-size: 14pt; ">Es besteht die Möglichkeit sich auf der Warteliste einzutragen.<br />
Wenn du das möchtest, klicke hier: <a class="normallink" href="?fid=' . $fid . '&waitlist">⇶ Warteliste</a></div>';
} // Formulardaten empfangen -> auswerten!
elseif ($environment->formDataReceived()) {
$sub = $signup_method->validateSubmission();
if ($sub['valid']) {
if ($environment->sendBachelorToDB($sub['data']))
header("Location: ?fid=" . $fid . "&success");
header("Location: ?fid=" . $fid . "&full");
if (!isset($_REQUEST['hideErrors'])) index_show_errors($sub['errors']);
$environment->setDanglingFormData($sub['data']);
$signup_method->getFallbackMethod()->showInlineHTML();
($openstatus == 0 || ($waitlist_confirmed && $openstatus < 2))
) {
$signup_method->getActiveMethod()->showInlineHTML();
// future feature: option to show edit view (when $_GET['bid'] isset)
if ($openstatus > 0 && !$waitlist_confirmed) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Anmeldung wurde geschlossen.</div>';
if ($openstatus != 2) {
echo '
<div style="text-align:center; font-size: 16pt; font-weight: bold">
Ein Auge offen halten, ob Plätze frei werden.
</div><div style="text-align:center; font-size: 14pt;">
Es gibt aber auch eine Warteliste.<br />
Wenn du da rauf möchtest, klicke hier:
<a class="normallink" href="?fid=' . $fid . '&waitlist">⇶ Warteliste</a>
</div>';
} elseif ($openstatus < 2) {
$methods = $signup_method->getSignupMethodsBaseInfo();
$link = '?fid=' . $fid . ($waitlist_confirmed ? '&waitlist' : '') . '&method=';
echo '<p>Es stehen verschiedene Methoden zur Anmeldung offen. Wähle eine davon:';
echo '<ul id="method-list">';
foreach ($methods as $method) {
echo '<li><a href="' . $link . $method['id'] . '#signup-container">' . $method["name"] . '</a> <br />' . $method['description'] . '</li>';

Tim Repke
committed
}
/**
* puts out a list of all errors
* @param $errors
*/
echo '<div class="message error"><ul>';
foreach ($errors as $e) {
echo '<li>' . $e . '</li>';
// ---------------------------------------------------------------------------------------------------------------------
// TRIP LISTING
function index_show_alleFahrten() {
$environment = Environment::getEnv();
comm_verbose(2, "Liste aller Fahrten (Jahr, Ziel, Zeitraum, Anz. Mitfahrer)");
$foos = $environment->database->select("fahrten",
['fahrt_id', 'titel', 'ziel', 'von', 'bis', 'beschreibung', 'leiter', 'kontakt', 'max_bachelor'],
echo 'Keine Fahrten im System gefunden';
return;
}

Tim Repke
committed
$fids = [];

Tim Repke
committed
array_push($fids, $foo['fahrt_id']);

Tim Repke
committed
index_show_fahrtHeader_js($fids);
}
/**
* @param $fahrt wenn array, dann Datenbankrow; wenn zahl, dann wird das selektiert
*/
function index_show_fahrtHeader($fahrt) {

Tim Repke
committed

Tim Repke
committed
// select fahrt by ID
$fahrt = $environment->database->select('fahrten',
['fahrt_id', 'titel', 'ziel', 'von', 'bis', 'leiter', 'kontakt', 'beschreibung', 'max_bachelor'],
['fahrt_id' => $fahrt]);
if (!$fahrt)
return; // break here and show nothing!
else
$fahrt = $fahrt[0];

Tim Repke
committed
}
$cnt = $environment->database->count("bachelor", ["AND" =>

Tim Repke
committed
["backstepped" => NULL,

Tim Repke
committed
echo '<div class="fahrt">
<a class="fahrthead" href="index.php?fid=' . $fahrt['fahrt_id'] . '">' . $fahrt['titel'] . '</a>';
echo 'Ziel: <i>' . $fahrt['ziel'] . '</i><br />';
echo 'Datum: <i>' . comm_from_mysqlDate($fahrt['von']) . " - " . comm_from_mysqlDate($fahrt['bis']) . '</i><br />';
echo "Ansprechpartner: <i>" . $fahrt['leiter'] . " (" . comm_convert_mail($fahrt['kontakt']) . ")</i><br />";
echo "Anmeldungen: <i>" . $cnt . " / " . $fahrt['max_bachelor'] . "</i>";
echo '<p>' . $fahrt['beschreibung'] . '</p></div>
<div class="map-canvas" id="map-canvas-' . $fahrt['fahrt_id'] . '"></div>

Tim Repke
committed
</div>';
}
function index_show_fahrtHeader_js($fahrten) {
$environment = Environment::getEnv();
$pins = $environment->database->select("fahrten", ["fahrt_id", "map_pin"], ["fahrt_id" => $fahrten]);

Tim Repke
committed
echo '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script type="text/javascript">
window.onload = function() {
$("div.fahrt-left i").click(function(){
});
$("div.fahrt-left i").hover(
function(){
$(this).html($(this).html().replace(/·/g, "🐭"));
$(this).html($(this).html().replace("Ø", "🐵"));
},
function(){
$(this).html($(this).html().replace(/🐭/g, "·"));
$(this).html($(this).html().replace("🐵", "Ø"));
}
);

Tim Repke
committed
if (!preg_match("/\\d+\\.\\d+ \\d+\\.\\d+/m", $p["map_pin"]))
$p["map_pin"] = '71.555267 99.690962';
echo '
var ziel_' . $p['fahrt_id'] . ' = new google.maps.LatLng(' . str_replace(" ", ", ", $p["map_pin"]) . ');
var marker_' . $p['fahrt_id'] . ';
var map_' . $p['fahrt_id'] . ';

Tim Repke
committed
';

Tim Repke
committed
}

Tim Repke
committed
function initialize() {

Tim Repke
committed
';
foreach ($pins as $p) {
echo '
var mapOptions_' . $p['fahrt_id'] . ' = {

Tim Repke
committed
zoom: 8,

Tim Repke
committed
panControl: false,
zoomControl: false,
scaleControl: true,
mapTypeControl: false,
streetViewControl: false,
overviewMapControl: false
};
map_' . $p['fahrt_id'] . ' = new google.maps.Map(document.getElementById(\'map-canvas-' . $p['fahrt_id'] . '\'), mapOptions_' . $p['fahrt_id'] . ');

Tim Repke
committed
marker_' . $p['fahrt_id'] . ' = new google.maps.Marker({
map:map_' . $p['fahrt_id'] . ',

Tim Repke
committed
draggable:true,
animation: google.maps.Animation.DROP,

Tim Repke
committed
});
marker_' . $p['fahrt_id'] . '.setAnimation(google.maps.Animation.BOUNCE);';

Tim Repke
committed
}

Tim Repke
committed
}
google.maps.event.addDomListener(window, \'load\', initialize);
</script>';
// ---------------------------------------------------------------------------------------------------------------------
// PUBLIC REGISTRATIONS LISTING
function index_show_signupTable($fid) {
$environment = Environment::getEnv();
$data = $environment->database->select('bachelor',
["pseudo", "antyp", "abtyp", "anday", "abday", "comment", "studityp"],
'public' => 1,
'backstepped' => NULL
if (!$data) echo '<div class="signups">Noch keine (sichtbaren) Anmeldungen!</div>';
else {
echo '
<table class="signups">
<thead>
<tr>
<!--td>' . $d["studityp"] . '</td-->
<td>' . $d["pseudo"] . '</td>
<td>' . comm_from_mysqlDate($d["anday"]) . '</td>
<td>' . index_show_signupTable_destroyTypes($d["antyp"]) . '</td>
<td>' . comm_from_mysqlDate($d["abday"]) . '</td>
<td>' . index_show_signupTable_destroyTypes($d["abtyp"]) . '</td>
<td>' . $d["comment"] . '</td>
function index_show_signupTable_destroyTypes($anabtyp) {
global $config_reisearten, $config_reisearten_destroyed;
if (array_search($anabtyp, $config_reisearten) >= 2)
return $config_reisearten_destroyed[array_rand($config_reisearten_destroyed)];
return $anabtyp;
function index_make_hurrdurr() {
echo "<script>
$(function () {
var hurdur = new HurDur();
new Elevator({
mainAudio: 'view/audio/audio.ogg',
endAudio: 'view/audio/end-audio.ogg',
duration: 5000,
startCallback: hurdur.start,
endCallback: hurdur.stop
});});</script>";
}
function index_show_countdown($opentime) {
echo '<script type="text/javascript" src="view/js/jquery.qrcode.js"></script>';
if(url.indexOf('#showQR')>0) $('#QRcode').qrcode({
render: 'canvas',
ecLevel: 'Q',
size: 150,
fill: '#000',
background: null,
text: url.replace('#showQR',''),
radius: 0.5,
quiet:2,
mode: 2,
label: 'FS Fahrt',
fontname: 'sans',
fontcolor: '#ff9818'
});
var hurdur = new HurDur({
cats: 10,
loopcb: function() {
$('#text, body').stop().animate({color:b?'#ffffff':'#000000'}, 1000);
var now = (Date.now() + ((new Date()).getTimezoneOffset()*60))/1000;
var diff = opentime - now;
var view = '';
if (diff <= 0) {
view = '00:00:00.00';
} else {
view = hurrdurrr(parseInt(diff/60/60/24, 10)) + 'd ' + hurrdurrr(parseInt(diff / 60 / 60 % 24, 10))
+ 'h:' + hurrdurrr(parseInt(diff / 60 % 60, 10)) + 'm.' + hurrdurrr(parseInt(diff%60, 10)) + 's';
}
$('#countdown').html(view);
function hurrdurrr(num) {
return ((num < 10) ? '0' : '') + num;
}
b = !b;
}});
hurdur.start();
});
</script>";
echo '<div id="text" style="font-weight:bold;text-align:center;font-size:40pt;font-family:Verdana, Geneva, sans-serif">
<div style="margin:0 auto; width:300px">
<iframe width="300" height="300" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/109529816&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>
echo '<canvas id="QRcode" style="position: fixed; bottom: 10px; right: -240px;width:500px;height:250px;"></canvas>';