<?php
session_start();
require_once("public/connection.php");
require_once("public/functions.php");

// Get administrative data
$query = "SELECT * FROM `administratives`";
$run_query = mysqli_query($connection, $query);

if (mysqli_num_rows($run_query) == 1) {
    $result = mysqli_fetch_assoc($run_query);
    $school_logo = $result['school_logo'];
    $school_name = $result['school_name'];
    $school_address = $result['school_motto'];
    $school_stamp = $result['school_stamp'];
}
?>
<?php
if (!isset($_GET['appnumber'])) {
    die("Invalid request");
}

$appnumber = mysqli_real_escape_string($connection, $_GET['appnumber']);
$query = "SELECT * FROM applications WHERE application_number = '$appnumber' LIMIT 1";
$result = mysqli_query($connection, $query);

if (mysqli_num_rows($result) == 0) {
    die("Application not found");
}

$student_data = mysqli_fetch_assoc($result);
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <!-- CSS-->
    <link rel='stylesheet' type='text/css' href='assets/css/main.css'>
    <link rel='stylesheet' type='text/css' href='assets/css/defined.css'>
    <link href="assets/SweetAlerts/sweetalert.css" rel="stylesheet">
	<link id="favicon" rel="icon" type="image/png" sizes="8x8" href="images/145.png">
    <!-- Font-icon css-->
    <link rel="stylesheet" href="assets/css/font-awesome-4.7.0/css/font-awesome.css">
    <title><?php echo $appnumber; ?> ~ ADAMSPRING </title>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries-->
    <!--if lt IE 9
    script(src='https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js')
    script(src='https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js')
    -->
    <script src="../../assets/js/jquery-2.1.4.min.js"></script>
	
    <script type="text/javascript">
      $(function () {
        // add multiple select / deselect functionality
        $("#selectall").click(function () {
            $('.subgroup').attr('checked', this.checked);
        }); 
        // if all checkbox are selected, then check the select all checkbox
        // and viceversa
        $(".subgroup").click(function () {
            if ($(".subgroup").length == $(".subgroup:checked").length) {
              $("#selectall").attr("checked", "checked");
            } else {
              $("#selectall").removeAttr("checked");
            }
        });
    });
    </script>
    <script type="text/javascript">
        window.onload = initClock;

        function initClock() {
          var now = new Date();
          var hr  = now.getHours();
          var min = now.getMinutes();
          var sec = now.getSeconds();
          if (min < 10) min = "0" + min;  // insert a leading zero
          if (sec < 10) sec = "0" + sec;
          document.getElementById('clockDisplay').innerHTML
                = hr + ":" + min + ":" + sec;
          setTimeout('initClock()', 500);
        }
    </script>
    <style type="text/css">
      .print_div {
        /*width: 21cm;
        min-height: 29.7cm;
        padding: 2cm;
        margin: 1cm auto;
        border: 1px #D3D3D3 solid;
        border-radius: 5px;
        background: white;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);*/
      }
      @page {
        size: A4;
        margin: 0;
      }

      @media print {
        .print_div {
          margin: 0;
          margin-top: -20%;
          padding-right: 4%;
          padding-left: 4%;
          border: 0;
          font-size: 12px;
          border-radius: 5px;
          /*width: 21cm;*/
          /*min-height: 29.7cm;*/
          box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
          background: white;
          page-break-after: always;
        }
    </style>
  </head>
  <body class='sidebar-mini fixed'>
    <div class='panel panel-primary'>
        <div class='panel-body'>
            <div class='row'>
                <div class='col-xs-2 col-sm-2 col-md-2 text-center'>
                    <img class='img-rounded img-responsive' src='<?php echo !empty($school_logo) ? $school_logo : "145.png"; ?>' alt='School Logo'/>
                </div>

                <div class='col-xs-8 col-sm-8 col-md-8 text-center'>
                    <h3><?php echo htmlspecialchars($school_name); ?></h3>
                    <p class='text-danger'>
                        <?php echo htmlspecialchars($school_address); ?><br/>
                    </p>
                </div>
               <div class='col-xs-2 col-sm-2 col-md-2 text-center text-responsive'> 
    <img src='<?php echo $student_data['passport']; ?>' 
         class='img-rounded img-responsive' 
         alt='Student Passport' 
         style='width: 120px; height: 120px;' />
</div>


            </div>
	<div style="text-align: center;">
    <h2>APPLICATION FORM</h2>
    <p>Application No: <strong><?php echo htmlspecialchars($student_data['application_number']); ?></strong></p>
	<p>Application Status: <strong><?php echo htmlspecialchars($student_data['status']); ?></strong></p>
</div>

<div class='row'>
    <div class='col-xs-4 col-md-4'>
        <legend>Bio-Data</legend>
        
        <p>Surname: <?php echo htmlspecialchars($student_data['fname']); ?></p>
        <p>Middle Name: <?php echo htmlspecialchars($student_data['mname']); ?></p>
        <p>Other Name: <?php echo htmlspecialchars($student_data['oname']); ?></p>
        <p>Gender: <?php echo htmlspecialchars($student_data['gender']); ?></p>
        <p>State: <?php echo htmlspecialchars($student_data['state']); ?></p>
        <p>Nationality: <?php echo htmlspecialchars($student_data['nationality']); ?></p>
    </div>
    <div class='col-xs-4 col-md-4'>
        <legend>Birthday</legend>
        <p>Date of Birth: <?php echo htmlspecialchars($student_data['dob']); ?></p>
    </div>
    <div class='col-xs-4 col-md-4'>
        <legend>Contact</legend>
        <p>Father's Name: <?php echo htmlspecialchars($student_data['ftitle'] . ' ' . $student_data['fsname'] . ' ' . $student_data['foname']); ?></p>
        <p>Father's Address: <?php echo htmlspecialchars($student_data['faddress']); ?></p>
        <p>Father's Occupation: <?php echo htmlspecialchars($student_data['foccupation']); ?></p>
        <p>Father's Phone: <?php echo htmlspecialchars($student_data['fpnumber']); ?></p>
        <p>Father's Alternate Phone: <?php echo htmlspecialchars($student_data['fapnumber']); ?></p>
        <p>Mother's Name: <?php echo htmlspecialchars($student_data['mtitle'] . ' ' . $student_data['msname'] . ' ' . $student_data['moname']); ?></p>
        <p>Mother's Address: <?php echo htmlspecialchars($student_data['maddress']); ?></p>
        <p>Mother's Occupation: <?php echo htmlspecialchars($student_data['moccupation']); ?></p>
        <p>Mother's Phone: <?php echo htmlspecialchars($student_data['mpnumber']); ?></p>
        <p>Mother's Alternate Phone: <?php echo htmlspecialchars($student_data['mapnumber']); ?></p>
    </div>
</div>
<br />

<div class='row'>
    <div class='col-xs-4 col-md-4'>
        <legend>Academics</legend>
        <p>Last School Attended: <?php echo htmlspecialchars($student_data['lschool']); ?></p>
        <p>Last Class: <?php echo htmlspecialchars($student_data['lclass']); ?></p>
        <p>Application Class: <?php echo htmlspecialchars($student_data['class']); ?></p>
    </div>
    <div class='col-xs-4 col-md-4'>
        <legend>Additional Info</legend>
        <p>Languages Spoken: <?php echo htmlspecialchars($student_data['language']); ?></p>
        <p>Health Challenges: <?php echo htmlspecialchars($student_data['challenge']); ?></p>
        <p>How You Heard About Us: <?php echo htmlspecialchars($student_data['hear']); ?></p>
    </div>
</div>

            <br/>
            <hr/>

            <div class='row'>
                <div class='col-xs-12 col-md-12 text-center'>
                    <em>
                        <strong>NOTE:</strong> Print this slip and keep it safe, you will require this for effective service of your application. 
                        We are always ready to assist in any way we can. 
                        <br/>                    
                        <button type='button' class='btn btn-primary noprint' onclick='window.print()' value='print a div!'>
                            <i class='fa fa-print'></i> Print
                        </button>
                        <a class='noprint btn btn-danger' href='index.php'>
                            <i class='fa fa-remove'></i> Close Slip
                        </a> 
                    </em>
                </div>
            </div>
        </div>
    </div>
<script src="assets/js/jquery-2.1.4.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/plugins/pace.min.js"></script>
    <script src="assets/js/main.js"></script>
    <script type="text/javascript" src="assets/js/plugins/moment.min.js"></script>
    <script type="text/javascript" src="assets/js/plugins/jquery-ui.custom.min.js"></script>
    <script type="text/javascript" src="assets/js/plugins/fullcalendar.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
      
      	$('#external-events .fc-event').each(function() {
      
      		// store data so the calendar knows to render an event upon drop
      		$(this).data('event', {
      			title: $.trim($(this).text()), // use the element's text as the event title
      			stick: true // maintain when user navigates (see docs on the renderEvent method)
      		});
      
      		// make the event draggable using jQuery UI
      		$(this).draggable({
      			zIndex: 999,
      			revert: true,      // will cause the event to go back to its
      			revertDuration: 0  //  original position after the drag
      		});
      
      	});
      
      	$('#calendar').fullCalendar({
      		header: {
      			left: 'prev,next today',
      			center: 'title',
      			right: 'month,agendaWeek,agendaDay'
      		},
      		editable: true,
      		droppable: true, // this allows things to be dropped onto the calendar
      		drop: function() {
      			// is the "remove after drop" checkbox checked?
      			if ($('#drop-remove').is(':checked')) {
      				// if so, remove the element from the "Draggable Events" list
      				$(this).remove();
      			}
      		}
      	});
      
      
      });
    </script>
    <script src="assets/SweetAlerts/sweetalert.js"></script>
</script>
<!-- SweetAlert2 JS -->
<?php
require_once("public/alert.php");
?>
  </body>
</html>
