<style type="text/css">
#map{ width:100%; height: 500px; margin-bottom: 10px; }
</style>
<style>
.del
{
	background: #d80c0c;
    border: none;
    margin-top: 8px;
    color: #fff;
    padding: 3px;
    font-size: 15px;
    font-weight: 700;
}
</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD3cFZavM5DEExtIl_rSuMZGmuFAMIlEI8"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script>
function getLocation(val) {
    $.ajax({
    type: "POST",
    url: "location.php",
    data:'pid='+val,
    success: function(data){
        $("#location-list").html(data);
    }
    });
}
</script>
<script>
function getType(val) {
	if(val==1) 
	{
		//$("#amenity").hide();
		$("#kitchen").hide();
		$("#kitchen1").hide();
		$("#kitchen2").hide();
	}
	else 
	{
		$("#amenity").show();
		$("#kitchen").show();
		$("#kitchen1").show();
		$("#kitchen2").show();
	}
    $.ajax({
    type: "POST",
    url: "type.php",
    data:'tid='+val,
    success: function(data){
    $("#type-list").html(data);
    }
    });
}
</script>
<?php include('header.php');?>
<?php include('sidebar.php');

include ('includes/db_config.php');?>

<?php
$maintitle="Property";
$page="property.php";
$table="tbl_property";
$field_id="propertyid";
$mode=$_REQUEST['mode'];
$search=$_REQUEST['search'];
$content_id=$_REQUEST['content_id'];
if(isset($_REQUEST['start'])){
$start=$_REQUEST['start']-1;
}
else {
$start=0;
}
?>
<?php
if(isset($_REQUEST['submit'])=="submit"){ 	
	
/*	
$name=$_POST['propertyname'];
$category=$_POST['category'];	
$category1=$_POST['category1'];
$propertytype=$_POST['propertytype'];
$price=$_POST['price'];
$area=$_POST['area'];
$bedrooms=$_POST['bedrooms'];
$bathrooms=$_POST['bathrooms'];
$kitchen=$_POST['kitchen'];
$garage=$_POST['garage'];
$city=$_POST['city'];
$location=$_POST['location'];
$view=$_POST['view'];
$pstatus=$_POST['status'];
$ppty_id=$_POST['propertyid'];
$rera=$_POST['rera'];
$description=$_POST['editor1'];
$latitude=$_POST['latitude'];
$longitude=$_POST['longitude'];*/
	
	if($_REQUEST['mode']=="add"){
		$title=$_POST['title'];
$name=$_POST['propertyname'];
$category=$_POST['category'];	
$category1=$_POST['category1'];
$propertytype=$_POST['propertytype'];
$price=$_POST['price'];
$area=$_POST['area'];
$bedrooms=$_POST['bedrooms'];
$bathrooms=$_POST['bathrooms'];
$kitchen=$_POST['kitchen'];
$garage=$_POST['garage'];
$city=$_POST['city'];
$location=$_POST['location'];
$view=$_POST['view'];
$pstatus=$_POST['status'];
$ppty_id=$_POST['propertyid'];
$rera=$_POST['rera'];
$description=$_POST['editor1'];
		$latitude=$_POST['latitude'];
$longitude=$_POST['longitude'];
mysqli_query( $con, "INSERT INTO tbl_property (title,name,category,category1,type,price,area,bedrooms,bathrooms,kitchen,garage,city,location,view,status,property_id,rerapermit,description,latitude,longitude) VALUES ('$title','$name','$category','$category1','$propertytype','$price','$area','$bedrooms','$bathrooms','$kitchen','$garage','$city','$location','$view','$pstatus','$ppty_id','$rera','$description','$latitude','$longitude')" );
		
		
		
		/******* Start Amenities *************/
$checkbox1=$_POST['amenities'];  
$chk="";  
foreach($checkbox1 as $chk1)  
   {  
$lastid=mysqli_query($con,"SELECT max(propertyid) as pid FROM tbl_property");
$pid1=mysqli_fetch_array($lastid);
$pid=$pid1['pid'];
mysqli_query($con,"insert into tbl_property_amenities(property,amenities,status) values($pid,'$chk1',1)");  
   }  

/******** End Amenities *************/
		
		
	
$lastid=mysqli_query($con,"SELECT LAST(propertyid) FROM tbl_property");
$pid=mysqli_fetch_array($lastid);
	
	
		$lastid=mysqli_query($con,"SELECT max(propertyid) as pid FROM tbl_property");
$pid1=mysqli_fetch_array($lastid);
$pidf=$pid1['pid'];
	
$message=mysqli_query($con,"insert into tbl_property_imagegallery(property,image,status) values('$pidf','',2)");
$sel_max=mysqli_query($con,"select max(galleryid) as maxslider from tbl_property_imagegallery");
$res_max=mysqli_fetch_array($sel_max);
$mid=$res_max['maxslider'];

$extension = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION);
$newname= "image-".$mid.".".$extension;
$image = $_FILES['image']['name'];
$target = "../images/propertygallery/".$newname;
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
mysqli_query($con,"update tbl_property_imagegallery set image='$newname' where galleryid='$mid'");
}

/****** Start Upload Gallery Images  ********/	

foreach ( $_FILES[ 'galleryimages' ][ 'name' ] as $up_filename ) {
$statement = mysqli_query( $con, "select max(galleryid) as maxid from  tbl_property_imagegallery");

$stsmt = mysqli_fetch_array( $statement );
$new_id = $stsmt[ 'maxid' ] + 1; //10 fixed
	$countfiles = count( $_FILES[ 'galleryimages' ][ 'name' ] );
	for ( $i = 0; $i < $countfiles; $i++ ) {
		//$up_filename=$_FILES["attached"]["name"];
		$file_basename = substr( $up_filename, 0, strripos( $up_filename, '.' ) ); // strip extention
		$file_ext = substr( $up_filename, strripos( $up_filename, '.' ) ); // strip name
		$f1 = $new_id . '-' . $i . $file_ext;

		if ( ( $file_ext != '.png' ) && ( $file_ext != '.jpg' ) && ( $file_ext != '.jpeg' ) && ( $file_ext != '.gif' ) )
			throw new Exception( "Only jpg, jpeg, png and gif format images are allowed to upload." );

		if ( move_uploaded_file( $_FILES[ 'galleryimages' ][ 'tmp_name' ][ $i ], '../images/propertygallery/' . $f1 ) ) {
			$lastid=mysqli_query($con,"SELECT max(propertyid) as pid FROM tbl_property");
$pid1=mysqli_fetch_array($lastid);
			$pid=$pid1['pid'];
			mysqli_query( $con, "INSERT INTO tbl_property_imagegallery (property,image,status) VALUES ('$pid','$f1',1)" );
			
		}
	}

}
/****** End Upload Gallery Images  ********/      
	
/****** Start Layout Gallery Images  ********/	

foreach ( $_FILES[ 'layoutimages' ][ 'name' ] as $layout_filename ) {
$layout = mysqli_query($con, "select max(layoutid) as layoutmaxid from  tbl_property_layout");
$layout1 = mysqli_fetch_array($layout);
$layoutnew_id = $layout1[ 'layoutmaxid' ] + 1; //10 fixed
$layoutcountfiles = count($_FILES[ 'layoutimages' ][ 'name' ]);
for ( $i = 0; $i < $layoutcountfiles; $i++ ) { 
	$layout_file_basename = substr( $layout_filename, 0, strripos( $layout_filename, '.' ) ); // strip extention
	$layout_file_ext = substr( $layout_filename, strripos( $layout_filename, '.' ) ); // strip name
	$layoutf1 = $layoutnew_id . '-' . $i . $layout_file_ext;

		if (( $layout_file_ext != '.png' ) && ( $layout_file_ext != '.jpg' ) && ( $layout_file_ext != '.jpeg' ) && ( $layout_file_ext != '.gif' ) )
			throw new Exception( "Only jpg, jpeg, png and gif format images are allowed to upload." );

		if ( move_uploaded_file( $_FILES[ 'layoutimages' ][ 'tmp_name' ][ $i ], '../images/propertylayout/' . $layoutf1) ) {
			$lastid=mysqli_query($con,"SELECT max(propertyid) as pid FROM tbl_property");
$pid1=mysqli_fetch_array($lastid);
			$pid=$pid1['pid'];
			mysqli_query( $con, "INSERT INTO tbl_property_layout (property,image,status) VALUES ('$pid','$layoutf1',1)" );
		}
	}

}
/****** End Layout Gallery Images  ********/   
	
	
/****** Start Location Gallery Images  ********/	

foreach ($_FILES[ 'locationimages' ][ 'name' ] as $location_filename ) {
$location = mysqli_query($con, "select max(locationid) as locationmaxid from   tbl_property_location");
$location1 = mysqli_fetch_array($location);
$locationnew_id = $location1['locationmaxid'] + 1; //10 fixed
$locationcountfiles = count($_FILES[ 'locationimages' ][ 'name' ]);
for ( $i = 0; $i < $locationcountfiles; $i++ ) { 
	$location_file_basename = substr( $location_filename, 0, strripos( $location_filename, '.' ) ); // strip extention
	$location_file_ext = substr( $location_filename, strripos( $location_filename, '.' ) ); // strip name
	$locationf1 = $locationnew_id . '-' . $i . $location_file_ext;

		if (( $location_file_ext != '.png' ) && ( $location_file_ext != '.jpg' ) && ( $location_file_ext != '.jpeg' ) && ( $location_file_ext != '.gif' ) )
			throw new Exception( "Only jpg, jpeg, png and gif format images are allowed to upload." );
		if ( move_uploaded_file( $_FILES[ 'locationimages' ][ 'tmp_name' ][ $i ], '../images/propertylocation/' . $locationf1) ) {
			$lastid=mysqli_query($con,"SELECT max(propertyid) as pid FROM tbl_property");
$pid1=mysqli_fetch_array($lastid);
			$pid=$pid1['pid'];
			mysqli_query( $con, "INSERT INTO  tbl_property_location (property,image,status) VALUES ('$pid','$locationf1',1)" );
		}
	}

}
/****** End Location Gallery Images  ********/   
	

 $message = "Item Added Successfully";
}
if($_REQUEST['mode']=="edit"){
	
$ppty=$_GET['contentid'];
$title=$_POST['title'];
$name=$_POST['propertyname'];
$category=$_POST['category'];	
$category1=$_POST['category1'];
$propertytype=$_POST['propertytype'];
$price=$_POST['price'];
$area=$_POST['area'];
$bedrooms=$_POST['bedrooms'];
$bathrooms=$_POST['bathrooms'];
$kitchen=$_POST['kitchen'];
$garage=$_POST['garage'];
$city=$_POST['city'];
$location=$_POST['location'];
$view=$_POST['view'];
$pstatus=$_POST['status'];
$ppty_id=$_POST['propertyid'];
$rera=$_POST['rera'];
$description=$_POST['editor1'];
$latitude=$_POST['latitude'];
$longitude=$_POST['longitude'];
mysqli_query( $con, "update tbl_property set title='$title', name='$name',category='$category',category1='$category1',type='$propertytype',price='$price',area='$area',bedrooms='$bedrooms',bathrooms='$bathrooms',kitchen='$kitchen',garage='$garage',city='$city',location='$location',view='$view',status='$pstatus',property_id='$ppty_id',rerapermit='$rera',description='$description',latitude='$latitude',longitude='$longitude' where propertyid='$ppty'" );

	
	
	
	
$gal_id=$_POST['oldimageid'];
	$image = $_FILES['image']['name'];
if($gal_id=='' && $image!='') 
{
$ppty=$_GET['contentid'];
$message=mysqli_query($con,"insert into tbl_property_imagegallery(property,image,status) values('$ppty','',2)");
$sel_max=mysqli_query($con,"select max(galleryid) as maxslider from tbl_property_imagegallery");
$res_max=mysqli_fetch_array($sel_max);
$mid=$res_max['maxslider'];

$extension = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION);
$newname= "image-".$mid.".".$extension;
$image = $_FILES['image']['name'];
$target = "../images/propertygallery/".$newname;
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
mysqli_query($con,"update tbl_property_imagegallery set image='$newname' where galleryid='$mid'");
}
}
	
	$image = $_FILES['image']['name'];
	if($gal_id!='' && $image!='')
	{
	$oldimage=$_POST['oldimage'];
	$image = $_FILES['image']['name'];
	if($image!=''){
	$extension = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION);
    $newname= "image-".$gal_id.".".$extension;
  	$target = "../images/propertygallery/".$newname;
 
  	echo $sql = "update  tbl_property_imagegallery set image='$newname' where galleryid=$gal_id";
  	mysqli_query($con, $sql); 
 
  	if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
  	$msg = "Image uploaded successfully";
  	}else{
  	//$msg = "Failed to upload image";
  	}
	}
	}
	
	/******* Start Amenities *************/
$checkbox2=$_POST['amenities'];  
  $ppty=$_GET['contentid'];
	   mysqli_query($con,"delete from tbl_property_amenities where property='$ppty'");
foreach($checkbox2 as $chk2)  
   {  
	 $ppty=$_GET['contentid'];
	   
     mysqli_query($con,"insert into tbl_property_amenities(property,amenities,status) values($ppty,'$chk2',1)");  
   }  

/******** End Amenities *************/
	
			
	
/****** Start Upload Gallery Images  ********/	


foreach ( $_FILES[ 'galleryimages' ][ 'name' ] as $up_filename1 ) {
$statement = mysqli_query( $con, "select max(galleryid) as maxid from  tbl_property_imagegallery");

$stsmt = mysqli_fetch_array( $statement );
$new_id = $stsmt[ 'maxid' ] + 1; //10 fixed
	$countfiles = count( $_FILES[ 'galleryimages' ][ 'name' ] );
	for ( $i = 0; $i < $countfiles; $i++ ) {
		//$up_filename=$_FILES["attached"]["name"];
		$file_basename = substr( $up_filename1, 0, strripos( $up_filename1, '.' ) ); // strip extention
		$file_ext = substr( $up_filename1, strripos( $up_filename1, '.' ) ); // strip name
		$f1 = $new_id . '-' . $i . $file_ext;

		if ( ( $file_ext != '.png' ) && ( $file_ext != '.jpg' ) && ( $file_ext != '.jpeg' ) && ( $file_ext != '.gif' ) )
			throw new Exception( "Only jpg, jpeg, png and gif format images are allowed to upload." );

		if ( move_uploaded_file( $_FILES[ 'galleryimages' ][ 'tmp_name' ][ $i ], '../images/propertygallery/' . $f1 ) ) {
			
			$pid=$_GET['contentid'];
			mysqli_query( $con, "INSERT INTO tbl_property_imagegallery (property,image,status) VALUES ('$pid','$f1',1)" );
			
		}
	}

}  
/****** End Upload Gallery Images  ********/      
	
	
	
	
/****** Start Layout Gallery Images  ********/	
  if(!empty($_FILES['layoutimages']['tmp_name'])){
foreach ( $_FILES[ 'layoutimages' ][ 'name' ] as $layout_filename ) {
$layout = mysqli_query($con, "select max(layoutid) as layoutmaxid from  tbl_property_layout");
$layout1 = mysqli_fetch_array($layout);
$layoutnew_id = $layout1[ 'layoutmaxid' ] + 1; //10 fixed
$layoutcountfiles = count($_FILES[ 'layoutimages' ][ 'name' ]);
for ( $i = 0; $i < $layoutcountfiles; $i++ ) { 
	$layout_file_basename = substr( $layout_filename, 0, strripos( $layout_filename, '.' ) ); // strip extention
	$layout_file_ext = substr( $layout_filename, strripos( $layout_filename, '.' ) ); // strip name
	$layoutf1 = $layoutnew_id . '-' . $i . $layout_file_ext;

		if (( $layout_file_ext != '.png' ) && ( $layout_file_ext != '.jpg' ) && ( $layout_file_ext != '.jpeg' ) && ( $layout_file_ext != '.gif' ) )
			throw new Exception( "Only jpg, jpeg, png and gif format images are allowed to upload." );

		if ( move_uploaded_file( $_FILES[ 'layoutimages' ][ 'tmp_name' ][ $i ], '../images/propertylayout/' . $layoutf1) ) {
			$pid=$_GET['contentid'];
			mysqli_query( $con, "INSERT INTO tbl_property_layout (property,image,status) VALUES ('$pid','$layoutf1',1)" );
		}
	}

}  }
/****** End Layout Gallery Images  ********/   
	
	
/****** Start Location Gallery Images  ********/	
  if(!empty($_FILES['locationimages']['tmp_name'])){
foreach ($_FILES[ 'locationimages' ][ 'name' ] as $location_filename ) {
$location = mysqli_query($con, "select max(locationid) as locationmaxid from   tbl_property_location");
$location1 = mysqli_fetch_array($location);
$locationnew_id = $location1['locationmaxid'] + 1; //10 fixed
$locationcountfiles = count($_FILES[ 'locationimages' ][ 'name' ]);
for ( $i = 0; $i < $locationcountfiles; $i++ ) { 
	$location_file_basename = substr( $location_filename, 0, strripos( $location_filename, '.' ) ); // strip extention
	$location_file_ext = substr( $location_filename, strripos( $location_filename, '.' ) ); // strip name
	$locationf1 = $locationnew_id . '-' . $i . $location_file_ext;

		if (( $location_file_ext != '.png' ) && ( $location_file_ext != '.jpg' ) && ( $location_file_ext != '.jpeg' ) && ( $location_file_ext != '.gif' ) )
			throw new Exception( "Only jpg, jpeg, png and gif format images are allowed to upload." );
		if ( move_uploaded_file( $_FILES[ 'locationimages' ][ 'tmp_name' ][ $i ], '../images/propertylocation/' . $locationf1) ) {
			$pid=$_GET['contentid'];
			mysqli_query( $con, "INSERT INTO  tbl_property_location (property,image,status) VALUES ('$pid','$locationf1',1)" );
		}
	}

} }

