# Date: 01/11/06 # Version: 105 $DOC(TYPES) name=Тип документа class=1 product=ALD_SQL name_formula=null remark_formula=null $STATE(SYSTEM) name=Системный статус class=1 $ENDSTATE $PROP(TYPE_NAME) name=название field_name=type_name table_name=t_types field_type=varchar field_length=255 field_scale=0 field_prec=255 page=0 order=1 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(TYPE_CODE) name=код field_name=type_code table_name=t_types field_type=varchar field_length=30 field_scale=0 field_prec=30 page=0 order=2 init_class=0 init_formula=null unique_index=1 numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(NAME_PARM) name=параметр наименование field_name=name_parm table_name=t_types field_type=varchar field_length=30 field_scale=0 field_prec=30 page=0 order=null init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(CLASS_ID) name=класс документа field_name=class_id table_name=t_types field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=4 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PRODUCT_ID) name=продукт field_name=product_id table_name=t_types field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=5 init_class=0 init_formula=null unique_index=1 numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(IS_NAME_PARM_FORM) name=параметр наименования формула field_name=is_name_parm_form table_name=t_types field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=6 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(NAME_PARM_FORMULA) name=формула наименования field_name=name_parm_formula table_name=t_types field_type=varchar field_length=255 field_scale=0 field_prec=255 page=0 order=7 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PARTNER_PARM) name=параметр владелец field_name=partner_parm table_name=t_types field_type=varchar field_length=30 field_scale=0 field_prec=30 page=0 order=8 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(IS_PARTNER_PARM_FORM) name=параметр владелец формула field_name=is_partner_parm_form table_name=t_types field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=9 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PARTNER_PARM_FORMULA) name=формула партнера field_name=partner_parm_formula table_name=t_types field_type=varchar field_length=255 field_scale=0 field_prec=255 page=0 order=10 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(REMARK_FORMULA) name=формула поискового комментария field_name=remark_formula table_name=t_types field_type=varchar field_length=255 field_scale=0 field_prec=255 page=0 order=11 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(CHDATE) name=Дата изменения field_name=chdate table_name=t_types field_type=datetime field_length=8 field_scale=3 field_prec=23 page=-1 order=12 init_class=null init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $RELATION(REL6) class=1 type=PROPS form=D_PROPS_LIST prop=null idname=type_sid order=10 $ENDRELATION $RELATION(REL7) class=1 type=ACTIONS form=UO_ACTIONS_LIST prop=null idname=type_sid order=40 $ENDRELATION $RELATION(REL8) class=1 type=STATES form=APT_STATES_VIEW prop=null idname=type_sid order=20 $ENDRELATION $RELATION(REL9) class=1 type=RELATION form=D_RELATIONS_LIST prop=null idname=s_type_sid order=50 $ENDRELATION $RELATION(REL10) class=1 type=FORMS form=UO_FORMS_LIST prop=null idname=type_sid order=30 $ENDRELATION $RELATION(REL1) class=1 type=ALIASES form=FORM_LIST prop=null idname=doc_type_id_s order=60 $ENDRELATION $RELATION(REL2) class=6 type=VERSION_SUPPORT form=TYPE_VERSION_HISTORY prop=null idname=null order=1000 $ENDRELATION $RELATION(REL3) class=0 type=ALADDIN_PRODUCT form=null prop=PRODUCT_ID idname=null order=3 $ENDRELATION $FORM(AP_CODE_FROM_TYPE) name=# ap_code_from_type class=5 filter=null target_state= uo=null dw=null procedure=ap_code_from_type patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @type_sid varchar(30) =null as begin select type_code from t_types where id=convert(numeric,@type_sid) end $ENDTEXT(19031656) $ENDFORM $FORM(TYPE_COPY_VIEW) name=Редактор копирования документов class=5 filter=null target_state= uo=uo_types_ins_edit dw=d_types_ins_edit procedure=null patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text= $ENDFORM $FORM(TYPE_FILTER) name=Фильтр class=6 filter=null target_state= uo=uo_filter dw=d_types_filter procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2053 height=680 proc_text= $FILTER(TYPE_CODE) type=3 label=код prop=TYPE_CODE arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $FILTER(PRODUCT_ID) type=1 label=продукт prop=PRODUCT_ID arg_code=null arg_type=null arg_length=null arg_prec=null arg_scale=null $ENDFILTER $ENDFORM $FORM(TYPE_VIEW) name=Просмотр class=5 filter=null target_state= uo=uo_edit dw=d_types_edit procedure=apt_types_item patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @type_id_s varchar(30), @new_state_id numeric, @state_name_id_s varchar(30) begin select @id = convert(numeric, @sid) select @action_id = %ACTION_ID% select @type_id_s = NULL select @state_name_id_s = NULL .CHECK_USER select sid = convert(varchar, t_types.id), item_name = t_types.type_name, t_types.type_code, t_types.name_parm, t_types.class_id, product_id_s=convert(varchar(30),t_types.product_id), t_aladdin_products.product_code, t_types.is_name_parm_form, t_types.name_parm_formula, t_types.is_partner_parm_form, t_types.partner_parm, t_types.partner_parm_formula, t_types.remark_formula from t_types,t_aladdin_products where t_types.id = @id and t_types.product_id = t_aladdin_products.id end $ENDTEXT(19031656) $ENDFORM $FORM(UO_TYPES_LIST) name=Список class=4 filter=TYPE_FILTER target_state= uo=uo_list dw=d_types_list procedure=apt_types_view patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=4526 height=2472 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @sid varchar(30) = null, @type_code varchar(30) = null, @type_name varchar(100) = null, @product_id_s varchar(30) = null as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @new_state_id numeric begin select @action_id = %ACTION_ID% select @id=convert(numeric,@sid) .CHECK_USER declare @product_id numeric declare @product_id_b numeric declare @product_id_e numeric declare @pers_char char(1) select @pers_char = '%' if @product_id_s is null begin select @product_id_b = 0 select @product_id_e = 999999999999999999 select @product_id = null end else begin select @product_id=convert(numeric,@product_id_s) select @product_id_b=@product_id select @product_id_e=@product_id end IF @type_name is null SELECT @type_name = '%' ELSE SELECT @type_name = '%' + upper(@type_name) + '%' IF @type_code is null SELECT @type_code = '%' ELSE SELECT @type_code = '%' + upper(@type_code) + '%' select sid = convert(varchar, t_types.id), item_name = t_types.type_name, t_types.type_code, t_types.name_parm, t_types.class_id, product_id_s = convert(varchar, t_types.product_id), t_aladdin_products.product_code, t_types.is_name_parm_form, t_types.name_parm_formula, t_types.is_partner_parm_form, t_types.partner_parm, t_types.partner_parm_formula, t_types.remark_formula from t_types,t_aladdin_products where (t_types.id=@id or @id is null) and t_types.product_id = t_aladdin_products.id and t_aladdin_products.is_actual = 1 and isnull(upper(t_types.type_code),'') LIKE @type_code and isnull(upper(t_types.type_name),'') LIKE @type_name and ((t_types.product_id between @product_id_b and @product_id_e) or (t_types.product_id = @product_id )) order by t_types.type_name end $ENDTEXT(19031656) $ENDFORM $ACTION(AP_TYPES_LOAD) name=.NET Загрузка class=9 form=null target_state=null procedure=ap_type_load patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @type_sid varchar(30) as begin -- !!! ВНИМАНИЕ -- данные версионности загружаются вместе с данными объектов. -- при добавлении полей следует сохранять существующий порядок -- и добавлять новые поля между полями объекта и версионности. -- порядок запросов так-же необходимо сохранять. -- при загрузки пары родитель-дети запрос загрузки детей должен -- распологаться ниже запроса загрузки родителя. -- при изменении порядка или удалении полей необходимо внести -- соотв. изменения в Aladdin.Kernel.Reflection и перекомпилить -- ядро. -- Допуска к методам и свойствам выбираются в переменные таблицы -- исключительно для генерации идентификаторов, когда в этом отпадёт -- необходимость, их можно убрать. -- поля документа обязательно сортируются по порядковому номеру -- идентификатор загружаемого типа declare @id numeric(18,0), @newid numeric(18,0), @intid int, @type_id numeric(18,0), @i int -- таблица для допусков к методам declare @state2action table ( sid varchar(30) null, id int identity not null, parent varchar(30) null, relation varchar(255) null, state varchar(255) null, name varchar(255) null, remark varchar(255) null, state_id numeric(18,0) null, action_id numeric(18,0) null, is_available tinyint null ) -- таблица для допусков к свойствам declare @state2prop table ( sid varchar(30) null, id int identity not null, parent varchar(30) null, relation varchar(255) null, state varchar(255) null, name varchar(255) null, remark varchar(255) null, state_id numeric(18,0) null, prop_id numeric(18,0) null, is_visible tinyint null, is_enabled tinyint null, is_mandatory tinyint null ) -- -- проверка необходимых параметров -- if @type_sid is null begin raiserror 40000 'Идентификатор типа не задан, загрузка прервана.' return -1 end if len(@type_sid) = 0 begin raiserror 40000 'Идентификатор типа не задан, загрузка прервана.' return -1 end -- получаем идентификатор типа select @id = convert(numeric, @type_sid) -- -- загружаем тип -- select sid = @type_sid, parent = null, relation = 'self', state = 'system', name = t_types.type_name, remark = '', t_types.type_name, t_types.type_code, t_types.name_parm_formula, t_types.class_id, product_id = convert(varchar, t_types.product_id), t_types.remark_formula, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_types, dbo.t_version where t_types.id = @id and t_version.id = @id if @@rowcount != 1 begin raiserror 40000 'По указанному идентификатору получена не одна запись. Загрузка прервана.' return -1 end if @@error != 0 begin raiserror 40000 'Ошибка при загрузке данных типа. Загрузка прервана.' return -1 end -- -- документы по связям для типа -- -- свойства select sid = convert(varchar, t_props.id), parent = @type_sid, relation = 'prop', state = 'system', name = t_props.prop_name, remark = '', t_props.prop_name, type_id = convert(varchar, t_props.type_id), t_props.table_name, t_props.field_name, t_props.field_type, t_props.field_length, t_props.field_prec, t_props.ref_field_name, t_props.ref_table_name, t_props.disp_field_name, is_unique = isnull(t_props.is_unique, 0), t_props.unique_index_no, t_props.field_as_name, t_props.ref_field_as_name, page_no = isnull(t_props.page_no, 0), t_props.ref_where, t_props.initial_formula, default_gen_id = convert(varchar, t_props.default_gen_id), t_props.init_class_id, t_props.init_order, t_props.prop_code, t_props.field_scale, t_props.prop_order, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_props, dbo.t_version where t_props.type_id = @id and t_version.id = t_props.id order by t_props.prop_order if @@error != 0 begin raiserror 40000 'Ошибка при загрузке свойств типа. Загрузка прервана.' return -1 end -- состояния select sid = convert(varchar, t_states.id), parent = @type_sid, relation = 'state', state = 'system', name = t_states.state_name, remark = '', type_id = convert(varchar, t_states.type_id), state_name = t_states.state_name, state_id = convert(varchar, t_states.state_id), t_states.class_id, t_states.state_code, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_states, dbo.t_version where t_states.type_id = @id and t_version.id = t_states.id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке статусов типа. Загрузка прервана.' return -1 end -- методы select sid = convert(varchar, t_actions.id), parent = @type_sid, relation = 'action', state = 'system', name = t_actions.action_name, remark = '', type_id = convert(varchar, t_actions.type_id), t_actions.action_code, t_actions.action_name, t_actions.class_id, vaction_id = convert(varchar, t_actions.vaction_id), faction_id = convert(varchar, t_actions.faction_id), t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, state_id = convert(varchar, t_actions.state_id), pat_id = convert(varchar, t_actions.pat_id), user_define = isnull(t_actions.user_define, 0), isvisible = isnull(t_actions.isvisible, 0), t_actions.x, t_actions.y, t_actions.width, t_actions.height, is_tab = isnull(t_actions.is_tab, 0), t_actions.dw_lib, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_actions, dbo.t_version where t_actions.type_id = @id and t_version.id = t_actions.id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке методов типа. Загрузка прервана.' return -1 end -- -- связи -- -- здесь действует хитрая заглушка. цель - создание у группы всех документов -- t_items связей класса "документ к группе" для всех типов документов, входящих -- в неё. это нужно для того, чтобы нормально загружались документы, привязанные -- к этой группе (для докмана). -- if('ITEMS' = ( select type_code from dbo.t_types where id = @id )) begin create table #report ( num int null, type_id numeric(18,0) null ) insert into #report ( type_id ) select distinct type_id from dbo.t_items select @i = 1 declare types_cur cursor for select type_id from #report open types_cur fetch next from types_cur into @type_id while @@fetch_status = 0 begin update #report set num = @i where type_id = @type_id fetch next from types_cur into @type_id select @i = @i + 1 end select sid = convert(varchar, #report.num), parent = @type_sid, relation = 'relation', state = 'system', name = '', remark = '', class_id = 5, -- документ к группе s_type_id = @type_sid, t_type_id = #report.type_id, action_id = null, prop_id = null, sid_asname = null, rel_order = #report.num, rel_code = 'REL' + convert(varchar, #report.num), crc = 0, create_site_id = (select id from dbo.t_sites where is_local = 1), create_date = getdate(), ceated_by_login = suser_sname(), created_by_name = suser_sname(), edit_date = getdate(), edited_by_login = suser_sname(), edited_by_name = suser_sname(), edit_site_id = (select id from dbo.t_sites where is_local = 1) from #report drop table #report end else begin -- честно выбираем связи документа select sid = convert(varchar, t_relation.id), parent = @type_sid, relation = 'relation', state = 'system', name = '', remark = '', t_relation.class_id, s_type_id = convert(varchar, t_relation.s_type_id), t_type_id = convert(varchar, t_relation.t_type_id), action_id = convert(varchar, t_relation.action_id), prop_id = convert(varchar, t_relation.prop_id), t_relation.sid_asname, rel_order = isnull(t_relation.rel_order, 0), t_relation.rel_code, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_relation, dbo.t_version where t_relation.s_type_id = @id and t_version.id = t_relation.id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке связей типа. Загрузка прервана.' return -1 end end -- алиасы документа select sid = convert(varchar, t_aliases.id), parent = @type_sid, relation = 'alias', state = 'system', name = t_aliases.alias_name, remark = t_aliases.alias_comment, t_aliases.alias_comment, t_aliases.alias_formula, t_aliases.alias_name, t_aliases.alias_order_no, t_aliases.alias_type, t_aliases.alias_type_length, t_aliases.alias_type_precision, t_aliases.alias_type_scale, t_aliases.doc_type_id from dbo.t_aliases where doc_type_id = @type_id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке алиасов. Загрузка прервана.' return -1 end -- допуска к свойствам select sid = convert(varchar, t_state2prop.id), parent = @type_sid, relation = 'state2prop', state = 'system', name = '', remark = '', state_id = convert(varchar, t_state2prop.state_id), prop_id = convert(varchar, t_state2prop.prop_id), t_state2prop.is_visible, t_state2prop.is_enable, t_state2prop.is_mandatory from dbo.t_state2prop, dbo.t_states, dbo.t_props where t_states.id = t_state2prop.state_id and t_props.id = t_state2prop.prop_id and t_states.type_id = @id and t_props.type_id = @id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке допусков к свойствам. Загрузка прервана.' return -1 end -- допуска к методам select sid = convert(varchar, t_state2action.id), parent = @type_sid, relation = 'state2action', state = 'system', name = '', remark = '', state_id = convert(varchar, t_state2action.state_id), action_id = convert(varchar, t_state2action.action_id), t_state2action.is_available from dbo.t_state2action, dbo.t_states, dbo.t_actions where t_states.id = t_state2action.state_id and t_actions.id = t_state2action.action_id and t_states.type_id = @id and t_actions.type_id = @id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке допусков к методам. Загрузка прервана.' return -1 end -- связи методов для запросов select sid = convert(varchar, t_action2relation.id), parent = convert(varchar, t_action2relation.action_id), relation = 'action2relation', state = 'system', name = '', remark = '', relation_id = convert(varchar, t_action2relation.rel_id), action_id = convert(varchar, t_action2relation.action_id), t_action2relation.where_syntax, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_actions, dbo.t_action2relation, dbo.t_version where t_actions.type_id = @id and t_action2relation.action_id = t_actions.id and t_version.id = t_action2relation.id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке связей методов для запросов. Загрузка прервана.' return -1 end -- связи методов select sid = convert(varchar, t_binds.id), parent = convert(varchar, t_binds.s_action_id), relation = 'bind', state = 'system', name = '', remark = '', s_action_id = convert(varchar, t_binds.s_action_id), t_action_id = convert(varchar, t_binds.t_action_id), t_binds.class_id, t_binds.bind_order, t_binds.sid_asname, t_binds.bind_code, t_type_id = convert(varchar, a2.type_id), t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_actions a1, dbo.t_binds, dbo.t_version, dbo.t_actions a2 where a1.type_id = @id and t_binds.s_action_id = a1.id and t_version.id = t_binds.id and a2.id = t_binds.t_action_id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке связей методов. Загрузка прервана.' return -1 end -- вычисляемые поля select sid = convert(varchar, t_calcprop.id), parent = convert(varchar, t_calcprop.action_id), relation = 'calcprop', state = 'system', name = t_calcprop.calc_name, remark = t_calcprop.calc_comment, action_id = convert(varchar, t_calcprop.action_id), t_calcprop.calc_name, t_calcprop.calc_type, t_calcprop.calc_length, t_calcprop.calc_prec, t_calcprop.calc_scale, t_calcprop.calc_formula, t_calcprop.calc_comment, t_calcprop.calc_class_id, -- 14 t_calcprop.prop_order, -- 15 t_calcprop.calc_code, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_actions, dbo.t_calcprop, dbo.t_version where t_actions.type_id = @id and t_calcprop.action_id = t_actions.id and t_version.id = t_calcprop.id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке вычисляемых полей. Загрузка прервана.' return -1 end -- поля фильтра select sid = convert(varchar, t_filter2action.id), parent = convert(varchar, t_filter2action.action_id), relation = 'filter2action', state = 'system', name = t_filter2action.filter_label, remark = '', action_id = convert(varchar, t_filter2action.action_id), t_filter2action.filter_label, t_filter2action.filter_type, prop_id = convert(varchar, t_filter2action.prop_id), t_filter2action.arg_field_code, t_filter2action.arg_field_type, t_filter2action.arg_field_length, t_filter2action.arg_field_prec, t_filter2action.arg_field_scale, t_filter2action.init_order, t_filter2action.filter_formula, t_filter2action.filter_formula_end, t_filter2action.filter_code, t_version.crc, t_version.create_site_id, t_version.create_date, t_version.created_by_login, t_version.created_by_name, t_version.edit_date, t_version.edited_by_login, t_version.edited_by_name, t_version.edit_site_id from dbo.t_actions, dbo.t_filter2action, dbo.t_version where t_actions.type_id = @id and t_filter2action.action_id = t_actions.id and t_version.id = t_filter2action.id if @@error != 0 begin raiserror 40000 'Ошибка при загрузке полей фильтра. Загрузка прервана.' return -1 end end $ENDTEXT(19031656) $ENDACTION $ACTION(TYPE_COPY) name=Копировать документ class=2 form=TYPE_COPY_VIEW target_state=null procedure=apt_type_ins_type patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2066 height=576 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @sid varchar(30) = null, @type_name varchar(255)= null, @type_code varchar(60) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric declare @s_type_id numeric, @dst_type_sid varchar(30) begin tran select @action_id = %ACTION_ID% .CHECK_USER select @s_type_id=convert(numeric,@sid) if @s_type_id is NULL begin rollback transaction execute ap_mess_raise 112 return end execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_types' return end select @dst_type_sid = convert(varchar(30),@id) if @type_name is null begin if @s_type_id <= 99999999999999.0 select @type_name = type_name from t_types where id =@s_type_id else select @type_name = type_name + ' новый' from t_types where id =@s_type_id end if @type_code is null begin if @s_type_id <= 99999999999999.0 select @type_code = type_code from t_types where id =@s_type_id else select @type_code = type_code + '_new' from t_types where id =@s_type_id end insert into t_types ( id, type_name, type_code, name_parm, class_id, product_id, is_name_parm_form, name_parm_formula, is_partner_parm_form, partner_parm, partner_parm_formula, remark_formula ) select @id, @type_name, @type_code, name_parm, class_id, product_id, is_name_parm_form, name_parm_formula, is_partner_parm_form, partner_parm, partner_parm_formula, remark_formula from t_types where id = @s_type_id if @@error != 0 begin rollback transaction raiserror 40000 'Вставка типа не прошла' return end execute apt_props_ins_type null,@dst_type_sid,@sid if @@error != 0 begin rollback transaction raiserror 40000 'Вставка полей не прошла' return end execute apt_states_ins_type 0,null,@dst_type_sid,@sid if @@error != 0 begin rollback transaction raiserror 40000 'Вставка статусов не прошла' return end /* * Александр В. Подзолко * Мы дублировать код не будем, мы вызовем процедуру копирования методов * execute apt_actions_ins_type 0,null,@dst_type_sid,@sid * */ execute dbo.apt_actions_copy 0, null, @dst_type_sid, @sid, null if @@error != 0 begin rollback transaction raiserror 40000 'Вставка методов не прошла' return end execute apt_relations_ins_type 0,null,@dst_type_sid,@sid if @@error != 0 begin rollback transaction raiserror 40000 'Вставка связей не прошла' return end commit tran $ENDTEXT(19031656) $ENDACTION $ACTION(TYPE_DELETE) name=Удалить class=3 form=TYPE_VIEW target_state=null procedure=apt_types_delete patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2094 height=856 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @sid varchar(255) = null, @type_name varchar(255) = null, @type_code varchar(255) = null, @name_parm varchar(30) = null, @class_id numeric = null, @product_id_s varchar(30) = null, @is_name_parm_form integer = 0, @name_parm_formula varchar(255)=null, @is_partner_parm_form integer=0, @partner_parm varchar(30)= null, @partner_parm_formula varchar(255)=null, @remark_formula varchar(255) = null as declare @id numeric declare @product_id numeric declare @del_id_s varchar(30) select @id = convert(numeric, @sid) if (@id is null) begin raiserror 40000 'не задан ключ для t_types' return end if exists(select 1 from t_items where type_id=@id) .EXIT_MESSAGE('Удаление невозможно. Существуют экземпляры данного документа') if exists(select 1 from t_subconto_types where subc_type_id=@id) .EXIT_MESSAGE('Удаление невозможно. Документ является субконто') .TRANSACTION_SAVE create table #del ( id numeric(18,0) ) declare del_cur cursor for select convert(varchar,id) from #del begin transaction insert into #del select id from t_states where type_id=@id --- Удаление статусов open del_cur fetch del_cur into @del_id_s while .CURSOR_STATE=0 begin EXECUTE dbo.apt_states_delete @sid = @del_id_s if @@error != 0 begin rollback transaction raiserror 40000 'Метод Удалить @sid = @del_id_s типа Состояние типа документа вернул ошибку' return end fetch del_cur into @del_id_s end close del_cur delete #del -- Forms insert into #del select id from t_actions where type_id=@id and class_id in (4,5,6) open del_cur fetch del_cur into @del_id_s while .CURSOR_STATE=0 begin EXECUTE dbo.apt_forms_delete @sid = @del_id_s if @@error != 0 begin rollback transaction raiserror 40000 'Метод Удалить @sid = @del_id_s типа Форма типа документа вернул ошибку' return end fetch del_cur into @del_id_s end close del_cur delete #del --actions insert into #del select id from t_actions where type_id=@id and class_id in (1,2,3,9) open del_cur fetch del_cur into @del_id_s while .CURSOR_STATE=0 begin EXECUTE dbo.apt_actions_delete @sid = @del_id_s if @@error != 0 begin rollback transaction raiserror 40000 'Метод Удалить @sid = @del_id_s типа Метод типа документа вернул ошибку' return end fetch del_cur into @del_id_s end close del_cur delete #del ---RELATION_DELETE insert into #del select id from t_relation where (s_type_id=@id) or (s_type_id=@id) open del_cur fetch del_cur into @del_id_s while .CURSOR_STATE=0 begin EXECUTE dbo.apt_relation_delete @sid = @del_id_s if @@error != 0 begin rollback transaction raiserror 40000 'Метод Удалить @sid = @del_id_s типа Связь типов документов вернул ошибку' return end fetch del_cur into @del_id_s end close del_cur delete #del --- Удаление параметров insert into #del select id from t_props where type_id=@id open del_cur fetch del_cur into @del_id_s while .CURSOR_STATE=0 begin EXECUTE dbo.apt_props_delete @sid = @del_id_s if @@error != 0 begin rollback transaction raiserror 40000 'Метод Удалить @sid = @del_id_s типа Параметр типа документа вернул ошибку' return end fetch del_cur into @del_id_s end close del_cur delete #del delete t_types where id=@id if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_types' return end .DEALLOCATE del_cur commit transaction drop table #del .TRANSACTION_RESTORE $ENDTEXT(19031656) $ENDACTION $ACTION(TYPE_INSERT) name=Добавить class=1 form=TYPE_VIEW target_state=SYSTEM procedure=apt_types_insert patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2062 height=1100 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @sid varchar(30) = null, @type_name varchar(255) = null, @type_code varchar(255) = null, @name_parm varchar(30) = null, @class_id numeric = null, @product_id_s varchar(30) = null, @is_name_parm_form integer = 0, @name_parm_formula varchar(255)=null, @is_partner_parm_form integer=0, @partner_parm varchar(30)= null, @partner_parm_formula varchar(255)=null, @remark_formula varchar(255) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric declare @product_id numeric begin begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_types' return end select @product_id = convert(numeric,@product_id_s) if (@product_id=null)or(not exists(select 1 from t_aladdin_products where id = @product_id and is_actual=1) ) begin rollback tran exec ap_mess_raise 112 return end insert into t_types ( id, type_name, type_code, name_parm, class_id, product_id, is_name_parm_form, name_parm_formula, is_partner_parm_form, partner_parm, partner_parm_formula, remark_formula ) values ( @id, @type_name, @type_code, @name_parm, @class_id, @product_id, @is_name_parm_form, @name_parm_formula, @is_partner_parm_form, @partner_parm, @partner_parm_formula, @remark_formula ) -- UPDATE CHANGE DATE -- update t_types set chdate = GetDate() where id = @id ------------------------ --.UPDATE_STATE commit tran select sid = convert(varchar, @id) end $ENDTEXT(19031656) $ENDACTION $ACTION(TYPE_UPDATE) name=Изменить class=2 form=TYPE_VIEW target_state=null procedure=apt_types_update patterns=null user_define=1 isvisible=0 istab=1 posx=0 posy=0 width=4215 height=2032 proc_text=$TEXT(19031656) create procedure dbo.%PROC% @sid varchar(30) = null, @type_name varchar(255) = null, @type_code varchar(255) = null, @name_parm varchar(30) = null, @class_id numeric = null, @product_id_s varchar(30) = null, @is_name_parm_form integer = 0, @name_parm_formula varchar(255)=null, @is_partner_parm_form integer=0, @partner_parm varchar(30)= null, @partner_parm_formula varchar(255)=null, @remark_formula varchar(255) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric declare @product_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_types' return end select @product_id = convert(numeric, @product_id_s) if (@product_id=null)or(not exists(select 1 from t_aladdin_products where id = @product_id and is_actual=1) ) begin rollback tran raiserror 40000 'Не задан продукт' return end if exists(select 1 from t_types where upper(type_code) = upper(@type_code) and id <> @id) begin rollback tran raiserror 40000 'Код документа уже используется системой' return end -- UPDATE CHANGE DATE -- IF NOT exists(select 1 from t_types where id = @id and type_name = @type_name and type_code = @type_code and name_parm_formula = @name_parm_formula and remark_formula = @remark_formula) begin update t_types set chdate = GetDate() where id = @id end ------------------------ update t_types set type_name = @type_name, type_code = @type_code, name_parm = @name_parm, class_id = @class_id, product_id = @product_id, is_name_parm_form=@is_name_parm_form, name_parm_formula=@name_parm_formula, is_partner_parm_form=@is_partner_parm_form, partner_parm=@partner_parm, partner_parm_formula=@partner_parm_formula, remark_formula = @remark_formula where id = @id commit tran $ENDTEXT(19031656) $ENDACTION $STATE2ACTION(SYSTEM.AP_CODE_FROM_TYPE) state=SYSTEM action=AP_CODE_FROM_TYPE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_TYPES_LOAD) state=SYSTEM action=AP_TYPES_LOAD is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_COPY) state=SYSTEM action=TYPE_COPY is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_COPY_VIEW) state=SYSTEM action=TYPE_COPY_VIEW is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_DELETE) state=SYSTEM action=TYPE_DELETE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_FILTER) state=SYSTEM action=TYPE_FILTER is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_INSERT) state=SYSTEM action=TYPE_INSERT is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_UPDATE) state=SYSTEM action=TYPE_UPDATE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_VIEW) state=SYSTEM action=TYPE_VIEW is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_TYPES_LIST) state=SYSTEM action=UO_TYPES_LIST is_available=1 $ENDSTATE2ACTION $STATE2PROP(SYSTEM.CHDATE) state=SYSTEM prop=CHDATE enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(SYSTEM.CLASS_ID) state=SYSTEM prop=CLASS_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.IS_NAME_PARM_FORM) state=SYSTEM prop=IS_NAME_PARM_FORM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.IS_PARTNER_PARM_FORM) state=SYSTEM prop=IS_PARTNER_PARM_FORM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.NAME_PARM) state=SYSTEM prop=NAME_PARM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.NAME_PARM_FORMULA) state=SYSTEM prop=NAME_PARM_FORMULA enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.PARTNER_PARM) state=SYSTEM prop=PARTNER_PARM enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.PARTNER_PARM_FORMULA) state=SYSTEM prop=PARTNER_PARM_FORMULA enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.PRODUCT_ID) state=SYSTEM prop=PRODUCT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.REMARK_FORMULA) state=SYSTEM prop=REMARK_FORMULA enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.TYPE_CODE) state=SYSTEM prop=TYPE_CODE enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.TYPE_NAME) state=SYSTEM prop=TYPE_NAME enable=1 mandatory=1 visible=1 $ENDSTATE2PROP $ENDDOC $DOC(SYSTEM) name=Системный class=0 product=ALD_SQL name_formula=null remark_formula=null $STATE(SYSTEM) name=Системный статус class=0 $ENDSTATE $FORM(ACTION_FROM_CODE) name=# Поиск метода по коду class=5 filter=null target_state= uo=null dw=null procedure=ap_action_from_code patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @type_sid varchar(30),@action_code varchar(30) =null as begin declare @type_id numeric select @type_id=convert(numeric,@type_sid) select sid=convert(varchar,id) from t_actions where rtrim(ltrim(UPPER(t_actions.action_code))) = rtrim(ltrim(UPPER(@action_code))) and t_actions.type_id = @type_id end $ENDTEXT(19031657) $ENDFORM $FORM(AP_GET_ACTION_PROC) name=# Описание метода class=5 filter=null target_state= uo=null dw=null procedure=ap_get_action_proc patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @type_sid varchar(30),@action_sid varchar(30) as begin declare @type_id numeric,@action_id numeric declare @pos1 int, @pos2 int,@type_code varchar(60),@action_code varchar(60) declare @mess_s varchar(255) if (@type_sid = 'null') or (@type_sid is null) or (@type_sid = '') begin raiserror 40000 'Не задан тип документа метода' end if (@action_sid = 'null') or (@action_sid is null) or (@action_sid = '') begin raiserror 40000 'Не задан тип метод документа' end select @pos1 = charindex(@type_sid,"'") if @pos1 > 0 begin select @pos2 = charindex(substring(@type_sid,@pos1+1,.CHAR_LENGTH(@type_sid) - @pos1 - 1),"'") if @pos2 <= 0 begin raiserror 40000 "Введите второй символ ' для ввода шифра типа" return end select @type_code = substring(@type_sid,@pos1+1,@pos2 - @pos1 - 2) select @type_id = id from t_types where rtrim(ltrim(upper(type_code))) = @type_code if @type_id is null begin select @mess_s = "Не найден тип с кодом '"+isnull(@type_code,' ')+"'" raiserror 40000 @mess_s return end end else begin select @type_id = convert(numeric,@type_sid) end select @pos1 = charindex(@action_sid,"'") if @pos1 > 0 begin select @pos2 = charindex(substring(@action_sid,@pos1+1,.CHAR_LENGTH(@action_sid) - @pos1 - 1),"'") if @pos2 <= 0 begin raiserror 40000 "Введите второй символ ' для ввода шифра метода" return end select @action_code = substring(@action_sid,@pos1+1,@pos2 - @pos1 - 2) select @action_id = id from t_actions where rtrim(ltrim(upper(action_code))) = @action_code and type_id = @type_id if @action_id is null begin select @mess_s = "Не найден метод с кодом '"+isnull(@type_code,' ')+"' у типа "+ isnull(@type_sid,' ')+"." raiserror 40000 @mess_s return end end else begin select @action_id = convert(numeric,@action_sid) end select sid = convert(varchar,t_actions.id),t_types.type_name, t_actions.action_name,t_actions.action_code,t_actions.proc_name,t_actions.class_id from t_actions,t_types where t_actions.type_id = @type_id and t_actions.id = @action_id and t_actions.type_id = t_types.id end $ENDTEXT(19031657) $ENDFORM $FORM(AP_TYPE2PARM_REPORT) name=# ap_type2parm_report class=4 filter=null target_state= uo=null dw=null procedure=ap_type2parm_report patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @type_id_s varchar(255) = null as declare @id numeric begin select @id = convert(numeric, @type_id_s) select t_props.table_name, t_props.field_name, t_props.prop_name from t_props where t_props.type_id = @id order by upper(t_props.prop_name) end $ENDTEXT(19031657) $ENDFORM $FORM(CREATERTL) name=Компилятор библиотек class=5 filter=null target_state= uo=uo_creatertl dw=null procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=null $ENDFORM $FORM(D_PLAN2PARTNER_REPORT2ANAL_F) name=Фильтр отчета по планам счетов class=6 filter=null target_state= uo=uo_filter dw=d_plans_filter procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=null $FILTER(PLAN_ID) type=1 label=План prop=null arg_code=plan_id arg_type=numeric arg_length=30 arg_prec=18 arg_scale=0 $ENDFILTER $ENDFORM $FORM(D_PLAN2PARTNER_REPORT2ANAL_L) name=Отчет по планам счетов class=4 filter=D_PLAN2PARTNER_REPORT2ANAL_F target_state= uo=uo_list_rep dw=d_plan2partner_report2anal_l procedure=ap_plan2partner_report2anal_l patterns=GENERIC_VIEW_LIST user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as .BEGIN('N') .CHECK_USER --.CHECK_VIEW_LIST .ARGCONVERT_FILTER create table #accounts( acc_id numeric, acc_num_eff varchar(255) null, acc_name varchar(255) null, plan_name varchar(255) null, plan_code varchar(255) null, subc_name varchar(255) null ) insert #accounts select t_accounts.id, t_accounts.acc_num_eff, t_accounts.acc_name, t_plans.plan_name, t_plans.plan_code, t_subconto_types.subc_name from t_accounts, t_plans, t_acc2subconto, t_subconto_types where t_acc2subconto.acc_id = t_accounts.id and t_subconto_types.id = t_acc2subconto.subc_id and t_plans.id = t_accounts.plan_id and ((t_plans.id=@plan_id_nn) or (t_plans.id between @plan_id_bb and @plan_id_ee)) insert #accounts select t_accounts.id, t_accounts.acc_num_eff, t_accounts.acc_name, t_plans.plan_name, t_plans.plan_code, null from t_accounts, t_plans where t_plans.id = t_accounts.plan_id and ((t_plans.id=@plan_id_nn) or (t_plans.id between @plan_id_bb and @plan_id_ee)) and t_accounts.id not in (select acc.acc_id from #accounts acc) select acc.acc_num_eff, acc.subc_name, acc.plan_name, acc.plan_code, acc.acc_name from #accounts acc order by plan_code,acc_num_eff .END $ENDTEXT(19031657) $ENDFORM $FORM(FORM2) name=Фильтр шаблонов class=6 filter=null target_state= uo=uo_filter dw=d_patterns_filter procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2057 height=776 proc_text=null $ENDFORM $FORM(FORM3) name=Фильтр списка методов для ген class=6 filter=null target_state= uo=uo_filter dw=d_actions_for_gen_filter procedure=null patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=2272 height=1000 proc_text=null $ENDFORM $FORM(FORM4) name=Отчет о полях документов class=4 filter=FORM6 target_state= uo=uo_list_rep dw=d_type2props_report procedure=ap_type2props_report patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @product_id_s varchar(255) = null as declare @id numeric begin select @id = convert(numeric, @product_id_s) select convert(varchar, t_types.id) as type_id_s, t_types.type_name, t_types.type_code from t_types where t_types.product_id = @id order by t_types.type_name end $ENDTEXT(19031657) $ENDFORM $FORM(FORM5) name=Отчет допуска к типам документов class=4 filter=FORM6 target_state= uo=uo_list_rep dw=d_type2role_report procedure=ap_type2role_report patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=4699 height=2724 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @product_id_s varchar(255) = null as declare @id numeric begin select @id = convert(numeric, @product_id_s) create table #report( type_id numeric, state_id numeric, action_id numeric, role_id numeric ) insert into #report select t_types.id, t_state2action2role.state_id, t_state2action2role.action_id, t_state2action2role.role_id from t_types, t_actions, t_state2action2role where t_types.product_id = @id and t_types.id = t_actions.type_id and t_actions.id = t_state2action2role.action_id and t_actions.class_id in (1,2,3,9) select convert(varchar, t_types.id) as type_id_s, t_types.type_name, t_types.type_code, convert(varchar, t_states.id) as state_id_s, t_states.state_name, t_states.state_code, convert(varchar, t_roles.id) as role_id_s, t_roles.role_name, convert(varchar, t_actions.id) as action_id_s, t_actions.action_name from #report, t_types, t_actions, t_roles, t_states where #report.type_id = t_types.id and #report.action_id = t_actions.id and #report.state_id = t_states.id and #report.role_id = t_roles.id order by t_types.type_name, t_states.state_name, t_roles.role_name, t_actions.class_id, t_actions.action_name end $ENDTEXT(19031657) $ENDFORM $FORM(FORM6) name=Фильтр к отчетам по продуктам class=6 filter=null target_state= uo=uo_filter dw=d_type2role_report_filter procedure=null patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=2048 height=360 proc_text=null $ENDFORM $FORM(GETPATTERN) name=# Поиск шаблона по названию class=4 filter=null target_state= uo=null dw=null procedure=ap_getpattern patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @pat_name varchar(255) = null as begin select sid = convert(varchar, t_patterns.id) from t_patterns where upper(t_patterns.pat_name) = upper(@pat_name) end $ENDTEXT(19031657) $ENDFORM $FORM(IS_IN_FOLDER) name=# Проверка вхождения документа в папку class=5 filter=null target_state= uo=null dw=null procedure=ap_is_in_folder patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @type_sid varchar(30) as begin declare @type_id numeric select @type_id = convert(numeric,@type_sid) if exists(select 1 from t_relation where t_relation.class_id=4 and t_relation.s_type_id = @type_id) or exists (select 1 from t_relation r1,t_relation r2 where r1.class_id=4 and r1.s_type_id = r2.s_type_id and r2.class_id=5 and r2.t_type_id = @type_id) select 1 as result else select 0 as result end $ENDTEXT(19031657) $ENDFORM $FORM(TYPE_FROM_CODE) name=Поиск типа документа по коду class=4 filter=null target_state= uo=null dw=null procedure=ap_type_from_code patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @type_code varchar(30) =null as begin select sid=convert(varchar,id) from t_types where rtrim(ltrim(UPPER(type_code))) = rtrim(ltrim(UPPER(@type_code))) end $ENDTEXT(19031657) $ENDFORM $FORM(UO_ACTIONS_GEN_LIST) name=Список методов для генерации class=4 filter=FORM3 target_state= uo=uo_actions_gen_list dw=null procedure=apt_actions_view_for_gen patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=4521 height=2020 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @class_id tinyint = null, @type_name varchar(150) = null, @type_code varchar(100) = null, @action_name varchar(255) = null, @action_code varchar(255) = null, @context_str varchar(255) = null, @product_id_s varchar(30) = null, @no_product_id_s varchar(30) = null, @proc_name varchar(32) = null as declare @type_id_b numeric, @type_id_e numeric, @type_id numeric, @class_id_b tinyint, @class_id_e tinyint, @sss varchar(2), @product_id numeric, @no_product_id numeric, @product_id_b numeric, @product_id_e numeric begin select @sss = '%' if @class_id is null begin select @class_id_b = 0 select @class_id_e = 255 end select @product_id = convert(numeric, @product_id_s) select @no_product_id = convert(numeric, @no_product_id_s) if @product_id is null begin execute ap_getminmax_id 0,@product_id_b out execute ap_getminmax_id 1,@product_id_e out end if @proc_name is null select @proc_name = '%' else select @proc_name = '%' + upper(rtrim(ltrim(@proc_name))) + '%' IF @type_name is null SELECT @type_name = '%' ELSE SELECT @type_name = '%' + upper(@type_name) + '%' IF @type_code is null SELECT @type_code = '%' ELSE SELECT @type_code = '%' + upper(@type_code) + '%' IF @action_name is null SELECT @action_name = '%' ELSE SELECT @action_name = '%' + upper(@action_name) + '%' IF @action_code is null SELECT @action_code = '%' ELSE SELECT @action_code = '%' + upper(@action_code) + '%' if @context_str is null select sid = convert(varchar, t_actions.id), item_name = t_actions.action_name, t_actions.action_name, t_actions.action_code, t_actions.class_id, vaction_sid = convert(varchar, t_actions.vaction_id), vaction_name = (select action_name from t_actions t1 where t1.id = t_actions.vaction_id), naction_sid = convert(varchar, t_actions.naction_id), naction_name = (select action_name from t_actions t1 where t1.id = t_actions.naction_id), faction_sid = convert(varchar, t_actions.faction_id), faction_name = (select action_name from t_actions t1 where t1.id = t_actions.faction_id), type_sid = convert(varchar, t_actions.type_id), type_code = t_types.type_code, type_name = t_types.type_name, state_sid = convert(varchar, t_actions.state_id), state_name = (select state_name from t_states where t_states.id = t_actions.state_id), is_gen = 0, err_comment = '', t_actions.proc_name from t_actions,t_types,t_aladdin_products where t_actions.type_id = t_types.id and isnull(rtrim(ltrim(upper(t_types.type_name))),'') like @type_name and isnull(rtrim(ltrim(upper(t_types.type_code))),'') like @type_code -- Оставьте пока если кто найдёт! /*and isnull(rtrim(ltrim(upper(t_types.type_code))),'') IN ( --Changes 'BANK_CHANGE', 'BILL_CHANGE', 'DEPO_ACC_OPS', 'DEPO_OPERATORS_CHANGE', 'DEPO_SUBACC_CHANGE', 'EMITENT_CHANGE', 'LINKED_PERSONS_CHANGE', 'PARTFIS_CHANGE', 'PARTJUR_CHANGE', 'STOCK_EMIS_CHANGE', --33 'QUERIES_QUERY_FCS_REPORTS_33', 'REPORTS_REPORT_FCS_ACC_33', 'REPORTS_REPORT_FCS_MOVES_33', 'REPORTS_REPORT_FCS_SUBACC_33', --711 'DEPO_LICENCE_SETUP', 'QUERY4BANK711_V2', 'REPORT_CLIENTS_STOCKS_711_V2', 'REPORT_DEPO_BRANCH_711_V2', 'REPORT_DEPO_CLIENTS_ACC_711_V2', 'REPORT_DEPO_LORO_QTY_711_V2', 'REPORT_DEPO_ND_QTY_711_V2', 'REPORT_DEPO_OWNER_711_V2', 'REPORT_DEPO_OWNER_ACC_711_V2', 'REPORT_OWNED_STOCKS_711_V2', --Srez 'SREZ', 'SREZ_ACC_OPEN', 'SREZ_LIST', 'SREZ_LIST_RATES', 'SREZ_MOVES', --Veksel 'BILL_CHANGE', 'D_EXCH_BILL_IN', 'D_EXCH_BILL_MOVE', 'D_EXCH_BILL_OUT', 'DEPO_BILL_OPERS', 'EXCHANGE_BILL', 'EXCHANGE_BILL4OPER', --QUERIES_DATE_EMI 'QUERIES_DATE_EMI')*/ ------------------------------- --- для массовой генерации ---- ------------------------------- /* -- набор методов and upper(t_types.type_code) + ':' + upper(t_actions.action_code) in ( 'DEALINGS_VIA_BROKER:EXP_ACTION_CANCEL_TS_BAY' ,'DEALINGS_VIA_BROKER_SALE:EXP_ACTION_CANCEL_TS_SALE' ,'DOG_DEALINGS_BAY_VBR:EXP_ACTION_MOVE2' ,'DOG_DEALINGS_SALE_VBR:EXP_ACTION_MOVE2' ,'D_STOCK_IN_OTHER_DEPO:EXP_ACTION11' ,'D_STOCK_OUT_OTHER_DEPO:EXP_ACTION13' ) */ /* -- документы ядра and upper(type_code) in ( 'ACTION2RELATION' ,'ACTION2RELATION2PROPS' ,'ACTIONS' ,'ALADDIN_PRODUCT' ,'ALIASES' ,'BINDS' ,'CALCPROP' ,'FILTER2ACTION' ,'FORMS' ,'NUMGEN' ,'PATTERN' ,'PATTERN_ARGS' ,'PROPS' ,'RELATION' ,'ROLES' ,'SITE' ,'STATE2ACTION' ,'STATE2PROP' ,'STATENAME' ,'STATES' ,'SUBC2ALIASES' ,'SUBCONTO' ,'TYPES' ) */ /* -- документы учета and upper(type_code) in ( 'ACC2SUBCONTO' ,'ACCOUNTS' ,'ALADDIN_CONST' ,'CLASS_VALUES' ,'MOVE_DIRECTION' ,'OBJECTS2ACCOUNTS' ,'OBJECTS2ACCOUNTS_LINKS' ,'PARTNERS_TYPES' ,'PLANS' ,'RELATION2PURPOSES' ,'RELATION2PURPOSES_OSN' ,'SIMPLES' ,'SUBC2OPPER' ,'TARGET_PURPOSES' ,'TYPE2CLASS' ,'TYPE_CLASSES' ) */ /* and upper(type_code) in ( 'SIMPLES_BLOCK1', 'SIMPLETYPES_BLOCK', 'TYPED_BLOCK_OPERATIONS', 'TYPED_METHOD2OPERS_BLOCKS', 'TYPED_OPERATIONS_CONDITION', 'CALCULATE_PARAMETER', 'TYPED_EXEC_METHOD', 'TYPED_EXEC_METHOD_LIST', 'TYPED_EXEC_METHOD_PARM', 'TYPED_EXEC_METHOD_GROUP', 'TYPED_FIN_CALC', 'TYPED_FIN_ANALYTIC', 'TYPED_OPERATIONB', 'SUBC2OPPER', 'TYPED_OPERATIONS_BLOCK_EXEC' ) */ -------------------------------------------------------------------------------------------------------------- and ((t_types.product_id between @product_id_b and @product_id_e) or (t_types.product_id = @product_id)) and ((t_types.product_id <> @no_product_id) or (@no_product_id is null)) and ((t_actions.class_id between @class_id_b and @class_id_e) or (t_actions.class_id = @class_id)) and isnull(rtrim(ltrim(upper(t_actions.action_name))),'') like @action_name and isnull(rtrim(ltrim(upper(t_actions.action_code))),'') like @action_code and isnull(upper(t_actions.proc_name),'') like @proc_name and t_types.product_id = t_aladdin_products.id and t_aladdin_products.is_actual = 1 ORDER BY t_types.type_name, t_actions.class_id, t_actions.action_name else BEGIN SELECT @context_str = @sss + rtrim(ltrim(UPPER(@context_str))) + @sss select sid = convert(varchar, t_actions.id), item_name = t_actions.action_name, t_actions.action_name, t_actions.action_code, t_actions.class_id, vaction_sid = convert(varchar, t_actions.vaction_id), vaction_name = (select action_name from t_actions t1 where t1.id = t_actions.vaction_id), naction_sid = convert(varchar, t_actions.naction_id), naction_name = (select action_name from t_actions t1 where t1.id = t_actions.naction_id), faction_sid = convert(varchar, t_actions.faction_id), faction_name = (select action_name from t_actions t1 where t1.id = t_actions.faction_id), type_sid = convert(varchar, t_actions.type_id), type_code = t_types.type_code, type_name = t_types.type_name, state_sid = convert(varchar, t_actions.state_id), state_name = (select state_name from t_states where t_states.id = t_actions.state_id), is_gen = 0, err_comment = '', t_actions.proc_name from t_actions ,t_types,t_aladdin_products where t_actions.type_id = t_types.id and isnull(rtrim(ltrim(upper(t_types.type_name))),'') like @type_name and isnull(rtrim(ltrim(upper(t_types.type_code))),'') like @type_code and ((t_types.product_id between @product_id_b and @product_id_e) or (t_types.product_id = @product_id)) and ((t_types.product_id <> @no_product_id) or (@no_product_id is null)) and ((t_actions.class_id between @class_id_b and @class_id_e) or (t_actions.class_id = @class_id)) and isnull(rtrim(ltrim(upper(t_actions.action_name))),'') like @action_name and isnull(rtrim(ltrim(upper(t_actions.action_code))),'') like @action_code and isnull(upper(t_actions.proc_name),'') like @proc_name and t_types.product_id = t_aladdin_products.id and t_aladdin_products.is_actual = 1 --- SEGMENT AND exists(SELECT 1 FROM t_segments WHERE t_segments.id = t_actions.id AND rtrim(ltrim(UPPER(t_segments.seg_text))) LIKE @context_str) ORDER BY t_types.type_name, t_actions.class_id, t_actions.action_name END end $ENDTEXT(19031657) $ENDFORM $FORM(UO_MENU_TREE) name=Настройка меню class=4 filter=null target_state= uo=uo_menu_tree dw=d_menu_list procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2939 height=1836 proc_text=null $ENDFORM $FORM(UO_PATTERNARGS_EDIT) name=Редактор аргументов шаблона class=5 filter=null target_state= uo=uo_patternargs_edit dw=null procedure=apt_patternargs_item patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric begin select @id = convert(numeric, @sid) select sid = convert(varchar, t_patternargs.id), pat_id_s = convert(varchar, t_patternargs.pat_id), t_patternargs.arg_id, t_patternargs.arg_name, t_patternargs.arg_label, t_patternargs.arg_comment , t_patternargs.is_needed, t_patternargs.default_value, convert(varchar(30), t_patternargs.choose_type_id) as choose_type_id_s, choose_type_name = (select type_name from t_types where id = t_patternargs.choose_type_id), t_patternargs.choose_action_code, t_patternargs.choose_field_name from t_patternargs where t_patternargs.id = @id end $ENDTEXT(19031657) $ENDFORM $FORM(UO_PATTERNS_EDIT) name=Редактор шаблонов class=5 filter=null target_state= uo=uo_patterns_edit dw=null procedure=apt_patterns_item patterns=null user_define=0 isvisible=1 istab=1 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031657) create procedure dbo.%PROC% @sid varchar(255) = null, @pat_name varchar(255) = NULL, @class_id integer = NULL, @pat_comment varchar(255)= NULL, @product_id_s varchar(30) = NULL as declare @id numeric, @class_id_b integer, @class_id_e integer, @product_id_b numeric, @product_id_e numeric, @product_id numeric begin select @id = convert(numeric, @sid) select sid = convert(varchar, t_patterns.id), item_name = t_patterns.pat_name, t_patterns.class_id, t_patterns.pat_comment, t_patterns.arg_str, t_patterns.arg_labels_str, product_id_s = convert(varchar,t_patterns.product_id) from t_patterns where t_patterns.id = @id end $ENDTEXT(19031657) $ENDFORM $FORM(UO_PATTERNS_LIST) name=Список шаблонов class=4 filter=FORM2 target_state= uo=uo_patterns_list dw=null procedure=apt_patterns_view patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=3579 height=1888 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @sid varchar(30) = null, @pat_name varchar(255) = NULL, @class_id integer = NULL, @pat_comment varchar(255)= NULL, @product_id_s varchar(30) = NULL, @pat_text varchar(255)=NULL as declare @id numeric, @class_id_b integer, @class_id_e integer, @product_id_b numeric, @product_id_e numeric, @product_id numeric begin declare @r_simb varchar(3) select @r_simb = '%' if @sid <> 'null' and not @sid is null select @id = convert(numeric, @sid) if @class_id is NULL begin select @class_id_b = -2147483648 select @class_id_e = 2147483647 end else begin select @class_id_b = @class_id select @class_id_e = @class_id end if @product_id_s is NULL begin select @product_id = NULL execute ap_getminmax_id 0,@product_id_b out execute ap_getminmax_id 1,@product_id_e out end else begin select @product_id = convert(numeric,@product_id_s) select @product_id_b = @product_id select @product_id_e = @product_id end IF @pat_name is null SELECT @pat_name = @r_simb ELSE SELECT @pat_name = @r_simb + rtrim(ltrim(UPPER(@pat_name))) + @r_simb IF @pat_comment is null SELECT @pat_comment = @r_simb ELSE SELECT @pat_comment = @r_simb + rtrim(ltrim(UPPER(@pat_comment))) + @r_simb if @pat_text is null select sid = convert(varchar, t_patterns.id), item_name = t_patterns.pat_name, t_patterns.class_id, t_patterns.pat_comment, t_patterns.arg_str, t_patterns.arg_labels_str, product_id_s = convert(varchar,t_patterns.product_id) from t_patterns where ((class_id between @class_id_b and @class_id_e) or (class_id = @class_id)) and ((product_id between @product_id_b and @product_id_e) or (product_id = @product_id)) and isnull(rtrim(ltrim(UPPER(t_patterns.pat_name))), '') LIKE @pat_name and isnull(rtrim(ltrim(UPPER(t_patterns.pat_comment))), '') LIKE @pat_comment order by t_patterns.pat_name else BEGIN SELECT @pat_text = @r_simb + rtrim(ltrim(UPPER(@pat_text))) + @r_simb select sid = convert(varchar, t_patterns.id), item_name = t_patterns.pat_name, t_patterns.class_id, t_patterns.pat_comment, t_patterns.arg_str, t_patterns.arg_labels_str, product_id_s = convert(varchar,t_patterns.product_id) from t_patterns where ((class_id between @class_id_b and @class_id_e) or (class_id = @class_id)) and ((product_id between @product_id_b and @product_id_e) or (product_id = @product_id)) and isnull(rtrim(ltrim(UPPER(t_patterns.pat_name))), '') LIKE @pat_name and isnull(rtrim(ltrim(UPPER(t_patterns.pat_comment))), '') LIKE @pat_comment --- SEGMENT AND exists(SELECT 1 FROM t_segments WHERE t_segments.id = t_patterns.id AND rtrim(ltrim(UPPER(t_segments.seg_text))) LIKE @pat_text) order by t_patterns.pat_name END end $ENDTEXT(19031659) $ENDFORM $FORM(UO_ROLES_LIST) name=Список ролей class=4 filter=null target_state= uo=uo_roles_list dw=null procedure=apt_roles_view patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=2834 height=1428 proc_text=$TEXT(19031659) create procedure dbo.%PROC% as begin select convert(varchar, t_roles.id) as sid, t_roles.role_name as item_name, t_roles.role_code as role_code from t_roles order by t_roles.role_name end $ENDTEXT(19031659) $ENDFORM $FORM(UO_SCRIPTMAKE) name=Генерация SQL скрипта class=4 filter=null target_state= uo=uo_scriptmake dw=null procedure=null patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=null $ENDFORM $FORM(UO_STATESLIST_LIST) name=Названия статусов документов class=4 filter=null target_state= uo=uo_stateslist_list dw=null procedure=apt_states_list_view patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @sid varchar(255) = null as declare @id numeric begin select @id = convert(numeric, @sid) if (@id is null) begin select sid = convert(varchar, t_states_list.id), item_name = t_states_list.state_name from t_states_list order by t_states_list.state_name end else begin select sid = convert(varchar, t_states_list.id), item_name = t_states_list.state_name from t_states_list where t_states_list.id = @id end end $ENDTEXT(19031659) $ENDFORM $FORM(UO_TABLE_FIELDS_LIST) name=Список полей таблицы class=4 filter=null target_state= uo=null dw=null procedure=ap_table_fields patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @table_name varchar(255) as begin select colname=syscolumns.name, coltype=systypes.name, length=syscolumns.length, prec=syscolumns.prec, scale=syscolumns.scale from syscolumns,sysobjects ,systypes where sysobjects.name=@table_name and sysobjects.type in ('U') and syscolumns.id=sysobjects.id and syscolumns.usertype=systypes.usertype and syscolumns.name != 'id' end $ENDTEXT(19031659) $ENDFORM $FORM(UO_TABLE_LIST) name=Список таблиц class=4 filter=null target_state= uo=uo_table_list dw=null procedure=ap_table_list patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% as begin select table_name=name from sysobjects where type in ('U') order by name end $ENDTEXT(19031659) $ENDFORM $FORM(AP_ACCOUNT_NOW_DATE) name=Дата для расчета текущих остатков по всем планам счетов class=5 filter=null target_state= uo=uo_edit dw=d_account_now_date procedure=ap_account_now_date patterns=GENERIC_VIEW_ITEM user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @sid varchar(30) = null as begin .DATE_VAR(@last_date) .DATE_VAR(@oper_date) .DATE_VAR(@max_op_date) select @last_date = max(op_date) from t_operations select @oper_date = .OPERDAY if (@last_date is null) or (@oper_date > @last_date) select @last_date = @oper_date if (@last_date is null) or (.TODAY > @last_date) select @last_date = .TODAY select @last_date = dateadd(dd,1,@last_date) select convert(varchar(30),0) as sid, convert(datetime,convert(varchar(8),@last_date,3),3) as last_date_d end $ENDTEXT(19031659) $ENDFORM $ACTION(ACTION_MOVE) name=# ap_getid class=9 form=null target_state=null procedure=ap_getid patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @id numeric out as declare @site_id numeric(2,0), @user_id numeric begin select @site_id=id from t_sites where is_local=1 if @@error!=0 return if @site_id is null begin raiserror 40000 'Неизвестна площадка' return end insert t_idgenerator (site_id) values (@site_id) if @@error!=0 return select @id = @@identity + @site_id*10000000000000000 end $ENDTEXT(19031659) $ENDACTION $ACTION(ACTION_MOVE1) name=# ap_getminmax_id class=9 form=null target_state=null procedure=ap_getminmax_id patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @maxormin int /* 0-Min ,other Max */, @res numeric out as begin if @maxormin<>0 select @res=100000000000000009 else select @res=-100000000000000009 end $ENDTEXT(19031659) $ENDACTION $ACTION(ACTION_MOVE2) name=# ap_getparm class=9 form=null target_state=null procedure=ap_getparm patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @objname varchar(30) as begin select c.name as name, t.name as type, c.length as length, c.prec as prec, c.scale as scale from syscolumns c, systypes t where c.id = object_id(@objname) and c.usertype *= t.usertype end $ENDTEXT(19031659) $ENDACTION $ACTION(ACTION_MOVE3) name=# ap_help - Данные по документам class=9 form=null target_state=null procedure=ap_help patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @id numeric = null as begin declare @state_id numeric declare @class_name varchar(255) if @id is null begin raiserror 40000 'Не задан ID документа' return end if exists(select 1 from t_types where id = @id) begin select t_types.type_name + ' (' + t_types.type_code + ')' as 'Тип документа:' from t_types where t_types.id = @id select count(*) as 'Док. данного типа:' from t_items where t_items.type_id = @id return end if exists(select 1 from t_states where id = @id) begin select t_states.state_name + ' (' + isNull(t_states.state_code, '') + ')' as 'Статус документа:' from t_states where t_states.id = @id select t_types.type_name + ' (' + t_types.type_code + ')' as 'Тип документа:' from t_types, t_states where t_types.id = t_states.type_id and t_states.id = @id select count(*) as 'Док. в данном статусе:' from t_items where t_items.state_id = @id return end if exists(select 1 from t_actions where id = @id) begin select t_actions.action_name + ' ' + isNull(t_actions.action_code, '') as 'Метод документа:' from t_actions where t_actions.id = @id select t_types.type_name + ' (' + t_types.type_code + ')' as 'Тип документа:' from t_types, t_actions where t_types.id = t_actions.type_id and t_actions.id = @id return end if not exists(select 1 from t_items where id = @id) begin raiserror 40000 'Документ в системе не зарегистрирован' return end select t_items.item_name + isnull(' (' + t_items.item_remark + ')', '') as 'Наименование:' from t_items where t_items.id = @id select t_types.type_name + '(' + isnull(t_types.type_code, '') + ')' as 'Тип:' from t_items, t_types where t_items.id = @id and t_items.type_id = t_types.id select @state_id = (select t_states.id from t_items, t_states where t_items.id = @id and t_items.state_id = t_states.id) select @class_name = '' select @class_name = 'Удален!, ' from t_states where t_states.id = @id and t_states.class_id = 2 select ltrim(@class_name + isnull(t_states.state_code + ', ', '') + t_states.state_name) as 'Статус:' from t_states where t_states.id = @state_id if exists(select 1 from t_operations where item_id = @id) begin select 'По документу есть проводки' as 'Проводки:' end else begin select 'нет' as 'Проводки:' end if exists(select 1 from t_oper_subconto where item_id = @id) begin select 'Документ является субконто' as 'Субконто:' end else begin select 'нет' as 'Субконто:' end end $ENDTEXT(19031659) $ENDACTION $ACTION(ACTION_MOVE4) name=# ap_restore_generator class=9 form=null target_state=null procedure=ap_restore_generator patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @id numeric = null as declare @max_id numeric, @min_id numeric begin if @id is null begin raiserror 40000 'Задайте ID сервера' return end select @min_id = @id * 10000000000000000 select @max_id = (@id + 1) * 10000000000000000 create table #generator( id numeric ) insert into #generator( id ) select (t_items.id - @min_id) from t_items where t_items.id >= @min_id and t_items.id < @max_id insert into #generator( id ) select (t_types.id - @min_id) from t_types where t_types.id >= @min_id and t_types.id < @max_id insert into #generator( id ) select (t_states.id - @min_id) from t_states where t_states.id >= @min_id and t_states.id < @max_id insert into #generator( id ) select (t_actions.id - @min_id) from t_actions where t_actions.id >= @min_id and t_actions.id < @max_id insert into #generator( id ) select (t_texts.id - @min_id) from t_texts where t_texts.id >= @min_id and t_texts.id < @max_id insert into #generator( id ) select (t_binds.id - @min_id) from t_binds where t_binds.id >= @min_id and t_binds.id < @max_id insert into #generator( id ) select (t_calcprop.id - @min_id) from t_calcprop where t_calcprop.id >= @min_id and t_calcprop.id < @max_id insert into #generator( id ) select (t_filter2action.id - @min_id) from t_filter2action where t_filter2action.id >= @min_id and t_filter2action.id < @max_id insert into #generator( id ) select (t_menu.id - @min_id) from t_menu where t_menu.id >= @min_id and t_menu.id < @max_id insert into #generator( id ) select (t_menu.id - @min_id) from t_menu where t_menu.id >= @min_id and t_menu.id < @max_id insert into #generator( id ) select (t_patternargs.id - @min_id) from t_patternargs where t_patternargs.id >= @min_id and t_patternargs.id < @max_id insert into #generator( id ) select (t_patterns.id - @min_id) from t_patterns where t_patterns.id >= @min_id and t_patterns.id < @max_id insert into #generator( id ) select (t_props.id - @min_id) from t_props where t_props.id >= @min_id and t_props.id < @max_id insert into #generator( id ) select (t_relation.id - @min_id) from t_relation where t_relation.id >= @min_id and t_relation.id < @max_id insert into #generator( id ) select (t_action2relation.id - @min_id) from t_action2relation where t_action2relation.id >= @min_id and t_action2relation.id < @max_id insert into #generator( id ) select (t_roles.id - @min_id) from t_roles where t_roles.id >= @min_id and t_roles.id < @max_id insert into #generator( id ) select (t_states_list.id - @min_id) from t_states_list where t_states_list.id >= @min_id and t_states_list.id < @max_id insert into #generator( id ) select (t_states_list.id - @min_id) from t_states_list where t_states_list.id >= @min_id and t_states_list.id < @max_id insert into #generator( id ) select (t_operations.id - @min_id) from t_operations where t_operations.id >= @min_id and t_operations.id < @max_id begin tran set identity_insert t_idgenerator on insert into t_idgenerator( id, site_id ) select distinct #generator.id, @id from #generator where #generator.id not in (select id from t_idgenerator) set identity_insert t_idgenerator off if @@error!=0 begin rollback tran raiserror 40000 'Ошибка' return end commit tran drop table #generator end $ENDTEXT(19031659) $ENDACTION $ACTION(ACTION_MOVE5) name=# apt_aladdin_products_view class=9 form=null target_state=null procedure=apt_aladdin_products_view patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% as begin select sid=convert(varchar,id), product_code, product_name from t_aladdin_products where is_actual=1 end $ENDTEXT(19031659) $ENDACTION $ACTION(APT_ACTIONS_ANY) name=# apt_actions_any class=9 form=null target_state=null procedure=apt_actions_any patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.apt_actions_any @action integer = 0, @sid varchar(255) = null, @action_name varchar(60) = null, @action_code varchar(30) = null, @class_id tinyint = null, @type_sid varchar(30) = null, @state_sid varchar(30) = null, @vaction_sid varchar(30) = null, @naction_sid varchar(30) = null, @faction_sid varchar(30) = null, @isvisible tinyint = 0, @is_tab tinyint =0 as declare @id numeric declare @type_id numeric declare @state_id numeric declare @vaction_id numeric declare @naction_id numeric declare @faction_id numeric begin transaction if (@action = 1) begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end select @type_id = convert(numeric, @type_sid) if (@type_id is null) begin rollback transaction raiserror 40000 'не задан тип документа' return end select @state_id = convert(numeric, @state_sid) select @vaction_id = convert(numeric, @vaction_sid) select @naction_id = convert(numeric, @naction_sid) select @faction_id = convert(numeric, @faction_sid) insert into t_actions ( id, action_name, action_code, class_id, type_id, state_id, vaction_id, naction_id, faction_id, isvisible, is_tab ) values ( @id, @action_name, @action_code, @class_id, @type_id, @state_id, @vaction_id, @naction_id, @faction_id, @isvisible, @is_tab ) end if (@action = 2) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end select @type_id = convert(numeric, @type_sid) if (@type_id is null) begin rollback transaction raiserror 40000 'не задан тип документа' return end select @state_id = convert(numeric, @state_sid) select @vaction_id = convert(numeric, @vaction_sid) select @naction_id = convert(numeric, @naction_sid) select @faction_id = convert(numeric, @faction_sid) update t_actions set action_name = @action_name, action_code = @action_code, class_id = @class_id, type_id = @type_id, state_id = @state_id, vaction_id = @vaction_id, naction_id = @naction_id, faction_id = @faction_id, isvisible = @isvisible, is_tab = @is_tab where id = @id end if (@action = 3) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end delete t_actions where id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_actions' return end commit transaction if (@action = 1) select sid = convert(varchar, @id) $ENDTEXT(19031659) $ENDACTION $ACTION(APT_ACTIONS_BYCLASS) name=# apt_actions_byclass class=9 form=null target_state=null procedure=apt_actions_byclass patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @class_name varchar(255) = null, @type_sid varchar(255) = null as declare @id numeric declare @type_id numeric declare @min_class_id tinyint declare @max_class_id tinyint begin if (@class_name is null) select @class_name = 'A' select @min_class_id = 0 select @max_class_id = 0 if (upper(@class_name) = 'N') select @min_class_id = 1, @max_class_id = 3 if (upper(@class_name) = 'V') select @min_class_id = 4, @max_class_id = 5 if (upper(@class_name) = 'F') select @min_class_id = 6, @max_class_id = 6 if (upper(@class_name) = 'P') select @min_class_id = 9, @max_class_id = 9 if (upper(@class_name) = 'A') select @min_class_id = 1, @max_class_id = 9 select @type_id = convert(numeric, @type_sid) select sid = convert(varchar, t_actions.id), t_actions.action_name, t_actions.action_code from t_actions where t_actions.type_id = @type_id and t_actions.class_id >= @min_class_id and t_actions.class_id <= @max_class_id order by t_actions.action_name end $ENDTEXT(19031659) $ENDACTION $ACTION(APT_ACTIONS_INS_TYPE) name=# apt_actions_ins_type class=9 form=null target_state=null procedure=apt_actions_ins_type patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.apt_actions_ins_type @action integer = 0, @sid varchar(255) = null, @type_sid varchar(255) = null, @s_type_sid varchar(255) = null as begin declare @id numeric declare @type_id numeric, @action_code varchar(30), @action_name varchar(60), @class_id tinyint, @naction_id numeric, @vaction_id numeric, @faction_id numeric, @uo_name varchar(60), @dw_name varchar(60), @proc_name varchar(30), @state_id numeric, @pat_id numeric, @user_define tinyint, @isvisible tinyint, @external_name varchar(255), @external_add_name varchar(255), @is_tab tinyint declare @c_action_id numeric, @new_action_id numeric, @calc_name varchar(30), @calc_type varchar(10), @calc_length smallint, @calc_prec smallint, @calc_scale smallint, @calc_formula varchar(255), @calc_comment varchar(255), @calc_class_id smallint, @action_sid varchar(30), @sid1 varchar(30) declare @new_state_id numeric, @s_type_id numeric , @action_id numeric begin transaction select @s_type_id=convert(numeric,@s_type_sid) if @s_type_id is NULL begin rollback transaction execute ap_mess_raise 112 return end select @type_id = convert(numeric, @type_sid) if @type_id is NULL begin rollback transaction execute ap_mess_raise 111 return end declare cur cursor for select distinct id, action_code, action_name, class_id, naction_id, vaction_id, faction_id, uo_name, dw_name, proc_name, state_id, pat_id, user_define, isvisible, external_name, external_add_name, is_tab from t_actions where type_id = @s_type_id and rtrim(ltrim(upper(t_actions.action_name))) not in (select rtrim(ltrim(upper(action_name))) from t_actions where type_id = @type_id) open cur fetch cur into @action_id, @action_code, @action_name, @class_id, @naction_id, @vaction_id, @faction_id, @uo_name, @dw_name, @proc_name, @state_id, @pat_id, @user_define, @isvisible, @external_name, @external_add_name, @is_tab while (.CURSOR_STATE=0) begin execute ap_getid @id out select @sid = convert(varchar, @id) if (@id is null) begin rollback transaction raiserror 40000 'Не задан id для t_actions' return end select @proc_name = 'ap_'+convert(varchar,@id) select @new_state_id= (select id from t_states where type_id=@type_id and rtrim(ltrim(upper(state_name))) = (select rtrim(ltrim(upper(state_name))) from t_states where id=@state_id)) insert into t_actions ( id, type_id, action_code, action_name, class_id, naction_id, vaction_id, faction_id, uo_name, dw_name, proc_name, state_id, pat_id, user_define, isvisible, external_name, external_add_name, is_tab ) values(@id, @type_id, null, @action_name, @class_id, @naction_id, @vaction_id, @faction_id, @uo_name, @dw_name, @proc_name, @new_state_id, @pat_id, @user_define, @isvisible, @external_name, @external_add_name, @is_tab ) /*------Filter */ select @action_sid = convert(varchar,@action_id) select @sid1 = convert(varchar,@id) execute apt_filter2action_copy @sid1 , @action_sid if @@error !=0 begin close cur return end /* Related states */ insert t_state2action(action_id,state_id) select @id,n.id from t_states n,t_states o,t_state2action where n.type_id=@type_id and o.type_id=@s_type_id and rtrim(ltrim(upper(n.state_name))) = rtrim(ltrim(upper(o.state_name))) and t_state2action.action_id=@action_id and t_state2action.state_id=o.id /*Tests*/ insert t_texts(id,seg_len,seg_num,text_len) select @id,seg_len,seg_num,text_len from t_texts where id=@action_id insert t_segments(id,seg_num,seg_text) select @id,seg_num,seg_text from t_segments where id=@action_id insert t_action2props(action_id,prop_id) select @id, n.id from t_props n,t_props o,t_action2props where n.type_id = @type_id and o.type_id = @s_type_id and o.table_name = n.table_name and o.field_name = n.field_name and t_action2props.action_id = @action_id and t_action2props.prop_id = o.id insert t_state2action2role(state_id,action_id,role_id) select n.id ,@id,s2r.role_id from t_states n,t_states o, t_state2action2role s2r where n.type_id = @type_id and o.type_id = @s_type_id and s2r.state_id = o.id and s2r.action_id = @id and rtrim(ltrim(upper(n.state_name))) = rtrim(ltrim(upper(o.state_name))) fetch cur into @action_id, @action_code, @action_name, @class_id, @naction_id, @vaction_id, @faction_id, @uo_name, @dw_name, @proc_name, @state_id, @pat_id, @user_define, @isvisible, @external_name, @external_add_name, @is_tab end close cur update t_actions set naction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.naction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), vaction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.vaction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), faction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.faction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) where type_id=@type_id /*Связи методов*/ declare @new_bind_id numeric, @bind_id numeric, @bind_class_id numeric, @bind_order int, @s_action_id numeric, @t_action_id numeric, @new_s_action_id numeric, @new_t_action_id numeric, @sid_asname varchar(30) declare b_cur cursor for select b.id,b.class_id,b.bind_order,b.s_action_id,b.t_action_id,b.sid_asname from t_binds b, t_actions a where b.s_action_id = a.id and a.type_id = @s_type_id open b_cur fetch b_cur into @bind_id, @bind_class_id, @bind_order, @s_action_id, @t_action_id, @sid_asname while (.CURSOR_STATE=0) begin execute ap_getid @new_bind_id out if (@id is null) begin rollback transaction raiserror 40000 'Не задан id для t_binds' return end select @new_s_action_id = (select n.id from t_actions n ,t_actions o where o.id = @s_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) select @new_t_action_id = (select n.id from t_actions n ,t_actions o where o.id = @t_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) if @new_t_action_id is null select @new_t_action_id = @t_action_id insert t_binds(id,class_id,bind_order,s_action_id,t_action_id,sid_asname) values(@new_bind_id,@bind_class_id,@bind_order,@new_s_action_id,@new_t_action_id,@sid_asname) fetch b_cur into @bind_id, @bind_class_id, @bind_order, @s_action_id, @t_action_id, @sid_asname end close b_cur declare calc_cur cursor for select c.action_id, c.calc_name, c.calc_type, c.calc_length, c.calc_prec, c.calc_scale, c.calc_formula, c.calc_comment, c.calc_class_id from t_calcprop c,t_actions where c.action_id = t_actions.id and t_actions.type_id = @s_type_id open calc_cur fetch calc_cur into @c_action_id, @calc_name, @calc_type, @calc_length, @calc_prec, @calc_scale, @calc_formula, @calc_comment, @calc_class_id while (.CURSOR_STATE=0) begin select @new_action_id = (select n.id from t_actions n ,t_actions o where o.id = @c_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'Не задан id для t_calcprop' return end insert t_calcprop( id, action_id, calc_name, calc_type, calc_length, calc_prec, calc_scale, calc_formula, calc_comment, calc_class_id ) values(@id, @new_action_id, @calc_name, @calc_type, @calc_length, @calc_prec, @calc_scale, @calc_formula, @calc_comment, @calc_class_id ) fetch calc_cur into @c_action_id, @calc_name, @calc_type, @calc_length, @calc_prec, @calc_scale, @calc_formula, @calc_comment, @calc_class_id end close calc_cur commit transaction end $ENDTEXT(19031659) $ENDACTION $ACTION(APT_FILTER2ACTION_COPY) name=# apt_filter2action_copy class=9 form=null target_state=null procedure=apt_filter2action_copy patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.%PROC% @action_sid varchar(30) = null, @s_action_sid varchar(30) = null as begin declare @id numeric declare @action_id numeric declare @src_action_id numeric declare @type_id numeric declare @src_type_id numeric declare @prop_id numeric, @filter_label varchar(255), @filter_type tinyint, @filter_formula varchar(255), @filter_formula_end varchar(255), @arg_field_code varchar(30), @arg_field_type varchar(30), @arg_field_length tinyint, @arg_field_prec tinyint, @arg_field_scale tinyint, @init_order tinyint begin transaction select @action_id = convert(numeric, @action_sid) if (@action_id is null) begin rollback transaction raiserror 40000 'не задан целевой метод для t_filter2action' return end select @src_action_id = convert(numeric, @s_action_sid) if (@action_id is null) begin rollback transaction raiserror 40000 'не задан метод - источник для t_filter2action' return end select @type_id = type_id from t_actions where id = @action_id select @src_type_id = type_id from t_actions where id = @src_action_id declare tmp_cur cursor for select s.prop_id , s.filter_label, s.filter_type, s.arg_field_code, s.arg_field_type, s.arg_field_length, s.arg_field_prec, s.arg_field_scale, s.init_order, s.filter_formula, s.filter_formula_end from t_filter2action s where s.action_id = @src_action_id for read only open tmp_cur fetch tmp_cur into @prop_id , @filter_label, @filter_type, @arg_field_code, @arg_field_type, @arg_field_length, @arg_field_prec, @arg_field_scale, @init_order, @filter_formula, @filter_formula_end while .CURSOR_STATE = 0 begin if @type_id != @src_type_id and @prop_id is not null begin select @prop_id = (select d.id from t_props s,t_props d where s.id = @prop_id and d.type_id =@type_id and s.field_name = d.field_name and s.table_name = d.table_name) end if not exists(select 1 from t_filter2action where action_id = @action_id and prop_id = @prop_id and arg_field_code = @arg_field_code) begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_filter2action' return end insert into t_filter2action ( id, action_id , prop_id , filter_label, filter_type, arg_field_code, arg_field_type, arg_field_length, arg_field_prec, arg_field_scale, init_order, filter_formula, filter_formula_end ) values( @id, @action_id , @prop_id , @filter_label, @filter_type, @arg_field_code, @arg_field_type, @arg_field_length, @arg_field_prec, @arg_field_scale, @init_order, @filter_formula, @filter_formula_end ) end fetch tmp_cur into @prop_id , @filter_label, @filter_type, @arg_field_code, @arg_field_type, @arg_field_length, @arg_field_prec, @arg_field_scale, @init_order, @filter_formula, @filter_formula_end end close tmp_cur commit tran end $ENDTEXT(19031659) $ENDACTION $ACTION(APT_RELATIONS_INS_TYPE) name=# apt_relations_ins_type class=9 form=null target_state=null procedure=apt_relations_ins_type patterns=null user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031659) create procedure dbo.apt_relations_ins_type @action integer = 0, @sid varchar(255) = null, @type_sid varchar(255) = null, @s_type_sid varchar(255) = null as begin declare @id numeric declare @new_id numeric, @a2r_id numeric, @rel_id numeric, @rel_type tinyint, @class_id numeric, @s_type_id numeric, @t_type_id numeric, @action_id numeric, @prop_id numeric, @sid_asname varchar(30), @new_action_id numeric, @new_parent_id numeric, @new_prop_id numeric, @new_rel_id numeric, @r_action_id numeric, @r_parent_id numeric, @r_where_syntax varchar(255), @r_id numeric, @type_id numeric, @rel_order int, @field_as_name varchar(255) begin transaction select @s_type_id=convert(numeric,@s_type_sid) if @s_type_id=NULL begin rollback transaction execute ap_mess_raise 112 return end select @type_id = convert(numeric, @type_sid) if @type_id is NULL begin rollback transaction execute ap_mess_raise 111 return end declare cur cursor for select distinct id, class_id, t_type_id, action_id, prop_id, sid_asname, rel_order from t_relation where s_type_id = @s_type_id open cur fetch cur into @rel_id, @class_id, @t_type_id, @action_id, @prop_id, @sid_asname, @rel_order while (.CURSOR_STATE=0) begin select @new_prop_id = (select n.id from t_props n, t_props o where n.type_id = @type_id and o.type_id =@s_type_id and o.id = @prop_id and n.field_name = o.field_name and n.table_name = o.table_name) if not exists(select 1 from t_relation where class_id = @class_id and s_type_id = @type_id and t_type_id = @t_type_id and action_id =@action_id and prop_id = @new_prop_id) begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'Не задан id для t_relations' return end insert into t_relation( id, class_id, s_type_id, t_type_id, action_id, prop_id, sid_asname, rel_order ) values(@id, @class_id, @type_id, @t_type_id, @action_id, @new_prop_id, @sid_asname, @rel_order ) insert t_relation2subc(rel_id,subc_id) select @id,subc_id from t_relation2subc where rel_id = @rel_id end fetch cur into @rel_id, @class_id, @t_type_id, @action_id, @prop_id, @sid_asname, @rel_order end close cur /* Action2relation*/ declare a2cur cursor for select a2r.action_id,a2r.parent_id,a2r.where_syntax, a2r.rel_id,a2r.rel_type, a2r.id from t_action2relation a2r,t_actions oa where a2r.action_id = oa.id and oa.type_id =@s_type_id open a2cur fetch a2cur into @r_action_id, @r_parent_id, @r_where_syntax, @rel_id, @rel_type, @a2r_id while (.CURSOR_STATE=0) begin execute ap_getid @r_id out if (@r_id is null) begin rollback transaction raiserror 40000 'Не задан id для t_action2relation' return end select @new_action_id = (select n.id from t_actions n, t_actions o where n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and o.id = @r_action_id and rtrim(ltrim(upper(o.action_name))) = rtrim(ltrim(upper(n.action_name)))) select @new_rel_id = (select n.id from t_relation n, t_relation o,t_props po, t_props pn where n.s_type_id = @type_id and o.s_type_id = @s_type_id and o.t_type_id = n.t_type_id and o.id = @rel_id and o.class_id = n.class_id and pn.type_id = @type_id and po.type_id = @s_type_id and po.id = o.prop_id and po.field_name = pn.field_name and po.table_name = pn.table_name and pn.id = n.prop_id) select @new_parent_id = (select n.id from t_action2relation n,t_action2relation o,t_actions an,t_actions ao,t_relation ro,t_relation rn where o.id = @r_parent_id and o.rel_id = ro.id and n.rel_id = @new_rel_id and o.rel_id = @rel_id and rn.s_type_id = @type_id and ro.s_type_id = @s_type_id and ro.class_id = rn.class_id and ro.t_type_id = rn.t_type_id and o.action_id = ao.id and n.action_id = an.id and an.type_id = @type_id and ao.type_id = @s_type_id and ao.class_id = an.class_id and rtrim(ltrim(upper(ao.action_name))) = rtrim(ltrim(upper(an.action_name)))) if @new_parent_id is null select @new_parent_id = 0 insert t_action2relation(id,rel_id,action_id,parent_id,where_syntax, rel_type) values(@r_id,@new_rel_id,@new_action_id,@new_parent_id,@r_where_syntax,@rel_type) declare a2r2p_cur cursor for select a2r2p.prop_id, a2r2p.field_as_name from dbo.t_action2relation2props a2r2p where a2r2p.action2rel_id = @a2r_id open a2r2p_cur fetch a2r2p_cur into @prop_id, @field_as_name while(.CURSOR_STATE=0) begin exec dbo.ap_getid @new_id out insert dbo.t_action2relation2props ( id, action2rel_id, prop_id, field_as_name ) values ( @new_id, @r_id, @prop_id, @field_as_name ) fetch a2r2p_cur into @prop_id, @field_as_name end close a2r2p_cur deallocate a2r2p_cur /* * этот код заменён на цикл с курсором выше потому, что теперь в * t_action2relation2props надо вставлять идентификаторы * Александр В. Подзолко * * insert t_action2relation2props(action2rel_id,prop_id,field_as_name) * select @r_id, a2r2p.prop_id, * a2r2p.field_as_name * from t_action2relation2props a2r2p * where a2r2p.action2rel_id = @a2r_id * */ fetch a2cur into @r_action_id, @r_parent_id, @r_where_syntax, @rel_id, @rel_type, @a2r_id end close a2cur commit transaction end $ENDTEXT(19031659) $ENDACTION $ACTION(APT_SEGMENTS_ANY) name=# apt_segments_any class=9 form=null target_state=null procedure=apt_segments_any patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.apt_segments_any @action integer = 0, @sid varchar(255) = null, @seg_num integer = null, @seg_text varchar(255) = null as declare @id numeric begin transaction select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_segments' return end if (@action = 1) begin if (@seg_num is null) begin rollback transaction raiserror 40000 'не задана строка для t_segments' return end insert into t_segments ( id, seg_num, seg_text ) values ( @id, @seg_num, @seg_text ) end if (@action = 3) begin delete t_segments where id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_segments' return end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(APT_STATES_INS_TYPE) name=# apt_states_ins_type class=9 form=null target_state=null procedure=apt_states_ins_type patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action integer = 0, @sid varchar(255) = null, @type_sid varchar(255) = null, @s_type_sid varchar(255) = null as begin declare @id numeric declare @type_id numeric declare @s_type_id numeric declare @state_code varchar(100),@state_name varchar(150) declare @class_id numeric,@state_id numeric begin transaction select @s_type_id=convert(numeric,@s_type_sid) if @s_type_id is NULL begin rollback transaction execute ap_mess_raise 112 return end select @type_id = convert(numeric, @type_sid) if @type_id is NULL begin rollback transaction execute ap_mess_raise 111 return end declare cur cursor for select distinct state_code,state_id,state_name,class_id from t_states where type_id = @s_type_id and rtrim(ltrim(upper(t_states.state_name))) not in (select rtrim(ltrim(upper(state_name))) from t_states where type_id = @type_id) open cur fetch cur into @state_code,@state_id,@state_name,@class_id while (.CURSOR_STATE=0) begin execute ap_getid @id out select @sid = convert(varchar, @id) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_states' return end insert into t_states ( id, type_id, state_code, state_id, state_name, class_id ) values(@id, @type_id, @state_code, @state_id, @state_name, @class_id ) fetch cur into @state_code,@state_id,@state_name,@class_id end close cur insert t_state2prop(state_id,prop_id,is_visible,is_mandatory,is_enable) select sn.id,pn.id,t_state2prop.is_visible,t_state2prop.is_mandatory,t_state2prop.is_enable from t_state2prop,t_states so,t_states sn, t_props po,t_props pn where t_state2prop.state_id = so.id and so.type_id = @s_type_id and sn.type_id = @type_id and rtrim(ltrim(upper(so.state_name))) = rtrim(ltrim(upper(sn.state_name))) and t_state2prop.prop_id = po.id and po.type_id = @s_type_id and pn.type_id = @type_id and pn.field_name = po.field_name and pn.table_name = po.table_name commit transaction end $ENDTEXT(19031660) $ENDACTION $ACTION(APT_TEXTS_ANY) name=# apt_texts_any class=9 form=null target_state=null procedure=apt_texts_any patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.apt_texts_any @action integer = 0, @sid varchar(255) = null, @text_len integer = null, @seg_len smallint = null, @seg_num integer = null as declare @id numeric begin transaction select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_texts' return end if (@action = 1) begin insert into t_texts ( id, text_len, seg_len, seg_num ) values ( @id, @text_len, @seg_len, @seg_num ) end if (@action = 2) begin update t_texts set text_len = @text_len, seg_len = @seg_len, seg_num = @seg_num where id = @id end if (@action = 3) begin delete t_texts where id = @id delete t_segments where id=@id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_texts' return end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(AP_MES_RAISE) name=# ap_mess_raise class=9 form=null target_state=null procedure=ap_mess_raise patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @mess_id numeric as declare @mess_string char(255), @raise_id numeric begin if @mess_id=101 select @mess_string=' Неизвестное сообщение' else if @mess_id=102 select @mess_string=' Данный план счетов предприятия не существует' else if @mess_id=103 select @mess_string='Период с датой операции закрыт' else if @mess_id=104 select @mess_string='Счет, указанный в проводке не существует' else if @mess_id=105 select @mess_string='Счет, указанный в проводке не является конечным' else if @mess_id=106 select @mess_string='Курс валюты операцм должен быть задан и не может быть < = 0' else if @mess_id=107 select @mess_string='Курс валюты плана должен быть задан и не может быть < = 0' else if @mess_id=108 select @mess_string='Курс валюты счета должен быть задан и не может быть < = 0' else if @mess_id=109 select @mess_string='Значение субконто дебетового счета не определено' else if @mess_id=110 select @mess_string='Значение субконто кредитового счета не определено' else if @mess_id=111 select @mess_string='Тип документа не задан' else if @mess_id=112 select @mess_string='Тип документа источника не задан' else select @mess_string='Неизвестная ошибка' raiserror 40000 @mess_string end $ENDTEXT(19031660) $ENDACTION $ACTION(AP_PROP2ACTION) name=# ap_prop2action class=9 form=null target_state=null procedure=ap_prop2action patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action_sid varchar(30) = null as begin declare @action_id numeric declare @type_id numeric select @action_id=convert(numeric,@action_sid) select @type_id=type_id from t_actions where id = @action_id create table #report ( prop_name varchar(255) null, table_name varchar(30) null, field_id int null, field_name varchar(30) null, field_as_name varchar(30) null, field_type varchar(30) null, field_length tinyint null, field_prec tinyint null, field_scale tinyint null, field_target tinyint null ) insert into #report ( prop_name, table_name, field_name, field_as_name, field_target, field_id, field_type, field_length, field_prec, field_scale ) select t_props.prop_name, t_props.table_name, t_props.field_name, t_props.field_as_name, 0, t_props.prop_order, t_props.field_type, t_props.field_length, t_props.field_prec, t_props.field_scale from t_props, t_action2props where t_action2props.action_id = @action_id and t_action2props.prop_id = t_props.id insert into #report ( prop_name, table_name, field_name, field_as_name, field_target, field_id, field_type, field_length, field_prec, field_scale ) select t_props.prop_name, t_props.table_name, t_props.field_name, t_props.field_as_name, 1, t_props.prop_order, t_props.field_type, t_props.field_length, t_props.field_prec, t_props.field_scale from t_props, t_relation, t_action2relation where t_action2relation.action_id = @action_id and t_action2relation.rel_type = 0 and t_relation.s_type_id = @type_id and t_action2relation.rel_id = t_relation.id and t_relation.class_id = 0 and t_relation.prop_id = t_props.id select * from #report where field_type is not null order by table_name, field_id end $ENDTEXT(19031660) $ENDACTION $ACTION(AP_PROP2ACTION2REL) name=# ap_prop2action2rel class=9 form=null target_state=null procedure=ap_prop2action2rel patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action2rel_sid varchar(30) = null as begin declare @rel_id numeric declare @rel_type tinyint declare @action2rel_id numeric declare @type_id numeric select @action2rel_id =convert(numeric, @action2rel_sid) select @rel_id = rel_id, @rel_type = rel_type from t_action2relation where id = @action2rel_id if (@rel_type = 0) select @type_id = t_type_id from t_relation where id = @rel_id else select @type_id = s_type_id from t_relation where id = @rel_id create table #report ( prop_name varchar(255) null, table_name varchar(30) null, field_id int null, field_name varchar(30) null, field_as_name varchar(30) null, field_type varchar(30) null, field_length tinyint null, field_prec tinyint null, field_scale tinyint null, field_target tinyint null ) insert into #report ( prop_name, table_name, field_name, field_as_name, field_target, field_id, field_type, field_length, field_prec, field_scale ) select t_props.prop_name, t_props.table_name, t_props.field_name, t_action2relation2props.field_as_name, 0, t_props.prop_order, t_props.field_type, t_props.field_length, t_props.field_prec, t_props.field_scale from t_props, t_action2relation2props where t_action2relation2props.action2rel_id = @action2rel_id and t_action2relation2props.prop_id = t_props.id insert into #report ( prop_name, table_name, field_name, field_as_name, field_target, field_id, field_type, field_length, field_prec, field_scale ) select t_props.prop_name, t_props.table_name, t_props.field_name, t_props.field_as_name, 1, t_props.prop_order, t_props.field_type, t_props.field_length, t_props.field_prec, t_props.field_scale from t_props, t_relation, t_action2relation where t_action2relation.parent_id = @action2rel_id and t_action2relation.rel_type = 0 and t_action2relation.rel_id = t_relation.id and t_relation.prop_id = t_props.id select * from #report where field_type is not null order by table_name, field_id end $ENDTEXT(19031660) $ENDACTION $ACTION(AP_SETSIZE2ACTION) name=# ap_setsize2action class=9 form=null target_state=null procedure=ap_setsize2action patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.ap_setsize2action @action_sid varchar(30) = null, @x int = 0, @y int = 0, @width int = 0, @height int = 0 as declare @action_id numeric begin select @action_id = convert(numeric, @action_sid) if (@action_id is not null) begin update t_actions set x = @x, y = @y, width = @width, height = @height where t_actions.id = @action_id end end $ENDTEXT(19031660) $ENDACTION $ACTION(AP_STATE_NAME2USER) name=# Список статусов для фильтра в группе class=9 form=null target_state=null procedure=ap_state_name2user patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.ap_state_name2user @type_id_s varchar(30) = null as declare @type_id numeric begin if (@type_id_s is null) begin select sid = convert(varchar, t_states_list.id), item_name = t_states_list.state_name from t_states_list where t_states_list.id in (select t_states.state_id from t_users, t_user2role, t_state2action2role,t_states where t_users.login_name = .SUSER_NAME and t_users.id = t_user2role.user_id and t_user2role.role_id = t_state2action2role.role_id and t_state2action2role.state_id = t_states.id ) order by t_states_list.state_name end else begin select @type_id = convert(numeric,@type_id_s) select sid = convert(varchar, t_states_list.id), item_name = t_states_list.state_name from t_states_list where t_states_list.id in (select t_states.state_id from t_users, t_user2role, t_state2action2role,t_states where t_users.login_name = .SUSER_NAME and t_users.id = t_user2role.user_id and t_user2role.role_id = t_state2action2role.role_id and t_state2action2role.state_id = t_states.id and t_states.type_id = @type_id ) order by t_states_list.state_name end end $ENDTEXT(19031660) $ENDACTION $ACTION(AP_TRANCOUNT) name=# ap_trancount class=9 form=null target_state=null procedure=ap_trancount patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.ap_trancount as begin select @@trancount as trancount end $ENDTEXT(19031660) $ENDACTION $ACTION(PATTERNARGS_COPY) name=Копирование агргументов шаблона class=2 form=null target_state=null procedure=apt_patternargs_copy patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action integer = 0, @sid varchar(30) = null, @s_pattern_id_s varchar(30) = null as declare @pat_id numeric,@id numeric, @arg_id numeric, @arg_name varchar(255), @arg_label varchar(255), @arg_comment varchar(255), @is_needed tinyint, @default_value varchar(255), @choose_type_id numeric, @choose_action_code varchar(255), @choose_field_name varchar(255) declare @s_pattern_id numeric begin transaction if (@sid is null) begin rollback transaction raiserror 40000 'не задан шаблон - приемник' return end select @pat_id = convert(numeric, @sid) if (@action = 1) begin select @pat_id = convert(numeric, @sid) if (@pat_id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patternargs' return end if (@s_pattern_id_s is null) or (upper(@s_pattern_id_s) = 'NULL' ) begin rollback transaction raiserror 40000 'не задан ключ шаблон - источник' return end select @s_pattern_id = convert(numeric, @s_pattern_id_s) declare tmp_cur cursor for select arg_id, arg_name, arg_label, arg_comment, is_needed, default_value, choose_type_id, choose_action_code, choose_field_name from t_patternargs where pat_id = @s_pattern_id and arg_name not in (select arg_name from t_patternargs where pat_id =@pat_id) for read only open tmp_cur fetch tmp_cur into @arg_id, @arg_name, @arg_label, @arg_comment, @is_needed, @default_value, @choose_type_id, @choose_action_code, @choose_field_name while .CURSOR_STATE =0 begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patternargs' return end insert into t_patternargs ( id, pat_id, arg_id, arg_name, arg_label, arg_comment, is_needed, default_value, choose_type_id, choose_action_code, choose_field_name )values( @id, @pat_id, @arg_id, @arg_name, @arg_label, @arg_comment, @is_needed, @default_value, @choose_type_id, @choose_action_code, @choose_field_name ) fetch tmp_cur into @arg_id, @arg_name, @arg_label, @arg_comment, @is_needed, @default_value, @choose_type_id, @choose_action_code, @choose_field_name end close tmp_cur end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(PATTERNARGS_DELALL) name=Удаление всех аргументов шаблона class=2 form=null target_state=null procedure=apt_patternargs_delall patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action integer = 0, @sid varchar(30) = null as declare @id numeric begin transaction if (@sid is null) begin rollback transaction raiserror 40000 'не задан шаблон - приемник' return end select @id = convert(numeric, @sid) if (@action = 3) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patternargs' return end delete t_patternargs where pat_id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_patternargs' return end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(PATTERNARGS_EDIT) name=Изменение аргументов шаблона class=2 form=UO_PATTERNARGS_EDIT target_state=null procedure=apt_patternargs_any patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action integer = 0, @sid varchar(30) = null, @pat_id_s varchar(30) = null, @arg_id tinyint = null, @arg_name varchar(255) = null, @arg_label varchar(255) = null, @arg_comment varchar(255) = null, @is_needed tinyint = 1, @default_value varchar(255) = NULL, @choose_type_id_s varchar(30) = NULL, @choose_action_code varchar(60) = NULL, @choose_field_name varchar(30) = NULL as declare @id numeric, @pat_id numeric declare @choose_type_id numeric begin transaction if (@arg_id is null) begin rollback transaction raiserror 40000 'не задан номер для t_patternargs' return end if (@action = 1) begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patternargs' return end select @pat_id = convert(numeric, @pat_id_s) if (@pat_id is null) begin rollback transaction raiserror 40000 'не задан шаблон ' return end if (upper(@choose_type_id_s) != 'NULL' ) and (@choose_type_id_s != null ) select @choose_type_id = convert(numeric, @choose_type_id_s) else select @choose_type_id = NULL insert into t_patternargs ( id, pat_id, arg_id, arg_name, arg_label, arg_comment, is_needed, default_value, choose_type_id, choose_action_code, choose_field_name ) values ( @id, @pat_id, @arg_id, @arg_name, @arg_label, @arg_comment, @is_needed, @default_value, @choose_type_id, @choose_action_code, @choose_field_name ) select @sid=convert(varchar,@id) select @sid end if (@action = 2) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patternargs' return end if (upper(@choose_type_id_s) != 'NULL') and (@choose_type_id_s != NULL) select @choose_type_id = convert(numeric, @choose_type_id_s) else select @choose_type_id = NULL update t_patternargs set arg_id = @arg_id, arg_name = @arg_name, arg_label = @arg_label, arg_comment = @arg_comment, is_needed = @is_needed, default_value = @default_value, choose_type_id = @choose_type_id, choose_action_code = @choose_action_code, choose_field_name = @choose_field_name where id = @id end if (@action = 3) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patternargs' return end delete t_patternargs where id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_patternargs' return end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(PATTERNS_EDIT) name=Изменение шаблонов class=2 form=UO_PATTERNS_EDIT target_state=null procedure=apt_patterns_any patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action integer = 0, @sid varchar(255) = null, @pat_name varchar(255) = null, @class_id tinyint = null, @pat_comment varchar(255) = null, @product_id_s varchar(30) as declare @id numeric declare @arg_name varchar(100),@arg_label varchar(100), @arg_labels_str varchar(255),@arg_str varchar(255), @product_id numeric select @product_id = convert(numeric,@product_id_s) declare per_cur cursor for select arg_name,arg_label from t_patternargs o where o.pat_id = @id order by arg_id begin transaction if (@action = 1) begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patterns' return end insert into t_patterns ( id, pat_name, class_id, pat_comment, product_id ) values ( @id, @pat_name, @class_id, @pat_comment, @product_id ) select @sid=convert(varchar,@id) select @sid end if (@action = 2) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patterns' return end /*------------*/ select @arg_labels_str = '' select @arg_str = '' open per_cur fetch per_cur into @arg_name ,@arg_label while .CURSOR_STATE=0 begin if @arg_labels_str != '' select @arg_labels_str = @arg_labels_str +',' if @arg_str != '' select @arg_str = @arg_str +',' select @arg_labels_str = @arg_labels_str + @arg_label select @arg_str = @arg_str + @arg_name fetch per_cur into @arg_name ,@arg_label end close per_cur .DEALLOCATE per_cur /* -----------*/ update t_patterns set pat_name = @pat_name, class_id = @class_id, arg_labels_str = @arg_labels_str, arg_str = @arg_str, pat_comment = @pat_comment, product_id = @product_id where id = @id end if (@action = 3) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_patterns' return end delete t_patterns where id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_patterns' return end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(STATESLIST_EDIT) name=Изменение названий статусов документов class=2 form=UO_STATESLIST_LIST target_state=null procedure=apt_states_list_any patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @action integer = 0, @sid varchar(255) = null, @state_name varchar(255) = null as declare @id numeric begin transaction if (@action = 1) begin execute ap_getid @id out if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_states_list' return end insert into t_states_list ( id, state_name ) values ( @id, @state_name ) select @sid=convert(varchar,@id) select @sid end if (@action = 2) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_states_list' return end update t_states_list set state_name = @state_name where id = @id end if (@action = 3) begin select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_states_list' return end delete t_states_list where id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_states_list' return end commit transaction $ENDTEXT(19031660) $ENDACTION $ACTION(UPDATE_LIC_ACCOUNTS) name=Обновление лицевых счетов class=2 form=null target_state=null procedure=ap_update_lic_accounts_subc_ef patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% as begin declare @plan_id numeric, @lic_acc_id numeric, @partner_id numeric, @op_date datetime, @partner2plan_id numeric, @acc_id numeric, @branch_id numeric, @subc_eff_num varchar(255), @subconto_type_id numeric, @item_id numeric, @field_no_i numeric, @s1 numeric, @s2 numeric, @s3 numeric, @s4 numeric, @s5 numeric, @s6 numeric, @s7 numeric, @s8 numeric, @s9 numeric, @s10 numeric, @s11 numeric, @s12 numeric, @s13 numeric, @s14 numeric, @s15 numeric, @acc_cur_id numeric, @acc_mode numeric, @acc_or_pass numeric .NAME_VAR(@lic_acc_no) .NAME_VAR(@lic_acc_no_ext) .NAME_VAR(@lic_acc_name) .NAME_VAR(@lic_acc_name_ext) declare @s_acc_cur_id numeric, @is_test_saldo numeric, @is_last numeric, @is_qty numeric, @type4cur_id numeric, @subc_type_set4lic_id numeric, @acc_num varchar(255), @acc_name varchar(255), @subc_eff_name varchar(255), @oper_list_id numeric, @lic_acc_set_type_id numeric declare list_oper cursor for select t_oper_list.op_date,t_oper_list.branch_id,t_oper_list.acc_id, t_oper_list.subc_eff_num,t_oper_list.lic_acc_id,t_oper_list.partner2plan_id,t_oper_list.acc_cur_id,t_oper_list.subc_eff_name, id from t_oper_list where t_oper_list.lic_acc_id is null order by t_oper_list.op_date /*union all select last_date,branch_id,acc_id,subc_eff_num,lic_acc_id,plan2partner_id,acc_cur_id,'1',id from t_account_now where lic_acc_id is null*/ /*union all select t_periods.period_date,t_account_history.branch_id,t_account_history.acc_id, t_account_history.subc_eff_num,t_account_history.lic_acc_id, t_periods.partner2plan_id,t_account_history.acc_cur_id,'1',t_account_history.id from t_account_history,t_periods where t_account_history.lic_acc_id is null and t_periods.id=t_account_history.period_id*/ for read only OPEN list_oper FETCH list_oper into @op_date,@branch_id,@acc_id, @subc_eff_num,@lic_acc_id,@partner2plan_id,@acc_cur_id,@subc_eff_name,@oper_list_id WHILE (@@fetch_status=0) begin select @plan_id=plan_id,@partner_id=partner_id ,@lic_acc_set_type_id = lic_acc_set_type_id from t_plans2partner where id=@partner2plan_id select @s1=null select @s2=null select @s3=null select @s4=null select @s5=null select @s6=null select @s7=null select @s8=null select @s9=null select @s10=null select @s11=null select @s12=null select @s13=null select @s14=null select @s15=null .FOR_SUBC_STR(@subc_eff_num,@subconto_type_id,@item_id) select @field_no_i=field_no_i from t_plan2subc where plan_id=@plan_id and subconto_type_id=@subconto_type_id if (@field_no_i=1) select @s1=@item_id if (@field_no_i=2) select @s2=@item_id if (@field_no_i=3) select @s3=@item_id if (@field_no_i=4) select @s4=@item_id if (@field_no_i=5) select @s5=@item_id if (@field_no_i=6) select @s6=@item_id if (@field_no_i=7) select @s7=@item_id if (@field_no_i=8) select @s8=@item_id if (@field_no_i=9) select @s9=@item_id if (@field_no_i=10) select @s10=@item_id if (@field_no_i=11) select @s11=@item_id if (@field_no_i=12) select @s12=@item_id if (@field_no_i=13) select @s13=@item_id if (@field_no_i=14) select @s14=@item_id if (@field_no_i=15) select @s15=@item_id .NEXT_SUBC_STR /*if @subc_eff_name='1' begin exec ap_subc_eff_name_from_no @subc_eff_name out, @subc_eff_num,0 end*/ select @lic_acc_id = (select min(l.id) from t_lic_accounts l where l.sint_acc_id = @acc_id -- Счет 2-го порядка and l.cur_id = @acc_cur_id -- Валюта and l.branch_id = @branch_id -- Бранч and l.subc_eff_num = @subc_eff_num and @op_date >= .DATE_NORM(l.open_date,'B') and .ITEMS_EXISTS_BY_TYPE_STATE(l.id,'LIC_ACCOUNTS','OPEN') ) if @lic_acc_id is null -- Не найден -> Создание нового begin if @acc_mode = 1 select @acc_or_pass = 1 else select @acc_or_pass = -1 select @s_acc_cur_id = t_accounts.cur_id, @is_test_saldo = is_test_saldo, @is_last = is_last, @is_qty = is_qty, @type4cur_id = type4cur_id, @subc_type_set4lic_id = subc_type_set4lic_id, @acc_mode=acc_type_id, @acc_num = acc_num_eff, @acc_name = acc_name from t_accounts where t_accounts.id = @acc_id .TYPE_INIT('LIC_ACCOUNTS') .TYPE_ASSIGN(open_date,@op_date) .TYPE_ASSIGN(acc_or_pass,@acc_or_pass) .TYPE_ASSIGN(cur_id,@acc_cur_id) .TYPE_ASSIGN(branch_id,@branch_id) .TYPE_ASSIGN(plan_id,@plan_id) .TYPE_ASSIGN(owner_id,@partner_id) .TYPE_ASSIGN(sint_acc_id,@acc_id) .TYPE_ASSIGN(subc_eff_num,@subc_eff_num) .TYPE_ASSIGN(subc_eff_name,@subc_eff_name) .TYPE_ASSIGN(lic_acc_type_id,1) -- Пока не понятно как формировать *п лиц счета. Ставим 1 -- Номера и наименования лицевого счета рассчитывается здесь declare @lic_acc_num_type_id numeric declare @f_lic_acc_num_type_id numeric select @lic_acc_num_type_id = t_subc_type_sets.lic_acc_num_type_id, @f_lic_acc_num_type_id = t_subc_type_sets.f_lic_acc_num_type_id from t_accounts, t_subc_type_sets where t_accounts.subc_type_set4lic_id=t_subc_type_sets.id and t_accounts.id=@acc_id ---select @lic_acc_no = @acc_num + '' -- !!! ---select @lic_acc_no_ext = '' -- Это номер для MIDAS ---select @lic_acc_name = @acc_num + ':'+ @acc_name +':'+ @subc_eff_name ---select @lic_acc_name_ext = @lic_acc_name -- Это наименование для MIDAS declare @step_num integer declare @serial_no numeric -- шаг нумерации, по умолчанию 1 -- нумеруем с шагом нумерации по каждому счету второго порядка -- select @step_num = isnull((select step_of_serial_no from t_lic_section_type where id = @f_lic_acc_num_type_id),1) select @step_num = isnull((select step_of_serial_no from t_lic_acc_num_type where id = @f_lic_acc_num_type_id),1) select @serial_no = isnull((select max(serial_no_i) from t_lic_accounts where sint_acc_id = @acc_id),0)+@step_num .TYPE_ASSIGN(serial_no_i,@serial_no) if (@lic_acc_set_type_id = 1) begin exec ap_lic_acc_num_type @id = @f_lic_acc_num_type_id, @acc_id = @acc_id, @branch_id = @branch_id, @op_date = @op_date, @oper_list_id = @oper_list_id, @acc_num = @acc_num, @acc_cur_id = @acc_cur_id, @serial_no = @serial_no, @lic_acc_no = @lic_acc_no_ext out, @lic_acc_name = @lic_acc_name_ext out exec ap_lic_acc_num_type @id = @lic_acc_num_type_id, @acc_id = @acc_id, @branch_id = @branch_id, @op_date = @op_date, @oper_list_id = @oper_list_id, @acc_num = @acc_num, @acc_cur_id = @acc_cur_id, @serial_no = @serial_no, @lic_acc_no = @lic_acc_no out, @lic_acc_name = @lic_acc_name out end else begin select @lic_acc_no=@acc_num select @lic_acc_name=@acc_name end if @lic_acc_no is null select @lic_acc_no = @acc_num + '' -- !!! ---select @lic_acc_no_ext = '' -- Это номер для MIDAS ---select @lic_acc_name = @acc_num + ':'+ @acc_name +':'+ @subc_eff_name ---select @lic_acc_name_ext = @lic_acc_name -- Это наименование для MIDAS ------- Разобраться с кешированием и убиранием t_items ----------- .TYPE_ASSIGN(lic_acc_no,@lic_acc_no) .TYPE_ASSIGN(lic_acc_no_ext,@lic_acc_no_ext) .TYPE_ASSIGN(lic_acc_name,@lic_acc_name) .TYPE_ASSIGN(lic_acc_name_ext,@lic_acc_name_ext) .TYPE_ASSIGN(s1,@s1) .TYPE_ASSIGN(s2,@s2) .TYPE_ASSIGN(s3,@s3) .TYPE_ASSIGN(s4,@s4) .TYPE_ASSIGN(s5,@s5) .TYPE_ASSIGN(s6,@s6) .TYPE_ASSIGN(s7,@s7) .TYPE_ASSIGN(s8,@s8) .TYPE_ASSIGN(s9,@s9) .TYPE_ASSIGN(s10,@s10) .TYPE_ASSIGN(s11,@s11) .TYPE_ASSIGN(s12,@s12) .TYPE_ASSIGN(s13,@s13) .TYPE_ASSIGN(s14,@s14) .TYPE_ASSIGN(s15,@s15) .TYPE_INSERT('LIC_ACCOUNTS','OPEN') select @lic_acc_id = .TYPE_FIELD(id) insert t_acc_lic2subc(lic_acc_id,subconto_type_id,item_id) select @lic_acc_id,subconto_type_id,item_id from t_oper_subconto where id = @oper_list_id end update t_oper_list set lic_acc_id=@lic_acc_id where id=@oper_list_id update t_account_now set lic_acc_id=@lic_acc_id where id=@oper_list_id update t_account_history set lic_acc_id=@lic_acc_id where id=@oper_list_id FETCH list_oper into @op_date,@branch_id,@acc_id, @subc_eff_num,@lic_acc_id,@partner2plan_id,@acc_cur_id,@subc_eff_name,@oper_list_id end close list_oper .DEALLOCATE list_oper end $ENDTEXT(19031660) $ENDACTION $ACTION(AP_ACCOUNT_NOW) name=Расчет текущих остатков по всем планам счетов class=2 form=ap_account_now_date target_state=null procedure=ap_account_now patterns=GENERIC_MOVE user_define=1 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031660) create procedure dbo.%PROC% @sid varchar(30) = null, @last_date_d varchar(30) = null as begin .TRANSACTION_SAVE declare @plan_id numeric, @partner_id numeric, @plan2partner_id numeric, @last_date datetime, @acc_id numeric, @subc_eff_num varchar(255), @acc_cur_id numeric, @branch_id numeric, @lic_acc_id numeric, @saldo_db money, @ac_saldo_db money, @q_saldo_db money, @saldo_cb money, @ac_saldo_cb money, @q_saldo_cb money, @d_id numeric, @c_id numeric, @subconto_type_id numeric, @item_id numeric, @saldo_r money, @ac_saldo_r money, @q_saldo_r money, @acc_mode int, @deb_or_cred_sign int, @subc_eff_name varchar(255) select @last_date = convert(datetime,@last_date_d,3) ---select @last_date = convert(datetime,'01/01/04',3) if @last_date is null select @last_date = convert(datetime,convert(varchar(8),getdate(),3),3) .DATE_VAR(@max_op_date) if exists (select 1 from t_operations where op_date > @last_date) begin select @max_op_date = max(op_date) from t_operations where op_date > @last_date .EXIT_MESSAGE_PARM('Есть проводки с датой позже пересчета',@max_op_date) end select @last_date_d = convert(varchar,@last_date) truncate table t_account_now truncate table t_accnow_subconto declare plan2partner_cur cursor for select t_plans2partner.id, t_plans2partner.plan_id, t_plans2partner.partner_id from t_plans2partner, t_items, t_states where t_plans2partner.id=t_items.id and t_states.id=t_items.state_id and t_states.class_id=0 open plan2partner_cur fetch plan2partner_cur into @plan2partner_id, @plan_id, @partner_id while .CURSOR_STATE=0 begin .TOTALS_QUERY(@partner_id,@plan_id,@last_date,N,ALL,N,L,N,Y,D,P,Y,S, N,N,N,L,N,Y,N,N,Y,N,N,Y,N,N) .BEG_SUBC_STR declare rep_cur cursor for select acc_id, subc_eff_num,subc_eff_name, acc_cur_id, branch_id, lic_acc_id, saldo_db, ac_saldo_db, q_saldo_db, saldo_cb, ac_saldo_cb, q_saldo_cb,t_accounts.acc_type_id from #tmp_osv,t_accounts where #tmp_osv.acc_id = t_accounts.id open rep_cur fetch rep_cur into @acc_id, @subc_eff_num,@subc_eff_name, @acc_cur_id, @branch_id, @lic_acc_id, @saldo_db, @ac_saldo_db, @q_saldo_db, @saldo_cb, @ac_saldo_cb, @q_saldo_cb, @acc_mode while .CURSOR_STATE =0 begin /* .GET_ID(@c_id)*/ select @saldo_r = isnull(@saldo_db,0) - isnull(@saldo_cb,0) select @ac_saldo_r = isnull(@ac_saldo_db,0) - isnull(@ac_saldo_cb,0) select @q_saldo_r = isnull(@q_saldo_db,0) - isnull(@q_saldo_cb,0) if not(@saldo_r=0 and @ac_saldo_r=0 and @q_saldo_r=0) begin -- Если счет активный (1) или активно-пассивный (3, 4), то будем заводить дебетовую запись, а если пассивный (2) - то кредитовую select @deb_or_cred_sign = case when @acc_mode in (1, 3, 4) then 1 when @acc_mode = 2 then -1 end if @deb_or_cred_sign = -1 begin select @saldo_r = @saldo_r * @deb_or_cred_sign select @ac_saldo_r = @ac_saldo_r * @deb_or_cred_sign select @q_saldo_r = @q_saldo_r * @deb_or_cred_sign end .GET_ID(@d_id) /*exec ap_create_lic_acc @d_id ,@plan_id ,@acc_id,@subc_eff_num , @acc_cur_id ,@branch_id,@op_date,@partner_id, @subc_eff_name,@acc_num,@acc_name,@acc_mode, @op_comment, @lic_acc_id out, @result out, @res_str out ---- if (@result!=0) return*/ -----===== END Привязка к лицевым по дебету insert t_account_now(id, plan2partner_id, last_date, acc_id, subc_eff_num, deb_or_cred, acc_cur_id, branch_id, lic_acc_id, saldo, saldo_accur, saldo_qty) values(@d_id, @plan2partner_id, @last_date, @acc_id, @subc_eff_num, @deb_or_cred_sign, @acc_cur_id, @branch_id, @lic_acc_id, @saldo_r, @ac_saldo_r, @q_saldo_r) end /* if not(@saldo_cb=0 and @ac_saldo_cb=0 and @q_saldo_cb=0) insert t_account_now(id, plan2partner_id, last_date, acc_id, subc_eff_num, deb_or_cred, acc_cur_id, branch_id, lic_acc_id, saldo, saldo_accur, saldo_qty) values(@c_id, @plan2partner_id, @last_date, @acc_id, @subc_eff_num, -1, @acc_cur_id, @branch_id, @lic_acc_id, @saldo_cb, @ac_saldo_cb, @q_saldo_cb) */ -- #define PRINT_DEBUG_INFO if @subc_eff_num is not null begin /* .DEBUG_INFO('@acc_id',@acc_id) .DEBUG_INFO('@subc_eff_num',@subc_eff_num) */ .FOR_SUBC_STR(@subc_eff_num,@subconto_type_id,@item_id) /* .DEBUG_INFO('@subconto_type_id',@subconto_type_id) .DEBUG_INFO('@item_id',@item_id) */ if not(@saldo_r=0 and @ac_saldo_r=0 and @q_saldo_r=0) insert t_accnow_subconto(id, subconto_type_id, item_id) values(@d_id, @subconto_type_id, @item_id) /* if not(@saldo_cb=0 and @ac_saldo_cb=0 and @q_saldo_cb=0) insert t_accnow_subconto(id, subconto_type_id, item_id) values(@c_id,@subconto_type_id,@item_id) */ .NEXT_SUBC_STR end fetch rep_cur into @acc_id, @subc_eff_num,@subc_eff_name, @acc_cur_id, @branch_id, @lic_acc_id, @saldo_db, @ac_saldo_db, @q_saldo_db, @saldo_cb, @ac_saldo_cb, @q_saldo_cb, @acc_mode end close rep_cur .DEALLOCATE rep_cur fetch plan2partner_cur into @plan2partner_id, @plan_id, @partner_id end close plan2partner_cur .DEALLOCATE plan2partner_cur .TRANSACTION_RESTORE end $ENDTEXT(19031660) $ENDACTION $STATE2ACTION(SYSTEM.ACTION_FROM_CODE) state=SYSTEM action=ACTION_FROM_CODE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_MOVE) state=SYSTEM action=ACTION_MOVE is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_MOVE1) state=SYSTEM action=ACTION_MOVE1 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_MOVE2) state=SYSTEM action=ACTION_MOVE2 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_MOVE3) state=SYSTEM action=ACTION_MOVE3 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_MOVE4) state=SYSTEM action=ACTION_MOVE4 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_MOVE5) state=SYSTEM action=ACTION_MOVE5 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_ACTIONS_ANY) state=SYSTEM action=APT_ACTIONS_ANY is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_ACTIONS_BYCLASS) state=SYSTEM action=APT_ACTIONS_BYCLASS is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_ACTIONS_INS_TYPE) state=SYSTEM action=APT_ACTIONS_INS_TYPE is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_FILTER2ACTION_COPY) state=SYSTEM action=APT_FILTER2ACTION_COPY is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_RELATIONS_INS_TYPE) state=SYSTEM action=APT_RELATIONS_INS_TYPE is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_SEGMENTS_ANY) state=SYSTEM action=APT_SEGMENTS_ANY is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_STATES_INS_TYPE) state=SYSTEM action=APT_STATES_INS_TYPE is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.APT_TEXTS_ANY) state=SYSTEM action=APT_TEXTS_ANY is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_GET_ACTION_PROC) state=SYSTEM action=AP_GET_ACTION_PROC is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_MES_RAISE) state=SYSTEM action=AP_MES_RAISE is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_PROP2ACTION) state=SYSTEM action=AP_PROP2ACTION is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_PROP2ACTION2REL) state=SYSTEM action=AP_PROP2ACTION2REL is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_SETSIZE2ACTION) state=SYSTEM action=AP_SETSIZE2ACTION is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_STATE_NAME2USER) state=SYSTEM action=AP_STATE_NAME2USER is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_TRANCOUNT) state=SYSTEM action=AP_TRANCOUNT is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_TYPE2PARM_REPORT) state=SYSTEM action=AP_TYPE2PARM_REPORT is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.CREATERTL) state=SYSTEM action=CREATERTL is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.D_PLAN2PARTNER_REPORT2ANAL_F) state=SYSTEM action=D_PLAN2PARTNER_REPORT2ANAL_F is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.D_PLAN2PARTNER_REPORT2ANAL_L) state=SYSTEM action=D_PLAN2PARTNER_REPORT2ANAL_L is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM2) state=SYSTEM action=FORM2 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM3) state=SYSTEM action=FORM3 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM4) state=SYSTEM action=FORM4 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM5) state=SYSTEM action=FORM5 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM6) state=SYSTEM action=FORM6 is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.GETPATTERN) state=SYSTEM action=GETPATTERN is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.IS_IN_FOLDER) state=SYSTEM action=IS_IN_FOLDER is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.PATTERNARGS_COPY) state=SYSTEM action=PATTERNARGS_COPY is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.PATTERNARGS_DELALL) state=SYSTEM action=PATTERNARGS_DELALL is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.PATTERNARGS_EDIT) state=SYSTEM action=PATTERNARGS_EDIT is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.PATTERNS_EDIT) state=SYSTEM action=PATTERNS_EDIT is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.STATESLIST_EDIT) state=SYSTEM action=STATESLIST_EDIT is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.TYPE_FROM_CODE) state=SYSTEM action=TYPE_FROM_CODE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_ACTIONS_GEN_LIST) state=SYSTEM action=UO_ACTIONS_GEN_LIST is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_MENU_TREE) state=SYSTEM action=UO_MENU_TREE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_PATTERNARGS_EDIT) state=SYSTEM action=UO_PATTERNARGS_EDIT is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_PATTERNS_EDIT) state=SYSTEM action=UO_PATTERNS_EDIT is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_PATTERNS_LIST) state=SYSTEM action=UO_PATTERNS_LIST is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_ROLES_LIST) state=SYSTEM action=UO_ROLES_LIST is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_SCRIPTMAKE) state=SYSTEM action=UO_SCRIPTMAKE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_STATESLIST_LIST) state=SYSTEM action=UO_STATESLIST_LIST is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_TABLE_FIELDS_LIST) state=SYSTEM action=UO_TABLE_FIELDS_LIST is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_TABLE_LIST) state=SYSTEM action=UO_TABLE_LIST is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UPDATE_LIC_ACCOUNTS) state=SYSTEM action=UPDATE_LIC_ACCOUNTS is_available=0 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_ACCOUNT_NOW) state=SYSTEM action=AP_ACCOUNT_NOW is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.AP_ACCOUNT_NOW_DATE) state=SYSTEM action=AP_ACCOUNT_NOW_DATE is_available=0 $ENDSTATE2ACTION $ENDDOC $DOC(ACTIONS) name=Метод типа документа class=1 product=ALD_SQL name_formula=null remark_formula=null $STATE(SYSTEM) name=Системный статус class=1 $ENDSTATE $PROP(TYPE_ID) name=тип field_name=type_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=1 init_class=0 init_formula=null unique_index=1 numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(ACTION_CODE) name=шифр field_name=action_code table_name=t_actions field_type=varchar field_length=30 field_scale=null field_prec=30 page=0 order=2 init_class=0 init_formula=null unique_index=1 numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(ACTION_NAME) name=название field_name=action_name table_name=t_actions field_type=varchar field_length=60 field_scale=null field_prec=60 page=0 order=3 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(CLASS_ID) name=класс field_name=class_id table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=4 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(NACTION_ID) name=невизульный метод field_name=naction_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=5 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(VACTION_ID) name=визуальный метод field_name=vaction_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=6 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(FACTION_ID) name=метод фильтра field_name=faction_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=7 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(UO_NAME) name=user object field_name=uo_name table_name=t_actions field_type=varchar field_length=30 field_scale=null field_prec=30 page=0 order=8 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DW_NAME) name=dw field_name=dw_name table_name=t_actions field_type=varchar field_length=30 field_scale=null field_prec=30 page=0 order=9 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PROC_NAME) name=процедура field_name=proc_name table_name=t_actions field_type=varchar field_length=30 field_scale=null field_prec=30 page=0 order=10 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(STATE_ID) name=состояние документа field_name=state_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=11 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PAT_ID) name=код шаблона field_name=pat_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=0 order=12 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(USER_DEFINE) name=шаблон изменен field_name=user_define table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=13 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(ISVISIBLE) name=видимость метода field_name=isvisible table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=14 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(EXTERNAL_NAME) name=Наименование внешнего источника field_name=external_name table_name=t_actions field_type=varchar field_length=255 field_scale=null field_prec=255 page=0 order=15 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(EXTERNAL_ADD_NAME) name=Дополнительн данные по вн источнику field_name=external_add_name table_name=t_actions field_type=varchar field_length=255 field_scale=null field_prec=255 page=0 order=16 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(X) name=x field_name=x table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=17 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(Y) name=y field_name=y table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=18 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(WIDTH) name=width field_name=width table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=19 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(HEIGHT) name=height field_name=height table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=20 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(IS_TAB) name=В Таб field_name=is_tab table_name=t_actions field_type=int field_length=4 field_scale=0 field_prec=10 page=0 order=21 init_class=0 init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(DW_LIB_0) name=Библиотека datawindow field_name=dw_lib table_name=t_actions field_type=varchar field_length=255 field_scale=null field_prec=255 page=0 order=23 init_class=null init_formula=null unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $PROP(PRODUCT_ID_-1) name=Продукт field_name=product_id table_name=t_actions field_type=numeric field_length=9 field_scale=0 field_prec=18 page=-1 order=22 init_class=0 init_formula=$TEXT(19031664) ( select t.product_id from t_types t, t_actions a where t.id = a.type_id and a.id = @id ) $ENDTEXT(19031664) unique_index=null numerator=null import_type=null import_table=null import_field=null import_where=null ref_table=null ref_key=null ref_display=null ref_alias=null ref_where=null $ENDPROP $RELATION(REL5) class=0 type=TYPES form=null prop=TYPE_ID idname=null order=5 $ENDRELATION $RELATION(REL12) class=0 type=ACTIONS form=null prop=NACTION_ID idname=null order=12 $ENDRELATION $RELATION(REL6) class=0 type=ACTIONS form=null prop=VACTION_ID idname=null order=6 $ENDRELATION $RELATION(REL7) class=0 type=ACTIONS form=null prop=FACTION_ID idname=null order=7 $ENDRELATION $RELATION(REL2) class=1 type=ACTIONS form=ACTION4 prop=null idname=null order=10 $ENDRELATION $RELATION(REL8) class=0 type=STATES form=null prop=STATE_ID idname=null order=8 $ENDRELATION $RELATION(REL1) class=1 type=STATE2ACTION form=ACTION2 prop=null idname=action_id_s order=50 $ENDRELATION $RELATION(REL9) class=1 type=ACTION2RELATION form=D_RELATION2ACTION_LIST prop=null idname=action_id_s order=70 $ENDRELATION $RELATION(REL3) class=1 type=BINDS form=D_BINDS_LIST prop=null idname=s_action_id_s order=40 $ENDRELATION $RELATION(REL10) class=1 type=FILTER2ACTION form=D_FILTER2ACTION_LIST prop=null idname=action_id_s order=80 $ENDRELATION $RELATION(REL13) class=1 type=CALCPROP form=FORM1 prop=null idname=action_id_s order=90 $ENDRELATION $RELATION(PRODUCT) class=0 type=ALADDIN_PRODUCT form=null prop=PRODUCT_ID_-1 idname=null order=0 $ENDRELATION $RELATION(REL11) class=0 type=PATTERN form=null prop=PAT_ID idname=null order=0 $ENDRELATION $FORM(ACTIONS_DESC) name=# Описание метода class=5 filter=null target_state= uo=null dw=null procedure=apt_actions_desc patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.%PROC% -- @sid varchar(30) = null @type_code varchar(30) = null, @action_code varchar(30) = null as declare @id numeric --select @id = convert(numeric,@sid) select @id = (select t_actions.id from t_actions, t_types where t_actions.type_id=t_types.id and upper(action_code)=upper(@action_code) and upper(type_code)=upper(@type_code)) if @id is null return select convert(varchar, @id) as sid, proc_name, (select dw_name from t_actions forms where forms.id=actions.vaction_id) dw_name from t_actions actions where actions.id=@id $ENDTEXT(19031665) $ENDFORM $FORM(ACTIONS_LOAD) name=# Список допусков class=4 filter=null target_state= uo=null dw=null procedure=ap_actions_load patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.%PROC% as begin create table #report ( name varchar(255) null, vaction_id numeric null, vaction_code varchar(60) null, vclass_id int null, vuo_name varchar(30) null, vdw_name varchar(30) null, vproc_name varchar(30) null, vx int null, vy int null, vwidth int null, vheight int null, naction_id numeric null, nclass_id int null, nuo_name varchar(30) null, ndw_name varchar(30) null, nproc_name varchar(30) null, type_id numeric null, state_id numeric null, is_tab tinyint null, rel_type_id numeric null ) -- -- Допуска -- -- -- Невизуальные методы -- insert #report ( name, naction_id, nclass_id, nuo_name, ndw_name, nproc_name, vaction_id, type_id, state_id, is_tab, vx, vy, vwidth, vheight ) select t_actions.action_name, t_actions.id, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.vaction_id, t_actions.type_id, t_state2action2user.state_id, t_actions.is_tab, t_actions.x, t_actions.y, t_actions.width, t_actions.height from t_actions, t_state2action2user where t_actions.isvisible=0 and t_actions.class_id in (1,2,3,9) and t_state2action2user.action_id=t_actions.id and t_state2action2user.suser_name=.SUSER_NAME -- -- Визуальные к невизуальным -- update #report set vaction_code = t_actions.action_code, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name from t_actions where t_actions.id = #report.vaction_id -- -- Просмотры -- insert #report ( name, vaction_id, vaction_code, vclass_id, vuo_name, vdw_name, vproc_name, vx, vy, vwidth, vheight, type_id, state_id, is_tab ) select t_actions.action_name, t_actions.id, t_actions.action_code, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.x, t_actions.y, t_actions.width, t_actions.height, t_actions.type_id, t_state2action2user.state_id, t_actions.is_tab from t_actions, t_state2action2user where t_actions.isvisible=0 and t_actions.class_id=5 and t_state2action2user.action_id=t_actions.id and t_state2action2user.suser_name=.SUSER_NAME update #report set name = name + ' ' + (select type_name from t_types where t_types.id=#report.type_id) where #report.nclass_id=1 select #report.name, vaction_sid = convert(varchar, #report.vaction_id), #report.vaction_code, #report.vclass_id, #report.vuo_name, #report.vdw_name, #report.vproc_name, #report.vx, #report.vy, #report.vwidth, #report.vheight, naction_sid = convert(varchar, #report.naction_id), #report.nclass_id, #report.nuo_name, #report.ndw_name, #report.nproc_name, convert(varchar, #report.type_id) as type_sid, convert(varchar, #report.state_id) as state_sid, #report.is_tab from #report order by nclass_id, vclass_id , #report.name -- -- Связи -- select convert(varchar, t_relation.s_type_id) as s_type_sid, convert(varchar, t_relation.t_type_id) as t_type_sid from t_relation where t_relation.class_id in (5) order by t_relation.s_type_id,t_relation.rel_order -- -- Вхождение в меню -- truncate table #report -- -- Невизуальные методы -- insert #report ( name, naction_id, nclass_id, nuo_name, ndw_name, nproc_name, vaction_id, type_id, state_id, is_tab, vx, vy, vwidth, vheight, rel_type_id ) select t_actions.action_name, t_actions.id, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.vaction_id, t_actions.type_id, t_state2action2user.state_id, t_actions.is_tab, t_actions.x, t_actions.y, t_actions.width, t_actions.height, t_relation.s_type_id from t_actions, t_state2action2user, t_relation where t_relation.class_id = 6 and t_relation.action_id=t_actions.id and t_actions.isvisible=0 and t_actions.class_id in (1,2,3,9) and t_state2action2user.action_id=t_actions.id and t_state2action2user.suser_name=.SUSER_NAME -- -- Визуальные к невизуальным -- update #report set vaction_code = t_actions.action_code, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name from t_actions where t_actions.id = #report.vaction_id -- -- Просмотры -- insert #report ( name, vaction_id, vaction_code, vclass_id, vuo_name, vdw_name, vproc_name, vx, vy, vwidth, vheight, type_id, state_id, is_tab, rel_type_id ) select t_actions.action_name, t_actions.id, t_actions.action_code, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.x, t_actions.y, t_actions.width, t_actions.height, t_actions.type_id, t_state2action2user.state_id, t_actions.is_tab, t_relation.s_type_id from t_actions, t_state2action2user, t_relation where t_relation.class_id=6 and t_relation.action_id=t_actions.id and t_actions.isvisible=0 and t_actions.class_id in (4,5) and t_state2action2user.action_id=t_actions.id and t_state2action2user.suser_name=.SUSER_NAME update #report set name = name + ' ' + (select type_name from t_types where t_types.id=#report.type_id) where #report.nclass_id=1 select #report.name, vaction_sid = convert(varchar, #report.vaction_id), #report.vaction_code, #report.vclass_id, #report.vuo_name, #report.vdw_name, #report.vproc_name, #report.vx, #report.vy, #report.vwidth, #report.vheight, naction_sid = convert(varchar, #report.naction_id), #report.nclass_id, #report.nuo_name, #report.ndw_name, #report.nproc_name, convert(varchar, #report.type_id) as type_sid, convert(varchar, #report.state_id) as state_sid, #report.is_tab, convert(varchar,#report.rel_type_id) as rel_type_sid from #report order by nclass_id, vclass_id , #report.name /* select t_actions.action_name, convert(varchar, t_actions.id) as vaction_sid, t_actions.action_code as vaction_code, t_actions.class_id as class_id, t_actions.uo_name as vuo_name, t_actions.dw_name as vdw_name, t_actions.proc_name as vproc_name, t_actions.x as vx, t_actions.y as vy, t_actions.width vwidth, t_actions.height as vheight, convert(varchar, t_actions.type_id) as type_sid, convert(varchar, t_state2action2user.state_id) as state_sid, t_actions.is_tab, t_relation.s_type_id as rel_type_id from t_relation, t_state2action2user, t_actions where t_relation.class_id = 6 and t_relation.action_id = t_actions.id and t_actions.class_id in (4, 5) and t_relation.action_id = t_state2action2user.action_id and t_state2action2user.suser_name=.SUSER_NAME and exists(select 1 from t_types, t_aladdin_products where t_types.id=t_relation.t_type_id and t_aladdin_products.id=t_types.product_id and t_aladdin_products.is_actual=1) */ drop table #report end $ENDTEXT(19031665) $ENDFORM $FORM(FORM2) name=Просмотр class=5 filter=null target_state= uo=uo_actions_edit dw=d_actions_edit procedure=apt_actions_item patterns=null user_define=0 isvisible=1 istab=1 posx=0 posy=0 width=2793 height=1840 proc_text=$TEXT(19031665) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @type_id_s varchar(30), @new_state_id numeric, @state_name_id_s varchar(30) begin select @id = convert(numeric, @sid) select @action_id = %ACTION_ID% select @type_id_s = NULL select @state_name_id_s = NULL .CHECK_USER select sid = convert(varchar, t_actions.id), item_name = t_actions.action_name, t_actions.action_name, t_actions.action_code, t_actions.class_id, vaction_sid = convert(varchar, t_actions.vaction_id), vaction_name = (select action_name from t_actions t1 where t1.id = t_actions.vaction_id), naction_sid = convert(varchar, t_actions.naction_id), naction_name = (select action_name from t_actions t1 where t1.id = t_actions.naction_id), faction_sid = convert(varchar, t_actions.faction_id), faction_name = (select action_name from t_actions t1 where t1.id = t_actions.faction_id), type_sid = convert(varchar, t_actions.type_id), state_sid = convert(varchar, t_actions.state_id), state_name = (select state_name from t_states where t_states.id = t_actions.state_id), t_actions.isvisible, t_actions.is_tab from t_actions where t_actions.id = @id end $ENDTEXT(19031665) $ENDFORM $FORM(FORM3) name=Редактор процедур class=5 filter=null target_state= uo=uo_actionpat_edit dw=d_actionpat_edit procedure=apt_actionpat_view patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.%PROC% @sid varchar(30) = null as declare @id numeric, @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @type_id_s varchar(30), @new_state_id numeric, @state_name_id_s varchar(30) begin select @id = convert(numeric, @sid) select @action_id = %ACTION_ID% select @type_id_s = NULL select @state_name_id_s = NULL .CHECK_USER select sid = convert(varchar, t_actions.id), t_actions.action_name, pat_sid = convert(varchar, t_actions.pat_id), pat_name = (select t_patterns.pat_name from t_patterns where t_patterns.id = t_actions.pat_id), t_actions.user_define, t_actions.proc_name from t_actions where t_actions.id = @id end $ENDTEXT(19031665) $ENDFORM $FORM(FORM4) name=# Меню для списков class=4 filter=null target_state= uo=null dw=null procedure=ap_menu2action patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.ap_menu2action @action_sid varchar(30) = null as declare @action_id numeric declare @type_id numeric declare @class_id numeric begin .TRANSACTION_SAVE select @action_id = convert(numeric, @action_sid) select @type_id = type_id from t_actions where id = @action_id select @class_id = class_id from t_types where id = @type_id /* create table #roles ( role_id numeric ) insert #roles (role_id) select distinct t_user2role.role_id from t_users, t_user2role where t_users.login_name = .SUSER_NAME and t_users.id = t_user2role.user_id */ create table #actions ( action_id numeric, state_id numeric ) /****************************************************************************************** * Без группы * ******************************************************************************************/ insert #actions (action_id,state_id) select distinct t_state2action2role.action_id,t_state2action2role.state_id from /*#roles,*/ t_actions, t_state2action2role .INDEX(t_state2action2role_pk) where t_actions.type_id = @type_id and t_state2action2role.action_id = t_actions.id /* and t_state2action2role.role_id=#roles.role_id */ and exists(select 1 from t_users, t_user2role where t_users.login_name=.SUSER_NAME and t_user2role.user_id=t_users.id and t_user2role.role_id=t_state2action2role.role_id) /****************************************************************************************** * С группой * ******************************************************************************************/ insert #actions (action_id,state_id) select distinct t_state2action2role.action_id,t_state2action2role.state_id from /*#roles,*/ t_actions, t_relation, t_state2action2role .INDEX(t_state2action2role_pk) where t_relation.t_type_id=t_actions.type_id and t_relation.s_type_id=@type_id and t_relation.class_id=5 and t_state2action2role.action_id=t_actions.id /* and t_state2action2role.role_id=#roles.role_id */ and exists(select 1 from t_users, t_user2role where t_users.login_name=.SUSER_NAME and t_user2role.user_id=t_users.id and t_user2role.role_id=t_state2action2role.role_id) create index #actions_pk on #actions(action_id) create table #report ( name varchar(60) null, vaction_id numeric null, vaction_code varchar(60) null, vclass_id int null, vuo_name varchar(30) null, vdw_name varchar(30) null, vproc_name varchar(30) null, vx int null, vy int null, vwidth int null, vheight int null, naction_id numeric null, nclass_id int null, nuo_name varchar(30) null, ndw_name varchar(30) null, nproc_name varchar(30) null, type_id numeric null, state_id numeric null, is_tab tinyint null ) /* Вставка, изменение, удаление, переходы */ insert #report ( name, naction_id, nclass_id, nuo_name, ndw_name, nproc_name, vaction_id, type_id, state_id, is_tab, vx, vy, vwidth, vheight ) select t_actions.action_name, t_actions.id, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.vaction_id, t_actions.type_id, #actions.state_id, t_actions.is_tab, t_actions.x, t_actions.y, t_actions.width, t_actions.height from #actions, t_actions .INDEX(t_actions_pk) where t_actions.isvisible=0 /* Видимый в меню - 0, системный - 1 */ and t_actions.class_id in (1,2,3,9) and t_actions.id = #actions.action_id /* Визуальные методы к невизуальным */ update #report set vaction_code = t_actions.action_code, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name from t_actions where t_actions.id = #report.vaction_id /* Редакторы */ insert #report ( name, vaction_id, vaction_code, vclass_id, vuo_name, vdw_name, vproc_name, vx, vy, vwidth, vheight, type_id, state_id, is_tab ) select t_actions.action_name, t_actions.id, t_actions.action_code, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.x, t_actions.y, t_actions.width, t_actions.height, t_actions.type_id, #actions.state_id, t_actions.is_tab from #actions, t_actions .INDEX(t_actions_pk) where t_actions.isvisible=0 /* Видимый в меню - 0, системный - 1 */ and t_actions.class_id=5 and t_actions.id = #actions.action_id /* Если меню для группы, то для вставок добавляется название типа документа */ if @class_id=5 update #report set #report.name=#report.name + ' ' + t_types.type_name from t_types where #report.type_id=t_types.id and #report.nclass_id=1 select #report.name, vaction_sid = convert(varchar, #report.vaction_id), #report.vaction_code, #report.vclass_id, #report.vuo_name, #report.vdw_name, #report.vproc_name, #report.vx, #report.vy, #report.vwidth, #report.vheight, naction_sid = convert(varchar, #report.naction_id), #report.nclass_id, #report.nuo_name, #report.ndw_name, #report.nproc_name, type_sid = convert(varchar, #report.type_id), state_sid = convert(varchar, #report.state_id), #report.is_tab from #report order by nclass_id, vclass_id , #report.name drop table #report drop table #actions /* drop table #roles */ .TRANSACTION_RESTORE end $ENDTEXT(19031665) $ENDFORM $FORM(FORM5) name=# Страницы для TAB class=4 filter=null target_state= uo=null dw=null procedure=ap_action2tab patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.%PROC% @action_sid varchar(30) = null, @sid varchar(30) = null as declare @action_id numeric declare @type_id numeric declare @class_id numeric declare @id numeric declare @state_id numeric select @action_id=convert(numeric, @action_sid) select @type_id=type_id, @class_id=class_id, @state_id=null from t_actions where id=@action_id -- -- Вставка -- if @class_id = 1 select @state_id=(select state_id from t_actions where id=@action_id) if (rtrim(@sid) is not null) and (lower(@sid)!='null') begin select @id = convert(numeric, @sid) if @state_id is null select @state_id=(select state_id from t_items where id=@id) if @state_id is null select @state_id=(select id from t_states where type_id = @type_id and UPPER(state_code)='SYSTEM') end create table #actions ( action_id numeric, sid_asname varchar(30) null, bind_order int null ) -- -- Методы данного типа -- -- -- Связи документов -- insert #actions (action_id, sid_asname, bind_order) select t_state2action2user.action_id, t_relation.sid_asname, isnull(t_relation.rel_order, 0) from t_relation, t_state2action2user where t_relation.class_id=1 and t_relation.s_type_id=@type_id and t_state2action2user.action_id=t_relation.action_id and t_state2action2user.suser_name=.SUSER_NAME and ((t_relation.t_type_id=@type_id and t_state2action2user.state_id=@state_id) /* or (t_relation.t_type_id!=@type_id) */ ) -- -- Связи методов -- insert #actions (action_id, sid_asname, bind_order) select t_state2action2user.action_id, t_binds.sid_asname, isnull(t_binds.bind_order, 0) from t_binds, t_actions, t_state2action2user where t_binds.class_id=1 and t_binds.s_action_id=@action_id and t_binds.t_action_id=t_actions.id and t_state2action2user.action_id=t_binds.t_action_id and t_state2action2user.suser_name=.SUSER_NAME and ((t_actions.type_id=@type_id and t_state2action2user.state_id=@state_id) /* or (t_actions.type_id!=@type_id) */ ) and not exists(select 1 from #actions ta where t_state2action2user.action_id=ta.action_id) -- -- Методы прочих типов -- -- -- Связи документов -- insert #actions (action_id, sid_asname, bind_order) select t_action2user.action_id, t_relation.sid_asname, isnull(t_relation.rel_order, 0) from t_relation, t_action2user where t_relation.class_id=1 and t_relation.s_type_id=@type_id and t_relation.t_type_id!=@type_id and t_action2user.action_id=t_relation.action_id and t_action2user.suser_name=.SUSER_NAME -- -- Связи методов -- insert #actions (action_id, sid_asname, bind_order) select t_action2user.action_id, t_binds.sid_asname, isnull(t_binds.bind_order, 0) from t_binds, t_actions, t_action2user where t_binds.class_id=1 and t_binds.s_action_id=@action_id and t_binds.t_action_id=t_actions.id and t_actions.type_id!=@type_id and t_action2user.action_id=t_binds.t_action_id and t_action2user.suser_name=.SUSER_NAME and not exists(select 1 from #actions ta where t_action2user.action_id = ta.action_id) create table #report ( name varchar(60) null, vaction_id numeric null, vaction_code varchar(60) null, vclass_id int null, vuo_name varchar(30) null, vdw_name varchar(30) null, vproc_name varchar(30) null, vx int null, vy int null, vwidth int null, vheight int null, naction_id numeric null, nclass_id int null, nuo_name varchar(30) null, ndw_name varchar(30) null, nproc_name varchar(30) null, type_id numeric null, is_tab int null, sid_asname varchar(30) null, bind_order int null ) -- -- Невизуальные методы -- insert #report ( name, naction_id, nclass_id, nuo_name, ndw_name, nproc_name, vaction_id, is_tab, vx, vy, vwidth, vheight, type_id, sid_asname, bind_order ) select t_actions.action_name, t_actions.id, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.vaction_id, t_actions.is_tab, t_actions.x, t_actions.y, t_actions.width, t_actions.height, t_actions.type_id, #actions.sid_asname, #actions.bind_order from #actions, t_actions where t_actions.class_id in (1,2,3) and t_actions.id = #actions.action_id -- -- Визуальные методы к невизуальным -- update #report set vaction_code = t_actions.action_code, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name from t_actions where t_actions.id = #report.vaction_id -- -- Просмотры -- insert #report ( name, vaction_id, vaction_code, vclass_id, vuo_name, vdw_name, vproc_name, is_tab, vx, vy, vwidth, vheight, type_id, sid_asname, bind_order ) select t_actions.action_name, t_actions.id, t_actions.action_code, t_actions.class_id, t_actions.uo_name, t_actions.dw_name, t_actions.proc_name, t_actions.is_tab, t_actions.x, t_actions.y, t_actions.width, t_actions.height, t_actions.type_id, #actions.sid_asname, #actions.bind_order from #actions, t_actions where t_actions.class_id in (4,5) and t_actions.id = #actions.action_id select #report.name, vaction_sid = convert(varchar, #report.vaction_id), #report.vaction_code, #report.vclass_id, #report.vuo_name, #report.vdw_name, #report.vproc_name, #report.vx, #report.vy, #report.vwidth, #report.vheight, naction_sid = convert(varchar, #report.naction_id), #report.nclass_id, #report.nuo_name, #report.ndw_name, #report.nproc_name, type_sid = convert(varchar, #report.type_id), #report.is_tab, #report.sid_asname from #report order by #report.bind_order drop table #report drop table #actions $ENDTEXT(19031665) $ENDFORM $FORM(FORM6) name=# Нужно для кнопки class=4 filter=null target_state= uo=null dw=null procedure=ap_getactionparm patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.%PROC% @sid varchar(255) = null, @code varchar(255) = null as declare @id numeric declare @class_id tinyint begin select @id = convert(numeric, @sid) if (@id is null) begin if (select count(*) from t_actions where UPPER(action_code) = UPPER(@code)) = 1 select @id = id, @class_id = class_id from t_actions where UPPER(action_code) = UPPER(@code) else return end else begin if (select count(*) from t_actions where id = @id) = 1 select @class_id = class_id from t_actions where id = @id else return end create table #report ( name varchar(60) null, vaction_id numeric null, vclass_id int null, vuo_name varchar(30) null, vdw_name varchar(30) null, vproc_name varchar(30) null, vx int null, vy int null, vwidth int null, vheight int null, naction_id numeric null, nclass_id int null, nuo_name varchar(30) null, ndw_name varchar(30) null, nproc_name varchar(30) null, faction_id numeric null, fclass_id int null, fuo_name varchar(30) null, fdw_name varchar(30) null, fproc_name varchar(30) null, fx int null, fy int null, fwidth int null, fheight int null, type_id numeric null, state_id numeric null, is_tab int ) insert #report ( name, type_id, state_id, is_tab ) select t_actions.action_name, t_actions.type_id, t_actions.state_id, t_actions.is_tab from t_actions where t_actions.id = @id if (@class_id = 0) begin /* other */ update #report set vaction_id = @id, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name, vx = t_actions.x, vy = t_actions.y, vwidth = t_actions.width, vheight = t_actions.height from t_actions where t_actions.id = @id end if (@class_id = 1 or @class_id = 2 or @class_id = 3) begin /* ins upd del */ update #report set naction_id = @id, nclass_id = t_actions.class_id, nuo_name = t_actions.uo_name, ndw_name = t_actions.dw_name, nproc_name = t_actions.proc_name, vaction_id = t_actions.vaction_id from t_actions where t_actions.id = @id update #report set vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name, vx = t_actions.x, vy = t_actions.y, vwidth = t_actions.width, vheight = t_actions.height from t_actions where #report.vaction_id = t_actions.id end if (@class_id = 4) begin /* list */ update #report set vaction_id = @id, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name, vx = t_actions.x, vy = t_actions.y, vwidth = t_actions.width, vheight = t_actions. height, naction_id = t_actions.naction_id, faction_id = t_actions.faction_id from t_actions where t_actions.id = @id update #report set nclass_id = t_actions.class_id, nuo_name = t_actions.uo_name, ndw_name = t_actions.dw_name, nproc_name = t_actions.proc_name, vaction_id = t_actions.vaction_id from t_actions where #report.naction_id = t_actions.id update #report set fclass_id = t_actions.class_id, fuo_name = t_actions.uo_name, fdw_name = t_actions.dw_name, fproc_name = t_actions.proc_name, fx = t_actions.x, fy = t_actions.y, fwidth = t_actions.width, fheight = t_actions.height from t_actions where #report.faction_id = t_actions.id end if (@class_id = 5) begin /* edit */ update #report set vaction_id = @id, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name, vx = t_actions.x, vy = t_actions.y, vwidth = t_actions.width, vheight = t_actions.height, naction_id = t_actions.naction_id from t_actions where t_actions.id = @id update #report set nclass_id = t_actions.class_id, nuo_name = t_actions.uo_name, ndw_name = t_actions.dw_name, nproc_name = t_actions.proc_name, vaction_id = t_actions.vaction_id from t_actions where #report.naction_id = t_actions.id end if (@class_id = 6) begin /* filter */ update #report set vaction_id = @id, vclass_id = t_actions.class_id, vuo_name = t_actions.uo_name, vdw_name = t_actions.dw_name, vproc_name = t_actions.proc_name, vx = t_actions.x, vy = t_actions.y, vwidth = t_actions.width, vheight = t_actions.height from t_actions where t_actions.id = @id end select #report.name, vaction_sid = convert(varchar, #report.vaction_id), #report.vclass_id, #report.vuo_name, #report.vdw_name, #report.vproc_name, #report.vx, #report.vy, #report.vwidth, #report.vheight, naction_sid = convert(varchar, #report.naction_id), #report.nclass_id, #report.nuo_name, #report.ndw_name, #report.nproc_name, faction_sid = convert(varchar, #report.faction_id), #report.fclass_id, #report.fuo_name, #report.fdw_name, #report.fproc_name, #report.fx, #report.fy, #report.fwidth, #report.fheight, type_sid = convert(varchar, #report.type_id), state_sid = convert(varchar, #report.state_id), is_tab from #report end $ENDTEXT(19031665) $ENDFORM $FORM(UO_ACTIONS_LIST) name=Методы class=4 filter=null target_state= uo=uo_list dw=d_actions_list procedure=apt_actions_view patterns=null user_define=0 isvisible=0 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031665) create procedure dbo.%PROC% @type_sid varchar(255) = null as declare @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @new_state_id numeric begin select @action_id = %ACTION_ID% .CHECK_USER select @type_id = convert(numeric, @type_sid) select sid = convert(varchar, t_actions.id), item_name = t_actions.action_name, t_actions.action_name, t_actions.action_code, t_actions.class_id, vaction_sid = convert(varchar, t_actions.vaction_id), vaction_name = (select action_name from t_actions t1 where t1.id = t_actions.vaction_id), naction_sid = convert(varchar, t_actions.naction_id), naction_name = (select action_name from t_actions t1 where t1.id = t_actions.naction_id), faction_sid = convert(varchar, t_actions.faction_id), faction_name = (select action_name from t_actions t1 where t1.id = t_actions.faction_id), type_sid = convert(varchar, t_actions.type_id), state_sid = convert(varchar, t_actions.state_id), state_name = (select state_name from t_states where t_states.id = t_actions.state_id) from t_actions where t_actions.type_id = @type_id and t_actions.class_id in (1,2,3,9) order by t_actions.action_name end $ENDTEXT(19031665) $ENDFORM $FORM(UO_PROPS_ACTION_CHOOSE) name=Выбор метода для копирования class=5 filter=null target_state= uo=uo_edit dw=d_props_action_choose procedure=null patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text= $ENDFORM $ACTION(ACTION1) name=Изменить class=2 form=FORM2 target_state=null procedure=apt_actions_update patterns=null user_define=1 isvisible=0 istab=1 posx=0 posy=0 width=3547 height=2028 proc_text=$TEXT(19031665) create procedure dbo.%PROC% @sid varchar(30) = null, @action_name varchar(60) = null, @action_code varchar(30) = null, @class_id tinyint = null, @type_sid varchar(30) = null, @state_sid varchar(30) = null, @vaction_sid varchar(30) = null, @naction_sid varchar(30) = null, @faction_sid varchar(30) = null, @isvisible tinyint = 0, @is_tab tinyint =0 as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric declare @vaction_id numeric declare @naction_id numeric declare @faction_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER select @id = convert(numeric, @sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end select @type_id = convert(numeric, @type_sid) if (@type_id is null) begin rollback transaction raiserror 40000 'не задан тип документа' return end select @state_id = convert(numeric, @state_sid) select @vaction_id = convert(numeric, @vaction_sid) select @naction_id = convert(numeric, @naction_sid) select @faction_id = convert(numeric, @faction_sid) -- UPDATE CHANGE DATE -- IF NOT exists(select 1 from t_actions where id = @id and action_name = @action_name and action_code = @action_code and class_id = @class_id and state_id = @state_id and vaction_id = @vaction_id and naction_id = @naction_id and faction_id = @faction_id and isvisible = @isvisible and is_tab = @is_tab ) begin update t_types set chdate = GetDate() where id = @type_id end ------------------------ update t_actions set action_name = @action_name, action_code = @action_code, class_id = @class_id, type_id = @type_id, state_id = @state_id, vaction_id = @vaction_id, naction_id = @naction_id, faction_id = @faction_id, isvisible = @isvisible, is_tab = @is_tab where id = @id if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_actions' return end if not exists(select 1 from t_state2action where action_id = @id) begin declare @new_state2action_id numeric(18,0) declare @cur_state_id numeric declare states_cur cursor for select id from t_states where type_id = @type_id for read only open states_cur fetch states_cur into @cur_state_id while .CURSOR_STATE = 0 begin exec ap_getid @new_state2action_id out insert into dbo.t_state2action ( id, state_id, action_id, is_available ) values ( @new_state2action_id, @cur_state_id, @id, 0 -- допуск по умолчанию закрыт ) fetch states_cur into @cur_state_id end close states_cur .DEALLOCATE states_cur end commit tran $ENDTEXT(19031665) $BIND(BIND1) type=TYPED_METHOD2OPERS_BLOCKS action=LIST_METHOD2BLOCK class=1 order=100 idname=method_id_s $ENDBIND $ENDACTION $ACTION(ACTION2) name=Добавить class=1 form=FORM2 target_state=SYSTEM procedure=apt_actions_insert patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2034 height=1088 proc_text=$TEXT(19031667) create procedure dbo.%PROC% @sid varchar(30) = null, @action_name varchar(60) = null, @action_code varchar(30) = null, @class_id tinyint = null, @type_sid varchar(30) = null, @state_sid varchar(30) = null, @vaction_sid varchar(30) = null, @naction_sid varchar(30) = null, @faction_sid varchar(30) = null, @isvisible tinyint = 0, @is_tab tinyint = 0 as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric declare @vaction_id numeric declare @naction_id numeric declare @faction_id numeric declare @silent tinyint -- идентификатор для допусков (Александр В. Подзолко, 22 июнь 2005) declare @new_state2action_id numeric(18,0) ----- begin begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER -- можем задать, а можем и не задать -- где не задаём не знаю, а задаём в процедуре копирования if @id is null begin execute ap_getid @id out select @silent = 0 end else begin select @silent = 1 end if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end select @type_id = convert(numeric, @type_sid) if (@type_id is null) begin rollback transaction raiserror 40000 'не задан тип документа' return end select @state_id = convert(numeric, @state_sid) select @vaction_id = convert(numeric, @vaction_sid) select @naction_id = convert(numeric, @naction_sid) select @faction_id = convert(numeric, @faction_sid) insert into t_actions ( id, action_name, action_code, class_id, type_id, state_id, vaction_id, naction_id, faction_id, isvisible, is_tab ) values ( @id, @action_name, @action_code, @class_id, @type_id, @state_id, @vaction_id, @naction_id, @faction_id, @isvisible, @is_tab ) if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_actions' return end -- вставляем запрещающие допуска (Александр В. Подзолко, 22 июнь 2005) declare @cur_state_id numeric declare states_cur cursor for select id from t_states where type_id = @type_id for read only open states_cur fetch states_cur into @cur_state_id while .CURSOR_STATE = 0 begin exec ap_getid @new_state2action_id out insert into dbo.t_state2action ( id, state_id, action_id, is_available ) values ( @new_state2action_id, @cur_state_id, @id, 0 -- допуск по умолчанию закрыт ) fetch states_cur into @cur_state_id end close states_cur .DEALLOCATE states_cur ------- -- UPDATE CHANGE DATE -- update t_types set chdate = GetDate() where id = @type_id -- commit tran -- условие введено для того, чтобы при использовании этой процедуры для копирования -- методов подавлять вывод резалтсетов, иначе оно падает. -- Александр В. Подзолко if @silent = 0 begin select sid = convert(varchar, @id) end end $ENDTEXT(19031667) $ENDACTION $ACTION(ACTION4) name=Процедура class=2 form=FORM3 target_state=null procedure=apt_actionpat_any patterns=null user_define=0 isvisible=1 istab=0 posx=0 posy=0 width=0 height=0 proc_text=$TEXT(19031667) create procedure dbo.%PROC% @sid varchar(30) = null, @action integer = 0, @pat_sid varchar(255) = null, @user_define int = null, @proc_name varchar(255) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @item_name varchar(100), @new_state_id numeric declare @pat_id numeric begin tran select @action_id = %ACTION_ID% .CHECK_USER select @id = convert(numeric, @sid) select @pat_id = convert(numeric, @pat_sid) if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end if (@action = 1) begin update t_actions set pat_id = @pat_id, user_define = @user_define, proc_name = @proc_name where id = @id end if (@action = 2) begin update t_actions set pat_id = @pat_id, user_define = @user_define, proc_name = @proc_name where id = @id end if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_actions' return end commit tran $ENDTEXT(19031667) $ENDACTION $ACTION(ACTION5) name=Скопировать class=1 form=UO_PROPS_ACTION_CHOOSE target_state=null procedure=apt_actions_copy patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2455 height=720 proc_text=$TEXT(19031667) create procedure dbo.%PROC% @action integer = 0, @sid varchar(30) = null, @type_sid varchar(30) = null, @s_type_sid varchar(30) = null, @s_action_sid varchar(30) = null as begin declare @id numeric(18,0), @type_id numeric(18,0), @new_state_id numeric(18,0), @new_state_sid varchar(30), @s_type_id numeric(18,0), @s_action_id numeric(18,0) declare @action_id numeric(18,0), @action_code varchar(30), @action_name varchar(60), @class_id tinyint, @naction_id numeric, @vaction_id numeric, @faction_id numeric, @uo_name varchar(60), @dw_name varchar(60), @proc_name varchar(30), @state_id numeric, @pat_id numeric, @user_define tinyint, @isvisible tinyint, @external_name varchar(255), @external_add_name varchar(255), @is_tab tinyint declare @new_bind_id numeric, @bind_id numeric, @bind_class_id numeric, @bind_order int, @s_bind_action_id numeric, @t_bind_action_id numeric, @new_s_bind_action_id numeric, @new_t_bind_action_id numeric, @sid_asname varchar(30) declare @new_calc_id numeric, @c_action_id numeric, @new_action_id numeric, @calc_name varchar(30), @calc_type varchar(10), @calc_length smallint, @calc_prec smallint, @calc_scale smallint, @calc_formula varchar(255), @calc_comment varchar(255), @calc_class_id smallint, @action_sid varchar(30), @sid1 varchar(30) declare @n_state_id numeric(18,0), @s2a_id numeric(18,0), @is_available tinyint select @s_type_id=convert(numeric(18,0),@s_type_sid) if @s_type_id is NULL begin rollback transaction raiserror 40000 'Не задан исходный тип документа' return end select @type_id = convert(numeric(18,0), @type_sid) if @type_id is NULL begin rollback transaction raiserror 40000 'Не задан целевой тип документа' return end select @s_action_id = convert(numeric(18,0), @s_action_sid) if @s_action_id is null -- -- Копирование всех методов документа -- declare cur cursor for select distinct id, action_code, action_name, class_id, naction_id, vaction_id, faction_id, uo_name, dw_name, proc_name, state_id, pat_id, user_define, isvisible, external_name, external_add_name, is_tab from t_actions where type_id = @s_type_id else -- -- Копирование заданного метода документа -- declare cur cursor for select distinct id, action_code, action_name, class_id, naction_id, vaction_id, faction_id, uo_name, dw_name, proc_name, state_id, pat_id, user_define, isvisible, external_name, external_add_name, is_tab from t_actions where type_id = @s_type_id and id=@s_action_id open cur fetch cur into @action_id, @action_code, @action_name, @class_id, @naction_id, @vaction_id, @faction_id, @uo_name, @dw_name, @proc_name, @state_id, @pat_id, @user_define, @isvisible, @external_name, @external_add_name, @is_tab -- -- Цикл копирования -- while .CURSOR_STATE=0 begin -- -- Заголовок метода -- execute ap_getid @id out -- это будет идентификатор нового метода select @sid = convert(varchar, @id) -- а это будет идентификатор старого метода -- select @s_action_id = @action_id if @id is null begin rollback transaction raiserror 40000 'Не задан id для t_actions' return end select @proc_name = 'ap_'+convert(varchar,@id) select @new_state_id= (select id from t_states where type_id=@type_id and rtrim(ltrim(upper(state_name))) = (select rtrim(ltrim(upper(state_name))) from t_states where id=@state_id)) select @new_state_sid = convert(varchar, @new_state_id) -- четыре нулла в параметрах символизируют значения, которые скопировать невозможно или очень очень сложно exec dbo.apt_actions_insert @sid, @action_name, @action_code, @class_id, @type_sid, @new_state_sid, null, null, null, @isvisible, @is_tab exec dbo.apt_actiondop_any @sid, 1, @uo_name, null, @dw_name, @external_name, @external_add_name /* Закомментировано: Александр В. Подзолко Причина: Для вставки методов следует использовать исключительно метод документа ACTIONS "Добавить". Тоже касается и других объектов. Иначе при изменении логики вставки (удаления, модификации) документа из других мест начинают вылезать побочные эффекты. С чем я тут и столкнулся. insert into t_actions (id, type_id, action_code, action_name, class_id, naction_id, vaction_id, faction_id, uo_name, dw_name, proc_name, state_id, pat_id, user_define, isvisible, external_name, external_add_name, is_tab ) values(@id, @type_id, null, @action_name, @class_id, @naction_id, @vaction_id, @faction_id, @uo_name, @dw_name, @proc_name, @new_state_id, @pat_id, @user_define, @isvisible, @external_name, @external_add_name, @is_tab ) */ /* -- -- Копирование фильтра -- select @action_sid = convert(varchar,@action_id) select @sid1 = convert(varchar,@id) execute apt_filter2action_copy @sid1 , @action_sid if @@error !=0 begin close cur raiserror ('Ошибка при копировании полей фильтра метода', 16, 1) return end -- -- Копирование допусков в статусах -- declare state2action_cur cursor read_only fast_forward for select n.id, t_state2action.is_available from t_states n, t_states o, t_state2action where n.type_id=@type_id and o.type_id=@s_type_id and rtrim(ltrim(upper(n.state_name))) = rtrim(ltrim(upper(o.state_name))) and t_state2action.action_id=@action_id and t_state2action.state_id=o.id open state2action_cur fetch state2action_cur into @n_state_id, @is_available while .CURSOR_STATE=0 begin update dbo.t_state2action set is_available = @is_available where state_id = @n_state_id and action_id = @id fetch state2action_cur into @n_state_id, @is_available end close state2action_cur .DEALLOCATE state2action_cur */ -- -- Копирование текста метода -- insert t_texts(id,seg_len,seg_num,text_len) select @id,seg_len,seg_num,text_len from t_texts where id=@action_id -- -- Копирование строк текста метода -- insert t_segments ( id, seg_num, seg_text ) select @id, seg_num, seg_text from dbo.t_segments where id=@action_id -- -- Копирование закладки "параметы" -- insert t_action2props(action_id,prop_id) select @id, n.id from t_props n,t_props o,t_action2props where n.type_id = @type_id and o.type_id = @s_type_id and o.table_name = n.table_name and o.field_name = n.field_name and t_action2props.action_id = @action_id and t_action2props.prop_id = o.id -- -- Копирование допусков для ролей -- insert t_state2action2role(state_id,action_id,role_id) select n.id ,@id,s2r.role_id from t_states n,t_states o, t_state2action2role s2r where n.type_id = @type_id and o.type_id = @s_type_id and s2r.state_id = o.id and s2r.action_id = @id and rtrim(ltrim(upper(n.state_name))) = rtrim(ltrim(upper(o.state_name))) fetch cur into @action_id, @action_code, @action_name, @class_id, @naction_id, @vaction_id, @faction_id, @uo_name, @dw_name, @proc_name, @state_id, @pat_id, @user_define, @isvisible, @external_name, @external_add_name, @is_tab end close cur -- -- Согласование звязей невизуальных, визуальных методов и фильтров со скопированными методами -- if @s_action_id is null update t_actions set naction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.naction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), vaction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.vaction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), faction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.faction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) where type_id=@type_id else update t_actions set naction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.naction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.id = @s_action_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), vaction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.vaction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.id = @s_action_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), faction_id = (select n.id from t_actions n ,t_actions o where o.id = t_actions.faction_id and n.type_id = @type_id and o.type_id = @s_type_id and o.id = @s_action_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) where type_id=@type_id and id=@s_action_id -- -- Копирование связей методов -- if @s_action_id is null declare b_cur cursor for select b.id,b.class_id,b.bind_order,b.s_action_id,b.t_action_id,b.sid_asname from t_binds b, t_actions a where b.s_action_id = a.id and a.type_id = @s_type_id else declare b_cur cursor for select b.id,b.class_id,b.bind_order,b.s_action_id,b.t_action_id,b.sid_asname from t_binds b, t_actions a where b.s_action_id = a.id and a.type_id = @s_type_id and a.id = @s_action_id open b_cur fetch b_cur into @bind_id, @bind_class_id, @bind_order, @s_bind_action_id, @t_bind_action_id, @sid_asname while .CURSOR_STATE=0 begin execute ap_getid @new_bind_id out if @new_bind_id is null begin rollback transaction raiserror 40000 'Не задан id для t_binds' return end if @s_action_id is null select @new_s_bind_action_id = (select n.id from t_actions n ,t_actions o where o.id = @s_bind_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), @new_t_bind_action_id = (select n.id from t_actions n ,t_actions o where o.id = @t_bind_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) else select @new_s_bind_action_id = (select n.id from t_actions n ,t_actions o where o.id = @s_bind_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.id = @s_action_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ), @new_t_bind_action_id = (select n.id from t_actions n ,t_actions o where o.id = @t_bind_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.id = @s_action_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) if @new_t_bind_action_id is null select @new_t_bind_action_id = @t_bind_action_id insert t_binds(id,class_id,bind_order,s_action_id,t_action_id,sid_asname) values(@new_bind_id,@bind_class_id,@bind_order,@new_s_bind_action_id,@new_t_bind_action_id,@sid_asname) fetch b_cur into @bind_id, @bind_class_id, @bind_order, @s_bind_action_id, @t_bind_action_id, @sid_asname end close b_cur -- -- Копирование вычислимых полей -- if @s_action_id is null declare calc_cur cursor for select c.action_id, c.calc_name, c.calc_type, c.calc_length, c.calc_prec, c.calc_scale, c.calc_formula, c.calc_comment, c.calc_class_id from t_calcprop c,t_actions where c.action_id = t_actions.id and t_actions.type_id = @s_type_id else declare calc_cur cursor for select c.action_id, c.calc_name, c.calc_type, c.calc_length, c.calc_prec, c.calc_scale, c.calc_formula, c.calc_comment, c.calc_class_id from t_calcprop c,t_actions where c.action_id = t_actions.id and t_actions.type_id = @s_type_id and t_actions.id = @s_action_id open calc_cur fetch calc_cur into @c_action_id, @calc_name, @calc_type, @calc_length, @calc_prec, @calc_scale, @calc_formula, @calc_comment, @calc_class_id while .CURSOR_STATE=0 begin if @s_action_id is null select @new_action_id = (select n.id from t_actions n ,t_actions o where o.id = @c_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) else select @new_action_id = (select n.id from t_actions n ,t_actions o where o.id = @c_action_id and n.type_id = @type_id and o.type_id = @s_type_id and o.id = @s_action_id and o.class_id = n.class_id and rtrim(ltrim(upper(n.action_name))) = rtrim(ltrim(upper(o.action_name))) ) execute ap_getid @new_calc_id out if (@new_calc_id is null) begin rollback transaction raiserror 40000 'Не задан id для t_calcprop' return end insert t_calcprop(id, action_id, calc_name, calc_type, calc_length, calc_prec, calc_scale, calc_formula, calc_comment, calc_class_id ) values(@new_calc_id, @new_action_id, @calc_name, @calc_type, @calc_length, @calc_prec, @calc_scale, @calc_formula, @calc_comment, @calc_class_id ) fetch calc_cur into @c_action_id, @calc_name, @calc_type, @calc_length, @calc_prec, @calc_scale, @calc_formula, @calc_comment, @calc_class_id end close calc_cur end $ENDTEXT(19031667) $ENDACTION $ACTION(ACTION_DELETE) name=Удалить class=3 form=FORM2 target_state=null procedure=apt_actions_delete patterns=null user_define=1 isvisible=0 istab=0 posx=0 posy=0 width=2039 height=1084 proc_text=$TEXT(19031667) create procedure dbo.%PROC% @sid varchar(30) = null as declare @action_id numeric, @id numeric, @user_id numeric, @state_id numeric, @new_state_id numeric, @type_id numeric begin tran select @action_id = %ACTION_ID% select @id = convert(numeric, @sid) .CHECK_USER if (@id is null) begin rollback transaction raiserror 40000 'не задан ключ для t_actions' return end if exists(select 1 from t_actions_history,t_operations where t_actions_history.action_id=@id and t_operations.action_history_id=t_actions_history.id) .EXIT_MESSAGE('Удаление невозможно, по этому методу существуют проводки') delete t_actions where id = @id if @@error != 0 begin rollback transaction raiserror 40000 'ошибка при работе с таблицей t_actions' return end delete t_state2action where action_id = @id delete t_state2action2role where action_id = @id delete t_filter2action where action_id = @id delete t_binds where s_action_id = @id delete t_calcprop where action_id = @id delete t_action2relation where action_id = @id -- UPDATE CHANGE DATE -- select @type_id = type_id from t_actions where id = @id update t_types set chdate = GetDate() where id = @type_id ------------------------ commit tran $ENDTEXT(19031667) $ENDACTION $STATE2ACTION(SYSTEM.ACTION1) state=SYSTEM action=ACTION1 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION2) state=SYSTEM action=ACTION2 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION4) state=SYSTEM action=ACTION4 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION5) state=SYSTEM action=ACTION5 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTIONS_DESC) state=SYSTEM action=ACTIONS_DESC is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTIONS_LOAD) state=SYSTEM action=ACTIONS_LOAD is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.ACTION_DELETE) state=SYSTEM action=ACTION_DELETE is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM2) state=SYSTEM action=FORM2 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM3) state=SYSTEM action=FORM3 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM4) state=SYSTEM action=FORM4 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM5) state=SYSTEM action=FORM5 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.FORM6) state=SYSTEM action=FORM6 is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_ACTIONS_LIST) state=SYSTEM action=UO_ACTIONS_LIST is_available=1 $ENDSTATE2ACTION $STATE2ACTION(SYSTEM.UO_PROPS_ACTION_CHOOSE) state=SYSTEM action=UO_PROPS_ACTION_CHOOSE is_available=1 $ENDSTATE2ACTION $STATE2PROP(SYSTEM.ACTION_CODE) state=SYSTEM prop=ACTION_CODE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.ACTION_NAME) state=SYSTEM prop=ACTION_NAME enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.CLASS_ID) state=SYSTEM prop=CLASS_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.DW_LIB_0) state=SYSTEM prop=DW_LIB_0 enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(SYSTEM.DW_NAME) state=SYSTEM prop=DW_NAME enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.EXTERNAL_ADD_NAME) state=SYSTEM prop=EXTERNAL_ADD_NAME enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.EXTERNAL_NAME) state=SYSTEM prop=EXTERNAL_NAME enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.FACTION_ID) state=SYSTEM prop=FACTION_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.HEIGHT) state=SYSTEM prop=HEIGHT enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.ISVISIBLE) state=SYSTEM prop=ISVISIBLE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.IS_TAB) state=SYSTEM prop=IS_TAB enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.NACTION_ID) state=SYSTEM prop=NACTION_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.PAT_ID) state=SYSTEM prop=PAT_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.PROC_NAME) state=SYSTEM prop=PROC_NAME enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.PRODUCT_ID_-1) state=SYSTEM prop=PRODUCT_ID_-1 enable=0 mandatory=0 visible=0 $ENDSTATE2PROP $STATE2PROP(SYSTEM.STATE_ID) state=SYSTEM prop=STATE_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.TYPE_ID) state=SYSTEM prop=TYPE_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.UO_NAME) state=SYSTEM prop=UO_NAME enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.USER_DEFINE) state=SYSTEM prop=USER_DEFINE enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.VACTION_ID) state=SYSTEM prop=VACTION_ID enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.WIDTH) state=SYSTEM prop=WIDTH enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.X) state=SYSTEM prop=X enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $STATE2PROP(SYSTEM.Y) state=SYSTEM prop=Y enable=1 mandatory=0 visible=1 $ENDSTATE2PROP $ENDDOC