-
Notifications
You must be signed in to change notification settings - Fork 1
/
tolak-lamaran.php
98 lines (83 loc) · 2.6 KB
/
tolak-lamaran.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
<?php
// panggil koneksi db
require "db.php";
// panggil file functions.php
require "functions.php";
// aktifkan session
session_start();
// ambil id lamaran
$idLamaran = $_GET["id"];
$lamaran = mysqli_query($db,"SELECT * from lamaran where id = $idLamaran");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- headtags -->
<?php require "headtags.php" ?>
<title>Hapus Data Lamaran</title>
</head>
<body>
<!-- navbar -->
<?php require "navbar.php" ?>
<h1 class="mt-5 display-4 text-center">Sedang Mencoba Menolak Lamaran</h1>
<!-- footer -->
<?php require "footer.php" ?>
</body>
</html>
<?php
// jika tidak login sbg perusahaan, tendang ke index
if (!isset($_SESSION["perusahaan"])){
echo "
<script>
Swal.fire('Akses Ditolak','Maaf Anda Tidak Dapat Mengakses Halaman Ini','warning').then(function(){
window.location = 'index.php';
});
</script>
";
}else if (isset($_GET["id"]) == NULL){ // jika tidak mendapatkan data id
echo "
<script>
Swal.fire('Halaman Tidak Memproses','Halaman Tidak Menerima Inputan Data Lamaran','warning').then(function(){
window.location = 'data-lamaran.php';
});
</script>
";
}else if (mysqli_num_rows($lamaran) == 0){ // jika id lamaran tidak ada di db
echo "
<script>
Swal.fire('Halaman Tidak Memproses','ID Lamaran Tidak Ditemukan','warning').then(function(){
window.location = 'data-lamaran.php';
});
</script>
";
}else {
$lamaran = mysqli_fetch_assoc(mysqli_query($db,"SELECT loker.idPerusahaan as idPerusahaan from lamaran join loker on lamaran.idLoker = loker.id where lamaran.id = $idLamaran"));
$idPerusahaanLoker = $lamaran["idPerusahaan"];
$emailPerusahaan = $_SESSION["perusahaan"];
$perusahaan = mysqli_fetch_assoc(mysqli_query($db, "SELECT * from perusahaan where email = '$email'"));
$idPerusahaanLogin = $perusahaan["id"];
// jika yg masuk bkn perusahaan yg punya loker
if ($idPerusahaanLoker != $idPerusahaanLogin){
echo "
<script>
Swal.fire('Akses Ditolak','Lamaran Ini Bukan Untuk Perusahaan Anda','warning').then(function(){
window.location = 'data-lamaran.php';
});
</script>
";
}else {
mysqli_query($db,"UPDATE lamaran SET status = 'Ditolak' where id = $idLamaran");
if (mysqli_affected_rows($db) == 1){
echo "
<script>
Swal.fire('Data Lamaran Ditolak','','success').then(function(){
window.location = 'data-lamaran.php';
});
</script>
";
}
}
}
?>