/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Doctor the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Doctor::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex() { $doctors = Doctor::model()->findAll(); $patient = new Patient('search'); $patient->unsetAttributes(); // clear any default values if (isset($_GET['Patient'])) { $patient->attributes = $_GET['Patient']; } $this->render('index', compact('doctors', 'patient')); }
public function actionRecent() { $doctors = Doctor::model()->findAll(); $recentOutpatients = new MedicalRecord('search'); $recentOutpatients->unsetAttributes(); if (isset($_GET['MedicalRecord'])) { $recentOutpatients->attributes = $_GET['MedicalRecord']; } $recentSurgeries = new SurgeryRecord('search'); $recentSurgeries->unsetAttributes(); if (isset($_GET['SurgeryRecord'])) { $recentSurgeries->attributes = $_GET['SurgeryRecord']; } $this->render('index', compact('recentOutpatients', 'recentSurgeries', 'doctors')); }
public function actionUpdate($id) { $model = $this->loadModel($id); $patient = $model->patient; $doctors = Doctor::model()->findAll(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['SurgeryRecord'])) { $model->attributes = $_POST['SurgeryRecord']; if ($model->save()) { Yii::app()->user->setFlash('success', '儲存成功.'); $this->redirect($this->createUrl('/patient/update/', array('id' => $patient->id))); } } $this->render('update', array('patient' => $patient, 'model' => $model, 'doctors' => $doctors)); }
/** * Authenticates a user. * @return boolean whether authentication succeeds. */ public function authenticate() { if ($this->user_type == 1 || $this->user_type == 2) { $criteria = new CDbCriteria(); $criteria->condition = 'LOWER(mid)=' . strtolower($this->username) . ' AND management_user_level_id=' . $this->user_type; $user = Management::model()->find($criteria); } else { if ($this->user_type == 4) { $user = Doctor::model()->find('LOWER(did)=?', array(strtolower($this->username))); } else { if ($this->user_type == 3) { $user = Patient::model()->find('LOWER(pid)=?', array(strtolower($this->username))); } else { $user = Nurses::model()->find('LOWER(nid)=?', array(strtolower($this->username))); } } } if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if (!($user->pass == $this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { if ($this->user_type == 1 || $this->user_type == 2) { $this->_id = $user->mid; $this->username = $user->mid; } else { if ($this->user_type == 4) { $this->_id = $user->did; $this->username = $user->did; } else { if ($this->user_type == 3) { $this->_id = $user->pid; $this->username = $user->pid; } else { $this->_id = $user->nid; $this->username = $user->nid; } } } $this->_type = $this->user_type; $this->errorCode = self::ERROR_NONE; $this->setState("type", $this->_type); } } return $this->errorCode == self::ERROR_NONE; }
public function actionTranslate() { $sqlsm = ""; $sqlm = ""; $i = 0; $authorities = Authority::model()->findAll(); foreach ($authorities as $r) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'authorities','authority_" . htmlentities($r->id, ENT_QUOTES, 'UTF-8') . "_charge');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($r->charge, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $numbers = Numbers::model()->findAll(); $sqlsm = ""; $sqlm = ""; $i = 34; foreach ($numbers as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'numbers','numbers_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_field');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->field, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $services = Service::model()->findAll(); $sqlsm = ""; $sqlm = ""; $i = 68; foreach ($services as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'services','services_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_name');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->name, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'services','services_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_description');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->description, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $modules = Module::model()->findAll(); $sqlsm = ""; $sqlm = ""; foreach ($modules as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'services','module_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_name');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->name, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'services','module_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_description');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->description, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $departments = Department::model()->findAll(); $sqlsm = ""; $sqlm = ""; $i = 157; foreach ($departments as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'departments','department_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_name');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->name, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $specialities = Speciality::model()->findAll(); $sqlsm = ""; $sqlm = ""; foreach ($specialities as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'departments','speciality_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_name');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->name, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $news = News::model()->findAll(); $sqlsm = ""; $sqlm = ""; $i = 229; foreach ($news as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'news','news_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_title');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->title, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'news','news_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_description');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->description, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $doctors = Doctor::model()->findAll(); $sqlsm = ""; $sqlm = ""; $i = 406; foreach ($doctors as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'doctors','doctor_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_specialty');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->specialism, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'doctors','doctor_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_fellowship');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->fellowship, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'doctors','doctor_" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_interests');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->interests, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; echo "<br/>"; $sqlm = ""; $con = mysqli_connect("166.63.0.204", "webcont_dba", "lN_Q*PR]FN[E", "webcont_hm"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con, "SELECT id_mdc, especialidad_mdc, fellowship_mdc, intereses_mdc FROM medicos"); $j = 406; while ($row = mysqli_fetch_array($result)) { $sqlm .= "update `Message` set translation='" . $row['fellowship_mdc'] . "' where id=" . $j++ . " and language='en';<br>"; $sqlm .= "update `Message` set translation='" . $row['especialidad_mdc'] . "' where id=" . $j++ . " and language='en';<br>"; $sqlm .= "update `Message` set translation='" . $row['intereses_mdc'] . "' where id=" . $j++ . " and language='en';<br>"; } mysqli_close($con); echo $sqlm; echo "<br/>"; $firstaids = FirstAid::model()->findAll(); $sqlsm = ""; $sqlm = ""; $i = 1263; foreach ($firstaids as $s) { $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'firstaid','" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_title');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->title, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; $sqlsm .= "insert into `SourceMessage` values (" . $i . ",'firstaid','" . htmlentities($s->id, ENT_QUOTES, 'UTF-8') . "_description');<br>"; $sqlm .= "insert into `Message` values (" . $i . ",'es','" . htmlentities($s->description, ENT_QUOTES, 'UTF-8') . "');<br>"; $sqlm .= "insert into `Message` values (" . $i++ . ",'en','');<br>"; } echo $sqlsm; echo $sqlm; }
public function actionViewDoctor() { $this->authenUser(); $doctorId; $doctorData; if (isset($_REQUEST['doctorId'])) { $doctorId = $_REQUEST['doctorId']; if (!is_numeric($doctorId)) { $this->redirect($statusCode = 404); } else { $doctorData = Doctor::model()->find('did=?', array($doctorId)); if ($doctorData == null) { $this->redirect($statusCode = 404); } // invalid request redirected to 404 not found page } } $this->render('viewDoctor', array('doctorProfile' => $doctorData)); }
public function actionViewProfile() { $this->authenUser(); $doctorProfile = Doctor::model()->find('did=?', array($this->userId)); $this->render('viewProfile', array('doctorProfile' => $doctorProfile)); }