<?php 
	require_once('../Connections/conn_ama.php');

	if(!isset($_SESSION)){
        session_start();
	} 
	$colname = -1;
	//define('MAX_FILE_SIZE',10121200);
	if(isset($_POST['uid'])){
        $colname = $_POST['uid'];
        $deptname = $_POST['d'];
    }
    
    echo $colname;
    echo $deptname;

    //Retrieve Unit details
    $query_rsUnit = "SELECT * FROM v_subdept  WHERE subsubdeptID = ".$colname;
    $rsUnit = mysqli_query($conn_ama, $query_rsUnit ) or die(mysqli_error($conn_ama));
    $row_rsUnit = mysqli_fetch_assoc($rsUnit);
    $totalRows_rsUnit = mysqli_num_rows($rsUnit);

 ?>

<!-- <div class="col-md-9 data-area"> -->
	<div class="data-area-wrap">
       
		<div class="form-wrapper"> 
			<h3><?php echo $deptname; ?> >> <?php echo $row_rsUnit['subunitname']; ?></h3>
			<form id="update-new-unit">
			  	<fieldset>
			  		<legend>Edit Unit</legend>
			  		<div class="form-group">
					    <label for="name">Unit</label>
					    <input type="text" name="subsubdeptname" class="form-control" id="name" value="<?php echo $row_rsUnit['subunitname']; ?>" >
				  	</div>

				  	<div class="form-group">
					    <label for="subsubdeptfunctions">Department Functions</label>
					  <textarea name="subsubdeptfunctions" class="tinymce" cols="" rows="" id="subsubdeptfunctions"><?php echo $row_rsUnit['subunitfunctions']; ?></textarea>
				  	</div>

				</fieldset>

				<fieldset>
				<legend>Contact Details</legend>
			    	<div class="form-group">
					    <label for="phone">Telephone</label>
					    <input type="text" name="phone" class="form-control" id="phone" value="<?php echo $row_rsUnit['phone']; ?>">
				  	</div>

					<div class="form-group">
					    <label for="email">E-Mail</label>
					    <input type="text" name="email" class="form-control" id="email" value="<?php echo $row_rsUnit['email']; ?>"  >
				  	</div>
			  	</fieldset>
				
				<hr>
				<input type="hidden" name="MM_unitID" value="<?php echo $colname; ?>" >
				<input type="hidden" name="MM_update" value="update-unit-details" >
			  <button type="submit" id="update-unit" class="btn btn-success">Submit</button>
			  
			  
			  <div class="error_msg"></div>
			</form>
		</div><!-- End .form-wrapper-->
	</div><!-- End .data-area-wrap-->	
<!--</div>-->	<!-- End .data-area -->

<!-- TinyMCE -->
        
<script type="text/javascript" src="_/js/tinymce/jquery.tinymce.min.js"></script> 
<script type="text/javascript" src="_/js/tinymce/tinymce.min.js"></script>           
<script type="text/javascript">
		$(function(){
			tinymce.init({
			selector: 'textarea#subsubdeptfunctions',
			height: 500,
			content_css: [
			'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
			'//www.tiny.cloud/css/codepen.min.css'
			]
		});
		});
	</script>
<!-- /TinyMCE -->