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

6822 lines
254 KiB
Plaintext

CREATE OR REPLACE PACKAGE BODY efnow092$ 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('<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;
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 find_passed_net_points( p_nepo_array IN owa_util.vc_arr
, p_network_point_array OUT network_point_array )
IS
CURSOR c_nepo( cp_id IN NUMBER ) IS
SELECT REPLACE(REPLACE(name,chr(13),''),chr(10),'') name
FROM network_points
WHERE nepo_id = cp_id;
--
l_count NUMBER := 0;
l_name network_points.name%TYPE;
--
BEGIN
--
IF NVL(p_nepo_array.COUNT,0) > 0 THEN
FOR i IN p_nepo_array.FIRST .. p_nepo_array.LAST LOOP
--
l_name := NULL;
l_count := l_count + 1;
--
-- Fetch the network point name
OPEN c_nepo( TO_NUMBER(p_nepo_array(i)) );
FETCH c_nepo INTO l_name;
IF c_nepo%FOUND THEN
-- valid network point
p_network_point_array(l_count).nepo_id := TO_NUMBER(p_nepo_array(i));
p_network_point_array(l_count).name := l_name;
ELSE
l_count := l_count - 1;
END IF;
CLOSE c_nepo;
--
END LOOP;
END IF;
--
END find_passed_net_points;
PROCEDURE find_passed_categories( p_cate_array IN owa_util.vc_arr
, p_template_id IN NUMBER
, p_category_array OUT category_array
, p_prev_template_id IN NUMBER DEFAULT 0 )
IS
-- Template categories (if template_id supplied)
CURSOR c_cotc IS
SELECT REPLACE(REPLACE(cate.name,chr(13),''),chr(10),'')||' ('||cate.units||')' category_name
, cate.cate_id category_id
FROM contract_template_categories cotc
, categories cate
WHERE cate.cate_id = cotc.cate_id
AND cotc.cote_id = p_template_id
ORDER BY cotc.display_sequence; --cate.name||' ('||cate.units||')' ASC;
--
CURSOR c_cate( cp_id IN NUMBER ) IS
SELECT REPLACE(REPLACE(name,chr(13),''),chr(10),'')||' ('||units||')' category_name
FROM categories
WHERE cate_id = cp_id;
--
l_count NUMBER := 0;
l_inh_count NUMBER := 0;
l_name VARCHAR2(200);
--
FUNCTION cat_exists( p_id IN NUMBER
, p_category_array IN category_array )
RETURN BOOLEAN
IS
l_success BOOLEAN := FALSE;
BEGIN
IF NVL(p_category_array.COUNT,0) > 0 THEN
FOR i IN p_category_array.FIRST..p_category_array.LAST LOOP
IF p_category_array(i).cate_id = p_id THEN
l_success := TRUE;
END IF;
END LOOP;
END IF;
RETURN l_success;
END cat_exists;
--
FUNCTION from_prev_template( p_prev_template_id IN NUMBER
, p_cate_id IN NUMBER )
RETURN BOOLEAN
IS
CURSOR c_cotc IS
SELECT 'x'
FROM contract_template_categories
WHERE cote_id = p_prev_template_id
AND cate_id = p_cate_id;
--
l_success BOOLEAN := FALSE;
l_dummy VARCHAR2(1);
--
BEGIN
OPEN c_cotc;
FETCH c_cotc INTO l_dummy;
IF c_cotc%FOUND THEN
l_success := TRUE;
END IF;
CLOSE c_cotc;
RETURN l_success;
END from_prev_template;
--
BEGIN
--
IF p_template_id IS NOT NULL
AND p_template_id > 0
THEN
FOR r IN c_cotc LOOP
l_inh_count := l_inh_count + 1;
p_category_array(l_inh_count).name := r.category_name;
p_category_array(l_inh_count).cate_id := r.category_id;
p_category_array(l_inh_count).inherited := 'Y';
END LOOP;
END IF;
--
l_count := l_inh_count;
--
IF NVL(p_cate_array.COUNT,0) > 0 THEN
FOR i IN p_cate_array.FIRST .. p_cate_array.LAST LOOP
--
-- Check that we dont already have it in the array
-- and check it isnt from a previous template (we need to remove it..)
IF NOT cat_exists( TO_NUMBER(p_cate_array(i)), p_category_array )
AND NOT from_prev_template( p_prev_template_id, TO_NUMBER(p_cate_array(i)) )
THEN
-- We dont have this one yet
-- Reinitialise the variable
l_name := NULL;
--
-- Fetch the category name
OPEN c_cate( TO_NUMBER(p_cate_array(i)) );
FETCH c_cate INTO l_name;
IF c_cate%FOUND THEN
--
l_count := l_count + 1;
-- valid category
p_category_array(l_count).cate_id := TO_NUMBER(p_cate_array(i));
p_category_array(l_count).name := l_name;
p_category_array(l_count).inherited := 'N';
END IF;
CLOSE c_cate;
--
END IF;
--
END LOOP;
END IF;
--
END find_passed_categories;
PROCEDURE find_passed_parameters( p_pars_array IN owa_util.vc_arr
, p_template_id IN NUMBER
, p_parameter_array OUT parameter_array
, p_prev_template_id IN NUMBER DEFAULT 0 )
IS
-- Template parameters (if template_id supplied)
CURSOR c_cotp IS
SELECT REPLACE(REPLACE(pars.name,chr(13),''),chr(10),'') parameter_name
, pars.pars_id parameter_id
FROM contract_template_params cotp
, parameters pars
WHERE pars.pars_id = cotp.pars_id
AND cotp.cote_id = p_template_id
AND pars.cate_id IS NULL
ORDER BY pars.name ASC;
--
CURSOR c_pars( cp_id IN NUMBER ) IS
SELECT REPLACE(REPLACE(name,chr(13),''),chr(10),'') name
FROM parameters
WHERE pars_id = cp_id
AND cate_id IS NULL;
--
l_count NUMBER := 0;
l_inh_count NUMBER := 0;
l_name parameters.name%TYPE;
--
FUNCTION par_exists( p_id IN NUMBER
, p_parameter_array IN parameter_array )
RETURN BOOLEAN
IS
l_success BOOLEAN := FALSE;
BEGIN
IF NVL(p_parameter_array.COUNT,0) > 0 THEN
FOR i IN p_parameter_array.FIRST..p_parameter_array.LAST LOOP
IF p_parameter_array(i).pars_id = p_id THEN
l_success := TRUE;
END IF;
END LOOP;
END IF;
RETURN l_success;
END par_exists;
--
FUNCTION from_prev_template( p_prev_template_id IN NUMBER
, p_pars_id IN NUMBER )
RETURN BOOLEAN
IS
CURSOR c_cotp IS
SELECT 'x'
FROM contract_template_params
WHERE cote_id = p_prev_template_id
AND pars_id = p_pars_id;
--
l_success BOOLEAN := FALSE;
l_dummy VARCHAR2(1);
--
BEGIN
OPEN c_cotp;
FETCH c_cotp INTO l_dummy;
IF c_cotp%FOUND THEN
l_success := TRUE;
END IF;
CLOSE c_cotp;
RETURN l_success;
END from_prev_template;
--
BEGIN
--
IF p_template_id IS NOT NULL
AND p_template_id > 0
THEN
FOR r IN c_cotp LOOP
l_inh_count := l_inh_count + 1;
p_parameter_array(l_inh_count).name := r.parameter_name;
p_parameter_array(l_inh_count).pars_id := r.parameter_id;
p_parameter_array(l_inh_count).inherited := 'Y';
END LOOP;
END IF;
--
l_count := l_inh_count;
--
IF NVL(p_pars_array.COUNT,0) > 0 THEN
FOR i IN p_pars_array.FIRST .. p_pars_array.LAST LOOP
--
-- Check that we dont already have it in the array
-- and check it isnt from a previous template (we need to remove it..)
IF NOT par_exists( TO_NUMBER(p_pars_array(i)), p_parameter_array )
AND NOT from_prev_template( p_prev_template_id, TO_NUMBER(p_pars_array(i)) )
THEN
-- Reinitialise the name variable
l_name := NULL;
-- We dont have this one yet
-- Fetch the parameter name
OPEN c_pars( TO_NUMBER(p_pars_array(i)) );
FETCH c_pars INTO l_name;
IF c_pars%FOUND THEN
-- valid parameter
l_count := l_count + 1;
--
p_parameter_array(l_count).pars_id := TO_NUMBER(p_pars_array(i));
p_parameter_array(l_count).name := l_name;
p_parameter_array(l_count).inherited := 'N';
END IF;
CLOSE c_pars;
--
END IF;
--
END LOOP;
END IF;
--
END find_passed_parameters;
PROCEDURE set_contract_options(p_contract_id IN NUMBER) IS
-- Cursor to get the default options
CURSOR c_option_defaults IS
SELECT substr(parameter, instr(parameter, '.') + 1) parameter,
VALUE
FROM application_parameters
WHERE upper(substr(parameter, 1, instr(parameter, '.') - 1)) = 'COOP'
ORDER BY appa_id;
-- Cursor to see if current options exist
CURSOR c_options IS
SELECT cont_id FROM contract_options WHERE cont_id = p_contract_id;
p_contract_opt_record contract_options%ROWTYPE;
l_contract_id contract_options.cont_id%TYPE;
l_new_contract BOOLEAN := FALSE;
BEGIN
IF p_contract_id IS NOT NULL
AND p_contract_id > 0 THEN
OPEN c_options;
FETCH c_options
INTO l_contract_id;
IF c_options%NOTFOUND THEN
l_new_contract := TRUE;
END IF;
CLOSE c_options;
--ELSE
--l_new_contract := TRUE;
END IF;
-- This is a new contract or there is no record of options for this contract
IF l_new_contract THEN
p_contract_opt_record.cont_id := p_contract_id;
FOR r IN c_option_defaults LOOP
IF upper(r.parameter) = 'NOM_CONF_SUBJECT' THEN
p_contract_opt_record.nom_conf_subject := r.value;
ELSIF upper(r.parameter) = 'NOM_CONF_CONTENT' THEN
p_contract_opt_record.nom_conf_content := r.value;
ELSIF upper(r.parameter) = 'COM_CONF_SUBJECT' THEN
p_contract_opt_record.com_conf_subject := r.value;
ELSIF upper(r.parameter) = 'COM_CONF_CONTENT' THEN
p_contract_opt_record.com_conf_content := r.value;
ELSIF upper(r.parameter) = 'AUTO_GEN_CONF' THEN
p_contract_opt_record.auto_gen_conf := r.value;
ELSIF upper(r.parameter) = 'CONF_TYPE' THEN
p_contract_opt_record.conf_type := r.value;
ELSIF upper(r.parameter) = 'IND_DEADLINE_FOR_NOM_SUBMIT' THEN
p_contract_opt_record.ind_deadline_for_nom_submit := r.value;
ELSIF upper(r.parameter) = 'SHIPPER' THEN
p_contract_opt_record.shipper := r.value;
ELSIF upper(r.parameter) = 'INT_SUBJECT' THEN
p_contract_opt_record.int_subject := r.value;
ELSIF upper(r.parameter) = 'INT_CONTENT' THEN
p_contract_opt_record.int_content := r.value;
ELSIF upper(r.parameter) = 'INT_SMS_CONTENT' THEN
p_contract_opt_record.int_sms_content := r.value;
END IF;
END LOOP;
--
INSERT INTO contract_options
(cont_id,
nom_conf_subject,
nom_conf_content,
com_conf_subject,
com_conf_content,
auto_gen_conf,
conf_type,
ind_deadline_for_nom_submit,
shipper,
int_subject,
int_content,
int_sms_content)
VALUES
(p_contract_opt_record.cont_id,
p_contract_opt_record.nom_conf_subject,
p_contract_opt_record.nom_conf_content,
p_contract_opt_record.com_conf_subject,
p_contract_opt_record.com_conf_content,
p_contract_opt_record.auto_gen_conf,
p_contract_opt_record.conf_type,
p_contract_opt_record.ind_deadline_for_nom_submit,
p_contract_opt_record.shipper,
p_contract_opt_record.int_subject,
p_contract_opt_record.int_content,
p_contract_opt_record.int_sms_content);
--
END IF;
END set_contract_options;
PROCEDURE get_contract_options(p_contract_id IN NUMBER,
p_contract_opt_record OUT contract_options%ROWTYPE) IS
-- Cursor to get the default options
CURSOR c_option_defaults IS
SELECT substr(parameter, instr(parameter, '.') + 1) parameter,
VALUE
FROM application_parameters
WHERE upper(substr(parameter, 1, instr(parameter, '.') - 1)) = 'COOP'
ORDER BY appa_id;
-- Cursor to get the current options
CURSOR c_options IS
SELECT cont_id,
nom_conf_subject,
nom_conf_content,
com_conf_subject,
com_conf_content,
auto_gen_conf,
conf_type,
ind_deadline_for_nom_submit,
shipper,
int_subject,
int_content,
int_sms_content
FROM contract_options
WHERE cont_id = p_contract_id;
l_new_contract BOOLEAN;
BEGIN
l_new_contract := FALSE;
IF p_contract_id IS NOT NULL
AND p_contract_id > 0 THEN
OPEN c_options;
FETCH c_options
INTO p_contract_opt_record;
IF c_options%NOTFOUND THEN
l_new_contract := TRUE;
END IF;
CLOSE c_options;
ELSE
l_new_contract := TRUE;
END IF;
-- This is a new contract or there is no record of options for this contract
IF l_new_contract THEN
p_contract_opt_record.cont_id := p_contract_id;
FOR r IN c_option_defaults LOOP
IF upper(r.parameter) = 'NOM_CONF_SUBJECT' THEN
p_contract_opt_record.nom_conf_subject := r.value;
ELSIF upper(r.parameter) = 'NOM_CONF_CONTENT' THEN
p_contract_opt_record.nom_conf_content := r.value;
ELSIF upper(r.parameter) = 'COM_CONF_SUBJECT' THEN
p_contract_opt_record.com_conf_subject := r.value;
ELSIF upper(r.parameter) = 'COM_CONF_CONTENT' THEN
p_contract_opt_record.com_conf_content := r.value;
ELSIF upper(r.parameter) = 'AUTO_GEN_CONF' THEN
p_contract_opt_record.auto_gen_conf := r.value;
ELSIF upper(r.parameter) = 'CONF_TYPE' THEN
p_contract_opt_record.conf_type := r.value;
ELSIF upper(r.parameter) = 'IND_DEADLINE_FOR_NOM_SUBMIT' THEN
p_contract_opt_record.ind_deadline_for_nom_submit := r.value;
ELSIF upper(r.parameter) = 'SHIPPER' THEN
p_contract_opt_record.shipper := r.value;
ELSIF upper(r.parameter) = 'INT_SUBJECT' THEN
p_contract_opt_record.int_subject := r.value;
ELSIF upper(r.parameter) = 'INT_CONTENT' THEN
p_contract_opt_record.int_content := r.value;
ELSIF upper(r.parameter) = 'INT_SMS_CONTENT' THEN
p_contract_opt_record.int_sms_content := r.value;
END IF;
END LOOP;
END IF;
END get_contract_options;
PROCEDURE get_contract_details_p1( p_contract_id IN NUMBER
, p_contract_record OUT contracts%ROWTYPE
, p_network_point_array OUT network_point_array
, p_category_array OUT category_array
, p_parameter_array OUT parameter_array )
IS
-- Cursor to get the full contract details row
CURSOR c_contract IS
SELECT *
FROM contracts
WHERE cont_id = p_contract_id;
--
-- Cursor to get all network points for this contract
CURSOR c_nepo IS
SELECT conp.nepo_id net_point_id
, nepo.name nepo_name
FROM cont_network_points conp
, network_points nepo
WHERE conp.nepo_id = nepo.nepo_id
AND conp.cont_id = p_contract_id
ORDER BY nepo.name;
--
-- Cursor to get all valid categories for this contract
CURSOR c_cate IS
SELECT coca.cate_id category_id
, cate.name||' ('||cate.units||')' category_name
, coca.inherited inherited
FROM contract_categories coca
, categories cate
WHERE coca.cate_id = cate.cate_id
AND coca.cont_id = p_contract_id
ORDER BY coca.inherited DESC, coca.display_sequence; --cate.name||' ('||cate.units||')';
--
-- Cursor to get all valid parameters for this contract
CURSOR c_pars IS
SELECT copa.pars_id parameter_id
, pars.name parameter_name
, copa.inherited inherited
FROM contract_parameters copa
, parameters pars
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND pars.cate_id IS NULL
ORDER BY pars.name;
--
l_count NUMBER := 0;
--
BEGIN
--
OPEN c_contract;
FETCH c_contract INTO p_contract_record;
CLOSE c_contract;
--
FOR r IN c_nepo LOOP
l_count := l_count + 1;
--
p_network_point_array(l_count).nepo_id := r.net_point_id;
p_network_point_array(l_count).name := r.nepo_name;
--
END LOOP;
--
l_count := 0;
--
FOR r IN c_cate LOOP
l_count := l_count + 1;
--
p_category_array(l_count).cate_id := r.category_id;
p_category_array(l_count).name := r.category_name;
p_category_array(l_count).inherited := r.inherited;
--
END LOOP;
--
l_count := 0;
--
FOR r IN c_pars LOOP
l_count := l_count + 1;
--
p_parameter_array(l_count).pars_id := r.parameter_id;
p_parameter_array(l_count).name := r.parameter_name;
p_parameter_array(l_count).inherited := r.inherited;
--
END LOOP;
--
END get_contract_details_p1;
PROCEDURE get_template_details_p1( p_template_id IN NUMBER
, p_template_record OUT contract_templates%ROWTYPE
, p_category_array OUT category_array
, p_parameter_array OUT parameter_array )
IS
-- Cursor to get the full contract template details row
CURSOR c_template IS
SELECT *
FROM contract_templates
WHERE cote_id = p_template_id;
--
-- Cursor to get all valid categories for this contract template
CURSOR c_cate IS
SELECT cotc.cate_id category_id
, cate.name||' ('||cate.units||')' category_name
, 'N' inherited
FROM contract_template_categories cotc
, categories cate
WHERE cotc.cate_id = cate.cate_id
AND cotc.cote_id = p_template_id
ORDER BY cotc.display_sequence; --cate.name||' ('||cate.units||')';
--
-- Cursor to get all valid parameters for this contract template
CURSOR c_pars IS
SELECT cotp.pars_id parameter_id
, pars.name parameter_name
, 'N' inherited
FROM contract_template_params cotp
, parameters pars
WHERE cotp.pars_id = pars.pars_id
AND cotp.cote_id = p_template_id
AND pars.cate_id IS NULL
ORDER BY pars.name;
--
l_count NUMBER := 0;
--
BEGIN
--
OPEN c_template;
FETCH c_template INTO p_template_record;
CLOSE c_template;
--
FOR r IN c_cate LOOP
l_count := l_count + 1;
--
p_category_array(l_count).cate_id := r.category_id;
p_category_array(l_count).name := r.category_name;
p_category_array(l_count).inherited := r.inherited;
--
END LOOP;
--
l_count := 0;
--
FOR r IN c_pars LOOP
l_count := l_count + 1;
--
p_parameter_array(l_count).pars_id := r.parameter_id;
p_parameter_array(l_count).name := r.parameter_name;
p_parameter_array(l_count).inherited := r.inherited;
--
END LOOP;
--
END get_template_details_p1;
PROCEDURE get_avail_net_points( p_network_point_array IN OUT network_point_array
, p_avail_net_points OUT network_point_array )
IS
-- Cursor to select ALL network points
CURSOR c_nepo IS
SELECT nepo_id
, REPLACE(REPLACE(name,chr(13),''),chr(10),'') name
FROM network_points
ORDER BY name;
--
l_array_pos NUMBER := 0;
l_out_pos NUMBER := 0;
--
l_holder_record network_point_record;
--
BEGIN
--
-- Need to ensure that we are dealing with like on like
-- i.e. both the given array and the cursor must be sorted by name
-- So sort the array - this is belt and braces approach as the array SHOULD arrive sorted correctly
-- The Bubble Sort method.
-- (yes there are MUCH better ways to sort - this algorithm I remember off the top off my head though)
IF NVL(p_network_point_array.COUNT,0) > 0 THEN
FOR i IN 1..p_network_point_array.COUNT LOOP
--
FOR j IN 1..(p_network_point_array.COUNT-1) LOOP
--
IF p_network_point_array(j).name > p_network_point_array(j+1).name THEN
--
l_holder_record := p_network_point_array(j+1);
p_network_point_array(j+1) := p_network_point_array(j);
p_network_point_array(j) := l_holder_record;
--
END IF;
--
END LOOP;
--
END LOOP;
END IF;
--
-- Ok, so lets go
l_array_pos := 1;
OPEN c_nepo;
FETCH c_nepo INTO l_holder_record;
--
WHILE c_nepo%FOUND AND l_array_pos <= p_network_point_array.COUNT LOOP
--
IF p_network_point_array(l_array_pos).name > l_holder_record.name THEN
-- Output the current cursor detail to the OUT array
l_out_pos := l_out_pos + 1;
p_avail_net_points(l_out_pos).nepo_id := l_holder_record.nepo_id;
p_avail_net_points(l_out_pos).name := l_holder_record.name;
--
FETCH c_nepo INTO l_holder_record;
--
ELSIF p_network_point_array(l_array_pos).name = l_holder_record.name THEN
-- Move both on
l_array_pos := l_array_pos + 1;
FETCH c_nepo INTO l_holder_record;
--
ELSE
-- Move the array position on - shouldn't realy happen as this means there
-- will be a foreign key violation soon...
l_array_pos := l_array_pos + 1;
END IF;
--
END LOOP;
--
-- If we still have rows in the cursor - output the values
WHILE c_nepo%FOUND LOOP
-- Output the current cursor detail to the OUT array
l_out_pos := l_out_pos + 1;
p_avail_net_points(l_out_pos).nepo_id := l_holder_record.nepo_id;
p_avail_net_points(l_out_pos).name := l_holder_record.name;
--
FETCH c_nepo INTO l_holder_record;
--
END LOOP;
--
CLOSE c_nepo;
--
END get_avail_net_points;
PROCEDURE get_avail_categories( p_category_array IN OUT category_array
, p_avail_categories OUT category_array )
IS
-- Cursor to select ALL categories
CURSOR c_cate IS
SELECT cate_id
, REPLACE(REPLACE(name,chr(13),''),chr(10),'')||' ('||units||')' name
, 'N'
FROM categories
ORDER BY display_sequence; --name||' ('||units||')';
--
l_array_pos NUMBER := 0;
l_out_pos NUMBER := 0;
--
l_holder_record category_record;
--
BEGIN
--
-- Need to ensure that we are dealing with like on like
-- i.e. both the given array and the cursor must be sorted by name
-- So sort the array - this is belt and braces approach as the array SHOULD arrive sorted correctly
-- The Bubble Sort method.
-- (yes there are MUCH better ways to sort - this algorithm I remember off the top off my head though)
/* IF NVL(p_category_array.COUNT,0) > 0 THEN
FOR i IN 1..p_category_array.COUNT LOOP
--
FOR j IN 1..(p_category_array.COUNT-1) LOOP
--
IF p_category_array(j).name > p_category_array(j+1).name THEN
--
l_holder_record := p_category_array(j+1);
p_category_array(j+1) := p_category_array(j);
p_category_array(j) := l_holder_record;
--
END IF;
--
END LOOP;
--
END LOOP;
END IF;*/
--
-- Reinitialise the holder record
l_holder_record := NULL;
--
OPEN c_cate;
FETCH c_cate INTO l_holder_record;
--
WHILE c_cate%FOUND LOOP
--
l_array_pos := 0;
--
<<array_loop>>
FOR idx IN 1..p_category_array.COUNT LOOP
--
-- Search the array for the category
--
IF p_category_array(idx).name = l_holder_record.name THEN
--
-- Found, mark as found and exit
--
NULL;
--
l_array_pos := idx;
--
EXIT array_loop;
--
END IF;
--
END LOOP;
--
IF l_array_pos = 0 THEN
--
-- Not found, mark as available
--
l_out_pos := l_out_pos + 1;
p_avail_categories(l_out_pos).cate_id := l_holder_record.cate_id;
p_avail_categories(l_out_pos).name := l_holder_record.name;
p_avail_categories(l_out_pos).inherited := 'N';
--
END IF;
--
FETCH c_cate INTO l_holder_record;
--
l_array_pos := p_category_array.FIRST;
--
END LOOP;
--
CLOSE c_cate;
--
END get_avail_categories;
FUNCTION inherited_categories( p_category_array IN category_array )
RETURN VARCHAR2
IS
l_name_list VARCHAR2(26000) := NULL;
l_temp_cate VARCHAR2(200) := NULL;
BEGIN
--
IF NVL(p_category_array.COUNT,0) > 0 THEN
FOR i IN 1..p_category_array.COUNT LOOP
--
IF p_category_array(i).inherited = 'Y' THEN
--
l_temp_cate := p_category_array(i).name;
--
-- Remove any newline/carriage returns (these cause problems)
l_temp_cate := REPLACE(REPLACE(l_temp_cate,chr(13),''),chr(10),'');
-- Now escape any metacharacters
l_temp_cate := REPLACE(l_temp_cate,'\','\\\');
l_temp_cate := REPLACE(l_temp_cate,'|','\\|');
l_temp_cate := REPLACE(l_temp_cate,'(','\\(');
l_temp_cate := REPLACE(l_temp_cate,')','\\)');
l_temp_cate := REPLACE(l_temp_cate,'[','\\[');
l_temp_cate := REPLACE(l_temp_cate,'{','\\{');
l_temp_cate := REPLACE(l_temp_cate,'^','\\^');
l_temp_cate := REPLACE(l_temp_cate,'$','\\$');
l_temp_cate := REPLACE(l_temp_cate,'*','\\*');
l_temp_cate := REPLACE(l_temp_cate,'+','\\+');
l_temp_cate := REPLACE(l_temp_cate,'?','\\?');
-- Add name to list
l_name_list := l_name_list||'|'||l_temp_cate;
--
END IF;
--
END LOOP;
END IF;
--
IF LENGTH(l_name_list) > 0 THEN
l_name_list := SUBSTR(l_name_list, 2); -- Strip the first | symbol
END IF;
--
RETURN l_name_list;
--
END inherited_categories;
PROCEDURE get_avail_parameters( p_parameter_array IN OUT parameter_array
, p_avail_parameters OUT parameter_array )
IS
-- Cursor to select ALL parameters not associated with categories
CURSOR c_pars IS
SELECT pars_id parameter_name
, REPLACE(REPLACE(name,chr(13),''),chr(10),'') parameter_name
, 'N' inherited
FROM parameters
WHERE cate_id IS NULL
ORDER BY name;
--
l_array_pos NUMBER := 0;
l_out_pos NUMBER := 0;
--
l_holder_record parameter_record;
--
BEGIN
--
-- Need to ensure that we are dealing with like on like
-- i.e. both the given array and the cursor must be sorted by name
-- So sort the array - this is belt and braces approach as the array SHOULD arrive sorted correctly
-- The Bubble Sort method.
-- (yes there are MUCH better ways to sort - this algorithm I remember off the top off my head though)
FOR i IN 1..p_parameter_array.COUNT LOOP
--
FOR j IN 1..(p_parameter_array.COUNT-1) LOOP
--
IF p_parameter_array(j).name > p_parameter_array(j+1).name THEN
--
l_holder_record := p_parameter_array(j+1);
p_parameter_array(j+1) := p_parameter_array(j);
p_parameter_array(j) := l_holder_record;
--
END IF;
--
END LOOP;
--
END LOOP;
--
-- Ok, so lets go
l_array_pos := 1;
OPEN c_pars;
FETCH c_pars INTO l_holder_record;
--
WHILE c_pars%FOUND AND l_array_pos <= NVL(p_parameter_array.COUNT,0) LOOP
--
IF p_parameter_array(l_array_pos).name > l_holder_record.name THEN
-- Output the current cursor detail to the OUT array
l_out_pos := l_out_pos + 1;
p_avail_parameters(l_out_pos).pars_id := l_holder_record.pars_id;
p_avail_parameters(l_out_pos).name := l_holder_record.name;
p_avail_parameters(l_out_pos).inherited := 'N';
--
FETCH c_pars INTO l_holder_record;
--
ELSIF p_parameter_array(l_array_pos).name = l_holder_record.name THEN
-- Move both on
l_array_pos := l_array_pos + 1;
FETCH c_pars INTO l_holder_record;
--
ELSE
-- Move the array position on - shouldn't realy happen as this means there
-- will be a foreign key violation soon...
l_array_pos := l_array_pos + 1;
END IF;
--
END LOOP;
--
-- If we still have rows in the cursor - output the values
WHILE c_pars%FOUND LOOP
-- Output the current cursor detail to the OUT array
l_out_pos := l_out_pos + 1;
p_avail_parameters(l_out_pos).pars_id := l_holder_record.pars_id;
p_avail_parameters(l_out_pos).name := l_holder_record.name;
p_avail_parameters(l_out_pos).inherited := 'N';
--
FETCH c_pars INTO l_holder_record;
--
END LOOP;
--
CLOSE c_pars;
--
END get_avail_parameters;
FUNCTION inherited_parameters( p_parameter_array IN parameter_array )
RETURN VARCHAR2
IS
l_name_list VARCHAR2(26000) := NULL;
l_temp_pars VARCHAR2(200) := NULL;
BEGIN
--
IF NVL(p_parameter_array.COUNT,0) > 0 THEN
FOR i IN 1..p_parameter_array.COUNT LOOP
--
IF p_parameter_array(i).inherited = 'Y' THEN
--
l_temp_pars := p_parameter_array(i).name;
--
-- Remove any newline/carriage returns (these cause problems)
l_temp_pars := REPLACE(REPLACE(l_temp_pars,chr(13),''),chr(10),'');
-- Now escape any metacharacters
l_temp_pars := REPLACE(l_temp_pars,'\','\\\');
l_temp_pars := REPLACE(l_temp_pars,'|','\\|');
l_temp_pars := REPLACE(l_temp_pars,'(','\\(');
l_temp_pars := REPLACE(l_temp_pars,')','\\)');
l_temp_pars := REPLACE(l_temp_pars,'[','\\[');
l_temp_pars := REPLACE(l_temp_pars,'{','\\{');
l_temp_pars := REPLACE(l_temp_pars,'^','\\^');
l_temp_pars := REPLACE(l_temp_pars,'$','\\$');
l_temp_pars := REPLACE(l_temp_pars,'*','\\*');
l_temp_pars := REPLACE(l_temp_pars,'+','\\+');
l_temp_pars := REPLACE(l_temp_pars,'?','\\?');
-- Add name to list
l_name_list := l_name_list||'|'||l_temp_pars;
--
END IF;
--
END LOOP;
END IF;
--
IF LENGTH(l_name_list) > 0 THEN
l_name_list := SUBSTR(l_name_list, 2); -- Strip the first | symbol
END IF;
--
RETURN l_name_list;
--
END inherited_parameters;
PROCEDURE templateRules_js
IS
BEGIN
--
htp.p('
function addTemplateRule( locURL ) {
var theRule = document.getElementById(''addTempRule'');
if (theRule.selectedIndex >= 0) {
var theRuleId = theRule.options[theRule.selectedIndex].value;
var theURL = locURL + theRuleId;
location.href = theURL;
}
}
function validateSequence( cotrId, locURL ) {
var theRuleSeq = document.getElementById( cotrId );
// Check that the value in the "sequence" is integer numeric
if (parseInt(theRuleSeq.value)) {
//go for the update
location.href = locURL + theRuleSeq.value;
}
else {
// Let the user know they entered invalid data
alert('''||caco_utilities.get_module_text(2336)||''');
}
}
function checkCotrDelete( locURL ) {
//check if the hidden contractsExist item exists
if (document.getElementById(''contractsExist'')) {
// lets ask for confirmation
if (confirm('''||caco_utilities.get_module_text(2309)||''')) {
location.href = locURL;
}
}
else {
//Just process the delete link
location.href = locURL;
}
}
function checkCotrAdd( locURL ) {
//check if the hidden contractsExist item exists
if (document.getElementById(''contractsExist'')) {
// lets ask for confirmation
if (confirm('''||caco_utilities.get_module_text(2308)||''')) {
addTemplateRule( locURL );
}
}
else {
//Just process the add link
addTemplateRule( locURL );
}
}
');
END templateRules_js;
PROCEDURE contractRules_js
IS
BEGIN
--
htp.p('
function addContractRule( locURL ) {
var theRule = document.getElementById(''addContRule'');
if (theRule.selectedIndex >= 0) {
var theRuleId = theRule.options[theRule.selectedIndex].value;
var theURL = locURL + theRuleId;
location.href = theURL;
}
}
function validateSequence( coruId, locURL ) {
var theRuleSeq = document.getElementById( coruId );
// Check that the value in the "sequence" is integer numeric
if (parseInt(theRuleSeq.value)) {
//go for the update
location.href = locURL + theRuleSeq.value;
}
else {
// Let the user know they entered invalid data
alert('''||caco_utilities.get_module_text(2336)||''');
}
}
');
END contractRules_js;
PROCEDURE contractP2_js
IS
BEGIN
--
htp.p('
function setChanged( obj ) {
if( obj.value != obj.getAttribute(''origval'') ) {
var pc = document.getElementById(''p_changes'');
pc.value = ''changed'';
}
}
function gotoPage( locURL ) {
var pc = document.getElementById(''p_changes'');
if( pc.value == ''changed'' ) {
if (confirm('''||caco_utilities.get_module_text(2343)||''')){
location.href = locURL;
}
}
else {
location.href = locURL;
}
}
function submitPage2() {
var theForm = document.getElementById(''contractFormP2'');
theForm.submit();
}
');
caco_utilities.thousand_separator_js;
--
END contractP2_js;
PROCEDURE contract_js
IS
BEGIN
--
htp.p('
function setListForSubmit( onOff, listId ) {
var theList = document.getElementById( listId );
if (onOff == "on") {
for (var i=0; i<theList.length; i++) {
theList.options[i].selected = true;
}
}
else {
for (var i=0; i<theList.length; i++) {
theList.options[i].selected = false;
}
}
}
function submitForm( formId ) {
var theForm = document.getElementById( formId );
theForm.submit();
}
function submitPage1() {
// Check to see if we have the network points lists - and set them if they are there
if (document.getElementById(''p_nepo_id'')) {
setListForSubmit(''on'',''p_nepo_id'');
setListForSubmit(''off'',''add_nepo_id'');
}
// set the category and parameter lists for submit
setListForSubmit(''on'',''p_cate_id'');
setListForSubmit(''on'',''p_pars_id'');
setListForSubmit(''off'',''add_cate_id'');
setListForSubmit(''off'',''add_pars_id'');
// Remove the unwanted inputs that wont be in the server procedure parameter list
if (document.getElementById(''p_template_changed'')) {
if (document.getElementById(''p_template_changed'').value == ''N'') {
var ptc = document.getElementById(''p_template_changed'');
ptc.parentNode.removeChild(ptc);
if (document.getElementById(''p_prev_template_id'')) {
var ppti = document.getElementById(''p_prev_template_id'');
ppti.parentNode.removeChild(ppti);
}
}
}
if (document.getElementById(''p_changes'')) {
var pch = document.getElementById(''p_changes'');
pch.parentNode.removeChild(pch);
}
submitForm(''contractFormP1'');
}
function setChanged() {
document.getElementById(''p_changes'').value = ''changed'';
}
function checkForChanges( whereToGo, screenType, locURL ) {
var changesItem = document.getElementById(''p_changes'');
if (changesItem.value == ''changed'') {
alert('''||caco_utilities.get_module_text(2324)||''');
}
else {
if(screenType == ''CONTRACT'') {
if (whereToGo == ''RULES'') {
location.href = locURL;
}
else if (whereToGo == ''VALUES'') {
location.href = locURL;
}
else if (whereToGo == ''OPTIONS'') {
location.href = locURL;
}
}
else if (screenType == ''TEMPLATE'') {
if (whereToGo == ''RULES'') {
location.href = locURL;
}
}
}
}
function areYouSureTemplateChange() {
if (confirm('''||caco_utilities.get_module_text(2225)||''')){
var ptc = document.getElementById(''p_template_changed'');
ptc.value = ''Y'';
var formId = document.getElementById(''contractFormP1'');
formId.action = "efnow050$.contract_startup";
submitPage1();
}
else {
var templateSelect = document.getElementById(''p_template_id'');
var prevId = document.getElementById(''p_prev_template_id'');
var curIndex = templateSelect.selectedIndex;
var newIndex = -1;
for( i=0; i<templateSelect.length; i++) {
if(templateSelect.options[i].value == prevId.value) {
newIndex = i;
}
}
if (newIndex == -1) {
newIndex = curIndex;
}
templateSelect.selectedIndex = newIndex;
}
}
function confirmTemplateSubmit() {
if (confirm('''||caco_utilities.get_module_text(2224)||''')) {
submitPage1();
}
}
function clearNetworkPointFilter() {
var npf = document.getElementById(''networkPointFilter'');
npf.value = '''';
}
function moveFocusTo( str ) {
if (document.getElementById(str)) {
document.getElementById(str).focus();
}
}
');
--
END contract_js;
PROCEDURE optiontransfer_js IS
BEGIN
htp.p('// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
// ===================================================================
');
htp.p('
/*
OptionTransfer.js
Last Modified: 7/12/2004
DESCRIPTION: This widget is used to easily and quickly create an interface
where the user can transfer choices from one select box to another. For
example, when selecting which columns to show or hide in search results.
This object adds value by automatically storing the values that were added
or removed from each list, as well as the state of the final list.
COMPATABILITY: Should work on all Javascript-compliant browsers.
USAGE:
// Create a new OptionTransfer object. Pass it the field names of the left
// select box and the right select box.
var ot = new OptionTransfer("from","to");
// Optionally tell the lists whether or not to auto-sort when options are
// moved. By default, the lists will be sorted.
ot.setAutoSort(true);
// Optionally set the delimiter to be used to separate values that are
// stored in hidden fields for the added and removed options, as well as
// final state of the lists. Defaults to a comma.
ot.setDelimiter("|");
// You can set a regular expression for option texts which are _not_ allowed to
// be transferred in either direction
ot.setStaticOptionRegex("static");');
htp.p('
// These functions assign the form fields which will store the state of
// the lists. Each one is optional, so you can pick to only store the
// new options which were transferred to the right list, for example.
// Each function takes the name of a HIDDEN or TEXT input field.
// Store list of options removed from left list into an input field
ot.saveRemovedLeftOptions("removedLeft");
// Store list of options removed from right list into an input field
ot.saveRemovedRightOptions("removedRight");
// Store list of options added to left list into an input field
ot.saveAddedLeftOptions("addedLeft");
// Store list of options radded to right list into an input field
ot.saveAddedRightOptions("addedRight");
// Store all options existing in the left list into an input field
ot.saveNewLeftOptions("newLeft");
// Store all options existing in the right list into an input field
ot.saveNewRightOptions("newRight");
// IMPORTANT: This step is required for the OptionTransfer object to work
// correctly.
// Add a call to the BODY onLoad="" tag of the page, and pass a reference to
// the form which contains the select boxes and input fields.
BODY onLoad="ot.init(document.forms[0])"
// ADDING ACTIONS INTO YOUR PAGE
// Finally, add calls to the object to move options back and forth, either
// from links in your page or from double-clicking the options themselves.
// See example page, and use the following methods:
ot.transferRight();
ot.transferAllRight();
ot.transferLeft();
ot.transferAllLeft();');
htp.p('
NOTES:
1) Requires the functions in selectbox.js
*/
function OT_transferLeft() { moveSelectedOptions(this.right,this.left,this.autoSort,this.staticOptionRegex); this.update(); }
function OT_transferRight() { moveSelectedOptions(this.left,this.right,this.autoSort,this.staticOptionRegex); this.update(); }
function OT_transferAllLeft() { moveAllOptions(this.right,this.left,this.autoSort,this.staticOptionRegex); this.update(); }
function OT_transferAllRight() { moveAllOptions(this.left,this.right,this.autoSort,this.staticOptionRegex); this.update(); }
function OT_saveRemovedLeftOptions(f) { this.removedLeftField = f; }
function OT_saveRemovedRightOptions(f) { this.removedRightField = f; }
function OT_saveAddedLeftOptions(f) { this.addedLeftField = f; }
function OT_saveAddedRightOptions(f) { this.addedRightField = f; }
function OT_saveNewLeftOptions(f) { this.newLeftField = f; }
function OT_saveNewRightOptions(f) { this.newRightField = f; }
function OT_update() {
var removedLeft = new Object();
var removedRight = new Object();
var addedLeft = new Object();
var addedRight = new Object();
var newLeft = new Object();
var newRight = new Object();
for (var i=0;i<this.left.options.length;i++) {
var o=this.left.options[i];
newLeft[o.value]=1;
if (typeof(this.originalLeftValues[o.value])=="undefined") {
addedLeft[o.value]=1;
removedRight[o.value]=1;
}
}
for (var i=0;i<this.right.options.length;i++) {
var o=this.right.options[i];
newRight[o.value]=1;
if (typeof(this.originalRightValues[o.value])=="undefined") {
addedRight[o.value]=1;
removedLeft[o.value]=1;
}
}
if (this.removedLeftField!=null) { this.removedLeftField.value = OT_join(removedLeft,this.delimiter); }
if (this.removedRightField!=null) { this.removedRightField.value = OT_join(removedRight,this.delimiter); }
if (this.addedLeftField!=null) { this.addedLeftField.value = OT_join(addedLeft,this.delimiter); }
if (this.addedRightField!=null) { this.addedRightField.value = OT_join(addedRight,this.delimiter); }
if (this.newLeftField!=null) { this.newLeftField.value = OT_join(newLeft,this.delimiter); }
if (this.newRightField!=null) { this.newRightField.value = OT_join(newRight,this.delimiter); }
}');
htp.p('
function OT_join(o,delimiter) {
var val; var str="";
for(val in o){
if (str.length>0) { str=str+delimiter; }
str=str+val;
}
return str;
}
function OT_setDelimiter(val) { this.delimiter=val; }
function OT_setAutoSort(val) { this.autoSort=val; }
function OT_setStaticOptionRegex(val) { this.staticOptionRegex=val; }
function OT_init(theform) {
this.form = theform;
if(!theform[this.left]){alert("OptionTransfer init(): Left select list does not exist in form!");return false;}
if(!theform[this.right]){alert("OptionTransfer init(): Right select list does not exist in form!");return false;}
this.left=theform[this.left];
this.right=theform[this.right];
for(var i=0;i<this.left.options.length;i++) {
this.originalLeftValues[this.left.options[i].value]=1;
}
for(var i=0;i<this.right.options.length;i++) {
this.originalRightValues[this.right.options[i].value]=1;
}
if(this.removedLeftField!=null) { this.removedLeftField=theform[this.removedLeftField]; }
if(this.removedRightField!=null) { this.removedRightField=theform[this.removedRightField]; }
if(this.addedLeftField!=null) { this.addedLeftField=theform[this.addedLeftField]; }
if(this.addedRightField!=null) { this.addedRightField=theform[this.addedRightField]; }
if(this.newLeftField!=null) { this.newLeftField=theform[this.newLeftField]; }
if(this.newRightField!=null) { this.newRightField=theform[this.newRightField]; }
this.update();
}
// -------------------------------------------------------------------
// OptionTransfer()
// This is the object interface.
// -------------------------------------------------------------------');
htp.p('
function OptionTransfer(l,r) {
this.form = null;
this.left=l;
this.right=r;
this.autoSort=true;
this.delimiter=",";
this.staticOptionRegex = "";
this.originalLeftValues = new Object();
this.originalRightValues = new Object();
this.removedLeftField = null;
this.removedRightField = null;
this.addedLeftField = null;
this.addedRightField = null;
this.newLeftField = null;
this.newRightField = null;
this.transferLeft=OT_transferLeft;
this.transferRight=OT_transferRight;
this.transferAllLeft=OT_transferAllLeft;
this.transferAllRight=OT_transferAllRight;
this.saveRemovedLeftOptions=OT_saveRemovedLeftOptions;
this.saveRemovedRightOptions=OT_saveRemovedRightOptions;
this.saveAddedLeftOptions=OT_saveAddedLeftOptions;
this.saveAddedRightOptions=OT_saveAddedRightOptions;
this.saveNewLeftOptions=OT_saveNewLeftOptions;
this.saveNewRightOptions=OT_saveNewRightOptions;
this.setDelimiter=OT_setDelimiter;
this.setAutoSort=OT_setAutoSort;
this.setStaticOptionRegex=OT_setStaticOptionRegex;
this.init=OT_init;
this.update=OT_update;
}
');
END optiontransfer_js;
PROCEDURE autocomplete_js IS
BEGIN
htp.p('// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
// ===================================================================
// -------------------------------------------------------------------
// autoComplete (text_input, select_input, ["text"|"value"], [true|false])
// Use this function when you have a SELECT box of values and a text
// input box with a fill-in value. Often, onChange of the SELECT box
// will fill in the selected value into the text input (working like
// a Windows combo box). Using this function, typing into the text
// box will auto-select the best match in the SELECT box and do
// auto-complete in supported browsers.
// Arguments:
// field = text input field object
// select = select list object containing valid values
// property = either "text" or "value". This chooses which of the
// SELECT properties gets filled into the text box -
// the ''value'' or ''text'' of the selected option
// forcematch = true or false. Set to ''true'' to not allow any text
// in the text box that does not match an option. Only
// supported in IE (possible future Netscape).
// -------------------------------------------------------------------
function autoComplete (field, select, property, forcematch) {
var found = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
found=true; break;
}
}
if (found) { select.selectedIndex = i; }
else { select.selectedIndex = -1; }
if (field.createTextRange) {
if (forcematch && !found) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found ? select.options[i][property] : oldValue;
if (newValue != field.value) {
field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart(''character'', oldValue.length) ;
rNew.select();
}
}
}
}
');
END autocomplete_js;
PROCEDURE selectbox_js IS
BEGIN
htp.p('// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
// ===================================================================
// HISTORY
// ------------------------------------------------------------------
// April 20, 2005: Fixed the removeSelectedOptions() function to
// correctly handle single selects
// June 12, 2003: Modified up and down functions to support more than
// one selected option
/*
DESCRIPTION: These are general functions to deal with and manipulate
select boxes. Also see the OptionTransfer library to more easily
handle transferring options between two lists
COMPATABILITY: These are fairly basic functions - they should work on
all browsers that support Javascript.
*/
// -------------------------------------------------------------------
// hasOptions(obj)
// Utility function to determine if a select object has an options array
// -------------------------------------------------------------------
function hasOptions(obj) {
if (obj!=null && obj.options!=null) { return true; }
return false;
}
// -------------------------------------------------------------------
// selectUnselectMatchingOptions(select_object,regex,select/unselect,true/false)
// This is a general function used by the select functions below, to
// avoid code duplication
// -------------------------------------------------------------------
function selectUnselectMatchingOptions(obj,regex,which,only) {
if (window.RegExp) {
if (which == "select") {
var selected1=true;
var selected2=false;
}
else if (which == "unselect") {
var selected1=false;
var selected2=true;
}
else {
return;
}
var re = new RegExp(regex);
if (!hasOptions(obj)) { return; }
for (var i=0; i<obj.options.length; i++) {
if (re.test(obj.options[i].text)) {
obj.options[i].selected = selected1;
}
else {
if (only == true) {
obj.options[i].selected = selected2;
}
}
}
}
}
// -------------------------------------------------------------------
// selectMatchingOptions(select_object,regex)
// This function selects all options that match the regular expression
// passed in. Currently-selected options will not be changed.
// -------------------------------------------------------------------
function selectMatchingOptions(obj,regex) {
selectUnselectMatchingOptions(obj,regex,"select",false);
}
// -------------------------------------------------------------------
// selectOnlyMatchingOptions(select_object,regex)
// This function selects all options that match the regular expression
// passed in. Selected options that don''t match will be un-selected.
// -------------------------------------------------------------------
function selectOnlyMatchingOptions(obj,regex) {
selectUnselectMatchingOptions(obj,regex,"select",true);
}
// -------------------------------------------------------------------
// unSelectMatchingOptions(select_object,regex)
// This function Unselects all options that match the regular expression
// passed in.
// -------------------------------------------------------------------
function unSelectMatchingOptions(obj,regex) {
selectUnselectMatchingOptions(obj,regex,"unselect",false);
}
// -------------------------------------------------------------------
// sortSelect(select_object)
// Pass this function a SELECT object and the options will be sorted
// by their text (display) values
// -------------------------------------------------------------------
function sortSelect(obj) {
var o = new Array();
if (!hasOptions(obj)) { return; }
for (var i=0; i<obj.options.length; i++) {
o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected);
o[i].className = obj.options[i].className;
}
if (o.length==0) { return; }
o = o.sort(
function(a,b) {
if ((a.text+"") < (b.text+"")) { return -1; }
if ((a.text+"") > (b.text+"")) { return 1; }
return 0;
}
);
for (var i=0; i<o.length; i++) {
obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
obj.options[i].className = o[i].className;
}
}
');
htp.p('
// -------------------------------------------------------------------
// selectAllOptions(select_object)
// This function takes a select box and selects all options (in a
// multiple select object). This is used when passing values between
// two select boxes. Select all options in the right box before
// submitting the form so the values will be sent to the server.
// -------------------------------------------------------------------
function selectAllOptions(obj) {
if (!hasOptions(obj)) { return; }
for (var i=0; i<obj.options.length; i++) {
obj.options[i].selected = true;
}
}
// -------------------------------------------------------------------
// moveSelectedOptions(select_object,select_object[,autosort(true/false)[,regex]])
// This function moves options between select boxes. Works best with
// multi-select boxes to create the common Windows control effect.
// Passes all selected values from the first object to the second
// object and re-sorts each box.
// If a third argument of ''false'' is passed, then the lists are not
// sorted after the move.
// If a fourth string argument is passed, this will function as a
// Regular Expression to match against the TEXT or the options. If
// the text of an option matches the pattern, it will NOT be moved.
// It will be treated as an unmoveable option.
// You can also put this into the <SELECT> object as follows:
// onDblClick="moveSelectedOptions(this,this.form.target)
// This way, when the user double-clicks on a value in one box, it
// will be transferred to the other (in browsers that support the
// onDblClick() event handler).
// -------------------------------------------------------------------
function moveSelectedOptions(from,to) {
// Unselect matching options, if required
if (arguments.length>3) {
var regex = arguments[3];
if (regex != "") {
unSelectMatchingOptions(from,regex);
}
}
// Move them over
if (!hasOptions(from)) { return; }
for (var i=0; i<from.options.length; i++) {
var o = from.options[i];
if (o.selected) {
if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
to.options[index] = new Option( o.text, o.value, false, false);
}
}
// Delete them from original
for (var i=(from.options.length-1); i>=0; i--) {
var o = from.options[i];
if (o.selected) {
from.options[i] = null;
}
}
if ((arguments.length<3) || (arguments[2]==true)) {
sortSelect(from);
sortSelect(to);
}
from.selectedIndex = -1;
to.selectedIndex = -1;
}
// -------------------------------------------------------------------
// copySelectedOptions(select_object,select_object[,autosort(true/false)])
// This function copies options between select boxes instead of
// moving items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copySelectedOptions(from,to) {
var options = new Object();
if (hasOptions(to)) {
for (var i=0; i<to.options.length; i++) {
options[to.options[i].value] = to.options[i].text;
}
}
if (!hasOptions(from)) { return; }
for (var i=0; i<from.options.length; i++) {
var o = from.options[i];
if (o.selected) {
if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text) {
if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
to.options[index] = new Option( o.text, o.value, false, false);
}
}
}
if ((arguments.length<3) || (arguments[2]==true)) {
sortSelect(to);
}
from.selectedIndex = -1;
to.selectedIndex = -1;
}
// -------------------------------------------------------------------
// moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
// Move all options from one select box to another.
// -------------------------------------------------------------------
function moveAllOptions(from,to) {
selectAllOptions(from);
if (arguments.length==2) {
moveSelectedOptions(from,to);
}
else if (arguments.length==3) {
moveSelectedOptions(from,to,arguments[2]);
}
else if (arguments.length==4) {
moveSelectedOptions(from,to,arguments[2],arguments[3]);
}
}
// -------------------------------------------------------------------
// copyAllOptions(select_object,select_object[,autosort(true/false)])
// Copy all options from one select box to another, instead of
// removing items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copyAllOptions(from,to) {
selectAllOptions(from);
if (arguments.length==2) {
copySelectedOptions(from,to);
}
else if (arguments.length==3) {
copySelectedOptions(from,to,arguments[2]);
}
}
');
htp.p('
// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
// Swap positions of two options in a select list
// -------------------------------------------------------------------
function swapOptions(obj,i,j) {
var o = obj.options;
var i_selected = o[i].selected;
var j_selected = o[j].selected;
var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
o[i] = temp2;
o[j] = temp;
o[i].selected = j_selected;
o[j].selected = i_selected;
}
// -------------------------------------------------------------------
// moveOptionUp(select_object)
// Move selected option in a select list up one
// -------------------------------------------------------------------
function moveOptionUp(obj) {
if (!hasOptions(obj)) { return; }
for (i=0; i<obj.options.length; i++) {
if (obj.options[i].selected) {
if (i != 0 && !obj.options[i-1].selected) {
swapOptions(obj,i,i-1);
obj.options[i-1].selected = true;
}
}
}
}
// -------------------------------------------------------------------
// moveOptionDown(select_object)
// Move selected option in a select list down one
// -------------------------------------------------------------------
function moveOptionDown(obj) {
if (!hasOptions(obj)) { return; }
for (i=obj.options.length-1; i>=0; i--) {
if (obj.options[i].selected) {
if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
swapOptions(obj,i,i+1);
obj.options[i+1].selected = true;
}
}
}
}
// -------------------------------------------------------------------
// removeSelectedOptions(select_object)
// Remove all selected options from a list
// (Thanks to Gene Ninestein)
// -------------------------------------------------------------------
function removeSelectedOptions(from) {
if (!hasOptions(from)) { return; }
if (from.type=="select-one") {
from.options[from.selectedIndex] = null;
}
else {
for (var i=(from.options.length-1); i>=0; i--) {
var o=from.options[i];
if (o.selected) {
from.options[i] = null;
}
}
}
from.selectedIndex = -1;
}
// -------------------------------------------------------------------
// removeAllOptions(select_object)
// Remove all options from a list
// -------------------------------------------------------------------
function removeAllOptions(from) {
if (!hasOptions(from)) { return; }
for (var i=(from.options.length-1); i>=0; i--) {
from.options[i] = null;
}
from.selectedIndex = -1;
}
// -------------------------------------------------------------------
// addOption(select_object,display_text,value,selected)
// Add an option to a list
// -------------------------------------------------------------------
function addOption(obj,text,value,selected) {
if (obj!=null && obj.options!=null) {
obj.options[obj.options.length] = new Option(text, value, false, selected);
}
}
');
END selectbox_js;
PROCEDURE templateRules_css IS
BEGIN
htp.p('
#ruleListDiv {
width : 95%;
}
.ruleTH {
text-align : center;
font-weight : normal;
height : 16px;
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;
}
.ruleTHname {
text-align : center;
font-weight : normal;
height : 16px;
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;
width : 250px;
}
.inhRuleTR {
background-color : #E6E6E6;
border-style : 1px solid;
}
.ruleTR {
background-color : #FFFFFF;
border-style : 1px solid;
}
.invalidRuleTR {
background-color : #FF9F98;
border-style : 1px solid;
}
.updSeqInput {
background-color : #FFFFFF;
text-align : right;
width : 50px;
}
.smallTextButton {
font-size : smaller;
}
');
END templateRules_css;
PROCEDURE contractRules_css IS
BEGIN
htp.p('
#ruleListDiv {
width : 95%;
}
.ruleTH {
text-align : center;
font-weight : normal;
height : 16px;
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;
}
.ruleTHname {
text-align : center;
font-weight : normal;
height : 16px;
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;
width : 250px;
}
.inhRuleTR {
background-color : #E6E6E6;
border-style : 1px solid;
}
.ruleTR {
background-color : #FFFFFF;
border-style : 1px solid;
}
.invalidRuleTR {
background-color : #FF9F98;
border-style : 1px solid;
}
.updSeqInput {
background-color : #FFFFFF;
text-align : right;
width : 50px;
}
.smallTextButton {
font-size : smaller;
}
');
END contractRules_css;
PROCEDURE contractP2_css IS
BEGIN
htp.p('
#nepoListDiv {
width : 170px;
float : left;
overflow-x : scroll;
}
#cnppvDiv {
overflow-x : scroll;
overflow-y : hidden;
}
* html body centrecontent{ /*IE6 hack*/
padding: 175px 0 45px 0; /*Set value to (HeightOfTopFrameDiv 0 HeightOfBottomFrameDiv 0)*/
}
.cnppvNepoTable {
border : 1px solid;
}
.cnppvNepoTH {
background-color : #D9D9D9;
text-align : center;
width : 165px;
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;
font-weight : normal;
height : 48px;
}
.cnppvNepoInput1 {
background-color : #FFFFFF;
color : #000000;
text-shadow : none;
text-decoration : none;
border-style : none;
width : 165px;
height : 16px;
padding : 0px;
margin : 0px;
}
.cnppvNepoInput2 {
background-color : #F5F5F5;
color : #000000;
text-shadow : none;
text-decoration : none;
border-style : none;
width : 165px;
height : 16px;
padding : 0px;
margin : 0px;
}
.cnppvTable {
border : 1px solid;
}
.cnppvTH1 {
background-color : #D9D9D9;
text-align : center;
font-weight : normal;
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 : 24px;
white-space : nowrap;
overflow : hidden;
}
.cnppvTH {
background-color : #D9D9D9;
text-align : center;
//width : 140px;
font-weight : normal;
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 : 24px;
white-space : nowrap;
overflow : hidden;
}
.rowspanTH {
background-color : #D9D9D9;
text-align : center;
font-weight : normal;
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;
white-space : nowrap;
overflow : hidden;
}
.cnppvTR1 {
background-color : #FFFFFF;
text-align : right;
border-style : none;
}
.cnppvTR2 {
background-color : #F5F5F5;
text-align : right;
border-style : none;
}
.cnppvInput1 {
background-color : #FFFFFF;
width : 80px;
text-align : right;
border-style : none;
height : 16px;
padding-top : 0px;
padding-left : 0px;
padding-right : 0px;
padding-bottom : 0px;
margin : 0px;
}
.cnppvInput2 {
background-color : #F5F5F5;
width : 80px;
text-align : right;
border-style : none;
height : 16px;
padding-top : 0px;
padding-left : 0px;
padding-right : 0px;
padding-bottom : 0px;
margin : 0px;
}
.cnppvError {
background-color : #FF9F98;
width : 80px;
text-align : right;
border-style : none;
height : 16px;
padding-top : 0px;
padding-left : 5px;
padding-right : 5px;
padding-bottom : 0px;
margin : 0px;
}
* HTML #p_spreadsheet {height: 24px;}
');
END contractP2_css;
PROCEDURE contractP1_css IS
BEGIN
--
htp.p('
#p_customer_id {
width : 250px;
}
#p_customer_name {
width : 250px;
}
#p_contract_number {
width : 250px;
}
#p_template_name {
width : 250px;
}
#p_template_desc {
width : 400px;
}
.contact {
width : 250px;
}
.datefield {
width : 80px;
}
.selectItemsDiv {
position : relative;
top : 10px;
float : left;
width : 270px;
border : 1px solid;
}
.selectBoxDiv {
height : 87px;
overflow : hide;
border : 1px solid;
}
.inheritedCat {
background-color : #E6E6E6;
}
.inheritedPar {
background-color : #E6E6E6;
}
.listTableHeadRow {
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;
}
.selectListWidth {
width : 264px;
}
.selectListWidthTH {
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;
}
.selectListButtonTD {
text-align : center
}
.selectListButton {
font-size : smaller;
}
');
--
END contractP1_css;
PROCEDURE display_lookback_action( p_lookback_action IN contracts.lookback_action%TYPE )
IS
BEGIN
-- Validation Action
htp.p(' <td>'||caco_utilities.get_module_text(2549)||'</td>'); -- Validation Action
htp.p(' <td>
<select id="p_lookback_action" name="p_lookback_action" size="1" onchange="setChanged();">');
--
IF p_lookback_action = 'T'
OR p_lookback_action IS NULL
THEN
htp.p('<option selected value="T">'||caco_utilities.get_module_text(2550)||'</option>');
htp.p('<option value="A">'||caco_utilities.get_module_text(2551)||'</option>');
ELSE
htp.p('<option value="T">'||caco_utilities.get_module_text(2550)||'</option>');
htp.p('<option selected value="A">'||caco_utilities.get_module_text(2551)||'</option>');
END IF;
--
htp.p(' </select>
</td>
<td>&nbsp</td>');
--
END display_lookback_action;
PROCEDURE display_message( p_success IN VARCHAR2
, p_error IN VARCHAR2
, p_err_msg IN VARCHAR2
, p_ins_or_upd IN VARCHAR2 )
IS
BEGIN
--
IF p_success = 'Y' THEN
-- Success!
htp.p('<b><font size="+2" color="#008000"><i>'||caco_utilities.get_module_text(876)||'</i></font><br /></b><p></p>');
ELSIF p_error = 'Y' THEN
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>');
ELSIF p_error = 'N' AND p_err_msg IS NOT NULL THEN
--
-- Spreadsheet update failed
--
htp.p('<b><font size="+2" color="#840201"><i>');
htp.p(caco_utilities.get_module_text(2340)); -- Update failed
htp.p('</i></font><br /></b>');
htp.p('<b>'||p_err_msg||'<br /></b><p></p>');
END IF;
--
END display_message;
PROCEDURE template_rules( p_template_id IN NUMBER
, p_success IN VARCHAR2 DEFAULT 'N'
, p_error IN VARCHAR2 DEFAULT 'N'
, p_err_msg IN VARCHAR2 DEFAULT NULL )
IS
-- Cursor to get the contract number
CURSOR c_template IS
SELECT name
FROM contract_templates
WHERE cote_id = p_template_id;
--
-- Cursor to list all the existing rules for this contract
CURSOR c_rules IS
SELECT cotr.display_sequence display_sequence
, rule.rule_name rule_name
, cotr.cotr_id cotr_id
, cotr.rule_id rule_id
FROM contract_template_rules cotr
, rules rule
WHERE rule.rule_id = cotr.rule_id
AND cotr.cote_id = p_template_id
ORDER BY display_sequence ASC
, rule_name ASC;
--
-- Cursor to get all remaining ROW rules that could be added to the contract template
CURSOR c_possible_row_rules IS
SELECT rule_name
, rule_id
FROM rules rule
WHERE NOT EXISTS (
SELECT 'X'
FROM contract_template_rules cotr
WHERE cotr.cote_id = p_template_id
AND cotr.rule_id = rule.rule_id
)
ORDER BY rule_name;
--
-- Cursor to determine if there are existing contracts with this template
CURSOR c_contracts_exist IS
SELECT 'X'
FROM contracts
WHERE cote_id = p_template_id;
--
l_template_name contract_templates.name%TYPE;
l_rule_rec c_rules%ROWTYPE;
l_dummy VARCHAR2(1);
--
l_temp_link VARCHAR2(255) := NULL;
l_upd_seq_link VARCHAR2(255) := NULL;
--
l_dummy_nnpcv_tab efno_confirmations.nnpcv_tab;
l_dummy_nom_data_table efno_rules.nom_validation_table;
--
l_success BOOLEAN := TRUE;
l_first_rule BOOLEAN := TRUE;
no_rules BOOLEAN := TRUE;
contracts_exist BOOLEAN := FALSE;
valid_rule BOOLEAN := TRUE;
--
BEGIN
--
OPEN c_template;
FETCH c_template INTO l_template_name;
IF c_template%NOTFOUND THEN
l_success := FALSE;
END IF;
CLOSE c_template;
--
-- List out all the existing rules associated with this contract template
IF l_success THEN
-- Find out if any contracts already exist with this template
--
OPEN c_contracts_exist;
FETCH c_contracts_exist INTO l_dummy;
IF c_contracts_exist%FOUND THEN
contracts_exist := TRUE;
END IF;
CLOSE c_contracts_exist;
--
-- htp.p('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
-- htp.p('<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb">');
wsgl.openpagehead(caco_utilities.get_module_text(2099)); -- Maintain Contract Template Rules
-- wsgl.metatag;
-- htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
caco_system.content_type;
htp.p('<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
htp.p(' <link rel="stylesheet" media="all" type="text/css" href="efnow092$.templateRules_css" />');
htp.p(' <script type="text/javascript" src="efnow092$.templateRules_js"></script>');
wsgl.closepagehead;
wsgl.openpagebody(FALSE);
htp.p(caco_system.menu);
--
htp.p('
<div style="margin:15px;">
<div>
<h1>'||caco_utilities.get_module_text(2099)||'</h1>'); -- Maintain Contract Template Rules
--
-- Put out success or error messages from completed or failed update
display_message( p_success => p_success
, p_error => p_error
, p_err_msg => p_err_msg
, p_ins_or_upd => 'UPDATE' );
--
htp.p('
<table>
<tr>
<td><b>'||caco_utilities.get_module_text(2090)||'&nbsp;&nbsp;</b></td>'); -- Contract Template Name
htp.p('
<td style="border: 1px solid;">'||l_template_name||'</td>
</tr>
</table>
<p />
<input type="button" value="'||caco_utilities.get_module_text(993)||'"'); -- Cancel
htp.p('
onclick="location.href='''||dad_path||'efnow050$.contract_startup?p_screen_type=TEMPLATE&p_template_id='
||p_template_id||'''" />');
--
-- Add button to allow creation of brand new ROW rule
-- The new Row rule will be available for all contracts/templates
l_temp_link := dad_path||'efnow080$.rule_startup';
l_temp_link := l_temp_link||'?p_item_name_array=P_CATEGORY&p_item_value_array=TEMPLATE';
l_temp_link := l_temp_link||'&p_item_name_array=P_TEMPLATE_ID&p_item_value_array='||p_template_id;
--
htp.p('<input type="button" value="'||caco_utilities.get_module_text(2101)||'"'); -- New Rule
htp.p(' onclick="location.href='''||l_temp_link||'''" />');
--
htp.p('</div>');
--
-- Current Contract Template Rules
htp.p('<p style="text-decoration:underline;"><b>'||caco_utilities.get_module_text(2102)||'</b></p>');
--
-- If contracts exist for this template, put a hidden input that can be used in javascript check routines
IF contracts_exist THEN
htp.p('<input id="contractsExist" type="hidden" value="Y" />');
END IF;
-- Now lets produce the list of existing Rules for this contract template in a table
-- Have we got any?
OPEN c_rules;
FETCH c_rules INTO l_rule_rec;
IF c_rules%FOUND THEN
no_rules := FALSE;
END IF;
CLOSE c_rules;
--
IF no_rules THEN
-- No Rules attached to this contract template
htp.p('<p><b><i>'||caco_utilities.get_module_text(2279)||'</i></b></p>');
--
ELSE
-- Output the list of rules.
htp.p('
<div id="ruleListDiv">
<table class="ruleTable">
<tr>');
htp.p(' <th class="ruleTH" colspan="2">'||caco_utilities.get_module_text(2031)||'&nbsp;</th>'); -- Display Sequence
htp.p(' <th class="ruleTHname">'||caco_utilities.get_module_text(2106)||'&nbsp;</th>'); -- Rule Name
htp.p(' <th class="ruleTH">'||caco_utilities.get_module_text(2008)||'&nbsp;</th>'); -- Edit
htp.p(' <th class="ruleTH">'||caco_utilities.get_module_text(838)||'&nbsp;</th>'); -- Delete
htp.p(' <th class="ruleTH">&nbsp;</th>
</tr>');
--
FOR r IN c_rules LOOP
--
l_temp_link := NULL;
l_upd_seq_link := NULL;
valid_rule := TRUE;
--
-- Lets check if the rule is currently valid for the template
-- (user may have removed required categories)
valid_rule := efno_rules.validate_rule( p_rule_id => r.rule_id
, p_rule_type => 'ROW'
, p_parse_only => TRUE
, p_nnpcv_tab => l_dummy_nnpcv_tab
, p_nom_table => l_dummy_nom_data_table
, p_template_id => p_template_id );
--
IF valid_rule THEN
htp.p('<tr class="ruleTR">');
ELSE
htp.p('<tr class="invalidRuleTR">');
END IF;
--
htp.p('<td><input id="'||r.cotr_id||'" class="updSeqInput" type="text" '
||'value="'||r.display_sequence||'" maxlength="6" /></td>');
--
-- Build a link to enable update of sequence - call a js function with a URL to go to
l_upd_seq_link := 'validateSequence('||r.cotr_id||','''||dad_path
||'efno_rules.upd_cotr_seq?p_template_id='||p_template_id
||'&p_cotr_id='||r.cotr_id||'&p_sequence='');';
--
htp.p('<td><input class="smallTextButton" type="button" value="'||caco_utilities.get_module_text(2339)||'"
onclick="'||l_upd_seq_link||'" /></td>');
--
htp.p('<td>'||r.rule_name||'</td>');
--
-- Build the href path
l_temp_link := dad_path||'efnow080$.rule_startup';
l_temp_link := l_temp_link||'?p_item_name_array=P_CATEGORY&p_item_value_array=TEMPLATE';
l_temp_link := l_temp_link||'&p_item_name_array=P_TEMPLATE_ID&p_item_value_array='||p_template_id;
l_temp_link := l_temp_link||'&p_item_name_array=P_RULE_ID&p_item_value_array='||r.rule_id;
--
-- put out Edit link
htp.p('<td><input class="smallTextButton" type="button" '
||'onclick="location.href='''||l_temp_link||'''" value="'||caco_utilities.get_module_text(2008)||'" /></td>');
--
-- put out delete link
-- button with a call to javascript function to request a confirmation
htp.p('<td align="center">'
||'<input class="smallTextButton" type="button" '
||'onclick="checkCotrDelete(''efno_rules.delete_template_rule?p_template_id='
||p_template_id||'&p_cotr_id='||r.cotr_id||''');" value="'||caco_utilities.get_module_text(2332)||'" /></td>');
--
--
IF valid_rule THEN
htp.p('<td>&nbsp;</td>');
ELSE
htp.p('<td>'||caco_utilities.get_module_text(2041)||'</td>'); -- Invalid
END IF;
-- Finalise table row
htp.p('</tr>');
--
END LOOP;
--
-- Close the table
htp.p('</table>');
--
-- Close the ruleList div
htp.p('</div>');
--
END IF;
--
htp.p('<p style="text-decoration:underline;"><b>'||caco_utilities.get_module_text(2326)||'</b></p>'); -- Add Existing Rules
--
--
-- Now have a selectbox with all the other possible rules listed
-- so the user can add rles one at a time
htp.p('<select id="addTempRule" size="1">');
--
-- Put out option list of available rules
FOR r IN c_possible_row_rules LOOP
--
IF l_first_rule THEN
htp.p('<option selected value="'||r.rule_id||'">'||r.rule_name||'</option>');
l_first_rule := FALSE;
ELSE
htp.p('<option value="'||r.rule_id||'">'||r.rule_name||'</option>');
END IF;
--
END LOOP;
--
htp.p('</select>');
--
-- put out an Add Rule button
l_temp_link := NULL;
l_temp_link := dad_path||'efno_rules.add_template_rule?p_template_id='||p_template_id||'&p_rule_id=';
--
htp.p('<input type="button" value="'||caco_utilities.get_module_text(2105)||'" onclick="checkCotrAdd('''||l_temp_link||''');" />');
--
-- Close the margin div
htp.p('</div>');
--
-- Close centrecontent div
htp.p('</div>');
--
-- Close outer div
htp.p('</div>');
--
wsgl.closepagebody;
--
END IF; -- l_success
--
END template_rules;
PROCEDURE contract_options_p(p_contract_id IN NUMBER,
p_success IN VARCHAR2 DEFAULT 'N',
p_error IN VARCHAR2 DEFAULT 'N',
p_err_msg IN VARCHAR2 DEFAULT NULL) IS
-- Cursor to get the contract number
CURSOR c_contract IS
SELECT contract_number FROM contracts WHERE cont_id = p_contract_id;
-- Cursor to get the contract options
CURSOR c_contract_options IS
SELECT cont_id,
nom_conf_subject,
nom_conf_content,
com_conf_subject,
com_conf_content,
auto_gen_conf,
conf_type,
ind_deadline_for_nom_submit,
shipper,
int_subject,
int_content,
int_sms_content
FROM contract_options
WHERE cont_id = p_contract_id;
CURSOR c_conf_type IS
SELECT rv_low_value,
rv_meaning
FROM cg_ref_codes
WHERE rv_domain = 'CONTRACT_OPTIONS.CONF_TYPE'
ORDER BY rv_meaning;
--
--
l_contract_options contract_options%ROWTYPE;
l_contract_number contracts.contract_number%TYPE;
--
l_success BOOLEAN := TRUE;
l_options_found BOOLEAN := TRUE;
--
l_cont_id contract_options.cont_id%TYPE;
l_nom_conf_subject contract_options.nom_conf_subject%TYPE;
l_nom_conf_content contract_options.nom_conf_content%TYPE;
l_com_conf_subject contract_options.com_conf_subject%TYPE;
l_com_conf_content contract_options.com_conf_content%TYPE;
l_auto_gen_conf contract_options.auto_gen_conf%TYPE;
l_conf_type contract_options.conf_type%TYPE;
l_ind_deadline_for_nom_submit contract_options.ind_deadline_for_nom_submit%TYPE;
l_ind_deadline_hr contract_options.ind_deadline_for_nom_submit%TYPE;
l_ind_deadline_mi contract_options.ind_deadline_for_nom_submit%TYPE;
l_shipper contract_options.shipper%TYPE;
l_int_subject contract_options.int_subject%TYPE;
l_int_content contract_options.int_content%TYPE;
l_int_sms_content contract_options.int_sms_content%TYPE;
--
l_hours NUMBER;
l_minutes NUMBER;
l_char_hours contract_options.ind_deadline_for_nom_submit%TYPE;
l_char_minutes contract_options.ind_deadline_for_nom_submit%TYPE;
BEGIN
--
-- Just to prove the contract exists
OPEN c_contract;
FETCH c_contract
INTO l_contract_number;
IF c_contract%NOTFOUND THEN
l_success := FALSE;
END IF;
CLOSE c_contract;
--
-- List out all the existing rules associated with this contract
IF l_success THEN
-- htp.p('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
-- htp.p('<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb">');
wsgl.openpagehead(caco_utilities.get_module_text(3967)); -- Maintain Contract Options
-- wsgl.metatag;
--htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
caco_system.content_type;
htp.p('<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
htp.p(' <link rel="stylesheet" media="all" type="text/css" href="efnow092$.contractP1_css" />');
htp.p(' <script type="text/javascript" src="efnow092$.contract_js"></script>');
--htp.p(' <script type="text/javascript" src="efnow092$.numbformat_js"></script>');
wsgl.closepagehead;
wsgl.openpagebody(FALSE);
htp.p(caco_system.menu);
--
-- Now we get to actually build the page.....
-- ...which should prove interesting seeing as how this is a multipurpose page....
htp.p('<div id="contractP1_border_div" style="margin:15px;">
<form id="contoptFormP1" name="contoptFormP1" method="POST" ');
--
htp.p('action="efno_contracts.ins_or_upd_cont_opt">');
--
htp.p('<div>');
--
htp.p('
<div style="margin:15px;">
<div>
<h1>' || caco_utilities.get_module_text(3967) ||
'</h1>'); -- Maintain Contract Options
--
-- Put out success or error messages from completed or failed update
display_message(p_success => p_success, p_error => p_error,
p_err_msg => p_err_msg, p_ins_or_upd => 'UPDATE');
--
htp.p('<table>
<tr>
<td><b>' || caco_utilities.get_module_text(2013) ||
'&nbsp;&nbsp;</b></td>'); -- Contract Number
htp.p('<td style="border: 1px solid;">' || l_contract_number ||
'</td>
</tr>
</table>');
htp.p('<p>');
htp.p('<input type="button" value="' ||
caco_utilities.get_module_text(993) || '"'); -- Cancel
htp.p(' onclick="location.href=''' || dad_path ||
'efnow050$.contract_startup?p_screen_type=CONTRACT&p_contract_id=' ||
p_contract_id || '''" />');
--
htp.p('<input type="button" ');
htp.p('value="' || caco_utilities.get_module_text(837) || '" '); -- Update
htp.p('onclick="submitForm(''contoptFormP1'');" />');
htp.p('</p>');
--
htp.p('</div>');
--
OPEN c_contract_options;
FETCH c_contract_options
INTO l_contract_options;
IF c_contract_options%NOTFOUND THEN
l_options_found := FALSE;
END IF;
--
IF l_options_found THEN
l_cont_id := l_contract_options.cont_id;
l_nom_conf_subject := l_contract_options.nom_conf_subject;
l_nom_conf_content := l_contract_options.nom_conf_content;
l_com_conf_subject := l_contract_options.com_conf_subject;
l_com_conf_content := l_contract_options.com_conf_content;
l_auto_gen_conf := l_contract_options.auto_gen_conf;
l_conf_type := l_contract_options.conf_type;
l_ind_deadline_for_nom_submit := l_contract_options.ind_deadline_for_nom_submit;
IF l_ind_deadline_for_nom_submit IS NULL THEN
l_ind_deadline_hr := '';
l_ind_deadline_mi := '';
ELSE
l_ind_deadline_hr := substr(l_ind_deadline_for_nom_submit, 1, 2);
l_ind_deadline_mi := substr(l_ind_deadline_for_nom_submit, 4, 2);
END IF;
l_shipper := l_contract_options.shipper;
l_int_subject := l_contract_options.int_subject;
l_int_content := l_contract_options.int_content;
l_int_sms_content := l_contract_options.int_sms_content;
--
htp.p('<input id="p_ind_deadline_for_nom_submit" name="p_ind_deadline_for_nom_submit" type="hidden" value="' ||
l_ind_deadline_for_nom_submit || '" />');
htp.p('<input id="p_cont_id" name="p_cont_id" type="hidden" value="' || l_cont_id || '" />');
--
htp.p('<table>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(3556) || '</b>'); -- Shipper
htp.p('</td><td>');
htp.p('<input id="p_shipper" name="p_shipper" type="text" size=38 value="' ||
l_shipper || '" />');
htp.p('</td></tr>');
--
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2470) || '</b>'); -- Auto Generate Confirmation
htp.p('</td><td>');
htp.p('<select id="p_auto_gen_conf" name="p_auto_gen_conf" size="1">');
IF l_auto_gen_conf = 'Y' THEN
htp.p('<option selected value="Y">Yes</option>');
htp.p('<option value="N">No</option>');
ELSIF l_auto_gen_conf = 'N' THEN
htp.p('<option value="Y">Yes</option>');
htp.p('<option selected value="N">No</option>');
ELSE
htp.p('<option selected value=""> </option>');
htp.p('<option value="Y">Yes</option>');
htp.p('<option value="N">No</option>');
END IF;
htp.p('</select>');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2471) || '</b>'); -- Confirmation Type
htp.p('</td><td>');
htp.p('<select id="p_conf_type" name="p_conf_type" size="1">');
IF l_conf_type IS NULL
OR l_conf_type = ''
OR l_conf_type = 'N' THEN
htp.p('<option selected value="N"> </option>');
ELSE
htp.p('<option value="N"> </option>');
END IF;
FOR r IN c_conf_type LOOP
IF r.rv_low_value = l_conf_type THEN
htp.p('<option selected value="' || r.rv_low_value || '">' ||
r.rv_meaning || '</option>');
ELSE
htp.p('<option value="' || r.rv_low_value || '">' ||
r.rv_meaning || '</option>');
END IF;
END LOOP;
htp.p('</select>');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2468) || '</b>'); -- Com Confirmation Subject
htp.p('</td><td>');
htp.p('<input id="p_com_conf_subject" name="p_com_conf_subject" type="text" size=38 value="' ||
l_com_conf_subject || '" />');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2469) || '</b>'); -- Com Confirmation Content
htp.p('</td><td>');
htp.p('<textarea id="p_com_conf_content" name="p_com_conf_content" ROWS=4 COLS=40 WRAP="VIRTUAL" >' ||
l_com_conf_content || '</textarea>');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2466) || '</b>'); -- Nom Confirmation Subject
htp.p('</td><td>');
htp.p('<input id="p_nom_conf_subject" name="p_nom_conf_subject" type="text" size=38 value="' ||
l_nom_conf_subject || '" />');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2467) || '</b>'); -- Nom Confirmation Content
htp.p('</td><td>');
htp.p('<textarea id="p_nom_conf_content" name="p_nom_conf_content" ROWS=4 COLS=40 WRAP="VIRTUAL" >' ||
l_nom_conf_content || '</textarea>');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2459) || '</b>'); -- Ind Sub Deadline (Hours)
htp.p('</td><td>');
htp.p('<select id="p_ind_deadline_hr" name="p_ind_deadline_hr" size="1">');
IF l_ind_deadline_hr = '' THEN
htp.p('<option selected value=""> </option>');
ELSE
htp.p('<option value=""> </option>');
END IF;
FOR l_hours IN 0 .. 23 LOOP
l_char_hours := trim(to_char(l_hours, '09'));
IF l_char_hours = l_ind_deadline_hr THEN
htp.p('<option selected value="' || l_char_hours || '">' ||
l_char_hours || '</option>');
ELSE
htp.p('<option value="' || l_char_hours || '">' || l_char_hours ||
'</option>');
END IF;
END LOOP;
htp.p('</select>');
/*
htp.p('<input id="p_ind_deadline_hr" name="p_ind_deadline_hr" type="text" size=2 value="' ||
l_ind_deadline_hr || '" />');
*/
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(2457) || '</b>'); -- Ind Sub Deadline (Mins)
htp.p('</td><td>');
htp.p('<select id="p_ind_deadline_mi" name="p_ind_deadline_mi" size="1">');
IF l_ind_deadline_mi = '' THEN
htp.p('<option selected value=""> </option>');
ELSE
htp.p('<option value=""> </option>');
END IF;
FOR l_minutes IN 0 .. 11 LOOP
l_char_minutes := trim(to_char((l_minutes * 5), '09'));
IF l_char_minutes = l_ind_deadline_mi THEN
htp.p('<option selected value="' || l_char_minutes || '">' ||
l_char_minutes || '</option>');
ELSE
htp.p('<option value="' || l_char_minutes || '">' ||
l_char_minutes || '</option>');
END IF;
END LOOP;
htp.p('</select>');
/*
htp.p('<input id="p_ind_deadline_mi" name="p_ind_deadline_mi" type="text" size=2 value="' ||
l_ind_deadline_mi || '" />');
*/
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(3591) || '</b>'); -- Interruption Subject
htp.p('</td><td>');
htp.p('<input id="p_int_subject" name="p_int_subject" type="text" size=38 value="' ||
l_int_subject || '" />');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(3592) || '</b>'); -- Interruption Content
htp.p('</td><td>');
htp.p('<textarea id="p_int_content" name="p_int_content" ROWS=4 COLS=40 WRAP="VIRTUAL" >' ||
l_int_content || '</textarea>');
htp.p('</td></tr>');
--
htp.p('<tr><td>');
htp.p('<b>' || caco_utilities.get_module_text(3593) || '</b>'); -- Interruption SMS Content
htp.p('</td><td>');
htp.p('<textarea id="p_int_sms_content" name="p_int_sms_content" ROWS=4 COLS=40 WRAP="VIRTUAL" >' ||
l_int_sms_content || '</textarea>');
htp.p('</td></tr>');
--
htp.p('</table>');
--
htp.p('<p><i>''*''' || caco_utilities.get_module_text(2202) ||
'</i></p>'); -- '*' Denotes a mandatory field
--
htp.p(caco_utilities.get_module_text(3605));
htp.p(caco_utilities.get_module_text(3606));
htp.p('<tr><td>{CONFIRMATION_IDENTIFIER}</td><td>{NOMINATION_IDENTIFIER}</td></tr>');
htp.p('<tr><td>{GAS_DAY}</td><td>{GAS_DAY_START}</td></tr>');
htp.p('<tr><td>{NOMINATION_IDENTIFIER}</td><td>{GAS_DAY_END}</td></tr>');
htp.p('<tr><td></td><td>{TIMESTAMP}</td></tr>');
htp.p('</table>');
htp.p(caco_utilities.get_module_text(3607));
--
END IF;
CLOSE c_contract_options;
--
--
wsgl.closepagebody;
--
END IF; -- l_success
--
END contract_options_p;
PROCEDURE contract_rules( p_contract_id IN NUMBER
, p_success IN VARCHAR2 DEFAULT 'N'
, p_error IN VARCHAR2 DEFAULT 'N'
, p_err_msg IN VARCHAR2 DEFAULT NULL )
IS
-- Cursor to get the contract number
CURSOR c_contract IS
SELECT contract_number
FROM contracts
WHERE cont_id = p_contract_id;
--
-- Cursor to get all remaining ROW rules that could be added to the rule
CURSOR c_possible_row_rules IS
SELECT rule_name
, rule_id
FROM rules rule
WHERE NOT EXISTS (
SELECT 'X'
FROM contract_rules coru
WHERE coru.cont_id = p_contract_id
AND coru.rule_id = rule.rule_id
)
ORDER BY rule_name;
--
--
l_contract_number contracts.contract_number%TYPE;
l_rule_rec efno_contracts.c_rules%ROWTYPE;
--
l_temp_rule_id rules.rule_id%TYPE;
l_temp_link VARCHAR2(255) := NULL;
l_upd_seq_link VARCHAR2(255) := NULL;
--
l_dummy_nnpcv_tab efno_confirmations.nnpcv_tab;
l_dummy_nom_data_table efno_rules.nom_validation_table;
--
l_success BOOLEAN := TRUE;
l_first_rule BOOLEAN := TRUE;
no_rules BOOLEAN := TRUE;
valid_rule BOOLEAN := TRUE;
--
--
BEGIN
--
OPEN c_contract;
FETCH c_contract INTO l_contract_number;
IF c_contract%NOTFOUND THEN
l_success := FALSE;
END IF;
CLOSE c_contract;
--
-- List out all the existing rules associated with this contract
IF l_success THEN
-- htp.p('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
-- htp.p('<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb">');
wsgl.openpagehead(caco_utilities.get_module_text(2272)); -- Maintain Contract Rules
-- wsgl.metatag;
--htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
caco_system.content_type;
htp.p('<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
htp.p(' <link rel="stylesheet" media="all" type="text/css" href="efnow092$.contractRules_css" />');
htp.p(' <script type="text/javascript" src="efnow092$.contractRules_js"></script>');
wsgl.closepagehead;
wsgl.openpagebody(FALSE);
htp.p(caco_system.menu);
--
htp.p('
<div style="margin:15px;">
<div>
<h1>'||caco_utilities.get_module_text(2272)||'</h1>'); -- Maintain Contract Rules
--
-- Put out success or error messages from completed or failed update
display_message( p_success => p_success
, p_error => p_error
, p_err_msg => p_err_msg
, p_ins_or_upd => 'UPDATE' );
--
htp.p('
<table>
<tr>
<td><b>'||caco_utilities.get_module_text(2013)||'&nbsp;&nbsp;</b></td>'); -- Contract Number
htp.p(' <td style="border: 1px solid;">'||l_contract_number||'</td>
</tr>
</table>
<p />
<input type="button" value="'||caco_utilities.get_module_text(993)||'"'); -- Cancel
htp.p(' onclick="location.href='''||dad_path
||'efnow050$.contract_startup?p_screen_type=CONTRACT&p_contract_id='
||p_contract_id||'''" />');
--
-- Add button to allow creation of brand new ROW or SHEET rule
-- (Row rule will be available for all contracts - Sheet rule is specific to this contract
l_temp_link := dad_path||'efnow080$.rule_startup';
l_temp_link := l_temp_link||'?p_item_name_array=P_CATEGORY&p_item_value_array=CONTRACT';
l_temp_link := l_temp_link||'&p_item_name_array=P_CONTRACT_ID&p_item_value_array='||p_contract_id;
--
htp.p('<input type="button" value="'||caco_utilities.get_module_text(2101)||'"'); -- New Rule
htp.p(' onclick="location.href='''||l_temp_link||'''" />');
--
htp.p('</div>');
--
htp.p('<p style="text-decoration:underline;"><b>'||caco_utilities.get_module_text(2238)||'</b></p>'); -- Current Contract Rules
--
-- Now lets produce the list of existing Rules for this contract in a table
-- Have we got any?
OPEN efno_contracts.c_rules( p_contract_id );
FETCH efno_contracts.c_rules INTO l_rule_rec;
IF efno_contracts.c_rules%FOUND THEN
no_rules := FALSE;
END IF;
CLOSE efno_contracts.c_rules;
--
IF no_rules THEN
--
htp.p('<p><b><i>'||caco_utilities.get_module_text(2279)||'</i></b></p>'); -- No Rules attached to this contract
--
ELSE
-- Output the list of rules.
htp.p('
<div id="ruleListDiv">
<table class="ruleTable">
<tr>
<th class="ruleTH" colspan="2">'||caco_utilities.get_module_text(2031)||'&nbsp;</th>'); -- Display Sequence
htp.p(' <th class="ruleTH">'||caco_utilities.get_module_text(2126)||'&nbsp;</th>'); -- Rule Type
htp.p(' <th class="ruleTHname">'||caco_utilities.get_module_text(2106)||'&nbsp;</th>'); -- Rule Name
htp.p(' <th class="ruleTH">'||caco_utilities.get_module_text(2008)||'&nbsp;</th>'); -- Edit
htp.p(' <th class="ruleTH">'||caco_utilities.get_module_text(838)||'&nbsp;</th>'); -- Delete
htp.p(' <th class="ruleTH">&nbsp;</th>
</tr>');
--
FOR r IN efno_contracts.c_rules( p_contract_id ) LOOP
--
l_temp_link := NULL;
l_upd_seq_link := NULL;
l_temp_rule_id := 0;
valid_rule := TRUE;
--
-- Lets check if the rule is currently valid for the template
-- (user may have removed required categories)
IF r.rule_type = 'ROW' THEN
l_temp_rule_id := r.rule_id;
ELSE
l_temp_rule_id := r.coru_id;
END IF;
--
valid_rule := efno_rules.validate_rule( p_rule_id => l_temp_rule_id
, p_rule_type => r.rule_type
, p_parse_only => TRUE
, p_nnpcv_tab => l_dummy_nnpcv_tab
, p_nom_table => l_dummy_nom_data_table
, p_contract_id => p_contract_id );
--
--
IF r.inherited = 'Y' THEN
htp.p('<tr class="inhRuleTR">');
ELSIF valid_rule THEN
htp.p('<tr class="ruleTR">');
ELSE
htp.p('<tr class="invalidRuleTR">');
END IF;
--
htp.p('<td><input id="'||r.coru_id||'" class="updSeqInput" type="text" '
||'value="'||r.display_sequence||'" maxlength="6" /></td>');
--
-- Build a link to enable update of sequence - call a js function with a URL to go to
l_upd_seq_link := 'validateSequence('||r.coru_id||','''||dad_path
||'efno_rules.upd_coru_seq?p_contract_id='||p_contract_id
||'&p_coru_id='||r.coru_id||'&p_sequence='');';
--
htp.p('<td><input class="smallTextButton" type="button" value="'
||caco_utilities.get_module_text(2339)||'"'); -- Upd Seq
htp.p(' title="'||caco_utilities.get_module_text(2107)||'"'); -- Upd Seq (short for Update Sequence)
htp.p(' onclick="'||l_upd_seq_link||'" /></td>');
--
htp.p('<td>'||r.rule_type||'</td>');
htp.p('<td>'||r.rule_name||'</td>');
--
-- Build the href path for non-inherited rules
IF NVL(r.inherited,'N') != 'Y' THEN
l_temp_link := dad_path||'efnow080$.rule_startup';
l_temp_link := l_temp_link||'?p_item_name_array=P_CATEGORY&p_item_value_array=CONTRACT';
l_temp_link := l_temp_link||'&p_item_name_array=P_CONTRACT_ID&p_item_value_array='||p_contract_id;
--
IF r.rule_id IS NULL THEN
l_temp_link := l_temp_link||'&p_item_name_array=P_CORU_ID&p_item_value_array='||r.coru_id;
ELSE
l_temp_link := l_temp_link||'&p_item_name_array=P_RULE_ID&p_item_value_array='||r.rule_id;
END IF;
--
-- put out Edit link
htp.p('<td><input class="smallTextButton" type="button" '
||'onclick="location.href='''||l_temp_link||'''" value="'
||caco_utilities.get_module_text(2008)||'" /></td>'); -- Edit
--
ELSE
htp.p('<td>&nbsp;</td>');
END IF;
--
-- put out delete link
IF NVL(r.inherited,'N') = 'Y' THEN
htp.p('<td>&nbsp;</td>');
ELSE
htp.p('<td align="center"><input class="smallTextButton" type="button" '
||'onclick="location.href=''efno_rules.delete_contract_rule?p_contract_id='
||p_contract_id||'&p_coru_id='||r.coru_id
||'''" value="'||caco_utilities.get_module_text(2332)||'" /></td>'); -- Del
END IF;
--
IF valid_rule THEN
htp.p('<td>&nbsp;</td>');
ELSE
htp.p('<td>'||caco_utilities.get_module_text(2041)||'</td>'); -- Invalid
END IF;
--
-- Finalise table row
htp.p('</tr>');
--
END LOOP;
--
-- Close the table
htp.p('</table>');
--
-- Close the ruleList div
htp.p('</div>');
--
END IF;
--
htp.p('<p style="text-decoration:underline;"><b>'||caco_utilities.get_module_text(2326)||'</b></p>'); -- Add Existing Rules
--
--
-- Now have a selectbox with all the other possible rules listed
-- so the user can add rles one at a time
htp.p('<select id="addContRule" size="1">');
--
-- Put out option list of available rules
FOR r IN c_possible_row_rules LOOP
--
IF l_first_rule THEN
htp.p('<option selected value="'||r.rule_id||'">'||r.rule_name||'</option>');
l_first_rule := FALSE;
ELSE
htp.p('<option value="'||r.rule_id||'">'||r.rule_name||'</option>');
END IF;
--
END LOOP;
--
htp.p('</select>');
--
-- put out an Add Rule button
l_temp_link := NULL;
l_temp_link := dad_path||'efno_rules.add_contract_row_rule?p_contract_id='||p_contract_id||'&p_rule_id=';
--
htp.p('<input type="button" value="'||caco_utilities.get_module_text(2105) -- Add Rule
||'" onclick="addContractRule('''||l_temp_link||''');" />');
--
-- Close the margin div
htp.p('</div>');
--
-- Close centrecontent div
htp.p('</div>');
--
-- Close outer div
htp.p('</div>');
--
wsgl.closepagebody;
--
END IF; -- l_success
--
END contract_rules;
PROCEDURE contract_values_ro( p_contract_id IN NUMBER
, p_page_no IN NUMBER DEFAULT 1
, p_success IN VARCHAR2 DEFAULT 'N'
, p_error IN VARCHAR2 DEFAULT 'N'
, p_err_msg IN VARCHAR2 DEFAULT NULL
, p_spreadsheet IN VARCHAR2 DEFAULT NULL
, p_cnppv_id IN owa_util.vc_arr DEFAULT g_vc_arr
, p_value IN owa_util.vc_arr DEFAULT g_vc_arr
, p_data_error IN owa_util.vc_arr DEFAULT g_vc_arr )
IS
--
-- Cursor to get the full contract details row
CURSOR c_contract IS
SELECT *
FROM contracts
WHERE cont_id = p_contract_id;
--
l_contract_row contracts%ROWTYPE;
--
CURSOR c_conp IS
SELECT conp.display_sequence display_sequence
, nepo.name netpoint_name
, conp.conp_id conp_id
, nepo.code netpoint_code
FROM cont_network_points conp
, network_points nepo
WHERE conp.nepo_id = nepo.nepo_id
AND conp.cont_id = p_contract_id
ORDER BY DECODE(nepo.nepo_type,'V',1,2),nepo.code; --nepo.name;
--
CURSOR c_count_conp IS
SELECT COUNT(DISTINCT nepo_id)
FROM cont_network_points
WHERE cont_id = p_contract_id;
--
CURSOR c_count_copa IS
SELECT COUNT(DISTINCT pars_id)
FROM contract_parameters
WHERE cont_id = p_contract_id;
--
CURSOR c_copa IS
SELECT cate_name
, param_seq
, param_name
, display_sequence
, copa_id
FROM (
SELECT REPLACE(REPLACE(cate.name,chr(13),''),chr(10),'')||' ('||cate.units||')' cate_name
, 'C' AS disp_type
, coca.display_sequence display_sequence
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', 'MIN'
, 'MAX', 'MAX'
, 'CTR', 'CTR'
, NULL ) param_seq
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', caco_utilities.get_module_text(2274) -- Minimum
, 'MAX', caco_utilities.get_module_text(2344) -- Maximum
, 'CTR', caco_utilities.get_module_text(2345) -- Contracted
, NULL ) param_name
, copa.copa_id copa_id
, coca.inherited
FROM contract_parameters copa
, contract_categories coca
, parameters pars
, categories cate
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND coca.cont_id = p_contract_id
AND coca.cate_id = pars.cate_id
AND cate.cate_id = pars.cate_id
UNION ALL
SELECT REPLACE(REPLACE(pars.name,chr(13),''),chr(10),'') cate_name
, 'P' AS disp_type
, copa.display_sequence display_sequence
, NULL param_seq
, NULL param_name
, copa.copa_id copa_id
, copa.inherited
FROM contract_parameters copa
, parameters pars
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND pars.cate_id IS NULL
)
ORDER BY disp_type
, inherited desc
, DECODE(display_sequence,0,999999999999,display_sequence) ASC
, cate_name ASC
, param_seq DESC;
--
CURSOR c_cnppv( cp_conp_id IN NUMBER
, cp_copa_id IN NUMBER ) IS
SELECT cnppv.cnppv_id cnppv_id
, cnppv.value cnppv_value
FROM cont_net_point_param_vals cnppv
WHERE conp_id = cp_conp_id
AND copa_id = cp_copa_id;
--
CURSOR c_vnepo (cp_conp_id IN NUMBER) IS
SELECT 'Y'
FROM network_points nepo,
cont_network_points conp
WHERE conp.nepo_id = nepo.nepo_id
AND conp.conp_id = cp_conp_id
AND nepo.nepo_type = 'V';
--
CURSOR c_perc_split (cp_copa_id IN NUMBER) IS
SELECT 'Y'
FROM parameters pars,
contract_parameters copa
WHERE copa.pars_id = pars.pars_id
AND copa.copa_id = cp_copa_id
AND pars.name IN (g_perc_split_en, g_perc_split_hu);
--
l_copa_rec c_copa%ROWTYPE;
l_prev_copa_rec c_copa%ROWTYPE;
--
l_conp_id_array owa_util.num_arr;
l_copa_id_array owa_util.num_arr;
--
l_input_class VARCHAR2(20);
l_cnppv_id NUMBER := 0;
l_cnppv_value NUMBER := 0;
l_prev_cate_pars NUMBER := 1;
--
l_total_conp NUMBER := 0;
l_total_copa NUMBER := 0;
l_num_pages NUMBER := 0;
l_nepo_per_page CONSTANT NUMBER := 25;
l_conp_count NUMBER := 0;
l_all_conp_count NUMBER := 0;
l_copa_count NUMBER := 0;
l_error_cell_count NUMBER := 0;
--
l_success BOOLEAN := TRUE;
--
l_vnepo VARCHAR2(1);
l_perc_split VARCHAR2(1);
--
BEGIN
--
OPEN c_contract;
FETCH c_contract INTO l_contract_row;
IF c_contract%NOTFOUND THEN
l_success := FALSE;
END IF;
CLOSE c_contract;
--
IF p_error = 'Y' THEN
--
-- Here we need to ensure that the data passed to us is used correctly
IF NVL(p_cnppv_id.COUNT,0) > 0
AND NVL(p_cnppv_id.COUNT,0) = NVL(p_value.COUNT,0)
AND NVL(p_cnppv_id.COUNT,0) = NVL(p_data_error.COUNT,0)
THEN
-- we have enough data - nothing to do - easier to test this way round?
NULL;
ELSE
-- a potential problem
l_success := FALSE;
--
caco_debug.putline('efnow092$.contract_values_ro : Data passed to screen was invalid. Contract ID : '||p_contract_id);
--
END IF;
--
END IF;
--
IF l_success THEN
-- htp.p('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
-- htp.p('<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb">');
wsgl.openpagehead(caco_utilities.get_module_text(3980)); -- View Contract Values
--wsgl.metatag;
--htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
caco_system.content_type;
htp.p('<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
htp.p(' <link rel="stylesheet" media="all" type="text/css" href="efnow092$.contractP2_css" />');
htp.p(' <script type="text/javascript" src="efnow092$.contractP2_js"></script>');
wsgl.closepagehead;
wsgl.openpagebody(FALSE);
htp.p(caco_system.menu);
--
--
OPEN c_count_conp;
FETCH c_count_conp INTO l_total_conp;
CLOSE c_count_conp;
--
OPEN c_count_copa;
FETCH c_count_copa INTO l_total_copa;
CLOSE c_count_copa;
--
-- Determine the number of pages that we are going to require for CNPPV
l_num_pages := CEIL( l_total_conp / l_nepo_per_page );
--
htp.p('
<div style="margin:15px;">
<div>
<h1>'||caco_utilities.get_module_text(3980)||'</h1>'); -- View Contract Values
--
-- Put out success or error messages from completed or failed update
display_message( p_success => p_success
, p_error => p_error
, p_err_msg => p_err_msg
, p_ins_or_upd => 'UPDATE' );
--
htp.p('
<table>
<tr>
<td><b>'||caco_utilities.get_module_text(2013)||'&nbsp;&nbsp;</b></td>'); -- Contract Number
htp.p(' <td style="border: 1px solid;">'||l_contract_row.contract_number||'</td>
</tr>
</table>
<p />');
IF p_error = 'N' THEN
htp.p('<input type="hidden" id="p_changes" value="none" />');
ELSE
htp.p('<input type="hidden" id="p_changes" value="changed" />');
END IF;
-- htp.p(' <input type="button" value="'||caco_utilities.get_module_text(837) -- Update
-- ||'" onclick="submitPage2();"/>');
htp.p(' <input type="button" value="'||caco_utilities.get_module_text(993)||'"'); -- Cancel
htp.p(' onClick="history.go(-1)" />');
htp.p(' <input type="button" value="'||caco_utilities.get_module_text(3862)||'"'); -- Export Values to Excel
htp.p(' onclick="location.href='''||dad_path
||'efnow092$.export_to_excel?p_contract_id='
||l_contract_row.cont_id||'''" />');
-- htp.p(' <input type="button" value="'||caco_utilities.get_module_text(3863)||'"'); -- Import Values from Excel
-- htp.p(' onclick="if (document.getElementById(''fileLoad'').style.display == ''none'') { document.getElementById(''fileLoad'').style.display = ''block''} else {document.getElementById(''fileLoad'').style.display = ''none''};" />');
htp.p('<br>');
htp.p('<br>');
htp.p('<div id="fileLoad" style="display: none;">');
-- htp.p('<form action='''||dad_path||'efnow092$.import_from_excel?p_cont_id='||l_contract_row.cont_id||'''" method="post" id="header" name="header" enctype="multipart/form-data">');
htp.p('<form action="efnow092$.import_from_excel" method="post" id="header" name="header" enctype="multipart/form-data">');
htp.p('<input id="p_contract_id" name="p_contract_id" type="hidden" value="'||p_contract_id||'" />');
htp.p(' '||caco_utilities.get_module_text(543)||' (.xls): <input name="p_spreadsheet" size="50" maxlength="200" id="p_spreadsheet" type="file" value="'||p_spreadsheet||'" accept="application/vnd.ms-excel">');
htp.formsubmit(cvalue => caco_utilities.get_module_text(1147));
htp.p('</form>');
htp.p('</div>');
htp.p(' </div>
<p><b style="text-decoration:underline;">'||caco_utilities.get_module_text(2276)||'</b>'); -- Network Point Parameter Values
--
IF l_num_pages > 1 THEN
-- Need return links to this procedure to display different network points (due to 2000 paramter limit)
htp.p('&nbsp;&nbsp;&nbsp;<b>'||caco_utilities.get_module_text(2346)||':</b>'); -- Page
FOR i IN 1..l_num_pages LOOP
--
IF i = p_page_no THEN
htp.p('<b>'||p_page_no||'</b>');
ELSE
htp.p('<a href="javascript:gotoPage(''efnow092$.contract_values_ro?p_contract_id='||p_contract_id||'&p_page_no='||i||''');" >'||i||'</a>');
END IF;
--
IF i < l_num_pages THEN
htp.p(',&nbsp;&nbsp;');
END IF;
--
END LOOP;
--
END IF;
--
htp.p('</p>');
--
-- Now lets produce the list of Network points for this contract in a table
-- Make the header span two rows so that it is the same height as the values table
htp.p('
<div id="nepoListDiv">
<table class="cnppvNepoTable">
<tr>
<th class="cnppvNepoTH">'||caco_utilities.get_module_text(2023)||'</th>'); -- Network Point
htp.p(' <th class="cnppvNepoTH">'||caco_utilities.get_module_text(1005)||'</th>'); -- Network Code
htp.p(' </tr>');
--
FOR r IN c_conp LOOP
-- Store the list of Contract Network Point Ids
-- We will need them later for getting/setting the contract values
l_all_conp_count := l_all_conp_count + 1;
--
IF l_all_conp_count > ((p_page_no - 1) * l_nepo_per_page)
AND l_all_conp_count <= ( p_page_no * l_nepo_per_page )
THEN
l_conp_count := l_conp_count + 1;
l_conp_id_array(l_conp_count) := r.conp_id;
--
IF MOD(l_conp_count,2) = 0 THEN
htp.p('
<tr class="cnppvTR2"><td><input disabled class="cnppvNepoInput2" ');
ELSE
htp.p('
<tr class="cnppvTR1"><td><input disabled class="cnppvNepoInput1" ');
END IF;
htp.p(' type="text" value="'||r.netpoint_name||'" /></td>');
--
-- Add network code
--
IF MOD(l_conp_count,2) = 0 THEN
htp.p('
<td><input disabled class="cnppvNepoInput2" ');
ELSE
htp.p('
<td><input disabled class="cnppvNepoInput1" ');
END IF;
htp.p(' type="text" value="'||r.netpoint_code||'" /></td></tr>');
--
END IF;
--
END LOOP;
--
htp.p('
</table>
</div>');
--
-- End of the Network Points list
--
-- Lets make a start on the values table
htp.p('
<div id="cnppvDiv">
<form id="contractFormP2" name="contractFormP2" method="POST" action="efno_contracts.upd_cnppv_records">');
--
-- Output the contract Id and Page number as hidden inputs
htp.p('<input id="p_contract_id" name="p_contract_id" type="hidden" value="'||p_contract_id||'" />');
htp.p('<input id="p_page_no" name="p_page_no" type="hidden" value="'||p_page_no||'" />');
--
-- open the table for the cnppv values.
htp.p('
<table class="cnppvTable">');
--
--
htp.p('<tr>');
-- 1st Header Row...
OPEN c_copa;
FETCH c_copa INTO l_prev_copa_rec;
WHILE c_copa%FOUND LOOP
l_copa_rec := NULL;
FETCH c_copa INTO l_copa_rec;
--
IF NVL(l_copa_rec.cate_name,'*$%()L*') != l_prev_copa_rec.cate_name THEN
--
-- If we have a standalone parameter, then rowspan the headers
IF l_prev_copa_rec.param_name IS NULL THEN
htp.p('<th rowspan="2" class="rowspanTH"');
ELSE
htp.p('<th class="cnppvTH1" colspan="'||l_prev_cate_pars||'" ');
END IF;
--
htp.p('style="text-align:center;">'||l_prev_copa_rec.cate_name||'</th>');
l_prev_cate_pars := 1;
--
ELSE
l_prev_cate_pars := l_prev_cate_pars + 1;
END IF;
--
l_prev_copa_rec := l_copa_rec;
--
END LOOP;
CLOSE c_copa;
htp.p('</tr>');
--
-- 2nd header row
htp.p('<tr>');
FOR r IN c_copa LOOP
--
l_copa_count := l_copa_count + 1;
l_copa_id_array(l_copa_count) := r.copa_id;
--
-- NULL param name means that it has been accounted for in first loop.
IF r.param_name IS NOT NULL THEN
htp.p('<th class="cnppvTH">'||r.param_name||'</th>');
END IF;
--
END LOOP;
htp.p('</tr>');
--
-- We need to do a row per network point of the same items as the header row.
<<cnppv_details_loop>>
FOR i IN 1..l_conp_count LOOP
--
IF MOD(i,2) = 0 THEN
htp.p('
<tr class="cnppvTR2">');
--
l_input_class := 'cnppvInput2';
ELSE
htp.p('
<tr class="cnppvTR1">');
--
l_input_class := 'cnppvInput1';
END IF;
--
FOR j IN 1..l_copa_count LOOP
--
IF p_error = 'N' THEN
--
-- No problems - just show the details from the DB
--
OPEN c_cnppv( l_conp_id_array(i), l_copa_id_array(j) );
FETCH c_cnppv INTO l_cnppv_id, l_cnppv_value;
IF c_cnppv%NOTFOUND THEN
--
-- This is a problem - the contract is not set up correctly
-- which is more than likely an undocumented "feature" of the system
-- output an error? Probably the best idea.
caco_debug.putline('efnow092$.contract_values_p2: '
||'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j) );
--
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j)
, p_source => 'efnow092$.contract_values_p2');
--
-- An unexpected error has occurred. Please contact support
htp.p('<td colspan="'||(l_copa_count-j+1)
||'"><input type="text" disabled class="cnppvNepoInput1" '
||'style="text-align:center;width:100%;" value="'
||caco_utilities.get_module_text(2330)||'" /></td></tr>');
EXIT cnppv_details_loop;
--
ELSE
-- We can output the values.
-- check if the contract is an entry mandatory offer contract
IF efno_contracts.emo_contract(p_contract_id) = 'Y' THEN
-- check if the network point is a virtual network point
OPEN c_vnepo(l_conp_id_array(i));
FETCH c_vnepo INTO l_vnepo;
IF c_vnepo%FOUND THEN
l_vnepo := 'Y';
l_perc_split := 'N';
ELSE
l_vnepo := 'N';
-- check if the parameter is Percentage Split
OPEN c_perc_split(l_copa_id_array(j));
FETCH c_perc_split INTO l_perc_split;
IF c_perc_split%FOUND THEN
l_perc_split := 'Y';
ELSE
l_perc_split := 'N';
END IF;
CLOSE c_perc_split;
END IF;
CLOSE c_vnepo;
--
-- need to disable any cnppv field which is not against a virtual network point
-- except those against Percentage Split values
htp.p('<td><input name="p_cnppv_id" type="hidden" value="'||l_cnppv_id||'" />');
IF l_vnepo = 'Y' OR l_perc_split = 'Y' THEN
htp.p(' <input readonly id="'||l_cnppv_id||'" name="p_value" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(l_cnppv_value)||'"'
||' origval="'||l_cnppv_value||'"'
||' onchange="setChanged(this);thousandSeparator(this.id,this.value)" /></td>');
ELSE
-- We need to create 2 input items for value one hidden and one disabled as
-- disabled input items don't get passed
htp.p('<input name="p_value" type="hidden" value="'||l_cnppv_value||'" />');
htp.p(' <input readonly disabled name="p_value2" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(l_cnppv_value)||'"'
||' origval="'||l_cnppv_value||'"'
||' onchange="setChanged(this);thousandSeparator(this.id,this.value)" /></td>');
END IF;
--
ELSE
htp.p('<td><input name="p_cnppv_id" type="hidden" value="'||l_cnppv_id||'" />');
htp.p(' <input readonly id="'||l_cnppv_id||'" name="p_value" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(l_cnppv_value)||'"'
||' origval="'||l_cnppv_value||'"'
||' onchange="setChanged(this);thousandSeparator(this.id,this.value)" /></td>');
--
END IF;
END IF;
CLOSE c_cnppv;
--
ELSE
l_error_cell_count := ((i-1) * l_copa_count) + j;
-- Recalled the screen with error - highlighting required.
IF p_data_error( l_error_cell_count ) = 'Y' THEN
htp.p('<td><input readonly name="p_cnppv_id" type="hidden" value="'||p_cnppv_id(l_error_cell_count)||'" />');
htp.p(' <input readonly id="'||p_cnppv_id(l_error_cell_count)||'" name="p_value" class="cnppvError" value="'||caco_utilities.to_thousand_separated(p_value(l_error_cell_count))||'" onchange="setChanged(this);thousandSeparator(this.id,this.value)"/></td>');
ELSE
htp.p('<td><input readonly name="p_cnppv_id" type="hidden" value="'||p_cnppv_id(l_error_cell_count)||'" />');
htp.p(' <input readonly id="'||p_cnppv_id(l_error_cell_count)||'" name="p_value" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(p_value(l_error_cell_count))||'" onchange="setChanged(this);thousandSeparator(this.id,this.value)"/></td>');
END IF;
--
END IF;
--
END LOOP; -- contract parameters loop
--
htp.p('
</tr>');
--
END LOOP cnppv_details_loop; -- contract network point loop
--
--
-- Close the CNPPV table
htp.p('</table>');
--
-- Close FORM contractFormP2
htp.p('</form>');
--
-- Close the enclosing cnppvDiv
htp.p('</div>');
--
-- Close the margin div
htp.p('</div>');
--
-- Close centrecontent div
htp.p('</div>');
--
wsgl.closepagebody;
--
END IF; -- l_success
--
END contract_values_ro;
PROCEDURE contract_values_p2( p_contract_id IN NUMBER
, p_page_no IN NUMBER DEFAULT 1
, p_success IN VARCHAR2 DEFAULT 'N'
, p_error IN VARCHAR2 DEFAULT 'N'
, p_err_msg IN VARCHAR2 DEFAULT NULL
, p_spreadsheet IN VARCHAR2 DEFAULT NULL
, p_cnppv_id IN owa_util.vc_arr DEFAULT g_vc_arr
, p_value IN owa_util.vc_arr DEFAULT g_vc_arr
, p_data_error IN owa_util.vc_arr DEFAULT g_vc_arr )
IS
--
-- Cursor to get the full contract details row
CURSOR c_contract IS
SELECT *
FROM contracts
WHERE cont_id = p_contract_id;
--
l_contract_row contracts%ROWTYPE;
--
CURSOR c_conp IS
SELECT conp.display_sequence display_sequence
, nepo.name netpoint_name
, conp.conp_id conp_id
, nepo.code netpoint_code
FROM cont_network_points conp
, network_points nepo
WHERE conp.nepo_id = nepo.nepo_id
AND conp.cont_id = p_contract_id
ORDER BY DECODE(nepo.nepo_type,'V',1,2),nepo.code; --nepo.name;
--
CURSOR c_count_conp IS
SELECT COUNT(DISTINCT nepo_id)
FROM cont_network_points
WHERE cont_id = p_contract_id;
--
CURSOR c_count_copa IS
SELECT COUNT(DISTINCT pars_id)
FROM contract_parameters
WHERE cont_id = p_contract_id;
--
CURSOR c_copa IS
SELECT cate_name
, param_seq
, param_name
, display_sequence
, copa_id
FROM (
SELECT REPLACE(REPLACE(cate.name,chr(13),''),chr(10),'')||' ('||cate.units||')' cate_name
, 'C' AS disp_type
, coca.display_sequence display_sequence
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', 'MIN'
, 'MAX', 'MAX'
, 'CTR', 'CTR'
, NULL ) param_seq
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', caco_utilities.get_module_text(2274) -- Minimum
, 'MAX', caco_utilities.get_module_text(2344) -- Maximum
, 'CTR', caco_utilities.get_module_text(2345) -- Contracted
, NULL ) param_name
, copa.copa_id copa_id
, coca.inherited
FROM contract_parameters copa
, contract_categories coca
, parameters pars
, categories cate
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND coca.cont_id = p_contract_id
AND coca.cate_id = pars.cate_id
AND cate.cate_id = pars.cate_id
UNION ALL
SELECT REPLACE(REPLACE(pars.name,chr(13),''),chr(10),'') cate_name
, 'P' AS disp_type
, copa.display_sequence display_sequence
, NULL param_seq
, NULL param_name
, copa.copa_id copa_id
, copa.inherited
FROM contract_parameters copa
, parameters pars
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND pars.cate_id IS NULL
)
ORDER BY disp_type
, inherited desc
, DECODE(display_sequence,0,999999999999,display_sequence) ASC
, cate_name ASC
, param_seq DESC;
--
CURSOR c_cnppv( cp_conp_id IN NUMBER
, cp_copa_id IN NUMBER ) IS
SELECT cnppv.cnppv_id cnppv_id
, cnppv.value cnppv_value
FROM cont_net_point_param_vals cnppv
WHERE conp_id = cp_conp_id
AND copa_id = cp_copa_id;
--
CURSOR c_vnepo (cp_conp_id IN NUMBER) IS
SELECT 'Y'
FROM network_points nepo,
cont_network_points conp
WHERE conp.nepo_id = nepo.nepo_id
AND conp.conp_id = cp_conp_id
AND nepo.nepo_type = 'V';
--
CURSOR c_perc_split (cp_copa_id IN NUMBER) IS
SELECT 'Y'
FROM parameters pars,
contract_parameters copa
WHERE copa.pars_id = pars.pars_id
AND copa.copa_id = cp_copa_id
AND pars.name IN (g_perc_split_en, g_perc_split_hu);
--
l_copa_rec c_copa%ROWTYPE;
l_prev_copa_rec c_copa%ROWTYPE;
--
l_conp_id_array owa_util.num_arr;
l_copa_id_array owa_util.num_arr;
--
l_input_class VARCHAR2(20);
l_cnppv_id NUMBER := 0;
l_cnppv_value NUMBER := 0;
l_prev_cate_pars NUMBER := 1;
--
l_total_conp NUMBER := 0;
l_total_copa NUMBER := 0;
l_num_pages NUMBER := 0;
l_nepo_per_page CONSTANT NUMBER := 25;
l_conp_count NUMBER := 0;
l_all_conp_count NUMBER := 0;
l_copa_count NUMBER := 0;
l_error_cell_count NUMBER := 0;
--
l_success BOOLEAN := TRUE;
--
l_vnepo VARCHAR2(1);
l_perc_split VARCHAR2(1);
--
BEGIN
--
OPEN c_contract;
FETCH c_contract INTO l_contract_row;
IF c_contract%NOTFOUND THEN
l_success := FALSE;
END IF;
CLOSE c_contract;
--
IF p_error = 'Y' THEN
--
-- Here we need to ensure that the data passed to us is used correctly
IF NVL(p_cnppv_id.COUNT,0) > 0
AND NVL(p_cnppv_id.COUNT,0) = NVL(p_value.COUNT,0)
AND NVL(p_cnppv_id.COUNT,0) = NVL(p_data_error.COUNT,0)
THEN
-- we have enough data - nothing to do - easier to test this way round?
NULL;
ELSE
-- a potential problem
l_success := FALSE;
--
caco_debug.putline('efnow092$.contract_values_p2 : Data passed to screen was invalid. Contract ID : '||p_contract_id);
--
END IF;
--
END IF;
--
IF l_success THEN
-- htp.p('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
-- htp.p('<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb">');
wsgl.openpagehead(caco_utilities.get_module_text(2273)); -- Maintain Contract Values
--wsgl.metatag;
--htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
caco_system.content_type;
htp.p('<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
htp.p(' <link rel="stylesheet" media="all" type="text/css" href="efnow092$.contractP2_css" />');
htp.p(' <script type="text/javascript" src="efnow092$.contractP2_js"></script>');
wsgl.closepagehead;
wsgl.openpagebody(FALSE);
htp.p(caco_system.menu);
--
--
OPEN c_count_conp;
FETCH c_count_conp INTO l_total_conp;
CLOSE c_count_conp;
--
OPEN c_count_copa;
FETCH c_count_copa INTO l_total_copa;
CLOSE c_count_copa;
--
-- Determine the number of pages that we are going to require for CNPPV
l_num_pages := CEIL( l_total_conp / l_nepo_per_page );
--
htp.p('
<div style="margin:15px;">
<div>
<h1>'||caco_utilities.get_module_text(2273)||'</h1>'); -- Maintain Contract Values
--
-- Put out success or error messages from completed or failed update
display_message( p_success => p_success
, p_error => p_error
, p_err_msg => p_err_msg
, p_ins_or_upd => 'UPDATE' );
--
htp.p('
<table>
<tr>
<td><b>'||caco_utilities.get_module_text(2013)||'&nbsp;&nbsp;</b></td>'); -- Contract Number
htp.p(' <td style="border: 1px solid;">'||l_contract_row.contract_number||'</td>
</tr>
</table>
<p />');
IF p_error = 'N' THEN
htp.p('<input type="hidden" id="p_changes" value="none" />');
ELSE
htp.p('<input type="hidden" id="p_changes" value="changed" />');
END IF;
htp.p(' <input type="button" value="'||caco_utilities.get_module_text(837) -- Update
||'" onclick="submitPage2();"/>');
htp.p(' <input type="button" value="'||caco_utilities.get_module_text(993)||'"'); -- Cancel
htp.p(' onclick="location.href='''||dad_path
||'efnow050$.contract_startup?p_screen_type=CONTRACT&p_contract_id='
||l_contract_row.cont_id||'''" />');
htp.p(' <input type="button" value="'||caco_utilities.get_module_text(3862)||'"'); -- Export Values to Excel
htp.p(' onclick="location.href='''||dad_path
||'efnow092$.export_to_excel?p_contract_id='
||l_contract_row.cont_id||'''" />');
htp.p(' <input type="button" value="'||caco_utilities.get_module_text(3863)||'"'); -- Import Values from Excel
htp.p(' onclick="if (document.getElementById(''fileLoad'').style.display == ''none'') { document.getElementById(''fileLoad'').style.display = ''block''} else {document.getElementById(''fileLoad'').style.display = ''none''};" />');
htp.p('<br>');
htp.p('<br>');
htp.p('<div id="fileLoad" style="display: none;">');
-- htp.p('<form action='''||dad_path||'efnow092$.import_from_excel?p_cont_id='||l_contract_row.cont_id||'''" method="post" id="header" name="header" enctype="multipart/form-data">');
htp.p('<form action="efnow092$.import_from_excel" method="post" id="header" name="header" enctype="multipart/form-data">');
htp.p('<input id="p_contract_id" name="p_contract_id" type="hidden" value="'||p_contract_id||'" />');
htp.p(' '||caco_utilities.get_module_text(543)||' (.xls): <input name="p_spreadsheet" size="50" maxlength="200" id="p_spreadsheet" type="file" value="'||p_spreadsheet||'" accept="application/vnd.ms-excel">');
htp.formsubmit(cvalue => caco_utilities.get_module_text(1147));
htp.p('</form>');
htp.p('</div>');
htp.p(' </div>
<p><b style="text-decoration:underline;">'||caco_utilities.get_module_text(2276)||'</b>'); -- Network Point Parameter Values
--
IF l_num_pages > 1 THEN
-- Need return links to this procedure to display different network points (due to 2000 paramter limit)
htp.p('&nbsp;&nbsp;&nbsp;<b>'||caco_utilities.get_module_text(2346)||':</b>'); -- Page
FOR i IN 1..l_num_pages LOOP
--
IF i = p_page_no THEN
htp.p('<b>'||p_page_no||'</b>');
ELSE
htp.p('<a href="javascript:gotoPage(''efnow092$.contract_values_p2?p_contract_id='||p_contract_id||'&p_page_no='||i||''');" >'||i||'</a>');
END IF;
--
IF i < l_num_pages THEN
htp.p(',&nbsp;&nbsp;');
END IF;
--
END LOOP;
--
END IF;
--
htp.p('</p>');
--
-- Now lets produce the list of Network points for this contract in a table
-- Make the header span two rows so that it is the same height as the values table
htp.p('
<div id="nepoListDiv">
<table class="cnppvNepoTable">
<tr>
<th class="cnppvNepoTH">'||caco_utilities.get_module_text(2023)||'</th>'); -- Network Point
htp.p(' <th class="cnppvNepoTH">'||caco_utilities.get_module_text(1005)||'</th>'); -- Network Code
htp.p(' </tr>');
--
FOR r IN c_conp LOOP
-- Store the list of Contract Network Point Ids
-- We will need them later for getting/setting the contract values
l_all_conp_count := l_all_conp_count + 1;
--
IF l_all_conp_count > ((p_page_no - 1) * l_nepo_per_page)
AND l_all_conp_count <= ( p_page_no * l_nepo_per_page )
THEN
l_conp_count := l_conp_count + 1;
l_conp_id_array(l_conp_count) := r.conp_id;
--
IF MOD(l_conp_count,2) = 0 THEN
htp.p('
<tr class="cnppvTR2"><td><input disabled class="cnppvNepoInput2" ');
ELSE
htp.p('
<tr class="cnppvTR1"><td><input disabled class="cnppvNepoInput1" ');
END IF;
htp.p(' type="text" value="'||r.netpoint_name||'" /></td>');
--
-- Add network code
--
IF MOD(l_conp_count,2) = 0 THEN
htp.p('
<td><input disabled class="cnppvNepoInput2" ');
ELSE
htp.p('
<td><input disabled class="cnppvNepoInput1" ');
END IF;
htp.p(' type="text" value="'||r.netpoint_code||'" /></td></tr>');
--
END IF;
--
END LOOP;
--
htp.p('
</table>
</div>');
--
-- End of the Network Points list
--
-- Lets make a start on the values table
htp.p('
<div id="cnppvDiv">
<form id="contractFormP2" name="contractFormP2" method="POST" action="efno_contracts.upd_cnppv_records">');
--
-- Output the contract Id and Page number as hidden inputs
htp.p('<input id="p_contract_id" name="p_contract_id" type="hidden" value="'||p_contract_id||'" />');
htp.p('<input id="p_page_no" name="p_page_no" type="hidden" value="'||p_page_no||'" />');
--
-- open the table for the cnppv values.
htp.p('
<table class="cnppvTable">');
--
--
htp.p('<tr>');
-- 1st Header Row...
OPEN c_copa;
FETCH c_copa INTO l_prev_copa_rec;
WHILE c_copa%FOUND LOOP
l_copa_rec := NULL;
FETCH c_copa INTO l_copa_rec;
--
IF NVL(l_copa_rec.cate_name,'*$%()L*') != l_prev_copa_rec.cate_name THEN
--
-- If we have a standalone parameter, then rowspan the headers
IF l_prev_copa_rec.param_name IS NULL THEN
htp.p('<th rowspan="2" class="rowspanTH"');
ELSE
htp.p('<th class="cnppvTH1" colspan="'||l_prev_cate_pars||'" ');
END IF;
--
htp.p('style="text-align:center;">'||l_prev_copa_rec.cate_name||'</th>');
l_prev_cate_pars := 1;
--
ELSE
l_prev_cate_pars := l_prev_cate_pars + 1;
END IF;
--
l_prev_copa_rec := l_copa_rec;
--
END LOOP;
CLOSE c_copa;
htp.p('</tr>');
--
-- 2nd header row
htp.p('<tr>');
FOR r IN c_copa LOOP
--
l_copa_count := l_copa_count + 1;
l_copa_id_array(l_copa_count) := r.copa_id;
--
-- NULL param name means that it has been accounted for in first loop.
IF r.param_name IS NOT NULL THEN
htp.p('<th class="cnppvTH">'||r.param_name||'</th>');
END IF;
--
END LOOP;
htp.p('</tr>');
--
-- We need to do a row per network point of the same items as the header row.
<<cnppv_details_loop>>
FOR i IN 1..l_conp_count LOOP
--
IF MOD(i,2) = 0 THEN
htp.p('
<tr class="cnppvTR2">');
--
l_input_class := 'cnppvInput2';
ELSE
htp.p('
<tr class="cnppvTR1">');
--
l_input_class := 'cnppvInput1';
END IF;
--
FOR j IN 1..l_copa_count LOOP
--
IF p_error = 'N' THEN
--
-- No problems - just show the details from the DB
--
OPEN c_cnppv( l_conp_id_array(i), l_copa_id_array(j) );
FETCH c_cnppv INTO l_cnppv_id, l_cnppv_value;
IF c_cnppv%NOTFOUND THEN
--
-- This is a problem - the contract is not set up correctly
-- which is more than likely an undocumented "feature" of the system
-- output an error? Probably the best idea.
caco_debug.putline('efnow092$.contract_values_p2: '
||'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j) );
--
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j)
, p_source => 'efnow092$.contract_values_p2');
--
-- An unexpected error has occurred. Please contact support
htp.p('<td colspan="'||(l_copa_count-j+1)
||'"><input type="text" disabled class="cnppvNepoInput1" '
||'style="text-align:center;width:100%;" value="'
||caco_utilities.get_module_text(2330)||'" /></td></tr>');
EXIT cnppv_details_loop;
--
ELSE
-- We can output the values.
-- check if the contract is an entry mandatory offer contract
IF efno_contracts.emo_contract(p_contract_id) = 'Y' THEN
-- check if the network point is a virtual network point
OPEN c_vnepo(l_conp_id_array(i));
FETCH c_vnepo INTO l_vnepo;
IF c_vnepo%FOUND THEN
l_vnepo := 'Y';
l_perc_split := 'N';
ELSE
l_vnepo := 'N';
-- check if the parameter is Percentage Split
OPEN c_perc_split(l_copa_id_array(j));
FETCH c_perc_split INTO l_perc_split;
IF c_perc_split%FOUND THEN
l_perc_split := 'Y';
ELSE
l_perc_split := 'N';
END IF;
CLOSE c_perc_split;
END IF;
CLOSE c_vnepo;
--
-- need to disable any cnppv field which is not against a virtual network point
-- except those against Percentage Split values
htp.p('<td><input name="p_cnppv_id" type="hidden" value="'||l_cnppv_id||'" />');
IF l_vnepo = 'Y' OR l_perc_split = 'Y' THEN
htp.p(' <input id="'||l_cnppv_id||'" name="p_value" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(l_cnppv_value)||'"'
||' origval="'||l_cnppv_value||'"'
||' onchange="setChanged(this);thousandSeparator(this.id,this.value)" /></td>');
ELSE
-- We need to create 2 input items for value one hidden and one disabled as
-- disabled input items don't get passed
htp.p('<input name="p_value" type="hidden" value="'||l_cnppv_value||'" />');
htp.p(' <input disabled name="p_value2" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(l_cnppv_value)||'"'
||' origval="'||l_cnppv_value||'"'
||' onchange="setChanged(this);thousandSeparator(this.id,this.value)" /></td>');
END IF;
--
ELSE
htp.p('<td><input name="p_cnppv_id" type="hidden" value="'||l_cnppv_id||'" />');
htp.p(' <input id="'||l_cnppv_id||'" name="p_value" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(l_cnppv_value)||'"'
||' origval="'||l_cnppv_value||'"'
||' onchange="setChanged(this);thousandSeparator(this.id,this.value)" /></td>');
--
END IF;
END IF;
CLOSE c_cnppv;
--
ELSE
l_error_cell_count := ((i-1) * l_copa_count) + j;
-- Recalled the screen with error - highlighting required.
IF p_data_error( l_error_cell_count ) = 'Y' THEN
htp.p('<td><input name="p_cnppv_id" type="hidden" value="'||p_cnppv_id(l_error_cell_count)||'" />');
htp.p(' <input id="'||p_cnppv_id(l_error_cell_count)||'" name="p_value" class="cnppvError" value="'||caco_utilities.to_thousand_separated(p_value(l_error_cell_count))||'" onchange="setChanged(this);thousandSeparator(this.id,this.value)"/></td>');
ELSE
htp.p('<td><input name="p_cnppv_id" type="hidden" value="'||p_cnppv_id(l_error_cell_count)||'" />');
htp.p(' <input id="'||p_cnppv_id(l_error_cell_count)||'" name="p_value" class="'||l_input_class||'" value="'||caco_utilities.to_thousand_separated(p_value(l_error_cell_count))||'" onchange="setChanged(this);thousandSeparator(this.id,this.value)"/></td>');
END IF;
--
END IF;
--
END LOOP; -- contract parameters loop
--
htp.p('
</tr>');
--
END LOOP cnppv_details_loop; -- contract network point loop
--
--
-- Close the CNPPV table
htp.p('</table>');
--
-- Close FORM contractFormP2
htp.p('</form>');
--
-- Close the enclosing cnppvDiv
htp.p('</div>');
--
-- Close the margin div
htp.p('</div>');
--
-- Close centrecontent div
htp.p('</div>');
--
wsgl.closepagebody;
--
END IF; -- l_success
--
END contract_values_p2;
PROCEDURE write_page_header( p_screen_type IN VARCHAR2
, p_inherited_cate IN VARCHAR2
, p_inherited_pars IN VARCHAR2 )
IS
BEGIN
--
htp.p(' <SCRIPT LANGUAGE="JavaScript">');
--
IF p_screen_type = 'CONTRACT' THEN
htp.p('
var opt = new OptionTransfer("add_nepo_id","p_nepo_id");
opt.setAutoSort(true);
opt.setDelimiter(",");
');
END IF;
--
IF p_screen_type = 'CONTRACT' THEN
htp.p('
var opt2 = new OptionTransfer("add_cate_id","p_cate_id");
opt2.setAutoSort(true);
opt2.setAutoSort(false);
opt2.setDelimiter(",");
');
ELSE
htp.p('
var opt2 = new OptionTransfer("add_cate_id","p_cate_id");
opt2.setAutoSort(false);
opt2.setDelimiter(",");
');
END IF;
--
IF p_screen_type = 'CONTRACT'
AND p_inherited_cate IS NOT NULL
THEN
htp.p('opt2.setStaticOptionRegex("^('||p_inherited_cate||')$");');
END IF;
--
htp.p('
var opt3 = new OptionTransfer("add_pars_id","p_pars_id");
opt3.setAutoSort(true);
opt3.setDelimiter(",");
');
--
IF p_screen_type = 'CONTRACT'
AND p_inherited_pars IS NOT NULL
THEN
htp.p('opt3.setStaticOptionRegex("^('||p_inherited_pars||')$");');
END IF;
--
htp.p(' </SCRIPT>');
--
END write_page_header;
PROCEDURE display_buttons( p_screen_type IN VARCHAR2
, p_ins_or_upd IN VARCHAR2
, p_contracts_exist IN BOOLEAN
, p_contract_id IN contracts.cont_id%TYPE
, p_template_id IN contract_templates.cote_id%TYPE
, p_template_changed IN VARCHAR2
, p_success IN VARCHAR2
, p_error IN VARCHAR2 )
IS
BEGIN
-- Insert or Update Button
htp.p('<p>');
htp.p('<input type="button" ');
IF p_ins_or_upd = 'INSERT'
OR p_ins_or_upd IS NULL
THEN
htp.p('value="'||caco_utilities.get_module_text(840)||'" '); -- Insert
ELSE
htp.p('value="'||caco_utilities.get_module_text(837)||'" '); -- Update
END IF;
--
IF p_screen_type = 'TEMPLATE' -- template and contracts exist for the template
AND p_contracts_exist
THEN
htp.p('onclick="confirmTemplateSubmit()" />');
ELSE
htp.p('onclick="submitPage1()" />');
END IF;
--
-- Contract "Set Values" (contract parameter values) Button
IF p_screen_type = 'CONTRACT' THEN
htp.p('<input type="button" value="'||caco_utilities.get_module_text(2347)||'" '); -- Set Values
IF ( p_contract_id IS NOT NULL
AND p_contract_id > 0
AND p_success != 'Y' )
OR p_contract_id IS NULL
OR p_contract_id = 0
OR p_template_changed = 'Y'
OR p_error = 'Y'
THEN
htp.p('disabled ');
END IF;
htp.p('onclick="checkForChanges(''VALUES'',''CONTRACT'','''
||dad_path||'efnow050$.contract_values_p2?p_contract_id='||p_contract_id||''');" />');
--
END IF;
--
-- Rules Button
htp.p('<input type="button" value="'||caco_utilities.get_module_text(2092)||'" '); -- Rules
--
IF p_screen_type = 'CONTRACT' THEN
--
IF ( p_contract_id IS NOT NULL
AND p_contract_id > 0
AND p_success != 'Y' )
OR p_contract_id IS NULL
OR p_contract_id = 0
OR p_template_changed = 'Y'
OR p_error = 'Y'
THEN
htp.p('disabled ');
END IF;
--
htp.p('onclick="checkForChanges(''RULES'',''CONTRACT'','''
||dad_path||'efnow050$.contract_rules?p_contract_id='||p_contract_id||''');" />');
--
ELSE
-- Contract Template
IF ( p_template_id IS NOT NULL
AND p_template_id > 0
AND p_success != 'Y' )
OR p_template_id IS NULL
OR p_template_id = 0
OR p_error = 'Y'
THEN
htp.p('disabled ');
END IF;
--
htp.p('onclick="checkForChanges(''RULES'',''TEMPLATE'','''
||dad_path||'efnow050$.template_rules?p_template_id='||p_template_id||''');" />');
--
END IF;
--
-- Options Button
htp.p('<input type="button" value="'||caco_utilities.get_module_text(3964)||'" '); -- Options
--
IF p_screen_type = 'CONTRACT' THEN
--
IF ( p_contract_id IS NOT NULL
AND p_contract_id > 0
AND p_success != 'Y' )
OR p_contract_id IS NULL
OR p_contract_id = 0
--OR p_template_changed = 'Y'
OR p_error = 'Y'
THEN
htp.p('disabled ');
END IF;
--
htp.p('onclick="checkForChanges(''OPTIONS'',''CONTRACT'','''
||dad_path||'efnow050$.contract_options_p?p_contract_id='||p_contract_id||''');" />');
--
ELSE
-- Contract Template
htp.p('disabled ');
htp.p('onclick="checkForChanges(''OPTIONS'',''TEMPLATE'','''
||dad_path||'efnow050$.contract_options_p?p_contract_id='||p_contract_id||''');" />');
--
END IF;
htp.p('</p>');
--
END display_buttons;
PROCEDURE display_contract_number( p_contract_number IN VARCHAR2 )
IS
BEGIN
--
htp.p('
<tr>
<td>
<b>'||caco_utilities.get_module_text(2013)||' *</b>'); -- Contract Number
htp.p(' </td>
<td>
<input id="p_contract_number" name="p_contract_number" type="text" value="'||p_contract_number||'" onchange="setChanged();" maxlength="30" />
</td>
<td>&nbsp;</td>
</tr>');
--
END display_contract_number;
PROCEDURE display_prev_contract_number(p_cust_id IN NUMBER,
p_contract_id IN NUMBER,
p_pre_contract_id IN VARCHAR2) IS
-- AWG October 2010
-- List of contracts that will have completed before the current contract starts
CURSOR c_pre_cont IS
SELECT cont_id,
contract_number
FROM contracts
WHERE cust_id = p_cust_id
AND valid_until <
(SELECT valid_from FROM contracts WHERE cont_id = p_contract_id)
ORDER BY valid_from DESC,
valid_until DESC;
BEGIN
--
htp.p('
<tr>
<td>' || caco_utilities.get_module_text(3961) || ' &nbsp</td>'); -- Previous Contract Number
htp.p(' <td>
<select id="p_pre_contract_id" name="p_pre_contract_id" size="1" onchange="setChanged();">');
--
IF p_pre_contract_id IS NULL OR p_pre_contract_id = 0
THEN
htp.p('<option selected value="0"> </option>');
ELSE
htp.p('<option value="0"> </option>');
END IF;
--
FOR r IN c_pre_cont LOOP
IF r.cont_id = p_pre_contract_id THEN
htp.p('<option selected value="' || r.cont_id || '">' || r.contract_number || '</option>');
ELSE
htp.p('<option value="' || r.cont_id || '">' || r.contract_number || '</option>');
END IF;
END LOOP;
htp.p(' </select>
</td>
<td>&nbsp</td>
</tr> ');
--
END display_prev_contract_number;
PROCEDURE display_contract_options(p_contract_id IN NUMBER,
p_contract_options IN contract_options%ROWTYPE) IS
-- AWG October 2010
-- Contract Options relating to contact details previously part
-- of the CUSTOMERS table.
BEGIN
--
htp.p('<input id="p_nom_conf_subject" name="p_nom_conf_subject" type="hidden" value="' ||
p_contract_options.nom_conf_subject || '" />');
--
htp.p('<input id="p_nom_conf_content" name="p_nom_conf_content" type="hidden" value="' ||
p_contract_options.nom_conf_content || '" />');
--
htp.p('<input id="p_com_conf_subject" name="p_com_conf_subject" type="hidden" value="' ||
p_contract_options.com_conf_subject || '" />');
--
htp.p('<input id="p_com_conf_content" name="p_com_conf_content" type="hidden" value="' ||
p_contract_options.com_conf_content || '" />');
--
htp.p('<input id="p_auto_gen_conf" name="p_auto_gen_conf" type="hidden" value="' ||
p_contract_options.auto_gen_conf || '" />');
--
htp.p('<input id="p_conf_type" name="p_conf_type" type="hidden" value="' ||
p_contract_options.conf_type || '" />');
--
htp.p('<input id="p_ind_deadline_for_nom_submit" name="p_ind_deadline_for_nom_submit" type="hidden" value="' ||
p_contract_options.ind_deadline_for_nom_submit || '" />');
--
htp.p('<input id="p_shipper" name="p_shipper" type="hidden" value="' ||
p_contract_options.shipper || '" />');
--
htp.p('<input id="p_int_subject" name="p_int_subject" type="hidden" value="' ||
p_contract_options.int_subject || '" />');
--
htp.p('<input id="p_int_content" name="p_int_content" type="hidden" value="' ||
p_contract_options.int_content || '" />');
--
htp.p('<input id="p_int_sms_content" name="p_int_sms_content" type="hidden" value="' ||
p_contract_options.int_sms_content || '" />');
--
END display_contract_options;
PROCEDURE display_customer( p_cust_id IN NUMBER )
IS
-- Get all possible customers for the person logged in
CURSOR c_cust IS
SELECT cust.cust_id customer_id
, cust.name customer_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 = 'Y' )
AND cuin.inte_id <> cout_system_configuration.get_configuration_item('INTE_ID')
GROUP BY cust.cust_id, cust.name
ORDER BY name;
--
BEGIN
--
htp.p('
<tr>
<td>'||caco_utilities.get_module_text(1145)||' *</td>'); -- Customer Name
htp.p(' <td>
<select id="p_customer_id" name="p_customer_id" size="1" onchange="setChanged();">');
--
-- Customer
-- Put out option list of available customers for THIS USER with selected as the given value
FOR r IN c_cust LOOP
--
IF r.customer_id = p_cust_id THEN
htp.p('<option selected value="'||r.customer_id||'">'||r.customer_name||'</option>');
ELSIF p_cust_id = 0 THEN
-- AWG October 2010 - Change Requests August 2010 Section 3.1
-- The customer cannot be updated in an existing contract to
-- accomodate the link to the previous contract.
htp.p('<option value="'||r.customer_id||'">'||r.customer_name||'</option>');
END IF;
--
END LOOP;
--
htp.p(' </select>
</td>
<td>&nbsp</td>
</tr> ');
--
END display_customer;
PROCEDURE display_contract_template( p_template_id IN NUMBER )
IS
-- Cursor to list all contract templates
CURSOR c_cote IS
SELECT cote_id template_id
, name template_name
FROM contract_templates
ORDER BY name;
--
BEGIN
--
-- Contract Template
htp.p('
<tr>
<td>
<b>'||caco_utilities.get_module_text(2090)|| '&nbsp<b>'); -- Contract Template Name
htp.p(' </td>
<td>');
--
-- Lets keep a hold of the currently selected value in this template list
htp.p(' <input id="p_prev_template_id" name="p_prev_template_id" type="hidden" value="'||p_template_id||'" />');
--
htp.p(' <select id="p_template_id" name="p_template_id" size="1" onchange="setChanged();areYouSureTemplateChange();">');
--
IF p_template_id IS NULL
OR p_template_id = 0
THEN
htp.p('<option selected value="0"> </option>');
ELSE
htp.p('<option value="0"> </option>');
END IF;
--
-- Now we can list all templates
FOR r IN c_cote LOOP
--
IF r.template_id = p_template_id THEN
htp.p('<option selected value="'||r.template_id||'">'||r.template_name||'</option>');
ELSE
htp.p('<option value="'||r.template_id||'">'||r.template_name||'</option>');
END IF;
--
END LOOP;
--
htp.p(' </select>
</td>
</tr>');
--
END display_contract_template;
PROCEDURE display_input_format( p_spte_id IN NUMBER )
IS
-- Get all possible Spreadsheet templates for contracts
CURSOR c_spte IS
SELECT spte_id
, name
FROM spreadsheet_templates
WHERE spte_type = 'NOST'
ORDER BY name;
--
CURSOR c_mtxt (c_text module_text.text%type) IS
SELECT text_number
FROM module_text
WHERE text = c_text;
l_lang module_text.language%type := caco_utilities.get_syus_lang;
CURSOR c_mtxt2 (c_text_number module_text.text_number%type) IS
SELECT text
FROM module_text
WHERE text_number = c_text_number
AND language = l_lang;
l_text_number module_text.text_number%type;
l_text module_text.text%type;
BEGIN
--
htp.p(' <td>'||caco_utilities.get_module_text(2264)||' *</td>'); -- Input Format
htp.p(' <td>
<select id="p_spte_id" name="p_spte_id" size="1" onchange="setChanged();">');
--
-- Now we can list all spreadsheet templates
FOR r IN c_spte LOOP
-- attempt translation if unsuccessful go with the spreadsheet_templates.name values
OPEN c_mtxt(r.name);
FETCH c_mtxt INTO l_text_number;
IF c_mtxt%NOTFOUND THEN
l_text := r.name;
ELSE
OPEN c_mtxt2(l_text_number);
FETCH c_mtxt2 INTO l_text;
IF c_mtxt2%NOTFOUND THEN
l_text := r.name;
END IF;
CLOSE c_mtxt2;
END IF;
CLOSE c_mtxt;
IF r.spte_id = p_spte_id THEN
htp.p('<option selected value="'||r.spte_id||'">'||l_text||'</option>');
ELSE
htp.p('<option value="'||r.spte_id||'">'||l_text||'</option>');
END IF;
--
END LOOP;
--
htp.p(' </select>
</td>');
--
END display_input_format;
PROCEDURE display_date_from( p_date_from IN VARCHAR2 )
IS
BEGIN
-- Date From
htp.p('
<td>'||caco_utilities.get_module_text(2241)||' *</td>'); -- Date From
htp.p(' <td>
<input id="p_date_from" name="p_date_from" type="text" value="'||p_date_from||'" onchange="setChanged();" maxlength="12" />
</td>
<td>');
--
htp.p(wsgjsl.calbutton(field_name => 'p_date_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 => cout_system_configuration.get_configuration_item('G_DATE_FORMAT')
,p_field_prompt => caco_utilities.get_module_text(2241) )); -- Date From
--
htp.p(' </td>');
--
END display_date_from;
PROCEDURE display_ops_contact( p_ops_contact IN VARCHAR2 )
IS
BEGIN
-- OPS Contact
htp.p(' <td>'||caco_utilities.get_module_text(2290)||' *</td>'); -- Ops Contact
htp.p(' <td>
<input id="p_ops_contact" class="contact" name="p_ops_contact" type="text" value="'||p_ops_contact||'" onchange="setChanged();" maxlength="50" />
</td>');
--
END display_ops_contact;
PROCEDURE display_date_to( p_date_to IN VARCHAR2 )
IS
BEGIN
-- Date To
htp.p(' <td>'||caco_utilities.get_module_text(2244)||' *</td>'); -- Date To
htp.p(' <td>
<input id="p_date_to" name="p_date_to" type="text" value="'||p_date_to||'" onchange="setChanged();" maxlength="12" />
</td>
<td>');
--
htp.p(wsgjsl.calbutton(field_name => 'p_date_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 => cout_system_configuration.get_configuration_item('G_DATE_FORMAT')
,p_field_prompt => caco_utilities.get_module_text(2244) ));
--
htp.p(' </td>');
--
END display_date_to;
PROCEDURE display_bus_contact( p_bus_contact IN VARCHAR2 )
IS
BEGIN
-- Business Contact
htp.p(' <td>'||caco_utilities.get_module_text(2228)||' *</td>'); -- Business Contact
htp.p(' <td>
<input id="p_bus_contact" class="contact" name="p_bus_contact" type="text" value="'||p_bus_contact||'" onchange="setChanged();" maxlength="50" />
</td>');
--
END display_bus_contact;
PROCEDURE display_val_window( p_val_window IN VARCHAR2 )
IS
BEGIN
-- Validation Window
htp.p(' <td>'||caco_utilities.get_module_text(2322)||' *</td>'); -- Validation Window
htp.p(' <td>
<input id="p_val_window" name="p_val_window" type="text" value="'||p_val_window||'" onchange="setChanged();" maxlength="38" />
</td>
<td>&nbsp;</td>');
--
END display_val_window;
PROCEDURE display_days_before( p_days_before IN VARCHAR2 )
IS
BEGIN
-- Days Before
htp.p(' <td>'||caco_utilities.get_module_text(2248)||' *</td>'); -- Days Before
htp.p(' <td>
<input id="p_days_before" name="p_days_before" type="text" value="'||p_days_before||'" onchange="setChanged();" maxlength="38" />
</td>');
--
END display_days_before;
PROCEDURE display_val_action( p_val_action IN VARCHAR2 )
IS
BEGIN
-- Validation Action
htp.p(' <td>'||caco_utilities.get_module_text(2318)||' *</td>'); -- Validation Action
htp.p(' <td>
<select id="p_val_action" name="p_val_action" size="1" onchange="setChanged();">');
--
IF p_val_action = 'T'
OR p_val_action IS NULL
THEN
htp.p('<option selected value="T">'||caco_utilities.get_module_text(2548)||'</option>');
htp.p('<option value="B">'||caco_utilities.get_module_text(2350)||'</option>');
ELSE -- Must be B lookback
htp.p('<option value="T">'||caco_utilities.get_module_text(2548)||'</option>');
htp.p('<option selected value="B">'||caco_utilities.get_module_text(2350)||'</option>');
END IF;
--
htp.p(' </select>
</td>
<td>&nbsp</td>');
--
END display_val_action;
PROCEDURE display_status( p_status IN VARCHAR2 )
IS
BEGIN
-- Status
htp.p(' <td>'||caco_utilities.get_module_text(2114)||' *</td>'); -- Status
htp.p(' <td>
<select id="p_status" name="p_status" size="1" onchange="setChanged();"> ');
--
IF UPPER(p_status) = 'O'
OR p_status IS NULL
THEN
htp.p('<option selected value="O">'||caco_utilities.get_module_text(2351)||'</option>'); -- Open
htp.p('<option value="C">'||caco_utilities.get_module_text(2352)||'</option>'); -- Closed
ELSE
htp.p('<option value="O">'||caco_utilities.get_module_text(2351)||'</option>'); -- Open
htp.p('<option selected value="C">'||caco_utilities.get_module_text(2352)||'</option>'); -- Closed
END IF;
--
htp.p(' </select>
</td>');
--
END display_status;
PROCEDURE display_emo( p_flag IN VARCHAR2 )
IS
BEGIN
-- Entry Mandatory Offer flag
htp.p(' <td>'||caco_utilities.get_module_text(3912)||' *</td>'); -- Entry Mandatory Offer
htp.p(' <td>
<select id="p_emo" name="p_emo" size="1" onchange="setChanged();"> ');
--
IF UPPER(p_flag) = 'Y'
THEN
htp.p('<option selected value="Y">'||caco_utilities.get_module_text(2191)||'</option>'); -- Yes
htp.p('<option value="N">'||caco_utilities.get_module_text(2192)||'</option>'); -- No
ELSE
htp.p('<option value="Y">'||caco_utilities.get_module_text(2191)||'</option>'); -- Yes
htp.p('<option selected value="N">'||caco_utilities.get_module_text(2192)||'</option>'); -- No
END IF;
--
htp.p(' </select>
</td>
<tr>
<td colspan="2"><hr /></td>
</tr>');
--
END display_emo;
PROCEDURE display_val_exception( p_val_exception IN VARCHAR2 )
IS
BEGIN
-- Validation Exception
htp.p(' <td>'||caco_utilities.get_module_text(2320)||' *</td>'); -- Validation Exception
htp.p(' <td>
<select id="p_val_exception" name="p_val_exception" size="1" onchange="setChanged();">');
--
IF p_val_exception = 'CO'
OR p_val_exception IS NULL
THEN
htp.p('<option selected value="CO">'||caco_utilities.get_module_text(2237)||'</option>'); -- Contracted Amount
htp.p('<option value="MI">'||caco_utilities.get_module_text(2274)||'</option>'); -- Minimum
htp.p('<option value="MA">'||caco_utilities.get_module_text(2344)||'</option>'); -- Maximum
ELSIF p_val_exception = 'MI' THEN
htp.p('<option value="CO">'||caco_utilities.get_module_text(2237)||'</option>');
htp.p('<option selected value="MI">'||caco_utilities.get_module_text(2274)||'</option>');
htp.p('<option value="MA">'||caco_utilities.get_module_text(2344)||'</option>'); -- Maximum
ELSE
htp.p('<option value="CO">'||caco_utilities.get_module_text(2237)||'</option>');
htp.p('<option value="MI">'||caco_utilities.get_module_text(2274)||'</option>');
htp.p('<option selected value="MA">'||caco_utilities.get_module_text(2344)||'</option>'); -- Maximum
END IF;
--
htp.p(' </select>
</td>
<td>&nbsp;</td>');
--
END display_val_exception;
PROCEDURE display_template_info( p_template_id IN contract_templates.cote_id%TYPE
, p_template_name IN contract_templates.name%TYPE
, p_template_desc IN contract_templates.description%TYPE )
IS
BEGIN
--
htp.p('
<tr>
<td>
<b>'||caco_utilities.get_module_text(2090)||' *<b>'); -- Contract Template Name
htp.p(' </td>
<td>
<input id="p_template_id" name="p_template_id" type="hidden" value="'||p_template_id||'" />
<input id="p_template_name" name="p_template_name" type="text" value="'||p_template_name||'" onchange="setChanged();" maxlength="50" />
</td>
</tr>
<tr>
<td>'||caco_utilities.get_module_text(20)||' *</td>'); -- Description
htp.p(' <td>
<input id="p_template_desc" name="p_template_desc" type="text" value="'||p_template_desc||'" onchange="setChanged();" maxlength="250" />
</td>
</tr>');
--
END display_template_info;
PROCEDURE display_network_points( p_network_point_array IN network_point_array
, p_avail_net_points IN network_point_array )
IS
BEGIN
-- Output the Network Points lists
htp.p('
<div class="selectItemsDiv" id="networkPointsDiv" >
<table>
<tr class="listTableHeadRow">
<th class="selectListWidthTH">'||caco_utilities.get_module_text(2277)||'</th>'); -- Network Points
htp.p(' </tr>
<tr>
<td>
<div class="selectBoxDiv">
<select class="selectListWidth" id="p_nepo_id" name="p_nepo_id" size="5" multiple
ondblclick="opt.transferLeft();setChanged();" >');
--
-- Now output the options we already found from the compiled arrays
IF NVL(p_network_point_array.COUNT,0) > 0 THEN
FOR i IN 1..p_network_point_array.COUNT LOOP
htp.p('<option value="'||p_network_point_array(i).nepo_id||'">'||p_network_point_array(i).name||'</option>');
END LOOP;
END IF;
--
htp.p('
</select>
</div>
</td>
</tr>
<tr>
<td class="selectListButtonTD">
<input class="selectListButton" type="button" value="'||caco_utilities.get_module_text(2294)||'"'); -- Remove Selected Network Points
htp.p(' onclick="opt.transferLeft();setChanged();" />
</td>
</tr>
<tr>
<td>
<div class="selectBoxDiv">
<select class="selectListWidth" id="add_nepo_id" name="add_nepo_id" size="5" multiple
ondblclick="opt.transferRight();setChanged();" >');
--
-- Output the remaining available Network Points that could be selected for this Contract
IF NVL(p_avail_net_points.COUNT,0) > 0 THEN
FOR i IN 1..p_avail_net_points.COUNT LOOP
htp.p('<option value="'||p_avail_net_points(i).nepo_id||'">'||p_avail_net_points(i).name||'</option>');
END LOOP;
END IF;
--
htp.p('
</select>
</div>
</td>
</tr>
<tr>
<td class="selectListButtonTD">
<input type="text" id="networkPointFilter"
onKeyUp="autoComplete( document.getElementById(''networkPointFilter'')
, document.getElementById(''add_nepo_id''), ''text'', true);" />
<input class="selectListButton" type="button" value="'||caco_utilities.get_module_text(2209)||'"'); -- Add Network Points
htp.p(' onclick="opt.transferRight();setChanged();clearNetworkPointFilter();moveFocusTo(''networkPointFilter'');" />
</td>
</tr>
</table>
</div>');
--
END display_network_points;
PROCEDURE display_categories( p_screen_type IN VARCHAR2
, p_category_array IN category_array
, p_avail_categories IN category_array )
IS
BEGIN
-- Output selected Categories and remaining available categories
htp.p('
<div class="selectItemsDiv" id="categoriesDiv" >
<table>
<tr class="listTableHeadRow">
<th class="selectListWidthTH">'||caco_utilities.get_module_text(2093)||'</th>'); -- Categories
htp.p(' </tr>
<tr>
<td>
<div class="selectBoxDiv">
<select class="selectListWidth" id="p_cate_id" name="p_cate_id" size="5" multiple
ondblclick="opt2.transferLeft();setChanged();" >');
--
-- output the options we already found from the compiled arrays
IF NVL(p_category_array.COUNT,0) > 0 THEN
FOR i IN 1..p_category_array.COUNT LOOP
IF p_screen_type = 'CONTRACT'
AND p_category_array(i).inherited = 'Y'
THEN
htp.p('<option class="inheritedCat" value="'||p_category_array(i).cate_id||'">'
||p_category_array(i).name||'</option>');
ELSE
htp.p('<option value="'||p_category_array(i).cate_id||'">'||p_category_array(i).name||'</option>');
END IF;
END LOOP;
END IF;
--
htp.p('
</select>
</div>
</td>
</tr>
<tr>
<td class="selectListButtonTD">
<input class="selectListButton" type="button" value="'||caco_utilities.get_module_text(2095)||'"'); -- Remove Selected Categories
htp.p(' onclick="opt2.transferLeft();setChanged();" />
</td>
</tr>
<tr>
<td>
<div class="selectBoxDiv">
<select class="selectListWidth" id="add_cate_id" name="add_cate_id" size="5" multiple
ondblclick="opt2.transferRight();setChanged();" >');
--
-- Output the remaining available Categories that could be selected for this Contract
IF NVL(p_avail_categories.COUNT,0) > 0 THEN
FOR i IN 1..p_avail_categories.COUNT LOOP
htp.p('<option value="'||p_avail_categories(i).cate_id||'">'||p_avail_categories(i).name||'</option>');
END LOOP;
END IF;
--
htp.p('
</select>
</div>
</td>
</tr>
<tr>
<td class="selectListButtonTD">
<input class="selectListButton" type="button" value="'||caco_utilities.get_module_text(2096)||'"'); -- Add Categories
htp.p(' onclick="opt2.transferRight();setChanged();" />
</td>
</tr>
</table>
</div>');
--
END display_categories;
PROCEDURE display_parameters( p_screen_type IN VARCHAR2
, p_parameter_array IN parameter_array
, p_avail_parameters IN parameter_array )
IS
BEGIN
-- Output selected Parameters and remaining available parameters
htp.p('
<div class="selectItemsDiv" id="parametersDiv" >
<table>
<tr class="listTableHeadRow">
<th class="selectListWidthTH">'||caco_utilities.get_module_text(2094)||'</th>'); -- Parameters
htp.p(' </tr>
<tr>
<td>
<div class="selectBoxDiv">
<select class="selectListWidth" id="p_pars_id" name="p_pars_id" size="5" multiple
ondblclick="opt3.transferLeft();setChanged();" >');
--
-- Output the options we already found from the compiled arrays
IF NVL(p_parameter_array.COUNT,0) > 0 THEN
FOR i IN 1..p_parameter_array.COUNT LOOP
IF p_screen_type = 'CONTRACT'
AND p_parameter_array(i).inherited = 'Y'
THEN
htp.p('<option class="inheritedPar" value="'||p_parameter_array(i).pars_id||'">'
||p_parameter_array(i).name||'</option>');
ELSE
htp.p('<option value="'||p_parameter_array(i).pars_id||'">'||p_parameter_array(i).name||'</option>');
END IF;
END LOOP;
END IF;
--
htp.p('
</select>
</div>
</td>
</tr>
<tr>
<td class="selectListButtonTD">
<input class="selectListButton" type="button" value="'||caco_utilities.get_module_text(2097)||'"'); --Remove Selected Parameters
htp.p(' onclick="opt3.transferLeft();setChanged();" />
</td>
</tr>
<tr>
<td>
<div class="selectBoxDiv">
<select class="selectListWidth" id="add_pars_id" name="add_pars_id" size="5" multiple
ondblclick="opt3.transferRight();setChanged();" >');
--
-- Output the remaining available Parameters that could be selected for this Contract
IF NVL(p_avail_parameters.COUNT,0) > 0 THEN
FOR i IN 1..p_avail_parameters.COUNT LOOP
htp.p('<option value="'||p_avail_parameters(i).pars_id||'">'||p_avail_parameters(i).name||'</option>');
END LOOP;
END IF;
--
htp.p('
</select>
</div>
</td>
</tr>
<tr>
<td class="selectListButtonTD">
<input class="selectListButton" type="button" value="'||caco_utilities.get_module_text(2098)||'"'); -- Add Parameters
htp.p(' onclick="opt3.transferRight();setChanged();" />
</td>
</tr>
</table>
</div>');
--
END display_parameters;
PROCEDURE startup( p_screen_type IN VARCHAR2 DEFAULT 'CONTRACT'
, p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT'
, p_success IN VARCHAR2 DEFAULT NULL
, p_contract_id IN contracts.cont_id%TYPE DEFAULT 0
, p_contract_number IN contracts.contract_number%TYPE DEFAULT NULL
, p_template_id IN contract_templates.cote_id%TYPE DEFAULT 0
, p_template_name IN VARCHAR2 DEFAULT NULL
, p_template_desc IN VARCHAR2 DEFAULT NULL
, p_emo IN VARCHAR2 DEFAULT NULL
, p_customer_id IN customers.cust_id%TYPE DEFAULT 0
, p_spte_id IN spreadsheet_templates.spte_id%TYPE DEFAULT 0
, p_ops_contact IN VARCHAR2 DEFAULT NULL
, p_bus_contact IN VARCHAR2 DEFAULT NULL
, p_status IN contracts.status%TYPE DEFAULT NULL
, p_days_before IN VARCHAR2 DEFAULT NULL
, p_date_from IN VARCHAR2 DEFAULT NULL
, p_date_to IN VARCHAR2 DEFAULT NULL
, p_val_window IN VARCHAR2 DEFAULT 0
, p_val_action IN contracts.validation_action%TYPE DEFAULT NULL
, p_val_exception IN contracts.validation_exception%TYPE DEFAULT NULL
, p_lookback_action IN contracts.lookback_action%TYPE DEFAULT NULL
, p_template_changed IN VARCHAR2 DEFAULT NULL
, p_prev_template_id IN NUMBER DEFAULT NULL
, p_error IN VARCHAR2 DEFAULT NULL
, p_err_msg IN VARCHAR2 DEFAULT NULL
, p_nepo_id IN owa_util.vc_arr DEFAULT g_vc_arr
, p_cate_id IN owa_util.vc_arr DEFAULT g_vc_arr
, p_pars_id IN owa_util.vc_arr DEFAULT g_vc_arr )
IS
--
-- Cursor used to determine if contracts exist for a given contract template
CURSOR c_cont_exists( cp_id IN NUMBER ) IS
SELECT 'X'
FROM contracts
WHERE cote_id = cp_id;
--
l_ins_or_upd VARCHAR2(6) := 'INSERT';
l_contract_id contracts.cont_id%TYPE := 0;
l_contract_number contracts.contract_number%TYPE := NULL;
l_prev_contract_id contracts.prev_cont_id%TYPE := 0;
l_template_id contract_templates.cote_id%TYPE := 0;
l_template_name VARCHAR2(2000) := NULL;
l_template_desc VARCHAR2(2000) := NULL;
l_customer_id contracts.cust_id%TYPE := 0;
l_spte_id contracts.spte_id%TYPE := 0;
l_ops_contact VARCHAR2(2000) := NULL;
l_bus_contact VARCHAR2(2000) := NULL;
l_status contracts.status%TYPE := NULL;
l_days_before VARCHAR2(255) := 60;
l_date_from VARCHAR2(12) := NULL;
l_date_to VARCHAR2(12) := NULL;
l_val_window VARCHAR2(2000) := NULL;
l_val_action contracts.validation_action%TYPE := 'B'; -- (I)gnore, (T)runcate or look(B)ack
l_val_exception contracts.validation_exception%TYPE := 'CO'; -- (CO)ntracted or (MI)nimum
--
l_lookback_action contracts.lookback_action%TYPE := 'T'; --Tip nomination
--
l_dummy_char VARCHAR2(1);
--
l_contract_record contracts%ROWTYPE;
l_contract_options contract_options%ROWTYPE;
l_template_record contract_templates%ROWTYPE;
l_network_point_array network_point_array;
l_avail_net_points network_point_array;
l_category_array category_array;
l_avail_categories category_array;
l_parameter_array parameter_array;
l_avail_parameters parameter_array;
l_inherited_cate VARCHAR2(26000) := NULL;
l_inherited_pars VARCHAR2(26000) := NULL;
--
l_onload_options VARCHAR2(255) := NULL;
--
l_code_position VARCHAR2(4) := '0000';
contracts_exist BOOLEAN := FALSE;
--
l_emo_flag VARCHAR2(1) := NULL;
--
BEGIN
--
IF NOT caco_security.security_check(g_package_name) THEN
RETURN;
END IF;
--
-- Ensure any passed parameters are correct
--
IF p_error IS NOT NULL
AND p_error = 'Y'
THEN
l_code_position := '0010';
--
-- Here we have to build the screen from the originally submitted data
-- that has NOT been saved to the DB
--
l_template_id := p_template_id;
--
-- get the bits required for a contract (not template)
IF p_screen_type = 'CONTRACT' THEN
-- Lets deal with Network Points
-- There are probably many so lets create an array by searching the array
find_passed_net_points( p_nepo_id -- this is the passed in array of nepo_id's
, l_network_point_array );
--
-- Put all other contract parameters into local variables
l_ins_or_upd := p_ins_or_upd;
l_contract_id := p_contract_id;
l_contract_number := p_contract_number;
l_prev_contract_id := l_contract_record.prev_cont_id;
l_customer_id := p_customer_id;
l_spte_id := p_spte_id;
l_ops_contact := p_ops_contact;
l_bus_contact := p_bus_contact;
l_status := p_status;
l_days_before := p_days_before;
l_date_from := p_date_from;
l_date_to := p_date_to;
l_val_window := p_val_window;
l_val_action := p_val_action;
l_val_exception := p_val_exception;
l_lookback_action := p_lookback_action;
ELSE
l_template_name := p_template_name;
l_template_desc := p_template_desc;
l_emo_flag := p_emo;
END IF;
--
l_code_position := '0020';
-- Now lets deal with Categories
-- There are probably many so lets create an array by searching the array
find_passed_categories( p_cate_id
, p_template_id
, l_category_array );
--
l_code_position := '0030';
-- Now lets deal with Parameters
-- There are probably many so lets create an array by searching the array
find_passed_parameters( p_pars_id
, p_template_id
, l_parameter_array );
--
ELSE
-- Was this a successful Insert or Update?
IF p_success = 'Y' THEN
l_code_position := '0500';
-- Just grab the data from the DB using the Contract ID or Template Id
IF p_contract_id IS NOT NULL
AND p_contract_id > 0
THEN
l_code_position := '0510';
--
l_ins_or_upd := 'UPDATE';
--
-- Get the details for the contract from the DB
--
get_contract_details_p1( p_contract_id
, l_contract_record
, l_network_point_array
, l_category_array
, l_parameter_array );
--
l_code_position := '0520';
-- More work required here to set the variables correctly...
l_contract_id := p_contract_id;
l_contract_number := l_contract_record.contract_number;
l_prev_contract_id := l_contract_record.prev_cont_id;
l_customer_id := l_contract_record.cust_id;
l_template_id := l_contract_record.cote_id;
l_spte_id := l_contract_record.spte_id;
l_ops_contact := l_contract_record.operations_contact;
l_bus_contact := l_contract_record.business_contact;
l_days_before := l_contract_record.receive_before_start;
l_date_from := TO_CHAR(l_contract_record.valid_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'));
l_date_to := TO_CHAR(l_contract_record.valid_until, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'));
l_status := l_contract_record.status;
l_val_window := l_contract_record.validation_window;
l_val_action := l_contract_record.validation_action;
l_val_exception := l_contract_record.validation_exception;
l_lookback_action := l_contract_record.lookback_action;
--
-- If this is a newly created contract then it will be necessary
-- to create a default set of contract options.
set_contract_options( l_contract_id );
--
ELSIF p_template_id IS NOT NULL
AND p_template_id > 0
THEN
l_code_position := '0530';
--
l_ins_or_upd := 'UPDATE';
--
-- Get the details for the contract template from the DB
--
get_template_details_p1( p_template_id
, l_template_record
, l_category_array
, l_parameter_array );
--
l_code_position := '0540';
-- More work required here to set the variables correctly...
l_template_id := l_template_record.cote_id;
l_template_name := l_template_record.name;
l_template_desc := l_template_record.description;
l_emo_flag := l_template_record.entry_mandatory_offer;
--
ELSE
l_code_position := '0550';
-- What happens if neither have been sent?
-- This shouldn't happen as success can only
-- come from the efno_contracts program units
NULL;
END IF;
--
ELSE
l_code_position := '0700';
-- Might be an internal call to update the contract template for a contract
-- or it may be a new insert/update
IF p_template_changed = 'Y' THEN
l_code_position := '0710';
--
IF p_screen_type = 'CONTRACT' THEN
l_code_position := '0720';
--
IF p_contract_id IS NOT NULL
AND p_contract_id > 0
THEN
--
l_ins_or_upd := 'UPDATE';
--
END IF;
--
l_contract_id := p_contract_id;
l_contract_number := p_contract_number;
l_prev_contract_id := l_contract_record.prev_cont_id;
l_customer_id := p_customer_id;
l_template_id := p_template_id;
l_spte_id := p_spte_id;
l_ops_contact := p_ops_contact;
l_bus_contact := p_bus_contact;
l_days_before := p_days_before;
l_date_from := p_date_from;
l_date_to := p_date_to;
l_status := p_status;
l_val_window := p_val_window;
l_val_action := p_val_action;
l_val_exception := p_val_exception;
l_lookback_action := p_lookback_action;
--
l_code_position := '0720';
--
find_passed_net_points( p_nepo_id
, l_network_point_array );
--
ELSE
l_code_position := '0730';
-- Template
IF p_template_id IS NOT NULL
AND p_template_id > 0
THEN
--
l_ins_or_upd := 'UPDATE';
l_template_id := p_template_id;
l_template_name := p_template_name;
l_template_desc := p_template_desc;
l_emo_flag := p_emo;
--
END IF;
--
END IF; -- end of contract or template IF
--
l_code_position := '0750';
--
-- Get the passed categories and parameters if there are any
find_passed_categories( p_cate_id
, p_template_id
, l_category_array
, p_prev_template_id );
--
l_code_position := '0760';
--
find_passed_parameters( p_pars_id
, p_template_id
, l_parameter_array
, p_prev_template_id );
--
ELSE
l_code_position := '0800';
-- Template not changed - real new or update.
IF p_screen_type = 'CONTRACT' THEN
l_code_position := '0810';
--
IF p_contract_id IS NOT NULL
AND p_contract_id > 0
THEN
l_code_position := '0820';
--
l_ins_or_upd := 'UPDATE';
--
-- Get the details for the contract from the DB
get_contract_details_p1( p_contract_id
, l_contract_record
, l_network_point_array
, l_category_array
, l_parameter_array );
--
l_code_position := '0830';
--
l_contract_id := p_contract_id;
l_contract_number := l_contract_record.contract_number;
l_prev_contract_id := l_contract_record.prev_cont_id;
l_customer_id := l_contract_record.cust_id;
l_template_id := l_contract_record.cote_id;
l_spte_id := l_contract_record.spte_id;
l_ops_contact := l_contract_record.operations_contact;
l_bus_contact := l_contract_record.business_contact;
l_days_before := l_contract_record.receive_before_start;
l_date_from := TO_CHAR(l_contract_record.valid_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'));
l_date_to := TO_CHAR(l_contract_record.valid_until, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'));
l_status := l_contract_record.status;
l_val_window := l_contract_record.validation_window;
l_val_action := l_contract_record.validation_action;
l_val_exception := l_contract_record.validation_exception;
l_lookback_action := l_contract_record.lookback_action;
--
END IF;
--
ELSE
l_code_position := '0860';
-- Template
IF p_template_id IS NOT NULL
AND p_template_id > 0
THEN
l_code_position := '0870';
--
l_ins_or_upd := 'UPDATE';
--
-- Get the details for the contract template from the DB
--
get_template_details_p1( p_template_id
, l_template_record
, l_category_array
, l_parameter_array );
--
l_template_id := l_template_record.cote_id;
l_template_name := l_template_record.name;
l_template_desc := l_template_record.description;
l_emo_flag := l_template_record.entry_mandatory_offer;
--
END IF;
END IF;
--
END IF; -- end of contract or template IF
--
END IF; -- end of successful insert/update IF
--
END IF; -- end of error screen build or ins/upd
--
l_code_position := '0900';
--
-- If a contract, get all network points and then filter list to ensure that only
-- the unselected ones are left in the resultant array
IF p_screen_type = 'CONTRACT' THEN
l_code_position := '1000';
--
get_avail_net_points( l_network_point_array -- array of already selected network points
, l_avail_net_points ); -- returning list of remaining net points
--
l_code_position := '1010';
-- Build list of inherited categories (so we can set them as non-movable in list)
l_inherited_cate := inherited_categories( l_category_array );
--
l_code_position := '1020';
-- Build list of inherited parameters (so we can set them as non-movable in list)
l_inherited_pars := inherited_parameters( l_parameter_array );
-- Gather Contract Options
get_contract_options( l_contract_id
, l_contract_options );
--
ELSE
-- Need to check if contracts exist for the given template
OPEN c_cont_exists( l_template_id );
FETCH c_cont_exists INTO l_dummy_char;
IF c_cont_exists%FOUND THEN
-- Contracts exist for the template
contracts_exist := TRUE;
END IF;
CLOSE c_cont_exists;
--
END IF;
--
l_code_position := '1100';
--
-- Get the list of categories that can still be selected for this contract or template
get_avail_categories( l_category_array -- already assigned
, l_avail_categories ); -- returned list of available categories
--
l_code_position := '1110';
--
-- Get the list of parameters that can still be selected for this contract or template
get_avail_parameters( l_parameter_array -- already assigned
, l_avail_parameters ); -- returned list of available parameters
--
--
--
-- htp.p(' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
-- htp.p(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
-- htp.p(' <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">');
--
l_code_position := '2000';
--
IF p_screen_type = 'CONTRACT' THEN
wsgl.openpagehead(caco_utilities.get_module_text(2271)); -- Maintain Contract
ELSE
wsgl.openpagehead(caco_utilities.get_module_text(2089)); -- Maintain Contract Template
END IF;
--
--wsgl.metatag;
--htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
caco_system.content_type;
htp.p('<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
htp.p(' <script type="text/javascript" src="efnow092$.selectbox_js"></script>');
htp.p(' <script type="text/javascript" src="efnow092$.optiontransfer_js"></script>');
htp.p(' <script type="text/javascript" src="efnow092$.autocomplete_js"></script>');
htp.p(' <script type="text/javascript" src="efnow092$.contract_js"></script>');
htp.p(' <link rel="stylesheet" media="all" type="text/css" href="efnow092$.contractP1_css" />');
--
htp.p(wsgjsl.openscript);
wsgjsl.output_invoke_cal_js('efnow092$'
,'scrollbars=no,resizable=no,width=320,height=350');
htp.p(wsgjsl.closescript);
--
write_page_header( p_screen_type => p_screen_type
, p_inherited_cate => l_inherited_cate
, p_inherited_pars => l_inherited_pars );
--
l_onload_options := 'onload="';
IF p_screen_type = 'CONTRACT' THEN
l_onload_options := l_onload_options||'opt.init(document.getElementById(''contractFormP1'')); ';
l_onload_options := l_onload_options||'opt2.init(document.getElementById(''contractFormP1'')); opt3.init(document.getElementById(''contractFormP1''));"';
ELSE
--
-- Changed to remove autosort
--
l_onload_options := l_onload_options||'opt2.init(document.getElementById(''contractFormP1'')); opt3.init(document.getElementById(''contractFormP1''));"';
--
END IF;
--
wsgl.closepagehead;
wsgl.openpagebody(FALSE, l_onload_options );
htp.p(caco_system.menu);
--
--
l_code_position := '2100';
--
-- Now we get to actually build the page.....
-- ...which should prove interesting seeing as how this is a multipurpose page....
htp.p('
<div id="contractP1_border_div" style="margin:15px;">
<form id="contractFormP1" name="contractFormP1" method="POST" ');
--
IF p_screen_type = 'CONTRACT' THEN
htp.p('action="efno_contracts.ins_or_upd_contract_p1">');
ELSE
htp.p('action="efno_contracts.ins_or_upd_template_p1">');
END IF;
--
htp.p('<div>');
--
l_code_position := '2010';
--
-- Output a hidden input to track if changes have been made to any of the parameters
IF p_error = 'Y'
OR p_template_changed = 'Y'
THEN
-- Still don't want the user to go to P2 (or P3) if there was a problem...
htp.p('<input id="p_changes" type="hidden" value="changed" />');
ELSE
htp.p('<input id="p_changes" type="hidden" value="none" />');
END IF;
--
l_code_position := '2020';
--
-- Put out all remaining hidden fields
htp.p('<input id="p_ins_or_upd" name="p_ins_or_upd" type="hidden" value="'||l_ins_or_upd||'" />');
--
IF p_screen_type = 'CONTRACT' THEN
htp.p('<input id="p_template_changed" name="p_template_changed" type="hidden" value="N" />');
htp.p('<input id="p_contract_id" name="p_contract_id" type="hidden" value="'||l_contract_id||'" />');
ELSE
-- just need to know if contracts exist for the given template (if one is given!
IF contracts_exist THEN
htp.p('<input id="contracts_exist" type="hidden" value="Y" />');
END IF;
--
END IF;
--
l_code_position := '2030';
--
IF p_screen_type = 'CONTRACT' THEN
htp.p('<h1>'||caco_utilities.get_module_text(2271)||'</h1>'); -- Maintain Contract
ELSE
htp.p('<h1>'||caco_utilities.get_module_text(2089)||'</h1>'); -- Maintain Contract Template
END IF;
--
l_code_position := '2040';
--
-- Put out success or error messages from completed or failed insert/update
display_message( p_success => p_success
, p_error => p_error
, p_err_msg => p_err_msg
, p_ins_or_upd => p_ins_or_upd );
--
l_code_position := '2050';
--
htp.p('
<table>');
--
IF p_screen_type = 'CONTRACT' THEN
l_code_position := '2500';
--
--display_contract_options( l_contract_id, l_contract_options );
--
display_contract_number( l_contract_number );
--
display_prev_contract_number( l_customer_id, l_contract_id, l_prev_contract_id );
--
display_customer( l_customer_id );
--
display_contract_template( l_template_id );
--
-- Horizontal line - to separate the above from the other minutiae
htp.p(' <tr>
<td colspan="3"><hr /></td>
</tr>');
--
-- Input Format starts the next row of the table
htp.p(' <tr>');
display_input_format( l_spte_id );
--
-- single table cell separator
htp.p(' <td>&nbsp;</td>');
--
display_date_from( l_date_from );
-- End the row and start a new one
htp.p(' </tr>
<tr>');
--
display_ops_contact( l_ops_contact );
--
-- single table cell separator
htp.p(' <td>&nbsp;</td>');
--
display_date_to( l_date_to );
--
htp.p(' </tr>
<tr>');
--
display_bus_contact( l_bus_contact );
--
-- single table cell separator
htp.p(' <td>&nbsp;</td>');
--
display_val_window( l_val_window );
--
htp.p(' </tr>
<tr>');
--
display_days_before( l_days_before );
--
-- single table cell separator
htp.p(' <td>&nbsp;</td>');
--
display_val_action( l_val_action );
--
htp.p(' </tr>
<tr>');
--
display_status( l_status );
--
htp.p(' <td>&nbsp;</td>');
--
display_val_exception( l_val_exception );
htp.p(' </tr>
<tr><td></td><td></td><td></td>');
--
display_lookback_action( l_lookback_action );
--
htp.p('</tr>');
--
ELSE
l_code_position := '2700';
-- Contract Template just requires the name and description
display_template_info( l_template_id
, l_template_name
, l_template_desc );
--
display_emo(l_emo_flag);
--
END IF;
--
-- Close the details table
htp.p(' </table>');
--
htp.p('<i>''*'''||caco_utilities.get_module_text(2202)||'</i>'); -- '*' Denotes a mandatory field
--
l_code_position := '2800';
--
-- Top level details done
-- Now write out the various select lists
--
IF p_screen_type = 'CONTRACT' THEN
htp.p('<p style="text-decoration:underline;"><b>'||caco_utilities.get_module_text(2353)||'</b></p>'); -- Contract Details
ELSE
htp.p('<p style="text-decoration:underline;"><b>'||caco_utilities.get_module_text(2091)||'</b></p>'); -- Contract Template Details
END IF;
--
l_code_position := '2810';
-- We need some buttons....required here due to CSS problems below the select lists.
display_buttons( p_screen_type => p_screen_type
, p_ins_or_upd => l_ins_or_upd
, p_contracts_exist => contracts_exist
, p_contract_id => p_contract_id
, p_template_id => p_template_id
, p_template_changed => p_template_changed
, p_success => p_success
, p_error => p_error );
--
l_code_position := '2820';
--
IF p_screen_type = 'CONTRACT' THEN
l_code_position := '2830';
--
display_network_points( l_network_point_array
, l_avail_net_points );
--
END IF;
--
l_code_position := '2900';
--
-- Output the categories
display_categories( p_screen_type
, l_category_array
, l_avail_categories );
--
l_code_position := '2940';
--
-- Finally we can do the Parameters
display_parameters( p_screen_type
, l_parameter_array
, l_avail_parameters );
--
l_code_position := '3000';
--
htp.p(chr(10)||'</div>'); -- Close of div just inside <form>
--
-- Close contractFormP1
htp.p('</form>');
-- Close contractP1_border_div
htp.p('</div>');
--
-- Close centrecontent div
htp.p('</div>');
--
wsgl.closepagebody;
--
EXCEPTION
WHEN others THEN
caco_debug.putline('efnow092$.startup: '
||'Position in Code : '||l_code_position||' : '||chr(10)
||sqlerrm(sqlcode));
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Position in Code : '||l_code_position
||' : '||chr(10)||sqlerrm(sqlcode)
, p_source => 'efnow092$.startup');
--
RAISE;
END startup;
PROCEDURE export_to_excel ( p_contract_id IN NUMBER) IS
--
--
-- Cursor to get the full contract details row
CURSOR c_contract IS
SELECT *
FROM contracts
WHERE cont_id = p_contract_id;
--
l_contract_row contracts%ROWTYPE;
--
CURSOR c_conp IS
SELECT conp.display_sequence display_sequence
, nepo.name netpoint_name
, conp.conp_id conp_id
, nepo.code netpoint_code
FROM cont_network_points conp
, network_points nepo
WHERE conp.nepo_id = nepo.nepo_id
AND conp.cont_id = p_contract_id
ORDER BY nepo.code; --nepo.name;
--
CURSOR c_copa IS
SELECT cate_name
, param_seq
, param_name
, display_sequence
, copa_id
FROM (
SELECT REPLACE(REPLACE(cate.name,chr(13),''),chr(10),'')||' ('||cate.units||')' cate_name
, 'C' AS disp_type
, coca.display_sequence display_sequence
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', 'MIN'
, 'MAX', 'MAX'
, 'CTR', 'CTR'
, NULL ) param_seq
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', caco_utilities.get_module_text(2274) -- Minimum
, 'MAX', caco_utilities.get_module_text(2344) -- Maximum
, 'CTR', caco_utilities.get_module_text(2345) -- Contracted
, NULL ) param_name
, copa.copa_id copa_id
, coca.inherited
FROM contract_parameters copa
, contract_categories coca
, parameters pars
, categories cate
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND coca.cont_id = p_contract_id
AND coca.cate_id = pars.cate_id
AND cate.cate_id = pars.cate_id
UNION ALL
SELECT REPLACE(REPLACE(pars.name,chr(13),''),chr(10),'') cate_name
, 'P' AS disp_type
, copa.display_sequence display_sequence
, NULL param_seq
, NULL param_name
, copa.copa_id copa_id
, copa.inherited
FROM contract_parameters copa
, parameters pars
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND pars.cate_id IS NULL
)
ORDER BY disp_type
, inherited desc
, DECODE(display_sequence,0,999999999999,display_sequence) ASC
, cate_name ASC
, param_seq DESC;
--
CURSOR c_cnppv( cp_conp_id IN NUMBER
, cp_copa_id IN NUMBER ) IS
SELECT cnppv.cnppv_id cnppv_id
, cnppv.value cnppv_value
FROM cont_net_point_param_vals cnppv
WHERE conp_id = cp_conp_id
AND copa_id = cp_copa_id;
--
l_copa_rec c_copa%ROWTYPE;
l_prev_copa_rec c_copa%ROWTYPE;
--
l_conp_id_array owa_util.num_arr;
l_copa_id_array owa_util.num_arr;
--
l_cnppv_id NUMBER := 0;
l_cnppv_value NUMBER := 0;
l_prev_cate_pars NUMBER := 1;
--
l_conp_count NUMBER := 0;
l_coca_count NUMBER := 0;
l_copa_count NUMBER := 0;
--
l_spreadsheet_id gtt_spreadsheet.spreadsheet_id%TYPE;
l_docu_id documents.docu_id%TYPE;
l_span NUMBER := 1;
l_extra_increment NUMBER := 0;
l_success BOOLEAN := TRUE;
--
PROCEDURE insert_cell ( p_spreadsheet_id IN gtt_spreadsheet.spreadsheet_id%TYPE
, p_value IN VARCHAR2
, p_datatype IN VARCHAR2 DEFAULT NULL
, p_col_width IN NUMBER DEFAULT NULL
, p_format_mask IN VARCHAR2 DEFAULT NULL
, p_x_axis IN VARCHAR2
, p_y_axis IN NUMBER
, p_x_increment IN NUMBER DEFAULT 0
, p_y_increment IN NUMBER DEFAULT 0
, p_span IN NUMBER DEFAULT NULL
) IS
--
l_x_axis VARCHAR2(2) := NULL;
--
BEGIN
--
IF p_x_increment > 0 THEN
--
IF (ASCII(p_x_axis)+p_x_increment) > 90 THEN
--
l_x_axis := CHR(64+TRUNC(((ASCII(p_x_axis)+p_x_increment)-65)/26))||CHR(65+MOD((((ASCII(p_x_axis)+p_x_increment)-65)),26)); --65=A, 90=Z
--
ELSE
--
l_x_axis := CHR(ASCII(p_x_axis)+p_x_increment);
--
END IF;
--
END IF;
--
-- htp.p(NVL(l_x_axis,p_x_axis)||TO_CHAR( p_y_axis + p_y_increment)||':'||to_char(p_x_increment)||':'||TO_CHAR(MOD((((ASCII(p_x_axis)+p_x_increment)-65)),26)));
IF p_value IS NOT NULL THEN
INSERT INTO gtt_spreadsheet ( spreadsheet_id
, x_axis
, y_axis
, cell_value
, cell_datatype
, cell_format_mask
, cell_border
, cell_background
, cell_merge
, cell_font
, cell_fontsize
, cell_align
, col_width
, row_height
, cell_wrap
)
VALUES ( p_spreadsheet_id
, NVL(l_x_axis,p_x_axis)
, p_y_axis + p_y_increment
, p_value
, p_datatype
, p_format_mask
, NULL
, NULL
, p_span
, NULL
, NULL
, NULL
, p_col_width
, NULL
, NULL
);
--
END IF;
--
END insert_cell;
--
BEGIN
--
OPEN c_contract;
FETCH c_contract INTO l_contract_row;
IF c_contract%NOTFOUND THEN
l_success := FALSE;
END IF;
CLOSE c_contract;
--
SELECT spte_seq.NEXTVAL
INTO l_spreadsheet_id
FROM DUAL;
--
-- Network Point Headers
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => caco_utilities.get_module_text(1006) -- Network Point Name
, p_x_axis => 'A'
, p_y_axis => 1
);
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => caco_utilities.get_module_text(1005) -- Network Point Code
, p_x_axis => 'B'
, p_y_axis => 1
);
--
-- Network Points
--
FOR r IN c_conp LOOP
--
-- Add network point name
--
l_conp_count := l_conp_count + 1;
l_conp_id_array(l_conp_count) := r.conp_id;
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => r.netpoint_name
, p_x_axis => 'A'
, p_y_axis => 3
, p_x_increment => 0
, p_y_increment => l_conp_count - 1
);
--
-- Add network code
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => r.netpoint_code
, p_x_axis => 'B'
, p_y_axis => 3
, p_x_increment => 0
, p_y_increment => l_conp_count - 1
);
--
END LOOP;
--
-- Contract Categories
--
OPEN c_copa;
FETCH c_copa INTO l_prev_copa_rec;
WHILE c_copa%FOUND LOOP
l_copa_rec := NULL;
FETCH c_copa INTO l_copa_rec;
--
IF NVL(l_copa_rec.cate_name,'*$%()L*') != l_prev_copa_rec.cate_name THEN
--
IF l_prev_cate_pars > 1 THEN
l_extra_increment := l_prev_cate_pars - 1;
END IF;
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => l_prev_copa_rec.cate_name
, p_x_axis => 'C'
, p_y_axis => 1
, p_x_increment => l_coca_count + l_extra_increment
, p_y_increment => 0
, p_span => l_span -1
);
l_coca_count := l_coca_count + l_prev_cate_pars;
l_prev_cate_pars := l_span;
l_span := 1;
--
ELSE
l_span := l_span + 1;
END IF;
--
l_prev_copa_rec := l_copa_rec;
--
END LOOP;
CLOSE c_copa;
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => '='
, p_x_axis => 'C'
, p_y_axis => 1
, p_x_increment => l_coca_count + l_extra_increment
);
--
-- Contract Parameter Headers
--
FOR r IN c_copa LOOP
--
l_copa_count := l_copa_count + 1;
l_copa_id_array(l_copa_count) := r.copa_id;
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => r.param_name
, p_x_axis => 'C'
, p_y_axis => 2
, p_x_increment => l_copa_count - 1
, p_y_increment => 0
);
--
END LOOP;
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => ' '
, p_x_axis => 'C'
, p_y_axis => 2
, p_x_increment => l_copa_count + 1
);
--
-- We need to do a row per network point of the same items as the header row.
--
<<cnppv_details_loop>>
FOR i IN 1..l_conp_count LOOP
--
FOR j IN 1..l_copa_count LOOP
--
OPEN c_cnppv( l_conp_id_array(i), l_copa_id_array(j) );
FETCH c_cnppv INTO l_cnppv_id, l_cnppv_value;
IF c_cnppv%NOTFOUND THEN
--
-- This is a problem - the contract is not set up correctly
-- which is more than likely an undocumented "feature" of the system
-- output an error? Probably the best idea.
caco_debug.putline('efnow092$.export_to_excel: '
||'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j) );
--
-- Write an error and carry on
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j)
, p_source => 'efnow092$.export_to_excel');
--
-- An unexpected error has occurred. Please contact support
htp.p(caco_utilities.get_module_text(2330));
EXIT cnppv_details_loop;
--
ELSE
-- We can output the values.
-- IF l_cnppv_value = TRUNC(l_cnppv_value) THEN
--
-- Integer, treat as number
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => l_cnppv_value
, p_datatype => 'N'
, p_format_mask => '#,##0'
, p_x_axis => 'C'
, p_y_axis => 3
, p_x_increment => j-1
, p_y_increment => i-1
);
/* --
ELSE
--
-- real number, treat as string
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => l_cnppv_value
--, p_datatype => 'N'
--, p_format_mask => '0'
, p_x_axis => 'C'
, p_y_axis => 3
, p_x_increment => j-1
, p_y_increment => i-1
);
--
END IF;*/
--
END IF;
CLOSE c_cnppv;
--
--
END LOOP; -- contract parameters loop
--
insert_cell ( p_spreadsheet_id => l_spreadsheet_id
, p_value => ' '
, p_x_axis => 'C'
, p_y_axis => 3
, p_x_increment => l_copa_count + 1
, p_y_increment => i-1
);
--
END LOOP cnppv_details_loop; -- contract network point loop
--
--
--
-- dbms_java.set_output(2000);
--
--
--
l_docu_id := amfr_excel.j_writeworkbook( l_spreadsheet_id
, l_contract_row.contract_number
);
--
UPDATE documents docs
SET docs.name = l_contract_row.contract_number || '_' || docs.name
WHERE docs.docu_id = l_docu_id;
--
amfr_excel.download(p_docu_id=>l_docu_id);
--
-- Now remove the document
--
DELETE
FROM documents d
WHERE d.docu_id = l_docu_id;
--
EXCEPTION
WHEN OTHERS THEN
htp.p(SQLERRM);
cout_err.report_and_go;
END export_to_excel;
--
PROCEDURE import_from_excel (p_contract_id IN NUMBER
,p_spreadsheet IN VARCHAR2 DEFAULT NULL ) IS
--
-- Cursor to get the full contract details row
--
CURSOR c_contract IS
SELECT *
FROM contracts
WHERE cont_id = p_contract_id;
--
l_contract_row contracts%ROWTYPE;
--
CURSOR c_conp IS
SELECT conp.display_sequence display_sequence
, nepo.name netpoint_name
, conp.conp_id conp_id
, nepo.code netpoint_code
FROM cont_network_points conp
, network_points nepo
WHERE conp.nepo_id = nepo.nepo_id
AND conp.cont_id = p_contract_id
ORDER BY nepo.code;
--
CURSOR c_copa IS
SELECT cate_name
, param_seq
, param_name
, display_sequence
, copa_id
FROM (
SELECT REPLACE(REPLACE(cate.name,chr(13),''),chr(10),'')||' ('||cate.units||')' cate_name
, 'C' AS disp_type
, coca.display_sequence display_sequence
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', 'MIN'
, 'MAX', 'MAX'
, 'CTR', 'CTR'
, NULL ) param_seq
, DECODE( SUBSTR(UPPER(pars.code),-3)
, 'MIN', caco_utilities.get_module_text(2274) -- Minimum
, 'MAX', caco_utilities.get_module_text(2344) -- Maximum
, 'CTR', caco_utilities.get_module_text(2345) -- Contracted
, NULL ) param_name
, copa.copa_id copa_id
, coca.inherited
FROM contract_parameters copa
, contract_categories coca
, parameters pars
, categories cate
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND coca.cont_id = p_contract_id
AND coca.cate_id = pars.cate_id
AND cate.cate_id = pars.cate_id
UNION ALL
SELECT REPLACE(REPLACE(pars.name,chr(13),''),chr(10),'') cate_name
, 'P' AS disp_type
, copa.display_sequence display_sequence
, NULL param_seq
, NULL param_name
, copa.copa_id copa_id
, copa.inherited
FROM contract_parameters copa
, parameters pars
WHERE copa.pars_id = pars.pars_id
AND copa.cont_id = p_contract_id
AND pars.cate_id IS NULL
)
ORDER BY disp_type
, inherited desc
, DECODE(display_sequence,0,999999999999,display_sequence) ASC
, cate_name ASC
, param_seq DESC;
--
CURSOR c_cnppv( cp_conp_id IN NUMBER
, cp_copa_id IN NUMBER ) IS
SELECT cnppv.cnppv_id cnppv_id
FROM cont_net_point_param_vals cnppv
WHERE conp_id = cp_conp_id
AND copa_id = cp_copa_id;
--
TYPE array_type IS TABLE OF gtt_spreadsheet.cell_value%TYPE;
--
l_copa_rec c_copa%ROWTYPE;
l_prev_copa_rec c_copa%ROWTYPE;
--
l_conp_id_array owa_util.num_arr;
l_copa_id_array owa_util.num_arr;
--
l_cnppv_id NUMBER := 0;
l_cnppv_value NUMBER := 0;
l_prev_cate_name categories.name%TYPE;
--
l_conp_count NUMBER := 0;
l_coca_count NUMBER := 0;
l_copa_count NUMBER := 0;
l_copa_all_count NUMBER := 0;
l_cnppv_values_count NUMBER := 0;
l_cnppv_ids_count NUMBER := 0;
--
l_spreadsheet_id gtt_spreadsheet.spreadsheet_id%TYPE;
l_docu_id documents.docu_id%TYPE;
l_span NUMBER := 1;
l_extra_increment NUMBER := 0;
l_success BOOLEAN := TRUE;
--
l_gtsp_id gtt_spreadsheet.spreadsheet_id%TYPE;
l_valid BOOLEAN := TRUE;
--
l_ss_nepo_names array_type := array_type();
l_ss_nepo_codes array_type := array_type();
l_db_nepo_names array_type := array_type();
l_db_nepo_codes array_type := array_type();
l_ss_cate_names array_type := array_type();
l_db_cate_names array_type := array_type();
l_ss_para_names array_type := array_type();
l_db_para_names array_type := array_type();
l_cnppv_values owa_util.vc_arr;
l_cnppv_ids owa_util.vc_arr;
--
l_nepo_names_count NUMBER := 0;
l_nepo_codes_count NUMBER := 0;
l_cate_names_count NUMBER := 0;
l_para_names_count NUMBER := 0;
--
-- print array procedure for testing
--
PROCEDURE print_array (p_array array_type) IS
BEGIN
htp.p('<br>');
FOR i IN 1..p_array.last LOOP
htp.p(i||':'||p_array(i));
htp.p('<br>');
END LOOP;
htp.p('------------------------');
END;
--
BEGIN
--
$IF $$debug_on $THEN
caco_debug.debug_on;
$END
--
caco_debug.putline('pp 1');
--
IF p_spreadsheet IS NULL THEN
--
caco_debug.putline('Error point 1');
l_valid := FALSE;
--
ELSE
--
caco_debug.putline('pp 2');
FOR i IN ( SELECT docu.docu_id
FROM documents docu
WHERE docu.name = p_spreadsheet
ORDER BY docu_id DESC
) LOOP
--
-- Decode the document using the java routines
--
BEGIN
--
l_gtsp_id := amfr_excel.j_readworkbook(p_docu_id => i.docu_id);
--
EXCEPTION
WHEN OTHERS THEN
--
caco_debug.putline('Error point 2');
--
l_valid := FALSE;
--
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => sqlerrm
);
--
l_valid := FALSE;
--
END;
--
caco_debug.putline('pp 3');
--
IF l_gtsp_id IS NOT NULL AND l_gtsp_id != 0 THEN
--
-- Spreadheet appears to be OK, continue processing
--
-- check network point names and codes
--
caco_debug.putline('pp 4');
--
FOR i IN ( SELECT *
FROM gtt_spreadsheet gtts
WHERE gtts.spreadsheet_id = l_gtsp_id
AND x_axis IN ('A', 'B')
AND y_axis = 0) LOOP
--
-- Check for changes in the static text title for network point name and network point code
--
IF i.x_axis = 'A' AND NVL(i.cell_value,'NULL') <> caco_utilities.get_module_text(1006) THEN
--
caco_debug.putline('Error point 2.3');
--
l_valid := FALSE;
--
END IF;
--
IF i.x_axis = 'B' AND NVL(i.cell_value,'NULL') <> caco_utilities.get_module_text(1005) THEN
--
caco_debug.putline('Error point 2.6');
--
l_valid := FALSE;
--
END IF;
--
END LOOP;
--
caco_debug.putline('pp 4.5');
--
FOR i IN ( SELECT *
FROM gtt_spreadsheet gtts
WHERE gtts.spreadsheet_id = l_gtsp_id
AND x_axis = 'A'
AND y_axis > 1) LOOP
--
l_nepo_names_count := l_nepo_names_count + 1;
l_ss_nepo_names.EXTEND;
l_ss_nepo_names(l_nepo_names_count) := i.cell_value||l_nepo_names_count;
--
END LOOP;
--
caco_debug.putline('pp 5');
FOR i IN ( SELECT *
FROM gtt_spreadsheet gtts
WHERE gtts.spreadsheet_id = l_gtsp_id
AND x_axis = 'B'
AND y_axis > 1) LOOP
--
l_nepo_codes_count := l_nepo_codes_count + 1;
l_ss_nepo_codes.EXTEND;
l_ss_nepo_codes(l_nepo_codes_count) := i.cell_value||l_nepo_codes_count;
--
END LOOP;
--
caco_debug.putline('pp 6');
FOR r IN c_conp LOOP
l_conp_count := l_conp_count + 1;
l_conp_id_array(l_conp_count) := r.conp_id;
l_db_nepo_names.EXTEND;
l_db_nepo_names(l_conp_count) := r.netpoint_name||l_conp_count;
l_db_nepo_codes.EXTEND;
l_db_nepo_codes(l_conp_count) := r.netpoint_code||l_conp_count;
END LOOP;
--
caco_debug.putline('pp 7');
IF l_ss_nepo_names != l_db_nepo_names OR
l_ss_nepo_codes != l_db_nepo_codes THEN
--
caco_debug.putline('Error point 3');
--
l_valid := FALSE;
--
END IF;
caco_debug.putline('pp 8');
--
-- check category names
--
IF l_valid THEN
FOR i IN ( SELECT *
FROM gtt_spreadsheet gtts
WHERE gtts.spreadsheet_id = l_gtsp_id
AND x_axis NOT IN ('A','B')
AND y_axis = 0
AND gtts.cell_value <> '=') LOOP
--
l_cate_names_count := l_cate_names_count + 1;
l_ss_cate_names.EXTEND;
l_ss_cate_names(l_cate_names_count) := i.cell_value||l_cate_names_count;
--
END LOOP;
--
caco_debug.putline('pp 9');
FOR r IN c_copa LOOP
--
IF r.cate_name != l_prev_cate_name OR l_prev_cate_name IS NULL THEN
--
l_coca_count := l_coca_count + 1;
l_db_cate_names.EXTEND;
l_db_cate_names(l_coca_count) := r.cate_name||l_coca_count;
l_prev_cate_name := r.cate_name;
--
END IF;
--
END LOOP;
--
IF l_ss_cate_names != l_db_cate_names THEN
--
caco_debug.putline('Error point 4');
--
l_valid := FALSE;
--
END IF;
--
END IF;
caco_debug.putline('pp 10');
--
-- check parameter names
--
IF l_valid THEN
--
FOR i IN ( SELECT *
FROM gtt_spreadsheet gtts
WHERE gtts.spreadsheet_id = l_gtsp_id
AND x_axis NOT IN ('A','B')
AND y_axis = 1
AND cell_value <> ' ') LOOP
--
l_para_names_count := l_para_names_count + 1;
l_ss_para_names.EXTEND;
l_ss_para_names(l_para_names_count) := i.cell_value||l_para_names_count;
--
END LOOP;
--
caco_debug.putline('pp 11');
FOR r IN c_copa LOOP
--
l_copa_all_count := l_copa_all_count + 1;
l_copa_id_array(l_copa_all_count) := r.copa_id;
IF r.param_name IS NOT NULL THEN
--
l_copa_count := l_copa_count + 1;
l_db_para_names.EXTEND;
l_db_para_names(l_copa_count) := r.param_name||l_copa_count;
--
END IF;
--
END LOOP;
caco_debug.putline('pp 12');
--
IF l_ss_para_names != l_db_para_names THEN
--
caco_debug.putline('Error point 5');
--
l_valid := FALSE;
--
END IF;
--
END IF;
caco_debug.putline('pp 13');
--
-- collect the spreadsheet cnppv values into an array
--
IF l_valid THEN
--
FOR i IN ( SELECT *
FROM gtt_spreadsheet gtts
WHERE gtts.spreadsheet_id = l_gtsp_id
AND x_axis NOT IN ('A','B')
AND y_axis > 1
AND cell_value <> ' '
ORDER BY gtts.y_axis
,ASCII(gtts.x_axis)) LOOP
--
l_cnppv_values_count := l_cnppv_values_count + 1;
--
IF SUBSTR(i.cell_value, LENGTH(i.cell_value)-1) = '.0' THEN
l_cnppv_values(l_cnppv_values_count) := REPLACE(i.cell_value, '.0');
ELSE
l_cnppv_values(l_cnppv_values_count) := i.cell_value;
END IF;
--
END LOOP;
caco_debug.putline('pp 14');
--
-- collect the correspomding database cnppv ids into an array
--
<<cnppv_details_loop>>
FOR i IN 1..l_conp_count LOOP
--
FOR j IN 1..l_copa_all_count LOOP
--
OPEN c_cnppv( l_conp_id_array(i), l_copa_id_array(j) );
FETCH c_cnppv INTO l_cnppv_id;
IF c_cnppv%NOTFOUND THEN
--
-- This is a problem - the contract is not set up correctly
-- which is more than likely an undocumented "feature" of the system
-- output an error? Probably the best idea.
--
caco_debug.putline('efnow092$.import_from_excel: '
||'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j) );
--
-- Write an error and carry on
--
cout_err.report_and_go( p_exception_number => sqlcode
, p_exception_message => 'Contract network Point Parameter Value not found: '
||' CONP_ID : '||l_conp_id_array(i)
||' COPA_ID : '||l_copa_id_array(j)
, p_source => 'efnow092$.import_from_excel');
--
-- An unexpected error has occurred. Please contact support
--
htp.p(caco_utilities.get_module_text(2330));
EXIT cnppv_details_loop;
--
ELSE
l_cnppv_ids_count := l_cnppv_ids_count + 1;
l_cnppv_ids(l_cnppv_ids_count) := l_cnppv_id;
END IF;
CLOSE c_cnppv;
--
--
END LOOP; -- contract parameters loop
--
--
END LOOP cnppv_details_loop; -- contract network point loop
--
-- check that the counts match
--
IF l_cnppv_values.count != l_cnppv_ids.count THEN
caco_debug.putline('Error point 7');
l_valid := FALSE;
END IF;
--
END IF;
caco_debug.putline('pp 15');
--
-- insert the spreadsheet values
--
IF l_valid THEN
--
-- remove thousand separators from val array
--
l_cnppv_values := caco_utilities.thousand_separated_to_char(l_cnppv_values);
--
efno_contracts.upd_cnppv_records( p_contract_id => p_contract_id
, p_cnppv_id => l_cnppv_ids
, p_value => l_cnppv_values
);
--
END IF;
--
ELSE
--
-- File doesn't appear to be in the correct format (that is, a spreadsheet)
--
caco_debug.putline('Error point 8');
l_valid := FALSE;
--
END IF;
--
EXIT;
--
END LOOP;
--
IF NOT l_valid THEN
--
-- Invalid, something went wrong, redisplay the screen
--
contract_values_p2 ( p_contract_id => p_contract_id
, p_error => 'N'
, p_success => 'N'
, p_err_msg => caco_utilities.get_module_text(3864)
);
--
END IF;
--
END IF;
--
EXCEPTION
WHEN OTHERS THEN
cout_err.report_and_go;
END import_from_excel;
/**
-- 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
--
NULL;
--
END EFNOW092$;
/