Beispiel #1
0
 public function actionModificar()
 {
     $msg = null;
     $model = new ValidarCategoria();
     if (isset($_REQUEST['id_categoria'])) {
         $model->id_categoria = $_REQUEST['id_categoria'];
         $table = Categoria::findOne($model->id_categoria);
         $model->nombre = $table->nombre;
         $model->edad_min = $table->edad_minima;
         $model->edad_max = $table->edad_maxima;
         $model->deporte = $table->id_deporte;
         $model->profesor_suplente = $table->id_profesor_suplente;
         $model->profesor_titular = $table->id_profesor_titular;
     }
     if ($model->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $table = Categoria::findOne($model->id_categoria);
             $table->nombre = $model->nombre;
             $table->edad_maxima = $model->edad_max;
             $table->edad_minima = $model->edad_min;
             $table->id_deporte = $model->deporte;
             $table->id_profesor_suplente = $model->profesor_suplente;
             $table->id_profesor_titular = $model->profesor_titular;
             if ($table->update()) {
                 $msg = "modificado con exito";
                 $model->nombre = NULL;
                 $model->edad_min = NULL;
                 $model->edad_max = NULL;
                 $model->deporte = NULL;
                 $model->profesor_suplente = NULL;
                 $model->profesor_titular = NULL;
                 $this->redirect(["categoria/buscar", 'msg' => $msg]);
             }
         }
     }
     $deporte = ArrayHelper::map(Deporte::find()->all(), 'id_deporte', 'nombre');
     $profesor = ArrayHelper::map(Profesor::find()->all(), 'dni', 'nombre');
     return $this->render("modificar_categoria", ['msg' => $msg, 'model' => $model, 'profesor' => $profesor, 'deporte' => $deporte]);
 }
 /**
  * Finds the Categoria model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Categoria the loaded modelCategoria
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($modelCategoria = Categoria::findOne($id)) !== null) {
         return $modelCategoria;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #3
0
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $searchModel app\models\MetasCoberturaSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Metas Coberturas');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="metas-cobertura-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Registrar Metas Cobertura'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'categoria', 'value' => function ($model) {
    return \app\models\Categoria::findOne(['id' => $model->categoria])->nombre;
}, 'filter' => Select2::widget(['name' => 'id', 'attribute' => 'id', 'model' => $searchModel, 'data' => ArrayHelper::map(Categoria::find()->all(), 'id', 'nombre'), 'options' => ['placeholder' => 'Categoría'], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'ano', 'value' => 'ano', 'filter' => Html::activeDropDownList($searchModel, 'ano', [2015 => "2015", 2016 => "2016", 2017 => "2017", 2018 => "2018", 2019 => "2019", 2020 => "2020"], ['class' => 'form-control'])], 'cobertura:integer', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
Beispiel #4
0
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\SubcategoriaSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Subcategorias');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="subcategoria-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Crear Subcategoria'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'categoria', 'value' => function ($model) {
    return Categoria::findOne(['id' => $model->categoria])->nombre;
}, 'filter' => Select2::widget(['name' => 'categoria', 'attribute' => 'categoria', 'model' => $searchModel, 'data' => ArrayHelper::map(Categoria::find()->all(), 'id', 'nombre'), 'options' => ['placeholder' => 'Categoría'], 'pluginOptions' => ['allowClear' => true]])], 'nombre', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Beispiel #5
0
 public function afterFind()
 {
     list($ano, $mes, $dia) = split('[-]', $this->data);
     $this->data = $dia . '/' . $mes . '/' . $ano;
     if ($this->dataConclusao != null) {
         list($ano, $mes, $dia) = split('[-]', $this->dataConclusao);
         $this->dataConclusao = $dia . '/' . $mes . '/' . $ano;
     }
     if ($this->hora != null) {
         list($hora, $minuto, $segundos) = split('[:]', $this->hora);
         $this->hora = $hora . ':' . $minuto;
     }
     $foto = FotoController::getFotoOcorrencia($this->idOcorrencia);
     if ($foto != null) {
         $this->comentarioFoto = $foto[0]->comentario;
     }
     $this->idCategoriabkp = $this->idCategoria;
     //    echo "Categoria bkp".$this->idCategoriabkp;
     $this->idSubLocalbkp = $this->idSubLocal;
     $this->idNaturezabkp = $this->idNatureza;
     $sublocal = Sublocal::findOne($this->idSubLocal);
     $this->idLocal = $sublocal->idLocal;
     $this->cpfbkp = $this->cpfUsuario;
     $this->idSubLocal = Sublocal::findOne($this->idSubLocal)->Nome;
     $this->cpfUsuario = User::findOne($this->cpfUsuario)->nome;
     $this->idNatureza = Naturezaocorrencia::findOne($this->idNatureza)->Nome;
     $this->idCategoria = Categoria::findOne($this->idCategoria)->Nome;
     if ($this->status == 1) {
         $this->status = 'Aberto';
     } elseif ($this->status == 2) {
         $this->status = 'Solucionado';
     } elseif ($this->status == 3) {
         $this->status = 'Não Solucionado';
     }
     if ($this->periodo == 1) {
         $this->periodo = 'Manhã';
     } elseif ($this->periodo == 2) {
         $this->periodo = 'Tarde';
     } elseif ($this->periodo == 3) {
         $this->periodo = 'Noite';
     } elseif ($this->periodo == 4) {
         $this->periodo = 'Madrugada';
     }
 }
 public function actionAgregar($dni)
 {
     session_start();
     if (isset($_SESSION['categoria']) && is_numeric($dni)) {
         $id_categoria = $_SESSION['categoria'];
         $id_deporte = Categoria::findOne($id_categoria);
         Yii::$app->db->createCommand("insert into deportista_categoria (dni,id_categoria,id_deporte,activo) value('{$dni}','{$id_categoria}',{$id_deporte->id_deporte},0)")->execute();
         $this->redirect(["deportista/buscarprueba"]);
     }
 }