-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_tenant.php
82 lines (80 loc) · 2.86 KB
/
manage_tenant.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
include 'db_connect.php';
if(isset($_GET['id'])){
$qry = $conn->query("SELECT * FROM tenants where id= ".$_GET['id']);
foreach($qry->fetch_array() as $k => $val){
$$k=$val;
}
}
?>
<div class="container-fluid">
<form action="" id="manage-tenant">
<input type="hidden" name="id" value="<?php echo isset($id) ? $id : '' ?>">
<div class="row form-group">
<div class="col-md-4">
<label for="" class="control-label">Last Name</label>
<input type="text" class="form-control" name="lastname" value="<?php echo isset($lastname) ? $lastname :'' ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">First Name</label>
<input type="text" class="form-control" name="firstname" value="<?php echo isset($firstname) ? $firstname :'' ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">Middle Name</label>
<input type="text" class="form-control" name="middlename" value="<?php echo isset($middlename) ? $middlename :'' ?>">
</div>
</div>
<div class="form-group row">
<div class="col-md-4">
<label for="" class="control-label">Email</label>
<input type="email" class="form-control" name="email" value="<?php echo isset($email) ? $email :'' ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">Contact #</label>
<input type="text" class="form-control" name="contact" value="<?php echo isset($contact) ? $contact :'' ?>" required>
</div>
</div>
<div class="form-group row">
<div class="col-md-4">
<label for="" class="control-label">House</label>
<select name="house_id" id="" class="custom-select select2">
<option value=""></option>
<?php
$house = $conn->query("SELECT * FROM houses where id not in (SELECT house_id from tenants where status = 1) ".(isset($house_id)? " or id = $house_id": "" )." ");
while($row= $house->fetch_assoc()):
?>
<option value="<?php echo $row['id'] ?>" <?php echo isset($house_id) && $house_id == $row['id'] ? 'selected' : '' ?>><?php echo $row['house_no'] ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="col-md-4">
<label for="" class="control-label">Registration Date</label>
<input type="date" class="form-control" name="date_in" value="<?php echo isset($date_in) ? date("Y-m-d",strtotime($date_in)) :'' ?>" required>
</div>
</div>
</form>
</div>
<script>
$('#manage-tenant').submit(function(e){
e.preventDefault()
start_load()
$('#msg').html('')
$.ajax({
url:'ajax.php?action=save_tenant',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success:function(resp){
if(resp==1){
alert_toast("Data successfully saved.",'success')
setTimeout(function(){
location.reload()
},1000)
}
}
})
})
</script>