ALTER PROCEDURE Dashbord @userid INT
AS
BEGIN
DECLARE @reportmanager INT
DECLARE @admintype INT
SET @reportmanager = (SELECT Count(managerid)
FROM reportingperson
WHERE employeeid = @userid)
SET @admintype = (SELECT Max(admintype)
FROM employee
WHERE content_id = @userid)
IF EXISTS (SELECT 1
WHERE @reportmanager > 0
AND @admintype = 0)
BEGIN
SELECT b.contentid,
x.content_id,
x.employeename,
x.imagetype,
CONVERT(VARCHAR(10), b.fromdate, 126) AS fromdate,
CONVERT(VARCHAR(10), b.todate, 126) AS Todate,
b.leaveapp,
b.leavesubject,
b.reason,
( CASE
WHEN ( b.status = 0 ) THEN 'Pending'
ELSE 'Approved'
END ) AS status,
CONVERT(VARCHAR(10), b.createddate, 126) AS Createddate
FROM leaves b
LEFT OUTER JOIN employee x
ON b.employeeid = x.content_id
WHERE ( b.employeeid = @userid )
AND b.status = 0
SELECT admintype
FROM employee
WHERE content_id = @userid
END
ELSE
BEGIN
SELECT b.contentid,
x.content_id,
x.employeename,
x.imagetype,
CONVERT(VARCHAR(10), b.fromdate, 126) AS fromdate,
CONVERT(VARCHAR(10), b.todate, 126) AS Todate,
b.leaveapp,
b.leavesubject,
b.reason,
( CASE
WHEN ( b.status = 0 ) THEN 'Pending'
ELSE 'Approved'
END ) AS status,
CONVERT(VARCHAR(10), b.createddate, 126) AS Createddate
FROM leaves b
LEFT OUTER JOIN employee x
ON b.employeeid = x.content_id
WHERE b.employeeid IN (SELECT employeeid
FROM reportingperson
WHERE managerid = @userid)
AND b.status = 0
SELECT admintype
FROM employee
WHERE content_id = @userid
END
END
我必须现在,一旦该人批准请假,通知必须发送给另一个报告人,然后批准请假,然后员工可以去这所房子