/****** End Location Gallery Images  ********/   
	
	$pid=$_GET['contentid'];
 $message = "Item updated Successfully";
	header("location: property-details.php?propertyid=".$pid);
	
	
}
	
}

if(isset($_REQUEST['deleteimg'])){ 
$app=$_POST['deletealll'];  
foreach($app as $chk1)  
{  
mysqli_query($con,"delete from tbl_property_imagegallery where galleryid='$chk1'");
}  
$cone=$_GET['contentid'];
header("location:property.php?mode=edit&contentid=".$cone."&start=1");
//header("location:http://localhost/nabeela/topnotchrealestate/admin/property.php");
}


if(isset($_REQUEST['deletelay'])){ 
$app=$_POST['deletealayout'];  
foreach($app as $chk1)  
{  
mysqli_query($con,"delete from  tbl_property_layout where layoutid='$chk1'");
}  
$cone=$_GET['contentid'];
header("location:property.php?mode=edit&contentid=".$cone."&start=1");
//header("location:http://localhost/nabeela/topnotchrealestate/admin/property.php");
}


if(isset($_REQUEST['deleteloc'])){ 
$app=$_POST['deletealocation'];  
foreach($app as $chk1)  
{  
mysqli_query($con,"delete from  tbl_property_location where locationid='$chk1'");
}  
$cone=$_GET['contentid'];
//header("location:http://localhost/nabeela/topnotchrealestate/admin/property.php");
header("location:property.php");
}
		
		?>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1><?php echo $maintitle;?></h1>
      <ol class="breadcrumb">
        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> <?php echo AL_DASHBOARD;?></a></li>
        <li class="active"><?php echo $maintitle;?></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
    <?php
	if($mode=="add" || $mode=="edit"){ 
	?>
     <div class="row">
 <!-- Add / Edit / Delete --> 
          <div class="col-sm-12"> 
          <div class="box box-success">
         <div class="box-header">
              <i class="fa fa-building-o"></i>
              <h3 class="box-title"><?php echo $maintitle;?></h3>
              <div class="box-tools pull-right">
                <div class="btn-group">
                <a href="<?php echo $page;?>"><button class="btn btn-danger btn-flat">&nbsp; <?php echo AL_LISTALL;?> <?php echo $maintitle;?></button></a>
                   
                </div>
              </div>
            </div> 
            </div> 
            </div>

 <!-- Add / Edit / Delete --> 
<?php
if($mode=="edit"){
$contentid=$_GET['contentid'];
$cc=mysqli_query($con,"select * from  tbl_property where propertyid='$contentid'");
$contentdetails=mysqli_fetch_array($cc);
}
?>

     <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"> <?php echo AL_ADD;?> <?php echo $maintitle;?></h3>
            </div>
            
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-success btn-flat" type="button"><?php echo $message;?></button>
			<?php	
			}
			?>
             <div class="nav-tabs-custom">
             <ul class="nav nav-tabs">
             <li class="active"><a href="#activity" data-toggle="tab">Property Details</a></li>
             </ul>
            <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
            <div class="tab-content">
            <div class="active tab-pane" id="activity">
            <input type="hidden" name="mode" value="<?php echo $_REQUEST['mode'];?>"/>
              <div class="box-body"> 
               <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Property Title</label>
                  <div class="col-sm-8">
                    <input type="text"  name="title" value="<?php echo $contentdetails['title'];?>" class="form-control" id="groupname" placeholder="Property Title" >
                  </div>
                </div>                
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Property Name</label>
                  <div class="col-sm-8">
                    <input type="text"  name="propertyname" value="<?php echo $contentdetails['name'];?>" class="form-control" id="groupname" placeholder="Property Name">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Property For</label>
                  <div class="col-sm-2">
                  <input type="radio" name="category"  value="1" <?php if($contentdetails['category']==1) { ?>checked<?php }?>> Rent &nbsp;&nbsp;
                   <input type="radio" name="category"  value="2" <?php if($contentdetails['category']==2) { ?>checked<?php }?>> Sale
                  </div>
                  <label for="inputEmail3" class="col-sm-1 control-label" >Category</label>
                  <div class="col-sm-2" >
                   <select class="form-control" name="category1" onChange="getType(this.value);">
                          <option value="">Select Category</option>
                           <?php
		$sel_cat=mysqli_query($con,"select * from tbl_category1 where status=1");
				while($res_cat=mysqli_fetch_array($sel_cat)){							  
			    ?>
<option <?php if($res_cat['categoryid']==$contentdetails['category1']){ echo "selected"; } ?> value="<?php  echo $res_cat['categoryid'];?>">
<?php  echo $res_cat['title'];?></option>                              
<?php
}
?>                         
                          
                        </select>
                  </div>
                  <label for="inputEmail3" class="col-sm-1 control-label">Type</label>
                  <div class="col-sm-2">
                    <select class="form-control" name="propertytype" id="type-list">
                         
                                    <?php
		if($mode=="edit"){
$sel_type=mysqli_query($con,"select * from tbl_property_type where propertytypeid = '".$contentdetails["type"]."'");
while($res_type=mysqli_fetch_array($sel_type)){							  
?>
<option <?php if($res_type['propertytypeid']==$contentdetails['type']){ echo "selected"; } ?> value="<?php  echo $res_type['propertytypeid'];?>"><?php  echo $res_type['title'];?></option>                              
<?php
} }
?>    
                          
                        </select>
                  </div>
                </div>
              
                <div class="form-group">
                  
                   <label for="inputEmail3" class="col-sm-3 control-label">Price</label>
                  <div class="col-sm-2">
                   <input type="text"  name="price" value="<?php echo $contentdetails['price'];?>" class="form-control"  placeholder="Price" >
                  </div>
                    <label for="inputEmail3" class="col-sm-1 control-label">Area</label>
                  <div class="col-sm-2">
                    <input type="text"  name="area" value="<?php echo $contentdetails['area'];?>" class="form-control" id="pobox" placeholder="sqft" >
                  </div>
                  <label for="inputEmail3" class="col-sm-1 control-label" id="kitchen1">Bedrooms</label>
                  <div class="col-sm-2" id="kitchen2">
                  <!--  <input type="text"  name="bedrooms" value="<?php echo $contentdetails['bedrooms'];?>" class="form-control" placeholder="Bedrooms" >-->
                    <select name="bedrooms" class="form-control">
                  <?php if($mode=="edit"){?>  <option value="<?php echo $contentdetails['bedrooms'];?>" selected><?php echo $contentdetails['bedrooms'];?></option>
                   <?php } else {?>
                    <option value="" selected="selected">Select Bedrooms</option> <?php } ?>
                     <option value="0">Studio</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                    
                  </select>
                  </div>
                </div>
              
               
                <div class="form-group" id="kitchen">
                  <label for="inputEmail3" class="col-sm-3 control-label">Bathrooms</label>
                  <div class="col-sm-2">
                    <input type="text"  name="bathrooms" value="<?php echo $contentdetails['bathrooms'];?>" class="form-control"  placeholder="Bathrooms">
                  </div>
                  <label for="inputEmail3" class="col-sm-1 control-label">Kitchen</label>
                  <div class="col-sm-2">
                    <input type="text"  name="kitchen" value="<?php echo $contentdetails['kitchen'];?>" class="form-control"  placeholder="Kitchen" >
                  </div>
                  <label for="inputEmail3" class="col-sm-1 control-label">Parking</label>
                  <div class="col-sm-2">
                    <input type="text" name="garage" value="<?php echo $contentdetails['garage'];?>" class="form-control" id="fax" placeholder="Garage">
                  </div>
                </div>
             
               
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">City</label>
                  <div class="col-sm-2">
                    <select class="form-control"  name="city" onChange="getLocation(this.value);">
                    <option value="" selected="selected">Select City</option>
                   
						<?php
         $sel_city=mysqli_query($con,"SELECT * FROM tbl_city");
         while($res_city=mysqli_fetch_array($sel_city)) { 
        ?>
        <option <?php if($res_city['cityid']==$contentdetails['city']){ echo "selected"; }?> value="<?php echo $res_city['cityid']; ?>"><?php echo $res_city['city']; ?></option>
        <?php
        }
        ?>
                  </select>

                  </div>
                  <label for="inputPassword3" class="col-sm-1 control-label">Location</label>
                  <div class="col-sm-2">
                   <select class="form-control"  name="location" id="location-list">
                    <?php
