major update

This commit is contained in:
renaldybrada
2026-03-17 10:29:33 +07:00
parent 64aa3480a0
commit 9f7f55c98d
5 changed files with 71 additions and 47 deletions
+15 -3
View File
@@ -21,6 +21,9 @@ switch ($action) {
case "searchTindakan":
searchTindakan($db, $q);
break;
case "postLaporanOperasi":
postLaporanOperasi($db, $_POST);
break;
default :
echo json_encode([
"error" => "invalid action"
@@ -28,15 +31,15 @@ switch ($action) {
}
function searchDPJP(PostgresDb $db, string $q) {
$query = "SELECT kddokter, namadokter, kdsmf, kode_dpjp FROM public.m_dokter WHERE kdsmf LIKE '%BEDAH%'";
$query = "SELECT kddokter, namadokter, kdsmf, kode_dpjp, nip FROM public.m_dokter WHERE kdsmf LIKE '%BEDAH%'";
if ($q != '') {
$query .= " AND (namadokter ILIKE '%$q%' OR kode_dpjp ILIKE '%$q%')";
}
$query .= " LIMIT 10";
$sql_dokter_bedah = $db->query($query);
$query .= " LIMIT 10";
$arr_dokter_bedah = array();
foreach ($sql_dokter_bedah->fetchAll() as $ds) {
@@ -91,4 +94,13 @@ function searchTindakan(PostgresDb $db, string $q) {
"data" => $result
]);
}
function postLaporanOperasi(PostgresDb $db, $data) {
$query = "INSERT into t_operasi ()";
echo json_encode([
"message" => "success post laporan operasi",
"data" => $data
]);
}
?>
+53 -7
View File
@@ -1,5 +1,12 @@
<?php
$riwayat = [
[
"tanggal" => "3/17/2026, 8:52:26 AM",
"status" => "Tervalidasi",
"operator" => " dr.SYAIFULLAH AMISRAGANI, Sp.OT"
],
];
if ($_SERVER['REQUEST_METHOD'] == "POST") {
echo "<pre>";
print_r($_POST);
@@ -16,7 +23,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
<title>Laporan Operasi</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href='/lib/suneditor/dist/css/suneditor.min.css' rel='stylesheet' type='text/css' />
<style>
.section-title {
font-weight: 600;
@@ -38,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
<h4 class="text-center mb-4">FORM LAPORAN OPERASI</h4>
<form method="POST" enctype="multipart/form-data">
<form method="POST" id="formLaporanOperasi" enctype="multipart/form-data">
<!-- IDENTITAS -->
@@ -54,6 +61,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
autocomplete="off"
>
<input type="hidden" name="dpjp_operator" id="dpjp_operator">
<input type="hidden" name="nama_dpjp_operator" id="nama_dpjp_operator">
<input type="hidden" name="nip_dpjp_operator" id="nip_dpjp_operator">
<div
id="resultDPJP"
class="list-group position-absolute w-100"
@@ -85,6 +95,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
autocomplete="off"
>
<input type="hidden" name="dpjp_anestesi" id="dpjp_anestesi">
<input type="hidden" name="nama_dpjp_anestesi" id="nama_dpjp_anestesi">
<div
id="resultDokterAnestesi"
class="list-group position-absolute w-100"
@@ -224,7 +235,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
</div>
<div class="col-md-8">
<div class="input-group">
<input type="number" id="lama_op" class="form-control">
<input type="number" name="lama_operasi" id="lama_op" class="form-control">
<span class="input-group-text">menit</span>
</div>
</div>
@@ -362,7 +373,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
<label>Uraian Operasi</label>
</div>
<div class="col-md-6">
<textarea class="form-control" rows="5" name="uraian"></textarea>
<textarea class="form-control" id="fr_uraian_operasi" name="uraian"></textarea>
</div>
</div>
</div>
@@ -671,13 +682,23 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script type='text/javascript' src='/lib/suneditor/dist/suneditor.min.js'></script>
<script>
const BASEURL = "http://localhost:8080/dataLaporanOperasi.php";
const frUraianOperasi = SUNEDITOR.create((document.getElementById('fr_uraian_operasi') || 'fr_uraian_operasi'), {
height: '200px',
})
</script>
<script>
const BASEURL = "http://10.10.150.191:8000/dataLaporanOperasi.php";
/* SEARCH AND SHOW DPJP*/
const inputDokter = document.getElementById("searchDPJP")
const resultDokter = document.getElementById("resultDPJP")
const hiddenDokter = document.getElementById("dpjp_operator")
const hiddenNamaDokter = document.getElementById("nama_dpjp_operator")
const hiddenNipDokter = document.getElementById("nip_dpjp_operator")
let timer = null
@@ -712,6 +733,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
inputDokter.value = d.namadokter
hiddenDokter.value = d.kddokter
hiddenNamaDokter.value = d.namadokter
hiddenNipDokter.value = d.nip
resultDokter.innerHTML = ""
@@ -731,6 +754,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
const inputDokterAnestesi = document.getElementById("searchDokterAnestesi")
const resultDokterAnestesi = document.getElementById("resultDokterAnestesi")
const hiddenDokterAnestesi = document.getElementById("dpjp_anestesi")
const hiddenNamaDokterAnestesi = document.getElementById("nama_dpjp_anestesi")
inputDokterAnestesi.addEventListener("input", () => {
@@ -763,6 +787,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
inputDokterAnestesi.value = d.namadokter
hiddenDokterAnestesi.value = d.kddokter
hiddenNamaDokterAnestesi.value = d.namadokter
resultDokterAnestesi.innerHTML = ""
@@ -828,7 +853,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
timerTindakan = setTimeout(() => {
fetch(`http://localhost:8080/dataLaporanOperasi.php?action=searchTindakan&q=${keyword}`)
fetch(`${BASEURL}?action=searchTindakan&q=${keyword}`)
.then(res => res.json())
.then(data => {
@@ -1031,7 +1056,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
/* Tabel Riwayat Operasi */
document.getElementById("btnSimpanLaporan").addEventListener("click", function() {
let operatorDPJP = document.getElementById("dpjp_operator").value
let operatorDPJP = document.getElementById("searchDPJP").value
let tglBedah = document.getElementById("tgl_bedah")
let dateNow = new Date()
@@ -1062,6 +1087,27 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
tglBedah.value = ""
})
// SUBMIT FORM
document.getElementById("btnSimpanLaporan").addEventListener("click", async function() {
const form = document.getElementById("formLaporanOperasi")
let formData = new FormData(form)
// const plainObject = Object.fromEntries(formData.entries());
// console.log("form value: ", plainObject)
let res = await fetch(`${BASEURL}?action=postLaporanOperasi`, {
method: "POST",
body: formData
})
let data = await res.json()
console.log(data)
})
</script>
</body>
-37
View File
@@ -1,37 +0,0 @@
<?php
if (!function_exists('form_dropdown')) {
function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '', $callback = null)
{
if (!is_array($selected)) {
$selected = array($selected);
}
// If no selected state was submitted we will attempt to set it automatically
if (count($selected) === 0) {
// If the form name appears in the $_POST array we have a winner!
if (isset($_POST[$name])) {
$selected = array($_POST[$name]);
}
}
if ($extra != '') $extra = ' ' . $extra;
$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
$form = '<select name="' . $name . '"' . $extra . $multiple . ">\n";
foreach ($options as $key => $val) {
$key = (string)$key;
if (is_array($val) && !empty($val)) {
$form .= '<optgroup label="' . $key . '">' . "\n";
foreach ($val as $optgroup_key => $optgroup_val) {
$sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
$form .= '<option value="' . $optgroup_key . '"' . $sel . '>' . (string)$optgroup_val . "</option>\n";
}
$form .= '</optgroup>' . "\n";
} else {
$val = ($callback != '') ? $callback($val) : $val;
$sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
$form .= '<option value="' . $key . '"' . $sel . '>' . (string)$val . "</option>\n";
}
}
$form .= '</select>';
return $form;
}
}
?>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long