This commit is contained in:
2024-05-02 10:25:34 +07:00
parent 04b0b2943d
commit 3ed0242963

View File

@@ -153,7 +153,7 @@ class PrescriptionController extends Controller
// delete item // delete item
DB::beginTransaction(); DB::beginTransaction();
PrescriptionItemAso::where('prescription_id', $prescriptionAso->id)->delete(); PrescriptionItemAso::where('prescription_id', $prescriptionAso->id)->delete();
PrescriptionItem::where('nIDPrescription', $prescriptionAso->id)->delete(); PrescriptionItem::where('nIDPrescription', $prescription->nID)->delete();
foreach($medicine as $key => $value){ foreach($medicine as $key => $value){
$drugData = Drug::where('id', $value['drug_id'])->first(); $drugData = Drug::where('id', $value['drug_id'])->first();
$drug = ''; $drug = '';
@@ -165,15 +165,8 @@ class PrescriptionController extends Controller
if ($unitData) { if ($unitData) {
$unit = $unitData->name; $unit = $unitData->name;
} }
$data = [
'nIDPrescription' => $prescription->id, // Insert Data
'sItemName' => $drug,
'nQty' => $value['qty'],
'sSatuan' => $unit,
'sSigna' => $value['signa'],
'sNote' => $value['note'],
];
$dataAso = [ $dataAso = [
'prescription_id' => $prescriptionAso->id, 'prescription_id' => $prescriptionAso->id,
'drug_id' => $value['drug_id'], 'drug_id' => $value['drug_id'],
@@ -182,7 +175,14 @@ class PrescriptionController extends Controller
'signa' => $value['signa'], 'signa' => $value['signa'],
'note' => $value['note'] 'note' => $value['note']
]; ];
// Insert Data $data = [
'nIDPrescription' => $prescription->nID,
'sItemName' => $drug,
'nQty' => $value['qty'],
'sSatuan' => $unit,
'sSigna' => $value['signa'],
'sNote' => $value['note'],
];
try { try {
// Insert to ASO // Insert to ASO
PrescriptionItemAso::create($dataAso); PrescriptionItemAso::create($dataAso);