<?php
error_reporting(0);
include('../db_connect.php');
if(isset($_POST['name'])){
	//header("location:vivek.php");
	$email = mysqli_real_escape_string($db, $_POST['email']);
	$name =  mysqli_real_escape_string($db, $_POST['name']);
	$address = mysqli_real_escape_string($db, $_POST['address']);
	$phone = mysqli_real_escape_string($db, $_POST['phone']);
	$website = mysqli_real_escape_string($db, $_POST['website']);
	$sector = mysqli_real_escape_string($db, $_POST['sector']);

mysqli_query($db,"insert into important_contacts(name,address,phone,website,sector,email) values ('$name','$address','$phone','$website','$sector','$email')");

	//echo "insert into important_contacts(name,address,phone,website,sector,email) values ('$name','$address','$phone','$website','$sector','$email')";
}

$con = mysqli_query($db,"select * from important_contacts");
?>
<!DOCTYPE html>
<head><meta charset="gb18030">
<title>COCAP</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="keywords" content="Colored Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- bootstrap-css -->
<link rel="stylesheet" href="css/bootstrap.css">
<!-- //bootstrap-css -->
<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />
<!-- font CSS -->
<link href='//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
<!-- font-awesome icons -->
<link rel="stylesheet" href="css/font.css" type="text/css"/>
<link href="css/font-awesome.css" rel="stylesheet"> 
<!-- //font-awesome icons -->
<script src="js/jquery2.0.3.min.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/jquery.cookie.js"></script>
<style>
	
td {
  word-break: break-all;
}

</style>
<script src="js/screenfull.js"></script>
		<script>
		$(function () {
			$('#supported').text('Supported/allowed: ' + !!screenfull.enabled);

			if (!screenfull.enabled) {
				return false;
			}

			

			$('#toggle').click(function () {
				screenfull.toggle($('#container')[0]);
			});	
		});
		</script>
