977 lines
31 KiB
Plaintext
977 lines
31 KiB
Plaintext
CREATE OR REPLACE PACKAGE BODY efnow131$ IS
|
|
--
|
|
-- Text constants
|
|
--
|
|
c_heading CONSTANT NUMBER := 1141;
|
|
c_gas_day CONSTANT NUMBER := 1142;
|
|
c_window_open CONSTANT NUMBER := 1143;
|
|
c_window_close CONSTANT NUMBER := 1144;
|
|
c_customer_name CONSTANT NUMBER := 1145;
|
|
c_contract_name CONSTANT NUMBER := 2082;
|
|
c_include_exclude CONSTANT NUMBER := 1146;
|
|
c_submit CONSTANT NUMBER := 1147;
|
|
c_selectall CONSTANT NUMBER := 1148;
|
|
c_message CONSTANT NUMBER := 1150;
|
|
c_customers CONSTANT NUMBER := 1045;
|
|
c_contracts CONSTANT NUMBER := 2401;
|
|
c_timestamp CONSTANT NUMBER := 1152;
|
|
c_subject CONSTANT NUMBER := 2148;
|
|
--
|
|
-- Other Constants
|
|
--
|
|
c_gas_day_start CONSTANT NUMBER := cout_system_configuration.get_configuration_item(p_parameter => 'GAS_DAY_OFFSET');
|
|
c_timecomp_format CONSTANT VARCHAR2(2) := '00';
|
|
c_yes CONSTANT VARCHAR2(1) := 'Y';
|
|
c_date_format CONSTANT VARCHAR2(255) := g_date_format;
|
|
c_datetime_format CONSTANT VARCHAR2(255) := c_date_format ||
|
|
' HH24:MI:SS';
|
|
c_nom_wdw_format CONSTANT VARCHAR2(255) := c_date_format || ' HH24:MI';
|
|
c_renom_window CONSTANT VARCHAR2(1) := 'R';
|
|
c_time_format CONSTANT VARCHAR2(255) := 'HH24:MI';
|
|
--
|
|
-- Global variables
|
|
--
|
|
g_gas_day_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_gas_day);
|
|
g_subject_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_subject);
|
|
g_message_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_message);
|
|
g_customers VARCHAR2(255) := caco_utilities.get_module_text(c_customers);
|
|
g_contracts VARCHAR2(255) := caco_utilities.get_module_text(c_contracts);
|
|
g_wdw_open_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_window_open);
|
|
g_wdw_close_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_window_close);
|
|
g_timestamp_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_timestamp);
|
|
--
|
|
-- 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;
|
|
--
|
|
-- Produce the hour poplist
|
|
--
|
|
PROCEDURE hour_option_list IS
|
|
--
|
|
l_hour NUMBER;
|
|
--
|
|
BEGIN
|
|
--
|
|
--
|
|
-- Start at the gas day begining....
|
|
--
|
|
l_hour := c_gas_day_start;
|
|
--
|
|
FOR i IN 1 .. 24 LOOP
|
|
--
|
|
-- Reset the counter to do hours from midnight to 5
|
|
--
|
|
IF l_hour > 23 THEN
|
|
--
|
|
l_hour := 0;
|
|
--
|
|
END IF;
|
|
--
|
|
IF TO_NUMBER(TO_CHAR(l_hour
|
|
,c_timecomp_format)) =
|
|
TO_NUMBER(TO_CHAR((SYSDATE + 1 / 24)
|
|
,'HH24')) THEN
|
|
--
|
|
htp.p('<option value="' ||
|
|
TO_CHAR(l_hour
|
|
,c_timecomp_format) || '", SELECTED>' ||
|
|
TO_CHAR(l_hour
|
|
,c_timecomp_format));
|
|
--
|
|
ELSE
|
|
--
|
|
htp.p('<option value="' || TO_CHAR(l_hour) || '">' ||
|
|
TO_CHAR(l_hour));
|
|
--
|
|
END IF;
|
|
--
|
|
l_hour := l_hour + 1;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END;
|
|
--
|
|
-- Produce the minute option list
|
|
--
|
|
PROCEDURE minute_option_list IS
|
|
--
|
|
l_minute VARCHAR2(2);
|
|
--
|
|
BEGIN
|
|
--
|
|
l_minute := 0;
|
|
--
|
|
FOR i IN 1 .. 12 LOOP
|
|
--
|
|
IF l_minute = 0 THEN
|
|
--
|
|
htp.p('<option value="' ||
|
|
TO_CHAR(l_minute
|
|
,c_timecomp_format) || '",SELECTED>' ||
|
|
TO_CHAR(l_minute
|
|
,c_timecomp_format));
|
|
--
|
|
ELSE
|
|
--
|
|
htp.p('<option value="' ||
|
|
TO_CHAR(l_minute
|
|
,c_timecomp_format) || '">' ||
|
|
TO_CHAR(l_minute
|
|
,c_timecomp_format));
|
|
--
|
|
END IF;
|
|
--
|
|
l_minute := l_minute + 5;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END;
|
|
--
|
|
-- Output the HTML page head
|
|
--
|
|
PROCEDURE page_header IS
|
|
--
|
|
l_header VARCHAR2(255);
|
|
l_gas_day DATE;
|
|
--
|
|
l_empty_tab_row VARCHAR2(255) := '<tr><td></td><td></td><td></td></tr>';
|
|
--
|
|
BEGIN
|
|
--
|
|
l_header := caco_utilities.get_module_text(c_heading);
|
|
--
|
|
htp.p('<div id="header_div">
|
|
<h1>' || l_header || '</h1>');
|
|
--
|
|
htp.p('<table>');
|
|
htp.p('<tr>
|
|
<td style="width:120px;"><b>' || g_gas_day_lbl ||
|
|
' * </b></td>
|
|
<td>
|
|
<input id="p_gas_day" name="p_gas_day" type="text" value="' ||
|
|
TO_CHAR(l_gas_day
|
|
,g_date_format) || '" />
|
|
</td>
|
|
<td>');
|
|
--
|
|
htp.p(wsgjsl.calbutton(field_name => 'p_gas_day'
|
|
,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_gas_day_lbl));
|
|
--
|
|
htp.p(' </td>
|
|
</tr>');
|
|
--
|
|
htp.p('</table>');
|
|
--
|
|
htp.p('<br>');
|
|
--
|
|
htp.p('<table>');
|
|
htp.p('<tr>
|
|
<td style="width:120px;"><b>' || g_wdw_open_lbl ||
|
|
' * </b></td>
|
|
<td>');
|
|
htp.p('<select name="p_wdw_open_hr">');
|
|
--
|
|
hour_option_list;
|
|
--
|
|
htp.p('</select>');
|
|
--
|
|
htp.p(' </td>
|
|
<td>');
|
|
--
|
|
htp.p('<select name="p_wdw_open_min">');
|
|
--
|
|
minute_option_list;
|
|
--
|
|
htp.p('</select>');
|
|
--
|
|
htp.p(' </td>
|
|
</tr>');
|
|
--
|
|
htp.p(l_empty_tab_row);
|
|
--
|
|
htp.p('<tr>
|
|
<td style="width:120px;"><b>' || g_wdw_close_lbl ||
|
|
' * </b></td>
|
|
<td>');
|
|
--
|
|
htp.p('<select name="p_wdw_close_hr">');
|
|
--
|
|
hour_option_list;
|
|
--
|
|
htp.p('</select>');
|
|
--
|
|
htp.p(' </td>
|
|
<td>');
|
|
--
|
|
htp.p('<select name="p_wdw_close_min">');
|
|
--
|
|
minute_option_list;
|
|
--
|
|
htp.p(' </td>
|
|
</tr>');
|
|
--
|
|
htp.p('</table>');
|
|
--
|
|
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_lbl ||
|
|
' * </b></td>');
|
|
htp.p('<td><textarea name="p_message" rows=5 cols=30></textarea></td>');
|
|
--
|
|
htp.p('</tr>');
|
|
--
|
|
/* htp.p('<tr valign="top">');
|
|
--
|
|
htp.p('<td style="width:120px;"><b>' || g_notes_lbl ||
|
|
' </b></td>');
|
|
htp.p('<td><textarea name="p_notes" rows=5 cols=30></textarea></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_cont_name_lbl VARCHAR2(255);
|
|
l_inc_exc_lbl VARCHAR2(255);
|
|
l_index NUMBER;
|
|
--
|
|
BEGIN
|
|
--
|
|
l_cust_name_lbl := caco_utilities.get_module_text(c_customer_name);
|
|
l_cont_name_lbl := caco_utilities.get_module_text(c_contract_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_cont_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.name
|
|
,cust.cust_id
|
|
,cont.cont_id
|
|
,cont.contract_number
|
|
FROM customers cust
|
|
,contracts cont
|
|
WHERE ( cust.cuty_id = caco_utilities.cuty_id_for_user
|
|
OR caco_utilities.user_has_system = c_yes )
|
|
AND cust.cust_id <> caco_utilities.get_system_customer
|
|
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
|
|
) LOOP
|
|
--
|
|
l_index := l_index + 1;
|
|
--
|
|
htp.p('<tr>');
|
|
htp.p('<td>' || cust_rec.name || '</td>');
|
|
htp.p('<td>' || cust_rec.contract_number || '</td>');
|
|
htp.p('<td>' || '<input type="checkbox" name="p_cont_id" VALUE="' ||
|
|
cust_rec.cont_id || '">' || '</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;
|
|
--
|
|
-- 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;
|
|
--
|
|
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);
|
|
--
|
|
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);
|
|
--
|
|
standard_html_header;
|
|
--
|
|
htp.p('<div id="form_content">');
|
|
--
|
|
htp.p('<form id="submit_form" name="submit_form" method="get" action="efnow131$.open_renom_window">');
|
|
--
|
|
-- Draw the page header
|
|
--
|
|
page_header;
|
|
--
|
|
page_body;
|
|
--
|
|
htp.p('<br>');
|
|
--
|
|
htp.p('<input type=submit value="' || l_submit_lbl || '">');
|
|
--
|
|
htp.p('<input type=button value="' || l_selectall_lbl ||
|
|
'" onClick="checkAll(''p_cont_id'')">');
|
|
--
|
|
htp.p('<br><br>');
|
|
htp.p('<i>''*''' || caco_utilities.get_module_text(2202) || '</i>'); -- '*' Denotes a mandatory field
|
|
--
|
|
htp.p('<br><br>');
|
|
htp.p('<p>'||caco_utilities.get_module_text(3928)||'</p>');
|
|
htp.p('<table border="1">
|
|
<tr>
|
|
<td>{GAS_DAY}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>{START_TIME}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>{END_TIME}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>{CUSTOMER_NAME}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>{CONTRACT_NAME}</td>
|
|
</tr>
|
|
</table>');
|
|
htp.p('</form>'); -- Submit_form
|
|
--
|
|
htp.p('</div>');
|
|
--
|
|
wsgl.closepagebody;
|
|
--
|
|
END;
|
|
--
|
|
-- Procedure to create the header nomination window record
|
|
--
|
|
PROCEDURE create_nom_wdw_header(p_gas_day IN DATE
|
|
,p_wdw_open IN DATE
|
|
,p_wdw_close IN DATE
|
|
,p_message IN VARCHAR2
|
|
,p_inserted OUT nomination_windows%ROWTYPE) IS
|
|
--
|
|
l_tsa_timestamp DATE;
|
|
l_nowi_id NUMBER;
|
|
l_empty_blob BLOB;
|
|
l_blob_of_message BLOB;
|
|
l_inserted nomination_windows%ROWTYPE;
|
|
l_error VARCHAR2(255);
|
|
--
|
|
BEGIN
|
|
--
|
|
SELECT nowi_seq.NEXTVAL
|
|
INTO l_nowi_id
|
|
FROM dual;
|
|
--
|
|
--
|
|
l_blob_of_message := l_empty_blob;
|
|
--
|
|
l_blob_of_message := utl_raw.cast_to_raw(p_message);
|
|
--
|
|
l_tsa_timestamp := amfr_timestamp.timestamp_document(p_identifier => l_nowi_id
|
|
,p_doctype => c_renom_window
|
|
,p_file_for_hash => l_blob_of_message);
|
|
--
|
|
INSERT INTO nomination_windows
|
|
(nowi_id
|
|
,gas_day
|
|
,window_start
|
|
,window_end
|
|
,message
|
|
,notes
|
|
,tsa_timestamp)
|
|
VALUES
|
|
(l_nowi_id
|
|
,p_gas_day
|
|
,p_wdw_open
|
|
,p_wdw_close
|
|
,p_message
|
|
,NULL
|
|
,SYSDATE)
|
|
RETURNING gas_day, window_start, window_end, message, notes, nowi_id, tsa_timestamp INTO l_inserted;
|
|
--
|
|
p_inserted := l_inserted;
|
|
--
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
--
|
|
l_error := 'ERROR in efnow131$.Create_Nom_Wdw_Header: ' || SQLERRM;
|
|
--
|
|
ROLLBACK;
|
|
--
|
|
wsgl.displaymessage(p_type => wsgl.mess_error
|
|
,p_mess => l_error);
|
|
END;
|
|
--
|
|
-- Procedure to create the child customer records and send messages
|
|
--
|
|
PROCEDURE create_nom_wdw_contracts(p_nowi_id IN NUMBER
|
|
,p_contracts IN owa_util.vc_arr
|
|
,p_subject IN VARCHAR2
|
|
,p_message IN VARCHAR2
|
|
,p_cont_tab OUT t_cont_tab) IS
|
|
--
|
|
l_idx NUMBER;
|
|
l_subject VARCHAR2(255);
|
|
l_message VARCHAR2(2000);
|
|
--
|
|
CURSOR c_cust(cp_cont_id IN contracts.cont_id%TYPE) IS
|
|
SELECT cu.name
|
|
, co.contract_number
|
|
, cu.cust_id
|
|
FROM customers cu
|
|
, contracts co
|
|
WHERE cu.cust_id = co.cust_id
|
|
AND co.cont_id = cp_cont_id;
|
|
--
|
|
l_cust_id customers.cust_id%TYPE;
|
|
l_cust_name customers.name%TYPE;
|
|
l_contract_number contracts.contract_number%TYPE;
|
|
--
|
|
l_cont_tab t_cont_tab;
|
|
l_cust_tab t_cont_tab;
|
|
l_cust_cont_tab t_cont_tab;
|
|
l_empty_cont_tab t_cont_tab;
|
|
--
|
|
BEGIN
|
|
--
|
|
l_cont_tab := l_empty_cont_tab;
|
|
l_cust_tab := l_empty_cont_tab;
|
|
l_cust_cont_tab := l_empty_cont_tab;
|
|
--
|
|
l_idx := p_contracts.FIRST;
|
|
--
|
|
FOR i IN 1 .. p_contracts.COUNT LOOP
|
|
--
|
|
OPEN c_cust(p_contracts(l_idx));
|
|
FETCH c_cust
|
|
INTO l_cust_name
|
|
, l_contract_number
|
|
, l_cust_id;
|
|
CLOSE c_cust;
|
|
--
|
|
l_cust_cont_tab(i) := l_cust_name||'-'||l_contract_number;
|
|
l_cont_tab(i) := l_contract_number;
|
|
l_cust_tab(i) := l_cust_name;
|
|
--
|
|
INSERT INTO nom_window_contracts
|
|
(cont_id
|
|
,nowi_id)
|
|
VALUES
|
|
(p_contracts(l_idx)
|
|
,p_nowi_id);
|
|
--
|
|
-- Replace any customer name tokens within the text
|
|
--
|
|
l_message := REPLACE(p_message, '{CUSTOMER_NAME}', l_cust_tab(i));
|
|
l_message := REPLACE(l_message, '{CONTRACT_NAME}', l_cont_tab(i));
|
|
l_subject := REPLACE(p_subject, '{CUSTOMER_NAME}', l_cust_tab(i));
|
|
l_subject := REPLACE(l_subject, '{CONTRACT_NAME}', l_cont_tab(i));
|
|
--
|
|
-- Create bulletin message
|
|
--
|
|
FOR syus IN (SELECT syus.syus_id syus_id
|
|
,syus.LANGUAGE
|
|
FROM system_users syus
|
|
WHERE syus.cust_id = l_cust_id) LOOP
|
|
--
|
|
amfr_message.create_message(p_subject => l_subject
|
|
,p_message => l_message
|
|
,p_cust_id => NULL
|
|
,p_sypr_id => NULL
|
|
,p_syus_id => syus.syus_id
|
|
,p_active_from => SYSDATE
|
|
,p_active_to => SYSDATE + 3);
|
|
--
|
|
END LOOP;
|
|
--
|
|
l_idx := p_contracts.NEXT(l_idx);
|
|
--
|
|
END LOOP;
|
|
--
|
|
p_cont_tab := l_cust_cont_tab;
|
|
--
|
|
END;
|
|
--
|
|
-- Function to check the date format
|
|
--
|
|
FUNCTION invalid_date_format(p_gas_day IN VARCHAR2) RETURN BOOLEAN IS
|
|
--
|
|
l_date DATE;
|
|
--
|
|
BEGIN
|
|
--
|
|
l_date := TO_DATE(p_gas_day
|
|
,c_date_format);
|
|
--
|
|
RETURN(FALSE);
|
|
--
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
RETURN(TRUE);
|
|
END;
|
|
--
|
|
-- Submit procedure called by the form
|
|
--
|
|
PROCEDURE open_renom_window(p_gas_day IN VARCHAR2
|
|
,p_wdw_open_hr IN VARCHAR2
|
|
,p_wdw_open_min IN VARCHAR2
|
|
,p_wdw_close_hr IN VARCHAR2
|
|
,p_wdw_close_min IN VARCHAR2
|
|
,p_subject IN VARCHAR2
|
|
,p_message IN VARCHAR2
|
|
,p_cont_id IN owa_util.vc_arr DEFAULT g_empty_vc_array) IS
|
|
--
|
|
missing_params EXCEPTION;
|
|
start_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_gas_day DATE;
|
|
l_wdw_open DATE;
|
|
l_wdw_close DATE;
|
|
l_error VARCHAR2(255);
|
|
l_error_type exception_messages.exme_type%TYPE;
|
|
l_header_rec nomination_windows%ROWTYPE;
|
|
l_inserted_row VARCHAR2(2000);
|
|
l_cont_idx NUMBER;
|
|
l_cont_tab t_cont_tab;
|
|
l_subject VARCHAR2(255);
|
|
l_message VARCHAR2(2000);
|
|
ex_invalid_date_format EXCEPTION;
|
|
--
|
|
FUNCTION p_adj_hour (p_hour IN VARCHAR2) RETURN NUMBER IS
|
|
--
|
|
l_return NUMBER := 0;
|
|
--
|
|
BEGIN
|
|
--
|
|
IF p_hour IN ('0','1','2','3','4','5') THEN
|
|
--
|
|
-- If the hour indicates it is the start of the next calendar day, increment the day
|
|
--
|
|
l_return := 1;
|
|
--
|
|
END IF;
|
|
--
|
|
RETURN l_return;
|
|
--
|
|
END p_adj_hour;
|
|
--
|
|
BEGIN
|
|
--
|
|
standard_html_header;
|
|
--
|
|
l_error_list := l_empty_error_list;
|
|
l_inserted_row := NULL;
|
|
--
|
|
-- Check mandatory parameters are entered.
|
|
--
|
|
IF p_gas_day IS NULL THEN
|
|
--
|
|
l_error_list(1) := g_gas_day_lbl;
|
|
RAISE missing_params;
|
|
--
|
|
ELSIF p_subject IS NULL THEN
|
|
--
|
|
l_error_list(1) := g_subject_lbl;
|
|
RAISE missing_params;
|
|
--
|
|
ELSIF p_message IS NULL THEN
|
|
--
|
|
l_error_list(1) := g_message_lbl;
|
|
RAISE missing_params;
|
|
--
|
|
ELSIF p_cont_id.COUNT < 1 THEN
|
|
--
|
|
l_error_list(1) := g_contracts;
|
|
RAISE missing_params;
|
|
--
|
|
END IF;
|
|
--
|
|
IF invalid_date_format(p_gas_day) THEN
|
|
RAISE ex_invalid_date_format;
|
|
END IF;
|
|
--
|
|
l_gas_day := TO_DATE(p_gas_day
|
|
,c_date_format) + (c_gas_day_start / 24);
|
|
--
|
|
l_wdw_open := TO_DATE(p_gas_day|| ' ' || p_wdw_open_hr || ':' ||
|
|
p_wdw_open_min
|
|
,c_nom_wdw_format)+p_adj_hour(p_wdw_open_hr);
|
|
--
|
|
l_wdw_close := TO_DATE(p_gas_day|| ' ' || p_wdw_close_hr || ':' ||
|
|
p_wdw_close_min
|
|
,c_nom_wdw_format)+p_adj_hour(p_wdw_close_hr);
|
|
--
|
|
IF l_wdw_open < SYSDATE THEN
|
|
--
|
|
RAISE start_date_in_past;
|
|
--
|
|
ELSIF l_wdw_close <= l_wdw_open THEN
|
|
--
|
|
RAISE dates_overlap;
|
|
--
|
|
END IF;
|
|
--
|
|
-- Replace any tokens within the text
|
|
l_message := p_message;
|
|
l_message := REPLACE(l_message, '{GAS_DAY}', p_gas_day);
|
|
l_message := REPLACE(l_message, '{START_TIME}', to_char(l_wdw_open,c_time_format));
|
|
l_message := REPLACE(l_message, '{END_TIME}', to_char(l_wdw_close,c_time_format));
|
|
l_subject := p_subject;
|
|
l_subject := REPLACE(l_subject, '{GAS_DAY}', p_gas_day);
|
|
l_subject := REPLACE(l_subject, '{START_TIME}', to_char(l_wdw_open,c_time_format));
|
|
l_subject := REPLACE(l_subject, '{END_TIME}', to_char(l_wdw_close,c_time_format));
|
|
--
|
|
create_nom_wdw_header(p_gas_day => l_gas_day
|
|
,p_wdw_open => l_wdw_open
|
|
,p_wdw_close => l_wdw_close
|
|
,p_message => l_message
|
|
,p_inserted => l_header_rec);
|
|
--
|
|
create_nom_wdw_contracts(p_nowi_id => l_header_rec.nowi_id
|
|
,p_contracts => p_cont_id
|
|
,p_subject => l_subject
|
|
,p_message => l_message
|
|
,p_cont_tab => l_cont_tab);
|
|
--
|
|
l_inserted_row := '<table>' || '<tr><td><b>' || g_gas_day_lbl || ': ' ||
|
|
'</b></td><td>' ||
|
|
TO_CHAR(l_header_rec.gas_day
|
|
,c_datetime_format) || '</td></tr>' ||
|
|
'<tr><td><b>' || g_wdw_open_lbl || ': ' ||
|
|
'</b></td><td>' ||
|
|
TO_CHAR(l_header_rec.window_start
|
|
,c_datetime_format) || '</td></tr>' ||
|
|
'<tr><td><b>' || g_wdw_close_lbl || ': ' ||
|
|
'</b></td><td>' ||
|
|
TO_CHAR(l_header_rec.window_end
|
|
,c_datetime_format) || '</td></tr>' ||
|
|
'<tr><td><b>' || g_message_lbl || ': ' ||
|
|
'</b></td><td>' || l_header_rec.message ||
|
|
'</td></tr><tr><td><b>' || g_timestamp_lbl || ': ' ||
|
|
'</b></td><td>' ||
|
|
TO_CHAR(l_header_rec.tsa_timestamp
|
|
,c_datetime_format) || '</td></tr>' ||
|
|
'</table>';
|
|
--
|
|
htp.p('<h1>'||caco_utilities.get_module_text(c_heading)||'</h1>');
|
|
--
|
|
wsgl.displaymessage(p_type => wsgl.mess_success
|
|
,p_mess => l_inserted_row);
|
|
--
|
|
htp.p('<br>');
|
|
htp.p('<b>' || g_contracts || '</b>');
|
|
htp.p('<br>');
|
|
--
|
|
l_cont_idx := l_cont_tab.FIRST;
|
|
--
|
|
FOR i IN 1 .. l_cont_tab.COUNT LOOP
|
|
--
|
|
htp.p('<p>' || l_cont_tab(l_cont_idx) || '</p>');
|
|
--
|
|
l_cont_idx := l_cont_tab.NEXT(l_cont_idx);
|
|
--
|
|
END LOOP;
|
|
--
|
|
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 start_date_in_past THEN
|
|
--
|
|
caco_utilities.get_exception_message(p_exception_number => -20507
|
|
,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 => -20508
|
|
,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 efnow131$.open_renom_window: ' || 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 efnow131$;
|
|
/
|