git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@50874 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
804
Data/BulkLoad/EFT/Nominations/plsql/amfrw021$.bdy
Normal file
804
Data/BulkLoad/EFT/Nominations/plsql/amfrw021$.bdy
Normal file
@@ -0,0 +1,804 @@
|
||||
CREATE OR REPLACE PACKAGE BODY amfrw021$ IS
|
||||
--
|
||||
-- Text constants
|
||||
--
|
||||
c_heading CONSTANT NUMBER := 2154;
|
||||
c_active_from CONSTANT NUMBER := 2150;
|
||||
c_active_to CONSTANT NUMBER := 2151;
|
||||
c_customer_name CONSTANT NUMBER := 1145;
|
||||
c_include_exclude CONSTANT NUMBER := 1146;
|
||||
c_submit CONSTANT NUMBER := 1147;
|
||||
c_selectall CONSTANT NUMBER := 1148;
|
||||
c_selectallopen CONSTANT NUMBER := 3926;
|
||||
c_subject CONSTANT NUMBER := 2148;
|
||||
c_message_text CONSTANT NUMBER := 3535;
|
||||
c_customers CONSTANT NUMBER := 1045;
|
||||
c_sms CONSTANT NUMBER := 3959;
|
||||
c_message_sent_to CONSTANT NUMBER := 3927;
|
||||
c_system_user CONSTANT NUMBER := 1057;
|
||||
--
|
||||
-- Other Constants
|
||||
--
|
||||
c_yes CONSTANT VARCHAR2(1) := 'Y';
|
||||
c_date_format CONSTANT VARCHAR2(255) := g_date_format;
|
||||
--
|
||||
-- Global variables
|
||||
--
|
||||
g_active_from_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_active_from);
|
||||
g_active_to_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_active_to);
|
||||
g_subject_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_subject);
|
||||
g_customers VARCHAR2(255) := caco_utilities.get_module_text(c_customers);
|
||||
g_message_text_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_message_text);
|
||||
g_sms_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_sms);
|
||||
g_system_user_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_system_user);
|
||||
--
|
||||
-- Output contents of an array to debug table
|
||||
-- useful for debugging..
|
||||
--
|
||||
PROCEDURE display_vc_arr(arr_name IN VARCHAR2,
|
||||
arr IN owa_util.vc_arr) IS
|
||||
BEGIN
|
||||
--
|
||||
IF arr.COUNT > 0 THEN
|
||||
caco_debug.putline('---------------------------------------');
|
||||
FOR i IN arr.FIRST..arr.LAST LOOP
|
||||
caco_debug.putline(arr_name||': '||i||' = '||arr(i));
|
||||
END LOOP;
|
||||
caco_debug.putline('---------------------------------------');
|
||||
END IF;
|
||||
--
|
||||
END display_vc_arr;
|
||||
--
|
||||
--
|
||||
-- standard web calendar package
|
||||
--
|
||||
PROCEDURE calendar(z_field_name IN VARCHAR2
|
||||
,z_caller_url IN VARCHAR2
|
||||
,z_field_value IN VARCHAR2 DEFAULT NULL
|
||||
,z_field_format IN VARCHAR2 DEFAULT NULL
|
||||
,z_field_prompt IN VARCHAR2 DEFAULT NULL) IS
|
||||
--
|
||||
field_caption VARCHAR2(2000);
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
IF z_field_prompt IS NULL THEN
|
||||
--
|
||||
field_caption := INITCAP(REPLACE(SUBSTR(z_field_name
|
||||
,3
|
||||
,LENGTH(z_field_name) - 2)
|
||||
,'_'
|
||||
,' '));
|
||||
--
|
||||
ELSE
|
||||
--
|
||||
field_caption := INITCAP(REPLACE(z_field_prompt
|
||||
,'_'
|
||||
,' '));
|
||||
--
|
||||
END IF;
|
||||
--
|
||||
wsgl.registerurl(g_package_name || '.calendar');
|
||||
wsgl.addurlparam('Z_FIELD_NAME'
|
||||
,z_field_name);
|
||||
wsgl.addurlparam('Z_CALLER_URL'
|
||||
,z_caller_url);
|
||||
--
|
||||
IF wsgl.notlowercase THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
--
|
||||
wsgl.output_calendar(z_field_name
|
||||
,z_field_value
|
||||
,z_field_format
|
||||
,wsgl.msggettext(123
|
||||
,wsglm.dsp128_cal_caption
|
||||
,field_caption)
|
||||
,NULL
|
||||
,g_package_name
|
||||
,'Close'
|
||||
,TRUE
|
||||
,g_date_format);
|
||||
--
|
||||
wsgl.output_calendar(z_field_name
|
||||
,z_field_value
|
||||
,z_field_format
|
||||
,wsgl.msggettext(123
|
||||
,wsglm.dsp128_cal_caption
|
||||
,field_caption)
|
||||
,NULL
|
||||
,g_package_name
|
||||
,'Close'
|
||||
,FALSE
|
||||
,g_date_format);
|
||||
--
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
wsgl.displaymessage(wsgl.mess_exception
|
||||
,SQLERRM
|
||||
,''
|
||||
,NULL
|
||||
,g_package_name || '.calendar');
|
||||
END calendar;
|
||||
--
|
||||
-- Standard web formatting package for submitted dates
|
||||
--
|
||||
PROCEDURE format_cal_date(z_field_name IN VARCHAR2
|
||||
,z_field_format IN VARCHAR2
|
||||
,DAY IN VARCHAR2
|
||||
,MONTH IN VARCHAR2
|
||||
,YEAR IN VARCHAR2) IS
|
||||
--
|
||||
field_caption VARCHAR2(2000) := INITCAP(REPLACE(SUBSTR(z_field_name
|
||||
,3
|
||||
,LENGTH(z_field_name) - 2)
|
||||
,'_'
|
||||
,' '));
|
||||
l_day VARCHAR2(15) := DAY;
|
||||
--
|
||||
PROCEDURE output_format_cal_js(page_header IN VARCHAR2
|
||||
,body_attributes IN VARCHAR2
|
||||
,chosen_date IN VARCHAR2
|
||||
,field_format IN VARCHAR2) IS
|
||||
--
|
||||
-- Copied from WSGL
|
||||
--
|
||||
the_date DATE := TO_DATE(chosen_date
|
||||
,'DD-MONTH-YYYY');
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
wsgl.openpagehead(page_header);
|
||||
wsgl.closepagehead;
|
||||
wsgl.openpagebody(FALSE
|
||||
,p_attributes => body_attributes);
|
||||
htp.p('<SCRIPT>');
|
||||
htp.p('opener.dateField.value = "' ||
|
||||
TO_CHAR(the_date
|
||||
,field_format) || '";');
|
||||
htp.p('opener.dateField.focus();');
|
||||
htp.p('if(opener.dateField.onchange != null) { opener.dateField.onchange(); }');
|
||||
htp.p('window.close();');
|
||||
htp.p('</SCRIPT>');
|
||||
wsgl.closepagebody;
|
||||
--
|
||||
END output_format_cal_js;
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
IF l_day = '0' THEN
|
||||
l_day := '01';
|
||||
END IF;
|
||||
--
|
||||
output_format_cal_js(wsgl.msggettext(123
|
||||
,wsglm.dsp128_cal_caption
|
||||
,field_caption)
|
||||
,NULL
|
||||
,l_day || '-' || MONTH || '-' || YEAR
|
||||
,z_field_format);
|
||||
--
|
||||
END format_cal_date;
|
||||
--
|
||||
-- Procedure to display the system user poplist
|
||||
--
|
||||
PROCEDURE display_system_user
|
||||
IS
|
||||
-- Get all possible customers for the person logged in
|
||||
CURSOR c_syus IS
|
||||
SELECT syus.syus_id syus_id
|
||||
,syus.db_username username
|
||||
FROM system_users syus
|
||||
WHERE SYSDATE BETWEEN syus.period_start AND
|
||||
nvl(syus.period_end
|
||||
,SYSDATE)
|
||||
AND syus.user_locked = 'N'
|
||||
AND syus.syus_id NOT IN (SELECT syus2.syus_id
|
||||
FROM system_users syus2
|
||||
WHERE upper(syus2.db_username) IN
|
||||
('SYSTEM'
|
||||
,'ADVANTICA'))
|
||||
AND syus_id IN
|
||||
(SELECT inus.syus_id
|
||||
FROM intermediary_users inus
|
||||
WHERE inus.inte_id IN (SELECT cbcv.inte_id
|
||||
FROM cust_by_cuty_v cbcv))
|
||||
ORDER BY syus.db_username;
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
htp.p('
|
||||
<tr>
|
||||
<td style="width:120px;"><b>'||g_system_user_lbl||'</b></td>'); -- System User
|
||||
htp.p(' <td>
|
||||
<select id="p_syus_id" name="p_syus_id" size="1">');
|
||||
--
|
||||
-- System User
|
||||
-- Put out option list of available system users
|
||||
htp.p('<option selected></option>');
|
||||
FOR r IN c_syus LOOP
|
||||
--
|
||||
htp.p('<option value="'||r.syus_id||'">'||r.username||'</option>');
|
||||
--
|
||||
END LOOP;
|
||||
--
|
||||
htp.p(' </select>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr> ');
|
||||
--
|
||||
END display_system_user;
|
||||
--
|
||||
-- Output the HTML page head
|
||||
--
|
||||
PROCEDURE page_header IS
|
||||
--
|
||||
l_header VARCHAR2(255);
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
l_header := caco_utilities.get_module_text(c_heading);
|
||||
--
|
||||
htp.p('<div id="header_div">
|
||||
<h1>' || l_header || '</h1>');
|
||||
--
|
||||
htp.p('<br>');
|
||||
--
|
||||
htp.p('<table>');
|
||||
--
|
||||
htp.p('<tr valign="top">');
|
||||
--
|
||||
htp.p('<td style="width:120px;"><b>' || g_subject_lbl ||
|
||||
' * </b></td>');
|
||||
htp.p('<td><input name="p_subject" SIZE="40" MAXLENGTH="100"></input></td>');
|
||||
--
|
||||
htp.p('</tr>');
|
||||
--
|
||||
htp.p('<tr valign="top">');
|
||||
--
|
||||
htp.p('<td style="width:120px;"><b>' || g_message_text_lbl ||
|
||||
' * </b></td>');
|
||||
htp.p('<td><textarea name="p_message_text" rows=5 cols=30></textarea></td>');
|
||||
--
|
||||
htp.p('</tr>');
|
||||
--
|
||||
htp.p('</table>');
|
||||
--
|
||||
htp.p('<table>');
|
||||
htp.p('<tr>
|
||||
<td style="width:120px;"><b>' || g_active_from_lbl ||
|
||||
' * </b></td>
|
||||
<td>
|
||||
<input id="p_active_from" name="p_active_from" size="11" type="text" value="' ||
|
||||
TO_CHAR(TRUNC(SYSDATE)
|
||||
,g_date_format) || '" />
|
||||
</td>
|
||||
<td>');
|
||||
--
|
||||
htp.p(wsgjsl.calbutton(field_name => 'p_active_from'
|
||||
,p_calbut => htf.img(curl => caco_system.images_path ||
|
||||
'lov.gif'
|
||||
,calign => 'TOP'
|
||||
,cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER')
|
||||
,field_format => g_date_format
|
||||
,p_field_prompt => g_active_from_lbl));
|
||||
--
|
||||
htp.p(' </td>
|
||||
</tr>');
|
||||
--
|
||||
htp.p('<tr>
|
||||
<td style="width:120px;"><b>' || g_active_to_lbl ||
|
||||
' * </b></td>
|
||||
<td>
|
||||
<input id="p_active_to" name="p_active_to" size="11" type="text" value="' ||
|
||||
TO_CHAR(TRUNC(SYSDATE)+14
|
||||
,g_date_format) || '" />
|
||||
</td>
|
||||
<td>');
|
||||
--
|
||||
htp.p(wsgjsl.calbutton(field_name => 'p_active_to'
|
||||
,p_calbut => htf.img(curl => caco_system.images_path ||
|
||||
'lov.gif'
|
||||
,calign => 'TOP'
|
||||
,cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER')
|
||||
,field_format => g_date_format
|
||||
,p_field_prompt => g_active_to_lbl));
|
||||
--
|
||||
htp.p(' </td>
|
||||
</tr>');
|
||||
--
|
||||
display_system_user;
|
||||
--
|
||||
htp.p('<tr>');
|
||||
htp.p('<td style="width:120px;"><b>' || g_sms_lbl || '</b></td>');
|
||||
htp.p('<td>' || '<input type="checkbox" name="p_sms" VALUE="Y" checked="checked">' || '</td>');
|
||||
htp.p('</tr>');
|
||||
htp.p('</table>');
|
||||
htp.p('<br>');
|
||||
htp.p('<hr/>');
|
||||
--
|
||||
htp.p('</div>');
|
||||
--
|
||||
END;
|
||||
--
|
||||
-- Output the form elements
|
||||
--
|
||||
PROCEDURE page_body IS
|
||||
--
|
||||
l_cust_name_lbl VARCHAR2(255);
|
||||
l_inc_exc_lbl VARCHAR2(255);
|
||||
l_index NUMBER;
|
||||
l_open VARCHAR2(1);
|
||||
--
|
||||
CURSOR c_cont (cp_cust_id NUMBER)IS
|
||||
SELECT 'Y'
|
||||
FROM customers cust
|
||||
,contracts cont
|
||||
WHERE cust.cust_id = cp_cust_id
|
||||
AND cont.cust_id = cust.cust_id
|
||||
AND cont.status = 'O'
|
||||
AND TRUNC(SYSDATE) BETWEEN cont.valid_from AND cont.valid_until
|
||||
ORDER BY cust.name;
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
l_cust_name_lbl := caco_utilities.get_module_text(c_customer_name);
|
||||
l_inc_exc_lbl := caco_utilities.get_module_text(c_include_exclude);
|
||||
--
|
||||
htp.p('<div id="page_body_div">');
|
||||
htp.p('<table>');
|
||||
htp.p('<thead>');
|
||||
--
|
||||
htp.p('<tr>');
|
||||
--
|
||||
htp.print('<th align="left">' || l_cust_name_lbl || '</th>');
|
||||
htp.print('<th align="left">' || l_inc_exc_lbl || '</th>');
|
||||
--
|
||||
htp.p('</tr>');
|
||||
--
|
||||
htp.p('</thead>');
|
||||
--
|
||||
htp.p('<tbody>');
|
||||
--
|
||||
l_index := 0;
|
||||
--
|
||||
FOR cust_rec IN (SELECT cust.cust_id cust_id
|
||||
, cust.name name
|
||||
FROM customers cust
|
||||
, customer_intermediaries cuin
|
||||
WHERE cust.cust_id = cuin.cust_id
|
||||
AND ( EXISTS ( SELECT 1
|
||||
FROM customer_intermediaries cuin1
|
||||
, customers cust1
|
||||
, customer_types cuty
|
||||
WHERE cuin.inte_id = cuin1.inte_id
|
||||
AND cust1.cust_id = cuin1.cust_id
|
||||
AND cust1.cuty_id = cuty.cuty_id
|
||||
AND cuty.cuty_id = caco_utilities.cuty_id_for_user )
|
||||
OR caco_utilities.user_has_system = c_yes
|
||||
OR caco_utilities.user_has_EFT_admin = c_yes)
|
||||
AND cuin.inte_id <> cout_system_configuration.get_configuration_item('INTE_ID')
|
||||
GROUP BY cust.cust_id, cust.name
|
||||
ORDER BY name
|
||||
) LOOP
|
||||
--
|
||||
l_index := l_index + 1;
|
||||
--
|
||||
OPEN c_cont(cust_rec.cust_id);
|
||||
FETCH c_cont INTO l_open;
|
||||
IF c_cont%NOTFOUND THEN
|
||||
l_open := 'N';
|
||||
END IF;
|
||||
CLOSE c_cont;
|
||||
htp.p('<tr>');
|
||||
htp.p('<td>' || cust_rec.name || '</td>');
|
||||
htp.p('<td>' || '<input type="checkbox" name="p_cust_id" VALUE="' ||
|
||||
cust_rec.cust_id || '"><input type="hidden" name="p_open" VALUE="' ||
|
||||
l_open ||'"></td>');
|
||||
htp.p('</tr>');
|
||||
--
|
||||
END LOOP;
|
||||
--
|
||||
htp.p('</tbody>');
|
||||
htp.p('</table>');
|
||||
htp.p('</div>');
|
||||
--
|
||||
END;
|
||||
--
|
||||
-- javascript routine to check all check boxes
|
||||
--
|
||||
PROCEDURE checkall_js IS
|
||||
--
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
htp.p('
|
||||
<script language="JavaScript">
|
||||
|
||||
function checkAll( field )
|
||||
{
|
||||
var x=document.getElementsByName(field);
|
||||
var action=true;
|
||||
if (x[0].checked == true ) {
|
||||
action=false;
|
||||
}
|
||||
for (i = 0; i < x.length; i++)
|
||||
{
|
||||
x[i].checked = action;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
');
|
||||
--
|
||||
END;
|
||||
--
|
||||
-- javascript routine to check all check boxes which belong to customers with open contracts
|
||||
--
|
||||
PROCEDURE checkallopencontracts_js IS
|
||||
--
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
htp.p('
|
||||
<script language="JavaScript">
|
||||
|
||||
function checkAllOpenContracts( field, open )
|
||||
{
|
||||
var x=document.getElementsByName(field);
|
||||
var y=document.getElementsByName(open);
|
||||
for (i = 0; i < x.length; i++)
|
||||
{
|
||||
if (y[i].value == ''Y'' ) {
|
||||
x[i].checked = true;
|
||||
}
|
||||
else {
|
||||
x[i].checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
');
|
||||
--
|
||||
END;
|
||||
--
|
||||
-- Output the standard html page headers including the document type
|
||||
--
|
||||
PROCEDURE standard_html_header IS
|
||||
BEGIN
|
||||
--
|
||||
htp.p(' <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">');
|
||||
--
|
||||
wsgl.openpagehead(g_title);
|
||||
caco_system.content_type;
|
||||
htp.p('<link rel=stylesheet href="caco_system.css?p_type=content" >');
|
||||
--
|
||||
-- Following required to show a calender screen
|
||||
--
|
||||
htp.p(wsgjsl.openscript);
|
||||
wsgjsl.output_invoke_cal_js(g_package_name
|
||||
,'scrollbars=no,resizable=no,width=320,height=350');
|
||||
htp.p(wsgjsl.closescript);
|
||||
--
|
||||
checkall_js;
|
||||
checkallopencontracts_js;
|
||||
--
|
||||
htp.p(CHR(10) ||
|
||||
'<link rel="stylesheet" media="all" type="text/css" href="caco_system.css" />');
|
||||
--
|
||||
wsgl.closepagehead;
|
||||
--
|
||||
wsgl.openpagebody(FALSE);
|
||||
--
|
||||
htp.p(caco_system.menu);
|
||||
--
|
||||
END;
|
||||
--
|
||||
-- Entry procedure
|
||||
--
|
||||
PROCEDURE startup IS
|
||||
--
|
||||
l_submit_lbl VARCHAR2(255);
|
||||
l_selectall_lbl VARCHAR2(255);
|
||||
l_selectallopen_lbl VARCHAR2(255);
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
IF NOT caco_security.security_check(g_package_name) THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
--
|
||||
l_submit_lbl := caco_utilities.get_module_text(c_submit);
|
||||
l_selectall_lbl := caco_utilities.get_module_text(c_selectall);
|
||||
l_selectallopen_lbl := caco_utilities.get_module_text(c_selectallopen);
|
||||
--
|
||||
standard_html_header;
|
||||
--
|
||||
htp.p('<div id="form_content">');
|
||||
--
|
||||
htp.p('<form id="submit_form" name="submit_form" method="get" action="amfrw021$.create_messages">');
|
||||
--
|
||||
-- Draw the page header
|
||||
--
|
||||
page_header;
|
||||
--
|
||||
page_body;
|
||||
--
|
||||
htp.p('<br>');
|
||||
--
|
||||
--
|
||||
htp.p('<input type=button value="' || l_selectall_lbl ||
|
||||
'" onClick="checkAll(''p_cust_id'')">');
|
||||
--
|
||||
htp.p('<input type=button value="' || l_selectallopen_lbl ||
|
||||
'" onClick="checkAllOpenContracts(''p_cust_id'',''p_open'')">');
|
||||
--
|
||||
htp.p('<br><br>');
|
||||
htp.p('<input type=submit value="' || l_submit_lbl || '">');
|
||||
htp.p('<br><br>');
|
||||
htp.p('<i>''*''' || caco_utilities.get_module_text(2202) || '</i>'); -- '*' Denotes a mandatory field
|
||||
--
|
||||
htp.p('</form>'); -- Submit_form
|
||||
--
|
||||
htp.p('</div>');
|
||||
--
|
||||
wsgl.closepagebody;
|
||||
--
|
||||
END;
|
||||
--
|
||||
-- Function to check the date format
|
||||
--
|
||||
FUNCTION invalid_date_format(p_date IN VARCHAR2) RETURN BOOLEAN IS
|
||||
--
|
||||
l_date DATE;
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
l_date := TO_DATE(p_date
|
||||
,c_date_format);
|
||||
--
|
||||
RETURN(FALSE);
|
||||
--
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN(TRUE);
|
||||
END;
|
||||
--
|
||||
-- Submit procedure called by the form
|
||||
--
|
||||
PROCEDURE create_messages(p_subject IN VARCHAR2
|
||||
,p_message_text IN VARCHAR2
|
||||
,p_active_from IN VARCHAR2
|
||||
,p_active_to IN VARCHAR2
|
||||
,p_syus_id IN VARCHAR2
|
||||
,p_sms IN VARCHAR2 DEFAULT NULL
|
||||
,p_cust_id IN owa_util.vc_arr DEFAULT g_empty_vc_array
|
||||
,p_open IN owa_util.vc_arr DEFAULT g_empty_vc_array) IS
|
||||
--
|
||||
missing_params EXCEPTION;
|
||||
missing_user_or_cust EXCEPTION;
|
||||
date_in_past EXCEPTION;
|
||||
dates_overlap EXCEPTION;
|
||||
l_error_list caco_utilities.g_t_substitution_list;
|
||||
l_empty_error_list caco_utilities.g_t_substitution_list;
|
||||
l_error VARCHAR2(255);
|
||||
l_error_type exception_messages.exme_type%TYPE;
|
||||
l_cust_tab t_cust_tab;
|
||||
ex_invalid_date_format EXCEPTION;
|
||||
l_message_sent_to_lbl VARCHAR2(255);
|
||||
l_temp_link VARCHAR2(255);
|
||||
--
|
||||
CURSOR c_cust(cp_cust_id IN customers.cust_id%TYPE) IS
|
||||
SELECT NAME
|
||||
FROM customers
|
||||
WHERE cust_id = cp_cust_id;
|
||||
--
|
||||
l_cust_name customers.NAME%TYPE;
|
||||
--
|
||||
BEGIN
|
||||
--
|
||||
standard_html_header;
|
||||
--
|
||||
l_error_list := l_empty_error_list;
|
||||
l_message_sent_to_lbl := caco_utilities.get_module_text(c_message_sent_to);
|
||||
--
|
||||
-- Check mandatory parameters are entered.
|
||||
--
|
||||
IF p_subject IS NULL THEN
|
||||
--
|
||||
l_error_list(1) := g_subject_lbl;
|
||||
RAISE missing_params;
|
||||
--
|
||||
ELSIF p_message_text IS NULL THEN
|
||||
--
|
||||
l_error_list(1) := g_message_text_lbl;
|
||||
RAISE missing_params;
|
||||
--
|
||||
ELSIF p_active_from IS NULL THEN
|
||||
--
|
||||
l_error_list(1) := g_active_from_lbl;
|
||||
RAISE missing_params;
|
||||
--
|
||||
ELSIF p_active_to IS NULL THEN
|
||||
--
|
||||
l_error_list(1) := g_active_to_lbl;
|
||||
RAISE missing_params;
|
||||
-- a system user or at least 1 customer checkbox must be selected
|
||||
ELSIF p_cust_id.COUNT < 1 AND p_syus_id IS NULL THEN
|
||||
--
|
||||
l_error_list(1) := g_customers;
|
||||
RAISE missing_user_or_cust;
|
||||
--
|
||||
END IF;
|
||||
--
|
||||
-- Check dates.
|
||||
--
|
||||
IF invalid_date_format(p_active_from) THEN
|
||||
RAISE ex_invalid_date_format;
|
||||
END IF;
|
||||
IF invalid_date_format(p_active_to) THEN
|
||||
RAISE ex_invalid_date_format;
|
||||
END IF;
|
||||
--
|
||||
IF to_date(p_active_from,c_date_format) < trunc(SYSDATE) THEN
|
||||
--
|
||||
RAISE date_in_past;
|
||||
--
|
||||
ELSIF to_date(p_active_to,c_date_format) < to_date(p_active_from,c_date_format) THEN
|
||||
--
|
||||
RAISE dates_overlap;
|
||||
--
|
||||
END IF;
|
||||
--
|
||||
-- loop around the customers selected
|
||||
--
|
||||
FOR i IN 1 .. p_cust_id.COUNT LOOP
|
||||
--
|
||||
OPEN c_cust(p_cust_id(i));
|
||||
FETCH c_cust
|
||||
INTO l_cust_name;
|
||||
CLOSE c_cust;
|
||||
--
|
||||
l_cust_tab(i) := l_cust_name;
|
||||
--
|
||||
-- Create messages for customers selected
|
||||
--
|
||||
amfr_message.create_message(p_subject => p_subject,
|
||||
p_message => p_message_text,
|
||||
p_cust_id => p_cust_id(i),
|
||||
p_sypr_id => NULL,
|
||||
p_syus_id => NULL,
|
||||
p_active_from => to_date(p_active_from,c_date_format),
|
||||
p_active_to => to_date(p_active_to,c_date_format),
|
||||
p_email_sms => NVL(p_sms,'N'));
|
||||
--
|
||||
END LOOP;
|
||||
--
|
||||
-- now deal with the system user
|
||||
--
|
||||
IF p_syus_id IS NOT NULL THEN
|
||||
--
|
||||
-- Create messages for system user selected
|
||||
--
|
||||
amfr_message.create_message(p_subject => p_subject,
|
||||
p_message => p_message_text,
|
||||
p_cust_id => NULL,
|
||||
p_sypr_id => NULL,
|
||||
p_syus_id => p_syus_id,
|
||||
p_active_from => to_date(p_active_from,c_date_format),
|
||||
p_active_to => to_date(p_active_to,c_date_format),
|
||||
p_email_sms => NVL(p_sms,'N'));
|
||||
--
|
||||
END IF;
|
||||
htp.p('<h1>'||caco_utilities.get_module_text(c_heading)||'</h1>');
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_success
|
||||
,p_mess => l_message_sent_to_lbl);
|
||||
--
|
||||
IF p_syus_id IS NOT NULL THEN
|
||||
htp.p('<br>');
|
||||
htp.p('<b>' || g_system_user_lbl || '</b>');
|
||||
htp.p('<br>');
|
||||
htp.p('<p> ' || caco_utilities.get_syus_name(p_syus_id) || '</p>');
|
||||
END IF;
|
||||
--
|
||||
IF l_cust_tab.COUNT > 0 THEN
|
||||
htp.p('<br>');
|
||||
htp.p('<b>' || g_customers || '</b>');
|
||||
htp.p('<br>');
|
||||
--
|
||||
FOR r IN 1 .. l_cust_tab.COUNT LOOP
|
||||
--
|
||||
htp.p('<p> ' || l_cust_tab(r) || '</p>');
|
||||
--
|
||||
END LOOP;
|
||||
END IF;
|
||||
htp.p('<br>');
|
||||
l_temp_link := caco_system.dad_path||'amfrw021$.startup';
|
||||
--
|
||||
htp.p('<input type="button" value="'||caco_utilities.get_module_text(851)||'"'); -- New button
|
||||
htp.p(' onclick="location.href='''||l_temp_link||'''" />');
|
||||
--
|
||||
wsgl.closepagebody;
|
||||
--
|
||||
COMMIT;
|
||||
--
|
||||
EXCEPTION
|
||||
WHEN ex_invalid_date_format THEN
|
||||
--
|
||||
caco_utilities.get_exception_message(p_exception_number => -20538
|
||||
,p_message => l_error
|
||||
,p_exme_type => l_error_type
|
||||
,p_substitution_list => l_error_list
|
||||
,p_language => caco_utilities.get_syus_lang);
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_error
|
||||
,p_mess => l_error);
|
||||
--
|
||||
WHEN missing_params THEN
|
||||
--
|
||||
caco_utilities.get_exception_message(p_exception_number => -20506
|
||||
,p_message => l_error
|
||||
,p_exme_type => l_error_type
|
||||
,p_substitution_list => l_error_list
|
||||
,p_language => caco_utilities.get_syus_lang);
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_error
|
||||
,p_mess => l_error);
|
||||
--
|
||||
WHEN missing_user_or_cust THEN
|
||||
--
|
||||
caco_utilities.get_exception_message(p_exception_number => -20553
|
||||
,p_message => l_error
|
||||
,p_exme_type => l_error_type
|
||||
,p_substitution_list => l_error_list
|
||||
,p_language => caco_utilities.get_syus_lang);
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_error
|
||||
,p_mess => l_error);
|
||||
--
|
||||
WHEN date_in_past THEN
|
||||
--
|
||||
caco_utilities.get_exception_message(p_exception_number => -20551
|
||||
,p_message => l_error
|
||||
,p_exme_type => l_error_type
|
||||
,p_substitution_list => l_error_list
|
||||
,p_language => caco_utilities.get_syus_lang);
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_error
|
||||
,p_mess => l_error);
|
||||
--
|
||||
WHEN dates_overlap THEN
|
||||
--
|
||||
caco_utilities.get_exception_message(p_exception_number => -20552
|
||||
,p_message => l_error
|
||||
,p_exme_type => l_error_type
|
||||
,p_substitution_list => l_error_list
|
||||
,p_language => caco_utilities.get_syus_lang);
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_error
|
||||
,p_mess => l_error);
|
||||
--
|
||||
WHEN OTHERS THEN
|
||||
--
|
||||
l_error := 'ERROR in amfrw021$.create_messages: ' || SQLERRM;
|
||||
--
|
||||
ROLLBACK;
|
||||
--
|
||||
wsgl.displaymessage(p_type => wsgl.mess_error
|
||||
,p_mess => l_error);
|
||||
|
||||
END;
|
||||
--
|
||||
-- About procedure
|
||||
--
|
||||
FUNCTION about RETURN VARCHAR2 IS
|
||||
BEGIN
|
||||
RETURN(g_package_name || chr(10) || g_revision || chr(10) || g_header);
|
||||
END about;
|
||||
--
|
||||
-- Package initialisation
|
||||
--
|
||||
BEGIN
|
||||
-- Initialization
|
||||
NULL;
|
||||
END amfrw021$;
|
||||
/
|
||||
Reference in New Issue
Block a user