<?php
include_once 'includes/processes.php';
$Process = new Login_Process;

$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);

$addDepartment = $Process->addDepartment($_POST, $_POST['add_dept']);
$updateDepartment = $Process->updateDepartment($_POST, $_POST['update_designation']);
$deleteDepartment = $Process->deleteDepartment($_POST, $_POST['delete_designation']);
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <title>Departments - APL Portal</title>

  <meta charset="utf-8">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width">

  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,300,700">
  <link rel="stylesheet" href="./css/font-awesome.min.css">
  <link rel="stylesheet" href="./js/libs/css/ui-lightness/jquery-ui-1.9.2.custom.min.css">
  <link rel="stylesheet" href="./css/bootstrap.min.css">

  <!-- Plugin CSS -->
  <link rel="stylesheet" href="./js/plugins/magnific/magnific-popup.css">

  <!-- App CSS -->
  <link rel="stylesheet" href="./css/target-admin.css">
  <link rel="stylesheet" href="./css/custom.css">


  <!-- 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>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  <![endif]-->
</head>

<body>

<?php include'includes/header.php'; ?>

<div class="container">

  <div class="content">

    <div class="content-container">

      

      <div class="content-header">
        <h2 class="content-header-title">Department</h2>
        <ol class="breadcrumb">
          <li><a href="./">Home</a></li>
          <li class="active">Department</li>
        </ol>
      </div> <!-- /.content-header -->

      

      <div class="row">
		 
        <div class="col-md-12">
		<?php echo $addDepartment; ?>
		<?php echo $updateDepartment; ?>
		<?php echo $deleteDepartment; ?>
		
		 <div class="portlet">

            <div class="portlet-header">

              <h3>
                <i class="fa fa-th"></i>
                Department
              </h3>
			  
			   <ul class="portlet-tools pull-right">
                <li>
                  <a data-toggle="modal" href="#basicModal" class="btn btn-sm btn-default">
                    add department
                  </a>
                </li>
              </ul>

            </div> <!-- /.portlet-header -->

            <div class="portlet-content">           
				<?php 
					//if(in_array("read_dept",$_SESSION['privileges'])) {
						$Process->getDepartments(); 
					//}						
				?>
            </div> <!-- /.portlet-content -->

          </div> <!-- /.portlet -->

		  
        </div> <!-- /.col -->

      </div> <!-- /.row -->



      




    </div> <!-- /.content-container -->
      
  </div> <!-- /.content -->

</div> <!-- /.container -->
	<?php include"includes/footer.php"; ?>
	
	

   <div id="basicModal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3 class="modal-title"><i class="fa fa-th"></i> New Department</h3>
      </div>
	  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		<div class="modal-body">
			<div class="row">
				<div class="form-group col-md-6 col-sm-12">
					<label class="control-label">Department</label>
					<input type="text" name="dept_name" class="form-control col-md-12 col-xs-12" autocomplete="off" placeholder="Department name" required />
				</div>
				<div class="form-group col-md-6 col-sm-12">
					<label class="control-label">Group Email</label>
					<input type="text" name="dept_email" class="form-control col-md-12 col-xs-12" autocomplete="off" placeholder="Department Email" required />
				</div>
				<div class="form-group col-md-4 col-sm-12">
					<label class="control-label">Designation</label>
					<div class="input-group">
						<input type="text" name="designation[]" class="form-control col-md-12 col-xs-12" autocomplete="off" placeholder="designation" required />
					</div>
				</div>
				
				<div id="dynamicInputs"></div>
			</div>
			<div class="row">			
				<div class="col-md-12">
				<a href="javascript:;" class="btn btn-info btn-lg btn-xs" type="button" onclick="addDesignation('dynamicInputs');">Add Designation <i class="fa fa-plus"></i></a>
				</div>
			</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			<button type="submit" name="add_dept" class="btn btn-primary">Add Department</button>
		</div>
	  </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade" id="editDepartment" >
		<div class="modal-dialog">
			<div class="modal-content"> 
			
			</div>
		</div>
	</div>
	
	<div class="modal fade" id="deleteDepartment">
		<div class="modal-dialog">
			<div class="modal-content">
			
			</div>
		</div>
	</div>

 <script src="./js/libs/jquery-1.10.1.min.js"></script>
  <script src="./js/libs/jquery-ui-1.9.2.custom.min.js"></script>
  <script src="./js/libs/bootstrap.min.js"></script>

  <!--[if lt IE 9]>
  <script src="./js/libs/excanvas.compiled.js"></script>
  <![endif]-->
  
  <!-- Plugin JS -->
  <script src="./js/plugins/datatables/jquery.dataTables.min.js"></script>
  <script src="./js/plugins/datatables/DT_bootstrap.js"></script>
  <script src="./js/plugins/tableCheckable/jquery.tableCheckable.js"></script>
  <script src="./js/plugins/icheck/jquery.icheck.min.js"></script>

  <!-- App JS -->
  <script src="./js/target-admin.js"></script>

  
  <script>
function addDesignation(divName){
     var newdiv = document.createElement('div');
	
     newdiv.innerHTML = "<div class='form-group col-md-4 col-sm-12'>"+
							"<label class='control-label'>Designation</label>"+
							"<div class='input-group'>"+
								"<input type='text' name='designation[]' class='form-control  autocomplete='off' col-md-12 col-xs-12' placeholder='designation' />"+
							"</div>"+
						"</div>";
						
     document.getElementById(divName).appendChild(newdiv);

}

function removeDesignation(sourceid) {
	var elementid = document.getElementById(sourceid);
	//counter--;
	elementid.remove();
}
</script>
<script type="text/javascript">
$(document).on("hidden.bs.modal", function (e) {
    $(e.target).removeData("bs.modal").find(".modal-content").empty();
});
</script>  
</body>
</html>
