====== pears.NetClientRequirementShortList ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create procedure "pears"."NetClientRequirementShortList"( 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 set "VacID" = "pRowID" end if; if "IsShift" = 1 then set "VacID" = (select "VacancyID" from "TempShiftPlan" where "tempshiftplanid" = "pRowID") end if; select distinct "pe"."name", "pe"."personid", "s"."name", (select "count"() from "diary" where "description" like 'Requested candidate%' and "personid" = "pe"."personid" and "vacancyid" = "p"."vacancyid") as "Requested", (select "count"() from "diary" where "description" like 'Shift Candidate Rejected%' 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 "person" as "pe" key join "progress" as "p" key join "vacancy" as "vac" key join "employment" as "em" key join "company" key join "employment" as "e" key join "iqxnetuserlink" as "i" ,"progress" as "p" join "status" as "s" on "s"."status" = "p"."status" and "s"."type" = 'R' where "i"."iqxnetuserid" = "pWebUserID" and "p"."vacancyid" = "VacID" and "s"."name" <> 'placed' and "Rejected" = 0 and "WithHeld" = 0 end /* DOC 2016-11-30 PC add requested / rejected, and add doc and test 2017-11-17 PC IW-266 remove candidate if Withheld 2019-02-18 PC/ET IW-817 remove "no data" 2019-02-22 PC modify to expand to all vacancies for company, not just consultant 2019-02-27 PC remove duplicates Tests: 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.client'; insert into progress (progressid,vacancyid,personid,status,staffid) on existing update values ('TEST','TEST','TEST','#','TEST'); delete from withholds where WithHoldsID='TEST'; delete from diary where personid='test' and vacancyid='test'; select * from NetClientRequirementShortList('test.client','TEST',null); expect EOF; update status set publishtoweb=1 where type='R' and status in ('A','#'); select * from NetClientRequirementShortList('test.client','TEST',0); expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=0,Rejected=0; insert into diary (diaryid,staffid,personid,vacancyid,diaryfrom,description) on existing update values ('TEST','TEST','TEST','TEST',dateformat(now(*),'yyyy-mm-dd'),'Requested Candidate'); select * from NetClientRequirementShortList('test.client','TEST',0); expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=1,Rejected=0; insert into withholds (WithHoldsID,PersonID,CompanyID) values ('TEST','TEST','TEST'); select * from NetClientRequirementShortList('test.client','TEST',0); expect EOF; update withholds set CompanyID=null,VacancyID='TEST' where WithHoldsID='TEST'; select * from NetClientRequirementShortList('test.client','TEST',0); expect EOF; delete from withholds where WithHoldsID='TEST'; insert into diary (diaryid,staffid,personid,vacancyid,diaryfrom,description) on existing update values ('TEST2','TEST','TEST','TEST',dateformat(now(*),'yyyy-mm-dd'),'Shift Candidate Rejected'); select * from NetClientRequirementShortList('test.client','TEST',0); expect EOF; select * from NetClientRequirementShortList('test.client','TEST',1); expect EOF; */ go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetClientRequirementShortList" IS {create PROCEDURE pears."NetClientRequirementShortList"(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 set VacID=pRowID; end if; if IsShift=1 then set "VacID" = (select VacancyID from "TempShiftPlan" where "tempshiftplanid" = pRowID); end if; select distinct pe.name, pe.personid, s.name, (select count(*) from diary where description like 'Requested candidate%' and personid=pe.personid and vacancyid=p.vacancyid) as Requested, (select count(*) from diary where description like 'Shift Candidate Rejected%' 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 person pe key join progress p key join vacancy vac key join employment em key join company key join "employment" as "e" key join "iqxnetuserlink" as "i", progress p join status s on s.status=p.status and s.type='R' where "i"."iqxnetuserid" = pWebUserID and p.vacancyid=VacID and s.name !='placed' and Rejected = 0 and WithHeld=0 END /* DOC 2016-11-30 PC add requested / rejected, and add doc and test 2017-11-17 PC IW-266 remove candidate if Withheld 2019-02-18 PC/ET IW-817 remove "no data" 2019-02-22 PC modify to expand to all vacancies for company, not just consultant 2019-02-27 PC remove duplicates Tests: 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.client'; insert into progress (progressid,vacancyid,personid,status,staffid) on existing update values ('TEST','TEST','TEST','#','TEST'); delete from withholds where WithHoldsID='TEST'; delete from diary where personid='test' and vacancyid='test'; select * from NetClientRequirementShortList('test.client','TEST',null); expect EOF; update status set publishtoweb=1 where type='R' and status in ('A','#'); select * from NetClientRequirementShortList('test.client','TEST',0); expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=0,Rejected=0; insert into diary (diaryid,staffid,personid,vacancyid,diaryfrom,description) on existing update values ('TEST','TEST','TEST','TEST',dateformat(now(*),'yyyy-mm-dd'),'Requested Candidate'); select * from NetClientRequirementShortList('test.client','TEST',0); expect PersonName=test,PersonID=TEST,PersonStatus=*,Requested=1,Rejected=0; insert into withholds (WithHoldsID,PersonID,CompanyID) values ('TEST','TEST','TEST'); select * from NetClientRequirementShortList('test.client','TEST',0); expect EOF; update withholds set CompanyID=null,VacancyID='TEST' where WithHoldsID='TEST'; select * from NetClientRequirementShortList('test.client','TEST',0); expect EOF; delete from withholds where WithHoldsID='TEST'; insert into diary (diaryid,staffid,personid,vacancyid,diaryfrom,description) on existing update values ('TEST2','TEST','TEST','TEST',dateformat(now(*),'yyyy-mm-dd'),'Shift Candidate Rejected'); select * from NetClientRequirementShortList('test.client','TEST',0); expect EOF; select * from NetClientRequirementShortList('test.client','TEST',1); expect EOF; */ }