implement feature 'put to cart ticket installment request'

This commit is contained in:
Roland Schneider
2019-03-26 07:29:47 +01:00
parent 3fce2c70c2
commit 8de73c0585
9 changed files with 444 additions and 203 deletions

View File

@@ -71,7 +71,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
}
public function validateOnlyClosed($attribute,$params){
public function validateOnlyClosed( ){
$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");
@@ -93,7 +93,12 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
]
], parent::behaviors());
}
/**
* @param $insert
* @param $changedAttributes
* @throws \Exception
*/
public function afterSave($insert, $changedAttributes){
if ( $insert ){
@@ -101,12 +106,18 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
if ( isset($this->id_account) && is_numeric($this->id_account)){
$query->andWhere(['id_account' => $this->id_account]);
}
if ( \Yii::$app->params['inventory.products.only.active']) {
$query->andWhere( ['status' => Product::STATUS_ACTIVE] );
}
$products = $query->all();
$inventoryGroups = InventoryGroup::find()->all();
foreach ($products as $product){
/** @var \common\models\Product $product */
foreach ($products as $product){
$form = new InventoryItemForm(
[
'inventory' => $this,
@@ -117,8 +128,9 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
);
$form->save();
}
foreach ($inventoryGroups as $group){
/** @var \common\models\InventoryGroup $group */
foreach ($inventoryGroups as $group){
$form = new InventoryItemForm(
[
'inventory' => $this,