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

	if(!isset($_SESSION)){
        session_start();
	} 
	
	//define('MAX_FILE_SIZE',10121200);
	if(isset($_POST['dpid'])){
		$deptID = $_POST['dpid'];
	}

	//Retrieve departments
	$query_rsDepartment = "CALL department_details(".$deptID.")";//"SELECT deptID, `deptname`, subdeptdetailsID, dateadded  FROM v_depts ORDER BY dateadded DESC";
	$rsDepartment = mysqli_query($conn_ama, $query_rsDepartment ) or die(mysqli_error($conn_ama));
	$row_rsDepartment = mysqli_fetch_assoc($rsDepartment);
	$totalRows_rsDepartment = mysqli_num_rows($rsDepartment);/**/

 ?>

<!-- <div class="col-md-9 data-area"> -->

	<div class="data-area-wrap">
		<div class="form-wrapper">
			<form id="update-new-dept-detail">
			  	<fieldset>
			  		<div class="form-row">
						<legend>Add Department Details <?php //print_r($_SESSION); ?></legend>
						<div class="form-group col-12">
							<label for="name">Department</label>
							<input type="text" name="deptname" class="form-control" id="name" value="<?php echo $row_rsDepartment['deptname']; ?>" >
						</div>

						<div class="form-group col-4">
							<select name="rank" class="form-control">
								<option value="<?php echo $row_rsDepartment['rank'];?>"><?php echo $row_rsDepartment['rank'];?></option>
								<option value="1">1</option>
								<option value="2" >2</option>
								<option value="3" >3</option>
							</select>
						</div>

						  <div class="form-group col-12">
							<label for="name">Sub Department</label>
							<input type="text" name="subdeptname" class="form-control" id="name" value="<?php echo $row_rsDepartment['subdeptname']; ?>" >
						  </div>
						  
						  <!-- <div class="form-group">
							<label for="gist">Gist</label>
							<input type="text" name="gist" class="form-control" id="gist" placeholder="Gist">
						  </div> -->
						  
						  <div class="form-group col-12 ">
							<label for="deptfunctions">Department Functions</label>
						  	<textarea name="deptfunctions" class="tinymce" cols="" rows="" id="deptfunctions"><?php echo $row_rsDepartment['deptfunctions']; ?></textarea>
						  </div>
						  
					  </div>
				</fieldset>

				<fieldset>
				<legend>Contact Details</legend>
					<div class="form-group">
						<label for="location">Location</label>
					  	<textarea name="location" class="form-control"  cols="" rows="" id="location"><?php echo $row_rsDepartment['location']; ?></textarea>
				  	</div>

					<div class="form-group">
					    <label for="digitaladdress">Ghana Post GPS Address</label>
					    <input type="text" name="digitaladdress" class="form-control" id="digitaladdress" value="<?php echo $row_rsDepartment['digitaladdress']; ?>" >
				  	</div>

					<div class="form-group">
					    <label for="address">Postal Address</label>
					    <input type="text" name="address" class="form-control" id="address" value="<?php echo $row_rsDepartment['address']; ?>" >
				  	</div>

					<div class="form-group">
					    <label for="phone">Telephone</label>
					    <input type="text" name="phone" class="form-control" id="phone" value="<?php echo $row_rsDepartment['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_rsDepartment['email']; ?>" >
				  	</div>

			  	</fieldset>
				
				<hr>
			  <button type="submit" id="update-dept" class="btn btn-success">Submit</button>
			  <input type="hidden" name="MM_update" value="update-dept-details" />
			  <input type="hidden" name="MM_deptID" value="<?php echo $deptID; ?>" />
			  <div class="error_msg"></div>
			</form>
		</div><!-- End .form-wrapper-->
	</div><!-- End .data-area-wrap-->	
<!--</div>-->	<!-- End .data-area -->

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