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

	if(!isset($_SESSION)){
        session_start();
    }

 ?>

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

	<div class="data-area-wrap">
		<div class="form-wrapper">
			<form id="new-project" method="post">
			  	<fieldset>
			  	<legend>Add Project: <?php //print_r($_SESSION); ?></legend>

				  	<div class="form-group">
					    <label for="projtitle">Project Title</label>
					    <input type="text" name="projtitle" class="form-control" id="projtitle" >
            </div>

            <div class="form-group">
              <label for="projcategory">Project Category</label>
              <select name="projcategory" id="projcategory" class="form-control">
                <option value="">-Select-</option>
                <option value="security infrastructure">Security Infrastruture</option>
                <option value="road">Road infrastructure</option>
              </select>
            </div>

				  	<div class="form-group">
					    <label for="elm1">Description</label>
					  	<textarea name="projectdesc" class="form-control" cols="" rows="3" id="emlm1"></textarea>
            </div>

            <div class="form-group">
              <label for="communities">Communities</label>
              <input type="text" name="communities" class="form-control" id="communities" >
            </div>

            <div class="form-group">
              <label for="gps">GPS Location</label>
              <input type="text" name="gps" class="form-control" id="gps" >
            </div>

            <div class="form-group">
              <label for="startdate">Start Date</label>
              <input type="text" name="startdate" class="form-control" id="startdate" >
              <label for="enddate">End Date</label>
              <input type="text" name="enddate" class="form-control" id="enddate" >
            </div>
            <div class="form-group">
              <label for="projectstatus">Project Status</label>
              <select name="projectstatus" id="projectstatus" class="form-control">
                <option value="">-Select-</option>
                <option value="ongoing">Ongoing</option>
                <option value="completed">Completed</option>
              </select>
            </div>

            <div class="form-group">
              <label for="percentage">Percentage</label>
              <input type="text" name="percentage" class="form-control" id="percentage" >
            </div>

			  	</fieldset>
				<hr>
			  <button type="submit" id="add-new-project" class="btn btn-success">Submit</button>
			  <input type="hidden" name="MM_insert" value="save-new-project" />
			  <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/tinymce.min.js"></script>
		<script type="text/javascript" src="_/js/tinymce/jquery.tinymce.min.js"></script>
		<script type="text/javascript">

						$('textarea.tinymce').tinymce({
									selector: 'textarea#emlm1',
									height: 300,
									theme: 'modern',
									plugins: [
										'advlist autolink lists link image charmap print preview hr anchor pagebreak',
										'searchreplace wordcount visualblocks visualchars code fullscreen',
										'insertdatetime media nonbreaking save table contextmenu directionality',
										'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc'
									],
									toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
									toolbar2: 'print preview media | forecolor backcolor emoticons | codesample',
									image_advtab: true,
									templates: [
										{ title: 'Test template 1', content: 'Test 1' },
										{ title: 'Test template 2', content: 'Test 2' }
									],
									content_css: [
										'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
										'//www.tinymce.com/css/codepen.min.css'
									]

						});



		</script>
<!-- /TinyMCE -->




<script>
	$(document).on('click','.delete-btn',function(e){
		e.preventDefault();

		//alert("form");
		$(this).parent('div').fadeOut();

	});

	$(".fileUpload").on('change', function () {
		//alert("askfljsd");
		//Get count of selected files
		var countFiles = $(this)[0].files.length;

		var imgPath = $(this)[0].value;
		var extn = imgPath.substring(imgPath.lastIndexOf('.') + 1).toLowerCase();
		var image_holder = $("#image-holder");
		image_holder.empty();

		if (extn == "gif" || extn == "png" || extn == "jpg" || extn == "jpeg") {
			if (typeof (FileReader) != "undefined") {

				//loop for each file selected for uploaded.
				for (var i = 0; i < countFiles; i++) {

					var reader = new FileReader();
					reader.onload = function (e) {
						$("<img />", {
							"src": e.target.result,
								"class": "thumb-image img-fluid"
						}).appendTo(image_holder);
					}

					image_holder.show();
					reader.readAsDataURL($(this)[0].files[i]);
				}

			} else {
				alert("This browser does not support FileReader.");
			}
		} else {
			alert("Pls select only images");
		}
	});
</script>
