IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_category_bizall]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_category_bizall]
GO
 
CREATE procedure [dbo].[mps_g_category_bizall](
@cmpid int,
@useruid int,
@useradmin int ,
@mobile int =default
)
as
begin
set nocount on 
if (@mobile is null or @mobile=-999999999) set @mobile=1 
select 1 none , 0 none1 where 0=1 

declare @t table(bizid int , ok int) 
insert into @t(bizid,ok) 
select biz_id ,0
from mps_biztype  
where biz_cmpid=@cmpid  

    
  update @t set ok=1 
    from mps_biztype_users 
    where bp_bizid=bizid and bp_cuid=@useruid and 
(bp_type='bizaudit' or bp_type='bizabolish' or bp_type='bizdelete' or bp_type='biznew' or bp_type='bizview' )

if (@mobile=0)
select  0 biz_order , 0 biz_id ,0 biz_formstyle, 1 biz_hidemenu ,
biz_category biz_title ,'all' biz_category  , '' biz_subcategory ,0 biz_comefrom , max(biz_icon0) biz_icon
from mps_biztype , @t 
where biz_id=bizid and ok=1 and biz_hidemenu_mobile=1 
group by biz_category  
order by biz_category 
else if (@mobile=1)
select  0 biz_order , 0 biz_id ,0 biz_formstyle, 1 biz_hidemenu ,
biz_category biz_title ,'all' biz_category  , '' biz_subcategory ,0 biz_comefrom , max(biz_icon0) biz_icon
from mps_biztype , @t 
where biz_id=bizid and ok=1 and biz_hidemenu=1 
group by biz_category  
order by biz_category 
else 
select  0 biz_order , 0 biz_id ,0 biz_formstyle, 1 biz_hidemenu ,
biz_category biz_title ,'all' biz_category  , '' biz_subcategory ,0 biz_comefrom , max(biz_icon0) biz_icon
from mps_biztype , @t 
where biz_id=bizid and ok=1  
group by biz_category  
order by biz_category 
set nocount off 
end