Merge branch 'release/v.0.1.05'
This commit is contained in:
commit
4826c566fe
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace backend\controllers;
|
namespace backend\controllers;
|
||||||
|
|
||||||
|
use common\models\Log;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Product;
|
use common\models\Product;
|
||||||
use backend\models\ProductSearch;
|
use backend\models\ProductSearch;
|
||||||
@ -117,8 +118,19 @@ class ProductController extends \backend\controllers\BackendController
|
|||||||
|
|
||||||
$accounts = Account::readAccounts($model->id_account);
|
$accounts = Account::readAccounts($model->id_account);
|
||||||
$categories = ProductCategory::read($model->id_product_category);
|
$categories = ProductCategory::read($model->id_product_category);
|
||||||
|
|
||||||
|
$stockOriginal = $model->stock;
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
|
|
||||||
|
$stockUpdated = $model->stock;
|
||||||
|
|
||||||
|
$message = "Update product. Stock: " . $stockOriginal . " -> " . $stockUpdated;
|
||||||
|
Log::log([
|
||||||
|
'type' =>Log::$TYPE_CRUD,
|
||||||
|
'message' => $message,
|
||||||
|
'id_product' => $model->id_product
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
} else {
|
} else {
|
||||||
return $this->render('update', [
|
return $this->render('update', [
|
||||||
|
|||||||
@ -76,9 +76,13 @@ class SiteController extends Controller
|
|||||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||||
|
|
||||||
$geoip = Helper::getGeoIp();
|
$geoip = Helper::getGeoIp();
|
||||||
|
|
||||||
|
|
||||||
$user = User::findOne(\Yii::$app->user->id);
|
$user = User::findOne(\Yii::$app->user->id);
|
||||||
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $geoip->ip . " Város: " . $geoip->city;
|
|
||||||
|
$ipAddress = ( isset($geoip) && isset($geoip->ip) ) ? $geoip->ip : "ismeretlen";
|
||||||
|
$geoCity = ( isset($geoip) && isset($geoip->city) ) ? $geoip->city : "ismeretlen";
|
||||||
|
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $ipAddress . " Város: " . $geoCity;
|
||||||
|
|
||||||
Log::log([
|
Log::log([
|
||||||
'type' =>Log::$TYPE_LOGIN,
|
'type' =>Log::$TYPE_LOGIN,
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace backend\models;
|
namespace backend\models;
|
||||||
|
|
||||||
|
use common\models\Waste;
|
||||||
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
Yii;
|
Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
@ -47,6 +48,7 @@ class InventoryItemForm extends Model{
|
|||||||
|
|
||||||
/** internal stuff*/
|
/** internal stuff*/
|
||||||
public $product_in;
|
public $product_in;
|
||||||
|
public $product_waste;
|
||||||
public $product_out;
|
public $product_out;
|
||||||
public $product_stock;
|
public $product_stock;
|
||||||
public $last_inventory_item;
|
public $last_inventory_item;
|
||||||
@ -94,19 +96,18 @@ class InventoryItemForm extends Model{
|
|||||||
|
|
||||||
public function save(){
|
public function save(){
|
||||||
|
|
||||||
|
|
||||||
$this->loadLastInventory();
|
$this->loadLastInventory();
|
||||||
|
|
||||||
$this->loadLastInventoryItem();
|
$this->loadLastInventoryItem();
|
||||||
$this->loadProductIn();
|
$this->loadProductIn();
|
||||||
$this->loadProductSold();
|
$this->loadProductSold();
|
||||||
$this->loadProductStock();
|
$this->loadProductStock();
|
||||||
|
$this->loadProductWaste();
|
||||||
|
|
||||||
$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_system = $this->product_stock;
|
$item->count_system = $this->product_stock;
|
||||||
|
$item->count_waste = $this->product_waste;
|
||||||
|
|
||||||
if ( isset($this->inventory )){
|
if ( isset($this->inventory )){
|
||||||
if ( $this->inventory->type == Inventory::$TYPE_DAILY){
|
if ( $this->inventory->type == Inventory::$TYPE_DAILY){
|
||||||
@ -125,7 +126,6 @@ class InventoryItemForm extends Model{
|
|||||||
}else{
|
}else{
|
||||||
$item->count_prev = 0;
|
$item->count_prev = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( isset(\Yii::$app->user )){
|
if ( isset(\Yii::$app->user )){
|
||||||
$item->id_user = \Yii::$app->user->id;
|
$item->id_user = \Yii::$app->user->id;
|
||||||
@ -157,7 +157,7 @@ class InventoryItemForm extends Model{
|
|||||||
$query->select(['coalesce(sum(procurement.count),0) as total_in']);
|
$query->select(['coalesce(sum(procurement.count),0) as total_in']);
|
||||||
$query->from(Procurement::tableName());
|
$query->from(Procurement::tableName());
|
||||||
$query->innerJoin(Product::tableName(),"product.id_product = procurement.id_product");
|
$query->innerJoin(Product::tableName(),"product.id_product = procurement.id_product");
|
||||||
|
|
||||||
if ( isset($this->last_inventory_item ) ){
|
if ( isset($this->last_inventory_item ) ){
|
||||||
$query->andWhere([ '>', 'procurement.created_at' ,$this->last_inventory_item->created_at]);
|
$query->andWhere([ '>', 'procurement.created_at' ,$this->last_inventory_item->created_at]);
|
||||||
}
|
}
|
||||||
@ -170,10 +170,31 @@ class InventoryItemForm extends Model{
|
|||||||
}else{
|
}else{
|
||||||
$query->andWhere(['product.id_inventory_group' => $this->inventoryGroup->id_inventory_group]);
|
$query->andWhere(['product.id_inventory_group' => $this->inventoryGroup->id_inventory_group]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->product_in = $query->scalar();
|
$this->product_in = $query->scalar();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function loadProductWaste(){
|
||||||
|
$query = new Query();
|
||||||
|
$query->select(['coalesce(sum(waste.count),0) as total_waste']);
|
||||||
|
$query->from(Waste::tableName());
|
||||||
|
$query->innerJoin(Product::tableName(),"product.id_product = waste.id_product");
|
||||||
|
|
||||||
|
if ( isset($this->last_inventory_item ) ){
|
||||||
|
$query->andWhere([ '>', 'waste.created_at' ,$this->last_inventory_item->created_at]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( $this->type == 'product') {
|
||||||
|
$query->andWhere(['product.id_product' => $this->product->id_product]);
|
||||||
|
}else{
|
||||||
|
$query->andWhere(['product.id_inventory_group' => $this->inventoryGroup->id_inventory_group]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->product_waste = $query->scalar();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadProductSold(){
|
protected function loadProductSold(){
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
-0.1.05
|
||||||
|
- add inventory waste fix
|
||||||
-0.1.04
|
-0.1.04
|
||||||
- add inventory daily
|
- add inventory daily
|
||||||
-0.1.03
|
-0.1.03
|
||||||
|
|||||||
@ -5,7 +5,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.1.04',
|
'version' => 'v0.1.05',
|
||||||
'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
|
||||||
|
|||||||
@ -17,6 +17,7 @@ use common\components\ProductAwareBehavior;
|
|||||||
* @property integer $id_inventory
|
* @property integer $id_inventory
|
||||||
* @property integer $count_in
|
* @property integer $count_in
|
||||||
* @property integer $count_sold
|
* @property integer $count_sold
|
||||||
|
* @property integer $count_waste
|
||||||
* @property integer $count
|
* @property integer $count
|
||||||
* @property integer $count_prev
|
* @property integer $count_prev
|
||||||
* @property integer $count_system
|
* @property integer $count_system
|
||||||
@ -229,6 +230,7 @@ class InventoryItem extends BaseFitnessActiveRecord
|
|||||||
$count_prev = 0;
|
$count_prev = 0;
|
||||||
$count_in = 0;
|
$count_in = 0;
|
||||||
$count_sold = 0;
|
$count_sold = 0;
|
||||||
|
$count_waste = 0;
|
||||||
|
|
||||||
$price = 0;
|
$price = 0;
|
||||||
if (isset($price) && is_numeric($price)){
|
if (isset($price) && is_numeric($price)){
|
||||||
@ -255,10 +257,14 @@ class InventoryItem extends BaseFitnessActiveRecord
|
|||||||
$count_sold = $this->count_sold;
|
$count_sold = $this->count_sold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isset($this->count_waste)){
|
||||||
|
$count_waste = $this->count_waste;
|
||||||
|
}
|
||||||
|
|
||||||
//netto készlet érték
|
//netto készlet érték
|
||||||
$this->net_stock_money = $count * $purchase_price_net;
|
$this->net_stock_money = $count * $purchase_price_net;
|
||||||
//leltárhiány db
|
//leltárhiány db
|
||||||
$this->stock_missing_count = $this->count - ($count_prev + $count_in - $count_sold) ;
|
$this->stock_missing_count = $this->count - ($count_prev + $count_in - $count_sold - $count_waste) ;
|
||||||
//leltárhiány összeg
|
//leltárhiány összeg
|
||||||
$this->stock_missing_money = $price * $this->stock_missing_count;
|
$this->stock_missing_money = $price * $this->stock_missing_count;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ class Log extends BaseFitnessActiveRecord
|
|||||||
public static $TYPE_KEY_UNASSIGN = 180;
|
public static $TYPE_KEY_UNASSIGN = 180;
|
||||||
public static $TYPE_TOWEL_IN = 190;
|
public static $TYPE_TOWEL_IN = 190;
|
||||||
public static $TYPE_TOWEL_OUT = 200;
|
public static $TYPE_TOWEL_OUT = 200;
|
||||||
|
public static $TYPE_CRUD = 210;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
|||||||
@ -1,22 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace console\controllers;
|
namespace console\controllers;
|
||||||
|
|
||||||
use backend\components\InventoryManager;
|
use backend\components\InventoryManager;
|
||||||
use common\models\Inventory;
|
use common\models\Inventory;
|
||||||
use common\models\InventoryItem;
|
use common\models\InventoryItem;
|
||||||
use common\models\Transfer;
|
use common\models\Product;
|
||||||
|
use common\models\Waste;
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
use yii\db\Expression;
|
|
||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
|
|
||||||
|
|
||||||
class InventoryConsoleController extends Controller{
|
class InventoryConsoleController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $idInventory
|
* @param $idInventory
|
||||||
*/
|
*/
|
||||||
public function actionFixSold($idInventory){
|
public function actionFixWaste($idInventory)
|
||||||
|
{
|
||||||
|
|
||||||
$inventory = Inventory::findOne($idInventory);
|
$inventory = Inventory::findOne($idInventory);
|
||||||
|
|
||||||
@ -25,38 +28,94 @@ class InventoryConsoleController extends Controller{
|
|||||||
$items = InventoryItem::find()->andWhere(['id_inventory' => $inventory->id_inventory])->all();
|
$items = InventoryItem::find()->andWhere(['id_inventory' => $inventory->id_inventory])->all();
|
||||||
|
|
||||||
/** @var /common/models/InventoryItem $item */
|
/** @var /common/models/InventoryItem $item */
|
||||||
foreach ($items as $item ){
|
foreach ($items as $item) {
|
||||||
|
|
||||||
|
/** @var /common/models/InventoryItem $prev */
|
||||||
$prev = $item->inventoryItemPrev;
|
$prev = $item->inventoryItemPrev;
|
||||||
|
|
||||||
if ( !isset($prev)){
|
if (!isset($prev)) {
|
||||||
continue;
|
$start = null;
|
||||||
|
$end = null;
|
||||||
|
} else {
|
||||||
|
$start = $prev->created_at;
|
||||||
|
$end = $item->created_at;
|
||||||
}
|
}
|
||||||
$start = $prev->created_at;
|
|
||||||
$end = $item->created_at;
|
|
||||||
|
|
||||||
|
|
||||||
$query = new Query();
|
$query = new Query();
|
||||||
$query->select([
|
$query->select(['coalesce(sum(waste.count),0) as total_waste']);
|
||||||
new Expression(" coalesce( sum( transfer.count ),0)")
|
$query->from(Waste::tableName());
|
||||||
]);
|
$query->innerJoin(Product::tableName(), "product.id_product = waste.id_product");
|
||||||
$query->from('transfer');
|
|
||||||
$query->innerJoin('sale','sale.id_sale = transfer.id_object');
|
|
||||||
$query->innerJoin('product','sale.id_product = product.id_product');
|
|
||||||
|
|
||||||
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
if (isset($prev)) {
|
||||||
$query->andWhere(['in', 'transfer.status', [Transfer::STATUS_NOT_PAID, Transfer::STATUS_PAID]]);
|
$query->andWhere(['>', 'waste.created_at', $prev->created_at]);
|
||||||
$query->andWhere(['product.id_product' => $prev->id_product]);
|
}
|
||||||
|
|
||||||
$query->andWhere([ '>','transfer.created_at',$start ]);
|
$query->andWhere(['<', 'waste.created_at', $inventory->created_at]);
|
||||||
$query->andWhere([ '<','transfer.created_at',$end ]);
|
|
||||||
|
|
||||||
$products = $query->scalar();
|
|
||||||
|
|
||||||
$item->count_sold = $products;
|
if ($item->type == 10) {
|
||||||
|
$query->andWhere(['product.id_product' => $item->id_product]);
|
||||||
|
} else {
|
||||||
|
$query->andWhere(['product.id_inventory_group' => $item->id_inventory_group]);
|
||||||
|
}
|
||||||
|
|
||||||
echo $item->price_brutto . " - ". $item->productName ."\n";
|
$product_waste = $query->scalar();
|
||||||
|
$item->count_waste = $product_waste;
|
||||||
|
|
||||||
|
echo $item->price_brutto . " - " . $item->productName . " - " . $product_waste . "\n";
|
||||||
|
|
||||||
|
$item->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idInventory
|
||||||
|
*/
|
||||||
|
public
|
||||||
|
function actionFixSold($idInventory)
|
||||||
|
{
|
||||||
|
|
||||||
|
$inventory = Inventory::findOne($idInventory);
|
||||||
|
|
||||||
|
|
||||||
|
/** @var /common/models/InventoryItem[] $items */
|
||||||
|
$items = InventoryItem::find()->andWhere(['id_inventory' => $inventory->id_inventory])->all();
|
||||||
|
|
||||||
|
/** @var /common/models/InventoryItem $item */
|
||||||
|
foreach ($items as $item) {
|
||||||
|
|
||||||
|
// $prev = $item->inventoryItemPrev;
|
||||||
|
//
|
||||||
|
// if ( !isset($prev)){
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// $start = $prev->created_at;
|
||||||
|
// $end = $item->created_at;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// $query = new Query();
|
||||||
|
// $query->select([
|
||||||
|
// new Expression(" coalesce( sum( transfer.count ),0)")
|
||||||
|
// ]);
|
||||||
|
// $query->from('transfer');
|
||||||
|
// $query->innerJoin('sale','sale.id_sale = transfer.id_object');
|
||||||
|
// $query->innerJoin('product','sale.id_product = product.id_product');
|
||||||
|
//
|
||||||
|
// $query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||||
|
// $query->andWhere(['in', 'transfer.status', [Transfer::STATUS_NOT_PAID, Transfer::STATUS_PAID]]);
|
||||||
|
// $query->andWhere(['product.id_product' => $prev->id_product]);
|
||||||
|
//
|
||||||
|
// $query->andWhere([ '>','transfer.created_at',$start ]);
|
||||||
|
// $query->andWhere([ '<','transfer.created_at',$end ]);
|
||||||
|
//
|
||||||
|
// $products = $query->scalar();
|
||||||
|
//
|
||||||
|
// $item->count_sold = $products;
|
||||||
|
//
|
||||||
|
|
||||||
|
echo $item->price_brutto . " - " . $item->productName . "\n";
|
||||||
|
|
||||||
$item->save();
|
$item->save();
|
||||||
|
|
||||||
@ -69,14 +128,12 @@ class InventoryConsoleController extends Controller{
|
|||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionCreate()
|
public function actionCreate()
|
||||||
{
|
{
|
||||||
$inventoryManager = new InventoryManager();
|
$inventoryManager = new InventoryManager();
|
||||||
$inventoryManager->generateDaily();
|
$inventoryManager->generateDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m170404_060114_alter_table_inventory_item_add_colum_count_waste extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("inventory_item", "count_waste", "int default 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m170404_060114_alter_table_inventory_item_add_colum_count_waste 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