[CODE]
class TwoForTwo extends \CSaleActionCtrlBasketGroup
{
public static function GetClassName()
{
return __CLASS__;
}
public static function GetShowIn($arControls)
{
return array(\CSaleActionCtrlGroup::GetControlID());
}
public static function GetControlID()
{
return 'TovarCondGroup2';
}
public static function GetAtoms()
{
return static::GetAtomsEx(false, false);
}
public static function GetAtomsEx($strControlID = false, $boolEx = false)
{
$boolEx = (true === $boolEx ? true : false);
$arAtomList = array(
'Cnt' => array(
'JS' => array(
'id' => 'Cnt',
'name' => 'extra_coll',
'type' => 'select',
'values' => array(
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
),
"defaultText" => "...",
"defaultValue" => "",
'first_option' => '...'
),
'ATOM' => array(
'ID' => 'Cnt',
'FIELD_TYPE' => 'string',
'FIELD_LENGTH' => 255,
'MULTIPLE' => 'N',
'VALIDATE' => 'list'
)
),
'Proc' => array(
'JS' => array(
'id' => 'Proc',
'name' => 'extra_proc',
'type' => 'input'
),
'ATOM' => array(
'ID' => 'Proc',
'FIELD_TYPE' => 'string',
'FIELD_LENGTH' => 255,
'MULTIPLE' => 'N',
'VALIDATE' => ''
)
)
);
if (!$boolEx) {
foreach ($arAtomList as &$arOneAtom) {
$arOneAtom = $arOneAtom['JS'];
}
if (isset($arOneAtom))
unset($arOneAtom);
}
return $arAtomList;
}
public static function GetControlDescr() {
$description = parent::GetControlDescr();
$description['EXECUTE_MODULE'] = 'all';
$description['SORT'] = 500;
return $description;
}
public static function GetControlShow($arParams)
{
$arAtoms = static::GetAtomsEx(false, false);
$arResult = array(
'controlId' => static::GetControlID(),
'group' => true,
//'containsOneAction' => true,
'label' => "тест",
'defaultText' => 'тест',
'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
//'children' => array(),
'control' => array(
$arAtoms['Cnt'],
" тест ",
$arAtoms['Proc'],
)
);
return $arResult;
}
public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
{
$mxResult = '';
$actionParams = array(
'CNT' => $arOneCondition['Cnt'],
'PROC' => $arOneCondition['Proc']
);
if (!empty($arSubs))
{
$filter = '$saleact'.$arParams['FUNC_ID'];
if ($arOneCondition['All'] == 'AND')
{
$prefix = '';
$logic = ' && ';
$itemPrefix = ($arOneCondition['True'] == 'True' ? '' : '!');
}
else
{
$itemPrefix = '';
if ($arOneCondition['True'] == 'True')
{
$prefix = '';
$logic = ' || ';
}
else
{
$prefix = '!';
$logic = ' && ';
}
}
$commandLine = $itemPrefix.implode($logic.$itemPrefix, $arSubs);
if ($prefix != '')
$commandLine = $prefix.'('.$commandLine.')';
$discountParams = array ( 'VALUE' => -10.0, 'UNIT' => 'P', 'LIMIT_VALUE' => 0, 'dopparam'=>$actionParams);
$mxResult = $filter.'=function($row){';
$mxResult .= 'return ('.$commandLine.');';
$mxResult .= '};';
$mxResult .= '\Roztech\SaleDiscount\Actions2::applyToBasket('.$arParams['ORDER'].', '.var_export($discountParams, true).', '.$filter.');';
unset($filter);
}
else
{
$discountParams = array ( 'VALUE' => -10.0, 'UNIT' => 'P', 'LIMIT_VALUE' => 0, 'dopparam'=>$actionParams);
$mxResult = '\Roztech\SaleDiscount\Actions2::applyToBasket('.$arParams['ORDER'].', '.var_export($discountParams, true).', "");';
}
return $mxResult;
}
}
[/CODE]