Files
mip/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow201$.bdy

1089 lines
42 KiB
Plaintext

CREATE OR REPLACE PACKAGE BODY efnow201$ IS
--
-- Text constants
--
c_heading CONSTANT NUMBER := 3594; -- Maintain Interruption Types
c_int_type_code CONSTANT NUMBER := 3595;
c_description CONSTANT NUMBER := 20;
c_related_cat CONSTANT NUMBER := 3596;
c_customer_name CONSTANT NUMBER := 1145;
c_contract_number CONSTANT NUMBER := 2013;
c_np_code CONSTANT NUMBER := 1005;
c_max_int CONSTANT NUMBER := 3597;
c_max_int_days CONSTANT NUMBER := 3598;
c_max_int_len CONSTANT NUMBER := 3855;
c_submit CONSTANT NUMBER := 1147;
c_update CONSTANT NUMBER := 837;
c_cancel CONSTANT NUMBER := 993;
--
-- Global variables
--
g_heading_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_heading);
g_int_type_code_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_int_type_code);
g_description_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_description);
g_related_cat_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_related_cat);
g_customer_name_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_customer_name);
g_contract_number_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_contract_number);
g_np_code_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_np_code);
g_max_int_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_max_int);
g_max_int_days_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_max_int_days);
g_max_int_len_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_max_int_len);
g_submit_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_submit);
g_update_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_update);
g_cancel_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_cancel);
--
FUNCTION gas_year_end RETURN DATE IS
--
this_year NUMBER;
gas_year_end DATE;
--
BEGIN
--
SELECT EXTRACT(YEAR FROM SYSDATE)
INTO this_year
FROM dual;
--
IF SYSDATE > TO_DATE('01-07-' || TO_CHAR(this_year),'dd-mm-yyyy') THEN
--
gas_year_end := TO_DATE('01-07-' || TO_CHAR(this_year + 1),'dd-mm-yyyy');
--
ELSE
--
gas_year_end := TO_DATE('01-07-' || TO_CHAR(this_year),'dd-mm-yyyy');
--
END IF;
--
RETURN gas_year_end;
--
END;
--
PROCEDURE display_message( p_success IN BOOLEAN
, p_err_msg IN VARCHAR2
, p_ins_or_upd IN VARCHAR2 )
IS
BEGIN
--
IF p_success THEN
-- Success!
htp.p('<b><font size="+2" color="#008000"><i>'||caco_utilities.get_module_text(876)||'</i></font><br /></b><p></p>');
ELSE
htp.p('<b><font size="+2" color="#840201"><i>');
IF p_ins_or_upd = 'INSERT' THEN
htp.p(caco_utilities.get_module_text(2334)); -- Insert failed
ELSE
htp.p(caco_utilities.get_module_text(2340)); -- Update failed
END IF;
htp.p('</i></font><br /></b>');
htp.p('<b>'||p_err_msg||'<br /></b><p></p>');
END IF;
--
END display_message;
--
PROCEDURE inty_css IS
BEGIN
-- Check we have permission to be using this module.
IF NOT caco_security.security_check(g_package_name) THEN
RETURN;
END IF;
--
owa_util.mime_header('text/css'
,TRUE);
--
htp.p('
.confTable {
border : 1px solid;
}
.confTable td {
border : 1px solid;
}
.confTable th {
font-weight : normal;
padding : 2px;
background-color : #D9D9D9;
border-left-width : 1px;
border-left-style : solid;
border-left-color : #F21C0A;
border-right-width : 1px;
border-right-style : solid;
border-right-color : #F21C0A;
border-top-width : 1px;
border-top-style : solid;
border-top-color : #F21C0A;
border-bottom-width : 1px;
border-bottom-style : solid;
border-bottom-color : #F21C0A;
height : 20px;
}
.Error {
background-color : #FF9F98;
text-align : left;
border-style : none;
}
');
END inty_css;
--
PROCEDURE inty_js IS
BEGIN
--
htp.p('
var changes = ''unchanged'';
function setChanged( obj ) {
if( obj.value != obj.getAttribute(''origval'') ) {
changes = ''changed'';
}
}
function gotoPage( locURL ) {
if( changes == ''changed'' ) {
if (confirm('''||caco_utilities.get_module_text(2343)||''')){
location.href = locURL;
}
}
else {
location.href = locURL;
}
}
');
END inty_js;
--
PROCEDURE display_category_list(p_cate_id IN VARCHAR2
, p_ins_or_upd IN VARCHAR2
, p_err_msg IN VARCHAR2
, p_action IN VARCHAR2) IS
-- Get all unassigned interruptible categories
CURSOR c_cate IS
SELECT c.cate_id cate_id
,c.name cate_name
FROM categories c
WHERE c.interuptible = 'Y'
AND NOT EXISTS (SELECT 1
FROM interruption_types i
WHERE c.cate_id = i.cate_id
AND status = 'A'
AND expiry_date > SYSDATE)
ORDER BY c.name;
-- cursor to get a single category name
CURSOR c_cate2 IS
SELECT c.name cate_name
FROM categories c
WHERE cate_id = p_cate_id;
--
l_cate_name categories.name%TYPE;
--
BEGIN
--
htp.p('
<tr>
<td style="width:170px;"><b>' || g_related_cat_lbl ||
' *</b></td><td>');
--
IF p_ins_or_upd = 'UPDATE' OR (p_ins_or_upd = 'INSERT' AND p_err_msg IS NULL AND p_action IS NOT NULL) THEN
--
OPEN c_cate2;
FETCH c_cate2 INTO l_cate_name;
CLOSE c_cate2;
htp.p('<input name="p_cate_id" type="hidden" value="'||p_cate_id||'" />');
htp.p('<input type="text" size="30" disabled value="' || l_cate_name || '">');
--
ELSE
-- Put out option list of all unassigned interruptible categories
htp.p('<select id="p_cate_id" name="p_cate_id" size="1" onchange="this.form.submit();">');
-- set selected option as null
htp.p('<option selected value=""></option>');
-- lets get the interruptible categories
FOR r IN c_cate LOOP
--
IF r.cate_id = p_cate_id THEN
htp.p('<option selected value="' || r.cate_id || '">' ||
r.cate_name || '</option>');
ELSE
htp.p('<option value="' || r.cate_id || '">' || r.cate_name ||
'</option>');
END IF;
--
END LOOP;
htp.p('</select>');
--
END IF;
htp.p(' </td>
<td>&nbsp</td>
</tr> ');
--
END display_category_list;
--
-- Page header
--
PROCEDURE page_header (p_inty_id IN VARCHAR2 DEFAULT NULL
, p_int_type_code IN VARCHAR2 DEFAULT NULL
, p_description IN VARCHAR2 DEFAULT NULL
, p_cate_id IN VARCHAR2 DEFAULT NULL
, p_success IN BOOLEAN DEFAULT FALSE
, p_action IN VARCHAR2 DEFAULT NULL
, p_err_msg IN VARCHAR2 DEFAULT NULL
, p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT') IS
--
CURSOR c_inty IS
SELECT *
FROM interruption_types
WHERE inty_id = p_inty_id;
--
-- cursor to get the minimum date for related contracts
-- this will be used to define the interruption type expiry date
--
CURSOR c_min_date IS
SELECT min(cont.valid_until) min_date
FROM contracts cont
,contract_categories coca
WHERE cont.cont_id = coca.cont_id
AND coca.cate_id = p_cate_id
AND cont.status = 'O'
AND cont.valid_from < SYSDATE
AND cont.valid_until > SYSDATE;
--
CURSOR c_new_inty IS
SELECT inty_id
FROM interruption_types i
WHERE i.cate_id = p_cate_id
AND i.status = 'A'
AND i.expiry_date > SYSDATE;
--
l_inty interruption_types%ROWTYPE := NULL;
l_min_date DATE := NULL;
l_inty_id interruption_types.inty_id%type := p_inty_id;
--
BEGIN
--
l_inty.code := p_int_type_code;
l_inty.description := p_description;
l_inty.cate_id := p_cate_id;
--
htp.p('<div id="header_div">
<h1>' || g_heading_lbl || '</h1>');
--
-- check if there was an insert or update made
IF p_action IS NOT NULL THEN
--
display_message( p_success => p_success
, p_err_msg => p_err_msg
, p_ins_or_upd => p_ins_or_upd );
--
END IF;
--
IF p_action IS NULL AND p_ins_or_upd = 'INSERT' THEN
-- this is a fresh insert so lets get the min date of all involved contracts
OPEN c_min_date;
FETCH c_min_date INTO l_min_date;
CLOSE c_min_date;
--
END IF;
--
IF p_action IS NOT NULL AND p_ins_or_upd = 'INSERT' AND p_err_msg IS NULL THEN
-- a successful insert has just occurred lets determine the inty_id
OPEN c_new_inty;
FETCH c_new_inty INTO l_inty_id;
CLOSE c_new_inty;
--
END IF;
--
IF p_action IS NULL AND p_ins_or_upd = 'UPDATE' THEN
-- lookup the inty values
OPEN c_inty;
FETCH c_inty INTO l_inty;
CLOSE c_inty;
--
END IF;
--
htp.p('<br>');
--
htp.p('<table>');
htp.p('<tr>
<td style="width:170px;"><b>' || g_int_type_code_lbl ||
'&nbsp;*&nbsp;</b></td>
<td>
<input name="p_min_date" type="hidden" value="'||l_min_date||'" />
<input name="p_inty_id" type="hidden" value="'||l_inty_id||'" />
<input id="p_int_type_code" name="p_int_type_code" size="30" maxlength="30" type="text" value="' ||
l_inty.code || '" />
</td></tr>');
--
htp.p('</table>');
--
htp.p('<br>');
--
htp.p('<table>');
--
htp.p('<tr valign="top">');
--
htp.p('<td style="width:170px;"><b>' || g_description_lbl ||
'&nbsp;*&nbsp;</b></td>');
htp.p('<td><textarea name="p_description" rows=5 cols=30>' || l_inty.description || '</textarea></td>');
--
htp.p('</tr>');
--
htp.p('</table>');
--
htp.p('<br>');
--
htp.p('<table>');
--
display_category_list(l_inty.cate_id
, p_ins_or_upd
, p_err_msg
, p_action);
--
htp.p('</table>');
--
htp.p('<hr/>');
--
htp.p('</div>');
--
END;
--
-- Page body
--
PROCEDURE page_body(p_cate_id IN VARCHAR2 DEFAULT NULL
, p_inty_id IN VARCHAR2 DEFAULT NULL
, p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT'
, p_err_msg IN VARCHAR2 DEFAULT NULL
, p_max_int IN owa_util.vc_arr
, p_max_int_days IN owa_util.vc_arr
, p_max_int_len IN owa_util.vc_arr
, p_max_int_error IN owa_util.vc_arr
, p_max_int_days_error IN owa_util.vc_arr
, p_max_int_len_error IN owa_util.vc_arr
) IS
--
CURSOR c_new_inty IS
SELECT inty_id
FROM interruption_types i
WHERE i.cate_id = p_cate_id
AND i.status = 'A'
AND i.expiry_date > SYSDATE;
--
CURSOR c_cust_nepo(cp_cate_id NUMBER) IS
SELECT cust.name customer_name
,nepo.code nepo_code
,conp.conp_id conp_id
,cont.contract_number contract_number
FROM customers cust
,network_points nepo
,contracts cont
,cont_network_points conp
,contract_categories coca
,contract_parameters copa
,parameters pars
,cont_net_point_param_vals cnppv
WHERE cust.cust_id = cont.cust_id
AND cont.cont_id = coca.cont_id
AND coca.cate_id = cp_cate_id
AND cont.cont_id = conp.cont_id
AND conp.nepo_id = nepo.nepo_id
AND cont.cont_id = copa.cont_id
AND copa.pars_id = pars.pars_id
AND coca.cate_id = pars.cate_id
AND cnppv.conp_id = conp.conp_id
AND cnppv.copa_id = copa.copa_id
AND SUBSTR(UPPER(pars.code),-3) = 'MAX'
AND cnppv.value > 0
AND cont.status = 'O'
AND TRUNC(SYSDATE) BETWEEN cont.valid_from AND cont.valid_until
ORDER BY cust.name,
cont.contract_number,
nepo.code;
--
CURSOR c_icp(c_inty_id IN NUMBER) IS
SELECT icp.max_interruptions max_int
,icp.max_interruption_days max_int_days
,icp.max_interruption_length max_int_len
,cust.name customer_name
,cont.contract_number contract_number
,nepo.code nepo_code
,conp.conp_id conp_id
FROM interruption_types inty
,inty_conp_params icp
,customers cust
,network_points nepo
,contracts cont
,cont_network_points conp
,contract_categories coca
WHERE cust.cust_id = cont.cust_id
AND cont.cont_id = coca.cont_id
AND coca.cate_id = inty.cate_id
AND cont.cont_id = conp.cont_id
AND conp.nepo_id = nepo.nepo_id
AND inty.inty_id = icp.inty_id
AND icp.conp_id = conp.conp_id
AND inty.inty_id = c_inty_id
AND icp.limits_enabled = 'Y'
ORDER BY cust.name,
cont.contract_number,
nepo.code;
--
l_rec_found BOOLEAN := FALSE;
l_dummy c_cust_nepo%ROWTYPE;
l_max_int NUMBER := 0;
l_max_int_days NUMBER := 0;
l_max_int_len NUMBER := 0;
l_inty_id NUMBER;
l_error_cell_count NUMBER := 0;
--
BEGIN
--
-- treat updates and inserts separately
--
IF p_ins_or_upd = 'UPDATE' THEN
-- lets check we've got the inty_id otherwise this must be a new insert so get it
IF p_inty_id IS NULL THEN
--
OPEN c_new_inty;
FETCH c_new_inty
INTO l_inty_id;
CLOSE c_new_inty;
--
ELSE
--
l_inty_id := p_inty_id;
--
END IF;
-- query back inty data
htp.p('<table class="confTable" style="border: none;">');
htp.p('<tr>');
htp.p('<th>'||g_customer_name_lbl||'</th>');
htp.p('<th>'||g_contract_number_lbl||'</th>');
htp.p('<th>'||g_np_code_lbl||'</th>');
htp.p('<th>'||g_max_int_lbl||'</th>');
htp.p('<th>'||g_max_int_days_lbl||'</th>');
htp.p('<th>'||g_max_int_len_lbl||'</th>');
--
-- Loop round all records and create a table row for each.
--
FOR r IN c_icp(l_inty_id) LOOP
--
l_error_cell_count := l_error_cell_count + 1;
-- We can output the values.
htp.p('<tr>');
htp.p('<th>'||r.customer_name||'</th>');
htp.p('<th>'||r.contract_number||'</th>');
htp.p('<th>'||r.nepo_code);
htp.p('<input name="p_conp_id" type="hidden" value="'||r.conp_id||'" /></th>');
--
IF p_err_msg IS NOT NULL THEN
--
IF p_max_int_error.COUNT >= l_error_cell_count THEN
IF p_max_int_error(l_error_cell_count) = 'Y' THEN
htp.p('<td><input name="p_max_int" class="Error" maxlength=3 size=28 value="'||p_max_int(l_error_cell_count)||'"/></td>');
ELSE
htp.p('<td><input name="p_max_int" maxlength=3 size=28 value="'||p_max_int(l_error_cell_count)||'"/></td>');
END IF;
ELSE
htp.p('<td><input name="p_max_int" maxlength=3 size=28 value="'||p_max_int(l_error_cell_count)||'"/></td>');
END IF;
--
IF p_max_int_days_error.COUNT >= l_error_cell_count THEN
IF p_max_int_days_error(l_error_cell_count) = 'Y' THEN
htp.p('<td><input name="p_max_int_days" class="Error" maxlength=3 size=25 value="'||p_max_int_days(l_error_cell_count)||'"/></td>');
ELSE
htp.p('<td><input name="p_max_int_days" maxlength=3 size=25 value="'||p_max_int_days(l_error_cell_count)||'"/></td>');
END IF;
ELSE
htp.p('<td><input name="p_max_int_days" maxlength=3 size=25 value="'||p_max_int_days(l_error_cell_count)||'"/></td>');
END IF;
--
IF p_max_int_len_error.COUNT >= l_error_cell_count THEN
IF p_max_int_len_error(l_error_cell_count) = 'Y' THEN
htp.p('<td><input name="p_max_int_len" class="Error" maxlength=3 size=25 value="'||p_max_int_len(l_error_cell_count)||'"/></td>');
ELSE
htp.p('<td><input name="p_max_int_len" maxlength=3 size=25 value="'||p_max_int_len(l_error_cell_count)||'"/></td>');
END IF;
ELSE
htp.p('<td><input name="p_max_int_len" maxlength=3 size=25 value="'||p_max_int_len(l_error_cell_count)||'"/></td>');
END IF;
--
ELSE
htp.p('<td><input name="p_max_int" maxlength=3 size=28 value="'||r.max_int||'"'
||' origval="'||r.max_int||'"'
||' onchange="setChanged(this);" /></td>');
htp.p('<td><input name="p_max_int_days" maxlength=3 size=25 value="'||r.max_int_days||'"'
||' origval="'||r.max_int_days||'"'
||' onchange="setChanged(this);" /></td>');
htp.p('<td><input name="p_max_int_len" maxlength=3 size=25 value="'||r.max_int_len||'"'
||' origval="'||r.max_int_len||'"'
||' onchange="setChanged(this);" /></td>');
END IF;
--
htp.p('</tr>');
--
END LOOP;
--
htp.p('</table>');
--
ELSE -- Insert
--
OPEN c_cust_nepo(p_cate_id);
FETCH c_cust_nepo
INTO l_dummy;
--
IF c_cust_nepo%FOUND THEN
l_rec_found := TRUE;
END IF;
--
CLOSE c_cust_nepo;
--
IF l_rec_found THEN
--
-- If we found any data then Open the table with a header row.
--
htp.p('<table class="confTable" style="border: none;">');
htp.p('<tr>');
htp.p('<th>'||g_customer_name_lbl||'</th>');
htp.p('<th>'||g_contract_number_lbl||'</th>');
htp.p('<th>'||g_np_code_lbl||'</th>');
htp.p('<th>'||g_max_int_lbl||'</th>');
htp.p('<th>'||g_max_int_days_lbl||'</th>');
htp.p('<th>'||g_max_int_len_lbl||'</th>');
--
-- Loop round all records and create a table row for each.
--
FOR r IN c_cust_nepo(p_cate_id) LOOP
-- We can output the values.
htp.p('<tr>');
htp.p('<th>'||r.customer_name||'</th>');
htp.p('<th>'||r.contract_number||'</th>');
htp.p('<th>'||r.nepo_code||'</th>');
htp.p('<td><input name="p_conp_id" type="hidden" value="'||r.conp_id||'" />');
htp.p(' <input name="p_max_int" maxlength=3 size=28 value="'||l_max_int||'"'
||' origval="'||l_max_int||'"'
||' onchange="setChanged(this);" /></td>');
htp.p('<td><input name="p_max_int_days" maxlength=3 size=25 value="'||l_max_int_days||'"'
||' origval="'||l_max_int_days||'"'
||' onchange="setChanged(this);" /></td>');
htp.p('<td><input name="p_max_int_len" maxlength=3 size=25 value="'||l_max_int_len||'"'
||' origval="'||l_max_int_len||'"'
||' onchange="setChanged(this);" /></td>');
htp.p('</tr>');
--
END LOOP;
--
htp.p('</table>');
--
END IF;
--
END IF;
--
END page_body;
--
-- Standard HTML Header
--
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" media="all" type="text/css" href="caco_system.css" />');
htp.p('<link rel="stylesheet" media="all" type="text/css" href="efnow201$.inty_css" />');
htp.p('<script type="text/javascript" src="efnow201$.inty_js"></script>');
--
wsgl.closepagehead;
--
wsgl.openpagebody(FALSE);
--
htp.p(caco_system.menu);
--
END;
--
--
--
FUNCTION ins_or_upd_int_type( p_inty_id IN VARCHAR2 DEFAULT NULL
, p_int_type_code IN VARCHAR2 DEFAULT NULL
, p_description IN VARCHAR2 DEFAULT NULL
, p_cate_id IN VARCHAR2 DEFAULT NULL
, p_min_date IN VARCHAR2 DEFAULT NULL
, p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT'
, p_conp_id IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int_days IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int_len IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int_error OUT owa_util.vc_arr
, p_max_int_days_error OUT owa_util.vc_arr
, p_max_int_len_error OUT owa_util.vc_arr
, p_return_error OUT VARCHAR2)
RETURN BOOLEAN IS
--
l_success BOOLEAN := TRUE;
l_expiry_date DATE := gas_year_end;
l_min_date DATE := TO_DATE(p_min_date,'DD-MON-YY');
l_inty_id interruption_types.inty_id%TYPE := 0;
l_temp_number NUMBER := 0;
--
BEGIN
--
-- check interruption type code
--
IF l_success
AND p_int_type_code IS NULL
THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3602);
-- You must provide an interruption type code
END IF;
--
-- check interruption type code
--
IF l_success
AND p_description IS NULL
THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3601);
-- You must provide an interruption type description
END IF;
--
-- check related category
--
IF l_success
AND p_cate_id IS NULL
THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3603);
-- You must provide a related category
END IF;
--
-- check there are some network points to interrupt
--
IF l_success
AND NVL(p_conp_id.COUNT,0) = 0
THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3604);
-- There are no contracts with the selected related category
END IF;
--
-- Lets check the max_int array data;
--
IF l_success THEN
--
FOR i IN 1..p_max_int.COUNT LOOP
--
p_max_int_error(i) := 'N';
--
IF NVL(p_max_int(i),'#~^!$') != '#~^!$' THEN
--
-- check to ensure data is numeric
BEGIN
SELECT TO_NUMBER(p_max_int(i))
INTO l_temp_number
FROM dual;
--
-- Check to ensure that the data is gte zero
--
IF p_max_int(i) < 0 THEN
-- An error -- ALL values must be positive (including zero)
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2357); -- All values must be zero or greater
p_max_int_error(i) := 'Y';
EXIT;
END IF;
--
EXCEPTION
WHEN others THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2289); -- Non numeric data supplied
p_max_int_error(i) := 'Y';
EXIT;
END;
--
ELSE
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2289); -- Non numeric data supplied
p_max_int_error(i) := 'Y';
EXIT;
END IF;
END LOOP;
END IF;
--
-- Lets check the max_int_days array data;
--
IF l_success THEN
FOR i IN 1..p_max_int_days.COUNT LOOP
--
p_max_int_days_error(i) := 'N';
--
IF NVL(p_max_int_days(i),'#~^!$') != '#~^!$' THEN
--
-- check to ensure data is numeric
BEGIN
SELECT TO_NUMBER(p_max_int_days(i))
INTO l_temp_number
FROM dual;
--
-- Check to ensure that the data is gte zero
IF p_max_int_days(i) < 0 THEN
-- An error -- ALL values must be positive (including zero)
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2357); -- All values must be zero or greater
p_max_int_days_error(i) := 'Y';
EXIT;
END IF;
--
EXCEPTION
WHEN others THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2289); -- Non numeric data supplied
p_max_int_days_error(i) := 'Y';
EXIT;
END;
--
ELSE
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2289); -- Non numeric data supplied
p_max_int_days_error(i) := 'Y';
EXIT;
END IF;
END LOOP;
END IF;
--
-- Lets check the max_int_len array data;
--
IF l_success THEN
--
FOR i IN 1..p_max_int_len.COUNT LOOP
--
p_max_int_len_error(i) := 'N';
--
IF NVL(p_max_int_len(i),'#~^!$') != '#~^!$' THEN -- eh? would is not null be better? AG
--
-- check to ensure data is numeric
--
BEGIN
SELECT TO_NUMBER(p_max_int_len(i))
INTO l_temp_number
FROM dual;
--
-- Check to ensure that the data is gte zero
IF p_max_int_len(i) < 0 THEN
-- An error -- ALL values must be positive (including zero)
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2357); -- All values must be zero or greater
p_max_int_len_error(i) := 'Y';
EXIT;
END IF;
--
EXCEPTION
WHEN others THEN
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2289); -- Non numeric data supplied
p_max_int_len_error(i) := 'Y';
EXIT;
END;
--
ELSE
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(2289); -- Non numeric data supplied
p_max_int_len_error(i) := 'Y';
EXIT;
END IF;
END LOOP;
END IF;
--
-- lets work out what expiry_date should be inserted
--
IF l_success THEN
-- get the min contract date of all contracts used to generate the int_type
-- if all are after the next 1st July then 1st July 00:00:00 should be used
IF l_expiry_date > l_min_date THEN
l_expiry_date := l_min_date;
END IF;
--
END IF;
--
SAVEPOINT before_ins_or_upd_inty;
--
IF p_ins_or_upd = 'INSERT' THEN
--
IF l_success THEN
-- Lets look at Inserting the interruption type
BEGIN
INSERT INTO interruption_types
( inty_id
, code
, description
, status
, cate_id
, expiry_date)
VALUES
( inty_seq.NEXTVAL
, p_int_type_code
, p_description
, 'A'
, p_cate_id
, l_expiry_date)
RETURNING inty_id INTO l_inty_id;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO SAVEPOINT before_ins_or_upd_inty;
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3599);
-- An unexpected error has occurred while inserting new interruption type. Please contact support
caco_debug.putline(g_package_name||'.insert_interruption_type: '
||'Insert of new interruption type failed : '||sqlerrm(sqlcode));
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => SQLCODE
, p_exception_message => 'Failed inserting new interruption type: '||sqlerrm(sqlcode)
, p_source => g_package_name||'.ins_or_upd_int_type');
--
END;
--
END IF;
--
IF l_success THEN
--
-- Lets look at Inserting the inty_conp_params values
--
<<ins_icp_loop>>
FOR i IN 1..p_conp_id.COUNT LOOP
--
BEGIN
--
INSERT INTO inty_conp_params
( icp_id
, inty_id
, conp_id
, max_interruptions
, max_interruption_days
, max_interruption_length
)
VALUES
( icp_seq.NEXTVAL
, l_inty_id
, p_conp_id(i)
, p_max_int(i)
, p_max_int_days(i)
, p_max_int_len(i)
);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO SAVEPOINT before_ins_or_upd_inty;
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3599);
-- An unexpected error has occurred while inserting new interruption type. Please contact support
caco_debug.putline(g_package_name||'.insert_interruption_type: '
||'Insert of new inty_conp_params record failed : '||SQLERRM(SQLCODE));
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => SQLCODE
, p_exception_message => 'Failed inserting new inty_conp_params record: '||sqlerrm(sqlcode)
, p_source => g_package_name||'.ins_or_upd_int_type');
--
EXIT ins_icp_loop;
--
END;
--
END LOOP ins_icp_loop;
--
END IF;
--
ELSE
--
IF l_success THEN
-- Lets look at Updating the interruption type
BEGIN
--
UPDATE interruption_types
SET code = p_int_type_code,
description = p_description
WHERE cate_id = p_cate_id
AND inty_id = p_inty_id
AND status = 'A';
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO SAVEPOINT before_ins_or_upd_inty;
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3600);
-- An unexpected error has occurred while updating the interruption type. Please contact support
caco_debug.putline(g_package_name||'.insert_interruption_type: '
||'Update of new interruption type failed : '||SQLERRM(SQLCODE));
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Failed updaing interruption type: '||SQLERRM(SQLCODE)
, p_source => g_package_name||'.ins_or_upd_int_type');
--
END;
END IF;
--
IF l_success THEN
-- Lets look at Updating the inty_conp_params values
<<upd_icp_loop>>
FOR i IN 1..p_conp_id.COUNT LOOP
--
BEGIN
--
UPDATE inty_conp_params
SET max_interruptions = p_max_int(i),
max_interruption_days = p_max_int_days(i),
max_interruption_length = p_max_int_len(i)
WHERE conp_id = p_conp_id(i)
AND inty_id = p_inty_id;
--
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO SAVEPOINT before_ins_or_upd_inty;
l_success := FALSE;
p_return_error := caco_utilities.get_module_text(3600);
-- An unexpected error has occurred while updating the interruption type. Please contact support
caco_debug.putline('efno_200$sp.insert_interruption_type: '
||'Update of inty_conp_params record failed : '||sqlerrm(sqlcode));
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Failed updating inty_conp_params record: '||sqlerrm(sqlcode)
, p_source => 'efno_200$sp.ins_or_upd_int_type');
--
EXIT upd_icp_loop;
END;
--
END LOOP upd_icp_loop;
--
END IF;
--
END IF;
--
COMMIT;
--
RETURN l_success;
--
END;
--
-- Startup
--
PROCEDURE startup(p_inty_id IN VARCHAR2 DEFAULT NULL
, p_int_type_code IN VARCHAR2 DEFAULT NULL
, p_description IN VARCHAR2 DEFAULT NULL
, p_cate_id IN VARCHAR2 DEFAULT NULL
, p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT'
, p_action IN VARCHAR2 DEFAULT NULL
, p_min_date IN VARCHAR2 DEFAULT NULL
, p_conp_id IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int_days IN owa_util.vc_arr DEFAULT g_empty_vc_array
, p_max_int_len IN owa_util.vc_arr DEFAULT g_empty_vc_array
) IS
--
l_success BOOLEAN := TRUE;
l_return_error VARCHAR2(250);
l_ins_or_upd VARCHAR2(10) := p_ins_or_upd;
l_max_int_error owa_util.vc_arr;
l_max_int_days_error owa_util.vc_arr;
l_max_int_len_error owa_util.vc_arr;
--
BEGIN
--
IF NOT caco_security.security_check(g_package_name) THEN
RETURN;
END IF;
--
IF p_action = g_submit_lbl THEN -- insert
--
l_success := ins_or_upd_int_type(p_int_type_code => p_int_type_code,
p_description => p_description,
p_cate_id => p_cate_id,
p_ins_or_upd => 'INSERT',
p_min_date => p_min_date,
p_conp_id => p_conp_id,
p_max_int => p_max_int,
p_max_int_days => p_max_int_days,
p_max_int_len => p_max_int_len,
p_return_error => l_return_error,
p_max_int_error => l_max_int_error,
p_max_int_days_error => l_max_int_days_error,
p_max_int_len_error => l_max_int_len_error
);
--
ELSIF p_action = g_update_lbl THEN --update
--
l_ins_or_upd := 'UPDATE';
--
l_success := ins_or_upd_int_type(p_inty_id => p_inty_id,
p_int_type_code => p_int_type_code,
p_description => p_description,
p_cate_id => p_cate_id,
p_ins_or_upd => l_ins_or_upd,
p_conp_id => p_conp_id,
p_max_int => p_max_int,
p_max_int_days => p_max_int_days,
p_max_int_len => p_max_int_len,
p_return_error => l_return_error,
p_max_int_error => l_max_int_error,
p_max_int_days_error => l_max_int_days_error,
p_max_int_len_error => l_max_int_len_error
);
--
END IF;
--
standard_html_header;
--
htp.p('<div id="form_content">');
--
htp.p('<form id="submit_form" name="submit_form" method="post" action="efnow201$.startup">');
--
-- Draw the page header
--
page_header(p_inty_id => p_inty_id,
p_int_type_code => p_int_type_code,
p_description => p_description,
p_cate_id => p_cate_id,
p_success => l_success,
p_action => p_action,
p_err_msg => l_return_error,
p_ins_or_upd => l_ins_or_upd);
--
-- Need to display an update form when a successful insert has occured
--
IF l_ins_or_upd = 'INSERT' AND l_return_error IS NULL AND p_action IS NOT NULL THEN
l_ins_or_upd := 'UPDATE';
END IF;
--
page_body(p_cate_id => p_cate_id,
p_inty_id => p_inty_id,
p_ins_or_upd => l_ins_or_upd,
p_err_msg => l_return_error,
p_max_int => p_max_int,
p_max_int_days => p_max_int_days,
p_max_int_len => p_max_int_len,
p_max_int_error => l_max_int_error,
p_max_int_days_error => l_max_int_days_error,
p_max_int_len_error => l_max_int_len_error
);
--
htp.p('<br>');
--
IF l_ins_or_upd = 'INSERT' THEN
htp.p('<input type=submit value="' || g_submit_lbl || '" name = "p_action"/>'); -- Submit (Insert)
ELSE
htp.p('<input type="submit" value="'|| g_update_lbl|| '" name="p_action"/>'); -- Update
END IF;
--
htp.p('<input type="button" value="'|| g_cancel_lbl ||'"'); -- Cancel
htp.p('onclick="location.href='''||caco_system.dad_path||'efnow200$.startup''" />');
htp.p('<br><br>');
htp.p('<i>''*'''||caco_utilities.get_module_text(2202)||'</i>');
--
htp.p('</form>'); -- Submit_form
--
htp.p('</div>');
--
wsgl.closepagebody;
--
END;
--
FUNCTION about RETURN VARCHAR2 IS
BEGIN
RETURN(g_package_name || chr(10) || g_revision || chr(10) || g_header);
END about;
--
END efnow201$;
/