svzla
Новичок
Суть проблемы такова: на сайте есть js ползунок с выбором интервала доставки(13-15, 15-17 и т.д.), но работает он немного криво. Нужно сделать так, чтобы выбор интервала на 'сегодняшний' день был ограничен - т.е., например, если человек хочет выбрать интервал 13-15 в 12:50, нужно заблокировать все нижестоящие интервалы, включая 13-15, и оставить для выбора только последующие. Буду очень благодарен помощи и советам! PHP код:
Код:
function showOrderProperty ( $arProp, $arDataProps )
{
$readonly = $required = $dataRequired = '';
if ( $arProp['REQUIRED'] == 'Y' )
{
$required = ' *';
$dataRequired = ' data-required';
}
if ( $arProp['READONLY'] == 'Y' )
{
$readonly = ' readonly';
}
$dataPhone = $arProp['IS_PHONE'] == 'Y' ? ' data-input-phone' : '';
$class = 'form-control bx-soa-customer-input bx-ios-fix';
$class .= $arProp['CODE'] == 'DATE' ? ' date-input' : '';
$class .= $arProp['CODE'] == 'TIME_DELIVERY' ? ' time-input' : '';
$class .= $arProp['IS_PHONE'] == 'Y' ? ' phone-input' : '';
$string = '<div class="form-group bx-soa-customer-field">';
if ( $arProp["TYPE"] == "ENUM" && $arProp["ID"] != 34)
{
foreach ( $arProp["OPTIONS"] as $value => $name )
{
$string .= '<div class="soa-property-container input-group">';
$string .= '<div class="radio">';
$string .= '<input type="radio" name="ORDER_PROP_' . $arProp['ID'] . '" value="' . $value . '" id="radio-' . $arProp['ID'] . '-' . $value . '" ' . ( in_array( $value, $arProp["VALUE"] ) ? 'checked' : '' ) . '>';
$string .= '<label for="radio-' . $arProp['ID'] . '-' . $value . '" class="bx-soa-custom-label">' . $name . '</label>';
$string .= '</div>';
$string .= '</div>';
}
}
elseif ( $arProp["ID"] == 34)
{
$current_hour = date("H")."-".date("H",strtotime($date. " + 2hour "));
$nextHour = date("H",strtotime($date. " + 1hour "))."-".date("H",strtotime($date. " + 3hour "));
$current_hour_selected = "";
$string .= '<div class="soa-property-container input-group">';
$string .= '<select name="ORDER_PROP_' . $arProp['ID'] . '" class="form-control">';
foreach ( $arProp["OPTIONS"] as $value => $name )
{
if( in_array( $value, $arProp["VALUE"] ) ){
$current_hour_selected = "selected";
}else{
if( intval($_REQUEST["currentStep"]) < 3 ){
if( $value == $current_hour || $value == $nextHour ){
$current_hour_selected = "selected";
}else{
$current_hour_selected = "";
}
}else{
$current_hour_selected = "";
}
}
$string .= '<option value="' . $value . '" ' . $current_hour_selected . ' data-sd="'.$nextHour.'" >' . $name . '</option>';
}
$string .= '</select><span></span>';
$string .= '</div>';
}
elseif ( $arProp["TYPE"] == "Y/N" )
{
// $string .= '<div class="soa-property-container input-group">';
$string .= '<input type="hidden" name="ORDER_PROP_' . $arProp['ID'] . '" value="N">';
$string .= '<div class="checkbox">';
$string .= '<input type="checkbox" name="ORDER_PROP_' . $arProp['ID'] . '" value="Y" id="checkbox-' . $arProp['ID'] . '-Y" ' . ( in_array( 'Y', $arProp["VALUE"] ) ? 'checked' : '' ) . '>';////
$string .= '<label for="checkbox-' . $arProp['ID'] . '-Y" class="bx-soa-custom-label">' . $arProp['NAME'] . '</label>';
$string .= '</div>';
// $string .= '</div>';
}
elseif ( $arProp["ROWS"] > 1 )
{
$string .= '<div class="soa-property-container input-group">';
$string .= '<textarea type="text" name="ORDER_PROP_' . $arProp['ID'] . '" id="soa-property-' . $arProp['ID'] . '" autocomplete="off" placeholder="' . $arProp['DESCRIPTION'] . $required .
'" class="form-control bx-soa-customer-input input-textarea bx-ios-fix">' . $arDataProps[ $arProp['ID'] ] . '</textarea>';
$string .= '</div>';
}
else
{
$my_datetime = "";
if( $arProp['ID'] == "27" ){
$my_datetime = " datetime_input_27";
}
$string .= "";
$string .= '<div class="soa-property-container input-group'.$my_datetime.'">';
$string .= '<input type="text" name="ORDER_PROP_' . $arProp['ID'] . '" id="soa-property-' . $arProp['ID'] . '" value="' . $arDataProps[ $arProp['ID'] ] .
'" class="' . $class . '" placeholder="' . $arProp['DESCRIPTION'] . $required . '"' . $dataRequired . $readonly . '>';
// $string .= $arProp['CODE'] == 'DATE'? '<div class="input-group-append bx-no-alter-margin"><span class="input-group-text"><i class="fa fa-calendar"></i></span></div>':'';
$string .= $arProp['CODE'] == 'DATE' ? '<span class="input-group-addon input-group-append bx-no-alter-margin"></span>' : '';
$string .= $arProp['CODE'] == 'TIME_DELIVERY' ? '<span class="input-group-addon input-group-append bx-no-alter-margin"></span>' : '';
$string .= '</div>';
}
$string .= '</div>';
return $string;
}
function showPropertyResult ( $arProp, $arDataProps )
{
$string = '<p>';
if($arProp['DESCRIPTION'])
$string .= '<b>' . $arProp['DESCRIPTION'] . '</b>: ';
if ( $arProp["TYPE"] == "ENUM" )
{
foreach ( $arProp["OPTIONS"] as $value => $name )
{
if ( in_array( $value, $arProp["VALUE"] ) )
{
$string .= $name;
}
}
}
elseif ( $arProp["TYPE"] == "Y/N" )
{
if ( in_array( 'Y', $arProp["VALUE"] ) )
{
$string .= $arProp['NAME'];
}
}
elseif ( $arProp["ROWS"] > 1 )
{
$string .= $arDataProps[ $arProp['ID'] ];
}
else
{
$string .= $arDataProps[ $arProp['ID'] ];
}
$string .= '</p>';
return $string;
}