-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_preview_renungan.php
56 lines (45 loc) · 2.09 KB
/
get_preview_renungan.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
<?php
include 'connect.php';
header('Content-type: application/json');
date_default_timezone_set("Asia/Bangkok");
// FILE UNTUK HANDLE REQUEST PREVIEW RENUNGAN
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Ambil info dari Ajax
$kitab = $_POST['kitab'];
$pasal = $_POST['pasal'];
$awal = $_POST['awal'];
$akhir = $_POST['akhir'];
$renungan = $_POST['renungan'];
// SQL Untuk Ambil Firman Sesuai Request
$sql = "SELECT firman
FROM isi_alkitab AS ia
WHERE ia.kitab = ?
AND ia.pasal = ?
AND ia.ayat >= ? AND ia.ayat <= ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$kitab, $pasal, $awal, $akhir]);
// Ambil Firman dan Tampilkan dalam Input Disabled
$firman = '';
while ($row = $stmt->fetch()) {
$firman .= $row['firman'];
}
$outputFirman = '<i class="fas fa-user prefix grey-text"> </i> <label class="form-label">Preview Firman</label>
<textarea class="form-control" style=" max-width: 565px; height:500px;" type="text" value="' . $firman . '" disabled >' . $firman . '</textarea>';
// Ambil Ayat dan Di Format
$formatAyat = ucwords($kitab) . ' ' . $pasal . ':' . $awal;
if ($awal != $akhir) {
$formatAyat .= '-' . $akhir;
}
// Tampilkan Ayat dan Renungan Dalam Input Disabled
$outputAyat = '<span><i class="fas fa-user prefix grey-text"> </i> <label class="form-label"> Ayat</label>
<input id="content-ayat" type="text" class="form-control" style=" max-width: 465px;" disabled value="' . $formatAyat . '"></span>';
$outputRenungan = '<span><i class="fas fa-user prefix grey-text"> </i> <label class="form-label"> Renungan</label>
<textarea id="content-renungan" class="form-control" height:300px;" style=" max-width: 465px;" type="text" value="' . $renungan . '" disabled >' . $renungan . '</textarea></span>';
$notif = '';
echo json_encode(array(
'outputFirman' => $outputFirman,
'outputAyat' => $outputAyat,
'outputRenungan' => $outputRenungan,
'notif' => $notif
));
}