From 84d40ba29ce67033e6ff8c10344b9fc03d71eed1 Mon Sep 17 00:00:00 2001 From: SuraMew Date: Tue, 17 Feb 2026 14:53:03 +0700 Subject: [PATCH] fix report --- .../controllers/CaseFrozenController.php | 50 ++++- .../controllers/CaseNonGynController.php | 51 ++++- .../controllers/CasePapController.php | 52 ++++- .../controllers/CaseSurgicalController.php | 23 +- .../controllers/CenterApproveController.php | 56 ++++- .../CytoNonGynDiagnosisController.php | 64 +++++- .../CytoPapDiagnosisController.php | 62 +++++- .../FinanceServiceChargeController.php | 207 +++++------------- .../controllers/FrozenDiagnosisController.php | 66 +++++- .../controllers/HospitalImportController.php | 73 ++++-- .../HospitalImportServiceChargeController.php | 60 +++-- .../SurgicalDiagnosisController.php | 65 +++++- .../views/case-surgical/index.php | 1 - .../views/finance-service-charge/_form.php | 40 +--- .../views/finance-service-charge/index.php | 10 +- .../views/finance-service-charge/update.php | 25 +-- .../views/finance-service-charge/view.php | 52 ++--- .../controllers/ReportLogController.php | 117 +++++++++- frontend/themes/nikom/views/layouts/_menu.php | 23 +- 19 files changed, 707 insertions(+), 390 deletions(-) diff --git a/frontend/modules/administrator/controllers/CaseFrozenController.php b/frontend/modules/administrator/controllers/CaseFrozenController.php index 3fca3ab2..3b0feaec 100644 --- a/frontend/modules/administrator/controllers/CaseFrozenController.php +++ b/frontend/modules/administrator/controllers/CaseFrozenController.php @@ -95,9 +95,32 @@ class CaseFrozenController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไข ID Case และ Status: ' . $model->id_case, Yii::$app->user->getId(), CaseFrozen::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไข ID Case และ Status: ' . $model->id_case, + Yii::$app->user->getId(), + CaseFrozen::tableName() + ); + + // Flash สำเร็จ + Yii::$app->session->setFlash( + 'success', + 'บันทึกการแก้ไข Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + // Flash กรณีบันทึกไม่สำเร็จ + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบข้อมูลอีกครั้ง' + ); + } } return $this->render('update', [ @@ -165,7 +188,6 @@ class CaseFrozenController extends Controller } return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -173,14 +195,20 @@ class CaseFrozenController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + if ($model->delete()) { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Case: ' . $id_case, - Yii::$app->user->getId(), - CaseFrozen::tableName() - ); + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Case: ' . $id_case, + Yii::$app->user->getId(), + CaseFrozen::tableName() + ); + + // ตั้งค่า Flash Message + Yii::$app->session->setFlash('success', 'ลบ Case: ' . $id_case . ' เรียบร้อยแล้ว'); + } else { + Yii::$app->session->setFlash('error', 'ไม่สามารถลบข้อมูลได้'); + } return $this->redirect(['index']); } diff --git a/frontend/modules/administrator/controllers/CaseNonGynController.php b/frontend/modules/administrator/controllers/CaseNonGynController.php index 642c1870..fa4af84f 100755 --- a/frontend/modules/administrator/controllers/CaseNonGynController.php +++ b/frontend/modules/administrator/controllers/CaseNonGynController.php @@ -87,9 +87,32 @@ class CaseNonGynController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไข ID Case และ Status: ' . $model->id_case, Yii::$app->user->getId(), CaseNonGyn::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไข ID Case และ Status: ' . $model->id_case, + Yii::$app->user->getId(), + CaseNonGyn::tableName() + ); + + // Flash สำเร็จ + Yii::$app->session->setFlash( + 'success', + 'บันทึกการแก้ไข Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + // Flash กรณีบันทึกไม่สำเร็จ + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบข้อมูลอีกครั้ง' + ); + } } return $this->render('update', [ @@ -142,7 +165,6 @@ class CaseNonGynController extends Controller return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -150,18 +172,25 @@ class CaseNonGynController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + if ($model->delete()) { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Case: ' . $id_case, - Yii::$app->user->getId(), - CaseNonGyn::tableName() - ); + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Case: ' . $id_case, + Yii::$app->user->getId(), + CaseNonGyn::tableName() + ); + + // ตั้งค่า Flash Message + Yii::$app->session->setFlash('success', 'ลบ Case: ' . $id_case . ' เรียบร้อยแล้ว'); + } else { + Yii::$app->session->setFlash('error', 'ไม่สามารถลบข้อมูลได้'); + } return $this->redirect(['index']); } + /** * Finds the CaseNonGyn model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. diff --git a/frontend/modules/administrator/controllers/CasePapController.php b/frontend/modules/administrator/controllers/CasePapController.php index 448ee026..a7a2b9d7 100755 --- a/frontend/modules/administrator/controllers/CasePapController.php +++ b/frontend/modules/administrator/controllers/CasePapController.php @@ -87,9 +87,32 @@ class CasePapController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไข ID Case และ Status: ' . $model->id_case, Yii::$app->user->getId(), CasePap::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไข ID Case และ Status: ' . $model->id_case, + Yii::$app->user->getId(), + CasePap::tableName() + ); + + // Flash สำเร็จ + Yii::$app->session->setFlash( + 'success', + 'บันทึกการแก้ไข Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + // Flash กรณีบันทึกไม่สำเร็จ + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบข้อมูลอีกครั้ง' + ); + } } return $this->render('update', [ @@ -153,7 +176,6 @@ class CasePapController extends Controller return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -161,14 +183,20 @@ class CasePapController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + if ($model->delete()) { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Case: ' . $id_case, - Yii::$app->user->getId(), - CasePap::tableName() - ); + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Case: ' . $id_case, + Yii::$app->user->getId(), + CasePap::tableName() + ); + + // ตั้งค่า Flash Message + Yii::$app->session->setFlash('success', 'ลบ Case: ' . $id_case . ' เรียบร้อยแล้ว'); + } else { + Yii::$app->session->setFlash('error', 'ไม่สามารถลบข้อมูลได้'); + } return $this->redirect(['index']); } @@ -188,4 +216,4 @@ class CasePapController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/CaseSurgicalController.php b/frontend/modules/administrator/controllers/CaseSurgicalController.php index 1f015deb..80e0d44f 100755 --- a/frontend/modules/administrator/controllers/CaseSurgicalController.php +++ b/frontend/modules/administrator/controllers/CaseSurgicalController.php @@ -187,18 +187,25 @@ class CaseSurgicalController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + if ($model->delete()) { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Case: ' . $id_case, - Yii::$app->user->getId(), - CaseSurgical::tableName() - ); + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Case: ' . $id_case, + Yii::$app->user->getId(), + CaseSurgical::tableName() + ); + + // ตั้งค่า Flash Message + Yii::$app->session->setFlash('success', 'ลบ Case ' . $id_case . ' เรียบร้อยแล้ว'); + } else { + Yii::$app->session->setFlash('error', 'ไม่สามารถลบข้อมูลได้'); + } return $this->redirect(['index']); } + /** * Finds the CaseSurgical model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. @@ -214,4 +221,4 @@ class CaseSurgicalController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} \ No newline at end of file +} diff --git a/frontend/modules/administrator/controllers/CenterApproveController.php b/frontend/modules/administrator/controllers/CenterApproveController.php index d047197e..733f1d7e 100644 --- a/frontend/modules/administrator/controllers/CenterApproveController.php +++ b/frontend/modules/administrator/controllers/CenterApproveController.php @@ -86,9 +86,30 @@ class CenterApproveController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไขสถานะ Center Approve: ' . $model->id_case, Yii::$app->user->getId(), CenterApprove::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไขสถานะ Center Approve: ' . $model->id_case, + Yii::$app->user->getId(), + CenterApprove::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'อัปเดตสถานะ Center Approve ของ Case ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบความถูกต้องอีกครั้ง' + ); + } } return $this->render('update', [ @@ -109,7 +130,6 @@ class CenterApproveController extends Controller return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -117,14 +137,26 @@ class CenterApproveController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + if ($model->delete()) { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบรายการ Center Approve: ' . $id_case, - Yii::$app->user->getId(), - CenterApprove::tableName() - ); + Yii::$app->pathology->setLog( + 'Delete', + 'ลบรายการ Center Approve: ' . $id_case, + Yii::$app->user->getId(), + CenterApprove::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบรายการ Center Approve ของ Case: ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ กรุณาลองใหม่อีกครั้ง' + ); + } return $this->redirect(['index']); } @@ -144,4 +176,4 @@ class CenterApproveController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/CytoNonGynDiagnosisController.php b/frontend/modules/administrator/controllers/CytoNonGynDiagnosisController.php index adbf1fcf..1a13821a 100644 --- a/frontend/modules/administrator/controllers/CytoNonGynDiagnosisController.php +++ b/frontend/modules/administrator/controllers/CytoNonGynDiagnosisController.php @@ -86,9 +86,30 @@ class CytoNonGynDiagnosisController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไขสถานะ Non-Gyn Diagnosis: ' . $model->id_case, Yii::$app->user->getId(), CytoNonGynDiagnosis::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไขสถานะ Non-Gyn Diagnosis: ' . $model->id_case, + Yii::$app->user->getId(), + CytoNonGynDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'อัปเดตสถานะ Non-Gyn Diagnosis ของ Case ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบความถูกต้องอีกครั้ง' + ); + } } return $this->render('update', [ @@ -117,14 +138,35 @@ class CytoNonGynDiagnosisController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + try { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Non-Gyn Diagnosis: ' . $id_case, - Yii::$app->user->getId(), - CytoNonGynDiagnosis::tableName() - ); + if ($model->delete()) { + + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Non-Gyn Diagnosis: ' . $id_case, + Yii::$app->user->getId(), + CytoNonGynDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบ Non-Gyn Diagnosis ของ Case ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้' + ); + } + } catch (\Throwable $e) { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' + ); + } return $this->redirect(['index']); } @@ -144,4 +186,4 @@ class CytoNonGynDiagnosisController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/CytoPapDiagnosisController.php b/frontend/modules/administrator/controllers/CytoPapDiagnosisController.php index 7ff600a4..2ac92bbb 100644 --- a/frontend/modules/administrator/controllers/CytoPapDiagnosisController.php +++ b/frontend/modules/administrator/controllers/CytoPapDiagnosisController.php @@ -86,9 +86,30 @@ class CytoPapDiagnosisController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไขสถานะ Gyn Diagnosis: ' . $model->id_case, Yii::$app->user->getId(), CytoPapDiagnosis::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไขสถานะ Gyn Diagnosis: ' . $model->id_case, + Yii::$app->user->getId(), + CytoPapDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'อัปเดตสถานะ Gyn Diagnosis ของ Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบความถูกต้องอีกครั้ง' + ); + } } return $this->render('update', [ @@ -117,14 +138,35 @@ class CytoPapDiagnosisController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + try { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Surgical Diagnosis: ' . $id_case, - Yii::$app->user->getId(), - CytoPapDiagnosis::tableName() - ); + if ($model->delete()) { + + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Gyn Diagnosis: ' . $id_case, + Yii::$app->user->getId(), + CytoPapDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบ Gyn Diagnosis ของ Case: ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้' + ); + } + } catch (\Throwable $e) { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' + ); + } return $this->redirect(['index']); } diff --git a/frontend/modules/administrator/controllers/FinanceServiceChargeController.php b/frontend/modules/administrator/controllers/FinanceServiceChargeController.php index 69bd74f3..e412cbb8 100644 --- a/frontend/modules/administrator/controllers/FinanceServiceChargeController.php +++ b/frontend/modules/administrator/controllers/FinanceServiceChargeController.php @@ -3,14 +3,10 @@ namespace frontend\modules\administrator\controllers; use Yii; -use yii\base\Exception; use yii\web\Controller; use yii\filters\VerbFilter; -use common\models\PatientCase; use yii\web\NotFoundHttpException; -use common\models\ConstServiceCharge; use common\models\FinanceServiceCharge; -use common\models\StainingOutlab; use frontend\modules\administrator\models\FinanceServiceChargeSearch; /** @@ -33,87 +29,6 @@ class FinanceServiceChargeController extends Controller ]; } - /** - * @return string|\yii\web\Response - * @throws Exception - */ - public function actionCharge() - { - $model = new CaseForm(); - $case = null; - if ($model->load(Yii::$app->request->get())) { - $case = Yii::$app->pathology->getCase($model->id_case); - //$case = CaseSurgical::findOne(['id_case' => $model->id_case]); //'status_id' => 1, - - $model->items = FinanceServiceCharge::find()->where(['id_case' => $case->id_case])->all(); - - $time_now = date('Y-m-d H:i:s'); - - try { - $items = Yii::$app->request->post(); - - //var_dump($items['SurgicalOperate']['items']); - //die(); - - if (isset($items['CaseForm']['items']) && count($items['CaseForm']['items']) > 0) { - //var_dump($items['CaseForm']['items']); - //die(); - - foreach ($items['CaseForm']['items'] as $key => $val) { - //var_dump($val['charge_id']); - //die(); - if (empty($val['id'])) { - $finance = new FinanceServiceCharge(); - } else { - $finance = FinanceServiceCharge::findOne($val['id']); - } - $finance->id_case = $case->id_case; - $finance->hospital_id = $case->hospital_id; - $finance->charge_id = $val['charge_id']; - //หาราคา - $charge = ConstServiceCharge::findOne($val['charge_id']); - - $finance->price = Yii::$app->pathology->getHosPrice($case->hospital_id, $val['charge_id']); //$price->price; - $finance->df = Yii::$app->pathology->getHosDF($case->hospital_id, $val['charge_id']); - $finance->is_cash = 0; - $finance->occur_at = $time_now; - $finance->is_able = 0; //คิดเงิน - if ($finance->save()) { - - $staining_outlab = StainingOutlab::findOne(['id_case' => $finance->id_case]); - - if (!$staining_outlab) { - $staining_outlab = new StainingOutlab([ - 'id_case' => $finance->id_case, - 'block_no' => '-', - 'sent_location' => $model->sent_location, - 'note' => '-', - 'sent_at' => date('Y-m-d H:i:s'), - ]); - } - - $staining_outlab->save(); - - Yii::$app->session->addFlash('success', 'เพิ่มรายการตรวจ ' . (isset($charge) ? $charge->name : '') . ' แล้ว'); - } else { - Yii::$app->session->addFlash('error', 'เพิ่มรายการตรวจ ' . (isset($charge) ? $charge->name : '') . ' ไม่ได้'); - } - } - - - //return $this->redirect(['charge', 'CaseForm[id_case]' => $case->id_case]); - return $this->redirect(['charge']); - } - } catch (Exception $e) { - throw new Exception($e->getMessage()); - } - } - return $this->render('charge', [ - 'model' => $model, - 'case' => $case, - ]); - } - /** * @return void * @throws \Throwable @@ -122,8 +37,6 @@ class FinanceServiceChargeController extends Controller public function actionFinanceServiceChargeDelete() { $p = Yii::$app->request->post(); - //var_dump($p); - //die(); $finance = FinanceServiceCharge::findOne(['id_case' => $p['id_case'], 'id' => $p['from_id']]); if (!$finance) { // || !$surgical @@ -134,7 +47,6 @@ class FinanceServiceChargeController extends Controller } } - /** * Lists all FinanceServiceCharge models. * @return mixed @@ -164,38 +76,7 @@ class FinanceServiceChargeController extends Controller } /** - * Creates a new FinanceServiceCharge model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new FinanceServiceCharge(); - - if ($model->load(Yii::$app->request->post())) { - - $case = PatientCase::findOne(['id_case' => $model->id_case]); - if (!$case) { - throw new Exception('ไม่พบ Case ที่ค้นหา'); - } - $model->price = Yii::$app->pathology->getHosPrice($case->hospital_id, $model->charge_id); //$price->price; - $model->df = Yii::$app->pathology->getHosDF($case->hospital_id, $model->charge_id); - $model->occur_at = date('Y-m-d H:i:s'); - if ($model->save()) { - Yii::$app->pathology->financeApiSendByCase($model->id_case); - Yii::$app->session->setFlash('success', 'บันทึกข้อมูลเรียบร้อย'); - } - - return $this->redirect(['view', 'id' => $model->id]); - } - - return $this->render('create', [ - 'model' => $model, - ]); - } - - /** - * Updates an existing FinanceServiceCharge model. + * Updates an existing CaseSurgical model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed @@ -207,19 +88,28 @@ class FinanceServiceChargeController extends Controller if ($model->load(Yii::$app->request->post())) { - $case = PatientCase::findOne(['id_case' => $model->id_case]); - if (!$case) { - throw new Exception('ไม่พบ Case ที่ค้นหา'); - } - $model->price = Yii::$app->pathology->getHosPrice($case->hospital_id, $model->charge_id); //$price->price; - $model->df = Yii::$app->pathology->getHosDF($case->hospital_id, $model->charge_id); - $model->occur_at = date('Y-m-d H:i:s'); if ($model->save()) { - Yii::$app->pathology->financeApiSendByCase($model->id_case); - Yii::$app->session->setFlash('success', 'บันทึกข้อมูลเรียบร้อย'); - } - return $this->redirect(['view', 'id' => $model->id]); + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไข ID Case และ Status: ' . $model->id_case, + Yii::$app->user->getId(), + FinanceServiceCharge::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'บันทึกการแก้ไขข้อมูลค่าบริการของ Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบความถูกต้องอีกครั้ง' + ); + } } return $this->render('update', [ @@ -237,31 +127,46 @@ class FinanceServiceChargeController extends Controller public function actionDelete($id) { $model = $this->findModel($id); - if ($model->delete()) { - //Yii::$app->pathology->financeApiSendByCase($model->id_case); - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Finance Service Charge: ' . $model->id_case, - Yii::$app->user->getId(), - FinanceServiceCharge::tableName() + + // เก็บ id_case ไว้ก่อนลบ (กันค่า null หลัง delete) + $id_case = $model->id_case; + + try { + + if ($model->delete()) { + + // ถ้าต้องการเรียก API หลังลบ + // Yii::$app->pathology->financeApiSendByCase($id_case); + + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Finance Service Charge: ' . $id_case, + Yii::$app->user->getId(), + FinanceServiceCharge::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบข้อมูล Finance Service Charge ของ Case: ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้' + ); + } + } catch (\Throwable $e) { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' ); - Yii::$app->session->setFlash('ลบข้อมูลเรียบร้อยแล้ว'); } return $this->redirect(['index']); } -/*public function actionDelete($id) - { - $model = $this->findModel($id); - if ($model->delete()) { - Yii::$app->pathology->financeApiSendByCase($model->id_case); - Yii::$app->session->setFlash('ลบข้อมูลเรียบร้อยแล้ว'); - } - - return $this->redirect(['index']); - }*/ - /** * Finds the FinanceServiceCharge model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. @@ -277,4 +182,4 @@ class FinanceServiceChargeController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/FrozenDiagnosisController.php b/frontend/modules/administrator/controllers/FrozenDiagnosisController.php index 5cee4b25..c2777d15 100644 --- a/frontend/modules/administrator/controllers/FrozenDiagnosisController.php +++ b/frontend/modules/administrator/controllers/FrozenDiagnosisController.php @@ -86,9 +86,30 @@ class FrozenDiagnosisController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไขสถานะ Frozen Diagnosis: ' . $model->id_case, Yii::$app->user->getId(), FrozenDiagnosis::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไขสถานะ Frozen Diagnosis: ' . $model->id_case, + Yii::$app->user->getId(), + FrozenDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'อัปเดตสถานะ Frozen Diagnosis ของ Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบความถูกต้องอีกครั้ง' + ); + } } return $this->render('update', [ @@ -96,6 +117,7 @@ class FrozenDiagnosisController extends Controller ]); } + /** * Deletes an existing FrozenDiagnosis model. * If deletion is successful, the browser will be redirected to the 'index' page. @@ -109,7 +131,6 @@ class FrozenDiagnosisController extends Controller return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -117,14 +138,35 @@ class FrozenDiagnosisController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + try { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Frozen Diagnosis: ' . $id_case, - Yii::$app->user->getId(), - FrozenDiagnosis::tableName() - ); + if ($model->delete()) { + + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Frozen Diagnosis: ' . $id_case, + Yii::$app->user->getId(), + FrozenDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบ Frozen Diagnosis Case: ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้' + ); + } + } catch (\Throwable $e) { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' + ); + } return $this->redirect(['index']); } @@ -144,4 +186,4 @@ class FrozenDiagnosisController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/HospitalImportController.php b/frontend/modules/administrator/controllers/HospitalImportController.php index 60999346..ee4b0ebd 100644 --- a/frontend/modules/administrator/controllers/HospitalImportController.php +++ b/frontend/modules/administrator/controllers/HospitalImportController.php @@ -86,9 +86,30 @@ class HospitalImportController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไข ID CASE' . $model->id_case, Yii::$app->user->getId(), HospitalImport::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไข ID CASE ' . $model->id_case, + Yii::$app->user->getId(), + HospitalImport::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'บันทึกการแก้ไขข้อมูล Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบข้อมูลอีกครั้ง' + ); + } } return $this->render('update', [ @@ -97,19 +118,12 @@ class HospitalImportController extends Controller } /** - * Deletes an existing HospitalImport model. + * Deletes an existing HisRequest model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed * @throws NotFoundHttpException if the model cannot be found */ - /*public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -117,14 +131,35 @@ class HospitalImportController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + try { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Hospital Import: ' . $id_case, - Yii::$app->user->getId(), - HospitalImport::tableName() - ); + if ($model->delete()) { + + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Hospital Import: ' . $id_case, + Yii::$app->user->getId(), + HospitalImport::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบข้อมูล Hospital Import ของ Case: ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้' + ); + } + } catch (\Throwable $e) { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' + ); + } return $this->redirect(['index']); } @@ -144,4 +179,4 @@ class HospitalImportController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/HospitalImportServiceChargeController.php b/frontend/modules/administrator/controllers/HospitalImportServiceChargeController.php index 8a7d05ed..ef13cdf8 100644 --- a/frontend/modules/administrator/controllers/HospitalImportServiceChargeController.php +++ b/frontend/modules/administrator/controllers/HospitalImportServiceChargeController.php @@ -86,9 +86,30 @@ class HospitalImportServiceChargeController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไข Hospital ImportService Charge' . $model->id_case, Yii::$app->user->getId(), HospitalImportServiceCharge::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไข Hospital Import Service Charge: ' . $model->id_case, + Yii::$app->user->getId(), + HospitalImportServiceCharge::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'บันทึกการแก้ไข Hospital Import Service Charge ของ Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบข้อมูลอีกครั้ง' + ); + } } return $this->render('update', [ @@ -109,22 +130,33 @@ class HospitalImportServiceChargeController extends Controller return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); - // เก็บ id_case ไว้ก่อนลบ - $id_case = $model->id_case; + // เก็บ req_no ไว้ก่อนลบ + $req_no = $model->req_no; - $model->delete(); + if ($model->delete()) { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Hospital Import Service Charge ' . $id_case, - Yii::$app->user->getId(), - HospitalImportServiceCharge::tableName() - ); + Yii::$app->pathology->setLog( + 'Delete', + 'ลบรายการตรวจ: ' . $req_no, + Yii::$app->user->getId(), + HospitalImportServiceCharge::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบรายการตรวจของ Request Number: ' . $req_no . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' + ); + } return $this->redirect(['index']); } @@ -144,4 +176,4 @@ class HospitalImportServiceChargeController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/controllers/SurgicalDiagnosisController.php b/frontend/modules/administrator/controllers/SurgicalDiagnosisController.php index 0a175ef4..ad91ab71 100644 --- a/frontend/modules/administrator/controllers/SurgicalDiagnosisController.php +++ b/frontend/modules/administrator/controllers/SurgicalDiagnosisController.php @@ -86,9 +86,30 @@ class SurgicalDiagnosisController extends Controller { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - Yii::$app->pathology->setLog('Update', 'แก้ไขสถานะ Surgical Diagnosis: ' . $model->id_case, Yii::$app->user->getId(), SurgicalDiagnosis::tableName()); - return $this->redirect(['view', 'id' => $model->id]); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + Yii::$app->pathology->setLog( + 'Update', + 'แก้ไขสถานะ Surgical Diagnosis: ' . $model->id_case, + Yii::$app->user->getId(), + SurgicalDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'อัปเดตสถานะ Surgical Diagnosis ของ Case: ' . $model->id_case . ' เรียบร้อยแล้ว' + ); + + return $this->redirect(['view', 'id' => $model->id]); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถบันทึกข้อมูลได้ กรุณาตรวจสอบความถูกต้องอีกครั้ง' + ); + } } return $this->render('update', [ @@ -109,7 +130,6 @@ class SurgicalDiagnosisController extends Controller return $this->redirect(['index']); }*/ - public function actionDelete($id) { $model = $this->findModel($id); @@ -117,14 +137,35 @@ class SurgicalDiagnosisController extends Controller // เก็บ id_case ไว้ก่อนลบ $id_case = $model->id_case; - $model->delete(); + try { - Yii::$app->pathology->setLog( - 'Delete', - 'ลบ Surgical Diagnosis: ' . $id_case, - Yii::$app->user->getId(), - SurgicalDiagnosis::tableName() - ); + if ($model->delete()) { + + Yii::$app->pathology->setLog( + 'Delete', + 'ลบ Surgical Diagnosis: ' . $id_case, + Yii::$app->user->getId(), + SurgicalDiagnosis::tableName() + ); + + Yii::$app->session->setFlash( + 'success', + 'ลบ Surgical Diagnosis Case: ' . $id_case . ' เรียบร้อยแล้ว' + ); + } else { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้' + ); + } + } catch (\Throwable $e) { + + Yii::$app->session->setFlash( + 'error', + 'ไม่สามารถลบข้อมูลได้ อาจมีข้อมูลที่เกี่ยวข้องอยู่ในระบบ' + ); + } return $this->redirect(['index']); } @@ -144,4 +185,4 @@ class SurgicalDiagnosisController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } -} +} \ No newline at end of file diff --git a/frontend/modules/administrator/views/case-surgical/index.php b/frontend/modules/administrator/views/case-surgical/index.php index e02dbf07..8c841c42 100755 --- a/frontend/modules/administrator/views/case-surgical/index.php +++ b/frontend/modules/administrator/views/case-surgical/index.php @@ -3,7 +3,6 @@ use common\models\CaseSurgical; use common\models\ConstStatus; - use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\grid\GridView; diff --git a/frontend/modules/administrator/views/finance-service-charge/_form.php b/frontend/modules/administrator/views/finance-service-charge/_form.php index 76adb166..f055631f 100644 --- a/frontend/modules/administrator/views/finance-service-charge/_form.php +++ b/frontend/modules/administrator/views/finance-service-charge/_form.php @@ -1,9 +1,6 @@ -
- - - - field($model, 'id_case')->textInput(['maxlength' => true]) ?> - - field($model, 'charge_id')->widget(Select2::class, [ - 'theme' => Select2::THEME_BOOTSTRAP, - 'data' => ArrayHelper::map(ConstServiceCharge::find()->where(['status' => 1])->all(), 'id', function ($model) { - return $model->code . '-' . $model->name; - }), - ]) ?> - - field($model, 'is_cash')->checkbox() - ?> - - field($model, 'is_able')->checkbox() - ?> - -
- isNewRecord ? 'เพิ่มข้อมูล' : 'แก้ไข', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> - $model->id], ['class' => 'btn btn-info']) ?> + +
+
+ field($model, 'id_case')->textInput(['maxlength' => true]) ?>
+
+ field($model, 'req_no')->textInput(['maxlength' => true, 'readonly' => true]) ?> +
+
+
+ บันทึกข้อมูล', ['class' => 'btn btn-primary']) ?> +
- - -
\ No newline at end of file + \ No newline at end of file diff --git a/frontend/modules/administrator/views/finance-service-charge/index.php b/frontend/modules/administrator/views/finance-service-charge/index.php index 946a4b52..dd74980c 100644 --- a/frontend/modules/administrator/views/finance-service-charge/index.php +++ b/frontend/modules/administrator/views/finance-service-charge/index.php @@ -35,10 +35,16 @@ $this->params['breadcrumbs'][] = $this->title; 'class' => 'yii\grid\ActionColumn', 'headerOptions' => ['class' => 'custom-action-column-header'], 'contentOptions' => ['class' => 'custom-action-column'], - 'template' => '{delete}', // Customize buttons if needed + 'template' => '{update} {delete}', // Customize buttons if needed 'buttons' => [ + 'update' => function ($url, $model, $key) { + return Html::a(' แก้ไข ID CASE', $url, [ + 'title' => Yii::t('app', 'Update'), + 'class' => 'btn btn-info btn-sm' + ]); + }, 'delete' => function ($url, $model, $key) { - return Html::a(' ลบ Case', $url, [ + return Html::a(' ลบรายการตรวจ', $url, [ 'title' => Yii::t('app', 'Delete'), 'data-confirm' => Yii::t('app', 'คุณแน่ใจว่าต้องการลบรายการนี้หรือไม่ ?'), 'data-method' => 'post', diff --git a/frontend/modules/administrator/views/finance-service-charge/update.php b/frontend/modules/administrator/views/finance-service-charge/update.php index e277915c..ffd7aa46 100644 --- a/frontend/modules/administrator/views/finance-service-charge/update.php +++ b/frontend/modules/administrator/views/finance-service-charge/update.php @@ -5,26 +5,19 @@ use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model common\models\FinanceServiceCharge */ -$this->title = 'Update Finance Service Charge: ' . $model->id; +$this->title = 'แก้ไข Finance Service Charge: ' . $model->id_case; $this->params['breadcrumbs'][] = ['label' => 'Finance Service Charges', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = ['label' => $model->id_case, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'แก้ไข'; ?> -
-
-
-

