add inventory admin fix, add procurement update

This commit is contained in:
2016-03-30 20:04:49 +02:00
parent 19761cb0cc
commit a12b87d3be
22 changed files with 853 additions and 245 deletions

View File

@@ -8,6 +8,7 @@ use yii\helpers\ArrayHelper;
use yii\db\Query;
use backend\models\InventoryItemForm;
use common\components\AccountAwareBehavior;
use common\components\Helper;
/**
* This is the model class for table "inventory".
@@ -15,6 +16,7 @@ use common\components\AccountAwareBehavior;
* @property integer $id_inventory
* @property integer $id_user
* @property integer $id_account
* @property integer $status
* @property string $name
* @property string $created_at
* @property string $updated_at
@@ -22,6 +24,9 @@ use common\components\AccountAwareBehavior;
class Inventory extends \common\models\BaseFitnessActiveRecord
{
public static $STATUS_OPEN = 10;
public static $STATUS_CLOSED = 20;
/**
* @inheritdoc
@@ -40,6 +45,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return [
[['name'], 'string'],
[['id_account'], 'integer'],
[['name'], 'validateOnlyClosed'],
];
}
@@ -51,6 +57,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
return [
'id_inventory' => Yii::t('common/inventory', 'Leltár azonosító'),
'name' => Yii::t('common/inventory', 'Megnevezés'),
'status' => Yii::t('common/inventory', 'Státusz'),
'id_user' => Yii::t('common/inventory', 'Felhasználó'),
'id_account' => Yii::t('common/inventory', 'Kassza'),
'created_at' => Yii::t('common/inventory', 'Létrehozás'),
@@ -58,6 +65,14 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
];
}
public function validateOnlyClosed($attribute,$params){
$opened = Inventory::find()->andWhere(['status' => Inventory::$STATUS_OPEN])->all();
if ( count($opened) > 0 ){
$this->addError("name","Kérem előbb zárjon le minden másik leltárt");
}
}
/**
* @inheritdoc
*/
@@ -85,7 +100,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
// $query->andWhere("product.id_inventory_group is null");
$products = $query->all();
echo "Products found: " . count($products);
//echo "Products found: " . count($products);
$inventoryGroups = InventoryGroup::find()->all();
@@ -120,5 +135,20 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
}
public static function statuses(){
return [
Inventory::$STATUS_CLOSED => "Lezárva",
Inventory::$STATUS_OPEN => "Nyitva"
];
}
public function getStatusHuman(){
return Helper::getArrayValue(self::statuses(), $this->status, "NA");
}
public function isOpen(){
return $this->status == self::$STATUS_OPEN;
}
}