<div class="right_col" role="main">
	<div class="">
		<div class="page-title">
			<div class="title_left">
				<table>
					<tr>
						<td width="150px"><h3>Property list</h3></td>
						<td><a href="index.php?pagecontent=property_new"><button type="button" class="btn btn-dark">Add Property</button></a></td>
					</tr>
				</table>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="row">
			<div class="col-md-12 col-sm-12 col-xs-12">
				<div class="x_panel">
					<div class="x_content">
						<table id="datatable" class="table table-striped table-bordered">
							<thead>
								<tr>
									<th>Title</th>
									<th>Short</th>
									<th>Code</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$result=mysqli_query($conn, "SELECT * FROM properties") or die (mysql_error());
									while($row = mysqli_fetch_array($result))
									{
                                        // if(filterPropertyAdmin($row['pty_id'],$_SESSION['admin'][0])==true){continue;};
                                        
										$rid = $row['pty_id'];
								?>
								<tr>
									<td><?php echo $row['pty_title'];?></td>
									<td><?php echo $row['pty_short'];?></td>
									<td><?php echo $row['pty_code'];?></td>
						
									<td>
										<a href="?pagecontent=property_update&id=<?php echo $row['pty_id']; ?>"><button class="btn btn-xs btn-primary">Update</button></a>
										
										<a href="?pagecontent=properties&remove=<?php echo $row['pty_id']; ?>"><button class="btn btn-xs btn-danger">Remove</button></a>
									</td>
								</tr>
								<?php
									}
								?>
						</table>
					</div>
				</div>
			</div>
        </div>
    </div>
</div>

<?php
	if(isset($_REQUEST['remove'])){
		$propertyId = $_REQUEST['remove']; 
		
				//TELEGRAM NOTIFICATION
		$adminUsername = $_SESSION['admin'][1];
		
$messaggio = "PROPERTY REMOVED BY ".$adminUsername."

Title : ".getDetailByTable('properties',$propertyId)['pty_title']."
Short : ".getDetailByTable('properties',$propertyId)['pty_short']."
Code : ".getDetailByTable('properties',$propertyId)['pty_code']."

".$ipAddress;

sendMessage($chatID, $messaggio, $token);
		
		mysqli_query($conn,"DELETE FROM properties WHERE pty_id=$propertyId");
		header('Location: ?pagecontent=properties'); 
	}
?>