51 lines
1.9 KiB
MySQL
51 lines
1.9 KiB
MySQL
|
|
CREATE OR ALTER PROCEDURE [dbo].[Hr_S_TrainingSync]
|
|||
|
|
@TrainingId uniqueidentifier,
|
|||
|
|
@UserId uniqueidentifier = NULL,
|
|||
|
|
@ActorId uniqueidentifier = NULL
|
|||
|
|
AS
|
|||
|
|
BEGIN
|
|||
|
|
SET NOCOUNT ON;
|
|||
|
|
|
|||
|
|
-- Eğitim ya da katılımcı kaydından sonra çalışır (@UserId boşsa eğitimin bütün katılımcıları):
|
|||
|
|
-- "Katıldı" işaretli katılımcının eğitim günleri puantajda Eğitim olur (devamsız yazılmaz), bağlı
|
|||
|
|
-- gelişim aksiyonu tamamlanır. Silinen katılımcı/eğitim ve değişen tarih için eski günleri
|
|||
|
|
-- puantaj hesabı kendisi düzeltir.
|
|||
|
|
DECLARE @TenantId uniqueidentifier, @StartDate date, @EndDate date;
|
|||
|
|
|
|||
|
|
SELECT @TenantId = TenantId, @StartDate = StartDate, @EndDate = EndDate
|
|||
|
|
FROM Hr_T_Training
|
|||
|
|
WHERE Id = @TrainingId;
|
|||
|
|
|
|||
|
|
IF @StartDate IS NULL
|
|||
|
|
RETURN;
|
|||
|
|
|
|||
|
|
DECLARE @Participant uniqueidentifier, @PlanId uniqueidentifier;
|
|||
|
|
|
|||
|
|
DECLARE participant_cursor CURSOR LOCAL FAST_FORWARD FOR
|
|||
|
|
SELECT DISTINCT UserId FROM Hr_T_TrainingParticipant
|
|||
|
|
WHERE TrainingId = @TrainingId AND (@UserId IS NULL OR UserId = @UserId);
|
|||
|
|
OPEN participant_cursor;
|
|||
|
|
FETCH NEXT FROM participant_cursor INTO @Participant;
|
|||
|
|
WHILE @@FETCH_STATUS = 0
|
|||
|
|
BEGIN
|
|||
|
|
EXEC dbo.Hr_S_TimesheetCalculate @TenantId, @Participant, @StartDate, @EndDate, @ActorId;
|
|||
|
|
FETCH NEXT FROM participant_cursor INTO @Participant;
|
|||
|
|
END
|
|||
|
|
CLOSE participant_cursor;
|
|||
|
|
DEALLOCATE participant_cursor;
|
|||
|
|
|
|||
|
|
DECLARE plan_cursor CURSOR LOCAL FAST_FORWARD FOR
|
|||
|
|
SELECT Id FROM Hr_T_DevelopmentPlan
|
|||
|
|
WHERE TrainingId = @TrainingId AND IsDeleted = 0 AND (@UserId IS NULL OR EmployeeId = @UserId);
|
|||
|
|
OPEN plan_cursor;
|
|||
|
|
FETCH NEXT FROM plan_cursor INTO @PlanId;
|
|||
|
|
WHILE @@FETCH_STATUS = 0
|
|||
|
|
BEGIN
|
|||
|
|
EXEC dbo.Hr_S_DevelopmentPlanSync @PlanId;
|
|||
|
|
FETCH NEXT FROM plan_cursor INTO @PlanId;
|
|||
|
|
END
|
|||
|
|
CLOSE plan_cursor;
|
|||
|
|
DEALLOCATE plan_cursor;
|
|||
|
|
END
|
|||
|
|
GO
|