/var/www/vhosts/nabawater/backend/models
Edit: /var/www/vhosts/nabawater/backend/models/ItemIngredientGroup.php (5851B)
[
self::SCENARIO_CREATE,
self::SCENARIO_UPDATE
]
]
];
return ArrayHelper::merge(parent::rules(), $rules);
}
/**
*
* @return array
*/
public function attributeLabels()
{
return [
'item_ingredient_status' => yii::t('backend','Ingredient Status'),
'group_name' => Yii::t('backend', 'Group Name'),
'ingredient_type' => Yii::t('backend', 'Ingredient Type'),
'sort_no' => Yii::t('backend', 'Sort No'),
'maximum' => Yii::t('backend', 'Maximum'),
'vendor_id' => Yii::t('backend', 'Vendor Name')
];
}
/**
*
* @return array
*/
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios[self::SCENARIO_CREATE] = [
'item_ingredient_status',
'ingredient_type',
'minimum',
'maximum',
'sort_no',
'vendor_id'
];
$scenarios[self::SCENARIO_UPDATE] = $scenarios[self::SCENARIO_CREATE];
return $scenarios;
}
/**
*
* @param type $ingredient_ids
* @param type $selection_type
* @param type $item_ingredient_group_id
* @return type
*/
public function getIngredients($ingredientIds = '', $selectionType = '', $itemIngredientGroupId = '', $vendor_id = null)
{
$userId = [
self::CREATED_USER_ID_ADMIN,
isset(Yii::$app->getUser()->getIdentity()->vendor_id),
];
if ($ingredientIds == '' ) {
$ingredientDataArray = Ingredient::find()
->alias('t')
->select(['t.ingredient_id','IL.ingredient_name', 'IIM.default_status'])
->innerJoin(['IL' => IngredientLang::tableName()], 'IL.ingredient_id = t.ingredient_id')
->leftJoin(['IIM' => ItemIngredientMapping::tableName()], 'IIM.ingredient_id = t.ingredient_id')
->where(['IL.language_code' => Yii::$app->language])
->andWhere(['t.ingredient_status' => self::ACTIVE])
->orderBy(['t.ingredient_id' => SORT_DESC])
->andWhere(['t.vendor_id' => $vendor_id])
->andWhere(['not', ['t.vendor_id' => null]])
->asArray()
->All();
} else {
$ingredientDataArray = Ingredient::find()
->alias('t')
->select([
't.ingredient_id',
'IL.ingredient_name',
'IIM.default_status',
'IIM.price'
])
->innerJoin(['IL' => IngredientLang::tableName()], 'IL.ingredient_id = t.ingredient_id AND t.ingredient_id '.$selectionType.'('.$ingredientIds.')')
->leftJoin(['IIM' => ItemIngredientMapping::tableName()], 'IIM.ingredient_id = t.ingredient_id AND IIM.item_ingredient_group_id ='.$itemIngredientGroupId)
->where(['IL.language_code' => Yii::$app->language])
->andWhere(['t.ingredient_status' => self::ACTIVE])
->andWhere(['t.vendor_id' => $vendor_id])
->andWhere(['not', ['t.vendor_id' => null]])
->orderBy([
'IIM.item_ingredient_mapping_id' => SORT_ASC,
't.ingredient_id' => SORT_DESC
])
->asArray()
->All();
}
if (!empty($ingredientDataArray)) {
return $ingredientDataArray;
} else {
return [];
}
}
/**
*
* @param type $item_ingredient_group_id
* @return int
*/
public function getDefaultStatusCount($itemIngredientGroupId='')
{
$defStatusCountArray = ItemIngredientMapping::find()
->alias('t')
->select(['t.item_ingredient_mapping_id'])
->where(['t.item_ingredient_group_id' => $itemIngredientGroupId])
->andWhere(['t.default_status' => 2])
->andWhere(['t.status' => ItemIngredientMapping::ACTIVE])
->asArray()
->All();
if (!empty($defStatusCountArray)) {
return count($defStatusCountArray);
} else {
return 0;
}
}
/**
*
* @param type $index
* @return type
*/
public function getIngredientType($index = '')
{
$ingTypeArray = [
1 => 'Modifier',
2 => 'Sub Course',
];
($index == '') ? ($ingTypeArray = $ingTypeArray) : ($ingTypeArray = ArrayHelper::getValue($ingTypeArray, $index));
return $ingTypeArray;
}
}