<!--- 

Developer: Coralys Cubero Rivera
Fall 2018

This script allows the user to see the specific information of a questionnaire associated to an experience.
 
 
 
 Updated by: Víctor A. Hernández
 Summer 2019
 
--->

<?php

	require_once 'processes/config.php';
	require_once 'processes/dbh.inc.php';
 
	if(isset($_GET['view'])) {
		$query = "SELECT * FROM `questionnair` WHERE `id`='".$_GET['view']."';";
		$result = mysqli_query($connection, $query);
		if(!$result) die("Error: ".mysqli_error($connection));
		$row = mysqli_fetch_array($result);
	}

	include_once 'header.php';
?>

		<div class='container'>
			<br>
			<h2>QUESTIONNAIRE <?php echo $row[0]; ?></h2>
			<br>
			<p> <font size='4'> <b> Title: </b> <?php echo $row[1]; ?> </font> </p>
			<p> <font size='4'> <b> Description: </b> <?php echo $row[2]; ?> </font>
				<a class='btn btn-info' style='float: right;' href='editQuestionnaire.php?edit=<?php echo $row[0]; ?>'> Edit Questionnaire </a>
			</p>
			<table class='table table-hover' id='tableEvaluations'>
			<?php
				$result = mysqli_query($connection, "SELECT `id`, `premise` FROM `question` WHERE `id` IN (SELECT `id_question` FROM `questionnair_question` WHERE `id_questionnair`='".$row[0]."');");
				echo "
				<thead>
					<tr>
						<th> ID </th>
						<th> Questions </th>
					</tr>
				</thead>
				<tbody>";
				while($row = mysqli_fetch_array($result)) {
					echo " <tr>";
					echo "<td> <p> ".$row['id']."</p> </td>";
					echo "<td> <p> ".$row['premise']." </p> </td>";
					echo "</tr>";
				}		
				echo "</tbody>"
			?>
			</table>
			<br><br>
		</div>

<?php include_once 'footer.html'; ?>

<?php
/*
		<!-- POPUP FOR EDIT EXPERIENCE -->
		<form class='form-horizontal' action='processes/updateExperience.php' method='POST'>
			<div class='modal fade' id='Edit_<?php echo $row['id']; ?>' tabindex='-1' role='dialog' aria-labelledby='EditLabel_<?php echo $row['id']; ?>' aria-hidden='true'>
				<div class='modal-dialog' role='document'>
 					<div class='modal-content'>
						<div class='modal-header'>
					   		<h3 class='modal-title' id='EditLabel_<?php echo $row['id']; ?>'>Experience Basic Info</h3>
      					</div>
      					<div class='modal-body'>
      						
      						
      						
      						<!-- ID -->
							<input type='hidden' name='id' value='<?php echo $row['id']; ?>'>
							
							<!-- NEW TITLE -->
							<div class='form-group form-horizontal'>
								<label class='col-sm-offset-1 col-sm-2 control-label'>Title:</label>
								<div class='col-sm-8'>
       								<input class='form-control' type='text' name='newTitle' value='<?php echo $row['title']; ?>'>
								</div>
							</div>
       										
       						<!-- NEW DESCRIPTION -->
							<div class='form-group form-horizontal'>
								<label class='col-sm-offset-1 col-sm-2 control-label'>Description:</label>
								<div class='col-sm-8'>
	   								<input class='form-control' type='text' name='newDescription' value='<?php echo $row['description']; ?>'>
								</div>
							</div>
												
							<!-- NEW TYPE -->
							<div class='form-group form-horizontal'>
    							<label class='col-sm-offset-1 col-sm-2 control-label'>Type:</label>
								<div class='col-sm-8'>
   	 								<input class='form-control' type='text' name='newType' value='<?php echo $row['type']; ?>'>
								</div>
   	    					</div>
       											
       						<!-- NEW DURATION -->
							<div class='form-group form-horizontal'>
   	    						<label class='col-sm-offset-1 col-sm-2 control-label'>Duration:</label>
   	    						<div class='col-sm-8'>
   	 								<input class='form-control' type='text' name='newDuration' value='<?php echo $row['duration_weeks']; ?>'>
   								</div>
   	    					</div>
       											
       						<!-- NEW START -->

							<div class='form-group form-horizontal'>
								<label class='col-sm-offset-1 col-sm-2 control-label'>Start Date:</label>
								<div class='col-sm-8'>
									<input class='form-control' type='text' name='newStart' value='<?php echo $row['start_date']; ?>'>
								</div>
							</div>

												
							<!-- NEW END -->
							<div class='form-group form-horizontal'>
								<label class='col-sm-offset-1 col-sm-2 control-label'>End Date:</label>
								<div class='col-sm-8'>
   	 								<input class='form-control' type='text' name='newEnd' value='<?php echo $row['end_date']; ?>'>
								</div>
   	    					</div>
   	    							
   	    							

      					</div><!--modal-body-->
      					
      					<!-- SUBMIT OR CANCEL -->
     					<div class='modal-footer'>
       						<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
        					<button type='submit' class='btn btn-primary' name='updateExperience'>Save Changes</button>
      					</div><!--modal-footer-->
      					
    				</div><!--modal-content-->
  				</div><!--modal-dialog-->
			</div><!--modal-->
		</form>
*/
?>