add card.flag implementation
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\components\UserAwareBehavior;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "inventory_item".
|
||||
@@ -24,6 +27,9 @@ use Yii;
|
||||
*/
|
||||
class InventoryItem extends BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
public static $TYPE_PRODUCT = 10;
|
||||
public static $TYPE_INVENTORY_GROUP = 20;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -56,10 +62,74 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
'id_product' => Yii::t('common/inventory_item', 'Id Product'),
|
||||
'id_inventory_group' => Yii::t('common/inventory_item', 'Id Inventory Group'),
|
||||
'id_user' => Yii::t('common/inventory_item', 'Id User'),
|
||||
'last_inventroy_at' => Yii::t('common/inventory_item', 'Last Inventroy At'),
|
||||
'created_at' => Yii::t('common/inventory_item', 'Created At'),
|
||||
'updated_at' => Yii::t('common/inventory_item', 'Updated At'),
|
||||
];
|
||||
}
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => UserAwareBehavior::className(),
|
||||
]
|
||||
], parent::behaviors());
|
||||
}
|
||||
|
||||
public static function creqteQueryInventoryItems($id_inventory ) {
|
||||
$query = InventoryItem::find();
|
||||
|
||||
$query->andWhere(['inventory_item.id_inventory' => $id_inventory]);
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getProduct(){
|
||||
return $this->hasOne( Product::className() , [ 'id_product' => 'id_product' ]);
|
||||
}
|
||||
|
||||
public function getInventoryGroup(){
|
||||
return $this->hasOne( Product::className() , [ 'id_inventory_group' => 'id_inventory_group' ]);
|
||||
}
|
||||
|
||||
public function getProductName(){
|
||||
$result = "";
|
||||
|
||||
$product = $this->product;
|
||||
|
||||
if ( isset($product)){
|
||||
$result = $product->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getInventoryGroupName(){
|
||||
$result = "";
|
||||
|
||||
$product = $this->inventoryGroup;
|
||||
|
||||
if ( isset($product)){
|
||||
$result = $product->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
$name = "";
|
||||
|
||||
if ( isset($this->id_product )){
|
||||
$name = $this->getProductName();
|
||||
}else{
|
||||
$name = $this->getInventoryGroupName();
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
public function getDifference(){
|
||||
$diff = $this->count - ( $this->count_prev + $this->count_in - $this->count_sold );
|
||||
return $diff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user