pears.NetAgencyCurrentRequirementAdditionalComments

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

CREATE PROCEDURE "pears"."NetAgencyCurrentRequirementAdditionalComments"( IN "pWebUserID" CHAR(20),IN "pLineID" CHAR(22) ) 
RESULT( "ActionTime" CHAR(20),"SentTo" CHAR(50),"Note" long VARCHAR,"shiftref" CHAR(255),"EventType" CHAR(30),"ContactDate" CHAR(10),"ContactTime" CHAR(10) ) 
// IQXWeb
BEGIN
  DECLARE "VacID" CHAR(20);
  DECLARE "TempShiftID" CHAR(20);
  DECLARE "CompID" CHAR(20);
  DECLARE "TempShiftRef" CHAR(20);
  DECLARE "VacRef" CHAR(20);
  DECLARE "ConfirmContactClass" CHAR(20);
  DECLARE "DeclineContactClass" CHAR(20);
  DECLARE "ClientCommentClass" CHAR(20);
  DECLARE "SecAgID" CHAR(20);
  SET "SecAgID" = (SELECT top 1 "employment"."companyid" FROM "employment" KEY JOIN "iqxnetuserlink" WHERE "iqxnetuserlink"."iqxnetuserid" = "pwebuserid" ORDER BY "isnull"("employment"."leavedate",CURRENT DATE) ASC);
  IF "left"("pLineId",1) = 'V' THEN
    SET "VacID" = "right"("pLineID",20)
  END IF;
  IF "left"("pLineId",1) = 'P' THEN
    SET "TempShiftID" = "right"("pLineID",20);
    SET "VacID" = (SELECT top 1 "vacancyid" FROM "tempshiftplan" WHERE "tempshiftplanid" = "right"("pLineID",20))
  END IF;
  SET "CompID" = (SELECT FIRST "employment"."companyid" FROM "employment" KEY JOIN "iqxnetuserlink" WHERE "iqxnetuserlink"."iqxnetuserid" = "pwebuserid");
  SET "TempShiftRef" = (SELECT "ShiftSerialNumber" FROM "TempShiftPlan" WHERE "tempshiftplanid" = "TempShiftID");
  SET "ConfirmContactClass" = (SELECT top 1 "classcode" FROM "contactclass" WHERE "classdescrip" = 'Confirm Interest' ORDER BY "sortorder" ASC);
  SET "DeclineContactClass" = (SELECT top 1 "classcode" FROM "contactclass" WHERE "classdescrip" = 'Decline Interest' ORDER BY "sortorder" ASC);
  SET "ClientCommentClass" = (SELECT top 1 "classcode" FROM "contactclass" WHERE "classdescrip" = 'Client Comment' ORDER BY "sortorder" ASC);
  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"
      ,"contactevent" AS "ce" LEFT OUTER JOIN "person" AS "p" LEFT OUTER JOIN "pay_employee" AS "pe"
    WHERE(("ce"."classcode" IN( "ConfirmContactClass","DeclineContactClass","ClientCommentClass" ) AND "va"."vacancyid" = "VacID")
    AND "e"."companyid" = "SecAgID")
    --and pe.secondaryagencyid=SecAgID
    ORDER BY "contactdate" DESC,"contacttime" DESC
