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 @@ -