-
Notifications
You must be signed in to change notification settings - Fork 0
/
material.php
249 lines (222 loc) · 8.8 KB
/
material.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
include 'connect.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Materi</title>
<meta name="description" content="Free Bootstrap Theme by uicookies.com">
<meta name="keywords" content="free website templates, free bootstrap themes, free template, free bootstrap, free website template">
<link href="https://fonts.googleapis.com/css?family=Rubik:300,400,500" rel="stylesheet">
<link rel="stylesheet" href="assets/user/css/styles-merged.css">
<link rel="stylesheet" href="assets/user/css/style.min.css">
<link rel="stylesheet" href="assets/user/css/custom.css">
<style>
.probootstrap-header {
background-color: cadetblue;
background-image: url("assets/user/img/3cross.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #464646;
width: 100%;
height: auto;
}
body {
background-color: cadetblue;
background-image: url("assets/user/img/3cross.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #464646;
width: 100%;
height: auto;
}
</style>
</head>
<body>
<header role="banner" class="probootstrap-header img-responsive">
<?php require_once('user_navbar.php') ?>
<section class="probootstrap-intro" style="height: 600px;">
<center>
<h1>Materi Bacaan</h1>
</center>
</section>
</header>
<section class="probootstrap-section probootstrap-section-extra">
<div class="container">
<?php
$emailnya = $_SESSION["email"];
$sql = "SELECT ayat,renungan,sudah_baca,sudah_baca_at,id_user,id_alkitab,id_group
FROM alkitab ,detail_group
JOIN user
where detail_group.id_user = user.id
and detail_group.id_alkitab = alkitab.id
and user.email=?
and alkitab.id != 0";
$stmt = $pdo->prepare($sql);
$stmt->execute([$emailnya]);
while ($row = $stmt->fetch()) {
$iduser = $row["id_user"];
$idgroup = $row["id_group"];
$idalkitab = $row["id_alkitab"];
$ayat = $row["ayat"];
$renungan = $row["renungan"];
$sb = $row["sudah_baca"];
$sbt = $row["sudah_baca_at"];
$btnset = "";
if ($sb == true) {
$txtt = "Sudah dibaca pada ";
$aksinya = "bacakembali";
$btnset = "Tandai belum dibaca";
$btcolor = "btn-warning";
} else {
$txtt = "Belum dibaca";
$aksinya = "tandai";
$btnset = "Sudah dibaca";
$btcolor = "btn-success";
}
echo '<div class="card bg-info">
<div class="card-header bg-primary text-white">
<h1 class="text-white">' . $renungan . '</h1>
</div>
<div class="card-body">
<i>' . $txtt . '</i>
<br>';
if ($sb) {
echo '<i>' . $sbt . '</i>';
}
$skitab = strtok($ayat, ' ');
$spasal = substr($ayat, strpos($ayat, " ") + 1);
$spasal = strtok($spasal, ':');
$sawal = substr($ayat, strpos($ayat, ":") + 1);
$sawal = strtok($sawal, '-');
$sakhir = substr($ayat, strpos($ayat, "-") + 1);
echo '<p class="card-text">' . $ayat . '</p>
<form method="post" action="">
<input name="user" type="hidden" value=' . $iduser . '></input>
<input name="group" type="hidden" value=' . $idgroup . '></input>
<input name="alkitab" type="hidden" value=' . $idalkitab . '></input>
<input name="kitab" type="hidden" value=' . $skitab . '></input>
<input name="pasal" type="hidden" value=' . $spasal . '></input>
<input name="awal" type="hidden" value=' . $sawal . '></input>
<input name="akhir" type="hidden" value=' . $sakhir . '></input>
<input name="renungan" type="hidden" value=' . $renungan . '></input>
<button type="submit" name = "aksi" value = "baca" class ="btn btn-primary">Baca Ayat</button >
<button type="submit" name = "aksi" value = "' . $aksinya . '" class ="btn ' . $btcolor . '" >' . $btnset . '</button >
</form>
</div>
</div> <br>';
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$aksi = $_POST["aksi"];
$puser = $_POST["user"];
$pgroup = $_POST["group"];
$palkitab = $_POST["alkitab"];
$pkitab = $_POST["kitab"];
$ppasal = $_POST["pasal"];
$pawal = $_POST["awal"];
$pakhir = $_POST["akhir"];
$prenungan = '';
$prenungan = $_POST["renungan"];
if ($aksi == "tandai") {
if (isset($puser) && isset($pgroup) && isset($palkitab)) {
$sqlupdate = "UPDATE detail_group
SET sudah_baca = 1 , sudah_baca_at = now()
WHERE id_user = ?
and id_group = ?
and id_alkitab = ?";
$stmt = $pdo->prepare($sqlupdate);
// $stmt->bind_param('sss', );
$stmt->execute([$puser, $pgroup, $palkitab]);
if ($stmt == false) {
$error = "Update failed. Please try again.";
} else {
echo "<script type='text/javascript'>" .
"alert('Berhasil update sudah dibaca.');
window.location.assign(window.location.href);" .
"</script>";
exit;
}
}
} elseif ($aksi == "bacakembali") {
if (isset($puser) && isset($pgroup) && isset($palkitab)) {
$sqlupdate = "UPDATE detail_group
SET sudah_baca = 0 , sudah_baca_at = NULL
WHERE id_user = ?
and id_group = ?
and id_alkitab = ?";
$stmt = $pdo->prepare($sqlupdate);
$stmt->execute([$puser, $pgroup, $palkitab]);
if ($stmt == false) {
$error = "Update failed. Please try again.";
} else {
echo "<script type='text/javascript'>" .
"alert('Berhasil update mengulang bacaan.');
window.location.assign(window.location.href);" .
"</script>";
exit;
}
}
} elseif ($aksi == "baca") {
if (isset($pkitab) && isset($ppasal) && isset($pawal) && isset($pakhir) && isset($prenungan)) {
echo " <script>
$.ajax({
url: 'get_preview_renungan.php',
method: 'POST',
data: {
kitab: '" . $pkitab . "',
pasal: " . $ppasal . ",
awal: " . $pawal . ",
akhir: " . $pakhir . ",
renungan: '" . $prenungan . "',
},
success: function(result) {
// Menampilkan Preview Firman, Ayat, dan Renungan
$('#preview-firman').html(result.outputFirman);
$('#preview-ayat').html(result.outputAyat);
$('#preview-renungan').html(result.outputRenungan);
// Hide Modal Add Renungan dan tampilkan Preview Renungan
$('#preview-renungan-modal').modal('show');
},
error: function(result) {
}
});
</script>";
}
}
}
?>
</div>
</section>
<div class="modal fade" id="preview-renungan-modal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="previewRenunganLabel">Preview Renungan</h5>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="col-md-6" id="preview-firman">
</div>
<div class="col-md-4 ">
<div class="row mb-5" id="preview-ayat" style=" max-width: 250px;"></div>
<div class="row" id="preview-renungan" style=" max-width: 250px;"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-dark" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php require_once('user_footer.php'); ?>
</body>
</html>