-
Notifications
You must be signed in to change notification settings - Fork 0
/
registration-add-process.php
104 lines (98 loc) · 3.11 KB
/
registration-add-process.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
include 'views/header.php';
include 'controller/connection.php';
date_default_timezone_set("Asia/Jakarta");
$tanggal=date('Y-m-d');
$jam=date("h:i:sa");
// menangkap data yang di kirim dari form
$id_catatan_medik = $_POST['id_catatan_medik'];
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$kontak = $_POST['kontak'];
$id_dokter = $_POST['id_dokter'];
$booking_tanggal = $_POST['booking_tanggal'];
$id_sesi = $_POST['id_sesi'];
$tanggal = $tanggal;
$jam = $jam;
$status = '2';
$keterangan = $_POST['keterangan'];
$tglsekarang = new DateTime();
$jadwal = new DateTime("$booking_tanggal");
$selisih = $tglsekarang->diff($jadwal)->format("%a");
// cek antrian
$a = mysqli_query($koneksi,
"SELECT COUNT(*) AS antrian
FROM booking
WHERE id_dokter='$id_dokter'
AND booking_tanggal='$booking_tanggal'
AND id_sesi='$id_sesi';");
while($b = mysqli_fetch_array($a)){
$antrian = $b['antrian']+1;
}
$c = mysqli_query($koneksi,
"SELECT kuota_status FROM dokter WHERE id_dokter='$id_dokter';");
while($d = mysqli_fetch_array($c)){
$kuota_status = $d['kuota_status'];
}
$e = mysqli_query($koneksi,
"SELECT COUNT(*) AS terdaftar
FROM booking
WHERE id_catatan_medik='$id_catatan_medik'
AND id_dokter='$id_dokter'
AND booking_tanggal='$booking_tanggal'
AND id_sesi='$id_sesi';");
while($f = mysqli_fetch_array($e)){
$terdaftar = $f['terdaftar'];
}
$error=array();
if (empty($nama)){
$error['nama']='Nama Harus Diisi!!!';
}if (empty($alamat)){
$error['alamat']='Alamat Harus Diisi!!!';
}if (empty($kontak)){
$error['kontak']='Kontak Harus Diisi!!!';
}if (empty($id_dokter)){
$error['id_dokter']='Dokter Harus Diisi!!!';
}if (empty($booking_tanggal)){
$error['booking_tanggal']='Tanggal Harus Diisi!!!';
}if (empty($id_sesi)){
$error['id_sesi']='Sesi Harus Diisi!!!';
}
if($kuota_status == 0){
// Cek kuota_status tidak aktif
include 'registration-add-query.php';
}else{
include '../koneksi.php';
$namahari = date('l', strtotime($booking_tanggal));
$e = mysqli_query($koneksi,
"SELECT kuota, kuota_hari FROM dokter WHERE id_dokter='$id_dokter';");
while($f = mysqli_fetch_array($e)){
$kuota = $f['kuota'];
$kuota_hari = $f['kuota_hari'];
$a1 = explode (", ",$kuota_hari);
$a2 = array("$namahari");
$result = array_intersect($a1,$a2);
}
if(!$namahari == $result){
include 'registration-add-query.php';
}else{
if($antrian > $kuota){
// Cek antrian melebihi kuota / tidak
echo "<script>
setTimeout(function() {
swal({
title: 'Kuota Penuh',
text: 'Silahkan Re-Schedule!',
type: 'error'
}, function() {
window.location = 'booking-tambah';
});
}, 10);
</script>";
}else{
include 'registration-add-query.php';
}
}
}
include 'views/footer.php';
?>