<!-- charts -->
<script src="js/raphael-min.js"></script>
<script src="js/morris.js"></script>
<link rel="stylesheet" href="css/morris.css">
<!-- //charts -->
<!--skycons-icons-->
<script src="js/skycons.js"></script>
<!--//skycons-icons-->
</head>
<body class="dashboard-page">
	<script>
	        var theme = $.cookie('protonTheme') || 'default';
	        $('body').removeClass (function (index, css) {
	            return (css.match (/\btheme-\S+/g) || []).join(' ');
	        });
	        if (theme !== 'default') $('body').addClass(theme);
        </script>
	<?php include('header.php'); ?>
	<section class="wrapper scrollable">
		<nav class="user-menu">
			<a href="javascript:;" class="main-menu-access">
			<i class="icon-proton-logo"></i>
			<i class="icon-reorder"></i>
			</a>
		</nav>
		<?php include("topMenu.php");?>
		<div class="main-grid">
			
		
			
			<div class="agile-grids">
				<div class="col-md-4 charts-right">
					<!-- area-chart -->
					<div class="area-grids">
						<div class="area-grids-heading">
							<h3>User Survey Report</h3>
						</div>
						<div id="graph4"></div>
						<script>
							Morris.Donut({
							  element: 'graph4',
							  data: [
								{value: 70, label: 'YES', formatted: '70%' },
								{value: 15, label: 'NO', formatted: '30%' },
								
							  ],
							  formatter: function (x, data) { return data.formatted; }
							});
						</script>

					</div>
					<!-- //area-chart -->
				</div>
				<div class="col-md-8 chart-left">
					<!-- updating-data -->
					<div class="agile-Updating-grids">
						
							<div class="w3l-table-info">

					 <h3>Important Contacts</h3> <br> <a href="#" class="btn btn-hover btn-dark btn-block" style="width: 29%;" data-toggle="modal" data-target="#contactsModal">Add Contact
					 	<?php if(isset($_POST['saveContact'])){echo "hello";}?></a>
					    <table id="table"> 
						<thead>
						  <tr>
							<th>Organization Name</th>
							<th>Address</th>
							<th>Phone</th>
							<th>E-mail</th>
							<th>Action</th>
							
							
						  </tr>
						</thead>
						<tbody>
							<?php
                                            
                            while($a = mysqli_fetch_array($con))
                            { ?>
						  <tr>
							<td><?php echo $a['name'];?></td>
							<td><?php echo $a['address'];?></td>
							<td class="MyClass"><?php echo $a['phone'];?></td>
							<td><?php echo $a['email'];?></td>
							<td>Action</td>
						
							
						  </tr>
						 <?php } ?>
						</tbody>
					  </table>
					</div>
				  <code class="js">
					
				  </code>
						

					</div>
					<!-- //updating-data -->
				</div>
				<div class="clearfix"> </div>
			</div>
			
	
	
		</div>
		<!-- footer -->
		<?php include('footer.php'); ?>
		<!-- //footer -->
	</section>
	<script src="js/bootstrap.js"></script>
	<script src="js/proton.js"></script>

	<div class="modal fade" id="contactsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Add Contact</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form method="POST" action="" class="valida" autocomplete="off" novalidate="novalidate">

										

										<label for="field-1">Name: (required)&nbsp;<span class="at-required-highlight">*</span></label>
										<div class="form-group">
											<input type="text" name="name" id="field-1" required="true" class="form-control">
										</div>

										<div class="row">

											<div class="col-xs-12 col-sm-5">

												<label for="field-1-2">Email: (required)</label>
												<div class="form-group">
													<input type="text" name="email" id="field-1-4-1" filter="email" class="form-control" data-invalid="Must be a valid email address">
												</div>

											</div>

											<div class="col-xs-12 col-sm-7">

												<label for="field-1-2">Address: (required)</label>
												<div class="form-group">
													<input type="text" name="address" id="field-1-4-2"  class="form-control" required="true">
												</div>

											</div>

										</div>

											<div class="row">

											<div class="col-xs-12 col-sm-5">

												<label for="field-1-2">Phone: (required)</label>
												<div class="form-group">
													<input type="text" name="phone" id="field-1-4-1" class="form-control" required="true" >
												</div>

											</div>

											<div class="col-xs-12 col-sm-7">

												<label for="field-1-2">Website: (optional)</label>
												<div class="form-group">
													<input type="text" name="website" id="field-1-4-2"  class="form-control">
												</div>

											</div>

										</div>

										<hr>


										<label for="field-2">Sector: (required)&nbsp;<span class="at-required-highlight">*</span></label>
										<div class="form-group">
											<select name="sector" id="field-2" required="true" class="form-control">
												<option value="">Choose One</option>
												<option value="psychology">Psychology</option>
												<option value="police">Police</option>
												<option value="human">Human Rights</option>
												<option value="legal">Legal Support</option>
												<option value="hospital">Hospoital</option>
											</select>
										</div>

										<hr>

										

										

										<p>
											<input type="submit" name="saveContact" value="Submit" class="btn btn-primary">
											<input type="reset" name="res-1" id="res-1" value="Reset" class="btn btn-danger">
											
										</p>
									</form>
      </div>
      
    </div>
  </div>
</div>
<script type="text/javascript" src="js/valida.2.1.6.min.js"></script>
		<script type="text/javascript" >

			$(document).ready(function() {

				// show Valida's version.
				$('#version').valida( 'version' );

				// Exemple 1
				$('.valida').valida();

				// Exemple 2
				/*
				$('.valida').valida({

					// basic settings
					validate: 'novalidate',
					autocomplete: 'off',
					tag: 'p',

					// default messages
					messages: {
						submit: 'Wait ...',
						required: 'Este campo é obrigatório',
						invalid: 'Field with invalid data',
						textarea_help: 'Digitados <span class="at-counter">{0}</span> de {1}'
					},

					// filters & callbacks
					use_filter: true,

					// a callback function that will be called right before valida runs.
					// it must return a boolan value (true for good results and false for errors)
					before_validate: null,

					// a callback function that will be called right after valida runs.
					// it must return a boolan value (true for good results and false for errors)
					after_validate: null

				});
				*/

        // setup the partial validation
				$('#partial-1').on('click', function( ev ) {
					ev.preventDefault();
					$('#res-1').click(); // clear form error msgs
					$('form').valida('partial', '#field-1'); // validate only field-1
					//$('form').valida('partial', '#field-1-3'); // validate only field-1-3
				});

			});

		</script>
</body>
</html>
