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(''); 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; -- <> 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 // 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;i0) { 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 // 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 // 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 (b.text+"")) { return 1; } return 0; } ); for (var i=0; i 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=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=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(' '||caco_utilities.get_module_text(2549)||''); -- Validation Action htp.p('  '); -- 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(''||caco_utilities.get_module_text(876)||'

'); ELSIF p_error = 'Y' THEN htp.p(''); 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('
'); htp.p(''||p_err_msg||'

'); ELSIF p_error = 'N' AND p_err_msg IS NOT NULL THEN -- -- Spreadsheet update failed -- htp.p(''); htp.p(caco_utilities.get_module_text(2340)); -- Update failed htp.p('
'); htp.p(''||p_err_msg||'

'); 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(''); -- htp.p(''); wsgl.openpagehead(caco_utilities.get_module_text(2099)); -- Maintain Contract Template Rules -- wsgl.metatag; -- htp.p('');'); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); wsgl.closepagehead; wsgl.openpagebody(FALSE); htp.p(caco_system.menu); -- htp.p('

'||caco_utilities.get_module_text(2099)||'

'); -- 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(' '); -- Contract Template Name htp.p('
'||caco_utilities.get_module_text(2090)||'  '||l_template_name||'

'); -- -- 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(''); -- htp.p('

'); -- -- Current Contract Template Rules htp.p('

'||caco_utilities.get_module_text(2102)||'

'); -- -- If contracts exist for this template, put a hidden input that can be used in javascript check routines IF contracts_exist THEN htp.p(''); 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('

'||caco_utilities.get_module_text(2279)||'

'); -- ELSE -- Output the list of rules. htp.p('
'); htp.p(' '); -- Display Sequence htp.p(' '); -- Rule Name htp.p(' '); -- Edit htp.p(' '); -- Delete htp.p(' '); -- 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(''); ELSE htp.p(''); END IF; -- htp.p(''); -- -- 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(''); -- htp.p(''); -- -- 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(''); -- -- put out delete link -- button with a call to javascript function to request a confirmation htp.p(''); -- -- IF valid_rule THEN htp.p(''); ELSE htp.p(''); -- Invalid END IF; -- Finalise table row htp.p(''); -- END LOOP; -- -- Close the table htp.p('
'||caco_utilities.get_module_text(2031)||' '||caco_utilities.get_module_text(2106)||' '||caco_utilities.get_module_text(2008)||' '||caco_utilities.get_module_text(838)||'  
'||r.rule_name||'' ||' '||caco_utilities.get_module_text(2041)||'
'); -- -- Close the ruleList div htp.p('
'); -- END IF; -- htp.p('

'||caco_utilities.get_module_text(2326)||'

'); -- 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(''); -- -- 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(''); -- -- Close the margin div htp.p('
'); -- -- Close centrecontent div htp.p(''); -- -- Close outer div htp.p(''); -- 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(''); -- htp.p(''); wsgl.openpagehead(caco_utilities.get_module_text(3967)); -- Maintain Contract Options -- wsgl.metatag; --htp.p(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); --htp.p(' '); 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('
'); -- htp.p('
'); -- htp.p('

' || caco_utilities.get_module_text(3967) || '

'); -- 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(''); -- Contract Number htp.p('
' || caco_utilities.get_module_text(2013) || '  ' || l_contract_number || '
'); htp.p('

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

'); -- htp.p('
'); -- 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(''); htp.p(''); -- htp.p(''); -- htp.p(''); -- -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p('
'); htp.p('' || caco_utilities.get_module_text(3556) || ''); -- Shipper htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2470) || ''); -- Auto Generate Confirmation htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2471) || ''); -- Confirmation Type htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2468) || ''); -- Com Confirmation Subject htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2469) || ''); -- Com Confirmation Content htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2466) || ''); -- Nom Confirmation Subject htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2467) || ''); -- Nom Confirmation Content htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(2459) || ''); -- Ind Sub Deadline (Hours) htp.p(''); htp.p(''); /* htp.p(''); */ htp.p('
'); htp.p('' || caco_utilities.get_module_text(2457) || ''); -- Ind Sub Deadline (Mins) htp.p(''); htp.p(''); /* htp.p(''); */ htp.p('
'); htp.p('' || caco_utilities.get_module_text(3591) || ''); -- Interruption Subject htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(3592) || ''); -- Interruption Content htp.p(''); htp.p(''); htp.p('
'); htp.p('' || caco_utilities.get_module_text(3593) || ''); -- Interruption SMS Content htp.p(''); htp.p(''); htp.p('
'); -- htp.p('

''*''' || caco_utilities.get_module_text(2202) || '

'); -- '*' Denotes a mandatory field -- htp.p(caco_utilities.get_module_text(3605)); htp.p(caco_utilities.get_module_text(3606)); htp.p('{CONFIRMATION_IDENTIFIER}{NOMINATION_IDENTIFIER}'); htp.p('{GAS_DAY}{GAS_DAY_START}'); htp.p('{NOMINATION_IDENTIFIER}{GAS_DAY_END}'); htp.p('{TIMESTAMP}'); htp.p(''); 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(''); -- htp.p(''); wsgl.openpagehead(caco_utilities.get_module_text(2272)); -- Maintain Contract Rules -- wsgl.metatag; --htp.p(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); wsgl.closepagehead; wsgl.openpagebody(FALSE); htp.p(caco_system.menu); -- htp.p('

'||caco_utilities.get_module_text(2272)||'

'); -- 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(' '); -- Contract Number htp.p('
'||caco_utilities.get_module_text(2013)||'  '||l_contract_number||'

'); -- -- 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(''); -- htp.p('

'); -- htp.p('

'||caco_utilities.get_module_text(2238)||'

'); -- 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('

'||caco_utilities.get_module_text(2279)||'

'); -- No Rules attached to this contract -- ELSE -- Output the list of rules. htp.p('
'); -- Display Sequence htp.p(' '); -- Rule Type htp.p(' '); -- Rule Name htp.p(' '); -- Edit htp.p(' '); -- Delete htp.p(' '); -- 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(''); ELSIF valid_rule THEN htp.p(''); ELSE htp.p(''); END IF; -- htp.p(''); -- -- 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(''); -- htp.p(''); htp.p(''); -- -- 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(''); -- Edit -- ELSE htp.p(''); END IF; -- -- put out delete link IF NVL(r.inherited,'N') = 'Y' THEN htp.p(''); ELSE htp.p(''); -- Del END IF; -- IF valid_rule THEN htp.p(''); ELSE htp.p(''); -- Invalid END IF; -- -- Finalise table row htp.p(''); -- END LOOP; -- -- Close the table htp.p('
'||caco_utilities.get_module_text(2031)||' '||caco_utilities.get_module_text(2126)||' '||caco_utilities.get_module_text(2106)||' '||caco_utilities.get_module_text(2008)||' '||caco_utilities.get_module_text(838)||'  
'||r.rule_type||''||r.rule_name||'   '||caco_utilities.get_module_text(2041)||'
'); -- -- Close the ruleList div htp.p('
'); -- END IF; -- htp.p('

'||caco_utilities.get_module_text(2326)||'

'); -- 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(''); -- -- 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(''); -- -- Close the margin div htp.p('
'); -- -- Close centrecontent div htp.p('
'); -- -- Close outer div htp.p('
'); -- 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(''); -- htp.p(''); wsgl.openpagehead(caco_utilities.get_module_text(3980)); -- View Contract Values --wsgl.metatag; --htp.p(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); 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('

'||caco_utilities.get_module_text(3980)||'

'); -- 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(' '); -- Contract Number htp.p('
'||caco_utilities.get_module_text(2013)||'  '||l_contract_row.contract_number||'

'); IF p_error = 'N' THEN htp.p(''); ELSE htp.p(''); END IF; -- htp.p(' '); htp.p(' '); htp.p(' '); -- htp.p(' '); htp.p('
'); htp.p('
'); htp.p('

'); htp.p('

'||caco_utilities.get_module_text(2276)||''); -- 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('   '||caco_utilities.get_module_text(2346)||':'); -- Page FOR i IN 1..l_num_pages LOOP -- IF i = p_page_no THEN htp.p(''||p_page_no||''); ELSE htp.p(''||i||''); END IF; -- IF i < l_num_pages THEN htp.p(',  '); END IF; -- END LOOP; -- END IF; -- htp.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('
'); -- Network Point htp.p(' '); -- Network Code htp.p(' '); -- 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(' '); -- -- Add network code -- IF MOD(l_conp_count,2) = 0 THEN htp.p(' '); -- END IF; -- END LOOP; -- htp.p('
'||caco_utilities.get_module_text(2023)||''||caco_utilities.get_module_text(1005)||'
'); -- -- End of the Network Points list -- -- Lets make a start on the values table htp.p('
'); -- -- Output the contract Id and Page number as hidden inputs htp.p(''); htp.p(''); -- -- open the table for the cnppv values. htp.p(' '); -- -- htp.p(''); -- 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(''); 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(''); -- -- 2nd header row htp.p(''); 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(''); END IF; -- END LOOP; htp.p(''); -- -- We need to do a row per network point of the same items as the header row. <> FOR i IN 1..l_conp_count LOOP -- IF MOD(i,2) = 0 THEN htp.p(' '); -- l_input_class := 'cnppvInput2'; ELSE htp.p(' '); -- 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(''); 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(''); 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(''); htp.p(' '); END IF; -- ELSE htp.p(''); -- 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(''); ELSE htp.p(''); END IF; -- END IF; -- END LOOP; -- contract parameters loop -- htp.p(' '); -- END LOOP cnppv_details_loop; -- contract network point loop -- -- -- Close the CNPPV table htp.p('
'||l_prev_copa_rec.cate_name||'
'||r.param_name||'
'); IF l_vnepo = 'Y' OR l_perc_split = 'Y' THEN htp.p(' '); htp.p(' '); htp.p(' '); htp.p('
'); -- -- Close FORM contractFormP2 htp.p('
'); -- -- Close the enclosing cnppvDiv htp.p('
'); -- -- Close the margin div htp.p('
'); -- -- Close centrecontent div htp.p('
'); -- 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(''); -- htp.p(''); wsgl.openpagehead(caco_utilities.get_module_text(2273)); -- Maintain Contract Values --wsgl.metatag; --htp.p(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); 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('

'||caco_utilities.get_module_text(2273)||'

'); -- 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(' '); -- Contract Number htp.p('
'||caco_utilities.get_module_text(2013)||'  '||l_contract_row.contract_number||'

'); IF p_error = 'N' THEN htp.p(''); ELSE htp.p(''); END IF; htp.p(' '); htp.p(' '); htp.p(' '); htp.p(' '); htp.p('
'); htp.p('
'); htp.p('

'); htp.p('

'||caco_utilities.get_module_text(2276)||''); -- 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('   '||caco_utilities.get_module_text(2346)||':'); -- Page FOR i IN 1..l_num_pages LOOP -- IF i = p_page_no THEN htp.p(''||p_page_no||''); ELSE htp.p(''||i||''); END IF; -- IF i < l_num_pages THEN htp.p(',  '); END IF; -- END LOOP; -- END IF; -- htp.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('
'); -- Network Point htp.p(' '); -- Network Code htp.p(' '); -- 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(' '); -- -- Add network code -- IF MOD(l_conp_count,2) = 0 THEN htp.p(' '); -- END IF; -- END LOOP; -- htp.p('
'||caco_utilities.get_module_text(2023)||''||caco_utilities.get_module_text(1005)||'
'); -- -- End of the Network Points list -- -- Lets make a start on the values table htp.p('
'); -- -- Output the contract Id and Page number as hidden inputs htp.p(''); htp.p(''); -- -- open the table for the cnppv values. htp.p(' '); -- -- htp.p(''); -- 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(''); 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(''); -- -- 2nd header row htp.p(''); 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(''); END IF; -- END LOOP; htp.p(''); -- -- We need to do a row per network point of the same items as the header row. <> FOR i IN 1..l_conp_count LOOP -- IF MOD(i,2) = 0 THEN htp.p(' '); -- l_input_class := 'cnppvInput2'; ELSE htp.p(' '); -- 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(''); 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(''); 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(''); htp.p(' '); END IF; -- ELSE htp.p(''); -- 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(''); ELSE htp.p(''); END IF; -- END IF; -- END LOOP; -- contract parameters loop -- htp.p(' '); -- END LOOP cnppv_details_loop; -- contract network point loop -- -- -- Close the CNPPV table htp.p('
'||l_prev_copa_rec.cate_name||'
'||r.param_name||'
'); IF l_vnepo = 'Y' OR l_perc_split = 'Y' THEN htp.p(' '); htp.p(' '); htp.p(' '); htp.p('
'); -- -- Close FORM contractFormP2 htp.p('
'); -- -- Close the enclosing cnppvDiv htp.p('
'); -- -- Close the margin div htp.p('
'); -- -- Close centrecontent div htp.p(''); -- 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(' '); -- 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('

'); htp.p(''); ELSE htp.p('onclick="submitPage1()" />'); END IF; -- -- Contract "Set Values" (contract parameter values) Button IF p_screen_type = 'CONTRACT' THEN htp.p(' 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(' 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(' 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('

'); -- END display_buttons; PROCEDURE display_contract_number( p_contract_number IN VARCHAR2 ) IS BEGIN -- htp.p(' '||caco_utilities.get_module_text(2013)||' *'); -- Contract Number htp.p('   '); -- 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(' ' || caco_utilities.get_module_text(3961) || '  '); -- Previous Contract Number htp.p('   '); -- 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(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- htp.p(''); -- 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(' '||caco_utilities.get_module_text(1145)||' *'); -- Customer Name htp.p('   '); -- 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(' '||caco_utilities.get_module_text(2090)|| ' '); -- Contract Template Name htp.p(' '); -- -- Lets keep a hold of the currently selected value in this template list htp.p(' '); -- htp.p(' '); -- 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(' '||caco_utilities.get_module_text(2264)||' *'); -- Input Format htp.p(' '); -- END display_input_format; PROCEDURE display_date_from( p_date_from IN VARCHAR2 ) IS BEGIN -- Date From htp.p(' '||caco_utilities.get_module_text(2241)||' *'); -- Date From htp.p(' '); -- 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(' '); -- END display_date_from; PROCEDURE display_ops_contact( p_ops_contact IN VARCHAR2 ) IS BEGIN -- OPS Contact htp.p(' '||caco_utilities.get_module_text(2290)||' *'); -- Ops Contact htp.p(' '); -- END display_ops_contact; PROCEDURE display_date_to( p_date_to IN VARCHAR2 ) IS BEGIN -- Date To htp.p(' '||caco_utilities.get_module_text(2244)||' *'); -- Date To htp.p(' '); -- 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(' '); -- END display_date_to; PROCEDURE display_bus_contact( p_bus_contact IN VARCHAR2 ) IS BEGIN -- Business Contact htp.p(' '||caco_utilities.get_module_text(2228)||' *'); -- Business Contact htp.p(' '); -- END display_bus_contact; PROCEDURE display_val_window( p_val_window IN VARCHAR2 ) IS BEGIN -- Validation Window htp.p(' '||caco_utilities.get_module_text(2322)||' *'); -- Validation Window htp.p('  '); -- END display_val_window; PROCEDURE display_days_before( p_days_before IN VARCHAR2 ) IS BEGIN -- Days Before htp.p(' '||caco_utilities.get_module_text(2248)||' *'); -- Days Before htp.p(' '); -- END display_days_before; PROCEDURE display_val_action( p_val_action IN VARCHAR2 ) IS BEGIN -- Validation Action htp.p(' '||caco_utilities.get_module_text(2318)||' *'); -- Validation Action htp.p('  '); -- END display_val_action; PROCEDURE display_status( p_status IN VARCHAR2 ) IS BEGIN -- Status htp.p(' '||caco_utilities.get_module_text(2114)||' *'); -- Status htp.p(' '); -- END display_status; PROCEDURE display_emo( p_flag IN VARCHAR2 ) IS BEGIN -- Entry Mandatory Offer flag htp.p(' '||caco_utilities.get_module_text(3912)||' *'); -- Entry Mandatory Offer htp.p('
'); -- END display_emo; PROCEDURE display_val_exception( p_val_exception IN VARCHAR2 ) IS BEGIN -- Validation Exception htp.p(' '||caco_utilities.get_module_text(2320)||' *'); -- Validation Exception htp.p('  '); -- 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(' '||caco_utilities.get_module_text(2090)||' *'); -- Contract Template Name htp.p(' '||caco_utilities.get_module_text(20)||' *'); -- Description htp.p(' '); -- 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('
'); -- Network Points htp.p('
'||caco_utilities.get_module_text(2277)||'
'); -- 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('
'); -- Categories htp.p('
'||caco_utilities.get_module_text(2093)||'
'); -- 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('
'); -- Parameters htp.p('
'||caco_utilities.get_module_text(2094)||'
'); -- 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(' '); -- htp.p(' '); -- 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(''); caco_system.content_type; htp.p(''); htp.p(' '); htp.p(' '); htp.p(' '); htp.p(' '); htp.p(' '); -- 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('
'); ELSE htp.p('action="efno_contracts.ins_or_upd_template_p1">'); END IF; -- htp.p('
'); -- 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(''); ELSE htp.p(''); END IF; -- l_code_position := '2020'; -- -- Put out all remaining hidden fields htp.p(''); -- IF p_screen_type = 'CONTRACT' THEN htp.p(''); htp.p(''); ELSE -- just need to know if contracts exist for the given template (if one is given! IF contracts_exist THEN htp.p(''); END IF; -- END IF; -- l_code_position := '2030'; -- IF p_screen_type = 'CONTRACT' THEN htp.p('

'||caco_utilities.get_module_text(2271)||'

'); -- Maintain Contract ELSE htp.p('

'||caco_utilities.get_module_text(2089)||'

'); -- 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(' '); -- 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(' '); -- -- Input Format starts the next row of the table htp.p(' '); display_input_format( l_spte_id ); -- -- single table cell separator htp.p(' '); -- display_date_from( l_date_from ); -- End the row and start a new one htp.p(' '); -- display_ops_contact( l_ops_contact ); -- -- single table cell separator htp.p(' '); -- display_date_to( l_date_to ); -- htp.p(' '); -- display_bus_contact( l_bus_contact ); -- -- single table cell separator htp.p(' '); -- display_val_window( l_val_window ); -- htp.p(' '); -- display_days_before( l_days_before ); -- -- single table cell separator htp.p(' '); -- display_val_action( l_val_action ); -- htp.p(' '); -- display_status( l_status ); -- htp.p(' '); -- display_val_exception( l_val_exception ); htp.p(' '); -- display_lookback_action( l_lookback_action ); -- htp.p(''); -- 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('

 
 
 
 
 
'); -- htp.p('''*'''||caco_utilities.get_module_text(2202)||''); -- '*' 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('

'||caco_utilities.get_module_text(2353)||'

'); -- Contract Details ELSE htp.p('

'||caco_utilities.get_module_text(2091)||'

'); -- 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)||'
'); -- Close of div just inside -- -- Close contractFormP1 htp.p('
'); -- Close contractP1_border_div htp.p('
'); -- -- Close centrecontent div htp.p(''); -- 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. -- <> 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('
'); FOR i IN 1..p_array.last LOOP htp.p(i||':'||p_array(i)); htp.p('
'); 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 -- <> 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$; /