END /* DOC
2013-08-28 PC Provide additional Comments for the detail line of Current Requirements
2016-10-06 PC set retreive confirm / decline / Note entry from contact event table
2017-01-19 PC filter by events belonging to agency candidates only
2018-05-03 PC revise test routines
2019-03-05 PC IW-873 add top 1 and order by on subqueries
 
This routine requires three contact event types which must contain the following text:
Confirm Interest
Decline Interest
Client Comment
*/
/* TEST
call NetTestSetup('');
update iqxnetuserlink set employmentid=null where IQXNetUserLinkID in ('test.candidate','test.client','test.owner');
update iqxnetuserlink set employmentid='TEST' where IQXNetUserLinkID='test.agency';
delete from contactevent where contacteventid like 'TEST%';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
insert into vacancy (vacancyid,departmentid,employmentid,status,position,staffid) values ('TESTTESTTESTTESTTEST','~~','TEST','[','test2','test');
insert into tempshiftplan (tempshiftplanid,vacancyid,description) on existing update defaults off values ('TESTTESTTESTTESTTEST','TESTTESTTESTTESTTEST','test2');
insert into "contactevent"( "contacteventid","vacancyid","staffid","employmentid","contactdate","contacttime","description","classcode","notes",whoentered,personid ) values
('TEST1','TESTTESTTESTTESTTEST','TEST','TEST',dateformat(now(*),'yyyy-mm-dd'),dateformat(now(*),'hh:mm:ss'),'Add comment:',(select top 1 classcode from contactclass where classdescrip='Confirm Interest' order by sortorder),'TestNote','TEST','TEST');
insert into pay_employee (personid,secondaryagencyid) on existing update defaults off values ('TEST','TEST');
select * from NetAgencyCurrentRequirementAdditionalComments('test.agency','VTESTTESTTESTTESTTEST');
expect SentTo=TestStaff,Note=TestNote;
expect EOF;
select * from NetAgencyCurrentRequirementAdditionalComments('test.agency','PTESTTESTTESTTESTTEST');
expect SentTo=TestStaff,Note=TestNote;
update pay_employee set secondaryagencyid='TEST' where personid='TEST';
select * from NetAgencyCurrentRequirementAdditionalComments('test.agency','PTESTTESTTESTTESTTEST');
expect SentTo=TestStaff,Note=TestNote;
expect EOF;
delete from contactevent where vacancyid='TESTTESTTESTTESTTEST';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
*/
GO
 
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetAgencyCurrentRequirementAdditionalComments" IS 
{CREATE PROCEDURE pears."NetAgencyCurrentRequirementAdditionalComments"( IN "pWebUserID" CHAR(20),IN "pLineID" CHAR(22)) 
RESULT( "ActionTime" CHAR(20),"SentTo" CHAR(50),"Note" long VARCHAR,shiftref CHAR(255),EventType CHAR(30),ContactDate CHAR(10),ContactTime CHAR(10) ) 
// IQXWeb
BEGIN
  DECLARE "VacID" CHAR(20);
  DECLARE "TempShiftID" CHAR(20);
  DECLARE "CompID" CHAR(20);
  DECLARE "TempShiftRef" CHAR(20);
  DECLARE "VacRef" CHAR(20);
  DECLARE ConfirmContactClass CHAR(20);
  DECLARE DeclineContactClass CHAR(20);
  DECLARE ClientCommentClass CHAR(20);
  DECLARE SecAgID CHAR(20);
  SET SecAgID = (SELECT top 1 "employment"."companyid" FROM "employment" KEY JOIN "iqxnetuserlink" WHERE "iqxnetuserlink"."iqxnetuserid" = "pwebuserid" ORDER BY isnull(employment.leavedate,CURRENT DATE));
  IF LEFT(pLineId,1)='V' THEN
    SET VacID=RIGHT(pLineID,20);
  END IF;
  IF LEFT(pLineId,1)='P' THEN
    SET TempShiftID=RIGHT(pLineID,20);
    SET VacID=(SELECT top 1 vacancyid FROM tempshiftplan WHERE tempshiftplanid=RIGHT(pLineID,20));
  END IF;
  SET "CompID" = (SELECT FIRST "employment"."companyid" FROM "employment" KEY JOIN "iqxnetuserlink" WHERE "iqxnetuserlink"."iqxnetuserid" = "pwebuserid");
  SET "TempShiftRef" = (SELECT "ShiftSerialNumber" FROM "TempShiftPlan" WHERE "tempshiftplanid" = "TempShiftID");
  SET ConfirmContactClass = (SELECT top 1 classcode FROM contactclass WHERE classdescrip='Confirm Interest' ORDER BY sortorder);
  SET DeclineContactClass = (SELECT top 1 classcode FROM contactclass WHERE classdescrip='Decline Interest' ORDER BY sortorder);
  SET ClientCommentClass = (SELECT top 1 classcode FROM contactclass WHERE classdescrip='Client Comment' ORDER BY sortorder);
  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,
    contactevent ce LEFT OUTER JOIN person p LEFT OUTER JOIN pay_employee pe
    WHERE(("ce"."classcode" IN (ConfirmContactClass,DeclineContactClass,ClientCommentClass) AND "va"."vacancyid" = "VacID")
    AND "e"."companyid" = "SecAgID")
    --and pe.secondaryagencyid=SecAgID
    ORDER BY "contactdate" DESC,"contacttime" DESC
END
 
/* DOC
2013-08-28 PC Provide additional Comments for the detail line of Current Requirements
2016-10-06 PC set retreive confirm / decline / Note entry from contact event table
2017-01-19 PC filter by events belonging to agency candidates only
2018-05-03 PC revise test routines
2019-03-05 PC IW-873 add top 1 and order by on subqueries
 
This routine requires three contact event types which must contain the following text:
    Confirm Interest
    Decline Interest
    Client Comment
*/
 
/* TEST
call NetTestSetup('');
update iqxnetuserlink set employmentid=null where IQXNetUserLinkID in ('test.candidate','test.client','test.owner');
update iqxnetuserlink set employmentid='TEST' where IQXNetUserLinkID='test.agency';
delete from contactevent where contacteventid like 'TEST%';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
insert into vacancy (vacancyid,departmentid,employmentid,status,position,staffid) values ('TESTTESTTESTTESTTEST','~~','TEST','[','test2','test');
insert into tempshiftplan (tempshiftplanid,vacancyid,description) on existing update defaults off values ('TESTTESTTESTTESTTEST','TESTTESTTESTTESTTEST','test2');
insert into "contactevent"( "contacteventid","vacancyid","staffid","employmentid","contactdate","contacttime","description","classcode","notes",whoentered,personid ) values
        ('TEST1','TESTTESTTESTTESTTEST','TEST','TEST',dateformat(now(*),'yyyy-mm-dd'),dateformat(now(*),'hh:mm:ss'),'Add comment:',(select top 1 classcode from contactclass where classdescrip='Confirm Interest' order by sortorder),'TestNote','TEST','TEST');
insert into pay_employee (personid,secondaryagencyid) on existing update defaults off values ('TEST','TEST');
select * from NetAgencyCurrentRequirementAdditionalComments('test.agency','VTESTTESTTESTTESTTEST');
expect SentTo=TestStaff,Note=TestNote;
expect EOF;
select * from NetAgencyCurrentRequirementAdditionalComments('test.agency','PTESTTESTTESTTESTTEST');
expect SentTo=TestStaff,Note=TestNote;
update pay_employee set secondaryagencyid='TEST' where personid='TEST';
select * from NetAgencyCurrentRequirementAdditionalComments('test.agency','PTESTTESTTESTTESTTEST');
expect SentTo=TestStaff,Note=TestNote;
expect EOF;
delete from contactevent where vacancyid='TESTTESTTESTTESTTEST';
delete from vacancy where vacancyid='TESTTESTTESTTESTTEST';
*/
}
  • database/procedures/pears_netagencycurrentrequirementadditionalcomments.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1