====== pears.NetClientCandidateSubmit ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetClientCandidateSubmit"( in "pWebUserID" char(20),in "pPersonID" char(20),in "pLineID" char(20),in "pIsShift" integer )
result( "pResult" char(250) )
// IQXWeb
begin
declare "sname" char(100);
declare "RefCode" char(20);
declare "VacID" char(20);
if "IQXNetHasPermission"("pWebUserID",'SUBMITCANDIDATES') = 0 then
select '99:~Permission denied';
return
end if;
set "sname" = (select "name" from "person" where "personid" = "pPersonID");
if "pIsShift" = 0 then
if(select "count"() from "progress" where "vacancyid" = "pLineID" and "personid" = "ppersonid") = 0 then
insert into "progress"( "progressid","vacancyid","personid","staffid","status","actiondate" ) values( "uniquekey"("ppersonid"+"plineid"),"pLineid","ppersonid","userstaffid",'A',current date ) ;
set "RefCode" = (select "refcode" from "vacancy" where "vacancyid" = "pLineID");
set "VacID" = "pLineID"
else
select '101:~This person is already in the short list';
return
end if
else set "vacid" = (select top 1 "vacancyid" from "tempshiftplan" where "tempshiftplanid" = "pLineID" order by "tempshiftplanid" asc);
if(select "count"() from "progress" where "vacancyid" = "vacid" and "personid" = "ppersonid") = 0 then
insert into "progress"( "progressid","vacancyid","personid","staffid","status","actiondate" ) values( "uniquekey"("ppersonid"+"plineid"),"vacid","ppersonid","userstaffid",'A',current date ) ;
set "RefCode" = (select "referencecode" from "tempshiftplan" where "tempshiftplanid" = "pLineID")
else
select '101:~This person is already in the short list';
return
end if end if;
if "isnull"("RefCode",'') <> '' then
set "RefCode" = '('+"RefCode"+')'
end if;
call "IQXNetPopup"("pWebUserID","pPersonID",null,"VacID",null,null,'SUBMITCANDIDATE','Candidate submitted by client '+"RefCode","sname");
select '0:~Success'
end /* DOC
2017-01-05 PC receive suggested candidate for shortlist of vacancy
2017-08-01 PC divert all entries to the progress table
2019-02-07 PC IW-809 modify to allow for entries into TempShiftProgress
Tests:
all invalid
pWebUserID valid
all valid for vacancy but no permission
all valid for vacancy with permission
all valid for vacancy repeated
all valid for shift with permission
all valid for shift repeated
*/
/* 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';
update tempshiftplan set referencecode='TestRefPlan' where tempshiftplanid='TEST';
delete from progress where vacancyid='TEST';
delete from iqxnetrightallowed where iqxnetrightid='SUBMITCANDIDATES' and iqxnetuserclassid='CLIENT';
delete from iqxnetrightassigned where iqxnetrightid='SUBMITCANDIDATES' and iqxnetuserid='test.client';
select * from NetClientCandidateSubmit(null,null,null,null);
expect pResult=99*;
select * from NetClientCandidateSubmit('test.client',null,null,null);
expect pResult=99*;
select * from NetClientCandidateSubmit('test.client','TEST','TEST',0);
expect pResult=99*;
INSERT INTO iqxnetrightallowed (iqxnetrightid,iqxnetuserclassid,id,MaintainOnWeb) values ('SUBMITCANDIDATES','CLIENT','*',1);
insert into iqxnetrightassigned (iqxnetuserid,iqxnetrightid,Assigned) values ('test.client','SUBMITCANDIDATES',1);
select * from NetClientCandidateSubmit('test.client','TEST','TEST',0);
expect pResult=0*;
select * from progress where vacancyid='test';
expect personid=TEST;
select top 1 *,replace(description,' ','_') as A from diary order by whenentered desc;
expect staffid=TEST,A=Candidate_submitted*;
delete from progress where vacancyid='TEST';
select * from NetClientCandidateSubmit('test.client','TEST','TEST',1);
expect pResult=0*;
select * from NetClientCandidateSubmit('test.client','TEST','TEST',1);
expect pResult=1*;
select top 1 *,replace(description,' ','_') as B from diary order by whenentered desc;
expect staffid=TEST,B=Candidate_submitted*;
update tempshiftplan set referencecode=null where tempshiftplanid='TEST';
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetClientCandidateSubmit" IS
{create PROCEDURE pears."NetClientCandidateSubmit"( in "pWebUserID" char(20),in "pPersonID" char(20),in "pLineID" char(20),in "pIsShift" integer)
result( "pResult" char(250) )
// IQXWeb
begin
declare sname char(100);
declare RefCode char(20);
declare VacID char(20);
if "IQXNetHasPermission"("pWebUserID",'SUBMITCANDIDATES') = 0 then
select '99:~Permission denied';
return
end if;
set sname=(select name from person where personid = pPersonID);
if pIsShift=0 then
if (select count(*) from progress where vacancyid=pLineID and personid=ppersonid) = 0 then
insert into "progress"( "progressid","vacancyid","personid","staffid","status","actiondate" ) values( "uniquekey"("ppersonid"+"plineid"),"pLineid","ppersonid","userstaffid",'A',current date );
set RefCode = (select refcode from vacancy where vacancyid = pLineID);
set VacID = pLineID;
else
select '101:~This person is already in the short list';
return;
end if;
else
set vacid=(select top 1 vacancyid from tempshiftplan where tempshiftplanid=pLineID order by tempshiftplanid);
if (select count(*) from progress where vacancyid=vacid and personid=ppersonid) = 0 then
insert into "progress"( "progressid","vacancyid","personid","staffid","status","actiondate" ) values( "uniquekey"("ppersonid"+"plineid"),"vacid","ppersonid","userstaffid",'A',current date );
set RefCode = (select referencecode from tempshiftplan where tempshiftplanid = pLineID);
else
select '101:~This person is already in the short list';
return;
end if;
end if;
if "isnull"(RefCode,'') <> '' then
set RefCode = '('+RefCode+')'
end if;
call "IQXNetPopup"("pWebUserID","pPersonID",null,"VacID",null,null,'SUBMITCANDIDATE','Candidate submitted by client '+RefCode,sname);
select '0:~Success';
end
/* DOC
2017-01-05 PC receive suggested candidate for shortlist of vacancy
2017-08-01 PC divert all entries to the progress table
2019-02-07 PC IW-809 modify to allow for entries into TempShiftProgress
Tests:
all invalid
pWebUserID valid
all valid for vacancy but no permission
all valid for vacancy with permission
all valid for vacancy repeated
all valid for shift with permission
all valid for shift repeated
*/
/* 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';
update tempshiftplan set referencecode='TestRefPlan' where tempshiftplanid='TEST';
delete from progress where vacancyid='TEST';
delete from iqxnetrightallowed where iqxnetrightid='SUBMITCANDIDATES' and iqxnetuserclassid='CLIENT';
delete from iqxnetrightassigned where iqxnetrightid='SUBMITCANDIDATES' and iqxnetuserid='test.client';
select * from NetClientCandidateSubmit(null,null,null,null);
expect pResult=99*;
select * from NetClientCandidateSubmit('test.client',null,null,null);
expect pResult=99*;
select * from NetClientCandidateSubmit('test.client','TEST','TEST',0);
expect pResult=99*;
INSERT INTO iqxnetrightallowed (iqxnetrightid,iqxnetuserclassid,id,MaintainOnWeb) values ('SUBMITCANDIDATES','CLIENT','*',1);
insert into iqxnetrightassigned (iqxnetuserid,iqxnetrightid,Assigned) values ('test.client','SUBMITCANDIDATES',1);
select * from NetClientCandidateSubmit('test.client','TEST','TEST',0);
expect pResult=0*;
select * from progress where vacancyid='test';
expect personid=TEST;
select top 1 *,replace(description,' ','_') as A from diary order by whenentered desc;
expect staffid=TEST,A=Candidate_submitted*;
delete from progress where vacancyid='TEST';
select * from NetClientCandidateSubmit('test.client','TEST','TEST',1);
expect pResult=0*;
select * from NetClientCandidateSubmit('test.client','TEST','TEST',1);
expect pResult=1*;
select top 1 *,replace(description,' ','_') as B from diary order by whenentered desc;
expect staffid=TEST,B=Candidate_submitted*;
update tempshiftplan set referencecode=null where tempshiftplanid='TEST';
*/
}