Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
field.php
1<?php
9
12
13Loc::loadMessages(__FILE__);
14
31class FieldTable extends Entity\DataManager
32{
38 public static function getTableName()
39 {
40 return 'b_consent_field';
41 }
42
48 public static function getMap()
49 {
50 return array(
51 'ID' => array(
52 'data_type' => 'integer',
53 'primary' => true,
54 'autocomplete' => true,
55 ),
56 'AGREEMENT_ID' => array(
57 'data_type' => 'integer',
58 'required' => true,
59 ),
60 'CODE' => array(
61 'data_type' => 'string',
62 'required' => true,
63 ),
64 'VALUE' => array(
65 'data_type' => 'text',
66 'required' => true,
67 )
68 );
69 }
70
77 public static function getConsentFields($agreementId)
78 {
79 $fields = array();
80 $fieldsDb = static::getList(array(
81 'filter' => array(
82 '=AGREEMENT_ID' => $agreementId
83 )
84 ));
85 while ($field = $fieldsDb->fetch())
86 {
87 $fields[$field['CODE']] = $field['VALUE'];
88 }
89
90 return $fields;
91 }
92
100 public static function setConsentFields($agreementId, array $fields)
101 {
102 // remove old fields
103 $deleteFieldsDb = static::getList(array(
104 'select' => array('ID'),
105 'filter' => array(
106 '=AGREEMENT_ID' => $agreementId
107 )
108 ));
109 while ($deleteField = $deleteFieldsDb->fetch())
110 {
111 static::delete($deleteField['ID']);
112 }
113
114 // add new fields
115 foreach ($fields as $code => $value)
116 {
117 $result = static::add(array(
118 'AGREEMENT_ID' => $agreementId,
119 'CODE' => $code,
120 'VALUE' => $value,
121 ));
122 $result->isSuccess();
123 }
124 }
125}
static loadMessages($file)
Definition loc.php:64