- -
-
    -
  • -
-
-
-
+ +
+
+
title ?>
+
+
render('_form', [ 'model' => $model, ]) ?> -
-
+
\ No newline at end of file diff --git a/frontend/modules/administrator/views/finance-service-charge/view.php b/frontend/modules/administrator/views/finance-service-charge/view.php index 8d29a803..dbc7c8a5 100644 --- a/frontend/modules/administrator/views/finance-service-charge/view.php +++ b/frontend/modules/administrator/views/finance-service-charge/view.php @@ -6,47 +6,29 @@ use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model common\models\FinanceServiceCharge */ -$this->title = $model->id; +$this->title = $model->id_case; $this->params['breadcrumbs'][] = ['label' => 'Finance Service Charges', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> -
- - -
-
-

title) ?>

- -
-
    -
  • $model->id], ['class' => 'btn btn-sm btn-warning']) ?>
  • -
  • $model->id], ['class' => 'btn btn-sm btn-info']) ?>
  • -
  • -
-
-
-
- - $model, - 'attributes' => [ - 'id', - 'from_id', - 'id_case', - 'hospital_id', - 'charge_id', - 'price', - 'df', - 'is_cash', - 'occur_at', - 'is_able', - 'is_ready', - ], - ]) ?> +
+
+
title) ?>
+
+ แก้ไข ID CASE', ['update', 'id' => $model->id], ['class' => 'btn btn-warning']) ?> + กลับหน้าหลัก', ['index', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
- +
+ $model, + 'attributes' => [ + 'id_case', + 'req_no', + ], + ]) ?> + +
\ No newline at end of file diff --git a/frontend/modules/report/controllers/ReportLogController.php b/frontend/modules/report/controllers/ReportLogController.php index 1c634d42..b5702e71 100755 --- a/frontend/modules/report/controllers/ReportLogController.php +++ b/frontend/modules/report/controllers/ReportLogController.php @@ -186,7 +186,7 @@ class ReportLogController extends Controller ]); }*/ - public function actionLogReportView( + /*public function actionLogReportView( $id_case, $report_type, $id, @@ -246,7 +246,8 @@ class ReportLogController extends Controller $diagnoses = $modelClass::find() ->where([ 'id_case' => $id_case, - 'report_type' => $report_type + 'report_type' => $report_type, + 'id' => $id ]) ->all(); @@ -279,6 +280,116 @@ class ReportLogController extends Controller } } + // ========================= + // 6. Render + // ========================= + return $this->render('pdf', [ + 'pdfUrl' => $pdfUrl, + ]); + }*/ + + public function actionLogReportView( + $id_case, + $report_type, + $id, + $mode, + $file, + $pdf_type, + $watermark = null + ) { + + // ========================= + // 1. Save log + // ========================= + $log = new ReportLog(); + $log->id_case = $id_case; + $log->type = $report_type; + $log->view_at = date('Y-m-d H:i:s'); + $log->view_by = Yii::$app->user->id; + + if (!$log->save()) { + Yii::error('Failed to save report log: ' . json_encode($log->errors)); + throw new \yii\web\ServerErrorHttpException('Failed to save report log'); + } + + // ========================= + // 2. Default Fallback PDF Generator + // ========================= + $pdfUrl = Url::to([ + '/report/case/' . $pdf_type . '-pdf', + 'id_case' => $id_case, + 'report_type' => $report_type, + 'id' => $id, + 'mode' => $mode, + 'file' => $file, + 'watermark' => $watermark + ]); + + // ========================= + // 3. Map Case Type → Model + // ========================= + $modelMap = [ + 'surgical' => SurgicalDiagnosis::class, + 'pap' => CytoPapDiagnosis::class, + 'non-gyn' => CytoNonGynDiagnosis::class, + 'frozen' => FrozenDiagnosis::class, + ]; + + $caseType = Yii::$app->pathology->getCaseType($id_case); + + if (!isset($modelMap[$caseType])) { + return $this->render('pdf', ['pdfUrl' => $pdfUrl]); + } + + $modelClass = $modelMap[$caseType]; + + // ========================= + // 4. Load Diagnosis by ID (สำคัญมาก) + // ========================= + $diagnosis = $modelClass::findOne([ + 'id_case' => $id_case, + 'report_type' => $report_type, + 'id' => $id + ]); + + if (!$diagnosis) { + return $this->render('pdf', ['pdfUrl' => $pdfUrl]); + } + + // ========================= + // 5. Get Report Files + // ========================= + if ($report_type === 'consult-outlab') { + $reports = $diagnosis->getConsultReport(); + $basePath = $diagnosis->uploadConsultReportFolder; + } else { + $reports = $diagnosis->getReport(); + $basePath = $diagnosis->uploadReportFolder; + } + + if (!empty($reports)) { + foreach ($reports as $value) { + + $filePath = $basePath . '/' . $value; + + if (!file_exists($filePath)) { + continue; + } + + $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); + + if ($ext === 'pdf') { + $pdfUrl = Yii::getAlias('@web') . '/' . $filePath; + break; + } + + // ถ้าเป็นรูป → ใช้ fallback generator + if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif'])) { + break; + } + } + } + // ========================= // 6. Render // ========================= @@ -286,4 +397,4 @@ class ReportLogController extends Controller 'pdfUrl' => $pdfUrl, ]); } -} +} \ No newline at end of file diff --git a/frontend/themes/nikom/views/layouts/_menu.php b/frontend/themes/nikom/views/layouts/_menu.php index 62efef3d..63003316 100755 --- a/frontend/themes/nikom/views/layouts/_menu.php +++ b/frontend/themes/nikom/views/layouts/_menu.php @@ -1083,14 +1083,6 @@ if (Yii::$app->user->can('administrator')) { 'options' => ['class' => 'treeview'], 'items' => [ ['label' => ' Hospital Import', 'url' => ['/administrator/hospital-import/index']], - ], - ]; - - $menuItems[] = [ - 'label' => ' Hospital Service Charge', - 'url' => 'javascript:void()', - 'options' => ['class' => 'treeview'], - 'items' => [ ['label' => ' Hospital Import Service Charge', 'url' => ['/administrator/hospital-import-service-charge/index']], ], ]; @@ -1100,26 +1092,14 @@ if (Yii::$app->user->can('administrator')) { 'url' => 'javascript:void()', 'options' => ['class' => 'treeview'], 'items' => [ + ['label' => ' Finance Service Charges', 'url' => ['/administrator/finance-service-charge/index']], ['label' => ' จัดการ Case Surgical (S)', 'url' => ['/administrator/case-surgical/index']], ['label' => ' จัดการ Case Non Gyn (N)', 'url' => ['/administrator/case-non-gyn/index']], ['label' => ' จัดการ Case Gyn (C)', 'url' => ['/administrator/case-pap/index']], ['label' => ' จัดการ Case Frozen (F)', 'url' => ['/administrator/case-frozen/index']], - //['label' => ' จัดการ Case Autopsy (A)', 'url' => ['/administrator/case-autopsy/index']], - //['label' => ' จัดการ Case HPV (H)', 'url' => ['/administrator/case-hpv/index']], ], ]; - $menuItems[] = [ - 'label' => ' Finance Service Charges', - 'url' => 'javascript:void()', - 'options' => ['class' => 'treeview'], - 'items' => [ - ['label' => ' Finance Service Charges', 'url' => ['/administrator/finance-service-charge/index']], - ], - ]; - - - $menuItems[] = [ 'label' => ' Manage Diagnosis', 'url' => 'javascript:void()', @@ -1141,7 +1121,6 @@ if (Yii::$app->user->can('administrator')) { ], ]; - // Administrator $menuItems[] = [ 'label' => ' ผู้ใช้งาน',