/var/www/vhosts/nabawater/backend/models
Edit: /var/www/vhosts/nabawater/backend/models/Item.php (8218B)
function ($model) {
return $model->is_offer === 1;
},
'whenClient' => "function (attribute, value) {
return ($('input:radio[name=\"Item[is_offer]\"]:checked').val() == 1) ? true : false;
}"
],
['quantity', 'number', 'min' => 0],
[
[
'item_price',
'item_size',
'orginal_price',
],
'number',
'min' => 1,
'max' => 1000000
],
[
'item_price',
'compare',
'compareAttribute' => 'orginal_price',
'operator' => '<',
'type' => 'number',
'message' => 'item price not less then or equal to orginal price',
'when' => function ($model) {
return $model->is_offer === 1;
},
'whenClient' => "function (attribute, value) {
return ($('input:radio[name=\"Item[is_offer]\"]:checked').val() == 1) ? true : false;
}"
],
];
return ArrayHelper::merge(parent::rules(), $rules);
}
/**
*
* @return array
*/
public function attributeLabels()
{
$label = [
'item_image_path' => yii::t('backend','Item Image'),
'vendor_id' => yii::t('backend','Vendor Name'),
'branch_id' => yii::t('backend','Branch Name'),
'branch_name' => yii::t('backend','Branch Name'),
'category_id' => yii::t('backend','Category Name'),
'cuisine_id' => yii::t('backend','Cuisine Name'),
'item_approved_status' => yii::t('backend','Approval Status'),
'item_name' => Yii::t('backend', 'Item Name'),
'category_name' => Yii::t('backend', 'Category Name'),
'vendor_name' => Yii::t('backend', 'Vendor Name'),
'cuisine_name' => Yii::t('backend', 'Cuisine Name'),
'item_price' => Yii::t('backend', 'Item Price'),
'orginal_price' => Yii::t('backend', 'Orginal Price'),
'sort_no' => Yii::t('backend', 'Sort No'),
'item_status' => Yii::t('backend', 'Item Status'),
'unit_id' => Yii::t('backend', 'Unit Name'),
'is_offer' => Yii::t('backend', 'Is Offer'),
'item_purchase_type' => Yii::t('backend', 'Item Purchase Type'),
'item_size' => Yii::t('backend', 'Item Size'),
'is_refund_bottle' => Yii::t('backend', 'Is Refund Bottle'),
'quantity' => Yii::t('backend', 'Quantity'),
];
return ArrayHelper::merge(parent::attributeLabels(), $label);
}
/**
*
* @param type $index
* @return array
*/
public function getItemData($index = '')
{
$itemData = Item::find()
->alias('I')
->select([
'I.item_id',
'IL.item_name'
])
->leftJoin(['IL' => ItemLang::tableName()], 'IL.item_id = I.item_id')
->where(['<>', 'I.item_status', Item::DELETE])
->asArray()
->all();
if (!empty($itemData)) {
return ArrayHelper::map($itemData,'item_id', 'item_name');
} else {
return [];
}
}
/**
*
* @param type $index
* @return array
*/
public function getBranchItem($branch)
{
$itemData = Item::find()
->alias('I')
->select([
'I.item_id',
'IL.item_name'
])
->leftJoin(['IL' => ItemLang::tableName()], 'IL.item_id = I.item_id')
->where(['<>', 'I.item_status', Item::DELETE])
->andwhere(['=', 'I.branch_id', $branch])
->asArray()
->all();
if (!empty($itemData)) {
return ArrayHelper::map($itemData,'item_id', 'item_name');
} else {
return [];
}
}
public static function getCategoryName() {
$categoryName = CategoryLang::find()
->alias('CL')
->leftJoin(['C'=> Category::tableName()], 'C.category_id = CL.category_id')
->select([
'C.category_id',
'CL.category_name'
])
->where(['CL.language_code' => Yii::$app->language])
->andwhere(['<>', 'C.parent_category_id' , 0])
->andwhere(['<>', 'C.category_status', Category::DELETE])
->asArray()
->all();
if (!empty($categoryName)) {
return ArrayHelper::map($categoryName,'category_id', 'category_name');
} else {
return [];
}
}
public static function getVendorName() {
$vendorName = VendorLang::find()
->alias('VL')
->leftJoin(['V'=> Vendor::tableName()], 'V.vendor_id = VL.vendor_id')
->select([
'V.vendor_id',
'VL.vendor_name'
])
->where(['VL.language_code' => Yii::$app->language])
->andwhere(['<>', 'V.vendor_status', Vendor::DELETE])
->asArray()
->all();
if (!empty($vendorName)) {
return ArrayHelper::map($vendorName,'vendor_id', 'vendor_name');
} else {
return [];
}
}
/**
*
* @param type $index
* @return array
*/
public function getVendorItemData($vendor_id = null)
{
$itemData = Item::find()
->alias('I')
->select([
'I.item_id',
'IL.item_name'
])
->leftJoin(['IL' => ItemLang::tableName()], 'IL.item_id = I.item_id AND IL.language_code = :language',['language' => \Yii::$app->language])
->where(['<>', 'I.item_status', Item::DELETE])
->andwhere(['=', 'I.vendor_id', $vendor_id])
->orderBy(['IL.item_name' => SORT_ASC])
->asArray()
->all();
// print_r($itemData); die;
if (!empty($itemData)) {
return ArrayHelper::map($itemData,'item_id', 'item_name');
} else {
return [];
}
}
}