Finish inventory2
This commit is contained in:
commit
3aa90ec98e
@ -79,6 +79,10 @@ class InventoryController extends Controller
|
|||||||
public function actionCreate()
|
public function actionCreate()
|
||||||
{
|
{
|
||||||
$model = new Inventory();
|
$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;
|
$model->id_user = \Yii::$app->user->id;
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
|
|||||||
@ -91,6 +91,9 @@ class InventoryItemForm extends Model{
|
|||||||
public function save(){
|
public function save(){
|
||||||
if ( $this->validate()) {
|
if ( $this->validate()) {
|
||||||
|
|
||||||
|
|
||||||
|
$this->loadLastInventory();
|
||||||
|
|
||||||
$this->loadLastInventoryItem();
|
$this->loadLastInventoryItem();
|
||||||
$this->loadProductIn();
|
$this->loadProductIn();
|
||||||
$this->loadProductSold();
|
$this->loadProductSold();
|
||||||
@ -99,7 +102,9 @@ class InventoryItemForm extends Model{
|
|||||||
$item = new InventoryItem();
|
$item = new InventoryItem();
|
||||||
$item->count_in = $this->product_in;
|
$item->count_in = $this->product_in;
|
||||||
$item->count_sold = $this->product_out;
|
$item->count_sold = $this->product_out;
|
||||||
$item->count = $this->product_stock;
|
$item->count = $this->count;
|
||||||
|
$item->count_system = $this->product_stock;
|
||||||
|
|
||||||
|
|
||||||
if ( isset( $this->last_inventory_item ) ){
|
if ( isset( $this->last_inventory_item ) ){
|
||||||
$item->id_inventory_item_prev = $this->last_inventory_item->id_inventory_item;
|
$item->id_inventory_item_prev = $this->last_inventory_item->id_inventory_item;
|
||||||
@ -198,6 +203,7 @@ class InventoryItemForm extends Model{
|
|||||||
protected function loadLastInventoryItem( ){
|
protected function loadLastInventoryItem( ){
|
||||||
if ( isset( $this->last_inventory ) ){
|
if ( isset( $this->last_inventory ) ){
|
||||||
$query = InventoryItem::find();
|
$query = InventoryItem::find();
|
||||||
|
|
||||||
$query->andWhere(['id_inventory' => $this->last_inventory->id_inventory]);
|
$query->andWhere(['id_inventory' => $this->last_inventory->id_inventory]);
|
||||||
|
|
||||||
if ( $this->type == 'product'){
|
if ( $this->type == 'product'){
|
||||||
@ -211,8 +217,8 @@ class InventoryItemForm extends Model{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function read(){
|
public function read(){
|
||||||
|
|
||||||
$this->loadInventory();
|
$this->loadInventory();
|
||||||
$this->loadLastInventory();
|
|
||||||
|
|
||||||
$this->loadProducts();
|
$this->loadProducts();
|
||||||
$this->loadInventoryGroups();
|
$this->loadInventoryGroups();
|
||||||
@ -229,6 +235,14 @@ class InventoryItemForm extends Model{
|
|||||||
}
|
}
|
||||||
public function loadLastInventory(){
|
public function loadLastInventory(){
|
||||||
$query = Inventory::find();
|
$query = Inventory::find();
|
||||||
|
$query->innerJoin(InventoryItem::tableName(),"inventory_item.id_inventory = inventory.id_inventory");
|
||||||
|
|
||||||
|
if ( $this->type == 'product'){
|
||||||
|
$query->andWhere(['inventory_item.id_product' => $this->product->id_product]);
|
||||||
|
}else{
|
||||||
|
$query->andWhere(['inventory_item.id_inventory_group' => $this->inventoryGroup->id_inventory_group]);
|
||||||
|
}
|
||||||
|
|
||||||
$query->andWhere(['<', 'inventory.created_at' , $this->inventory->created_at]);
|
$query->andWhere(['<', 'inventory.created_at' , $this->inventory->created_at]);
|
||||||
$query->orderBy(['created_at' => SORT_DESC ]);
|
$query->orderBy(['created_at' => SORT_DESC ]);
|
||||||
$this->last_inventory =$query->limit(1)->one();
|
$this->last_inventory =$query->limit(1)->one();
|
||||||
@ -265,7 +279,8 @@ class InventoryItemForm extends Model{
|
|||||||
public function attributeLabels()
|
public function attributeLabels()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'count' => 'Mennyiség'
|
'count' => 'Mennyiség',
|
||||||
|
'name' => "Termék/Termék csoport neve"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use common\models\User;
|
|||||||
use common\models\Product;
|
use common\models\Product;
|
||||||
use common\models\InventoryGroup;
|
use common\models\InventoryGroup;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
|
use common\models\Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* InventoryItemSearch represents the model behind the search form about `common\models\InventoryItem`.
|
* InventoryItemSearch represents the model behind the search form about `common\models\InventoryItem`.
|
||||||
@ -58,6 +59,10 @@ class InventoryItemSearch extends InventoryItem
|
|||||||
'coalesce(inventory_item.count_in,0) as item_count_in',
|
'coalesce(inventory_item.count_in,0) as item_count_in',
|
||||||
'coalesce(inventory_item.count_sold,0) as item_count_sold',
|
'coalesce(inventory_item.count_sold,0) as item_count_sold',
|
||||||
'coalesce(inventory_item.count,0) as item_count',
|
'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('(inventory_item.count - ( inventory_item.count_prev + inventory_item.count_in - inventory_item.count_sold )) as item_difference'),
|
new Expression('(inventory_item.count - ( inventory_item.count_prev + inventory_item.count_in - inventory_item.count_sold )) as item_difference'),
|
||||||
]);
|
]);
|
||||||
$query->from(InventoryItem::tableName());
|
$query->from(InventoryItem::tableName());
|
||||||
@ -66,8 +71,12 @@ class InventoryItemSearch extends InventoryItem
|
|||||||
$query->innerJoin(User::tableName(), "user.id = inventory_item.id_user");
|
$query->innerJoin(User::tableName(), "user.id = inventory_item.id_user");
|
||||||
$query->leftJoin(Product::tableName(), "product.id_product = inventory_item.id_product");
|
$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(InventoryGroup::tableName(), "inventory_group.id_inventory_group = inventory_item.id_inventory_group");
|
||||||
|
$query->leftJoin(Inventory::tableName(), "inventory.id_inventory = inventory_item.id_inventory");
|
||||||
|
|
||||||
$query->andWhere( ['id_inventory' => $this->inventory->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] );
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider(
|
$dataProvider = new ActiveDataProvider(
|
||||||
['query' => $query ,
|
['query' => $query ,
|
||||||
@ -82,6 +91,10 @@ class InventoryItemSearch extends InventoryItem
|
|||||||
['item_count', 'item_count'],
|
['item_count', 'item_count'],
|
||||||
['item_count', 'item_count'],
|
['item_count', 'item_count'],
|
||||||
['item_difference', 'item_difference'],
|
['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'],
|
||||||
])
|
])
|
||||||
,
|
,
|
||||||
]
|
]
|
||||||
@ -96,17 +109,12 @@ class InventoryItemSearch extends InventoryItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id_inventory_item' => $this->id_inventory_item,
|
'inventory_item.id_inventory_item' => $this->id_inventory_item,
|
||||||
'id_inventory' => $this->id_inventory,
|
'inventory_item.type' => $this->type,
|
||||||
'count_in' => $this->count_in,
|
'inventory_item.id_product' => $this->id_product,
|
||||||
'count_sold' => $this->count_sold,
|
'inventory_item.id_inventory_group' => $this->id_inventory_group,
|
||||||
'count' => $this->count,
|
'inventory_item.id_user' => $this->id_user,
|
||||||
'type' => $this->type,
|
'inventory_item.created_at' => $this->created_at,
|
||||||
'id_product' => $this->id_product,
|
|
||||||
'id_inventory_group' => $this->id_inventory_group,
|
|
||||||
'id_user' => $this->id_user,
|
|
||||||
'created_at' => $this->created_at,
|
|
||||||
'updated_at' => $this->updated_at,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id_inventory',
|
'id_inventory',
|
||||||
|
'name',
|
||||||
['attribute'=>'id_user',
|
['attribute'=>'id_user',
|
||||||
'value'=>$model->userName
|
'value'=>$model->userName
|
||||||
],
|
],
|
||||||
@ -31,7 +32,31 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a(Yii::t('common/inventory', 'Új termék'), ['inventory-item/create','id' =>$model->id_inventory], ['class' => 'btn btn-success']) ?>
|
<?= 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']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Magyarázat:
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
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.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Beszerzett mennyiség: Az előző leltár óta történt beszerzett mennyiségek összege
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Eladott mennyiség: Az előző leltár óta eladott darabszám összege
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Leltározott mennyiség: A felhasználó által összeszámolt és leltár létrehozásakor beírt mennyiség
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Rendszer szerinti mennyiség: a rendszer által számolt és aktuális látott mennyiség
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Különbség: = "Leltározott mennyiség - ( "Előző leltár" + "Beszerzett mennyiség" - "Eladott mennyiség" )
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@ -52,6 +77,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'attribute' => 'user_username',
|
'attribute' => 'user_username',
|
||||||
'label' => 'Felhasználó',
|
'label' => 'Felhasználó',
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'inventory_prev_name',
|
||||||
|
'label' => 'Utolsó leltár'
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'item_count_prev',
|
'attribute' => 'item_count_prev',
|
||||||
@ -72,6 +102,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'attribute' => 'item_count',
|
'attribute' => 'item_count',
|
||||||
'label' => 'Leltározott mennyiség (db)',
|
'label' => 'Leltározott mennyiség (db)',
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'item_count_system',
|
||||||
|
'label' => 'Rendszer szerinti mennyiség (db)',
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'item_difference',
|
'attribute' => 'item_difference',
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<?php echo $form->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']) ?>
|
<?= 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']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'columns' => [
|
'columns' => [
|
||||||
|
|
||||||
'id_inventory',
|
'id_inventory',
|
||||||
'id_user',
|
'name',
|
||||||
|
[ 'attribute' => 'id_user', "value" =>"userName" ],
|
||||||
'created_at:datetime',
|
'created_at:datetime',
|
||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn',
|
['class' => 'yii\grid\ActionColumn',
|
||||||
@ -34,7 +35,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
if ( $action == 'view' ){
|
if ( $action == 'view' ){
|
||||||
return Url::to(['inventory-item/index' , 'id'=> $model->id_inventory]);
|
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',
|
||||||
|
]) ;
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -21,6 +21,7 @@ $this->params['breadcrumbs'][] = "Leltár";
|
|||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id_inventory',
|
'id_inventory',
|
||||||
|
'name',
|
||||||
['attribute'=>'id_user',
|
['attribute'=>'id_user',
|
||||||
'value'=>$model->userName
|
'value'=>$model->userName
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
-0.0.53
|
||||||
|
- inventory changes
|
||||||
|
- add id_ticket_current to card and ticket table
|
||||||
-0.0.52
|
-0.0.52
|
||||||
- card flag
|
- card flag
|
||||||
- inventory item
|
- inventory item
|
||||||
|
|||||||
@ -4,7 +4,7 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.52',
|
'version' => 'v0.0.53',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
|
|||||||
@ -11,11 +11,14 @@ use yii\helpers\ArrayHelper;
|
|||||||
*
|
*
|
||||||
* @property integer $id_inventory
|
* @property integer $id_inventory
|
||||||
* @property integer $id_user
|
* @property integer $id_user
|
||||||
|
* @property string $name
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
*/
|
*/
|
||||||
class Inventory extends \common\models\BaseFitnessActiveRecord
|
class Inventory extends \common\models\BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -30,6 +33,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
[['name'], 'string']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +44,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'),
|
'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_user' => Yii::t('common/inventory', 'Felhasználó'),
|
||||||
'created_at' => Yii::t('common/inventory', 'Létrehozás'),
|
'created_at' => Yii::t('common/inventory', 'Létrehozás'),
|
||||||
'updated_at' => Yii::t('common/inventory', 'Módosítás'),
|
'updated_at' => Yii::t('common/inventory', 'Módosítás'),
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use common\components\Helper;
|
|||||||
* @property integer $count_sold
|
* @property integer $count_sold
|
||||||
* @property integer $count
|
* @property integer $count
|
||||||
* @property integer $count_prev
|
* @property integer $count_prev
|
||||||
|
* @property integer $count_system
|
||||||
* @property integer $type
|
* @property integer $type
|
||||||
* @property integer $id_product
|
* @property integer $id_product
|
||||||
* @property integer $id_inventory_group
|
* @property integer $id_inventory_group
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160311_064422_add__inventory__column__name__add__inventory__column__current_count extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("inventory", "name", "string");
|
||||||
|
$this->addColumn("inventory_item", "count_system", "int");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160311_064422_add__inventory__column__name__add__inventory__column__current_count cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160311_204131_add_card_current_id_ticket extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("door_log", "id_ticket_current", "int default null");
|
||||||
|
$this->addColumn("card", "id_ticket_current", "int default null");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160311_204131_add_card_current_id_ticket cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user