Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • AdditionalMenuWidget_Item
  • AdvancedSliderHomepageWidget_Item
  • AssetManagerFolder
  • BannerWidget_Item
  • BaseObjectDecorator
  • BookingOrder
  • BookingPaymentMethod
  • BookingService
  • Boolean
  • ButtonsBlockHomepageWidget_Item
  • CarouselHomepageWidget_Item
  • CatalogRubricsHomepageWidget_CatalogDecorator
  • ClientEmailOrderNotification
  • ClientVKOrderNotification
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • DocumentItem
  • DocumentPage_File
  • Double
  • Enum
  • ErrorPageSubsite
  • FileDataObjectTrackingDecorator
  • FileImportDecorator
  • Float
  • ForeignKey
  • Hierarchy
  • HTMLText
  • HTMLVarchar
  • ImportLog_Item
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • OrderDataObject
  • OrderHandlersDecorator
  • OrderItemVariationDecorator
  • OrderService
  • OrderServiceOrder
  • OrdersExportDecorator
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • RatePeriod
  • RealtyImportLog
  • RealtyImportLog_Item
  • RedirectEntry
  • RoomOrder
  • RoomOrderPerson
  • RoomRate
  • RoomService
  • RoomServiceOrder
  • SberbankPaymentDecorator
  • SeoOpenGraphPageDecorator
  • ServiceOrder
  • ShippingMethodPaymentDecorator
  • ShopCountry
  • SimpleOrderCatalogDecorator
  • SimpleOrderProductDecorator
  • SiteConfigWidgets
  • SiteTreeDecorator
  • SiteTreeImportDecorator
  • SliderHomepageWidget_Item
  • SMSCOrderNotification
  • SMSOrderNotification
  • SortableDataObject
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • StringField
  • SubsiteDomain
  • Text
  • TextAnonsWidget_Item
  • Texture3D_File
  • Time
  • Varchar
  • Versioned
  • Versioned_Version
  • VideoCategory
  • VideoEntry
  • VKNotificationQueue
  • WebylonWidget_Item
  • YaMoneyPaymentDecorator
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface
 1 <?php
 2 /*
 3  * Услуги (базовый класс)
 4  *
 5  * @author menedem
 6  */
 7 class BookingService extends DataObject {
 8     static $db = array(
 9         'Title' => 'Varchar(200)',
10         'Price' => 'Decimal(10, 2)',
11         'Active' => 'Boolean',
12         'Description' => 'HTMLText',
13         'MaxCountType' => "Enum('person, day, count')", //максимальное количество: по кол-ву человек; по кол-ву дней (по идее только для однократных услуг); N раз + поле ввода N
14         'MaxCount' => 'Int', //поле N
15         'Repeat' => "Enum('one_time, every_day')", //повторяемость: однократная услуга/на каждый день
16     );
17     
18     static $has_one = array(
19         'Icon' => 'Image'
20     );
21     
22     static $searchable_fields = array('Title', 'Active', 'Price');
23     static $summary_fields = array('Title', 'ActiveTitle', 'Price');
24     
25     function fieldLabels($relations = true) {
26         $labels = parent::fieldLabels($relations);
27         $labels['ActiveTitle'] = $labels['Active'];
28         return $labels;
29     }
30 
31     function ActiveTitle() {
32         return ($this->Active) ? _t('Boolean.YES') : _t('Boolean.NO');
33     }
34     
35     function getCMSFields() {
36         $fields = parent::getCMSFields();
37         $fields->addFieldToTab('Root', new Tab("FullContent", $this->fieldLabel('Description')));
38         $fields->addFieldToTab('Root.FullContent', $fields->dataFieldByName('Description'));
39         
40         $values = array();
41         foreach ($this->dbObject('MaxCountType')->enumValues() as $val) {
42             $title = _t('BookingService.MaxCountType_' . $val, $val);
43             $values["$val//$title"] = ($val == 'count') ? $fields->dataFieldByName('MaxCount') : new LabelField('','');
44         }
45         $fields->removeByName('MaxCount');          
46         $fields->replaceField('MaxCountType', new SelectionGroup('MaxCountType', $values));     
47         $fields->addFieldToTab('Root.Main', new LabelField('labelMaxCountType', $this->fieldLabel('MaxCountType')), 'MaxCountType');
48 
49         $values = array();
50         foreach($this->dbObject('Repeat')->enumValues() as $val) {
51             $values[$val] = _t('BookingService.Repeat_' . $val);
52         }
53         $fields->replaceField('Repeat', new OptionsetField('Repeat', $this->fieldLabel('Repeat'), $values));        
54 
55         return $fields;
56     }
57     
58     function getServiceSelector($prefix, $count) {
59         $className = $this->ClassName;
60         $nums = array();
61         $nums[0] = _t('BookingService.SelectText', 'select');
62         for($i=1; $i <= $count; $i++) {
63             $nums[$i] = $i;
64         }
65         $f = new DropdownField("{$prefix}[$this->ID]", '', $nums);
66         $f->addExtraClass("{$className}Selector");
67         $f->addExtraClass($this->MaxCountType);
68         $f->addExtraAttribute('data-service_id', $this->ID);
69         
70         return $f;      
71     }
72     
73     // цена за период проживания в зависимости от типа
74     function Cost() {
75         if ($this->Repeat == 'one_time') {
76             return (float)$this->Price;
77         }
78         return (float)BookingPage::getFilterDatesPeriodLength() * $this->Price;
79     }
80 
81     function onBeforeWrite() {
82         if ($this->isChanged('MaxCountType') && ($this->MaxCountType == 'day')) {
83             $this->Repeat = 'one_time';
84         }
85         parent::onBeforeWrite();
86     }
87 }
[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. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0