Amended site_file_assocations to point at new DOCUMENTS and DOCUMENT_ROLES tables.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3008 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2007-12-17 10:15:56 +00:00
parent bb77d61785
commit ed275a4a8a

View File

@@ -7,9 +7,9 @@ CREATE OR REPLACE PACKAGE mip_enquiry IS
-- --
-- Public function and procedure declarations -- Public function and procedure declarations
FUNCTION set_enquiry_role(p_enquiryid IN NUMBER, FUNCTION set_enquiry_role(p_enquiryid IN NUMBER
p_partyid IN NUMBER, ,p_partyid IN NUMBER
p_rolecode IN VARCHAR2) RETURN BOOLEAN; ,p_rolecode IN VARCHAR2) RETURN BOOLEAN;
/* /*
FUNCTION set_enquiry_role FUNCTION set_enquiry_role
@@ -20,14 +20,17 @@ CREATE OR REPLACE PACKAGE mip_enquiry IS
%param p_rolecode - what kind of role this will be. %param p_rolecode - what kind of role this will be.
%param p_description - a description for the enquiry role %param p_description - a description for the enquiry role
*/ */
FUNCTION set_enquiry_role(p_enquiryid IN NUMBER, FUNCTION set_enquiry_role(p_enquiryid IN NUMBER
p_partyid IN NUMBER, ,p_partyid IN NUMBER
p_rolecode IN VARCHAR2, ,p_rolecode IN VARCHAR2
p_description IN VARCHAR2) RETURN BOOLEAN; ,p_description IN VARCHAR2) RETURN BOOLEAN;
FUNCTION set_file_association(p_enquiryid IN NUMBER
,p_fileid IN VARCHAR2
,p_description IN VARCHAR2) RETURN BOOLEAN;
-- --
FUNCTION set_enquiry_event(p_enquiryid IN NUMBER, FUNCTION set_enquiry_event(p_enquiryid IN NUMBER
p_eventcode IN VARCHAR2) RETURN BOOLEAN; ,p_eventcode IN VARCHAR2) RETURN BOOLEAN;
/* /*
FUNCTION copy_enquiry FUNCTION copy_enquiry
@@ -41,9 +44,9 @@ CREATE OR REPLACE PACKAGE mip_enquiry IS
-- NOTE: there is no need to copy any quote information. All quotes will be -- NOTE: there is no need to copy any quote information. All quotes will be
-- regenerated for the new enquiry when submitted. -- regenerated for the new enquiry when submitted.
*/ */
FUNCTION copy_enquiry(p_enquiry_id enquiries.id%TYPE, FUNCTION copy_enquiry(p_enquiry_id enquiries.id%TYPE
p_enqu_owner parties.id%TYPE, ,p_enqu_owner parties.id%TYPE
p_enqu_supp parties.id%TYPE) RETURN VARCHAR2; ,p_enqu_supp parties.id%TYPE) RETURN VARCHAR2;
-- --
END mip_enquiry; END mip_enquiry;
@@ -57,15 +60,21 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
%param p_partyid - the user or party to assign to this role. %param p_partyid - the user or party to assign to this role.
%param p_rolecode - what kind of role this will be. %param p_rolecode - what kind of role this will be.
*/ */
FUNCTION set_enquiry_role(p_enquiryid IN NUMBER, FUNCTION set_enquiry_role(p_enquiryid IN NUMBER
p_partyid IN NUMBER, ,p_partyid IN NUMBER
p_rolecode IN VARCHAR2) RETURN BOOLEAN AS ,p_rolecode IN VARCHAR2) RETURN BOOLEAN AS
BEGIN BEGIN
INSERT INTO enquiry_roles INSERT INTO enquiry_roles
(enqu_id, prty_id, start_date, rt_code) (enqu_id
,prty_id
,start_date
,rt_code)
VALUES VALUES
(p_enquiryid, p_partyid, SYSDATE, p_rolecode); (p_enquiryid
,p_partyid
,SYSDATE
,p_rolecode);
RETURN TRUE; RETURN TRUE;
-- --
@@ -85,16 +94,24 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
%param p_rolecode - what kind of role this will be. %param p_rolecode - what kind of role this will be.
%param p_description - a description for the enquiry role %param p_description - a description for the enquiry role
*/ */
FUNCTION set_enquiry_role(p_enquiryid IN NUMBER, FUNCTION set_enquiry_role(p_enquiryid IN NUMBER
p_partyid IN NUMBER, ,p_partyid IN NUMBER
p_rolecode IN VARCHAR2, ,p_rolecode IN VARCHAR2
p_description IN VARCHAR2) RETURN BOOLEAN AS ,p_description IN VARCHAR2) RETURN BOOLEAN AS
BEGIN BEGIN
INSERT INTO enquiry_roles INSERT INTO enquiry_roles
(enqu_id, prty_id, start_date, rt_code, description) (enqu_id
,prty_id
,start_date
,rt_code
,description)
VALUES VALUES
(p_enquiryid, p_partyid, SYSDATE, p_rolecode, p_description); (p_enquiryid
,p_partyid
,SYSDATE
,p_rolecode
,p_description);
RETURN TRUE; RETURN TRUE;
-- --
@@ -103,6 +120,45 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
RETURN FALSE; RETURN FALSE;
END set_enquiry_role; END set_enquiry_role;
-- --
FUNCTION set_file_association(p_enquiryid IN NUMBER
,p_fileid IN VARCHAR2
,p_description IN VARCHAR2) RETURN BOOLEAN AS
l_docu_id documents.id%TYPE;
BEGIN
-- the document is stored by APEX in the standard 'files' table
-- record the 'additional' document details in our own table.
INSERT INTO documents
(id
,docu_type
,uri
,description)
VALUES
(docu_seq.NEXTVAL
,'INDO'
,p_fileid
,p_description)
RETURNING id INTO l_docu_id;
--record the role of this document for the enquiry
INSERT INTO document_roles
(id
,rt_code
,start_date
,description
,enqu_id
,doro_type
,docu_id)
VALUES
(doro_seq.NEXTVAL
,'GENERATED QUOTATION'
,SYSDATE
,p_description
,p_enquiryid
,'ENDO'
,l_docu_id);
RETURN TRUE;
--
END set_file_association;
/* /*
FUNCTION set_enquiry_event FUNCTION set_enquiry_event
@@ -111,14 +167,18 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
%param p_enquiryid - the current enquiry to save the event role against. %param p_enquiryid - the current enquiry to save the event role against.
%param p_eventcode - what kind of event role this will be. %param p_eventcode - what kind of event role this will be.
*/ */
FUNCTION set_enquiry_event(p_enquiryid IN NUMBER, FUNCTION set_enquiry_event(p_enquiryid IN NUMBER
p_eventcode IN VARCHAR2) RETURN BOOLEAN AS ,p_eventcode IN VARCHAR2) RETURN BOOLEAN AS
BEGIN BEGIN
INSERT INTO enquiry_events INSERT INTO enquiry_events
(enqu_id, event_date, enst_code) (enqu_id
,event_date
,enst_code)
VALUES VALUES
(p_enquiryid, SYSDATE, p_eventcode); (p_enquiryid
,SYSDATE
,p_eventcode);
RETURN TRUE; RETURN TRUE;
-- --
@@ -141,17 +201,20 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
-- NOTE: there is no need to copy any quote information. All quotes will be -- NOTE: there is no need to copy any quote information. All quotes will be
-- regenerated for the new enquiry when submitted. -- regenerated for the new enquiry when submitted.
*/ */
FUNCTION copy_enquiry(p_enquiry_id enquiries.id%TYPE, FUNCTION copy_enquiry(p_enquiry_id enquiries.id%TYPE
p_enqu_owner parties.id%TYPE, ,p_enqu_owner parties.id%TYPE
p_enqu_supp parties.id%TYPE) RETURN VARCHAR2 IS ,p_enqu_supp parties.id%TYPE) RETURN VARCHAR2 IS
-- --
-- cursor to get a new enquiry ID from the sequence -- cursor to get a new enquiry ID from the sequence
CURSOR c_get_new_id IS CURSOR c_get_new_id IS
SELECT enqu_seq.NEXTVAL FROM dual; SELECT enqu_seq.NEXTVAL
FROM dual;
-- cursor to get the current enquiry -- cursor to get the current enquiry
CURSOR c_get_enquiry IS CURSOR c_get_enquiry IS
SELECT * FROM enquiries WHERE id = p_enquiry_id; SELECT *
FROM enquiries
WHERE id = p_enquiry_id;
-- variable to hold the enquiry details returned -- variable to hold the enquiry details returned
l_enqu_row enquiries%ROWTYPE; l_enqu_row enquiries%ROWTYPE;
@@ -166,11 +229,13 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
-- first thing to do is check the user's role allows them to copy enquiries -- first thing to do is check the user's role allows them to copy enquiries
-- only agents and I&C users. -- only agents and I&C users.
IF NOT mip_parties.get_user_role(p_username => v('APP_USER')) IN ('AGENT','ICU', 'MIPADMIN') THEN IF NOT mip_parties.get_user_role(p_username => v('APP_USER')) IN
raise_application_error(-20100,'User '||v('APP_USER') || ' is not permitted to copy enquiries.'); ('AGENT', 'ICU', 'MIPADMIN') THEN
raise_application_error(-20100
,'User ' || v('APP_USER') ||
' is not permitted to copy enquiries.');
END IF; END IF;
-- --
-- try to get the enquiry based on the ID we've been given. -- try to get the enquiry based on the ID we've been given.
-- --
@@ -188,7 +253,8 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
WHEN no_data_found THEN WHEN no_data_found THEN
CLOSE c_get_enquiry; CLOSE c_get_enquiry;
-- couldn't find the enquiry, tell someone -- couldn't find the enquiry, tell someone
raise_application_error(-20100,'Unable to find the specified enquiry. Please try again.'); raise_application_error(-20100
,'Unable to find the specified enquiry. Please try again.');
END; END;
-- --
@@ -201,41 +267,46 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS
EXCEPTION EXCEPTION
WHEN no_data_found THEN WHEN no_data_found THEN
CLOSE c_get_new_id; CLOSE c_get_new_id;
raise_application_error(-20101,'Unable to retrieve a new ID for the enquiry.'); raise_application_error(-20101
,'Unable to retrieve a new ID for the enquiry.');
END; END;
l_enqu_row.id := l_enqu_id; l_enqu_row.id := l_enqu_id;
-- now do the insert (copy) for the enquiry -- now do the insert (copy) for the enquiry
INSERT INTO enquiries VALUES l_enqu_row; INSERT INTO enquiries
VALUES l_enqu_row;
-- --
-- create an enquiry supplier, add a description of where it was copied from -- create an enquiry supplier, add a description of where it was copied from
l_dummy := set_enquiry_role(p_enquiryid => l_enqu_id, l_dummy := set_enquiry_role(p_enquiryid => l_enqu_id
p_partyid => p_enqu_supp, ,p_partyid => p_enqu_supp
p_rolecode => 'ENQ SUPP', ,p_rolecode => 'ENQ SUPP'
p_description => 'Enquiry copied from enquiry ' || ,p_description => 'Enquiry copied from enquiry ' ||
p_enquiry_id || ' by user ' || p_enquiry_id || ' by user ' ||
v(':APP_USER')); v(':APP_USER'));
IF NOT l_dummy THEN IF NOT l_dummy THEN
raise_application_error(-20102,'Unable to set enquiry supplier.'); raise_application_error(-20102
,'Unable to set enquiry supplier.');
END IF; END IF;
-- create an enquiry owner -- create an enquiry owner
l_dummy := set_enquiry_role(p_enquiryid => l_enqu_id, l_dummy := set_enquiry_role(p_enquiryid => l_enqu_id
p_partyid => p_enqu_owner, ,p_partyid => p_enqu_owner
p_rolecode => 'ENQ OWN'); ,p_rolecode => 'ENQ OWN');
IF NOT l_dummy THEN IF NOT l_dummy THEN
raise_application_error(-20103,'Unable to set enquiry owner.'); raise_application_error(-20103
,'Unable to set enquiry owner.');
END IF; END IF;
-- --
-- set the enquiry event to "In Progress" -- set the enquiry event to "In Progress"
l_dummy := set_enquiry_event(p_enquiryid => l_enqu_id, l_dummy := set_enquiry_event(p_enquiryid => l_enqu_id
p_eventcode => 'INP'); ,p_eventcode => 'INP');
IF NOT l_dummy THEN IF NOT l_dummy THEN
raise_application_error(-20104,'Unable to set enquiry owner.'); raise_application_error(-20104
,'Unable to set enquiry owner.');
END IF; END IF;
-- --