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"); } }
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; }
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"); } }
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; }
/** * 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]); } }
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>
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; }
/** * @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()); } }
/** * 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); }
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]); } }
/** * Lists all Persona models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Persona::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
<?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') {
public function getNombres() { $persona = Persona::find()->where(['id' => $this->persona_id])->one(); return $persona->getfullName(); }
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; }