====== pears.NetOwnerDiary ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create procedure "pears"."NetOwnerDiary"( in "pWebUserID" char(20), in "pConsultantID" char(20) default null, in "pStartDate" char(30) default null, in "pEndDate" char(30) default null, in "pSlice" integer default 0, in "pSliceSize" integer default 1000 ) result( "DiaryID" char(20), "Description" char(100), "DiaryFrom" char(30), "DiaryTo" char(30), "Status" char(1), "Priority" char(1), "Notes" long varchar, "Speil" char(255), "PopupMinutes" char(5), "ContactName" char(60), "CandName" char(60), "CompanyName" char(60), "VacPos" char(60), "CandID" char(20), "VacID" char(20), "ContactID" char(20) ) // IQXWeb begin declare "xStartDate" timestamp; declare "xEndDate" timestamp; declare "WhoseDiary" char(20); declare "x" integer; declare "y" integer; set "x" = "isNull"("pSliceSize",100); set "y" = "x"*"isNull"("pSlice",0)+1; set "xStartDate" = "isnull"("NetStringToTimestamp"("pStartDate"),current date-7); set "xEndDate" = "isnull"("NetStringToTimestamp"("pEndDate"),current date+30); set "WhoseDiary" = "isnull"("pConsultantID",(select top 1 "staffid" from "iqxnetuser" where "iqxnetuserid" = "pWebUserID" order by "loginid" asc)); select top "x" start at "y" "d"."diaryid" as "DiaryID", "d"."description" as "Description", "dateformat"("d"."diaryfrom",'dd/mm/yyyy HH:nn') as "DiaryFrom", "dateformat"("d"."diaryto",'dd/mm/yyyy HH:nn') as "DiaryTo", (if "d"."DurationType" = 'R' then 'R' else 'A' endif) as "Status", "isnull"("d"."priority",0) as "Priority", "d"."notes" as "Notes", ((if "isnull"("ContactName",'') <> '' then 'With '+"ContactName"+' of '+"CompanyName" endif) +(if "isnull"("CandName",'') <> '' and "isnull"("ContactName",'') <> '' then ' and ' endif) +(if "isnull"("CandName",'') <> '' and "isnull"("ContactName",'') = '' then 'With ' endif) +"CandName" +(if "isnull"("VacPos",'') <> '' then ' regarding '+"VacPos" endif)) as "Speil", "d"."PopupMinutes", "p"."name" as "ContactName", "pe"."name" as "CandName", "c"."name" as "CompanyName", "v"."position" as "VacPos", "d"."personid" as "CandID", "d"."vacancyid" as "VacID", "d"."employmentid" as "ContactID" from "diary" as "d" key join "staff" as "s" left outer join "iqxnetuser" as "u" ,"diary" as "d" left outer join "employment" as "e" left outer join "person" as "p" ,"employment" as "e" left outer join "company" as "c" ,"diary" as "d" left outer join "person" as "pe" ,"diary" as "d" left outer join "vacancy" as "v" where "s"."staffid" = "WhoseDiary" and "d"."diaryfrom" <= "xEndDate" and "isNull"("d"."diaryto","d"."diaryfrom") >= "xStartDate" order by "d"."DiaryFrom" asc end /* DOC 2016-07-25 PC Provide master list for Owner diary 2016-09-09 PC GJ remove date filter, but keep it handy for the moment. Remember to re-edit the TEST section 2016-09-30 PC modify date format to match NetOwnerDiarySet 2018-02-15 PC OP-29 allow consultants to view other calendars 2018-03-15 PC modify method of selection of 'other' staff 2018-05-14 GJ Removed order by priority 2018-07-23 PC revise test routines 2018-08-01 PC modify date parameters and add pSlice 2018-08-03 ET modify date filter now uses a string input (e.g. 2018-02-02 20:10) which is converted to a time stamp. Tests: Create three records, 2 months in past, today and one month in future should return default dataset limited to month start-7 and month end+7 should return dataset limited to one month in past and month end+7 should return dataset limited to three days in past and month end+7 should return dataset limited to three months in past and one month in future should return dataset limited to between one month and three months in future should return dataset limited to between today and one month in future should return default dataset limited to month start-7 and month end+7, ordered by priority */ /* 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 diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) on existing update values ('TEST1','TEST','TEST','TEST','TEST',now(*),now(*),'TestEntry','TestEntryNotes',now(*),'TEST','5'); insert into diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) on existing update values ('TEST2','TEST','TEST','TEST','TEST',dateadd(mm,-2,now(*)),dateadd(mm,-2,now(*)),'TestEntry2','TestEntryNotes2',now(*),'TEST','5'); insert into diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) on existing update values ('TEST3','TEST','TEST','TEST','TEST',dateadd(mm,2,now(*)),dateadd(mm,2,now(*)),'TestEntry3','TestEntryNotes3',now(*),'TEST','5'); select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,null,null) where diaryid like 'test%' order by diaryid; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,-1,now(*)),null) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,-3,now(*)),null) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,-3,now(*)),dateadd(mm,-1,now(*))) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,1,now(*)),dateadd(mm,3,now(*))) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,1,now(*))) where diaryid like 'test%'; insert into diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) values ('TEST4','TEST','TEST','TEST','TEST',now(*),now(*),'TestEntry4','TestEntryNotes4',now(*),'TEST','1'); select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,null,null) where diaryid like 'test%' order by DiaryID; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; expect DiaryID=TEST4,Description=TestEntry4,Status=R,Priority=1,Notes=TestEntryNotes4; */ go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetOwnerDiary" IS {create PROCEDURE pears."NetOwnerDiary"( in pWebUserID char(20), in pConsultantID char(20) default null, in pStartDate char(30) default null, in pEndDate char(30) default null, in pSlice integer default 0, in pSliceSize integer default 1000 ) RESULT( DiaryID char(20), Description char(100), DiaryFrom char(30), DiaryTo char(30), Status char(1), Priority char(1), Notes long varchar, Speil char(255), PopupMinutes char(5), ContactName char(60), CandName char(60), CompanyName char(60), VacPos char(60), CandID char(20), VacID char(20), ContactID char(20) ) // IQXWeb BEGIN declare xStartDate timestamp; declare xEndDate timestamp; declare WhoseDiary char(20); declare x integer; declare y integer; set x=isNull(pSliceSize, 100); set y=x*isNull(pSlice, 0)+1; set xStartDate=isnull(NetStringToTimestamp(pStartDate), current date - 7); set xEndDate=isnull(NetStringToTimestamp(pEndDate), current date + 30); set WhoseDiary=isnull(pConsultantID,(select top 1 staffid from iqxnetuser where iqxnetuserid=pWebUserID order by loginid)); select top x start at y d.diaryid as DiaryID, d.description as Description, dateformat(d.diaryfrom,'dd/mm/yyyy HH:nn') as DiaryFrom, dateformat(d.diaryto,'dd/mm/yyyy HH:nn') as DiaryTo, (if d.DurationType = 'R' then 'R' else 'A' endif) as Status, isnull(d.priority,0) as Priority, d.notes as Notes, ((if isnull(ContactName,'')!='' then 'With ' + ContactName + ' of ' + CompanyName endif) + (if isnull(CandName,'')!='' and isnull(ContactName,'')!='' then ' and ' endif) + (if isnull(CandName,'')!='' and isnull(ContactName,'')='' then 'With ' endif) + CandName + (if isnull(VacPos,'')!='' then ' regarding ' + VacPos endif)) as Speil, d.PopupMinutes, p.name as ContactName, pe.name as CandName, c.name as CompanyName, v.position as VacPos, d.personid as CandID, d.vacancyid as VacID, d.employmentid as ContactID from diary d key join staff s left join iqxnetuser u, diary d left join employment e left join person p, employment e left join company c, diary d left join person pe, diary d left join vacancy v where s.staffid=WhoseDiary and d.diaryfrom <= xEndDate and isNull(d.diaryto, d.diaryfrom) >= xStartDate order by d.DiaryFrom END /* DOC 2016-07-25 PC Provide master list for Owner diary 2016-09-09 PC GJ remove date filter, but keep it handy for the moment. Remember to re-edit the TEST section 2016-09-30 PC modify date format to match NetOwnerDiarySet 2018-02-15 PC OP-29 allow consultants to view other calendars 2018-03-15 PC modify method of selection of 'other' staff 2018-05-14 GJ Removed order by priority 2018-07-23 PC revise test routines 2018-08-01 PC modify date parameters and add pSlice 2018-08-03 ET modify date filter now uses a string input (e.g. 2018-02-02 20:10) which is converted to a time stamp. Tests: Create three records, 2 months in past, today and one month in future should return default dataset limited to month start-7 and month end+7 should return dataset limited to one month in past and month end+7 should return dataset limited to three days in past and month end+7 should return dataset limited to three months in past and one month in future should return dataset limited to between one month and three months in future should return dataset limited to between today and one month in future should return default dataset limited to month start-7 and month end+7, ordered by priority */ /* 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 diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) on existing update values ('TEST1','TEST','TEST','TEST','TEST',now(*),now(*),'TestEntry','TestEntryNotes',now(*),'TEST','5'); insert into diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) on existing update values ('TEST2','TEST','TEST','TEST','TEST',dateadd(mm,-2,now(*)),dateadd(mm,-2,now(*)),'TestEntry2','TestEntryNotes2',now(*),'TEST','5'); insert into diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) on existing update values ('TEST3','TEST','TEST','TEST','TEST',dateadd(mm,2,now(*)),dateadd(mm,2,now(*)),'TestEntry3','TestEntryNotes3',now(*),'TEST','5'); select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,null,null) where diaryid like 'test%' order by diaryid; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,-1,now(*)),null) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,-3,now(*)),null) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,-3,now(*)),dateadd(mm,-1,now(*))) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,1,now(*)),dateadd(mm,3,now(*))) where diaryid like 'test%'; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,dateadd(mm,1,now(*))) where diaryid like 'test%'; insert into diary (diaryid,staffid,personid,vacancyid,employmentid,diaryfrom,diaryto,description,notes,whenentered,whoentered,priority) values ('TEST4','TEST','TEST','TEST','TEST',now(*),now(*),'TestEntry4','TestEntryNotes4',now(*),'TEST','1'); select DiaryID,Description,Status,Priority,Notes from NetOwnerDiary('TEST.OWNER',null,null,null) where diaryid like 'test%' order by DiaryID; expect DiaryID=TEST1,Description=TestEntry,Status=R,Priority=5,Notes=TestEntryNotes; expect DiaryID=TEST4,Description=TestEntry4,Status=R,Priority=1,Notes=TestEntryNotes4; */ }