Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-mm committed Nov 9, 2022
1 parent 1c9b50f commit e8a9dde
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Binary file added docs/discussion.pdf
Binary file not shown.
36 changes: 33 additions & 3 deletions sql-files/set_up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ VALUES (:new.service_center_id, serviceId, 3, 100);
END LOOP;
CLOSE serviceCursor;
END;
create or replace TRIGGER AUTO_APPROVE_LEAVE BEFORE
INSERT ON LEAVE FOR EACH ROW BEGIN :new.status := 1;
END;
create or replace TRIGGER ON_SWAP_SLOT_APPROVE
AFTER
UPDATE ON SWAP_SLOT FOR EACH ROW
Expand All @@ -299,4 +296,37 @@ UPDATE SERVICE_EVENT SE
SET SE.mechanic_id = :new.requestor_employee_id
WHERE :new.requested_employee_id = SE.mechanic_id
AND :new.invoice_take = SE.invoice_id;
END;
create or replace TRIGGER AUTO_APPROVE_LEAVE BEFORE
INSERT ON LEAVE FOR EACH ROW
DECLARE activeMechanics INT;
events INT;
BEGIN
SELECT Count(*) into activeMechanics
FROM EMPLOYEE E
WHERE E.Role = 3
AND E.employee_id <> :new.employee_id
AND E.service_center_id = :new.service_center_id
AND NOT EXISTS (
SELECT *
FROM LEAVE L
WHERE L.employee_id = E.employee_id
AND L.service_center_id = E.service_center_id
AND L.status = 1
AND (
:new.START_DATE BETWEEN trunc(L.START_DATE) AND trunc(L.END_DATE)
)
OR (
:new.END_DATE BETWEEN trunc(L.START_DATE) AND trunc(L.END_DATE)
)
);
SELECT Count(*) into events
FROM SERVICE_EVENT SE
WHERE SE.mechanic_id = :new.employee_id
AND SE.service_center_id = :new.service_center_id
AND SE.START_TIME BETWEEN trunc(:new.START_DATE) AND trunc(:new.END_DATE);
IF activeMechanics >= 3
and events = 0 THEN :new.status := 1;
ELSE :new.status := 2;
END IF;
END;

0 comments on commit e8a9dde

Please sign in to comment.