Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(ClienteRequest $request)
 {
     $contacto = new Contacto();
     $contacto->fill($request->all());
     $contacto->save();
     $persona = new Persona();
     $persona->fill($request->all());
     $persona->fecha_nacimiento = Carbon::createFromTimestamp(strtotime($request->fecha_nacimiento))->format('Y-m-d');
     $persona->contacto_id = $contacto->id;
     $persona->save();
     $cliente = new Cliente();
     $cliente->fill($request->all());
     $cliente->fecha_registro = Carbon::now();
     $cliente->numero_cliente = '000' . $persona->id;
     $cliente->persona_id = $persona->id;
     $cliente->save();
     $pregunta = new PreguntaSecreta();
     $pregunta->fill($request->all());
     $pregunta->save();
     $cuenta = new Cuenta();
     $cuenta->fill($request->all());
     $cuenta->cliente_id = $cliente->id;
     $cuenta->placa_auto = '';
     $cuenta->credito_disponible = 0;
     $cuenta->sucursal_gasolinera_id = $request->sucursal_gasolinera_id;
     $cuenta->pregunta_secreta_id = $pregunta->id;
     $cuenta->save();
     $usuario = new User();
     $usuario->name = $request->name;
     $usuario->password = bcrypt($request->password);
     $usuario->email = $request->correo;
     $usuario->cliente_id = $cliente->id;
     $usuario->save();
     return redirect()->route('cliente.index');
 }
Beispiel #2
0
 public function RegistrarInscripcion(&$Persona, $DetalleInscripcion)
 {
     //verificamos si existe la parsona;
     $flag;
     $aux = Persona::find()->where(['ci' => $Persona->ci])->one();
     $DetalleInscripcion = DynamicFormModel::createMultiple(InscripcionExamen::className());
     DynamicFormModel::loadMultiple($DetalleInscripcion, Yii::$app->request->post());
     $valid = $Persona->validate();
     $valid = DynamicFormModel::validateMultiple($DetalleInscripcion) && $valid;
     if ($aux != null) {
         $Persona = $aux;
     } else {
         $Persona->eliminado = 0;
         $flag = $Persona->save(false);
     }
     foreach ($DetalleInscripcion as $i => $DetalleInscripcion) {
         //$DetalleInscripcion->idAlumno = $Persona;
         $DetalleInscripcion->fecha_inscripcion = date('Y-m-d H:i:s');
         $DetalleInscripcion->eliminado = 0;
         if (!($flag = $DetalleInscripcion->save(false))) {
             $transaction->rollBack();
             return false;
         }
         $DetalleInscripcion->link('idAlumno', $Persona);
     }
     return true;
 }
Beispiel #3
0
 public function dni_existe($attribute, $params)
 {
     $table = Persona::find()->where("dni=:dni", [":dni" => $this->dni]);
     if ($table->count() != 0) {
         $this->addError($attribute, "El dni seleccionado existe");
     }
 }
Beispiel #4
0
 public function email_existe($attribute, $params)
 {
     //Buscar el email en la tabla
     $table = Persona::find()->where("email=:email", [":email" => $this->email]);
     //Si el email existe mostrar el error
     if ($table->count() != 0) {
         $this->addError($attribute, "El email seleccionado existe");
     }
 }
