Skip to content

Instantly share code, notes, and snippets.

@BekNaji
Created November 3, 2021 14:13
Show Gist options
  • Save BekNaji/bf21b0e9cf7f4b8262530d0c78f8d140 to your computer and use it in GitHub Desktop.
Save BekNaji/bf21b0e9cf7f4b8262530d0c78f8d140 to your computer and use it in GitHub Desktop.
<?php
AddEventHandler('iblock', 'OnIBlockPropertyBuildList', array('CIBlockPropertyCustomButton', 'GetUserTypeDescription'));
class CIBlockPropertyCustomButton
{
function GetUserTypeDescription()
{
return array(
"PROPERTY_TYPE" => "L",
"USER_TYPE" => "custom_button",
"DESCRIPTION" => 'Разделить как группу',
"GetPublicViewHTML" => array("CIBlockPropertyCustomButton","GetPublicViewHTML"),
"GetAdminListViewHTML" => array("CIBlockPropertyCustomButton","GetAdminListViewHTML"),
"GetPropertyFieldHtml" => array("CIBlockPropertyCustomButton","GetPropertyFieldHtml"),
"ConvertToDB" => array("CIBlockPropertyCustomButton","ConvertToDB"),
"ConvertFromDB" => array("CIBlockPropertyCustomButton","ConvertFromDB"),
);
}
function GetPublicViewHTML($arProperty, $value, $strHTMLControlName)
{
return '';
}
function GetAdminListViewHTML($arProperty, $value, $strHTMLControlName)
{
return '';
}
function GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
{
$html = '
<tr id="tr_CODE">
<td class="adm-detail-content-cell-r">
<input type="text" name="'.$strHTMLControlName["VALUE"].'[SUM]" value="'.$value['VALUE']['SUM'].'" size="20" maxlength="255">
</td>
<td width="60%" class="adm-detail-content-cell-r">
<select name="'.$strHTMLControlName["VALUE"].'[CURRENYC]" size="1">
<option value="UZS" '.($value["VALUE"]["CURRENYC"] == "UZS" ? "selected" : "").'>UZS</option>
<option value="USD" '.($value["VALUE"]["CURRENYC"] == "USD" ? "selected" : "").'>USD</option>
</select>
</td>
</tr>';
return $html;
}
function ConvertToDB($arProperty, $value)
{
$newValue = json_encode($value["VALUE"]);
$value['VALUE'] = $newValue;
return $value;
}
function ConvertFromDB($arProperty, $value)
{
$newValue = json_decode($value['VALUE'],true);
$value['VALUE'] = $newValue;
return $value;
}
function PrepareSettings($arFields)
{
//echo '<pre>'; print_r($arFields); echo '</pre>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment