<?php $propertyId = $_GET['id'] ? $_GET['id'] : header("Location: ?pagecontent=properties"); ?>
<div class="right_col" role="main">
    <div class="">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
					<div class="x_title">
						<h2>Property Detail</h2>
						<div class="clearfix"></div>
					</div>
					<div class="x_content">

						<form class="form-horizontal form-label-left" method="post">

							
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomno">Title <span class="required">*</span></label>
								<div class="col-md-4 col-sm-3 col-xs-12">
									<input id="roomno" class="form-control col-md-7 col-xs-12" name="title" type="text" value="<?php echo getDetailByTable('properties',$propertyId)['pty_title']; ?>">
								</div>
							</div>
							
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomno">Short<span class="required">*</span></label>
								<div class="col-md-4 col-sm-3 col-xs-12">
									<input id="roomno" class="form-control col-md-7 col-xs-12" name="short" type="text" value="<?php echo getDetailByTable('properties',$propertyId)['pty_short']; ?>">
								</div>
							</div>
							
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomno">Code<span class="required">*</span></label>
								<div class="col-md-4 col-sm-3 col-xs-12">
									<input id="roomno" class="form-control col-md-7 col-xs-12" name="code" type="text" value="<?php echo getDetailByTable('properties',$propertyId)['pty_code']; ?>">
								</div>
							</div>
							
						
							<div class="ln_solid"></div>
							<div class="form-group">
								<div class="col-md-6 col-md-offset-3">
									<button id="send" type="submit" name="submit" class="btn btn-success">Add</button>
								</div>
							</div>
						</form>
					</div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php

	if(isset($_POST['submit']))
	{
		$postTitle = $_POST['title'];
		$postShort = $_POST['short'];
		$postCode = $_POST['code'];
		$adminId = $_SESSION['admin'][0];
		
		mysqli_query($conn, "UPDATE properties SET pty_title='$postTitle',pty_short='$postShort',pty_code='$postCode', a_id=$adminId WHERE pty_id=$propertyId");
		
		header('Location: ?pagecontent=properties');
		
		//TELEGRAM NOTIFICATION
		$adminUsername = $_SESSION['admin'][1];
		
$messaggio = "PROPERTY UPDATED BY ".$adminUsername."

Title : ".$postTitle."
Short : ".$postShort."
Code : ".$postCode."

".$ipAddress;

sendMessage($chatID, $messaggio, $token);
	}
?>