diff --git a/common/models/MoneyMovement.php b/common/models/MoneyMovement.php new file mode 100644 index 0000000..d2c2e32 --- /dev/null +++ b/common/models/MoneyMovement.php @@ -0,0 +1,61 @@ + 64], + [['comment'], 'string', 'max' => 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id_money_movement' => Yii::t('common/money-movement', 'Id Money Movement'), + 'id_account' => Yii::t('common/money-movement', 'Id Account'), + 'id_user' => Yii::t('common/money-movement', 'Id User'), + 'name' => Yii::t('common/money-movement', 'Name'), + 'type' => Yii::t('common/money-movement', 'Type'), + 'money' => Yii::t('common/money-movement', 'Money'), + 'comment' => Yii::t('common/money-movement', 'Comment'), + 'created_at' => Yii::t('common/money-movement', 'Created At'), + 'updated_at' => Yii::t('common/money-movement', 'Updated At'), + ]; + } +} diff --git a/console/migrations/m151019_061146_add__table__money__movement.php b/console/migrations/m151019_061146_add__table__money__movement.php new file mode 100644 index 0000000..d7736e5 --- /dev/null +++ b/console/migrations/m151019_061146_add__table__money__movement.php @@ -0,0 +1,46 @@ +db->driverName === 'mysql') { + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + $this->createTable('{{%money_movement}}', [ + 'id_money_movement' => $this->primaryKey(), + 'id_account' => $this->integer()->notNull(), + 'id_user' => $this->integer()->notNull(), + 'name' => $this->string(64)->notNull(), + 'type' => $this->integer()->notNull(), + 'money' => $this->integer()->notNull(), + 'comment' => $this->string(255), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + ], $tableOptions); + } + + public function down() + { + echo "m151019_061146_add__table__money__movement cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/components/FrontendMenuStructure.php b/frontend/components/FrontendMenuStructure.php index 091efa4..e076884 100644 --- a/frontend/components/FrontendMenuStructure.php +++ b/frontend/components/FrontendMenuStructure.php @@ -30,6 +30,7 @@ class FrontendMenuStructure{ protected function addRecepcio(){ if ( $this->isLogged() ){ $this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ]; + $this->menuItems[] = ['label' => 'Pénzmozgások', 'url' => ['/money-movement/index'] ]; $this->menuItems[] = ['label' => 'Kassza', 'items' => [ ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index'] ], diff --git a/frontend/controllers/MoneyMovementController.php b/frontend/controllers/MoneyMovementController.php new file mode 100644 index 0000000..6cbc383 --- /dev/null +++ b/frontend/controllers/MoneyMovementController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all MoneyMovement models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new MoneyMovementSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single MoneyMovement model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new MoneyMovement model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new MoneyMovement(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_money_movement]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing MoneyMovement model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_money_movement]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing MoneyMovement model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the MoneyMovement model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return MoneyMovement the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = MoneyMovement::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/models/MoneyMovementSearch.php b/frontend/models/MoneyMovementSearch.php new file mode 100644 index 0000000..2f9109f --- /dev/null +++ b/frontend/models/MoneyMovementSearch.php @@ -0,0 +1,73 @@ + $query, + ]); + + $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; + } + + $query->andFilterWhere([ + 'id_money_movement' => $this->id_money_movement, + 'id_account' => $this->id_account, + 'id_user' => $this->id_user, + 'type' => $this->type, + 'money' => $this->money, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/frontend/views/money-movement/_form.php b/frontend/views/money-movement/_form.php new file mode 100644 index 0000000..c23f1b2 --- /dev/null +++ b/frontend/views/money-movement/_form.php @@ -0,0 +1,37 @@ + + +
+ + + + field($model, 'id_account')->textInput() ?> + + field($model, 'id_user')->textInput() ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'type')->textInput() ?> + + field($model, 'money')->textInput() ?> + + field($model, 'comment')->textInput(['maxlength' => true]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('backend/money-movement', 'Create') : Yii::t('backend/money-movement', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/frontend/views/money-movement/_search.php b/frontend/views/money-movement/_search.php new file mode 100644 index 0000000..79e99aa --- /dev/null +++ b/frontend/views/money-movement/_search.php @@ -0,0 +1,43 @@ + + + diff --git a/frontend/views/money-movement/create.php b/frontend/views/money-movement/create.php new file mode 100644 index 0000000..b726f7e --- /dev/null +++ b/frontend/views/money-movement/create.php @@ -0,0 +1,21 @@ +title = Yii::t('backend/money-movement', 'Create Money Movement'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/money-movement', 'Money Movements'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/money-movement/index.php b/frontend/views/money-movement/index.php new file mode 100644 index 0000000..a4b1133 --- /dev/null +++ b/frontend/views/money-movement/index.php @@ -0,0 +1,42 @@ +title = Yii::t('backend/money-movement', 'Money Movements'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

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

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id_money_movement', + 'id_account', + 'id_user', + 'name', + 'type', + // 'money', + // 'comment', + // 'created_at', + // 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/frontend/views/money-movement/update.php b/frontend/views/money-movement/update.php new file mode 100644 index 0000000..5e380bb --- /dev/null +++ b/frontend/views/money-movement/update.php @@ -0,0 +1,23 @@ +title = Yii::t('backend/money-movement', 'Update {modelClass}: ', [ + 'modelClass' => 'Money Movement', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/money-movement', 'Money Movements'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_money_movement]]; +$this->params['breadcrumbs'][] = Yii::t('backend/money-movement', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/money-movement/view.php b/frontend/views/money-movement/view.php new file mode 100644 index 0000000..34fc19f --- /dev/null +++ b/frontend/views/money-movement/view.php @@ -0,0 +1,43 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/money-movement', 'Money Movements'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_money_movement], ['class' => 'btn btn-primary']) ?> + $model->id_money_movement], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('backend/money-movement', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id_money_movement', + 'id_account', + 'id_user', + 'name', + 'type', + 'money', + 'comment', + 'created_at', + 'updated_at', + ], + ]) ?> + +