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; field($model, 'number')->textInput(['maxlength' => true]) ?> - field($model, 'status')->textInput() ?> + field($model, 'status')->dropDownList( Key::statuses() ) /*->textInput()*/ ?> field($model, 'type')->textInput() ?> - field($model, 'created_at')->textInput() ?> + field($model, 'created_at')->textInput() ?> - field($model, 'updated_at')->textInput() ?> + field($model, 'updated_at')->textInput() ?>
isNewRecord ? Yii::t('backend/key', 'Create') : Yii::t('backend/key', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> diff --git a/backend/views/key/_search.php b/backend/views/key/_search.php index 6610f21..06395b2 100644 --- a/backend/views/key/_search.php +++ b/backend/views/key/_search.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; +use common\models\Key; /* @var $this yii\web\View */ /* @var $model backend\models\KeySearch */ @@ -15,21 +16,22 @@ use yii\widgets\ActiveForm; 'method' => 'get', ]); ?> - field($model, 'id_key') ?> + field($model, 'id_key') ?> - field($model, 'number') ?> + field($model, 'number') ?> + field($model, 'status')->dropDownList( Key::statuses() ) /*->textInput()*/ ?> - field($model, 'status') ?> + field($model, 'status') ?> - field($model, 'type') ?> + field($model, 'type') ?> - field($model, 'created_at') ?> + field($model, 'created_at') ?> field($model, 'updated_at') ?>
'btn btn-primary']) ?> - 'btn btn-default']) ?> + 'btn btn-default']); /* Reset gomb */ ?>
diff --git a/backend/views/key/create.php b/backend/views/key/create.php index 19177f7..47bc7c7 100644 --- a/backend/views/key/create.php +++ b/backend/views/key/create.php @@ -12,7 +12,7 @@ $this->params['breadcrumbs'][] = $this->title; ?>
-

title) ?>

+

Új kulcs létrehozás title)*/ ?>

render('_form', [ 'model' => $model, diff --git a/backend/views/key/index.php b/backend/views/key/index.php index c8ab4cc..7f9479c 100644 --- a/backend/views/key/index.php +++ b/backend/views/key/index.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use yii\grid\GridView; +use common\models\Key; /* @var $this yii\web\View */ /* @var $searchModel backend\models\KeySearch */ @@ -11,23 +12,33 @@ $this->title = Yii::t('backend/key', 'Keys'); $this->params['breadcrumbs'][] = $this->title; ?>
-asdf +

title) ?>

- render('_search', ['model' => $searchModel]); ?> + render('_search', ['model' => $searchModel]); /* ezt megcsinálni hogy csak numberre lehessen itt a fitness-web/backend/views/key/_search.php töltődik be */?>

- 'btn btn-success']) ?> + 'btn btn-success']); + ?>

$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'), + ]; + } }