Esempio n. 1
0
 /**
  * Finds the ErRegist model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ErRegist the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ErRegist::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 public function search2($params)
 {
     $this->load($params);
     $sql_s = "select ";
     $select = " c.`name` as n1 ,d.`name` as doctor,\n                    sum(if(month(r.vstdate) = 1,1,0)) as jan,\n                    sum(if(month(r.vstdate) = 2,1,0)) as feb,\n                    sum(if(month(r.vstdate) = 3,1,0)) as mar,\n                    sum(if(month(r.vstdate) = 4,1,0)) as apr,\n                    sum(if(month(r.vstdate) = 5,1,0)) as may,\n                    sum(if(month(r.vstdate) = 6,1,0)) as jun,\n                    sum(if(month(r.vstdate) = 7,1,0)) as jul,\n                    sum(if(month(r.vstdate) = 8,1,0)) as aug,\n                    sum(if(month(r.vstdate) = 9,1,0)) as sep,\n                    sum(if(month(r.vstdate) = 10,1,0)) as oct,\n                    sum(if(month(r.vstdate) = 11,1,0)) as nov,\n                    sum(if(month(r.vstdate) = 12,1,0)) as dece,\n                    count(e.er_oper_code) as c";
     $from = " from er_regist_oper e ";
     $join = " inner JOIN er_regist r on r.vn = e.vn\n                  INNER JOIN er_oper_code c ON c.er_oper_code = e.er_oper_code\n                  inner JOIN doctor d on d.code = e.doctor ";
     $where = " where ";
     $groupby = " group by e.er_oper_code order by d.name ";
     if (!is_null($this->vstdate) && strpos($this->vstdate, ' - ') !== false) {
         list($start_date, $end_date) = explode(' - ', $this->vstdate);
         //$query->andFilterWhere(['between', 'vstdate', $start_date, $end_date]);
         //echo "asdfasfasdf";
         //$this->vstdate = null;
         //print_r($query);
         $where .= "  r.vstdate between '" . $start_date . "' and '" . $end_date . "'";
     } else {
         $where .= "  r.vstdate = CURDATE() ";
     }
     $query = ErRegist::find();
     $sql = $sql_s . $select . $from . $join . $where . $groupby;
     $count = Yii::$app->db2->createCommand($sql)->execute();
     //        $dataProvider = new ActiveDataProvider([
     //            'query' => $query,
     //        ]);
     $dataProvider = new \yii\data\SqlDataProvider(['db' => 'db2', 'sql' => $sql, 'pagination' => ['pageSize' => 100], 'totalCount' => $count, 'sort' => ['attributes' => ['name' => ['asc' => ['doctor' => SORT_ASC], 'desc' => ['doctor' => SORT_DESC], 'default' => SORT_DESC]]]]);
     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(['vstdate' => $this->vstdate, 'er_period' => $this->er_period, 'er_pt_type' => $this->er_pt_type, 'er_emergency_type' => $this->er_emergency_type, 'er_dch_type' => $this->er_dch_type, 'er_time_1' => $this->er_time_1, 'er_time_2' => $this->er_time_2, 'er_time_3' => $this->er_time_3, 'enter_er_time' => $this->enter_er_time, 'doctor_tx_time' => $this->doctor_tx_time, 'finish_time' => $this->finish_time, 'ems_command_list_id' => $this->ems_command_list_id, 'er_emergency_level_id' => $this->er_emergency_level_id, 'update_datetime' => $this->update_datetime]);
     $query->andFilterWhere(['like', 'vn', $this->vn])->andFilterWhere(['like', 'er_doctor', $this->er_doctor])->andFilterWhere(['like', 'er_legal_action', $this->er_legal_action])->andFilterWhere(['like', 'dba', $this->dba])->andFilterWhere(['like', 'er_list', $this->er_list])->andFilterWhere(['like', 'oper_note', $this->oper_note])->andFilterWhere(['like', 'vn_guid', $this->vn_guid])->andFilterWhere(['like', 'observe', $this->observe])->andFilterWhere(['like', 'hos_guid', $this->hos_guid])->andFilterWhere(['like', 'er_screen', $this->er_screen])->andFilterWhere(['like', 'update_staff', $this->update_staff])->andFilterWhere(['like', 'er_depcode', $this->er_depcode]);
     return $dataProvider;
 }