if($mode=="edit"){
$sel_location=mysqli_query($con,"SELECT * FROM tbl_location WHERE locationid = '".$contentdetails["location"]."'");

?>
<option>Select Location</option>
<?php
 while($res_location=mysqli_fetch_array($sel_location)) {
?>
 <option value="<?php echo $res_location['locationid']; ?>" selected><?php echo $res_location['location']; ?></option>
<?php
} }
?>
       </select>

                  </div>
                  
                  <label for="inputPassword3" class="col-sm-1 control-label">View</label>
                  <div class="col-sm-2">
                   <input type="text" name="view" value="<?php echo $contentdetails['view'];?>" class="form-control"  placeholder="view" >
                  </div>
                </div>
                
                
                <div class="form-group">
                  
                   <label for="inputEmail3" class="col-sm-3 control-label">Status</label>
                  <div class="col-sm-2">
                   <input type="text"  name="status" value="<?php echo $contentdetails['status'];?>" class="form-control"  placeholder="Status" >
                  </div>
                    <label for="inputEmail3" class="col-sm-1 control-label">Property Id</label>
                  <div class="col-sm-2">
                    <input type="text"  name="propertyid" value="<?php echo $contentdetails['property_id'];?>" class="form-control" placeholder="Property Id" >
                  </div>
                  <label for="inputEmail3" class="col-sm-1 control-label" >RERA PERMIT</label>
                  <div class="col-sm-2" >
                    <input type="text"  name="rera" value="<?php echo $contentdetails['rerapermit'];?>" class="form-control" placeholder="RERA PERMIT">
                  </div>
                </div>
                
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Description</label>
                  <div class="col-sm-8">
                   <textarea name="editor1" class="form-control" rows="5"><?php echo $contentdetails['description'];?></textarea>
                 </div>
                </div>
                
              <hr>
                <!--<div class="form-group">
				 <?php
			if($contentdetails[0]['image']!=""){
			?>
              <img class="profile-user-img img-responsive img-circle" src="<?php echo $site_url;?>thumb.php?src=<?php echo $site_url;?>images/company/<?php echo $contentdetails[0]['image'];?>&w=160&h=160" alt="<?php echo $contentdetails[0]['firstname'];?>">
              <?php
			} else {
			?>
             <img class="profile-user-img img-responsive img-circle" src="<?php echo $site_url;?>thumb.php?src=<?php echo $site_url;?>images/no-image.jpg&w=160&h=160" alt="<?php echo $contentdetails[0]['firstname'];?>">
            <?php
			}
			?>
            </div>-->
              <div class="form-group" id="amenity">
              <label for="inputEmail3" class="col-sm-3 control-label">Amenities</label>
              <div class="col-sm-8">
              <?php
			  
					  
					 $sel_amenities=mysqli_query($con,"select * from tbl_amenities");
				while($res_amenities=mysqli_fetch_array($sel_amenities)) {
					$amid=$res_amenities['amenitiesid'];
					  $sel_am_ppty=mysqli_query($con,"select * from  tbl_property_amenities where property= '".$_GET['contentid']."' and amenities=$amid");
				 $res_am=mysqli_fetch_array($sel_am_ppty);
			    ?>
                <input type="checkbox" name="amenities[]" <?php if($res_amenities['amenitiesid']==$res_am['amenities']){ echo "checked"; } ?> value="<?php  echo $res_amenities['amenitiesid'];?>"> <?php  echo $res_amenities['title'];?>  &nbsp;&nbsp;&nbsp; 
                 <?php }  ?>         
                  </div>
                </div>
                <hr>
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Gallery image (740 x 436)</label>
                  <div class="col-sm-2">
                     <input type="file" class="" name="image" >
                  </div>
                  <?php    if($mode=="edit"){ 
					 $sel_img_gal=mysqli_query($con,"select * from  tbl_property_imagegallery where status='2' and property= '".$_GET['contentid']."'");
					$res_img_gal=mysqli_fetch_array($sel_img_gal);
					 ?>
                  <input type="hidden" value="<?php echo $res_img_gal['galleryid'];?>" name="oldimageid">
                   <input type="hidden" value="<?php echo $res_img_gal['image'];?>" name="oldimage">
                    <img src="../images/propertygallery/<?php echo $res_img_gal['image'];?>" style="    width: 8%;">
                    <?php } ?>
                </div>
                <hr>
                <form method="post">
               <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Gallery images (740 x 436)</label>
                
                  
                  <div class="col-sm-2">
                     <input type="file" class="" name="galleryimages[]" multiple>
                <?php   $sel_img_gal=mysqli_query($con,"select * from  tbl_property_imagegallery where status!='2' and property= '".$_GET['contentid']."'");
		 $nn=mysqli_num_rows($sel_img_gal);
		if($nn>=1){
			?> 
                
                  	<button class="del" type="submit" name="deleteimg">Delete</button>
                  
                  <?php }  ?>
                  </div>
                  <div class="col-sm-7">
                   <?php 
		if($mode=="edit"){ 
					 $sel_img_gal=mysqli_query($con,"select * from  tbl_property_imagegallery where status!='2' and property= '".$_GET['contentid']."'");
					while($res_img_gal=mysqli_fetch_array($sel_img_gal)) {
					 ?>
                 
                    
                    
                     <div class="col-sm-3" style="text-align: center; margin-bottom: 5px; ">
                    <input type="checkbox" name="deletealll[]" value="<?php echo $res_img_gal['galleryid'];?>">  <img src="../images/propertygallery/<?php echo $res_img_gal['image'];?>" style="width: 93px; height: 62px">
                    <!-- <br>
                   <a href="property.php?mode=deleteimg&imgid=<?php echo $res_img_gal['galleryid'];?>&contentid=<?php echo $_GET['contentid'];?>" ><i class="fa fa-times" aria-hidden="true"></i></a>-->
                     </div>
                    <?php } } ?>
                  </div>
				  </div>
                </form>
                 <hr>
              
                  <form method="post" style="display:none;">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Location (500 x 335)</label>
                  <div class="col-sm-2">
                    <input type="file" class="" name="locationimages[]" multiple>
                     
                     <?php     $sel_loc=mysqli_query($con,"select * from  tbl_property_location where  property= '".$_GET['contentid']."'");
		 $nn=mysqli_num_rows($sel_loc);
		if($nn>=1){
			?>
                 	
                  	<input type="hidden" value="<?php echo $_GET['contentid'];?>">
                  	<button class="del" type="submit" name="deleteloc">Delete</button>
                 
                  <?php }  ?>
                  </div>
                   <div class="col-sm-7">
                  <?php    if($mode=="edit"){ 
					 $sel_loc=mysqli_query($con,"select * from  tbl_property_location where  property= '".$_GET['contentid']."'");
					while($res_loc=mysqli_fetch_array($sel_loc)) {
					 ?>
                 
                    
                    <div class="col-sm-3" style="text-align: center; margin-bottom: 15px;">
                    <input type="checkbox" name="deletealocation[]" value="<?php echo $res_loc['locationid'];?>"> 
                    <img src="../images/propertylocation/<?php echo $res_loc['image'];?>"  style="width: 93px; height: 62px">
                   <!-- <br>
                    <a href="property.php?mode=deleteloc&imgid=<?php echo $res_loc['locationid'];?>&contentid=<?php echo $_GET['contentid'];?>" ><i class="fa fa-times" aria-hidden="true"></i></a>-->
                     </div>
                    <?php } } ?>
                  </div>
                </div>
                 </form>
				  <label for="inputEmail3" class="col-sm-2 control-label" style="display:none;">Latitude</label>
                  <div class="col-sm-3" style="display:none;">
					  <input type="text" name="latitude" id="lat" value="<?php echo $contentdetails['latitude'];?>" ></div>
           <label for="inputEmail3" class="col-sm-2 control-label" style="display:none;">Longitude</label>
                  <div class="col-sm-3" style="display:none;">
					  <input type="text" name="longitude" id="lng" value="<?php echo $contentdetails['longitude'];?>" ></div>
					  <hr>
               <div id="map" style="display:none;"></div>
               
               
               
              </div>
              </div>
                <?php /* ?>
              <div class="tab-pane" id="timeline">
                                <div class="box-body">
                                     <div class="form-group">                  
                                          <div class="col-sm-12">
                                               <div class="table-responsive"> 
                                                <table class="table table-bordered" id="dynamic_fields"> 
                                                 <tr>  
                                                         <td><b>Name</b></td>    
                                                         <td><b>Position</b></td> 
                                                         <td><b>Function Areas</b></td>
                                                         <td><b>Email ID</b></td> 
                                                         <td><b>Phone</b></td>
                                                 </tr>
                                                 <?php
							 $k=300;
							$formfields = $helper->select("tbl_group_contacts","*",array("groupid"=>$contentdetails[0]['groupid']));
							 
							if(count($formfields)>0){
								foreach($formfields as $formfield){
							?>
                            <tr id="rowa<?php echo $k;?>">   
                           <td><input  type="text" name="name[]" value="<?php echo $formfield['name'];?>" placeholder="Student Name" class="form-control name_list" /></td>    
                           <td><input id="<?php echo $k;?>" type="text" name="position[]" value="<?php echo $formfield['position'];?>" placeholder="Position" class="form-control name_list emiratesid" /></td> 
                           <td><input type="text" name="functionarea[]" value="<?php echo $formfield['functionarea'];?>" placeholder="Function Afrea" class="form-control name_list" /></td>
                           <td><input type="text" name="contactemail[]" value="<?php echo $formfield['contactemail'];?>" placeholder="Email Id" class="form-control name_list" /></td> 
                           <td><input type="text" name="contactphone[]" value="<?php echo $formfield['contactphone'];?>" placeholder="Phone" class="form-control name_list" /></td>
                           <td><button type="button" name="remove" id="<?php echo $k;?>" class="btn btn-danger btn_removes">X</button></td>  
                                    </tr>
                            <?php
							 $k=$k+1;
							}
							  }
							  ?>
                                                  <tr>  
                                                 <td><input  type="text" name="name[]" placeholder="Name" class="form-control name_list" /></td>    
                                                 <td><input type="text" name="position[]" placeholder="Position" class="form-control name_list emiratesid" id="0" /></td> 
                                                 <td><input type="text" name="functionarea[]" placeholder="Function Area" class="form-control name_list" /></td>
                                                 <td><input type="text" name="contactemail[]" placeholder="Email Id" class="form-control name_list" /></td> 
                                                 <td><input type="text" name="contactphone[]" placeholder="Phone" class="form-control name_list" /></td>
                                                 <td><button  type="button" name="add" id="adds" class="btn btn-success">Add More</button> 
                                                 </td>  
                                                 </tr>  
                                                 </table> 
                                               </div>                                               
                                           </div>
                                       </div>
                                 </div>
                      </div>
                <?php */ ?>
              <!-- /.box-body -->
              <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" name="submit" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-right"/>
                 
              </div>
              <!-- /.box-footer -->
              </div>
            </form>
              <script type="text/javascript" src="map.js"></script>
             
          </div>
         
        </div>
        </div>
        <?php
	    }
		else {
	    ?>
        <?php
		if($mode=="delete"){
			 $ff=$_GET['contentid'];
			//echo("delete from tbl_property  where propertyid=$ff");
			mysqli_query($con,"delete from tbl_property  where propertyid=$ff");
			mysqli_query($con,"delete from tbl_property_imagegallery  where property='$ff'");
			mysqli_query($con,"delete from  tbl_property_layout  where property='$ff'");
			mysqli_query($con,"delete from  tbl_property_location  where property='$ff'");
			mysqli_query($con,"delete from  tbl_property_amenities  where property='$ff'");
			header("location: property.php");
		}
		?>
          <?php
		if($mode=="approve"){
			$ff=$_GET['contentid'];
			mysqli_query($con,"update tbl_property set statuss=0 where propertyid=$ff");
			header("location: property.php");exit();
		}
		?>
         <?php
		if($mode=="pending"){
			$ff=$_GET['contentid'];
			mysqli_query($con,"update tbl_property set statuss=1 where propertyid=$ff");
			header("location: property.php");exit();
		}
		
		?>
        <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right">
                <div class="btn-group">           
                <div class="searchbox">
                <form action="" method="post"><input type="text" name="search" class="searchtext" placeholder="Search"/>
                <button class="btn btn-danger btn-flat searchbtn" name="searchppty" type="submit"><i class="glyphicon  glyphicon-search"></i>&nbsp;Search</button>
                </form>
                </div>
         <a href="<?php echo $page;?>?mode=add"><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i>&nbsp;<?php echo AL_ADDNEW;?> <?php echo $maintitle;?></button></a>
 </div>
              </div>
            </div>
          
            <?php
			if($search!=""){
				$ss=$_POST['search'];
				
			$listtypes=mysqli_query($con,"select * from tbl_property where name like '%$ss%' or property_id like '%$ss%'");
			} else {
		//	$listtypes=$helper->selectlimit($table,"*",array(),$start,$limit);
				$listtypes=mysqli_query($con,"select * from tbl_property ");
			}
			?>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
          
             <form method="post" action="approve-action.php">
              <table class="table table-hover">
                <tr>
                  <th width="25"><?php echo AL_SERIALNO;?></th>
                  <th width="99">Category</th>
                  <th width="79">For</th>
                  <th width="294">Property Name</th>
                  <th width="162">Property ID</th>
<!--
                  <th width="222"><?php echo AL_STATUS;?><br>
                  <input type="submit" name="approve" value="APPROVE" style="background: #00a65a;border: none;font-size: 14px;">
                  <input type="submit" name="disapprove" value="DISAPPROVE" style="background: #e7b600;border: none;font-size: 14px;">
                  </th>
-->
                  <th width="178">Show/Hide<br>
                  <input type="submit" name="show" value="Show" style="background: #00a65a;border: none;font-size: 14px;">
                  <input type="submit" name="hide" value="Hide" style="background: #e7b600;border: none;font-size: 14px;">
                  </th>
                  <th width="222"><?php echo AL_ACTION;?></th>
                </tr>
                <?php
				$i=($start*$limit)+1;
				while($type=mysqli_fetch_array($listtypes)){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                   //$valexist=$helper->datapresent($table,"parent_id",$type[$field_id]);
				   $valexist2=$helper->datapresent("tbl_members","typeid",$type[$field_id]);
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  <td><?php $cat1=$type['category1']; $sel_cat1=mysqli_query($con,"select * from tbl_category1 where categoryid='$cat1'");
					  $res_cat1=mysqli_fetch_array($sel_cat1); echo $res_cat1['title'];?></td>
                  <td><?php $cat11=$type['category']; $sel_cat11=mysqli_query($con,"select * from tbl_category where categoryid='$cat11'");
					  $res_cat11=mysqli_fetch_array($sel_cat11); echo $res_cat11['title'];?></td>
                 <td><?php echo $type['name'];?></td>
                 <td><?php echo $type['property_id'];?></td>
<!--
                  <td>
                  
                  <?php
				  if($type['statuss']==0){
				  ?>  <input type="checkbox" name="approve[]"  value="<?php  echo $type['propertyid'];?>">
<a href="<?php echo $admin_url;?><?php echo $page;?>?mode=pending&contentid=<?php echo $type['propertyid'];?>&start=<?php echo $limitpage; ?>"><span class="label label-success">      Active</span></a>
                  <?php
				  }
				  else {
				  ?>
				  <input type="checkbox" name="approve[]"  value="<?php  echo $type['propertyid'];?>">
				  <a href="<?php echo $admin_url;?><?php echo $page;?>?mode=approve&contentid=<?php echo $type['propertyid'];?>&start=<?php echo $limitpage; ?>"><span class="label label-danger"> Deactivate</span></a>
                  <?php
				  }
				  ?>
                  </td>
-->
                <td>
                  
                  <?php
				  if($type['showppty']==1){
				  ?>  <input type="checkbox" name="show[]"  value="<?php  echo $type['propertyid'];?>">
<a href="<?php echo $admin_url;?><?php echo $page;?>?mode=pending&contentid=<?php echo $type['propertyid'];?>&start=<?php echo $limitpage; ?>"><span class="label label-danger">      Hide</span></a>
                  <?php
				  }
				  else {
				  ?>
				  <input type="checkbox" name="show[]"  value="<?php  echo $type['propertyid'];?>">
				  <a href="<?php echo $admin_url;?><?php echo $page;?>?mode=approve&contentid=<?php echo $type['propertyid'];?>&start=<?php echo $limitpage; ?>"><span class="label label-success"> Show</span></a>
                  <?php
				  }
				  ?>
                  </td>
                  <td>
                  
                  <a href="<?php echo $admin_url;?>property-details.php?propertyid=<?php echo $type[$field_id];?>"><span class="label label-primary" style="background-color: #dd4b39!important;"><i class="fa fa-search" aria-hidden="true"></i> View</span></a>
                  
                  <a href="<?php echo $admin_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                  <?php
				  if($valexist2==0){
				  ?>
                   <a href="<?php echo $admin_url;?><?php echo $page;?>?mode=delete&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>" onclick="return getConfirmation()"><span class="label label-danger"><i class="fa fa-times"></i> <?php echo AL_DELETE;?></span></a>
                   <?php
				  }
				  ?>
                   </td>
                </tr>
                  
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
              </form>
              <?php
			if($search!=""){
				$counter_list= $helper->countofsearch($table,array("companyname"=>$search),$limit,array("status"=>"ASC"));
			 
			} else {
			 $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			}
			?>
              <?php  //include('pagination/pagination.php'); ?>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
      <?php
		}
		?>

    </section>
    <!-- /.content -->
  </div>
  <script>
  CKEDITOR.replace( 'editor1' );
  </script>
<?php include('footer.php');  ?>