1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
templatetable.php
См. документацию.
1<?php
2namespace Bitrix\MessageService\Internal\Entity;
3
4use Bitrix\Main\Type\DateTime;
5use Bitrix\Main\ORM\Data\DataManager;
6use Bitrix\Main\ORM\Fields\StringField;
7use Bitrix\Main\ORM\Fields\DatetimeField;
8use Bitrix\Main\ORM\Fields\IntegerField;
9use Bitrix\Main\ORM\Fields\Validators\LengthValidator;
10use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
11use Bitrix\Main\ORM\Data\Internal\MergeTrait;
12
14{
15 use MergeTrait;
16 use DeleteByFilterTrait;
17
21 public static function getTableName(): string
22 {
23 return 'b_messageservice_template';
24 }
25
29 public static function getMap(): array
30 {
31 return [
32 'ID' =>
33 (new IntegerField('ID'))
34 ->configurePrimary()
35 ->configureAutocomplete()
36 ,
37 'NAME' =>
38 (new StringField('NAME'))
39 ->configureRequired()
40 ->configureSize(500)
41 ->addValidator(new LengthValidator(1, 500))
42 ,
43 'TITLE' =>
44 (new StringField('TITLE'))
45 ->configureRequired()
46 ->configureSize(500)
47 ->addValidator(new LengthValidator(1, 500))
48 ,
49 'DATE_CREATE' =>
50 (new DatetimeField('DATE_CREATE'))
51 ->configureDefaultValue(function()
52 {
53 return new DateTime();
54 })
55 ,
56 'ACTIVE' =>
57 (new StringField('ACTIVE'))
58 ->configureRequired()
59 ->configureSize(1)
60 ->addValidator(new LengthValidator(1, 1))
61 ->configureDefaultValue('Y')
62 ,
63 ];
64 }
65
66 public static function refreshTemplates(array $templates = []): bool
67 {
68 $names = [];
69 $titles = [];
70 $outdatedTemplates = [];
71 $allTemplates = self::getList()->fetchAll();
72 foreach ($templates as $template)
73 {
74 $names[$template['NAME']] = $template['NAME'];
75 $titles[$template['NAME']] = $template['TITLE'];
76 }
77
78 foreach ($allTemplates as $template)
79 {
80 if (!in_array($template['NAME'], $names, true))
81 {
82 $outdatedTemplates[] = $template['ID'];
83 }
84
85 unset($names[$template['NAME']]);
86 }
87
88 if (count($outdatedTemplates))
89 {
90 self::updateMulti(
91 $outdatedTemplates,
92 ['ACTIVE' => 'N'],
93 true
94 );
95 }
96
97 if (count($names))
98 {
99 $newTemplates = [];
100 foreach ($names as $name)
101 {
102 $newTemplates[] = [
103 'NAME' => $name,
104 'TITLE' => $titles[$name] ?? $name,
105 ];
106 }
107 self::addMulti($newTemplates, true);
108 }
109
111
112 return true;
113 }
114}
static getList(array $parameters=array())
Определения datamanager.php:431
static addMulti($rows, $ignoreEvents=false)
Определения datamanager.php:1041
static refreshTemplates(array $templates=[])
Определения templatetable.php:66
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936