<?php
$page_title = "Course Registration";
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/common_functions.php"); //common functions in the course registartion system
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/config.php"); //holds global config variables
require_once($_SERVER['DOCUMENT_ROOT'] . "/phplist/config/config.php"); //phplist config values
check_if_authenticated('admin');//check if user is logged in
include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/top-admin.php"); //get the HTML heading common to all pages in the CES admin module
?>
<article class="ces-admin">
<h2>CES Admin - Register User for Session</h2>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/nav-admin.php"); //get the HTML nav common to all pages in the CES admin module
//open connection to database
$db = mysqli_connect($mysql_server, $user, $pass, $database);
$session_id = '';
if(isset($_GET['session_id']))
$session_id = $_GET['session_id'];
if(isset($_POST['session_id']))
$session_id = $_POST['session_id'];
$session_type = session_type($session_id);
//first make sure that the person is not already registered in the session
$check_id_sql = mysqli_query($db, "SELECT COUNT(*) FROM ces_course_registration WHERE session_id = '$_GET[session_id]' and id = '$_GET[id]'");
$already_registered = mysqli_fetch_row($check_id_sql);
if($already_registered[0] > 0){ //person is already registered in this session so output error and don't attempt to register them again
echo "<p class='alert alert-info'>You are already registered in this session.</p>";
}//if
elseif (!is_session_open($session_id) ) {
echo "<p class='alert alert-error'>Registration is currently closed for this session.</p>";
}elseif (is_session_cancelled($session_id) ) {
echo "<p class='alert alert-error'>Registration is currently closed for this session.</p>";
}
elseif (!$_POST['submit']){ //if form has not been submitted yet
echo "\n<form method='post' action=" . $_SERVER['PHP_SELF'] . ">";
echo "<input type=hidden name=session_id value=" . $_GET['session_id'] . ">"; //so we can keep track of the session_id
echo "<input type=hidden name=id value=" . $_GET['id'] . ">"; //so we can keep track of the person
echo "<input type=hidden name=location_id value=" . get_session_location_id($_GET['session_id']) . ">"; //so we can keep track of the location
echo "<input type=hidden name=user_type value=" . $_GET['user_type'] . ">"; //so we can keep track of if a user or admin is logged in
//get the course details
//there should be only one row returned as there is supposed to only be one main location (ces.locations.telehealth=false) per session
$session_sql = mysqli_query($db, "SELECT session.session_id, course.course_id, course.course_name, course.course_description, unix_timestamp(session.start_dt) start_dt, unix_timestamp(session.end_dt) end_dt, session.telehealth, location.location_id, location.location_name, location.address_line1, location.address_line2, location.city, location.province, location.postal_code, level.level_description
FROM ces_sessions session
LEFT OUTER JOIN ces_courses course ON session.course_id = course.course_id
LEFT OUTER JOIN ces_locations location ON location.location_id = '$_GET[location_id]'
LEFT OUTER JOIN ces_levels level ON level.level_id = course.level_id
WHERE session.session_id = '$_GET[session_id]'");
while ($session_query = mysqli_fetch_array($session_sql)){
$current_date_GMT = time(); //timezone is now set properly in no need to convert it
$start_date_GMT = convert_local_to_GMT($session_query['start_dt']); //convert session start date to GMT
if(($start_date_GMT > $current_date_GMT) && is_session_full($session_query['session_id'], $session_query['location_id'])){ //session is full, and registering person before the session's end date, so put person on waiting list if they still want to register
$on_waiting_list = 1;
$button_text = "Register on Waiting List";
}//if
else {
$on_waiting_list = 0;
$button_text = "Confirm Registration";
}//else
echo "<input id='ces-waitlist-input' type=hidden name=on_waiting_list value=" . $on_waiting_list . ">"; //so we can use the waiting list identifier when form is submitted
if(is_session_online($_GET['session_id'])){
echo '<p class="alert alert-info">The following online session is presented in the Windows Media Video (WMV) format. Internet Explorer and/or Windows Media Player is required to view this session.</p>';
}
?>
<dl class='ces-description-list'>
<dt>Course:</dt>
<dd><?php echo $session_query['course_name']; ?></dd>
<dt>Session Type:</dt>
<dd><?php echo ucfirst($session_type); ?></dd>
<dt>Date:</dt>
<?php
if (date('Ymd', $session_query['start_dt']) == date('Ymd', $session_query['end_dt'])){
//starts and ends on the same day
echo "<dd class='ces-registration-time'>". date('F j, Y g:i A', $session_query['start_dt']). " to " . date('g:i A', $session_query['end_dt']) . "</dd>";
}
else{
echo "<dd class='ces-registration-time'>". date('F j, Y g:i A', $session_query['start_dt']). " to " . date('F j, Y g:i A', $session_query['end_dt']) . "</dd>";
}
?>
<dt>Description:</dt>
<dd><?php echo ($session_query['course_description']?$session_query['course_description']: 'None'); ?></dd>
<dt>Level:</dt>
<dd><?php echo ($session_query['level_description']? $session_query['level_description']: 'None'); ?></dd>
<?php if($session_type != "webex" && $session_type != "online"){?>
<dt>Location:</dt>
<dd>
<?php
output_map_link($session_query['location_id']);
if (strlen($session_query['address_line1']) > 0)
echo "\n<br>" . $session_query['address_line1'];
if (strlen($session_query['address_line2']) > 0)
echo "\n<br>" . $session_query['address_line2'];
if (strlen($session_query['city']) > 0)
echo "\n<br>" . $session_query['city'];
if (strlen($session_query['province']) > 0)
echo ", " . $session_query['province'];
if (strlen($session_query['postal_code']) > 0)
echo "\n<br>" . substr($session_query['postal_code'], 0, 3). " " . substr($session_query['postal_code'], 3, 3);
?>
</dd>
<?php
}
//change options if telehealth is avalible
if ($session_type === "telehealth"){
?>
<div>
<dt>Attending:</dt>
<dd>
<?php echo ($on_waiting_list? '<p class="alert-info">This session is currently full. Select <em>In Person</em> when registering to be placed on the waiting list. Otherwise you can register for a <em>Video Conference</em> or an <em>Audioline</em> session.</p>': ''); ?>
<div class="radio">
<label><input id="ces-in-person" type="radio" name='attend' value="in_person" checked onclick="javascript:showGuests();">In Person</label>
</div>
<div class="radio">
<label><input id="ces-via-video" type="radio" name='attend' value="video" onclick="javascript:showGuests();">Via Video Conferencing</label>
<div class="alert alert-info" id="alert-tel" style="margin:0 40px 5px 20px;"><p><strong>Telehealth/Video Conferencing</strong> - A way to access a session using <em>specialized equipment</em>. If your facility, or other nearby site, has this equipment, please register for the session <em>then</em> email ces@ahs.ca requesting a connection to the session.</p><p>Telehealth/Video Conference sessions <strong>can not</strong> be viewed from a personal computer.</p><p>Telehealth/Video Conference connection requests are required no later than <strong>7 days</strong> before the start of the session.</p><a href='/sessions/instructions/telehealth.php' class='btn ces-blue-btn' title='Via Video'><span class='glyphicon glyphicon-facetime-video'></span> Instructions</a></div>
</div>
<div class="radio">
<label><input id="ces-via-audio" type="radio" name='attend' value="audio" onclick="javascript:showGuests();">Via Audioline</label>
<div class="alert alert-info" id="alert-audio" style="margin:0 40px 5px 20px;"><p><strong>Audioline</strong> - A way to access the session via <em>your telephone</em>. A session handout is typically provided which allows you to follow along.</p><a href='/sessions/instructions/audioline.php' class='btn ces-blue-btn' title='Via Audio'><span class='glyphicon glyphicon-phone-alt'></span> Instructions</a></div>
</div>
</dd>
</div>
<?php }//end if
if(is_session_online($session_query['session_id'])){
?>
<input type="hidden" name='attend' value="online">
<?php }//end if
if($session_type != "webex" && $session_type != "online"){
?>
<div>
<dt>Guests:</dt>
<dd>
<span class="help">Will this user bring any guests?</span>
<div class="radio"><label><input type="radio" name='guests' value="0" checked id="zero-guests" >0</label></div>
<div class="radio"><label><input type="radio" name='guests' value="1" id="one-guests">1</label></div>
<div class="radio"><label><input type="radio" name='guests' value="2" id="two-guests">2</label></div>
</dd>
</div>
<?php }//end if
else{
echo '<input type="hidden" name="guests" value="0">';
}
?>
</dl>
<div class="ces-register-page-btn">
<a href="search.php?session_id=<?php echo $session_query['session_id']?>"" class="btn btn-lg btn-block ces-cancel-btn">Cancel</a>
<input id="register-button" class="btn btn-lg btn-block" type='submit' name='submit' value="<?php echo $button_text; ?> ">
</div>
</form>
<?php
echo "\n</table>";
}//while
} //end elseif
else {
echo register_person_in_session($_POST['session_id'], $_POST['id'], $_POST['location_id'], $_POST['on_waiting_list'], '0', $_POST['attend'], $_POST['guests']);
echo "<a href='/admin/courses/#".get_course_id($_POST['session_id'])."' class='btn ces-blue-btn'>Show All Courses</a>";
echo "<a href='/admin/users/index.php?id=".$_POST['id']."' class='btn ces-orange-btn'>User Course List</a>";
}//else
?>
</article>
</section><!-- #middle-->
</div><!-- #wrapper -->
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/require/footer.php';?>
<script type="text/javascript">
document.getElementById('alert-tel').style.display = 'none';
document.getElementById('alert-audio').style.display = 'none';
function showGuests() {
if (document.getElementById('ces-in-person').checked) {
document.getElementById('zero-guests').disabled = false;
document.getElementById('one-guests').disabled = false;
document.getElementById('two-guests').disabled = false;
document.getElementById('alert-tel').style.display = 'none';
document.getElementById('alert-audio').style.display = 'none';
if(document.getElementById('ces-waitlist-input').value == 1){
document.getElementById('register-button').value = "Register on Waiting List";
}else{
document.getElementById('register-button').value = "Confirm Registration";
}
} else {
document.getElementById('zero-guests').disabled = true;
document.getElementById('one-guests').disabled = true;
document.getElementById('two-guests').disabled = true;
document.getElementById("zero-guests").checked = true;
if(document.getElementById('ces-via-video').checked){
document.getElementById('register-button').value = "Register for Video Session";
document.getElementById('alert-tel').style.display = 'block';
document.getElementById('alert-audio').style.display = 'none';
}else if(document.getElementById('ces-via-audio').checked){
document.getElementById('register-button').value = "Register for Audio Session";
document.getElementById('alert-audio').style.display = 'block';
document.getElementById('alert-tel').style.display = 'none';
}
}
}
</script>