fix merge conflicts
This commit is contained in:
@@ -166,4 +166,10 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
]);
|
||||
}
|
||||
|
||||
public static function updateCardFlagTicket($id){
|
||||
$db = \Yii::$app->db;
|
||||
$command = $db->createCommand(Ticket::$SQL_UPDATE_CARD,[':id' => $id]);
|
||||
$command->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -140,4 +140,13 @@ class DoorLog extends \yii\db\ActiveRecord
|
||||
19 => "Bérlet érvényességi időn kívüli BE olvastatás (nem enged)",
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCardFlagTexts( ){
|
||||
return [
|
||||
0 => "Kártya ok",
|
||||
1 => "Nincs érvényes bérlet",
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
60
common/models/Inventory.php
Normal file
60
common/models/Inventory.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use common\components\UserAwareBehavior;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "inventory".
|
||||
*
|
||||
* @property integer $id_inventory
|
||||
* @property integer $id_user
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Inventory extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'inventory';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'),
|
||||
'id_user' => Yii::t('common/inventory', 'Felhasználó'),
|
||||
'created_at' => Yii::t('common/inventory', 'Létrehozás'),
|
||||
'updated_at' => Yii::t('common/inventory', 'Módosítás'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => UserAwareBehavior::className(),
|
||||
]
|
||||
], parent::behaviors());
|
||||
}
|
||||
}
|
||||
135
common/models/InventoryItem.php
Normal file
135
common/models/InventoryItem.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
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".
|
||||
*
|
||||
* @property integer $id_inventory_item
|
||||
* @property integer $id_inventory
|
||||
* @property integer $count_in
|
||||
* @property integer $count_sold
|
||||
* @property integer $count
|
||||
* @property integer $count_prev
|
||||
* @property integer $type
|
||||
* @property integer $id_product
|
||||
* @property integer $id_inventory_group
|
||||
* @property integer $id_user
|
||||
* @property integer $id_inventory_item_prev
|
||||
* @property integer $id_user
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class InventoryItem extends BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
public static $TYPE_PRODUCT = 10;
|
||||
public static $TYPE_INVENTORY_GROUP = 20;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'inventory_item';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_inventory_item' => Yii::t('common/inventory_item', 'Id Inventory Item'),
|
||||
'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'),
|
||||
'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'),
|
||||
'id_user' => Yii::t('common/inventory_item', 'Id User'),
|
||||
'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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,20 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
const STATUS_ACTIVE = 10;
|
||||
const STATUS_INACTIVE = 20;
|
||||
|
||||
public static $SQL_UPDATE = "UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card from ticket
|
||||
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end";
|
||||
|
||||
public static $SQL_UPDATE_CARD = "UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card from ticket
|
||||
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end
|
||||
WHERE c1.id_card = :id";
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -312,4 +326,13 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes) {
|
||||
Card::updateCardFlagTicket($this->id_card);;
|
||||
}
|
||||
|
||||
public function afterDelete(){
|
||||
Card::updateCardFlagTicket($this->id_card);;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -927,6 +927,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
// storno contract
|
||||
|
||||
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
||||
|
||||
Reference in New Issue
Block a user