====== pears.NetOwnerRequirementShortList ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetOwnerRequirementShortList"( in "pWebUserID" char(20),in "pRowID" char(20),in "IsShift" char(1) )
result( "PersonName" char(60),"PersonID" char(20),"PersonStatus" char(50),"Requested" char(1),"Rejected" char(1),"WithHeld" char(1) )
// IQXWeb
begin
declare "VacID" char(20);
if "IsShift" = 0 then
select "pe"."name",
"pe"."personid",
"s"."name",
(select "count"() from "progress" where "status" = 'P' and "personid" = "pe"."personid" and "vacancyid" = "p"."vacancyid") as "Requested",
(select "count"() from "progress" where "status" = 'R' and "personid" = "pe"."personid" and "vacancyid" = "p"."vacancyid") as "Rejected",
(select "count"() from "withholds" as "w" where "w"."personid" = "p"."personid" and("p"."vacancyid" = "w"."vacancyid" or "e"."companyid" = "w"."companyid")) as "WithHeld"
from "employment" as "e"
key join "vacancy"
key join "progress" as "p"
key join "person" as "pe"
,"progress" as "p"
join "status" as "s" on "s"."status" = "p"."status" and "s"."type" = 'R'
where "p"."vacancyid" = "pRowID"
and "s"."name" not like 'placed%'
and "p"."rejectionreason" is null
and "WithHeld" = 0
else
set "VacID" = (select "VacancyID" from "TempShiftPlan" where "tempshiftplanid" = "pRowID");
select "pe"."name",
"pe"."personid",
"s"."name",
(select "count"() from "tempshiftprogress" where "status" = 'P' and "personid" = "pe"."personid" and "tempshiftplanid" = "n"."tempshiftplanid") as "Requested",
(select "count"() from "tempshiftprogress" where "status" = 'R' and "personid" = "pe"."personid" and "tempshiftplanid" = "n"."tempshiftplanid") as "Rejected",
(select "count"() from "withholds" as "w" where "w"."personid" = "p"."personid" and("pl"."vacancyid" = "w"."vacancyid" or "e"."companyid" = "w"."companyid")) as "WithHeld"
from "employment" as "e"
key join "vacancy"
key join "tempshiftplan" as "pl"
key join "tempshiftprogress" as "p"
key join "person" as "pe"
,"tempshiftprogress" as "p"
join "status" as "s" on "s"."status" = "p"."status" and "s"."type" = 'R'
,"tempshiftprogress" as "p"
key join "tempshiftplan" as "n"
where "p"."tempshiftplanid" = "pRowID"
and "s"."name" <> 'placed'
and "p"."rejectionreason" is null
and "WithHeld" = 0
end if
end /* DOC
This routine requires contact event types CI and CD
2016-11-30 PC add requested / rejected, and add doc and test
2017-11-17 PC IW-266 remove candidate if Withheld
2018-01-03 PC IW-300,35 bug fix on withheld
2018-05-04 PC IW-482 it is now possible to view vacancies other than your own so remove owner filters
Tests:
invalid pWebUserID
valid pWebUserID, invalid Rowid
valid pWebUserID, Rowid invalid IsShift
valid pWebUserID, Rowid, IsShift=0 with no events
valid pWebUserID, Rowid, IsShift=0 with requested
valid pWebUserID, Rowid, IsShift=0 with rejected
valid pWebUserID, Rowid, IsShift=1 with requested and rejected
*/
/* TEST
call NetTestSetup('');
update iqxnetuserlink set employmentid=null where IQXNetUserLinkID in ('test.client','test.agency','test.candidate','test.owner');
update iqxnetuserlink set employmentid='TEST' where IQXNetUserLinkID='test.owner';
insert into progress (progressid,vacancyid,personid,status,staffid) on existing skip values ('TEST','TEST','TEST','#','TEST');
update vacancy set staffid='TEST' where vacancyid='TEST';
select * from NetOwnerRequirementShortList(null,null,null);
expect EOF;
select * from NetOwnerRequirementShortList('test.owner',null,null);
expect EOF;
select * from NetOwnerRequirementShortList('test.owner','zz',null);
expect EOF;
select * from NetOwnerRequirementShortList('test.owner','TEST',null) order by PersonStatus asc;
expect PersonName=test;
select * from NetOwnerRequirementShortList('test.owner','TEST',0) order by PersonStatus asc;
expect PersonName=test;
insert into progress (progressid,vacancyid,personid,status,staffid) on existing skip values ('TEST2','TEST','TEST','P','TEST');
select * from NetOwnerRequirementShortList('test.owner','TEST',0);
expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=1,Rejected=0;
insert into progress (progressid,vacancyid,personid,status,staffid) values ('TEST3','TEST','TEST','R','TEST');
select * from NetOwnerRequirementShortList('test.owner','TEST',0);
expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=1,Rejected=1;
insert into tempshiftprogress (tempshiftprogressid,tempshiftplanid,status,staffid,personid) values('TEST','TEST','A','TEST','TEST');
select * from NetOwnerRequirementShortList('test.owner','TEST',1);
expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=0,Rejected=0;
insert into withholds (WithHoldsID,PersonID,CompanyID) values ('TEST','TEST','TEST');
select * from NetOwnerRequirementShortList('test.client','TEST',0);
expect EOF;
update withholds set CompanyID=null,VacancyID='TEST' where WithHoldsID='TEST';
select * from NetOwnerRequirementShortList('test.client','TEST',0);
expect EOF;
delete from withholds where WithHoldsID='TEST';
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetOwnerRequirementShortList" IS
{create PROCEDURE pears."NetOwnerRequirementShortList"(in pWebUserID char(20),in pRowID char(20),in IsShift char(1))
RESULT(PersonName char(60),PersonID char(20),PersonStatus char(50),Requested char(1),Rejected char(1),WithHeld char(1))
// IQXWeb
BEGIN
declare VacID char(20);
if IsShift=0 then
select
pe.name,
pe.personid,
s.name,
(select count(*) from progress where status ='P' and personid=pe.personid and vacancyid=p.vacancyid) as Requested,
(select count(*) from progress where status ='R' and personid=pe.personid and vacancyid=p.vacancyid) as Rejected,
(select count(*) from withholds w where w.personid=p.personid and (p.vacancyid=w.vacancyid or e.companyid=w.companyid)) as WithHeld
from
employment e
key join vacancy
key join progress p
key join person pe,
progress p
join status s on s.status=p.status and s.type='R'
where
p.vacancyid=pRowID
and s.name not like 'placed%'
and p.rejectionreason is null
and WithHeld=0
else
set "VacID" = (select VacancyID from "TempShiftPlan" where "tempshiftplanid" = pRowID);
select
pe.name,
pe.personid,
s.name,
(select count(*) from tempshiftprogress where status ='P' and personid=pe.personid and tempshiftplanid=n.tempshiftplanid) as Requested,
(select count(*) from tempshiftprogress where status ='R' and personid=pe.personid and tempshiftplanid=n.tempshiftplanid) as Rejected,
(select count(*) from withholds w where w.personid=p.personid and (pl.vacancyid=w.vacancyid or e.companyid=w.companyid)) as WithHeld
from
employment e
key join vacancy
key join tempshiftplan pl
key join tempshiftprogress p
key join person pe,
tempshiftprogress p
join status s on s.status=p.status and s.type='R',
tempshiftprogress p
key join tempshiftplan n
where
p.tempshiftplanid=pRowID
and s.name !='placed'
and p.rejectionreason is null
and WithHeld=0;
end if;
END
/* DOC
This routine requires contact event types CI and CD
2016-11-30 PC add requested / rejected, and add doc and test
2017-11-17 PC IW-266 remove candidate if Withheld
2018-01-03 PC IW-300,35 bug fix on withheld
2018-05-04 PC IW-482 it is now possible to view vacancies other than your own so remove owner filters
Tests:
invalid pWebUserID
valid pWebUserID, invalid Rowid
valid pWebUserID, Rowid invalid IsShift
valid pWebUserID, Rowid, IsShift=0 with no events
valid pWebUserID, Rowid, IsShift=0 with requested
valid pWebUserID, Rowid, IsShift=0 with rejected
valid pWebUserID, Rowid, IsShift=1 with requested and rejected
*/
/* TEST
call NetTestSetup('');
update iqxnetuserlink set employmentid=null where IQXNetUserLinkID in ('test.client','test.agency','test.candidate','test.owner');
update iqxnetuserlink set employmentid='TEST' where IQXNetUserLinkID='test.owner';
insert into progress (progressid,vacancyid,personid,status,staffid) on existing skip values ('TEST','TEST','TEST','#','TEST');
update vacancy set staffid='TEST' where vacancyid='TEST';
select * from NetOwnerRequirementShortList(null,null,null);
expect EOF;
select * from NetOwnerRequirementShortList('test.owner',null,null);
expect EOF;
select * from NetOwnerRequirementShortList('test.owner','zz',null);
expect EOF;
select * from NetOwnerRequirementShortList('test.owner','TEST',null) order by PersonStatus asc;
expect PersonName=test;
select * from NetOwnerRequirementShortList('test.owner','TEST',0) order by PersonStatus asc;
expect PersonName=test;
insert into progress (progressid,vacancyid,personid,status,staffid) on existing skip values ('TEST2','TEST','TEST','P','TEST');
select * from NetOwnerRequirementShortList('test.owner','TEST',0);
expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=1,Rejected=0;
insert into progress (progressid,vacancyid,personid,status,staffid) values ('TEST3','TEST','TEST','R','TEST');
select * from NetOwnerRequirementShortList('test.owner','TEST',0);
expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=1,Rejected=1;
insert into tempshiftprogress (tempshiftprogressid,tempshiftplanid,status,staffid,personid) values('TEST','TEST','A','TEST','TEST');
select * from NetOwnerRequirementShortList('test.owner','TEST',1);
expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=0,Rejected=0;
insert into withholds (WithHoldsID,PersonID,CompanyID) values ('TEST','TEST','TEST');
select * from NetOwnerRequirementShortList('test.client','TEST',0);
expect EOF;
update withholds set CompanyID=null,VacancyID='TEST' where WithHoldsID='TEST';
select * from NetOwnerRequirementShortList('test.client','TEST',0);
expect EOF;
delete from withholds where WithHoldsID='TEST';
*/
}