Version: current

     1 <?php
     2
     3 /**
     4  * Настройки для каталога
     5  *
     6  * @package Catalog
     7  * @author inxo, menedem, dvp
     8  */
     9 class Orders1CExchange_SiteConfig extends SiteConfigDecorator {
    10
    11     function extraStatics() {
    12         return array(
    13             'db' => array(
    14                 'OrderStatusToExportFrom' => "Enum('Unpaid,Paid,Processing,Complete')", // С какого статуса отправлять заказы в 1С
    15             )
    16         );
    17     }
    18
    19     static $exchanger_class = 'Orders1CExchange_Exporter';
    20
    21     public function updateCMSFields(FieldSet &$fields) {
    22         $tab = self::get_config_tab($fields, 'Export1C');
    23
    24         $statusValues = $this->owner->dbObject('OrderStatusToExportFrom')->enumValues();
    25         foreach ($statusValues as $statusItem => $statusName) {
    26             $statusValues[$statusItem] = Order::status_title($statusItem);
    27         }
    28         $tab->push(new DropdownField('OrderStatusToExportFrom', $this->owner->FieldLabel('OrderStatusToExportFrom'), $statusValues));
    29     }
    30
    31     function StatusesToExport() {
    32         $statuses = array();
    33         $statusValues = singleton('Order')->dbObject('Status')->enumValues();
    34         $find = false;
    35         foreach ($statusValues as $statusItem => $statusName) {
    36             if ($statusItem == $this->owner->OrderStatusToExportFrom) {
    37                 $find = true;
    38             }
    39             if ($find) {
    40                 $statuses[$statusItem] = "'{$statusItem}'";
    41             }
    42         }
    43         return $statuses;
    44     }
    45
    46     function requireDefaultRecords() {
    47          if (!$Group = DataObject::get_one("Group", "`Group`.`Code` = 'EXCHANGE_1C'")) {
    48             $group = new Group();
    49             $group->Code = 'EXCHANGE_1C';
    50             $group->Title = "Экспорт в 1С";
    51             $group->write();
    52
    53             Permission::grant($group->ID, 'EXCHANGE_1C');
    54             if (method_exists('DB', 'alteration_message'))
    55                 DB::alteration_message(_t('Registration.GROUPCREATED', 'Members group created'), "created");
    56         }
    57
    58     }
    59 }
    60

[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. -