1771 lines
62 KiB
Plaintext
1771 lines
62 KiB
Plaintext
CREATE OR REPLACE PACKAGE BODY efnow093$ IS
|
|
--
|
|
--
|
|
FUNCTION validate_array( p_item_name_array IN owa_util.vc_arr
|
|
, p_item_value_array IN owa_util.vc_arr
|
|
, p_message IN OUT VARCHAR2 )
|
|
RETURN BOOLEAN
|
|
IS
|
|
--
|
|
l_return BOOLEAN;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- Have an optimisitc viewpoint
|
|
--
|
|
l_return := TRUE;
|
|
--
|
|
IF p_item_name_array.COUNT < 1 THEN
|
|
--
|
|
l_return := FALSE;
|
|
p_message := caco_utilities.get_module_text(2283);
|
|
-- No paramaters passed
|
|
--
|
|
END IF;
|
|
--
|
|
IF l_return
|
|
AND p_item_value_array.COUNT < 1
|
|
THEN
|
|
--
|
|
l_return := FALSE;
|
|
p_message := caco_utilities.get_module_text(2282);
|
|
-- No paramater values passed
|
|
--
|
|
END IF;
|
|
--
|
|
IF l_return
|
|
AND p_item_value_array.COUNT <> p_item_name_array.COUNT
|
|
THEN
|
|
--
|
|
l_return := FALSE;
|
|
p_message := caco_utilities.get_module_text(2307);
|
|
-- There is a mismatch in parameters and values
|
|
--
|
|
END IF;
|
|
--
|
|
RETURN l_return;
|
|
--
|
|
END validate_array;
|
|
--
|
|
--
|
|
FUNCTION scan_array( p_item_name_array IN owa_util.vc_arr
|
|
, p_item_value_array IN owa_util.vc_arr
|
|
, p_scan_name IN VARCHAR2 )
|
|
RETURN VARCHAR2
|
|
IS
|
|
--
|
|
l_return VARCHAR2(4000) := NULL;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- Loop around all items in the passed array
|
|
--
|
|
FOR i IN p_item_name_array.FIRST .. p_item_name_array.LAST LOOP
|
|
--
|
|
-- Search the array for the passed item
|
|
--
|
|
IF p_item_name_array(i) = p_scan_name THEN
|
|
--
|
|
l_return := p_item_value_array(i);
|
|
--
|
|
END IF;
|
|
--
|
|
END LOOP;
|
|
--
|
|
-- Just return the value - should we distinguish between notfound and no value?
|
|
--
|
|
RETURN l_return;
|
|
--
|
|
END scan_array;
|
|
--
|
|
|
|
|
|
|
|
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 autocomplete_js IS
|
|
BEGIN
|
|
htp.p('// ===================================================================
|
|
// Author: Matt Kruse <matt@mattkruse.com>
|
|
// WWW: http://www.mattkruse.com/
|
|
//
|
|
// NOTICE: You may use this code for any purpose, commercial or
|
|
// private, without any further permission from the author. You may
|
|
// remove this notice from your final code if you wish, however it is
|
|
// appreciated by the author if at least my web site address is kept.
|
|
// ===================================================================
|
|
// -------------------------------------------------------------------
|
|
// autoComplete (text_input, select_input, ["text"|"value"], [true|false])
|
|
// Use this function when you have a SELECT box of values and a text
|
|
// input box with a fill-in value. Often, onChange of the SELECT box
|
|
// will fill in the selected value into the text input (working like
|
|
// a Windows combo box). Using this function, typing into the text
|
|
// box will auto-select the best match in the SELECT box and do
|
|
// auto-complete in supported browsers.
|
|
// Arguments:
|
|
// field = text input field object
|
|
// select = select list object containing valid values
|
|
// property = either "text" or "value". This chooses which of the
|
|
// SELECT properties gets filled into the text box -
|
|
// the ''value'' or ''text'' of the selected option
|
|
// forcematch = true or false. Set to ''true'' to not allow any text
|
|
// in the text box that does not match an option. Only
|
|
// supported in IE (possible future Netscape).
|
|
// -------------------------------------------------------------------
|
|
function autoComplete (field, select, property, forcematch) {
|
|
var found = false;
|
|
for (var i = 0; i < select.options.length; i++) {
|
|
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
|
|
found=true; break;
|
|
}
|
|
}
|
|
if (found) { select.selectedIndex = i; }
|
|
else { select.selectedIndex = -1; }
|
|
if (field.createTextRange) {
|
|
if (forcematch && !found) {
|
|
field.value=field.value.substring(0,field.value.length-1);
|
|
return;
|
|
}
|
|
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
|
|
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
|
|
var r1 = field.createTextRange();
|
|
var oldValue = r1.text;
|
|
var newValue = found ? select.options[i][property] : oldValue;
|
|
if (newValue != field.value) {
|
|
field.value = newValue;
|
|
var rNew = field.createTextRange();
|
|
rNew.moveStart(''character'', oldValue.length) ;
|
|
rNew.select();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
');
|
|
END autocomplete_js;
|
|
|
|
--
|
|
|
|
--
|
|
|
|
PROCEDURE rules_js IS
|
|
BEGIN
|
|
htp.p('
|
|
function addOperator(side, operator) {
|
|
var idName = "p_" + side + "_side";
|
|
var elemId = document.getElementById(idName);
|
|
|
|
elemId.focus();
|
|
elemId.value += operator + " ";
|
|
}
|
|
|
|
|
|
function addToken(side, tokenId) {
|
|
var sideIdName = "p_" + side + "_side";
|
|
|
|
var elemId = document.getElementById(sideIdName);
|
|
elemId.focus();
|
|
|
|
var itemId = document.getElementById(tokenId);
|
|
|
|
if (itemId.selectedIndex >= 0) {
|
|
var tokenValue = itemId.options[itemId.selectedIndex].value;
|
|
|
|
elemId.value += "$<" + tokenValue + "> ";
|
|
}
|
|
}
|
|
|
|
|
|
function ruleReset(side) {
|
|
var elemId = document.getElementById("p_" + side + "_side");
|
|
elemId.focus();
|
|
elemId.value = "";
|
|
}
|
|
|
|
function ruleResetAll() {
|
|
ruleReset(''left'');
|
|
ruleReset(''right'');
|
|
}
|
|
|
|
function clearItem(item) {
|
|
document.getElementById(item).value = "";
|
|
}
|
|
|
|
|
|
function stripSpace (inString) {
|
|
var outString = "";
|
|
for (i = 0; i < inString.length; i++) {
|
|
if (inString.charAt(i) != " " ) {
|
|
outString += inString.charAt(i);
|
|
}
|
|
}
|
|
return outString
|
|
}
|
|
|
|
function createTokenId( value ) {
|
|
var newTokenString = value.toLowerCase();
|
|
newTokenString = stripSpace( newTokenString );
|
|
|
|
return newTokenString;
|
|
}
|
|
|
|
|
|
function changeContractLists() {
|
|
var contract_id = document.getElementById(''p_contract_id'').value;
|
|
var theRuleType = document.getElementById(''p_rule_type'');
|
|
|
|
var selectedRuleType = theRuleType.options[theRuleType.selectedIndex].value;
|
|
|
|
var currentURL = window.location.href;
|
|
|
|
var newURL = currentURL.substr( 0, currentURL.indexOf("startup") + 7);
|
|
|
|
newURL += "?p_item_name_array=P_CATEGORY&p_item_value_array=CONTRACT";
|
|
newURL += "&p_item_name_array=P_CONTRACT_ID&p_item_value_array=" + contract_id;
|
|
newURL += "&p_item_name_array=P_RULE_TYPE&p_item_value_array=" + selectedRuleType;
|
|
|
|
location.href = newURL;
|
|
//location.reload();
|
|
}
|
|
|
|
function confirmUpdate( theText ) {
|
|
//check if they wish to proceed
|
|
var confText = '''||caco_utilities.get_module_text(2229)||''';
|
|
|
|
if (confirm(confText)){
|
|
var theForm = document.getElementById(''ruleform'');
|
|
theForm.submit();
|
|
}
|
|
}
|
|
|
|
');
|
|
END rules_js;
|
|
|
|
|
|
|
|
PROCEDURE m_rules_css IS
|
|
BEGIN
|
|
htp.p('
|
|
#p_rule_name {
|
|
width : 400px;
|
|
}
|
|
|
|
#p_rule_type {
|
|
width : 80px;
|
|
}
|
|
|
|
.rule_err_message {
|
|
width : 500px;
|
|
}
|
|
|
|
//#theRule {
|
|
// background-color : #FEFFE8;
|
|
//}
|
|
|
|
#ruleLeftSide {
|
|
float : left;
|
|
}
|
|
|
|
#ruleRelation {
|
|
float : left;
|
|
text-align : center;
|
|
}
|
|
|
|
.ruleText {
|
|
font-size : 90%;
|
|
}
|
|
|
|
.ruleOp {
|
|
width : 25px;
|
|
height : 25px;
|
|
font-weight : bold;
|
|
}
|
|
|
|
.ruleButtonReset {
|
|
height : 25px;
|
|
font-size : smaller;
|
|
}
|
|
|
|
* {
|
|
-moz-box-sizing : border-box;
|
|
}
|
|
|
|
#ruleTokens {
|
|
position : absolute;
|
|
top : 460px;
|
|
left : 80px;
|
|
width : 640px;
|
|
height : 50px;
|
|
}
|
|
|
|
#ruleSitesDiv {
|
|
position : absolute;
|
|
top : 515px;
|
|
left : 80px;
|
|
width : 640px;
|
|
height : 87px;
|
|
}
|
|
|
|
');
|
|
END m_rules_css;
|
|
|
|
|
|
PROCEDURE display_rule_category( p_category IN VARCHAR2
|
|
, p_contract_id IN NUMBER
|
|
, p_template_id IN NUMBER
|
|
, p_rule_id IN NUMBER
|
|
, p_rule_type IN VARCHAR2 DEFAULT 'ROW' )
|
|
IS
|
|
--
|
|
l_display_name VARCHAR2(50) := NULL;
|
|
--
|
|
-- Cursor to get the Template Name
|
|
CURSOR c_template IS
|
|
SELECT name
|
|
FROM contract_templates
|
|
WHERE cote_id = p_template_id;
|
|
--
|
|
--
|
|
-- Cursor to get the Contract Number
|
|
CURSOR c_contract IS
|
|
SELECT contract_number
|
|
FROM contracts
|
|
WHERE cont_id = p_contract_id;
|
|
--
|
|
BEGIN
|
|
IF UPPER(p_category) = 'TEMPLATE' THEN
|
|
--
|
|
OPEN c_template;
|
|
FETCH c_template INTO l_display_name;
|
|
CLOSE c_template;
|
|
--
|
|
-- Put hidden parameters
|
|
--
|
|
htp.p('<input id="p_template_id" type="hidden" name="p_template_id" value="'||p_template_id||'" />');
|
|
htp.p('<input id="p_contract_id" type="hidden" name="p_contract_id" value="0" />');
|
|
htp.p('<input id="p_coru_id" type="hidden" name="p_coru_id" value="" />');
|
|
htp.p('<input id="p_rule_id" type="hidden" name="p_rule_id" value="'||p_rule_id||'" />');
|
|
--
|
|
-- Display Template Information
|
|
htp.p('
|
|
<table>
|
|
<tr>
|
|
<td><b>'||caco_utilities.get_module_text(2090)||' </b></td>'); -- Contract Template Name
|
|
htp.p(' <td style="border: 1px solid;">'||l_display_name||'</td>
|
|
</tr>
|
|
</table>
|
|
<p />');
|
|
--
|
|
ELSIF UPPER(p_category) = 'CONTRACT' THEN
|
|
--
|
|
OPEN c_contract;
|
|
FETCH c_contract INTO l_display_name;
|
|
CLOSE c_contract;
|
|
--
|
|
-- Put hidden parameters
|
|
--
|
|
htp.p('<input id="p_template_id" type="hidden" name="p_template_id" value="0" />');
|
|
htp.p('<input id="p_contract_id" type="hidden" name="p_contract_id" value="'||p_contract_id||'" />');
|
|
--
|
|
IF p_rule_type = 'ROW' THEN
|
|
htp.p('<input id="p_coru_id" type="hidden" name="p_coru_id" value="" />');
|
|
htp.p('<input id="p_rule_id" type="hidden" name="p_rule_id" value="'||p_rule_id||'" />');
|
|
ELSE
|
|
-- SHEET
|
|
htp.p('<input id="p_coru_id" type="hidden" name="p_coru_id" value="'||p_rule_id||'" />');
|
|
htp.p('<input id="p_rule_id" type="hidden" name="p_rule_id" value="" />');
|
|
END IF;
|
|
--
|
|
-- Display Contract Information
|
|
htp.p('
|
|
<table>
|
|
<tr>
|
|
<td><b>'||caco_utilities.get_module_text(2013)||' </b></td>'); -- Contract Number
|
|
htp.p(' <td style="border: 1px solid;">'||l_display_name||'</td>
|
|
</tr>
|
|
</table>
|
|
<p />');
|
|
--
|
|
ELSE
|
|
-- This is a brand new ROW based rule (as it is not possible to create
|
|
-- a SHEET based rule for anything other than a contract)
|
|
-- So here we need to output just the empty hidden parameters
|
|
--
|
|
htp.p('<input id="p_template_id" type="hidden" name="p_template_id" value="0" />');
|
|
htp.p('<input id="p_contract_id" type="hidden" name="p_contract_id" value="0" />');
|
|
htp.p('<input id="p_coru_id" type="hidden" name="p_coru_id" value="" />');
|
|
htp.p('<input id="p_rule_id" type="hidden" name="p_rule_id" value="'||p_rule_id||'" />');
|
|
--
|
|
END IF;
|
|
END display_rule_category;
|
|
|
|
PROCEDURE get_rule_details( p_category IN VARCHAR
|
|
, p_rule_id IN NUMBER
|
|
, p_rule_record OUT rule_record
|
|
, p_rule_type IN VARCHAR2 DEFAULT 'ROW' )
|
|
IS
|
|
-- Cursor to pull back existing Contract Rule information if contract rule id is supplied.
|
|
CURSOR c_contract_rule IS
|
|
SELECT rule_id
|
|
, rule_name
|
|
, left_side
|
|
, right_side
|
|
, rule_relation
|
|
, error_message_hu
|
|
, error_message_en
|
|
FROM contract_rules
|
|
WHERE coru_id = p_rule_id;
|
|
--
|
|
-- Cursor to pull back ROW based rule info for a given rule_id
|
|
-- Called AFTER c_contract_rule for contracts
|
|
CURSOR c_rule IS
|
|
SELECT rule_id
|
|
, rule_name
|
|
, left_side
|
|
, right_side
|
|
, rule_relation
|
|
, error_message_hu
|
|
, error_message_en
|
|
FROM rules
|
|
WHERE rule_id = p_rule_id;
|
|
--
|
|
BEGIN
|
|
IF p_category = 'TEMPLATE' THEN
|
|
--
|
|
OPEN c_rule;
|
|
FETCH c_rule INTO p_rule_record;
|
|
CLOSE c_rule;
|
|
--
|
|
ELSIF p_category = 'CONTRACT' THEN
|
|
--
|
|
IF p_rule_type = 'ROW' THEN
|
|
--
|
|
OPEN c_rule;
|
|
FETCH c_rule INTO p_rule_record;
|
|
CLOSE c_rule;
|
|
--
|
|
ELSE
|
|
--
|
|
OPEN c_contract_rule;
|
|
FETCH c_contract_rule INTO p_rule_record;
|
|
CLOSE c_contract_rule;
|
|
--
|
|
END IF;
|
|
--
|
|
ELSE
|
|
-- Get a standalone rule
|
|
OPEN c_rule;
|
|
FETCH c_rule INTO p_rule_record;
|
|
CLOSE c_rule;
|
|
--
|
|
END IF;
|
|
END get_rule_details;
|
|
|
|
|
|
|
|
PROCEDURE get_contract_categories( p_contract_id IN NUMBER
|
|
, p_rule_type IN VARCHAR2
|
|
, p_category_array OUT token_array )
|
|
IS
|
|
-- Cursor to generate appropriate Category list for given contract information
|
|
-- for ROW contract rules only
|
|
-- Not to be used at all if the screen has been called from a contract
|
|
-- and the rule is inherited from a contract template
|
|
CURSOR c_contract_row_cat IS
|
|
SELECT cate.name token_name
|
|
, cate.code token_value -- Unique Category Code
|
|
, coca.display_sequence display_sequence -- Used for ordering purposes only
|
|
FROM contract_categories coca
|
|
, categories cate
|
|
WHERE coca.cate_id = cate.cate_id
|
|
AND coca.cont_id = p_contract_id
|
|
ORDER BY coca.display_sequence ASC
|
|
, cate.name;
|
|
--
|
|
--
|
|
-- Cursor to generate appropriate Category list for given contract information
|
|
-- for SHEET contract rules only
|
|
-- Not to be used at all if the screen has been called from a contract
|
|
-- and the rule is inherited from a contract template
|
|
CURSOR c_contract_sheet_cat IS
|
|
SELECT nepo.name||'.'||cate.name||' ('||cate.units||')' token_name -- Will be seen in the select list
|
|
, nepo.code||'.'||cate.code token_value -- Will be the select list value
|
|
, coca.display_sequence coca_display -- Used for ordering
|
|
, conp.display_sequence conp_display -- Used for ordering
|
|
, nepo.name nepo_name -- Used for ordering
|
|
, cate.name cate_name -- Used for ordering
|
|
FROM network_points nepo
|
|
, cont_network_points conp -- Yes. This is a Cartesian Product
|
|
, contract_categories coca -- between the network points and categories
|
|
, categories cate -- Deliberately done.
|
|
WHERE coca.cate_id = cate.cate_id
|
|
AND coca.cont_id = p_contract_id
|
|
AND nepo.nepo_id = conp.nepo_id
|
|
AND conp.cont_id = p_contract_id
|
|
ORDER BY conp.display_sequence
|
|
, nepo.name
|
|
, coca.display_sequence
|
|
, cate.name;
|
|
--
|
|
--
|
|
-- Cursor to generate appropriate network point group Category list for given contract information
|
|
-- for SHEET contract rules only
|
|
--
|
|
CURSOR c_nepg_cat IS
|
|
SELECT nepg.name||'.'||cate.name||' ('||cate.units||')' token_name -- Will be seen in the select list
|
|
, nepg.code||'.'||cate.code token_value -- Will be the select list value
|
|
FROM network_point_groups nepg
|
|
, network_point_mappings nepm
|
|
, network_points nepo
|
|
, cont_network_points conp
|
|
, contract_categories coca
|
|
, categories cate
|
|
WHERE coca.cate_id = cate.cate_id
|
|
AND coca.cont_id = p_contract_id
|
|
AND nepo.nepo_id = conp.nepo_id
|
|
AND conp.cont_id = p_contract_id
|
|
AND nepm.nepo_id = nepo.nepo_id
|
|
AND nepm.nepg_id = nepg.nepg_id
|
|
GROUP BY nepg.name||'.'||cate.name||' ('||cate.units||')'
|
|
, nepg.code||'.'||cate.code
|
|
ORDER BY 1;
|
|
--
|
|
l_count NUMBER := 0;
|
|
BEGIN
|
|
--
|
|
IF p_rule_type = 'SHEET' THEN
|
|
--
|
|
-- add the network point group categories to the array first
|
|
FOR i IN c_nepg_cat LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_category_array(l_count).token_name := i.token_name;
|
|
p_category_array(l_count).token_value := i.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
FOR r IN c_contract_sheet_cat LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_category_array(l_count).token_name := r.token_name;
|
|
p_category_array(l_count).token_value := r.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
ELSE
|
|
--
|
|
FOR r IN c_contract_row_cat LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_category_array(l_count).token_name := r.token_name;
|
|
p_category_array(l_count).token_value := r.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END IF;
|
|
--
|
|
END get_contract_categories;
|
|
|
|
|
|
PROCEDURE get_template_categories( p_template_id IN NUMBER
|
|
, p_category_array OUT token_array )
|
|
IS
|
|
--
|
|
-- Cursor to generate appropriate Category list for given contract TEMPLATE information
|
|
-- Only ROW rules are available for contract templates (no references to network points)
|
|
CURSOR c_template_cat IS
|
|
SELECT cotc.display_sequence -- Used for ordering purposes only
|
|
, cate.name||' ('||cate.units||')' token_name
|
|
, cate.code token_value -- Unique Category Code
|
|
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 ASC
|
|
, cate.name||' ('||cate.units||')'
|
|
, cate.code;
|
|
--
|
|
l_count NUMBER := 0;
|
|
--
|
|
BEGIN
|
|
--
|
|
FOR r IN c_template_cat LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_category_array(l_count).token_name := r.token_name;
|
|
p_category_array(l_count).token_value := r.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END get_template_categories;
|
|
|
|
|
|
PROCEDURE get_all_categories( p_category_array OUT token_array )
|
|
IS
|
|
CURSOR c_categories IS
|
|
SELECT name||' ('||units||')' name
|
|
, code
|
|
FROM categories
|
|
ORDER BY name||' ('||units||')';
|
|
--
|
|
l_count NUMBER := 0;
|
|
--
|
|
BEGIN
|
|
--
|
|
FOR r IN c_categories LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_category_array(l_count).token_name := r.name;
|
|
p_category_array(l_count).token_value := r.code;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END get_all_categories;
|
|
|
|
|
|
PROCEDURE display_categories( p_category_array IN token_array )
|
|
IS
|
|
BEGIN
|
|
--
|
|
--
|
|
htp.p('
|
|
<table>
|
|
<tr>
|
|
<td colspan="2">'||caco_utilities.get_module_text(2134)||'</td>'); -- Category Filter
|
|
htp.p(' <td rowspan="3" valign="middle">
|
|
<input class="insertLeft" type="button" value="<< '
|
|
||caco_utilities.get_module_text(840) -- Insert
|
|
||'" onclick="addToken(''left'',''categoryToken'')" />
|
|
</td>
|
|
<td rowspan="3">
|
|
<select id="categoryToken" size="6" style="width:500px;">
|
|
');
|
|
--
|
|
-- Put out all the options in the supplied array
|
|
--
|
|
FOR i IN 1..p_category_array.COUNT LOOP
|
|
--
|
|
-- Create each select option
|
|
htp.p('<option id="'||p_category_array(i).token_value
|
|
||'" value="'||p_category_array(i).token_value
|
|
||'" >'||p_category_array(i).token_name||'</option>');
|
|
--
|
|
END LOOP;
|
|
--
|
|
-- Close the table
|
|
--
|
|
htp.p(' </select>
|
|
</td>
|
|
<td rowspan="3" valign="middle">
|
|
<input class="insertRight" type="button" value="'
|
|
||caco_utilities.get_module_text(840) -- Insert
|
|
||' >>" onclick="addToken(''right'',''categoryToken'')" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="2" valign="top">
|
|
<input type="text" id="categoryFilter" style="width:103px;"
|
|
onKeyUp="autoComplete(document.getElementById(''categoryFilter'')
|
|
, document.getElementById(''categoryToken''), ''text'', true);" />
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
');
|
|
--
|
|
END display_categories;
|
|
|
|
--
|
|
--
|
|
|
|
PROCEDURE get_standard_params( p_index IN OUT NUMBER
|
|
, p_parameter_array IN OUT token_array )
|
|
IS
|
|
BEGIN
|
|
-- Add standard parameters
|
|
p_index := p_index + 1;
|
|
--
|
|
--
|
|
p_parameter_array(p_index).token_name := 'Hours In Gas Day';
|
|
p_parameter_array(p_index).token_value := 'hours_in_gas_day';
|
|
--
|
|
--
|
|
-- Add any new standard parameters below this comment
|
|
--
|
|
END get_standard_params;
|
|
--
|
|
|
|
PROCEDURE get_contract_parameters( p_contract_id IN NUMBER
|
|
, p_rule_type IN VARCHAR2
|
|
, p_parameter_array OUT token_array )
|
|
IS
|
|
--
|
|
-- Cursor to generate appropriate Parameter list for given contract information
|
|
-- for ROW contract rules only
|
|
-- Not to be used at all if the screen has been called from a contract
|
|
-- and the rule is inherited from a contract template
|
|
CURSOR c_contract_row_par IS
|
|
SELECT token_name
|
|
, token_value
|
|
FROM
|
|
(
|
|
SELECT pars.name token_name
|
|
, pars.code token_value
|
|
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
|
|
UNION ALL
|
|
SELECT pars.name||' ('||cate.units||')' token_name
|
|
, pars.code token_value
|
|
FROM contract_parameters copa
|
|
, parameters pars
|
|
, categories cate
|
|
WHERE copa.pars_id = pars.pars_id
|
|
AND pars.cate_id = cate.cate_id
|
|
AND copa.cont_id = p_contract_id
|
|
)
|
|
ORDER BY token_name;
|
|
--
|
|
--
|
|
-- Cursor to generate appropriate Parameter list for given contract information
|
|
-- for SHEET contract rules only
|
|
-- Not to be used at all if the screen has been called from a contract
|
|
-- and the rule is inherited from a contract template
|
|
CURSOR c_contract_sheet_par IS
|
|
SELECT token_name
|
|
, token_value
|
|
FROM
|
|
(
|
|
SELECT nepo.name||'.'||pars.name token_name -- Will be seen in the select list
|
|
, nepo.code||'.'||pars.code token_value -- Will be the select list value
|
|
FROM network_points nepo
|
|
, cont_network_points conp -- Yes. This is a Cartesian Product
|
|
, contract_parameters copa -- between the network points and parameters
|
|
, parameters pars -- Deliberately done.
|
|
WHERE copa.pars_id = pars.pars_id
|
|
AND copa.cont_id = p_contract_id
|
|
AND nepo.nepo_id = conp.nepo_id
|
|
AND conp.cont_id = p_contract_id
|
|
AND pars.cate_id IS NULL
|
|
UNION ALL
|
|
SELECT nepo.name||'.'||pars.name||' ('||cate.units||')' token_name -- Will be seen in the select list
|
|
, nepo.code||'.'||pars.code token_value -- Will be the select list value
|
|
FROM network_points nepo
|
|
, cont_network_points conp -- Yes. This is a Cartesian Product
|
|
, contract_parameters copa -- between the network points and parameters
|
|
, parameters pars -- Deliberately done.
|
|
, categories cate
|
|
WHERE copa.pars_id = pars.pars_id
|
|
AND copa.cont_id = p_contract_id
|
|
AND cate.cate_id = pars.cate_id
|
|
AND nepo.nepo_id = conp.nepo_id
|
|
AND conp.cont_id = p_contract_id
|
|
)
|
|
ORDER BY token_name;
|
|
--
|
|
-- Cursor to generate appropriate network point group parameter list for a given contract
|
|
-- for SHEET contract rules only
|
|
--
|
|
CURSOR c_npgp IS
|
|
SELECT nepg.name||'.'||npgp.name token_name -- Will be seen in the select list
|
|
, nepg.code||'.'||npgp.code token_value -- Will be the select list value
|
|
FROM network_point_groups nepg
|
|
, network_point_gp_params npgp
|
|
WHERE nepg.nepg_id = npgp.nepg_id
|
|
AND npgp.cont_id = p_contract_id;
|
|
--
|
|
l_count NUMBER := 0;
|
|
--
|
|
BEGIN
|
|
-- Add any standard Parameters
|
|
--
|
|
get_standard_params( l_count, p_parameter_array );
|
|
--
|
|
--
|
|
IF p_rule_type = 'SHEET' THEN
|
|
-- add network point group parameters to array first
|
|
FOR i IN c_npgp LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_parameter_array(l_count).token_name := i.token_name;
|
|
p_parameter_array(l_count).token_value := i.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
FOR r IN c_contract_sheet_par LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_parameter_array(l_count).token_name := r.token_name;
|
|
p_parameter_array(l_count).token_value := r.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
ELSE
|
|
--
|
|
FOR r IN c_contract_row_par LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_parameter_array(l_count).token_name := r.token_name;
|
|
p_parameter_array(l_count).token_value := r.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END IF;
|
|
--
|
|
END get_contract_parameters;
|
|
|
|
|
|
PROCEDURE get_template_parameters( p_template_id IN NUMBER
|
|
, p_parameter_array OUT token_array )
|
|
IS
|
|
--
|
|
-- Cursor to generate appropriate Parameter list for given contract TEMPLATE information
|
|
-- Only ROW rules are available for contract templates (no references to network points)
|
|
CURSOR c_template_par IS
|
|
SELECT token_name
|
|
, token_value
|
|
FROM
|
|
(
|
|
SELECT pars.name token_name
|
|
, pars.code token_value
|
|
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
|
|
UNION ALL
|
|
SELECT pars.name||' ('||cate.units||')' token_name
|
|
, pars.code token_value
|
|
FROM contract_template_params cotp
|
|
, parameters pars
|
|
, categories cate
|
|
WHERE cotp.pars_id = pars.pars_id
|
|
AND pars.cate_id = cate.cate_id
|
|
AND cotp.cote_id = p_template_id
|
|
)
|
|
ORDER BY token_name;
|
|
--
|
|
l_count NUMBER := 0;
|
|
--
|
|
BEGIN
|
|
-- Add any standard Parameters
|
|
--
|
|
get_standard_params( l_count, p_parameter_array );
|
|
--
|
|
--
|
|
FOR r IN c_template_par LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_parameter_array(l_count).token_name := r.token_name;
|
|
p_parameter_array(l_count).token_value := r.token_value;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END get_template_parameters;
|
|
|
|
|
|
PROCEDURE get_all_parameters( p_parameter_array OUT token_array )
|
|
IS
|
|
CURSOR c_parameters IS
|
|
SELECT name
|
|
, code
|
|
FROM
|
|
(
|
|
SELECT pars.name name
|
|
, pars.code code
|
|
FROM parameters pars
|
|
WHERE pars.cate_id IS NULL
|
|
UNION ALL
|
|
SELECT pars.name||' ('||cate.units||')'
|
|
, pars.code
|
|
FROM parameters pars
|
|
, categories cate
|
|
WHERE pars.cate_id = cate.cate_id
|
|
)
|
|
ORDER BY name
|
|
, code;
|
|
--
|
|
l_count NUMBER := 0;
|
|
--
|
|
BEGIN
|
|
-- Add any standard Parameters
|
|
--
|
|
get_standard_params( l_count, p_parameter_array );
|
|
--
|
|
--
|
|
FOR r IN c_parameters LOOP
|
|
--
|
|
l_count := l_count + 1;
|
|
--
|
|
p_parameter_array(l_count).token_name := r.name;
|
|
p_parameter_array(l_count).token_value := r.code;
|
|
--
|
|
END LOOP;
|
|
--
|
|
END get_all_parameters;
|
|
|
|
|
|
PROCEDURE display_parameters( p_parameter_array IN token_array )
|
|
IS
|
|
BEGIN
|
|
--
|
|
--
|
|
htp.p('
|
|
<table>
|
|
<tr>
|
|
<td colspan="2">'||caco_utilities.get_module_text(2135)||'</td>
|
|
<td rowspan="3" valign="middle">
|
|
<input class="insertLeft" type="button" value="<< '
|
|
||caco_utilities.get_module_text(840) -- Insert
|
|
||'" onclick="addToken(''left'',''parameterToken'')" />
|
|
</td>
|
|
<td rowspan="3">
|
|
<select id="parameterToken" size="6" style="width:500px;">
|
|
');
|
|
--
|
|
-- Put out all the options in the supplied array
|
|
--
|
|
FOR i IN 1..p_parameter_array.COUNT LOOP
|
|
--
|
|
-- Create each select option
|
|
htp.p('<option id="'||p_parameter_array(i).token_value
|
|
||'" value="'||p_parameter_array(i).token_value
|
|
||'" >'||p_parameter_array(i).token_name||'</option>');
|
|
--
|
|
END LOOP;
|
|
--
|
|
-- Close the table
|
|
--
|
|
htp.p(' </select>
|
|
</td>
|
|
<td rowspan="3" valign="middle">
|
|
<input class="insertRight" type="button" value="'
|
|
||caco_utilities.get_module_text(840) -- Insert
|
|
||' >>" onclick="addToken(''right'',''parameterToken'')" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="2" valign="top">
|
|
<input type="text" id="parameterFilter" style="width:103px;"
|
|
onKeyUp="autoComplete(document.getElementById(''parameterFilter'')
|
|
, document.getElementById(''parameterToken''), ''text'', true);" />
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
');
|
|
--
|
|
END display_parameters;
|
|
|
|
--
|
|
--
|
|
|
|
PROCEDURE display_buttons( p_ins_or_upd IN VARCHAR2
|
|
, p_screen_category IN VARCHAR2
|
|
, p_rule_id IN NUMBER DEFAULT 0
|
|
, p_contract_id IN NUMBER DEFAULT 0
|
|
, p_template_id IN NUMBER DEFAULT 0 )
|
|
IS
|
|
-- Cursor to see if contracts or OTHER contract templates have this rule
|
|
CURSOR c_coru IS
|
|
SELECT 'X'
|
|
FROM contract_rules coru
|
|
, contracts cont
|
|
WHERE coru.cont_id = cont.cont_id
|
|
AND NVL(coru.rule_id,-1) = p_rule_id
|
|
UNION ALL
|
|
SELECT 'X'
|
|
FROM contract_template_rules
|
|
WHERE rule_id = p_rule_id
|
|
AND cote_id != p_template_id;
|
|
--
|
|
-- Cursor to find any contracts/contract templates that have this rule
|
|
CURSOR c_cotr IS
|
|
SELECT 'X'
|
|
FROM contract_template_rules cotr
|
|
, contracts cont
|
|
WHERE cotr.cote_id = cont.cote_id
|
|
AND cont.cont_id != p_contract_id
|
|
AND cotr.rule_id = p_rule_id
|
|
UNION ALL
|
|
SELECT 'X'
|
|
FROM contract_rules coru
|
|
, contracts cont
|
|
WHERE coru.cont_id = cont.cont_id
|
|
AND coru.cont_id != p_contract_id
|
|
AND NVL(coru.rule_id,-1) = p_rule_id;
|
|
--
|
|
-- Cursor to see if ANY contracts or templates have this rule (if updating standalone)
|
|
CURSOR c_rules IS
|
|
SELECT 'X'
|
|
FROM contract_rules
|
|
WHERE NVL(rule_id,-1) = p_rule_id
|
|
UNION ALL
|
|
SELECT 'X'
|
|
FROM contract_template_rules
|
|
WHERE rule_id = p_rule_id;
|
|
--
|
|
l_url VARCHAR2(255) := NULL;
|
|
l_dummy VARCHAR2(1) := 'X';
|
|
--
|
|
BEGIN
|
|
--
|
|
IF p_ins_or_upd = 'INSERT' THEN
|
|
--
|
|
htp.p('<input type="submit" value="'||caco_utilities.get_module_text(840)||'" />'); -- Insert
|
|
--
|
|
END IF;
|
|
--
|
|
-- Set the cancel button to return to the calling page
|
|
-- we can work this out from the passed parameters
|
|
IF p_screen_category = 'TEMPLATE' THEN
|
|
--
|
|
IF p_ins_or_upd = 'UPDATE' THEN
|
|
-- check if any contracts not on this template have this rule
|
|
OPEN c_coru;
|
|
FETCH c_coru INTO l_dummy;
|
|
IF c_coru%FOUND THEN
|
|
htp.p('<input type="button" value="'||caco_utilities.get_module_text(837)||'" onclick="confirmUpdate();" />'); -- Update
|
|
ELSE
|
|
htp.p('<input type="submit" value="'||caco_utilities.get_module_text(837)||'" />'); -- Update
|
|
END IF;
|
|
CLOSE c_coru;
|
|
--
|
|
END IF;
|
|
--
|
|
l_url := dad_path||'efnow050$.template_rules?p_template_id='||p_template_id;
|
|
--
|
|
ELSIF p_screen_category = 'CONTRACT' THEN
|
|
--
|
|
IF p_ins_or_upd = 'UPDATE' THEN
|
|
-- check if any other contracts or templates have this rule
|
|
OPEN c_cotr;
|
|
FETCH c_cotr INTO l_dummy;
|
|
IF c_cotr%FOUND THEN
|
|
htp.p('<input type="button" value="'||caco_utilities.get_module_text(837)||'" onclick="confirmUpdate();" />'); -- Update
|
|
ELSE
|
|
htp.p('<input type="submit" value="'||caco_utilities.get_module_text(837)||'" />'); -- Update
|
|
END IF;
|
|
CLOSE c_cotr;
|
|
--
|
|
END IF;
|
|
--
|
|
l_url := dad_path||'efnow050$.contract_rules?p_contract_id='||p_contract_id;
|
|
--
|
|
ELSE
|
|
IF p_ins_or_upd = 'UPDATE' THEN
|
|
-- Check if the rule is used ANYwhere
|
|
OPEN c_rules;
|
|
FETCH c_rules INTO l_dummy;
|
|
IF c_rules%FOUND THEN
|
|
htp.p('<input type="button" value="'||caco_utilities.get_module_text(837)||'" onclick="confirmUpdate();" />'); -- Update
|
|
ELSE
|
|
htp.p('<input type="submit" value="'||caco_utilities.get_module_text(837)||'" />'); -- Update
|
|
END IF;
|
|
CLOSE c_rules;
|
|
--
|
|
END IF;
|
|
--
|
|
-- Rules screen called from main menu - just go home.
|
|
l_url := dad_path||'efnow080$.startup';
|
|
--
|
|
END IF;
|
|
--
|
|
htp.p('<input type="button" value="'||caco_utilities.get_module_text(993)||'" onclick="location.href='''||l_url||'''" />'); -- Cancel
|
|
--
|
|
END display_buttons;
|
|
|
|
--
|
|
--
|
|
|
|
PROCEDURE startup( p_item_name_array IN owa_util.vc_arr DEFAULT g_vc_arr
|
|
, p_item_value_array IN owa_util.vc_arr DEFAULT g_vc_arr )
|
|
IS
|
|
--
|
|
l_rule_record rule_record;
|
|
--
|
|
l_error_message VARCHAR2(100);
|
|
--
|
|
l_rule_category VARCHAR2(8) := NULL;
|
|
l_template_id NUMBER := 0;
|
|
l_contract_id NUMBER := 0;
|
|
l_rule_id NUMBER := 0;
|
|
l_button_rule_id NUMBER := 0;
|
|
l_contract_rule_type VARCHAR2(5) := 'ROW';
|
|
--
|
|
l_ins_or_upd VARCHAR2(6) := 'INSERT';
|
|
--
|
|
category_array token_array;
|
|
parameter_array token_array;
|
|
--
|
|
l_success VARCHAR2(1) := NULL;
|
|
--
|
|
-- Variables used when an error has occurred whilst trying to insert or update a rule
|
|
-- _re_ - stands for rule_error (a shortening)
|
|
--
|
|
l_rule_error VARCHAR2(1) := NULL;
|
|
l_re_message VARCHAR2(250) := NULL;
|
|
l_re_ins_or_upd VARCHAR2(6) := NULL;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- Check we have permission to be using this module.
|
|
IF NOT caco_security.security_check(g_package_name) THEN
|
|
RETURN;
|
|
END IF;
|
|
--
|
|
caco_debug.putline('efnow093$.startup');
|
|
--
|
|
-- Ensure any passed parameres are correct
|
|
--
|
|
IF validate_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_message => l_error_message )
|
|
THEN
|
|
--
|
|
-- Look for what type of screen we have
|
|
--
|
|
-- Find out if this was inserted or updated and had an error
|
|
--
|
|
l_rule_error := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_ERROR' );
|
|
--
|
|
IF l_rule_error IS NOT NULL
|
|
AND l_rule_error = 'Y'
|
|
THEN
|
|
--
|
|
-- Get the error message
|
|
l_re_message := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_ERR_MSG' );
|
|
--
|
|
-- We need to build the page according to the returned error data
|
|
-- This will be the originally submitted information
|
|
--
|
|
-- Find insert or update
|
|
l_re_ins_or_upd := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_INS_OR_UPD' );
|
|
--
|
|
IF l_re_ins_or_upd IS NOT NULL THEN
|
|
l_ins_or_upd := l_re_ins_or_upd;
|
|
END IF;
|
|
--
|
|
-- Find the template id
|
|
l_template_id := TO_NUMBER( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_TEMPLATE_ID' ) );
|
|
--
|
|
IF l_template_id IS NOT NULL
|
|
AND l_template_id > 0
|
|
THEN
|
|
l_rule_category := 'TEMPLATE';
|
|
END IF;
|
|
--
|
|
-- Find the contract id
|
|
l_contract_id := TO_NUMBER( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_CONTRACT_ID' ) );
|
|
--
|
|
IF l_contract_id IS NOT NULL
|
|
AND l_contract_id > 0
|
|
THEN
|
|
l_rule_category := 'CONTRACT';
|
|
END IF;
|
|
--
|
|
-- Find the Rule id
|
|
l_rule_id := TO_NUMBER( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_ID' ) );
|
|
--
|
|
IF l_rule_id IS NULL
|
|
OR l_rule_id = 0
|
|
THEN
|
|
-- Find the Contract Rule Id
|
|
l_rule_id := TO_NUMBER( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_CORU_ID' ) );
|
|
END IF;
|
|
--
|
|
-- Find the rule name
|
|
l_rule_record.rule_name := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_NAME' );
|
|
--
|
|
-- Find the rule type
|
|
l_contract_rule_type := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_TYPE' );
|
|
--
|
|
IF l_contract_rule_type IS NULL THEN
|
|
l_contract_rule_type := 'ROW';
|
|
END IF;
|
|
--
|
|
-- Find the Hungarian error message
|
|
l_rule_record.err_message_hu := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_ERR_MESSAGE_HU' );
|
|
--
|
|
-- Find the English error message
|
|
l_rule_record.err_message_en := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_ERR_MESSAGE_EN' );
|
|
--
|
|
-- Find the left side text
|
|
l_rule_record.left_side := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_LEFT_SIDE' );
|
|
--
|
|
-- Find the Rule Relation
|
|
l_rule_record.rule_relation := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_RELATION' );
|
|
--
|
|
-- Find the Right side text
|
|
l_rule_record.right_side := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RIGHT_SIDE' );
|
|
--
|
|
ELSE
|
|
-- Not an error - check for non-error name value pairs
|
|
--
|
|
-- Was this a successful Insert or Update?
|
|
l_success := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_SUCCESS' );
|
|
--
|
|
--
|
|
l_rule_category := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_CATEGORY' );
|
|
--
|
|
IF l_rule_category = 'TEMPLATE' THEN
|
|
--
|
|
-- Get the template id
|
|
--
|
|
l_template_id := to_number( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_TEMPLATE_ID' ) );
|
|
--
|
|
IF l_template_id IS NOT NULL AND l_template_id > 0 THEN
|
|
--
|
|
-- Get the Appropriate rule data
|
|
--
|
|
l_rule_id := to_number( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_ID' ) );
|
|
--
|
|
IF l_rule_id IS NOT NULL AND l_rule_id > 0 THEN
|
|
--
|
|
-- An existing Rule - we are Updating
|
|
--
|
|
l_ins_or_upd := 'UPDATE';
|
|
--
|
|
-- need to go get all the rule details for showing later
|
|
--
|
|
get_rule_details( 'TEMPLATE'
|
|
, l_rule_id
|
|
, l_rule_record );
|
|
--
|
|
ELSE
|
|
--
|
|
-- No Rule supplied - must be creating a new one
|
|
--
|
|
l_ins_or_upd := 'INSERT';
|
|
--
|
|
END IF;
|
|
END IF;
|
|
--
|
|
ELSIF l_rule_category = 'CONTRACT' THEN
|
|
--
|
|
-- Get the contract id
|
|
--
|
|
l_contract_id := to_number( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_CONTRACT_ID' ) );
|
|
--
|
|
IF l_contract_id IS NOT NULL AND l_contract_id > 0 THEN
|
|
--
|
|
-- Get the Appropriate rule data
|
|
--
|
|
l_rule_id := to_number( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_ID' ) );
|
|
--
|
|
IF l_rule_id IS NULL or l_rule_id = 0 THEN
|
|
--
|
|
-- Rule will be a SHEET contract rule
|
|
--
|
|
l_rule_id := to_number( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_CORU_ID' ) );
|
|
--
|
|
l_contract_rule_type := 'SHEET';
|
|
--
|
|
END IF;
|
|
--
|
|
IF l_rule_id IS NOT NULL AND l_rule_id > 0 THEN
|
|
--
|
|
-- An existing Rule - we are Updating
|
|
--
|
|
l_ins_or_upd := 'UPDATE';
|
|
--
|
|
-- need to go get all the rule details for showing later
|
|
--
|
|
get_rule_details( 'CONTRACT'
|
|
, l_rule_id
|
|
, l_rule_record
|
|
, l_contract_rule_type );
|
|
--
|
|
ELSE
|
|
--
|
|
-- No Rule supplied - must be creating a new one
|
|
--
|
|
l_ins_or_upd := 'INSERT';
|
|
--
|
|
-- See if the rule type was passed (as this determines what categories and parameters are available
|
|
l_contract_rule_type := scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_TYPE' );
|
|
-- Entry Mandatory Offer Contracts can only create SHEET Rules
|
|
IF efno_contracts.emo_contract(l_contract_id) = 'Y' THEN
|
|
l_contract_rule_type := 'SHEET';
|
|
END IF;
|
|
--
|
|
END IF;
|
|
END IF; -- End of contract id not null or zero
|
|
--
|
|
ELSE
|
|
-- Not from template or contract - check if a standalone rule
|
|
--
|
|
-- Get the Appropriate rule data
|
|
--
|
|
l_rule_id := to_number( scan_array( p_item_name_array => p_item_name_array
|
|
, p_item_value_array => p_item_value_array
|
|
, p_scan_name => 'P_RULE_ID' ) );
|
|
--
|
|
IF l_rule_id IS NOT NULL AND l_rule_id > 0 THEN
|
|
--
|
|
-- An existing Rule - we are Updating
|
|
--
|
|
l_ins_or_upd := 'UPDATE';
|
|
--
|
|
-- need to go get all the rule details for showing later
|
|
--
|
|
get_rule_details( NULL -- Standalone rule
|
|
, l_rule_id
|
|
, l_rule_record
|
|
, l_contract_rule_type );
|
|
--
|
|
ELSE
|
|
--
|
|
-- No Rule supplied - must be creating a new one
|
|
--
|
|
l_ins_or_upd := 'INSERT';
|
|
--
|
|
END IF;
|
|
END IF; --End of category check
|
|
--
|
|
END IF; -- Error or not
|
|
--
|
|
ELSE
|
|
-- Duff parameters...
|
|
l_rule_category := 'NONE';
|
|
--
|
|
END IF;
|
|
--
|
|
--
|
|
-- htp.p('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
|
|
-- htp.p(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
|
|
-- htp.p(chr(10)||'<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">');
|
|
--
|
|
wsgl.openpagehead(g_title);
|
|
--wsgl.metatag;
|
|
--htp.p('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
|
|
caco_system.content_type;
|
|
htp.p(chr(10)||'<LINK REL=stylesheet HREF="caco_system.css?p_type=content" >');
|
|
htp.p(chr(10)||'<script type="text/javascript" src="efnow093$.rules_js"></script>');
|
|
htp.p(chr(10)||'<script type="text/javascript" src="efnow093$.autocomplete_js"></script>');
|
|
htp.p(chr(10)||'<link rel="stylesheet" media="all" type="text/css" href="efnow093$.m_rules_css" />');
|
|
--
|
|
--
|
|
wsgl.closepagehead;
|
|
wsgl.openpagebody(FALSE);
|
|
htp.p(caco_system.menu);
|
|
--
|
|
--
|
|
-- Here comes the fun bit. Or should that be the 'slightly more complicated' bit?
|
|
--
|
|
-- Put out the screen title in a bordered div
|
|
htp.p('
|
|
<div id="rule_border_div" style="margin:15px;">
|
|
<form id="ruleform" name="ruleform" method="POST" action="efno_rules.insert_or_update_rule">
|
|
<div>
|
|
<h1>'||caco_utilities.get_module_text(2125)||'</h1>'); -- Maintain Rule
|
|
--
|
|
-- Put out success or error messages from completed or failed insert/update
|
|
--
|
|
IF l_success = 'Y' THEN
|
|
htp.p('<b><font size="+2" color="#008000"><i>'||caco_utilities.get_module_text(876)||'</i></font><br /></b><p></p>'); -- Success!
|
|
ELSIF l_rule_error = 'Y' THEN
|
|
htp.p('<b><font size="+2" color="#800000"><i>');
|
|
IF l_ins_or_upd = 'INSERT' THEN
|
|
htp.p(caco_utilities.get_module_text(2334)); -- Insert failed
|
|
ELSE
|
|
htp.p(caco_utilities.get_module_text(2340)); -- Update failed
|
|
END IF;
|
|
htp.p('</i></font><br /></b>');
|
|
htp.p('<b>'||l_re_message||'<br /></b><p></p>');
|
|
END IF;
|
|
--
|
|
--
|
|
-- Put a hidden parameter out showing whether we are inserting or updating
|
|
--
|
|
htp.p('<input id="p_ins_or_upd" type="hidden" name="p_ins_or_upd" value="'||l_ins_or_upd||'" />');
|
|
--
|
|
-- Display the category and relevant info
|
|
--
|
|
display_rule_category( l_rule_category
|
|
, l_contract_id
|
|
, l_template_id
|
|
, l_rule_id
|
|
, l_contract_rule_type );
|
|
--
|
|
--
|
|
-- Now display the Rule name
|
|
--
|
|
htp.p('
|
|
<table>
|
|
<tr>
|
|
<td><b>'||caco_utilities.get_module_text(2106)||' * </b></td>'); -- Rule Name
|
|
htp.p(' <td>
|
|
<input id="p_rule_name" name="p_rule_name" type="text" value="'||l_rule_record.rule_name||'" maxlength="50" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>'||caco_utilities.get_module_text(2126)||' * </td>
|
|
<td>'); -- Rule Type
|
|
--
|
|
-- Put out the Rule Type
|
|
IF l_rule_category = 'CONTRACT' THEN
|
|
--
|
|
-- IF Inserting, then the User can choose - otherwise it's fixed as existing
|
|
IF l_ins_or_upd = 'UPDATE' THEN
|
|
--
|
|
-- Check the type to show EN or HU
|
|
htp.p('<input name="p_rule_type" type="hidden" value="'||l_contract_rule_type||'" />');
|
|
IF NVL(l_contract_rule_type,'ROW') = 'ROW' THEN
|
|
htp.p('<input id="p_rule_type" type="text" value="'||caco_utilities.get_module_text(887)||'" onFocus="document.getElementById(''p_err_message_hu'').focus()" />'); -- Row
|
|
ELSE
|
|
htp.p('<input id="p_rule_type" type="text" value="'||caco_utilities.get_module_text(2418)||'" onFocus="document.getElementById(''p_err_message_hu'').focus()" />'); -- Sheet
|
|
END IF;
|
|
--
|
|
ELSE
|
|
--
|
|
htp.p('<select id="p_rule_type" name="p_rule_type" size="1" onchange="changeContractLists();">');
|
|
-- Entry Mandatory Offer Contracts can only create SHEET Rules
|
|
IF efno_contracts.emo_contract(l_contract_id) = 'Y' THEN
|
|
htp.p('<option selected value="SHEET">'||caco_utilities.get_module_text(2418)||'</option>'); -- Sheet
|
|
ELSE
|
|
IF NVL(l_contract_rule_type,'ROW') = 'ROW' THEN
|
|
htp.p('<option selected value="ROW">'||caco_utilities.get_module_text(887)||'</option>'); -- Row
|
|
htp.p('<option value="SHEET">'||caco_utilities.get_module_text(2418)||'</option>'); -- Sheet
|
|
ELSE
|
|
htp.p('<option value="ROW">'||caco_utilities.get_module_text(887)||'</option>'); -- Row
|
|
htp.p('<option selected value="SHEET">'||caco_utilities.get_module_text(2418)||'</option>'); -- Sheet
|
|
END IF;
|
|
END IF;
|
|
htp.p('</select>');
|
|
--
|
|
END IF;
|
|
--
|
|
ELSE
|
|
-- The rule type becomes fixed to ROW
|
|
htp.p('<input name="p_rule_type" type="hidden" value="ROW" />');
|
|
htp.p('<input id="p_rule_type" type="text" value="'||caco_utilities.get_module_text(887)||'" onFocus="document.getElementById(''p_err_message_hu'').focus()" />'); -- Row
|
|
--
|
|
END IF;
|
|
--
|
|
htp.p('</td></tr>');
|
|
--
|
|
-- Error message inputs
|
|
--
|
|
htp.p('
|
|
<tr>
|
|
<td>'||caco_utilities.get_module_text(2127)||' * </td>'); -- Error message (HU)
|
|
htp.p(' <td>
|
|
<input name="p_err_message_hu" type="text" class="rule_err_message" maxlength="250"
|
|
id="p_err_message_hu" value="'||l_rule_record.err_message_hu||'" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>'||caco_utilities.get_module_text(2128)||' * </td>'); -- Error Message (EN)
|
|
htp.p(' <td>
|
|
<input name="p_err_message_en" type="text" class="rule_err_message" maxlength="250"
|
|
id="p_err_message_en" value="'||l_rule_record.err_message_en||'" />
|
|
</td>
|
|
</tr>
|
|
');
|
|
--
|
|
-- Close the Rule specific heading table
|
|
--
|
|
htp.p('</table><br />');
|
|
--
|
|
--
|
|
-- Now move on to the left and right sides and rule relation layout.
|
|
htp.p('
|
|
<div id="theRule">
|
|
<div id="ruleLeftSide">
|
|
'||caco_utilities.get_module_text(2129)||' * <br />'); -- Left Side
|
|
htp.p(' <textarea class="ruleText" name="p_left_side" id="p_left_side" rows=11 cols=43 maxlength="4000">'
|
|
||l_rule_record.left_side||'</textarea><br />
|
|
<input class="ruleOp" type="button" value="+" onclick="addOperator(''left'', ''+'')" />
|
|
<input class="ruleOp" type="button" value="-" onclick="addOperator(''left'', ''-'')" />
|
|
<input class="ruleOp" type="button" value="*" onclick="addOperator(''left'', ''*'')" />
|
|
<input class="ruleOp" type="button" value="/" onclick="addOperator(''left'', ''/'')" />
|
|
<input class="ruleOp" type="button" value="(" onclick="addOperator(''left'', ''('')" />
|
|
<input class="ruleOp" type="button" value=")" onclick="addOperator(''left'', '')'')" />
|
|
<input class="ruleButtonReset" type="button" value="'
|
|
||caco_utilities.get_module_text(2419) -- Clear Left
|
|
||'" onclick="ruleReset(''left'')" />
|
|
</div>
|
|
|
|
<div id="ruleRelation">
|
|
<br /><br /><br />
|
|
<p style="text-align:center;">'||caco_utilities.get_module_text(2131)||'</p>'); -- Rule Relation
|
|
htp.p(' <select id="p_rule_relation" name="p_rule_relation" size="1">
|
|
');
|
|
--
|
|
IF l_rule_record.rule_relation = '<'
|
|
OR l_rule_record.rule_relation IS NULL
|
|
THEN
|
|
htp.p('<option selected value="<"><</option>');
|
|
ELSE
|
|
htp.p('<option value="<"><</option>');
|
|
END IF;
|
|
--
|
|
IF l_rule_record.rule_relation = '<=' THEN
|
|
htp.p('<option selected value="<="><=</option>');
|
|
ELSE
|
|
htp.p('<option value="<="><=</option>');
|
|
END IF;
|
|
--
|
|
IF l_rule_record.rule_relation = '>' THEN
|
|
htp.p('<option selected value=">">></option>');
|
|
ELSE
|
|
htp.p('<option value=">">></option>');
|
|
END IF;
|
|
--
|
|
IF l_rule_record.rule_relation = '>=' THEN
|
|
htp.p('<option selected value=">=">>=</option>');
|
|
ELSE
|
|
htp.p('<option value=">=">>=</option>');
|
|
END IF;
|
|
--
|
|
IF l_rule_record.rule_relation = '=' THEN
|
|
htp.p('<option selected value="=">=</option>');
|
|
ELSE
|
|
htp.p('<option value="=">=</option>');
|
|
END IF;
|
|
--
|
|
IF l_rule_record.rule_relation = '!=' THEN
|
|
htp.p('<option selected value="!=">!=</option>');
|
|
ELSE
|
|
htp.p('<option value="!=">!=</option>');
|
|
END IF;
|
|
--
|
|
htp.p('
|
|
</select>
|
|
<br /><br /><br />
|
|
<input type="button" class="ruleButtonReset" value="'
|
|
||caco_utilities.get_module_text(2420) -- Clear Both
|
|
||'" style="text-align:center;" onclick="ruleResetAll()" />
|
|
<br /><br /><br />
|
|
<br /><br />
|
|
</div>
|
|
|
|
<div id="ruleRightSide">
|
|
'||caco_utilities.get_module_text(2130)||' * <br />'); -- Right Side
|
|
htp.p(' <textarea class="ruleText" name="p_right_side" id="p_right_side" rows=11 cols=43 maxlength="4000">'
|
|
||l_rule_record.right_side||'</textarea><br />
|
|
<input class="ruleOp" type="button" value="+" onclick="addOperator(''right'', ''+'')" />
|
|
<input class="ruleOp" type="button" value="-" onclick="addOperator(''right'', ''-'')" />
|
|
<input class="ruleOp" type="button" value="*" onclick="addOperator(''right'', ''*'')" />
|
|
<input class="ruleOp" type="button" value="/" onclick="addOperator(''right'', ''/'')" />
|
|
<input class="ruleOp" type="button" value="(" onclick="addOperator(''right'', ''('')" />
|
|
<input class="ruleOp" type="button" value=")" onclick="addOperator(''right'', '')'')" />
|
|
<input class="ruleButtonReset" type="button" value="'
|
|
||caco_utilities.get_module_text(2421) -- Clear Right
|
|
||'" onclick="ruleReset(''right'')" />
|
|
</div>
|
|
</div>
|
|
<br />
|
|
');
|
|
--
|
|
--
|
|
-- Now lets go and get the options available for categories
|
|
IF l_rule_category = 'CONTRACT' THEN
|
|
--
|
|
get_contract_categories( l_contract_id
|
|
, l_contract_rule_type
|
|
, category_array );
|
|
--
|
|
ELSIF l_rule_category = 'TEMPLATE' THEN
|
|
--
|
|
get_template_categories( l_template_id, category_array );
|
|
--
|
|
ELSE
|
|
--
|
|
get_all_categories( category_array );
|
|
--
|
|
END IF;
|
|
--
|
|
-- Display the resultant categories in a searchable select box.
|
|
display_categories( category_array );
|
|
--
|
|
--
|
|
-- Now lets go and get the options available for parameters
|
|
IF l_rule_category = 'CONTRACT' THEN
|
|
--
|
|
get_contract_parameters( l_contract_id
|
|
, l_contract_rule_type
|
|
, parameter_array );
|
|
--
|
|
ELSIF l_rule_category = 'TEMPLATE' THEN
|
|
--
|
|
get_template_parameters( l_template_id, parameter_array );
|
|
--
|
|
ELSE
|
|
--
|
|
get_all_parameters( parameter_array );
|
|
--
|
|
END IF;
|
|
--
|
|
-- Display the resultant categories in a searchable select box.
|
|
display_parameters( parameter_array );
|
|
--
|
|
--
|
|
-- Finally, display either an Update/Insert button and Cancel Button
|
|
-- For the future - on the rules screen allow a Delete button (with relevant checks)
|
|
BEGIN
|
|
SELECT DECODE( NVL(l_contract_rule_type,'ROW'), 'ROW', l_rule_id, 0 )
|
|
INTO l_button_rule_id
|
|
FROM dual;
|
|
EXCEPTION
|
|
WHEN others THEN
|
|
l_button_rule_id := 0;
|
|
END;
|
|
--
|
|
display_buttons( l_ins_or_upd
|
|
, l_rule_category
|
|
, l_button_rule_id
|
|
, l_contract_id
|
|
, l_template_id );
|
|
--
|
|
--
|
|
htp.p('<br><br>');
|
|
htp.p('<i>''*'''||caco_utilities.get_module_text(2202)||'</i>'); -- '*' Denotes a mandatory field
|
|
--
|
|
htp.p(chr(10)||'</div>'); -- Close of div just inside <form>
|
|
--
|
|
-- Close the Rule Form
|
|
htp.p('</form>');
|
|
-- Close rule_border_div
|
|
htp.p('</div>');
|
|
--
|
|
-- Close centrecontent div
|
|
htp.p('</div>');
|
|
--
|
|
-- Close outer div
|
|
htp.p('</div>');
|
|
--
|
|
wsgl.closepagebody;
|
|
--
|
|
END startup;
|
|
|
|
|
|
|
|
--
|
|
PROCEDURE showabout IS
|
|
--
|
|
l_usr VARCHAR2(255) := NULL;
|
|
--
|
|
BEGIN
|
|
--
|
|
l_usr := caco_security.get_user;
|
|
--
|
|
wsgl.registerurl(g_package_name || '.showabout');
|
|
--
|
|
IF wsgl.notlowercase THEN
|
|
RETURN;
|
|
END IF;
|
|
--
|
|
wsgl.openpagehead(wsgl.msggettext( 107
|
|
, wsglm.dsp107_about) || ' ' );
|
|
wsgl.metatag;
|
|
|
|
htp.linkrel( 'stylesheet'
|
|
, 'caco_system.css?p_type=about' );
|
|
--
|
|
wsgl.closepagehead;
|
|
wsgl.openpagebody( FALSE
|
|
, p_attributes => '' );
|
|
--
|
|
htp.p(caco_system.menu);
|
|
--
|
|
wsgl.defaultpagecaption(wsgl.msggettext( 107
|
|
, wsglm.dsp107_about) || ' ' );
|
|
--
|
|
htp.para;
|
|
htp.p(g_revision);
|
|
htp.para;
|
|
--
|
|
htp.para;
|
|
--
|
|
htp.p(wsgl.msggettext( 108
|
|
, wsglm.dsp108_generated_by
|
|
, 'PL/SQL Web Generator'
|
|
, '6.5.94.3.12') );
|
|
htp.para;
|
|
--
|
|
wsgl.info( FALSE
|
|
, 'EFT Framework'
|
|
, g_package_name
|
|
, l_usr );
|
|
--
|
|
wsgl.closepagebody;
|
|
--
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
wsgl.displaymessage( wsgl.mess_exception
|
|
, SQLERRM
|
|
, ''
|
|
, ''
|
|
, g_package_name || '.showabout' );
|
|
END showabout;
|
|
--
|
|
BEGIN
|
|
--
|
|
NULL;
|
|
--
|
|
END efnow093$;
|
|
/
|