<?php
include('../headertop.php');
include('../datepicker.php');
include('../db.php');

$disp = '';
$pagetitle = 'View/Search Clients';
//$disp .=' <div class="col-md-6">';


$q = "select * from project where type='ct'";
$res = mysqli_query($dbcon,$q) or die(mysqli_error($dbcon,$q));
if(mysqli_num_rows($res)<1)
{
$disp .= 'No projects. First create a project';
include('../template.php');
exit;
}
 
if(isset($_REQUEST['sm']))
$disp .= '<div class="smdiv">'.$_REQUEST['sm'].'</div>';
else
$disp .= '';

$disp .='<form role="form" id="viewclientsform" method="post" action="">
                                    <div class="row">
                                <div class="col-md-6">
                                    <h3>Select Project to View Clients</h3>
								<div class="form-group">
										<label>Project</label><select class="form-control" name="project" id="project">
										<option value=""></option> 
										<option value="all">All Projects</option>';
										
		while($row = mysqli_fetch_array($res))
	{
	$disp .= '<option value="'.$row['id'].'">'.$row['project_name'].'</option>';
	}									
		$disp .= '</select></div></form>
		
		</div></div>
		
<div class="row"><div class="col-md-12" style="text-align:center">
                                       <div id="clientdiv">Client Details </div> 
										</div>
                                    </div>';
									
									
                                    ?>
                                    <script>
                                    $.validate({
  form : '#viewclientsform'
});
</script>

<script>
		$(function() {
		
			$("#project").change(function() {
				//$("#text-two").load("textdata/" + $(this).val() + ".txt");
				$("#clientdiv").load("viewclients.php?project=" + $("#project").val());
			});
			
			//

		});
		
		
		
	</script>
    
    <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });
    </script>
    
    <?php
	include('../template.php');
	include('../header.php');