diff --git a/backend/config/main.php b/backend/config/main.php index af688c7..d88d098 100644 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -14,12 +14,12 @@ return [ 'bootstrap' => ['log'], 'modules' => [], 'components' => [ - 'request' => [ + /*'request' => [ 'csrfParam' => '_backendCSRF', 'csrfCookie' => [ 'path' => '/backend/web', ], - ], + ],*/ 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => true, diff --git a/backend/controllers/KeyController.php b/backend/controllers/KeyController.php index c07709c..9d2efb7 100644 --- a/backend/controllers/KeyController.php +++ b/backend/controllers/KeyController.php @@ -38,7 +38,7 @@ class KeyController extends Controller // backend/views/kex/index.php return $this->render('index', [ 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, + 'dataProvider' => $dataProvider, //csomagoló osztály a queryhez ]); } diff --git a/backend/models/KeySearch.php b/backend/models/KeySearch.php index 79eeb5b..72f9773 100644 --- a/backend/models/KeySearch.php +++ b/backend/models/KeySearch.php @@ -57,6 +57,7 @@ class KeySearch extends Key $query->andFilterWhere([ 'id_key' => $this->id_key, + 'number' => $this->number, 'status' => $this->status, 'type' => $this->type, 'created_at' => $this->created_at, diff --git a/backend/views/key/_form.php b/backend/views/key/_form.php index 0f26488..3f4d051 100644 --- a/backend/views/key/_form.php +++ b/backend/views/key/_form.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; +use common\models\Key; /* @var $this yii\web\View */ /* @var $model common\models\Key */ @@ -14,13 +15,13 @@ use yii\widgets\ActiveForm; = $form->field($model, 'number')->textInput(['maxlength' => true]) ?> - = $form->field($model, 'status')->textInput() ?> + = $form->field($model, 'status')->dropDownList( Key::statuses() ) /*->textInput()*/ ?> = $form->field($model, 'type')->textInput() ?> - = $form->field($model, 'created_at')->textInput() ?> + field($model, 'created_at')->textInput() ?> - = $form->field($model, 'updated_at')->textInput() ?> + field($model, 'updated_at')->textInput() ?>
- = Html::a(Yii::t('backend/key', 'Create Key'), ['create'], ['class' => 'btn btn-success']) ?> + 'btn btn-success']); + ?>
= GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, + //'filterModel' => $searchModel, // ezt nem szeretjük 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'id_key', + // ['class' => 'yii\grid\SerialColumn'], + // 'id_key', 'number', - 'status', + [ + 'attribute' => 'status', + 'value' => function ($model, $key, $index, $column){ + $statuszok = Key::statuses(); + $result = $statuszok[$model->status]; + return $result; + } + ], + //'status', 'type', 'created_at', // 'updated_at', diff --git a/common/messages/hu/backend/key.php b/common/messages/hu/backend/key.php new file mode 100644 index 0000000..a57a6b4 --- /dev/null +++ b/common/messages/hu/backend/key.php @@ -0,0 +1,8 @@ + 'Kulcsok', + 'Create Key' => 'Új kulcs', + 'Search' => 'Keresés', + 'Reset' => 'Mégsem' +]; +?> diff --git a/common/messages/hu/common/key.php b/common/messages/hu/common/key.php new file mode 100644 index 0000000..4ca4bc0 --- /dev/null +++ b/common/messages/hu/common/key.php @@ -0,0 +1,11 @@ + 'Aktív', + 'Inactive' => 'Inaktív', + 'Number' => 'Név, szám', + 'Status' => 'Státusz', + 'Search' => 'Keresés', + 'Type' => 'Típus', + 'Created At' => 'Létrehozva', +]; +?> diff --git a/common/models/Key.php b/common/models/Key.php index 985a764..de7cb24 100644 --- a/common/models/Key.php +++ b/common/models/Key.php @@ -3,6 +3,7 @@ namespace common\models; use Yii; +use yii\behaviors\TimestampBehavior; /** * This is the model class for table "key". @@ -16,6 +17,8 @@ use Yii; */ class Key extends \yii\db\ActiveRecord { + const STATUS_DELETED = 0; + const STATUS_ACTIVE = 10; /** * @inheritdoc */ @@ -30,15 +33,26 @@ class Key extends \yii\db\ActiveRecord public function rules() { return [ - [['status', 'type'], 'integer'], - [['created_at', 'updated_at'], 'required'], - [['created_at', 'updated_at'], 'safe'], - [['number'], 'string', 'max' => 255] + [['status', 'type'], 'integer'], //csak szám + //[['created_at', 'updated_at'], 'required'],//kötelezőek + //[['created_at', 'updated_at'], 'safe'], //bármi lehet + [['number'], 'string', 'max' => 255], + [['number' ], 'unique'], ]; } + + + public function behaviors() + { + return [ + [ 'class' => TimestampBehavior::className(), //mentés előtt kitölti a save methódus meghívása előtt kitölti a created... mezőket + 'value' => function(){ return date('Y-m-d H:i:s' ); } + ] + ]; + } /** - * @inheritdoc + * @inheritdoc Minden modelnak van egy Attribut labels függvénye ami modelhez tartalmazza a fordítások */ public function attributeLabels() { @@ -51,4 +65,11 @@ class Key extends \yii\db\ActiveRecord 'updated_at' => Yii::t('common/key', 'Updated At'), ]; } + + static function statuses() { + return [ + self::STATUS_ACTIVE => Yii::t('common/key', 'Active'), // t - translate a key a kategoria common/messages/hu/common/key.php mappa (létre kell hozni a fájlt) + self::STATUS_DELETED => Yii::t('common/key', 'Inactive'), + ]; + } }