<?php
session_start();
if(!isset ($_SESSION['user_id'])){
    header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('../Server/connection.php');
	include('includes/session.php');
?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <?php
	include 'title.php';
	?>
	
	<link type = "image/png" rel="icon" href="images/nembo.png" />

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
	 <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- bootstrap-datetimepicker -->
    <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
	
	<!-- bootstrap-datetimepicker -->
    <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
    
    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<style>
  .error {
    color: #F00;
}  
</style>
	
<script src="assests/jquery/jquery.min.js"></script>
<!--<script src="vendor/jquery/jquery.min.js"></script>-->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js"></script>

	
	
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
    <?php
	//include 'header.php';
	?>
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
            <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>

           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="viewReport.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content" style="overflow: auto;">
				  
				  <?php
			  $i = $_GET['i'];
   			$sql9 = "SELECT * FROM reports WHERE report_id='$i'";
	$result9 = $conn->query($sql9);
	while($edge9=mysqli_fetch_array($result9)){
	   $Type = $edge9['Type'];
	    $fileName = $edge9['path'];
	         }
			
			 ?>

                    
                    <form class="form-horizontal" id="id_frm" action="php_action/editFile.php" method="POST" enctype="multipart/form-data">
					
					<input type="hidden" name="report_id" value="<?php echo $i;?>" />
                      
					  
                      <span class="section">Edit File</span>
					  
					  <center>
					  <?php
  echo '<font color="red">';
  if(isset($_GET['msg'])){
	$msg = $_GET['msg'];
	?>
	
	<?php
	print $msg;
	}else{
	$msg = '';
    print $msg;	
	}
  echo '</font>';
	?>				  
					 </center>
					 
					 
					 
					 <div class="item form-group">
                        <label for="password" class="control-label col-md-3">View Uploaded &nbsp<?php echo  $Type;  ?> </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<?php
						if($Type=='file'){
						?>
						</br>
					<?php	
					
						echo '<div class="btn-group">
	    <a class="btn btn-primary" href="../files/'.$fileName.'"  id="editOrderModalBtn"> View/Download</a>
	</div>';
	?>
						
						<?php
						}else{
						?>
						
						<?php
			//display all uploaded video


$query=$conn->query("SELECT * FROM reports WHERE report_id='$i'");

	while($all_video=mysqli_fetch_array($query))

	{
?>
	 
	 <video width="300" height="200" controls>
	<source src="../files/<?php echo $all_video['path']; ?>" type="video/mp4">
	</video> 
	
	<?php }  ?>			
						
						
						<?php
                          }
						?>
                           
						  
                         	
                        </div>
                      </div>
					  
					  </br></br>
					  
					  <div class="item form-group">
					  <label for="password" class="control-label col-md-3">Upload Status</label>
					<div class="col-md-6 col-sm-6 col-xs-12">  
                         &nbsp&nbsp&nbsp&nbsp<label class="radio-inline">
          <input type="radio" name="upload_status" value="Upload File" id="upload_status"> Upload File ( i.e image,doc,excel,pdf )
         </label>&nbsp&nbsp&nbsp&nbsp
         <label class="radio-inline">
          <input type="radio" name="upload_status" value="Upload Video" id="upload_status"> Upload Video/Audio ( i.e mp4,mp3 )
         </label>

        

         <br/>
        <label for="upload_status" class="error" generated="true"></label>
		
			  <div id="textboxes3" style="display: none">		
		     <div class="item form-group">
			 <div class="col-md-6 col-sm-6 col-xs-12">
		      <label for="edit-name">Attach File ( i.e image,doc,excel,pdf ) </label>
		      <input type="file" name="file"  id="file"  class="form-control">
			  </br>
		     <label for="file" class="error" generated="true"></label>
			 </div>
			 
		    </div>
			</div>
			
			<div id="textboxes8" style="display: none">		
		     <div class="item form-group">
			 <div class="col-md-6 col-sm-6 col-xs-12">
		      <label for="edit-name">Attach Video/Audio ( i.e mp4,mp3) </label>
		      <input type="file" name="file"  id="video" class="form-control">
			  </br>
		     <label for="video" class="error" generated="true"></label>
			 </div>
		    </div>
			</div>
		
		
						</div>
						
						
						
                      </div>
					  
					  
				
					  
                      
					 
				
					  <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
						 <button class="btn btn-success"><span class="glyphicon glyphicon-registration-save"> </span> Send</button>
						 
                        </div>
                      </div>
                    </form>
					
					<script>
//$(function(){
$(document).ready(function(){
    $('input[name="upload_status"]').on('click', function(){
        if ($(this).val() == 'Upload File'){
			 $('#textboxes8').hide();
			 $('#textboxes3').show();
        }else if($(this).val() == 'Upload Video'){
			$('#textboxes3').hide();
			$('#textboxes8').show();
		}else{
			$('#textboxes3').hide();
			$('#textboxes8').hide();
		}
    });
});


 $("#id_frm").validate({
        rules: {
			
			"reportDesc": {
                required: true
            },
			
			"upload_status": {
                required: true
            },
			
            "file": {
                required: true,
                //minlength: 10,
                // minlength: 10 // same rule twice
            },
			
			"video": {
                required: true
            }
            
        },
        messages: {
			
			"reportDesc": {
                required: "Please Select Report Description."
            },
			
			"upload_status": {
                required: "Select whether you want to upload or not."
            },
			
            "file": {
                required: "Please attach file (pdf,image,doc,excel etc)."
            },
			
			"video": {
                required: "Please attach Video/Audio (mp4,mp3 etc)."
            }
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });


</script>
					
		
					
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	

    <!-- jQuery -->
    <!--<script src="../vendors/jquery/dist/jquery.min.js"></script>-->
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
	
    <!-- validator -->
    <!--<script src="../vendors/validator/validator.js"></script>-->
	
	<!-- bootstrap-daterangepicker -->
    <script src="../vendors/moment/min/moment.min.js"></script>
	
	<!-- bootstrap-datetimepicker -->    
    <script src="../vendors/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	
	
  </body>
</html>



<?php
}
?>