public function excel($params) { $query = Profesional::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]); return $dataProvider; }
/** * Creates a new Reserva model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Reserva(); $modelHora = new Hora(); $modelsExamen = [new HoraExamenSolicitado()]; if ($model->load(Yii::$app->request->post()) && $modelHora->load(Yii::$app->request->post())) { $modelsExamen = Model::createMultiple(HoraExamenSolicitado::classname()); Model::loadMultiple($modelsExamen, Yii::$app->request->post()); $valid = $model->validate(); $valid = $modelHora->validate() && $valid; $valid = Model::validateMultiple($modelsExamen) && $valid; if ($valid) { $transaction = \Yii::$app->db->beginTransaction(); try { $administrador = Administrador::find()->where(['id' => Yii::$app->user->getId()])->one(); $modelHora->administrador_id = $administrador->id; $modelHora->save(false); $profesional = Profesional::find()->where(['id' => $modelHora->profesional_id])->one(); $persona = Persona::find()->where(['id' => $profesional->persona_id])->one(); $model->hora_medica_id = $modelHora->id; $model->persona_id_ingresa_reserva = $persona->id; $model->save(false); foreach ($modelsExamen as $modelExamen) { $modelExamen->hora_id = $model->hora_medica_id; if (!($flag = $modelExamen->save(false))) { $transaction->rollBack(); break; } } if ($flag) { $transaction->commit(); return $this->redirect(['view', 'id' => $model->id]); } } catch (Exception $e) { $transaction->rollBack(); } } } else { return $this->render('create', ['model' => $model, 'modelHora' => $modelHora, 'modelsExamen' => empty($modelsExamen) ? [new HoraExamenSolicitado()] : $modelsExamen]); } }
<?php $rces = RceExamen::find('reserva_id')->all(); $ids = []; foreach ($rces as $i => $rce) { $ids[$i] = $rce->reserva_id; } $data = ArrayHelper::map(Reserva::find()->where(['not in', 'id', $ids])->all(), 'id', 'ReservaSelect'); ?> <?php echo $form->field($model, "reserva_id")->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Seleccionar Reserva...', 'id' => 'reservaId'], 'pluginOptions' => ['width' => '300px', 'disabled' => !$model->isNewRecord]]); ?> <?php $data = ArrayHelper::map(Profesional::find()->all(), 'id', 'Nombres'); ?> <?php echo $form->field($model, "persona_id_realiza_examen")->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Seleccionar Profesional que realiza el Examen...'], 'pluginOptions' => ['width' => '300px', 'disabled' => !$model->isNewRecord]]); ?> <?php foreach ($modelsExamenes as $i => $modelExamen) { $script = <<<JS // here you right all your javascript stuff \$('#reservaId').change(function(){ var reservaId = \$(this).val(); \$.get('index.php?r=examen/get-datos-examen',{ reservaId : reservaId },function(data){ var data = \$.parseJSON(data);
/* @var $model app\models\Hora */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="hora-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'tipo_hora_id')->dropDownList(ArrayHelper::map(TipoHora::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccionar Tipo de Hora', 'style' => 'width:300px']); ?> <?php echo $form->field($model, 'profesional_id')->dropDownList(ArrayHelper::map(Profesional::find()->all(), 'id', 'Nombres'), ['prompt' => 'Seleccionar Profesional', 'style' => 'width:300px']); ?> <?php echo $form->field($model, 'administrador_id')->dropDownList(ArrayHelper::map(Administrador::find()->all(), 'id', 'Nombres'), ['prompt' => 'Seleccionar Administrador', 'style' => 'width:300px']); ?> <?php echo $form->field($model, 'hora_inicio')->widget(TimePicker::className(), ['pluginOptions' => ['format' => 'HH:MM', 'showMeridian' => false, 'minuteStep' => 1], 'options' => ['style' => 'width:260px'], 'addonOptions' => ['asButton' => true, 'inline-addon' => true]]); ?> <?php echo $form->field($model, 'tiempo_periodo')->textInput(['style' => 'width:300px']); ?> <?php
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $profesional = Profesional::find($id); $profesional->delete(); return redirect()->back(); }
public function getReservaSelect() { $hora = Hora::find()->where(['id' => $this->hora_medica_id])->one(); $profesional = Profesional::find()->where(['id' => $hora->profesional_id])->one(); return $this->fecha . ' ' . $this->getHoraInicio() . ' - ' . $this->getNombresPaciente() . ' - ' . $profesional->getNombres(); }
public function getProfesional() { $hora = Hora::find()->where(['id' => $this->hora_id])->one(); $profesional = Profesional::find()->where(['id' => $hora->profesional_id])->one(); return $profesional->getNombres(); }
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'; } } } }
/** * 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']); }
public function getNombresPersona() { $persona = Profesional::find()->where(['id' => $this->persona_id_realiza_examen])->one(); return $persona->getNombres(); }
/** * Finds the Profesional model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Profesional the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Profesional::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }