Finish leltar_csoport

This commit is contained in:
Roland Schneider 2016-02-29 20:52:10 +01:00
commit b07bc4eca9
19 changed files with 589 additions and 4 deletions

View File

@ -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,

View 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.');
}
}
}

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View File

@ -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]) ?>

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,76 @@
<?php
namespace common\models;
use Yii;
use common\components\Helper;
/**
* This is the model class for table "inventory_group".
*
* @property integer $id_inventory_group
* @property string $name
* @property integer $id_product_category
* @property integer $status
* @property string $created_at
* @property string $updated_at
*/
class InventoryGroup extends \common\models\BaseFitnessActiveRecord
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'inventory_group';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_product_category', 'status'], 'integer'],
[['name'], 'string', 'max' => 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;
}
}

View File

@ -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 (), [

View File

@ -0,0 +1,46 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160229_064305_inventory_group extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->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()
{
}
*/
}

View File

@ -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");
}

View File

@ -24,6 +24,8 @@ use common\components\Azaz;
$ticketMoneyMonthText = $azaz->toString($ticketMoneyMonth);
$customerBankName = $customer->bank_name;
$img = "<img height='20px' src='" . \Yii::getAlias("@webroot") . DIRECTORY_SEPARATOR. "images" . DIRECTORY_SEPARATOR . "alairas.jpg'>";
?>
@ -153,7 +155,8 @@ másrészről:
</p>
<table style="width: 100%; margin-top: 30px;">
<tr>
<td style="width: 33%">
<td style="width: 33%; text-align: center;">
<?php echo $img; ?>
</td>
<td>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB