IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_ordbrowse_md]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_ordbrowse_md]
GO
create procedure [dbo].[mps_g_ordbrowse_md]
(
@cmpid int,
@useradmin int,
@terminal int,
@useruid int,
@bizid int  
)
as
begin
set nocount on

select * from mps_biztype where biz_id=@bizid
select * from mps_template where tmp_cmpid=@cmpid  and tmp_type='bizquery' and tmp_objid=@bizid 
select top 1 * from mps_biztype_comefrom,mps_biztype_comefrom_fieldmap 
where bs_bizid=@bizid  and bs_ord2tag=0 and bs_sord2tag=0 and bs_popwin=0 and bsf_use=0 and bsf_bsid=bs_id  
select * from mps_biztype_users 
where bp_bizid=@bizid  and  bp_cuid=@useruid

declare @mdtag varchar(100) 
-- 扩展功能功能 t5 
set @mdtag='bizbrow' 
if (@terminal=0) 
begin
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin order by mn_order 
end  else 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=0 order by mn_order 
end 
end else 
begin
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=@useradmin)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=@useradmin order by mn_order 
end  else 
begin
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=0)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=0 order by mn_order 
end else 
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin order by mn_order 
end else 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=0 order by mn_order 
end 
end 
end
-- 选中后功能 t5 
set @mdtag='bizbrowslt' 
if (@terminal=0) 
begin
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin order by mn_order 
end  else 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=0 order by mn_order 
end 
end else 
begin
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=@useradmin)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=@useradmin order by mn_order 
end  else 
begin
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=0)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=1 and mn_roleid=0 order by mn_order 
end else 
if (exists (select 1 from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin)) 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=@useradmin order by mn_order 
end else 
begin
select * from mps_menu where mn_cmpid=@cmpid and mn_flag=@mdtag+convert(varchar(10),@bizid) and mn_terminal=0 and mn_roleid=0 order by mn_order 
end 
end 
end
set nocount off
end