251 lines
7.2 KiB
Plaintext
251 lines
7.2 KiB
Plaintext
CREATE OR REPLACE PACKAGE BODY EFT_NOM.saco_documents IS
|
|
|
|
/*
|
|
* $Header: /Isle Of Grain/database/PLSQL/saco_documents.pck 1 7/01/05 12:54 Gilberta $
|
|
* $Revision: 1 $
|
|
*
|
|
*/
|
|
PROCEDURE upload_form IS
|
|
|
|
FUNCTION language_label RETURN VARCHAR2 IS
|
|
BEGIN
|
|
RETURN htf.bold(caco_utilities.get_module_text(p_text_number => 14));
|
|
END language_label;
|
|
|
|
FUNCTION language_selection RETURN VARCHAR2 IS
|
|
v_string VARCHAR2(32767);
|
|
BEGIN
|
|
v_string := v_string || htf.formselectopen(cname => 'p_language');
|
|
FOR v_languages IN (SELECT cg.rv_low_value
|
|
,cg.rv_meaning
|
|
,decode(rv_low_value
|
|
,'EN'
|
|
,1
|
|
,NULL) AS selected
|
|
FROM cg_ref_codes cg
|
|
WHERE cg.rv_domain = 'LANGUAGE'
|
|
ORDER BY cg.rv_low_value) LOOP
|
|
v_string := v_string ||
|
|
htf.formselectoption(cvalue => v_languages.rv_meaning
|
|
,cattributes => 'Value="' ||
|
|
v_languages.rv_low_value || '"'
|
|
,cselected => v_languages.selected);
|
|
END LOOP;
|
|
v_string := v_string || htf.formselectclose;
|
|
RETURN v_string;
|
|
END language_selection;
|
|
|
|
FUNCTION file_label RETURN VARCHAR2 IS
|
|
BEGIN
|
|
RETURN htf.bold(caco_utilities.get_module_text(p_text_number => 543));
|
|
END file_label;
|
|
|
|
FUNCTION file_selection RETURN VARCHAR2 IS
|
|
BEGIN
|
|
RETURN '<INPUT TYPE="FILE" NAME="p_file">';
|
|
END file_selection;
|
|
|
|
FUNCTION description_label RETURN VARCHAR2 IS
|
|
BEGIN
|
|
RETURN htf.bold(caco_utilities.get_module_text(p_text_number => 20));
|
|
END description_label;
|
|
|
|
FUNCTION description_selection RETURN VARCHAR2 IS
|
|
BEGIN
|
|
RETURN htf.formtext(cname => 'p_description');
|
|
END description_selection;
|
|
|
|
BEGIN
|
|
htp.htmlopen;
|
|
htp.headopen;
|
|
htp.title(ctitle => caco_utilities.get_module_text(p_text_number => 1023) || ': ' ||
|
|
caco_utilities.get_module_text(p_text_number => 1022));
|
|
htp.linkrel('stylesheet'
|
|
,'caco_system.css?p_type=general');
|
|
htp.headclose;
|
|
htp.bodyopen;
|
|
htp.print(caco_system.menu);
|
|
|
|
htp.header(nsize => 1
|
|
,cheader => caco_utilities.get_module_text(p_text_number => 1022));
|
|
|
|
htp.formopen(curl => 'saco_documents.upload'
|
|
,cmethod => 'POST'
|
|
,cenctype => 'multipart/form-data');
|
|
|
|
htp.tableopen;
|
|
|
|
htp.tablerowopen;
|
|
htp.tabledata(cvalue => file_label);
|
|
htp.tabledata(cvalue => file_selection);
|
|
htp.tablerowclose;
|
|
|
|
htp.tablerowopen;
|
|
htp.tabledata(cvalue => language_label);
|
|
htp.tabledata(cvalue => language_selection);
|
|
htp.tablerowclose;
|
|
|
|
htp.tablerowopen;
|
|
htp.tabledata(cvalue => description_label);
|
|
htp.tabledata(cvalue => description_selection);
|
|
htp.tablerowclose;
|
|
|
|
htp.tableclose;
|
|
|
|
htp.br;
|
|
|
|
htp.formsubmit;
|
|
htp.formclose;
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
htp.p(SQLERRM);
|
|
END upload_form;
|
|
|
|
PROCEDURE upload(p_language IN VARCHAR2
|
|
,p_file IN VARCHAR2
|
|
,p_description IN VARCHAR2) IS
|
|
BEGIN
|
|
|
|
UPDATE documents d
|
|
SET d.description = p_description
|
|
,d.LANGUAGE = p_language
|
|
WHERE d.NAME = p_file;
|
|
|
|
htp.htmlopen;
|
|
htp.headopen;
|
|
htp.title(ctitle => caco_utilities.get_module_text(p_text_number => 1022) || ': ' ||
|
|
caco_utilities.get_module_text(p_text_number => 1021));
|
|
htp.linkrel('stylesheet'
|
|
,'caco_system.css?p_type=help');
|
|
htp.headclose;
|
|
htp.bodyopen;
|
|
htp.print(caco_system.menu);
|
|
htp.header(nsize => 1
|
|
,cheader => caco_utilities.get_module_text(p_text_number => 1020) || ': ' ||
|
|
caco_utilities.get_module_text(p_text_number => 1021));
|
|
|
|
htp.bold('Language ' || p_language || htf.br || 'Filename ' || p_file ||
|
|
htf.br);
|
|
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
END upload;
|
|
|
|
PROCEDURE download_form IS
|
|
BEGIN
|
|
NULL;
|
|
END download_form;
|
|
|
|
PROCEDURE download_document(p_docu_id IN documents.docu_id%TYPE) IS
|
|
v_length NUMBER;
|
|
v_mime_type documents.mime_type%TYPE;
|
|
v_name documents.NAME%TYPE;
|
|
BEGIN
|
|
SELECT dbms_lob.getlength(d.blob_content)
|
|
,d.mime_type
|
|
,d.NAME
|
|
INTO v_length
|
|
,v_mime_type
|
|
,v_name
|
|
FROM documents d
|
|
WHERE d.docu_id = p_docu_id;
|
|
owa_util.mime_header(ccontent_type => v_mime_type
|
|
,bclose_header => FALSE);
|
|
htp.p('Content-Length: ' || v_length);
|
|
owa_util.http_header_close;
|
|
wpg_docload.download_file(p_filename => v_name);
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
htp.htmlopen;
|
|
htp.headopen;
|
|
htp.title(ctitle => 'ERROR!');
|
|
htp.headclose;
|
|
htp.bodyopen;
|
|
htp.p(SQLERRM);
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
END download_document;
|
|
|
|
PROCEDURE download(p_file IN VARCHAR2) IS
|
|
BEGIN
|
|
caco_debug.debug_on;
|
|
caco_debug.putline('download passed ' || p_file);
|
|
wpg_docload.download_file(p_file);
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
htp.p(SQLERRM);
|
|
caco_debug.putline('download ' || SQLERRM);
|
|
RETURN;
|
|
END download;
|
|
|
|
PROCEDURE download IS
|
|
v_filename documents.NAME%TYPE := owa_util.get_cgi_env('PATH_INFO');
|
|
BEGIN
|
|
--
|
|
-- account for case conversion and the fact that stored
|
|
-- file names do not have the leading '/'
|
|
--
|
|
SELECT NAME
|
|
INTO v_filename
|
|
FROM documents
|
|
WHERE '/' || upper(NAME) = upper(v_filename);
|
|
|
|
wpg_docload.download_file(v_filename);
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
htp.p(SQLERRM);
|
|
END download;
|
|
|
|
PROCEDURE test_download IS
|
|
v_name documents.NAME%TYPE;
|
|
BEGIN
|
|
SELECT NAME
|
|
INTO v_name
|
|
FROM documents
|
|
WHERE mime_type LIKE '%pdf%' AND rownum < 2;
|
|
download(p_file => v_name);
|
|
END test_download;
|
|
|
|
PROCEDURE embed_document(p_docu_id IN documents.docu_id%TYPE) IS
|
|
v_mime_type documents.mime_type%TYPE;
|
|
v_name documents.NAME%TYPE;
|
|
BEGIN
|
|
SELECT d.mime_type
|
|
,d.NAME
|
|
INTO v_mime_type
|
|
,v_name
|
|
FROM documents d
|
|
WHERE d.docu_id = p_docu_id;
|
|
|
|
htp.p('<embed src="saco_documents.download_document?p_docu_id=' ||
|
|
p_docu_id || '" type="' || v_mime_type ||
|
|
'" height="200" width="200">');
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
htp.bold('Looking for Document ' || p_docu_id || ':' || SQLERRM);
|
|
END embed_document;
|
|
|
|
PROCEDURE test_embed IS
|
|
BEGIN
|
|
htp.htmlopen;
|
|
htp.bodyopen;
|
|
FOR v_data IN (SELECT docu_id
|
|
FROM documents
|
|
WHERE mime_type NOT LIKE '%download%') LOOP
|
|
htp.br;
|
|
embed_document(v_data.docu_id);
|
|
END LOOP;
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
END test_embed;
|
|
|
|
BEGIN
|
|
-- Initialization
|
|
NULL;
|
|
END saco_documents;
|
|
/
|
|
|