
USE [Darmangah]
Go



declare @old_name varchar(200)
IF EXISTS (SELECT name FROM sysobjects
     WHERE name = '_2031_r_atten_one_per_hours_01' AND type = 'P')
	 begin
	 set @old_name='_2031_r_atten_one_per_hours_01'+'_old_'+[dbo].[Fn_Now_DateTime]()
	  EXEC sp_rename '_2031_r_atten_one_per_hours_01',@old_name;
   end
Go
--------------

CREATE procedure [dbo].[_2031_r_atten_one_per_hours_01]
-- By AliCh NeedSoft 1399/02/11
-- exec _2031_r_atten_one_per_hours_01 '1399/02/09','1399/02/12','','','','','','','','','','','','','','','','2','','','','','',''
-- select * from In_Out_Person
(
@fday char(10),
@tday char(10),
@ftime char(20),
@ttime char(20),
@code_user int,
@code_shift	int,
@code_shobeh int,
@code_pay int,
@code_bimeh int,
@code_bakhsh int,
@code_pezeshk int,
@code_dastyar int,
@code_darman int,
@code_bimar int,
@code_ranandeh int,
@code_yaraneh int,
@code_mokammel	int,
@sh_kargozini varchar(20),
@code_ertebat	varchar(20),
@code_shift_str	varchar(500),
@code_bimeh_str	varchar(500),
@code_bakhsh_str varchar(500),
@code_pezeshk_str varchar(500),
@lucp int
)
as
begin

set @fday=RTRIM(LTRIM(@fday))
set @tday=RTRIM(LTRIM(@tday))
set @ftime=RTRIM(LTRIM(@ftime))
set @ttime=RTRIM(LTRIM(@ttime))
set @sh_kargozini=RTRIM(LTRIM(@sh_kargozini))
set @code_ertebat=RTRIM(LTRIM(@code_ertebat))
set @code_shift_str=RTRIM(LTRIM(@code_shift_str))
set @code_bimeh_str=RTRIM(LTRIM(@code_bimeh_str))
set @code_bakhsh_str=RTRIM(LTRIM(@code_bakhsh_str))
set @code_pezeshk_str=RTRIM(LTRIM(@code_pezeshk_str))

declare @code_person int=1
set @code_person=@sh_kargozini

    if ( (LEN(@fday)=10) and (LEN(@tday)=10) and @code_person > 0)
	begin


	    SELECT
      tarikh,
      [dbo].[Fn_Sum_Attendance](@code_person, tarikh) AS Sum_Minutes,
      [dbo].[FN_MinutesToDuration]([dbo].[Fn_Sum_Attendance](@code_person, tarikh)) AS Sum_Houre,
      [dbo].[Fn_String_Attendance](@code_person, tarikh) AS St_Attendance
    FROM In_Out_Person
    WHERE tarikh BETWEEN @fday AND @tday
    GROUP BY tarikh


    

	end
	else
	select 0 as s_result, ' محدوده تاریخ و شماره کاگزینی بعنوان کد شخص را وارد نمایید '+OBJECT_NAME(@@PROCID) as s_message ,' no param '+OBJECT_NAME(@@PROCID) as s_param


end

GO

INSERT [dbo].[users_permission] ([cp], [c_permission]) VALUES (1, 2031)
GO
INSERT [dbo].[users_permission_itm] ([c_permission], [n_permission], [descr], [act], [c_kind]) VALUES (2031, N'_2031_r_atten_one_per_hours_01', N'گزارش کارکرد یک شخص در محدوده تاریخ', 1, 11)

Go




