Version: current

     1 <?php
     2 /*
     3  * Услуги номеров
     4  *
     5  * @author menedem
     6  */
     7 class RoomService extends BookingService {
     8     static $belongs_many_many = array(
     9         'Rooms' => 'Room',
    10         'RoomRate' => 'RoomRate',
    11     );
    12
    13     static function get_active() {
    14         return DataObject::get('RoomService', 'Active = 1');
    15     }
    16
    17     function getCMSFields() {
    18         $fields = parent::getCMSFields();
    19         $fields->removeByName('Rooms');
    20         $fields->removeByName('RoomRate');
    21         return $fields;
    22     }
    23
    24     /**
    25      *
    26      *
    27      * @param <type> $rate
    28      *
    29      * @return <type>
    30      */
    31     function HTML($order, $value=0) {
    32         $rate = $order->Rate();
    33         $count = 1;
    34         $days = BookingPage::getFilterDatesPeriodLength();
    35         $persons = $rate->TotalPersonCount;
    36         switch ($this->MaxCountType) {
    37             case 'person':
    38                 $count = $persons;
    39                 break;
    40
    41             case 'day':
    42                 $count = $days;
    43                 break;
    44
    45             case 'count':
    46                 $count = $this->MaxCount;
    47                 break;
    48         }
    49
    50         $selector = $this->getServiceSelector("RoomService[$order->ID]", $count);
    51         $selector->setValue($value);
    52         $selector->addExtraAttribute('data-rate_id', $rate->ID);
    53         $selector->addExtraAttribute('autocomplete', 'off');
    54
    55         return $this->customise(array(
    56             'RoomID' => $rate->RoomID,
    57             'Count' => $count,
    58             'Person' => $persons,
    59             'Day' => $days,
    60             'Service' => $this,
    61             'Rate' => $rate,
    62             'Selector' => $selector,
    63             'ServicePrice' => $this->Cost() * $value,
    64         ))->renderWith('RoomService');
    65     }
    66 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -