예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Generadores::find();
     $pageSize = isset($_GET['per-page']) ? $_GET['per-page'] : \Yii::$app->params['generadores.defaultPageSize'];
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'enableMultiSort' => true]]);
     $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, 'activo' => $this->activo]);
     $query->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }
예제 #2
0
파일: index.php 프로젝트: ibergonzi/country
    <h3><?php 
echo Html::encode($this->title);
?>
</h3>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<?php 
$lbl2 = '';
$pdfHeader = ['L' => ['content' => \Yii::$app->params['lblName']], 'C' => ['content' => $this->title . $lbl2, 'font-style' => 'B'], 'R' => ['content' => '']];
$pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']];
$columns = ['id', 'descripcion', ['attribute' => 'activo', 'value' => function ($model) {
    return Generadores::getSiNo($model->activo);
}, 'filter' => Generadores::getSiNo()], ['class' => 'kartik\\grid\\ActionColumn', 'header' => Html::a('<span class="glyphicon glyphicon-plus-sign"></span>', ['create'], ['class' => 'btn-sm btn-primary', 'title' => Yii::t('app', 'Nuevo')]), '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) {
										$("#divcomentarionuevo").html(response);
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGenerador()
 {
     return $this->hasOne(Generadores::className(), ['id' => 'id_generador']);
 }
예제 #4
0
 /**
  * Finds the Generadores model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Generadores the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Generadores::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #5
0
파일: _form.php 프로젝트: ibergonzi/country
use yii\widgets\ActiveForm;
use frontend\models\Generadores;
use kartik\datecontrol\DateControl;
/* @var $this yii\web\View */
/* @var $model frontend\models\CortesEnergiaGen */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="cortes-energia-gen-form">

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

    <?php 
echo $form->field($model, 'id_generador')->dropDownList(Generadores::getGeneradoresActivos());
?>

    <?php 
echo $form->field($model, 'hora_desde')->widget(DateControl::classname(), ['type' => DateControl::FORMAT_DATETIME, 'displayFormat' => 'php:d/m/Y H:i']);
?>

    <?php 
echo $form->field($model, 'hora_hasta')->widget(DateControl::classname(), ['type' => DateControl::FORMAT_DATETIME, 'displayFormat' => 'php:d/m/Y H:i']);
?>

    <?php 
echo $form->field($model, 'observaciones')->textInput(['maxlength' => true]);
?>

    <div class="form-group">