-- Аннотация блока нужна только для пакета update.
-- #BLOCK#
DELETE FROM script_event_type WHERE mid='0';

SET @mid=0, @old_event_id=1, @new_event_id='ru.bitel.bgbilling.kernel.contract.balance.server.event.PaymentEvent', @event_title='Приход платежа';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=2, @new_event_id='ru.bitel.bgbilling.kernel.contract.balance.server.event.ChargeEvent', @event_title='Занесение расхода';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=44, @new_event_id='ru.bitel.bgbilling.kernel.contract.balance.server.event.PaymentDeletedEvent', @event_title='Платеж удален';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=45, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractSetStatusLogicEvent', @event_title='Задание логики перетирания статусов';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=18, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractStatusChangingEvent', @event_title='Изменение статуса договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=19, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractStatusChangedEvent', @event_title='Статус договора изменен';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ContractWebLoginEvent', 1, 'Авторизация в Web');

SET @mid=0, @old_event_id=5, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractCreatedEvent', @event_title='Договор создан';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=9, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractParamChangedEvent', @event_title='Изменен параметр договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=11, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ServiceUpdateEvent', @event_title='Изменение/добавления услуги договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=12, @new_event_id='ru.bitel.bgbilling.kernel.event.events.GetAdditionalWebActionListEvent', @event_title='Получение списка доп. действия для Web статистики';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=15, @new_event_id='ru.bitel.bgbilling.kernel.event.events.GetAdditionalActionListEvent', @event_title='Получение списка доп. действия для договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=16, @new_event_id='ru.bitel.bgbilling.kernel.event.events.AdditionalActionEvent', @event_title='Обработка доп. действия для договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=22, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractAddObjectEvent', @event_title='Объект: Добавление объекта договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=23, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractUpdateObjectEvent', @event_title='Объект: Изменение объекта договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=24, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractDeleteObjectEvent', @event_title='Объект: Удаление объекта договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=27, @new_event_id='ru.bitel.bgbilling.kernel.event.events.OnContractWrapEvent', @event_title='Договор переоформлен';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=29, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractObjectParameterUpdateEvent', @event_title='Объект: Изменен параметр объекта договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=32, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractTariffUpdateEvent', @event_title='Тариф: Изменение тарифа договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=33, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractTariffDeleteEvent', @event_title='Тариф: Удаление тарифа договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=35, @new_event_id='ru.bitel.bgbilling.kernel.event.events.PersonalTariffUpdateEvent', @event_title='Тариф: Добавление/Изменение персонального тарифного плана';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=36, @new_event_id='ru.bitel.bgbilling.kernel.event.events.PersonalTariffDeleteEvent', @event_title='Тариф: Удаление  персонального тарифного плана';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=37, @new_event_id='ru.bitel.bgbilling.kernel.event.events.PersonalTariffTreeUpdateEvent', @event_title='Тариф: Изменение в дереве персонального тарифного плана';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=3, @new_event_id='ru.bitel.bgbilling.kernel.event.events.TimerEvent', @event_title='Таймер';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=4, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ChangeTariffByTaskEvent', @event_title='Тариф: Смена тарифа по заданию пользователя';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=10, @new_event_id='ru.bitel.bgbilling.kernel.event.events.BeforeServiceDeleteEvent', @event_title='Перед удалением услуги договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=20, @new_event_id='ru.bitel.bgbilling.kernel.event.events.GetChangeTariffDatesEvent', @event_title='Тариф: Запрос дат с которых разрешена смена тарифа через Web';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=21, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractParamBeforeChangeEvent', @event_title='Перед изменением параметра договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=25, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractLimitUserLow', @event_title='Лимит: Временное понижение лимита пользователем через Web';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=26, @new_event_id='ru.bitel.bgbilling.kernel.event.events.GetContractCardsListEvent', @event_title='Получение списка карточек регистрации договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=28, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ContractObjectParameterBeforeUpdateEvent', @event_title='Объект: Перед измением параметра объекта договора';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=30, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ActionBeforeEvent', @event_title='Перед действием';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=31, @new_event_id='ru.bitel.bgbilling.kernel.event.events.ActionAfterEvent', @event_title='После действия';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=34, @new_event_id='ru.bitel.bgbilling.kernel.event.events.GetContractStatusChangeDatesEvent', @event_title='Получение списка дат для смены статуса договора в Web';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=38, @new_event_id='ru.bitel.bgbilling.kernel.event.events.CancelTariffEvent', @event_title='Тариф: Отмена перехода на тарифный план (Web)';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=41, @new_event_id='ru.bitel.bgbilling.kernel.tariff.option.server.event.TariffOptionActivatedEvent', @event_title='Тарифная опция: Активирована/реактивирована тарифная опция';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

SET @mid=0, @old_event_id=43, @new_event_id='ru.bitel.bgbilling.kernel.tariff.option.server.event.TariffOptionDeactivatedEvent', @event_title='Тарифная опция: Деактивирована тарифная опция';
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (@mid, @new_event_id, 1, @event_title);
INSERT INTO script_function_event_type(fid, mid, event_id) SELECT sfet1.fid, sfet1.mid, @new_event_id FROM script_function_event_type AS sfet1 LEFT JOIN script_function_event_type AS sfet2 ON sfet1.fid=sfet2.fid AND sfet1.mid=sfet2.mid AND sfet2.event_id=@new_event_id WHERE sfet1.mid=@mid AND sfet1.event_id=@old_event_id AND sfet2.fid IS NULL;

INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.tariff.option.server.event.TariffOptionBeforeActivateEvent', 1, 'Тарифная опция: Перед активацией тарифной опции');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.tariff.option.server.event.TariffOptionListAvailableEvent', 1, 'Тарифная опция: Получение списка доступных тарифных опций');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ValidateTextParamEvent', 1, 'Валидация текстового параметра');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ServerStartEvent', 0, 'Старт сервера');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.LimitChangedEvent', 1, 'Лимит:  Изменение лимита договора' );
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ContractAddingSubEvent', 1, 'Перед добавлением субдоговора');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ContractServicesChangedEvent', 1, 'Изменение подключенных услуг');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.contract.api.common.event.ContractPasswordChangedEvent', 1, 'Изменение пароля личного кабинета');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.oss.systems.order.product.common.event.ProductOfferingListEvent', 1, 'Продукт: Получение списка доступных продуктов');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.GetTariffListEvent', 1, 'Тариф: Получение списка тарифных планов для смены в Web');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ChangeContractLimitEvent', 1, 'Лимит: Проверка возможности изменения лимита договора');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ContractStatusChangingCheck', 1, 'Проверка возможности смены статуса');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.contract.period.server.event.ContractPeriodCloseEvent', 1, 'Окончание учетного периода' );
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.contract.period.server.event.ContractPeriodUpdateEvent', 1, 'Создание/редактирование учетного периода' );
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.contract.period.server.event.ContractPeriodDeleteEvent', 1, 'Удаление учетного периода' );
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.event.events.ContractCommentPatternEvent', 1, 'Генерация комментария договора по шаблону' );
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.bgbilling.kernel.contract.api.common.event', 1, 'Изменён домен на договоре');
INSERT INTO script_event_type (mid, event_id, event_mode, title) VALUES (0, 'ru.bitel.oss.systems.order.product.common.event.ProductDeactivatedEvent', 1, 'Продукт: Продукт деактивирован');

-- старые события 
INSERT INTO script_event_type ( mid, event_id, title ) VALUES ( 0, 17, "(Устарело) Добавление задания на смену тарифа через Web");
-- #ENDB#
