====== pears.NetAgencyAdditionalComments ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetAgencyAdditionalComments"( in "pWebUserID" char(20),in "pLineID" char(22) )
result( "ActionTime" char(20),"SentTo" char(50),"Note" long varchar,"shiftref" char(10),"EventType" char(30),"ContactDate" date,"ContactTime" time )
// IQXWeb
begin
declare "VacID" char(20);
declare "TempShiftID" char(20);
declare "CompID" char(20);
declare "TempShiftRef" char(20);
declare "VacRef" char(20);
if "left"("pLineId",1) = 'V' then
set "VacID" = "right"("pLineID",20)
end if;
if "left"("pLineId",1) = 'P' then
set "TempShiftID" = "right"("pLineID",20)
end if;
set "CompID" = (select top 1 "employment"."companyid" from "employment" key join "iqxnetuserlink" where "iqxnetuserlink"."iqxnetuserid" = "pwebuserid" order by "employment"."employmentid" asc);
if "VacID" is null then
set "VacID" = (select "VacancyID" from "TempShiftPlan" where "tempshiftplanid" = "TempShiftID")
end if;
select distinct
cast("dateformat"("ce"."contactdate",'dd/mm/yyyy') as char)+' '+cast("dateformat"("ce"."contacttime",'hh:nn') as char) as "ActionTime",
"s"."name" as "SentTo",
"ce"."notes" as "Note",
"substring"("ce"."description","charindex"(':',"ce"."description")+1) as "ShiftRef",
"cc"."classdescrip",
"ce"."contactdate" as "contactdate",
"ce"."contacttime" as "contacttime"
from "vacancy" as "va"
,"tempshiftplan" as "tsp"
right outer join "vacancy" as "va"
key join "contactevent" as "ce"
key join "staff" as "s"
,"contactevent" as "ce"
key join "employment" as "e"
,"contactevent" as "ce" key join "contactclass" as "cc"
where(("ce"."classcode" in( 'CD','CI' ) and "va"."vacancyid" = "VacID")
and "e"."companyid" = "CompID")
order by "contactdate" desc,"contacttime" desc
end /* DOC
28-08-2013 Provide additional Comments for the detail line of Current Requirements.
This routine requires contact events with classcode of CD and CI
25-11-2016 PC Doc and Test
17-04-2018 PC modify test
2019-03-04 PC IW-873 add top 1 and order by on subqueries
Tests:
Lineid starting with V with no contact event
Lineid starting with V with contact event
Lineid starting with P with contact event
*/
/* TEST
NetTestSetup('');
delete from contactevent where contacteventid='TEST';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
insert into vacancy (vacancyid,departmentid,employmentid,status,position) values ('TESTTESTTESTTESTTEST','~~','TEST','[','test2');
insert into contactclass (classcode,classdescrip) on existing update defaults off values ('CI','Confirm Interest');
insert into contactclass (classcode,classdescrip) on existing update defaults off values ('CD','Decline Interest');
insert into contactclass (classcode,classdescrip) on existing update defaults off values ('~~','Test');
insert into contactevent (contacteventid,staffid,contactdate,description,classcode) on existing update defaults off values ('TEST','TEST',now(*),'Test','~~');
update iqxnetuserlink set employmentid=null where IQXNetUserLinkID in ('test.candidate','test.client','test.owner');
update iqxnetuserlink set employmentid='TEST' where IQXNetUserLinkID='test.agency';
update contactevent set classcode='CI',vacancyid='TESTTESTTESTTESTTEST',employmentid='TEST' where contacteventid='TEST';
select shiftref,SentTo,replace(EventType,' ','!') as A from NetAgencyAdditionalComments('test.agency','VTESTTESTTESTTESTTEST') ;
expect shiftref=Test,SentTo=TestStaff,A=Confirm!Interest;
insert into tempshiftplan (tempshiftplanid,vacancyid,description) values ('TESTTESTTESTTESTTEST','TESTTESTTESTTESTTEST','Test2');
select shiftref,SentTo,replace(EventType,' ','!') as B from NetAgencyAdditionalComments('test.agency','PTESTTESTTESTTESTTEST') ;
expect shiftref=Test,SentTo=TestStaff,B=Confirm!Interest;
update contactevent set classcode='~~',vacancyid=null,employmentid=null where contacteventid='TEST';
update tempshiftplan set vacancyid='TEST' where tempshiftplanid='TEST';
delete from contactevent where contacteventid='TEST';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetAgencyAdditionalComments" IS
{create PROCEDURE pears."NetAgencyAdditionalComments"( in "pWebUserID" char(20),in "pLineID" char(22))
result( "ActionTime" char(20),"SentTo" char(50),"Note" long varchar,shiftref char(10),EventType char(30),ContactDate date,ContactTime time )
// IQXWeb
begin
declare "VacID" char(20);
declare "TempShiftID" char(20);
declare "CompID" char(20);
declare "TempShiftRef" char(20);
declare "VacRef" char(20);
if left(pLineId,1)='V' then
set VacID=right(pLineID,20);
end if;
if left(pLineId,1)='P' then
set TempShiftID=right(pLineID,20);
end if;
set "CompID" = (select top 1 "employment"."companyid" from "employment" key join "iqxnetuserlink" where "iqxnetuserlink"."iqxnetuserid" = "pwebuserid" order by employment.employmentid);
if VacID is null then
set "VacID" = (select VacancyID from "TempShiftPlan" where "tempshiftplanid" = "TempShiftID");
end if;
select distinct
cast("dateformat"("ce"."contactdate",'dd/mm/yyyy') as char)+' '+cast("dateformat"("ce"."contacttime",'hh:nn') as char) as "ActionTime",
"s"."name" as "SentTo",
"ce"."notes" as "Note",
"substring"("ce"."description","charindex"(':',"ce"."description")+1) as "ShiftRef",
cc.classdescrip,
"ce"."contactdate" as "contactdate",
"ce"."contacttime" as "contacttime"
from "vacancy" as "va"
,"tempshiftplan" as "tsp"
right outer join "vacancy" as "va"
key join "contactevent" as "ce"
key join "staff" as "s"
,"contactevent" as "ce"
key join "employment" as "e",
contactevent ce key join contactclass cc
where(("ce"."classcode" in ('CD','CI') and "va"."vacancyid" = "VacID")
and "e"."companyid" = "CompID")
order by "contactdate" desc,"contacttime" desc
end
/* DOC
28-08-2013 Provide additional Comments for the detail line of Current Requirements.
This routine requires contact events with classcode of CD and CI
25-11-2016 PC Doc and Test
17-04-2018 PC modify test
2019-03-04 PC IW-873 add top 1 and order by on subqueries
Tests:
Lineid starting with V with no contact event
Lineid starting with V with contact event
Lineid starting with P with contact event
*/
/* TEST
NetTestSetup('');
delete from contactevent where contacteventid='TEST';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
insert into vacancy (vacancyid,departmentid,employmentid,status,position) values ('TESTTESTTESTTESTTEST','~~','TEST','[','test2');
insert into contactclass (classcode,classdescrip) on existing update defaults off values ('CI','Confirm Interest');
insert into contactclass (classcode,classdescrip) on existing update defaults off values ('CD','Decline Interest');
insert into contactclass (classcode,classdescrip) on existing update defaults off values ('~~','Test');
insert into contactevent (contacteventid,staffid,contactdate,description,classcode) on existing update defaults off values ('TEST','TEST',now(*),'Test','~~');
update iqxnetuserlink set employmentid=null where IQXNetUserLinkID in ('test.candidate','test.client','test.owner');
update iqxnetuserlink set employmentid='TEST' where IQXNetUserLinkID='test.agency';
update contactevent set classcode='CI',vacancyid='TESTTESTTESTTESTTEST',employmentid='TEST' where contacteventid='TEST';
select shiftref,SentTo,replace(EventType,' ','!') as A from NetAgencyAdditionalComments('test.agency','VTESTTESTTESTTESTTEST') ;
expect shiftref=Test,SentTo=TestStaff,A=Confirm!Interest;
insert into tempshiftplan (tempshiftplanid,vacancyid,description) values ('TESTTESTTESTTESTTEST','TESTTESTTESTTESTTEST','Test2');
select shiftref,SentTo,replace(EventType,' ','!') as B from NetAgencyAdditionalComments('test.agency','PTESTTESTTESTTESTTEST') ;
expect shiftref=Test,SentTo=TestStaff,B=Confirm!Interest;
update contactevent set classcode='~~',vacancyid=null,employmentid=null where contacteventid='TEST';
update tempshiftplan set vacancyid='TEST' where tempshiftplanid='TEST';
delete from contactevent where contacteventid='TEST';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
*/
}