Example #1
0
 public function excel($params)
 {
     $query = Paciente::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 10000)]);
     $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, 'persona_id' => $this->persona_id]);
     $query->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Validates the password.
  * This method serves as the inline validation for password.
  *
  * @param string $attribute the attribute currently being validated
  * @param array $params the additional name-value pairs given in the rule
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $user = $this->getUser();
         if (!$user || !$user->validatePassword($this->password)) {
             $this->addError($attribute, 'Usuario o contraseña incorrectos.');
         }
         /*
          * Método que define que, si el usuario es un paciente (no es administrador o profesional), 
          * devuelve un mensaje indicándole que no tiene los permisos para iniciar sesión.
          */
         if (Paciente::find()->where(['persona_id' => $user->id])->exists()) {
             $this->addError($attribute, 'Usted no cuenta con los permisos para iniciar sesión.');
         }
     }
 }
Example #3
0
 public function getNombresPaciente()
 {
     $paciente = Paciente::find()->where(['id' => $this->paciente_id])->one();
     return $paciente->getNombres();
 }
 public function deleteDestroy($id)
 {
     $pac = Paciente::findOrFail($id);
     $pac->delete();
     return $pac;
 }
 public function getPaciente()
 {
     $reserva = Reserva::find()->where(['hora_medica_id' => $this->hora_id])->one();
     $paciente = Paciente::find()->where(['id' => $reserva->paciente_id])->one();
     return $paciente->getNombres();
 }
Example #6
0
use kartik\time\TimePicker;
use yii\grid\GridView;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model app\models\Reserva */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="reserva-form">

    <?php 
$form = ActiveForm::begin(['id' => 'dynamic-form']);
?>

    <?php 
$data = ArrayHelper::map(Paciente::find()->all(), 'id', 'Nombres');
?>

    <?php 
echo $form->field($model, 'paciente_id')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Seleccionar Paciente ...'], 'pluginOptions' => ['width' => '300px']]);
?>

    <?php 
echo $form->field($modelHora, "tipo_hora_id")->dropDownList(ArrayHelper::map(TipoHora::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccionar Tipo de Hora', 'style' => 'width:300px']);
?>

    <?php 
$data = ArrayHelper::map(Profesional::find()->all(), 'id', 'Nombres');
?>
        
    <?php 
 /**
  * Finds the Paciente model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Paciente the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Paciente::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function deleteDestroy($id)
 {
     $img = ImagenModel::findOrFail($id);
     $filename = 'images/perfil/' . $img->nombre;
     // Debería crear un código que impida borrar si la imagen es usada.
     if (File::exists($filename)) {
         File::delete($filename);
         $img->delete();
     } else {
         return 'No se encuentra la imagen a eliminar. ' . $img->nombre;
     }
     // Elimino cualquier referencia que otros tengan a esa imagen borrada.
     $pacientes = Paciente::where('image_id', $id)->get();
     foreach ($pacientes as $paci) {
         $paci->image_id = null;
         $paci->save();
     }
     $users = User::where('image_id', $id)->get();
     foreach ($users as $user) {
         $user->image_id = null;
         $user->save();
     }
     $confs = Configuracion::where('logo_id', $id)->get();
     foreach ($confs as $conf) {
         $conf->logo_id = null;
         $conf->save();
     }
     return $img;
 }
Example #9
0
 public function getPerfil()
 {
     if (Administrador::find()->where(['persona_id' => $this->id])->exists()) {
         return 'Administrador';
     } else {
         if (Profesional::find()->where(['persona_id' => $this->id])->exists()) {
             return 'Profesional';
         } else {
             if (Paciente::find()->where(['persona_id' => $this->id])->exists()) {
                 return 'Paciente';
             }
         }
     }
 }
Example #10
0
 /**
  * Deletes an existing Persona model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if (Administrador::find()->where(['persona_id' => $model->id])->exists()) {
         $admin = Administrador::find()->where(['persona_id' => $model->id])->one();
         $admin->delete();
         $model->delete();
     } else {
         if (Profesional::find()->where(['persona_id' => $model->id])->exists()) {
             $profesional = Profesional::find()->where(['persona_id' => $model->id])->one();
             $profesional->delete();
             $model->delete();
         } else {
             if (Paciente::find()->where(['persona_id' => $model->id])->exists()) {
                 $paciente = Paciente::find()->where(['persona_id' => $model->id])->one();
                 $paciente->delete();
                 $model->delete();
             }
         }
     }
     return $this->redirect(['index']);
 }