/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Hoso::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); return $dataProvider; }
/** * 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']); }
/** * Finds the Hoso model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Hoso the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Hoso::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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> <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 $benhan = \app\models\Benhan::findOne(['id' => $_GET['benhan']]); $hoso = \app\models\Hoso::findOne(['id' => $benhan->maHS]); $benhnhan = \app\models\Benhnhan::findOne(['id' => $hoso->maBN]); $donthuoc = \app\models\Donthuoc::findOne(['maBA' => $benhan->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>