<?php 
require_once("header1.php");

$get_type = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `pd_property_type` WHERE `type_id` = '".$_REQUEST['type_id']."'"));
?>

			<!-- page template area start -->
			<section id="about" style="background:#f1f1f1;">
				<div class="container mt-0 pb-10 pt-10">
				    <div class="col-md-3">
				        <div class="row">
	                        <div class="col-xs-12 col-sm-12 col-md-12">
		                        <div class="media-body" style="border:1px solid #003f7d; padding:5px;">
		                            <p style="background-color:#003f7d; color:#fff; padding:5px; text-align:left;">Price Range</p>
                            		<form action="" method="get" onsubmit="return form_validationg();">
                            	    <input type="hidden" name="type_id" id="type_id" value="<?php echo $_REQUEST['type_id'];?>">
                            		<input type="hidden" name="psearch" id="psearch" value="1">
                            		<table width="100%" border="0" cellspacing="2" cellpadding="2">
                            			<tr>
                            				<td>
                            				    <div class="form-group">
                            						<input type="text" name="from_price" id="from_price" class="form-control" placeholder="Enter Price From">
                            					</div>
                            				</td>
                            			</tr>
                            			<tr>
                            				<td>
                            				    <div class="form-group">
                            						<input type="text" name="to_price" id="to_price" class="form-control" placeholder="Enter Price To">
                            					</div>
                            				</td>
                            			</tr>
                            			<tr>
                            				<td>
                            				    <div class="form-group" style="margin:0; text-align:center;">
                            						<button type="submit" class="btn btn-flat btn-theme-colored border-left-theme-color-2-4px">Submit</button>
                            					</div>
                            				</td>
                            			</tr>
                            		</table>
                            		</form>
	                            </div>
                            </div>
                            <div>&nbsp;</div>
                        </div>
                        <div class="row">
    	                    <div class="col-xs-12 col-sm-12 col-md-12">
    		                    <div class="media-body" style="border:1px solid #003f7d; padding:5px;">
    		                        <p style="background-color:#003f7d; color:#fff; padding:5px; text-align:left;">Property Type</p>
    		                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
    		                        <?php
                                    $sql_type1 = "SELECT * FROM `pd_property_subtype` WHERE `type_id`  = '".$_REQUEST['type_id']."' AND `subtype_status` = 'Active' ORDER BY `subtype_id` ASC";
                                    $exe_type1 = mysqli_query($connection,$sql_type1);
                                    while($arr_type1 = mysqli_fetch_array($exe_type1))
                                    {
                                    	?>
    		    			            <tr>
                            				<td width="90%" style="padding-left:5px; border-bottom:1px solid #f1f1f1; border-top:1px solid #f1f1f1; "><a href="property-list.php?subtype_id=<?php echo $arr_type1['subtype_id'];?>&type_id=<?php echo $_REQUEST['type_id'];?>" style="color:#2b2b2b;"><?php echo stripslashes($arr_type1['subtype']);?></a></td>
    			                        </tr>
    			                        <?php
                                    }
                                    ?>
    					        </table>
    	                    </div>
                        </div>
                        <div>&nbsp;</div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12">
    	                    <div class="media-body" style="border:1px solid #003f7d; padding:5px;">
    	                        <p style="background-color:#003f7d; color:#fff; padding:5px; text-align:left;">Location</p>
    	                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
    	                        <?php
    							$sql_location = "SELECT * FROM `pd_locations` WHERE `location_status` = 'Active' ORDER BY `location_id` ASC";
    							$exe_location = mysqli_query($connection,$sql_location);
    							while($arr_location = mysqli_fetch_array($exe_location))
    							{
    								?>
    	    			            <tr>
                        				<td width="90%" style="padding-left:5px; border-bottom:1px solid #f1f1f1; border-top:1px solid #f1f1f1; "><a href="property-list.php?location_id=<?php echo $arr_location['location_id'];?>&type_id=<?php echo $_REQUEST['type_id'];?>" style="color:#2b2b2b;"><?php echo stripslashes($arr_location['location']);?></a></td>
    		                        </tr>
    		                        <?php
                                }
                                ?>
    				            </table>
                            </div>
                        </div>
                        <div>&nbsp;</div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12">
    	                    <div class="media-body" style="border:1px solid #003f7d; padding:5px;">
    	                        <p style="background-color:#003f7d; color:#fff; padding:5px; text-align:left;">Ownership Type</p>
    	                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
    	    			        <?php
    							$sql_otype = "SELECT * FROM `pd_ownership_type` WHERE `otype_status` = 'Active' ORDER BY `otype_id` ASC";
    							$exe_otype = mysqli_query($connection,$sql_otype);
    							while($arr_otype = mysqli_fetch_array($exe_otype))
    							{
    								?>
    	    			            <tr>
                        				<td width="90%" style="padding-left:5px; border-bottom:1px solid #f1f1f1; border-top:1px solid #f1f1f1; "><a href="property-list.php?otype_id=<?php echo $arr_otype['otype_id'];?>&type_id=<?php echo $_REQUEST['type_id'];?>" style="color:#2b2b2b;"><?php echo stripslashes($arr_otype['otype']);?></a></td>
    		                        </tr>
    		                        <?php
                                }
                                ?>
    				            </table>
                            </div>
                        </div>
                        <div>&nbsp;</div>
                    </div>
                    <p style="text-align:center;"><a class="btn btn-colored btn-theme-colored btn-lg mt-0" href="property-list.php?type_id=<?php echo $_REQUEST['type_id']?>" >Reset</a></p>
                    <div>&nbsp;</div>
				</div>
			    <div class="col-lg-8">
					<h1 class="title mt-5 mb-15" style="text-align:left;"><?php echo $get_type['type'];?> List</h1>
					<?php if(isset($_SESSION['del_succ_msg'])) { ?>
					<p><img src="images/tick.png" alt="" /> <?php echo $_SESSION['del_succ_msg'];?></p>
					<?php
					unset($_SESSION['del_succ_msg']);
					}
					?>
					<?php
					$sql_order = "SELECT * FROM `pd_property` WHERE  `property_status` = 'Active' AND `type_id` = '".$_REQUEST['type_id']."'";
					if($_REQUEST['psearch'])
					{
					    $sql_order .= " AND `price` BETWEEN '".$_REQUEST['from_price']."' AND '".$_REQUEST['to_price']."'";
					}
					if($_REQUEST['subtype_id'])
					{
					$sql_order .= " AND `subtype_id` = '".$_REQUEST['subtype_id']."'";
					}
					if($_REQUEST['location_id'])
					{
					$sql_order .= " AND `location_id` = '".$_REQUEST['location_id']."'";
					}
					if($_REQUEST['otype_id'])
					{
					$sql_order .= " AND `otype_id` = '".$_REQUEST['otype_id']."'";
					}
					if($_REQUEST['price_to'])
					{
					$sql_order .= " AND `price` BETWEEN '0' AND '".$_REQUEST['price_to']."'";
					}
					if($_REQUEST['bhk'])
					{
					$sql_order .= " AND `type_id` = '".$_REQUEST['type_id']."' AND `bhk` = '".$_REQUEST['bhk']."'";
					}
					//else
					//{
					$sql_order .= " ORDER BY `property_id` DESC";
					//}
					//echo $sql_order;
					$exe_order = mysqli_query($connection,$sql_order);
					$num_order = mysqli_num_rows($exe_order);
					if($num_order>0)
					{
					while($arr_order = mysqli_fetch_array($exe_order))
					{								
						if($arr_order['floor'] == 0)
						{
						    $flr = "Ground";
						}
						else
						{
						    $flr = $arr_order['floor'];
						}
						
						$get_location = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `pd_locations` WHERE `location_id` = '".$arr_order['location_id']."'"));
						$get_type = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `pd_property_type` WHERE `type_id` = '".$arr_order['type_id']."'"));
						$get_subtype = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `pd_property_subtype` WHERE `subtype_id` = '".$arr_order['subtype_id']."'"));
						$get_otype = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `pd_ownership_type` WHERE `otype_id` = '".$arr_order['otype_id']."'"));
						$get_broker = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `pd_brokers` WHERE `user_id` = '".$arr_order['broker_id']."'"));
						?>	
						<div class="col-md-12" style="background:#fff; padding:10px; margin-bottom:20px; border: 1px solid #ccc; box-shadow: -3px 5px 7px 0px #ccc; background-color:#fff; border-bottom-right-radius: 7px; border-bottom-left-radius: 7px; border-radius:5px;">
						    <div class="col-md-4"><img class="img-fullwidth mb-10" style="" alt="" src="uploads/property/<?php echo stripslashes($arr_order['cover_photo']);?>"></div>
						    <div class="col-md-8">
						        <h3 style="margin-bottom:5px; margin-top:0;"><?php echo stripslashes($get_subtype['subtype']);?> - <?php echo $get_location['location'];?></h3>
						        <p class="text-left mb-0" style="color:#888;"><?php echo stripslashes($get_otype['otype']);?> <?php echo stripslashes($get_subtype['subtype']);?></p>
						        <?php if($arr_order['type_id'] == 1) { ?>
						        <p class="text-left mb-0">Carpet Area : <?php echo stripslashes($arr_order['carpet_area']);?> sqft</p>
						        <p class="text-left mb-0"><?php echo stripslashes($arr_order['bhk']);?>, <?php echo $flr;?> Floor, <?php echo stripslashes($arr_order['bathroom']);?> Bathroom, <?php echo stripslashes($arr_order['balcony']);?> Balcony</p>
						        <p class="text-left mb-0" style="color:#888;"><?php echo stripslashes($arr_order['furnishing_type']);?></p>
						        <?php } ?>
						        <?php if($arr_order['type_id'] == 2) { ?>
						        <p class="text-left mb-0">Carpet Area : <?php echo stripslashes($arr_order['carpet_area']);?> sqft</p>
						        <p class="text-left mb-0"><?php echo $flr;?> Floor, <?php echo stripslashes($arr_order['bathroom']);?> Bathroom</p>
						        <p class="text-left mb-0" style="color:#888;"><?php echo stripslashes($arr_order['furnishing_type']);?></p>
						        <?php } ?>
						        <?php if($arr_order['type_id'] == 3) { ?>
						        <p class="text-left mb-0">Total Area : <?php echo stripslashes($arr_order['plot_area']);?> sqft</p>
						        <p class="text-left mb-0" style="color:#888;">Open Sides : <?php echo stripslashes($arr_order['open_sides']);?></p>
						        <?php } ?>
								<p class="text-left mb-0" style="color:#e53935;"><b>Total Price : &#8377;<?php echo stripslashes($arr_order['price']);?></b></p>
								<p class="text-left mb-10"><b>Agent Code : <?php echo stripslashes($get_broker['broker_code']);?></b></p>
						        <p><button type="button" class="btn btn-flat btn-theme-colored2 border-left-theme-color-2-4px" onclick="window.location.href='property-details.php?property_id=<?php echo stripslashes($arr_order['property_id']);?>'">View Details</button>&nbsp;&nbsp;<a class="btn btn-colored btn-theme-colored btn-lg mt-0" href="property-photo.php?property_id=<?php echo $arr_order['property_id']?>&type_id=<?php echo $arr_order['type_id']?>">View Photos</a></p>
						    </div>
						</div>
					    <?php
					}
					}
					else
					{
					?>
					<p style="color:#e53935; text-align:left;">No propety found</p>
					<?php
					}
					?>
					</div>
				</div>
			</section>
			<!-- page template area end -->
  
<?php require_once("footer1.php");?>