Beispiel #5
0
 public static function findByUsername($username)
 {
     $users = Persona::find()->where(['email' => $username])->one();
     if (!count($users)) {
         return null;
     } else {
         return new static($users);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Persona::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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_PERSONA' => $this->ID_PERSONA]);
     $query->andFilterWhere(['like', 'NOMBRE', $this->NOMBRE]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Persona::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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, 'fechaNacimiento' => $this->fechaNacimiento, 'localidad_id' => $this->localidad_id]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellido', $this->apellido])->andFilterWhere(['like', 'mail', $this->mail])->andFilterWhere(['like', 'domicilio', $this->domicilio])->andFilterWhere(['like', 'telefono', $this->telefono]);
     return $dataProvider;
 }
Beispiel #8
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(UserCreateRequest $request)
 {
     $persona = new Persona();
     $persona->fill($request->all());
     $persona->contacto_id = 1;
     $persona->fecha_nacimiento = Carbon::createFromTimestamp(strtotime($persona->fecha_nacimiento))->format('Y-m-d');
     $persona->save();
     $cliente = new Cliente();
     $cliente->numero_cliente = 0;
     $cliente->curp = '';
     $cliente->rfc = '';
     $cliente->razon_social = '';
     $cliente->actividad_economica = '';
     $cliente->fecha_registro = Carbon::now();
     $cliente->persona_id = $persona->id;
     $cliente->save();
     $user = new User();
     $user->fill($request->all());
     $user->password = bcrypt($request->password);
     $user->cliente_id = $cliente->id;
     $user->save();
     $user->roles()->sync($request->roles);
     return redirect()->route('usuario.index');
 }
 /**
  * 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]);
     }
 }
 public function actionFind($q = null, $id = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $out = ['results' => ['id' => '', 'nombre' => '']];
     if (!is_null($q)) {
         $query = new \yii\db\Query();
         $query->select('id, nombre')->from('persona')->where(['like', 'nombre', $q])->limit(10);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'nombre' => Persona::find($id)->nombre];
     }
     return $out;
 }
Beispiel #11
0
 public function actionReset($dni)
 {
     $form = new ValidarBusqueda();
     if (is_numeric($dni)) {
         $tabla = Persona::findOne($_REQUEST['dni']);
         $email = $tabla->email;
         $contra = $this->randKey("abcdef0123456789", 6);
         $pass = crypt($contra, Yii::$app->params["salt"]);
         $tabla = Users::findOne($_REQUEST['dni']);
         $tabla->contrasenia = $pass;
         if ($tabla->update()) {
             $subject = "Nueva contrasenia";
             $body = "<h1>Su contraseña a sido reseteada</h1>";
             $body .= "<a >Usuario: {$tabla->nombre_usuario}</a> ";
             $body .= "<a>Contraseña: {$contra} </a>";
             $body .= "<a>Por favor cambie su contraseña luego de loguearse </a>";
             $body .= "<p><a href='http://localhost/basic/web/index.php'>Login</a></p>";
             Yii::$app->mailer->compose()->setTo($email)->setFrom([Yii::$app->params["adminEmail"] => Yii::$app->params["title"]])->setSubject($subject)->setHtmlBody($body)->send();
             $msg = "contraseña reseteada con exito";
         } else {
             $msg = "problemas al resetear";
         }
     } else {
         $msg = "usuario no encontrado";
     }
     $this->redirect(["usuario/buscar", 'msg' => $msg]);
 }
Beispiel #12
0
 public function getNombresAdministrador()
 {
     $administrador = Persona::find()->where(['id' => $this->administrador_id])->one();
     return $administrador->getfullName();
 }
 /**
  * Creates a new RceExamen model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new RceExamen();
     $modelsPago = [new Pago()];
     $modelsBitacora = [new Bitacora()];
     $modelsExamenes = [new RceExamenExamen()];
     $userId = Yii::$app->user->getId();
     $persona = Persona::find()->where(['id' => $userId])->one();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $modelsPago = Model::createMultiple(Pago::classname());
         Model::loadMultiple($modelsPago, Yii::$app->request->post());
         $modelsBitacora = Model::createMultiple(Bitacora::classname());
         Model::loadMultiple($modelsBitacora, Yii::$app->request->post());
         $modelsExamenes = Model::createMultiple(RceExamenExamen::classname());
         Model::loadMultiple($modelsExamenes, Yii::$app->request->post());
         // 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)) {
                     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;
                         $modelBitacora->persona_id_ingresa_bitacora = $persona->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();
             }
         }
     } else {
         return $this->render('create', ['model' => $model, 'modelsPago' => empty($modelsPago) ? [new Pago()] : $modelsPago, 'modelsBitacora' => empty($modelsBitacora) ? [new Bitacora()] : $modelsBitacora, 'modelsExamenes' => empty($modelsExamenes) ? [new RceExamenExamen()] : $modelsExamenes]);
     }
 }
 /**
  * Updates an existing InscripcionExamen model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionGetPersonaByCi($ci)
 {
     $persona = Persona::find()->where(['ci' => $ci, 'eliminado' => 0])->one();
     echo Json::encode($persona);
 }
Beispiel #15
0
 public function excel($params)
 {
     $query = Persona::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, 'fecha_nacimiento' => $this->fecha_nacimiento]);
     $query->andFilterWhere(['like', 'rut', $this->rut])->andFilterWhere(['like', 'nombres', $this->nombres])->andFilterWhere(['like', 'apellido_paterno', $this->apellido_paterno])->andFilterWhere(['like', 'apellido_materno', $this->apellido_materno])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'identificadorfacebook', $this->identificadorfacebook]);
     return $dataProvider;
 }
Beispiel #16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $asociado = Asociado::findOrFail($id);
     $asociado->fill($request->all());
     $asociado->save();
     $persona = Persona::findOrFail($asociado->persona_id);
     $persona->fill($request->all());
     $persona->fecha_nacimiento = Carbon::createFromTimestamp(strtotime($persona->fecha_nacimiento))->format('Y-m-d');
     $persona->save();
     return redirect()->route('cliente.asociados', $asociado->cliente_id);
 }
 /**
  * Finds the Persona model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Persona the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Persona::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPersona()
 {
     return $this->hasOne(Persona::className(), ['id' => 'persona_id']);
 }
Beispiel #19
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPersonaIdRealizaExamen()
 {
     return $this->hasOne(Persona::className(), ['id' => 'persona_id_realiza_examen']);
 }
 /**
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function removeCollaborator(Request $request)
 {
     try {
         $user = AuthenticateController::checkUser(null);
         $user->load('Persona');
         $persona = Persona::find($request->idPersona);
         $proyecto = $user->Persona->Proyecto()->where('Proyecto.id', $request->idProyecto)->first();
         if ($proyecto == null || $persona == null) {
             return response()->json(['message' => 'server_error'], 500);
         }
         if ($proyecto->pivot->Owner != 1) {
             return response()->json(['message' => 'owner_not_matching'], 500);
         } else {
             $proyecto_persona = $proyecto->Persona()->where('Persona.id', $request->idPersona)->where('Owner', 0)->first();
             if ($proyecto_persona == null) {
                 return response()->json(['message' => 'server_error'], 200);
             }
             $proyecto_persona->delete();
             return response()->json(['message' => 'success'], 200);
         }
     } catch (QueryException $e) {
         return response()->json(['message' => 'server_error', 'exception' => $e->getMessage()], 500);
     } catch (Exceptions\TokenExpiredException $e) {
         return response()->json(['token_expired'], $e->getStatusCode());
     } catch (Exceptions\TokenInvalidException $e) {
         return response()->json(['token_invalid'], $e->getStatusCode());
     } catch (Exceptions\JWTException $e) {
         return response()->json(['token_absent'], $e->getStatusCode());
     }
 }
    <?php 
$dataPersona = \yii\helpers\ArrayHelper::map(\app\models\Persona::find()->asArray()->all(), 'id', 'nombre');
$dataTipoPersona = \yii\helpers\ArrayHelper::map(\app\models\TipoPersona::find()->asArray()->all(), 'id', 'nombre');
//         $form->field($model, 'nombre', [
//                'hintType' => ActiveField::HINT_SPECIAL,
//                'hintSettings' => [
//                    'showIcon' => false,
//                    'title' => '<i class="glyphicon glyphicon-info-sign"></i> Nota'
//                ]
//                ])->textInput()->hint('Ingrese el nombre/designación con que se describirá el objeto.');
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 2, 'attributes' => ['persona_id' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'label' => 'Persona Donante', 'options' => ['options' => ['placeholder' => 'Seleccione Persona...'], 'data' => $dataPersona, 'pluginOptions' => ['allowClear' => true]]], 'tipoPersona_id' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'options' => ['options' => ['placeholder' => 'Seleccione Tipo de Persona...'], 'data' => $dataTipoPersona, 'pluginOptions' => ['allowClear' => true]]]]]);
?>
        
    <?php 
$dataPersonaDonante = \yii\helpers\ArrayHelper::map(\app\models\Persona::find()->asArray()->all(), 'id', 'nombre');
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['persona_id_depositante' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'label' => 'Persona Depositante', 'options' => ['options' => ['placeholder' => 'Seleccione Persona Depositante...'], 'data' => $dataPersona, 'pluginOptions' => ['allowClear' => true]]]]]);
?>



    </div>
    
    <div>       
    <?php 
$heading = '<i class="glyphicon glyphicon-book"></i> Acervos';
$gridColumns = [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'nombre', 'vAlign' => 'middle', 'format' => 'raw', 'noWrap' => true], ['attribute' => 'nroInventario', 'vAlign' => 'middle', 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column']], ['class' => 'kartik\\grid\\ActionColumn', 'dropdownOptions' => ['class' => 'pull-right'], 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action == 'update') {
        return Url::toRoute(['acervo/update-ingreso', 'id' => $key]);
    }
    if ($action == 'view') {
Beispiel #22
0
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use app\models\Persona;
/* @var $this yii\web\View */
/* @var $model app\models\Paciente */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="paciente-form">

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

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

    <?php 
echo $form->field($model, 'nombres');
?>

    <?php 
echo $form->field($model, 'descripcion')->textArea(['rows' => '6', 'style' => 'width:300px']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Ingresar Paciente' : 'Actualizar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
Beispiel #23
0
 public function getNombres()
 {
     $persona = Persona::find()->where(['id' => $this->persona_id])->one();
     return $persona->getfullName();
 }
Beispiel #24
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdAlumno()
 {
     return $this->hasOne(Persona::className(), ['id' => 'id_alumno']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPersonas()
 {
     return $this->hasMany(Persona::className(), ['localidad_id' => 'id']);
 }
Beispiel #26
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdPersona()
 {
     return $this->hasOne(Persona::className(), ['id' => 'id_persona']);
 }
Beispiel #27
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPersonas()
 {
     return $this->hasMany(Persona::className(), ['id_colegio' => 'id']);
 }
Beispiel #28
0
 public function actionModificar()
 {
     $model = new ValidarDeportistamodif();
     $msg = null;
     if ($model->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if (isset($_REQUEST['dni'])) {
         if ((int) $_REQUEST['dni']) {
             $model->dni = $_REQUEST['dni'];
             $table = Deportista::findOne($model->dni);
             $model->numero_socio = $table->numero_socio;
             $id = $table->id_planilla;
             $table = Persona::findOne($model->dni);
             $model->nombre = $table->nombre;
             $model->apellido = $table->apellido;
             $model->domicilio = $table->domicilio;
             $model->telefono = $table->telefono;
             $model->email = $table->email;
             $table = Planilla::findOne($id);
             $model->medico_cabecera = $table->medico_cabecera;
             $model->grupo_sanguineo = $table->grupo_sanguineo;
             $model->obra_social = $table->obra_social;
             $model->medicamento = $table->medicamento;
             $model->desc_medicamento = $table->desc_medicamento;
             $model->alergia = $table->alergia;
             $model->desc_alergia = $table->desc_alergia;
             $model->anemia = $table->anemia;
             $model->enf_cardiologica = $table->enf_cardiologica;
             $model->desc_cardiologia = $table->desc_cardiologia;
             $model->asma = $table->asma;
             $model->desc_asma = $table->desc_asma;
             $model->presion = $table->presion;
             $model->convulsiones = $table->convulsiones;
             $model->ultima_convulsion = $table->ultima_convulsion;
             $model->trastornos_hemorragicos = $table->trastornos_hemorragicos;
             $model->fuma = $table->fuma;
             $model->cuanto_fuma = $table->cuanto_fuma;
             $model->diabetes = $table->diabetes;
             $model->desc_diabetes = $table->desc_diabetes;
             $model->tratamiento = $table->tratamiento;
             $model->desc_tratamiento = $table->desc_tratamiento;
             $model->internaciones = $table->internaciones;
             $model->desc_internacion = $table->medico_cabecera;
             $model->nombreyapellido1 = $table->nombreyapellido1;
             $model->domicilio1 = $table->domicilio1;
             $model->telefono1 = $table->telefono1;
             $model->nombreyapellido2 = $table->nombreyapellido2;
             $model->domicilio2 = $table->domicilio2;
             $model->telefono2 = $table->telefono2;
             $model->observaciones = $table->observaciones;
             $table = Deportista_cat::find()->where(['dni' => $model->dni])->count();
             $cant = $table;
             switch ($table) {
                 case 1:
                     $table = Deportista_cat::find()->where(['dni' => $model->dni])->offset(0)->one();
                     $model->deporte1 = $table->id_deporte;
                     $model->categoria1 = $table->id_categoria;
                     $model->aux1 = $model->categoria1;
                     break;
                 case 2:
                     $table = Deportista_cat::find()->where(['dni' => $model->dni])->offset(0)->one();
                     $model->deporte1 = $table->id_deporte;
                     $model->categoria1 = $table->id_categoria;
                     $table = Deportista_cat::find()->where(['dni' => $model->dni])->offset(1)->one();
                     $model->deporte2 = $table->id_deporte;
                     $model->categoria2 = $table->id_categoria;
                     $model->aux1 = $model->categoria1;
                     $model->aux2 = $model->categoria2;
                     break;
                 case 3:
                     $table = Deportista_cat::find()->where(['dni' => $model->dni])->offset(0)->one();
                     $model->deporte1 = $table->id_deporte;
                     $model->categoria1 = $table->id_categoria;
                     $table = Deportista_cat::find()->where(['dni' => $model->dni])->offset(1)->one();
                     $model->deporte2 = $table->id_deporte;
                     $model->categoria2 = $table->id_categoria;
                     $table = Deportista_cat::find()->where(['dni' => $model->dni])->offset(2)->one();
                     $model->deporte3 = $table->id_deporte;
                     $model->categoria3 = $table->id_categoria;
                     $model->aux1 = $model->categoria1;
                     $model->aux2 = $model->categoria2;
                     $model->aux3 = $model->categoria3;
                     break;
             }
         }
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $datos = array("0" => array('deporte' => $model->deporte1, 'categoria' => $model->categoria1, 'aux' => $model->aux1), "1" => array('deporte' => $model->deporte1, 'categoria' => $model->categoria1, 'aux' => $model->aux1), "2" => array('deporte' => $model->deporte1, 'categoria' => $model->categoria1, 'aux' => $model->aux1));
             $connection = \Yii::$app->db;
             $transaction = $connection->beginTransaction();
             $sql1 = "UPDATE persona SET dni='{$model->dni}',nombre='{$model->nombre}',apellido='{$model->apellido}' where persona.dni='{$model->dni}' ";
             $sql2 = "update planilla,deportista set medico_cabecera='{$model->medico_cabecera}',grupo_sanguineo='{$model->grupo_sanguineo}',obra_social='{$model->obra_social}',medicamento='{$model->medicamento}',desc_medicamento='{$model->desc_medicamento}',\n                    alergia='{$model->alergia}',desc_alergia='{$model->desc_alergia}',anemia='{$model->anemia}',enf_cardiologica='{$model->enf_cardiologica}',desc_cardiologia='{$model->desc_cardiologia}',asma='{$model->asma}',desc_asma='{$model->desc_asma}',presion='{$model->presion}',convulsiones='{$model->convulsiones}',ultima_convulsion='{$model->ultima_convulsion}',\n                       trastornos_hemorragicos='{$model->trastornos_hemorragicos}',fuma='{$model->fuma}',cuanto_fuma='{$model->cuanto_fuma}',diabetes='{$model->diabetes}',desc_diabetes='{$model->desc_diabetes}',tratamiento='{$model->tratamiento}',desc_tratamiento='{$model->desc_tratamiento}',internaciones='{$model->internaciones}',desc_internacion='{$model->desc_internacion}',nombreyapellido1='{$model->nombreyapellido1}',domicilio1='{$model->domicilio1}',\n                            telefono1='{$model->telefono1}',nombreyapellido2='{$model->nombreyapellido2}',domicilio2='{$model->domicilio2}',telefono2='{$model->telefono2}',observaciones='{$model->observaciones}' where planilla.id_planilla=deportista.id_planilla";
             foreach ($datos as $val) {
                 if ($val['categoria'] != "") {
                     $deporte = $val['deporte'];
                     $categoria = $val['categoria'];
                     $aux = $val['aux'];
                     $connection->createCommand("update deportista_categoria set id_categoria={$categoria}, id_deporte={$deporte} where dni={$model->dni} and id_categoria={$aux}")->execute();
                 }
             }
             try {
                 $connection->createCommand($sql1)->execute();
                 $connection->createCommand($sql2)->execute();
                 $sql3 = "UPDATE deportista SET numero_socio='{$model->numero_socio}' where deportista.dni='{$model->dni}'";
                 $connection->createCommand($sql3)->execute();
                 $transaction->commit();
                 $msg = "Modificacion realizada con exito realizada con exito";
                 $model->nombre = null;
                 $model->apellido = null;
                 $model->dni = NULL;
                 $model->domicilio = null;
                 $model->telefono = null;
                 $model->telefono1 = null;
                 $model->email = null;
                 $model->numero_socio = null;
                 $model->medico_cabecera = null;
                 $model->grupo_sanguineo = null;
                 $model->obra_social = null;
                 $model->medicamento = null;
                 $model->desc_medicamento = null;
                 $model->alergia = null;
                 $model->desc_alergia = null;
                 $model->anemia = null;
                 $model->enf_cardiologica = null;
                 $model->desc_cardiologia = null;
                 $model->asma = null;
                 $model->desc_asma = null;
                 $model->presion = null;
                 $model->convulsiones = null;
                 $model->ultima_convulsion = null;
                 $model->trastornos_hemorragicos = null;
                 $model->fuma = null;
                 $model->cuanto_fuma = null;
                 $model->diabetes = null;
                 $model->desc_diabetes = null;
                 $model->tratamiento = null;
                 $model->desc_tratamiento = null;
                 $model->internaciones = null;
                 $model->desc_internacion = null;
                 $model->nombreyapellido1 = null;
                 $model->domicilio1 = null;
                 $model->telefono1 = null;
                 $model->nombreyapellido2 = null;
                 $model->domicilio2 = null;
                 $model->telefono2 = null;
                 $model->observaciones = null;
                 $this->redirect(["deportista/buscar", 'msg' => $msg]);
             } catch (\Exception $e) {
                 $msg = "Registracion realizada con exito";
                 $transaction->rollBack();
                 throw $e;
             }
         }
     }
     $deporte = ArrayHelper::map(Deporte::find()->all(), 'id_deporte', 'nombre');
     $categoria = ArrayHelper::map(Categoria::find()->all(), 'id_categoria', 'nombre_categoria');
     return $this->render("modificar_deportista", ["model" => $model, "msg" => $msg, 'deporte' => $deporte, 'categoria' => $categoria, 'cant' => $cant]);
 }
 public function getPersonaDepositanteTexto()
 {
     $persona = $this->hasOne(Persona::className(), ['id' => 'persona_id_depositante'])->one();
     //   var_dump($persona); die();
     if ($persona) {
         return $persona->apellido . ' ' . $persona->nombre;
     }
     return '';
 }