diff --git a/Modules/HospitalPortal/Http/Controllers/ApotekController.php b/Modules/HospitalPortal/Http/Controllers/ApotekController.php index d8a7ff71..ae464599 100644 --- a/Modules/HospitalPortal/Http/Controllers/ApotekController.php +++ b/Modules/HospitalPortal/Http/Controllers/ApotekController.php @@ -378,6 +378,29 @@ class ApotekController extends Controller 'dUpdateOn' => date('Y-m-d H:i:s'), ]); + // Insert the log + $prescriptionOrder = DB::connection('oldlms') + ->table('tx_prescription_orders') + ->where('tx_prescription_orders.nID', '=', $id) + ->join('tx_delivery_orders', 'tx_delivery_orders.nIDPrescriptionOrder', '=', 'tx_prescription_orders.nID') + ->select('tx_prescription_orders.*', 'tx_delivery_orders.*', 'tx_delivery_orders.nID as nIDDelivery') // Add specific columns you want to select + ->first(); + + if ($prescriptionOrder) { + $createdBy = $prescriptionOrder->sCreateBy; + $nIDPrescription = $prescriptionOrder->nIDPrescription; + $nIDDeliveryOrder = $prescriptionOrder->nIDDelivery; + + // Insert data into the tx_delivery_log table + DB::connection('oldlms')->table('tx_delivery_log')->insert([ + 'sStatus' => $prescriptionOrder->sDeliveryStatus, + 'sStatusPrescription' => $status, + 'nIDDeliveryOrder' => $nIDDeliveryOrder, + 'nIDPrescription' => $nIDPrescription, + 'dCreatedOn' => now(), + ]); + } + // Commit the transaction DB::connection('oldlms')->commit(); @@ -668,4 +691,5 @@ class ApotekController extends Controller $uuidV5 = Uuid::uuid5($namespace, $id_prescription_order); return $uuidV5->toString(); } + }