//manage_check_out.php
<?php
include('db_connect.php');
if($_GET['id']){
$id = $_GET['id'];
$qry = $conn->query("SELECT * FROM checked where id =".$id);
if($qry->num_rows > 0){
foreach($qry->fetch_array() as $k => $v){
$$k=$v;
}
}
if($room_id > 0){
$room = $conn->query("SELECT * FROM rooms where id =".$room_id)->fetch_array();
$cat = $conn->query("SELECT * FROM room_categories where id =".$room['category_id'])->fetch_array();
}else{
$cat = $conn->query("SELECT * FROM room_categories where id =".$booked_cid)->fetch_array();
}
$calc_days = abs(strtotime($date_out) - strtotime($date_in)) ;
$calc_days =floor($calc_days / (60*60*24) );
}
?>
<style>
.container-fluid p{
margin: unset
}
#uni_modal .modal-footer{
display: none;
}
</style>
<div class="container-fluid">
<p><b>ห้อง : </b><?php echo isset($room['room']) ? $room['room'] : 'NA' ?></p>
<p><b>ประเภท : </b><?php echo $cat['name'] ?></p>
<p><b>ราคา : </b><?php echo ''.number_format($cat['price'],2) ?> บาท</p>
<p><b>อ้างอิง : </b><?php echo $ref_no ?></p>
<p><b>ชื่อ : </b><?php echo $name ?></p>
<p><b>เบอร์โทรศัพท์ : </b><?php echo $contact_no ?></p>
<p><b>เช็คอิน วัน/เวลา : </b><?php echo date("M d, Y h:i ",strtotime($date_in)) ?></p>
<p><b>เช็คเอาท์ วัน/เวลา : </b><?php echo date("M d, Y h:i ",strtotime($date_out)) ?></p>
<p><b>จำนวน : </b><?php echo $calc_days ?> วัน</p>
<p><b>จำนวน (ราคา * วัน) : </b><?php echo ''.number_format($cat['price'] * $calc_days ,2) ?> บาท</p>
<div class="row">
<?php if(isset($_GET['checkout']) && $status != 2): ?>
<div class="col-md-3">
<button type="button" class="btn btn-primary" id="checkout">เช็คเอาท์</button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-primary" id="edit_checkin">แก้ไข</button>
</div>
<?php endif; ?>
<div class="col-md-3">
<button type="button" class="btn btn-secondary" data-dismiss="modal">ยกเลิก</button>
</div>
</div>
</div>
<script>
$(document).ready(function(){
})
$('#edit_checkin').click(function(){
uni_modal("แก้ไขข้อมูล","manage_check_in.php?id=<?php echo $id ?>&rid=<?php echo $room_id ?>")
})
$('#checkout').click(function(){
start_load()
$.ajax({
url:'ajax.php?action=save_checkout',
method:'POST',
data:{id:'<?php echo $id ?>',rid:'<?php echo $room_id ?>'},
success:function(resp){
if(resp ==1){
alert_toast("บันทึกสำเร็จ",'success')
setTimeout(function(){
location.reload()
},1500)
}
}
})
})
</script>
//check_out.php
<?php include('db_connect.php');
$cat = $conn->query("SELECT * FROM room_categories");
$cat_arr = array();
while($row = $cat->fetch_assoc()){
$cat_arr[$row['id']] = $row;
}
$room = $conn->query("SELECT * FROM rooms");
$room_arr = array();
while($row = $room->fetch_assoc()){
$room_arr[$row['id']] = $row;
}
?>
<div class="container-fluid">
<div class="col-lg-12">
<div class="row mt-3">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<table class="table table-bordered">
<thead>
<th><center>ลำดับ</th></center>
<th><center>ประเภท</th></center>
<th><center>ห้อง</th></center>
<th><center>อ้างอิง</th></center>
<th><center>สถานะ</th></center>
<th><center>จัดการ</th></center>
</thead>
<tbody>
<?php
$i = 1;
$checked = $conn->query("SELECT * FROM checked where status != 0 order by status desc, id asc ");
while($row=$checked->fetch_assoc()):
?>
<tr>
<td class="text-center"><?php echo $i++ ?></td>
<td class="text-center"><?php echo $cat_arr[$room_arr[$row['room_id']]['category_id']]['name'] ?></td>
<td class="text-center"><?php echo $room_arr[$row['room_id']]['room'] ?></td>
<td class="text-center"><?php echo $row['ref_no'] ?></td>
<?php if($row['status'] == 1): ?>
<td class="text-center"><span class="badge badge-warning">เช็คอิน</span></td>
<?php else: ?>
<td class="text-center"><span class="badge badge-success">เช็คเอาท์</span></td>
<?php endif; ?>
<td class="text-center">
<button class="btn btn-sm btn-primary check_out" type="button" data-id="<?php echo $row['id'] ?>">แสดง</button>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('table').dataTable()
$('.check_out').click(function(){
uni_modal("เช็คเอาท์","manage_check_out.php?checkout=1&id="+$(this).attr("data-id"))
})
$('#filter').submit(function(e){
e.preventDefault()
location.replace('index.php?page=check_in&category_id='+$(this).find('[name="category_id"]').val()+'&status='+$(this).find('[name="status"]').val())
})
</script>
มันขึ้น
Warning: Undefined array key 0 in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Undefined array key "" in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Undefined array key 0 in C:\xampp\htdocs\88\admin\check_out.php on line 37
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\88\admin\check_out.php on line 37
ผมพึ่งหัดเขียนโปรแกรมช่วยดูให้หน่อยครับ
<?php
include('db_connect.php');
if($_GET['id']){
$id = $_GET['id'];
$qry = $conn->query("SELECT * FROM checked where id =".$id);
if($qry->num_rows > 0){
foreach($qry->fetch_array() as $k => $v){
$$k=$v;
}
}
if($room_id > 0){
$room = $conn->query("SELECT * FROM rooms where id =".$room_id)->fetch_array();
$cat = $conn->query("SELECT * FROM room_categories where id =".$room['category_id'])->fetch_array();
}else{
$cat = $conn->query("SELECT * FROM room_categories where id =".$booked_cid)->fetch_array();
}
$calc_days = abs(strtotime($date_out) - strtotime($date_in)) ;
$calc_days =floor($calc_days / (60*60*24) );
}
?>
<style>
.container-fluid p{
margin: unset
}
#uni_modal .modal-footer{
display: none;
}
</style>
<div class="container-fluid">
<p><b>ห้อง : </b><?php echo isset($room['room']) ? $room['room'] : 'NA' ?></p>
<p><b>ประเภท : </b><?php echo $cat['name'] ?></p>
<p><b>ราคา : </b><?php echo ''.number_format($cat['price'],2) ?> บาท</p>
<p><b>อ้างอิง : </b><?php echo $ref_no ?></p>
<p><b>ชื่อ : </b><?php echo $name ?></p>
<p><b>เบอร์โทรศัพท์ : </b><?php echo $contact_no ?></p>
<p><b>เช็คอิน วัน/เวลา : </b><?php echo date("M d, Y h:i ",strtotime($date_in)) ?></p>
<p><b>เช็คเอาท์ วัน/เวลา : </b><?php echo date("M d, Y h:i ",strtotime($date_out)) ?></p>
<p><b>จำนวน : </b><?php echo $calc_days ?> วัน</p>
<p><b>จำนวน (ราคา * วัน) : </b><?php echo ''.number_format($cat['price'] * $calc_days ,2) ?> บาท</p>
<div class="row">
<?php if(isset($_GET['checkout']) && $status != 2): ?>
<div class="col-md-3">
<button type="button" class="btn btn-primary" id="checkout">เช็คเอาท์</button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-primary" id="edit_checkin">แก้ไข</button>
</div>
<?php endif; ?>
<div class="col-md-3">
<button type="button" class="btn btn-secondary" data-dismiss="modal">ยกเลิก</button>
</div>
</div>
</div>
<script>
$(document).ready(function(){
})
$('#edit_checkin').click(function(){
uni_modal("แก้ไขข้อมูล","manage_check_in.php?id=<?php echo $id ?>&rid=<?php echo $room_id ?>")
})
$('#checkout').click(function(){
start_load()
$.ajax({
url:'ajax.php?action=save_checkout',
method:'POST',
data:{id:'<?php echo $id ?>',rid:'<?php echo $room_id ?>'},
success:function(resp){
if(resp ==1){
alert_toast("บันทึกสำเร็จ",'success')
setTimeout(function(){
location.reload()
},1500)
}
}
})
})
</script>
//check_out.php
<?php include('db_connect.php');
$cat = $conn->query("SELECT * FROM room_categories");
$cat_arr = array();
while($row = $cat->fetch_assoc()){
$cat_arr[$row['id']] = $row;
}
$room = $conn->query("SELECT * FROM rooms");
$room_arr = array();
while($row = $room->fetch_assoc()){
$room_arr[$row['id']] = $row;
}
?>
<div class="container-fluid">
<div class="col-lg-12">
<div class="row mt-3">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<table class="table table-bordered">
<thead>
<th><center>ลำดับ</th></center>
<th><center>ประเภท</th></center>
<th><center>ห้อง</th></center>
<th><center>อ้างอิง</th></center>
<th><center>สถานะ</th></center>
<th><center>จัดการ</th></center>
</thead>
<tbody>
<?php
$i = 1;
$checked = $conn->query("SELECT * FROM checked where status != 0 order by status desc, id asc ");
while($row=$checked->fetch_assoc()):
?>
<tr>
<td class="text-center"><?php echo $i++ ?></td>
<td class="text-center"><?php echo $cat_arr[$room_arr[$row['room_id']]['category_id']]['name'] ?></td>
<td class="text-center"><?php echo $room_arr[$row['room_id']]['room'] ?></td>
<td class="text-center"><?php echo $row['ref_no'] ?></td>
<?php if($row['status'] == 1): ?>
<td class="text-center"><span class="badge badge-warning">เช็คอิน</span></td>
<?php else: ?>
<td class="text-center"><span class="badge badge-success">เช็คเอาท์</span></td>
<?php endif; ?>
<td class="text-center">
<button class="btn btn-sm btn-primary check_out" type="button" data-id="<?php echo $row['id'] ?>">แสดง</button>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('table').dataTable()
$('.check_out').click(function(){
uni_modal("เช็คเอาท์","manage_check_out.php?checkout=1&id="+$(this).attr("data-id"))
})
$('#filter').submit(function(e){
e.preventDefault()
location.replace('index.php?page=check_in&category_id='+$(this).find('[name="category_id"]').val()+'&status='+$(this).find('[name="status"]').val())
})
</script>
มันขึ้น
Warning: Undefined array key 0 in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Undefined array key "" in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\88\admin\check_out.php on line 36
Warning: Undefined array key 0 in C:\xampp\htdocs\88\admin\check_out.php on line 37
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\88\admin\check_out.php on line 37