コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CortesEnergiaGen::find()->joinWith('generador');
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'enableMultiSort' => true]]);
     $dataProvider->sort->attributes['descripcion'] = ['asc' => ['generadores.descripcion' => SORT_ASC], 'desc' => ['generadores.descripcion' => SORT_DESC]];
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'id_cortes_energia' => $this->id_cortes_energia, 'id_generador' => $this->descripcion, 'hora_desde' => $this->hora_desde, 'hora_hasta' => $this->hora_hasta, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at, 'estado' => $this->estado]);
     $query->andFilterWhere(['like', 'motivo_baja', $this->motivo_baja])->andFilterWhere(['like', 'observaciones', $this->observaciones]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the CortesEnergiaGen model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CortesEnergiaGen the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CortesEnergiaGen::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: ibergonzi/country
$this->registerCss('
.kv-grid-loading {
    opacity: 0.5;
    background: #ffffff url("../images/loading.gif") top center no-repeat !important;
}
');
?>
<div class="cortes-energia-gen-index">

    <h3><?php 
echo Html::encode($this->title . ' ' . Yii::$app->formatter->asDatetime($parent->hora_desde) . ' - ' . Yii::$app->formatter->asTime($parent->hora_hasta));
?>
    </h3>
    <?php 
$columns = [['attribute' => 'descripcion', 'value' => 'generador.descripcion'], ['attribute' => 'hora_desde', 'format' => ['datetime']], ['attribute' => 'hora_hasta', 'format' => ['datetime']], ['attribute' => 'estado', 'value' => function ($data) {
    return CortesEnergiaGen::getEstados($data->estado);
}], 'motivo_baja', ['class' => 'kartik\\grid\\ActionColumn', 'header' => Html::a('<span class="glyphicon glyphicon-plus-sign"></span>', ['create', 'idParent' => $parent->id], ['class' => 'btn-sm btn-primary', 'title' => 'Alta de novedad']), 'template' => '{view} {comentario}', 'buttons' => ['comentario' => function ($url, $model) {
    $c = Comentarios::getComentariosByModelId($model->className(), $model->id);
    $text = '<span class="glyphicon glyphicon-copyright-mark"';
    if (!empty($c)) {
        $text .= ' style="color:#FF8000"></span>';
        $titl = 'Ingresar nuevo/Ver comentarios';
    } else {
        $text .= '></span>';
        $titl = 'Ingresar nuevo comentario';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
							type     :"POST",
							cache    : false,
							url  : $(this).attr("href"),
							success  : function(response) {
コード例 #4
0
ファイル: view.php プロジェクト: ibergonzi/country
$this->title = 'Novedad de generador';
$this->params['breadcrumbs'][] = ['label' => 'Cortes de energía', 'url' => ['cortes-energia/index']];
$this->params['breadcrumbs'][] = ['label' => 'Novedades de generadores', 'url' => ['cortes-energia-gen/index', 'idParent' => $parent->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="cortes-energia-gen-view">

    <h3><?php 
echo Html::encode($this->title . ' ' . Yii::$app->formatter->asDatetime($parent->hora_desde) . ' - ' . Yii::$app->formatter->asTime($parent->hora_hasta));
?>
</h3>

	<?php 
if ($model->estado == CortesEnergiaGen::ESTADO_ACTIVO) {
    echo '<p>';
    if (\Yii::$app->user->can('modificarCorte')) {
        echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
    }
    if (\Yii::$app->user->can('borrarCorte')) {
        echo ' ' . Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger']);
    }
    echo '</p>';
}
?>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['generador.descripcion', 'hora_desde:datetime', 'hora_hasta:datetime', 'userCreatedBy.username', 'created_at:datetime', 'userUpdatedBy.username', 'updated_at:datetime', ['label' => 'Estado', 'value' => CortesEnergiaGen::getEstados($model->estado)], 'motivo_baja']]);
?>

</div>
コード例 #5
0
ファイル: CortesEnergia.php プロジェクト: ibergonzi/country
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCortesEnergiaGen()
 {
     return $this->hasMany(CortesEnergiaGen::className(), ['id_cortes_energia' => 'id']);
 }
コード例 #6
0
ファイル: Generadores.php プロジェクト: ibergonzi/country
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCortesEnergiaGens()
 {
     return $this->hasMany(CortesEnergiaGen::className(), ['id_generador' => 'id']);
 }