258 lines
16 KiB
PHP
258 lines
16 KiB
PHP
<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
|
|
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
|
|
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
|
|
<?php $component->withName('app-layout'); ?>
|
|
<?php if ($component->shouldRender()): ?>
|
|
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
|
|
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
|
|
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
|
|
<?php endif; ?>
|
|
<?php $component->withAttributes([]); ?>
|
|
<div class="max-w-5xl mx-auto space-y-6 pb-12" x-data="treatmentForm()">
|
|
|
|
<div class="flex items-center gap-4">
|
|
<a href="<?php echo e(route('treatments.index')); ?>" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
|
|
<i class="fas fa-arrow-left"></i>
|
|
</a>
|
|
<div>
|
|
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Edit Rekam Medis</h2>
|
|
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Memperbarui Catatan & Penyesuaian Multi-Obat</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="p-4 bg-amber-50 border border-amber-100 rounded-2xl flex items-start gap-3">
|
|
<i class="fas fa-sync-alt text-amber-500 mt-1 animate-spin-slow"></i>
|
|
<div>
|
|
<p class="text-xs font-black text-amber-700 uppercase tracking-widest">Sinkronisasi Inventori Otomatis</p>
|
|
<p class="text-[11px] text-amber-600 font-medium leading-relaxed">Sistem akan otomatis mengembalikan stok lama yang tercatat dan memotong stok baru berdasarkan perubahan yang Anda simpan di bawah ini.</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php if($errors->any()): ?>
|
|
<div class="bg-rose-50 border border-rose-200 rounded-2xl p-6 flex items-start gap-4">
|
|
<div class="w-10 h-10 bg-rose-100 text-rose-500 rounded-xl flex items-center justify-center shrink-0">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
<div>
|
|
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest mb-1">Gagal Menyimpan Data</h4>
|
|
<ul class="text-[11px] text-rose-500 font-bold list-disc list-inside space-y-1">
|
|
<?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
|
<li><?php echo e($error); ?></li>
|
|
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form action="<?php echo e(route('treatments.update', $treatment->id)); ?>" method="POST" enctype="multipart/form-data" class="space-y-6">
|
|
<?php echo csrf_field(); ?>
|
|
<?php echo method_field('PATCH'); ?>
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
|
|
<div class="lg:col-span-1 space-y-6">
|
|
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm space-y-6">
|
|
<h4 class="text-xs font-black text-indigo-600 uppercase tracking-widest border-b border-slate-100 pb-3">Data Pasien</h4>
|
|
|
|
<div class="space-y-4">
|
|
<div class="space-y-2">
|
|
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Pasien</label>
|
|
<select name="cat_id" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all">
|
|
<?php $__currentLoopData = $cats; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
|
<option value="<?php echo e($cat->id); ?>" <?php echo e(old('cat_id', $treatment->cat_id) == $cat->id ? 'selected' : ''); ?>>
|
|
<?php echo e($cat->nama_kucing); ?> (<?php echo e($cat->ras); ?>)
|
|
</option>
|
|
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
|
</select>
|
|
</div>
|
|
<div class="space-y-2">
|
|
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Pemeriksaan</label>
|
|
<input type="date" name="tanggal" value="<?php echo e(old('tanggal', $treatment->tanggal->format('Y-m-d'))); ?>" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-indigo-500 transition-all">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-6 shadow-sm space-y-4">
|
|
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Lampiran Foto Bukti</label>
|
|
<div class="relative group">
|
|
<div class="w-full h-48 rounded-3xl bg-slate-50 border-2 border-dashed border-slate-200 overflow-hidden shadow-inner flex items-center justify-center">
|
|
<img id="preview" src="<?php echo e($treatment->foto_bukti ? asset('storage/' . $treatment->foto_bukti) : 'https://ui-avatars.com/api/?name=No+Photo&background=f1f5f9&color=94a3b8'); ?>" class="w-full h-full object-cover">
|
|
</div>
|
|
<input type="file" name="foto_bukti" onchange="previewImage(event)" class="mt-3 w-full text-[10px] font-black text-slate-400 file:mr-3 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-[9px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100 cursor-pointer">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="lg:col-span-2 space-y-6">
|
|
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
|
|
<h4 class="text-xs font-black text-rose-600 uppercase tracking-widest border-b border-slate-100 pb-3">Diagnosa Klinik</h4>
|
|
|
|
<div class="space-y-4">
|
|
<div class="space-y-2">
|
|
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Keluhan Utama</label>
|
|
<input type="text" name="keluhan" value="<?php echo e(old('keluhan', $treatment->keluhan)); ?>" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all">
|
|
</div>
|
|
<div class="space-y-2">
|
|
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Hasil Diagnosa & Tindakan</label>
|
|
<textarea name="diagnosa" rows="4" required class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold focus:ring-2 focus:ring-rose-500 transition-all"><?php echo e(old('diagnosa', $treatment->diagnosa)); ?></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
|
|
<div class="flex items-center justify-between border-b border-slate-100 pb-4">
|
|
<h4 class="text-xs font-black text-emerald-600 uppercase tracking-widest">Penyesuaian Resep & Stok</h4>
|
|
<button type="button" @click="addMedicine" class="px-4 py-2 bg-emerald-50 text-emerald-600 text-[10px] font-black rounded-xl hover:bg-emerald-600 hover:text-white transition-all flex items-center gap-2">
|
|
<i class="fas fa-plus"></i> TAMBAH OBAT LAIN
|
|
</button>
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
|
|
<div class="hidden md:grid grid-cols-12 gap-4 px-4 text-[9px] font-black text-slate-400 uppercase tracking-widest">
|
|
<div class="col-span-4">Nama Obat</div>
|
|
<div class="col-span-2 text-center">Jumlah</div>
|
|
<div class="col-span-1"></div>
|
|
</div>
|
|
|
|
|
|
<template x-for="(item, index) in items" :key="index">
|
|
<div class="grid grid-cols-1 md:grid-cols-12 gap-3 bg-slate-50 p-4 md:p-2 rounded-2xl items-center border border-slate-100 transition-all">
|
|
|
|
<div class="col-span-1 md:col-span-4">
|
|
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase tracking-widest mb-1 block">Obat</label>
|
|
<select :name="`items[${index}][medicine_id]`"
|
|
x-model="item.medicine_id"
|
|
@change="updateUnit(index)"
|
|
required
|
|
class="w-full px-3 py-2 bg-white border border-slate-200 rounded-xl text-xs font-bold focus:ring-emerald-500">
|
|
<option value="">-- Pilih --</option>
|
|
<?php $__currentLoopData = $medicines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $med): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
|
<option value="<?php echo e($med->id); ?>" data-unit="<?php echo e($med->unit); ?>">
|
|
<?php echo e($med->nama_obat); ?> (Stok: <?php echo e((float)$med->qty); ?> <?php echo e($med->unit); ?>)
|
|
</option>
|
|
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
|
</select>
|
|
</div>
|
|
|
|
|
|
<div class="col-span-1 md:col-span-2">
|
|
<label class="md:hidden text-[9px] font-black text-slate-400 uppercase tracking-widest mb-1 block">Qty Potong Stok</label>
|
|
<div class="relative">
|
|
<input type="number" :name="`items[${index}][qty_used]`" x-model="item.qty_used" step="0.01" required
|
|
class="w-full pl-3 pr-8 py-2 bg-white border border-slate-200 rounded-xl text-xs font-black">
|
|
<span class="absolute right-2 top-1/2 -translate-y-1/2 text-[8px] font-black text-slate-300" x-text="item.unit"></span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-span-1 md:col-span-1 text-center mt-2 md:mt-0">
|
|
<button type="button" @click="removeItem(index)" x-show="items.length > 1" class="w-8 h-8 inline-flex items-center justify-center bg-rose-50 text-rose-500 rounded-lg hover:bg-rose-500 hover:text-white transition-all">
|
|
<i class="fas fa-times text-xs"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="w-full py-5 bg-slate-900 text-white text-sm font-black rounded-3xl shadow-xl hover:bg-indigo-600 transition-all active:scale-[0.98] flex items-center justify-center gap-2">
|
|
<i class="fas fa-save"></i> PERBARUI REKAM MEDIS & SINKRONISASI STOK
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php $__env->startPush('scripts'); ?>
|
|
<script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
|
|
|
|
<?php
|
|
// [FIX ERROR SYNTAX BLADE]
|
|
$mappedItems = [];
|
|
$oldItems = old('items');
|
|
|
|
if ($oldItems) {
|
|
$mappedItems = $oldItems;
|
|
} else {
|
|
if (isset($treatment->details) && $treatment->details->count() > 0) {
|
|
$mappedItems = $treatment->details->map(function($detail) {
|
|
return [
|
|
'medicine_id' => $detail->medicine_id,
|
|
'qty_used' => (float) $detail->qty_used,
|
|
'unit' => $detail->medicine->unit ?? 'UNIT',
|
|
'dosis' => $detail->dosis ?? '',
|
|
'keterangan' => $detail->keterangan ?? '',
|
|
];
|
|
})->toArray();
|
|
} else {
|
|
$mappedItems = [[
|
|
'medicine_id' => $treatment->medicine_id,
|
|
'qty_used' => (float) $treatment->qty_used,
|
|
'unit' => $treatment->medicine->unit ?? 'UNIT',
|
|
'dosis' => $treatment->dosis ?? '',
|
|
'keterangan' => $treatment->keterangan ?? '',
|
|
]];
|
|
}
|
|
}
|
|
?>
|
|
|
|
<script>
|
|
function treatmentForm() {
|
|
return {
|
|
items: <?php echo json_encode($mappedItems, 15, 512) ?>,
|
|
|
|
addMedicine() {
|
|
this.items.push({
|
|
medicine_id: '',
|
|
qty_used: 1,
|
|
unit: 'UNIT',
|
|
dosis: '',
|
|
keterangan: ''
|
|
});
|
|
},
|
|
|
|
removeItem(index) {
|
|
this.items.splice(index, 1);
|
|
},
|
|
|
|
updateUnit(index) {
|
|
setTimeout(() => {
|
|
const select = document.querySelectorAll('select[name^="items"]')[index];
|
|
if (select) {
|
|
const selectedOption = select.options[select.selectedIndex];
|
|
const unit = selectedOption.getAttribute('data-unit');
|
|
this.items[index].unit = unit ? unit : 'UNIT';
|
|
}
|
|
}, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
function previewImage(event) {
|
|
const reader = new FileReader();
|
|
reader.onload = function() {
|
|
const output = document.getElementById('preview');
|
|
output.src = reader.result;
|
|
}
|
|
if(event.target.files[0]) {
|
|
reader.readAsDataURL(event.target.files[0]);
|
|
}
|
|
}
|
|
</script>
|
|
<?php $__env->stopPush(); ?>
|
|
<?php echo $__env->renderComponent(); ?>
|
|
<?php endif; ?>
|
|
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
|
|
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
|
|
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
|
|
<?php endif; ?>
|
|
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
|
|
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
|
|
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
|
|
<?php endif; ?><?php /**PATH /home/u806112658/domains/earrinasia.com/ilycats/resources/views/pages/treatments/edit.blade.php ENDPATH**/ ?>
|