<?php
date_default_timezone_set('Asia/Kolkata'); 
//echo $date = date("Y-m-d", time());
include ('../config.php');
@session_start();
@$user_id1=$_SESSION['user_id1'];
@$idvfied1=$_SESSION['idverified1'];
@$namevfied1=$_SESSION['namevfied1'];
if(!isset($_SESSION['user_id1'])){
	header("Location: index.php");
}

$timeout = 60 * 60 * 24 * 365;
$s_name = session_name();
if(isset( $_COOKIE[ $s_name ] )) {
  setcookie( $s_name, $_COOKIE[ $s_name ], time() + $timeout, '/' );
}

$sel1=mysqli_query($conn,"select * from hr_dump where empid='".@$user_id1."'");
$fetch1=mysqli_fetch_array($sel1);

$queryFR=mysqli_query($conn,"select * from tracker where Functional_Reporting='$fetch1[Employee_Number]'");
$dataFR=mysqli_fetch_array($queryFR);

$queryFR=mysqli_query($conn,"select * from emp_leave where Functional_Reporting='$fetch1[Employee_Number]'");
$dataFR=mysqli_fetch_array($queryFR);
?>

<!doctype html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Search Project</title>
	
	<?php	include ('header.php');	?>
	
	<div id="appCapsule">
        <div class="section wallet-card-section pt-1">
            <div class="wallet-card">
				<!--<div class="balance">
                    <div class="left">
                        <span class="title"></?php echo $fetch1['Employee_Full_Name']; ?></span>
                        <h4></?php echo $fetch1['Team_Name']; ?></h4>
                        <h6></?php echo $date = date("Y-m-d", time()); ?></h6>
                    </div>
                    <div class="right">
                        <a href="#"><img src="../assets/img/noimage.png" alt="logo" class="logo-profile"></a>
                    </div>
                </div>-->
				
				<?php	include ('include/wallet-balance.php');	?>
				<div class="mb-4 py-2">
					<h6 class="text-center">Search Open Projects</h6>
					<div class="py-4">
						<form class="form-horizontal" name="m3m" action="open-projects.php" method="post" enctype="multipart/form-data" autocomplete="off">
							<div class="row">
							<?php
								$query = "SELECT * FROM proj_cities ORDER BY City_Name ASC"; 
								$result = $connpe->query($query); 
							?>
							<div class="col-md-3 col-sm-3">
								<select name="cityID_proj" id="city" class="form-control">
									<option value="">-Select City-</option>
									<?php if($result->num_rows > 0){ 
										while($row = $result->fetch_assoc()){ 
											echo '<option value="'.$row['cityID_proj'].'">'.$row['City_Name'].'</option>'; 
										} 
									}else{	echo '<option value="">city not available</option>';	} 
									?>
								</select>
							</div>
							<?php
								$cat_q = $connpe->query("select * from proj_open GROUP BY Location ASC");
								$catCount = $cat_q->num_rows;
							?>
							<div class="col-md-3 col-sm-3">
								<select name="Location" id="location_name" required class="form-control location_name">
									<option value="">-Select City First-</option>
								</select>
							</div>
							<?php
								$service_query = $connpe->query("SELECT * FROM proj_category ORDER BY category_name ASC");
								$serviceRowCount = $service_query->num_rows;
							?>
							<div class="col-md-4 col-sm-4">
								<select name="category_name" id="service" required class="form-control margin-bottom">
									<option value="">-Category Name-</option>
									<?php			if($serviceRowCount > 0){
										while($row = $service_query->fetch_assoc()){ 
											echo '<option value="'.$row['category_name'].'">'.$row['category_name'].'</option>'; }
									}else{echo '<option value="">Category not available</option>';}
									?>
								</select>
							</div>
							<div class="col-md-2 col-sm-2 text-center">
								<div style="margin: auto;"><button name="projsearch" class="btn btn-success">Submit</button></div>
							</div>
							<script>
							$(document).ready(function(){
								$('#city').on('change', function(){
									var cityID_proj = $(this).val();
									if(cityID_proj){
										$.ajax({
											type:'POST',
											url:'ams_location.php',
											data:'cityID_proj='+cityID_proj,
											success:function(html){	$('#location_name').html(html);	}
										}); 
									}else{	$('#location_name').html('<option value="">Select test city first</option>');	}
								});
							});
							</script>
							</div>
						</form> 
					</div>
					
					<div class="row stat-box py-2">
						<div class="table">
							<table id=" " class="table table-striped table-bordered">
							<thead>
							<tr>
								<th>Developer</th>
								<th>Project</th>
								<th>Closing Manager</th>
								<th>Number</th>
								<th>View</th>
							</thead>
							<tbody>
							<?php
							echo "<h4 class='text-center'>$_POST[Location]</h4>";
							$query="select * from proj_open where Location LIKE '".@$_POST['Location']."' AND  category_name LIKE '".@$_POST['category_name']."' AND Project_Status='Active' ";
							$result=mysqli_query($connpe,$query);
							while($data=mysqli_fetch_assoc($result))
							{
							@$sn++;
							?>
							<tr>
								<td><?php echo $data['Developer'] ?></td>
								<td><?php echo $data['Project'] ?></td>
								<td><?php echo $data['Closing_Manager'] ?></td>
								<td><?php echo $data['Closing_Manager_Number'] ?></td>
								<td><a href="open-projects-view.php?SNo=<?php echo $data['SNo']; ?>" class="btn btn-primary btn-sm">View</a></td>
							</tr>
							<?php    }    ?> 
							</tbody>
							</table>		
						</div>
					</div>
				</div>
            </div>
        </div>
		
		
        
		<!--</?php	include ('include/quik_links.php');	?>
		</?php	include ('include/extra_links.php');	?>-->
	
	<?php	include ('include/copyright.php');	?>
	</div>
	
	<?php	include ('footer.php');	?>