public function excel($params) { $query = Reserva::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, 'paciente_id' => $this->paciente_id, 'persona_id_ingresa_reserva' => $this->persona_id_ingresa_reserva, 'hora_medica_id' => $this->hora_medica_id, 'fecha' => $this->fecha]); return $dataProvider; }
<?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?> <?php echo $form->field($model, 'procedencia_id')->dropDownList(ArrayHelper::map(Procedencia::find()->all(), 'id', 'descripcion'), ['prompt' => 'Seleccionar Procedencia', 'style' => 'width:300px']); ?> <?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
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(); }
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); }
/** * @return \yii\db\ActiveQuery */ public function getReservas() { return $this->hasMany(Reserva::className(), ['hora_medica_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]); }
/** * @return \yii\db\ActiveQuery */ public function getReservas() { return $this->hasMany(Reserva::className(), ['persona_id_ingresa_reserva' => 'id']); }
public function getReservasSinRCE() { $bitacora = Reserva::find()->where(['id' => $this->reserva_id])->one(); }
public function actionGetReserva($reservaId) { // find the zip code from the locations table $reserva = Reserva::findOne($reservaId); echo Json::encode($reserva); }
/** * @return \yii\db\ActiveQuery */ public function getReservas() { return $this->hasMany(Reserva::className(), ['paciente_id' => 'id']); }