Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- use Bitrix\Main\Loader,
- Bitrix\Main\Localization\Loc,
- Bitrix\Sale;
- if (!Loader::includeModule('catalog') || !Loader::includeModule('sale')) return;
- require_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/sale/general/sale_act.php';
- class CSaleActionCondCtrlBasketProps extends CSaleActionCtrlComplex
- {
- public static function GetClassName()
- {
- return __CLASS__;
- }
- public static function GetControlShow($arParams)
- {
- $arControls = static::GetControls();
- $arResult = array(
- 'controlgroup' => true,
- 'group' => false,
- 'label' => 'Свойства товаров в корзине',
- 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
- 'children' => array()
- );
- foreach ($arControls as &$arOneControl)
- {
- $arOne = array(
- 'controlId' => $arOneControl['ID'],
- 'group' => ('Y' == $arOneControl['GROUP']),
- 'label' => $arOneControl['LABEL'],
- 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
- 'control' => array(
- array(
- 'id' => 'prefix',
- 'type' => 'prefix',
- 'text' => $arOneControl['PREFIX']
- ),
- static::GetLogicAtom($arOneControl['LOGIC']),
- static::GetValueAtom($arOneControl['JS_VALUE'])
- )
- );
- if ('CondBsktPropDiscountSave' == $arOneControl['ID'])
- {
- $arOne['control'][] = '%';
- }
- if (!empty($arOne))
- $arResult['children'][] = $arOne;
- }
- if (isset($arOneControl))
- unset($arOneControl);
- return $arResult;
- }
- public static function GetControls($strControlID = false)
- {
- $arControlList = array(
- 'CondBsktPropDiscountSave' => array(
- 'ID' => 'CondBsktPropDiscountSave',
- 'FIELD' => 'DISCOUNT_SAVE',
- 'FIELD_TYPE' => 'double',
- 'LABEL' => 'Процент накопительной скидки',
- 'PREFIX' => 'поле Процент накопительной скидки',
- 'LOGIC' => static::GetLogic(
- array(
- BT_COND_LOGIC_EQ,
- BT_COND_LOGIC_NOT_EQ,
- BT_COND_LOGIC_GR,
- BT_COND_LOGIC_LS,
- BT_COND_LOGIC_EGR,
- BT_COND_LOGIC_ELS
- )
- ),
- 'JS_VALUE' => array(
- 'type' => 'input'
- ),
- )
- );
- foreach ($arControlList as &$control)
- {
- $control['MODULE_ID'] = 'sale';
- $control['MODULE_ENTITY'] = 'sale';
- $control['ENTITY'] = 'PRORS';
- $control['MULTIPLE'] = 'N';
- $control['GROUP'] = 'N';
- }
- unset($control);
- if (false === $strControlID)
- {
- return $arControlList;
- }
- elseif (isset($arControlList[$strControlID]))
- {
- return $arControlList[$strControlID];
- }
- else
- {
- return false;
- }
- }
- public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
- {
- $strResult = '';
- if (is_string($arControl))
- {
- $arControl = static::GetControls($arControl);
- }
- if (count($arControl)) {
- //$strPrefix = 'Site\HelpersShop::searchProps($row, #FIELD#) !== false && ';
- $strPrefix = '';
- foreach ($arControl['LOGIC'] as &$arC) {
- if ($arC['ID'] == BT_COND_LOGIC_EQ) {
- if (isset($arC['OP']['N'])) {
- $arC['OP']['N'] = $strPrefix.'Site\HelpersShop::getDiscountSave($row) == #VALUE#';
- }//\\ if
- if (isset($arC['OP']['Y'])) {
- $arC['OP']['Y'] = $strPrefix.'in_array(#VALUE#, Site\HelpersShop::getDiscountSave($row))';
- }//\\ if
- } elseif ($arC['ID'] == BT_COND_LOGIC_NOT_EQ) {
- if (isset($arC['OP']['N'])) {
- $arC['OP']['N'] = $strPrefix.'Site\HelpersShop::getDiscountSave($row) != #VALUE#';
- }//\\ if
- if (isset($arC['OP']['Y'])) {
- $arC['OP']['Y'] = $strPrefix.'!in_array(#VALUE#, Site\HelpersShop::getDiscountSave($row))';
- }//\\ if
- } elseif ($arC['ID'] == BT_COND_LOGIC_GR) {
- if (isset($arC['OP']['N'])) {
- $arC['OP']['N'] = $strPrefix.'Site\HelpersShop::getDiscountSave($row) > #VALUE#';
- }//\\ if
- if (isset($arC['OP']['Y'])) {
- $arC['OP']['Y'] = $strPrefix.'CGlobalCondCtrl::LogicGreat(Site\HelpersShop::getDiscountSave($row), #VALUE#)';
- }//\\ if
- } elseif ($arC['ID'] == BT_COND_LOGIC_LS) {
- if (isset($arC['OP']['N'])) {
- $arC['OP']['N'] = $strPrefix.'Site\HelpersShop::getDiscountSave($row) < #VALUE#';
- }//\\ if
- if (isset($arC['OP']['Y'])) {
- $arC['OP']['Y'] = $strPrefix.'CGlobalCondCtrl::LogicLess(Site\HelpersShop::getDiscountSave($row), #VALUE#)';
- }//\\ if
- } elseif ($arC['ID'] == BT_COND_LOGIC_EGR) {
- if (isset($arC['OP']['N'])) {
- $arC['OP']['N'] = $strPrefix.'Site\HelpersShop::getDiscountSave($row) >= #VALUE#';
- }//\\ if
- if (isset($arC['OP']['Y'])) {
- $arC['OP']['Y'] = $strPrefix.'CGlobalCondCtrl::LogicEqualGreat(Site\HelpersShop::getDiscountSave($row), #VALUE#)';
- }//\\ if
- } elseif ($arC['ID'] == BT_COND_LOGIC_ELS) {
- if (isset($arC['OP']['N'])) {
- $arC['OP']['N'] = $strPrefix.'Site\HelpersShop::getDiscountSave($row) <= #VALUE#';
- }//\\ if
- if (isset($arC['OP']['Y'])) {
- $arC['OP']['Y'] = $strPrefix.'CGlobalCondCtrl::LogicEqualLess(Site\HelpersShop::getDiscountSave($row), #VALUE#)';
- }//\\ if
- }//\\ if
- }
- }
- $boolError = !is_array($arControl);
- if (!$boolError)
- {
- $arValues = static::Check($arOneCondition, $arOneCondition, $arControl, false);
- $boolError = (false === $arValues);
- }
- if (!$boolError)
- {
- $arLogic = static::SearchLogic($arValues['logic'], $arControl['LOGIC']);
- if (!isset($arLogic['OP'][$arControl['MULTIPLE']]) || empty($arLogic['OP'][$arControl['MULTIPLE']]))
- {
- $boolError = true;
- }
- else
- {
- $valueField = '\''.$arControl['FIELD'].'\'';
- // (isset($row['PROPS']) && count($row['PROPS']) && Site\HelpersShop::searchProps($row, 'DISCOUNT_SAVE') !== false && $row['PROPS'][Site\HelpersShop::searchProps($row, 'DISCOUNT_SAVE')]['VALUE'] == 2)
- switch ($arControl['FIELD_TYPE'])
- {
- case 'int':
- case 'double':
- $strResult = str_replace(array('#FIELD#', '#VALUE#'), array($valueField, $arValues['value']), $arLogic['OP'][$arControl['MULTIPLE']]);
- break;
- case 'char':
- case 'string':
- case 'text':
- $strResult = str_replace(array('#FIELD#', '#VALUE#'), array($valueField, '"'.EscapePHPString($arValues['value']).'"'), $arLogic['OP'][$arControl['MULTIPLE']]);
- break;
- case 'date':
- case 'datetime':
- $strResult = str_replace(array('#FIELD#', '#VALUE#'), array($valueField, $arValues['value']), $arLogic['OP'][$arControl['MULTIPLE']]);
- break;
- }
- //$strResult = 'isset($row[\'PROPS\']) && count($row[\'PROPS\']) && '.$strResult;
- }
- }
- return (!$boolError ? $strResult : false);
- }
- public static function GetShowIn($arControls)
- {
- $arControls = array(CSaleActionCtrlBasketGroup::GetControlID(), CSaleActionCtrlSubGroup::GetControlID());
- return $arControls;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement