add inventory group
This commit is contained in:
@@ -90,6 +90,7 @@ class AdminMenuStructure{
|
||||
$items = [];
|
||||
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
||||
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
||||
$items[] = ['label' => 'Leltár csoport', 'url' => ['/inventory-group/index'] ];
|
||||
$items[] = ['label' => 'Részletes eladások', 'url' => ['/transfer/sale' ,'TransferSaleSearch[start]' =>$todayDatetime,'TransferSaleSearch[end]' => $tomorrowDatetime ] ];
|
||||
$items[] = ['label' => 'Termék összesítő', 'url' => ['/product/statistics' ,'ProductStatisticsSearch[start]' =>$todayDatetime,'ProductStatisticsSearch[end]' => $tomorrowDatetime ] ];
|
||||
$this->menuItems[] = ['label' => 'Termékek', 'url' => $this->emptyUrl,
|
||||
|
||||
139
backend/controllers/InventoryGroupController.php
Normal file
139
backend/controllers/InventoryGroupController.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\InventoryGroup;
|
||||
use backend\models\InventoryGroupSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use common\models\Product;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
/**
|
||||
* InventoryGroupController implements the CRUD actions for InventoryGroup model.
|
||||
*/
|
||||
class InventoryGroupController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all InventoryGroup models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new InventoryGroupSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single InventoryGroup model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
$products = Product::find()->andWhere(['id_inventory_group' => $model->id_inventory_group])->all();
|
||||
|
||||
$pdb = new ArrayDataProvider(
|
||||
[
|
||||
'pagination' => false,
|
||||
'sort' => false,
|
||||
'models' => $products
|
||||
]
|
||||
);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'products' => $pdb
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new InventoryGroup model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new InventoryGroup();
|
||||
|
||||
$model->status = InventoryGroup::STATUS_ACTIVE;
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['index' ]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates an existing InventoryGroup 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(['index' ]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing InventoryGroup 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 InventoryGroup model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return InventoryGroup the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = InventoryGroup::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
70
backend/models/InventoryGroupSearch.php
Normal file
70
backend/models/InventoryGroupSearch.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\InventoryGroup;
|
||||
|
||||
/**
|
||||
* InventoryGroupSearch represents the model behind the search form about `common\models\InventoryGroup`.
|
||||
*/
|
||||
class InventoryGroupSearch extends InventoryGroup
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_inventory_group', 'id_product_category', 'status'], 'integer'],
|
||||
[['name', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = InventoryGroup::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $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_inventory_group' => $this->id_inventory_group,
|
||||
'id_product_category' => $this->id_product_category,
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
35
backend/views/inventory-group/_form.php
Normal file
35
backend/views/inventory-group/_form.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use common\models\ProductCategory;
|
||||
use frontend\components\HtmlHelper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryGroup */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
$cats = ProductCategory::read();
|
||||
$cats = HtmlHelper::mkOptions($cats, 'id_product_category');
|
||||
?>
|
||||
|
||||
|
||||
<div class="inventory-group-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'id_product_category')->dropDownList($cats) ?>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/inventory_group', 'Létrehoz') : Yii::t('common/inventory_group', 'Módosít'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
37
backend/views/inventory-group/_search.php
Normal file
37
backend/views/inventory-group/_search.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\InventoryGroupSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="inventory-group-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id_inventory_group') ?>
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<?= $form->field($model, 'id_product_category') ?>
|
||||
|
||||
<?= $form->field($model, 'status') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('common/inventory_group', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton(Yii::t('common/inventory_group', 'Reset'), ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
21
backend/views/inventory-group/create.php
Normal file
21
backend/views/inventory-group/create.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryGroup */
|
||||
|
||||
$this->title = Yii::t('common/inventory_group', 'Create Inventory Group');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory_group', 'Inventory Groups'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="inventory-group-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
40
backend/views/inventory-group/index.php
Normal file
40
backend/views/inventory-group/index.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\InventoryGroupSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('common/inventory_group', 'Leltár csoportok');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="inventory-group-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/inventory_group', 'Új leltár csoport'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
|
||||
'id_inventory_group',
|
||||
'name',
|
||||
[
|
||||
'attribute' => 'id_product_category',
|
||||
'value' => 'productCategoryName'
|
||||
],
|
||||
'created_at:datetime',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update}'
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
21
backend/views/inventory-group/update.php
Normal file
21
backend/views/inventory-group/update.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryGroup */
|
||||
|
||||
$this->title = Yii::t('common/inventory_group', 'Leltár csoport módosítása' );
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory_group', 'Inventory Groups'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_inventory_group]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/inventory_group', 'Update');
|
||||
?>
|
||||
<div class="inventory-group-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
59
backend/views/inventory-group/view.php
Normal file
59
backend/views/inventory-group/view.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\grid\GridView;
|
||||
use yii\base\Widget;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryGroup */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory_group', 'Leltár csoportok'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<div class="inventory-group-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/inventory_group', 'Módosít'), ['update', 'id' => $model->id_inventory_group], ['class' => 'btn btn-primary']) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_inventory_group',
|
||||
'name',
|
||||
'id_product_category',
|
||||
'created_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
||||
<h2>Termékek a csoportban</h2>
|
||||
<?php echo GridView::widget([
|
||||
'dataProvider' => $products,
|
||||
'columns' => [
|
||||
[
|
||||
'attribute' =>'id_product',
|
||||
'label' => 'Termék azon'
|
||||
],
|
||||
[
|
||||
'attribute' =>'name',
|
||||
'label' => 'Termék neve'
|
||||
],
|
||||
[
|
||||
'attribute' =>'id_account',
|
||||
'value' => 'accountName',
|
||||
'label' => 'Kassza'
|
||||
]
|
||||
]
|
||||
])?>
|
||||
|
||||
</div>
|
||||
@@ -3,6 +3,7 @@
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\InventoryGroup;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Product */
|
||||
@@ -13,6 +14,9 @@ use yii\helpers\ArrayHelper;
|
||||
$account_options = ArrayHelper::map($accounts, 'id_account', 'name');
|
||||
$product_category_options = ArrayHelper::map($categories, 'id_product_category', 'name');
|
||||
|
||||
$inventory_groups = InventoryGroup::find()->andWhere(['status' => InventoryGroup::STATUS_ACTIVE])->all();
|
||||
$inventory_groups = ['' => ''] + ArrayHelper::map($inventory_groups, "id_inventory_group", "name");
|
||||
|
||||
?>
|
||||
<div class="product-form">
|
||||
|
||||
@@ -23,6 +27,8 @@ $product_category_options = ArrayHelper::map($categories, 'id_product_category',
|
||||
<?= $form->field($model, 'id_account')->dropDownList($account_options) ?>
|
||||
|
||||
<?= $form->field($model, 'id_product_category')->dropDownList($product_category_options) ?>
|
||||
|
||||
<?= $form->field($model, 'id_inventory_group')->dropDownList($inventory_groups) ?>
|
||||
|
||||
<?= $form->field($model, 'product_number')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'statusHuman',
|
||||
'stock',
|
||||
[
|
||||
'attribute' => 'id_inventory_group',
|
||||
'value' => $model->getInventoryGroupName(),
|
||||
],
|
||||
[
|
||||
'attribute' => 'description',
|
||||
'value' => nl2br($model->description),
|
||||
'format' => 'raw'
|
||||
@@ -40,5 +44,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'updated_at:datetime',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user