CREATE OR REPLACE PACKAGE BODY efnow095$ IS -- -- -- 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 , 'DD-MON-RRRR' ); -- 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 , 'DD-MON-RRRR' ); -- EXCEPTION WHEN OTHERS THEN wsgl.displaymessage( wsgl.mess_exception , SQLERRM , '' , NULL , g_package_name || '.calendar' ); END calendar; -- -- -- 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(''); 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; -- -- FUNCTION dad_path RETURN VARCHAR2 IS BEGIN RETURN(lower(owa_util.get_cgi_env('REQUEST_PROTOCOL') || '://' || owa_util.get_cgi_env('HTTP_HOST') || owa_util.get_cgi_env('SCRIPT_NAME') || '/')); END dad_path; -- -- -- PROCEDURE approve_conf_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; -- htp.p(' h2 { color : #F21C0A; } .confTable { border : 1px solid; } .confTable td { border : 1px solid; } .confTable th { 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; } .confTH { 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; } .confTHCreatedDate { 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; width : 170px; } .confTHCentre { text-align : center; padding : 2px; font-weight : normal; 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; width : 50px; } .smallTextButton { font-size : smaller; } .nomValidTR1 { background-color : #FFFFFF; border-style : none; height : 20px; } .nomValidTR2 { background-color : #F5F5F5; border-style : none; height : 20px; } .nomInvalid { background-color : #FF9F98; padding : 2px; height : 20px; } .nomTDCentre { text-align : center; padding : 2px; } .nomTDGasDay { text-align : center; padding : 2px; width : 100px } .nomTDValid { text-align : center; padding : 2px; width : 60px; } '); END approve_conf_css; -- -- -- PROCEDURE approve_conf_js IS BEGIN -- Check we have permission to be using this module. IF NOT caco_security.security_check(g_package_name) THEN RETURN; END IF; -- htp.p(' function checkDateThenGo( dadPath ) { var theDate = document.getElementById(''p_gas_day''); if ( theDate.value != "" ) { location.href = dadPath + ''efnow095$.startup?p_gas_day='' + theDate.value; } else { alert('''||caco_utilities.get_module_text(2422)||''');'); -- Select a Gas Day htp.p(' } } function changeCheckBox( obj ) { var prevInput = obj.previousSibling; if (obj.checked) { prevInput.value = "Y"; } else { prevInput.value = "N"; } } function checkAll( field ) { var i=0 var x=new Array() while (document.getElementById(field+i)!=null){ x[i]= document.getElementById(field+i) i++ } for (i = 0; i < x.length; i++) { x[i].checked = true; changeCheckBox(x[i]); } } function setApp( obj ) { var appItem = obj.previousSibling; var allAppItems = document.getElementsByName( ''p_approve'' ); var allDelItems = document.getElementsByName( ''p_delete'' ); var appIndex = -1; // to hold the index of the approval item we are interested in for (i=0;i -1) { if (obj.checked) { appItem.value = ''Y''; allDelItems[appIndex].value = ''N''; allDelItems[appIndex].nextSibling.checked = false; } else { appItem.value = ''N''; } } } function setDel( obj ) { var delItem = obj.previousSibling; var allDelItems = document.getElementsByName( ''p_delete'' ); var allAppItems = document.getElementsByName( ''p_approve'' ); var delIndex = -1; // to hold the index of the delete item we are interested in for (i=0;i -1) { if (obj.checked) { delItem.value = ''Y''; allAppItems[delIndex].value = ''N''; allAppItems[delIndex].nextSibling.checked = false; } else { delItem.value = ''N''; } } } function checkAppAll( field ) { var i=0 var x=new Array() while (document.getElementById(field+i)!=null){ x[i]= document.getElementById(field+i) i++ } for (i = 0; i < x.length; i++) { x[i].checked = true; if (field == "p_approve_disp") { setApp(x[i])} else { setDel(x[i])}; } } '); END approve_conf_js; -- -- PROCEDURE conf_approve_tabhead IS BEGIN htp.p('
'); -- Created On htp.p(' '); -- Customer htp.p(' '); -- Contract Number htp.p(' '); -- Nomination ID htp.p(' '); -- Gas Day htp.p(' '); -- View htp.p(' '); -- Send htp.p(' '); -- Delete htp.p(' '); END conf_approve_tabhead; -- -- PROCEDURE conf_approve_tabclose IS BEGIN htp.p('
'||caco_utilities.get_module_text(118)||' '||caco_utilities.get_module_text(1047)||' '||caco_utilities.get_module_text(2013)||' '||caco_utilities.get_module_text(2286)||' '||caco_utilities.get_module_text(1142)||' '||caco_utilities.get_module_text(2062)||''||caco_utilities.get_module_text(3559)||''||caco_utilities.get_module_text(838)||'

'); -- Submit htp.p('
'); END conf_approve_tabclose; -- -- PROCEDURE approve_confirmations( p_call_type IN VARCHAR2 DEFAULT 'EXISTING' , p_s_conf_id IN owa_util.vc_arr DEFAULT g_vc_arr , p_f_nomi_id IN owa_util.vc_arr DEFAULT g_vc_arr , p_f_nom_identifier IN owa_util.vc_arr DEFAULT g_vc_arr , p_f_cont_num IN owa_util.vc_arr DEFAULT g_vc_arr , p_f_conf_error IN owa_util.vc_arr DEFAULT g_vc_arr ) IS -- CURSOR c_conf( cp_conf_id IN NUMBER ) IS SELECT conf.created_on , cust.name , cont.contract_number , nomi.identifier , ( SELECT MIN(gas_day) FROM conf_net_point_cat_vals cnpcv WHERE cnpcv.conf_id = conf.conf_id ) gas_day FROM nominations nomi , contracts cont , confirmations conf , customers cust WHERE conf.conf_id = cp_conf_id AND nomi.nomi_id(+) = conf.nomi_id AND cont.cont_id = conf.cont_id AND cont.cust_id = cust.cust_id AND cust.cuty_id = caco_utilities.cuty_id_for_user; -- -- Cursor to list all unapproved commercial confirmations CURSOR c_unapproved_conf IS SELECT conf.conf_id , conf.created_on , cust.name , nomi.identifier , cont.contract_number , ( SELECT MIN(gas_day) FROM conf_net_point_cat_vals cnpcv WHERE cnpcv.conf_id = conf.conf_id ) gas_day FROM confirmations conf , nominations nomi , contracts cont , customers cust WHERE conf.confirmation_type = 'CO' AND NVL(conf.approved,'N') = 'N' AND conf.nomi_id = nomi.nomi_id (+) AND conf.cont_id = cont.cont_id AND cont.cust_id = cust.cust_id AND cust.cuty_id = caco_utilities.cuty_id_for_user ORDER BY cust.name , gas_day DESC , conf.created_on DESC , cont.contract_number , nomi.identifier; -- CURSOR c_custname( cp_cont_num IN VARCHAR2 ) IS SELECT cust.name, cont.contract_number FROM customers cust , contracts cont WHERE cont.cont_id = cp_cont_num AND cust.cust_id = cont.cust_id AND cust.cuty_id = caco_utilities.cuty_id_for_user; -- -- l_conf_rec c_conf%ROWTYPE; l_dummy_rec c_unapproved_conf%ROWTYPE; l_cust_name customers.name%TYPE; l_cont_num contracts.contract_number%TYPE; -- l_count NUMBER := 0; -- l_approve_idx NUMBER := 0; l_delete_idx NUMBER := 0; -- BEGIN -- -- Check we have permission to be using this module. IF NOT caco_security.security_check(g_package_name) THEN RETURN; END IF; -- -- -- htp.p(' '); htp.p(' '); -- wsgl.openpagehead(caco_utilities.get_module_text(2426)); -- Approve Commercial Confirmation --wsgl.metatag; --htp.p(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); -- wsgl.closepagehead; wsgl.openpagebody(FALSE); htp.p(caco_system.menu); -- htp.p('

'||caco_utilities.get_module_text(2426)||'

'); -- Approve Commercial Confirmation -- -- IF p_call_type = 'EXISTING' THEN -- We haven't created new commercial confirmations for approval, -- we are looking for any unapproved commercial confirmation OPEN c_unapproved_conf; FETCH c_unapproved_conf INTO l_dummy_rec; IF c_unapproved_conf%FOUND THEN CLOSE c_unapproved_conf; -- -- Open a form and the table with its header row. conf_approve_tabhead; -- FOR r IN c_unapproved_conf LOOP -- l_count := l_count + 1; -- htp.p(''); -- -- Open the row IF MOD(l_count,2) = 0 THEN htp.p(''); ELSE htp.p(''); END IF; -- htp.p(''||TO_CHAR(r.created_on, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI:SS')||''); htp.p(''||r.name||''); htp.p(''||r.contract_number||''); htp.p(''||r.identifier||''); htp.p(''||TO_CHAR(r.gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))||''); htp.p(' '); -- Window name will be overwritten htp.p(' '); htp.p(' '); -- l_approve_idx := l_approve_idx + 1; l_delete_idx := l_delete_idx + 1; -- -- Close the row htp.p(''); -- END LOOP; -- -- Close the table, show a submit button and close the form conf_approve_tabclose; -- ELSE CLOSE c_unapproved_conf; -- htp.p('

'||caco_utilities.get_module_text(2427)||'

'); -- No unapproved confirmations exist -- END IF; -- ELSE -- We have been called from the create commercial confirmations routine IF NVL(p_s_conf_id.COUNT,0) = 0 AND NVL(p_f_nomi_id.COUNT,0) = 0 THEN -- htp.p('

'||caco_utilities.get_module_text(2281)||'

'); -- No nominations were submitted -- ELSE -- List successful Send Confirmations IF NVL(p_s_conf_id.COUNT,0) > 0 THEN -- htp.p(''||caco_utilities.get_module_text(2428)||'

'); -- Successfully created confirmations -- -- Open a form and the table with its header row. conf_approve_tabhead; -- FOR i IN 1..p_s_conf_id.COUNT LOOP -- htp.p(''); -- -- Open the row IF MOD(i,2) = 0 THEN htp.p(''); ELSE htp.p(''); END IF; -- OPEN c_conf( p_s_conf_id(i) ); FETCH c_conf INTO l_conf_rec; IF c_conf%FOUND THEN -- htp.p(''||TO_CHAR(l_conf_rec.created_on, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI:SS')||''); htp.p(''||l_conf_rec.name||''); htp.p(''||l_conf_rec.contract_number||''); htp.p(''||l_conf_rec.identifier||''); htp.p(''||TO_CHAR(l_conf_rec.gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))||''); htp.p(' '); -- Window title will be overwritten htp.p(' '); htp.p(' '); -- l_approve_idx := l_approve_idx + 1; l_delete_idx := l_delete_idx + 1; -- ELSE -- Span an error message across all columns htp.p(''||caco_utilities.get_module_text(2072)||' : ' -- Confirmation ||p_s_conf_id(i)||' : '||caco_utilities.get_module_text(2429)||''); -- not found END IF; CLOSE c_conf; -- -- Close the row htp.p(''); -- END LOOP; -- -- Close the table, show a submit button and close the form conf_approve_tabclose; -- -- END IF; -- -- List unsuccessful send confirmations IF NVL(p_f_nomi_id.COUNT,0) > 0 AND NVL(p_f_nomi_id.COUNT,0) = NVL(p_f_nom_identifier.COUNT,0) AND NVL(p_f_nomi_id.COUNT,0) = NVL(p_f_cont_num.COUNT,0) AND NVL(p_f_nomi_id.COUNT,0) = NVL(p_f_conf_error.COUNT,0) THEN -- Failed to create the following commercial confirmations htp.p(''||caco_utilities.get_module_text(2430)||'

'); -- htp.p(''); -- Customer htp.p(' '); -- Contract Number htp.p(' '); -- Nomination ID htp.p(' '); -- Exception Message htp.p(' '); -- FOR i IN 1..p_f_nomi_id.COUNT LOOP -- get the customer name l_cust_name := NULL; OPEN c_custname(p_f_cont_num(i)); FETCH c_custname INTO l_cust_name, l_cont_num; CLOSE c_custname; -- IF MOD(i,2) = 0 THEN htp.p(''); ELSE htp.p(''); END IF; -- htp.p(''); htp.p(''); htp.p(''); htp.p(''); -- htp.p(''); -- END LOOP; -- htp.p('
'||caco_utilities.get_module_text(1047)||' '||caco_utilities.get_module_text(2013)||' '||caco_utilities.get_module_text(2286)||' '||caco_utilities.get_module_text(2259)||'
'||l_cust_name||''||l_cont_num||''||p_f_nom_identifier(i)||''||p_f_conf_error(i)||'
'); -- END IF; -- END IF; -- END IF; -- called from create commercial confirmations -- -- Close the margin div htp.p('
'); -- -- Close centrecontent div htp.p(''); -- -- Close outer div htp.p(''); -- wsgl.closepagebody; -- -- END approve_confirmations; -- -- PROCEDURE find_nom_button IS BEGIN -- Find Nominations htp.p('

'); -- END find_nom_button; -- -- -- -- PROCEDURE startup( p_gas_day IN VARCHAR2 DEFAULT NULL , p_error IN VARCHAR2 DEFAULT 'N' , p_error_text IN VARCHAR2 DEFAULT NULL ) IS -- CURSOR c_contracts( cp_gas_day IN DATE ) IS SELECT cust.name customer_name , cont.cont_id contract_id , cont.contract_number contract_number -- , nomi.nomi_id nom_id -- , nomi.status nom_status -- , nomi.identifier nom_identifier -- , nomi.created_on nom_created_on -- , nomi.nom_gas_day_from nom_gas_day_from -- , nomi.nom_gas_day_to nom_gas_day_to FROM contracts cont , customers cust /* , ( SELECT cont.cust_id , nomi.cont_id , nomi.nomi_id , nomi.status status , nomi.identifier identifier , nomi.created_on created_on , MIN(nnpcv.gas_day) nom_gas_day_from , MAX(nnpcv.gas_day) nom_gas_day_to FROM nominations nomi ,nom_net_point_cat_vals nnpcv ,contracts cont WHERE nnpcv.nomi_id = nomi.nomi_id AND nomi.status = 'A' AND cont.cont_id = nomi.cont_id GROUP BY cont.cust_id , nomi.cont_id , nomi.nomi_id , nomi.status , nomi.identifier , nomi.created_on HAVING cp_gas_day BETWEEN MIN(nnpcv.gas_day) AND MAX(nnpcv.gas_day) ) nomi */ WHERE cont.cust_id = cust.cust_id -- AND cont.cont_id = nomi.cont_id -- AND cust.cust_id = nomi.cust_id (+) AND cust.cuty_id = caco_utilities.cuty_id_for_user AND (cust.cust_id = caco_utilities.get_cust_id OR caco_utilities.get_cust_id = cout_system_configuration.get_configuration_item('G_OMT_CUST_ID')) AND cp_gas_day BETWEEN cont.valid_from AND cont.valid_until AND cont.status = 'O' GROUP BY cust.name , cont.cont_id , cont.contract_number -- , nomi.nomi_id -- , nomi.status -- , nomi.identifier -- , nomi.created_on -- , nomi.nom_gas_day_from -- , nomi.nom_gas_day_to ORDER BY cust.name , cont.contract_number; --, nomi.nom_gas_day_from DESC /* fix for 49980 */ --, nomi.created_on DESC; -- /* AG */ /* CURSOR cur_last_nomi ( cp_cont_id IN contracts.cont_id%TYPE , cp_gas_day IN DATE ) IS SELECT MAX(nnpcv.gas_day) gas_day ,nomi.nomi_id FROM nom_net_point_cat_vals nnpcv ,nominations nomi ,contracts cont1 ,contracts cont2 WHERE nnpcv.nomi_id = nomi.nomi_id AND cont1.cust_id = cont2.cust_id AND cont1.cont_id = cp_cont_id AND nnpcv.gas_day <= cp_gas_day AND nomi.cont_id = cont2.cont_id GROUP BY nomi.nomi_id , nomi.created_on ORDER BY MAX(nnpcv.gas_day) DESC , nomi.created_on DESC;*/ -- CURSOR cur_last_nomi ( cp_cont_id IN contracts.cont_id%TYPE , cp_gas_day IN DATE , cp_nomi_id IN nominations.nomi_id%TYPE) IS SELECT MAX(nnpcv.gas_day) gas_day ,nomi.nomi_id FROM nom_net_point_cat_vals nnpcv ,nominations nomi -- ,contracts cont WHERE nnpcv.nomi_id = nomi.nomi_id -- AND nomi.cont_id = cont.cont_id AND nomi.cont_id IN (SELECT cont2.cont_id FROM contracts cont2 CONNECT BY PRIOR cont2.prev_cont_id = cont2.cont_id START WITH cont2.cont_id = cp_cont_id) -- AND cont.cust_id = (SELECT cust_id FROM contracts where cont_id= cp_cont_id) AND nnpcv.gas_day <= cp_gas_day AND nomi.nomi_id <> NVL(cp_nomi_id,-1) GROUP BY nomi.nomi_id , nomi.created_on ORDER BY MAX(nnpcv.gas_day) DESC , nomi.created_on DESC; -- -- CURSOR cur_nomi (cp_gas_day IN DATE ,c_cont_id IN contracts.cont_id%TYPE) IS SELECT nomi.nomi_id nom_id , nomi.status nom_status , nomi.identifier nom_identifier , nomi.created_on nom_created_on , MIN(nnpcv.gas_day) nom_gas_day_from , MAX(nnpcv.gas_day) nom_gas_day_to FROM nominations nomi , nom_net_point_cat_vals nnpcv WHERE nnpcv.nomi_id = nomi.nomi_id AND nomi.status = 'A' AND nomi.cont_id = c_cont_id GROUP BY nomi.nomi_id , nomi.status , nomi.identifier , nomi.created_on HAVING cp_gas_day BETWEEN MIN(nnpcv.gas_day) AND MAX(nnpcv.gas_day); l_nom_rec cur_nomi%ROWTYPE; l_last_nomi_rec cur_last_nomi%ROWTYPE; -- l_gas_day DATE; gas_day_chosen BOOLEAN := FALSE; date_in_past BOOLEAN := FALSE; l_noms_found BOOLEAN := FALSE; l_nom_count NUMBER := 0; l_prev_contract contracts.contract_number%TYPE; l_prev_customer customers.name%TYPE; l_return_error VARCHAR2(255) := NULL; -- nom_valid BOOLEAN := FALSE; -- l_force_idx NUMBER := 0; l_accept_idx NUMBER := 0; -- BEGIN -- -- Check we have permission to be using this module. IF NOT caco_security.security_check(g_package_name) THEN RETURN; END IF; -- -- IF p_gas_day IS NOT NULL THEN -- Convert the varchar gas day into a date BEGIN SELECT TO_DATE(p_gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) INTO l_gas_day FROM dual; -- -- Successful so we have chosen a gas day to look for -- Check its today or the future /* IF (l_gas_day) < TRUNC(SYSDATE-(cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24)) THEN date_in_past := TRUE; ELSE gas_day_chosen := TRUE; END IF; */ gas_day_chosen := TRUE; -- EXCEPTION WHEN others THEN -- Invalid date - but we dont have to do anything. NULL; END; -- END IF; -- -- htp.p(' '); htp.p(' '); -- wsgl.openpagehead(g_title); --wsgl.metatag; --htp.p(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); -- -- 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); -- wsgl.closepagehead; wsgl.openpagebody(FALSE); htp.p(caco_system.menu); -- htp.p('

'||caco_utilities.get_module_text(2431)||'

'); -- Create Commercial Confirmation -- IF p_error = 'Y' THEN htp.p('Send Failed
'); htp.p(''||p_error_text||'

'); END IF; -- htp.p(''); -- Gas Day htp.p('
'||caco_utilities.get_module_text(1142)||'  
'); -- 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 => cout_system_configuration.get_configuration_item('G_DATE_FORMAT') ,p_field_prompt => caco_utilities.get_module_text(1142) )); -- Gas Day -- htp.p('
'); -- -- Now show the nominations that are available to confirm IF gas_day_chosen THEN -- Loop through each nomination found -- Validate it and give a check box for the valid noms -- need to ensure only select one nom for a given contract for a given day.. -- htp.p('
'); -- -- Lets just check if there is any data.... FOR rec_contracts IN c_contracts( l_gas_day ) LOOP OPEN cur_last_nomi (rec_contracts.contract_id ,l_gas_day ,NULL); FETCH cur_last_nomi INTO l_last_nomi_rec; IF cur_last_nomi%FOUND THEN l_noms_found := TRUE; END IF; CLOSE cur_last_nomi; END LOOP; -- -- IF l_noms_found THEN -- l_prev_contract := '~@?^$&'; -- -- Put out the gas day selected to pass to the commercial confirmation creation routine. -- We know it is in the correct format or we wouldnt be here. -- htp.p(''); -- Put the submit button at the top in case there are many nominations that overflow the visible page htp.p('

'); -- Submit Selected htp.p('

'); -- -- If we found any data then Open the table with a header row. -- htp.p(''); -- Customer htp.p(' '); -- Contract Number htp.p(' '); -- Nom Identifier htp.p(' '); -- Nom Created On htp.p(' '); -- Gas Day From htp.p(' '); -- Gas Day To htp.p(' '); -- Valid? htp.p(' '); -- Accept htp.p(' '); -- Force htp.p(' '); -- -- Loop through all the noms/contracts caco_debug.putline('-----EFNOW095$ c_contracts LOOP START'); FOR r IN c_contracts( l_gas_day ) LOOP -- l_nom_rec := NULL; OPEN cur_nomi (l_gas_day ,r.contract_id); FETCH cur_nomi INTO l_nom_rec; CLOSE cur_nomi; nom_valid := FALSE; l_nom_count := l_nom_count + 1; -- -- The below ensures that only the tip nomination is shown for each contract -- Should you ever need to show all Nominations, remove this IF -- and remove status=A from the c_contracts cursor IF l_prev_contract != r.contract_number THEN -- Only want the "tips" -- Validate the nomination IF l_nom_rec.nom_id IS NOT NULL THEN -- nom_valid := efno_contracts.validate_nomination( r.contract_id , l_nom_rec.nom_id , l_return_error ); -- not used in this program unit -- ELSE -- -- No nomination therefore not valid. -- -- nom_valid := FALSE; -- END IF; -- -- Write out the details IF nom_valid THEN IF MOD(l_nom_count,2) = 0 THEN htp.p(''); ELSE htp.p(''); END IF; ELSE htp.p(''); END IF; -- IF l_prev_customer = r.customer_name THEN htp.p(' '); ELSE htp.p(' '); END IF; -- IF l_prev_contract = r.contract_number THEN htp.p(' '); ELSE htp.p(' '); END IF; -- IF l_nom_rec.nom_identifier IS NOT NULL AND nom_valid THEN -- htp.p(' '); -- ELSE BEGIN l_last_nomi_rec := NULL; OPEN cur_last_nomi ( r.contract_id , l_gas_day , l_nom_rec.nom_id); FETCH cur_last_nomi INTO l_last_nomi_rec; CLOSE cur_last_nomi; -- EXCEPTION WHEN OTHERS THEN -- l_last_nomi_rec := NULL; -- continue processing if an error occurs finding the last nomination, it is purely for information only -- END; -- IF l_last_nomi_rec.nomi_id IS NOT NULL THEN htp.p(''); l_last_nomi_rec.nomi_id := NULL; ELSE htp.p(''); END IF; -- END IF; -- -- Check if valid again -- NOTE: there must NOT be a carriage return or space between p_accept and the checkbox -- (otherwise the changeCheckBox javascript function does not work) IF nom_valid THEN htp.p(''); htp.p(''); htp.p(''); l_accept_idx := l_accept_idx + 1; ELSE htp.p(''); htp.p(''); htp.p(''); l_force_idx := l_force_idx + 1; END IF; -- htp.p(''); -- l_prev_contract := r.contract_number; l_prev_customer := r.customer_name; -- END IF; -- END LOOP; caco_debug.putline('-----EFNOW095$ c_contracts LOOP END'); -- -- Close the table htp.p('
'||caco_utilities.get_module_text(2081)||''||caco_utilities.get_module_text(2013)||''||caco_utilities.get_module_text(2038)||''||caco_utilities.get_module_text(2039)||''||caco_utilities.get_module_text(2058)||''||caco_utilities.get_module_text(2059)||''||caco_utilities.get_module_text(2040)||''||caco_utilities.get_module_text(2042)||''||caco_utilities.get_module_text(2043)||'
 '||r.customer_name||' '||r.contract_number||''||l_nom_rec.nom_identifier||' '||TO_CHAR(l_nom_rec.nom_created_on, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI:SS')||' '||TO_CHAR(l_nom_rec.nom_gas_day_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))||' '||TO_CHAR(l_nom_rec.nom_gas_day_to, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))||''||caco_utilities.get_module_text(2037)||'. '||REPLACE(REPLACE(REPLACE(caco_utilities.get_module_text(3557), '',TO_CHAR(l_gas_day,cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))),'',l_last_nomi_rec.nomi_id),'',TO_CHAR(l_last_nomi_rec.gas_day,cout_system_configuration.get_configuration_item('G_DATE_FORMAT')))||''||caco_utilities.get_module_text(2037)||'. '||REPLACE(caco_utilities.get_module_text(3558), '', TO_CHAR(l_gas_day,cout_system_configuration.get_configuration_item('G_DATE_FORMAT')))||''||RTRIM(caco_utilities.get_module_text(2040),'?')||'  '||caco_utilities.get_module_text(2041)||' 
'); -- ELSE -- Need a button to recall the screen with a chosen gas day find_nom_button; -- No Nominations found - put out a message to that effect -- There are no nominations for the chosen gas day htp.p('

'||caco_utilities.get_module_text(2037)||'

'); END IF; -- htp.p('
'); -- ELSIF date_in_past THEN -- find_nom_button; -- You may only create commercial confirmations for today and future gas days htp.p('

'||caco_utilities.get_module_text(2432)||'

'); -- ELSE -- Need a button to recall the screen with a chosen gas day find_nom_button; -- END IF; -- gas day chosen -- -- Close the margin div htp.p('
'); -- -- Close centrecontent div htp.p(''); -- -- Close outer div htp.p(''); -- wsgl.closepagebody; -- END startup; -- -- /** -- FUNCTION about -- -- Returns the version number and VSS header for this package -- -- %return The version number and VSS header for this package */ FUNCTION about RETURN VARCHAR2 IS BEGIN RETURN ( g_package_name || CHR(10) ||g_revision||chr(10)|| g_header ); END about; -- -- -- BEGIN -- Initialization NULL; -- END efnow095$; /