====== pears.NetMessage ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetMessage"( in "pWebUserID" char(20),in "ptype" char(20),in "ptitle" char(100),in "pdescription" long varchar,
in "pvacancyid" char(20) default null,in "pplacementid" char(20) default null,in "pprogressid" char(20) default null,
in "pprovtimesheetid" char(20) default null,in "ptimesheetid" char(20) default null )
result( "pResult" char(250) )
// IQXWeb
begin
declare "persid" char(20);
declare "empid" char(20);
if(select "Value" from "IQXNetSwitch" where "IQXNetSwitchID" = 'POPUPDOCUPDISABLE') = 1 then
select '99:~Permission denied';
return
end if;
set "persid" = null;
set "empid" = (select first "employmentid" from "iqxnetuserlink" where "iqxnetuserid" = "pwebuserid");
if "empid" is null then
set "persid" = (select first "personid" from "iqxnetuserlink" where "iqxnetuserid" = "pwebuserid");
if "persid" is null then
select '99:~Permission denied';
return
end if end if;
set "pprovtimesheetid" = "nullif"("trim"("pprovtimesheetid"),'');
set "ptimesheetid" = "nullif"("trim"("ptimesheetid"),'');
if "pprovtimesheetid" is not null then
set "pvacancyid" = (select first "vacancyid" from "tempprovtimesheet" where "tempprovtimesheetid" = "pprovtimesheetid")
end if;
if "ptimesheetid" is not null then
set "pplacementid" = (select first "placementid" from "temptimesheet" where "temptimesheetid" = "ptimesheetid");
set "pvacancyid" = (select first "vacancyid" from "placement" where "placementid" = "pplacementid")
end if;
if "trim"("isnull"("ptype",'')) = '' then
select '101:~Invalid message type';
return
end if;
if "trim"("isnull"("ptitle",'')) = '' then
select '102:~Incomplete message';
return
end if;
call "IQXNetPopup"("pWebUserID","persid","empid","pvacancyid","pplacementid","pprogressid","ptype","ptitle","pdescription");
select '0:~Success'
end /* DOC
2016-08-30 PC test and doc
2018-08-27 PC improve error handler
2019-11-22 GJ Added option to disable popup for document upload (IW-1040)
tests:
invalid person attached to pWebUserID
invalid message type
incomplete message
valid message attached to vacancy
valid message attached to placement
valid message attached to progress
valid message attached to prov timesheet
valid message attached to timesheet
*/
/* TEST
call NetTestSetup('');
select * from NetMessage('test.zz',null,null,null,null,null,null,null);
expect pResult=99*;
select * from NetMessage('test.client','zz',null,null,null,null,null,null);
expect pResult=102*;
select * from NetMessage('test.client','','TestMessage','TestDescription',null,null,null,null);
expect pResult=101*;
select * from NetMessage('test.client','TEST','TestMessage','TestDescription','TEST',null,null,null);
expect pResult=0*;
select top 1 * from diary where staffid='TEST' order by whenentered desc;
expect vacancyid=TEST,employmentid=TEST,description=TestMessage;
delete from diary where staffid='test';
select * from NetMessage('test.client','TEST','TestMessage2','TestDescription2',null,'TEST',null,null);
expect pResult=0*;
select top 1 * from diary where staffid='TEST' order by whenentered desc;
expect vacancyid=TEST,employmentid=TEST,description=TestMessage2;
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetMessage" IS
{create PROCEDURE pears."NetMessage"(in pWebUserID char(20),in ptype char(20),in ptitle char(100),in pdescription long varchar,in pvacancyid char(20) default
null,in pplacementid char(20) default null,in pprogressid char(20) default null,in pprovtimesheetid char(20) default
null,in ptimesheetid char(20) default null)
result(pResult char(250))
// IQXWeb
begin
declare persid char(20);
declare empid char(20);
IF (SELECT "Value" FROM IQXNetSwitch WHERE IQXNetSwitchID = 'POPUPDOCUPDISABLE') = 1 THEN
SELECT '99:~Permission denied';
RETURN;
END IF;
set persid=null;
set empid=(select first employmentid from iqxnetuserlink where iqxnetuserid = pwebuserid);
if empid is null then
set persid=(select first personid from iqxnetuserlink where iqxnetuserid = pwebuserid);
if persid is null then
select '99:~Permission denied';
return
end if
end if;
set pprovtimesheetid=nullif(trim(pprovtimesheetid),'');
set ptimesheetid=nullif(trim(ptimesheetid),'');
if pprovtimesheetid is not null then
set pvacancyid=(select first vacancyid from tempprovtimesheet where tempprovtimesheetid = pprovtimesheetid)
end if;
if ptimesheetid is not null then
set pplacementid=(select first placementid from temptimesheet where temptimesheetid = ptimesheetid);
set pvacancyid=(select first vacancyid from placement where placementid = pplacementid)
end if;
if trim(isnull(ptype,'')) = '' then
select '101:~Invalid message type';
return
end if;
if trim(isnull(ptitle,'')) = '' then
select '102:~Incomplete message';
return
end if;
call IQXNetPopup(pWebUserID,persid,empid,pvacancyid,pplacementid,pprogressid,ptype,ptitle,pdescription);
select '0:~Success'
end
/* DOC
2016-08-30 PC test and doc
2018-08-27 PC improve error handler
2019-11-22 GJ Added option to disable popup for document upload (IW-1040)
tests:
invalid person attached to pWebUserID
invalid message type
incomplete message
valid message attached to vacancy
valid message attached to placement
valid message attached to progress
valid message attached to prov timesheet
valid message attached to timesheet
*/
/* TEST
call NetTestSetup('');
select * from NetMessage('test.zz',null,null,null,null,null,null,null);
expect pResult=99*;
select * from NetMessage('test.client','zz',null,null,null,null,null,null);
expect pResult=102*;
select * from NetMessage('test.client','','TestMessage','TestDescription',null,null,null,null);
expect pResult=101*;
select * from NetMessage('test.client','TEST','TestMessage','TestDescription','TEST',null,null,null);
expect pResult=0*;
select top 1 * from diary where staffid='TEST' order by whenentered desc;
expect vacancyid=TEST,employmentid=TEST,description=TestMessage;
delete from diary where staffid='test';
select * from NetMessage('test.client','TEST','TestMessage2','TestDescription2',null,'TEST',null,null);
expect pResult=0*;
select top 1 * from diary where staffid='TEST' order by whenentered desc;
expect vacancyid=TEST,employmentid=TEST,description=TestMessage2;
*/
}