diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index 55ca0a3..43ce4d0 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -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, diff --git a/backend/controllers/InventoryGroupController.php b/backend/controllers/InventoryGroupController.php new file mode 100644 index 0000000..2f5a5a0 --- /dev/null +++ b/backend/controllers/InventoryGroupController.php @@ -0,0 +1,139 @@ + [ + '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.'); + } + } +} diff --git a/backend/models/InventoryGroupSearch.php b/backend/models/InventoryGroupSearch.php new file mode 100644 index 0000000..1b80a5f --- /dev/null +++ b/backend/models/InventoryGroupSearch.php @@ -0,0 +1,70 @@ + $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; + } +} diff --git a/backend/views/inventory-group/_form.php b/backend/views/inventory-group/_form.php new file mode 100644 index 0000000..0fffcc8 --- /dev/null +++ b/backend/views/inventory-group/_form.php @@ -0,0 +1,35 @@ + + + + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'id_product_category')->dropDownList($cats) ?> + + +
+ 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']) ?> +
+ + + +
diff --git a/backend/views/inventory-group/_search.php b/backend/views/inventory-group/_search.php new file mode 100644 index 0000000..97247d4 --- /dev/null +++ b/backend/views/inventory-group/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/views/inventory-group/create.php b/backend/views/inventory-group/create.php new file mode 100644 index 0000000..b9f0d8f --- /dev/null +++ b/backend/views/inventory-group/create.php @@ -0,0 +1,21 @@ +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; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/inventory-group/index.php b/backend/views/inventory-group/index.php new file mode 100644 index 0000000..77fa829 --- /dev/null +++ b/backend/views/inventory-group/index.php @@ -0,0 +1,40 @@ +title = Yii::t('common/inventory_group', 'Leltár csoportok'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + + 'id_inventory_group', + 'name', + [ + 'attribute' => 'id_product_category', + 'value' => 'productCategoryName' + ], + 'created_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update}' + ], + ], + ]); ?> + +
diff --git a/backend/views/inventory-group/update.php b/backend/views/inventory-group/update.php new file mode 100644 index 0000000..eaa7783 --- /dev/null +++ b/backend/views/inventory-group/update.php @@ -0,0 +1,21 @@ +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'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/inventory-group/view.php b/backend/views/inventory-group/view.php new file mode 100644 index 0000000..c26c137 --- /dev/null +++ b/backend/views/inventory-group/view.php @@ -0,0 +1,59 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory_group', 'Leltár csoportok'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; + + + + + +?> +
+ +

title) ?>

+ +

+ $model->id_inventory_group], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ + 'id_inventory_group', + 'name', + 'id_product_category', + 'created_at', + ], + ]) ?> + + +

Termékek a csoportban

+ $products, + 'columns' => [ + [ + 'attribute' =>'id_product', + 'label' => 'Termék azon' + ], + [ + 'attribute' =>'name', + 'label' => 'Termék neve' + ], + [ + 'attribute' =>'id_account', + 'value' => 'accountName', + 'label' => 'Kassza' + ] + ] + ])?> + +
diff --git a/backend/views/product/_form.php b/backend/views/product/_form.php index 182b4b5..bb477ae 100644 --- a/backend/views/product/_form.php +++ b/backend/views/product/_form.php @@ -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"); + ?>
@@ -23,6 +27,8 @@ $product_category_options = ArrayHelper::map($categories, 'id_product_category', field($model, 'id_account')->dropDownList($account_options) ?> field($model, 'id_product_category')->dropDownList($product_category_options) ?> + + field($model, 'id_inventory_group')->dropDownList($inventory_groups) ?> field($model, 'product_number')->textInput(['maxlength' => true]) ?> diff --git a/backend/views/product/view.php b/backend/views/product/view.php index b59f1d0..30002c5 100644 --- a/backend/views/product/view.php +++ b/backend/views/product/view.php @@ -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', ], ]) ?> + + +
diff --git a/changelog.txt b/changelog.txt index 0a498d4..15c3b54 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +-0.0.45 + - add inventory group + - fix contract already exists validator + - add contract sign image -0.0.44 - add common/config property assetmanager > timestamp -0.0.43 diff --git a/common/config/params.php b/common/config/params.php index b2467ad..e75efd0 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -4,7 +4,7 @@ return [ 'supportEmail' => 'rocho02@gmail.com', 'infoEmail' => 'info@rocho-net.hu', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.0.44', + 'version' => 'v0.0.45', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global diff --git a/common/models/InventoryGroup.php b/common/models/InventoryGroup.php new file mode 100644 index 0000000..dc71ac0 --- /dev/null +++ b/common/models/InventoryGroup.php @@ -0,0 +1,76 @@ + 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id_inventory_group' => Yii::t('common/inventory_group', 'Leltár cs. azon.'), + 'name' => Yii::t('common/inventory_group', 'Név'), + 'id_product_category' => Yii::t('common/inventory_group', 'Termék kategória'), + 'status' => Yii::t('common/inventory_group', 'Státusz'), + 'created_at' => Yii::t('common/inventory_group', 'Létrehozva'), + ]; + } + + public function getProductCategory( ) { + return $this->hasOne(ProductCategory::className(),[ "id_product_category" => "id_product_category" ]); + } + + + public function getProductCategoryName( ) { + $result = ""; + $cat = $this->productCategory; + + if ( isset($cat)){ + $result = $cat->name; + } + + + return $result; + + } + + +} diff --git a/common/models/Product.php b/common/models/Product.php index 928a5b8..927787a 100644 --- a/common/models/Product.php +++ b/common/models/Product.php @@ -46,7 +46,7 @@ class Product extends \common\models\BaseFitnessActiveRecord { { return [ [['id_product_category', 'id_account', 'name'], 'required'], - [['id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'], + [['id_inventory_group', 'id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'], [['product_number', 'barcode'], 'string', 'max' => 20], [['product_number', 'barcode'], 'filter', 'filter' => 'trim', 'skipOnArray' => true], [['name'], 'string', 'max' => 128], @@ -87,6 +87,7 @@ class Product extends \common\models\BaseFitnessActiveRecord { 'description' => Yii::t('common/product', 'Description'), 'created_at' => Yii::t('common/product', 'Created At'), 'updated_at' => Yii::t('common/product', 'Updated At'), + 'id_inventory_group' => Yii::t('common/product', 'Leltár csoport'), ]; } @@ -99,6 +100,20 @@ class Product extends \common\models\BaseFitnessActiveRecord { public function getAccountName() { return $this->account->name; } + + public function getInventoryGroup() { + return $this->hasOne ( InventoryGroup::className (), [ + 'id_inventory_group' => 'id_inventory_group' + ] ); + } + public function getInventoryGroupName() { + $result = ""; + $inventoryGroup = $this->inventoryGroup; + if ( isset($inventoryGroup)){ + $result = $inventoryGroup->name; + } + return $result; + } public function getProductCategory() { return $this->hasOne ( ProductCategory::className (), [ diff --git a/console/migrations/m160229_064305_inventory_group.php b/console/migrations/m160229_064305_inventory_group.php new file mode 100644 index 0000000..d895e02 --- /dev/null +++ b/console/migrations/m160229_064305_inventory_group.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('{{%inventory_group}}', [ + 'id_inventory_group' => $this->primaryKey(), + 'name' => $this->string(), + 'id_product_category' => $this->integer(11), + 'status' => $this->integer(11), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + ], $tableOptions); + + + $this->addColumn("product", "id_inventory_group", "int default null"); + } + + public function down() + { + echo "m160229_064305_inventory_group 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/models/ContractForm.php b/frontend/models/ContractForm.php index da434d9..63c8f72 100644 --- a/frontend/models/ContractForm.php +++ b/frontend/models/ContractForm.php @@ -132,7 +132,10 @@ class ContractForm extends Model { if (! isset ( $this->ticketType )) { $this->addError ( $attribute, "Bérlet típus nem található" ); }else{ - $contracts = Contract::find()->andWhere(['>' ,'contract.expired_at', date('Y-m-d')])->andWhere(['not in' ,'contract.flag',[Contract::$FLAG_DELETED]])->all(); + $contracts = Contract::find() + ->andWhere( ['>' ,'contract.expired_at', date('Y-m-d')]) + ->andWhere(['not in' ,'contract.flag',[Contract::$FLAG_DELETED]]) + ->andWhere(['contract.id_customer' => $this->customer->id_customer])->all(); if ( count($contracts) > 0 ){ $this->addError( $attribute , "Már van érvényes vagy lemondott szerződés az adott időszakban"); } diff --git a/frontend/views/contract/_contract.php b/frontend/views/contract/_contract.php index 95d2de1..38c31f3 100644 --- a/frontend/views/contract/_contract.php +++ b/frontend/views/contract/_contract.php @@ -24,6 +24,8 @@ use common\components\Azaz; $ticketMoneyMonthText = $azaz->toString($ticketMoneyMonth); $customerBankName = $customer->bank_name; + $img = ""; + ?> @@ -153,7 +155,8 @@ másrészről:

-
+ + diff --git a/frontend/web/images/alairas.jpg b/frontend/web/images/alairas.jpg new file mode 100644 index 0000000..9c4e107 Binary files /dev/null and b/frontend/web/images/alairas.jpg differ