<?php
namespace Bitrix\Sale;
use Bitrix\Main,
Bitrix\Main\Localization\Loc;
Loc::loadMessages(__FILE__);
/**
* Class DiscountCouponTable
*
* Fields:
* <ul>
* <li> ID int mandatory
* <li> DISCOUNT_ID int mandatory
* <li> ACTIVE bool optional default 'Y'
* <li> ACTIVE_FROM datetime optional
* <li> ACTIVE_TO datetime optional
* <li> COUPON string(32) mandatory
* <li> TYPE int mandatory
* <li> MAX_USE int mandatory
* <li> USE_COUNT int mandatory
* <li> USER_ID int mandatory
* <li> DATE_APPLY datetime optional
* <li> TIMESTAMP_X datetime optional
* <li> MODIFIED_BY int optional
* <li> DATE_CREATE datetime optional
* <li> CREATED_BY int optional
* <li> DESCRIPTION string optional
* <li> DISCOUNT reference to {@link \Bitrix\Sale\SaleDiscountTable}
* <li> USER reference to {@link \Bitrix\User\UserTable}
* <li> MODIFIED_BY reference to {@link \Bitrix\User\UserTable}
* </ul>
*
* @package Bitrix\Sale
**/
class DiscountCouponTable extends Main\Entity\DataManager
{
/**
* Returns DB table name for entity.
*
* @return string
*/
public static function getTableName()
{
return 'b_sale_discount_coupon';
}
/**
* Returns entity map definition.
*
* @return array
*/
public static function getMap()
{
return array(
'ID' => array(
'data_type' => 'integer',
'primary' => true,
'autocomplete' => true,
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_ID_FIELD'),
),
'DISCOUNT_ID' => array(
'data_type' => 'integer',
'required' => true,
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_DISCOUNT_ID_FIELD'),
),
'ACTIVE' => array(
'data_type' => 'boolean',
'values' => array('N', 'Y'),
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_ACTIVE_FIELD'),
),
'ACTIVE_FROM' => array(
'data_type' => 'datetime',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_ACTIVE_FROM_FIELD'),
),
'ACTIVE_TO' => array(
'data_type' => 'datetime',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_ACTIVE_TO_FIELD'),
),
'COUPON' => array(
'data_type' => 'string',
'required' => true,
'validation' => array(__CLASS__, 'validateCoupon'),
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_COUPON_FIELD'),
),
'TYPE' => array(
'data_type' => 'integer',
'required' => true,
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_TYPE_FIELD'),
),
'MAX_USE' => array(
'data_type' => 'integer',
'required' => true,
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_MAX_USE_FIELD'),
),
'USE_COUNT' => array(
'data_type' => 'integer',
'required' => true,
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_USE_COUNT_FIELD'),
),
'USER_ID' => array(
'data_type' => 'integer',
'required' => true,
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_USER_ID_FIELD'),
),
'DATE_APPLY' => array(
'data_type' => 'datetime',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_DATE_APPLY_FIELD'),
),
'TIMESTAMP_X' => array(
'data_type' => 'datetime',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_TIMESTAMP_X_FIELD'),
),
'MODIFIED_BY' => array(
'data_type' => 'integer',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_MODIFIED_BY_FIELD'),
),
'DATE_CREATE' => array(
'data_type' => 'datetime',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_DATE_CREATE_FIELD'),
),
'CREATED_BY' => array(
'data_type' => 'integer',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_CREATED_BY_FIELD'),
),
'DESCRIPTION' => array(
'data_type' => 'text',
'title' => Loc::getMessage('DISCOUNT_COUPON_ENTITY_DESCRIPTION_FIELD'),
),
'DISCOUNT' => array(
'data_type' => 'Bitrix\Sale\SaleDiscount',
'reference' => array('=this.DISCOUNT_ID' => 'ref.ID'),
),
'USER' => array(
'data_type' => 'Bitrix\User\User',
'reference' => array('=this.USER_ID' => 'ref.ID'),
),
'MODIFIED_BY' => array(
'data_type' => 'Bitrix\User\User',
'reference' => array('=this.MODIFIED_BY' => 'ref.ID'),
),
);
}
/**
* Returns validators for COUPON field.
*
* @return array
*/
public static function validateCoupon()
{
return array(
new Main\Entity\Validator\Length(null, 32),
);
}
}