@@ -23,17 +33,17 @@ $this->params['breadcrumbs'][] = $this->title;
'name',
['attribute'=>'id_user',
'value'=>$model->userName
+ ],
+ ['attribute'=>'id_account',
+ 'value'=>$model->accountName
],
'created_at:datetime',
],
]) ?>
- render('_search', ['model' => $searchModel]); ?>
+ render('_search', ['model' => $searchModel]); ?>
-
- = Html::a(Yii::t('common/inventory', 'Új termék felvétele a leltárba'), ['inventory-item/create','id' =>$model->id_inventory], ['class' => 'btn btn-success']) ?>
-
Magyarázat:
@@ -59,6 +69,10 @@ $this->params['breadcrumbs'][] = $this->title;
+
$dataProvider,
@@ -114,16 +128,14 @@ $this->params['breadcrumbs'][] = $this->title;
],
['class' => 'yii\grid\ActionColumn',
- 'template' => '{delete}',
+ 'template' => '',
'urlCreator' => function ($action, $model, $key, $index){
- return Url::to(['inventory-item/delete', 'id' => $model['item_id_inventory_item' ] ]) ;
+ return Url::to(['inventory-item/update', 'id' => $model['item_id_inventory_item' ] ]) ;
},
'buttons' =>[
- 'delete' =>function ($url, $model, $key) {
- return Html::a('Törlés', $url,['class' => 'btn btn-xs btn-danger',
+ 'update' =>function ($url, $model, $key) {
+ return Html::a('Módosítás', $url,['class' => 'btn btn-xs btn-success',
'data' => [
- 'confirm' => Yii::t('common/inventory-item', 'Biztosan törlöd ezt az elemet?'),
- 'method' => 'post',
],
]) ;
}
diff --git a/backend/views/inventory-item/update.php b/backend/views/inventory-item/update.php
index cba8142..a9ec386 100644
--- a/backend/views/inventory-item/update.php
+++ b/backend/views/inventory-item/update.php
@@ -1,13 +1,12 @@
title = Yii::t('common/inventory-item', 'Update {modelClass}: ', [
- 'modelClass' => 'Inventory Item',
-]) . ' ' . $model->id_inventory_item;
+$this->title = Yii::t('common/inventory-item', 'Leltár termék');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory-item', 'Inventory Items'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_inventory_item, 'url' => ['view', 'id' => $model->id_inventory_item]];
$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Update');
@@ -16,6 +15,37 @@ $this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Update');
+ = DetailView::widget([
+ 'model' => $inventory,
+ 'attributes' => [
+ 'id_inventory',
+ 'name',
+ ['attribute'=>'id_user',
+ 'value'=>$inventory->userName
+ ],
+ ['attribute'=>'id_account',
+ 'value'=>$inventory->accountName
+ ],
+ 'created_at:datetime',
+ ],
+ ]) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ [
+
+ 'value' => $model->name,
+ 'label' =>"Név"
+ ],
+
+
+
+ ],
+ ]) ?>
+
= $this->render('_form', [
'model' => $model,
]) ?>
diff --git a/backend/views/inventory/_form.php b/backend/views/inventory/_form.php
index 30dea89..87f4acd 100644
--- a/backend/views/inventory/_form.php
+++ b/backend/views/inventory/_form.php
@@ -2,18 +2,27 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
+use common\models\Account;
+use common\components\Helper;
+use frontend\components\HtmlHelper;
/* @var $this yii\web\View */
/* @var $model common\models\Inventory */
/* @var $form yii\widgets\ActiveForm */
?>
+'Mind'] + HtmlHelper::mkAccountOptions( Account::readAccounts() );
+?>
+
+ field($model, "id_account")->dropDownList($accounts)?>
field($model, "name")->textInput()?>
= Html::submitButton($model->isNewRecord ? Yii::t('common/inventory', 'Létrehoz') : Yii::t('common/inventory', 'Módosít'), [ 'name'=>'Inventory[submit]' ,'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/backend/views/inventory/index.php b/backend/views/inventory/index.php
index 566635a..75dfff2 100644
--- a/backend/views/inventory/index.php
+++ b/backend/views/inventory/index.php
@@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
render('_search', ['model' => $searchModel]); ?>
- = Html::a(Yii::t('common/inventory', 'Új leltár'), ['create'], ['class' => 'btn btn-success']) ?>
+ 'btn btn-success']) ?>
= GridView::widget([
diff --git a/backend/views/transfer/_search_payment_later.php b/backend/views/transfer/_search_payment_later.php
new file mode 100644
index 0000000..345af63
--- /dev/null
+++ b/backend/views/transfer/_search_payment_later.php
@@ -0,0 +1,65 @@
+
+
+ 'Mind'] + HtmlHelper::mkOptions(User::find()->all(),'id','username');
+ $ticketTypeOptions = ['' => 'Mind'] + HtmlHelper::mkTicketTypeOptions(TicketType::find()->all());
+?>
+
+
+
+ ['list'],
+ 'method' => 'get',
+ ]); ?>
+
+
+
+
+ = $form->field($model, 'start')->widget(DateTimePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd hh:ii'
+ ]
+ ]) ?>
+
+
+
+ = $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd hh:ii'
+ ]
+ ]) ?>
+
+
+
+
+ = $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions)->label("Bérlet típus") ?>
+
+
+ = $form->field($model, 'id_user')->dropDownList($userOptions) ?>
+
+
+
+
+ = Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
+
+
+
+
+
+
diff --git a/backend/views/transfer/payment_later.php b/backend/views/transfer/payment_later.php
new file mode 100644
index 0000000..cf265b0
--- /dev/null
+++ b/backend/views/transfer/payment_later.php
@@ -0,0 +1,129 @@
+title = "Tranzakciók későbbi utalás fizetés típussal";
+$this->params['breadcrumbs'][] = $this->title;
+
+?>
+
+
+
+
+
= Html::encode($this->title) ?>
+ render('_search_payment_later', ['model' => $searchModel, ]); ?>
+
+
+
+ 'btn btn-primary select-all' ,'style' => 'margin-right: 6px;',
+ 'onclick' => "$('.table-transfer').find(\"input[type='checkbox']\").prop('checked',true);"
+]);
+echo Html::a("Egyiket sem",null, ['class' => 'btn btn-primary deselect-all',
+ 'onclick' => "$('.table-transfer').find(\"input[type='checkbox']\").prop('checked',false);"
+
+]);
+
+?>
+
+
+
+ Url::current() ]
+ ); ?>
+
+ Összesen: total_money;?> Ft
+
+ = GridView::widget([
+ 'tableOptions' => ['class' => 'table table-striped table-bordered table-transfer'],
+ 'dataProvider' => $dataProvider,
+ 'showFooter'=>TRUE,
+
+ 'columns' => [
+ [
+ 'label' => '',
+ 'value' => function ($model, $key, $index, $column) use ( &$searchModel){
+
+
+ return Html::checkbox(Html::getInputName($searchModel, 'selected[]') , in_array($model['transfer_id_transfer'], $searchModel->selected) , [ 'class' => 'cart-item', 'value' => $model['transfer_id_transfer']] );
+ },
+ 'format' => 'raw'
+ ],
+ [
+ 'attribute' => 'user_username',
+ 'label' => 'Felhasználó'
+ ],
+ [
+ 'attribute' => 'customer_name',
+ 'label' => 'Vendég'
+ ],
+ [
+ 'attribute' => 'ticket_type_name',
+ 'label' => 'Bérlet típus'
+ ],
+ [
+ 'attribute' => 'ticket_start',
+ 'label' => 'Érvényes -tól',
+ 'format' => 'date'
+ ],
+ [
+ 'attribute' => 'ticket_end',
+ 'label' => 'Érvényes -ig',
+ 'format' => 'date'
+ ],
+ [
+ 'attribute' => 'product_name',
+ 'label' => 'Termék'
+ ],
+ [
+ 'attribute' => 'transfer_created_at',
+ 'label' => 'Kiadva',
+ 'format' => 'datetime'
+ ],
+ [
+ 'attribute' => 'transfer_money',
+ 'label' => 'Összeg'
+ ],
+ [
+ 'attribute' => 'transfer_status',
+ 'label' => 'Státusz',
+ 'value' => function ($model, $key, $index, $column){
+ return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],'');
+ },
+ ],
+ ],
+ ]); ?>
+
+
+
+ = Html::submitButton( 'Fizetettnek jelöl', [ 'class' => 'btn btn-success' ] ) ?>
+
+
+
+
+
+
+
diff --git a/backend/web/js/inventory.item.index.js b/backend/web/js/inventory.item.index.js
new file mode 100644
index 0000000..a025c96
--- /dev/null
+++ b/backend/web/js/inventory.item.index.js
@@ -0,0 +1,58 @@
+
+
+var inventoryItemIndex = {
+
+ defaults : {
+ products: [],
+ selector_type : '#inventoryitemsearch-item_type',
+ selector_name : '#inventoryitemsearch-item_name',
+ selector_id : '#inventoryitemsearch-item_id',
+ },
+ product: null,
+ init: function(o){
+ this.defaults = $.extend( this.defaults, o );
+ this.initAutocomplete();
+
+ },
+
+ initAutocomplete : function (){
+ var self = this;
+
+ var $input = $(self.defaults.selector_name);
+ $input.typeahead({source : self.defaults.products,
+ autoSelect: true,
+ items: 20,
+ minLength: 3,
+ });
+ $input.change(function() {
+ var current = $input.typeahead("getActive");
+ $("#filter_text").val('');
+ if (current) {
+ // Some item from your model is active!
+ if (current.name == $input.val()) {
+ self.product = current;
+ } else {
+ self.product = null;
+ }
+ } else {
+ self.product = null;
+ }
+ self.productChange();
+ });
+ },
+ productChange: function( ){
+ this.clearProductData();
+ this.setProductData();
+ },
+ clearProductData: function(){
+ $(this.defaults.selector_type).val('');
+ $(this.defaults.selector_id).val('');
+ },
+ setProductData: function(){
+ if ( this.product ){
+ $(this.defaults.selector_type).val( this.product.type);
+ $(this.defaults.selector_id ).val( this.product.id);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/changelog.txt b/changelog.txt
index d318fb0..886f0b2 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,5 @@
+-0.0.55
+ - new type transfer later
-0.0.54
- add ticket usage count increment trigger
- add log
diff --git a/common/config/params.php b/common/config/params.php
index 2d8fcb0..aa94d6c 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.54',
+ 'version' => 'v0.0.55',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
diff --git a/common/mail/login_frontend.php b/common/mail/login_frontend.php
index 414126e..99a7028 100644
--- a/common/mail/login_frontend.php
+++ b/common/mail/login_frontend.php
@@ -5,7 +5,7 @@
Felhasználó: username ;?>
Idő: formatter->asDatetime(time());?>
city)){
+if ( isset($geoip) && isset($geoip->city)){
?>
Ip cím: ip?>
Város: city?>
diff --git a/common/models/Inventory.php b/common/models/Inventory.php
index 45ed4e0..c809adf 100644
--- a/common/models/Inventory.php
+++ b/common/models/Inventory.php
@@ -5,12 +5,16 @@ namespace common\models;
use Yii;
use common\components\UserAwareBehavior;
use yii\helpers\ArrayHelper;
+use yii\db\Query;
+use backend\models\InventoryItemForm;
+use common\components\AccountAwareBehavior;
/**
* This is the model class for table "inventory".
*
* @property integer $id_inventory
* @property integer $id_user
+ * @property integer $id_account
* @property string $name
* @property string $created_at
* @property string $updated_at
@@ -26,6 +30,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
{
return 'inventory';
}
+
/**
* @inheritdoc
@@ -33,7 +38,8 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
public function rules()
{
return [
- [['name'], 'string']
+ [['name'], 'string'],
+ [['id_account'], 'integer'],
];
}
@@ -46,6 +52,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'),
'name' => Yii::t('common/inventory', 'Megnevezés'),
'id_user' => Yii::t('common/inventory', 'Felhasználó'),
+ 'id_account' => Yii::t('common/inventory', 'Kassza'),
'created_at' => Yii::t('common/inventory', 'Létrehozás'),
'updated_at' => Yii::t('common/inventory', 'Módosítás'),
];
@@ -59,7 +66,59 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return ArrayHelper::merge( [
[
'class' => UserAwareBehavior::className(),
+ ],
+ [
+ 'class' => AccountAwareBehavior::className()
+
]
], parent::behaviors());
}
+
+ public function afterSave($insert, $changedAttributes){
+ if ( $insert ){
+
+ $query = Product::find();
+ if ( isset($this->id_account) && is_numeric($this->id_account)){
+ $query->andWhere(['id_account' => $this->id_account]);
+
+ }
+// $query->andWhere("product.id_inventory_group is null");
+ $products = $query->all();
+
+ echo "Products found: " . count($products);
+
+ $inventoryGroups = InventoryGroup::find()->all();
+
+
+ foreach ($products as $product){
+ $form = new InventoryItemForm(
+ [
+ 'inventory' => $this,
+ 'id_product' => $product->id_product,
+ 'product' => $product,
+ 'type' => 'product'
+ ]
+ );
+ $form->save();
+ }
+
+ foreach ($inventoryGroups as $group){
+ $form = new InventoryItemForm(
+ [
+ 'inventory' => $this,
+ 'id_product' => $group->id_inventory_group,
+ 'inventoryGroup' => $group,
+ 'type' => 'group'
+ ]
+ );
+ $form->save();
+ }
+
+
+
+ }
+ }
+
+
+
}
diff --git a/common/models/InventoryItem.php b/common/models/InventoryItem.php
index 2f759ef..34c961c 100644
--- a/common/models/InventoryItem.php
+++ b/common/models/InventoryItem.php
@@ -6,6 +6,7 @@ use Yii;
use yii\helpers\ArrayHelper;
use common\components\UserAwareBehavior;
use common\components\Helper;
+use common\components\ProductAwareBehavior;
/**
* This is the model class for table "inventory_item".
@@ -45,6 +46,8 @@ class InventoryItem extends BaseFitnessActiveRecord
public function rules()
{
return [
+ [['count'],'integer'] ,
+ [['count'],'required'] ,
];
}
@@ -58,7 +61,7 @@ class InventoryItem extends BaseFitnessActiveRecord
'id_inventory' => Yii::t('common/inventory_item', 'Id Inventory'),
'count_in' => Yii::t('common/inventory_item', 'Count In'),
'count_sold' => Yii::t('common/inventory_item', 'Count Sold'),
- 'count' => Yii::t('common/inventory_item', 'Count'),
+ 'count' => Yii::t('common/inventory_item', 'Leltározott mennyiség'),
'type' => Yii::t('common/inventory_item', 'Type'),
'id_product' => Yii::t('common/inventory_item', 'Id Product'),
'id_inventory_group' => Yii::t('common/inventory_item', 'Id Inventory Group'),
@@ -72,6 +75,9 @@ class InventoryItem extends BaseFitnessActiveRecord
return ArrayHelper::merge( [
[
'class' => UserAwareBehavior::className(),
+ ],
+ [
+ 'class' => ProductAwareBehavior::className(),
]
], parent::behaviors());
}
@@ -133,4 +139,18 @@ class InventoryItem extends BaseFitnessActiveRecord
}
+
+ public function afterSave($insert, $changedAttributes){
+ if ( !$insert ){
+ if ( $this->type == 'product'){
+ $product = $this->product;
+ $product->stock = $this->count;
+ if ( !$product->save(false) ){
+ \Yii::error("Failed to save product stock");
+ throw new \Exception("A leltár elem mentése nem sikerült");
+ }
+ }
+ }
+ }
+
}
diff --git a/common/models/Product.php b/common/models/Product.php
index 4618d14..281f7c3 100644
--- a/common/models/Product.php
+++ b/common/models/Product.php
@@ -264,4 +264,36 @@ class Product extends \common\models\BaseFitnessActiveRecord {
$product->stock = $product->stock - $count;
}
+
+ public static function readProductsNotPartOfInventoryGroup( $id_account = null ){
+ $query = Product::find();
+ $query->andWhere("id_inventory_group is null");
+ $query->andWhere(['status' => Product::STATUS_ACTIVE]);
+ return $query->all();
+ }
+
+ public static function readInventoryGroups(){
+ $query = InventoryGroup::find();
+ $query->andWhere(['status' => Product::STATUS_ACTIVE]);
+ return $query->all();
+ }
+
+ public static function buildProductAndInventoryGroupList($id_account = null){
+ $productOptions = [];
+
+ $products = Product::readProductsNotPartOfInventoryGroup($id_account);
+ $inventoryGroups = Product::readInventoryGroups();
+
+ foreach ($products as $product ){
+ $productOptions[]= [ 'type' =>'product', 'id' => $product->id_product ,'name' => $product->name . " (Termék/" .$product->productCategoryName ."/" . $product->accountName .")" ];
+ }
+
+ foreach ($inventoryGroups as $inventoryGroup ){
+ $productOptions[] = ['type' =>'group', 'id' =>$inventoryGroup->id_inventory_group ,'name' =>$inventoryGroup->name ."/Termékcsoport" ];
+
+ }
+ return $productOptions;
+ }
+
+
}
diff --git a/common/models/Transfer.php b/common/models/Transfer.php
index 1e40361..8a18981 100644
--- a/common/models/Transfer.php
+++ b/common/models/Transfer.php
@@ -53,6 +53,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
const PAYMENT_METHOD_CAFETERY = 40; // SZÉCHENYI KÁRTYA
// const PAYMENT_METHOD_DEBIT_MANDATE = 50;//CSOPORTOS BESZEDÉSI MEGBÍZÁS
+ const PAYMENT_METHOD_TRANSFER_LATER = 50;
/**
* @inheritdoc
*/
@@ -526,11 +527,24 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
self::PAYMENT_METHOD_CASH => Yii::t ( 'common/transfer', 'Készpénz' ),
self::PAYMENT_METHOD_BANCCARD => Yii::t ( 'common/transfer', 'Bankkártyás fizetés' ),
self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalás' ),
- self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' )
+ self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' ),
+ self::PAYMENT_METHOD_TRANSFER_LATER => Yii::t ( 'common/transfer', 'Átutalás később' )
]
// self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
;
}
+
+ public static function paymentMethodsForProduct() {
+ return [
+ self::PAYMENT_METHOD_CASH => Yii::t ( 'common/transfer', 'Készpénz' ),
+ self::PAYMENT_METHOD_BANCCARD => Yii::t ( 'common/transfer', 'Bankkártyás fizetés' ),
+ self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalás' ),
+ self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' ),
+ ]
+ // self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
+ ;
+ }
+
public static function statuses() {
return [
self::STATUS_NOT_PAID => Yii::t ( 'common/transfer', 'Nincs fizetve' ),
@@ -946,7 +960,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]);
UserSoldItem::deleteAll(['id_transfer' => $this->id_transfer]);
}
- public function payout() {
+ public function payout($id_account = null) {
if ($this->status != Transfer::STATUS_NOT_PAID) {
return false;
@@ -956,14 +970,18 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
$this->paid_at = Helper::getDateTimeString ();
$this->paid_by = \Yii::$app->user->id;
- if( Helper::isUserCartVisibilityAll() ){
- $this->id_account = Account::readDefault();
+ if ( isset($id_account)){
+ $this->id_account = $id_account;
+ }else{
+ if( Helper::isUserCartVisibilityAll() ){
+ $this->id_account = Account::readDefault();
+ }
}
ShoppingCart::deleteAll ( [ 'id_transfer' => $this->id_transfer ] );
UserSoldItem::deleteAll ( [ 'id_transfer' => $this->id_transfer
] );
- return $this->save ();
+ return $this->save (false);
}
@@ -1067,4 +1085,19 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
return [$transfer,$ticket];
}
+
+ public static function canBeAddedToCart($payment_method) {
+ if ( $payment_method == Transfer::PAYMENT_METHOD_TRANSFER_LATER){
+ return false;
+ }
+ return true;
+ }
+
+ public static function canMarkPaidByReception($payment_method) {
+ if ( $payment_method == Transfer::PAYMENT_METHOD_TRANSFER_LATER){
+ return false;
+ }
+ return true;
+ }
+
}
diff --git a/common/views/total/total_detailed_money_movement.php b/common/views/total/total_detailed_money_movement.php
index 3698083..c680439 100644
--- a/common/views/total/total_detailed_money_movement.php
+++ b/common/views/total/total_detailed_money_movement.php
@@ -23,18 +23,24 @@
+
+ moneyMovements ) == 0 ) {
+ ?>
+
+ |
+ Nincs találat
+ |
+
+
+
- moneyMovements ) == 0 ) {
- ?>
- Nincs találat
-
-
+ moneyMovements ) > 0 ) {
+ ?>
Összesen: formatter->asInteger( $model->moneyMovementMoneis); ?> Ft
-
addColumn("inventory", "id_account", "int");
+ }
+
+ public function down()
+ {
+ echo "m160321_082725_alter__inventory__add__column__id_account 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/console/migrations/m160324_203543_devlog.php b/console/migrations/m160324_203543_devlog.php
new file mode 100644
index 0000000..7157639
--- /dev/null
+++ b/console/migrations/m160324_203543_devlog.php
@@ -0,0 +1,39 @@
+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( '{{%devlog}}', [
+ 'id_devlog' => $this->primaryKey(),
+ 'msg' => $this->string(),
+ ], $tableOptions );
+ }
+
+ public function down()
+ {
+ echo "m160324_203543_devlog 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/assets/InventoryItemIndexAsset.php b/frontend/assets/InventoryItemIndexAsset.php
new file mode 100644
index 0000000..31599cb
--- /dev/null
+++ b/frontend/assets/InventoryItemIndexAsset.php
@@ -0,0 +1,30 @@
+
+ * @since 2.0
+ */
+class InventoryItemIndexAsset extends AssetBundle
+{
+ public $basePath = '@webroot';
+ public $baseUrl = '@web';
+ public $css = [
+ ];
+ public $js = [
+ 'js/inventory.item.index.js',
+ ];
+ public $depends = [
+ 'frontend\assets\AppAsset',
+ 'yii\jui\JuiAsset',
+ 'common\assets\TypeAheadAsset',
+ ];
+}
diff --git a/frontend/components/AccountStateBanknoteCountWidget.php b/frontend/components/AccountStateBanknoteCountWidget.php
index e8d283e..e248fc0 100644
--- a/frontend/components/AccountStateBanknoteCountWidget.php
+++ b/frontend/components/AccountStateBanknoteCountWidget.php
@@ -22,6 +22,7 @@ class AccountStateBanknoteCountWidget extends Widget{
public $model;
public $layout;
public $index;
+ public $showDailyDownload = true;
public function run(){
@@ -60,11 +61,13 @@ class AccountStateBanknoteCountWidget extends Widget{
$s .= Html::a( Html::tag("span","",['class' =>'glyphicon glyphicon-download-alt']) ." Pdf", Url::to([ 'view', 'id' =>$this->model->id_account_state, 'output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf','style' =>'margin-bottom: 12px; margin-right: 6px;']);
if ( $this->model->isTypeClose() ){
- $s .= Html::a('
Napi összefoglaló', Url::toRoute(['mixed','id' =>$this->model->id_account_state]), [
- 'title' => 'Napi összefoglaló',
- 'class' => 'btn btn-success',
- 'style' =>'margin-bottom: 12px; margin-right: 6px;'
- ]);
+ if ( $this->showDailyDownload ){
+ $s .= Html::a('
Napi összefoglaló', Url::toRoute(['mixed','id' =>$this->model->id_account_state]), [
+ 'title' => 'Napi összefoglaló',
+ 'class' => 'btn btn-success',
+ 'style' =>'margin-bottom: 12px; margin-right: 6px;'
+ ]);
+ }
}
$s .= Html::a('
Részletek', Url::toRoute(['view','id' =>$this->model->id_account_state]), [
diff --git a/frontend/components/FrontendMenuStructure.php b/frontend/components/FrontendMenuStructure.php
index d5ebc01..1c69b35 100644
--- a/frontend/components/FrontendMenuStructure.php
+++ b/frontend/components/FrontendMenuStructure.php
@@ -88,7 +88,8 @@ class FrontendMenuStructure{
// }
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
- $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
+// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
+ $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ];
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),
diff --git a/frontend/controllers/InventoryController.php b/frontend/controllers/InventoryController.php
new file mode 100644
index 0000000..c2b9c64
--- /dev/null
+++ b/frontend/controllers/InventoryController.php
@@ -0,0 +1,86 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['post'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all Inventory models.
+ * @return mixed
+ */
+ public function actionIndex()
+ {
+ $searchModel = new InventorySearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+
+ /**
+ * Creates a new Inventory model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new Inventory();
+ $user = User::findOne(\Yii::$app->user->id);
+
+
+ $model->name = 'Leltár_'.date('Ymd_His') .'_' . $user->username;
+
+ $model->id_user = \Yii::$app->user->id;
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['inventory-item/index', 'id' => $model->id_inventory]);
+ } else {
+ }
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+
+
+ /**
+ * Finds the Inventory model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return Inventory the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = Inventory::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+}
diff --git a/frontend/controllers/InventoryItemController.php b/frontend/controllers/InventoryItemController.php
new file mode 100644
index 0000000..86287ad
--- /dev/null
+++ b/frontend/controllers/InventoryItemController.php
@@ -0,0 +1,228 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['post'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all InventoryItem models.
+ * @return mixed
+ */
+ public function actionIndex($id)
+ {
+ $inventory = Inventory::findOne($id);
+
+ if ( !isset($inventory)){
+ throw new NotFoundHttpException("Leltár nem található");
+ }
+
+ $searchModel = new InventoryItemSearch(['inventory' => $inventory]);
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ $productOptions = Product::buildProductAndInventoryGroupList();
+
+ if ($searchModel->output == 'xls') {
+ $this->downloadIndexXls($dataProvider);
+ }else{
+ Url::remember(Url::current(),"inventory-item-index");
+ }
+
+
+ return $this->render('index', [
+ 'model' => $inventory,
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ 'productOptions' =>$productOptions
+ ]);
+ }
+
+
+ protected function downloadIndexXls($dataProvider){
+
+
+ $defs = [['item_created_at', 'Létrehozva'],
+ ['item_name', 'Termék/Termék csoport'],
+ ['user_username', 'Felhasználó'],
+ ['item_count_prev', 'Előző leltár (db)'],
+ ['item_count_sold', 'Eladott mennyiség (db)'],
+ ['item_count_in', 'Beszerzett mennyiség (db)'],
+ ['item_count', 'Leltározott mennyiség (db)'],
+ ['item_difference', 'Különbség (db)'],
+ ['item_count_system', 'Rendszer szerinti mennyiség (db)'],
+ ];
+ $cols = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'];
+
+ $models = $dataProvider->getModels ();
+ $objPHPExcel = new \PHPExcel ();
+
+ $sheet = $objPHPExcel->setActiveSheetIndex ( 0 );
+ /**
+ * Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
+ */
+ $row = 1;
+ $col = 0;
+ foreach ( $defs as $def ) {
+ $sheet->setCellValue ( $cols [$col] . $row, $def [1] );
+ $col ++;
+ }
+
+ foreach ( $models as $model ) {
+ $row ++;
+ $col = 0;
+ foreach ( $defs as $def ) {
+ $sheet->setCellValue ( $cols [$col] . $row, $model[$def [0]] );
+ $col ++;
+ }
+ }
+
+ $styleArray = array (
+ 'font' => array (
+ 'bold' => true
+ )
+ );
+ // 'color' => array('rgb' => 'FF0000'),
+ // 'size' => 15,
+ // 'name' => 'Verdana'
+
+
+
+ foreach ( range ( 'A', 'I' ) as $columnID ) {
+ $sheet->getColumnDimension ( $columnID )->setAutoSize ( true );
+ $sheet->getStyle ( $columnID . '1' )->applyFromArray ( $styleArray );
+ }
+
+ // Redirect output to a client’s web browser (Excel5)
+ header ( 'Content-Type: application/vnd.ms-excel' );
+ header ( 'Content-Disposition: attachment;filename="leltar.xls"' );
+ header ( 'Cache-Control: max-age=0' );
+ // If you're serving to IE 9, then the following may be needed
+ header ( 'Cache-Control: max-age=1' );
+ // If you're serving to IE over SSL, then the following may be needed
+ header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); // Date in the past
+ header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ); // always modified
+ header ( 'Cache-Control: cache, must-revalidate' ); // HTTP/1.1
+ header ( 'Pragma: public' ); // HTTP/1.0
+ $objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' );
+ $objWriter->save ( 'php://output' );
+ exit ();
+ }
+
+ /**
+ * Displays a single InventoryItem model.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new InventoryItem model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate($id)
+ {
+ $model = new InventoryItemForm([
+ 'id_inventory' => $id
+ ]);
+
+ $model->read();
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['inventory-item/index', 'id' => $model->inventory->id_inventory]);
+ } else {
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+ }
+
+ /**
+ * Updates an existing InventoryItem 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);
+ $inventory = Inventory::findOne($model->id_inventory);
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+
+ $prev = Url::previous("inventory-item-index");
+ if ( isset($prev)){
+ return $this->redirect($prev);
+ }else{
+ return $this->redirect([ 'index', 'id' => $inventory->id_inventory ]);
+ }
+
+ } else {
+ return $this->render('update', [
+ 'model' => $model,
+ 'inventory' => $inventory,
+ ]);
+ }
+ }
+
+ /**
+ * Deletes an existing InventoryItem model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionDelete($id)
+ {
+ $item = $this->findModel($id);
+ $id_inventory = $item->id_inventory;
+ $item->delete();
+
+ return $this->redirect(['index', 'id' => $id_inventory]);
+ }
+
+ /**
+ * Finds the InventoryItem model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return InventoryItem the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = InventoryItem::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+}
diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php
index 6247449..3619a2e 100644
--- a/frontend/controllers/SiteController.php
+++ b/frontend/controllers/SiteController.php
@@ -94,8 +94,11 @@ class SiteController extends Controller
$geoip = Helper::getGeoIp();
+ $message = "";
$user = User::findOne(\Yii::$app->user->id);
- $message = "Bejelentkezés: " .$user->username. " Ip cím:". $geoip->ip . " Város: " . $geoip->city;
+ if ( isset($geoip)){
+ $message = "Bejelentkezés: " .$user->username. " Ip cím:". $geoip->ip . " Város: " . $geoip->city;
+ }
Log::log([
'type' =>Log::$TYPE_LOGIN,
diff --git a/frontend/models/InventoryItemSearch.php b/frontend/models/InventoryItemSearch.php
new file mode 100644
index 0000000..2b32c03
--- /dev/null
+++ b/frontend/models/InventoryItemSearch.php
@@ -0,0 +1,135 @@
+select([
+ 'inventory_item.id_inventory_item as item_id_inventory_item',
+ 'inventory_item.created_at as item_created_at',
+ new Expression('case when inventory_item.id_product is null then inventory_group.name else product.name end as item_name'),
+ 'user.username as user_username',
+ 'coalesce(inventory_item.count_prev ,0)as item_count_prev',
+ 'coalesce(inventory_item.count_in,0) as item_count_in',
+ 'coalesce(inventory_item.count_sold,0) as item_count_sold',
+ 'coalesce(inventory_item.count,0) as item_count',
+ 'coalesce(inventory_item.count_system,0) as item_count_system',
+ 'inventory.created_at as inventory_created_at',
+ 'inventory_prev.id_inventory as inventory_prev_id_inventory',
+ 'inventory_prev.name as inventory_prev_name',
+ new Expression('(coalesce(inventory_item.count,0) - ( coalesce(inventory_item.count_prev,0) + coalesce(inventory_item.count_in,0) - coalesce(inventory_item.count_sold,0) )) as item_difference'),
+ ]);
+
+ $query->from(InventoryItem::tableName());
+
+
+ $query->innerJoin(User::tableName(), "user.id = inventory_item.id_user");
+ $query->leftJoin(Product::tableName(), "product.id_product = inventory_item.id_product");
+ $query->leftJoin(InventoryGroup::tableName(), "inventory_group.id_inventory_group = inventory_item.id_inventory_group");
+ $query->leftJoin(Inventory::tableName(), "inventory.id_inventory = inventory_item.id_inventory");
+
+ $query->leftJoin( "inventory_item as item_prev", "item_prev.id_inventory_item = inventory_item.id_inventory_item_prev" );
+ $query->leftJoin( "inventory as inventory_prev", "inventory_prev.id_inventory = item_prev.id_inventory" );
+
+ $query->andWhere( ['inventory_item.id_inventory' => $this->inventory->id_inventory] );
+
+ $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;
+ }
+
+ $dataProvider = new ActiveDataProvider(
+ ['query' => $query ,
+ 'pagination' => ( empty($this->output) ? [] : false ),
+ 'sort' => [
+ 'defaultOrder' => ['item_name' => SORT_ASC],
+ 'attributes' => Helper::mkYiiSortItems([
+ ['item_created_at', 'item_created_at'],
+ ['item_name', 'item_name'],
+ ['user_username', 'user_username'],
+ ['item_count_prev', 'item_count_prev'],
+ ['item_count_sold', 'item_count_sold'],
+ ['item_count_in', 'item_count_in'],
+ ['item_count', 'item_count'],
+ ['item_count', 'item_count'],
+ ['item_difference', 'item_difference'],
+ ['item_count_system', 'item_count_system'],
+ ['inventory.id_inventory', 'inventory_id_inventory'],
+ ['inventory.name', 'inventory_name'],
+ ['inventory_prev_name', 'inventory_prev_name'],
+ ])
+ ,
+ ]
+ ]
+ );
+
+
+ if ( !empty($this->item_type) && is_numeric($this->item_id) ){
+ if ( $this->item_type == 'product'){
+ $query->andFilterWhere(['product.id_product' => $this->item_id]);
+ }else if ( $this->item_type == 'group' ){
+ $query->andFilterWhere(['inventory_group.id_inventory_group' => $this->item_id]);
+ }
+ }
+
+
+ return $dataProvider;
+ }
+}
diff --git a/frontend/models/InventorySearch.php b/frontend/models/InventorySearch.php
new file mode 100644
index 0000000..c2052ff
--- /dev/null
+++ b/frontend/models/InventorySearch.php
@@ -0,0 +1,70 @@
+ $query,
+ 'sort' =>[
+ 'defaultOrder' => [ 'created_at' => SORT_DESC ]
+ ]
+ ]);
+
+ $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' => $this->id_inventory,
+ 'id_user' => $this->id_user,
+ 'created_at' => $this->created_at,
+ 'updated_at' => $this->updated_at,
+ ]);
+
+ return $dataProvider;
+ }
+}
diff --git a/frontend/models/ProductSaleForm.php b/frontend/models/ProductSaleForm.php
index f52601f..7553a9a 100644
--- a/frontend/models/ProductSaleForm.php
+++ b/frontend/models/ProductSaleForm.php
@@ -192,7 +192,9 @@ class ProductSaleForm extends Model
$customer = null;
$paid_at;
$status = Transfer::STATUS_PAID;
- if ( $this->isAppendToUserCart() ){
+ if ( !Transfer::canMarkPaidByReception($this->payment_method)){
+ $status = Transfer::STATUS_NOT_PAID;
+ }else if ( $this->isAppendToUserCart() ){
$status = Transfer::STATUS_NOT_PAID;
}else if ( $this->isAppendToCustomerCart() ){
$status = Transfer::STATUS_NOT_PAID;
@@ -237,10 +239,12 @@ class ProductSaleForm extends Model
public function appendToUserCart(){
if ( $this->isAppendToUserCart() ){
- $item = new UserSoldItem();
- $item->id_transfer = $this->transfer->id_transfer;
- $item->id_user = Yii::$app->user->id;
- $item->save(false);
+ if ( Transfer::canBeAddedToCart($this->payment_method)){
+ $item = new UserSoldItem();
+ $item->id_transfer = $this->transfer->id_transfer;
+ $item->id_user = Yii::$app->user->id;
+ $item->save(false);
+ }
}
}
public function isAppendToCustomerCart(){
@@ -253,10 +257,12 @@ class ProductSaleForm extends Model
public function appendToCustomerCart(){
if ( $this->isAppendToCustomerCart() && isset($this->customer) ){
- $item = new ShoppingCart();
- $item->id_customer = $this->customer->id_customer;
- $item->id_transfer = $this->transfer->id_transfer;
- $item->save(false);
+ if ( Transfer::canBeAddedToCart($this->payment_method)){
+ $item = new ShoppingCart();
+ $item->id_customer = $this->customer->id_customer;
+ $item->id_transfer = $this->transfer->id_transfer;
+ $item->save(false);
+ }
}
}
}
diff --git a/frontend/models/TicketCreate.php b/frontend/models/TicketCreate.php
index 5b9c117..e59e98f 100644
--- a/frontend/models/TicketCreate.php
+++ b/frontend/models/TicketCreate.php
@@ -217,7 +217,10 @@ class TicketCreate extends Ticket{
$transfer->id_account = $this->_account->id_account;
$status = Transfer::STATUS_PAID;
- if ( $this->isAppendToUserCart() ){
+
+ if ( !Transfer::canMarkPaidByReception( $this->payment_method ) ){
+ $status = Transfer::STATUS_NOT_PAID;
+ }else if ( $this->isAppendToUserCart() ){
$status = Transfer::STATUS_NOT_PAID;
}else if ( $this->isAppendToCustomerCart() ){
$status = Transfer::STATUS_NOT_PAID;
@@ -284,15 +287,17 @@ class TicketCreate extends Ticket{
}
public function appendToCustomerCart(){
- if ( $this->isAppendToCustomerCart() && isset($this->customer) ){
- $item = new ShoppingCart();
- $item->id_customer = $this->customer->id_customer;
- $item->id_transfer = $this->_transfer->id_transfer;
- if ( !$item->save(false) ){
- \Yii::error("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
- throw new \Exception("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
- }
-
+ if ( Transfer::canBeAddedToCart($this->payment_method)){
+ if ( $this->isAppendToCustomerCart() && isset($this->customer) ){
+ $item = new ShoppingCart();
+ $item->id_customer = $this->customer->id_customer;
+ $item->id_transfer = $this->_transfer->id_transfer;
+ if ( !$item->save(false) ){
+ \Yii::error("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
+ throw new \Exception("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
+ }
+
+ }
}
}
diff --git a/frontend/views/account-state/_mixed.php b/frontend/views/account-state/_mixed.php
index 72c3186..cc12352 100644
--- a/frontend/views/account-state/_mixed.php
+++ b/frontend/views/account-state/_mixed.php
@@ -4,6 +4,8 @@ use common\components\total\TotalDetailedMoneyMovementWidget;
?>
+
+
Bérletek típus szerint
$details]);?>
Termékek kategória szerint
diff --git a/frontend/views/account-state/mixed_pdf.php b/frontend/views/account-state/mixed_pdf.php
index 8eaf501..0de10a0 100644
--- a/frontend/views/account-state/mixed_pdf.php
+++ b/frontend/views/account-state/mixed_pdf.php
@@ -3,7 +3,14 @@ use common\components\accountstate\AccountStateWidget;
use common\components\total\TotalDifferenceWidget;
?>
-
+
diff --git a/frontend/views/card/index.php b/frontend/views/card/index.php
index fca56fa..1e509ab 100644
--- a/frontend/views/card/index.php
+++ b/frontend/views/card/index.php
@@ -45,11 +45,14 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\ActionColumn',
- 'template' => '{ticket} {ticket_history} {keys} {contract}',
+ 'template' => '{ticket} {product} {ticket_history} {keys} {contract}',
'buttons' => [
'ticket' => function ($url, $model, $key) {
return Html::a('Új bérlet', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
},
+ 'product' => function ($url, $model, $key) {
+ return Html::a('Új termék', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
+ },
'ticket_history' => function ($url, $model, $key) {
return Html::a('Befizetések', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
},
@@ -64,6 +67,8 @@ $this->params['breadcrumbs'][] = $this->title;
$url = "";
if ( 'ticket' == $action ){
$url = Url::to(['ticket/create','number' => $model['card_number']]);
+ }else if ( 'product' == $action ){
+ $url = Url::to(['product/sale','number' => $model['card_number']]);
}else if ( 'ticket_history' == $action ){
$url = Url::to(['ticket/index','number' => $model['card_number']]);
}else if ( 'keys' == $action ){
diff --git a/frontend/views/inventory-item/_form.php b/frontend/views/inventory-item/_form.php
new file mode 100644
index 0000000..e804144
--- /dev/null
+++ b/frontend/views/inventory-item/_form.php
@@ -0,0 +1,25 @@
+
+
+
diff --git a/frontend/views/inventory-item/_search.php b/frontend/views/inventory-item/_search.php
new file mode 100644
index 0000000..9214ca1
--- /dev/null
+++ b/frontend/views/inventory-item/_search.php
@@ -0,0 +1,34 @@
+
+
+
+
+ ['index','id' => $model->inventory->id_inventory],
+ 'method' => 'get',
+ ]); ?>
+
+ = $form->field($model, 'item_type')->hiddenInput()->label(false) ?>
+ = $form->field($model, 'item_id')->hiddenInput()->label(false) ?>
+
+
+ = $form->field($model, 'item_name')->label("Termék/Termék csoport neve") ?>
+
+
+
+
+
+
+ = Html::submitButton(Yii::t('common/inventory-item', 'Keresés'), ['class' => 'btn btn-primary']) ?>
+
+
+
+
+
diff --git a/frontend/views/inventory-item/create.php b/frontend/views/inventory-item/create.php
new file mode 100644
index 0000000..16056d1
--- /dev/null
+++ b/frontend/views/inventory-item/create.php
@@ -0,0 +1,33 @@
+title = Yii::t('common/inventory-item', 'Új leltár elem');
+$this->params['breadcrumbs'][] = ['label' => 'Leltár' , 'url' => ['inventory/view', 'id' => $model->inventory->id_inventory]];
+$this->params['breadcrumbs'][] = $this->title;
+
+InventoryItemCreateAsset::register($this);
+
+
+$options = [];
+$options['products'] = $model->productOptions;
+$options['url_product_find'] = Url::toRoute(['product/find']);
+
+$this->registerJs('inventoryItemCreate.init( '. json_encode($options) .' );');
+
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/frontend/views/inventory-item/index.php b/frontend/views/inventory-item/index.php
new file mode 100644
index 0000000..79a3975
--- /dev/null
+++ b/frontend/views/inventory-item/index.php
@@ -0,0 +1,146 @@
+title = Yii::t('common/inventory-item', 'Leltár részletei');
+
+$this->params['breadcrumbs'][] = ['label' => 'Leltár lista' , 'url' => ['inventory/index']];;
+$this->params['breadcrumbs'][] = $this->title;
+
+
+InventoryItemIndexAsset::register($this);
+
+$options = [];
+$options['products'] = $productOptions;
+
+$this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
+
+?>
+
+
+
+
= Html::encode($this->title) ?>
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id_inventory',
+ 'name',
+ ['attribute'=>'id_user',
+ 'value'=>$model->userName
+ ],
+ ['attribute'=>'id_account',
+ 'value'=>$model->accountName
+ ],
+ 'created_at:datetime',
+ ],
+ ]) ?>
+
+ render('_search', ['model' => $searchModel]); ?>
+
+
+
+
+ Magyarázat:
+
+ -
+ Előző leltár (db): az előző leltárban összeszámolt mennyiség. Ha ez a termék első leltározása akkor 0.
+
+ -
+ Beszerzett mennyiség: Az előző leltár óta történt beszerzett mennyiségek összege
+
+ -
+ Eladott mennyiség: Az előző leltár óta eladott darabszám összege
+
+ -
+ Leltározott mennyiség: A felhasználó által összeszámolt és leltár létrehozásakor beírt mennyiség
+
+ -
+ Rendszer szerinti mennyiség: a rendszer által számolt és aktuális látott mennyiség
+
+ -
+ Különbség: = "Leltározott mennyiség - ( "Előző leltár" + "Beszerzett mennyiség" - "Eladott mennyiség" )
+
+
+
+
+
+ 'xls']),['class' =>'btn btn-primary'])?>
+
+
+ $dataProvider,
+ 'columns' =>[
+ [
+ 'attribute' => 'item_name',
+ 'label' => 'Név',
+
+ ],
+ [
+ 'attribute' => 'item_count_system',
+ 'label' => 'Rendszer szerinti mennyiség (db)',
+
+ ],
+
+
+ [
+ 'attribute' => 'item_count',
+ 'label' => 'Leltározott mennyiség (db)',
+
+ ],
+ [
+ 'attribute' => 'item_count_prev',
+ 'label' => 'Előzö leltár (db)'
+
+ ],
+ [
+ 'attribute' => 'item_count_in',
+ 'label' => 'Beszerzett mennyiség (db)'
+
+ ],
+ [
+ 'attribute' => 'item_count_sold',
+ 'label' => 'Eladott mennyiség (db)',
+
+ ],
+
+
+ [
+ 'attribute' => 'item_difference',
+ 'label' => 'Különbség (db)',
+
+ ],
+ ['class' => 'yii\grid\ActionColumn',
+ 'template' => '{update}',
+ 'urlCreator' => function ($action, $model, $key, $index){
+ return Url::to(['inventory-item/update', 'id' => $model['item_id_inventory_item' ] ]) ;
+ },
+ 'buttons' =>[
+ 'update' =>function ($url, $model, $key) {
+ return Html::a('Módosítás', $url,['class' => 'btn btn-xs btn-success',
+ 'data' => [
+ ],
+ ]) ;
+ }
+ ]
+
+ ]
+ ]
+
+ ]);
+ ?>
+
+
diff --git a/frontend/views/inventory-item/update.php b/frontend/views/inventory-item/update.php
new file mode 100644
index 0000000..fb0e8b6
--- /dev/null
+++ b/frontend/views/inventory-item/update.php
@@ -0,0 +1,81 @@
+title = Yii::t('common/inventory-item', 'Leltár termék');
+$this->params['breadcrumbs'][] = ['label' => 'Leltár lista', 'url' => ['inventory/index']];
+$this->params['breadcrumbs'][] = ['label' => 'Leltár', 'url' => ['inventory-item/index', 'id' => $model->id_inventory ]];
+$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Update');
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ Leltár
+ = DetailView::widget([
+ 'model' => $inventory,
+ 'attributes' => [
+ 'id_inventory',
+ 'name',
+ ['attribute'=>'id_user',
+ 'value'=>$inventory->userName
+ ],
+ ['attribute'=>'id_account',
+ 'value'=>$inventory->accountName
+ ],
+ 'created_at:datetime',
+ ],
+ ]) ?>
+
+ Termék
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ [
+
+ 'value' => $model->name,
+ 'label' =>"Név"
+ ],
+ [
+ 'value' => $model->count_system,
+ 'label' => 'Rendszer szerinti mennyiség (db)',
+ ],
+ [
+ 'value' => $model->count,
+ 'label' => 'Leltározott mennyiség (db)',
+ ],
+ [
+ 'value' => $model->count_prev,
+ 'label' => 'Előző leltár (db)',
+ ],
+ [
+ 'value' => $model->count_in,
+ 'label' => 'Beszerzett mennyiség (db)',
+ ],
+ [
+ 'value' => $model->count_sold,
+ 'label' => 'Eladott mennyiség (db)',
+ ],
+ [
+ 'value' => $model->getDifference(),
+ 'label' => 'Különbség',
+ ],
+ [
+ 'value' => '',
+ 'label' => '',
+ ],
+
+
+
+ ],
+ ]) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/frontend/views/inventory-item/view.php b/frontend/views/inventory-item/view.php
new file mode 100644
index 0000000..094f06c
--- /dev/null
+++ b/frontend/views/inventory-item/view.php
@@ -0,0 +1,45 @@
+title = $model->id_inventory_item;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory-item', 'Inventory Items'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+
+ = Html::a(Yii::t('common/inventory-item', 'Update'), ['update', 'id' => $model->id_inventory_item], ['class' => 'btn btn-primary']) ?>
+ = Html::a(Yii::t('common/inventory-item', 'Delete'), ['delete', 'id' => $model->id_inventory_item], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('common/inventory-item', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id_inventory_item',
+ 'id_inventory',
+ 'count_in',
+ 'count_sold',
+ 'count',
+ 'type',
+ 'id_product',
+ 'id_inventory_group',
+ 'id_user',
+ 'created_at',
+ 'updated_at',
+ ],
+ ]) ?>
+
+
diff --git a/frontend/views/inventory/_form.php b/frontend/views/inventory/_form.php
new file mode 100644
index 0000000..87f4acd
--- /dev/null
+++ b/frontend/views/inventory/_form.php
@@ -0,0 +1,32 @@
+
+
+'Mind'] + HtmlHelper::mkAccountOptions( Account::readAccounts() );
+?>
+
+
diff --git a/frontend/views/inventory/_search.php b/frontend/views/inventory/_search.php
new file mode 100644
index 0000000..48ba4bc
--- /dev/null
+++ b/frontend/views/inventory/_search.php
@@ -0,0 +1,33 @@
+
+
+
+
+ ['index'],
+ 'method' => 'get',
+ ]); ?>
+
+ = $form->field($model, 'id_inventory') ?>
+
+ = $form->field($model, 'id_user') ?>
+
+ = $form->field($model, 'created_at') ?>
+
+ = $form->field($model, 'updated_at') ?>
+
+
+ = Html::submitButton(Yii::t('common/inventory', 'Search'), ['class' => 'btn btn-primary']) ?>
+ = Html::resetButton(Yii::t('common/inventory', 'Reset'), ['class' => 'btn btn-default']) ?>
+
+
+
+
+
diff --git a/frontend/views/inventory/create.php b/frontend/views/inventory/create.php
new file mode 100644
index 0000000..0bb57b8
--- /dev/null
+++ b/frontend/views/inventory/create.php
@@ -0,0 +1,21 @@
+title = Yii::t('common/inventory', 'Új leltár');
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory', 'Leltár lista'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/frontend/views/inventory/index.php b/frontend/views/inventory/index.php
new file mode 100644
index 0000000..566635a
--- /dev/null
+++ b/frontend/views/inventory/index.php
@@ -0,0 +1,50 @@
+title = Yii::t('common/inventory', 'Leltár lista');
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+ render('_search', ['model' => $searchModel]); ?>
+
+
+ = Html::a(Yii::t('common/inventory', 'Új leltár'), ['create'], ['class' => 'btn btn-success']) ?>
+
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+
+ 'id_inventory',
+ 'name',
+ [ 'attribute' => 'id_user', "value" =>"userName" ],
+ 'created_at:datetime',
+
+ ['class' => 'yii\grid\ActionColumn',
+ 'template' => '{view}',
+ 'urlCreator' => function( $action, $model, $key, $index ){
+ if ( $action == 'view' ){
+ return Url::to(['inventory-item/index' , 'id'=> $model->id_inventory]);
+ }
+ },
+ 'buttons' =>[
+ 'view' =>function ($url, $model, $key) {
+ return Html::a('Részletek', $url,['class' => 'btn btn-xs btn-primary',
+ ]) ;
+ }
+ ]
+
+ ],
+ ],
+ ]); ?>
+
+
diff --git a/frontend/views/inventory/update.php b/frontend/views/inventory/update.php
new file mode 100644
index 0000000..218789b
--- /dev/null
+++ b/frontend/views/inventory/update.php
@@ -0,0 +1,23 @@
+title = Yii::t('common/inventory', 'Update {modelClass}: ', [
+ 'modelClass' => 'Inventory',
+]) . ' ' . $model->id_inventory;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory', 'Inventories'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->id_inventory, 'url' => ['view', 'id' => $model->id_inventory]];
+$this->params['breadcrumbs'][] = Yii::t('common/inventory', 'Update');
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/frontend/views/inventory/view.php b/frontend/views/inventory/view.php
new file mode 100644
index 0000000..6fef3cd
--- /dev/null
+++ b/frontend/views/inventory/view.php
@@ -0,0 +1,89 @@
+title = $model->id_inventory;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory', 'Leltár lista'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = "Leltár";
+?>
+
+
+
= Html::encode("Leltár") ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id_inventory',
+ 'name',
+ ['attribute'=>'id_user',
+ 'value'=>$model->userName
+ ],
+ 'created_at:datetime',
+ ],
+ ]) ?>
+
+
+
+
+
+
+ = Html::a(Yii::t('common/inventory', 'Új termék'), ['inventory-item/create','id' =>$model->id_inventory], ['class' => 'btn btn-success']) ?>
+
+
+ $dataProvider,
+ 'columns' =>[
+ [
+ 'attribute' => 'item_created_at',
+ 'label' => 'Létrehozva',
+ 'format' => 'datetime'
+ ],
+ [
+ 'attribute' => 'item_name',
+ 'label' => 'Név',
+
+ ],
+ [
+ 'attribute' => 'user_username',
+ 'label' => 'Felhasználó',
+
+ ],
+ [
+ 'attribute' => 'item_count_prev',
+ 'label' => 'Előzö leltár (db)'
+
+ ],
+ [
+ 'attribute' => 'item_count_in',
+ 'label' => 'Beszerzett mennyiség (db)'
+
+ ],
+ [
+ 'attribute' => 'item_count_sold',
+ 'label' => 'Eladott mennyiség (db)',
+
+ ],
+ [
+ 'attribute' => 'item_count',
+ 'label' => 'Leltározott mennyiség (db)',
+
+ ],
+ [
+ 'attribute' => 'item_difference',
+ 'label' => 'Különbség (db)',
+
+ ],
+ ]
+
+ ]);
+ ?>
+
diff --git a/frontend/views/product/_sale_form.php b/frontend/views/product/_sale_form.php
index 2609f36..1e2b743 100644
--- a/frontend/views/product/_sale_form.php
+++ b/frontend/views/product/_sale_form.php
@@ -98,7 +98,7 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
- field($model,'payment_method')->dropDownList(Transfer::paymentMethods()) ?>
+ field($model,'payment_method')->dropDownList(Transfer::paymentMethodsForProduct()) ?>
diff --git a/frontend/web/js/inventory.item.index.js b/frontend/web/js/inventory.item.index.js
new file mode 100644
index 0000000..a025c96
--- /dev/null
+++ b/frontend/web/js/inventory.item.index.js
@@ -0,0 +1,58 @@
+
+
+var inventoryItemIndex = {
+
+ defaults : {
+ products: [],
+ selector_type : '#inventoryitemsearch-item_type',
+ selector_name : '#inventoryitemsearch-item_name',
+ selector_id : '#inventoryitemsearch-item_id',
+ },
+ product: null,
+ init: function(o){
+ this.defaults = $.extend( this.defaults, o );
+ this.initAutocomplete();
+
+ },
+
+ initAutocomplete : function (){
+ var self = this;
+
+ var $input = $(self.defaults.selector_name);
+ $input.typeahead({source : self.defaults.products,
+ autoSelect: true,
+ items: 20,
+ minLength: 3,
+ });
+ $input.change(function() {
+ var current = $input.typeahead("getActive");
+ $("#filter_text").val('');
+ if (current) {
+ // Some item from your model is active!
+ if (current.name == $input.val()) {
+ self.product = current;
+ } else {
+ self.product = null;
+ }
+ } else {
+ self.product = null;
+ }
+ self.productChange();
+ });
+ },
+ productChange: function( ){
+ this.clearProductData();
+ this.setProductData();
+ },
+ clearProductData: function(){
+ $(this.defaults.selector_type).val('');
+ $(this.defaults.selector_id).val('');
+ },
+ setProductData: function(){
+ if ( this.product ){
+ $(this.defaults.selector_type).val( this.product.type);
+ $(this.defaults.selector_id ).val( this.product.id);
+ }
+
+ }
+}
\ No newline at end of file