За последние 24 часа нас посетили 20390 программистов и 1095 роботов. Сейчас ищут 807 программистов ...

Корректировка php скрипта

Тема в разделе "Сделайте за меня", создана пользователем svzla, 26 окт 2021.

Метки:
  1. svzla

    svzla Новичок

    С нами с:
    26 окт 2021
    Сообщения:
    1
    Симпатии:
    0
    Суть проблемы такова: на сайте есть js ползунок с выбором интервала доставки(13-15, 15-17 и т.д.), но работает он немного криво. Нужно сделать так, чтобы выбор интервала на 'сегодняшний' день был ограничен - т.е., например, если человек хочет выбрать интервал 13-15 в 12:50, нужно заблокировать все нижестоящие интервалы, включая 13-15, и оставить для выбора только последующие. Буду очень благодарен помощи и советам! PHP код:
    PHP:
    1. function showOrderProperty ( $arProp, $arDataProps )
    2. {
    3.  $readonly = $required = $dataRequired = '';
    4.  if ( $arProp['REQUIRED'] == 'Y' )
    5.  {
    6.  $required = ' *';
    7.  $dataRequired = ' data-required';
    8.  }
    9.  
    10.  if ( $arProp['READONLY'] == 'Y' )
    11.  {
    12.  $readonly = ' readonly';
    13.  }
    14.  
    15.  $dataPhone = $arProp['IS_PHONE'] == 'Y' ? ' data-input-phone' : '';
    16.  $class = 'form-control bx-soa-customer-input bx-ios-fix';
    17.  $class .= $arProp['CODE'] == 'DATE' ? ' date-input' : '';
    18.  $class .= $arProp['CODE'] == 'TIME_DELIVERY' ? ' time-input' : '';
    19.  $class .= $arProp['IS_PHONE'] == 'Y' ? ' phone-input' : '';
    20.  $string = '<div class="form-group bx-soa-customer-field">';
    21.  if ( $arProp["TYPE"] == "ENUM" && $arProp["ID"] != 34)
    22.  {
    23.  foreach ( $arProp["OPTIONS"] as $value => $name )
    24.  {
    25.  $string .= '<div class="soa-property-container input-group">';
    26.  $string .= '<div class="radio">';
    27.  $string .= '<input type="radio" name="ORDER_PROP_' . $arProp['ID'] . '" value="' . $value . '" id="radio-' . $arProp['ID'] . '-' . $value . '" ' . ( in_array( $value, $arProp["VALUE"] ) ? 'checked' : '' ) . '>';
    28.  $string .= '<label for="radio-' . $arProp['ID'] . '-' . $value . '" class="bx-soa-custom-label">' . $name . '</label>';
    29.  $string .= '</div>';
    30.  $string .= '</div>';
    31.  }
    32.  }
    33.  elseif ( $arProp["ID"] == 34)
    34.  {
    35.  $current_hour = date("H")."-".date("H",strtotime($date. " + 2hour "));
    36.  $nextHour = date("H",strtotime($date. " + 1hour "))."-".date("H",strtotime($date. " + 3hour "));
    37.  
    38.  $current_hour_selected = "";
    39.  
    40.  $string .= '<div class="soa-property-container input-group">';
    41.  $string .= '<select name="ORDER_PROP_' . $arProp['ID'] . '" class="form-control">';
    42.  foreach ( $arProp["OPTIONS"] as $value => $name )
    43.  {
    44.  
    45.  if( in_array( $value, $arProp["VALUE"] ) ){
    46.  $current_hour_selected = "selected";
    47.  }else{
    48.  
    49.  if( intval($_REQUEST["currentStep"]) < 3 ){
    50.  if( $value == $current_hour || $value == $nextHour ){
    51.  $current_hour_selected = "selected";
    52.  }else{
    53.  $current_hour_selected = "";
    54.  }
    55.  }else{
    56.  $current_hour_selected = "";
    57.  }
    58.  
    59.  }
    60.  
    61.  $string .= '<option value="' . $value . '" ' . $current_hour_selected . ' data-sd="'.$nextHour.'" >' . $name . '</option>';
    62.  }
    63.  $string .= '</select><span></span>';
    64.  $string .= '</div>';
    65.  }
    66.  elseif ( $arProp["TYPE"] == "Y/N" )
    67.  {
    68.  // $string .= '<div class="soa-property-container input-group">';
    69.  $string .= '<input type="hidden" name="ORDER_PROP_' . $arProp['ID'] . '" value="N">';
    70.  
    71.  $string .= '<div class="checkbox">';
    72.  $string .= '<input type="checkbox" name="ORDER_PROP_' . $arProp['ID'] . '" value="Y" id="checkbox-' . $arProp['ID'] . '-Y" ' . ( in_array( 'Y', $arProp["VALUE"] ) ? 'checked' : '' ) . '>';////
    73.  $string .= '<label for="checkbox-' . $arProp['ID'] . '-Y" class="bx-soa-custom-label">' . $arProp['NAME'] . '</label>';
    74.  $string .= '</div>';
    75.  // $string .= '</div>';
    76.  }
    77.  elseif ( $arProp["ROWS"] > 1 )
    78.  {
    79.  $string .= '<div class="soa-property-container input-group">';
    80.  $string .= '<textarea type="text" name="ORDER_PROP_' . $arProp['ID'] . '" id="soa-property-' . $arProp['ID'] . '" autocomplete="off" placeholder="' . $arProp['DESCRIPTION'] . $required .
    81.  '" class="form-control bx-soa-customer-input input-textarea bx-ios-fix">' . $arDataProps[ $arProp['ID'] ] . '</textarea>';
    82.  $string .= '</div>';
    83.  }
    84.  else
    85.  {
    86.  $my_datetime = "";
    87.  if( $arProp['ID'] == "27" ){
    88.  $my_datetime = " datetime_input_27";
    89.  }
    90.  
    91.  $string .= "";
    92.  $string .= '<div class="soa-property-container input-group'.$my_datetime.'">';
    93.  $string .= '<input type="text" name="ORDER_PROP_' . $arProp['ID'] . '" id="soa-property-' . $arProp['ID'] . '" value="' . $arDataProps[ $arProp['ID'] ] .
    94.  '" class="' . $class . '" placeholder="' . $arProp['DESCRIPTION'] . $required . '"' . $dataRequired . $readonly . '>';
    95.  // $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>':'';
    96.  $string .= $arProp['CODE'] == 'DATE' ? '<span class="input-group-addon input-group-append bx-no-alter-margin"></span>' : '';
    97.  $string .= $arProp['CODE'] == 'TIME_DELIVERY' ? '<span class="input-group-addon input-group-append bx-no-alter-margin"></span>' : '';
    98.  $string .= '</div>';
    99.  }
    100.  
    101.  $string .= '</div>';
    102.  
    103.  return $string;
    104. }
    105.  
    106.  
    107. function showPropertyResult ( $arProp, $arDataProps )
    108. {
    109.  $string = '<p>';
    110.  if($arProp['DESCRIPTION'])
    111.  $string .= '<b>' . $arProp['DESCRIPTION'] . '</b>: ';
    112.  if ( $arProp["TYPE"] == "ENUM" )
    113.  {
    114.  foreach ( $arProp["OPTIONS"] as $value => $name )
    115.  {
    116.  if ( in_array( $value, $arProp["VALUE"] ) )
    117.  {
    118.  $string .= $name;
    119.  }
    120.  }
    121.  }
    122.  elseif ( $arProp["TYPE"] == "Y/N" )
    123.  {
    124.  if ( in_array( 'Y', $arProp["VALUE"] ) )
    125.  {
    126.  $string .= $arProp['NAME'];
    127.  }
    128.  }
    129.  elseif ( $arProp["ROWS"] > 1 )
    130.  {
    131.  $string .= $arDataProps[ $arProp['ID'] ];
    132.  }
    133.  else
    134.  {
    135.  $string .= $arDataProps[ $arProp['ID'] ];
    136.  
    137.  }
    138.  $string .= '</p>';
    139.  
    140.  return $string;
    141. }
    От модератора: для вставки кода кнопка </>
     
    #1 svzla, 26 окт 2021
    Последнее редактирование модератором: 26 окт 2021