/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Noitru::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'maBN' => $this->maBN, 'soPhong' => $this->soPhong, 'soGiuong' => $this->soGiuong, 'ngayXuatVien' => $this->ngayXuatVien]); return $dataProvider; }
function printContent(el){ var restorepage = document.body.innerHTML; var printcontent = document.getElementById(el).innerHTML; document.body.innerHTML = printcontent; window.print(); document.body.innerHTML = restorepage; } </script> <a href='javascript:history.go(-1)' class="btn btn-warning">Quay lại trang trước</a> <!--this.style.display ='none'; window.print()--> <input type="button" class="btn btn-default" id="print_button" value="In hóa đơn" onclick="printContent('donthuoc')" /> <div class="col-md-10 col-md-offset-1" id="donthuoc"> <center><h3>ĐƠN THUỐC</h3></center> <br /><br /> <?php $maNT = \app\models\Noitru::findOne(['id' => $_GET['noitru']]); $benhnhan = \app\models\Benhnhan::findOne(['id' => $maNT->maBN]); $donthuoc = \app\models\Donthuocnt::findOne(['maNT' => $maNT->id]); ?> <h4> <table> <tr> <td>Bệnh nhân :</td> <td><?php echo $benhnhan->tenBN; ?> </td> </tr> <tr></tr> <tr> <td>Đơn thuốc :</td>
</h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Tạo bệnh nhân mới', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'tenBN', 'ngaySinh', ['label' => 'Giới tính', 'format' => 'raw', 'value' => function ($data) { if ($data->gioiTinh == 1) { return 'Nam'; } else { return 'Nữ'; } }], ['label' => 'Thêm vào nội trú', 'format' => 'raw', 'value' => function ($data) { $BNnoitru = \app\models\Noitru::findOne(['maBN' => $data->id]); if (empty($BNnoitru)) { $url = yii::$app->request->baseUrl . '/noitru/create?maBN=' . $data->id; return Html::a('Thêm vào nội trú', $url, ['title' => 'Go']); } else { return ''; } }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/** * Finds the Noitru model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Noitru the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Noitru::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Deletes an existing Benhnhan model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $noitru = Noitru::findOne(['maBN' => $id]); if (!empty($noitru)) { Noitru::findOne(['maBN' => $id])->delete(); } $maHS = Hoso::findOne(['maBN' => $id])->id; $benhan = Benhan::find()->all(); foreach ($benhan as $ba) { if ($ba->maHS == $maHS) { Benhan::findOne(['id' => $ba->id])->delete(); } } Hoso::findOne(['maBN' => $id])->delete(); $this->findModel($id)->delete(); return $this->redirect(['index']); }
public function actionStatistics($bieudo) { if ($bieudo == 'tonghop') { $tonghop = array(); $tonghop['Số lượng hồ sơ bệnh nhân lưu trong hệ thống'] = count(Benhnhan::find()->all()); $tonghop['Số lượng bệnh nhân nội trú'] = count(Noitru::find()->all()); $tonghop['Số lượng nhân viên'] = count(Nhanvien::find()->all()); $tonghop['Số lượng phòng khám'] = count(Phongkham::find()->all()); $tonghop['Số lượng khoa'] = count(Khoa::find()->all()); return $this->render('statistics', ['tonghop' => $tonghop]); } if ($bieudo == 'benhnhan') { $count = array(); $count['0'] = 0; $count['1'] = 0; $count['2'] = 0; $count['3'] = 0; $array = $this->actionThang(); $benhan = Benhan::find()->all(); foreach ($benhan as $ba) { if (date('m', $ba->created_at) == $array['0']) { $count['0'] = $count[0] + 1; } if (date('m', $ba->created_at) == $array['1']) { $count['1']++; } if (date('m', $ba->created_at) == $array['2']) { $count['2']++; } if (date('m', $ba->created_at) == $array['3']) { $count['3']++; } } return $this->render('statisticsBN', ['thang' => $array, 'value' => $count]); } $khoa = Khoa::find()->all(); $dskhoa = array(); $dsmakhoa = array(); $count = array(); $j = 0; foreach ($khoa as $k) { $dskhoa["{$j}"] = $k->tenKhoa; $dsmakhoa["{$j}"] = $k->id; $count["{$j}"] = 0; $j++; } $thang = 0; $now = getdate(); if ($now['mon'] == 1) { $thang = 12; } else { $thang = $now['mon']; } $benhan = Benhan::find()->all(); foreach (Bnpk::find()->all() as $lk) { if (date('m', $lk->ngayKham == $thang)) { for ($i = 0; $i < count($khoa); $i++) { if (Phongkham::findOne(['id' => $lk->maPK])->maKhoa == $dsmakhoa["{$i}"]) { $count["{$i}"]++; } } } } return $this->render('statisticsLK', ['thang' => $thang, 'dskhoa' => $dskhoa, 'value' => $count, 'count' => $j]); }