Exemple #1
0
 public function excel($params)
 {
     $query = Hora::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, 'tipo_hora_id' => $this->tipo_hora_id, 'profesional_id' => $this->profesional_id, 'administrador_id' => $this->administrador_id, 'hora_inicio' => $this->hora_inicio, 'tiempo_periodo' => $this->tiempo_periodo]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getHoras()
 {
     return $this->hasMany(Hora::className(), ['administrador_id' => 'id']);
 }
Exemple #3
0
 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 actionGetDatosExamen($reservaId)
 {
     // find the zip code from the locations table
     $reserva = Reserva::findOne($reservaId);
     $hora = Hora::findOne($reserva->hora_medica_id);
     $exSolicitados = HoraExamenSolicitado::find()->where(['hora_id' => $hora->id])->all();
     foreach ($exSolicitados as $i => $exSolicitado) {
         $examen = Examen::findOne($exSolicitado->examen_id);
         $examenes[$i] = $examen;
     }
     echo Json::encode($examenes);
 }
Exemple #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getHoras()
 {
     return $this->hasMany(Hora::className(), ['tipo_hora_id' => 'id']);
 }
 /**
  * Updates an existing RceExamen model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelsPago = $model->pagos;
     $modelsBitacora = $model->bitacoras;
     $modelsExamenes = $model->rceExamenExamens;
     foreach ($modelsExamenes as $modelExamen) {
         $examen = Examen::find()->where(['id' => $modelExamen->examen_id])->one();
         $modelExamen->descripcion = $examen->descripcion;
         $modelExamen->observaciones = $examen->observaciones;
     }
     if ($model->load(Yii::$app->request->post())) {
         $oldIDsPago = ArrayHelper::map($modelsPago, 'id', 'id');
         $modelsPago = Model::createMultiple(Pago::classname(), $modelsPago);
         Model::loadMultiple($modelsPago, Yii::$app->request->post());
         $deletedIDsPago = array_diff($oldIDsPago, array_filter(ArrayHelper::map($modelsPago, 'id', 'id')));
         $oldIDsExamen = ArrayHelper::map($modelsExamenes, 'id', 'id');
         $modelsExamenes = Model::createMultiple(Examen::classname(), $modelsExamenes);
         Model::loadMultiple($modelsExamenes, Yii::$app->request->post());
         $deletedIDsExamen = array_diff($oldIDsExamen, array_filter(ArrayHelper::map($modelsExamenes, 'id', 'id')));
         // validate all models
         $valid = $model->validate();
         $valid = Model::validateMultiple($modelsPago) && $valid;
         $valid = Model::validateMultiple($modelsBitacora) && $valid;
         $valid = Model::validateMultiple($modelsExamenes) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $model->save(false)) {
                     if (!empty($deletedIDsPago)) {
                         Pago::deleteAll(['id' => $deletedIDsPago]);
                     } else {
                         if (!empty($deletedIDsBitacora)) {
                             Bitacora::deleteAll(['id' => $deletedIDsBitacora]);
                         } else {
                             if (!empty($deletedIDsREE)) {
                                 RceExamenExamen::deleteAll(['id' => $deletedIDsREE]);
                             }
                         }
                     }
                     foreach ($modelsPago as $modelPago) {
                         $modelPago->rce_examen_id = $model->id;
                         if (!($flag = $modelPago->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                     foreach ($modelsBitacora as $modelBitacora) {
                         $modelBitacora->rce_examen_id = $model->id;
                         if (!($flag = $modelBitacora->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                     $reserva = Reserva::find()->where(['id' => $model->reserva_id])->one();
                     $hora = Hora::find()->where(['id' => $reserva->hora_medica_id])->one();
                     $examenes = HoraExamenSolicitado::find()->where(['hora_id' => $hora->id])->all();
                     for ($i = 0; $i < count($examenes); ++$i) {
                         $examen = Examen::find()->where(['id' => $examenes[$i]->examen_id])->one();
                         $modelsExamenes[$i] = new RceExamenExamen();
                         $modelsExamenes[$i]->rce_examen_id = $model->id;
                         $modelsExamenes[$i]->examen_id = $examenes[$i]->examen_id;
                         $modelsExamenes[$i]->monto_a_pagar = $examen->monto;
                         if (!($flag = $modelsExamenes[$i]->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('update', ['model' => $model, 'modelsPago' => empty($modelsPago) ? [new Pago()] : $modelsPago, 'modelsBitacora' => empty($modelsBitacora) ? [new Bitacora()] : $modelsBitacora, 'modelsExamenes' => empty($modelsExamenes) ? [new RceExamenExamen()] : $modelsExamenes]);
 }
 /**
  * Finds the Hora model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Hora the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Hora::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getHoras()
 {
     return $this->hasMany(Hora::className(), ['profesional_id' => 'id']);
 }
Exemple #10
0
 public function getHora()
 {
     $reserva = Reserva::find()->where(['id' => $this->reserva_id])->one();
     $hora = Hora::find()->where(['id' => $reserva->hora_medica_id])->one();
     return $hora->hora_inicio;
 }
 /**
  * Updates an existing Reserva model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelHora = $model->horaMedica;
     $modelsExamen = $modelHora->horaExamenSolicitados;
     if ($model->load(Yii::$app->request->post()) && $modelHora->load(Yii::$app->request->post())) {
         $oldIDHora = ArrayHelper::map($modelHora, 'id', 'id');
         $modelHora = new Hora();
         Model::load($modelHora, Yii::$app->request->post());
         $deletedIDHora = array_diff($oldIDHora, array_filter(ArrayHelper::map($modelHora, 'id', 'id')));
         $oldIDsExamen = ArrayHelper::map($modelsExamen, 'id', 'id');
         $modelsExamen = Model::createMultiple(Pago::classname(), $modelsExamen);
         Model::loadMultiple($modelsExamen, Yii::$app->request->post());
         $deletedIDsExamen = array_diff($oldIDsExamen, array_filter(ArrayHelper::map($modelsExamen, 'id', 'id')));
         $valid = $model->validate();
         $valid = $modelHora->validate();
         $valid = Model::validateMultiple($modelsExamen) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $model->save(false)) {
                     if (!empty($deletedIDHora)) {
                         Hora::deleteAll(['id' => $deletedIDHora]);
                     } else {
                         if (!empty($deletedIDsExamen)) {
                             HoraExamenSolicitado::deleteAll(['id' => $deletedIDsExamen]);
                         }
                     }
                     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();
             }
         }
     }
     return $this->render('update', ['model' => $model, 'modelHora' => $modelHora, 'modelsExamen' => empty($modelsExamen) ? [new HoraExamenSolicitado()] : $modelsExamen]);
 }
Exemple #12
0
use yii\helpers\ArrayHelper;
use app\models\Hora;
use app\models\Examen;
/* @var $this yii\web\View */
/* @var $model app\models\HoraExamenSolicitado */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="hora-examen-solicitado-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'hora_id')->dropDownList(ArrayHelper::map(Hora::find()->all(), 'id', 'hora_inicio'), ['prompt' => 'Seleccionar Hora', 'style' => 'width:300px']);
?>

    <?php 
echo $form->field($model, 'examen_id')->dropDownList(ArrayHelper::map(Examen::find()->all(), 'id', 'descripcion'), ['prompt' => 'Seleccionar Examen', 'style' => 'width:300px']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Ingresar Hora Examen Solicitado' : 'Actualizar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>