diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.PKB b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.PKB new file mode 100644 index 0000000..5bd8f93 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.PKB @@ -0,0 +1,986 @@ + +PROMPT Creating API Package Body for Table 'APPLICATION_PARAMETERS' +-------------------------------------------------------------------------------- +-- Name: cg$APPLICATION_PARAMETERS +-- Description: APPLICATION_PARAMETERS table API package definitions +-------------------------------------------------------------------------------- +CREATE OR REPLACE PACKAGE BODY cg$APPLICATION_PARAMETERS IS + +PROCEDURE validate_mandatory(cg$val_rec IN cg$row_type, + loc IN VARCHAR2 DEFAULT ''); +PROCEDURE up_autogen_columns(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + operation IN VARCHAR2 DEFAULT 'INS', + do_denorm IN BOOLEAN DEFAULT TRUE); +PROCEDURE err_msg(msg IN VARCHAR2, + type IN INTEGER, + loc IN VARCHAR2 DEFAULT ''); + +-------------------------------------------------------------------------------- +-- Name: raise_uk_not_updateable +-- +-- Description: Raise appropriate error when unique key updated +-- +-- Parameters: none +-------------------------------------------------------------------------------- +PROCEDURE raise_uk_not_updateable(uk IN VARCHAR2) IS +BEGIN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_UNIQUE_KEY_UPDATE, cg$errors.ERR_UK_UPDATE, uk), + 'E', + 'API', + cg$errors.API_UNIQUE_KEY_UPDATE, + 'cg$APPLICATION_PARAMETERS.raise_uk_not_updateable'); + cg$errors.raise_failure; +END raise_uk_not_updateable; + + +-------------------------------------------------------------------------------- +-- Name: raise_fk_not_transferable +-- +-- Description: Raise appropriate error when foreign key updated +-- +-- Parameters: none +-------------------------------------------------------------------------------- +PROCEDURE raise_fk_not_transferable(fk IN VARCHAR2) IS +BEGIN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_FOREIGN_KEY_TRANS, cg$errors.ERR_FK_TRANS, fk), + 'E', + 'API', + cg$errors.API_FOREIGN_KEY_TRANS, + 'cg$APPLICATION_PARAMETERS.raise_fk_not_transferable'); + cg$errors.raise_failure; +END raise_fk_not_transferable; + + +-------------------------------------------------------------------------------- +-- Name: up_autogen_columns +-- +-- Description: Specific autogeneration of column values and conversion to +-- uppercase +-- +-- Parameters: cg$rec Record of row to be manipulated +-- cg$ind Indicators for row +-- operation Procedure where this procedure was called +-------------------------------------------------------------------------------- +PROCEDURE up_autogen_columns(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + operation IN VARCHAR2 DEFAULT 'INS', + do_denorm IN BOOLEAN DEFAULT TRUE) IS +BEGIN + IF (operation = 'INS') THEN + BEGIN + IF (cg$ind.APPA_ID = FALSE + OR cg$rec.APPA_ID is NULL) THEN + SELECT APPA_SEQ.nextval + INTO cg$rec.APPA_ID + FROM DUAL; + cg$ind.APPA_ID := TRUE; + END IF; + EXCEPTION WHEN others THEN + cg$errors.push(SQLERRM, 'E', 'ORA', SQLCODE, + 'cg$APPLICATION_PARAMETERS.up_autogen.APPA_ID.OTHERS'); + cg$errors.raise_failure; + END; + NULL; + ELSE -- (operation = 'UPD') + NULL; + END IF; -- (operation = 'INS') ELSE (operation = 'UPD') + + -- Statements executed for both 'INS' and 'UPD' + + +EXCEPTION + WHEN no_data_found THEN + NULL; + WHEN others THEN + cg$errors.push( SQLERRM, 'E', 'ORA', SQLCODE, + 'cg$APPLICATION_PARAMETERS.up_autogen_columns'); + cg$errors.raise_failure; +END up_autogen_columns; + + +-------------------------------------------------------------------------------- +-- Name: validate_mandatory +-- +-- Description: Checks all mandatory columns are not null and raises appropriate +-- error if not satisfied +-- +-- Parameters: cg$val_rec Record of row to be checked +-- loc Place where this procedure was called for error +-- trapping +-------------------------------------------------------------------------------- +PROCEDURE validate_mandatory(cg$val_rec IN cg$row_type, + loc IN VARCHAR2 DEFAULT '') IS +BEGIN + IF (cg$val_rec.APPA_ID IS NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_MAND_COLUMN_ISNULL, cg$errors.VAL_MAND, P10APPA_ID), + 'E', + 'API', + cg$errors.API_MAND_COLUMN_ISNULL, + loc); + END IF; + IF (cg$val_rec.PARAMETER IS NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_MAND_COLUMN_ISNULL, cg$errors.VAL_MAND, P20PARAMETER), + 'E', + 'API', + cg$errors.API_MAND_COLUMN_ISNULL, + loc); + END IF; + NULL; +END validate_mandatory; + + +-------------------------------------------------------------------------------- +-- Name: validate_foreign_keys +-- +-- Description: Checks all mandatory columns are not null and raises appropriate +-- error if not satisfied +-- +-- Parameters: cg$rec Record of row to be checked +-------------------------------------------------------------------------------- +PROCEDURE validate_foreign_keys_ins(cg$rec IN cg$row_type) IS + fk_check INTEGER; +BEGIN +NULL; +END; + +PROCEDURE validate_foreign_keys_upd( cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type) IS + fk_check INTEGER; +BEGIN +NULL; +END; + +PROCEDURE validate_foreign_keys_del(cg$rec IN cg$row_type) IS + fk_check INTEGER; +BEGIN +NULL; +END; + + +-------------------------------------------------------------------------------- +-- Name: slct +-- +-- Description: Selects into the given parameter all the attributes for the row +-- given by the primary key +-- +-- Parameters: cg$sel_rec Record of row to be selected into using its PK +-------------------------------------------------------------------------------- +PROCEDURE slct(cg$sel_rec IN OUT cg$row_type) IS + +BEGIN + + IF cg$sel_rec.the_rowid is null THEN + SELECT APPA_ID + , PARAMETER + , VALUE + , DESCRIPTION + , rowid + INTO cg$sel_rec.APPA_ID + , cg$sel_rec.PARAMETER + , cg$sel_rec.VALUE + , cg$sel_rec.DESCRIPTION + ,cg$sel_rec.the_rowid + FROM APPLICATION_PARAMETERS + WHERE APPA_ID = cg$sel_rec.APPA_ID; + ELSE + SELECT APPA_ID + , PARAMETER + , VALUE + , DESCRIPTION + , rowid + INTO cg$sel_rec.APPA_ID + , cg$sel_rec.PARAMETER + , cg$sel_rec.VALUE + , cg$sel_rec.DESCRIPTION + ,cg$sel_rec.the_rowid + FROM APPLICATION_PARAMETERS + WHERE rowid = cg$sel_rec.the_rowid; + END IF; + +EXCEPTION WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.slct.others'); + cg$errors.raise_failure; + +END slct; + + +-------------------------------------------------------------------------------- +-- Name: cascade_update +-- +-- Description: Updates all child tables affected by a change to APPLICATION_PARAMETERS +-- +-- Parameters: cg$rec Record of APPLICATION_PARAMETERS current values +-- cg$old_rec Record of APPLICATION_PARAMETERS previous values +-------------------------------------------------------------------------------- +PROCEDURE cascade_update(cg$new_rec IN OUT cg$row_type, + cg$old_rec IN cg$row_type) IS +BEGIN + NULL; +END cascade_update; + + +-------------------------------------------------------------------------------- +-- Name: validate_domain_cascade_update +-- +-- Description: Implement the Domain Key Constraint Cascade Updates Resticts rule +-- of each child table that references this tableAPPLICATION_PARAMETERS +-- +-- Parameters: cg$old_rec Record of APPLICATION_PARAMETERS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_domain_cascade_update( cg$old_rec IN cg$row_type ) IS + dk_check INTEGER; +BEGIN + NULL; +END validate_domain_cascade_update; + + +----------------------------------------------------------------------------------------- +-- Name: domain_cascade_update +-- +-- Description: Implement the Domain Key Constraint Cascade Updates rules of each +-- child table that references this table APPLICATION_PARAMETERS +-- +-- Parameters: cg$new_rec New values for APPLICATION_PARAMETERS's domain key constraint columns +-- cg$new_ind Indicates changed APPLICATION_PARAMETERS's domain key constraint columns +-- cg$old_rec Current values for APPLICATION_PARAMETERS's domain key constraint columns +----------------------------------------------------------------------------------------- +PROCEDURE domain_cascade_update(cg$new_rec IN OUT cg$row_type, + cg$new_ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type) IS +BEGIN + NULL; +END domain_cascade_update; + + +-------------------------------------------------------------------------------- +-- Name: cascade_delete +-- +-- Description: Delete all child tables affected by a delete to APPLICATION_PARAMETERS +-- +-- Parameters: cg$rec Record of APPLICATION_PARAMETERS current values +-------------------------------------------------------------------------------- +PROCEDURE cascade_delete(cg$old_rec IN OUT cg$row_type) +IS +BEGIN + NULL; +END cascade_delete; + +-------------------------------------------------------------------------------- +-- Name: domain_cascade_delete +-- +-- Description: Implement the Domain Key Constraint Cascade Delete rules of each +-- child table that references this tableAPPLICATION_PARAMETERS +-- +-- Parameters: cg$old_rec Record of APPLICATION_PARAMETERS current values +-------------------------------------------------------------------------------- +PROCEDURE domain_cascade_delete( cg$old_rec IN cg$row_type ) +IS +BEGIN + NULL; +END domain_cascade_delete; + + +-------------------------------------------------------------------------------- +-- Name: validate_domain_cascade_delete +-- +-- Description: Implement the Domain Key Constraint Cascade Delete Restricts rule +-- of each child table that references this tableAPPLICATION_PARAMETERS +-- +-- Parameters: cg$old_rec Record of APPLICATION_PARAMETERS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_domain_cascade_delete(cg$old_rec IN cg$row_type) +IS + dk_check INTEGER; +BEGIN + NULL; +END validate_domain_cascade_delete; + + + +-------------------------------------------------------------------------------- +-- Name: validate_arc +-- +-- Description: Checks for adherence to arc relationship +-- +-- Parameters: cg$rec Record of APPLICATION_PARAMETERS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_arc(cg$rec IN OUT cg$row_type) IS +i NUMBER; +BEGIN + NULL; +END validate_arc; + + +-------------------------------------------------------------------------------- +-- Name: validate_domain +-- +-- Description: Checks against reference table for values lying in a domain +-- +-- Parameters: cg$rec Record of APPLICATION_PARAMETERS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_domain(cg$rec IN OUT cg$row_type, + cg$ind IN cg$ind_type DEFAULT cg$ind_true) +IS + dummy NUMBER; + found BOOLEAN; + no_tabview EXCEPTION; + PRAGMA EXCEPTION_INIT(no_tabview, -942); +BEGIN + + + + + + + NULL; + +EXCEPTION + WHEN cg$errors.cg$error THEN + cg$errors.raise_failure; + WHEN no_tabview THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_RV_TAB_NOT_FOUND, + cg$errors.APIMSG_RV_TAB_NOT_FOUND, + 'CG_REF_CODES','APPLICATION_PARAMETERS'), + 'E', + 'API', + cg$errors.API_RV_TAB_NOT_FOUND, + 'cg$APPLICATION_PARAMETERS.v_domain.no_reftable_found'); + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.v_domain.others'); + cg$errors.raise_failure; +END validate_domain; + + +-------------------------------------------------------------------------------- +-- Name: err_msg +-- +-- Description: Pushes onto stack appropriate user defined error message +-- depending on the rule violated +-- +-- Parameters: msg Oracle error message +-- type Type of violation e.g. check_constraint: ERR_CHECK_CON +-- loc Place where this procedure was called for error +-- trapping +-------------------------------------------------------------------------------- +PROCEDURE err_msg(msg IN VARCHAR2, + type IN INTEGER, + loc IN VARCHAR2 DEFAULT '') IS +con_name VARCHAR2(240); +BEGIN + con_name := cg$errors.parse_constraint(msg, type); + IF (con_name = 'APPA_PK') THEN + cg$errors.push(nvl(APPA_PK + ,cg$errors.MsgGetText(cg$errors.API_PK_CON_VIOLATED + ,cg$errors.APIMSG_PK_VIOLAT + ,'APPA_PK' + ,'APPLICATION_PARAMETERS')), + 'E', + 'API', + cg$errors.API_PK_CON_VIOLATED, + loc); + ELSIF (con_name = 'APPA_UK') THEN + cg$errors.push(nvl(APPA_UK + ,cg$errors.MsgGetText(cg$errors.API_UQ_CON_VIOLATED + ,cg$errors.APIMSG_UK_VIOLAT + ,'APPA_UK' + ,'APPLICATION_PARAMETERS')), + 'E', + 'API', + cg$errors.API_UQ_CON_VIOLATED, + loc); + + ELSE + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + loc); + END IF; +END err_msg; + + + + +-------------------------------------------------------------------------------- +-- Name: doLobs +-- +-- Description: This function is updating lob columns +-- +-- Parameters: cg$rec Record of row to be inserted +-- cg$ind Record of columns specifically set +-------------------------------------------------------------------------------- +PROCEDURE doLobs(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type) IS +BEGIN + NULL; +END doLobs; + + +-------------------------------------------------------------------------------- +-- Name: ins +-- +-- Description: API insert procedure +-- +-- Parameters: cg$rec Record of row to be inserted +-- cg$ind Record of columns specifically set +-- do_ins Whether we want the actual INSERT to occur +-------------------------------------------------------------------------------- +PROCEDURE ins(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_ins IN BOOLEAN DEFAULT TRUE) IS +cg$tmp_rec cg$row_type; + +-- Constant default values + + +BEGIN +-- Application_logic Pre-Insert <> +-- Application_logic Pre-Insert << End >> + +-- Defaulted + +-- Auto-generated and uppercased columns + + up_autogen_columns(cg$rec, cg$ind, 'INS', do_ins); + + called_from_package := TRUE; + + IF (do_ins) THEN + validate_foreign_keys_ins(cg$rec); + validate_arc(cg$rec); + validate_domain(cg$rec); + + INSERT INTO APPLICATION_PARAMETERS + (APPA_ID + ,PARAMETER + ,VALUE + ,DESCRIPTION) + VALUES + (cg$rec.APPA_ID + ,cg$rec.PARAMETER + ,cg$rec.VALUE + ,cg$rec.DESCRIPTION +); + doLobs(cg$rec, cg$ind); + slct(cg$rec); + + upd_oper_denorm2(cg$rec, cg$tmp_rec, cg$ind, 'INS'); + END IF; + + called_from_package := FALSE; + + + +-- Application logic Post-Insert <> +-- Application logic Post-Insert << End >> + +EXCEPTION + WHEN cg$errors.cg$error THEN + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.mandatory_missing THEN + validate_mandatory(cg$rec, 'cg$APPLICATION_PARAMETERS.ins.mandatory_missing'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.check_violation THEN + err_msg(SQLERRM, cg$errors.ERR_CHECK_CON, 'cg$APPLICATION_PARAMETERS.ins.check_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.fk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_FOREIGN_KEY, 'cg$APPLICATION_PARAMETERS.ins.fk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.uk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_UNIQUE_KEY, 'cg$APPLICATION_PARAMETERS.ins.uk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.ins.others'); + called_from_package := FALSE; + cg$errors.raise_failure; +END ins; + + +-------------------------------------------------------------------------------- +-- Name: upd +-- +-- Description: API update procedure +-- +-- Parameters: cg$rec Record of row to be updated +-- cg$ind Record of columns specifically set +-- do_upd Whether we want the actual UPDATE to occur +-------------------------------------------------------------------------------- +PROCEDURE upd(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_upd IN BOOLEAN DEFAULT TRUE, + cg$pk IN cg$row_type DEFAULT NULL ) +IS + cg$upd_rec cg$row_type; + cg$old_rec cg$row_type; + RECORD_LOGGED BOOLEAN := FALSE; +BEGIN +-- Application_logic Pre-Update <> +-- Application_logic Pre-Update << End >> + + + IF ( cg$pk.APPA_ID IS NULL ) THEN + cg$upd_rec.APPA_ID := cg$rec.APPA_ID; + ELSE + cg$upd_rec.APPA_ID := cg$pk.APPA_ID; + END IF; + cg$old_rec.APPA_ID := cg$upd_rec.APPA_ID; + + IF ( cg$pk.the_rowid IS NULL ) THEN + cg$upd_rec.the_rowid := cg$rec.the_rowid; + ELSE + cg$upd_rec.the_rowid := cg$pk.the_rowid; + END IF; + cg$old_rec.the_rowid := cg$upd_rec.the_rowid; + + IF ( do_upd ) THEN + + slct(cg$upd_rec); + + + -- Report error if attempt to update non updateable Primary Key APPA_PK + IF (cg$ind.APPA_ID AND cg$rec.APPA_ID != cg$upd_rec.APPA_ID) THEN + raise_uk_not_updateable('APPA_PK'); + END IF; + IF NOT (cg$ind.APPA_ID) THEN + cg$rec.APPA_ID := cg$upd_rec.APPA_ID; + END IF; + IF NOT (cg$ind.PARAMETER) THEN + cg$rec.PARAMETER := cg$upd_rec.PARAMETER; + END IF; + IF NOT (cg$ind.VALUE) THEN + cg$rec.VALUE := cg$upd_rec.VALUE; + END IF; + IF NOT (cg$ind.DESCRIPTION) THEN + cg$rec.DESCRIPTION := cg$upd_rec.DESCRIPTION; + END IF; + ELSE + -- Perform checks if called from a trigger + -- Indicators are only set on changed values + null; + -- Report error if attempt to update non updateable Primary Key APPA_PK + IF ( cg$ind.APPA_ID ) THEN + raise_uk_not_updateable('APPA_PK'); + END IF; + END IF; + + up_autogen_columns(cg$rec, cg$ind, 'UPD', do_upd); -- Auto-generated and uppercased columns + +-- Now do update if updateable columns exist + IF (do_upd) THEN + DECLARE + called_from BOOLEAN := called_from_package; + BEGIN + called_from_package := TRUE; + + slct(cg$old_rec); + validate_foreign_keys_upd(cg$rec, cg$old_rec, cg$ind); + validate_arc(cg$rec); + validate_domain(cg$rec, cg$ind); + validate_domain_cascade_update(cg$old_rec); + + IF cg$rec.the_rowid is null THEN + UPDATE APPLICATION_PARAMETERS + SET + PARAMETER = cg$rec.PARAMETER + ,VALUE = cg$rec.VALUE + ,DESCRIPTION = cg$rec.DESCRIPTION + WHERE APPA_ID = cg$rec.APPA_ID; + null; + ELSE + UPDATE APPLICATION_PARAMETERS + SET + PARAMETER = cg$rec.PARAMETER + ,VALUE = cg$rec.VALUE + ,DESCRIPTION = cg$rec.DESCRIPTION + WHERE rowid = cg$rec.the_rowid; + + null; + END IF; + + slct(cg$rec); + + upd_denorm2(cg$rec, cg$ind); + upd_oper_denorm2(cg$rec, cg$old_rec, cg$ind, 'UPD'); + cascade_update(cg$rec, cg$old_rec); + domain_cascade_update(cg$rec, cg$ind, cg$old_rec); + called_from_package := called_from; + END; + END IF; + + + + IF NOT (do_upd) THEN + cg$table(idx).APPA_ID := cg$rec.APPA_ID; + cg$tableind(idx).APPA_ID := cg$ind.APPA_ID; + cg$table(idx).PARAMETER := cg$rec.PARAMETER; + cg$tableind(idx).PARAMETER := cg$ind.PARAMETER; + cg$table(idx).VALUE := cg$rec.VALUE; + cg$tableind(idx).VALUE := cg$ind.VALUE; + cg$table(idx).DESCRIPTION := cg$rec.DESCRIPTION; + cg$tableind(idx).DESCRIPTION := cg$ind.DESCRIPTION; + idx := idx + 1; + END IF; + +-- Application_logic Post-Update <> +-- Application_logic Post-Update << End >> + +EXCEPTION + WHEN cg$errors.cg$error THEN + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.upd_mandatory_null THEN + validate_mandatory(cg$rec, 'cg$APPLICATION_PARAMETERS.upd.upd_mandatory_null'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.check_violation THEN + err_msg(SQLERRM, cg$errors.ERR_CHECK_CON, 'cg$APPLICATION_PARAMETERS.upd.check_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.fk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_FOREIGN_KEY, 'cg$APPLICATION_PARAMETERS.upd.fk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.uk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_UNIQUE_KEY, 'cg$APPLICATION_PARAMETERS.upd.uk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.upd.others'); + called_from_package := FALSE; + cg$errors.raise_failure; +END upd; + + +---------------------------------------------------------------------------------------- +-- Name: domain_cascade_upd +-- +-- Description: Update the Domain Constraint Key columns of APPLICATION_PARAMETERS when the +-- Cascade Update rule is Cascades and the domain table has been +-- updated. Called from .domain_cascade_update(). +-- +-- Parameters: cg$rec New values for APPLICATION_PARAMETERS's domain key constraint columns +-- cg$ind Indicates changed APPLICATION_PARAMETERS's domain key constraint columns +-- cg$old_rec Current values for APPLICATION_PARAMETERS's domain key constraint columns +---------------------------------------------------------------------------------------- +PROCEDURE domain_cascade_upd( cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type ) +IS + called_from BOOLEAN := called_from_package; +BEGIN + + null; +END domain_cascade_upd; + + +-------------------------------------------------------------------------------- +-- Name: upd_denorm +-- +-- Description: API procedure for simple denormalization +-- +-- Parameters: cg$rec Record of row to be updated +-- cg$ind Record of columns specifically set +-- do_upd Whether we want the actual UPDATE to occur +-------------------------------------------------------------------------------- +PROCEDURE upd_denorm2( cg$rec IN cg$row_type, + cg$ind IN cg$ind_type ) IS +BEGIN + NULL; +END upd_denorm2; + + +-------------------------------------------------------------------------------- +-- Name: upd_oper_denorm +-- +-- Description: API procedure for operation denormalization +-- +-- Parameters: cg$rec Record of row to be updated +-- cg$ind Record of columns specifically set +-- do_upd Whether we want the actual UPDATE to occur +-------------------------------------------------------------------------------- +PROCEDURE upd_oper_denorm2( cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type, + operation IN VARCHAR2 DEFAULT 'UPD' + ) +IS +BEGIN + + + + +NULL; +END upd_oper_denorm2; + +-------------------------------------------------------------------------------- +-- Name: del +-- +-- Description: API delete procedure +-- +-- Parameters: cg$pk Primary key record of row to be deleted +-------------------------------------------------------------------------------- +PROCEDURE del(cg$pk IN cg$pk_type, + do_del IN BOOLEAN DEFAULT TRUE) IS +BEGIN +-- Application_logic Pre-Delete <> +-- Application_logic Pre-Delete << End >> + +-- Delete the record + + called_from_package := TRUE; + + IF (do_del) THEN + DECLARE + cg$rec cg$row_type; + cg$old_rec cg$row_type; + cg$ind cg$ind_type; + BEGIN + cg$rec.APPA_ID := cg$pk.APPA_ID; + slct(cg$rec); + + validate_foreign_keys_del(cg$rec); + validate_domain_cascade_delete(cg$rec); + + IF cg$pk.the_rowid is null THEN + DELETE APPLICATION_PARAMETERS + WHERE APPA_ID = cg$pk.APPA_ID; + ELSE + DELETE APPLICATION_PARAMETERS + WHERE rowid = cg$pk.the_rowid; + END IF; + + upd_oper_denorm2(cg$rec, cg$old_rec, cg$ind, 'DEL'); + cascade_delete(cg$rec); + domain_cascade_delete(cg$rec); + END; + END IF; + + called_from_package := FALSE; + + +-- Application_logic Post-Delete <> +-- Application_logic Post-Delete << End >> + +EXCEPTION + WHEN cg$errors.cg$error THEN + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.delete_restrict THEN + err_msg(SQLERRM, cg$errors.ERR_DELETE_RESTRICT, 'cg$APPLICATION_PARAMETERS.del.delete_restrict'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN no_data_found THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_DEL, cg$errors.ROW_DEL), + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.del.no_data_found'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.del.others'); + called_from_package := FALSE; + cg$errors.raise_failure; +END del; + + +-------------------------------------------------------------------------------- +-- Name: lck +-- +-- Description: API lock procedure +-- +-- Parameters: cg$old_rec Calling apps view of record of row to be locked +-- cg$old_ind Record of columns to raise error if modified +-- nowait_flag TRUE lock with NOWAIT, FALSE don't fail if busy +-------------------------------------------------------------------------------- +PROCEDURE lck(cg$old_rec IN cg$row_type, + cg$old_ind IN cg$ind_type, + nowait_flag IN BOOLEAN DEFAULT TRUE) IS +cg$tmp_rec cg$row_type; +any_modified BOOLEAN := FALSE; + +BEGIN +-- Application_logic Pre-Lock <> +-- Application_logic Pre-Lock << End >> + +-- Do the row lock + + BEGIN + IF (nowait_flag) THEN + IF cg$old_rec.the_rowid is null THEN + SELECT APPA_ID + , PARAMETER + , VALUE + , DESCRIPTION + INTO cg$tmp_rec.APPA_ID + , cg$tmp_rec.PARAMETER + , cg$tmp_rec.VALUE + , cg$tmp_rec.DESCRIPTION + FROM APPLICATION_PARAMETERS + WHERE APPA_ID = cg$old_rec.APPA_ID + FOR UPDATE NOWAIT; + ELSE + SELECT APPA_ID + , PARAMETER + , VALUE + , DESCRIPTION + INTO cg$tmp_rec.APPA_ID + , cg$tmp_rec.PARAMETER + , cg$tmp_rec.VALUE + , cg$tmp_rec.DESCRIPTION + FROM APPLICATION_PARAMETERS + WHERE rowid = cg$old_rec.the_rowid + FOR UPDATE NOWAIT; + END IF; + ELSE + IF cg$old_rec.the_rowid is null THEN + SELECT APPA_ID + , PARAMETER + , VALUE + , DESCRIPTION + INTO cg$tmp_rec.APPA_ID + , cg$tmp_rec.PARAMETER + , cg$tmp_rec.VALUE + , cg$tmp_rec.DESCRIPTION + FROM APPLICATION_PARAMETERS + WHERE APPA_ID = cg$old_rec.APPA_ID + FOR UPDATE; + ELSE + SELECT APPA_ID + , PARAMETER + , VALUE + , DESCRIPTION + INTO cg$tmp_rec.APPA_ID + , cg$tmp_rec.PARAMETER + , cg$tmp_rec.VALUE + , cg$tmp_rec.DESCRIPTION + FROM APPLICATION_PARAMETERS + WHERE rowid = cg$old_rec.the_rowid + FOR UPDATE; + END IF; + END IF; + + EXCEPTION + WHEN cg$errors.cg$error THEN + cg$errors.raise_failure; + WHEN cg$errors.resource_busy THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_LCK, cg$errors.ROW_LCK), + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.lck.resource_busy'); + cg$errors.raise_failure; + WHEN no_data_found THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_DEL, cg$errors.ROW_DEL), + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.lck.no_data_found'); + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$APPLICATION_PARAMETERS.lck.others'); + cg$errors.raise_failure; + END; + +-- Optional Columns + + IF (cg$old_ind.VALUE) THEN + IF (cg$tmp_rec.VALUE IS NOT NULL + AND cg$old_rec.VALUE IS NOT NULL) THEN + IF (cg$tmp_rec.VALUE != cg$old_rec.VALUE) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P30VALUE + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$APPLICATION_PARAMETERS.lck'); + any_modified := TRUE; + END IF; + ELSIF (cg$tmp_rec.VALUE IS NOT NULL + OR cg$old_rec.VALUE IS NOT NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P30VALUE + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$APPLICATION_PARAMETERS.lck'); + any_modified := TRUE; + END IF; + END IF; + IF (cg$old_ind.DESCRIPTION) THEN + IF (cg$tmp_rec.DESCRIPTION IS NOT NULL + AND cg$old_rec.DESCRIPTION IS NOT NULL) THEN + IF (cg$tmp_rec.DESCRIPTION != cg$old_rec.DESCRIPTION) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P40DESCRIPTION + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$APPLICATION_PARAMETERS.lck'); + any_modified := TRUE; + END IF; + ELSIF (cg$tmp_rec.DESCRIPTION IS NOT NULL + OR cg$old_rec.DESCRIPTION IS NOT NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P40DESCRIPTION + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$APPLICATION_PARAMETERS.lck'); + any_modified := TRUE; + END IF; + END IF; + +-- Mandatory Columns + + IF (cg$old_ind.APPA_ID) THEN + IF (cg$tmp_rec.APPA_ID != cg$old_rec.APPA_ID) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P10APPA_ID + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$APPLICATION_PARAMETERS.lck'); + any_modified := TRUE; + END IF; + END IF; + IF (cg$old_ind.PARAMETER) THEN + IF (cg$tmp_rec.PARAMETER != cg$old_rec.PARAMETER) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P20PARAMETER + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$APPLICATION_PARAMETERS.lck'); + any_modified := TRUE; + END IF; + END IF; + + IF (any_modified) THEN + cg$errors.raise_failure; + END IF; + +-- Application_logic Post-Lock <> +-- Application_logic Post-Lock << End >> + +END lck; + + +BEGIN + cg$ind_true.APPA_ID := TRUE; + cg$ind_true.PARAMETER := TRUE; + cg$ind_true.VALUE := TRUE; + cg$ind_true.DESCRIPTION := TRUE; + + +END cg$APPLICATION_PARAMETERS; +/ + diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.PKS b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.PKS new file mode 100644 index 0000000..58d9b93 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.PKS @@ -0,0 +1,109 @@ + +PROMPT Creating API Package Specification for Table 'APPLICATION_PARAMETERS' +-------------------------------------------------------------------------------- +-- Name: cg$APPLICATION_PARAMETERS +-- Description: APPLICATION_PARAMETERS table API package declarations +-------------------------------------------------------------------------------- +CREATE OR REPLACE PACKAGE cg$APPLICATION_PARAMETERS IS + +called_from_package BOOLEAN := FALSE; + +-- Repository User-Defined Error Messages +APPA_PK CONSTANT VARCHAR2(240) := ''; +APPA_UK CONSTANT VARCHAR2(240) := ''; + +-- Column default prompts. Format PSEQNO_COL +P10APPA_ID CONSTANT VARCHAR2(240) := 'Appa Id'; +P20PARAMETER CONSTANT VARCHAR2(240) := 'Parameter'; +P30VALUE CONSTANT VARCHAR2(240) := 'Value'; +P40DESCRIPTION CONSTANT VARCHAR2(240) := 'Description'; + +cg$row APPLICATION_PARAMETERS%ROWTYPE; + +-- APPLICATION_PARAMETERS row type variable +TYPE cg$row_type IS RECORD +(APPA_ID cg$row.APPA_ID%TYPE +,PARAMETER cg$row.PARAMETER%TYPE +,VALUE cg$row.VALUE%TYPE +,DESCRIPTION cg$row.DESCRIPTION%TYPE +,the_rowid ROWID) +; + +-- APPLICATION_PARAMETERS indicator type variable +TYPE cg$ind_type IS RECORD +(APPA_ID BOOLEAN DEFAULT FALSE +,PARAMETER BOOLEAN DEFAULT FALSE +,VALUE BOOLEAN DEFAULT FALSE +,DESCRIPTION BOOLEAN DEFAULT FALSE); + +cg$ind_true cg$ind_type; + +-- APPLICATION_PARAMETERS primary key type variable +TYPE cg$pk_type IS RECORD +(APPA_ID cg$row.APPA_ID%TYPE +,the_rowid ROWID) +; + +-- PL/SQL Table Type variable for triggers +TYPE cg$table_type IS TABLE OF APPLICATION_PARAMETERS%ROWTYPE + INDEX BY BINARY_INTEGER; +cg$table cg$table_type; + +TYPE cg$tableind_type IS TABLE OF cg$ind_type + INDEX BY BINARY_INTEGER; +cg$tableind cg$tableind_type; +idx BINARY_INTEGER := 1; + +PROCEDURE ins(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_ins IN BOOLEAN DEFAULT TRUE + ); +PROCEDURE upd(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_upd IN BOOLEAN DEFAULT TRUE, + cg$pk IN cg$row_type DEFAULT NULL + ); +PROCEDURE del(cg$pk IN cg$pk_type, + do_del IN BOOLEAN DEFAULT TRUE + ); +PROCEDURE lck(cg$old_rec IN cg$row_type, + cg$old_ind IN cg$ind_type, + nowait_flag IN BOOLEAN DEFAULT TRUE + ); +PROCEDURE slct(cg$sel_rec IN OUT cg$row_type); + +PROCEDURE validate_arc(cg$rec IN OUT cg$row_type); + +PROCEDURE validate_domain(cg$rec IN OUT cg$row_type, + cg$ind IN cg$ind_type DEFAULT cg$ind_true); + +PROCEDURE validate_foreign_keys_ins(cg$rec IN cg$row_type); +PROCEDURE validate_foreign_keys_upd(cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type); +PROCEDURE validate_foreign_keys_del(cg$rec IN cg$row_type); + +PROCEDURE validate_domain_cascade_delete(cg$old_rec IN cg$row_type); +PROCEDURE validate_domain_cascade_update(cg$old_rec IN cg$row_type); + +PROCEDURE cascade_update(cg$new_rec IN OUT cg$row_type, + cg$old_rec IN cg$row_type ); +PROCEDURE domain_cascade_update(cg$new_rec IN OUT cg$row_type, + cg$new_ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type); +PROCEDURE domain_cascade_upd( cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type); + +PROCEDURE cascade_delete(cg$old_rec IN OUT cg$row_type); +PROCEDURE domain_cascade_delete(cg$old_rec IN cg$row_type); + +PROCEDURE upd_denorm2( cg$rec IN cg$row_type, + cg$ind IN cg$ind_type ); +PROCEDURE upd_oper_denorm2( cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type, + operation IN VARCHAR2 DEFAULT 'UPD' ); +END cg$APPLICATION_PARAMETERS; +/ + diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.TRG b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.TRG new file mode 100644 index 0000000..851506c --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/APPA.TRG @@ -0,0 +1,372 @@ + +PROMPT Creating Trigger Logic for Table 'APPLICATION_PARAMETERS' +PROMPT Creating Before Insert Statement Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$BIS_APPLICATION_PARAMETERS +BEFORE INSERT ON APPLICATION_PARAMETERS +BEGIN +-- Application_logic Pre-Before-Insert-statement <> +-- Application_logic Pre-Before-Insert-statement << End >> + + cg$APPLICATION_PARAMETERS.cg$table.DELETE; + cg$APPLICATION_PARAMETERS.cg$tableind.DELETE; + cg$APPLICATION_PARAMETERS.idx := 1; + +-- Application_logic Post-Before-Insert-statement <> +-- Application_logic Post-Before-Insert-statement << End >> +END; +/ + + +PROMPT Creating Before Insert Row Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$BIR_APPLICATION_PARAMETERS +BEFORE INSERT ON APPLICATION_PARAMETERS FOR EACH ROW +DECLARE + cg$rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$ind cg$APPLICATION_PARAMETERS.cg$ind_type; +BEGIN +-- Application_logic Pre-Before-Insert-row <> +-- Application_logic Pre-Before-Insert-row << End >> + +-- Load cg$rec/cg$ind values from new + + cg$rec.APPA_ID := :new.APPA_ID; + cg$ind.APPA_ID := TRUE; + cg$rec.PARAMETER := :new.PARAMETER; + cg$ind.PARAMETER := TRUE; + cg$rec.VALUE := :new.VALUE; + cg$ind.VALUE := TRUE; + cg$rec.DESCRIPTION := :new.DESCRIPTION; + cg$ind.DESCRIPTION := TRUE; + + if not (cg$APPLICATION_PARAMETERS.called_from_package) then + cg$APPLICATION_PARAMETERS.validate_arc(cg$rec); + cg$APPLICATION_PARAMETERS.validate_domain(cg$rec); + + cg$APPLICATION_PARAMETERS.ins(cg$rec, cg$ind, FALSE); + cg$APPLICATION_PARAMETERS.called_from_package := FALSE; + end if; + + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).APPA_ID := cg$rec.APPA_ID; + cg$APPLICATION_PARAMETERS.cg$tableind(cg$APPLICATION_PARAMETERS.idx).APPA_ID := cg$ind.APPA_ID; + + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).PARAMETER := cg$rec.PARAMETER; + cg$APPLICATION_PARAMETERS.cg$tableind(cg$APPLICATION_PARAMETERS.idx).PARAMETER := cg$ind.PARAMETER; + + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).VALUE := cg$rec.VALUE; + cg$APPLICATION_PARAMETERS.cg$tableind(cg$APPLICATION_PARAMETERS.idx).VALUE := cg$ind.VALUE; + + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).DESCRIPTION := cg$rec.DESCRIPTION; + cg$APPLICATION_PARAMETERS.cg$tableind(cg$APPLICATION_PARAMETERS.idx).DESCRIPTION := cg$ind.DESCRIPTION; + + cg$APPLICATION_PARAMETERS.idx := cg$APPLICATION_PARAMETERS.idx + 1; + + :new.APPA_ID := cg$rec.APPA_ID; + :new.PARAMETER := cg$rec.PARAMETER; + :new.VALUE := cg$rec.VALUE; + :new.DESCRIPTION := cg$rec.DESCRIPTION; + +-- Application_logic Post-Before-Insert-row <> +-- Application_logic Post-Before-Insert-row << End >> +END; +/ + + +-- No application logic defined for Trigger cg$AIR_APPLICATION_PARAMETERS, so drop it. +-- To avoid an error if there isn't one, create or replace it, and then drop it +CREATE OR REPLACE TRIGGER cg$AIR_APPLICATION_PARAMETERS +AFTER INSERT ON APPLICATION_PARAMETERS FOR EACH ROW +BEGIN + null; +END; +/ +drop trigger cg$AIR_APPLICATION_PARAMETERS +/ + +PROMPT Creating After Insert Statement Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$AIS_APPLICATION_PARAMETERS +AFTER INSERT ON APPLICATION_PARAMETERS +DECLARE + idx BINARY_INTEGER := cg$APPLICATION_PARAMETERS.cg$table.FIRST; + cg$rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$old_rec cg$APPLICATION_PARAMETERS.cg$row_type; + fk_check INTEGER; +BEGIN +-- Application_logic Pre-After-Insert-statement <> +-- Application_logic Pre-After-Insert-statement << End >> + + + IF NOT (cg$APPLICATION_PARAMETERS.called_from_package) THEN + WHILE idx IS NOT NULL LOOP + cg$rec.APPA_ID := cg$APPLICATION_PARAMETERS.cg$table(idx).APPA_ID; + cg$rec.PARAMETER := cg$APPLICATION_PARAMETERS.cg$table(idx).PARAMETER; + cg$rec.VALUE := cg$APPLICATION_PARAMETERS.cg$table(idx).VALUE; + cg$rec.DESCRIPTION := cg$APPLICATION_PARAMETERS.cg$table(idx).DESCRIPTION; + + cg$APPLICATION_PARAMETERS.validate_foreign_keys_ins(cg$rec); + + cg$APPLICATION_PARAMETERS.upd_oper_denorm2( cg$rec, + cg$old_rec, + cg$APPLICATION_PARAMETERS.cg$tableind(idx), + 'INS' + ); + + idx := cg$APPLICATION_PARAMETERS.cg$table.NEXT(idx); + END LOOP; + END IF; + +-- Application_logic Post-After-Insert-statement <> +-- Application_logic Post-After-Insert-statement << End >> + +END; +/ + + + + +PROMPT Creating Before Update Statement Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$BUS_APPLICATION_PARAMETERS +BEFORE UPDATE ON APPLICATION_PARAMETERS +BEGIN +-- Application_logic Pre-Before-Update-statement <> +-- Application_logic Pre-Before-Update-statement << End >> + + cg$APPLICATION_PARAMETERS.cg$table.DELETE; + cg$APPLICATION_PARAMETERS.cg$tableind.DELETE; + cg$APPLICATION_PARAMETERS.idx := 1; + +-- Application_logic Post-Before-Update-statement <> +-- Application_logic Post-Before-Update-statement << End >> + +END; +/ + + +PROMPT Creating Before Update Row Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$BUR_APPLICATION_PARAMETERS +BEFORE UPDATE ON APPLICATION_PARAMETERS FOR EACH ROW +DECLARE + cg$rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$ind cg$APPLICATION_PARAMETERS.cg$ind_type; + cg$old_rec cg$APPLICATION_PARAMETERS.cg$row_type; +BEGIN +-- Application_logic Pre-Before-Update-row <> +-- Application_logic Pre-Before-Update-row << End >> + +-- Load cg$rec/cg$ind values from new + + cg$rec.APPA_ID := :new.APPA_ID; + cg$ind.APPA_ID := (:new.APPA_ID IS NULL AND :old.APPA_ID IS NOT NULL ) + OR (:new.APPA_ID IS NOT NULL AND :old.APPA_ID IS NULL) + OR NOT(:new.APPA_ID = :old.APPA_ID) ; + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).APPA_ID := :old.APPA_ID; + cg$rec.PARAMETER := :new.PARAMETER; + cg$ind.PARAMETER := (:new.PARAMETER IS NULL AND :old.PARAMETER IS NOT NULL ) + OR (:new.PARAMETER IS NOT NULL AND :old.PARAMETER IS NULL) + OR NOT(:new.PARAMETER = :old.PARAMETER) ; + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).PARAMETER := :old.PARAMETER; + cg$rec.VALUE := :new.VALUE; + cg$ind.VALUE := (:new.VALUE IS NULL AND :old.VALUE IS NOT NULL ) + OR (:new.VALUE IS NOT NULL AND :old.VALUE IS NULL) + OR NOT(:new.VALUE = :old.VALUE) ; + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).VALUE := :old.VALUE; + cg$rec.DESCRIPTION := :new.DESCRIPTION; + cg$ind.DESCRIPTION := (:new.DESCRIPTION IS NULL AND :old.DESCRIPTION IS NOT NULL ) + OR (:new.DESCRIPTION IS NOT NULL AND :old.DESCRIPTION IS NULL) + OR NOT(:new.DESCRIPTION = :old.DESCRIPTION) ; + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).DESCRIPTION := :old.DESCRIPTION; + + + cg$APPLICATION_PARAMETERS.idx := cg$APPLICATION_PARAMETERS.idx + 1; + + if not (cg$APPLICATION_PARAMETERS.called_from_package) then + cg$APPLICATION_PARAMETERS.validate_arc(cg$rec); + cg$APPLICATION_PARAMETERS.validate_domain(cg$rec, cg$ind); + cg$APPLICATION_PARAMETERS.validate_domain_cascade_update(cg$old_rec); + + cg$APPLICATION_PARAMETERS.upd(cg$rec, cg$ind, FALSE); + cg$APPLICATION_PARAMETERS.called_from_package := FALSE; + end if; + + :new.PARAMETER := cg$rec.PARAMETER; + :new.VALUE := cg$rec.VALUE; + :new.DESCRIPTION := cg$rec.DESCRIPTION; +-- Application_logic Post-Before-Update-row <> +-- Application_logic Post-Before-Update-row << End >> +END; +/ + +-- No application logic defined for Trigger cg$AUR_APPLICATION_PARAMETERS, so drop it. +-- To avoid an error if there isn't one, create or replace it, and then drop it +CREATE OR REPLACE TRIGGER cg$AUR_APPLICATION_PARAMETERS +AFTER UPDATE ON APPLICATION_PARAMETERS FOR EACH ROW +BEGIN + null; +END; +/ +drop trigger cg$AUR_APPLICATION_PARAMETERS +/ + + + + + + +PROMPT Creating After Update Statement Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$AUS_APPLICATION_PARAMETERS +AFTER UPDATE ON APPLICATION_PARAMETERS +DECLARE + idx BINARY_INTEGER := cg$APPLICATION_PARAMETERS.cg$table.FIRST; + cg$old_rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$ind cg$APPLICATION_PARAMETERS.cg$ind_type; +BEGIN +-- Application_logic Pre-After-Update-statement <> +-- Application_logic Pre-After-Update-statement << End >> + + WHILE idx IS NOT NULL LOOP + cg$old_rec.APPA_ID := cg$APPLICATION_PARAMETERS.cg$table(idx).APPA_ID; + cg$old_rec.PARAMETER := cg$APPLICATION_PARAMETERS.cg$table(idx).PARAMETER; + cg$old_rec.VALUE := cg$APPLICATION_PARAMETERS.cg$table(idx).VALUE; + cg$old_rec.DESCRIPTION := cg$APPLICATION_PARAMETERS.cg$table(idx).DESCRIPTION; + + IF NOT (cg$APPLICATION_PARAMETERS.called_from_package) THEN + idx := cg$APPLICATION_PARAMETERS.cg$table.NEXT(idx); + cg$rec.APPA_ID := cg$APPLICATION_PARAMETERS.cg$table(idx).APPA_ID; + cg$ind.APPA_ID := updating('APPA_ID'); + cg$rec.PARAMETER := cg$APPLICATION_PARAMETERS.cg$table(idx).PARAMETER; + cg$ind.PARAMETER := updating('PARAMETER'); + cg$rec.VALUE := cg$APPLICATION_PARAMETERS.cg$table(idx).VALUE; + cg$ind.VALUE := updating('VALUE'); + cg$rec.DESCRIPTION := cg$APPLICATION_PARAMETERS.cg$table(idx).DESCRIPTION; + cg$ind.DESCRIPTION := updating('DESCRIPTION'); + + cg$APPLICATION_PARAMETERS.validate_foreign_keys_upd(cg$rec, cg$old_rec, cg$ind); + + cg$APPLICATION_PARAMETERS.upd_denorm2( cg$rec, + cg$APPLICATION_PARAMETERS.cg$tableind(idx) + ); + cg$APPLICATION_PARAMETERS.upd_oper_denorm2( cg$rec, + cg$old_rec, + cg$APPLICATION_PARAMETERS.cg$tableind(idx) + ); + cg$APPLICATION_PARAMETERS.cascade_update(cg$rec, cg$old_rec); + cg$APPLICATION_PARAMETERS.domain_cascade_update(cg$rec, cg$ind, cg$old_rec); + + cg$APPLICATION_PARAMETERS.called_from_package := FALSE; + END IF; + idx := cg$APPLICATION_PARAMETERS.cg$table.NEXT(idx); + END LOOP; + + cg$APPLICATION_PARAMETERS.cg$table.DELETE; + +-- Application_logic Post-After-Update-statement <> +-- Application_logic Post-After-Update-statement << End >> + +END; +/ + +PROMPT Creating Before Delete Statement Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$BDS_APPLICATION_PARAMETERS +BEFORE DELETE ON APPLICATION_PARAMETERS +BEGIN +-- Application_logic Pre-Before-Delete-statement <> +-- Application_logic Pre-Before-Delete-statement << End >> + + cg$APPLICATION_PARAMETERS.cg$table.DELETE; + cg$APPLICATION_PARAMETERS.cg$tableind.DELETE; + cg$APPLICATION_PARAMETERS.idx := 1; + +-- Application_logic Post-Before-Delete-statement <> +-- Application_logic Post-Before-Delete-statement << End >> +END; +/ + + +PROMPT Creating Before Delete Row Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$BDR_APPLICATION_PARAMETERS +BEFORE DELETE ON APPLICATION_PARAMETERS FOR EACH ROW +DECLARE + cg$pk cg$APPLICATION_PARAMETERS.cg$pk_type; + cg$rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$ind cg$APPLICATION_PARAMETERS.cg$ind_type; +BEGIN +-- Application_logic Pre-Before-Delete-row <> +-- Application_logic Pre-Before-Delete-row << End >> + +-- Load cg$rec/cg$ind values from new + + cg$pk.APPA_ID := :old.APPA_ID; + cg$rec.APPA_ID := :old.APPA_ID; + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).APPA_ID := :old.APPA_ID; + cg$rec.PARAMETER := :old.PARAMETER; + cg$APPLICATION_PARAMETERS.cg$table(cg$APPLICATION_PARAMETERS.idx).PARAMETER := :old.PARAMETER; + + + cg$APPLICATION_PARAMETERS.idx := cg$APPLICATION_PARAMETERS.idx + 1; + + if not (cg$APPLICATION_PARAMETERS.called_from_package) then + cg$APPLICATION_PARAMETERS.validate_domain_cascade_delete(cg$rec); + cg$APPLICATION_PARAMETERS.del(cg$pk, FALSE); + cg$APPLICATION_PARAMETERS.called_from_package := FALSE; + end if; + +-- Application_logic Post-Before-Delete-row <> +-- Application_logic Post-Before-Delete-row << End >> +END; +/ + +-- No application logic defined for Trigger cg$ADR_APPLICATION_PARAMETERS, so drop it. +-- To avoid an error if there isn't one, create or replace it, and then drop it +CREATE OR REPLACE TRIGGER cg$ADR_APPLICATION_PARAMETERS +AFTER DELETE ON APPLICATION_PARAMETERS FOR EACH ROW +BEGIN + null; +END; +/ +drop trigger cg$ADR_APPLICATION_PARAMETERS +/ + +PROMPT Creating After Delete Statement Trigger on 'APPLICATION_PARAMETERS' +CREATE OR REPLACE TRIGGER cg$ADS_APPLICATION_PARAMETERS +AFTER DELETE ON APPLICATION_PARAMETERS +DECLARE + idx BINARY_INTEGER := cg$APPLICATION_PARAMETERS.cg$table.FIRST; + cg$rec cg$APPLICATION_PARAMETERS.cg$row_type; + cg$old_rec cg$APPLICATION_PARAMETERS.cg$row_type; +BEGIN +-- Application_logic Pre-After-Delete-statement <> +-- Application_logic Pre-After-Delete-statement << End >> + + IF NOT (cg$APPLICATION_PARAMETERS.called_from_package) THEN + WHILE idx IS NOT NULL LOOP + cg$rec.APPA_ID := cg$APPLICATION_PARAMETERS.cg$table(idx).APPA_ID; + cg$APPLICATION_PARAMETERS.cg$tableind(idx).APPA_ID := TRUE; + cg$rec.PARAMETER := cg$APPLICATION_PARAMETERS.cg$table(idx).PARAMETER; + cg$APPLICATION_PARAMETERS.cg$tableind(idx).PARAMETER := TRUE; + cg$rec.VALUE := cg$APPLICATION_PARAMETERS.cg$table(idx).VALUE; + cg$APPLICATION_PARAMETERS.cg$tableind(idx).VALUE := TRUE; + cg$rec.DESCRIPTION := cg$APPLICATION_PARAMETERS.cg$table(idx).DESCRIPTION; + cg$APPLICATION_PARAMETERS.cg$tableind(idx).DESCRIPTION := TRUE; + + cg$APPLICATION_PARAMETERS.validate_foreign_keys_del(cg$rec); + cg$APPLICATION_PARAMETERS.upd_oper_denorm2( cg$rec, + cg$old_rec, + cg$APPLICATION_PARAMETERS.cg$tableind(idx), + 'DEL' + ); + + cg$APPLICATION_PARAMETERS.cascade_delete(cg$rec); + cg$APPLICATION_PARAMETERS.domain_cascade_delete(cg$rec); + + idx := cg$APPLICATION_PARAMETERS.cg$table.NEXT(idx); + END LOOP; + END IF; + +-- Application_logic Post-After-Delete-statement <> +-- Application_logic Post-After-Delete-statement << End >> + +END; +/ + + + diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/Account Locking Unit Test Script.doc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/Account Locking Unit Test Script.doc new file mode 100644 index 0000000..0d508ac Binary files /dev/null and b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/Account Locking Unit Test Script.doc differ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/Commercial Confirmations Unit Test Script.doc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/Commercial Confirmations Unit Test Script.doc new file mode 100644 index 0000000..ff9a532 Binary files /dev/null and b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/Commercial Confirmations Unit Test Script.doc differ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.PKB b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.PKB new file mode 100644 index 0000000..a2296eb --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.PKB @@ -0,0 +1,956 @@ + +PROMPT Creating API Package Body for Table 'NOM_WINDOW_CONTRACTS' +-------------------------------------------------------------------------------- +-- Name: cg$NOM_WINDOW_CONTRACTS +-- Description: NOM_WINDOW_CONTRACTS table API package definitions +-------------------------------------------------------------------------------- +CREATE OR REPLACE PACKAGE BODY cg$NOM_WINDOW_CONTRACTS IS + +PROCEDURE validate_mandatory(cg$val_rec IN cg$row_type, + loc IN VARCHAR2 DEFAULT ''); +PROCEDURE up_autogen_columns(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + operation IN VARCHAR2 DEFAULT 'INS', + do_denorm IN BOOLEAN DEFAULT TRUE); +PROCEDURE err_msg(msg IN VARCHAR2, + type IN INTEGER, + loc IN VARCHAR2 DEFAULT ''); + +-------------------------------------------------------------------------------- +-- Name: raise_uk_not_updateable +-- +-- Description: Raise appropriate error when unique key updated +-- +-- Parameters: none +-------------------------------------------------------------------------------- +PROCEDURE raise_uk_not_updateable(uk IN VARCHAR2) IS +BEGIN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_UNIQUE_KEY_UPDATE, cg$errors.ERR_UK_UPDATE, uk), + 'E', + 'API', + cg$errors.API_UNIQUE_KEY_UPDATE, + 'cg$NOM_WINDOW_CONTRACTS.raise_uk_not_updateable'); + cg$errors.raise_failure; +END raise_uk_not_updateable; + + +-------------------------------------------------------------------------------- +-- Name: raise_fk_not_transferable +-- +-- Description: Raise appropriate error when foreign key updated +-- +-- Parameters: none +-------------------------------------------------------------------------------- +PROCEDURE raise_fk_not_transferable(fk IN VARCHAR2) IS +BEGIN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_FOREIGN_KEY_TRANS, cg$errors.ERR_FK_TRANS, fk), + 'E', + 'API', + cg$errors.API_FOREIGN_KEY_TRANS, + 'cg$NOM_WINDOW_CONTRACTS.raise_fk_not_transferable'); + cg$errors.raise_failure; +END raise_fk_not_transferable; + + +-------------------------------------------------------------------------------- +-- Name: up_autogen_columns +-- +-- Description: Specific autogeneration of column values and conversion to +-- uppercase +-- +-- Parameters: cg$rec Record of row to be manipulated +-- cg$ind Indicators for row +-- operation Procedure where this procedure was called +-------------------------------------------------------------------------------- +PROCEDURE up_autogen_columns(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + operation IN VARCHAR2 DEFAULT 'INS', + do_denorm IN BOOLEAN DEFAULT TRUE) IS +BEGIN + IF (operation = 'INS') THEN + BEGIN + IF (cg$ind.NOWC_ID = FALSE + OR cg$rec.NOWC_ID is NULL) THEN + SELECT NOWC_SEQ.nextval + INTO cg$rec.NOWC_ID + FROM DUAL; + cg$ind.NOWC_ID := TRUE; + END IF; + EXCEPTION WHEN others THEN + cg$errors.push(SQLERRM, 'E', 'ORA', SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.up_autogen.NOWC_ID.OTHERS'); + cg$errors.raise_failure; + END; + NULL; + ELSE -- (operation = 'UPD') + NULL; + END IF; -- (operation = 'INS') ELSE (operation = 'UPD') + + -- Statements executed for both 'INS' and 'UPD' + + +EXCEPTION + WHEN no_data_found THEN + NULL; + WHEN others THEN + cg$errors.push( SQLERRM, 'E', 'ORA', SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.up_autogen_columns'); + cg$errors.raise_failure; +END up_autogen_columns; + + +-------------------------------------------------------------------------------- +-- Name: validate_mandatory +-- +-- Description: Checks all mandatory columns are not null and raises appropriate +-- error if not satisfied +-- +-- Parameters: cg$val_rec Record of row to be checked +-- loc Place where this procedure was called for error +-- trapping +-------------------------------------------------------------------------------- +PROCEDURE validate_mandatory(cg$val_rec IN cg$row_type, + loc IN VARCHAR2 DEFAULT '') IS +BEGIN + IF (cg$val_rec.CONT_ID IS NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_MAND_COLUMN_ISNULL, cg$errors.VAL_MAND, P1CONT_ID), + 'E', + 'API', + cg$errors.API_MAND_COLUMN_ISNULL, + loc); + END IF; + IF (cg$val_rec.NOWI_ID IS NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_MAND_COLUMN_ISNULL, cg$errors.VAL_MAND, P2NOWI_ID), + 'E', + 'API', + cg$errors.API_MAND_COLUMN_ISNULL, + loc); + END IF; + IF (cg$val_rec.NOWC_ID IS NULL) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_MAND_COLUMN_ISNULL, cg$errors.VAL_MAND, P3NOWC_ID), + 'E', + 'API', + cg$errors.API_MAND_COLUMN_ISNULL, + loc); + END IF; + NULL; +END validate_mandatory; + + +-------------------------------------------------------------------------------- +-- Name: validate_foreign_keys +-- +-- Description: Checks all mandatory columns are not null and raises appropriate +-- error if not satisfied +-- +-- Parameters: cg$rec Record of row to be checked +-------------------------------------------------------------------------------- +PROCEDURE validate_foreign_keys_ins(cg$rec IN cg$row_type) IS + fk_check INTEGER; +BEGIN +NULL; +END; + +PROCEDURE validate_foreign_keys_upd( cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type) IS + fk_check INTEGER; +BEGIN +NULL; +END; + +PROCEDURE validate_foreign_keys_del(cg$rec IN cg$row_type) IS + fk_check INTEGER; +BEGIN +NULL; +END; + + +-------------------------------------------------------------------------------- +-- Name: slct +-- +-- Description: Selects into the given parameter all the attributes for the row +-- given by the primary key +-- +-- Parameters: cg$sel_rec Record of row to be selected into using its PK +-------------------------------------------------------------------------------- +PROCEDURE slct(cg$sel_rec IN OUT cg$row_type) IS + +BEGIN + + IF cg$sel_rec.the_rowid is null THEN + SELECT CONT_ID + , NOWI_ID + , NOWC_ID + , rowid + INTO cg$sel_rec.CONT_ID + , cg$sel_rec.NOWI_ID + , cg$sel_rec.NOWC_ID + ,cg$sel_rec.the_rowid + FROM NOM_WINDOW_CONTRACTS + WHERE NOWC_ID = cg$sel_rec.NOWC_ID; + ELSE + SELECT CONT_ID + , NOWI_ID + , NOWC_ID + , rowid + INTO cg$sel_rec.CONT_ID + , cg$sel_rec.NOWI_ID + , cg$sel_rec.NOWC_ID + ,cg$sel_rec.the_rowid + FROM NOM_WINDOW_CONTRACTS + WHERE rowid = cg$sel_rec.the_rowid; + END IF; + +EXCEPTION WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.slct.others'); + cg$errors.raise_failure; + +END slct; + + +-------------------------------------------------------------------------------- +-- Name: cascade_update +-- +-- Description: Updates all child tables affected by a change to NOM_WINDOW_CONTRACTS +-- +-- Parameters: cg$rec Record of NOM_WINDOW_CONTRACTS current values +-- cg$old_rec Record of NOM_WINDOW_CONTRACTS previous values +-------------------------------------------------------------------------------- +PROCEDURE cascade_update(cg$new_rec IN OUT cg$row_type, + cg$old_rec IN cg$row_type) IS +BEGIN + NULL; +END cascade_update; + + +-------------------------------------------------------------------------------- +-- Name: validate_domain_cascade_update +-- +-- Description: Implement the Domain Key Constraint Cascade Updates Resticts rule +-- of each child table that references this tableNOM_WINDOW_CONTRACTS +-- +-- Parameters: cg$old_rec Record of NOM_WINDOW_CONTRACTS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_domain_cascade_update( cg$old_rec IN cg$row_type ) IS + dk_check INTEGER; +BEGIN + NULL; +END validate_domain_cascade_update; + + +----------------------------------------------------------------------------------------- +-- Name: domain_cascade_update +-- +-- Description: Implement the Domain Key Constraint Cascade Updates rules of each +-- child table that references this table NOM_WINDOW_CONTRACTS +-- +-- Parameters: cg$new_rec New values for NOM_WINDOW_CONTRACTS's domain key constraint columns +-- cg$new_ind Indicates changed NOM_WINDOW_CONTRACTS's domain key constraint columns +-- cg$old_rec Current values for NOM_WINDOW_CONTRACTS's domain key constraint columns +----------------------------------------------------------------------------------------- +PROCEDURE domain_cascade_update(cg$new_rec IN OUT cg$row_type, + cg$new_ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type) IS +BEGIN + NULL; +END domain_cascade_update; + + +-------------------------------------------------------------------------------- +-- Name: cascade_delete +-- +-- Description: Delete all child tables affected by a delete to NOM_WINDOW_CONTRACTS +-- +-- Parameters: cg$rec Record of NOM_WINDOW_CONTRACTS current values +-------------------------------------------------------------------------------- +PROCEDURE cascade_delete(cg$old_rec IN OUT cg$row_type) +IS +BEGIN + NULL; +END cascade_delete; + +-------------------------------------------------------------------------------- +-- Name: domain_cascade_delete +-- +-- Description: Implement the Domain Key Constraint Cascade Delete rules of each +-- child table that references this tableNOM_WINDOW_CONTRACTS +-- +-- Parameters: cg$old_rec Record of NOM_WINDOW_CONTRACTS current values +-------------------------------------------------------------------------------- +PROCEDURE domain_cascade_delete( cg$old_rec IN cg$row_type ) +IS +BEGIN + NULL; +END domain_cascade_delete; + + +-------------------------------------------------------------------------------- +-- Name: validate_domain_cascade_delete +-- +-- Description: Implement the Domain Key Constraint Cascade Delete Restricts rule +-- of each child table that references this tableNOM_WINDOW_CONTRACTS +-- +-- Parameters: cg$old_rec Record of NOM_WINDOW_CONTRACTS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_domain_cascade_delete(cg$old_rec IN cg$row_type) +IS + dk_check INTEGER; +BEGIN + NULL; +END validate_domain_cascade_delete; + + + +-------------------------------------------------------------------------------- +-- Name: validate_arc +-- +-- Description: Checks for adherence to arc relationship +-- +-- Parameters: cg$rec Record of NOM_WINDOW_CONTRACTS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_arc(cg$rec IN OUT cg$row_type) IS +i NUMBER; +BEGIN + NULL; +END validate_arc; + + +-------------------------------------------------------------------------------- +-- Name: validate_domain +-- +-- Description: Checks against reference table for values lying in a domain +-- +-- Parameters: cg$rec Record of NOM_WINDOW_CONTRACTS current values +-------------------------------------------------------------------------------- +PROCEDURE validate_domain(cg$rec IN OUT cg$row_type, + cg$ind IN cg$ind_type DEFAULT cg$ind_true) +IS + dummy NUMBER; + found BOOLEAN; + no_tabview EXCEPTION; + PRAGMA EXCEPTION_INIT(no_tabview, -942); +BEGIN + + + + + + NULL; + +EXCEPTION + WHEN cg$errors.cg$error THEN + cg$errors.raise_failure; + WHEN no_tabview THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_RV_TAB_NOT_FOUND, + cg$errors.APIMSG_RV_TAB_NOT_FOUND, + 'CG_REF_CODES','NOM_WINDOW_CONTRACTS'), + 'E', + 'API', + cg$errors.API_RV_TAB_NOT_FOUND, + 'cg$NOM_WINDOW_CONTRACTS.v_domain.no_reftable_found'); + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.v_domain.others'); + cg$errors.raise_failure; +END validate_domain; + + +-------------------------------------------------------------------------------- +-- Name: err_msg +-- +-- Description: Pushes onto stack appropriate user defined error message +-- depending on the rule violated +-- +-- Parameters: msg Oracle error message +-- type Type of violation e.g. check_constraint: ERR_CHECK_CON +-- loc Place where this procedure was called for error +-- trapping +-------------------------------------------------------------------------------- +PROCEDURE err_msg(msg IN VARCHAR2, + type IN INTEGER, + loc IN VARCHAR2 DEFAULT '') IS +con_name VARCHAR2(240); +BEGIN + con_name := cg$errors.parse_constraint(msg, type); + IF (con_name = 'NOWC_PK') THEN + cg$errors.push(nvl(NOWC_PK + ,cg$errors.MsgGetText(cg$errors.API_PK_CON_VIOLATED + ,cg$errors.APIMSG_PK_VIOLAT + ,'NOWC_PK' + ,'NOM_WINDOW_CONTRACTS')), + 'E', + 'API', + cg$errors.API_PK_CON_VIOLATED, + loc); + + ELSIF (con_name = 'NOWC_CUST_FK') THEN + cg$errors.push(nvl(NOWC_CUST_FK + ,cg$errors.MsgGetText(cg$errors.API_FK_CON_VIOLATED + ,cg$errors.APIMSG_FK_VIOLAT + ,'NOWC_CUST_FK' + ,'NOM_WINDOW_CONTRACTS')), + 'E', + 'API', + cg$errors.API_FK_CON_VIOLATED, + loc); + ELSIF (con_name = 'NOWC_NOWI_FK') THEN + cg$errors.push(nvl(NOWC_NOWI_FK + ,cg$errors.MsgGetText(cg$errors.API_FK_CON_VIOLATED + ,cg$errors.APIMSG_FK_VIOLAT + ,'NOWC_NOWI_FK' + ,'NOM_WINDOW_CONTRACTS')), + 'E', + 'API', + cg$errors.API_FK_CON_VIOLATED, + loc); + ELSE + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + loc); + END IF; +END err_msg; + + + + +-------------------------------------------------------------------------------- +-- Name: doLobs +-- +-- Description: This function is updating lob columns +-- +-- Parameters: cg$rec Record of row to be inserted +-- cg$ind Record of columns specifically set +-------------------------------------------------------------------------------- +PROCEDURE doLobs(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type) IS +BEGIN + NULL; +END doLobs; + + +-------------------------------------------------------------------------------- +-- Name: ins +-- +-- Description: API insert procedure +-- +-- Parameters: cg$rec Record of row to be inserted +-- cg$ind Record of columns specifically set +-- do_ins Whether we want the actual INSERT to occur +-------------------------------------------------------------------------------- +PROCEDURE ins(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_ins IN BOOLEAN DEFAULT TRUE) IS +cg$tmp_rec cg$row_type; + +-- Constant default values + + +BEGIN +-- Application_logic Pre-Insert <> +-- Application_logic Pre-Insert << End >> + +-- Defaulted + +-- Auto-generated and uppercased columns + + up_autogen_columns(cg$rec, cg$ind, 'INS', do_ins); + + called_from_package := TRUE; + + IF (do_ins) THEN + validate_foreign_keys_ins(cg$rec); + validate_arc(cg$rec); + validate_domain(cg$rec); + + INSERT INTO NOM_WINDOW_CONTRACTS + (CONT_ID + ,NOWI_ID + ,NOWC_ID) + VALUES + (cg$rec.CONT_ID + ,cg$rec.NOWI_ID + ,cg$rec.NOWC_ID +); + doLobs(cg$rec, cg$ind); + slct(cg$rec); + + upd_oper_denorm2(cg$rec, cg$tmp_rec, cg$ind, 'INS'); + END IF; + + called_from_package := FALSE; + + + +-- Application logic Post-Insert <> +-- Application logic Post-Insert << End >> + +EXCEPTION + WHEN cg$errors.cg$error THEN + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.mandatory_missing THEN + validate_mandatory(cg$rec, 'cg$NOM_WINDOW_CONTRACTS.ins.mandatory_missing'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.check_violation THEN + err_msg(SQLERRM, cg$errors.ERR_CHECK_CON, 'cg$NOM_WINDOW_CONTRACTS.ins.check_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.fk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_FOREIGN_KEY, 'cg$NOM_WINDOW_CONTRACTS.ins.fk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.uk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_UNIQUE_KEY, 'cg$NOM_WINDOW_CONTRACTS.ins.uk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.ins.others'); + called_from_package := FALSE; + cg$errors.raise_failure; +END ins; + + +-------------------------------------------------------------------------------- +-- Name: upd +-- +-- Description: API update procedure +-- +-- Parameters: cg$rec Record of row to be updated +-- cg$ind Record of columns specifically set +-- do_upd Whether we want the actual UPDATE to occur +-------------------------------------------------------------------------------- +PROCEDURE upd(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_upd IN BOOLEAN DEFAULT TRUE, + cg$pk IN cg$row_type DEFAULT NULL ) +IS + cg$upd_rec cg$row_type; + cg$old_rec cg$row_type; + RECORD_LOGGED BOOLEAN := FALSE; +BEGIN +-- Application_logic Pre-Update <> +-- Application_logic Pre-Update << End >> + + + IF ( cg$pk.NOWC_ID IS NULL ) THEN + cg$upd_rec.NOWC_ID := cg$rec.NOWC_ID; + ELSE + cg$upd_rec.NOWC_ID := cg$pk.NOWC_ID; + END IF; + cg$old_rec.NOWC_ID := cg$upd_rec.NOWC_ID; + + IF ( cg$pk.the_rowid IS NULL ) THEN + cg$upd_rec.the_rowid := cg$rec.the_rowid; + ELSE + cg$upd_rec.the_rowid := cg$pk.the_rowid; + END IF; + cg$old_rec.the_rowid := cg$upd_rec.the_rowid; + + IF ( do_upd ) THEN + + slct(cg$upd_rec); + + + -- Report error if attempt to update non updateable Primary Key NOWC_PK + IF (cg$ind.NOWC_ID AND cg$rec.NOWC_ID != cg$upd_rec.NOWC_ID) THEN + raise_uk_not_updateable('NOWC_PK'); + END IF; + IF NOT (cg$ind.CONT_ID) THEN + cg$rec.CONT_ID := cg$upd_rec.CONT_ID; + END IF; + IF NOT (cg$ind.NOWI_ID) THEN + cg$rec.NOWI_ID := cg$upd_rec.NOWI_ID; + END IF; + IF NOT (cg$ind.NOWC_ID) THEN + cg$rec.NOWC_ID := cg$upd_rec.NOWC_ID; + END IF; + ELSE + -- Perform checks if called from a trigger + -- Indicators are only set on changed values + null; + -- Report error if attempt to update non updateable Primary Key NOWC_PK + IF ( cg$ind.NOWC_ID ) THEN + raise_uk_not_updateable('NOWC_PK'); + END IF; + END IF; + + up_autogen_columns(cg$rec, cg$ind, 'UPD', do_upd); -- Auto-generated and uppercased columns + +-- Now do update if updateable columns exist + IF (do_upd) THEN + DECLARE + called_from BOOLEAN := called_from_package; + BEGIN + called_from_package := TRUE; + + slct(cg$old_rec); + validate_foreign_keys_upd(cg$rec, cg$old_rec, cg$ind); + validate_arc(cg$rec); + validate_domain(cg$rec, cg$ind); + validate_domain_cascade_update(cg$old_rec); + + IF cg$rec.the_rowid is null THEN + UPDATE NOM_WINDOW_CONTRACTS + SET + CONT_ID = cg$rec.CONT_ID + ,NOWI_ID = cg$rec.NOWI_ID + WHERE NOWC_ID = cg$rec.NOWC_ID; + null; + ELSE + UPDATE NOM_WINDOW_CONTRACTS + SET + CONT_ID = cg$rec.CONT_ID + ,NOWI_ID = cg$rec.NOWI_ID + WHERE rowid = cg$rec.the_rowid; + + null; + END IF; + + slct(cg$rec); + + upd_denorm2(cg$rec, cg$ind); + upd_oper_denorm2(cg$rec, cg$old_rec, cg$ind, 'UPD'); + cascade_update(cg$rec, cg$old_rec); + domain_cascade_update(cg$rec, cg$ind, cg$old_rec); + called_from_package := called_from; + END; + END IF; + + + + IF NOT (do_upd) THEN + cg$table(idx).CONT_ID := cg$rec.CONT_ID; + cg$tableind(idx).CONT_ID := cg$ind.CONT_ID; + cg$table(idx).NOWI_ID := cg$rec.NOWI_ID; + cg$tableind(idx).NOWI_ID := cg$ind.NOWI_ID; + cg$table(idx).NOWC_ID := cg$rec.NOWC_ID; + cg$tableind(idx).NOWC_ID := cg$ind.NOWC_ID; + idx := idx + 1; + END IF; + +-- Application_logic Post-Update <> +-- Application_logic Post-Update << End >> + +EXCEPTION + WHEN cg$errors.cg$error THEN + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.upd_mandatory_null THEN + validate_mandatory(cg$rec, 'cg$NOM_WINDOW_CONTRACTS.upd.upd_mandatory_null'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.check_violation THEN + err_msg(SQLERRM, cg$errors.ERR_CHECK_CON, 'cg$NOM_WINDOW_CONTRACTS.upd.check_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.fk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_FOREIGN_KEY, 'cg$NOM_WINDOW_CONTRACTS.upd.fk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.uk_violation THEN + err_msg(SQLERRM, cg$errors.ERR_UNIQUE_KEY, 'cg$NOM_WINDOW_CONTRACTS.upd.uk_violation'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.upd.others'); + called_from_package := FALSE; + cg$errors.raise_failure; +END upd; + + +---------------------------------------------------------------------------------------- +-- Name: domain_cascade_upd +-- +-- Description: Update the Domain Constraint Key columns of NOM_WINDOW_CONTRACTS when the +-- Cascade Update rule is Cascades and the domain table has been +-- updated. Called from .domain_cascade_update(). +-- +-- Parameters: cg$rec New values for NOM_WINDOW_CONTRACTS's domain key constraint columns +-- cg$ind Indicates changed NOM_WINDOW_CONTRACTS's domain key constraint columns +-- cg$old_rec Current values for NOM_WINDOW_CONTRACTS's domain key constraint columns +---------------------------------------------------------------------------------------- +PROCEDURE domain_cascade_upd( cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type ) +IS + called_from BOOLEAN := called_from_package; +BEGIN + + null; +END domain_cascade_upd; + + +-------------------------------------------------------------------------------- +-- Name: upd_denorm +-- +-- Description: API procedure for simple denormalization +-- +-- Parameters: cg$rec Record of row to be updated +-- cg$ind Record of columns specifically set +-- do_upd Whether we want the actual UPDATE to occur +-------------------------------------------------------------------------------- +PROCEDURE upd_denorm2( cg$rec IN cg$row_type, + cg$ind IN cg$ind_type ) IS +BEGIN + NULL; +END upd_denorm2; + + +-------------------------------------------------------------------------------- +-- Name: upd_oper_denorm +-- +-- Description: API procedure for operation denormalization +-- +-- Parameters: cg$rec Record of row to be updated +-- cg$ind Record of columns specifically set +-- do_upd Whether we want the actual UPDATE to occur +-------------------------------------------------------------------------------- +PROCEDURE upd_oper_denorm2( cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type, + operation IN VARCHAR2 DEFAULT 'UPD' + ) +IS +BEGIN + + + +NULL; +END upd_oper_denorm2; + +-------------------------------------------------------------------------------- +-- Name: del +-- +-- Description: API delete procedure +-- +-- Parameters: cg$pk Primary key record of row to be deleted +-------------------------------------------------------------------------------- +PROCEDURE del(cg$pk IN cg$pk_type, + do_del IN BOOLEAN DEFAULT TRUE) IS +BEGIN +-- Application_logic Pre-Delete <> +-- Application_logic Pre-Delete << End >> + +-- Delete the record + + called_from_package := TRUE; + + IF (do_del) THEN + DECLARE + cg$rec cg$row_type; + cg$old_rec cg$row_type; + cg$ind cg$ind_type; + BEGIN + cg$rec.NOWC_ID := cg$pk.NOWC_ID; + slct(cg$rec); + + validate_foreign_keys_del(cg$rec); + validate_domain_cascade_delete(cg$rec); + + IF cg$pk.the_rowid is null THEN + DELETE NOM_WINDOW_CONTRACTS + WHERE NOWC_ID = cg$pk.NOWC_ID; + ELSE + DELETE NOM_WINDOW_CONTRACTS + WHERE rowid = cg$pk.the_rowid; + END IF; + + upd_oper_denorm2(cg$rec, cg$old_rec, cg$ind, 'DEL'); + cascade_delete(cg$rec); + domain_cascade_delete(cg$rec); + END; + END IF; + + called_from_package := FALSE; + + +-- Application_logic Post-Delete <> +-- Application_logic Post-Delete << End >> + +EXCEPTION + WHEN cg$errors.cg$error THEN + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN cg$errors.delete_restrict THEN + err_msg(SQLERRM, cg$errors.ERR_DELETE_RESTRICT, 'cg$NOM_WINDOW_CONTRACTS.del.delete_restrict'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN no_data_found THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_DEL, cg$errors.ROW_DEL), + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.del.no_data_found'); + called_from_package := FALSE; + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.del.others'); + called_from_package := FALSE; + cg$errors.raise_failure; +END del; + + +-------------------------------------------------------------------------------- +-- Name: lck +-- +-- Description: API lock procedure +-- +-- Parameters: cg$old_rec Calling apps view of record of row to be locked +-- cg$old_ind Record of columns to raise error if modified +-- nowait_flag TRUE lock with NOWAIT, FALSE don't fail if busy +-------------------------------------------------------------------------------- +PROCEDURE lck(cg$old_rec IN cg$row_type, + cg$old_ind IN cg$ind_type, + nowait_flag IN BOOLEAN DEFAULT TRUE) IS +cg$tmp_rec cg$row_type; +any_modified BOOLEAN := FALSE; + +BEGIN +-- Application_logic Pre-Lock <> +-- Application_logic Pre-Lock << End >> + +-- Do the row lock + + BEGIN + IF (nowait_flag) THEN + IF cg$old_rec.the_rowid is null THEN + SELECT CONT_ID + , NOWI_ID + , NOWC_ID + INTO cg$tmp_rec.CONT_ID + , cg$tmp_rec.NOWI_ID + , cg$tmp_rec.NOWC_ID + FROM NOM_WINDOW_CONTRACTS + WHERE NOWC_ID = cg$old_rec.NOWC_ID + FOR UPDATE NOWAIT; + ELSE + SELECT CONT_ID + , NOWI_ID + , NOWC_ID + INTO cg$tmp_rec.CONT_ID + , cg$tmp_rec.NOWI_ID + , cg$tmp_rec.NOWC_ID + FROM NOM_WINDOW_CONTRACTS + WHERE rowid = cg$old_rec.the_rowid + FOR UPDATE NOWAIT; + END IF; + ELSE + IF cg$old_rec.the_rowid is null THEN + SELECT CONT_ID + , NOWI_ID + , NOWC_ID + INTO cg$tmp_rec.CONT_ID + , cg$tmp_rec.NOWI_ID + , cg$tmp_rec.NOWC_ID + FROM NOM_WINDOW_CONTRACTS + WHERE NOWC_ID = cg$old_rec.NOWC_ID + FOR UPDATE; + ELSE + SELECT CONT_ID + , NOWI_ID + , NOWC_ID + INTO cg$tmp_rec.CONT_ID + , cg$tmp_rec.NOWI_ID + , cg$tmp_rec.NOWC_ID + FROM NOM_WINDOW_CONTRACTS + WHERE rowid = cg$old_rec.the_rowid + FOR UPDATE; + END IF; + END IF; + + EXCEPTION + WHEN cg$errors.cg$error THEN + cg$errors.raise_failure; + WHEN cg$errors.resource_busy THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_LCK, cg$errors.ROW_LCK), + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.lck.resource_busy'); + cg$errors.raise_failure; + WHEN no_data_found THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_DEL, cg$errors.ROW_DEL), + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.lck.no_data_found'); + cg$errors.raise_failure; + WHEN OTHERS THEN + cg$errors.push(SQLERRM, + 'E', + 'ORA', + SQLCODE, + 'cg$NOM_WINDOW_CONTRACTS.lck.others'); + cg$errors.raise_failure; + END; + +-- Optional Columns + + +-- Mandatory Columns + + IF (cg$old_ind.CONT_ID) THEN + IF (cg$tmp_rec.CONT_ID != cg$old_rec.CONT_ID) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P1CONT_ID + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$NOM_WINDOW_CONTRACTS.lck'); + any_modified := TRUE; + END IF; + END IF; + IF (cg$old_ind.NOWI_ID) THEN + IF (cg$tmp_rec.NOWI_ID != cg$old_rec.NOWI_ID) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P2NOWI_ID + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$NOM_WINDOW_CONTRACTS.lck'); + any_modified := TRUE; + END IF; + END IF; + IF (cg$old_ind.NOWC_ID) THEN + IF (cg$tmp_rec.NOWC_ID != cg$old_rec.NOWC_ID) THEN + cg$errors.push(cg$errors.MsgGetText(cg$errors.API_ROW_MOD, cg$errors.ROW_MOD, P3NOWC_ID + ),'E', 'API', CG$ERRORS.API_MODIFIED, 'cg$NOM_WINDOW_CONTRACTS.lck'); + any_modified := TRUE; + END IF; + END IF; + + IF (any_modified) THEN + cg$errors.raise_failure; + END IF; + +-- Application_logic Post-Lock <> +-- Application_logic Post-Lock << End >> + +END lck; + + +BEGIN + cg$ind_true.CONT_ID := TRUE; + cg$ind_true.NOWI_ID := TRUE; + cg$ind_true.NOWC_ID := TRUE; + + +END cg$NOM_WINDOW_CONTRACTS; +/ + diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.PKS b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.PKS new file mode 100644 index 0000000..b85822c --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.PKS @@ -0,0 +1,107 @@ + +PROMPT Creating API Package Specification for Table 'NOM_WINDOW_CONTRACTS' +-------------------------------------------------------------------------------- +-- Name: cg$NOM_WINDOW_CONTRACTS +-- Description: NOM_WINDOW_CONTRACTS table API package declarations +-------------------------------------------------------------------------------- +CREATE OR REPLACE PACKAGE cg$NOM_WINDOW_CONTRACTS IS + +called_from_package BOOLEAN := FALSE; + +-- Repository User-Defined Error Messages +NOWC_PK CONSTANT VARCHAR2(240) := ''; +NOWC_CUST_FK CONSTANT VARCHAR2(240) := ''; +NOWC_NOWI_FK CONSTANT VARCHAR2(240) := ''; + +-- Column default prompts. Format PSEQNO_COL +P1CONT_ID CONSTANT VARCHAR2(240) := 'Cust Id'; +P2NOWI_ID CONSTANT VARCHAR2(240) := 'Nowi Id'; +P3NOWC_ID CONSTANT VARCHAR2(240) := 'Nowc Id'; + +cg$row NOM_WINDOW_CONTRACTS%ROWTYPE; + +-- NOM_WINDOW_CONTRACTS row type variable +TYPE cg$row_type IS RECORD +(CONT_ID cg$row.CONT_ID%TYPE +,NOWI_ID cg$row.NOWI_ID%TYPE +,NOWC_ID cg$row.NOWC_ID%TYPE +,the_rowid ROWID) +; + +-- NOM_WINDOW_CONTRACTS indicator type variable +TYPE cg$ind_type IS RECORD +(CONT_ID BOOLEAN DEFAULT FALSE +,NOWI_ID BOOLEAN DEFAULT FALSE +,NOWC_ID BOOLEAN DEFAULT FALSE); + +cg$ind_true cg$ind_type; + +-- NOM_WINDOW_CONTRACTS primary key type variable +TYPE cg$pk_type IS RECORD +(NOWC_ID cg$row.NOWC_ID%TYPE +,the_rowid ROWID) +; + +-- PL/SQL Table Type variable for triggers +TYPE cg$table_type IS TABLE OF NOM_WINDOW_CONTRACTS%ROWTYPE + INDEX BY BINARY_INTEGER; +cg$table cg$table_type; + +TYPE cg$tableind_type IS TABLE OF cg$ind_type + INDEX BY BINARY_INTEGER; +cg$tableind cg$tableind_type; +idx BINARY_INTEGER := 1; + +PROCEDURE ins(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_ins IN BOOLEAN DEFAULT TRUE + ); +PROCEDURE upd(cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + do_upd IN BOOLEAN DEFAULT TRUE, + cg$pk IN cg$row_type DEFAULT NULL + ); +PROCEDURE del(cg$pk IN cg$pk_type, + do_del IN BOOLEAN DEFAULT TRUE + ); +PROCEDURE lck(cg$old_rec IN cg$row_type, + cg$old_ind IN cg$ind_type, + nowait_flag IN BOOLEAN DEFAULT TRUE + ); +PROCEDURE slct(cg$sel_rec IN OUT cg$row_type); + +PROCEDURE validate_arc(cg$rec IN OUT cg$row_type); + +PROCEDURE validate_domain(cg$rec IN OUT cg$row_type, + cg$ind IN cg$ind_type DEFAULT cg$ind_true); + +PROCEDURE validate_foreign_keys_ins(cg$rec IN cg$row_type); +PROCEDURE validate_foreign_keys_upd(cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type); +PROCEDURE validate_foreign_keys_del(cg$rec IN cg$row_type); + +PROCEDURE validate_domain_cascade_delete(cg$old_rec IN cg$row_type); +PROCEDURE validate_domain_cascade_update(cg$old_rec IN cg$row_type); + +PROCEDURE cascade_update(cg$new_rec IN OUT cg$row_type, + cg$old_rec IN cg$row_type ); +PROCEDURE domain_cascade_update(cg$new_rec IN OUT cg$row_type, + cg$new_ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type); +PROCEDURE domain_cascade_upd( cg$rec IN OUT cg$row_type, + cg$ind IN OUT cg$ind_type, + cg$old_rec IN cg$row_type); + +PROCEDURE cascade_delete(cg$old_rec IN OUT cg$row_type); +PROCEDURE domain_cascade_delete(cg$old_rec IN cg$row_type); + +PROCEDURE upd_denorm2( cg$rec IN cg$row_type, + cg$ind IN cg$ind_type ); +PROCEDURE upd_oper_denorm2( cg$rec IN cg$row_type, + cg$old_rec IN cg$row_type, + cg$ind IN cg$ind_type, + operation IN VARCHAR2 DEFAULT 'UPD' ); +END cg$NOM_WINDOW_CONTRACTS; +/ + diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.TRG b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.TRG new file mode 100644 index 0000000..21a52a7 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/NOWC.TRG @@ -0,0 +1,356 @@ + +PROMPT Creating Trigger Logic for Table 'NOM_WINDOW_CONTRACTS' +PROMPT Creating Before Insert Statement Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$BIS_NOM_WINDOW_CONTRACTS +BEFORE INSERT ON NOM_WINDOW_CONTRACTS +BEGIN +-- Application_logic Pre-Before-Insert-statement <> +-- Application_logic Pre-Before-Insert-statement << End >> + + cg$NOM_WINDOW_CONTRACTS.cg$table.DELETE; + cg$NOM_WINDOW_CONTRACTS.cg$tableind.DELETE; + cg$NOM_WINDOW_CONTRACTS.idx := 1; + +-- Application_logic Post-Before-Insert-statement <> +-- Application_logic Post-Before-Insert-statement << End >> +END; +/ + + +PROMPT Creating Before Insert Row Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$BIR_NOM_WINDOW_CONTRACTS +BEFORE INSERT ON NOM_WINDOW_CONTRACTS FOR EACH ROW +DECLARE + cg$rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$ind cg$NOM_WINDOW_CONTRACTS.cg$ind_type; +BEGIN +-- Application_logic Pre-Before-Insert-row <> +-- Application_logic Pre-Before-Insert-row << End >> + +-- Load cg$rec/cg$ind values from new + + cg$rec.CONT_ID := :new.CONT_ID; + cg$ind.CONT_ID := TRUE; + cg$rec.NOWI_ID := :new.NOWI_ID; + cg$ind.NOWI_ID := TRUE; + cg$rec.NOWC_ID := :new.NOWC_ID; + cg$ind.NOWC_ID := TRUE; + + if not (cg$NOM_WINDOW_CONTRACTS.called_from_package) then + cg$NOM_WINDOW_CONTRACTS.validate_arc(cg$rec); + cg$NOM_WINDOW_CONTRACTS.validate_domain(cg$rec); + + cg$NOM_WINDOW_CONTRACTS.ins(cg$rec, cg$ind, FALSE); + cg$NOM_WINDOW_CONTRACTS.called_from_package := FALSE; + end if; + + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).CONT_ID := cg$rec.CONT_ID; + cg$NOM_WINDOW_CONTRACTS.cg$tableind(cg$NOM_WINDOW_CONTRACTS.idx).CONT_ID := cg$ind.CONT_ID; + + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).NOWI_ID := cg$rec.NOWI_ID; + cg$NOM_WINDOW_CONTRACTS.cg$tableind(cg$NOM_WINDOW_CONTRACTS.idx).NOWI_ID := cg$ind.NOWI_ID; + + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).NOWC_ID := cg$rec.NOWC_ID; + cg$NOM_WINDOW_CONTRACTS.cg$tableind(cg$NOM_WINDOW_CONTRACTS.idx).NOWC_ID := cg$ind.NOWC_ID; + + cg$NOM_WINDOW_CONTRACTS.idx := cg$NOM_WINDOW_CONTRACTS.idx + 1; + + :new.CONT_ID := cg$rec.CONT_ID; + :new.NOWI_ID := cg$rec.NOWI_ID; + :new.NOWC_ID := cg$rec.NOWC_ID; + +-- Application_logic Post-Before-Insert-row <> +-- Application_logic Post-Before-Insert-row << End >> +END; +/ + + +-- No application logic defined for Trigger cg$AIR_NOM_WINDOW_CONTRACTS, so drop it. +-- To avoid an error if there isn't one, create or replace it, and then drop it +CREATE OR REPLACE TRIGGER cg$AIR_NOM_WINDOW_CONTRACTS +AFTER INSERT ON NOM_WINDOW_CONTRACTS FOR EACH ROW +BEGIN + null; +END; +/ +drop trigger cg$AIR_NOM_WINDOW_CONTRACTS +/ + +PROMPT Creating After Insert Statement Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$AIS_NOM_WINDOW_CONTRACTS +AFTER INSERT ON NOM_WINDOW_CONTRACTS +DECLARE + idx BINARY_INTEGER := cg$NOM_WINDOW_CONTRACTS.cg$table.FIRST; + cg$rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$old_rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + fk_check INTEGER; +BEGIN +-- Application_logic Pre-After-Insert-statement <> +-- Application_logic Pre-After-Insert-statement << End >> + + + IF NOT (cg$NOM_WINDOW_CONTRACTS.called_from_package) THEN + WHILE idx IS NOT NULL LOOP + cg$rec.CONT_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).CONT_ID; + cg$rec.NOWI_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWI_ID; + cg$rec.NOWC_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWC_ID; + + cg$NOM_WINDOW_CONTRACTS.validate_foreign_keys_ins(cg$rec); + + cg$NOM_WINDOW_CONTRACTS.upd_oper_denorm2( cg$rec, + cg$old_rec, + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx), + 'INS' + ); + + idx := cg$NOM_WINDOW_CONTRACTS.cg$table.NEXT(idx); + END LOOP; + END IF; + +-- Application_logic Post-After-Insert-statement <> +-- Application_logic Post-After-Insert-statement << End >> + +END; +/ + + + + +PROMPT Creating Before Update Statement Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$BUS_NOM_WINDOW_CONTRACTS +BEFORE UPDATE ON NOM_WINDOW_CONTRACTS +BEGIN +-- Application_logic Pre-Before-Update-statement <> +-- Application_logic Pre-Before-Update-statement << End >> + + cg$NOM_WINDOW_CONTRACTS.cg$table.DELETE; + cg$NOM_WINDOW_CONTRACTS.cg$tableind.DELETE; + cg$NOM_WINDOW_CONTRACTS.idx := 1; + +-- Application_logic Post-Before-Update-statement <> +-- Application_logic Post-Before-Update-statement << End >> + +END; +/ + + +PROMPT Creating Before Update Row Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$BUR_NOM_WINDOW_CONTRACTS +BEFORE UPDATE ON NOM_WINDOW_CONTRACTS FOR EACH ROW +DECLARE + cg$rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$ind cg$NOM_WINDOW_CONTRACTS.cg$ind_type; + cg$old_rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; +BEGIN +-- Application_logic Pre-Before-Update-row <> +-- Application_logic Pre-Before-Update-row << End >> + +-- Load cg$rec/cg$ind values from new + + cg$rec.CONT_ID := :new.CONT_ID; + cg$ind.CONT_ID := (:new.CONT_ID IS NULL AND :old.CONT_ID IS NOT NULL ) + OR (:new.CONT_ID IS NOT NULL AND :old.CONT_ID IS NULL) + OR NOT(:new.CONT_ID = :old.CONT_ID) ; + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).CONT_ID := :old.CONT_ID; + cg$rec.NOWI_ID := :new.NOWI_ID; + cg$ind.NOWI_ID := (:new.NOWI_ID IS NULL AND :old.NOWI_ID IS NOT NULL ) + OR (:new.NOWI_ID IS NOT NULL AND :old.NOWI_ID IS NULL) + OR NOT(:new.NOWI_ID = :old.NOWI_ID) ; + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).NOWI_ID := :old.NOWI_ID; + cg$rec.NOWC_ID := :new.NOWC_ID; + cg$ind.NOWC_ID := (:new.NOWC_ID IS NULL AND :old.NOWC_ID IS NOT NULL ) + OR (:new.NOWC_ID IS NOT NULL AND :old.NOWC_ID IS NULL) + OR NOT(:new.NOWC_ID = :old.NOWC_ID) ; + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).NOWC_ID := :old.NOWC_ID; + + + cg$NOM_WINDOW_CONTRACTS.idx := cg$NOM_WINDOW_CONTRACTS.idx + 1; + + if not (cg$NOM_WINDOW_CONTRACTS.called_from_package) then + cg$NOM_WINDOW_CONTRACTS.validate_arc(cg$rec); + cg$NOM_WINDOW_CONTRACTS.validate_domain(cg$rec, cg$ind); + cg$NOM_WINDOW_CONTRACTS.validate_domain_cascade_update(cg$old_rec); + + cg$NOM_WINDOW_CONTRACTS.upd(cg$rec, cg$ind, FALSE); + cg$NOM_WINDOW_CONTRACTS.called_from_package := FALSE; + end if; + + :new.CONT_ID := cg$rec.CONT_ID; + :new.NOWI_ID := cg$rec.NOWI_ID; +-- Application_logic Post-Before-Update-row <> +-- Application_logic Post-Before-Update-row << End >> +END; +/ + +-- No application logic defined for Trigger cg$AUR_NOM_WINDOW_CONTRACTS, so drop it. +-- To avoid an error if there isn't one, create or replace it, and then drop it +CREATE OR REPLACE TRIGGER cg$AUR_NOM_WINDOW_CONTRACTS +AFTER UPDATE ON NOM_WINDOW_CONTRACTS FOR EACH ROW +BEGIN + null; +END; +/ +drop trigger cg$AUR_NOM_WINDOW_CONTRACTS +/ + + + + + + +PROMPT Creating After Update Statement Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$AUS_NOM_WINDOW_CONTRACTS +AFTER UPDATE ON NOM_WINDOW_CONTRACTS +DECLARE + idx BINARY_INTEGER := cg$NOM_WINDOW_CONTRACTS.cg$table.FIRST; + cg$old_rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$ind cg$NOM_WINDOW_CONTRACTS.cg$ind_type; +BEGIN +-- Application_logic Pre-After-Update-statement <> +-- Application_logic Pre-After-Update-statement << End >> + + WHILE idx IS NOT NULL LOOP + cg$old_rec.CONT_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).CONT_ID; + cg$old_rec.NOWI_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWI_ID; + cg$old_rec.NOWC_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWC_ID; + + IF NOT (cg$NOM_WINDOW_CONTRACTS.called_from_package) THEN + idx := cg$NOM_WINDOW_CONTRACTS.cg$table.NEXT(idx); + cg$rec.CONT_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).CONT_ID; + cg$ind.CONT_ID := updating('CONT_ID'); + cg$rec.NOWI_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWI_ID; + cg$ind.NOWI_ID := updating('NOWI_ID'); + cg$rec.NOWC_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWC_ID; + cg$ind.NOWC_ID := updating('NOWC_ID'); + + cg$NOM_WINDOW_CONTRACTS.validate_foreign_keys_upd(cg$rec, cg$old_rec, cg$ind); + + cg$NOM_WINDOW_CONTRACTS.upd_denorm2( cg$rec, + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx) + ); + cg$NOM_WINDOW_CONTRACTS.upd_oper_denorm2( cg$rec, + cg$old_rec, + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx) + ); + cg$NOM_WINDOW_CONTRACTS.cascade_update(cg$rec, cg$old_rec); + cg$NOM_WINDOW_CONTRACTS.domain_cascade_update(cg$rec, cg$ind, cg$old_rec); + + cg$NOM_WINDOW_CONTRACTS.called_from_package := FALSE; + END IF; + idx := cg$NOM_WINDOW_CONTRACTS.cg$table.NEXT(idx); + END LOOP; + + cg$NOM_WINDOW_CONTRACTS.cg$table.DELETE; + +-- Application_logic Post-After-Update-statement <> +-- Application_logic Post-After-Update-statement << End >> + +END; +/ + +PROMPT Creating Before Delete Statement Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$BDS_NOM_WINDOW_CONTRACTS +BEFORE DELETE ON NOM_WINDOW_CONTRACTS +BEGIN +-- Application_logic Pre-Before-Delete-statement <> +-- Application_logic Pre-Before-Delete-statement << End >> + + cg$NOM_WINDOW_CONTRACTS.cg$table.DELETE; + cg$NOM_WINDOW_CONTRACTS.cg$tableind.DELETE; + cg$NOM_WINDOW_CONTRACTS.idx := 1; + +-- Application_logic Post-Before-Delete-statement <> +-- Application_logic Post-Before-Delete-statement << End >> +END; +/ + + +PROMPT Creating Before Delete Row Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$BDR_NOM_WINDOW_CONTRACTS +BEFORE DELETE ON NOM_WINDOW_CONTRACTS FOR EACH ROW +DECLARE + cg$pk cg$NOM_WINDOW_CONTRACTS.cg$pk_type; + cg$rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$ind cg$NOM_WINDOW_CONTRACTS.cg$ind_type; +BEGIN +-- Application_logic Pre-Before-Delete-row <> +-- Application_logic Pre-Before-Delete-row << End >> + +-- Load cg$rec/cg$ind values from new + + cg$pk.NOWC_ID := :old.NOWC_ID; + cg$rec.NOWC_ID := :old.NOWC_ID; + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).NOWC_ID := :old.NOWC_ID; + cg$rec.CONT_ID := :old.CONT_ID; + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).CONT_ID := :old.CONT_ID; + cg$rec.NOWI_ID := :old.NOWI_ID; + cg$NOM_WINDOW_CONTRACTS.cg$table(cg$NOM_WINDOW_CONTRACTS.idx).NOWI_ID := :old.NOWI_ID; + + + cg$NOM_WINDOW_CONTRACTS.idx := cg$NOM_WINDOW_CONTRACTS.idx + 1; + + if not (cg$NOM_WINDOW_CONTRACTS.called_from_package) then + cg$NOM_WINDOW_CONTRACTS.validate_domain_cascade_delete(cg$rec); + cg$NOM_WINDOW_CONTRACTS.del(cg$pk, FALSE); + cg$NOM_WINDOW_CONTRACTS.called_from_package := FALSE; + end if; + +-- Application_logic Post-Before-Delete-row <> +-- Application_logic Post-Before-Delete-row << End >> +END; +/ + +-- No application logic defined for Trigger cg$ADR_NOM_WINDOW_CONTRACTS, so drop it. +-- To avoid an error if there isn't one, create or replace it, and then drop it +CREATE OR REPLACE TRIGGER cg$ADR_NOM_WINDOW_CONTRACTS +AFTER DELETE ON NOM_WINDOW_CONTRACTS FOR EACH ROW +BEGIN + null; +END; +/ +drop trigger cg$ADR_NOM_WINDOW_CONTRACTS +/ + +PROMPT Creating After Delete Statement Trigger on 'NOM_WINDOW_CONTRACTS' +CREATE OR REPLACE TRIGGER cg$ADS_NOM_WINDOW_CONTRACTS +AFTER DELETE ON NOM_WINDOW_CONTRACTS +DECLARE + idx BINARY_INTEGER := cg$NOM_WINDOW_CONTRACTS.cg$table.FIRST; + cg$rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; + cg$old_rec cg$NOM_WINDOW_CONTRACTS.cg$row_type; +BEGIN +-- Application_logic Pre-After-Delete-statement <> +-- Application_logic Pre-After-Delete-statement << End >> + + IF NOT (cg$NOM_WINDOW_CONTRACTS.called_from_package) THEN + WHILE idx IS NOT NULL LOOP + cg$rec.CONT_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).CONT_ID; + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx).CONT_ID := TRUE; + cg$rec.NOWI_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWI_ID; + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx).NOWI_ID := TRUE; + cg$rec.NOWC_ID := cg$NOM_WINDOW_CONTRACTS.cg$table(idx).NOWC_ID; + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx).NOWC_ID := TRUE; + + cg$NOM_WINDOW_CONTRACTS.validate_foreign_keys_del(cg$rec); + cg$NOM_WINDOW_CONTRACTS.upd_oper_denorm2( cg$rec, + cg$old_rec, + cg$NOM_WINDOW_CONTRACTS.cg$tableind(idx), + 'DEL' + ); + + cg$NOM_WINDOW_CONTRACTS.cascade_delete(cg$rec); + cg$NOM_WINDOW_CONTRACTS.domain_cascade_delete(cg$rec); + + idx := cg$NOM_WINDOW_CONTRACTS.cg$table.NEXT(idx); + END LOOP; + END IF; + +-- Application_logic Post-After-Delete-statement <> +-- Application_logic Post-After-Delete-statement << End >> + +END; +/ + + + diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$.bdy new file mode 100644 index 0000000..6fced5b --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$.bdy @@ -0,0 +1,226 @@ +create or replace package body amadw025$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +-------------------------------------------------------------------------------- +-- Name: amadw025$.Startup +-- +-- Description: This procedure is the entry point for the 'amadw025$' +-- module. +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('amadw025$') then + return; + end if; + + WSGL.RegisterURL('amadw025$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, WSGL.MsgGetText(21,WSGLM.CAP021_TOP_LEVEL)); + amadw025$appa.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'amadw025$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: amadw025$.firstpage +-- +-- Description: This procedure creates the first page for the 'amadw025$' +-- module. +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('amadw025$') then + return; + end if; + + WSGL.OpenPageHead(''); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'amadw025$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'amadw025$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: amadw025$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'amadw025$' module. +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('amadw025$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('amadw025$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Access Manager Framework', 'AMADW025', l_usr); + + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'amadw025$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: amadw025$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('amadw025$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'amadw025$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: amadw025$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'amadw025$' module. +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'amadw025$' + , pFirstTitle => '' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'amadw025$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: amadw025$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$.spc new file mode 100644 index 0000000..7f46fb6 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$.spc @@ -0,0 +1,14 @@ +create or replace package amadw025$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$appa.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$appa.bdy new file mode 100644 index 0000000..4faccbf --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$appa.bdy @@ -0,0 +1,1404 @@ +create or replace package body amadw025$appa is + + procedure FormView(Z_FORM_STATUS in number, + Z_POST_DML in boolean default false, + Z_MULTI_PAGE in boolean default true, + Z_ACTION in varchar2 default null, + Z_START in varchar2 default '1'); + function BuildSQL( + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + + procedure ActionUpdate (p_row in integer default 0 + ,p_row_success in out boolean + ,p_row_lck in out boolean + ); + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function Validate(Z_MODE in varchar2, Z_FORCE_UPDATE in out boolean) return boolean; + function PreUpdate return boolean; + function PostUpdate return boolean; + function PreQuery return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + VF_UPDATE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(6,WSGLM.CAP006_VF_UPDATE); + VF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(8,WSGLM.CAP008_VF_REVERT); + VF_DELETE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(7,WSGLM.CAP007_VF_DELETE); + VF_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + VF_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + VF_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + VF_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + VF_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + VF_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + VF_NTOM_BUT_CAPTION constant varchar2(100) := '%s -> %e'; + VF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + VF_UPDATE_BUT_ACTION constant varchar2(10) := 'UPDATE'; + VF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + VF_DELETE_BUT_ACTION constant varchar2(10) := 'DELETE'; + VF_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + VF_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + VF_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + VF_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + VF_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + VF_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + VF_NTOM_BUT_ACTION constant varchar2(10) := 'NTOM'; + VF_VERIFIED_DELETE constant varchar2(100) := 'VerifiedDelete'; + VF_NUMBER_OF_COLUMNS constant number(4) := 10; + VF_RECORD_SET_SIZE constant number(5) := 100; + + VF_TOTAL_COUNT_REQD constant boolean := FALSE; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + CURR_IND CG$APPLICATION_PARAMETERS.CG$IND_TYPE; + CURR_PK CG$APPLICATION_PARAMETERS.CG$PK_TYPE; + PREV_VAL CG$APPLICATION_PARAMETERS.CG$ROW_TYPE; + PREV_IND CG$APPLICATION_PARAMETERS.CG$IND_TYPE; + NULL_VAL CG$APPLICATION_PARAMETERS.CG$ROW_TYPE; + NULL_IND CG$APPLICATION_PARAMETERS.CG$IND_TYPE; + + type FORM_REC is record + (PARAMETER varchar2(1440) + ,DESCRIPTION varchar2(1440) + ,VALUE varchar2(1440) + ,APPA_ID varchar2(40) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + VF_ROWS_UPDATED integer := 0; + VF_ROWS_DELETED integer := 0; + VF_ROWS_ERROR integer := 0; + type CTX_REC is record + ( PARAMETER varchar2(1440) + ); + type CTX_REC_ARR is table of CTX_REC index by binary_integer; + VF_DELETED_ROWS CTX_REC_ARR; + type ROW_REC is record + ( F_PARAMETER varchar2(1440) + , F_DESCRIPTION varchar2(1440) + , F_VALUE varchar2(1440) + , F_APPA_ID varchar2(40) + , SUCCESS_FLAG boolean + , ROW_DELETED boolean + , ROW_NOT_LOCKED boolean + , ROW_ID rowid + ); + type ROW_SET_TYPE is table of ROW_REC index by binary_integer; + VF_ROW_SET ROW_SET_TYPE; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_PARAMETER WSGOC.ITEM_REF; + R_DESCRIPTION WSGOC.ITEM_REF; + R_VALUE WSGOC.ITEM_REF; + R_APPA_ID WSGOC.ITEM_REF; + + + +PROCEDURE Audit_appa IS + +-- Audit_appa +-- +-- + + + + --- + -- Will be called by a PreUpdate event so the transaction will not have been applied yet. + --- + CURSOR c_old_appa IS + SELECT parameter, + description, + value + FROM application_parameters + WHERE appa_id = curr_val.appa_id; + -- + l_parameter application_parameters.parameter%TYPE; + l_description application_parameters.description%TYPE; + l_value application_parameters.value%TYPE; + -- +BEGIN + -- + OPEN c_old_appa; + FETCH c_old_appa INTO l_Parameter, + l_description, + l_value; + CLOSE c_old_appa; + -- + amfr_journal.log_transaction('UPDATE', + 'APPLICATION_PARAMETERS', + name_value_tab( + name_value_rec('APP PARAMETERS IDENTIFIER',curr_val.appa_id), + name_value_rec('PARAMETER',l_parameter), + name_value_rec('DESCRIPTION',l_description), + name_value_rec('VALUE',l_value) + ), + name_value_tab( + name_value_rec('APP PARAMETERS IDENTIFIER',curr_val.appa_id), + name_value_rec('PARAMETER',curr_val.PARAMETER), + name_value_rec('DESCRIPTION',curr_val.DESCRIPTION), + name_value_rec('VALUE',curr_val.VALUE) + ) + ); + -- +END; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.PreUpdate +-- +-- Description: Provides place holder for code to be run prior to an update +-- for the 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreUpdate return boolean is + L_RET_VAL boolean := TRUE; + begin +-- PrU_Audit_Update +-- +-- + +BEGIN + Audit_appa; +END; + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.PreUpdate'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.Validate +-- +-- Description: Provides validation of the 'APPA' module component +-- (#Maintain Application Parameters#3968#). +-- +-- Parameters: Z_MODE Ins(ert) or Upd(ate) +-- Z_FORCE_UPDATE Set this to TRUE within this event to force +-- Pre and Post-Update triggers to fire even if +-- no base item values have changed. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function Validate(Z_MODE in varchar2, Z_FORCE_UPDATE in out boolean) return boolean is + L_ERROR_MESS varchar2(1000); + L_RET_VAL boolean := TRUE; + begin + + + if Z_MODE = 'UPD' then + begin + CURR_VAL.VALUE := FORM_VAL.VALUE; + CURR_IND.VALUE := TRUE; + exception + when others then + cg$errors.push('#Value#3555#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'amadw025$appa.Validate'); + L_RET_VAL := FALSE; + end; + + end if; + + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.Validate'); + return FALSE; + end; +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.Startup +-- +-- Description: Entry point for the 'APPA' module +-- component (#Maintain Application Parameters#3968#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('amadw025$appa') then + return; + end if; + + WSGL.RegisterURL('amadw025$appa.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, '#Maintain Application Parameters#3968#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + end if; + if l_Foundform = FALSE then + QueryView( + Z_EXECUTE_QUERY=>'Y', + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + DEF_BODY_ATTRIBUTES, 'amadw025$appa.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('amadw025$appa') then + return -1; + end if; + + if not BuildSQL then + return -1; + end if; + + if not PreQuery then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Application Parameters#3968#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + DEF_BODY_ATTRIBUTES, 'amadw025$appa.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.BuildSQL +-- +-- Description: Builds the SQL for the 'APPA' module component (#Maintain Application Parameters#3968#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE APPA_ID = ' || to_char(CURR_VAL.APPA_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + + null; + end if; + + ZONE_SQL := 'SELECT PARAMETER, + DESCRIPTION, + VALUE, + APPA_ID + FROM ( SELECT APPA.PARAMETER PARAMETER, + APPA.DESCRIPTION DESCRIPTION, + APPA.VALUE VALUE, + APPA.APPA_ID APPA_ID, + APPA.ROWID CG$ROW_ID +FROM APPLICATION_PARAMETERS APPA + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY 1'; + + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + DEF_BODY_ATTRIBUTES, 'amadw025$appa.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, CURR_VAL.PARAMETER, 240); + dbms_sql.define_column(I_CURSOR, 2, CURR_VAL.DESCRIPTION, 240); + dbms_sql.define_column(I_CURSOR, 3, CURR_VAL.VALUE, 240); + dbms_sql.define_column(I_CURSOR, 4, CURR_VAL.APPA_ID); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + '', 'amadw025$appa.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, CURR_VAL.PARAMETER); + dbms_sql.column_value(I_CURSOR, 2, CURR_VAL.DESCRIPTION); + dbms_sql.column_value(I_CURSOR, 3, CURR_VAL.VALUE); + dbms_sql.column_value(I_CURSOR, 4, CURR_VAL.APPA_ID); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.APPA_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + '', 'amadw025$appa.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.FormView +-- +-- Description: This procedure builds an HTML form for view/update of fields in +-- the 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: Z_FORM_STATUS Status of the form +-- +-------------------------------------------------------------------------------- + procedure FormView(Z_FORM_STATUS in number, + Z_POST_DML in boolean, + Z_MULTI_PAGE in boolean, + Z_ACTION in varchar2, + Z_START in varchar2) is + + I_CURSOR integer; + I_VOID integer; + I_COUNT integer; + l_row integer := 0; + l_rowset_row integer := null; + l_error varchar2(2000); + l_rows_ret integer; + l_row_deleted boolean := false; + l_row_no_lock boolean := false; + l_total_rows integer := 0; + I_START number(38) := to_number(Z_START); + I_PREV_BUT boolean := false; + I_NEXT_BUT boolean := false; + l_total_text varchar2(200) := ''; + l_ntom_butstr varchar2(2000) := VF_NTOM_BUT_CAPTION; + l_force_upd boolean := false; + l_success boolean := true; + l_skip_data boolean := false; + begin + if not caco_security.security_check('amadw025$appa') then + return; + end if; + + l_success := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + + WSGL.OpenPageHead(''||' : '||'#Maintain Application Parameters#3968#'); + WSGL.METATag; + htp.script('FormType = "Update";'); + amadw025$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>VF_BODY_ATTRIBUTES || 'onLoad="return APPA_OnLoad()"'); + + amadw025$js$appa.CreateViewJavaScript( + VF_ROWS_UPDATED, + VF_ROWS_DELETED, + VF_ROWS_ERROR, + VF_BODY_ATTRIBUTES, + LOV_FRAME + ); + htp.p(caco_system.menu); + amadw025$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + + + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="VF$AIFormTop"'); + htp.formClose; + + + + if Z_FORM_STATUS = WSGL.FORM_STATUS_ERROR then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Application Parameters#3968#', VF_BODY_ATTRIBUTES); + htp.script('DataChangeErrors = true;'); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_UPD then + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(207, WSGLM.MSG207_ROW_UPDATED), + ''||' : '||'#Maintain Application Parameters#3968#', VF_BODY_ATTRIBUTES); + htp.script('DataChange = true;'); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_INS then + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(208, WSGLM.MSG208_ROW_INSERTED), + ''||' : '||'#Maintain Application Parameters#3968#', VF_BODY_ATTRIBUTES); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_NO_UPD then + htp.p( ''||WSGL.MsgGetText(136,WSGLM.DSP136_NO_ROW_UPDATED)||'
' ); + end if; + if VF_ROWS_UPDATED > 0 then + htp.p(htf.bold(htf.br || WSGL.MsgGetText(137,WSGLM.DSP137_ROWS_UPDATED)) || ' ' ||to_char(VF_ROWS_UPDATED) ); + end if; + if VF_ROWS_ERROR > 0 then + htp.p(htf.bold(htf.br || WSGL.MsgGetText(138,WSGLM.DSP138_ERRORS)) || ' ' ||to_char(VF_ROWS_ERROR) ); + end if; + if VF_ROWS_DELETED > 0 then + htp.p(htf.bold(htf.br || WSGL.MsgGetText(139,WSGLM.DSP139_ROWS_DELETED)) || ' ' ||to_char(VF_ROWS_DELETED) ); + end if; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'amadw025$appa.actionview', cattributes => 'NAME="amadw025$appa$VForm"'); + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + + WSGL.LayoutRowStart; + WSGL.LayoutHeader(50, 'LEFT', htf.bold('#Parameter Name#2498#')); + WSGL.LayoutHeader(50, 'LEFT', htf.bold('#Value#3555#')); + + + WSGL.LayoutHeader(2,'LEFT',null); + + WSGL.LayoutRowEnd; + if Z_MULTI_PAGE then + if (Z_ACTION = VF_LAST_BUT_ACTION) or (Z_ACTION = VF_LAST_BUT_CAPTION) or + (Z_ACTION = VF_COUNT_BUT_ACTION) or (Z_ACTION = VF_COUNT_BUT_CAPTION) or + (VF_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits; + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = VF_COUNT_BUT_ACTION) or (Z_ACTION = VF_COUNT_BUT_CAPTION) or (VF_TOTAL_COUNT_REQD) then + l_total_text := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + + if Z_START IS NULL or (Z_ACTION = VF_FIRST_BUT_ACTION) or (Z_ACTION = VF_FIRST_BUT_CAPTION) then + I_START := 1; + elsif (Z_ACTION = VF_NEXT_BUT_ACTION) or (Z_ACTION = VF_NEXT_BUT_CAPTION) then + I_START := I_START + VF_RECORD_SET_SIZE; + elsif (Z_ACTION = VF_PREV_BUT_ACTION) or (Z_ACTION = VF_PREV_BUT_CAPTION) then + I_START := I_START - VF_RECORD_SET_SIZE; + elsif (Z_ACTION = VF_LAST_BUT_ACTION) or (Z_ACTION = VF_LAST_BUT_CAPTION) then + I_START := 1 + (floor((I_COUNT-1)/VF_RECORD_SET_SIZE)*VF_RECORD_SET_SIZE); + end if; + + if I_START < 1 then + I_START := 1; + end if; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + end if; + OpenZoneSql(I_CURSOR); + l_row := 0; + if VF_ROW_SET.count = 0 then + I_VOID := dbms_sql.execute(I_CURSOR); + end if; + while true loop + if not l_row_deleted then + l_row := l_row + 1; + end if; + + l_row_deleted := false; + l_row_no_lock := false; + if VF_ROW_SET.count > 0 then + if l_rowset_row is null then + l_rowset_row := VF_ROW_SET.first; + else + l_rowset_row := VF_ROW_SET.next( l_rowset_row ); + end if; + if l_rowset_row is not null then + if not VF_ROW_SET( l_rowset_row ).ROW_DELETED then + dbms_sql.bind_variable(I_CURSOR, 'b_row_id', rowidtochar(VF_ROW_SET( l_rowset_row ).ROW_ID)); + I_VOID := dbms_sql.execute(I_CURSOR); + else + l_row_deleted := true; + end if; + if not VF_ROW_SET( l_rowset_row ).ROW_NOT_LOCKED then + FORM_VAL.VALUE := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_VALUE); + l_force_upd := false; + if not PostQuery(Z_POST_DML, l_force_upd) then + if cg$errors.pop(l_error) then + WSGL.LayoutTextLine(htf.bold(''|| + htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + end if; + end if; + + else + l_row_no_lock := true; + end if; + if VF_ROW_SET( l_rowset_row ).SUCCESS_FLAG then + htp.script('DataChange = true;'); + end if; + if not VF_ROW_SET( l_rowset_row ).SUCCESS_FLAG and cg$errors.pop_head( l_error ) then + htp.script('DataChangeErrors = true;'); + WSGL.LayoutTextLine(htf.bold(''||htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + end if; + else + exit; + end if; + end if; + + if not (l_row_deleted) then + if Z_MULTI_PAGE then + while l_total_rows < I_START - 1 loop + l_rows_ret := dbms_sql.fetch_rows(I_CURSOR); + l_total_rows := l_total_rows + l_rows_ret; + if l_rows_ret = 0 then + exit; + end if; + end loop; + end if; + l_rows_ret := dbms_sql.fetch_rows(I_CURSOR); + l_total_rows := l_total_rows + l_rows_ret; + + if (l_rows_ret > 0) and (l_total_rows < (I_START + VF_RECORD_SET_SIZE)) then + AssignZoneRow(I_CURSOR); + else + exit; + end if; + end if; + if (VF_ROW_SET.count = 0 and Z_FORM_STATUS != WSGL.FORM_STATUS_ERROR) or l_row_no_lock then + FORM_VAL.VALUE := WSGL.EscapeItem(CURR_VAL.VALUE); + end if; + FORM_VAL.PARAMETER := WSGL.EscapeItem(CURR_VAL.PARAMETER); + FORM_VAL.DESCRIPTION := WSGL.EscapeItem(CURR_VAL.DESCRIPTION); + FORM_VAL.APPA_ID := WSGL.EscapeItem(CURR_VAL.APPA_ID); + + l_force_upd := false; + if not PostQuery(Z_POST_DML, l_force_upd) then + if cg$errors.pop(l_error) then + WSGL.LayoutTextLine(htf.bold(''|| + htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + end if; + end if; + if not l_row_deleted then + WSGL.HiddenField('P_APPA_ID', CURR_VAL.APPA_ID); + WSGL.HiddenField('O_APPA_ID', CURR_VAL.APPA_ID); + end if; + l_skip_data := false; + WSGL.HiddenField('H_PARAMETER', CURR_VAL.PARAMETER); + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(FORM_VAL.PARAMETER); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.VALUE); + else + WSGL.LayoutData(WSGL.BuildTextControl('VALUE', '50', '1', '240',FORM_VAL.VALUE, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if (l_row_deleted) then + WSGL.LayoutData(' '); + else + WSGL.LayoutData(''); + end if; + WSGL.LayoutRowEnd; + + + + + + + + + + + + if not (l_row_deleted) then + htp.p(WSGJSL.OpenScript); + if l_force_upd then + htp.p('document.write('''');'); + else + htp.p('document.write('''');'); + end if; + htp.p(WSGJSL.CloseScript); + WSGL.HiddenField('O_PARAMETER', CURR_VAL.PARAMETER); + WSGL.HiddenField('O_DESCRIPTION', CURR_VAL.DESCRIPTION); + WSGL.HiddenField('O_VALUE', CURR_VAL.VALUE); + + end if; + + end loop; + WSGL.LayoutClose; + + if l_row < 3 then + WSGL.HiddenField('P_APPA_ID',''); + WSGL.HiddenField('P_VALUE',''); + WSGL.HiddenField('O_PARAMETER', ''); + WSGL.HiddenField('O_DESCRIPTION', ''); + WSGL.HiddenField('O_VALUE', ''); + WSGL.HiddenField('H_PARAMETER',''); + WSGL.HiddenField('z_modified','dummy_row'); + end if; + + dbms_sql.close_cursor(I_CURSOR); + + if l_rows_ret > 0 then + I_NEXT_BUT := true; + end if; + + if l_total_rows = 0 then + htp.p(WSGL.MsgGetText(112, WSGLM.DSP112_NO_RECORDS)); + htp.para; + elsif Z_MULTI_PAGE then + if I_START = l_total_rows or VF_RECORD_SET_SIZE = 1 then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_START))||l_total_text); + else + if I_NEXT_BUT then + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(l_total_rows - 1))||l_total_text); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(l_total_rows))||l_total_text); + end if; + end if; + htp.para; + end if; + + WSGL.SubmitButton('Z_ACTION', htf.escape_sc(VF_UPDATE_BUT_CAPTION), 'btnVFU', 'this.form.Z_ACTION.value=\''' || VF_UPDATE_BUT_ACTION || '\'''); + htp.formReset(htf.escape_sc(VF_CLEAR_BUT_CAPTION), cattributes=>'ID="'||htf.escape_sc(VF_CLEAR_BUT_CAPTION)||'"'||' onClick="return JSLRevertForm( this.form, '|| l_row ||' )"'); + + + if VF_ROW_SET.count > 0 or Z_FORM_STATUS = WSGL.FORM_STATUS_INS then + I_START := nvl(I_START, 1); + l_ntom_butstr := replace(l_ntom_butstr, '%s', to_char(I_START)); + l_ntom_butstr := replace(l_ntom_butstr, '%e', to_char(I_START + VF_RECORD_SET_SIZE - 1)); + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(l_ntom_butstr), p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_NTOM_BUT_ACTION || '\'', true)"', + p_type_button=>true); + end if; + + if Z_MULTI_PAGE and VF_ROW_SET.count = 0 then + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(VF_FIRST_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_FIRST_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(VF_PREV_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_PREV_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(VF_NEXT_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_NEXT_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(VF_LAST_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_LAST_BUT_ACTION || '\'', true)"', + p_type_button=>true); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(VF_REQUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_REQUERY_BUT_ACTION || '\'', true)"', + p_type_button=>true); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(VF_COUNT_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_COUNT_BUT_ACTION || '\'', true)"', + p_type_button=>true); + end if; + + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''||CURR_VAL.APPA_ID))); + + + WSGL.HiddenField('Z_START', to_char(I_START)); + + htp.formClose; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.FormView'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.QueryView +-- +-- Description: Queries the details of a single row in preparation for display. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryView( + K_APPA_ID in varchar2, + Z_EXECUTE_QUERY in varchar2, + Z_POST_DML in boolean, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_CHK in varchar2) is + L_ROW_ID ROWID; + begin + if not caco_security.security_check('amadw025$appa') then + return; + end if; + + + + WSGL.RegisterURL('amadw025$appa.queryview'); + WSGL.AddURLParam('K_APPA_ID', K_APPA_ID); + WSGL.AddURLParam('Z_EXECUTE_QUERY', Z_EXECUTE_QUERY); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + if not Z_DIRECT_CALL then + + null; + + end if; + + + + + null; + + + + if K_APPA_ID is not null then + CURR_VAL.APPA_ID := K_APPA_ID; + end if; + + if Z_EXECUTE_QUERY is null then + if VF_ROW_SET.count = 0 then + if BuildSQL( Z_QUERY_BY_KEY=>true) then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>false, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + else + if BuildSQL( z_bind_row_id=>true ) then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>false, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + end if; + + else + if not PreQuery then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Application Parameters#3968#', VF_BODY_ATTRIBUTES); + return; + end if; + + if BuildSQL + then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>true, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + + end if; + + exception + when NO_DATA_FOUND then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(204, WSGLM.MSG204_ROW_DELETED), + ''||' : '||'#Maintain Application Parameters#3968#', VF_BODY_ATTRIBUTES); + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.QueryView'); + end; +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.QueryViewByKey +-- +-- Description: Queries the details of a single row in preparation for display. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryViewByKey( + P_APPA_ID in varchar2, + Z_POST_DML in boolean, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is +begin + if not caco_security.security_check('amadw025$appa') then + return; + end if; + + QueryView( + K_APPA_ID=>P_APPA_ID, + Z_EXECUTE_QUERY=>null, + Z_POST_DML=>Z_POST_DML, + Z_FORM_STATUS=>Z_FORM_STATUS, + Z_DIRECT_CALL=>Z_DIRECT_CALL, + Z_CHK=>Z_CHK); +end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.ActionView +-- +-- Description: This procedure is called when the View Form is submitted to +-- action an update, delete or requery request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionView( + P_APPA_ID in owa_text.vc_arr, + P_VALUE in owa_text.vc_arr, + O_PARAMETER in owa_text.vc_arr, + O_DESCRIPTION in owa_text.vc_arr, + O_VALUE in owa_text.vc_arr, + O_APPA_ID in owa_text.vc_arr, + H_PARAMETER in owa_text.vc_arr, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2, + Z_START in varchar2, + Z_CHK in varchar2 ) is +-- + l_row integer; + l_row_failed boolean := false; + l_success boolean; + l_rowset_row integer := 1; + l_delset_row integer := 1; + l_cbcount integer; + l_do_delete boolean := false; + l_record_lck boolean := false; + l_dummy_bool boolean := false; + + begin + if not caco_security.security_check('amadw025$appa') then + return; + end if; + + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + +if (Z_ACTION = VF_COUNT_BUT_ACTION or Z_ACTION = VF_COUNT_BUT_CAPTION) or + (Z_ACTION = VF_FIRST_BUT_ACTION or Z_ACTION = VF_FIRST_BUT_CAPTION) or + (Z_ACTION = VF_PREV_BUT_ACTION or Z_ACTION = VF_PREV_BUT_CAPTION) or + (Z_ACTION = VF_NEXT_BUT_ACTION or Z_ACTION = VF_NEXT_BUT_CAPTION) or + (Z_ACTION = VF_LAST_BUT_ACTION or Z_ACTION = VF_LAST_BUT_CAPTION) or + (Z_ACTION = VF_REQUERY_BUT_ACTION or Z_ACTION = VF_REQUERY_BUT_CAPTION) or + (Z_ACTION = VF_NTOM_BUT_ACTION or Z_ACTION = VF_NTOM_BUT_CAPTION) then + QueryView(Z_EXECUTE_QUERY=>'Y', + Z_POST_DML=>FALSE, + Z_DIRECT_CALL=>TRUE, + Z_ACTION=>Z_ACTION, + Z_START=>Z_START); +end if; + +if (Z_ACTION = VF_UPDATE_BUT_ACTION) or (Z_ACTION = VF_UPDATE_BUT_CAPTION) or ltrim(Z_ACTION) is null then + l_row := z_modified.first; + while l_row is not null loop + l_do_delete := false; + if z_modified( l_row ) = 'Y' or l_do_delete then + PROCESSING_VIEW := true; + FORM_VAL.APPA_ID := P_APPA_ID( l_row ); + FORM_VAL.PARAMETER := H_PARAMETER( l_row ); + FORM_VAL.VALUE := P_VALUE( l_row ); + + PREV_VAL.APPA_ID := P_APPA_ID( l_row ); + PREV_IND.APPA_ID := TRUE; + PREV_VAL.PARAMETER := O_PARAMETER( l_row ); + PREV_IND.PARAMETER := TRUE; + PREV_VAL.DESCRIPTION := O_DESCRIPTION( l_row ); + PREV_IND.DESCRIPTION := TRUE; + PREV_VAL.VALUE := O_VALUE( l_row ); + PREV_IND.VALUE := TRUE; + CURR_IND := NULL_IND; + CURR_VAL := PREV_VAL; + CURR_PK.APPA_ID := CURR_VAL.APPA_ID; + ActionUpdate( p_row=>l_row, p_row_success=>l_success, p_row_lck=>l_record_lck ); + + if ( not l_do_delete ) or ( l_do_delete and not l_success ) then + VF_ROW_SET( l_rowset_row ).ROW_DELETED := false; + begin + select ROWID + into VF_ROW_SET( l_rowset_row ).ROW_ID + from APPLICATION_PARAMETERS + where APPA_ID = CURR_VAL.APPA_ID; + exception when no_data_found then + l_success := false; + VF_ROW_SET( l_rowset_row ).ROW_DELETED := true; + end; + VF_ROW_SET( l_rowset_row ).SUCCESS_FLAG := l_success; + VF_ROW_SET( l_rowset_row ).ROW_NOT_LOCKED := ( not l_record_lck ); + VF_ROW_SET( l_rowset_row ).F_PARAMETER := FORM_VAL.PARAMETER; + VF_ROW_SET( l_rowset_row ).F_DESCRIPTION := FORM_VAL.DESCRIPTION; + VF_ROW_SET( l_rowset_row ).F_VALUE := FORM_VAL.VALUE; + VF_ROW_SET( l_rowset_row ).F_APPA_ID := FORM_VAL.APPA_ID; + if l_success then + VF_ROWS_UPDATED := VF_ROWS_UPDATED + 1; + else + VF_ROWS_ERROR := VF_ROWS_ERROR + 1; + end if; + l_rowset_row := l_rowset_row + 1; + end if; + end if; + l_row := z_modified.next( l_row ); + end loop; + + if VF_ROW_SET.count > 0 then + QueryView(Z_EXECUTE_QUERY=>null, + Z_POST_DML=>TRUE, + Z_DIRECT_CALL=>TRUE, + Z_START=>Z_START, + Z_ACTION=>Z_ACTION); + else + QueryView(Z_EXECUTE_QUERY=>'Y', + Z_POST_DML=>FALSE, + Z_DIRECT_CALL=>TRUE, + Z_START=>Z_START, + Z_ACTION=>Z_ACTION); + end if; +end if; + + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.ActionView'); + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.ActionUpdate +-- +-- Description: Called from ActionView to process an update request +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionUpdate (p_row in integer default 0 + ,p_row_success in out boolean + ,p_row_lck in out boolean + ) + is + + I_ERROR_MESS varchar2(2000) := null; + I_RETURN number(6); + l_force_upd boolean := false; + + begin + p_row_success := true; + p_row_lck := true; + begin + CG$APPLICATION_PARAMETERS.Lck(PREV_VAL, PREV_IND); + exception + when cg$errors.cg$error then + p_row_success := false; + p_row_lck := false; + return; + when others then + raise; + end; + + + if not Validate('UPD', l_force_upd) then + rollback; + p_row_success := false; + return; + end if; + + + if not PreUpdate then + rollback; + p_row_success := false; + return; + end if; + + begin + CG$APPLICATION_PARAMETERS.Upd(CURR_VAL, CURR_IND); + exception + when cg$errors.cg$error then + p_row_success := false; + rollback; + return; + when others then + raise; + end; + + if not PostUpdate then + rollback; + p_row_success := false; + return; + end if; + + commit; + + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.ActionUpdate'); + end;-------------------------------------------------------------------------------- +-- Name: amadw025$appa.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.APPA_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + '', 'amadw025$appa.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.SaveState +-- +-- Description: Saves the data state for the 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + '', 'amadw025$appa.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.LoadCache +-- +-- Description: Populate the object cache with +-- 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + + ref_Component := WSGOC.Component + ( pModule => amadw025$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'APPA' + , pTitle => '#Maintain Application Parameters#3968#' + , pSystemImagePath=> '/images/' + ); + + r_PARAMETER := WSGOC.Item + ( pName => 'PARAMETER' + , pPrompt => '#Parameter Name#2498#' + , pIsContext=> true + ); + r_DESCRIPTION := WSGOC.Item + ( pName => 'DESCRIPTION' + , pPrompt => 'Description' + ); + r_VALUE := WSGOC.Item + ( pName => 'VALUE' + , pPrompt => '#Value#3555#' + ); + r_APPA_ID := WSGOC.Item + ( pName => 'APPA_ID' + , pPrompt => 'Appa Id' + ); + + WSGOC.Add_Items(ref_Component, r_PARAMETER); + WSGOC.Add_Items(ref_Component, r_DESCRIPTION); + WSGOC.Add_Items(ref_Component, r_VALUE); + WSGOC.Add_Items(ref_Component, r_APPA_ID); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_PARAMETER, replace(WSGL.EscapeItem(CURR_VAL.PARAMETER), ' +', '
+') ); + WSGOC.Set_Value( r_DESCRIPTION, replace(WSGL.EscapeItem(CURR_VAL.DESCRIPTION), ' +', '
+') ); + WSGOC.Set_Value( r_VALUE, replace(WSGL.EscapeItem(CURR_VAL.VALUE), ' +', '
+') ); + WSGOC.Set_Value( r_APPA_ID, WSGL.EscapeItem(CURR_VAL.APPA_ID) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + '', 'amadw025$appa.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + DEF_BODY_ATTRIBUTES, 'amadw025$appa.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + DEF_BODY_ATTRIBUTES, 'amadw025$appa.PostQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: amadw025$appa.PostUpdate +-- +-- Description: Provides place holder for code to be run after an update +-- for the 'APPA' module component (#Maintain Application Parameters#3968#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostUpdate return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$appa.PostUpdate'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$appa.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$appa.spc new file mode 100644 index 0000000..96e6d7b --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$appa.spc @@ -0,0 +1,60 @@ +create or replace package amadw025$appa is + + + CURR_VAL CG$APPLICATION_PARAMETERS.CG$ROW_TYPE; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure QueryView( + K_APPA_ID in varchar2 default null, + Z_EXECUTE_QUERY in varchar2 default null, + Z_POST_DML in boolean default false, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_START in varchar2 default '1', + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null); + function QueryHits return number; + + procedure ActionView( + P_APPA_ID in owa_text.vc_arr, + P_VALUE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_PARAMETER in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_DESCRIPTION in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_VALUE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_APPA_ID in owa_text.vc_arr default WSGL.EmptyVCArrLong, + H_PARAMETER in owa_text.vc_arr default WSGL.EmptyVCArrLong, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2 default null, + Z_START in varchar2 default '1', + Z_CHK in varchar2 default null ); + procedure QueryViewByKey( + P_APPA_ID in varchar2 default null, + Z_POST_DML in boolean default false, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + +PROCEDURE Audit_appa; + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$js$appa.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$js$appa.bdy new file mode 100644 index 0000000..2aa1599 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$js$appa.bdy @@ -0,0 +1,105 @@ +create or replace package body amadw025$js$appa is + + +-------------------------------------------------------------------------------- +-- Name: amadw025$js$appa.CreateViewJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateViewJavaScript( + VF_ROWS_UPDATED in integer, + VF_ROWS_DELETED in integer, + VF_ROWS_ERROR in integer, + VF_BODY_ATTRIBUTES in varchar2, + LOV_FRAME in varchar2) is + begin + if not caco_security.security_check('amadw025$appa') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var index = 0;'); + htp.p( 'var DataChangeErrors = false;' ); + htp.p( 'var DataChange = false;' ); + + + htp.p( 'var P_3 = new Array();' ); + + htp.p(WSGJSL.RtnCheckModified); + htp.p(WSGJSL.RtnRevertForm); + + + htp.p(' +function ResetRadios( form, num_rows ) +{ + return; +}; +'); + + htp.p(WSGJSL.OpenEvent('VALUE','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('APPA','Validate'));htp.p('var index = 0;'); +htp.p(' +for (index = 0; index < ctl.form.P_VALUE.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + +htp.p(' +}'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('APPA','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFU','OnClick')); + htp.p(' if (!APPA_Validate(ctl)) { return false; }'); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFD','OnClick')); + htp.p(WSGJSL.VerifyDelete(WSGL.MsgGetText(118, WSGLM.DSP118_CONFIRM_DELETE))); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFR','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Application Parameters#3968#', + VF_BODY_ATTRIBUTES, 'amadw025$js$appa.CreateViewJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$js$appa.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$js$appa.spc new file mode 100644 index 0000000..8656bac --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/amadw025$js$appa.spc @@ -0,0 +1,11 @@ +create or replace package amadw025$js$appa is + + procedure CreateViewJavaScript( + VF_ROWS_UPDATED in integer, + VF_ROWS_DELETED in integer, + VF_ROWS_ERROR in integer, + VF_BODY_ATTRIBUTES in varchar2, + LOV_FRAME in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/caco_security.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/caco_security.bdy new file mode 100644 index 0000000..2975bdb --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/caco_security.bdy @@ -0,0 +1,2527 @@ +CREATE OR REPLACE PACKAGE BODY caco_security IS + -- + -- Constants + -- + c_session_duration_hours CONSTANT NUMBER := TO_NUMBER(cout_system_configuration.get_configuration_item('SESSION_TIMEOUT'),'999.999'); + -- + -- Use the configuration parameter to set when the password expires following a change, if not found use 30 days as a default. + -- + c_password_expiry_period CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_ACCOUNT_EXPIRE_PERIOD'),30); + -- + -- Private procedural logic + -- + FUNCTION scramble(p_string IN VARCHAR2) RETURN VARCHAR2 IS + -- + v_return VARCHAR2(30); + -- + BEGIN + -- + v_return := substr(dbms_obfuscation_toolkit.md5(input => utl_raw.cast_to_raw(p_string)) + ,1 + ,30); + -- + RETURN v_return; + -- + END scramble; + -- + -- Get User + -- + FUNCTION get_user RETURN VARCHAR2 IS + BEGIN + -- + RETURN g_current_user; + -- + END get_user; + -- + -- + -- + PROCEDURE get_session_data(p_client_id IN VARCHAR2 DEFAULT NULL) IS + BEGIN + -- + IF g_client_id IS NULL THEN + -- + IF p_client_id IS NULL THEN + -- + g_client_id := wsgl.getclientid; + -- + ELSE + -- + g_client_id := p_client_id; + -- + END IF; + -- + END IF; + -- + IF g_client_id IS NOT NULL THEN + -- + BEGIN + SELECT user_name + ,syus_id + ,inte_id + ,cust_id + INTO g_current_user + ,g_current_syus_id + ,g_current_inte_id + ,g_current_cust_id + FROM sessions + WHERE client_id = g_client_id; + EXCEPTION + WHEN no_data_found THEN + -- + -- the client id is invalid + -- + g_current_user := NULL; + g_current_syus_id := NULL; + g_current_inte_id := NULL; + g_current_cust_id := NULL; + END; + -- + END IF; + -- + END; + -- + -- + -- + PROCEDURE storeclientid(p_client_id_str IN VARCHAR2) IS + l_script_name VARCHAR2(80) := owa_util.get_cgi_env('SCRIPT_NAME'); + BEGIN + -- + IF substr(l_script_name + ,-1 + ,1) = '/' THEN + l_script_name := substr(l_script_name + ,1 + ,length(l_script_name) - 1); + END IF; + + owa_util.mime_header('text/html' + ,FALSE); + -- + owa_cookie.send(wsgl.wsg_clientid_cookie + ,p_client_id_str + ,NULL + ,l_script_name + ,NULL); + -- + owa_util.http_header_close; + -- + END; + -- Check_Session: Check that the supplied client ID is valid + -- for the IP address of the client, that the + -- session is still valid, and that the client + -- ID supplied is not null. + -- + FUNCTION check_session(p_client_id IN VARCHAR2) RETURN BOOLEAN IS + l_stored_ip VARCHAR2(30); + l_current_ip VARCHAR2(30); + l_check_ok BOOLEAN; + l_expires DATE; + l_debugging BOOLEAN := caco_debug.debugging; + BEGIN + -- + IF p_client_id IS NOT NULL THEN + -- + -- Get IP address of client + -- + l_current_ip := owa_util.get_cgi_env('REMOTE_ADDR'); + l_check_ok := TRUE; + -- + -- Check wsgsec_sessions table for an existing session + -- with the specified ID and the current IP address + -- + BEGIN + SELECT ip_address + ,expires + INTO l_stored_ip + ,l_expires + FROM sessions + WHERE client_id = p_client_id + AND ip_address = l_current_ip; + + EXCEPTION + WHEN no_data_found THEN + BEGIN + SELECT ip_address + ,expires + INTO l_stored_ip + ,l_expires + FROM sessions + WHERE client_id = p_client_id; + IF NOT l_debugging THEN + caco_debug.debug_on; + END IF; + caco_debug.putline('Looked for client at ' || l_current_ip || + ' and failed. Found client at IP ' || + l_stored_ip); + IF (NOT l_debugging) + AND caco_debug.debugging THEN + caco_debug.debug_off; + END IF; + EXCEPTION + WHEN no_data_found THEN + IF NOT l_debugging THEN + caco_debug.debug_on; + END IF; + caco_debug.putline('Looked for client at any IP and failed.'); + IF (NOT l_debugging) + AND caco_debug.debugging THEN + caco_debug.debug_off; + END IF; + l_check_ok := FALSE; + l_expires := SYSDATE; + END; + END; + -- + -- Check that the session has not expired + -- + IF (SYSDATE > l_expires) THEN + l_check_ok := FALSE; + END IF; + -- + ELSE + -- + -- Supplied client ID was null, so return fail. + -- + l_check_ok := FALSE; + -- + END IF; + -- + -- Check that the license is valid + -- + IF NOT saco_licensing.check_license THEN + -- + l_check_ok := FALSE; + -- + END IF; + -- + -- If an invalid session was found (either expired or for + -- another IP address) then delete that session. + -- + IF NOT l_check_ok + AND p_client_id IS NOT NULL THEN + -- + BEGIN + -- + dbms_transaction.begin_discrete_transaction; + -- + DELETE FROM sessions + WHERE client_id = p_client_id; + COMMIT; + EXCEPTION + WHEN OTHERS THEN + IF NOT caco_debug.debugging THEN + caco_debug.debug_on; + caco_debug.putline(SQLERRM); + caco_debug.debug_off; + ELSE + caco_debug.putline(SQLERRM); + END IF; + END; + -- + END IF; + -- + RETURN l_check_ok; + -- + END; + -- + -- + -- Generate_Client_Id: Generate a unique identifier for a new session. + -- + FUNCTION generate_client_id RETURN VARCHAR2 IS + -- + l_client_id VARCHAR2(240); + l_is_unique BOOLEAN := FALSE; + l_count INTEGER; + -- + BEGIN + -- + -- Generate a pseudo random number. + SELECT to_char(to_number(userenv('sessionid')) * + to_number(to_char(SYSDATE + ,'DDDSSSS'))) + INTO l_client_id + FROM sys.dual; + -- + -- Check that it is unique in the session table. If it is not, increment + -- it until it is. + -- + WHILE NOT l_is_unique LOOP + BEGIN + SELECT COUNT(*) + INTO l_count + FROM sessions + WHERE client_id = l_client_id; + EXCEPTION + WHEN no_data_found THEN + l_count := 0; + END; + IF l_count = 0 THEN + -- + -- The ID does not already exist in session table + -- + l_is_unique := TRUE; + ELSE + l_client_id := to_number(l_client_id) + 1; + END IF; + END LOOP; + RETURN l_client_id; + END; + + PROCEDURE update_session_expiry(p_client_id sessions.client_id%TYPE) IS + PRAGMA AUTONOMOUS_TRANSACTION; + e_resource_busy EXCEPTION; + PRAGMA EXCEPTION_INIT(e_resource_busy + ,-54); + l_dummy sessions.client_id%TYPE; + BEGIN + SELECT client_id + INTO l_dummy + FROM sessions + WHERE client_id = p_client_id + FOR UPDATE NOWAIT; + + UPDATE sessions + SET expires = SYSDATE + (c_session_duration_hours / 24) + WHERE client_id = p_client_id; + COMMIT; + EXCEPTION + WHEN e_resource_busy THEN + -- + -- Unable to lock the client session, must be another update occurring + COMMIT; + END update_session_expiry; + -- + -- + -- Security_Check: Returns true if the currently logged on user is + -- allowed access to the specified package. If not, + -- will return false. This function will also provide + -- a means for the user to log on. + -- + FUNCTION security_check(p_package_name IN VARCHAR2) RETURN BOOLEAN IS + -- + l_client_id VARCHAR2(240); + l_username VARCHAR2(30); + l_rows INTEGER := 0; + -- + BEGIN + -- + -- Get the current client ID + -- + l_client_id := wsgl.getclientid; + -- + IF l_client_id IS NOT NULL THEN + -- + -- Call check_session to ensure current session + -- is valid + -- + IF check_session(l_client_id) THEN + -- + -- Update the session table to set the expiry date to SYSDATE + session duration + -- + update_session_expiry(l_client_id); + -- + -- Get user name + -- + get_session_data(l_client_id); + -- + -- Check that the current user has a responsibility + -- that allows it to access the specified package name + -- + IF lower(p_package_name) = 'home' THEN + -- + l_rows := 1; + -- + ELSE + -- + BEGIN + -- + SELECT COUNT(*) + INTO l_rows + FROM user_profiles uspr + ,profile_options prop + ,system_options syop + WHERE uspr.syus_id = g_current_syus_id + AND uspr.sypr_id = prop.sypr_id + AND syop.syop_id = prop.syop_id + AND syop.module_name IS NOT NULL + AND upper(substr(syop.module_name + ,1 + ,decode(instr(syop.module_name + ,'$') + ,0 + ,length(syop.module_name) + ,instr(syop.module_name + ,'$')))) = + upper(substr(p_package_name + ,1 + ,decode(instr(p_package_name + ,'$') + ,0 + ,length(p_package_name) + ,instr(p_package_name + ,'$')))); + -- + EXCEPTION + WHEN no_data_found THEN + l_rows := 0; + END; + -- + END IF; + -- + ELSE + -- + -- No valid session was found, so display a + -- logon form. + -- + IF saco_licensing.check_license + AND saco_licensing.check_users THEN + -- + IF lower(p_package_name) = 'home' THEN + -- + show_logon_form(p_embedded => TRUE); + -- + ELSE + -- + show_logon_form(p_embedded => FALSE); + -- + END IF; + -- + END IF; + -- + RETURN FALSE; + -- + END IF; + -- + IF l_rows != 0 THEN + -- + -- User is logged on and has permission to access + -- the specified package. + -- + RETURN TRUE; + -- + ELSE + -- + -- User is logged on but does not have permission + -- to access the specified package + -- + show_no_access; + RETURN FALSE; + -- + END IF; + -- + ELSE + -- + -- No current client ID, so display logon form. + -- + IF lower(p_package_name) = 'home' THEN + -- + show_logon_form(p_embedded => TRUE); + -- + ELSE + -- + show_logon_form(p_embedded => FALSE); + -- + END IF; + -- + RETURN FALSE; + -- + END IF; + -- + END; + -- + -- allow_username_login: allows the user to login using a username or password + -- + FUNCTION allow_username_login RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + IF cout_system_configuration.get_configuration_item('G_ALLOW_USERNAME_LOGIN') = 'Y' THEN + -- + l_return := TRUE; + -- + END IF; + -- + RETURN l_return; + -- + END allow_username_login; + -- + -- Show_Logon_Form: Renders logon form + -- + PROCEDURE show_logon_form(p_embedded IN BOOLEAN + ,h_href IN VARCHAR2 DEFAULT NULL) IS + BEGIN + -- + IF saco_licensing.check_license + AND saco_licensing.check_users THEN + -- + IF NOT p_embedded THEN + -- + owa_util.mime_header('text/html' + ,FALSE); + htp.p('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + owa_util.http_header_close; + -- + htp.p(''); + -- + htp.headopen; + -- + htp.title(wsgl.msggettext(605 + ,wsglm.sec605_logon_caption)); + -- + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css?p_type=general'); + -- + -- Display the standard menu + -- + htp.print(caco_system.menu); + -- + htp.headclose; + -- + END IF; + -- + -- Output JavaScript for handling onLoad event for setting + -- the focus to the username field upon invocation. + -- + htp.bodyopen(cattributes => 'onLoad="return Logon_OnLoad()"'); + htp.p(''); + htp.formopen(curl => 'caco_security.process_logon' + ,ctarget => '' + ,cmethod => 'POST' + ,cattributes => 'NAME="Logonform"'); + -- + -- Hidden field to store the calling URL + -- + htp.formHidden(cname => 'h_href', cvalue => h_href); + -- + -- + htp.p('
+ +
+ +
+
+ +
+
+

E.ON Földgáz Trade Zrt

'); + -- + IF allow_username_login THEN + -- + htp.p('

+ Please log in here +

'); + -- + END IF; + -- + htp.p('
+
+
+
+
+
'); + -- + IF allow_username_login THEN + -- + htp.p('
+ Login +

*) required fields

+ *) + + + +
+
+ + *) + +
+
+ + +
+
+
'); + -- + END IF; + -- + htp.p('
+ Register + New users register here + +
+
+
+
+
+
+
+ +
+
+
+
+
+
'); + -- + htp.formclose; + -- + IF NOT p_embedded THEN + caco_system.footer(p_closebody => TRUE); + END IF; + -- + END IF; + -- + END; + -- + PROCEDURE online_user_registration ( p_register_title IN VARCHAR2 DEFAULT NULL + , p_register_first_name IN VARCHAR2 DEFAULT NULL + , p_register_surname IN VARCHAR2 DEFAULT NULL + , p_register_company IN VARCHAR2 DEFAULT NULL + , p_register_email IN VARCHAR2 DEFAULT NULL + , p_register_phone IN VARCHAR2 DEFAULT NULL + , p_register_submit IN VARCHAR2 DEFAULT NULL + ) IS + -- + l_email_body VARCHAR2(4000); + -- + BEGIN + -- + -- Output the standard pages headings + -- + htp.p(''); + htp.p(' + '); + -- + htp.p(''); + htp.comment(ctext => 'Copyright 2009 GL Industrial Services'); + htp.p('E.ON Földgáz Trade Zrt - User Registration'); + htp.p(' '); + htp.p(''); + htp.p('
+ +
    +
+
'); + htp.p('
+ + + +
    +
+
+
    +
+ +
    +
+
'); + -- + -- Now output the content + -- + IF p_register_submit IS NULL THEN + -- + htp.formopen(curl => 'caco_security.online_user_registration' + ,ctarget => '' + ,cmethod => 'POST' + ,cattributes => ' onsubmit="return validate_form(this.form);"'); + -- + END IF; + -- + htp.p('
+ +
+ +
+
+ +
+
+

User Registration

'); + -- + htp.p('
+
+
+
+
+
'); + -- + IF p_register_submit IS NULL THEN + -- + -- Personal Identification + -- + htp.p('
+ Person'); + htp.p(' + +
+ + +
+ + +
+ + +
'); + -- + -- Contact Details + -- + htp.p('
+ Contact Details + + +
+ + +
+
+ +
'); + -- + ELSE + -- + -- Record what we have received + -- + amfr_journal.log_transaction( 'INSERT' + , 'Application Registration Received' + , name_value_tab( + name_value_rec('TITLE' , p_register_title ) + , name_value_rec('FIRST NAME', p_register_first_name ) + , name_value_rec('SURNAME' , p_register_surname ) + , name_value_rec('COMPANY' , p_register_company ) + , name_value_rec('EMAIL' , p_register_email ) + , name_value_rec('PHONE' , p_register_phone ) + ) + , amfr_journal.g_name_value_tab + ); + -- + -- Send it as an email + -- + l_email_body := CHR(13) || caco_utilities.get_module_text(3931)|| CHR(13); + l_email_body := l_email_body || 'Title: ' || CHR(9) || CHR(9) || p_register_title || CHR(13); + l_email_body := l_email_body || 'First Name: ' || CHR(9) || p_register_first_name || CHR(13); + l_email_body := l_email_body || 'Surname: ' || CHR(9) || p_register_surname || CHR(13); + l_email_body := l_email_body || 'Company: ' || CHR(9) || p_register_company || CHR(13); + l_email_body := l_email_body || 'Email: ' || CHR(9) || CHR(9) || p_register_email || CHR(13); + l_email_body := l_email_body || 'Phone Number: ' || CHR(9) || p_register_phone || CHR(13); + -- + amfr_messaging.send_background_email( from_name => cout_system_configuration.get_configuration_item('CONTACT_EMAIL') + , to_names => cout_system_configuration.get_configuration_item('G_SYSADMIN_EMAIL_ADDRESS') + , subject => caco_utilities.get_module_text(3933) + , message => l_email_body + ); + -- + -- Output the details + -- + htp.p(''||caco_utilities.get_module_text(3932)||''); + htp.p('
'); + -- + END IF; + -- + htp.p(' +
+
+
+ +
+
+
+
+
+
'); + -- + IF p_register_submit IS NULL THEN + -- + htp.formclose; + -- + END IF; + -- + -- Standard Footer + -- + htp.p('
+
+
+
+

E.ON Földgáz Trade Zrt.

+ +
+
+ + '); + -- + END online_user_registration; + -- + -- Process_Logon: Accepts submitted logon form and logs user on. If logon + -- fails then notifies user. + -- + PROCEDURE process_logon(p_username IN VARCHAR2 DEFAULT NULL + ,p_password IN VARCHAR2 DEFAULT NULL + ,h_href IN VARCHAR2 DEFAULT NULL + ,p_login_button IN VARCHAR2 DEFAULT NULL + ) IS + -- + l_client_id VARCHAR2(240); + l_success BOOLEAN := FALSE; + l_invalid_password BOOLEAN := FALSE; + l_current_ip VARCHAR2(30); + -- + v_message VARCHAR2(2000); + -- + CURSOR cur_syus(p_username IN system_users.db_username%TYPE) IS + SELECT syus.syus_id + ,syus.cust_id + ,syus.inte_id + ,syus.password_expires + ,syus.grace_logins + ,nvl(syus.user_locked + ,'N') user_locked + ,syus.period_start + ,syus.period_end + ,NVL(syus.failed_login_attempts,0) failed_login_attempts + ,syus.password + FROM system_users syus + WHERE syus.db_username = p_username; + -- + r_syus_rec cur_syus%ROWTYPE; + -- + BEGIN + -- + -- If the request is a login request + -- + IF p_login_button = 'Login' THEN + -- + -- Retrieve details from system users for the passed username and password + -- + IF p_username IS NOT NULL THEN + -- + OPEN cur_syus(p_username); + FETCH cur_syus + INTO r_syus_rec; + IF cur_syus%FOUND + THEN + IF scramble(p_username || '/' || p_password) <> r_syus_rec.password + THEN + l_invalid_password := TRUE; + END IF; + END IF; + CLOSE cur_syus; + -- + -- Get current client ID + -- + l_client_id := wsgl.getclientid; + -- + END IF; + -- + -- If username/password valid + -- + IF r_syus_rec.syus_id IS NOT NULL + AND r_syus_rec.user_locked <> 'Y' + AND saco_licensing.check_users + AND saco_licensing.check_license + AND SYSDATE >= r_syus_rec.period_start -- user validity period + AND SYSDATE < (TRUNC(NVL(r_syus_rec.period_end,SYSDATE)) + 1 - (1/86400)) -- HH24:MI:SS = 23:59:59 + AND p_username IS NOT NULL + AND allow_username_login + AND NOT l_invalid_password + THEN + -- + -- Check that current client ID is valid + -- + IF l_client_id IS NOT NULL + AND check_session(l_client_id) THEN + -- + -- Update the session table for this client with + -- the new user + -- + dbms_transaction.begin_discrete_transaction; + -- + UPDATE sessions + SET user_name = p_username + WHERE client_id = l_client_id; + -- + COMMIT; + -- + l_success := TRUE; + -- + ELSE + -- + -- Current client ID is not valid so create a new one + -- + l_client_id := generate_client_id; + -- + -- Write to browser as a cookie + -- + storeclientid(l_client_id); + -- + -- Get current IP address + -- + l_current_ip := NVL(owa_util.get_cgi_env('REMOTE_ADDR'), '127.0.0.1'); + -- + -- Create new session in session table + -- + dbms_transaction.begin_discrete_transaction; + -- + INSERT INTO sessions + (client_id + ,user_name + ,syus_id + ,cust_id + ,inte_id + ,ip_address + ,expires) + VALUES + (l_client_id + ,p_username + ,r_syus_rec.syus_id + ,r_syus_rec.cust_id + ,r_syus_rec.inte_id + ,l_current_ip + ,SYSDATE + (c_session_duration_hours / 24)); + -- + COMMIT; + -- + l_success := TRUE; + -- + END IF; + -- + UPDATE system_users syus + SET syus.failed_login_attempts = 0 + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + -- + -- User can connect, but check to see if account is nearing expiry + -- + IF r_syus_rec.password_expires IS NOT NULL THEN + IF r_syus_rec.password_expires <= SYSDATE THEN + -- + IF r_syus_rec.grace_logins = 0 THEN + -- + r_syus_rec.user_locked := 'Y'; + -- + UPDATE system_users syus + SET syus.user_locked = r_syus_rec.user_locked + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + l_success := FALSE; + v_message := caco_utilities.get_module_text(1000); + -- + ELSIF r_syus_rec.grace_logins = 1 THEN + -- + -- password has expired with no grace logins remaining + -- + UPDATE system_users syus + SET syus.grace_logins = 0 + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + v_message := caco_utilities.get_module_text(1001); + -- + ELSE + -- + -- Password expired, update grace logins + -- + UPDATE system_users syus + SET syus.grace_logins = nvl(grace_logins + ,3) - 1 + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + v_message := wsgl.msggettext(p_msgno => NULL + ,p_dflttext => caco_utilities.get_module_text(1003) + ,p_subst1 => nvl(r_syus_rec.grace_logins + ,3) - 1); + -- + END IF; + -- + ELSIF trunc(r_syus_rec.password_expires) - trunc(SYSDATE) <= 5 THEN + -- + v_message := wsgl.msggettext(p_msgno => NULL + ,p_dflttext => caco_utilities.get_module_text(1004) + ,p_subst1 => trunc(r_syus_rec.password_expires) - + trunc(SYSDATE)); + -- + END IF; + -- + END IF; + -- + ELSE + -- + -- Invalid username / password + -- + IF NOT allow_username_login THEN + -- + v_message := caco_utilities.get_module_text(3930); -- username authentication has been disabled. + -- + ELSIF l_invalid_password + AND r_syus_rec.syus_id IS NOT NULL + AND NVL(r_syus_rec.user_locked,'N') <> 'Y' + THEN + -- + r_syus_rec.failed_login_attempts := NVL(r_syus_rec.failed_login_attempts,0) + 1; + IF r_syus_rec.failed_login_attempts >= C_password_max_tries + THEN + r_syus_rec.user_locked := 'Y'; + v_message := caco_utilities.get_module_text(3966); + ELSE + v_message := REPLACE(caco_utilities.get_module_text(3965),'',TO_CHAR((C_password_max_tries - r_syus_rec.failed_login_attempts))); + END IF; + -- + UPDATE system_users syus + SET syus.failed_login_attempts = r_syus_rec.failed_login_attempts + , syus.user_locked = r_syus_rec.user_locked + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + + ELSIF r_syus_rec.syus_id IS NULL THEN + -- + v_message := wsgl.msggettext(608 + ,wsglm.sec608_invalid_logon); + -- + ELSIF r_syus_rec.user_locked = 'Y' THEN + -- + v_message := caco_utilities.get_module_text(1000); + -- + ELSIF NOT saco_licensing.check_users THEN + -- + v_message := 'Number of concurrent users exceeded, please try again later.'; + -- + ELSIF NOT saco_licensing.check_license THEN + -- + v_message := 'License is not valid - please contact your system administrator.'; + -- + ELSIF SYSDATE < r_syus_rec.period_start -- user validity period + OR SYSDATE > (TRUNC(NVL(r_syus_rec.period_end,SYSDATE)) + 1 - (1/86400)) -- HH24:MI:SS = 23:59:59 + THEN + -- The user has expired. Please contact your system administrator + v_message := caco_utilities.get_module_text(2518); + -- + END IF; + -- + -- EFT request to log failed logons + amfr_journal.log_transaction( 'FAILED LOGIN' + , caco_utilities.get_system_name + , name_value_tab( + name_value_rec('USERNAME', p_username ) + , name_value_rec('CLIENT_ID', l_client_id ) + , name_value_rec('REMOTE_IP', owa_util.get_cgi_env('REMOTE_ADDR') ) + , name_value_rec('MESSAGE', v_message ) + ) + , amfr_journal.g_name_value_tab + ); + -- + IF l_client_id IS NOT NULL THEN + -- + -- Invalid logon so delete the session for the current client. + -- + dbms_transaction.begin_discrete_transaction; + -- + DELETE FROM sessions + WHERE client_id = l_client_id; + -- + COMMIT; + -- + END IF; + -- + END IF; + -- + -- Output HTML to indicate success or failure + -- + htp.htmlopen; + -- + IF l_success THEN + -- + -- Audit the logon action, if enabled + -- + IF cout_system_configuration.get_configuration_item('AUDIT_LOGON') = 'Y' THEN + -- + -- Populate the global variables for use with other packages + -- + caco_security.g_client_id := l_client_id; + -- + amfr_journal.log_transaction('LOGON' + ,caco_utilities.get_system_name + ,amfr_journal.g_name_value_tab + ,amfr_journal.g_name_value_tab); + -- + END IF; + -- + -- Close the login box and navigate back to the application + -- + IF v_message IS NOT NULL THEN + -- + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css'); + -- + -- Display the standard menu + -- + htp.print(caco_system.menu); + + htp.bodyopen; + htp.header(2 + ,wsgl.msggettext(606 + ,wsglm.sec606_logon_success)); + -- + htp.header(4 + ,v_message); + htp.tabledata(htf.formsubmit(cname => 'p_button' + ,cvalue => caco_utilities.get_module_text(992) + ,cattributes => 'onclick="location.href = ''caco_security.change_password'';"') || + ' ' || + htf.formsubmit(cname => 'p_button' + ,cvalue => caco_utilities.get_module_text(993) + ,cattributes => 'onclick="location.href = ''home'';"')); + -- + ELSE + -- + htp.bodyopen; + -- + IF h_href IS NULL + OR UPPER(h_href) LIKE '%/HOME?%' THEN + -- + htp.script(''); + -- + ELSE + -- + htp.script(''); + -- + END IF; + -- + END IF; + -- + ELSE + -- + -- Display failure message + -- + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.eon_css'); + -- + -- Display the standard menu + -- + htp.p(' + '); + htp.p(''); + htp.p('E.ON Földgáz Trade Zrt - Login + + '); + htp.p(' '); + htp.p('
+ +
    +
+
'); + + htp.p(' +
+ + + +
    +
+
+
    + +
+ +
    +
+ +
'); + -- + htp.bodyopen(cattributes => 'onLoad="return Logon_OnLoad()"'); + htp.br; + htp.header(2 + ,v_message); + htp.br; + -- + show_logon_form(TRUE, h_href); + -- + htp.p('
+
+
+
+

© E.ON Földgáz Trade Zrt. 2007

+ +
+
+ + '); + -- + END IF; + -- + htp.bodyclose; + htp.htmlclose; + -- + ELSIF p_login_button = 'Register' THEN + -- + -- Show the user registration page + -- + online_user_registration; + -- + END IF; + -- + END process_logon; + -- + -- Process_Logon: Overloaded version for client certificate + -- + PROCEDURE process_certificate_logon IS + -- + l_client_id VARCHAR2(240); + l_success BOOLEAN := FALSE; + l_current_ip VARCHAR2(30); + -- + l_client_certificate VARCHAR2(4000) := SUBSTR(owa_util.get_cgi_env('SSL_CLIENT_CERT'),1,4000); + l_client_cert_serial VARCHAR2(4000) := SUBSTR(owa_util.get_cgi_env('SSL_CLIENT_M_SERIAL'),1,4000); + l_client_cert_start VARCHAR2(4000) := SUBSTR(owa_util.get_cgi_env('SSL_CLIENT_V_START'),1,4000); + l_client_cert_end VARCHAR2(4000) := SUBSTR(owa_util.get_cgi_env('SSL_CLIENT_V_END'),1,4000); + l_client_cert_verify VARCHAR2(4000) := SUBSTR(owa_util.get_cgi_env('SSL_CLIENT_VERIFY'),1,4000); + -- + BEGIN + -- + IF l_client_certificate IS NOT NULL + AND l_client_cert_serial IS NOT NULL THEN + -- + -- Client certificate has been presented, let's check it + -- + IF l_client_cert_verify = 'SUCCESS' THEN + -- + -- Certificate is valid, check the date range + -- + IF SYSDATE BETWEEN TO_DATE(SUBSTR(l_client_cert_start,1,20),'Mon DD HH24:MI:SS YYYY') AND TO_DATE(SUBSTR(l_client_cert_end,1,20),'Mon DD HH24:MI:SS YYYY') THEN + -- + -- Change the serial number into a recognised format + -- + l_client_cert_serial := SUBSTR(l_client_cert_serial,3,2)||':'||SUBSTR(l_client_cert_serial,5,2)||':'||SUBSTR(l_client_cert_serial,7,2)||':'||SUBSTR(l_client_cert_serial,9,2)||':'||SUBSTR(l_client_cert_serial,11,2)||':'||SUBSTR(l_client_cert_serial,13,2); + -- + -- Check to see if this certificate is linked to an active user + -- + FOR rec IN (SELECT su.syus_id + ,su.db_username + ,su.inte_id + ,su.cust_id + FROM system_users su + WHERE su.certificate_serial = l_client_cert_serial + AND SYSDATE BETWEEN period_start AND NVL(period_end, SYSDATE) + AND user_locked = 'N' + ) LOOP + -- + l_client_id := wsgl.getclientid; + -- + IF l_client_id IS NOT NULL + AND check_session(l_client_id) THEN + -- + -- Update the session table for this client with + -- the new user + -- + dbms_transaction.begin_discrete_transaction; + -- + UPDATE sessions + SET user_name = rec.db_username + WHERE client_id = l_client_id; + -- + COMMIT; + -- + l_success := TRUE; + -- + ELSE + -- + -- Current client ID is not valid so create a new one + -- + l_client_id := generate_client_id; + -- + -- Write to browser as a cookie + -- + storeclientid(l_client_id); + -- + -- Get current IP address + -- + l_current_ip := NVL(owa_util.get_cgi_env('REMOTE_ADDR'), '127.0.0.1'); + -- + -- Create new session in session table + -- + dbms_transaction.begin_discrete_transaction; + -- + INSERT INTO sessions + (client_id + ,user_name + ,syus_id + ,cust_id + ,inte_id + ,ip_address + ,expires) + VALUES + (l_client_id + ,rec.db_username + ,rec.syus_id + ,rec.cust_id + ,rec.inte_id + ,l_current_ip + ,SYSDATE + (c_session_duration_hours / 24)); + -- + COMMIT; + -- + l_success := TRUE; + get_session_data(l_client_id); + -- + END IF; + -- + END LOOP; + -- + ELSE + -- + -- Current date falls outside valid range, should never happen as AS should catch this + -- + htp.p('Client certificate is not valid at this time. Date from '||l_client_cert_start||' to '||l_client_cert_end); + -- + END IF; + -- + ELSE + -- + -- Client certificate isn't valid - should put out a message, just print out for the moment + -- + htp.p('Client certificate is not valid, status is: '||l_client_cert_verify); + -- + END IF; + -- + -- Journal this request + -- + amfr_journal.log_transaction( 'INSERT' + , 'Certificate Login' + , name_value_tab( + name_value_rec('Serial Number', l_client_cert_serial ) + ) + , amfr_journal.g_name_value_tab + ); + -- + END IF; + -- + END process_certificate_logon; + -- + -- Show_No_Access: Displays message to inform user that they do not + -- have access to the application. Provides a link + -- to the logon form. + -- + PROCEDURE show_no_access IS + BEGIN + htp.htmlopen; + -- + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css?p_type=logon'); + -- + htp.headopen; + htp.title('Access Denied'); + htp.headclose; + htp.bodyopen; + htp.script(' +function show_logon() { + frmLogon = open("caco_security.show_logon_form","winLogon","scrollbars=no,resizable=yes,width=400,height=300"); + if (frmLogon.opener == null) { + frmLogon.opener = self; + }; +};'); + htp.header(2 + ,wsgl.msggettext(609 + ,wsglm.sec609_access_denied)); + htp.header(4 + ,wsgl.msggettext(610 + ,wsglm.sec610_no_permission)); + htp.hr; + htp.p(''); + htp.p(''); + htp.bodyclose; + htp.htmlclose; + END; + -- + -- + -- Call_Logon_Form: Outputs javascript to popup logon form in new window, + -- or include logon form in current window if javascript + -- is not available. + -- + PROCEDURE call_logon_form IS + BEGIN + -- + IF saco_licensing.check_license + AND saco_licensing.check_users THEN + -- + htp.htmlopen; + -- + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css?p_type=general'); + -- + htp.bodyopen; + -- + htp.script(' +'); + htp.p(''); + -- + htp.bodyclose; + htp.htmlclose; + -- + END IF; + -- + END; + -- + -- + -- Add_Package_Resp: Adds a respondibility to a package, allowing users + -- with that responsibility to access the application. + -- This is called from the generated application + -- installation script if a value is supplied for + -- preference SECRES. + -- + PROCEDURE add_package_resp(p_package_name IN VARCHAR2 + ,p_responsibility IN VARCHAR2) IS + l_rows INTEGER := 0; + l_syop_id NUMBER; + l_sypr_id NUMBER; + v_exists BOOLEAN; + v_module_to_add system_options.module_name%TYPE; + v_syop_id system_options.syop_id%TYPE; + v_sypr_id system_profiles.sypr_id%TYPE; + + FUNCTION get_syop_id(p_module_name IN system_options.module_name%TYPE) + RETURN system_options.syop_id%TYPE IS + v_syop_id system_options.syop_id%TYPE; + BEGIN + v_syop_id := NULL; + FOR v_syop_rec IN (SELECT syop_id + FROM system_options syop + WHERE lower(syop.module_name) = + lower(p_module_name)) LOOP + v_syop_id := v_syop_rec.syop_id; + END LOOP; + IF v_syop_id IS NULL THEN + -- + -- this module does not currently exist + -- + INSERT INTO system_options + (option_type + ,description + ,NAME + ,module_name) + VALUES + ('S' + ,'Generated ' || to_char(SYSDATE + ,'dd-mon-yy hh24:mi:ss') + ,substr(lower(p_module_name) + ,1 + ,40) + ,substr(p_module_name + ,1 + ,255)) + RETURNING syop_id INTO v_syop_id; + END IF; + + RETURN v_syop_id; + END get_syop_id; + + FUNCTION get_sypr_id(p_name IN system_profiles.NAME%TYPE) + RETURN system_profiles.sypr_id%TYPE IS + v_sypr_id system_profiles.sypr_id%TYPE; + BEGIN + v_sypr_id := NULL; + FOR v_sypr_rec IN (SELECT sypr_id + FROM system_profiles sypr + WHERE upper(sypr.NAME) = upper(p_name)) LOOP + v_sypr_id := v_sypr_rec.sypr_id; + END LOOP; + + IF v_sypr_id IS NULL THEN + -- + -- this role does not currently exist + -- + INSERT INTO system_profiles + (NAME + ,description + ,role_name) + VALUES + (p_name + ,'Generated ' || to_char(SYSDATE + ,'dd-mon-yy hh24:mi:ss') || ' ' || + p_name + ,p_name) + RETURNING sypr_id INTO v_sypr_id; + END IF; + RETURN v_sypr_id; + END get_sypr_id; + + BEGIN + -- + -- get the role and the option ids + -- + v_sypr_id := get_sypr_id(p_responsibility); + -- + IF instr(p_package_name + ,'$') > 0 THEN + -- + v_module_to_add := lower(substr(p_package_name + ,1 + ,instr(p_package_name + ,'$'))) || '.startup'; + -- + ELSE + -- + v_module_to_add := p_package_name; + -- + END IF; + -- + v_syop_id := get_syop_id(v_module_to_add); + v_exists := FALSE; + -- + FOR v_package_installed IN (SELECT 1 + FROM profile_options + WHERE sypr_id = v_sypr_id + AND syop_id = v_syop_id) LOOP + v_exists := TRUE; + END LOOP; + + IF NOT v_exists THEN + INSERT INTO profile_options + (sypr_id + ,syop_id) + VALUES + (v_sypr_id + ,v_syop_id); + END IF; + END add_package_resp; + -- + PROCEDURE logout AS + l_client_id VARCHAR2(240); + l_script_name VARCHAR2(80) := owa_util.get_cgi_env('SCRIPT_NAME'); + BEGIN + -- Send a redirect to a public home page + htp.p('Location: ' || caco_system.home_path); + -- Send a cookie to indicate that that you want to logout + owa_cookie.send(NAME => 'WDB_GATEWAY_LOGOUT' + ,VALUE => 'YES' + ,path => '/'); + IF substr(l_script_name + ,-1 + ,1) = '/' THEN + l_script_name := substr(l_script_name + ,1 + ,length(l_script_name) - 1); + END IF; + + -- send a cookie to set the clientid to null + owa_cookie.send(NAME => wsgl.wsg_clientid_cookie + ,VALUE => NULL + ,path => l_script_name); + -- + -- Close the http header + -- + htp.p; + -- + -- Get current client ID + -- + l_client_id := wsgl.getclientid; + IF l_client_id IS NOT NULL THEN + -- + -- Delete session for this client + -- + dbms_transaction.begin_discrete_transaction; + -- + IF cout_system_configuration.get_configuration_item('AUDIT_LOGOFF') = 'Y' THEN + -- + -- Populate the global variables for use with other packages + -- + amfr_journal.log_transaction('LOGOFF' + ,caco_utilities.get_system_name + ,amfr_journal.g_name_value_tab + ,amfr_journal.g_name_value_tab); + -- + END IF; + -- + DELETE FROM sessions + WHERE client_id = l_client_id; + COMMIT; + END IF; + + END; + + -- + -- Logoff: Removes the current user's session, logging them off. Outputs + -- HTML message when complete. + -- + PROCEDURE logoff IS + l_client_id VARCHAR2(240); + BEGIN + htp.htmlopen; + -- + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css?p_type=logon'); + -- + htp.headopen; + htp.title(wsgl.msggettext(611 + ,wsglm.sec611_logging_off)); + htp.headclose; + htp.bodyopen; + -- + -- Get current client ID + -- + l_client_id := wsgl.getclientid; + IF l_client_id IS NOT NULL THEN + -- + -- Delete session for this client + -- + dbms_transaction.begin_discrete_transaction; + -- + IF cout_system_configuration.get_configuration_item('AUDIT_LOGOFF') = 'Y' THEN + -- + -- Populate the global variables for use with other packages + -- + amfr_journal.log_transaction('LOGOFF' + ,caco_utilities.get_system_name + ,amfr_journal.g_name_value_tab + ,amfr_journal.g_name_value_tab); + -- + END IF; + -- + DELETE FROM sessions + WHERE client_id = l_client_id; + -- + COMMIT; + -- + END IF; + htp.header(2 + ,wsgl.msggettext(612 + ,wsglm.sec612_logged_off)); + htp.bodyclose; + htp.htmlclose; + END; + -- + --- + -- S E T C U R R E N T I N T E C U S T + --- + PROCEDURE set_current_inte_cust(p_inte_id IN intermediaries.inte_id%TYPE + ,p_cust_id IN customers.cust_id%TYPE) IS + -- + CURSOR cur_cust_inte(p_syus_id IN system_users.syus_id%TYPE, p_inte_id IN intermediaries.inte_id%TYPE, p_cust_id IN customers.cust_id%TYPE) IS + SELECT NULL + FROM intermediary_users inus + ,customer_intermediaries cuin + WHERE cuin.inte_id = inus.inte_id + AND cuin.cust_id = p_cust_id + AND cuin.inte_id = p_inte_id + AND inus.syus_id = p_syus_id; + -- + v_dummy VARCHAR2(10); + -- + BEGIN + -- + caco_utilities.get_user_data; + -- + FOR v_cust_inte IN (SELECT NULL + FROM intermediary_users inus + ,customer_intermediaries cuin + WHERE cuin.inte_id = inus.inte_id + AND cuin.cust_id = p_cust_id + AND cuin.inte_id = p_inte_id + AND inus.syus_id = + caco_security.g_current_syus_id) LOOP + -- + UPDATE sessions sess + SET sess.cust_id = p_cust_id + ,sess.inte_id = nvl(p_inte_id + ,sess.inte_id) + WHERE sess.client_id = caco_security.g_client_id; + -- + caco_utilities.get_user_data(TRUE); + -- + END LOOP; + -- + END set_current_inte_cust; + --- + -- C H A N G E C U S T I N T E + --- + PROCEDURE change_cust_inte(p_inte_id IN intermediaries.inte_id%TYPE DEFAULT NULL + ,p_cust_id IN customers.cust_id%TYPE DEFAULT NULL + ,p_savebtn IN VARCHAR2 DEFAULT NULL + ,p_cancbtn IN VARCHAR2 DEFAULT NULL + ,p_message IN VARCHAR2 DEFAULT NULL) IS + -- + CURSOR cur_inte IS + SELECT inte.inte_id + ,inte.NAME + FROM intermediaries inte + ,intermediary_users inus + WHERE inte.inte_id = inus.inte_id + AND inus.syus_id = caco_utilities.get_syus_id + ORDER BY inte.NAME; + -- + CURSOR cur_cust(p_inte_id IN intermediaries.inte_id%TYPE DEFAULT NULL) IS + SELECT cust.cust_id + ,cust.NAME + FROM customers cust + ,customer_intermediaries cuin + ,intermediary_users inus + WHERE cuin.inte_id = inus.inte_id + AND cust.cust_id = cuin.cust_id + AND inus.syus_id = caco_utilities.get_syus_id + AND (cuin.inte_id = p_inte_id OR p_inte_id IS NULL) + GROUP BY cust.cust_id + ,cust.NAME + ORDER BY cust.NAME; + -- + v_array_string VARCHAR2(2000); + v_first_inte_id NUMBER; + v_first BOOLEAN; + -- + BEGIN + -- + IF NOT caco_security.security_check('caco_security.change_cust_inte') THEN + -- + RETURN; + -- + END IF; + -- + IF p_savebtn IS NULL + AND p_cancbtn IS NULL THEN + -- + -- Draw screen + -- + htp.htmlopen; + caco_System.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css?p_type=general'); + -- + htp.bodyopen; + htp.p(caco_system.menu); + htp.p(caco_system.statusbar); + htp.bodyclose; + -- + htp.p(''); + -- + htp.title(caco_utilities.get_module_text(3540)); + -- + htp.header(1 + ,caco_utilities.get_module_text(3540)); + -- + htp.bodyopen; + -- + IF p_message IS NOT NULL THEN + -- + htp.p(htf.italic(p_message)); + -- + END IF; + -- + htp.formopen(curl => 'caco_security.change_cust_inte' + ,cmethod => 'POST' + ,cattributes => 'NAME="custinte"'); + -- + htp.tableopen(cborder => '0'); + -- + htp.tablerowopen; + -- + htp.tabledata(calign => 'LEFT' + ,cattributes => 'WIDTH="25%"' + ,cvalue => htf.bold(caco_utilities.get_module_text(3541)||': ')); + -- + htp.p(''); + -- + htp.formselectopen(cname => 'p_inte_id' + ,cattributes => 'onChange="populateCustomer(document.custinte,document.custinte.p_inte_id.options[document.custinte.p_inte_id.selectedIndex].value)"'); + -- + v_first := TRUE; + -- + FOR cur_inte_rec IN cur_inte LOOP + -- + htp.formselectoption(cur_inte_rec.NAME + ,NULL + ,cattributes => 'VALUE="' || + to_char(cur_inte_rec.inte_id) || '"'); + -- + IF v_first THEN + -- + -- Get the first inte put into the poplist in order to sync the customers + -- + v_first_inte_id := cur_inte_rec.inte_id; + v_first := FALSE; + -- + END IF; + -- + END LOOP; + -- + htp.formselectclose; + htp.p(''); + htp.tabledata(calign => 'LEFT' + ,cattributes => 'WIDTH="25%"' + ,cvalue => htf.bold(caco_utilities.get_module_text(3542)||': ')); + htp.tabledata(calign => 'LEFT' + ,cattributes => 'WIDTH="25%"' + ,cvalue => caco_utilities.get_inte_name); + htp.tablerowclose; + -- + htp.tablerowopen; + -- + htp.tabledata(cvalue => htf.bold(caco_utilities.get_module_text(3543)||': ')); + -- + htp.p(''); + -- + htp.formselectopen(cname => 'p_cust_id'); + -- + FOR cur_cust_rec IN cur_cust(v_first_inte_id) LOOP + -- + htp.formselectoption(cur_cust_rec.NAME + ,NULL + ,cattributes => 'VALUE="' || + to_char(cur_cust_rec.cust_id) || '"'); + -- + END LOOP; + -- + htp.formselectclose; + htp.p(''); + htp.tabledata(calign => 'LEFT' + ,cattributes => 'WIDTH="25%"' + ,cvalue => htf.bold(caco_utilities.get_module_text(3541)||': ')); + htp.tabledata(calign => 'LEFT' + ,cattributes => 'WIDTH="25%"' + ,cvalue => caco_utilities.get_cust_name); + htp.tablerowclose; + -- + htp.tableclose; + htp.br; + -- + htp.formsubmit('p_savebtn' + ,caco_utilities.get_module_text(837)); + htp.formsubmit('p_cancbtn' + ,caco_utilities.get_module_text(993)); + -- + htp.formclose; + htp.bodyclose; + htp.htmlclose; + -- + ELSIF p_cancbtn IS NOT NULL THEN + -- + change_cust_inte(p_message => caco_utilities.get_module_text(3545)); + -- + ELSIF p_savebtn IS NOT NULL THEN + -- + -- Update current customer and intermediary + -- + set_current_inte_cust(p_inte_id + ,p_cust_id); + -- + change_cust_inte(p_message => caco_utilities.get_module_text(3546)); + -- + END IF; + -- + END change_cust_inte; + -- + PROCEDURE check_password_policies ( p_password IN VARCHAR2 + , p_message IN OUT VARCHAR2 + , p_success IN OUT BOOLEAN + ) IS + -- + c_password_length CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_PASSWORD_LENGTH'),1); + c_numeric_chars CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_PASSWORD_NUM_CHRS'),0); + c_uppercase_chars CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_PASSWORD_UPP_CHRS'),0); + c_lowercase_chars CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_PASSWORD_LOW_CHRS'),0); + c_punct_chars CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_PASSWORD_SPC_CHRS'),0); + -- + c_digitarray CONSTANT VARCHAR2(20) := '0123456789'; + c_punctarray CONSTANT VARCHAR2(25) := '!"#$%&()``*+,-/:;<=>?_'; + c_upperarray CONSTANT VARCHAR2(26) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + c_lowerarray CONSTANT VARCHAR2(26) := 'abcdefghijklmnopqrstuvwxyz'; + -- + v_password_length NUMBER; + v_numeric_chars NUMBER; + v_uppercase_chars NUMBER; + v_lowercase_chars NUMBER; + v_punct_chars NUMBER; + -- + v_dummy VARCHAR2(50); + v_type VARCHAR2(50); + v_sub_list caco_utilities.g_t_substitution_list; + -- + BEGIN + -- + -- Get password length + -- + v_password_length := LENGTH(p_password); + -- + -- Check for numerics + -- + v_dummy := p_password; + -- + FOR i IN 1..LENGTH(c_digitarray) LOOP + -- + v_dummy := REPLACE(v_dummy, SUBSTR(c_digitarray,i,1),''); + -- + END LOOP; + -- + v_numeric_chars := v_password_length - LENGTH(v_dummy); + -- + -- Check for uppercase characters + -- + v_dummy := p_password; + -- + FOR i IN 1..LENGTH(c_upperarray) LOOP + -- + v_dummy := REPLACE(v_dummy, SUBSTR(c_upperarray,i,1),''); + -- + END LOOP; + -- + v_uppercase_chars := v_password_length - LENGTH(v_dummy); + -- + -- Check for lowercase characters + -- + v_dummy := p_password; + -- + FOR i IN 1..LENGTH(c_lowerarray) LOOP + -- + v_dummy := REPLACE(v_dummy, SUBSTR(c_lowerarray,i,1),''); + -- + END LOOP; + -- + v_lowercase_chars := v_password_length - LENGTH(v_dummy); + -- + -- Check for special characters + -- + v_dummy := p_password; + -- + FOR i IN 1..LENGTH(c_punctarray) LOOP + -- + v_dummy := REPLACE(v_dummy, SUBSTR(c_punctarray,i,1),''); + -- + END LOOP; + -- + v_punct_chars := v_password_length - LENGTH(v_dummy); + -- + -- Gathered all the info, now check and report + -- + IF v_password_length < c_password_length THEN + -- + v_sub_list(1) := c_password_length; + -- + caco_utilities.get_exception_message ( p_exception_number => -20528 + , p_message => p_message + , p_exme_type => v_type + , p_substitution_list => v_sub_list + ); + -- + p_success := FALSE; + -- + ELSIF v_numeric_chars < c_numeric_chars THEN + -- + v_sub_list(1) := c_numeric_chars; + -- + caco_utilities.get_exception_message ( p_exception_number => -20529 + , p_message => p_message + , p_exme_type => v_type + , p_substitution_list => v_sub_list + ); + -- + p_success := FALSE; + -- + ELSIF v_uppercase_chars < c_uppercase_chars THEN + -- + v_sub_list(1) := c_uppercase_chars; + -- + caco_utilities.get_exception_message ( p_exception_number => -20530 + , p_message => p_message + , p_exme_type => v_type + , p_substitution_list => v_sub_list + ); + -- + p_success := FALSE; + -- + ELSIF v_lowercase_chars < c_lowercase_chars THEN + -- + v_sub_list(1) := c_lowercase_chars; + -- + caco_utilities.get_exception_message ( p_exception_number => -20531 + , p_message => p_message + , p_exme_type => v_type + , p_substitution_list => v_sub_list + ); + -- + p_success := FALSE; + -- + ELSIF v_punct_chars < c_punct_chars THEN + -- + v_sub_list(1) := c_punctarray; + v_sub_list(2) := c_punct_chars; + -- + caco_utilities.get_exception_message ( p_exception_number => -20532 + , p_message => p_message + , p_exme_type => v_type + , p_substitution_list => v_sub_list + ); + -- + p_success := FALSE; + -- + END IF; + -- + v_dummy := NULL; + -- + END check_password_policies; + -- + PROCEDURE change_password(p_call_type IN VARCHAR2 DEFAULT NULL + ,p_old_password IN VARCHAR2 DEFAULT NULL + ,p_password IN VARCHAR2 DEFAULT NULL + ,p_confirm IN VARCHAR2 DEFAULT NULL + ,p_button IN VARCHAR2 DEFAULT NULL + ,p_embedded IN BOOLEAN DEFAULT FALSE) IS + -- + CURSOR cur_syop(p_syus_id IN system_users.syus_id%TYPE) IS + SELECT syus.password + FROM system_users syus + WHERE syus.syus_id = p_syus_id; + -- + v_message module_text.text%TYPE; + v_proceed BOOLEAN := TRUE; + v_password system_users.password%TYPE; + -- + BEGIN + -- + -- Standard HTML header. + -- + IF NOT caco_security.security_check('caco_security.change_password') THEN + -- + RETURN; + -- + END IF; + -- + IF NOT p_embedded THEN + -- + htp.htmlopen; + caco_system.content_type; + htp.linkrel('stylesheet' + ,'caco_system.css?p_type=content'); + -- + htp.headopen; + htp.p(caco_system.menu); + htp.p(caco_system.statusbar); + htp.headclose; + -- + htp.bodyopen; + -- + htp.title(caco_utilities.get_module_text(986)); + htp.header(1 + ,caco_utilities.get_module_text(987) || ' ' || + caco_utilities.get_syus_name); + -- + END IF; + -- + IF p_call_type IS NULL THEN + -- + htp.p(''); + -- + htp.para; + htp.p(caco_utilities.get_module_text(988)); + -- + htp.formopen(curl => 'caco_security.change_password' + ,ctarget => '' + ,cattributes => 'NAME="Passwordform"'); + -- + htp.formhidden(cname => 'p_call_type' + ,cvalue => 'C'); + -- + htp.tableopen; + -- + htp.tablerowopen; + htp.tabledata(htf.bold(caco_utilities.get_module_text(345))); + htp.tabledata(htf.bold(caco_utilities.get_syus_name)); + htp.tablerowclose; + -- + htp.tablerowopen; + htp.tabledata(htf.bold(caco_utilities.get_module_text(989))); + htp.tabledata(htf.formpassword(cname => 'p_old_password')); + htp.tablerowclose; + -- + htp.tablerowopen; + htp.tabledata(htf.bold(caco_utilities.get_module_text(990))); + htp.tabledata(htf.formpassword(cname => 'p_password')); + htp.tablerowclose; + -- + htp.tablerowopen; + htp.tabledata(htf.bold(caco_utilities.get_module_text(991))); + htp.tabledata(htf.formpassword(cname => 'p_confirm')); + htp.tablerowclose; + -- + htp.tablerowopen; + htp.tabledata(htf.br); + htp.tabledata(htf.br); + htp.tablerowclose; + -- + htp.tablerowopen; + htp.tabledata(htf.formsubmit(cname => 'p_button' + ,cvalue => caco_utilities.get_module_text(992)) || + ' ' || + htf.formsubmit(cname => 'p_button' + ,cvalue => caco_utilities.get_module_text(993))); + htp.tablerowclose; + -- + htp.tablerowopen; + htp.tabledata('''*'''||caco_utilities.get_module_text(2202)); + htp.tablerowclose; + -- + htp.formclose; + -- + ELSE + -- + -- Not the main screen, therefore validate and process passed data + -- + IF p_button = caco_utilities.get_module_text(992) THEN + -- + -- OK, validate and process password entry + -- + IF p_old_password IS NULL + OR p_password IS NULL + OR p_confirm IS NULL THEN + -- + -- Not all mandatory fields have been entered + -- + v_message := caco_utilities.get_module_text(994); + v_proceed := FALSE; + -- + END IF; + -- + -- Check old password against stored password + -- + OPEN cur_syop(caco_utilities.get_syus_id); + FETCH cur_syop + INTO v_password; + CLOSE cur_syop; + -- + IF v_password <> + scramble(caco_utilities.get_syus_name || '/' || p_old_password) THEN + -- + v_message := caco_utilities.get_module_text(995); + v_proceed := FALSE; + -- + END IF; + -- + -- Check p_password is the same as p_confirm + -- + IF p_password <> p_confirm THEN + -- + v_message := caco_utilities.get_module_text(996); + v_proceed := FALSE; + -- + END IF; + -- + -- Check that p_old_password <> p_password + -- + /*IF scramble(caco_utilities.get_syus_name || '/' || p_password) = + p_old_password THEN*/ + IF p_password = p_old_password THEN + -- + v_message := caco_utilities.get_module_text(997); + v_proceed := FALSE; + -- + END IF; + -- + -- Additional password policies + -- + check_password_policies ( p_password => p_password + , p_message => v_message + , p_success => v_proceed + ); + -- + IF v_proceed THEN + -- + -- Update the system user with the new password + -- also set the expiry date to 30 days from today + -- and reset the grace logins to 3 + -- + v_password := scramble(caco_utilities.get_syus_name || '/' || + p_password); + -- + UPDATE system_users syus + SET syus.password = v_password + ,syus.password_expires = trunc(SYSDATE) + C_password_expiry_period + ,syus.grace_logins = 3 + WHERE syus.syus_id = caco_utilities.get_syus_id; + -- + --amfrw050$syus.update_user_details(caco_utilities.get_syus_name, p_password, 'UPDATE'); + -- + htp.header(4 + ,caco_utilities.get_module_text(998) || ' ' || + to_char(trunc(SYSDATE) + 30 + ,'DD-MON-YYYY')); + -- + ELSE + -- + -- Something is wrong, display the stored error message and redisplay the change password page + -- + htp.header(4 + ,v_message); + htp.hr; + -- + caco_security.change_password(p_embedded => TRUE); + -- + END IF; + -- + ELSIF p_button = caco_utilities.get_module_text(993) THEN + -- + -- Cancel, show cancelation screen + -- + htp.header(4 + ,caco_utilities.get_module_text(999)); + -- + END IF; + -- + END IF; + -- + IF NOT p_embedded THEN + -- + htp.bodyclose; + htp.htmlclose; + -- + END IF; + -- + END change_password; + -- + -- Remove expired sessions + -- + PROCEDURE remove_expired_sessions IS + -- + PRAGMA AUTONOMOUS_TRANSACTION; + -- + BEGIN + -- + DELETE FROM sessions sess + WHERE sess.expires < SYSDATE; + -- + COMMIT; + -- + END remove_expired_sessions; + --- + -- PROCESS INTERFACE LOGON + --- + PROCEDURE process_interface_logon ( p_username IN VARCHAR2 + , p_password IN VARCHAR2 + , p_success OUT BOOLEAN + , p_message OUT VARCHAR2 ) IS + -- + l_client_id VARCHAR2(240); + -- + CURSOR cur_syus ( p_username IN system_users.db_username%TYPE + , p_password IN system_users.password%TYPE + ) IS + SELECT syus.syus_id + ,syus.cust_id + ,syus.inte_id + ,syus.password_expires + ,syus.grace_logins + ,nvl(syus.user_locked + ,'N') user_locked + ,syus.period_start + ,syus.period_end + FROM system_users syus + WHERE syus.db_username = p_username + AND syus.password = p_password; + -- + r_syus_rec cur_syus%ROWTYPE; + -- + BEGIN + -- + -- Initialise boolean with a pessimistic viewpoint + -- + p_success := FALSE; + -- + -- Retrieve details from system users for the passed username and password + -- + OPEN cur_syus(p_username + ,scramble(p_username || '/' || p_password)); + FETCH cur_syus + INTO r_syus_rec; + CLOSE cur_syus; + -- + -- Get current client ID + -- + --l_client_id := wsgl.getclientid; //AG removed + -- + -- If username/password valid + -- + IF r_syus_rec.syus_id IS NOT NULL + AND r_syus_rec.user_locked <> 'Y' + AND saco_licensing.check_users + AND saco_licensing.check_license + AND SYSDATE >= r_syus_rec.period_start -- user validity period + AND SYSDATE < (TRUNC(NVL(r_syus_rec.period_end,SYSDATE)) + 1 - (1/86400)) THEN -- HH24:MI:SS = 23:59:59 + -- + -- Check that current client ID is valid + -- + IF l_client_id IS NOT NULL + AND check_session(l_client_id) THEN + -- + -- Update the session table for this client with + -- the new user + -- +-- dbms_transaction.begin_discrete_transaction; + -- + UPDATE sessions s + SET s.user_name = p_username + ,s.syus_id = r_syus_rec.syus_id + ,s.cust_id = r_syus_rec.cust_id + ,s.inte_id = r_syus_rec.inte_id + WHERE client_id = l_client_id; + -- +-- COMMIT; + -- + -- + ELSE + -- + -- Current client ID is not valid so create a new one + -- + l_client_id := generate_client_id; + -- + -- Write to browser as a cookie + -- + --storeclientid(l_client_id); //AG removed + -- + -- Create new session in session table + -- +-- dbms_transaction.begin_discrete_transaction; + -- + INSERT INTO sessions + (client_id + ,user_name + ,syus_id + ,cust_id + ,inte_id + ,ip_address + ,expires) + VALUES + (l_client_id + ,p_username + ,r_syus_rec.syus_id + ,r_syus_rec.cust_id + ,r_syus_rec.inte_id + ,NVL(owa_util.get_cgi_env('REMOTE_ADDR'),'127.0.0.1') + ,SYSDATE + (c_session_duration_hours / 24)); + -- + g_current_syus_id := r_syus_rec.syus_id; + -- +-- COMMIT; + -- + END IF; + -- + -- If I'm here, I'm successful + -- + p_success := TRUE; + -- + -- + -- User can connect, but check to see if account is nearing expiry + -- + IF r_syus_rec.password_expires IS NOT NULL THEN + -- + IF r_syus_rec.password_expires <= SYSDATE THEN + -- + IF r_syus_rec.grace_logins = 0 THEN + -- + r_syus_rec.user_locked := 'Y'; + -- + UPDATE system_users syus + SET syus.user_locked = r_syus_rec.user_locked + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + p_success := FALSE; + p_message := caco_utilities.get_module_text(1000); + -- + ELSIF r_syus_rec.grace_logins = 1 THEN + -- + -- password has expired with no grace logins remaining + -- + UPDATE system_users syus + SET syus.grace_logins = 0 + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + ELSE + -- + -- Password expired, update grace logins + -- + UPDATE system_users syus + SET syus.grace_logins = NVL(grace_logins + ,3) - 1 + WHERE syus.syus_id = r_syus_rec.syus_id; + -- + END IF; + -- + END IF; + -- + END IF; + -- + ELSE + -- + -- Invalid username / password + -- + IF r_syus_rec.syus_id IS NULL THEN + -- + p_message := wsgl.msggettext(608 + ,wsglm.sec608_invalid_logon); + -- + ELSIF r_syus_rec.user_locked = 'Y' THEN + -- + p_message := caco_utilities.get_module_text(1000); + -- + ELSIF NOT saco_licensing.check_license THEN + -- + p_message := 'License is not valid - please contact your system administrator.'; + -- + ELSIF SYSDATE < r_syus_rec.period_start -- user validity period + OR SYSDATE > (TRUNC(NVL(r_syus_rec.period_end,SYSDATE)) + 1 - (1/86400)) -- HH24:MI:SS = 23:59:59 + THEN + -- The user has expired. Please contact your system administrator + p_message := caco_utilities.get_module_text(2518); + -- + END IF; + -- + IF l_client_id IS NOT NULL THEN + -- + -- Invalid logon so delete the session for the current client. + -- +-- dbms_transaction.begin_discrete_transaction; + -- + DELETE FROM sessions + WHERE client_id = l_client_id; + -- +-- COMMIT; + -- + END IF; + -- + END IF; + -- + END process_interface_logon; + -- +END caco_security; -- of package +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/caco_security.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/caco_security.spc new file mode 100644 index 0000000..e900696 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/caco_security.spc @@ -0,0 +1,170 @@ +CREATE OR REPLACE PACKAGE caco_security IS + -- + g_header CONSTANT VARCHAR2(160) := '$Header: /Isle Of Grain/database/PLSQL/caco_security.pck 4 20/10/05 13:33 Gilberta $'; + g_revision CONSTANT VARCHAR2(160) := '$Revision: 4 $ Patch 0.2'; + -- + /* + * $History: caco_security.pck $ + * + * ******** EFT - Nominations - Patch 0.2 ******** + * Added logging of failed login + * + * ***************** Version 4 ***************** + * User: Gilberta Date: 20/10/05 Time: 13:33 + * Updated in $/Isle Of Grain/database/PLSQL + * Modified to size the username and password fields on the login screen + * for the benefit of IE6. + * + * ***************** Version 3 ***************** + * User: Gilberta Date: 18/07/05 Time: 10:22 + * Updated in $/Isle Of Grain/database/PLSQL + * Modified to fix password expiry + * + * ***************** Version 1 ***************** + * User: Gilberta Date: 7/01/05 Time: 12:54 + * Created in $/Isle Of Grain/database/PLSQL + * Initial Version + * + */ + -- + -- Globals + -- + g_current_user VARCHAR2(30); + g_current_syus_id NUMBER; + g_current_cust_id NUMBER; + g_current_inte_id NUMBER; + C_password_max_tries CONSTANT NUMBER := NVL(cout_system_configuration.get_configuration_item('G_PASSWORD_FAILED_LOGINS'),3); + + -- + g_client_id VARCHAR2(240); + -- + --------------------------------------------------------------------- + -- Security API functions + -- These functions may be called from generated WSG applications. + --------------------------------------------------------------------- + -- + -- Security_Check: Returns true if the currently logged on user is + -- allowed access to the specified package. If not, + -- will return false. This function will also provide + -- a means for the user to log on. + -- + FUNCTION security_check(p_package_name IN VARCHAR2) RETURN BOOLEAN; + -- + -- + -- Add_Package_Resp: Adds a respondibility to a package, allowing users + -- with that responsibility to access the application. + -- This is called from the generated application + -- installation script if a value is supplied for + -- preference SECRES. + -- + PROCEDURE add_package_resp(p_package_name IN VARCHAR2 + ,p_responsibility IN VARCHAR2); + -- + -------------------------------------------------------------------------- + -- Implementation specific functions + -- These functions are used only by this implementation of the + -- security package. + -------------------------------------------------------------------------- + -- + -- Get User + -- + FUNCTION get_user RETURN VARCHAR2; + -- + -- get session data + -- + PROCEDURE get_session_data(p_client_id IN VARCHAR2 DEFAULT NULL); + -- + -- + -- Show_Logon_Form: Renders logon form + -- + PROCEDURE show_logon_form(p_embedded IN BOOLEAN DEFAULT FALSE + ,h_href IN VARCHAR2 DEFAULT NULL); + -- + -- + -- Process_Logon: Accepts submitted logon form and logs user on. If logon + -- fails then notifies user. + -- + PROCEDURE process_logon(p_username IN VARCHAR2 DEFAULT NULL + ,p_password IN VARCHAR2 DEFAULT NULL + ,h_href IN VARCHAR2 DEFAULT NULL + ,p_login_button IN VARCHAR2 DEFAULT NULL + ); + -- + -- Process_Logon: Overloaded version for client certificate + -- + PROCEDURE process_certificate_logon; + -- + -- + -- Show_No_Access: Displays message to inform user that they do not + -- have access to the application. Provides a link + -- to the logon form. + -- + PROCEDURE show_no_access; + -- + -- + -- Call_Logon_Form: Output HTML to call the logon form, which + -- may be in a separate window. + -- + PROCEDURE call_logon_form; + -- + -- + -- Logoff: Removes the current user's session, logging them off. Outputs + -- HTML message when complete. + -- + PROCEDURE logoff; + -- + -- Logout: Removes the current user's session, logging them off. Redirects to the + -- home page + -- + PROCEDURE logout; + -- + --- + -- Moved from CACO_UTILITIES 26-APR-2003 + --- + PROCEDURE change_cust_inte(p_inte_id IN intermediaries.inte_id%TYPE DEFAULT NULL + ,p_cust_id IN customers.cust_id%TYPE DEFAULT NULL + ,p_savebtn IN VARCHAR2 DEFAULT NULL + ,p_cancbtn IN VARCHAR2 DEFAULT NULL + ,p_message IN VARCHAR2 DEFAULT NULL); + /** + -- Procedure to allow user to change their password. + -- Call without parameters to display the startup screen, other parameters are used internally. + -- @param p_call_type Used internally to determine which screen to display + -- @param p_old_password Existing password for the user + -- @param p_password New password for the user + -- @param p_confirm New password for the user + -- @param p_button Value returned by a button press + -- + */ + PROCEDURE change_password(p_call_type IN VARCHAR2 DEFAULT NULL + ,p_old_password IN VARCHAR2 DEFAULT NULL + ,p_password IN VARCHAR2 DEFAULT NULL + ,p_confirm IN VARCHAR2 DEFAULT NULL + ,p_button IN VARCHAR2 DEFAULT NULL + ,p_embedded IN BOOLEAN DEFAULT FALSE); + /** + -- Procedure to remove expired sessions + -- No parameters required + */ + PROCEDURE remove_expired_sessions; + /** + -- Procedure to produce the register screen + */ + PROCEDURE online_user_registration ( p_register_title IN VARCHAR2 DEFAULT NULL + , p_register_first_name IN VARCHAR2 DEFAULT NULL + , p_register_surname IN VARCHAR2 DEFAULT NULL + , p_register_company IN VARCHAR2 DEFAULT NULL + , p_register_email IN VARCHAR2 DEFAULT NULL + , p_register_phone IN VARCHAR2 DEFAULT NULL + , p_register_submit IN VARCHAR2 DEFAULT NULL + ); + /** + -- Procedure to process a logon using an interface + */ + PROCEDURE process_interface_logon ( p_username IN VARCHAR2 + , p_password IN VARCHAR2 + , p_success OUT BOOLEAN + , p_message OUT VARCHAR2 ); + -- +END caco_security; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_confirmations.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_confirmations.bdy new file mode 100644 index 0000000..a33c733 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_confirmations.bdy @@ -0,0 +1,4269 @@ +CREATE OR REPLACE PACKAGE BODY efno_confirmations IS + -- + g_auto_gen BOOLEAN := FALSE; + -- +PROCEDURE output_nnpcv_tab (p_nnpcv_tab IN nnpcv_tab) IS +BEGIN +caco_debug.putline('------SP_CONF: output_nnpcv_tab 001------'); + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + caco_debug.putline('nnpcv_tab '||i||' nnpcv_id = '||p_nnpcv_tab(i).nnpcv_id); + caco_debug.putline('nnpcv_tab '||i||' coca_id = '||p_nnpcv_tab(i).coca_id); + caco_debug.putline('nnpcv_tab '||i||' conp_id = '||p_nnpcv_tab(i).conp_id); + caco_debug.putline('nnpcv_tab '||i||' coru_id = '||p_nnpcv_tab(i).coru_id); + caco_debug.putline('nnpcv_tab '||i||' value = '||p_nnpcv_tab(i).value); + caco_debug.putline('nnpcv_tab '||i||' nomi_id = '||p_nnpcv_tab(i).nomi_id); + caco_debug.putline('nnpcv_tab '||i||' nomi_received = '||p_nnpcv_tab(i).nomi_received); + caco_debug.putline('nnpcv_tab '||i||' defaulted = '||p_nnpcv_tab(i).defaulted); + caco_debug.putline('nnpcv_tab '||i||' missing = '||p_nnpcv_tab(i).missing); + caco_debug.putline('nnpcv_tab '||i||' gas_day = '||p_nnpcv_tab(i).gas_day); + caco_debug.putline('nnpcv_tab '||i||' in_error = '||sys.diutil.bool_to_int(p_nnpcv_tab(i).in_error)); + END LOOP; +caco_debug.putline('------SP_CONF: output_nnpcv_tab 999------'); +END output_nnpcv_tab; +-- +PROCEDURE output_nnpcv_rec (p_nnpcv_rec IN nnpcv_rec) IS +BEGIN +caco_debug.putline('------SP_CONF: output_nnpcv_rec 001------'); + caco_debug.putline('nnpcv_rec nnpcv_id = '||p_nnpcv_rec.nnpcv_id); + caco_debug.putline('nnpcv_tab coca_id = '||p_nnpcv_rec.coca_id); + caco_debug.putline('nnpcv_tab conp_id = '||p_nnpcv_rec.conp_id); + caco_debug.putline('nnpcv_tab coru_id = '||p_nnpcv_rec.coru_id); + caco_debug.putline('nnpcv_tab value = '||p_nnpcv_rec.value); + caco_debug.putline('nnpcv_tab nomi_id = '||p_nnpcv_rec.nomi_id); + caco_debug.putline('nnpcv_tab nomi_received = '||p_nnpcv_rec.nomi_received); + caco_debug.putline('nnpcv_tab defaulted = '||p_nnpcv_rec.defaulted); + caco_debug.putline('nnpcv_tab missing = '||p_nnpcv_rec.missing); + caco_debug.putline('nnpcv_tab gas_day = '||p_nnpcv_rec.gas_day); + caco_debug.putline('nnpcv_tab in_error = '||sys.diutil.bool_to_int(p_nnpcv_rec.in_error)); +caco_debug.putline('------SP_CONF: output_nnpcv_rec 999------'); +END output_nnpcv_rec; +/** +-- PROCEDURE upd_conf_timestamp +-- Autonomous Transaction +-- Updates the confirmation timestamp with the given date +-- Used by the timestamping functions when a RETRY has been required +-- +-- %param p_conf_id Unique Identifier of the confirmation to be updated +-- %param p_timestamp Successful timestamp information +-- +*/ +PROCEDURE upd_conf_timestamp( p_conf_id IN confirmations.conf_id%TYPE + , p_timestamp IN DATE + ) +IS + PRAGMA AUTONOMOUS_TRANSACTION; +BEGIN + -- + --caco_debug.debug_on('Enter upd_conf_timestamp'); + -- Check we have permission to be using this module. + IF NOT g_auto_gen THEN + -- + IF NOT caco_security.security_check('efnow095$') THEN + RETURN; + END IF; + -- + END IF; + -- + BEGIN + -- + UPDATE confirmations + SET confirmation_sent = p_timestamp + , approved = 'Y' + WHERE conf_id = p_conf_id; + -- + COMMIT; + -- + --caco_debug.debug_on('Exit upd_conf_timestamp'); + -- + EXCEPTION + WHEN others THEN + -- Need to log an error and email system support... + NULL; + END; + -- +END upd_conf_timestamp; +-- +-- +FUNCTION get_interrupted_value (p_conp_id IN NUMBER, + p_coca_id IN NUMBER, + p_gas_day IN DATE) + RETURN NUMBER +IS + -- + CURSOR c_int IS + SELECT icv.interrupted_value + FROM int_conp_coca_vals icv + WHERE icv.coca_id = p_coca_id + AND icv.conp_id = p_conp_id + AND icv.send_to_customer = 'Y' + AND EXISTS ( SELECT 'x' + FROM interruptions int + WHERE int.int_id = icv.int_id + AND p_gas_day >= int.gas_day_start + AND (p_gas_day <= int.gas_day_end OR int.gas_day_end IS NULL)); + -- + l_interrupted_value NUMBER := NULL; + -- +BEGIN + -- + OPEN c_int; + FETCH c_int + INTO l_interrupted_value; + IF c_int%NOTFOUND THEN + l_interrupted_value := NULL; + END IF; + CLOSE c_int; + -- + RETURN l_interrupted_value; + -- +END get_interrupted_value; +-- +-- +FUNCTION ins_lookback_cnpcv_vals( p_conf_id IN confirmations.conf_id%TYPE + , p_nnpcv_tab IN OUT nnpcv_tab + , p_nomi_id IN nominations.nomi_id%TYPE + , p_nomi_date IN nominations.created_on%TYPE + , p_return_error OUT VARCHAR2 + ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + -- Cursor to get the value for the given previous nomination and CONP COCA pair from the nnpcv_tab + CURSOR c_nnpcv( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT nnpcv1.nnpcv_id nnpcv_id + , nnpcv1.value value + , nnpcv1.gas_day gas_day + , cnp2.nepo_id nepo_id + FROM nom_net_point_cat_vals nnpcv1 + ,cont_network_points cnp1 + ,cont_network_points cnp2 + ,contract_categories cc1 + ,contract_categories cc2 + WHERE nnpcv1.nomi_id = p_nomi_id + AND cc1.cate_id = cc2.cate_id + AND cc1.coca_id = cp_coca_id + AND cc2.coca_id = nnpcv1.coca_id + AND cnp1.nepo_id = cnp2.nepo_id + AND cnp1.conp_id = cp_conp_id + AND cnp2.conp_id = nnpcv1.conp_id + AND nnpcv1.gas_day = ( SELECT MAX( nnpcv2.gas_day ) + FROM nom_net_point_cat_vals nnpcv2 + WHERE nnpcv2.nomi_id = p_nomi_id ); + -- + l_nnpcv_id nom_net_point_cat_vals.nnpcv_id%TYPE; + l_value nom_net_point_cat_vals.value%TYPE; + l_int_value nom_net_point_cat_vals.value%TYPE; + l_lb_value nom_net_point_cat_vals.value%TYPE; + l_gas_day nom_net_point_cat_vals.gas_day%TYPE; + l_success BOOLEAN := TRUE; + l_nepo_id network_points.nepo_id%TYPE; + l_interrupted conf_net_point_cat_vals.interrupted%TYPE; + -- +BEGIN +caco_debug.putline('SP_CONF: ins_lookback_cnpcv_vals 001'); + -- + caco_debug.putline('Enter ins_lookback_cnpcv_vals with '||NVL(p_nnpcv_tab.COUNT,0)||' elements'); + -- + SAVEPOINT before_ins_cnpcv; + -- + -- Loop through the nnpcv tab and update CNPCV with the nom values + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + -- + <> + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + -- check if there is an interruption active + l_int_value := get_interrupted_value( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , p_nnpcv_tab(i).gas_day ); +IF l_int_value IS NOT NULL THEN + caco_debug.putline('l_int_value: '||l_int_value); +END IF; + -- + -- Get the value for the specific conp and coca for the given nomination + -- for the latest gas day in the valid nomination + -- + OPEN c_nnpcv( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_nnpcv INTO l_nnpcv_id, l_lb_value, l_gas_day, l_nepo_id; + IF c_nnpcv%NOTFOUND THEN + l_success := FALSE; + END IF; + CLOSE c_nnpcv; + -- Compare the lookback value and the interrupted value and go with the lowest value + IF l_int_value IS NULL THEN + l_interrupted := 'N'; + ELSE + l_interrupted := 'Y'; + END IF; + -- + l_value := l_lb_value; + -- + IF l_success THEN + -- + caco_debug.putline('Inserting values'); + -- +--output_nnpcv_rec(p_nnpcv_tab(i)); + BEGIN + INSERT INTO conf_net_point_cat_vals + ( nnpcv_id + , conf_id + , nomi_id + , value + , gas_day + , conp_id + , coca_id + , valid + , last_nomi_id + , last_nom_received + , last_gas_day + , defaulted + , interrupted ) + VALUES + ( l_nnpcv_id + , p_conf_id + , p_nomi_id + , l_value + , p_nnpcv_tab(i).gas_day + , p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'Y' + , p_nomi_id + , p_nomi_date + , l_gas_day + , 'N' + , l_interrupted ); + -- + EXCEPTION + WHEN dup_val_on_index THEN + NULL; + WHEN others THEN + ROLLBACK TO SAVEPOINT before_ins_cnpcv; + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2311); + -- Unable to force confirm invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.ins_lookback_cnpcv_vals:' + ||' Failed to insert lookback confirmation value: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id||' on ' + ||TO_CHAR(p_nnpcv_tab(i).gas_day,'DD-MON-YYYY') + ||chr(10)||'SQLERRM : '||sqlerrm(sqlcode) ); + -- + -- Write an error and carry on + -- + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => ' Failed to insert lookback confirmation value: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id||' on ' + ||TO_CHAR(p_nnpcv_tab(i).gas_day,'DD-MON-YYYY') + ||chr(10)||'SQLERRM : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.ins_lookback_cnpcv_vals'); + -- + EXIT cnpcv_insert_loop; + END; + -- + END IF; + -- + END LOOP cnpcv_insert_loop; + -- + COMMIT; + -- + END IF; + -- + caco_debug.putline('SP_CONF: ins_lookback_cnpcv_vals 999'); + RETURN l_success; + -- +END ins_lookback_cnpcv_vals; +-- +-- +FUNCTION default_lookback( p_conf_id IN confirmations.conf_id%TYPE + , p_nomi_id IN nominations.nomi_id%TYPE + , p_contract_id IN contracts.cont_id%TYPE + , p_lookback_date IN DATE + , p_lookback_action IN contracts.lookback_action%TYPE + , p_nnpcv_tab IN nnpcv_tab + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Require a cursor to list all "tip" nominations for the contract + CURSOR c_nominations(cp_lookback_action IN VARCHAR2) IS + SELECT nomi.nomi_id + , nomi.created_on + , nomi.status + , cont1.cust_id + FROM nominations nomi + ,contracts cont1 + WHERE nomi.cont_id = cont1.cont_id + AND cont1.cont_id IN (SELECT cont2.cont_id + FROM contracts cont2 + CONNECT BY PRIOR cont2.prev_cont_id = cont2.cont_id + START WITH cont2.cont_id = p_contract_id) + AND ( nomi.nomi_id < p_nomi_id + OR p_nomi_id IS NULL ) + AND EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + GROUP BY nnpcv.gas_day + HAVING MIN(nnpcv.gas_day) <= (SELECT gas_day FROM confirmations WHERE conf_id = p_conf_id) + AND MIN(nnpcv.gas_day) >= p_lookback_date ) +-- AND ( ( nomi.status = 'A' -- 'A' will be the TIP each day + AND ( cp_lookback_action = 'T' + AND ( nomi_id IN ((SELECT nomi_id + FROM ( SELECT DISTINCT n.nomi_id, n.gas_day, no.created_on, RANK() OVER (partition by gas_day ORDER BY gas_day, no.created_on DESC) nom_rank + FROM nom_net_point_cat_vals n + ,nominations no + ,contracts c + WHERE n.nomi_id = no.nomi_id + AND no.cont_id = c.cont_id + AND no.status = 'A' -- SP 19/10/2009 moved here to improve performance + AND c.cont_id IN (SELECT c2.cont_id + FROM contracts c2 + CONNECT BY PRIOR c2.prev_cont_id = c2.cont_id + START WITH c2.cont_id = p_contract_id) + ) + WHERE nom_rank = 1)) + ) + -- ) + OR ( cp_lookback_action = 'A' + ) + ) + ORDER BY ( SELECT MAX(nnpcv.gas_day) + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + ) DESC, nomi.created_on DESC; +/* + SELECT nomi.nomi_id + , nomi.created_on + , nomi.status + , cont1.cust_id + FROM nominations nomi + ,contracts cont1 + ,contracts cont2 + WHERE nomi.cont_id = cont1.cont_id + AND cont1.cust_id = cont2.cust_id + AND cont2.cont_id = p_contract_id + AND ( nomi.nomi_id < p_nomi_id + OR p_nomi_id IS NULL ) + AND EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + GROUP BY nnpcv.gas_day + HAVING MIN(nnpcv.gas_day) <= (SELECT gas_day FROM confirmations WHERE conf_id = p_conf_id) + AND MIN(nnpcv.gas_day) >= p_lookback_date ) +-- AND ( ( nomi.status = 'A' -- 'A' will be the TIP each day + AND ( cp_lookback_action = 'T' + AND ( nomi_id IN ((SELECT nomi_id + FROM ( SELECT DISTINCT n.nomi_id, n.gas_day, no.created_on, RANK() OVER (partition by gas_day ORDER BY gas_day, no.created_on DESC) nom_rank + FROM nom_net_point_cat_vals n + ,nominations no + ,contracts c + ,contracts c2 + WHERE n.nomi_id = no.nomi_id + AND no.cont_id = c.cont_id + AND no.status = 'A' -- SP 19/10/2009 moved here to improve performance + AND c.cust_id = c2.cust_id + AND c2.cont_id = p_contract_id + ) + WHERE nom_rank = 1)) + ) + -- ) + OR ( cp_lookback_action = 'A' + ) + ) + ORDER BY ( SELECT MAX(nnpcv.gas_day) + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + ) DESC, nomi.created_on DESC; +*/ + -- + l_nnpcv_tab nnpcv_tab; + -- + l_success BOOLEAN := FALSE; + -- + BEGIN + -- + caco_debug.putline('SP_CONF: default_lookback 001'); + caco_debug.putline('p_conf_id: '||p_conf_id|| + ' p_nomi_id: '||p_nomi_id|| + ' p_contract_id: '||p_contract_id|| + ' p_lookback_date: '||p_lookback_date|| + ' p_lookback_action: '||p_lookback_action|| + ' p_return_error: '||p_return_error); + -- + l_nnpcv_tab := p_nnpcv_tab; + -- + <> + FOR r IN c_nominations(NVL(p_lookback_action, 'A')) LOOP + -- + l_success := TRUE; + caco_debug.putline('we have a nom to look back at: nomi_id = '||r.nomi_id); + -- + -- + caco_debug.putline('Update nominated values'); + -- + l_success := ins_lookback_cnpcv_vals( p_conf_id => p_conf_id + , p_nnpcv_tab => l_nnpcv_tab + , p_nomi_id => r.nomi_id + , p_nomi_date => r.created_on + , p_return_error => p_return_error + ); + -- + -- Exit the loop - we got values for the cnpcv_id's.. + -- so there is no point looking back any further. + -- + EXIT nom_lookback_loop; + -- + END LOOP nom_lookback_loop; + -- + caco_debug.putline('SP_CONF: default_lookback 999'); + RETURN l_success; + -- + EXCEPTION + WHEN others THEN + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => ' Failed in default_lookback: ' + ||' Error : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.default_lookback' ); + -- + caco_debug.putline('SP_CONF: error in default_lookback: '||sqlerrm); + l_success := FALSE; + -- An unexpected error has occurred while creating confirmation. Please contact support + p_return_error := caco_utilities.get_module_text(2212); +END default_lookback; +-- +-- +/** +-- FUNCTION remove_surplus_cnpcv RETURN BOOLEAN +-- Autonomous Transaction +-- Returns TRUE if successful +-- If the contract has been amended between nomination and confirmation this +-- Ensures that the confirmation contains only network points and categories +-- that are valid for the contract at point of confirmation +-- +-- %param p_conf_id Unique Identifier of the confirmation to be updated +-- %param p_cont_id Unique identifier of the contract to which this confirmation relates +-- %param p_return_error OUT: Error message in the case of an unexpected error +-- +*/ +FUNCTION remove_surplus_cnpcv( p_conf_id IN confirmations.conf_id%TYPE + , p_cont_id IN contracts.cont_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + l_success BOOLEAN := TRUE; + l_tmpstr VARCHAR2(1000); + -- +BEGIN + -- + p_return_error := NULL; + -- + SAVEPOINT before_delete; + -- Anonymous block to handle exceptions + BEGIN + -- + -- Remove invalid network points + -- + DELETE conf_net_point_cat_vals + WHERE conf_id = p_conf_id + AND conp_id NOT IN ( SELECT conp.conp_id + FROM cont_network_points conp + WHERE conp.cont_id = p_cont_id ); + -- + -- Remove invalid categories + -- + DELETE conf_net_point_cat_vals + WHERE conf_id = p_conf_id + AND coca_id NOT IN ( SELECT coca.coca_id + FROM contract_categories coca + WHERE coca.cont_id = p_cont_id ); + -- + COMMIT; + -- + EXCEPTION + WHEN others THEN + ROLLBACK TO SAVEPOINT before_delete; + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => ' Failed to delete surplus cnppv: ' + ||' CONF_ID : '||p_conf_id||chr(10) + ||' CONT_ID : '||p_cont_id||chr(10) + ||' Error : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.remove_surplus_cnpcv' ); + -- + l_success := FALSE; + -- An unexpected error has occurred while creating confirmation. Please contact support + p_return_error := caco_utilities.get_module_text(2212); + -- + END; + -- + RETURN l_success; + -- +END remove_surplus_cnpcv; +-- +-- Function to calculate the exception value based on the percentage split and virtual network point values +-- +FUNCTION get_cnppv_emo_exp_value (p_conp_id IN NUMBER + , p_coca_id IN NUMBER + , p_exception IN VARCHAR2 + , p_cont_id IN contracts.cont_id%TYPE + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) + RETURN NUMBER +IS + -- + -- Cursor to get the Percentage Split value of the virtual network point from cnppv table + CURSOR c_vnp_per_split IS + SELECT cnppv.value value + FROM parameters pars + , cont_network_points conp + , contract_parameters copa + , network_points nepo + , cont_net_point_param_vals cnppv + WHERE copa.pars_id = pars.pars_id + AND copa.copa_id = cnppv.copa_id + AND conp.conp_id = cnppv.conp_id + AND conp.cont_id = p_cont_id + AND conp.nepo_id = nepo.nepo_id + AND nepo.nepo_type = 'V' + AND pars.name IN (g_perc_split_en, g_perc_split_hu); + -- + -- Cursor to get the Percentage Split values from cnppv table + CURSOR c_cnppv_per_split(cp_conp_id IN NUMBER) IS + SELECT cnppv.value value + FROM parameters pars + , cont_network_points conp + , contract_parameters copa + , cont_net_point_param_vals cnppv + WHERE copa.pars_id = pars.pars_id + AND copa.copa_id = cnppv.copa_id + AND conp.conp_id = cnppv.conp_id + AND conp.conp_id = cp_conp_id + AND conp.cont_id = p_cont_id + AND pars.name IN (g_perc_split_en, g_perc_split_hu); + -- + -- Cursor to get the exception value for the virtual network point of a given + -- contract category + CURSOR c_cnppv_emo_exp(cp_coca_id IN NUMBER, + cp_exception IN VARCHAR2) IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + , cont_network_points conp + , network_points nepo + WHERE cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(UPPER(pars.code),-3) = cp_exception + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id + AND conp.cont_id = p_cont_id + AND cnppv.conp_id = conp.conp_id + AND nepo.nepo_id = conp.nepo_id + AND nepo.nepo_type = 'V'; + -- + l_perc_split cont_net_point_param_vals.value%TYPE; + l_emo_exp_value cont_net_point_param_vals.value%TYPE; + l_tot_perc_split cont_net_point_param_vals.value%TYPE; + l_cont_value cont_net_point_param_vals.value%TYPE := 0; + l_success BOOLEAN := TRUE; + -- +BEGIN + caco_debug.putline('SP_CONF: get_cnppv_emo_exp_value 001'); + -- get the Percentage Split value of the virtual network point from cnppv table + OPEN c_vnp_per_split; + FETCH c_vnp_per_split INTO l_tot_perc_split; + CLOSE c_vnp_per_split; + -- + -- get the percentage split value of the network point + OPEN c_cnppv_per_split(p_conp_id); + FETCH c_cnppv_per_split INTO l_perc_split; + IF c_cnppv_per_split%NOTFOUND THEN + CLOSE c_cnppv_per_split; + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2337); + -- Unable to find contracted value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.create_missing_cnpcv: Unable to locate Percentage Split parameter for: ' + ||' CONP_ID : '||p_conp_id); + -- + END IF; + CLOSE c_cnppv_per_split; + -- get the virtual network point validation exception value + IF l_success THEN + OPEN c_cnppv_emo_exp(p_coca_id, + p_exception); + FETCH c_cnppv_emo_exp INTO l_emo_exp_value; + IF c_cnppv_emo_exp%NOTFOUND THEN + CLOSE c_cnppv_emo_exp; + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2337); + -- Unable to find contracted value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.create_missing_cnpcv: Unable to locate VNP CTR value for: ' + ||' COCA_ID : '||p_coca_id); + -- + END IF; + CLOSE c_cnppv_emo_exp; + -- calculate the exception value based on the percentage split and virtual network point values + l_cont_value := ROUND((l_perc_split/l_tot_perc_split)*l_emo_exp_value); + -- + END IF; + p_success := l_success; + caco_debug.putline('SP_CONF: get_cnppv_emo_exp_value 999'); + RETURN l_cont_value; + -- +END get_cnppv_emo_exp_value; +-- +-- +-- +/** +-- FUNCTION create_missing_cnpcv RETURN BOOLEAN +-- Autonomous Transaction +-- Returns TRUE if successful +-- If the contract has been amended between nomination and confirmation this +-- Ensures that the confirmation contains any additional network points and categories +-- that have been added +-- +-- %param p_conf_id Unique Identifier of the confirmation to be updated +-- %param p_nomi_id Unique identifier of the nomination to which this confirmation relates +-- %param p_nnpcv_tab +-- %param p_return_error OUT: Error message in the case of an unexpected error +-- +*/ +PROCEDURE create_missing_cnpcv( p_conf_id IN confirmations.conf_id%TYPE + , p_nomi_id IN nominations.nomi_id%TYPE + , p_nnpcv_tab IN OUT nnpcv_tab + , p_exception IN contracts.validation_exception%TYPE + , p_validation_action IN contracts.validation_action%TYPE + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 + , p_defaulted IN VARCHAR2 DEFAULT 'Y' + , p_cont_id IN contracts.cont_id%TYPE + , p_lookback_date IN DATE + , p_lookback_action IN contracts.lookback_action%TYPE) +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + -- Cursor to get the minimum value for a given CONP and COCA pair + CURSOR c_cnppv_min( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(UPPER(pars.code),-3) = 'MIN' -- Need the MIN parameter + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id; + -- + -- Cursor to get the contracted value for a given CONP and COCA pair + CURSOR c_cnppv_ctr( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(UPPER(pars.code),-3) = 'CTR' -- Need the CTR parameter + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id; + -- + -- Cursor to get the maximum value for a given CONP and COCA pair + CURSOR c_cnppv_max( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(UPPER(pars.code),-3) = 'MAX' -- Need the MAX parameter + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id; + -- + l_value conf_net_point_cat_vals.value%TYPE; + l_int_value conf_net_point_cat_vals.value%TYPE; + l_cont_value conf_net_point_cat_vals.value%TYPE; + l_success BOOLEAN := TRUE; + l_interrupted conf_net_point_cat_vals.interrupted%TYPE; + -- +BEGIN +caco_debug.putline('SP_CONF: create_missing_cnpcv 001'); + SAVEPOINT before_create_missing; + p_success := TRUE; + p_return_error := NULL; + -- +--output_nnpcv_tab(p_nnpcv_tab); + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + IF p_validation_action = 'B' THEN + + l_success := default_lookback( p_conf_id + , p_nomi_id + , p_cont_id + , p_lookback_date + , p_lookback_action + , p_nnpcv_tab + , p_return_error ); + END IF; +/* + if sub OR lookback failed + ...existing code, remove +10 + end if; +*/ + IF NOT l_success OR p_validation_action = 'T' THEN + caco_debug.putline('SP_CONF: create_missing_cnpcv 555: using contract vals'); + <> + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + IF NVL(p_nnpcv_tab(i).missing, 'N') = 'Y' THEN + -- + -- Get the interrupted value if there is one + l_int_value := get_interrupted_value( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , p_nnpcv_tab(i).gas_day ); + -- + -- Get the contract value depending on the validation exception + IF p_exception = 'CO' THEN + -- + IF efno_contracts.emo_contract(p_cont_id) = 'Y' THEN + -- + -- calculate the exception value based on the percentage split and + -- virtual network point values + l_cont_value := get_cnppv_emo_exp_value(p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'CTR' + , p_cont_id + , p_success + , p_return_error); + IF NOT p_success THEN + EXIT cnppv_loop; + END IF; + ELSE + OPEN c_cnppv_ctr( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_cnppv_ctr INTO l_cont_value; + IF c_cnppv_ctr%NOTFOUND THEN + CLOSE c_cnppv_ctr; + -- + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2337); + -- Unable to find contracted value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.create_missing_cnpcv: Unable to locate Contract parameter CTR for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + -- + EXIT cnppv_loop; + END IF; + CLOSE c_cnppv_ctr; + END IF; + -- + ELSIF p_exception = 'MI' THEN -- Minimum + -- + IF efno_contracts.emo_contract(p_cont_id) = 'Y' THEN + -- + -- calculate the exception value based on the percentage split and + -- virtual network point values + l_cont_value := get_cnppv_emo_exp_value(p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'MIN' + , p_cont_id + , p_success + , p_return_error); + IF NOT p_success THEN + EXIT cnppv_loop; + END IF; + ELSE + OPEN c_cnppv_min( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_cnppv_min INTO l_cont_value; + IF c_cnppv_min%NOTFOUND THEN + CLOSE c_cnppv_min; + -- + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2310); + -- Unable to find minimum value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.create_missing_cnpcv: Unable to locate Contract parameter MIN for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + -- + EXIT cnppv_loop; + END IF; + CLOSE c_cnppv_min; + END IF; + -- + ELSIF p_exception IN ('MA', 'EX') THEN -- Maximum + -- + IF efno_contracts.emo_contract(p_cont_id) = 'Y' THEN + -- + -- calculate the exception value based on the percentage split and + -- virtual network point values + l_cont_value := get_cnppv_emo_exp_value(p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'MAX' + , p_cont_id + , p_success + , p_return_error); + IF NOT p_success THEN + EXIT cnppv_loop; + END IF; + ELSE + OPEN c_cnppv_max( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_cnppv_max INTO l_cont_value; + IF c_cnppv_max%NOTFOUND THEN + CLOSE c_cnppv_max; + -- + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2310); + -- Unable to find minimum value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.create_missing_cnpcv: Unable to locate Contract parameter MAX for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + -- + EXIT cnppv_loop; + END IF; + CLOSE c_cnppv_max; + END IF; + -- +/* IF p_exception = 'EX' THEN +caco_debug.putline('SP_CONF: create_missing_cnpcv (adding + 10) 500'); + l_value := l_value + 10; + END IF;*/ + -- + END IF; + -- Compare the contract value and the interrupted value and go with the lowest value + IF l_int_value IS NULL THEN + l_value := l_cont_value; + l_interrupted := 'N'; + ELSE + IF l_int_value > l_cont_value THEN + l_value := l_cont_value; + ELSE + l_value := l_int_value; + END IF; + l_interrupted := 'Y'; + END IF; + -- +--output_nnpcv_rec(p_nnpcv_tab(i)); + BEGIN + INSERT INTO conf_net_point_cat_vals + ( conf_id + , nomi_id + , value + , gas_day + , conp_id + , coca_id + , valid + , defaulted + , interrupted + , last_gas_day ) + VALUES + ( p_conf_id + , p_nomi_id + , l_value + , p_nnpcv_tab(i).gas_day + , p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'Y' +-- , p_defaulted --05/03/08 SP replaced with 'Y' to repress nom date on confirmation + , 'Y' + , l_interrupted + , NULL ); + EXCEPTION + WHEN dup_val_on_index THEN + NULL; + WHEN others THEN + ROLLBACK TO SAVEPOINT before_create_missing; + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2311); + -- Unable to force confirm invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.create_missing_cnpcv:' + ||' Failed to insert default confirmation value: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id||' on ' + ||TO_CHAR(p_nnpcv_tab(i).gas_day,'DD-MON-YYYY') + ||chr(10)||'SQLERRM : '||sqlerrm(sqlcode) ); + -- + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => ' Failed to insert default confirmation value: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id||' on ' + ||TO_CHAR(p_nnpcv_tab(i).gas_day,'DD-MON-YYYY') + ||chr(10)||'SQLERRM : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.create_missing_cnpcv'); + -- + EXIT cnppv_loop; + END; + -- + END IF; + -- + END LOOP cnppv_loop; + END IF; + -- + -- + IF p_success THEN + COMMIT; + END IF; + -- + END IF; + -- +caco_debug.putline('SP_CONF: create_missing_cnpcv 999'); +END create_missing_cnpcv; +-- +-- +FUNCTION add_missing_cnpcv( p_conf_id IN confirmations.conf_id%TYPE + , p_nomi_id IN nominations.nomi_id%TYPE + , p_contract_row IN contracts%ROWTYPE + , p_gas_day IN DATE + , p_return_error OUT VARCHAR2 + , p_defaulted IN VARCHAR2 DEFAULT 'Y' ) + RETURN BOOLEAN +IS + l_success BOOLEAN := TRUE; + -- + l_cnpcv_tab nnpcv_tab; + l_counter NUMBER := 0; + l_lookback_date DATE; + -- + l_only_short_day VARCHAR2(1) := 'N'; + l_cont_long_day VARCHAR2(1) := 'N'; + -- +BEGIN +caco_debug.putline('SP_CONF: add_missing_cnpcv 001'); + p_return_error := NULL; + l_lookback_date := p_gas_day - p_contract_row.validation_window; + -- Check to see if the gas day we are looking at is a long or short day + IF cout_dates.hours_in_gas_day(p_gas_day) = 25 THEN + l_cont_long_day := 'Y'; + END IF; + IF cout_dates.hours_in_gas_day(p_gas_day) = 23 THEN + l_only_short_day := 'Y'; + END IF; + -- + -- Check if there are missing Network Points + caco_debug.putline('Enter add missing'||p_contract_row.cont_id||':'||p_conf_id); + FOR r IN ( SELECT DISTINCT conp.conp_id conp_id + FROM cont_network_points conp + WHERE conp.cont_id = p_contract_row.cont_id + AND NOT EXISTS ( SELECT 'x' + FROM conf_net_point_cat_vals cnpcv + WHERE cnpcv.conf_id = p_conf_id + AND cnpcv.conp_id = conp.conp_id ) + ) + LOOP + caco_debug.putline('In nepo: '||r.conp_id); + -- Add a missing entry for each network point for all categories + FOR r2 IN ( SELECT coca.coca_id coca_id + FROM contract_categories coca + ,categories cate + WHERE coca.cont_id = p_contract_row.cont_id + AND cate.cate_id = coca.cate_id + AND ((cate.display_cond = 'LO' AND l_cont_long_day = 'Y') OR + (cate.display_cond = 'SH' AND l_only_short_day = 'N') OR + cate.display_cond = 'AL')) + LOOP + l_counter := l_counter + 1; + -- + l_cnpcv_tab(l_counter).conp_id := r.conp_id; + l_cnpcv_tab(l_counter).coca_id := r2.coca_id; + l_cnpcv_tab(l_counter).gas_day := p_gas_day; + l_cnpcv_tab(l_counter).missing := 'Y'; + -- + END LOOP; + -- + END LOOP; + -- + IF l_counter > 0 THEN + -- create the missing entries + caco_debug.putline('SP_CONF: add_missing_cnpcv missing nepo 100'); + create_missing_cnpcv( p_conf_id => p_conf_id + , p_nomi_id => p_nomi_id + , p_nnpcv_tab => l_cnpcv_tab + , p_exception => p_contract_row.validation_exception + , p_validation_action => p_contract_row.validation_action + , p_success => l_success + , p_return_error => p_return_error + , p_defaulted => p_defaulted + , p_cont_id => p_contract_row.cont_id + , p_lookback_date => l_lookback_date + , p_lookback_action => p_contract_row.lookback_action ); + -- + END IF; + -- + IF l_success THEN + -- + l_counter := 0; + l_cnpcv_tab.DELETE; + -- + -- Now check for missing Categories + FOR r IN ( SELECT DISTINCT coca.coca_id coca_id + FROM contract_categories coca + ,categories cate + WHERE coca.cont_id = p_contract_row.cont_id + AND cate.cate_id = coca.cate_id + AND ((cate.display_cond = 'LO' AND l_cont_long_day = 'Y') OR + (cate.display_cond = 'SH' AND l_only_short_day = 'N') OR + cate.display_cond = 'AL') + AND NOT EXISTS ( SELECT 'x' + FROM conf_net_point_cat_vals cnpcv + WHERE cnpcv.conf_id = p_conf_id + AND cnpcv.coca_id = coca.coca_id ) + ) + LOOP + caco_debug.putline('In coca: '||r.coca_id); + -- Add a missing entry for each category for all network point + FOR r2 IN ( SELECT conp.conp_id conp_id + FROM cont_network_points conp + WHERE conp.cont_id = p_contract_row.cont_id ) + LOOP + l_counter := l_counter + 1; + -- + l_cnpcv_tab(l_counter).conp_id := r2.conp_id; + l_cnpcv_tab(l_counter).coca_id := r.coca_id; + l_cnpcv_tab(l_counter).gas_day := p_gas_day; + l_cnpcv_tab(l_counter).missing := 'Y'; + -- + END LOOP; + -- + END LOOP; + -- + IF l_counter > 0 THEN + -- create the missing entries + caco_debug.putline('SP_CONF: add_missing_cnpcv missing cate 200'); + create_missing_cnpcv( p_conf_id => p_conf_id + , p_nomi_id => p_nomi_id + , p_nnpcv_tab => l_cnpcv_tab + , p_exception => p_contract_row.validation_exception + , p_validation_action => p_contract_row.validation_action + , p_success => l_success + , p_return_error => p_return_error + , p_defaulted => p_defaulted + , p_cont_id => p_contract_row.cont_id + , p_lookback_date => l_lookback_date + , p_lookback_action => p_contract_row.lookback_action ); + -- + END IF; + -- + END IF; + -- + caco_debug.putline('SP_CONF: add_missing_cnpcv 999'); + RETURN l_success; + -- +END add_missing_cnpcv; +-- +FUNCTION replace_cnpcv( p_conf_id IN confirmations.conf_id%TYPE + , p_nnpcv_tab IN nnpcv_tab + , p_exception IN contracts.validation_exception%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- Cursor to select the Contract Category Maximum + CURSOR c_contract_val( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER + , cp_type IN VARCHAR2 ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + , categories cate + , contracts cont + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND cont.cont_id = coca.cont_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(UPPER(pars.code),-3) = NVL(DECODE(cont.validation_exception, 'CO','CTR','MI','MIN','MA','MAX'),'MAX') + AND pars.cate_id = cate.cate_id + AND coca.cate_id = cate.cate_id + AND coca.coca_id = cp_coca_id; + -- + -- Cursor to get the correct row from CNPCV table + CURSOR c_cnpcv( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER + , cp_gas_day IN DATE ) + IS + SELECT cnpcv.* + FROM conf_net_point_cat_vals cnpcv + WHERE conf_id = p_conf_id + AND conp_id = cp_conp_id + AND coca_id = cp_coca_id + AND gas_day = cp_gas_day + FOR UPDATE; + -- + l_cnpcv_row c_cnpcv%ROWTYPE; + l_contract_value NUMBER := 0; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + caco_debug.putline('SP_CONF: replace_cnpcv 001'); + -- + SAVEPOINT before_replace; + -- + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + -- + <> + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + -- Reset temp variables + l_cnpcv_row := NULL; + l_contract_value := 0; + -- + IF p_nnpcv_tab(i).in_error THEN + -- + caco_debug.putline('REPLACE(conp|coca) '||p_exception||': '||p_nnpcv_tab(i).conp_id||':'||p_nnpcv_tab(i).coca_id||':-'||sys.diutil.bool_to_int(p_nnpcv_tab(i).in_error)); + -- + OPEN c_contract_val( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , p_exception + ); + FETCH c_contract_val + INTO l_contract_value; + IF c_contract_val%NOTFOUND THEN + -- + CLOSE c_contract_val; + -- bit of a problem - contract is messaed up somewhere... + -- don't know what to do here - no guidance. + ROLLBACK TO SAVEPOINT before_replace; + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2313); + -- Unable to locate contract parameter maximum. Please contact support + caco_debug.putline('efno_confirmations.replace_cnpcv: Unable to locate Contract parameter '||p_exception||' for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + EXIT replace_loop; + -- + ELSE + CLOSE c_contract_val; + END IF; + -- + OPEN c_cnpcv( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id --con_val.coca_id --p_nnpcv_tab(i).coca_id + , p_nnpcv_tab(i).gas_day ); + FETCH c_cnpcv + INTO l_cnpcv_row; + IF c_cnpcv%FOUND THEN + -- + caco_debug.putline('DEBUG1'); + UPDATE conf_net_point_cat_vals cnpcv + SET cnpcv.value = l_contract_value + ,cnpcv.defaulted = 'Y' + ,cnpcv.last_nomi_id = NULL + ,cnpcv.last_nom_received = NULL + WHERE CURRENT OF c_cnpcv; + -- + caco_debug.putline('Updated conf_id: '||l_cnpcv_row.conf_id||' conp_id: '||l_cnpcv_row.conp_id||' coca_id: '||l_cnpcv_row.coca_id); + -- + -- Now update the others that are for the same network point + -- + caco_debug.putline('DEBUG2'); + UPDATE conf_net_point_cat_vals cnpcvz + SET ( cnpcvz.value + , cnpcvz.defaulted + , cnpcvz.last_nomi_id + , cnpcvz.last_nom_received + ) = + ( SELECT cnppv.value + , 'Y' + , NULL + , NULL + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + , categories cate + , contracts cont + WHERE cnppv.conp_id = p_nnpcv_tab(i).conp_id + AND cnppv.copa_id = copa.copa_id + AND cont.cont_id = coca.cont_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(UPPER(pars.code),-3) = NVL(DECODE(cont.validation_exception, 'CO','CTR','MI','MIN','MA','MAX'),'MAX') + AND pars.cate_id = cate.cate_id + AND coca.cate_id = cate.cate_id + AND coca.coca_id = cnpcvz.coca_id + ) + WHERE cnpcvz.conf_id = p_conf_id + AND cnpcvz.conp_id = p_nnpcv_tab(i).conp_id + AND cnpcvz.coca_id <> p_nnpcv_tab(i).coca_id; + -- + CLOSE c_cnpcv; + ELSE + CLOSE c_cnpcv; + -- Problem - couldnt find the nnpcv_id in the CNPCV table + ROLLBACK TO SAVEPOINT before_replace; + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2314); + -- Unable to locate data. Please contact support + caco_debug.putline('efno_confirmations.replace_cnpcv: Unable to locate data in conf_net_point_cat_vals: ' + ||' CONF_ID : '||p_conf_id + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id + ||' GAS_DAY : '||TO_DATE(p_nnpcv_tab(i).gas_day,'DD-MON-YYYY') ); + EXIT replace_loop; + -- + END IF; + -- + END IF; + -- + END LOOP truncate_to_max_loop; + -- + IF l_success THEN + -- + COMMIT; + -- + END IF; + -- + END IF; + -- + caco_debug.putline('SP_CONF: replace_cnpcv 999'); + -- + RETURN l_success; + -- +EXCEPTION + WHEN OTHERS THEN + ROLLBACK TO SAVEPOINT before_replace; + caco_debug.putline('efno_confirmations.truncate_cnpcv_to_max: Unexpected Error ' + ||' CONF_ID : '||p_conf_id + ||CHR(10)||' Error Msg : '||sqlerrm(sqlcode) ); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Unexpected Error ' + ||' CONF_ID : '||p_conf_id + ||chr(10)||' Error Msg : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.truncate_cnpcv_to_max'); + -- + RETURN FALSE; + -- +END replace_cnpcv; +-- +FUNCTION default_cnpcv_values( p_gas_day IN DATE + , p_conf_id IN confirmations.conf_id%TYPE + , p_nnpcv_tab IN nnpcv_tab + , p_exception IN contracts.validation_exception%TYPE + , p_return_error OUT VARCHAR2 + , p_check IN BOOLEAN DEFAULT FALSE ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + -- Cursor to get the minimum value for a given CONP and COCA pair + CURSOR c_cnppv_min( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(pars.code,-3) = 'MIN' -- Need the MIN parameter + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id; + -- + -- Cursor to get the contracted value for a given CONP and COCA pair + CURSOR c_cnppv_ctr( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(pars.code,-3) = 'CTR' -- Need the CTR parameter + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id; + -- + -- Cursor to get the contracted value for a given CONP and COCA pair + CURSOR c_cnppv_max( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT cnppv.value + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , contract_categories coca + WHERE cnppv.conp_id = cp_conp_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND SUBSTR(pars.code,-3) = 'MAX' -- Need the CTR parameter + AND pars.cate_id = coca.cate_id + AND coca.coca_id = cp_coca_id; + -- + l_value cont_net_point_param_vals.value%TYPE; + l_int_value conf_net_point_cat_vals.value%TYPE; + l_cont_value conf_net_point_cat_vals.value%TYPE; + l_cont_id NUMBER; + -- + l_success BOOLEAN := TRUE; + l_interrupted conf_net_point_cat_vals.interrupted%TYPE; + -- +BEGIN + caco_debug.putline('SP_CONF: default_cnpcv_values 001'); + SAVEPOINT before_default; + -- quite simply, we should loop through the table of given nnpcv and update the values + -- to the Minimum or Contracted values for the contract + -- + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + -- + -- get the contract id + SELECT conp.cont_id INTO l_cont_id + FROM cont_network_points conp + WHERE conp.conp_id = p_nnpcv_tab(1).conp_id; + -- + caco_debug.putline('SP_CONF: default_cnpcv_values cont_id: '||l_cont_id); + -- + <> + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + -- + IF NOT p_check OR (p_check AND p_nnpcv_tab(i).in_error) THEN + -- + l_value := 0; + -- Get the interrupted value if there is one + l_int_value := get_interrupted_value( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id +-- , p_nnpcv_tab(i).gas_day ); + , p_gas_day ); + -- + -- + IF p_exception = 'CO' THEN + -- + IF efno_contracts.emo_contract(l_cont_id) = 'Y' THEN + -- + -- calculate the exception value based on the percentage split and + -- virtual network point values + l_cont_value := get_cnppv_emo_exp_value(p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'CTR' + , l_cont_id + , l_success + , p_return_error); + IF NOT l_success THEN + EXIT cnppv_loop; + END IF; + ELSE + OPEN c_cnppv_ctr( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_cnppv_ctr INTO l_cont_value; + IF c_cnppv_ctr%NOTFOUND THEN + CLOSE c_cnppv_ctr; + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2337); + -- Unable to find contracted value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.default_gtcv_values: Unable to locate Contract parameter CTR for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + -- + EXIT cnppv_loop; + END IF; + CLOSE c_cnppv_ctr; + END IF; + -- + ELSIF p_exception = 'MI' THEN -- must be MI (minimum) + -- + IF efno_contracts.emo_contract(l_cont_id) = 'Y' THEN + -- + -- calculate the exception value based on the percentage split and + -- virtual network point values + l_cont_value := get_cnppv_emo_exp_value(p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'MIN' + , l_cont_id + , l_success + , p_return_error); + IF NOT l_success THEN + EXIT cnppv_loop; + END IF; + ELSE + OPEN c_cnppv_min( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_cnppv_min INTO l_cont_value; + IF c_cnppv_min%NOTFOUND THEN + CLOSE c_cnppv_min; + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2310); + -- Unable to find minimum value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.default_gtcv_values: Unable to locate Contract parameter MIN for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + -- + EXIT cnppv_loop; + ELSE + CLOSE c_cnppv_min; + END IF; + END IF; + -- + ELSIF p_exception = 'MA' THEN -- must be MA (Maximum) + -- + IF efno_contracts.emo_contract(l_cont_id) = 'Y' THEN + -- + -- calculate the exception value based on the percentage split and + -- virtual network point values + l_cont_value := get_cnppv_emo_exp_value(p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id + , 'MIN' + , l_cont_id + , l_success + , p_return_error); + IF NOT l_success THEN + EXIT cnppv_loop; + END IF; + ELSE + OPEN c_cnppv_max( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_cnppv_max INTO l_cont_value; + IF c_cnppv_max%NOTFOUND THEN + CLOSE c_cnppv_max; + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2310); + -- Unable to find minimum value for invalid nomination. Please contact support + caco_debug.putline('efno_confirmations.default_gtcv_values: Unable to locate Contract parameter MAX for: ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ); + -- + EXIT cnppv_loop; + ELSE + CLOSE c_cnppv_max; + END IF; + END IF; + -- + END IF; + -- Compare the contract value and the interrupted value and go with the lowest value + caco_debug.putline('l_int_value: '||l_int_value); + caco_debug.putline('l_cont_value: '||l_cont_value); + IF l_int_value IS NULL THEN + l_value := l_cont_value; + l_interrupted := 'N'; + ELSE + IF l_int_value > l_cont_value THEN + l_value := l_cont_value; + ELSE + l_value := l_int_value; + END IF; + l_interrupted := 'Y'; + END IF; + caco_debug.putline('l_value: '||l_value); + caco_debug.putline('l_interrupted: '||l_interrupted); + -- + BEGIN + -- So now update the value in conf_ and set the defaulted flag + caco_debug.putline('DEBUG3'); + UPDATE conf_net_point_cat_vals + SET last_nom_received = NULL + , last_nomi_id = NULL + , last_gas_day = NULL + , last_coru_id = NULL + , defaulted = 'Y' + , valid = 'Y' + , value = l_value + , interrupted = l_interrupted + WHERE conf_id = p_conf_id + AND conp_id = p_nnpcv_tab(i).conp_id + AND coca_id = p_nnpcv_tab(i).coca_id; + -- + caco_debug.putline('Valu: '||l_value||' : '||p_nnpcv_tab(i).coca_id); +-- SP 3/3/08 - commented update back in and now setting last_gas_day to null to stop +-- nomination date appearing on confirmation + UPDATE conf_net_point_cat_vals + SET defaulted = 'Y', + last_gas_day = NULL + WHERE conf_id = p_conf_id + AND conp_id = p_nnpcv_tab(i).conp_id; + -- + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2257); + -- Error defaulting invalid nomination values. Please contact support + caco_debug.putline('efno_confirmations.default_gtcv_values: Update failed : ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id + ||chr(10)||' Error Msg : '||sqlerrm(sqlcode) ); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Update failed : ' + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id||' and ' + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id + ||chr(10)||' Error Msg : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.default_cnpcv_values'); + -- + END; + -- + END IF; + -- + END LOOP cnppv_loop; + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_default; + ELSE + COMMIT; + END IF; + -- + caco_debug.putline('SP_CONF: default_cnpcv_values 999'); + -- + RETURN l_success; + -- +END default_cnpcv_values; +-- +FUNCTION upd_cnpcv_vals_with_nom( p_conf_id IN confirmations.conf_id%TYPE + , p_nnpcv_tab IN OUT nnpcv_tab + , p_coru_id IN contract_rules.coru_id%TYPE + , p_nomi_id IN nominations.nomi_id%TYPE + , p_nomi_date IN nominations.created_on%TYPE + , p_return_error OUT VARCHAR2 + , p_nom_table IN efno_rules.nom_validation_table + ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + -- Cursor to get the value for the given previous nomination and CONP COCA pair from the nnpcv_tab + CURSOR c_nnpcv( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER ) + IS + SELECT nnpcv1.value value + , nnpcv1.gas_day gas_day + , cnp2.nepo_id nepo_id + FROM nom_net_point_cat_vals nnpcv1 + ,cont_network_points cnp1 + ,cont_network_points cnp2 + ,contract_categories cc1 + ,contract_categories cc2 + WHERE nnpcv1.nomi_id = p_nomi_id + AND cc1.cate_id = cc2.cate_id + AND cc1.coca_id = cp_coca_id + AND cc2.coca_id = nnpcv1.coca_id + AND cnp1.nepo_id = cnp2.nepo_id + AND cnp1.conp_id = cp_conp_id + AND cnp2.conp_id = nnpcv1.conp_id + AND nnpcv1.gas_day = ( SELECT MAX( nnpcv2.gas_day ) + FROM nom_net_point_cat_vals nnpcv2 + WHERE nnpcv2.nomi_id = p_nomi_id ); + -- + l_value nom_net_point_cat_vals.value%TYPE; + l_gas_day nom_net_point_cat_vals.gas_day%TYPE; + l_success BOOLEAN := TRUE; + l_nepo_id network_points.nepo_id%TYPE; + -- +BEGIN + -- + caco_debug.putline('SP_CONF: upd_cnpcv_vals_with_nom 001'); + -- + SAVEPOINT before_upd_cnpcv; + -- + -- Loop through the nnpcv tab and update CNPCV with the nom values + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + -- + <> + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + -- + IF p_nnpcv_tab(i).in_error THEN + -- + -- Only update if the row is in error + -- + l_value := 0; + -- + -- Get the value for the specific conp and coca for the given nomination + -- for the latest gas day in the valid nomination + -- + OPEN c_nnpcv( p_nnpcv_tab(i).conp_id + , p_nnpcv_tab(i).coca_id ); + FETCH c_nnpcv INTO l_value, l_gas_day, l_nepo_id; + IF c_nnpcv%NOTFOUND THEN + CLOSE c_nnpcv; + -- + NULL; + -- + ELSE + -- + CLOSE c_nnpcv; + -- + IF p_nom_table.COUNT > 0 THEN + -- + <> + FOR n IN 1..p_nom_table.COUNT LOOP + -- + IF p_nom_table(n).nr_nepo_id = l_nepo_id AND p_nom_table(n).nr_valid THEN + -- + -- Update the conf_net_point_cat_vals table with the found and provided values + -- + caco_debug.putline('Update confimation for: '||p_nnpcv_tab(i).conp_id); + -- + caco_debug.putline('UPDATE!'||l_value); + -- + caco_debug.putline('DEBUG4'); + UPDATE conf_net_point_cat_vals + SET last_nom_received = p_nomi_date + , last_nomi_id = p_nomi_id + , last_coru_id = p_coru_id + , last_gas_day = l_gas_day + , value = l_value + WHERE conf_id = p_conf_id + AND conp_id = p_nnpcv_tab(i).conp_id + AND coca_id = p_nnpcv_tab(i).coca_id; + -- + IF SQL%ROWCOUNT = 0 THEN + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2212); + -- An unexpected error has occurred while creating confirmation. Please contact support + caco_debug.putline('efno_confirmations.upd_cnpcv_vals_with_nom: Unable to UPDATE conf_net_point_cat_vals : ' + ||' CONF_ID : '||p_conf_id + ||' CONP_ID : '||p_nnpcv_tab(i).conp_id + ||' COCA_ID : '||p_nnpcv_tab(i).coca_id ||sqlerrm(sqlcode)); + -- + ROLLBACK TO SAVEPOINT before_upd_cnpcv; + EXIT cnpcv_update_loop; + -- + ELSE + -- + p_nnpcv_tab(i).in_error := FALSE; + -- + END IF; + -- + -- Update the rest of the values + -- + caco_debug.putline('DEBUG5'); + UPDATE conf_net_point_cat_vals c + SET ( last_nom_received + , last_nomi_id + , last_coru_id + , last_gas_day + , value + ) = ( + SELECT p_nomi_date + ,p_nomi_id + ,p_coru_id + ,l_gas_day + ,nn.value + FROM nominations n + ,nom_net_point_cat_vals nn + ,cont_network_points cnp1 + ,cont_network_points cnp2 + ,contract_categories cc1 + ,contract_categories cc2 + WHERE nn.nomi_id = n.nomi_id + AND n.nomi_id = p_nomi_id + AND nn.coca_id = cc1.coca_id + AND nn.conp_id = cnp1.conp_id + AND c.coca_id = cc2.coca_id + AND c.conp_id = cnp2.conp_id + AND cnp1.nepo_id = cnp2.nepo_id + AND cc1.cate_id = cc2.cate_id + AND nn.gas_day = ( SELECT MAX( nnpcv2.gas_day ) + FROM nom_net_point_cat_vals nnpcv2 + WHERE nnpcv2.nomi_id = p_nomi_id ) + ) WHERE c.conf_id = p_conf_id + AND c.coca_id <> p_nnpcv_tab(i).coca_id + AND c.conp_id = p_nnpcv_tab(i).conp_id + AND EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nz1 + ,cont_network_points cnpz1 + ,cont_network_points cnpz2 + ,contract_categories ccz1 + ,contract_categories ccz2 + WHERE nz1.nomi_id = p_nomi_id + AND nz1.coca_id = ccz1.coca_id + AND nz1.conp_id = cnpz1.conp_id + AND cnpz1.nepo_id = cnpz2.nepo_id + AND ccz1.cate_id = ccz2.cate_id + AND cnpz2.conp_id = c.conp_id + AND ccz2.coca_id = c.coca_id + AND nz1.value IS NOT NULL); + -- + -- Now we need to update all other values to zero + -- + caco_debug.putline('DEBUG7'); + UPDATE conf_net_point_cat_vals + SET last_nom_received = p_nomi_date + , last_nomi_id = p_nomi_id + , last_coru_id = p_coru_id + , last_gas_day = l_gas_day + , value = 0 + , defaulted = 'N' + WHERE conf_id = p_conf_id + AND conp_id = p_nnpcv_tab(i).conp_id + AND last_nom_received IS NULL; + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + END IF; + -- + END IF; + -- + END LOOP cnpcv_update_loop; + -- + -- + END IF; + -- + COMMIT; + caco_debug.putline('SP_CONF: upd_cnpcv_vals_with_nom 999'); + RETURN l_success; + -- +END upd_cnpcv_vals_with_nom; +-- +-- +-- +-- +/** +-- FUNCTION evaluate_rule +-- Validates a single EXISTING rule previously defined through the EFT Nominations Web interface +-- and optionally validates the data stored +-- +-- Examples +-- To just parse an existing ROW rule (not assigned to a contract or contract template) +-- l_boolean := validate_rule( 12, 'ROW', TRUE, l_dummy_nom_data_table ); +-- +-- To parse a Rule for a specified contract template +-- l_boolean := validate_rule( 12, 'ROW', TRUE, l_dummy_nom_data_table, 1 ); +-- +-- To parse a Rule for a specified contract +-- l_boolean := validate_rule( 12, 'ROW', TRUE, l_dummy_nom_data_table, p_contract_id => 2 ); +-- OR l_boolean := validate_rule( 12, 'ROW', TRUE, l_dummy_nom_data_table, NULL, 2 ); +-- +-- To parse a Rule for a contract AND validate the data for a nomination +-- l_boolean := validate_rule( 12, 'ROW', FALSE, l_nom_data_table, p_contract_id => 2, p_nomination_id => 3 ); +-- OR l_boolean := validate_rule( 12, 'ROW', FALSE, l_nom_data_table, NULL, 2, 3 ); +-- +-- %param p_rule_id The Unique identifier of the ROW or SHEET rule +-- %param p_rule_type ROW or SHEET +-- %param p_parse_only TRUE indicates that only syntax checking is required +-- %param p_nom_table Table of resulting values passed out to the calling routine for evaluation +-- %param p_template_id Unique identifier of a contract template +-- %param p_contract_id Unique identifier of a contract +-- %param p_nomination_id Unique identifier of a Nomination - used if not parsing +-- +-- %return BOOLEAN TRUE indicating that the rule is valid syntactically if parse only or that the data passed the test +-- and values have been returned for further checking +*/ +FUNCTION evaluate_rule ( p_rule_id IN rules.rule_id%TYPE + , p_rule_type IN VARCHAR2 + , p_conf_id IN confirmations.conf_id%TYPE + , p_gas_day IN DATE + , p_nnpcv_tab OUT nnpcv_tab + , p_contract_id IN contracts.cont_id%TYPE DEFAULT 0 + , p_nomination_id IN nominations.nomi_id%TYPE DEFAULT 0 + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to grab the parts of the row rule required + CURSOR c_row_rule IS + SELECT left_side + , right_side + , rule_relation + , error_message_hu + , error_message_en + FROM rules + WHERE rule_id = p_rule_id; + -- + -- Cursor to grab sheet based rule information + CURSOR c_sheet_rule IS + SELECT left_side + , right_side + , rule_relation + , error_message_hu + , error_message_en + FROM contract_rules + WHERE coru_id = p_rule_id; + -- + -- Cursor to get the date from a SHEET based nomination (our Confirmation copy of it) + -- (sheet based rules can only work against a single day nomination) + CURSOR c_sheet_nom IS + SELECT gas_day + FROM conf_net_point_cat_vals + WHERE conf_id = p_conf_id + AND ROWNUM = 1; + -- + -- Cursor to get the specific Network Points for the given nomination confirmation + -- 9/10/2009 SP for entry mandatory offer contracts we only need to + -- select the virtual network point for row based rules + CURSOR c_row_nom IS + SELECT DISTINCT conp.nepo_id network_point + , conp.display_sequence display_sequence + , conp.conp_id + FROM conf_net_point_cat_vals cnpcv + , cont_network_points conp + , network_points nepo + WHERE cnpcv.conf_id = p_conf_id + AND cnpcv.conp_id = conp.conp_id + AND nepo.nepo_id = conp.nepo_id + AND ((efno_contracts.emo_contract(p_contract_id) = 'Y' AND nepo.nepo_type = 'V') + OR efno_contracts.emo_contract(p_contract_id) = 'N') + ORDER BY conp.display_sequence ASC; + -- + -- + l_success BOOLEAN := TRUE; + -- + l_rule_row c_row_rule%ROWTYPE; + left_is_valid BOOLEAN := FALSE; + right_is_valid BOOLEAN := FALSE; + -- + -- + l_left_sql VARCHAR2(32767) := NULL; + l_left_select VARCHAR2(32767) := NULL; + l_left_from VARCHAR2(32767) := NULL; + l_left_where VARCHAR2(32767) := NULL; + l_left_side_value NUMBER := 0; + l_left_error VARCHAR2(255) := NULL; + -- + l_right_sql VARCHAR2(32767) := NULL; + l_right_select VARCHAR2(32767) := NULL; + l_right_from VARCHAR2(32767) := NULL; + l_right_where VARCHAR2(32767) := NULL; + l_right_side_value NUMBER := 0; + l_right_error VARCHAR2(255) := NULL; + -- + -- + l_gas_day DATE := NULL; + l_gas_day_char VARCHAR2(40) := NULL; + -- + rule_found BOOLEAN := FALSE; + l_no_data BOOLEAN := FALSE; + invalid_row_rules BOOLEAN := FALSE; + -- + l_element_count NUMBER := 0; + -- + l_nom_sites_count NUMBER := 0; + -- + BEGIN + -- + -- Get the rule information + caco_debug.putline('SP_CONF: evaluate_rule 001'); + -- + l_element_count := NVL(p_nnpcv_tab.COUNT, 0); + -- + IF UPPER(p_rule_type) = 'ROW' THEN + -- + OPEN c_row_rule; + FETCH c_row_rule INTO l_rule_row; + IF c_row_rule%FOUND THEN + rule_found := TRUE; + END IF; + CLOSE c_row_rule; + -- + ELSIF UPPER(p_rule_type) = 'SHEET' THEN + -- + OPEN c_sheet_rule; + FETCH c_sheet_rule INTO l_rule_row; + IF c_sheet_rule%FOUND THEN + rule_found := TRUE; + END IF; + CLOSE c_sheet_rule; + -- + -- Get the specific gas day for the SHEET rule + OPEN c_sheet_nom; + FETCH c_sheet_nom INTO l_gas_day; + -- + IF c_sheet_nom%NOTFOUND THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2267); + -- Invalid Nomination - Gas Day not found. Please contact support + END IF; + CLOSE c_sheet_nom; + -- + END IF; + -- + IF rule_found + AND l_success + THEN + -- + -- Need to fully evaluate the rule against the nomination data as we are not just parsing + IF p_nomination_id IS NOT NULL AND p_nomination_id > 0 + AND p_contract_id IS NOT NULL AND p_contract_id > 0 + THEN + -- + -- Find the specific gas day if the rule is a sheet based rule + IF UPPER(p_rule_type) = 'SHEET' THEN + -- Process/validate the left side - output used specifically for SHEET rules + left_is_valid := efno_rules.rule_text( p_text => l_rule_row.left_side + , p_rule_type => p_rule_type + , p_select => l_left_select + , p_from => l_left_from + , p_where => l_left_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_nomination_id => p_nomination_id + , p_conf_id => p_conf_id + , p_force_conf => TRUE + , p_return_error => l_left_error ); + -- + -- Process/validate the Right side + right_is_valid := efno_rules.rule_text( p_text => l_rule_row.right_side + , p_rule_type => p_rule_type + , p_select => l_right_select + , p_from => l_right_from + , p_where => l_right_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_nomination_id => p_nomination_id + , p_conf_id => p_conf_id + , p_force_conf => TRUE + , p_return_error => l_right_error ); + -- + IF l_left_error IS NOT NULL THEN + p_return_error := l_left_error; + ELSIF l_right_error IS NOT NULL THEN + p_return_error := l_right_error; + END IF; + -- + IF left_is_valid + AND right_is_valid + AND p_return_error IS NULL + THEN + -- Ensure that the FROMs and the WHEREs are not null + IF l_left_from IS NULL THEN + l_left_from := 'dual'; + END IF; + IF l_right_from IS NULL THEN + l_right_from := 'dual'; + END IF; + IF l_left_where IS NOT NULL THEN + l_left_where := ' WHERE '||l_left_where; + END IF; + IF l_right_where IS NOT NULL THEN + l_right_where := ' WHERE '||l_right_where; + END IF; + -- + -- We need to get the values - build the sql statements + l_left_sql := 'SELECT ('||l_left_select||') sql_value FROM '||l_left_from||l_left_where; + -- + l_right_sql := 'SELECT ('||l_right_select||') sql_value FROM '||l_right_from||l_right_where; + -- + -- We will have to replace any p_gas_day token with a TO_DATE conversion of the gas day + -- due to needing to submit a text SQL statement to DBMS_SQL + l_gas_day_char := 'TO_DATE('''||TO_CHAR(l_gas_day, 'DD-MON-YYYY')||''',''DD-MON-YYYY'')'; + -- + l_left_sql := REPLACE( l_left_sql, 'p_gas_day', l_gas_day_char ); + -- + l_right_sql := REPLACE( l_right_sql, 'p_gas_day', l_gas_day_char ); + -- + -- There should be only a single returned value from each side of the rule + efno_rules.evaluate_rule_sql( l_left_sql + , l_success + , l_no_data + , l_left_side_value ); + -- + IF l_success THEN + -- + -- Not worth doing this unless the left side was a success! + efno_rules.evaluate_rule_sql( l_right_sql + , l_success + , l_no_data + , l_right_side_value ); + -- + END IF; + -- + -- Success variable has already been set on result of evaluating each side of the SQL + -- So see if the values satisfy the relation + IF l_success THEN + -- + IF NOT efno_rules.rule_test_passed( l_left_side_value + , l_right_side_value + , l_rule_row.rule_relation ) THEN + -- + l_success := FALSE; + -- + END IF; + -- + END IF; + -- + ELSE + -- Either the left side or the right side of the rule is invalid - how much should we report? + -- If p_return_error is NULL then we have missing nnpcv records (contract changed) + -- Need to check for this in the calling package. + -- + -- Set the gas day in the nnpcv_tab for sheet nominations + -- (Row rules automatically have to do this) + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + p_nnpcv_tab(i).gas_day := l_gas_day; + END LOOP; + END IF; + -- + l_success := FALSE; + -- + END IF; + -- + ELSE -- Row Rules + -- We need to run the rule for each and every site of the nomination + -- So we need to construct an array of left side values and the result + -- of the comparsion with the rule relation + FOR r IN c_row_nom LOOP + caco_debug.putline('Row Nom Loop: '||r.network_point); + END LOOP; + <> + FOR r IN c_row_nom LOOP + -- + caco_debug.putline('c_row_nom'); + -- + l_nom_sites_count := l_nom_sites_count + 1; + left_is_valid := FALSE; + right_is_valid := FALSE; + -- + l_no_data := FALSE; + l_left_sql := NULL; + l_right_sql := NULL; + l_left_error := NULL; + l_right_error := NULL; + -- + left_is_valid := efno_rules.rule_text( p_text => l_rule_row.left_side + , p_rule_type => p_rule_type + , p_select => l_left_select + , p_from => l_left_from + , p_where => l_left_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_conf_id => p_conf_id + , p_nomination_id => p_nomination_id + , p_net_point_id => r.network_point + , p_gas_day => p_gas_day + , p_force_conf => TRUE + , p_return_error => l_left_error ); + -- + -- Process/validate the Right side + right_is_valid := efno_rules.rule_text( p_text => l_rule_row.right_side + , p_rule_type => p_rule_type + , p_select => l_right_select + , p_from => l_right_from + , p_where => l_right_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_conf_id => p_conf_id + , p_nomination_id => p_nomination_id + , p_net_point_id => r.network_point + , p_gas_day => p_gas_day + , p_force_conf => TRUE + , p_return_error => l_right_error ); + -- + IF l_left_error IS NOT NULL THEN + p_return_error := l_left_error; + ELSIF l_right_error IS NOT NULL THEN + p_return_error := l_right_error; + END IF; + -- + IF left_is_valid + AND right_is_valid + AND p_return_error IS NULL + THEN + -- + -- Ensure that the FROMs and the WHEREs are not null + IF l_left_from IS NULL THEN + l_left_from := 'dual'; + END IF; + IF l_right_from IS NULL THEN + l_right_from := 'dual'; + END IF; + IF l_left_where IS NOT NULL THEN + l_left_where := ' WHERE '||l_left_where; + END IF; + IF l_right_where IS NOT NULL THEN + l_right_where := ' WHERE '||l_right_where; + END IF; + -- + -- We need to get the values so lets build the sql statements + l_left_sql := 'SELECT ('||l_left_select||') sql_value FROM '||l_left_from||l_left_where; + -- + l_right_sql := 'SELECT ('||l_right_select||') sql_value FROM '||l_right_from||l_right_where; + -- + -- + -- We will have to replace any p_gas_day token with a TO_DATE conversion of the gas day + -- due to needing to submit a text SQL statement to DBMS_SQL + l_gas_day_char := 'TO_DATE('''||TO_CHAR(p_gas_day, 'DD-MON-YYYY')||''',''DD-MON-YYYY'')'; + -- + l_left_sql := REPLACE( l_left_sql, 'p_gas_day', l_gas_day_char ); + l_right_sql := REPLACE( l_right_sql, 'p_gas_day', l_gas_day_char ); + -- + -- Get the fully evaluated Numeric Value of each side of the rule + -- for the given information and this specific network point + efno_rules.evaluate_rule_sql( l_left_sql + , l_success + , l_no_data + , l_left_side_value ); + -- +-- IF l_success THEN + -- Not worth doing this unless the left side was a success! + efno_rules.evaluate_rule_sql( l_right_sql + , l_success + , l_no_data + , l_right_side_value ); +-- END IF; + -- + IF NOT l_success THEN + -- Exit Loop as the rule won't validate... + caco_debug.putline('EXIT 1'); +-- EXIT row_nom_loop2; + END IF; + -- + IF NOT efno_rules.rule_test_passed( l_left_side_value + , l_right_side_value + , l_rule_row.rule_relation ) THEN + -- + l_success := FALSE; + -- + FOR i IN l_element_count+1..p_nnpcv_tab.COUNT LOOP + -- + IF p_nnpcv_tab(i).conp_id = r.conp_id THEN + p_nnpcv_tab(i).in_error := TRUE; + caco_debug.putline('Element '||i||' in error'); + END IF; + -- + IF p_nnpcv_tab(i).in_error IS NULL THEN + -- + p_nnpcv_tab(i).in_error := FALSE; + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + -- + ELSIF p_return_error IS NULL THEN + -- Dont want to Exit Loop even though the rule won't validate... + -- we need to check for every network point before failing + invalid_row_rules := TRUE; + -- + ELSE + -- Exit the loop - something went wrong that we havent dealt with + l_success := FALSE; + caco_debug.putline('EXIT 2'); + EXIT row_nom_loop2; + -- + END IF; + -- + END LOOP row_nom_loop; + -- + IF c_row_nom%ISOPEN THEN + CLOSE c_row_nom; + END IF; + -- + END IF; + -- + ELSE + -- + -- To evaluate the rule - we need the nomination id and contract id so this fails + -- + caco_debug.putline('Eval without nomination'); + -- + IF p_nomination_id IS NULL THEN + -- + -- Find the specific gas day if the rule is a sheet based rule + IF UPPER(p_rule_type) = 'SHEET' THEN + -- Process/validate the left side - output used specifically for SHEET rules + left_is_valid := efno_rules.rule_text( p_text => l_rule_row.left_side + , p_rule_type => p_rule_type + , p_select => l_left_select + , p_from => l_left_from + , p_where => l_left_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_nomination_id => p_nomination_id + , p_conf_id => p_conf_id + , p_force_conf => TRUE + , p_return_error => l_left_error ); + -- + -- Process/validate the Right side + right_is_valid := efno_rules.rule_text( p_text => l_rule_row.right_side + , p_rule_type => p_rule_type + , p_select => l_right_select + , p_from => l_right_from + , p_where => l_right_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_nomination_id => p_nomination_id + , p_conf_id => p_conf_id + , p_force_conf => TRUE + , p_return_error => l_right_error ); + -- + IF l_left_error IS NOT NULL THEN + p_return_error := l_left_error; + ELSIF l_right_error IS NOT NULL THEN + p_return_error := l_right_error; + END IF; + -- + IF left_is_valid + AND right_is_valid + AND p_return_error IS NULL + THEN + -- Ensure that the FROMs and the WHEREs are not null + IF l_left_from IS NULL THEN + l_left_from := 'dual'; + END IF; + IF l_right_from IS NULL THEN + l_right_from := 'dual'; + END IF; + IF l_left_where IS NOT NULL THEN + l_left_where := ' WHERE '||l_left_where; + END IF; + IF l_right_where IS NOT NULL THEN + l_right_where := ' WHERE '||l_right_where; + END IF; + -- + -- We need to get the values - build the sql statements + l_left_sql := 'SELECT ('||l_left_select||') sql_value FROM '||l_left_from||l_left_where; + -- + l_right_sql := 'SELECT ('||l_right_select||') sql_value FROM '||l_right_from||l_right_where; + -- + -- We will have to replace any p_gas_day token with a TO_DATE conversion of the gas day + -- due to needing to submit a text SQL statement to DBMS_SQL + l_gas_day_char := 'TO_DATE('''||TO_CHAR(l_gas_day, 'DD-MON-YYYY')||''',''DD-MON-YYYY'')'; + -- + l_left_sql := REPLACE( l_left_sql, 'p_gas_day', l_gas_day_char ); + -- + l_right_sql := REPLACE( l_right_sql, 'p_gas_day', l_gas_day_char ); + -- + -- There should be only a single returned value from each side of the rule + efno_rules.evaluate_rule_sql( l_left_sql + , l_success + , l_no_data + , l_left_side_value ); + -- + IF l_success THEN + -- + -- Not worth doing this unless the left side was a success! + efno_rules.evaluate_rule_sql( l_right_sql + , l_success + , l_no_data + , l_right_side_value ); + -- + END IF; + -- + -- Success variable has already been set on result of evaluating each side of the SQL + -- So see if the values satisfy the relation + IF l_success THEN + -- + IF NOT efno_rules.rule_test_passed( l_left_side_value + , l_right_side_value + , l_rule_row.rule_relation ) THEN + -- + l_success := FALSE; + -- + END IF; + -- + END IF; + -- + ELSE + -- Either the left side or the right side of the rule is invalid - how much should we report? + -- If p_return_error is NULL then we have missing nnpcv records (contract changed) + -- Need to check for this in the calling package. + -- + -- Set the gas day in the nnpcv_tab for sheet nominations + -- (Row rules automatically have to do this) + IF NVL(p_nnpcv_tab.COUNT,0) > 0 THEN + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + p_nnpcv_tab(i).gas_day := l_gas_day; + END LOOP; + END IF; + -- + l_success := FALSE; + -- + END IF; + -- + ELSE -- Row Rules + -- We need to run the rule for each and every site of the nomination + -- So we need to construct an array of left side values and the result + -- of the comparsion with the rule relation + <> + FOR r IN c_row_nom LOOP + -- + caco_debug.putline('c_row_nom2 nepo:'||r.network_point); + -- + l_nom_sites_count := l_nom_sites_count + 1; + left_is_valid := FALSE; + right_is_valid := FALSE; + -- + l_no_data := FALSE; + l_left_sql := NULL; + l_right_sql := NULL; + l_left_error := NULL; + l_right_error := NULL; + -- + left_is_valid := efno_rules.rule_text( p_text => l_rule_row.left_side + , p_rule_type => p_rule_type + , p_select => l_left_select + , p_from => l_left_from + , p_where => l_left_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_conf_id => p_conf_id + , p_nomination_id => p_nomination_id + , p_net_point_id => r.network_point + , p_gas_day => p_gas_day + , p_force_conf => TRUE + , p_return_error => l_left_error ); + -- + -- Process/validate the Right side + right_is_valid := efno_rules.rule_text( p_text => l_rule_row.right_side + , p_rule_type => p_rule_type + , p_select => l_right_select + , p_from => l_right_from + , p_where => l_right_where + , p_nnpcv_tab => p_nnpcv_tab + , p_contract_id => p_contract_id + , p_conf_id => p_conf_id + , p_nomination_id => p_nomination_id + , p_net_point_id => r.network_point + , p_gas_day => p_gas_day + , p_force_conf => TRUE + , p_return_error => l_right_error ); + -- + IF l_left_error IS NOT NULL THEN + p_return_error := l_left_error; + ELSIF l_right_error IS NOT NULL THEN + p_return_error := l_right_error; + END IF; + -- + IF left_is_valid + AND right_is_valid + AND p_return_error IS NULL + THEN + -- + -- Ensure that the FROMs and the WHEREs are not null + IF l_left_from IS NULL THEN + l_left_from := 'dual'; + END IF; + IF l_right_from IS NULL THEN + l_right_from := 'dual'; + END IF; + IF l_left_where IS NOT NULL THEN + l_left_where := ' WHERE '||l_left_where; + END IF; + IF l_right_where IS NOT NULL THEN + l_right_where := ' WHERE '||l_right_where; + END IF; + -- + -- We need to get the values so lets build the sql statements + l_left_sql := 'SELECT ('||l_left_select||') sql_value FROM '||l_left_from||l_left_where; + -- + l_right_sql := 'SELECT ('||l_right_select||') sql_value FROM '||l_right_from||l_right_where; + -- + -- + -- We will have to replace any p_gas_day token with a TO_DATE conversion of the gas day + -- due to needing to submit a text SQL statement to DBMS_SQL + l_gas_day_char := 'TO_DATE('''||TO_CHAR(p_gas_day, 'DD-MON-YYYY')||''',''DD-MON-YYYY'')'; + -- + l_left_sql := REPLACE( l_left_sql, 'p_gas_day', l_gas_day_char ); + l_right_sql := REPLACE( l_right_sql, 'p_gas_day', l_gas_day_char ); + --caco_debug.putline('Right: '|| l_right_sql); + --caco_debug.putline('Left: '|| l_left_sql); + -- + -- Get the fully evaluated Numeric Value of each side of the rule + -- for the given information and this specific network point + efno_rules.evaluate_rule_sql( l_left_sql + , l_success + , l_no_data + , l_left_side_value ); + -- +-- IF l_success THEN + -- Not worth doing this unless the left side was a success! + caco_debug.putline('Eval right'); + efno_rules.evaluate_rule_sql( l_right_sql + , l_success + , l_no_data + , l_right_side_value ); +-- END IF; + -- + IF NOT l_success THEN + -- Exit Loop as the rule won't validate... + caco_debug.putline('Rule not valid - EXIT1'); +-- EXIT row_nom_loop; + END IF; + -- + caco_debug.putline(l_left_side_value||l_rule_row.rule_relation||l_right_side_value); + + IF NOT efno_rules.rule_test_passed( l_left_side_value + , l_right_side_value + , l_rule_row.rule_relation ) THEN + -- + -- Leave this in as it doesn't work without + -- + l_success := FALSE; + -- + FOR i IN l_element_count+1..p_nnpcv_tab.COUNT LOOP + -- + IF p_nnpcv_tab(i).conp_id = r.conp_id THEN + p_nnpcv_tab(i).in_error := TRUE; + caco_debug.putline('Element '||i||' in error'); + END IF; + -- + END LOOP; + -- + END IF; + -- + ELSIF p_return_error IS NULL THEN + -- Dont want to Exit Loop even though the rule won't validate... + -- we need to check for every network point before failing + invalid_row_rules := TRUE; + caco_debug.putline('**INVALID ROW RULES**'); + -- + ELSE + -- Exit the loop - something went wrong that we havent dealt with + l_success := FALSE; + caco_debug.putline('EXIT2'); + EXIT row_nom_loop; + -- + END IF; + -- + END LOOP row_nom_loop; + -- + IF c_row_nom%ISOPEN THEN + CLOSE c_row_nom; + END IF; + -- + END IF; + -- + END IF; + END IF; + -- + ELSIF NOT rule_found THEN + -- No rule found + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2433); + -- Rule not found. Please contact support + -- + END IF; + -- + IF invalid_row_rules THEN + l_success := FALSE; + END IF; + -- + caco_debug.putline('SP_CONF: evaluate_rule 999'); + RETURN l_success; + -- +EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(3581); + -- Error + caco_debug.putline('efno_confirmations.evaluate_rule - : Error : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Unexpected Error: '||sqlerrm(sqlcode) + ||chr(10)||'NOMI_ID: '||p_nomination_id + ||'Failed evaluating rules ' + ||'for gas day : '||TO_CHAR(p_gas_day,'DD-MON-YYYY') + , p_source => 'efno_confirmations.evaluate_rule'); + -- +END evaluate_rule; +-- +-- +-- +-- +FUNCTION fix_nom_with_lookback( p_conf_id IN confirmations.conf_id%TYPE + , p_gas_day IN DATE + , p_nomination_row IN nominations%ROWTYPE + , p_contract_id IN contracts.cont_id%TYPE + , p_rule_record IN efno_contracts.contract_rules_rec + , p_lookback_date IN DATE + , p_exception IN contracts.validation_exception%TYPE + , p_lookback_action IN contracts.lookback_action%TYPE + , p_nnpcv_tab IN nnpcv_tab + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Require a cursor to list all "tip" nominations for the contract + CURSOR c_nominations( cp_last_nomi_date IN DATE + , cp_lookback_action IN VARCHAR2 + ) IS + SELECT nomi.nomi_id + , nomi.created_on + , nomi.status + , cont1.cust_id + FROM nominations nomi + ,contracts cont1 + WHERE nomi.cont_id = cont1.cont_id + AND cont1.cont_id IN (SELECT cont2.cont_id + FROM contracts cont2 + CONNECT BY PRIOR cont2.prev_cont_id = cont2.cont_id + START WITH cont2.cont_id = p_contract_id) + AND ( nomi.nomi_id < p_nomination_row.nomi_id + OR p_nomination_row.nomi_id IS NULL ) + AND EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + GROUP BY nnpcv.gas_day + HAVING MIN(nnpcv.gas_day) <= (SELECT gas_day FROM confirmations WHERE conf_id = p_conf_id) + AND MIN(nnpcv.gas_day) >= p_lookback_date ) + AND ( ( nomi.status = 'A' -- 'A' will be the TIP each day + AND cp_lookback_action = 'T' + AND ( nomi_id IN ((SELECT nomi_id + FROM ( SELECT DISTINCT n.nomi_id, n.gas_day, no.created_on, RANK() OVER (partition by gas_day ORDER BY gas_day, no.created_on DESC) nom_rank + FROM nom_net_point_cat_vals n + ,nominations no + ,contracts c + WHERE n.nomi_id = no.nomi_id + AND no.cont_id = c.cont_id + AND c.cont_id IN (SELECT c2.cont_id + FROM contracts c2 + CONNECT BY PRIOR c2.prev_cont_id = c2.cont_id + START WITH c2.cont_id = p_contract_id) + ) + WHERE nom_rank = 1)) + ) + ) + OR ( cp_lookback_action = 'A' + ) + ) + ORDER BY ( SELECT MIN(nnpcv.gas_day) + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + ) DESC, nomi.created_on DESC; +/* + SELECT nomi.nomi_id + , nomi.created_on + , nomi.status + , cont1.cust_id + FROM nominations nomi + ,contracts cont1 + ,contracts cont2 + WHERE nomi.cont_id = cont1.cont_id + AND cont1.cust_id = cont2.cust_id + AND cont2.cont_id = p_contract_id + AND ( nomi.nomi_id < p_nomination_row.nomi_id + OR p_nomination_row.nomi_id IS NULL ) + AND EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + GROUP BY nnpcv.gas_day + HAVING MIN(nnpcv.gas_day) <= (SELECT gas_day FROM confirmations WHERE conf_id = p_conf_id) + AND MIN(nnpcv.gas_day) >= p_lookback_date ) + AND ( ( nomi.status = 'A' -- 'A' will be the TIP each day + AND cp_lookback_action = 'T' + AND ( nomi_id IN ((SELECT nomi_id + FROM ( SELECT DISTINCT n.nomi_id, n.gas_day, no.created_on, RANK() OVER (partition by gas_day ORDER BY gas_day, no.created_on DESC) nom_rank + FROM nom_net_point_cat_vals n + ,nominations no + ,contracts c + ,contracts c2 + WHERE n.nomi_id = no.nomi_id + AND no.cont_id = c.cont_id + AND c.cust_id = c2.cust_id + AND c2.cont_id = p_contract_id + ) + WHERE nom_rank = 1)) + ) + ) + OR ( cp_lookback_action = 'A' + ) + ) + ORDER BY ( SELECT MIN(nnpcv.gas_day) + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + ) DESC, nomi.created_on DESC; +*/ + -- + -- Cursor to lookup the current status of the CNPCV value + CURSOR c_cnpcv_val( cp_conp_id IN NUMBER + , cp_coca_id IN NUMBER + , cp_gas_day IN DATE ) + IS + SELECT cnpcv.* + FROM conf_net_point_cat_vals cnpcv + ,cont_network_points t + ,cont_network_points t2 + ,contract_categories c + ,contract_categories c2 + WHERE cnpcv.conf_id = p_conf_id + AND t2.conp_id = cnpcv.conp_id + AND t.conp_id = cp_conp_id + AND t.nepo_id = t2.nepo_id + AND c.cate_id = c2.cate_id + AND c2.coca_id = cnpcv.coca_id + AND c.coca_id = cp_coca_id + AND gas_day = cp_gas_day; + -- + -- Cursor to get the days before figure that the nominations can be input + CURSOR c_days_before IS + SELECT receive_before_start + FROM contracts + WHERE cont_id = p_contract_id; + -- + l_cnpcv_val_rec c_cnpcv_val%ROWTYPE; + -- + l_temp_rule_id rules.rule_id%TYPE; + -- + l_nom_table efno_rules.nom_validation_table; + l_dummy_nnpcv_tab nnpcv_tab; + l_nnpcv_tab nnpcv_tab; + l_days_before NUMBER := 0; + l_oldest_nom_date DATE; + -- + values_defaulted BOOLEAN := FALSE; + found_valid_nom BOOLEAN := FALSE; + -- + l_success BOOLEAN := TRUE; + -- + BEGIN + -- + -- Get local copy to allow valid/invalid to be updated + -- + --caco_debug.debug_on; + caco_debug.putline('SP_CONF: fix_nom_with_lookback 001'); + l_nnpcv_tab := p_nnpcv_tab; + -- + FOR i IN 1..l_nnpcv_tab.COUNT LOOP + caco_debug.putline('*'||l_nnpcv_tab(i).conp_id||'-'||sys.diutil.bool_to_int(l_nnpcv_tab(i).in_error)); + END LOOP; + -- + caco_debug.putline('Enter fix with lookback'); + -- + -- Work out the temp_rule (to pass to "evaluate_rule" + -- + IF p_rule_record.rule_type = 'SHEET' THEN + l_temp_rule_id := p_rule_record.coru_id; + ELSE + l_temp_rule_id := p_rule_record.rule_id; + END IF; + -- + -- Get the Days before figure to add to sysdate to default the "oldest Nom date" + -- + OPEN c_days_before; + FETCH c_days_before + INTO l_days_before; + CLOSE c_days_before; + -- + l_oldest_nom_date := SYSDATE + l_days_before; + -- + -- We know the current nomination is invalid - and that it affects the given + -- nomination categories values within the p_nnpcv_tab. + -- So we need to find a previous nomination that still satisfies the given rule + -- If we cant find a previous nomination within the lookback window that satisifies + -- the given rule then we need to default the category values to the validation_exception + -- type - which will be the contracted value or the minimum. + -- + -- The values that satisfy the given rule should be placed onto the conf_net_point_cat_vals table + -- + -- We need to check if we have already updated the nom values previously + -- Get the oldest nomination id and date created for each of the items + -- + IF NVL(l_nnpcv_tab.COUNT,0) > 0 THEN + -- + <> + FOR i IN 1..l_nnpcv_tab.COUNT LOOP + -- + OPEN c_cnpcv_val( l_nnpcv_tab(i).conp_id + , l_nnpcv_tab(i).coca_id + , l_nnpcv_tab(i).gas_day ); + FETCH c_cnpcv_val INTO l_cnpcv_val_rec; + IF c_cnpcv_val%NOTFOUND THEN + CLOSE c_cnpcv_val; + -- problem + -- cant fix the value if it isn't found - this should never happen. + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2315); + -- Unable to locate required data. Please contact support + caco_debug.putline('efno_confirmations.fix_nom_with_lookback: Unable to locate data in conf_net_point_cat_vals: ' + ||' CONF_ID : '||p_conf_id + ||' CONP_ID : '||l_nnpcv_tab(i).conp_id + ||' COCA_ID : '||l_nnpcv_tab(i).coca_id ); + EXIT cnpcv_lookup_loop; + -- + ELSE + CLOSE c_cnpcv_val; + -- + -- Check to see if the CNPCV value has already been defaulted + IF l_cnpcv_val_rec.defaulted = 'Y' THEN + -- + caco_debug.putline('values have been defaulted'); + values_defaulted := TRUE; + -- + ELSIF NVL(l_cnpcv_val_rec.last_nom_received, SYSDATE + l_days_before) < l_oldest_nom_date THEN + -- + caco_debug.putline('oldest nom date : '||to_char(l_oldest_nom_date,'DD-MON-YYYY HH24:MI:SS') + ||' : Last nom received : ' + ||to_char(l_cnpcv_val_rec.last_nom_received,'DD-MON-YYYY HH24:MI:SS')); + -- Set the oldest nom date to be the oldest date already used to set a value + l_oldest_nom_date := l_cnpcv_val_rec.last_nom_received; + -- + END IF; + -- + END IF; + END LOOP cnpcv_lookup_loop; + -- + END IF; + -- + IF l_success THEN + -- now we can loop through the previous tip nominations and see if any of them are valid + IF values_defaulted THEN + -- + -- We should just default each of the categories in the list as at least one of them + -- has already been defaulted to either the MIN or CTR value + -- Call the routine to default the values for the categories in our table + l_success := default_cnpcv_values( p_gas_day + , p_conf_id + , l_nnpcv_tab + , p_exception + , p_return_error ); + -- + ELSE +caco_debug.putline('cp_last_nomi_date: '||l_oldest_nom_date||' lookback_date: '||p_lookback_date||' action: '||NVL(p_lookback_action, 'A')); + caco_debug.putline('Contract: '||p_contract_id||' Nomi : '||p_nomination_row.nomi_id||' conf: '||p_conf_id); + -- We should look back for a valid value from a previous nomination if there is one... + <> + FOR r IN c_nominations( l_oldest_nom_date + , NVL(p_lookback_action, 'A')) LOOP + -- + caco_debug.putline('we have a nom to look back at: nomi_id = '||r.nomi_id); + -- + l_nom_table.DELETE; + -- + -- We want to validate the nomination - not force the confirmation here..... + -- + <> + FOR rec_nom_lookback_gas_day IN (SELECT gas_day + FROM (SELECT gas_day + FROM nom_net_point_cat_vals + WHERE nomi_id = r.nomi_id + GROUP BY gas_day) + ORDER BY gas_day DESC) + LOOP + found_valid_nom := efno_rules.validate_rule_conf( p_gas_day => rec_nom_lookback_gas_day.gas_day -- p_gas_day + , p_rule_id => l_temp_rule_id + , p_rule_type => p_rule_record.rule_type + , p_parse_only => FALSE + , p_nnpcv_tab => l_nnpcv_tab + , p_nom_table => l_nom_table + , p_contract_id => p_contract_id + , p_nomination_id => r.nomi_id); + -- + IF found_valid_nom + THEN + EXIT nom_lookback_gas_day_loop; + END IF; + END LOOP; + -- +--caco_debug.debug_on; + FOR i IN 1..l_nnpcv_tab.COUNT LOOP + caco_debug.putline('*'||l_nnpcv_tab(i).conp_id||'-'||sys.diutil.bool_to_int(l_nnpcv_tab(i).in_error)); + END LOOP; + -- + caco_debug.putline('RETURN FROM efno_rules.evaluate_rules:'||l_nom_table.COUNT||':'||l_nnpcv_tab.COUNT); + -- + IF NVL(l_nom_table.COUNT,0) > 0 THEN + -- + found_valid_nom := FALSE; + -- + <> + FOR i IN 1..l_nom_table.COUNT LOOP + -- + caco_debug.putline('Value returned: '||l_nom_table(i).nr_nepo_id||':'||sys.diutil.bool_to_int(l_nom_table(i).nr_valid)); + -- + IF l_nom_table(i).nr_valid THEN + found_valid_nom := TRUE; + EXIT nom_loop; + END IF; + -- + END LOOP nom_loop; + -- + END IF; + -- + IF found_valid_nom THEN + -- + caco_debug.putline('Update nominated values'); + -- + -- Put the details of this nomination (l_lookback_nnpcv_tab) onto the p_nnpcv_tab entries + -- + l_success := upd_cnpcv_vals_with_nom( p_conf_id => p_conf_id + , p_nnpcv_tab => l_nnpcv_tab + , p_coru_id => p_rule_record.coru_id + , p_nomi_id => r.nomi_id + , p_nomi_date => r.created_on + , p_return_error => p_return_error + , p_nom_table => l_nom_table + ); + -- + -- Exit the loop - we got good values for the cnpcv_id's.. + -- so there is no point looking back any further. + -- +-- EXIT nom_lookback_loop; + -- + END IF; + -- + END LOOP nom_lookback_loop; + -- + -- Now look to see if we still have any invalid values left over + -- + IF l_nnpcv_tab.COUNT > 0 THEN + -- + <> + FOR j IN 1..l_nnpcv_tab.COUNT LOOP + -- + IF l_nnpcv_tab(j).in_error THEN + -- + found_valid_nom := FALSE; + -- + EXIT l_nnpcv_loop; + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + -- Did we find a valid nomination? If not, we need to default the values + -- + IF NOT found_valid_nom THEN + -- + caco_debug.putline('No valid nominations'); + -- Call the routine to default the values for the categories in our table + l_success := default_cnpcv_values( p_gas_day + , p_conf_id + , l_nnpcv_tab + , p_exception + , p_return_error + , TRUE ); + -- + END IF; + -- + END IF; -- values defaulted or not + -- + END IF; --successful GTT lookups + -- + caco_debug.putline('SP_CONF: fix_nom_with_lookback 999'); + RETURN l_success; + -- +END fix_nom_with_lookback; +-- +FUNCTION fetch_contract_number( p_nomi_id IN nominations.nomi_id%TYPE ) + RETURN VARCHAR2 +IS + CURSOR c_cont IS + SELECT cont.contract_number + FROM contracts cont + , nominations nomi + WHERE nomi.cont_id = cont.cont_id + AND nomi.nomi_id = p_nomi_id; + -- + l_contract_number contracts.contract_number%TYPE := NULL; + -- +BEGIN + -- + OPEN c_cont; + FETCH c_cont INTO l_contract_number; + CLOSE c_cont; + -- + RETURN l_contract_number; + -- +END fetch_contract_number; +-- +FUNCTION fetch_nom_identifier( p_nomi_id IN nominations.nomi_id%TYPE ) + RETURN VARCHAR2 +IS + CURSOR c_nomi IS + SELECT identifier + FROM nominations + WHERE nomi_id = p_nomi_id; + -- + l_identifier nominations.identifier%TYPE := NULL; + -- +BEGIN + -- + OPEN c_nomi; + FETCH c_nomi INTO l_identifier; + CLOSE c_nomi; + -- + RETURN l_identifier; + -- +END fetch_nom_identifier; +-- +FUNCTION force_validate_cnpcv_nom( p_conf_id IN confirmations.conf_id%TYPE + , p_nomination_row IN nominations%ROWTYPE + , p_contract_id IN contracts.cont_id%TYPE + , p_gas_day IN DATE + , p_replace IN BOOLEAN DEFAULT FALSE + , p_ignore IN BOOLEAN DEFAULT FALSE + , p_window IN contracts.validation_window%TYPE DEFAULT 0 + , p_exception IN contracts.validation_exception%TYPE DEFAULT NULL + , p_lookback_action IN contracts.lookback_action%TYPE DEFAULT NULL + , p_validation_action IN contracts.validation_action%TYPE DEFAULT NULL + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_lookback_date DATE; + l_rule_record efno_contracts.contract_rules_rec; + l_temp_rule rules.rule_id%TYPE; + l_nnpcv_tab nnpcv_tab; + rule_valid BOOLEAN := TRUE; + nom_invalid BOOLEAN := FALSE; + missing_nnpcv BOOLEAN := FALSE; + -- + l_success BOOLEAN := TRUE; + -- + l_count_rules NUMBER := 0; + -- +BEGIN +caco_debug.putline('SP_CONF: force_validate_cnpcv_nom 001'); + -- Check we have permission to be using this module. +/* IF NOT caco_security.security_check('efnow095$') THEN + p_return_error := caco_utilities.get_module_text(960); -- You do not have permission to use this application + RETURN FALSE; + END IF; +*/ -- + -- The full lookback date is the confirmation gas day minus the lookback window + l_lookback_date := p_gas_day - p_window; + -- + caco_debug.putline('Lookback window date is : '||to_char(l_lookback_date,'DD-MON-YYYY')); + -- + -- Need to loop through the contract rules and validate the nomination held in the global temporary table + -- If a rule fails, we need to perform the appropriate action as depicted by the received parameters + -- If we are truncating values to Max then we complete all rules + -- If we are looking back for a validation window, we fix the failed rule and exit + -- + OPEN efno_contracts.c_rules( p_contract_id ); + FETCH efno_contracts.c_rules INTO l_rule_record; + -- + <> + WHILE efno_contracts.c_rules%FOUND LOOP + -- + l_count_rules := l_count_rules + 1; + l_temp_rule := 0; + l_nnpcv_tab.DELETE; + -- + IF l_rule_record.rule_type = 'SHEET' THEN + l_temp_rule := l_rule_record.coru_id; + ELSE + l_temp_rule := l_rule_record.rule_id; + END IF; + -- + rule_valid := evaluate_rule( l_temp_rule + , l_rule_record.rule_type + , p_conf_id + , p_gas_day + , l_nnpcv_tab + , p_contract_id + , p_nomination_row.nomi_id + , p_return_error ); + -- + caco_debug.putline('Z0 post evaluate rule: '||p_return_error||':bool:'||sys.diutil.bool_to_int(rule_valid)); + -- + IF NOT rule_valid + AND p_return_error IS NULL + THEN + -- Check to see if any of the nnpcv values were missing + IF NVL(l_nnpcv_tab.COUNT,0) > 0 THEN + <> + FOR i IN 1..l_nnpcv_tab.COUNT LOOP + -- + IF l_nnpcv_tab(i).missing = 'Y' THEN + missing_nnpcv := TRUE; + EXIT missing_nnpcv_loop; + END IF; + -- + END LOOP missing_nnpcv_loop; + END IF; + -- + IF missing_nnpcv THEN + -- + caco_debug.putline('Have missing nnpcv so must create them : rule_type :' + ||l_rule_record.rule_type||': rule/coru number : '||l_temp_rule); + -- + create_missing_cnpcv( p_conf_id => p_conf_id + , p_nomi_id => p_nomination_row.nomi_id + , p_nnpcv_tab => l_nnpcv_tab + , p_exception => p_exception + , p_validation_action => p_validation_action + , p_success => l_success + , p_return_error => p_return_error + , p_cont_id => p_contract_id + , p_lookback_date => l_lookback_date + , p_lookback_action => p_lookback_action ); + -- + END IF; + -- + caco_debug.putline('Pre-lookback'); + -- + IF l_success THEN + -- + IF p_replace THEN + -- + caco_debug.putline('about to replace'); + -- + l_success := replace_cnpcv( p_conf_id + , l_nnpcv_tab + , p_exception + , p_return_error ); + -- + IF NOT l_success THEN + EXIT contract_rules_loop; + END IF; + -- + ELSIF p_ignore THEN + -- + NULL; + -- + ELSE + -- + caco_debug.putline('about to fix nom with lookback'); + -- + l_success := fix_nom_with_lookback( p_conf_id + , p_gas_day + , p_nomination_row + , p_contract_id + , l_rule_record + , l_lookback_date + , p_exception + , p_lookback_action + , l_nnpcv_tab + , p_return_error ); + -- + IF NOT l_success THEN + EXIT contract_rules_loop; + END IF; + -- + nom_invalid := TRUE; + -- EXIT contract_rules_loop; -- commented 05/06 AG, not sure if this should be here? + -- + END IF; + -- + ELSIF p_return_error IS NOT NULL THEN + -- Something went wrong in creating the missing cnpcv records + -- We have to abandon the attempt + nom_invalid := TRUE; + EXIT contract_rules_loop; + END IF; + -- + ELSIF p_return_error IS NOT NULL THEN + -- Something went wrong in the force of the nomination + -- We have to abandon the attempt + nom_invalid := TRUE; + EXIT contract_rules_loop; + -- + END IF; + -- + -- Fetch the next rule record + FETCH efno_contracts.c_rules INTO l_rule_record; + -- + END LOOP contract_rules_loop; + -- + CLOSE efno_contracts.c_rules; + -- + caco_debug.putline('SP_CONF: force_validate_cnpcv_nom 999'); + RETURN nom_invalid; + -- +END force_validate_cnpcv_nom; +-- +-- +FUNCTION insert_comm_conf( p_nomi_id IN nominations.nomi_id%TYPE + , p_cont_id IN contracts.cont_id%TYPE + , p_gas_day IN DATE + , p_conf_id OUT confirmations.conf_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + -- + caco_debug.putline('SP_CONF: insert_comm_conf 001'); + -- + SAVEPOINT before_insert; + -- + BEGIN + INSERT INTO confirmations + ( conf_id + , confirmation_type + , nomi_id + , approved + , cont_id + , gas_day ) + VALUES + ( conf_seq.NEXTVAL + , 'CO' + , p_nomi_id + , 'N' + , p_cont_id + , p_gas_day ) + RETURNING conf_id INTO p_conf_id; + -- + COMMIT; + -- + EXCEPTION + WHEN others THEN + ROLLBACK TO SAVEPOINT before_insert; + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2330); + -- An unexpected error has occurred. Please contact support + caco_debug.putline('efno_confirmations.insert_comm_conf : NOMI_ID :' + ||p_nomi_id||' : Error : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Insert failed : ' + ||'NOMI_ID :'||p_nomi_id + ||' : Error : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.insert_comm_conf'); + -- + END; + -- + caco_debug.putline('SP_CONF: insert_comm_conf 999'); + RETURN l_success; + -- +END insert_comm_conf; +-- +-- +-- +-- +FUNCTION update_comm_conf( p_conf_id IN confirmations.conf_id%TYPE + , p_spreadsheet IN BLOB + , p_conf_text IN CLOB + , p_conf_type IN contract_options.conf_type%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_update; + -- + BEGIN + -- + UPDATE confirmations conf + SET conf.confirmation = p_spreadsheet + , conf.confirmation_text = p_conf_text + , conf.conf_file_type = p_conf_type + WHERE conf_id = p_conf_id; + -- + COMMIT; + -- + EXCEPTION + WHEN others THEN + ROLLBACK TO SAVEPOINT before_update; + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2330); + -- An unexpected error has occurred. Please contact support + caco_debug.putline('efno_confirmations.update_comm_conf : CONF_ID :'||p_conf_id + ||chr(10)||' : Error : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Update failed : ' + ||'CONF_ID :'||p_conf_id||chr(10) + ||' : Error : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.update_comm_conf'); + -- + END; + -- + RETURN l_success; + -- +END update_comm_conf; +-- +-- +-- +-- +PROCEDURE clearup_failed_comm_conf( p_conf_id IN confirmations.conf_id%TYPE ) +IS + PRAGMA AUTONOMOUS_TRANSACTION; +BEGIN + -- + DELETE conf_net_point_cat_vals + WHERE conf_id = p_conf_id; + -- + DELETE confirmations + WHERE conf_id = p_conf_id; + -- + COMMIT; + -- +EXCEPTION + WHEN others THEN + ROLLBACK; + caco_debug.putline('efno_confirmations.clearup_failed_comm_conf : CONF_ID :'||p_conf_id + ||chr(10)||' : Error : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed to clear up commercial confirmation - this needs to be done manually : ' + ||chr(10)||'CONF_ID :'||p_conf_id + ||chr(10)||': Error : '||sqlerrm(sqlcode) + , p_source => 'efno_confirmations.clearup_failed_comm_conf'); + -- + RAISE; +END clearup_failed_comm_conf; +-- +-- +-- +-- +-- +-- +FUNCTION copy_nom_to_cnpcv( p_conf_id IN confirmations.conf_id%TYPE + , p_nomi_id IN nominations.nomi_id%TYPE + , p_cont_id IN contracts.cont_id%TYPE + , p_gas_day IN DATE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + PRAGMA AUTONOMOUS_TRANSACTION; + -- + CURSOR c_cnpcv IS + SELECT p_conf_id conf_id + , nnpcv_id nnpcv_id + , value value + , gas_day gas_day + , c.coca_id coca_id + , nomi_id nomi_id + , t.conp_id conp_id + FROM nom_net_point_cat_vals n + ,cont_network_points t + ,cont_network_points t2 + ,contract_categories c + ,contract_categories c2 + WHERE n.nomi_id = p_nomi_id + AND t.cont_id = p_cont_id + AND t.nepo_id = t2.nepo_id + AND t2.conp_id = n.conp_id + AND c.cont_id = p_cont_id + AND c.cate_id = c2.cate_id + AND c2.coca_id = n.coca_id + AND gas_day = p_gas_day; + -- + l_success BOOLEAN := TRUE; + l_dummy VARCHAR2(100); + l_value conf_net_point_cat_vals.value%TYPE; + l_interrupted conf_net_point_cat_vals.interrupted%TYPE; + -- +BEGIN +caco_debug.putline('SP_CONF: copy_nom_to_cnpcv 001'); +caco_debug.putline('p_conf_id: '||p_conf_id); +caco_debug.putline('p_nomi_id: '||p_nomi_id); +caco_debug.putline('p_cont_id: '||p_cont_id); +caco_debug.putline('p_gas_day: '||p_gas_day); + SAVEPOINT before_insert; + -- + FOR r IN c_cnpcv LOOP + -- check for an active interruption + l_value := get_interrupted_value( r.conp_id + , r.coca_id + , r.gas_day ); + -- + /* IF l_value IS NULL THEN + l_value := r.value; + l_interrupted := 'N'; + ELSE + IF l_value > r.value THEN + l_value := r.value; + END IF; + l_interrupted := 'Y'; + END IF; */ -- removed 13/02 to stop interruptions taking priority + IF l_value IS NOT NULL THEN + l_interrupted := 'Y'; + END IF; + -- + l_value := r.value; + -- + BEGIN + INSERT INTO conf_net_point_cat_vals + ( conf_id + , nnpcv_id + , value + , gas_day + , coca_id + , nomi_id + , conp_id + , interrupted ) + VALUES + ( p_conf_id + , r.nnpcv_id + , l_value + , r.gas_day + , r.coca_id + , r.nomi_id + , r.conp_id + , l_interrupted ); + EXCEPTION + WHEN others THEN + ROLLBACK TO SAVEPOINT before_insert; + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2266); + -- Internal error copying nomination detail records for confirmation. Please contact support + caco_debug.putline('efno_confirmations.copy_nom_to_cnpcv - : NOMI_ID :'||p_nomi_id + ||' : Error : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Unexpected Error: '||sqlerrm(sqlcode) + ||chr(10)||'NOMI_ID: '||p_nomi_id + ||'Failed inserting into conf_net_point_cat_vals ' + ||'for gas day : '||TO_CHAR(p_gas_day,'DD-MON-YYYY') + , p_source => 'efno_confirmations.copy_nom_to_cnpcv'); + -- + END; + -- + END LOOP; + COMMIT; + -- + caco_debug.putline('SP_CONF: copy_nom_to_cnpcv 999'); + RETURN l_success; + -- +END copy_nom_to_cnpcv; +-- +FUNCTION force_comm_conf( p_conf_id IN confirmations.conf_id%TYPE + , p_nomination_row IN nominations%ROWTYPE + , p_contract_row IN contracts%ROWTYPE + , p_gas_day IN DATE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN IS + -- + nom_invalid BOOLEAN := TRUE; + l_success BOOLEAN := TRUE; + l_tip_nomi_id nominations.nomi_id%TYPE; + l_cont_id_used contracts.cont_id%TYPE; + l_nnpcv_tab nnpcv_tab; + l_contract_row contracts%ROWTYPE; + -- +BEGIN + caco_debug.putline('SP_CONF: force_comm_conf 001'); + -- We know that the nomination didn't fully validate as we are having to force the confirmation + -- Copy the nomination category values to a global temporary table + IF p_nomination_row.nomi_id IS NOT NULL THEN + -- + -- + -- + l_success := copy_nom_to_cnpcv( p_conf_id + , p_nomination_row.nomi_id + , p_contract_row.cont_id + , p_gas_day + , p_return_error ); + -- + l_success := remove_surplus_cnpcv ( p_conf_id => p_conf_id + , p_cont_id => p_contract_row.cont_id + , p_return_error => p_return_error + ); + -- + l_contract_row := p_contract_row; +-- l_contract_row.validation_exception := 'EX'; + -- + l_success := add_missing_cnpcv ( p_conf_id => p_conf_id + , p_nomi_id => p_nomination_row.nomi_id + , p_contract_row => l_contract_row + , p_gas_day => p_gas_day + , p_return_error => p_return_error + , p_defaulted => 'N' + ); + -- + ELSE + -- + -- No nomination found, precreate the confirmation details (perhaps invalid?) + -- + IF p_contract_row.validation_action = 'B' THEN + -- + l_contract_row := p_contract_row; +--caco_debug.putline('SP_CONF: force_comm_conf(setting to EX) 500'); +-- l_contract_row.validation_exception := 'EX'; + + l_success := add_missing_cnpcv ( p_conf_id => p_conf_id + , p_nomi_id => NULL + , p_contract_row => l_contract_row + , p_gas_day => p_gas_day + , p_return_error => p_return_error + , p_defaulted => 'N' + ); + -- + END IF; + -- + END IF; + --- + -- Look below, if didn't have a nomi_id nothing happened + -- as previously the condition above switches l_success to FALSE + -- now we should have a nomi_id so the remainder should handle all the + -- pitfalls of validating a nomination entered on one contract + -- against another contract! + --- + -- + -- Now we need to validate the nomination and mark the invalid category/ies + IF l_success THEN + -- + -- So what here? + -- We need to know what fails. + -- + -- IF l_contract_row.validation_action = 'I' + -- I - leave Invalid + -- Leave the nomination invalid - so nothing to do + -- otherwise.... + IF p_contract_row.validation_action = 'T' THEN + -- T - Replace (with exception value) + -- nom_invalid is throwaway here as we wont try to make the nomination valid + -- we will just replace those values that are invalid to the specified value + IF p_nomination_row.nomi_id IS NULL THEN + -- + -- If no nom, might as well do as we did before as there is nothing to look back at today + -- + nom_invalid := force_validate_cnpcv_nom( p_conf_id => p_conf_id + , p_nomination_row => p_nomination_row + , p_contract_id => p_contract_row.cont_id + , p_gas_day => p_gas_day + , p_replace => TRUE + , p_return_error => p_return_error ); + ELSE + -- + -- Fix with lookback for today only + -- +-- caco_debug.debug_on; + caco_debug.putline('Lookback 0 days'); + nom_invalid := force_validate_cnpcv_nom( p_conf_id => p_conf_id + , p_nomination_row => p_nomination_row + , p_contract_id => p_contract_row.cont_id + , p_gas_day => p_gas_day + , p_window => 0 + , p_exception => p_contract_row.validation_exception + , p_lookback_action => 'A' + , p_validation_action => p_contract_row.validation_action + , p_return_error => p_return_error ); + -- + END IF; + -- + IF p_return_error IS NOT NULL THEN + -- Have been unable to force the nomination to validate (or unable to fix missing nnpcv) + -- Has to be a serious error! + l_success := FALSE; + -- + END IF; + -- + ELSIF p_contract_row.validation_action = 'B' THEN + -- B - lookBack + -- Look back - use a loop to keep recalling the validate routine + -- until we have either got a valid nomination or have used min or contracted values +-- <> +-- WHILE nom_invalid LOOP + -- + nom_invalid := force_validate_cnpcv_nom( p_conf_id => p_conf_id + , p_nomination_row => p_nomination_row + , p_contract_id => p_contract_row.cont_id + , p_gas_day => p_gas_day + , p_window => p_contract_row.validation_window + , p_exception => p_contract_row.validation_exception + , p_lookback_action => p_contract_row.lookback_action + , p_validation_action => p_contract_row.validation_action + , p_return_error => p_return_error ); + -- + IF p_return_error IS NOT NULL THEN + -- Have been unable to force the nomination to validate + -- Has to be a serious error! + l_success := FALSE; +-- EXIT lookback_loop; + -- + END IF; + + --EXIT lookback_loop; + -- +-- END LOOP lookback_loop; + -- + ELSE + -- + -- Ignore - replace with eith min, max or contracted, do not attempt lookback. + -- + nom_invalid := force_validate_cnpcv_nom( p_conf_id => p_conf_id + , p_nomination_row => p_nomination_row + , p_contract_id => p_contract_row.cont_id + , p_gas_day => p_gas_day + , p_ignore => TRUE + , p_return_error => p_return_error ); + -- + IF p_return_error IS NOT NULL THEN + -- Have been unable to force the nomination to validate (or unable to fix missing nnpcv) + -- Has to be a serious error! + l_success := FALSE; + -- + END IF; + -- + END IF; + -- + END IF; + -- + caco_debug.putline('SP_CONF: force_comm_conf 999'); + RETURN l_success; + -- +END force_comm_conf; +-- +-- +-- +-- +-- +FUNCTION create_comm_conf( p_nomi_id IN nominations.nomi_id%TYPE + , p_force IN VARCHAR2 + , p_gas_day IN DATE + , p_cont_id IN contracts.cont_id%TYPE + , p_conf_id OUT confirmations.conf_id%TYPE + , p_return_error OUT VARCHAR2 ) RETURN BOOLEAN IS + -- + CURSOR c_contract IS + SELECT * + FROM contracts + WHERE cont_id = p_cont_id; + -- + CURSOR c_contract_options IS + SELECT * + FROM contract_options + WHERE cont_id = p_cont_id; + -- + CURSOR c_customer( cp_cust_id IN NUMBER ) IS + SELECT * + FROM customers + WHERE cust_id = cp_cust_id; + -- + CURSOR c_nomination IS + SELECT * + FROM nominations + WHERE nomi_id = p_nomi_id; + -- + -- + l_contract_row c_contract%ROWTYPE; + l_cont_opt_row c_contract_options%ROWTYPE; + l_nomination_row c_nomination%ROWTYPE; + l_customer_row c_customer%ROWTYPE; + -- + l_confirmation_id confirmations.conf_id%TYPE; + l_spreadsheet BLOB; + l_conf_text_clob CLOB; + l_conf_text VARCHAR2(32767); + l_timestamp DATE; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN +caco_debug.putline('SP_CONF: create_comm_conf 001: '||P_NOMI_ID); + -- Default the conf_id + p_conf_id := -1; + -- + -- Get the required details + IF p_nomi_id IS NOT NULL THEN + -- + OPEN c_nomination; + FETCH c_nomination + INTO l_nomination_row; + IF c_nomination%NOTFOUND THEN + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2261); + -- Failed to find Nomination Details + -- + END IF; + CLOSE c_nomination; + -- + END IF; + -- + IF l_success THEN + -- + OPEN c_contract; + FETCH c_contract + INTO l_contract_row; + IF c_contract%NOTFOUND THEN + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2260); + -- Failed to find Contract details for nomination + -- + END IF; + CLOSE c_contract; + -- + END IF; + -- + IF l_success THEN + -- + OPEN c_contract_options; + FETCH c_contract_options + INTO l_cont_opt_row; + IF c_contract_options%NOTFOUND THEN + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2260); + -- Failed to find Contract details for nomination + -- + END IF; + CLOSE c_contract_options; + -- + END IF; + -- + IF l_success THEN + -- + OPEN c_customer( l_contract_row.cust_id ); + FETCH c_customer INTO l_customer_row; + IF c_customer%NOTFOUND THEN + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2239); + -- Customer not found + -- + END IF; + CLOSE c_customer; + -- + END IF; + -- + -- If everything went well so far then we should create a "stub" of a confirmation + IF l_success THEN + -- + l_success := insert_comm_conf( p_nomi_id + , p_cont_id + , p_gas_day + , l_confirmation_id + , p_return_error ); + -- + END IF; + -- + -- + IF l_success THEN + -- + -- Create the confirmation text as a combination of various bits + l_conf_text := l_cont_opt_row.com_conf_subject; + l_conf_text := l_conf_text||chr(10)||chr(10); + l_conf_text := l_cont_opt_row.com_conf_content; + -- Replace any tokens within the text + l_conf_text := REPLACE(l_conf_text, '{NOMINATION_IDENTIFIER}', l_nomination_row.identifier); + l_conf_text := REPLACE(l_conf_text, '{GAS_DAY}', TO_CHAR(p_gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))); + l_conf_text := REPLACE(l_conf_text, '{CONFIRMATION_IDENTIFIER}', l_confirmation_id ); + -- + -- Add this to the temporary CLOB + l_conf_text_clob := NVL(l_conf_text,' '); + -- + IF p_force = 'N' THEN + -- Copy the nomination to the confirmation detail table + l_success := copy_nom_to_cnpcv( l_confirmation_id + , p_nomi_id + , p_cont_id + , p_gas_day + , p_return_error ); + -- + ELSIF p_force = 'Y' THEN + -- + -- Need to create a temporary table of the nomination + l_success := force_comm_conf( l_confirmation_id + , l_nomination_row -- currently will be empty if no nomination found (e.g. contract closed) + , l_contract_row + , p_gas_day + , p_return_error ); + -- + ELSE + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2330); + -- An unexpected error has occurred. Please contact support + -- + END IF; + -- + -- If the contract has changed and removed a Network Point or Category + -- then we need to remove those nominated network points or categories + -- (it is theoretically possible that the rules wont check everything) + IF l_success THEN + -- + l_success := remove_surplus_cnpcv( l_confirmation_id + , l_contract_row.cont_id + , p_return_error ); + -- + END IF; + -- + -- Final check for the created Confirmation. + -- If the contract has changed and Added a Network Point or Category + -- then we need to add the default values for those nepo or cate + -- (it is theoretically possible that the rules wont check everything) + IF l_success THEN + -- + l_success := add_missing_cnpcv( l_confirmation_id + , l_nomination_row.nomi_id + , l_contract_row + , p_gas_day + , p_return_error ); + -- + END IF; + -- + IF l_success THEN + -- Create the spreadsheet from the confirmation (conf_net_point_cat_vals) + BEGIN + l_spreadsheet := amfr_excel.return_conf(p_conf_id => l_confirmation_id); + EXCEPTION + WHEN OTHERS THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2212); + -- An unexpected error has occurred while creating confirmation. Please contact support + END; + END IF; + -- + IF l_success THEN + -- + -- Finally, Insert it all into the confirmations table + l_success := update_comm_conf( l_confirmation_id + , l_spreadsheet + , l_conf_text_clob + , l_customer_row.conf_type + , p_return_error ); + -- + IF l_success THEN + -- Set the return confirmation id + p_conf_id := l_confirmation_id; + END IF; + -- + ELSE + -- clear up after a failure + clearup_failed_comm_conf( p_conf_id => l_confirmation_id ); + -- + END IF; + -- + END IF; + -- + caco_debug.putline('SP_CONF: create_comm_conf 999'); + RETURN l_success; + -- + EXCEPTION + WHEN OTHERS THEN + caco_debug.putline('efno_confirmations.create_comm_conf - Error : '||sqlerrm(sqlcode)); + -- +END create_comm_conf; +-- +-- +-- +-- +PROCEDURE send_comm_conf( p_gas_day IN VARCHAR2 + , p_nomi_id IN owa_util.vc_arr DEFAULT g_vc_arr + , p_cont_id IN owa_util.vc_arr DEFAULT g_vc_arr + , p_accept IN owa_util.vc_arr DEFAULT g_vc_arr + , p_force IN owa_util.vc_arr DEFAULT g_vc_arr ) +IS + -- + l_s_conf_id owa_util.vc_arr; + l_f_nomi_id owa_util.vc_arr; + l_f_nom_identifier owa_util.vc_arr; + l_f_cont_num owa_util.vc_arr; + l_f_conf_error owa_util.vc_arr; + l_conf_id confirmations.conf_id%TYPE; + l_conf_error VARCHAR2(255); + -- + l_gas_day DATE; + l_count_nom NUMBER := 0; + l_successful_nom NUMBER := 0; + l_failed_comm_con NUMBER := 0; + successful_comm_conf BOOLEAN := TRUE; + process_this_nom BOOLEAN := TRUE; + l_success BOOLEAN := TRUE; + -- + BEGIN + -- +-- caco_debug.debug_on; + -- + caco_debug.putline('SP_CONF: send_comm_conf 001'); + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow095$') THEN + RETURN; + END IF; + -- + -- Check that we have had some data delivered + l_count_nom := NVL(p_nomi_id.COUNT,0); + -- + IF l_count_nom = 0 + OR NVL(p_accept.COUNT,0) != l_count_nom + OR NVL(p_force.COUNT,0) != l_count_nom + THEN + -- Either no data was passed to the routine or there is a mismatch in the number + -- of data items presented in the three arrays + -- Either way we shouldnt continue as something has gone wrong + l_success := FALSE; + -- + END IF; + -- + -- Ensure that the passed VARCHAR date converts to DATE + IF l_success THEN + -- + BEGIN + SELECT TO_DATE(p_gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + INTO l_gas_day + FROM dual; + EXCEPTION + WHEN others THEN + l_success := FALSE; + END; + -- + END IF; + -- + IF l_success THEN + -- + FOR i IN 1..p_nomi_id.COUNT LOOP + -- + -- Reset any variables + successful_comm_conf := TRUE; + process_this_nom := TRUE; + l_conf_error := NULL; + -- + -- Lets deal with simplicity first. + IF p_accept(i) = 'Y' THEN + -- + -- We just need to create the commercial confirmation spreadsheet directly from + -- the nomination as we know that the nomination was correct (can only 'accept' if it was valid) + -- this saves us from revalidating the entire nomination + successful_comm_conf := create_comm_conf( p_nomi_id(i) + , 'N' + , l_gas_day + , p_cont_id(i) + , l_conf_id + , l_conf_error ); + -- + ELSIF p_force(i) = 'Y' THEN + -- + -- In this scenario, the nomination is not valid + -- We have to revalidate every nominated category against the contract + -- For those items that are invalid, we have to attempt to find valid values either + -- by traversing through all previous tip nominations until we find a valid value - + -- if one is not found then we have to take the contracted or minimum amount from the + -- contract parameter values - or we truncate the value to the contracted or minimum + -- + -- If we cannot find a value due to missing nnpcv entries, we should create one based + -- upon the Validation Exception of the Contract - i.e. create a cnpcv entry specifically + -- for the confirmation (only stored in cnpcv - not in nnpcv). + -- + caco_debug.putline('efno_confirmation point A10'); + successful_comm_conf := create_comm_conf( p_nomi_id(i) + , 'Y' + , l_gas_day + , p_cont_id(i) + , l_conf_id + , l_conf_error + ); + caco_debug.putline('efno_confirmation point A20'); + -- + ELSE + -- + -- Dont want to process this one - not accepted and not forced. + -- + process_this_nom := FALSE; + -- + END IF; + -- + -- + IF NOT successful_comm_conf + AND process_this_nom + THEN + -- + -- We need to record details to pass back to the user - use some arrays + l_failed_comm_con := l_failed_comm_con + 1; + -- + -- Get the Nomination Identifier and Contract number + l_f_nomi_id(l_failed_comm_con) := p_nomi_id(i); + l_f_nom_identifier(l_failed_comm_con) := fetch_nom_identifier( p_nomi_id(i) ); + l_f_cont_num(l_failed_comm_con) := p_cont_id(i); + l_f_conf_error(l_failed_comm_con) := l_conf_error; + -- + ELSIF process_this_nom THEN + -- + -- Successful - store info for showing as a mini report + l_successful_nom := l_successful_nom + 1; + -- + l_s_conf_id(l_successful_nom) := l_conf_id; + -- + END IF; + -- + END LOOP; + -- + -- need to call the send confirmation screen with appropriate success and failure report. + -- probably better to be a different screen within the efnow095$ package + -- + efnow095$.approve_confirmations( 'CREATED' + , l_s_conf_id + , l_f_nomi_id + , l_f_nom_identifier + , l_f_cont_num + , l_f_conf_error ); + -- + ELSE + -- We should just report an error back to the Send Confirmation screen + efnow095$.startup( p_error => 'Y' + , p_error_text => caco_utilities.get_module_text(2330) ); + -- An unexpected error has occurred. Please contact support + -- + END IF; + -- + caco_debug.putline('SP_CONF: send_comm_conf 999'); + -- +END send_comm_conf; +-- +-- +-- +-- +PROCEDURE app_or_del_comm_conf( p_conf_id IN owa_util.vc_arr DEFAULT g_vc_arr + , p_approve IN owa_util.vc_arr DEFAULT g_vc_arr + , p_delete IN owa_util.vc_arr DEFAULT g_vc_arr + ) +IS + -- + -- Cursor to get Commercial confirmation details + CURSOR c_conf( cp_conf_id IN NUMBER ) IS + SELECT conf.confirmation + , conf.confirmation_text + , nomi.identifier + , cont.cust_id + , coop.com_conf_subject + , conf.gas_day + , cust.code + , conf.conf_file_type + FROM confirmations conf + , nominations nomi + , contracts cont + , customers cust + , contract_options coop + WHERE conf.conf_id = cp_conf_id + AND conf.nomi_id = nomi.nomi_id (+) + AND conf.cont_id = cont.cont_id + AND cust.cust_id = cont.cust_id + AND coop.cont_id = cont.cont_id; + -- + l_conf_rec c_conf%ROWTYPE; + l_timestamp DATE; + l_sms_msg_en VARCHAR2(160); + l_sms_msg_hu VARCHAR2(160); + -- + l_document_name documents.name%TYPE; + -- +BEGIN + -- + -- Check we have permission to be using this module. + IF NOT g_auto_gen THEN + -- + IF NOT caco_security.security_check('efnow095$') THEN + RETURN; + END IF; + -- + END IF; + -- + IF NVL(p_conf_id.COUNT,0) > 0 + AND NVL(p_conf_id.COUNT,0) = NVL(p_approve.COUNT,0) + AND NVL(p_conf_id.COUNT,0) = NVL(p_delete.COUNT,0) + THEN + -- We have some data to deal with. + FOR i IN 1..p_conf_id.COUNT LOOP + -- + l_conf_rec := NULL; + l_timestamp := NULL; + -- + IF p_approve(i) = 'Y' + AND p_delete(i) = 'N' + THEN + -- + OPEN c_conf( p_conf_id(i) ); + FETCH c_conf INTO l_conf_rec; + IF c_conf%FOUND THEN + -- + -- Timestamping + l_timestamp := amfr_timestamp.timestamp_document( p_identifier => p_conf_id(i) + , p_doctype => amfr_timestamp.c_confirmation + , p_file_for_hash => l_conf_rec.confirmation ); + -- + upd_conf_timestamp( p_conf_id(i) + , l_timestamp + ); + -- + -- Confirmation Acceptance for Nomination sent at + -- Define the English SMS content + l_sms_msg_en := caco_utilities.get_module_text( p_text_number => 2233 + , p_language => 'EN' ); + l_sms_msg_en := REPLACE( l_sms_msg_en, '', l_conf_rec.identifier ); + l_sms_msg_en := REPLACE( l_sms_msg_en, '', TO_CHAR(l_timestamp, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI:SS') ); + -- + -- Define the Hungarian SMS content + l_sms_msg_hu := caco_utilities.get_module_text( p_text_number => 2233 + , p_language => 'HU' ); + l_sms_msg_hu := REPLACE( l_sms_msg_hu, '', l_conf_rec.identifier ); + l_sms_msg_hu := REPLACE( l_sms_msg_hu, '', TO_CHAR(l_timestamp, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI:SS') ); + -- + -- Replace the tags in the SMS content + -- + l_conf_rec.com_conf_subject := REPLACE(l_conf_rec.com_conf_subject, '{NOMINATION_IDENTIFIER}', l_conf_rec.identifier); + l_conf_rec.com_conf_subject := REPLACE(l_conf_rec.com_conf_subject, '{GAS_DAY}', TO_CHAR(l_conf_rec.gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))); + l_conf_rec.com_conf_subject := REPLACE(l_conf_rec.com_conf_subject, '{CONFIRMATION_IDENTIFIER}', p_conf_id(i) ); + -- + l_document_name := REPLACE(l_conf_rec.code,' ','_')||'_'||TO_CHAR(l_conf_rec.gas_day, 'YYYYMMDD')||'_'||TO_CHAR(p_conf_id(i)); + -- + IF l_conf_rec.conf_file_type = 'E' THEN + -- + l_document_name := l_document_name||'.xls'; + -- + ELSIF l_conf_rec.conf_file_type = 'X' THEN + -- + l_document_name := l_document_name||'.xml'; + -- + END IF; + -- + efno_msgsubs.send_messages( p_cust_id => l_conf_rec.cust_id + , p_suca_id => efno_msgsubs.get_suca_id( p_suca_group => 'CONFIRMATION' + , p_suca_name => 'ACCEPTANCE' ) + , p_email_content_en => DBMS_LOB.SUBSTR(l_conf_rec.confirmation_text,32767,1) + , p_email_subject_en => l_conf_rec.com_conf_subject + , p_sms_content_en => l_sms_msg_en + , p_sms_content_hu => l_sms_msg_hu + , p_file => l_conf_rec.confirmation + , p_filename => l_document_name + , p_file_mime_type => 'application/vnd.ms-excel' ); + -- + END IF; + CLOSE c_conf; + -- + ELSIF p_approve(i) = 'N' + AND p_delete(i) = 'Y' + THEN + -- + clearup_failed_comm_conf( p_conf_id(i) ); + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + -- Finally just recall the approve confirmations screen with no values + -- (if nothing was passed - nothing will have happened) + -- Only call if proc was called from the screen and not through auto generation of confirmations + IF NOT g_auto_gen THEN + efnow095$.approve_confirmations; + END IF; + -- +END app_or_del_comm_conf; +-- +-- +/** +-- PROCEDURE auto_gen_confirmations +-- Automatically generate confirmations for the given gas day. +-- and Customer type (if provided otherwaise all customers) +-- +-- %param p_gas_day Gas Day that Commercial confirmations shuold be created for +-- %param p_cuty_id Customer Type ID. All customer if excluded +-- +*/ +PROCEDURE auto_gen_confirmations( p_gas_day IN DATE + , p_cuty_id IN customer_types.cuty_id%TYPE + , p_cnrt_id IN conf_run_times.cnrt_id%TYPE DEFAULT NULL ) IS + -- + l_found_nomination BOOLEAN; + l_nomination_valid BOOLEAN; + l_nomi_id nominations.nomi_id%TYPE; + l_dummy VARCHAR2(255); + l_success BOOLEAN; + -- + l_conf_id confirmations.conf_id%TYPE; + l_return_error VARCHAR2(255); + -- + l_conf_id_arr owa_util.vc_arr; + l_conf_a_arr owa_util.vc_arr; + l_conf_d_arr owa_util.vc_arr; + -- + l_cfrl_id conf_run_log.cfrl_id%TYPE; + -- + l_cont_count NUMBER := 0; + l_nom_count NUMBER := 0; + l_force_count NUMBER := 0; + l_conf_sent NUMBER := 0; + l_log_details VARCHAR2(1000); + l_run_date DATE := SYSDATE; + -- + BEGIN + -- + -- Set global flag to indicate to other confirmation processes we are being called by a job + -- + g_auto_gen := TRUE; + -- + -- Loop around all active contracts for the cuty + -- + caco_debug.putline('Entered efno_confirmation.auto_gen_confirmation with:'); + caco_debug.putline('p_gas_day '||p_gas_day); + caco_debug.putline('p_cuty_id '||p_cuty_id); + caco_debug.putline('p_cnrt_id '||p_cnrt_id); + -- + IF p_cnrt_id IS NOT NULL THEN + -- + INSERT INTO conf_run_log ( cnrt_id + , start_time + ) + VALUES ( p_cnrt_id + , SYSDATE + ) + RETURNING cfrl_id INTO l_cfrl_id; + -- + END IF; + -- + FOR cont_rec IN ( SELECT cont.cont_id + ,coop.auto_gen_conf + FROM contracts cont + ,customers cust + ,contract_options coop + WHERE cont.cust_id = cust.cust_id + AND cust.cuty_id = p_cuty_id + AND cont.cont_id = coop.cont_id + AND p_gas_day BETWEEN cont.valid_from AND cont.valid_until + AND cont.status = 'O' ) LOOP + -- + l_found_nomination := FALSE; + l_nomination_valid := FALSE; + l_nomi_id := NULL; + l_cont_count := l_cont_count + 1; + -- + -- Now look for an active nomination + -- + FOR nomi_rec IN ( SELECT nomi.nomi_id + FROM nominations nomi + , nom_net_point_cat_vals nnpcv + WHERE nomi.cont_id = cont_rec.cont_id + AND nnpcv.nomi_id = nomi.nomi_id + AND nomi.status = 'A' + GROUP BY nomi.nomi_id + HAVING p_gas_day BETWEEN MIN(nnpcv.gas_day) AND MAX(nnpcv.gas_day) + ) LOOP + -- + l_found_nomination := TRUE; + l_nomi_id := nomi_rec.nomi_id; + -- + EXIT; + -- + END LOOP; + -- + IF l_found_nomination THEN + -- + -- We have a nomination, lets check that its valid + -- + l_nomination_valid := efno_contracts.validate_nomination( cont_rec.cont_id + , l_nomi_id + , l_dummy + ); + -- + END IF; + -- + -- If a nomination was found which is valid, no need to force, otherwise force the commercial confirmation + -- + IF l_found_nomination AND l_nomination_valid THEN + -- + l_nom_count := l_nom_count + 1; + -- + l_success := create_comm_conf( l_nomi_id + , 'N' + , p_gas_day + , cont_rec.cont_id + , l_conf_id + , l_return_error + ); + -- + ELSE + -- + l_force_count := l_force_count + 1; + -- + l_success := create_comm_conf( NULL + , 'Y' + , p_gas_day + , cont_rec.cont_id + , l_conf_id + , l_return_error + ); + -- + END IF; + -- + IF l_success AND cont_rec.auto_gen_conf = 'Y' THEN + -- + l_conf_sent := l_conf_sent + 1; + -- + l_conf_id_arr.DELETE; + l_conf_a_arr.DELETE; + l_conf_d_arr.DELETE; + -- + l_conf_id_arr(1):= l_conf_id; + l_conf_a_arr(1) := 'Y'; + l_conf_d_arr(1) := 'N'; + -- + app_or_del_comm_conf( p_conf_id => l_conf_id_arr + , p_approve => l_conf_a_arr + , p_delete => l_conf_d_arr + ); + -- + ELSIF NOT l_success THEN + -- + cout_err.report_and_go( p_exception_number => 20001 + , p_exception_message => 'Unable to create confirmation for : ' + ||' CONT_ID : ' + ||cont_rec.cont_id + ||' : NOMI_ID : ' + ||l_nomi_id + ||CHR(10) + ||' Error Msg : ' + ||l_return_error + , p_source => 'efno_confirmations.auto_gen_confirmations' + ); + -- + END IF; + -- + END LOOP; + -- + l_log_details := TO_CHAR(l_cont_count)||' contracts processed, '||TO_CHAR(l_nom_count)||' valid nominations, '||TO_CHAR(l_force_count)||' confirmations forced and '||TO_CHAR(l_conf_sent)||' confirmations automatically sent.'; + -- + IF p_cnrt_id IS NOT NULL THEN + -- + UPDATE conf_run_log + SET end_time = SYSDATE + ,log_details = l_log_details + WHERE cfrl_id = l_cfrl_id; + -- + END IF; + -- + caco_debug.putline('End auto_gen_confirmations'); + -- +EXCEPTION + -- + WHEN OTHERS THEN + -- + -- Write an error and stop + -- + cout_err.report_and_stop( p_exception_number => SQLCODE + , p_exception_message => 'Automatic Generation of confirmations failed : ' + ||' Gas Day : ' + ||TO_CHAR(p_gas_day,'DD-MON-YYYY') + ||CHR(10) + ||' Error Msg : ' + ||SQLERRM(SQLCODE) + , p_source => 'efno_confirmations.auto_gen_confirmations' + ); + -- +END auto_gen_confirmations; +-- +-- +-- +-- +/** +-- 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_revision || CHR(10) || g_header ); +END about; +-- +-- +BEGIN + -- Initialization + NULL; + -- +END efno_confirmations; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_contracts.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_contracts.bdy new file mode 100644 index 0000000..3c5733c --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_contracts.bdy @@ -0,0 +1,5009 @@ +CREATE OR REPLACE PACKAGE BODY efno_contracts IS + +-- Single point of finding Contract rules in the correct order. +CURSOR c_rules( cp_cont_id IN NUMBER ) + RETURN contract_rules_rec +IS + SELECT display_sequence + , rule_name + , rule_type + , coru_id + , rule_id + , inherited + FROM ( + SELECT coru.display_sequence display_sequence + , rule.rule_name rule_name + , coru.coru_type rule_type + , coru.coru_id coru_id + , coru.rule_id rule_id + , coru.inherited inherited + FROM contract_rules coru + , rules rule + WHERE rule.rule_id = coru.rule_id + AND coru.cont_id = cp_cont_id + UNION ALL + SELECT display_sequence + , rule_name + , coru_type + , coru_id + , rule_id + , inherited + FROM contract_rules + WHERE cont_id = cp_cont_id + AND rule_id IS NULL + ) + ORDER BY rule_type DESC -- SHEET rules first (contract specific) + , inherited DESC -- Inherited (Y) first + , display_sequence ASC + , rule_name ASC; +-- +-- +FUNCTION invalidate_inty( p_contract_id IN contracts.cont_id%TYPE) + RETURN BOOLEAN +IS + CURSOR c_inty IS + SELECT inty_id + FROM interruption_types + WHERE cate_id IN (SELECT cate_id + FROM contract_categories + WHERE cont_id = p_contract_id) + AND status = 'A' + AND expiry_date > SYSDATE; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_upd_inty; + -- + <> + FOR r IN c_inty LOOP + -- + BEGIN + -- + UPDATE interruption_types + SET status = 'I' + WHERE inty_id = r.inty_id; + -- + EXCEPTION + WHEN others THEN + l_success := FALSE; + caco_debug.putline('efno_contracts.invalidate_inty: ' + ||'Update of interruption types failed: ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed updating INTY: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.invalidate_inty'); + -- + ROLLBACK TO SAVEPOINT before_upd_inty; + EXIT upd_inty_loop; + END; + END LOOP; + -- + RETURN l_success; + -- +END invalidate_inty; + /** + -- FUNCTION contract_active + -- + -- Determines whether a given contract ID is active and current + -- + -- %param p_cont_id The unique identifier for a contract + -- + -- %return BOOLEAN Indicates whether the contract is active + */ + FUNCTION contract_active ( p_cont_id IN contracts.cont_id%TYPE ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + FOR cont IN ( SELECT NULL + FROM contracts cont + WHERE cont.cont_id = p_cont_id + AND cont.status = 'O' + AND TRUNC(SYSDATE) BETWEEN cont.valid_from AND cont.valid_until ) LOOP + -- + -- will only retuen one row as unique key lookup + -- + l_return := TRUE; + -- + END LOOP; + -- + RETURN l_return; + -- + END contract_active; +-- +-- +/** +-- FUNCTION validate_nomination +-- Fairly Simplistic function that will just return TRUE or FALSE +-- to indicate if the given nomination is valid for the contract as it stands +-- +-- %param p_contract_id The Unique identifier of a Contract +-- %param p_nomination_id The Unique identifier of a Nomination +-- %param p_return_error OUT: Message giving brief reason why the rule is invalid if indeed it is +-- +-- %return BOOLEAN TRUE indicating that the nomination is valid +*/ +FUNCTION validate_nomination( p_contract_id IN contracts.cont_id%TYPE + , p_nomination_id IN nominations.nomi_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + -- Cursor to get the contract details + CURSOR c_contract IS + SELECT * + FROM contracts + WHERE cont_id = p_contract_id; + -- + -- Cursor to get the nomination identifier and the min and max days of the nom + -- this is required to ensure that the nominations fall within the contract validity period + CURSOR c_nomination IS + SELECT nomi.identifier identifier + , MIN(nnpcv.gas_day) gas_day_from + , MAX(nnpcv.gas_day) gas_day_to + FROM nominations nomi + , nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + AND nomi.nomi_id = p_nomination_id + GROUP BY nomi.identifier; + -- + -- + l_contract_row c_contract%ROWTYPE; + l_nom_row c_nomination%ROWTYPE; + l_rule_id NUMBER := 0; + l_nnpcv_tab efno_confirmations.nnpcv_tab; + l_nom_validation_table efno_rules.nom_validation_table; + -- + rule_valid BOOLEAN := TRUE; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + -- + -- Check we have permission to be using this module. + -- Only called from the Create commercial confirmation screen + IF NOT caco_security.security_check('efnow095$') THEN + RETURN FALSE; + END IF; + -- + -- Get the Contract row + OPEN c_contract; + FETCH c_contract INTO l_contract_row; + IF c_contract%NOTFOUND THEN + -- problem - no contract! + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2235); -- Contract not found + END IF; + CLOSE c_contract; + -- + IF l_success THEN + -- Get the nomination details + OPEN c_nomination; + FETCH c_nomination INTO l_nom_row; + IF c_nomination%NOTFOUND THEN + -- no nomination! How can this happen? + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2288); -- Nomination not found + END IF; + CLOSE c_nomination; + -- + END IF; + -- + IF l_success THEN + -- Lets check that the nomination gas days are within the contract period + IF l_contract_row.valid_from > l_nom_row.gas_day_from + OR l_contract_row.valid_until < l_nom_row.gas_day_to + THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2285); -- Nomination Gas Days are not within the Contract validity period + END IF; + END IF; + -- + IF l_success THEN + -- Lets loop through all the rules for the contract and check that the + -- nomination data is valid for them + <> + FOR r IN c_rules( p_contract_id ) LOOP + -- + l_nom_validation_table.DELETE; + rule_valid := FALSE; + l_rule_id := 0; + -- + IF r.rule_type = 'SHEET' THEN + l_rule_id := r.coru_id; + ELSE + l_rule_id := r.rule_id; + END IF; + -- + rule_valid := efno_rules.validate_rule( p_rule_id => l_rule_id + , p_rule_type => r.rule_type + , p_parse_only => FALSE + , p_nnpcv_tab => l_nnpcv_tab + , p_nom_table => l_nom_validation_table + , p_contract_id => p_contract_id + , p_nomination_id => p_nomination_id ); + -- + IF rule_valid THEN + -- We now need to check that all of the data satisified the conditions of the rule + -- just need to check nr_valid in the validation_table + IF NVL(l_nom_validation_table.COUNT,0) > 0 THEN + -- + FOR i IN 1..l_nom_validation_table.COUNT LOOP + -- + IF NOT l_nom_validation_table(i).nr_valid THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2284); -- Nomination Data failed Contract Rule validation + EXIT nom_rule_loop; + END IF; + END LOOP; + -- + END IF; + -- + ELSE + -- The nommination failed rule validation + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2234); -- Contract Rule is invalid + EXIT nom_rule_loop; + END IF; + -- + END LOOP nom_rule_loop; + -- + -- + END IF; + -- + RETURN l_success; + -- +END validate_nomination; + + + + + +PROCEDURE find_passed_net_points( p_nepo_array IN owa_util.vc_arr + , p_network_point_array OUT network_point_array ) +IS + l_count NUMBER := 0; +BEGIN + -- + IF NVL(p_nepo_array.COUNT,0) > 0 THEN + FOR i IN p_nepo_array.FIRST .. p_nepo_array.LAST LOOP + -- + l_count := l_count + 1; + p_network_point_array(l_count) := TO_NUMBER(p_nepo_array(i)); + -- + END LOOP; + END IF; + -- +END find_passed_net_points; + + + + + +PROCEDURE find_passed_categories( p_cate_array IN owa_util.vc_arr + , p_category_array OUT category_array ) +IS + l_count NUMBER := 0; +BEGIN + -- + IF NVL(p_cate_array.COUNT,0) > 0 THEN + FOR i IN p_cate_array.FIRST .. p_cate_array.LAST LOOP + -- + l_count := l_count + 1; + -- + p_category_array(l_count).cate_id := TO_NUMBER(p_cate_array(i)); + p_category_array(l_count).inherited := 'N'; + -- + -- Set sequence to added sequence rather than inherited sequence + -- + p_category_array(l_count).display_sequence := l_count; + -- + END LOOP; + END IF; + -- +END find_passed_categories; + + + + + + +PROCEDURE find_passed_parameters( p_pars_array IN owa_util.vc_arr + , p_parameter_array OUT parameter_array ) +IS + l_count NUMBER := 0; +BEGIN + -- + IF NVL(p_pars_array.COUNT,0) > 0 THEN + FOR i IN p_pars_array.FIRST .. p_pars_array.LAST LOOP + -- + l_count := l_count + 1; + -- + p_parameter_array(l_count).pars_id := TO_NUMBER(p_pars_array(i)); + p_parameter_array(l_count).inherited := 'N'; -- default value - replace it later (for contracts) + -- + END LOOP; + END IF; + -- +END find_passed_parameters; + +-- Function to check if the nomination gate closure has occured for a given date +FUNCTION check_gate_closure ( p_cont_id IN contracts.cont_id%TYPE + , p_date IN DATE + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := TRUE; + l_deadline VARCHAR2(5) := NULL; + l_active_date DATE := NULL; + l_date DATE := NULL; + l_cust_id NUMBER := NULL; + -- + FUNCTION in_a_renom_window + RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + FOR i IN ( SELECT NULL + FROM nomination_windows nw + ,nom_window_contracts nwc + WHERE nw.nowi_id = nwc.nowi_id + AND nwc.cont_id = p_cont_id + AND nw.gas_day = TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24) + cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24 + AND SYSDATE BETWEEN nw.window_start AND nw.window_end + ) LOOP + -- + l_return := TRUE; + -- + EXIT; + -- + END LOOP; + -- + RETURN l_return; + -- + END in_a_renom_window; + -- + FUNCTION get_deadline ( p_cust_id IN customers.cust_id%TYPE ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(5) := NULL; + -- + BEGIN + -- + SELECT cust.ind_deadline_for_nom_submit + INTO l_return + FROM customers cust + WHERE cust.cust_id = p_cust_id; + -- + IF l_return IS NULL THEN + -- + l_return := cout_system_configuration.get_configuration_item('G_SUBMISSION_DEADLINE'); + -- + END IF; + -- + RETURN l_return; + -- + END get_deadline; + -- + BEGIN + -- + -- get the cust_id from contracts table + SELECT cust_id + INTO l_cust_id + FROM contracts + WHERE cont_id = p_cont_id; + -- + l_date := TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24)+ + NVL(cout_system_configuration.get_configuration_item('G_NOM_DATE_OFFSET'),1); + IF l_date = p_date THEN + -- + -- There is a nomination for tomorrow, need to check gate closure + -- + l_deadline := get_deadline(p_cust_id => l_cust_id); + -- + IF l_deadline IS NOT NULL THEN + -- + IF TO_NUMBER(RTRIM(SUBSTR(l_deadline,1,2),':')) < cout_system_configuration.get_configuration_item(p_parameter => 'GAS_DAY_OFFSET') THEN + -- + -- Is tomorrow, add one to the date + -- + l_active_date := TO_DATE(TO_CHAR(TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24),'DD/MM/YYYY')||l_deadline, 'DD/MM/YYYYHH24:MI')+1; + -- + ELSE + -- + -- same calendar date, OK + -- + l_active_date := TO_DATE(TO_CHAR(TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24),'DD/MM/YYYY')||l_deadline, 'DD/MM/YYYYHH24:MI'); + -- + END IF; + -- + -- Determined what the deadline is, now check it + -- + IF SYSDATE > l_active_date THEN + -- + l_return := FALSE; + -- + END IF; -- p_date > l_active_date + -- + END IF; -- l_deadline not null + -- + END IF; -- nominating for tomorrow + -- + -- Renom window check + -- + IF l_date > p_date THEN + -- + -- Nominating for today, check for renom window + -- + IF NOT in_a_renom_window THEN + -- + l_return := FALSE; + -- + END IF; + -- + END IF; + -- + RETURN l_return; + -- + END check_gate_closure; + +-- FUNCTION recalc_emo_noms +-- +-- recalculate any nominations for the entry mandatory offer contract which are before gate closure +-- +-- %param p_cont_id The unique identifier for a contract +-- %param p_err_msg to return an error message to calling program +-- %return BOOLEAN Indicates whether the function succeeded +FUNCTION recalc_emo_noms ( p_cont_id IN contracts.cont_id%TYPE + ,p_err_msg OUT VARCHAR2 ) RETURN BOOLEAN IS + -- + l_success BOOLEAN := TRUE; + l_tot_perc_split NUMBER := 0; + -- + CURSOR c_vnepo_coca (cp_nomi_id NUMBER + ,cp_gas_day DATE) IS + SELECT nnpcv.coca_id + , nnpcv.value value + FROM nom_net_point_cat_vals nnpcv + , contracts cont + , cont_network_points conp + , network_points nepo + WHERE nnpcv.nomi_id = cp_nomi_id + AND nnpcv.gas_day = cp_gas_day + AND cont.cont_id = p_cont_id + AND nnpcv.conp_id = conp.conp_id + AND conp.nepo_id = nepo.nepo_id + AND nepo.nepo_type = 'V' + ORDER BY 1; + -- +BEGIN + caco_debug.putline('efno_contracts.recalc_emo_noms - start'); + -- get the total of the percentage split values + OPEN efnow098$.c_tot_perc_split(p_cont_id); + FETCH efnow098$.c_tot_perc_split INTO l_tot_perc_split; + CLOSE efnow098$.c_tot_perc_split; + -- + -- loop round all active nominations for the contract to see if they need recalculating + -- starting with two days back to be safe. + FOR nom IN ( SELECT nomi.nomi_id + ,nnpcv.gas_day + FROM nominations nomi + ,nom_net_point_cat_vals nnpcv + WHERE nomi.nomi_id = nnpcv.nomi_id + AND nomi.cont_id = p_cont_id + AND nomi.status = 'A' + GROUP BY nnpcv.gas_day + ,nomi.nomi_id + HAVING nnpcv.gas_day > trunc(SYSDATE) - 2 + ORDER BY gas_day ) LOOP + -- + -- check nomination gate closure for the gas day + IF check_gate_closure(p_cont_id,nom.gas_day) THEN + -- loop round the virtual network point nomination categories for the gas day + FOR v IN c_vnepo_coca(nom.nomi_id + ,nom.gas_day) LOOP + -- loop round each non virtual network point assigned to the contract + -- retrieving the percentage split parameters + FOR i IN efnow098$.c_conp(p_cont_id) LOOP + -- update the existing nominated values + caco_debug.putline('efno_contracts.recalc_emo_noms - updating nominations'); + UPDATE nom_net_point_cat_vals nnpcv + SET value = ROUND((i.perc_split/l_tot_perc_split)*v.value) + WHERE nnpcv.nomi_id = nom.nomi_id + AND nnpcv.gas_day = nom.gas_day + AND nnpcv.coca_id = v.coca_id + AND nnpcv.conp_id = i.conp_id; + -- + END LOOP; + END LOOP; + -- save new spreadsheet for updated nomination + amfr_excel.get_template(p_id => p_cont_id + ,p_type => amfr_excel.gc_nomination + ,p_nomi_conf_id => nom.nomi_id + ,p_mode => 'INSERT' + ); + END IF; + -- + END LOOP; + -- + caco_debug.putline('efno_contracts.recalc_emo_noms - end'); + RETURN l_success; + -- +EXCEPTION + WHEN others THEN + caco_debug.putline('efno_contracts.recalc_emo_noms failed'); + l_success := FALSE; + p_err_msg := caco_utilities.get_module_text(3918); + RETURN l_success; + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => sqlerrm(sqlcode) + , p_source => 'efno_contracts.recalc_emo_noms'); + -- +END recalc_emo_noms; + +-- +-- For returning the number of network points assigned to a contract +FUNCTION nepo_count( p_contract_id IN NUMBER ) + RETURN NUMBER +IS + CURSOR c_conp IS + SELECT count(*) + FROM cont_network_points + WHERE cont_id = p_contract_id; + -- + l_count NUMBER := 0; + -- +BEGIN + OPEN c_conp; + FETCH c_conp INTO l_count; + CLOSE c_conp; + RETURN l_count; +END nepo_count; + +PROCEDURE upd_cnppv_records( p_contract_id IN NUMBER + , p_page_no IN NUMBER DEFAULT 1 + , p_cnppv_id IN owa_util.vc_arr DEFAULT g_vc_arr + , p_value IN owa_util.vc_arr DEFAULT g_vc_arr ) +IS + -- Cursor used to find the appropriate Number Format for the given id/value pair + CURSOR c_cnppv( cp_cnppv_id IN NUMBER ) IS + SELECT cate.number_format num_format + ,cate.interuptible interruptible + ,cate.cate_id cate_id + ,cnppv.conp_id conp_id + FROM cont_net_point_param_vals cnppv + , contract_parameters copa + , parameters pars + , categories cate + WHERE cnppv.cnppv_id = cp_cnppv_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND pars.cate_id = cate.cate_id; + -- + -- Find the category parameter type (if it is one!) + CURSOR c_cate_par_type( cp_cnppv_id IN NUMBER ) IS + SELECT SUBSTR(pars.code,-3) code + FROM parameters pars + , contract_parameters copa + , cont_net_point_param_vals cnppv + WHERE cnppv.cnppv_id = cp_cnppv_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND pars.cate_id IS NOT NULL; + -- + -- Find if contract has Percentage Split parameter + CURSOR c_copa IS + SELECT copa.copa_id copa_id + FROM parameters pars + , contract_parameters copa + , contracts cont + WHERE cont.cont_id = p_contract_id + AND copa.cont_id = cont.cont_id + AND copa.pars_id = pars.pars_id + AND pars.name IN (g_perc_split_en, g_perc_split_hu); + -- + -- Find the Percentage Split total + CURSOR c_perc_split(cp_vnepo IN VARCHAR2) IS + SELECT NVL(SUM(cnppv.value),0) + FROM parameters pars + , contract_parameters copa + , cont_net_point_param_vals cnppv + , contracts cont + , cont_network_points conp + , network_points nepo + WHERE cont.cont_id = p_contract_id + AND copa.cont_id = cont.cont_id + AND cnppv.copa_id = copa.copa_id + AND copa.pars_id = pars.pars_id + AND cnppv.conp_id = conp.conp_id + AND conp.nepo_id = nepo.nepo_id + AND ((nepo.nepo_type IN ('N','X') AND cp_vnepo = 'N') OR + (nepo.nepo_type = 'V' AND cp_vnepo = 'Y')) + AND pars.name IN (g_perc_split_en, g_perc_split_hu); + -- + -- Find the Percentage Split values from cnppv table + CURSOR c_cnppv_per_split IS + SELECT cnppv.conp_id conp_id + , cnppv.value value + FROM parameters pars + , contract_parameters copa + , cont_net_point_param_vals cnppv + WHERE copa.cont_id = p_contract_id + AND copa.pars_id = pars.pars_id + AND copa.copa_id = cnppv.copa_id + AND pars.name IN (g_perc_split_en, g_perc_split_hu) + order by 1; + -- + l_number_format categories.number_format%TYPE; + l_cate_int categories.interuptible%TYPE; + l_cate_id categories.cate_id%TYPE; + l_conp_id cont_network_points.conp_id%TYPE; + l_current_type VARCHAR2(3) := NULL; + prev_valid_num BOOLEAN := TRUE; + prev2_valid_num BOOLEAN := TRUE; + curr_valid_num BOOLEAN := TRUE; + l_temp_number NUMBER := 0; + l_prev_value NUMBER := 0; + -- + l_array_length NUMBER := 0; + l_data_error owa_util.vc_arr; + -- + l_error_message VARCHAR2(400) := NULL; + l_success BOOLEAN := TRUE; + l_invalid_number BOOLEAN := FALSE; + l_invalid_format BOOLEAN := FALSE; + l_update_error BOOLEAN := FALSE; + l_negatives BOOLEAN := FALSE; + l_min_gt_max BOOLEAN := FALSE; + l_ctr_lt_min BOOLEAN := FALSE; + l_ctr_gt_max BOOLEAN := FALSE; + -- + l_copa_id NUMBER; + l_tot_per_split NUMBER := 0; + l_vnepo_per_split NUMBER := 0; + l_perc_split_array perc_split_array; + l_count NUMBER := 0; + recalc_noms BOOLEAN := FALSE; + -- + -- array to contain p_value array contents with no thousand separators + l_val_no_thou_sep owa_util.vc_arr; + -- + BEGIN + -- Check we have permission to be using this module. + -- Only called from the Create contracts screen + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + SAVEPOINT before_upd_cnppv; + -- + -- remove thousand separators from p_value array + -- + l_val_no_thou_sep := caco_utilities.thousand_separated_to_char(p_value); + -- Check that the number of values in the arrays is consistent + IF NVL(p_cnppv_id.COUNT,0) > 0 + AND NVL(l_val_no_thou_sep.COUNT,0) > 0 + AND NVL(p_cnppv_id.COUNT,0) = NVL(l_val_no_thou_sep.COUNT,0) + THEN + -- We are on good ground + l_array_length := p_cnppv_id.COUNT; + ELSE + -- + l_success := FALSE; + -- + IF NVL(p_cnppv_id.COUNT,0) = 0 + AND NVL(l_val_no_thou_sep.COUNT,0) = 0 + THEN + l_error_message := caco_utilities.get_module_text(2278); -- No Data passed to update routine + -- + ELSE + l_error_message := caco_utilities.get_module_text(2275); -- Mismatched Id and Value arrays. Check contract details before returning to this page + END IF; + -- + END IF; + -- Check if contract has Percentage Split parameter assigned to it + OPEN c_copa; + FETCH c_copa INTO l_copa_id; + CLOSE c_copa; + -- + IF l_copa_id IS NOT NULL THEN + -- put the current saved percentage split parameters into an array + OPEN c_cnppv_per_split; + FETCH c_cnppv_per_split BULK COLLECT INTO l_perc_split_array; + CLOSE c_cnppv_per_split; + -- + END IF; + -- + -- Lets check all the passed data; + IF l_success THEN + FOR i IN 1..l_array_length LOOP + -- + l_temp_number := 0; + l_number_format := NULL; + l_current_type := NULL; + prev2_valid_num := prev_valid_num; + prev_valid_num := curr_valid_num; + curr_valid_num := TRUE; + l_data_error(i) := 'N'; + -- + IF NVL(l_val_no_thou_sep(i),'#~^!$') != '#~^!$' THEN -- should this be IS NOT NULL + -- + OPEN c_cnppv( p_cnppv_id(i) ); + FETCH c_cnppv + INTO l_number_format + ,l_cate_int + ,l_cate_id + ,l_conp_id; + IF c_cnppv%FOUND THEN + -- we need to check that the entered value matches the number format found + BEGIN + SELECT TO_NUMBER(l_val_no_thou_sep(i),l_number_format) + INTO l_temp_number + FROM dual; + -- + -- Check to ensure that the data is gte zero + IF l_val_no_thou_sep(i) < 0 THEN + -- An error -- ALL values must be positive (including zero) + l_success := FALSE; + l_negatives := TRUE; + l_data_error(i) := 'Y'; + END IF; + -- + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_data_error(i) := 'Y'; + l_invalid_format := TRUE; + curr_valid_num := FALSE; + END; + -- + ELSE + -- Just ensure that the data is numeric + BEGIN + SELECT TO_NUMBER(l_val_no_thou_sep(i)) + INTO l_temp_number + FROM dual; + -- + -- Check to ensure that the data is gte zero + IF l_val_no_thou_sep(i) < 0 THEN + -- An error -- ALL values must be positive (or zero) + l_success := FALSE; + l_negatives := TRUE; + l_data_error(i) := 'Y'; + END IF; + -- + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_data_error(i) := 'Y'; + l_invalid_number := TRUE; + curr_valid_num := FALSE; + END; + -- + END IF; + CLOSE c_cnppv; + -- + ELSE + l_success := FALSE; + l_data_error(i) := 'Y'; + l_invalid_number := TRUE; + curr_valid_num := FALSE; + END IF; + -- + -- If numeric and correct format - ensure that max is greater than min + -- min is less than max and contracted is between the two. + -- Slightly easier than it sounds as we know that these three values are consecutive + -- we just need to know which one this is.... + -- We should only do the checks when we have found the CTR amount otherwise we wont know + -- if all the values are numeric... + -- Find out if we are a category parameter (dont check standalone parameters) + OPEN c_cate_par_type(p_cnppv_id(i)); + FETCH c_cate_par_type INTO l_current_type; + IF c_cate_par_type%FOUND THEN + IF l_current_type = 'CTR' THEN + -- lets check MIN, MAX and CTR are valid together. + IF prev_valid_num + AND prev2_valid_num + AND TO_NUMBER(l_val_no_thou_sep(i-2)) > TO_NUMBER(l_val_no_thou_sep(i-1)) + THEN + -- Min > Max + l_success := FALSE; + l_min_gt_max := TRUE; + l_data_error(i-2) := 'Y'; + l_data_error(i-1) := 'Y'; + END IF; + IF curr_valid_num + AND prev2_valid_num + AND TO_NUMBER(l_val_no_thou_sep(i)) < TO_NUMBER(l_val_no_thou_sep(i-2)) + THEN + -- CTR < MIN + l_success := FALSE; + l_ctr_lt_min := TRUE; + l_data_error(i) := 'Y'; + END IF; + IF curr_valid_num + AND prev_valid_num + AND TO_NUMBER(l_val_no_thou_sep(i)) > TO_NUMBER(l_val_no_thou_sep(i-1)) + THEN + -- CTR > MAX + l_success := FALSE; + l_ctr_gt_max := TRUE; + l_data_error(i) := 'Y'; + END IF; + END IF; + END IF; + CLOSE c_cate_par_type; + -- + -- If the above is ok and no previous error has been found - update the DB + IF l_success THEN + -- + BEGIN + -- + IF l_current_type = 'MAX' THEN + -- + -- If the current value is a maximum value, lookup the current value before updating + -- + SELECT value + INTO l_prev_value + FROM cont_net_point_param_vals cnppv + WHERE cnppv.cnppv_id = p_cnppv_id(i); + -- + END IF; + -- + UPDATE cont_net_point_param_vals + SET value = l_temp_number + WHERE cnppv_id = p_cnppv_id(i); + -- + EXCEPTION + WHEN others THEN + caco_debug.putline('efno_contracts.upd_cnppv_records : Failed Update - CNPPV_ID : ' + ||p_cnppv_id(i)||' : Value : '||l_val_no_thou_sep(i)); + l_success := FALSE; + l_update_error := TRUE; + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => sqlerrm(sqlcode) + , p_source => 'efno_contracts.upd_cnppv_records'); + -- + END; + -- + END IF; + -- + -- Addition to activate/deactive inty_conp_params + -- + IF l_success THEN + -- + -- Check that the contract is active and current + -- + IF contract_active(p_contract_id) THEN + -- + -- If we're looking at a maximum value + -- + IF l_current_type = 'MAX' THEN + -- + -- And the previous value was 0 and the new value isn't, or the + -- + IF (l_temp_number = 0 AND l_prev_value <> 0) + OR (l_prev_value = 0 AND l_temp_number <> 0) THEN + -- + -- And the category is classified as interruptible + -- + IF l_cate_int = 'Y' THEN + -- + -- Finally, check for an active interruption type + -- + FOR inty IN ( SELECT inty.inty_id + FROM interruption_types inty + WHERE inty.status = 'A' + AND inty.cate_id = l_cate_id + ) LOOP + -- + -- Now update/insert inty_conp_params + -- + /* -- problem with merge statement and table API + MERGE INTO inty_conp_params incp + USING (SELECT inty.inty_id inty_id + , l_conp_id conp_id + , 0 max_int + , 0 max_days + , 0 max_len + , DECODE(l_temp_number, 0, 'N', 'Y') flag + FROM DUAL) sq1 + ON ( incp.inty_id = sq1.inty_id + AND incp.conp_id = sq1.conp_id ) + WHEN MATCHED THEN + UPDATE SET incp.limits_enabled = sq1.flag + WHEN NOT MATCHED THEN + INSERT + (icp_id + ,inty_id + ,conp_id + ,max_interruptions + ,max_interruption_days + ,max_interruption_length + ,limits_enabled + ) + VALUES + ( icp_seq.NEXTVAL + , sq1.inty_id + , sq1.conp_id + , sq1.max_int + , sq1.max_days + , sq1.max_len + , sq1.flag + ) + WHERE DECODE(l_temp_number, 0, 'N', 'Y') = 'Y'; + */ + UPDATE inty_conp_params incp + SET incp.limits_enabled = DECODE(l_temp_number, 0, 'N', 'Y') + WHERE incp.inty_id = inty.inty_id + AND incp.conp_id = l_conp_id; + -- + IF SQL%NOTFOUND THEN + -- + INSERT INTO inty_conp_params incp + ( icp_id + , inty_id + , conp_id + , max_interruptions + , max_interruption_days + , max_interruption_length + , limits_enabled + ) + VALUES + ( icp_seq.NEXTVAL + , inty.inty_id + , l_conp_id + , 0 + , 0 + , 0 + , DECODE(l_temp_number, 0, 'N', 'Y') + ); + -- + END IF; + -- + END LOOP; + -- + END IF; -- category interruptable + -- + END IF; -- last number zero, new number not OR new number zero, last number not + -- + END IF; -- Maximum Value + -- + END IF; -- contract active + -- + END IF; -- if l_success + -- + END LOOP; + END IF; + -- + IF l_success THEN + -- + IF l_copa_id IS NOT NULL THEN + -- Validate Percentage Split values + -- get the percentage split of the virtual network point + OPEN c_perc_split('Y'); + FETCH c_perc_split INTO l_vnepo_per_split; + CLOSE c_perc_split; + -- + -- get the percentage split total of the network points + OPEN c_perc_split('N'); + FETCH c_perc_split INTO l_tot_per_split; + CLOSE c_perc_split; + -- + -- check that all of the network points are displayed on one page + IF nepo_count(p_contract_id) <= 25 THEN + IF l_vnepo_per_split <> l_tot_per_split THEN + -- + l_success := FALSE; + -- + l_error_message := caco_utilities.get_module_text(3924); + -- Percentage Split values of network points must add up to the Percentage Split value of the virtual network point + END IF; + ELSE + -- there are more than 25 network points so we have to be more lenient on the percentage + -- split validation as the network points are displayed on multiple pages + IF l_vnepo_per_split < l_tot_per_split THEN + -- + l_success := FALSE; + -- + l_error_message := caco_utilities.get_module_text(3915); + -- Percentage Split values of network points must add up to less than or equal to the Percentage Split value of the virtual network point + END IF; + END IF; + -- Check if the contract is an entry mandatory offer contract + IF l_success THEN + IF efno_contracts.emo_contract(p_contract_id) = 'Y' THEN + -- check if the percentage split values have changed + FOR i IN c_cnppv_per_split LOOP + l_count := l_count + 1; + caco_debug.putline('comparing '||i.value||' with '||l_perc_split_array(l_count).value); + IF i.value <> l_perc_split_array(l_count).value THEN + recalc_noms := TRUE; + EXIT; + END IF; + END LOOP; + IF recalc_noms THEN + -- recalculate any nominations for the contract which are before gate closure + caco_debug.putline('recalculating noms'); + l_success := recalc_emo_noms(p_contract_id, l_error_message); + END IF; + END IF; + END IF; + END IF; + END IF; + -- + IF l_success THEN + -- + -- Call the values screen with just the contract id and the success flag + efnow092$.contract_values_p2( p_contract_id => p_contract_id + , p_page_no => p_page_no + , p_success => 'Y' ); + -- + ELSE + ROLLBACK TO SAVEPOINT before_upd_cnppv; + -- + -- If the supplied values had invalid formats + IF l_error_message IS NULL THEN + IF l_update_error THEN + l_error_message := caco_utilities.get_module_text(2210); + -- An error occurred whilst updating the contract values. Please contact support stating Contract Number + END IF; + IF l_invalid_format THEN + l_error_message := l_error_message||' '||caco_utilities.get_module_text(2240)||'.'; -- Data supplied with invalid number formats + END IF; + IF l_invalid_number THEN + l_error_message := l_error_message||' '||caco_utilities.get_module_text(2289)||'.'; -- Non numeric data supplied + END IF; + IF l_min_gt_max THEN + l_error_message := l_error_message||' '||caco_utilities.get_module_text(2354)||'.'; -- Minimum greater than Maximum + END IF; + IF l_ctr_lt_min THEN + l_error_message := l_error_message||' '||caco_utilities.get_module_text(2355)||'.'; -- Contracted less than Minimum + END IF; + IF l_ctr_gt_max THEN + l_error_message := l_error_message||' '||caco_utilities.get_module_text(2356)||'.'; -- Contracted greater than Maximum + END IF; + IF l_negatives THEN + l_error_message := l_error_message||' '||caco_utilities.get_module_text(2357); -- All values must be zero or greater + END IF; + END IF; + -- + -- pass the data back... + efnow092$.contract_values_p2( p_contract_id => p_contract_id + , p_page_no => p_page_no + , p_error => 'Y' + , p_err_msg => l_error_message + , p_cnppv_id => p_cnppv_id + , p_value => l_val_no_thou_sep + , p_data_error => l_data_error ); + -- + END IF; + -- + -- +END upd_cnppv_records; + +PROCEDURE upd_cotc ( p_cote_id IN contract_templates.cote_id%TYPE + , p_cate_id IN categories.cate_id%TYPE + , p_display_sequence IN NUMBER + ) IS +BEGIN + -- + -- Update the template category + -- + UPDATE contract_template_categories ctc + SET ctc.display_sequence = p_display_sequence + WHERE ctc.cote_id = p_cote_id + AND ctc.cate_id = p_cate_id; + -- + -- Now update the related contract categories + -- + UPDATE contract_categories cc + SET cc.display_sequence = p_display_sequence + WHERE cc.cate_id = p_cate_id + AND cc.cont_id IN ( SELECT cont_id + FROM contracts c + WHERE c.cote_id = p_cote_id + ); + -- +END upd_cotc; + + + +-- Insert or Update Contract Rules inherited from a Contract Template +-- needs to be called immediately after insert of a new contract +-- or immediately before update of an existing contract +-- (otherwise the template id will already be changed!) +FUNCTION ins_or_upd_inh_rules( p_ins_or_upd IN VARCHAR2 + , p_contract_id IN NUMBER + , p_template_id IN NUMBER + , p_err_message OUT VARCHAR2 ) + RETURN BOOLEAN +IS + CURSOR c_cont IS + SELECT cote_id + FROM contracts + WHERE cont_id = p_contract_id; + -- + -- Cursor to list the inherited rules for the new contract template + CURSOR c_inh_rules IS + SELECT rule_id + , display_sequence + FROM contract_template_rules + WHERE cote_id = p_template_id; + -- + l_temp_cote_id contracts.cote_id%TYPE := NULL; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + -- + SAVEPOINT before_inh_rules; + -- + IF p_ins_or_upd = 'UPDATE' THEN + -- Firstly, lets check that the contract template has changed + -- if not - we have no work to do! + OPEN c_cont; + FETCH c_cont INTO l_temp_cote_id; + CLOSE c_cont; + -- + ELSE + -- Inserting - just set to zero + l_temp_cote_id := 0; + END IF; + -- + IF NVL(l_temp_cote_id,0) != NVL(p_template_id,0) THEN + -- + -- The Template has been changed + -- We need to remove the existing inherited contract rules + -- and add the new ones from the new contract template + IF p_ins_or_upd = 'UPDATE' + AND NVL(l_temp_cote_id,0) != 0 + THEN + -- If we are updating and the old template is not null then + -- we need to remove the existing inherited rules from contract_rules + BEGIN + DELETE contract_rules + WHERE cont_id = p_contract_id + AND NVL(inherited,'N') = 'Y'; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_err_message := caco_utilities.get_module_text(2293); -- Removal of old template inherited rules failed. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_inh_rules failed deleting inherited rules : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting inherited rules: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_inh_rules'); + -- + END; + -- + END IF; + -- + IF l_success THEN + -- We can insert the inherited rules + <> + FOR r IN c_inh_rules LOOP + -- + BEGIN + INSERT INTO contract_rules + ( coru_id + , display_sequence + , inherited + , cont_id + , coru_type + , rule_id ) + VALUES + ( coru_seq.NEXTVAL + , r.display_sequence + , 'Y' + , p_contract_id + , 'ROW' + , r.rule_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + caco_debug.putline('efno_contracts.ins_or_upd_inh_rules failed inserting inherited rules : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting inherited rules: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_inh_rules'); + -- + EXIT ins_inh_rules_loop; + END; + -- + END LOOP ins_inh_rules_loop; + -- + END IF; + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_inh_rules; + END IF; + -- + RETURN l_success; + -- +END ins_or_upd_inh_rules; + + + +FUNCTION del_conp_cnppv( p_conp_id IN cont_network_points.conp_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_del_cnppv; + -- + BEGIN + DELETE cont_net_point_param_vals + WHERE conp_id = p_conp_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2213); + -- An unexpected error has occurred while deleting contract network point. Please contact support + caco_debug.putline('efno_contracts.del_conp_cnppv : ' + ||'Delete of contract network point parameter values failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting cnppv: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_conp_cnppv'); + -- + END; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_del_cnppv; + END IF; + -- + RETURN l_success; + -- +END del_conp_cnppv; + +FUNCTION del_conp_icp( p_conp_id IN cont_network_points.conp_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + -- + SAVEPOINT before_del_icp; + -- + BEGIN + DELETE inty_conp_params + WHERE conp_id = p_conp_id; + EXCEPTION + WHEN OTHERS THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2213); + -- An unexpected error has occurred while deleting contract network point. Please contact support + caco_debug.putline('efno_contracts.del_conp_icp: ' + ||'Delete of interruption type contract network point parameter values failed : ' + ||SQLERRM(SQLCODE)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => SQLCODE + , p_exception_message => 'Failed deleting icp: '||SQLERRM(SQLCODE) + , p_source => 'efno_contracts.del_conp_icp'); + -- + END; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_del_icp; + END IF; + -- + RETURN l_success; + -- +END del_conp_icp; + + +FUNCTION ins_conp_cnppv( p_contract_id IN contracts.cont_id%TYPE + , p_conp_id IN cont_network_points.conp_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to list all parameters stored for this contract + CURSOR c_copa IS + SELECT copa_id + FROM contract_parameters + WHERE cont_id = p_contract_id; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_ins_cnppv; + -- + <> + FOR r IN c_copa LOOP + -- + BEGIN + INSERT INTO cont_net_point_param_vals + ( cnppv_id + , value + , conp_id + , copa_id ) + VALUES + ( cnppv_seq.NEXTVAL + , 0 + , p_conp_id + , r.copa_id ); + EXCEPTION + WHEN others THEN + ROLLBACK TO SAVEPOINT before_ins_cnppv; + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2215); + -- An unexpected error has occurred while inserting contract network point. Please contact support + caco_debug.putline('efno_contracts.ins_conp_cnppv : ' + ||'Insert of contract network point parameter values failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting cnppv: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_conp_cnppv'); + -- + EXIT ins_cnppv_loop; + END; + -- + END LOOP ins_cnppv_loop; + -- + RETURN l_success; + -- +END ins_conp_cnppv; + + + + + +FUNCTION insert_cont_nepo( p_contract_id IN contracts.cont_id%TYPE + , p_network_point_array IN network_point_array + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_conp_id cont_network_points.conp_id%TYPE := 0; + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_ins_cont_nepo; + -- + <> + FOR i IN 1..p_network_point_array.COUNT LOOP + -- + BEGIN + INSERT INTO cont_network_points + ( conp_id + , display_sequence + , nepo_id + , cont_id ) + VALUES + ( conp_seq.NEXTVAL + , ( SELECT NVL(MAX(display_sequence),0)+10 + FROM cont_network_points + WHERE cont_id = p_contract_id ) + , p_network_point_array(i) + , p_contract_id ) + RETURNING conp_id INTO l_conp_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2327); + -- An unexpected error has occurred while inserting new contract. Please contact support + caco_debug.putline('efno_contracts.insert_cont_nepo : ' + ||'Insert of new contract network points failed : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting new CONP: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.insert_conp_nepo'); + -- + ROLLBACK TO SAVEPOINT before_ins_cont_nepo; + EXIT ins_net_point_loop; + END; + -- + l_success := ins_conp_cnppv( p_contract_id + , l_conp_id + , p_return_error ); + IF NOT l_success THEN + EXIT ins_net_point_loop; + END IF; + -- + END LOOP ins_net_point_loop; + -- + -- Invalidate any interruption types related to this contract +-- IF p_network_point_array.COUNT > 0 THEN + -- +-- l_success := invalidate_inty(p_contract_id); + -- +-- END IF; -- removed as part of INT027 + RETURN l_success; + -- +END insert_cont_nepo; + + + + +FUNCTION ins_copa_cnppv( p_contract_id IN contracts.cont_id%TYPE + , p_copa_id IN contract_parameters.copa_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to loop through all network points for the given contract + CURSOR c_conp IS + SELECT conp_id + FROM cont_network_points + WHERE cont_id = p_contract_id; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_ins_cnppv; + -- + <> + FOR r IN c_conp LOOP + -- + BEGIN + INSERT INTO cont_net_point_param_vals + ( cnppv_id + , value + , conp_id + , copa_id ) + VALUES + ( cnppv_seq.NEXTVAL + , 0 + , r.conp_id + , p_copa_id ); + EXCEPTION + WHEN others THEN + ROLLBACK TO SAVEPOINT before_ins_cnppv; + caco_debug.putline('efno_contracts.ins_copa_cnppv failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting cnppv: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_copa_cnppv'); + -- + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2265); + -- Inserting Contract values failed. Please contact support + EXIT ins_cnppv_loop; + END; + -- + END LOOP ins_cnppv_loop; + -- + RETURN l_success; + -- +END ins_copa_cnppv; + + + + +FUNCTION ins_contract_pars( p_contract_id IN contracts.cont_id%TYPE + , p_pars_id IN parameters.pars_id%TYPE + , p_inherited IN VARCHAR2 + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_copa_id contract_parameters.copa_id%TYPE := 0; + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_ins_cont_pars; + -- + BEGIN + INSERT INTO contract_parameters + ( copa_id + , inherited + , display_sequence + , cont_id + , pars_id ) + VALUES + ( copa_seq.NEXTVAL + , p_inherited + , 0 -- parameters are not inherited from a category + , p_contract_id + , p_pars_id ) + RETURNING copa_id INTO l_copa_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2216); + -- An unexpected error has occurred while inserting contract parameter. Please contact support + caco_debug.putline('efno_contracts.ins_contract_pars: ' + ||'Insert of contract parameter failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting contract parameters: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_contract_pars'); + -- + END; + -- + IF l_success THEN + -- insert the relevant contract network point parameter values + l_success := ins_copa_cnppv( p_contract_id + , l_copa_id + , p_return_error ); + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_ins_cont_pars; + END IF; + -- + RETURN l_success; + -- +END ins_contract_pars; + + + + +FUNCTION upd_contract_cate( p_contract_id IN contracts.cont_id%TYPE + , p_cate_id IN categories.cate_id%TYPE + , p_inherited IN VARCHAR2 + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_upd_cont_cate; + -- + -- But if the category DOES exist - make sure it is correctly inherited + BEGIN + UPDATE contract_categories coca + SET inherited = p_inherited + WHERE cont_id = p_contract_id + AND cate_id = p_cate_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2221); + -- An unexpected error has occurred while updating contract category. Please contact support + caco_debug.putline('efno_contracts.upd_contract_cae: ' + ||'Update of contract category failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed updating contract categories: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.upd_contract_cate'); + -- + END; + -- + IF l_success THEN + -- Also check the parameters.... + BEGIN + UPDATE contract_parameters copa + SET inherited = p_inherited + WHERE cont_id = p_contract_id + AND copa.copa_id IN ( SELECT copa2.copa_id + FROM contract_parameters copa2 + , parameters pars + WHERE copa2.pars_id = pars.pars_id + AND copa2.cont_id = p_contract_id + AND pars.cate_id = p_cate_id + ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2221); + -- An unexpected error has occurred while updating contract category. Please contact support + caco_debug.putline('efno_contracts.upd_contract_cate: ' + ||'Update of contract category failed (updating parameters): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed updating contract category related parameters: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.upd_contract_cate'); + -- + END; + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_upd_cont_cate; + END IF; + -- + RETURN l_success; + -- +END upd_contract_cate; + + + + + + +FUNCTION del_contract_cate( p_contract_id IN contracts.cont_id%TYPE + , p_cate_id IN categories.cate_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_del_cont_cate; + -- + -- Delete contract parameter values for this category + BEGIN + DELETE cont_net_point_param_vals cnppv + WHERE cnppv.copa_id IN ( SELECT copa.copa_id + FROM contract_parameters copa + , parameters pars + WHERE copa.cont_id = p_contract_id + AND copa.pars_id = pars.pars_id + AND pars.cate_id = p_cate_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.del_contract_cate: ' + ||'Update of contract category failed ' + ||'(deleting associated parameter values) : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting cnppv: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_contract_cate'); + -- + END; + -- + IF l_success THEN + -- Delete contract parameters inherited from this category + BEGIN + DELETE contract_parameters copa + WHERE copa.cont_id = p_contract_id + AND copa.pars_id IN ( SELECT pars.pars_id + FROM parameters pars + WHERE pars.cate_id = p_cate_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.del_contract_cate: ' + ||'Update of contract category failed ' + ||'(deleting associated parameters) : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting COPA: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_contract_cate'); + -- + END; + END IF; + -- + IF l_success THEN + -- Delete the given contract category + BEGIN + DELETE contract_categories + WHERE cont_id = p_contract_id + AND cate_id = p_cate_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.del_contract_cate: ' + ||'Update of contract category failed (deleting category): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting COCA: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_contract_cate'); + -- + END; + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_del_cont_cate; + END IF; + -- + RETURN l_success; + -- +END del_contract_cate; + + + + + + +FUNCTION ins_contract_cate( p_contract_id IN contracts.cont_id%TYPE + , p_cate_id IN categories.cate_id%TYPE + , p_display_sequence IN categories.display_sequence%TYPE DEFAULT NULL + , p_inherited IN VARCHAR2 + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to get associated parameters for INSERTed categories + CURSOR c_cate_pars IS + SELECT pars.pars_id pars_id + , cate.display_sequence display_sequence + FROM parameters pars + , categories cate + WHERE pars.cate_id = p_cate_id + AND pars.cate_id = cate.cate_id; + -- + l_copa_id contract_parameters.copa_id%TYPE := 0; + l_success BOOLEAN := TRUE; + -- + BEGIN + -- + SAVEPOINT before_ins_cont_cate; + -- + BEGIN + IF p_display_sequence IS NULL THEN + INSERT INTO contract_categories + ( coca_id + , inherited + , display_sequence + , cont_id + , cate_id ) + VALUES + ( coca_seq.NEXTVAL + , p_inherited + , ( SELECT cate.display_sequence + FROM categories cate + WHERE cate.cate_id = p_cate_id ) + , p_contract_id + , p_cate_id ); + ELSE + INSERT INTO contract_categories + ( coca_id + , inherited + , display_sequence + , cont_id + , cate_id ) + VALUES + ( coca_seq.NEXTVAL + , p_inherited + , p_display_sequence + , p_contract_id + , p_cate_id ); + END IF; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2214); + -- An unexpected error has occurred while inserting contract category. Please contact support + caco_debug.putline('efno_contracts.ins_contract_cate: ' + ||'Insert of contract category failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting COCA: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_contract_cate'); + -- + END; + -- + -- We also need to insert any parameters associated with this category + IF l_success THEN + -- + <> + FOR r IN c_cate_pars LOOP + -- + l_copa_id := 0; + -- + BEGIN + INSERT INTO contract_parameters + ( copa_id + , display_sequence + , inherited + , cont_id + , pars_id ) + VALUES + ( copa_seq.NEXTVAL + , r.display_sequence + , p_inherited + , p_contract_id + , r.pars_id ) + RETURNING copa_id INTO l_copa_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2214); + -- An unexpected error has occurred while inserting contract category. Please contact support + caco_debug.putline('efno_contracts.ins_contract_cate: ' + ||'Update of contract category associated parameters failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting COCA associated COPA'||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_contract_cate'); + -- + EXIT cont_cate_loop; + END; + -- + IF l_success THEN + -- insert the relevant contract network point parameter values + l_success := ins_copa_cnppv( p_contract_id + , l_copa_id + , p_return_error ); + -- + IF NOT l_success THEN + EXIT cont_cate_loop; + END IF; + -- + END IF; + -- + END LOOP cont_cate_loop; -- end of inserting associated parameters + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_ins_cont_cate; + END IF; + -- + RETURN l_success; + -- +END ins_contract_cate; + + + + +-- For Updating Contract Network Points - to enable delete of those no longer attached +FUNCTION nepo_in_array( p_id IN NUMBER + , p_nepo_array IN network_point_array ) + RETURN BOOLEAN +IS + l_success BOOLEAN := FALSE; +BEGIN + IF NVL(p_nepo_array.COUNT,0) > 0 THEN + FOR i IN p_nepo_array.FIRST..p_nepo_array.LAST LOOP + IF p_nepo_array(i) = p_id THEN + l_success := TRUE; + END IF; + END LOOP; + END IF; + RETURN l_success; +END nepo_in_array; + + + + + +-- +-- For Updating Contract Network Points - to determine if we need to insert into DB +FUNCTION nepo_in_db( p_nepo_id IN NUMBER + , p_contract_id IN NUMBER ) + RETURN BOOLEAN +IS + CURSOR c_nepo IS + SELECT 'Y' + FROM cont_network_points + WHERE cont_id = p_contract_id + AND nepo_id = p_nepo_id; + -- + l_success BOOLEAN := FALSE; + l_dummy VARCHAR2(1) := 'X'; + -- +BEGIN + OPEN c_nepo; + FETCH c_nepo INTO l_dummy; + IF c_nepo%FOUND THEN + l_success := TRUE; + END IF; + CLOSE c_nepo; + RETURN l_success; +END nepo_in_db; + + + + + +-- +-- For Updating Contract Categories - to enable delete of those no longer attached +FUNCTION coca_in_array( p_id IN NUMBER + , p_cate_array IN category_array ) + RETURN BOOLEAN +IS + l_success BOOLEAN := FALSE; +BEGIN + IF NVL(p_cate_array.COUNT,0) > 0 THEN + FOR i IN p_cate_array.FIRST..p_cate_array.LAST LOOP + IF p_cate_array(i).cate_id = p_id THEN + l_success := TRUE; + END IF; + END LOOP; + END IF; + RETURN l_success; +END coca_in_array; + + + + + +-- +-- Function to check if an virtual network point exists in an array of nepo_ids +FUNCTION vnepo_count( p_network_point_array IN network_point_array ) + RETURN NUMBER +IS + -- + CURSOR c_vnepo(cp_nepo_id network_points.nepo_id%TYPE) IS + SELECT nepo.nepo_type + FROM network_points nepo + WHERE nepo_id = cp_nepo_id; + -- + l_count NUMBER := 0; + l_nepo_type network_points.nepo_type%TYPE; + -- +BEGIN + FOR i IN 1..p_network_point_array.COUNT LOOP + OPEN c_vnepo(p_network_point_array(i)); + FETCH c_vnepo INTO l_nepo_type; + CLOSE c_vnepo; + -- + IF l_nepo_type = 'V' THEN + l_count := l_count + 1; + END IF; + -- + END LOOP; + RETURN l_count; +END vnepo_count; + +-- +-- Function to check if a template is an Entry Mandatory Offer template +FUNCTION emo_template( p_template_id IN NUMBER ) + RETURN BOOLEAN +IS + -- + CURSOR c_emo IS + SELECT cote.entry_mandatory_offer + FROM contract_templates cote + WHERE cote_id = p_template_id; + -- + l_return BOOLEAN := FALSE; + l_emo contract_templates.entry_mandatory_offer%TYPE; + -- +BEGIN + OPEN c_emo; + FETCH c_emo INTO l_emo; + CLOSE c_emo; + -- + IF l_emo = 'Y' THEN + l_return := TRUE; + END IF; + -- + RETURN l_return; +END emo_template; + +-- Function to check if a contract is an Entry Mandatory Offer contract +FUNCTION emo_contract( p_contract_id IN NUMBER ) + RETURN VARCHAR2 +IS + -- + CURSOR c_emo IS + SELECT cote.entry_mandatory_offer + FROM contract_templates cote + ,contracts cont + WHERE cote.cote_id = cont.cote_id + AND cont.cont_id = p_contract_id; + -- + l_return VARCHAR2(1) := 'N'; + l_emo contract_templates.entry_mandatory_offer%TYPE; + -- +BEGIN + OPEN c_emo; + FETCH c_emo INTO l_emo; + CLOSE c_emo; + -- + IF l_emo = 'Y' THEN + l_return := 'Y'; + END IF; + -- + RETURN l_return; +END emo_contract; + +-- Function to check if a contract network point is a virtual network point +FUNCTION virtual_nepo( p_conp_id IN NUMBER ) + RETURN BOOLEAN +IS + -- + CURSOR c_nepo IS + SELECT nepo.nepo_type + FROM network_points nepo + ,cont_network_points conp + WHERE nepo.nepo_id = conp.nepo_id + AND conp.conp_id = p_conp_id; + -- + l_return BOOLEAN := FALSE; + l_nepo_type network_points.nepo_type%TYPE; + -- +BEGIN + OPEN c_nepo; + FETCH c_nepo INTO l_nepo_type; + CLOSE c_nepo; + -- + IF l_nepo_type = 'V' THEN + l_return := TRUE; + END IF; + -- + RETURN l_return; +END virtual_nepo; + + +/** +-- FUNCTION nepo_in_contract +-- +-- Determines whether a given network point ID is being used in a contract +-- +-- used in EFNOW030 - maintain network points +-- +-- %param p_nepo_id The unique identifier for a network point +-- +-- %return BOOLEAN Indicates whether the network point is being used +*/ +FUNCTION nepo_in_contract ( p_nepo_id IN network_points.nepo_id%TYPE ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- +BEGIN + -- + FOR cont IN ( SELECT NULL + FROM cont_network_points conp, + network_points nepo + WHERE conp.nepo_id = nepo.nepo_id + AND nepo.nepo_id = p_nepo_id ) LOOP + -- + l_return := TRUE; + -- + END LOOP; + -- + RETURN l_return; + -- +END nepo_in_contract; + +-- +-- For Updating Contract Categories - to determine if we need to insert into DB +FUNCTION coca_in_db( p_cate_id IN NUMBER + , p_contract_id IN NUMBER ) + RETURN BOOLEAN +IS + CURSOR c_coca IS + SELECT 'Y' + FROM contract_categories + WHERE cont_id = p_contract_id + AND cate_id = p_cate_id; + -- + l_success BOOLEAN := FALSE; + l_dummy VARCHAR2(1) := 'X'; + -- +BEGIN + OPEN c_coca; + FETCH c_coca INTO l_dummy; + IF c_coca%FOUND THEN + l_success := TRUE; + END IF; + CLOSE c_coca; + RETURN l_success; +END coca_in_db; + + + + + + + + +-- For Updating Contract Parameters - to enable delete of those no longer attached +FUNCTION copa_in_array( p_id IN NUMBER + , p_pars_array IN parameter_array ) + RETURN BOOLEAN +IS + l_success BOOLEAN := FALSE; +BEGIN + IF NVL(p_pars_array.COUNT,0) > 0 THEN + FOR i IN p_pars_array.FIRST..p_pars_array.LAST LOOP + IF p_pars_array(i).pars_id = p_id THEN + l_success := TRUE; + END IF; + END LOOP; + END IF; + RETURN l_success; +END copa_in_array; + + + + +-- For Updating Contract Parameters - to determine if we need to insert into DB +-- Note: We are relying on the contract screen to only show those parameters +-- that are NOT associated with categories +FUNCTION copa_in_db( p_pars_id IN NUMBER + , p_contract_id IN NUMBER ) + RETURN BOOLEAN +IS + CURSOR c_copa IS + SELECT 'Y' + FROM contract_parameters + WHERE cont_id = p_contract_id + AND pars_id = p_pars_id; + -- + l_success BOOLEAN := FALSE; + l_dummy VARCHAR2(1) := 'X'; + -- +BEGIN + OPEN c_copa; + FETCH c_copa INTO l_dummy; + IF c_copa%FOUND THEN + l_success := TRUE; + END IF; + CLOSE c_copa; + RETURN l_success; +END copa_in_db; + + + + + + + +PROCEDURE del_redundant_nepo( p_contract_id IN contracts.cont_id%TYPE + , p_network_point_array IN network_point_array + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) +IS + -- + l_dummy NUMBER := 0; + -- + CURSOR c_cont_nepo( cp_cont_id IN NUMBER) IS + SELECT nepo_id + , conp_id + FROM cont_network_points + WHERE cont_id = cp_cont_id + FOR UPDATE; + -- +BEGIN + p_success := TRUE; + -- + <> + FOR r IN c_cont_nepo( p_contract_id ) LOOP + -- + IF NOT nepo_in_array( r.nepo_id + , p_network_point_array ) + THEN + -- + -- This network point doesn't exist in the new set, needs to be removed if possible + -- Check for any nominations for this network point + -- + SELECT COUNT(*) + INTO l_dummy + FROM nom_net_point_cat_vals n + WHERE n.conp_id = r.conp_id; + -- + IF l_dummy > 0 THEN + -- + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2520); -- a nomination exists + -- + EXIT upd_del_net_point_loop; + -- + END IF; + -- + -- Check for any interruptions for this network point + -- + SELECT COUNT(*) + INTO l_dummy + FROM int_conp_coca_vals iccv + WHERE iccv.conp_id = r.conp_id; + -- + IF l_dummy > 0 THEN + -- + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(3857); -- an interruption exists + -- + EXIT upd_del_net_point_loop; + -- + END IF; + -- + -- delete the associated CNPPV records + -- + p_success := del_conp_cnppv( r.conp_id + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_del_net_point_loop; + END IF; + -- + -- Remove any interruption types + -- + p_success := del_conp_icp( r.conp_id + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_del_net_point_loop; + END IF; + -- + -- Finally, remove the conp record + -- + BEGIN + DELETE cont_network_points + WHERE CURRENT OF c_cont_nepo; + EXCEPTION + WHEN others THEN + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'Update of contract network points failed (delete): '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting CONP: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_redundant_nepo'); + -- + EXIT upd_del_net_point_loop; + END; + END IF; + -- + END LOOP upd_del_net_point_loop; + -- +END del_redundant_nepo; + + + + + +PROCEDURE ins_required_nepo( p_contract_id IN contracts.cont_id%TYPE + , p_network_point_array IN network_point_array + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) +IS + l_conp_id cont_network_points.conp_id%TYPE; +BEGIN + SAVEPOINT before_ins_nepo; + -- + p_success := TRUE; + -- + <> + FOR i IN 1..p_network_point_array.COUNT LOOP + -- + IF NOT nepo_in_db( p_network_point_array(i) + , p_contract_id ) + THEN + l_conp_id := 0; + -- + BEGIN + INSERT INTO cont_network_points + ( conp_id + , display_sequence + , nepo_id + , cont_id ) + VALUES + ( conp_seq.NEXTVAL + , ( SELECT NVL(MAX(display_sequence),0)+10 + FROM cont_network_points + WHERE cont_id = p_contract_id ) + , p_network_point_array(i) + , p_contract_id ) + RETURNING conp_id INTO l_conp_id; + EXCEPTION + WHEN others THEN + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'Update of contract network points failed (insert): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting CONP: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_required_nepov'); + -- + ROLLBACK TO SAVEPOINT before_ins_nepo; + EXIT upd_ins_net_point_loop; + END; + -- + -- Now insert the relevant CNPPV records + p_success := ins_conp_cnppv( p_contract_id + , l_conp_id + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_ins_net_point_loop; + END IF; + -- + END IF; + -- + END LOOP upd_ins_net_point_loop; + -- + -- Invalidate any interruption types related to this contract +-- IF p_network_point_array.COUNT > 0 THEN + -- +-- p_success := invalidate_inty(p_contract_id); + -- +-- END IF; -- INT027 + -- +END ins_required_nepo; + + + + + + +PROCEDURE del_redundant_cate( p_contract_id IN contracts.cont_id%TYPE + , p_category_array IN category_array + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) +IS + -- + CURSOR c_cont_cate( cp_cont_id IN NUMBER ) IS + SELECT cate_id + FROM contract_categories + WHERE cont_id = cp_cont_id + FOR UPDATE; + -- +BEGIN + p_success := TRUE; + -- + <> + FOR r IN c_cont_cate( p_contract_id ) LOOP + -- + IF NOT coca_in_array( r.cate_id + , p_category_array ) + THEN + -- This Category doesn't exist in the new set + p_success := del_contract_cate( p_contract_id + , r.cate_id + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_del_coca_loop; + END IF; + -- + END IF; + -- + END LOOP upd_del_coca_loop; + -- +END del_redundant_cate; + + + + + +PROCEDURE ins_required_cate( p_contract_id IN contracts.cont_id%TYPE + , p_template_id IN contract_templates.cote_id%TYPE + , p_category_array IN category_array + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) +IS + -- + CURSOR c_cotc( cp_cote_id IN NUMBER + , cp_cate_id IN NUMBER ) IS + SELECT 'Y' + FROM contract_template_categories + WHERE cote_id = cp_cote_id + AND cate_id = cp_cate_id; + -- + l_inherited VARCHAR2(1) := 'N'; + -- +BEGIN + p_success := TRUE; + -- + <> + FOR i IN 1..p_category_array.COUNT LOOP + -- + l_inherited := 'N'; + -- Test if this category was inherited + OPEN c_cotc( p_template_id, p_category_array(i).cate_id ); + FETCH c_cotc INTO l_inherited; + CLOSE c_cotc; + -- + IF NOT coca_in_db( p_category_array(i).cate_id + , p_contract_id ) + THEN + -- + -- Current category does not exist in the DB so we need to INSERT + p_success := ins_contract_cate( p_contract_id + , p_category_array(i).cate_id + , NULL + , l_inherited + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_ins_coca_loop; + END IF; + -- + ELSE + -- But if the category DOES exist - make sure it is correctly inherited + p_success := upd_contract_cate( p_contract_id + , p_category_array(i).cate_id + , l_inherited + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_ins_coca_loop; + END IF; + -- + END IF; -- end of if contract category not already in DB + END LOOP upd_ins_coca_loop; + -- +END ins_required_cate; + + + + + +PROCEDURE del_redundant_pars( p_contract_id IN contracts.cont_id%TYPE + , p_parameter_array IN parameter_array + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) +IS + -- + CURSOR c_cont_pars( cp_cont_id IN NUMBER ) IS + SELECT copa.pars_id pars_id + , copa.copa_id copa_id + FROM contract_parameters copa + , parameters pars + WHERE copa.pars_id = pars.pars_id + AND copa.cont_id = cp_cont_id + AND pars.cate_id IS NULL; + -- +BEGIN + SAVEPOINT before_del_pars; + p_success := TRUE; + -- + <> + FOR r IN c_cont_pars( p_contract_id ) LOOP + -- + IF NOT copa_in_array( r.pars_id + , p_parameter_array ) + THEN + -- This Parameter doesn't exist in the new set + -- We need to delete the parameter after deleting the contract net point param values + -- can use WHERE CURRENT OF cursor for deleting the COPA + BEGIN + DELETE cont_net_point_param_vals + WHERE copa_id = r.copa_id; + -- + DELETE contract_parameters + WHERE copa_id = r.copa_id; + EXCEPTION + WHEN others THEN + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'Update of contract parameters failed (deleting parameter): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting CNPPV or COPA: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_redundant_pars'); + -- + ROLLBACK TO SAVEPOINT before_del_pars; + EXIT upd_del_copa_loop; + END; + -- + END IF; -- end when the parameter has been removed from the contract + -- + END LOOP upd_del_copa_loop; + -- +END del_redundant_pars; + + + +PROCEDURE ins_required_pars( p_contract_id IN contracts.cont_id%TYPE + , p_template_id IN contract_templates.cote_id%TYPE + , p_parameter_array IN parameter_array + , p_success OUT BOOLEAN + , p_return_error OUT VARCHAR2 ) +IS + -- + CURSOR c_cotp( cp_cote_id IN NUMBER + , cp_pars_id IN NUMBER ) IS + SELECT 'Y' + FROM contract_template_params + WHERE cote_id = cp_cote_id + AND pars_id = cp_pars_id; + -- + l_inherited VARCHAR2(1) := 'N'; +BEGIN + SAVEPOINT before_ins_pars; + -- + p_success := TRUE; + -- + <> + FOR i IN 1..p_parameter_array.COUNT LOOP + -- + l_inherited := 'N'; + -- Test if this parameter was inherited + OPEN c_cotp( p_template_id, p_parameter_array(i).pars_id ); + FETCH c_cotp INTO l_inherited; + CLOSE c_cotp; + -- + IF NOT copa_in_db( p_parameter_array(i).pars_id + , p_contract_id ) + THEN + -- Current Parameter does not exist in the DB so we need to INSERT + p_success := ins_contract_pars( p_contract_id + , p_parameter_array(i).pars_id + , l_inherited + , p_return_error ); + -- + IF NOT p_success THEN + EXIT upd_ins_copa_loop; + END IF; + -- + ELSE + -- But if the parameter DOES exist - make sure it has the correct contract template id + -- in case there has been a change of contract template.... + BEGIN + UPDATE contract_parameters + SET inherited = l_inherited + WHERE cont_id = p_contract_id + AND pars_id = p_parameter_array(i).pars_id; + EXCEPTION + WHEN others THEN + p_success := FALSE; + p_return_error := caco_utilities.get_module_text(2222); + -- An unexpected error has occurred while updating contract parameters. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'Update of contract parameters failed (update): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting COPA: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_required_pars'); + -- + ROLLBACK TO SAVEPOINT before_ins_pars; + EXIT upd_ins_copa_loop; + END; + -- + END IF; -- end of parameter doesnt exist in DB + END LOOP upd_ins_copa_loop; + -- +END ins_required_pars; + + +PROCEDURE ins_or_upd_cont_opt(p_cont_id IN contract_options.cont_id%TYPE, + p_ind_deadline_for_nom_submit IN contract_options.ind_deadline_for_nom_submit%TYPE, + p_shipper IN contract_options.shipper%TYPE, + p_auto_gen_conf IN contract_options.auto_gen_conf%TYPE, + p_conf_type IN contract_options.conf_type%TYPE, + p_com_conf_subject IN contract_options.com_conf_subject%TYPE, + p_com_conf_content IN contract_options.com_conf_content%TYPE, + p_nom_conf_subject IN contract_options.nom_conf_subject%TYPE, + p_nom_conf_content IN contract_options.nom_conf_content%TYPE, + p_ind_deadline_hr IN contract_options.ind_deadline_for_nom_submit%TYPE, + p_ind_deadline_mi IN contract_options.ind_deadline_for_nom_submit%TYPE, + p_int_subject IN contract_options.int_subject%TYPE, + p_int_content IN contract_options.int_content%TYPE, + p_int_sms_content IN contract_options.int_sms_content%TYPE) IS + -- + l_error VARCHAR2(1); + l_return_error VARCHAR2(250); -- If the insert or update fails - put an error message in here. + l_success BOOLEAN := TRUE; -- Used to track how well we are doing in this code.. + l_success_char VARCHAR2(1) := NULL; + l_contract_exists VARCHAR2(1) := 'N'; + l_conf_type_found BOOLEAN := FALSE; + -- + l_cont_id contract_options.cont_id%TYPE; + l_ind_deadline_for_nom_submit contract_options.ind_deadline_for_nom_submit%TYPE; + l_shipper contract_options.shipper%TYPE; + l_auto_gen_conf contract_options.auto_gen_conf%TYPE; --not null + l_conf_type contract_options.conf_type%TYPE; --not null + l_com_conf_subject contract_options.com_conf_subject%TYPE; --not null + l_com_conf_content contract_options.com_conf_content%TYPE; --not null + l_nom_conf_subject contract_options.nom_conf_subject%TYPE; --not null + l_nom_conf_content contract_options.nom_conf_content%TYPE; --not null + 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_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; + -- + CURSOR c_cont(cp_contract_id IN NUMBER) IS + SELECT 'Y' FROM contract_options WHERE cont_id = cp_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; +BEGIN + -- Check we have permission to be using this module. + -- Only called from the Create contracts screen + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- Validation + -- Valid Contract ID + OPEN c_cont(p_cont_id); + FETCH c_cont + INTO l_contract_exists; + CLOSE c_cont; + IF l_contract_exists != 'Y' THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3969); + -- Data is not linked to a valid contract number. Please contact support + END IF; + -- + IF l_success THEN + l_cont_id := p_cont_id; + l_ind_deadline_for_nom_submit := p_ind_deadline_for_nom_submit; + l_shipper := p_shipper; + l_auto_gen_conf := p_auto_gen_conf; + l_conf_type := p_conf_type; + l_com_conf_subject := TRIM(p_com_conf_subject); + l_com_conf_content := TRIM(p_com_conf_content); + l_nom_conf_subject := TRIM(p_nom_conf_subject); + l_nom_conf_content := TRIM(p_nom_conf_content); + l_ind_deadline_hr := TRIM(p_ind_deadline_hr); + l_ind_deadline_mi := TRIM(p_ind_deadline_mi); + l_int_subject := p_int_subject; + l_int_content := p_int_content; + l_int_sms_content := p_int_sms_content; + END IF; + -- + -- Mandatory Fields + -- + --Auto Generate Confirm - must be Y or N + IF l_auto_gen_conf != 'Y' + AND l_auto_gen_conf != 'N' + AND l_success THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3970); + -- Auto Generate Confirm is a mandatory field + END IF; + --Confirmation Type - is it in the list? + IF l_success THEN + FOR r IN c_conf_type LOOP + IF r.rv_low_value = l_conf_type THEN + l_conf_type_found := TRUE; + END IF; + END LOOP; + IF NOT l_conf_type_found THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3971); + -- Confirmation Format is a mandatory field + END IF; + END IF; + --Com Confirmation Subject + IF (l_com_conf_subject IS NULL OR l_com_conf_subject = '') + AND l_success THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3972); + -- Com Confirmation Subject is a mandatory field + END IF; + --Com Confirmation Content + IF (l_com_conf_content IS NULL OR l_com_conf_content = '') + AND l_success THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3973); + -- Com Confirmation Content is a mandatory field + END IF; + --Nom Confirmation Subject + IF (l_nom_conf_subject IS NULL OR l_nom_conf_subject = '') + AND l_success THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3974); + -- Nom Confirmation Subject is a mandatory field + END IF; + --Nom Confirmation Content + IF (l_nom_conf_content IS NULL OR l_nom_conf_content = '') + AND l_success THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3975); + -- Nom Confirmation Content is a mandatory field + END IF; + -- + -- Making sense of the Ind Sub Deadline + IF l_success THEN + IF length(l_ind_deadline_hr) = 2 + AND length(l_ind_deadline_mi) = 2 THEN + l_ind_deadline_for_nom_submit := l_ind_deadline_hr || ':' || + l_ind_deadline_mi; + ELSIF length(l_ind_deadline_hr) < 2 + AND length(l_ind_deadline_mi) = 2 THEN + l_ind_deadline_for_nom_submit := '00:' || l_ind_deadline_mi; + ELSIF length(l_ind_deadline_hr) = 2 + AND length(l_ind_deadline_mi) < 2 THEN + l_ind_deadline_for_nom_submit := l_ind_deadline_hr || ':00'; + ELSE + l_ind_deadline_for_nom_submit := ''; + END IF; + END IF; + -- + -- If we are happy and we know it update the table + IF l_success THEN + BEGIN + UPDATE contract_options + SET nom_conf_subject = l_nom_conf_subject, + nom_conf_content = l_nom_conf_content, + com_conf_subject = l_com_conf_subject, + com_conf_content = l_com_conf_content, + auto_gen_conf = l_auto_gen_conf, + conf_type = l_conf_type, + ind_deadline_for_nom_submit = l_ind_deadline_for_nom_submit, + shipper = l_shipper, + int_subject = l_int_subject, + int_content = l_int_content, + int_sms_content = l_int_sms_content + WHERE cont_id = l_cont_id; + EXCEPTION + WHEN OTHERS THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3976); + -- An unexpected error has occurred while updating contract options. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' || + 'Insert of new contract failed : ' || + SQLERRM(SQLCODE)); + -- Write an error and carry on + cout_err.report_and_go(p_exception_number => SQLCODE, + p_exception_message => 'Failed updating contract options: ' || + SQLERRM(SQLCODE), + p_source => 'efno_contracts.ins_or_upd_cont_opt'); + -- + END; + IF l_success THEN + -- Commit the changes + COMMIT; + -- + l_success_char := 'Y'; + l_error := NULL; + l_return_error := NULL; + -- + ELSE + -- Failed somewhere + -- Rollback any partially made inserts/updates + ROLLBACK; + -- + l_success_char := NULL; + l_error := 'Y'; + -- + END IF; + -- + -- Call the contract options screen + efnow050$.contract_options_p(p_contract_id => l_cont_id, + p_success => l_success_char, + p_error => l_error, + p_err_msg => l_return_error); + -- + END IF; +END ins_or_upd_cont_opt; + + +PROCEDURE ins_or_upd_contract_p1( p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT' + , p_contract_id IN contracts.cont_id%TYPE DEFAULT 0 + , p_contract_number IN VARCHAR2 DEFAULT NULL + , p_pre_contract_id IN contracts.prev_cont_id%TYPE DEFAULT 0 + , p_customer_id IN customers.cust_id%TYPE DEFAULT 0 + , p_template_id IN contract_templates.cote_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 NULL + , 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_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 c_cont (cp_contract_id IN NUMBER) IS + SELECT * + FROM contracts + WHERE cont_id = cp_contract_id; + -- + CURSOR c_cotc( cp_cote_id IN NUMBER + , cp_cate_id IN NUMBER ) IS + SELECT 'Y' + FROM contract_template_categories + WHERE cote_id = cp_cote_id + AND cate_id = cp_cate_id; + -- + CURSOR c_cotp( cp_cote_id IN NUMBER + , cp_pars_id IN NUMBER ) IS + SELECT 'Y' + FROM contract_template_params + WHERE cote_id = cp_cote_id + AND pars_id = cp_pars_id; + -- + -- Cursor to determine if the contract number has been used previously for the customer TYPE + CURSOR c_unique_cont_num( cp_cont_num IN VARCHAR2 ) IS + SELECT 'X' + FROM contracts cont + , customers cust + WHERE cust.cust_id = cont.cust_id + AND cust.cuty_id = caco_utilities.cuty_id_for_user + AND cont.contract_number = cp_cont_num + AND cont.cont_id != NVL(p_contract_id,0); + -- + -- Cursor to check if there are any open contracts for this customer + -- for the date range given + CURSOR c_active_cont_check( cp_date_from IN DATE + , cp_date_to IN DATE ) + IS + SELECT 'X' + FROM contracts + WHERE cust_id = p_customer_id -- this customer + AND cont_id != NVL(p_contract_id,0) -- Not this contract (if updating) + AND status = 'O' -- Open + AND ( valid_from BETWEEN cp_date_from AND cp_date_to + OR valid_until BETWEEN cp_date_from AND cp_date_to + OR cp_date_from BETWEEN valid_from AND valid_until ); + -- + -- Cursor to check if the previous contract is consistent following + -- a change of valid_from date + CURSOR c_pre_cont(cp_pre_cont_id in number, cp_date_from IN DATE) IS + SELECT 'X' + FROM contracts + WHERE cont_id = cp_pre_cont_id + AND valid_until < cp_date_from; + -- + l_error VARCHAR2(1); + l_return_error VARCHAR2(250); -- If the insert or update fails - put an error message in here. + -- + l_contract_id contracts.cont_id%TYPE := 0; + l_pre_contract_id contracts.prev_cont_id%TYPE := 0; + l_contract_number VARCHAR2(2000) := NULL; + l_template_id contracts.cote_id%TYPE := 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(2000) := NULL; + l_date_from VARCHAR2(2000) := NULL; + l_date_to VARCHAR2(2000) := NULL; + l_val_window VARCHAR2(2000) := NULL; + l_val_action contracts.validation_action%TYPE := NUlL; + l_val_exception contracts.validation_exception%TYPE := NULL; + l_lookback_action contracts.lookback_action%TYPE := NULL; + -- + l_inherited VARCHAR2(1) := 'N'; + -- + l_network_point_array network_point_array; + l_category_array category_array; + l_parameter_array parameter_array; + -- + l_dummy_date_from DATE; + l_dummy_date_to DATE; + l_dummy_char VARCHAR2(1); + -- + l_nepo_id owa_util.vc_arr; + l_cate_id owa_util.vc_arr; + l_pars_id owa_util.vc_arr; + -- + l_success BOOLEAN := TRUE; -- Used to track how well we are doing in this code.. + l_success_char VARCHAR2(1) := NULL; + -- + l_code_position VARCHAR2(4) := '0000'; + -- + l_contract contracts%ROWTYPE; + -- +BEGIN + -- Check we have permission to be using this module. + -- Only called from the Create contracts screen + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- Look for whether we are inserting or updating + IF p_ins_or_upd IS NULL + AND l_success + OR ( UPPER(p_ins_or_upd) != 'INSERT' AND UPPER(p_ins_or_upd) != 'UPDATE' ) + THEN + -- Cannot tell if we should be inserting or updating. Well, we could + -- but it's easier to enforce this on the calling prog instead of Assuming. + -- and you know the old adage about ASSUME eh? + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2331); + -- Could not determine if Inserting or Updating + -- + END IF; + -- + -- Only check contract id if updating + IF l_success + AND p_ins_or_upd = 'UPDATE' + AND ( p_contract_id IS NULL OR p_contract_id = 0 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2317); + -- Update of Contract failed - No Contract Id was provided + END IF; + -- + -- Get Contract Template Id (do this first in case no contract number provided. + -- (for re-creating the maintain contract screen correctly with error message) + IF l_success + AND ( p_template_id IS NULL OR p_template_id = 0 ) + THEN + l_template_id := NULL; + -- + ELSIF l_success THEN + l_template_id := p_template_id; + END IF; + -- + -- Get Contract Number + IF l_success + AND ( p_contract_number IS NULL OR LENGTH(p_contract_number) > 30 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2236); + -- Contract number must be present with a maximum length of 30 characters + -- + ELSIF l_success THEN + -- Need to ensure that the contract number is unique within OMT or PUW + OPEN c_unique_cont_num( p_contract_number ); + FETCH c_unique_cont_num INTO l_dummy_char; + IF c_unique_cont_num%FOUND THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2252); + -- Duplicate Contract Number already exists + END IF; + CLOSE c_unique_cont_num; + -- + END IF; + -- + -- Get Customer ID + IF l_success + AND ( p_customer_id IS NULL OR p_customer_id = 0 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2325); + -- You must select a Customer for this Contract + END IF; + -- + -- Get Spreadsheet Template + IF l_success + AND ( p_spte_id IS NULL OR p_spte_id = 0 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2207); + -- A Spreadsheet Template must be selected + END IF; + -- + -- Get Ops Contact + IF l_success + AND ( p_ops_contact IS NULL OR LENGTH(p_ops_contact) > 25 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2291); + -- Ops Contact must be present with a maximum length of 25 characters + END IF; + -- + -- Get Business Contact + IF l_success + AND ( p_bus_contact IS NULL OR LENGTH(p_bus_contact) > 25 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2227); + -- Bus Contact must be present with a maximum length of 25 characters + END IF; + -- + -- Get Status + IF l_success + AND ( p_status IS NULL + OR ( p_status != 'O' AND p_status != 'C' ) ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2300); + -- Status must be present as either OPEN or CLOSED + END IF; + -- + -- Get Days Before + IF l_success + AND p_days_before IS NULL + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2247); + -- Days Before must be entered + ELSIF l_success THEN + BEGIN + SELECT TO_NUMBER(p_days_before) + INTO l_days_before + FROM dual; + -- + IF l_days_before < 1 THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2516); + -- Days Before must be greater than 0 (zero) + END IF; + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2416); + -- Days Before must be a valid number + END; + END IF; + -- + l_code_position := '0200'; + -- + -- Get Date From + IF l_success + AND p_date_from IS NOT NULL + THEN + BEGIN + SELECT TO_DATE(p_date_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + INTO l_dummy_date_from + FROM dual; + EXCEPTION + WHEN others THEN + l_success := FALSE; + -- Date From must be a valid date + l_return_error := caco_utilities.get_module_text(2242); + END; + ELSIF l_success + AND p_date_from IS NULL + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2243); + -- Date From must be entered + END IF; + -- + -- Get Date To + IF l_success + AND p_date_to IS NOT NULL + THEN + BEGIN + SELECT TO_DATE(p_date_to, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + INTO l_dummy_date_to + FROM dual; + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2245); + -- Date To must be a valid date + END; + ELSIF l_success + AND p_date_to IS NULL + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2246); + -- Date To must be entered + END IF; + -- + -- Check that Date from is before Date To + IF l_success + AND l_dummy_date_to <= l_dummy_date_from + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2417); + -- Date To must be after Date From + END IF; + -- Check that Date From is consistent with the named Previous Contract + IF l_success AND p_pre_contract_id <> 0 AND p_pre_contract_id is not null + THEN + open c_pre_cont(p_pre_contract_id, l_dummy_date_from); + fetch c_pre_cont into l_dummy_char; + if c_pre_cont%notfound then + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3962); + -- Date From must be after Previous Contract Date To + end if; + END IF; + -- + -- AWG October 2010 - Change Requests August 2010 Section 3.1 + -- This validation will be removed so that a customer can have more than one open + -- contract for a date period. + /* + -- + -- Can create a CLOSED contract at any time + -- but need to check for open contracts when creating or updating to OPEN + IF l_success + AND p_status = 'O' + THEN + -- Need to ensure that there is only ever one OPEN contract for the customer for a date period + -- An OPEN contract CAN overlap a CLOSED one + OPEN c_active_cont_check( l_dummy_date_from + , l_dummy_date_to ); + FETCH c_active_cont_check INTO l_dummy_char; + IF c_active_cont_check%FOUND THEN + -- An existing contract is open for part (or all) of the period specified for this contract + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2434); + -- Open contracts exist for this date period + -- + END IF; + CLOSE c_active_cont_check; + -- + END IF; + */ + -- + -- Get validation window + IF l_success + AND p_val_window IS NULL + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2323); + -- Validation Window must be a number with a value between 0 and 365 + ELSIF l_success THEN + BEGIN + SELECT TO_NUMBER(p_val_window) + INTO l_val_window + FROM dual; + -- + IF l_val_window < 0 OR l_val_window > 365 THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2323); + -- Validation Window must be a number with a value between 0 and 365 + END IF; + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2323); + -- Validation Window must be a number with a value between 0 and 365 + END; + END IF; + -- + -- Get validation action + IF l_success + AND ( p_val_action IS NULL OR p_val_action NOT IN ('I','T','B') ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2319); + -- Validation action must be selected + END IF; + -- + -- Get validation exception + IF l_success + AND ( p_val_exception IS NULL OR p_val_exception NOT IN ('CO','MI','MA') ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2321); + -- Validation Exception must be selected + END IF; + -- + -- Get lookback action + IF l_success + AND ( p_lookback_action IS NULL OR p_lookback_action NOT IN ('T','A') ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2321); + -- Validation Exception must be selected + END IF; + -- + -- Check that the virtual network point is only selected for entry mandatory offer contracts + l_code_position := '0300'; + IF l_success + THEN + find_passed_net_points( p_nepo_id + , l_network_point_array ); + IF vnepo_count(l_network_point_array) > 0 AND NOT emo_template(l_template_id) THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3913); + -- Virtual Network Point can only be assigned to an Entry Mandatory Offer Contract + ELSIF vnepo_count(l_network_point_array) = 0 AND emo_template(l_template_id) THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3914); + -- An Entry Mandatory Offer Contract must have a Virtual Network Point assigned + ELSIF vnepo_count(l_network_point_array) > 1 AND emo_template(l_template_id) THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(3922); + -- A contract can only contain one Virtual Network Point + END IF; + END IF; + -- + -- Hokey Cokey. Insert or Update the basic part of the contract/template + -- and then the network points, categories and parameters + -- Remember - for each category, add its associated parameters. + -- + l_code_position := '0900'; + -- + IF l_success THEN + l_code_position := '1000'; + -- Lets look at Inserting the contract first... + IF p_ins_or_upd = 'INSERT' THEN + BEGIN + INSERT INTO contracts + ( cont_id + , contract_number + , spte_id + , operations_contact + , business_contact + , receive_before_start + , valid_from + , valid_until + , status + , cote_id + , cust_id + , validation_window + , validation_action + , validation_exception + , lookback_action + , prev_cont_id ) + VALUES + ( cont_seq.NEXTVAL + , p_contract_number + , p_spte_id + , p_ops_contact + , p_bus_contact + , p_days_before + , TO_DATE(p_date_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , TO_DATE(p_date_to, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , p_status + , l_template_id + , p_customer_id + , p_val_window + , p_val_action + , p_val_exception + , p_lookback_action + , p_pre_contract_id ) + RETURNING cont_id INTO l_contract_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2327); + -- An unexpected error has occurred while inserting new contract. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'Insert of new contract failed : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting new contract: '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_contract_p1'); + -- + END; + -- + IF l_success THEN + l_success := ins_or_upd_inh_rules( p_ins_or_upd + , l_contract_id + , l_template_id + , l_return_error ); + END IF; + -- + ELSE + l_code_position := '1100'; + -- + l_success := ins_or_upd_inh_rules( p_ins_or_upd + , p_contract_id + , l_template_id + , l_return_error ); + -- + -- Only want to update the contract if the inherited rules have updated correctly + IF l_success THEN + -- get the currect contract values before updating so we can check for changes + OPEN c_cont(p_contract_id); + FETCH c_cont INTO l_contract; + CLOSE c_cont; + -- Update + BEGIN + UPDATE contracts + SET contract_number = p_contract_number + , spte_id = p_spte_id + , operations_contact = p_ops_contact + , business_contact = p_bus_contact + , receive_before_start = p_days_before + , valid_from = TO_DATE(p_date_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , valid_until = TO_DATE(p_date_to, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , status = p_status + , cote_id = l_template_id + , cust_id = p_customer_id + , validation_window = p_val_window + , validation_action = p_val_action + , validation_exception = p_val_exception + , lookback_action = p_lookback_action + , prev_cont_id = p_pre_contract_id + WHERE cont_id = p_contract_id; + -- + EXCEPTION + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2329); + -- An unexpected error has occurred while updating contract. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'Update of contract failed : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed updating contract (ID = '||p_contract_id||'): '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_contract_p1'); + -- + END; + -- + -- Invalidate any related interruption types if key column values have changed + IF l_contract.valid_from <> TO_DATE(p_date_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) OR + l_contract.valid_until <> TO_DATE(p_date_to, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) OR + l_contract.status <> p_status THEN + -- + l_success := invalidate_inty(p_contract_id); + -- + END IF; + -- + l_contract_id := p_contract_id; + -- + END IF; + END IF; -- Insert or Update of contract + END IF; -- End of basic insert + -- + l_code_position := '1200'; + -- + -- Get Network Points + IF l_success THEN + l_code_position := '2000'; + -- Find passed network points + -- SP 7/7/09 find_passed_net_points is now done in validation so no longer required here +/* find_passed_net_points( p_nepo_id + , l_network_point_array );*/ + -- + IF p_ins_or_upd = 'INSERT' THEN + l_code_position := '2100'; + -- Insert all Network Points + l_success := insert_cont_nepo( l_contract_id + , l_network_point_array + , l_return_error ); + -- + ELSE + l_code_position := '2200'; + -- Update + -- This is easier to get to grips with as a two pass process + -- First, zip through the existing DB data for the contract and delete existing rows not in our array + del_redundant_nepo( l_contract_id + , l_network_point_array + , l_success + , l_return_error ); + -- + l_code_position := '2250'; + -- Second time around go through the passed array and insert those that dont exist. + IF l_success THEN + -- + ins_required_nepo( l_contract_id + , l_network_point_array + , l_success + , l_return_error ); + -- + END IF; -- end of if successful delete of existing cont net points + -- + END IF; -- end of insert or update contract network points + END IF; -- end of network points + -- + l_code_position := '2900'; + -- + -- Get Categories + IF l_success THEN + find_passed_categories( p_cate_id + , l_category_array ); + -- + IF p_ins_or_upd = 'INSERT' THEN + -- + <> + FOR i IN 1..l_category_array.COUNT LOOP + -- + l_inherited := 'N'; + -- Test if this category was inherited + OPEN c_cotc( l_template_id, l_category_array(i).cate_id ); + FETCH c_cotc INTO l_inherited; + CLOSE c_cotc; + -- + l_success := ins_contract_cate( l_contract_id + , l_category_array(i).cate_id + , NULL + , l_inherited + , l_return_error ); + -- + IF NOT l_success THEN + EXIT ins_coca_loop; + END IF; + -- + END LOOP ins_coca_loop; + -- + ELSE + -- This is easier to get to grips with as a two pass process + -- First, zip through the existing DB data for the contract and delete existing rows not in our array + del_redundant_cate( l_contract_id + , l_category_array + , l_success + , l_return_error ); + -- + -- Second, go through the passed array and insert those categories that dont already exist. + IF l_success THEN + -- + ins_required_cate( l_contract_id + , l_template_id + , l_category_array + , l_success + , l_return_error ); + -- + END IF; + -- + END IF; -- contract categories insert or update + END IF; -- end of categories + -- + l_code_position := '3990'; + -- + IF l_success THEN + l_code_position := '4000'; + -- Get Parameters + find_passed_parameters( p_pars_id + , l_parameter_array ); + -- + IF p_ins_or_upd = 'INSERT' THEN + l_code_position := '4010'; + -- Easy, just insert all passed parameters once you know if it is inherited or not. + -- + <> + FOR i IN 1..l_parameter_array.COUNT LOOP + -- + l_inherited := 'N'; + -- Test if this parameter was inherited + OPEN c_cotp( l_template_id, l_parameter_array(i).pars_id ); + FETCH c_cotp INTO l_inherited; + CLOSE c_cotp; + -- + l_success := ins_contract_pars( l_contract_id + , l_parameter_array(i).pars_id + , l_inherited + , l_return_error ); + -- + IF NOT l_success THEN + EXIT ins_copa_loop; + END IF; + -- + END LOOP ins_copa_loop; -- end of inserting new parameters + -- + ELSE + l_code_position := '4100'; + -- UPDATE. This is easier to get to grips with as a two pass process + -- First, zip through the existing DB data for the contract + -- and delete existing rows not in our array + del_redundant_pars( l_contract_id + , l_parameter_array + , l_success + , l_return_error ); + -- + l_code_position := '4150'; + -- Second, go through the passed array and insert those parameters that dont already exist. + -- + IF l_success THEN + -- + ins_required_pars( l_contract_id + , l_template_id + , l_parameter_array + , l_success + , l_return_error ); + -- + END IF; + -- + END IF; -- contract template insert or update parameter. + -- + END IF; -- end of parameters + -- + -- + IF l_success THEN + -- Commit the changes + COMMIT; + -- + l_code_position := '9010'; + -- + l_success_char := 'Y'; + l_error := NULL; + l_return_error := NULL; + l_contract_number := NULL; + l_customer_id := 0; + l_spte_id := 0; + l_ops_contact := NULL; + l_bus_contact := NULL; + l_status := NULL; + l_days_before := NULL; + l_date_from := NULL; + l_date_to := NULL; + l_val_window := NULL; + l_val_action := NULL; + l_val_exception := NULL; + l_lookback_action := NULL; + l_nepo_id := g_vc_arr; + l_cate_id := g_vc_arr; + l_pars_id := g_vc_arr; + -- + ELSE + l_code_position := '9020'; + -- + -- Failed somewhere + -- Rollback any partially made inserts/updates + ROLLBACK; + -- + IF l_contract_id = 0 + AND p_ins_or_upd = 'UPDATE' + THEN + l_contract_id := p_contract_id; + END IF; + -- + l_success_char := NULL; + l_error := 'Y'; + l_contract_number := p_contract_number; + 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; + l_nepo_id := p_nepo_id; + l_cate_id := p_cate_id; + l_pars_id := p_pars_id; + -- + END IF; + -- + l_code_position := '9100'; + -- + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: '||chr(10) + ||chr(10)||'p_ins_or_upd : '||p_ins_or_upd + ||chr(10)||'p_success : '||l_success_char + ||chr(10)||'p_error : '|| l_error + ||chr(10)||'p_err_msg : '||l_return_error + ||chr(10)||'p_contract_id : '||l_contract_id + ||chr(10)||'p_contract_number : '||l_contract_number + ||chr(10)||'p_template_id : '||l_template_id + ||chr(10)||'p_customer_id : '||l_customer_id + ||chr(10)||'p_spte_id : '||l_spte_id + ||chr(10)||'p_ops_contact : '||l_ops_contact + ||chr(10)||'p_bus_contact : '||l_bus_contact + ||chr(10)||'p_status : '||l_status + ||chr(10)||'p_days_before : '||l_days_before + ||chr(10)||'p_date_from : '||l_date_from + ||chr(10)||'p_date_to : '||l_date_to + ||chr(10)||'p_val_window : '||l_val_window + ||chr(10)||'p_val_action : '||l_val_action + ||chr(10)||'p_val_exception : '||l_val_exception + ||chr(10)||'p_lookback_action : '||l_lookback_action + ); + -- + -- Call the contracts screen + efnow050$.contract_startup( p_screen_type => 'CONTRACT' + , p_ins_or_upd => p_ins_or_upd + , p_success => l_success_char + , p_error => l_error + , p_err_msg => l_return_error + , p_contract_id => l_contract_id + , p_contract_number => l_contract_number + , p_template_id => l_template_id + , p_customer_id => l_customer_id + , p_spte_id => l_spte_id + , p_ops_contact => l_ops_contact + , p_bus_contact => l_bus_contact + , p_status => l_status + , p_days_before => l_days_before + , p_date_from => l_date_from + , p_date_to => l_date_to + , p_val_window => l_val_window + , p_val_action => l_val_action + , p_val_exception => l_val_exception + , p_lookback_action => l_lookback_action + , p_nepo_id => l_nepo_id + , p_cate_id => l_cate_id + , p_pars_id => l_pars_id ); + -- +EXCEPTION + WHEN others THEN + caco_debug.debug_on; + caco_debug.putline('efno_contracts.ins_or_upd_contract_p1: ' + ||'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 => 'Failed at position : '||l_code_position||' : '||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_contract_p1'); + -- + ROLLBACK; + RAISE; +END ins_or_upd_contract_p1; + + + +FUNCTION del_template_pars( p_template_id IN contract_templates.cote_id%TYPE + , p_pars_id IN parameters.pars_id%TYPE + , p_contracts_exist IN BOOLEAN + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to loop through all contracts that have the specified contract template + CURSOR c_cont IS + SELECT cont_id + FROM contracts + WHERE cote_id = p_template_id; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_del_cotp; + -- + IF p_contracts_exist THEN + -- + <> + FOR r IN c_cont LOOP + -- Delete contract parameter values + BEGIN + DELETE cont_net_point_param_vals cnppv + WHERE cnppv.copa_id IN ( SELECT copa.copa_id + FROM contract_parameters copa + , parameters pars + WHERE copa.cont_id = r.cont_id + AND copa.pars_id = p_pars_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2328); + -- An unexpected error has occurred while updating contract template. Please contact support + caco_debug.putline('efno_contracts.del_template_pars: ' + ||'Update of contract template parameters failed ' + ||'(deleting associated parameters values from contracts) : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting template parameters associated contract parameter values: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.delete_template_pars'); + -- + EXIT cont_pars_loop; + END; + -- + -- Delete contract parameters + BEGIN + DELETE contract_parameters + WHERE cont_id = r.cont_id + AND pars_id = p_pars_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2328); + -- An unexpected error has occurred while updating contract template. Please contact support + caco_debug.putline('efno_contracts.del_template_pars: ' + ||'Update of contract template parameters failed ' + ||'(deleting contract parameters): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting template parameters from associated contracts: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.delete_template_pars'); + -- + EXIT cont_pars_loop; + END; + -- + END LOOP cont_pars_loop; + -- + END IF; + -- + IF l_success THEN + -- + BEGIN + DELETE contract_template_params + WHERE cote_id = p_template_id + AND pars_id = p_pars_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2328); + -- An unexpected error has occurred while updating contract template. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'Update of contract template parameters failed (deleting parameter): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting contract template parameters: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.delete_template_pars'); + -- + END; + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_del_cotp; + END IF; + -- + RETURN l_success; + -- +END del_template_pars; + + + +FUNCTION ins_template_pars( p_template_id IN contract_templates.cote_id%TYPE + , p_pars_id IN parameters.pars_id%TYPE + , p_contracts_exist IN BOOLEAN + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to loop through all contracts that have the specified contract template + CURSOR c_cont IS + SELECT cont_id + FROM contracts + WHERE cote_id = p_template_id; + -- + l_success BOOLEAN := TRUE; + -- + l_copa_id contract_parameters.copa_id%TYPE; + -- +BEGIN + SAVEPOINT before_ins_cotp; + -- + -- Insert the parameter to all contracts that have the specified contract template + IF p_contracts_exist THEN + -- + <> + FOR r IN c_cont LOOP + -- + BEGIN + INSERT INTO contract_parameters + ( copa_id + , display_sequence + , inherited + , cont_id + , pars_id ) + VALUES + ( copa_seq.NEXTVAL + , 0 -- these parameters are not from a category + , 'Y' + , r.cont_id + , p_pars_id ) + RETURNING copa_id INTO l_copa_id; + -- + -- Now insert the values as we know it can be a little fragile without... + -- + l_success := ins_copa_cnppv ( p_contract_id => r.cont_id + , p_copa_id => l_copa_id + , p_return_error => p_return_error + ); + -- + IF NOT l_success THEN + -- + EXIT cont_pars_loop; + -- + END IF; + -- + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2217); + -- An unexpected error has occurred while inserting contract template parameters. Please contact support + caco_debug.putline('efno_contracts.ins_template_pars: ' + ||'Insert of contract template parameters failed ' + ||'(inserting parameter to associated contracts) : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting parameters into associated contracts: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_template_pars'); + -- + EXIT cont_pars_loop; + END; + -- + END LOOP cont_pars_loop; + -- + END IF; -- contracts exist + -- + -- Insert the template parameter. + IF l_success THEN + BEGIN + INSERT INTO contract_template_params + ( cotp_id + , display_sequence + , inherited + , cote_id + , pars_id ) + VALUES + ( cotp_seq.NEXTVAL + , ( SELECT NVL(MAX(cotp2.display_sequence),0)+10 + FROM contract_template_params cotp2 + WHERE cotp2.cote_id = p_template_id ) + , 'N' + , p_template_id + , p_pars_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2217); + -- An unexpected error has occurred while inserting contract template parameters. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'Insert of contract template parameters failed : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting contract template parameters: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_contract_p1'); + -- + END; + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_ins_cotp; + END IF; + -- + RETURN l_success; + -- +END ins_template_pars; + +FUNCTION del_template_cate( p_template_id IN contract_templates.cote_id%TYPE + , p_cate_id IN categories.cate_id%TYPE + , p_contracts_exist IN BOOLEAN + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN +IS + -- Cursor to loop through all contracts that have the specified contract template + CURSOR c_cont IS + SELECT cont_id + FROM contracts + WHERE cote_id = p_template_id; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + SAVEPOINT before_del_cotc; + -- + -- Delete the categories and their associated parameters from all + -- contracts that have the specified contract template + IF p_contracts_exist THEN + -- + <> + FOR r IN c_cont LOOP + -- + l_success := del_contract_cate( r.cont_id + , p_cate_id + , p_return_error ); + -- + IF NOT l_success THEN + EXIT cont_cate_loop; + END IF; + -- + END LOOP cont_cate_loop; + -- + END IF; -- contracts exist + -- + -- Delete the parameters inherited from the category for this template + IF l_success THEN + BEGIN + DELETE contract_template_params cotp + WHERE cotp.cote_id = p_template_id + AND cotp.pars_id IN ( SELECT pars.pars_id + FROM parameters pars + WHERE pars.cate_id = p_cate_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2328); + -- An unexpected error has occurred while updating contract template. Please contact support + caco_debug.putline('efno_contracts.del_template_cate: ' + ||'Update of contract template categories failed (deleting associated parameters): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting contract template categories associated parameters: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_template_cate'); + -- + END; + END IF; + -- + -- + IF l_success THEN + -- Now we need to delete the category from the template + BEGIN + DELETE contract_template_categories + WHERE cote_id = p_template_id + AND cate_id = p_cate_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2328); + -- An unexpected error has occurred while updating contract template. Please contact support + caco_debug.putline('efno_contracts.del_template_cate: ' + ||'Update of contract template categories failed (deleting category): ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed deleting contract template categories: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.del_template_cate'); + -- + END; + -- + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_del_cotc; + END IF; + -- + RETURN l_success; + -- +END del_template_cate; + + + + +FUNCTION ins_template_cate( p_template_id IN contract_templates.cote_id%TYPE + , p_cate_id IN categories.cate_id%TYPE + , p_display_sequence IN categories.display_sequence%TYPE + , p_contracts_exist IN BOOLEAN + , p_return_error OUT VARCHAR2 ) RETURN BOOLEAN IS + -- + -- Cursor to loop through all contracts that have the specified contract template + -- + CURSOR c_cont IS + SELECT cont_id + FROM contracts + WHERE cote_id = p_template_id; + -- + -- Cursor to get associated parameters for INSERTed categories + CURSOR c_cate_pars IS + SELECT pars.pars_id pars_id + , cate.display_sequence display_sequence + FROM parameters pars + , categories cate + WHERE pars.cate_id = p_cate_id + AND pars.cate_id = cate.cate_id; + -- + l_success BOOLEAN := TRUE; + -- + -- For Updating Contract Categories - to determine if we need to insert into DB + FUNCTION coca_in_db( p_cate_id IN NUMBER + , p_contract_id IN NUMBER ) + RETURN BOOLEAN + IS + CURSOR c_coca IS + SELECT 'Y' + FROM contract_categories + WHERE cont_id = p_contract_id + AND cate_id = p_cate_id; + -- + l_success BOOLEAN := FALSE; + l_dummy VARCHAR2(1) := 'X'; + -- + BEGIN + OPEN c_coca; + FETCH c_coca INTO l_dummy; + IF c_coca%FOUND THEN + l_success := TRUE; + END IF; + CLOSE c_coca; + RETURN l_success; + END coca_in_db; + -- +BEGIN + SAVEPOINT before_ins_cotc; + -- + -- Insert the category and its associated parameters to all + -- contracts that have the specified contract template + IF p_contracts_exist THEN + -- + <> + FOR r IN c_cont LOOP + -- + IF NOT coca_in_db( p_cate_id + , r.cont_id ) + THEN + -- + l_success := ins_contract_cate( r.cont_id + , p_cate_id + , p_display_sequence + , 'Y' -- inherited + , p_return_error ); + -- + IF NOT l_success THEN + EXIT cont_cate_loop; + END IF; + -- + ELSE + -- Already in the DB for this contract + BEGIN + UPDATE contract_categories + SET inherited = 'Y' + ,display_sequence = p_display_sequence + WHERE cate_id = p_cate_id + AND cont_id = r.cont_id; + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2223); + -- An unexpected error has occurred while updating contract template categories. Please contact support + caco_debug.putline('efno_contracts.ins_template_cate : ' + ||'Update of contract template categories failed ' + ||'(updating existing contract categories) : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed updating contract categories to be inherited: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_template_cate'); + -- + EXIT cont_cate_loop; + END; + -- we dont need to touch the parameters as they are "inherited" from the category + -- + END IF; -- already in DB or not + -- + END LOOP cont_cate_loop; + -- + END IF; -- contracts exist + -- + IF l_success THEN + BEGIN + INSERT INTO contract_template_categories + ( cotc_id + , display_sequence + , cote_id + , cate_id ) + VALUES + ( cotc_seq.NEXTVAL + , p_display_sequence + , p_template_id + , p_cate_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2223); + -- An unexpected error has occurred while updating contract template categories. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'Update of contract template categories failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting contract template categories: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_template_cate'); + -- + END; + END IF; + -- + -- We also need to insert any parameters associated with this category + IF l_success THEN + FOR r IN c_cate_pars LOOP + BEGIN + INSERT INTO contract_template_params + ( cotp_id + , display_sequence + , inherited + , cote_id + , pars_id ) + VALUES + ( cotp_seq.NEXTVAL + , r.display_sequence + , 'Y' + , p_template_id + , r.pars_id ); + EXCEPTION + WHEN others THEN + l_success := FALSE; + p_return_error := caco_utilities.get_module_text(2223); + -- An unexpected error has occurred while updating contract template categories. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'Update of contract template categories associated parameters failed : ' + ||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting contract template categories associated parameters: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_template_cate'); + -- + END; + END LOOP; -- end of inserting associated parameters + END IF; + -- + IF NOT l_success THEN + ROLLBACK TO SAVEPOINT before_ins_cotc; + END IF; + -- + RETURN l_success; + -- +END ins_template_cate; + + + + + +-- For Updating Contract Template Categories - to enable delete of those no longer attached +FUNCTION cotc_in_array( p_id IN NUMBER + , p_cate_array IN category_array ) + RETURN BOOLEAN +IS + l_success BOOLEAN := FALSE; +BEGIN + IF NVL(p_cate_array.COUNT,0) > 0 THEN + FOR i IN p_cate_array.FIRST..p_cate_array.LAST LOOP + IF p_cate_array(i).cate_id = p_id THEN + l_success := TRUE; + END IF; + END LOOP; + END IF; + RETURN l_success; +END cotc_in_array; + + + + +-- For Updating Contract Template Categories - to determine if we need to insert into DB +FUNCTION cotc_in_db( p_cate_id IN NUMBER + , p_template_id IN NUMBER ) + RETURN BOOLEAN +IS + CURSOR c_cotc IS + SELECT 'Y' + FROM contract_template_categories + WHERE cote_id = p_template_id + AND cate_id = p_cate_id; + -- + l_success BOOLEAN := FALSE; + l_dummy VARCHAR2(1) := 'X'; + -- +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 cotc_in_db; + + + + +-- For Updating Contract Template Parameters - to enable delete of those no longer attached +FUNCTION cotp_in_array( p_id IN NUMBER + , p_pars_array IN parameter_array ) + RETURN BOOLEAN +IS + l_success BOOLEAN := FALSE; +BEGIN + IF NVL(p_pars_array.COUNT,0) > 0 THEN + FOR i IN p_pars_array.FIRST..p_pars_array.LAST LOOP + IF p_pars_array(i).pars_id = p_id THEN + l_success := TRUE; + END IF; + END LOOP; + END IF; + RETURN l_success; +END cotp_in_array; + + + + +-- For Updating Contract Template Parameters - to determine if we need to insert into DB +-- Note: We are relying on the contract template screen to only show those parameters +-- that are NOT associated with categories +FUNCTION cotp_in_db( p_pars_id IN NUMBER + , p_template_id IN NUMBER ) + RETURN BOOLEAN +IS + CURSOR c_cotp IS + SELECT 'Y' + FROM contract_template_params + WHERE cote_id = p_template_id + AND pars_id = p_pars_id; + -- + l_success BOOLEAN := FALSE; + l_dummy VARCHAR2(1) := 'X'; + -- +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 cotp_in_db; + + + + + + + +PROCEDURE ins_or_upd_template_p1( p_ins_or_upd IN VARCHAR2 DEFAULT NULL + , p_template_id IN NUMBER DEFAULT 0 + , p_template_name IN VARCHAR2 DEFAULT NULL + , p_template_desc IN VARCHAR2 DEFAULT NULL + , p_emo IN VARCHAR2 DEFAULT NULL + , 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 to list all contracts using the given template + CURSOR c_cont IS + SELECT cont_id + FROM contracts + WHERE cote_id = p_template_id; + -- + CURSOR c_cote_cate( cp_cote_id IN NUMBER ) IS + SELECT cate_id + FROM contract_template_categories + WHERE cote_id = cp_cote_id + FOR UPDATE; + -- + CURSOR c_cote_pars( cp_cote_id IN NUMBER ) IS + SELECT pars_id + FROM contract_template_params + WHERE cote_id = cp_cote_id + AND NVL(inherited,'N') = 'N' + FOR UPDATE; + -- + l_error VARCHAR2(1); + l_return_error VARCHAR2(250); -- If the insert or update fails - put an error message in here. + -- + l_template_id NUMBER := 0; + l_template_name contract_templates.name%TYPE := NULL; + l_template_desc contract_templates.description%TYPE := NULL; + l_emo_flag contract_templates.entry_mandatory_offer%TYPE := NULL; + l_dummy_cont_id contracts.cont_id%TYPE := 0; + -- + l_cate_id owa_util.vc_arr; + l_pars_id owa_util.vc_arr; + -- + l_category_array category_array; + l_parameter_array parameter_array; + -- + l_success BOOLEAN := TRUE; -- Used to track how well we are doing in this code.. + l_success_char VARCHAR2(1); + contracts_exist BOOLEAN := FALSE; + -- + l_code_position VARCHAR2(4) := '0000'; + -- +BEGIN + -- Check we have permission to be using this module. + -- Only called from the Create contracts screen + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + l_code_position := '0010'; + -- + IF p_ins_or_upd IS NULL + OR ( UPPER(p_ins_or_upd) != 'INSERT' AND UPPER(p_ins_or_upd) != 'UPDATE' ) + THEN + -- Cannot tell if we should be inserting or updating. Well, we could + -- but it's easier to enforce this on the calling prog instead of Assuming. + l_code_position := '0015'; + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2331); + -- Could not determine if Inserting or Updating + -- + END IF; + -- + IF l_success THEN + l_code_position := '0020'; + -- + IF UPPER(p_ins_or_upd) = 'UPDATE' + AND ( p_template_id IS NULL OR p_template_id = 0 ) + THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2316); + -- Update of Contract Template failed - No Template ID was provided + END IF; + -- + l_code_position := '0030'; + -- + IF l_success + AND ( p_template_name IS NULL OR LENGTH(p_template_name) > 50 ) + THEN + -- + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2304); + -- Template Name must be present with a maximum length of 50 characters + -- + END IF; + -- + l_code_position := '0040'; + -- + IF l_success + AND ( p_template_desc IS NULL OR LENGTH(p_template_desc) > 250 ) + THEN + -- + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2303); + -- Template Description must be present with a maximum length of 250 characters + -- + END IF; + -- + -- Hokey Cokey. Insert or Update the basic part of the template + -- and then the categories and parameters + -- Remember - for each category, add its associated parameters. + -- + l_code_position := '0050'; + -- + IF l_success THEN + -- Lets look at Inserting the contract template first... + IF p_ins_or_upd = 'INSERT' THEN + -- + l_code_position := '0060'; + -- + BEGIN + INSERT INTO contract_templates + ( cote_id + , name + , description + , entry_mandatory_offer ) + VALUES + ( cote_seq.NEXTVAL + , p_template_name + , p_template_desc + , p_emo ) + RETURNING cote_id INTO l_template_id; + EXCEPTION + WHEN dup_val_on_index THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2253); + -- Duplicate Contract Template Name already exists + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2219); + -- An unexpected error has occurred while inserting new contract template. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'Insert of new contract template failed : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed inserting contract template: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_template_p1'); + -- + END; + -- + ELSE + l_code_position := '0070'; + -- Update + BEGIN + UPDATE contract_templates + SET name = p_template_name + , description = p_template_desc + , entry_mandatory_offer = p_emo + WHERE cote_id = p_template_id; + EXCEPTION + WHEN dup_val_on_index THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2253); + -- Duplicate Contract Template Name already exists + WHEN others THEN + l_success := FALSE; + l_return_error := caco_utilities.get_module_text(2328); + -- An unexpected error has occurred while updating contract template. Please contact support + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'Update of contract template failed : '||sqlerrm(sqlcode)); + -- Write an error and carry on + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => 'Failed updating contract template: ' + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_template_p1'); + -- + END; + -- + -- Do we have any contracts for the given template id? + IF l_success THEN + OPEN c_cont; + FETCH c_cont INTO l_dummy_cont_id; + IF c_cont%FOUND THEN + contracts_exist := TRUE; + END IF; + CLOSE c_cont; + END IF; + -- + END IF; -- end of "if insert or update contract template" + -- + END IF; -- End of basic insert + -- + l_code_position := '0080'; + -- + -- Get Categories + IF l_success THEN + l_code_position := '1000'; + -- + l_template_name := p_template_name; + l_template_desc := p_template_desc; + l_emo_flag := p_emo; + -- + find_passed_categories( p_cate_id + , l_category_array ); + -- + IF p_ins_or_upd = 'INSERT' THEN + -- + l_code_position := '1010'; + -- + <> + FOR i IN 1..l_category_array.COUNT LOOP + -- + l_code_position := '1020'; + -- + l_success := ins_template_cate( l_template_id + , l_category_array(i).cate_id + , i+1 + , FALSE + , l_return_error ); + -- + IF NOT l_success THEN + EXIT ins_cotc_loop; + END IF; + -- + END LOOP ins_cotc_loop; -- end of inserting new categories + -- + ELSE + -- Update + l_code_position := '1200'; + -- + l_template_id := p_template_id; + -- + -- This is easier to get to grips with as a two pass process + -- First, zip through the existing DB data for the contract and delete existing rows not in our array + <> + FOR r IN c_cote_cate( p_template_id ) LOOP + -- + IF NOT cotc_in_array( r.cate_id + , l_category_array ) + THEN + l_code_position := '1210'; + -- This Category doesn't exist in the new set + -- So we need to delete any parameters associated with this category and then + -- delete the category itself. If any contracts have this template - we need + -- to remove the parameters and categories from those also. + -- + l_success := del_template_cate( p_template_id + , r.cate_id + , contracts_exist + , l_return_error ); + -- + IF NOT l_success THEN + EXIT upd_del_cotc_loop; + END IF; + -- + END IF; + -- + END LOOP upd_del_cotc_loop; + -- + l_code_position := '1300'; + -- + -- Second, go through the passed array and insert those categories that dont already exist. + -- + <> + FOR i IN 1..l_category_array.COUNT LOOP + -- + IF NOT cotc_in_db( l_category_array(i).cate_id + , p_template_id ) + THEN + l_code_position := '1310'; + -- + -- Current category does not exist in the DB so we need to INSERT + -- Also need to add the category and associated parameters to all contracts + -- that have this contract template + -- + l_success := ins_template_cate( p_template_id + , l_category_array(i).cate_id + , i+1 + , contracts_exist + , l_return_error ); + -- + IF NOT l_success THEN + EXIT upd_ins_cotc_loop; + END IF; + -- + ELSE + -- + -- Contract template category DOES exist, just update it's sequence + -- + upd_cotc( p_template_id + , l_category_array(i).cate_id + , i+1); + -- + END IF; + -- + END LOOP upd_ins_cotc_loop; + -- + END IF; -- contract template insert or update categories. + -- + END IF; -- End of categories + -- + l_code_position := '2000'; + -- + IF l_success THEN + l_code_position := '2010'; + -- + -- Get Parameters + find_passed_parameters( p_pars_id + , l_parameter_array ); + -- + IF p_ins_or_upd = 'INSERT' THEN + l_code_position := '2020'; + -- + -- Easy, just insert all passed parameters. + <> + FOR i IN 1..l_parameter_array.COUNT LOOP + -- + l_success := ins_template_pars( l_template_id + , l_parameter_array(i).pars_id + , contracts_exist + , l_return_error ); + -- + IF NOT l_success THEN + EXIT ins_cotp_loop; + END IF; + -- + END LOOP ins_cotp_loop; -- end of inserting new parameters + -- + ELSE + l_code_position := '2300'; + -- UPDATE. This is easier to get to grips with as a two pass process + -- First, zip through the existing DB data for the contract template + -- and delete existing rows not in our array + <> + FOR r IN c_cote_pars( p_template_id ) LOOP + -- + IF NOT cotp_in_array( r.pars_id + , l_parameter_array ) + THEN + -- This Parameterory doesn't exist in the new set + -- We need to delete the parameter + -- + l_success := del_template_pars( p_template_id + , r.pars_id + , contracts_exist + , l_return_error ); + -- + IF NOT l_success THEN + EXIT upd_del_cotp_loop; + END IF; + -- + END IF; -- end when the parameter has been removed from the contract template + -- + END LOOP upd_del_cotp_loop; + -- + l_code_position := '2310'; + -- + -- Second, go through the passed array and insert those parameters that dont already exist. + <> + FOR i IN 1..l_parameter_array.COUNT LOOP + -- + l_code_position := '2320'; + -- + IF NOT cotp_in_db( l_parameter_array(i).pars_id + , p_template_id ) + THEN + l_code_position := '2330'; + -- Current Parameter does not exist in the DB so we need to INSERT + l_success := ins_template_pars( p_template_id + , l_parameter_array(i).pars_id + , contracts_exist + , l_return_error ); + -- + IF NOT l_success THEN + EXIT upd_ins_cotp_loop; + END IF; + -- + END IF; -- end of parameter doesnt exist in DB + -- + END LOOP upd_ins_cotp_loop; + -- + END IF; -- contract template insert or update parameter. + -- + END IF; -- end of contract template parameters + -- + END IF; + -- + l_code_position := '9000'; + -- + IF l_success THEN + -- Commit the changes + COMMIT; + -- + l_success_char := 'Y'; + l_error := NULL; + l_return_error := NULL; + -- + l_code_position := '9010'; + -- + l_cate_id := g_vc_arr; + l_pars_id := g_vc_arr; + -- + ELSE + l_code_position := '9020'; + -- + l_success_char := NULL; + l_error := 'Y'; + -- + -- Failed somewhere + -- Rollback any partially made inserts/updates + ROLLBACK; + -- + l_cate_id := p_cate_id; + l_pars_id := p_pars_id; + -- + END IF; + -- + l_code_position := '9100'; + -- Call the contracts screen + efnow050$.contract_startup( p_screen_type => 'TEMPLATE' + , p_ins_or_upd => p_ins_or_upd + , p_success => l_success_char + , p_error => l_error + , p_err_msg => l_return_error + , p_template_id => l_template_id + , p_template_name => l_template_name + , p_template_desc => l_template_desc + , p_emo => l_emo_flag + , p_cate_id => l_cate_id + , p_pars_id => l_pars_id ); + -- +EXCEPTION + WHEN others THEN + ROLLBACK; + caco_debug.putline('efno_contracts.ins_or_upd_template_p1: ' + ||'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 => 'Unexpected error: Position in Code :'||l_code_position + ||chr(10)||sqlerrm(sqlcode) + , p_source => 'efno_contracts.ins_or_upd_template_p1'); + -- + RAISE; +END ins_or_upd_template_p1; +-- + +PROCEDURE copy_contract_opts(p_cont_id_from IN contracts.cont_id%TYPE, + p_cont_id_to IN contracts.cont_id%TYPE) IS + -- Cursor to collect current options exist + CURSOR c_options_from IS + SELECT * FROM contract_options WHERE cont_id = p_cont_id_from; + -- Cursor to see if new options already exist + CURSOR c_options_to IS + SELECT cont_id FROM contract_options WHERE cont_id = p_cont_id_to; + l_contract_opt_record contract_options%ROWTYPE; + l_contract_id contract_options.cont_id%TYPE; + l_success BOOLEAN := TRUE; +BEGIN + IF p_cont_id_from IS NOT NULL + AND p_cont_id_from > 0 THEN + OPEN c_options_from; + FETCH c_options_from + INTO l_contract_opt_record; + IF c_options_from%NOTFOUND THEN + l_success := FALSE; + END IF; + CLOSE c_options_from; + ELSE + l_success := FALSE; + END IF; + -- + IF l_success + AND p_cont_id_to IS NOT NULL + AND p_cont_id_to > 0 THEN + OPEN c_options_to; + FETCH c_options_to + INTO l_contract_id; + IF c_options_to%FOUND THEN + l_success := FALSE; + UPDATE contract_options + SET nom_conf_subject = l_contract_opt_record.nom_conf_subject, + nom_conf_content = l_contract_opt_record.nom_conf_content, + com_conf_subject = l_contract_opt_record.com_conf_subject, + com_conf_content = l_contract_opt_record.com_conf_content, + auto_gen_conf = l_contract_opt_record.auto_gen_conf, + conf_type = l_contract_opt_record.conf_type, + ind_deadline_for_nom_submit = l_contract_opt_record.ind_deadline_for_nom_submit, + shipper = l_contract_opt_record.shipper, + int_subject = l_contract_opt_record.int_subject, + int_content = l_contract_opt_record.int_content, + int_sms_content = l_contract_opt_record.int_sms_content + WHERE cont_id = p_cont_id_to; + END IF; + CLOSE c_options_to; + ELSE + l_success := FALSE; + END IF; + -- Copy contract options across + IF l_success THEN + 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_cont_id_to, + l_contract_opt_record.nom_conf_subject, + l_contract_opt_record.nom_conf_content, + l_contract_opt_record.com_conf_subject, + l_contract_opt_record.com_conf_content, + l_contract_opt_record.auto_gen_conf, + l_contract_opt_record.conf_type, + l_contract_opt_record.ind_deadline_for_nom_submit, + l_contract_opt_record.shipper, + l_contract_opt_record.int_subject, + l_contract_opt_record.int_content, + l_contract_opt_record.int_sms_content); + END IF; +END copy_contract_opts; + +PROCEDURE copy_contract ( p_cont_id_from contracts.cont_id%TYPE + , p_cont_number_to contracts.contract_number%TYPE + ) IS + -- + l_contract_row contracts%ROWTYPE; + l_old_cont_id contracts.cont_id%TYPE; + -- + l_nepo_array owa_util.vc_arr; + l_cate_array owa_util.vc_arr; + l_pars_array owa_util.vc_arr; + -- +BEGIN + -- + -- Security check (Only called from the Create contracts screen) + -- + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- OK, get the contract values + -- + SELECT c.* + INTO l_contract_row + FROM contracts c + WHERE c.cont_id = p_cont_id_from; + -- + SELECT cnp.nepo_id + BULK COLLECT INTO l_nepo_array + FROM cont_network_points cnp + WHERE cnp.cont_id = p_cont_id_from; + -- + SELECT cc.cate_id + BULK COLLECT INTO l_cate_array + FROM contract_categories cc + WHERE cc.cont_id = p_cont_id_from; + -- + SELECT cp.pars_id + BULK COLLECT INTO l_pars_array + FROM contract_parameters cp + WHERE cp.cont_id = p_cont_id_from + AND cp.pars_id IN (SELECT pars_id + FROM parameters p + WHERE p.cate_id IS NULL); +-- AND cp.inherited = 'N'; +-- 31/07/07 SP Commented out above line so all parameters are copied including parameters inherited from template. +-- 31/08/07 SP Commented back in as caused duplicate columns on contract set values screen for copied contracts. +-- 19/09/07 SP Replaced with new AND clause to allow copying without duplication. + -- + -- Override specific settings - new contract must be closed + -- + l_contract_row.status := 'C'; + -- + SELECT cont_seq.nextval + INTO l_old_cont_id + FROM DUAL; + -- + commit; + -- + -- AWG Dec 2010 Requested modification to the copied contract + -- The new contract will have the original as its previous contract to + -- start the day after and last for 30 days. + ins_or_upd_contract_p1 ( p_ins_or_upd => 'INSERT' + , p_contract_id => 0 + , p_contract_number => p_cont_number_to + --, p_pre_contract_id => l_contract_row.prev_cont_id + , p_pre_contract_id => l_contract_row.cont_id + , p_customer_id => l_contract_row.cust_id + , p_template_id => l_contract_row.cote_id + , p_spte_id => l_contract_row.spte_id + , p_ops_contact => l_contract_row.operations_contact + , p_bus_contact => l_contract_row.business_contact + , p_status => l_contract_row.status + , p_days_before => l_contract_row.receive_before_start + --, p_date_from => TO_CHAR(l_contract_row.valid_from, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + --, p_date_to => TO_CHAR(l_contract_row.valid_until, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , p_date_from => TO_CHAR(l_contract_row.valid_until + 1, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , p_date_to => TO_CHAR(l_contract_row.valid_until + 31, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , p_val_window => l_contract_row.validation_window + , p_val_action => l_contract_row.validation_action + , p_val_exception => l_contract_row.validation_exception + , p_lookback_action => l_contract_row.lookback_action + , p_nepo_id => l_nepo_array + , p_cate_id => l_cate_array + , p_pars_id => l_pars_array + ); + -- + SELECT cont_seq.currval + INTO l_contract_row.cont_id + FROM DUAL; + -- + IF l_contract_row.cont_id > l_old_cont_id THEN + -- + -- Copy the contract options + -- + copy_contract_opts(p_cont_id_from, l_contract_row.cont_id); + -- + -- Copy The network point group parameters + -- + INSERT INTO network_point_gp_params ( nepg_id + , cont_id + , name + , code + , value + ) + SELECT nepg_id + , l_contract_row.cont_id + , name + , code + , value + FROM network_point_gp_params npgp + WHERE npgp.cont_id = p_cont_id_from; + -- + -- Now copy the rules + -- + INSERT INTO contract_rules ( coru_id + , display_sequence + , inherited + , cont_id + , coru_type + , rule_name + , left_side + , rule_relation + , right_side + , error_message_hu + , error_message_en + , rule_id + ) + SELECT coru_seq.NEXTVAL + , cr.display_sequence + , cr.inherited + , l_contract_row.cont_id + , cr.coru_type + , cr.rule_name + , cr.left_side + , cr.rule_relation + , cr.right_side + , cr.error_message_hu + , cr.error_message_en + , cr.rule_id + FROM contract_rules cr + WHERE cr.cont_id = p_cont_id_from + AND cr.inherited = 'N'; + -- + -- Finally copy the values + -- + MERGE INTO cont_net_point_param_vals cnppv + USING ( SELECT cnppv2.value + ,cnpt.conp_id + ,cpt.copa_id + FROM cont_net_point_param_vals cnppv2 + ,contract_parameters cpf + ,contract_parameters cpt + ,cont_network_points cnpf + ,cont_network_points cnpt + WHERE cnppv2.copa_id = cpf.copa_id + AND cnppv2.conp_id = cnpf.conp_id + AND cpf.cont_id = p_cont_id_from + AND cpf.pars_id = cpt.pars_id + AND cnpf.nepo_id = cnpt.nepo_id + AND cpt.cont_id = l_contract_row.cont_id + AND cnpt.cont_id = l_contract_row.cont_id ) cnppv_sq1 + ON ( cnppv.conp_id = cnppv_sq1.conp_id + AND cnppv.copa_id = cnppv_sq1.copa_id ) + WHEN MATCHED THEN + UPDATE SET cnppv.value = cnppv_sq1.value + WHEN NOT MATCHED THEN + INSERT ( cnppv.cnppv_id + , cnppv.value + , cnppv.conp_id + , cnppv.copa_id + ) + VALUES ( cnppv_seq.NEXTVAL + , cnppv_sq1.value + , cnppv_sq1.conp_id + , cnppv_sq1.copa_id + ); + -- + END IF; + -- +END copy_contract; +-- +PROCEDURE efnow050$copy ( p_contract_id IN NUMBER DEFAULT NULL + , p_contract_name IN VARCHAR2 DEFAULT NULL + , p_action IN VARCHAR2 DEFAULT NULL + ) IS + -- + l_in_error BOOLEAN := FALSE; + -- +BEGIN + -- + -- Security check (Only called from the Create contracts screen) + -- + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- Build the screen + -- + IF p_contract_name IS NOT NULL THEN + -- + FOR i IN ( SELECT NULL + FROM contracts c + WHERE c.contract_number = p_contract_name ) LOOP + -- + l_in_error := TRUE; + EXIT; + -- + END LOOP; + -- + END IF; + -- + IF p_action IS NULL OR l_in_error THEN + -- + -- OK, let's build the form. + -- + wsgl.openpagehead(caco_utilities.get_module_text(2099)); -- Maintain Contract Template Rules + caco_system.content_type; + htp.p(''); + wsgl.closepagehead; + wsgl.openpagebody(FALSE); + htp.p(caco_system.menu); + htp.header( nsize => 1 + , cheader => caco_utilities.get_module_text(3549) + ); + -- + IF l_in_error THEN + -- + wsgl.displaymessage(p_type => WSGL.MESS_ERROR + ,p_mess => caco_utilities.get_module_text(2252) + ); + -- + END IF; + -- + htp.p('
'); + -- + htp.p('
'); + -- + htp.p(''); + htp.p(''); + htp.p(''); + htp.p(''); + htp.p('
'||caco_utilities.get_module_text(3552)||':
'||caco_utilities.get_module_text(3553)||':
'); + -- + htp.p('
'); + -- + htp.p(''); + -- + htp.p('
'); + -- + caco_system.footer(p_closebody => TRUE); + -- + ELSE + -- + -- Otherwise, copy the contract + -- + efno_contracts.copy_contract ( p_cont_id_from => p_contract_id + , p_cont_number_to => p_contract_name + ); + -- + END IF; + -- +END efnow050$copy; +-- +/** +-- 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_revision || CHR(10) || g_header ); +END about; + + +BEGIN + -- Initialization + NULL; +END efno_contracts; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_contracts.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_contracts.spc new file mode 100644 index 0000000..b0b7e53 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_contracts.spc @@ -0,0 +1,142 @@ +CREATE OR REPLACE PACKAGE efno_contracts IS +-- +-- Purpose : Nomination Rule engine functions +-- #version $Revision: 1 $ +-- #author $Author: Laceyk $ +-- Created : 12/02/2007 16:15:16 +-- +g_package_name CONSTANT VARCHAR2(30) := 'efno_contracts'; +g_header CONSTANT VARCHAR2(160) := '$Header: $'; +g_revision CONSTANT VARCHAR2(160) := '$Revision: $ Patch 0.3'; +-- +g_perc_split_en module_text.text%TYPE := caco_utilities.get_module_text(3921,'EN'); +g_perc_split_hu module_text.text%TYPE := caco_utilities.get_module_text(3921,'HU'); +-- + -- + g_vc_arr owa_util.vc_arr; + g_num_arr owa_util.num_arr; + -- + TYPE network_point_array IS TABLE OF network_points.nepo_id%TYPE INDEX BY BINARY_INTEGER; + -- + TYPE category_record IS RECORD ( cate_id categories.cate_id%TYPE + , inherited VARCHAR2(1) + , display_sequence NUMBER ); + -- + TYPE category_array IS TABLE OF category_record INDEX BY BINARY_INTEGER; + -- + TYPE parameter_record IS RECORD ( pars_id parameters.pars_id%TYPE + , inherited VARCHAR2(1) ); + -- + TYPE parameter_array IS TABLE OF parameter_record INDEX BY BINARY_INTEGER; + -- + TYPE contract_rules_rec IS RECORD ( display_sequence contract_rules.display_sequence%TYPE + , rule_name contract_rules.rule_name%TYPE + , rule_type contract_rules.coru_type%TYPE + , coru_id contract_rules.coru_id%TYPE + , rule_id rules.rule_id%TYPE + , inherited contract_rules.inherited%TYPE ); + -- + TYPE perc_split_record IS RECORD ( conp_id cont_net_point_param_vals.conp_id%TYPE + , value cont_net_point_param_vals.value%TYPE); + -- + TYPE perc_split_array IS TABLE OF perc_split_record INDEX BY BINARY_INTEGER; + -- + -- + CURSOR c_rules( cp_cont_id IN NUMBER ) + RETURN contract_rules_rec; + -- + /** + -- FUNCTION validate_nomination + -- Fairly Simplistic function that will just return TRUE or FALSE + -- to indicate if the given nomination is valid for the contract as it stands + -- + -- %param p_contract_id The Unique identifier of a Contract + -- %param p_nomination_id The Unique identifier of a Nomination + -- %param p_return_error OUT: Message giving brief reason why the rule is invalid if indeed it is + -- + -- %return BOOLEAN TRUE indicating that the nomination is valid + */ + FUNCTION validate_nomination( p_contract_id IN contracts.cont_id%TYPE + , p_nomination_id IN nominations.nomi_id%TYPE + , p_return_error OUT VARCHAR2 ) + RETURN BOOLEAN; + -- + -- +PROCEDURE upd_cnppv_records( p_contract_id IN NUMBER + , p_page_no IN NUMBER DEFAULT 1 + , p_cnppv_id IN owa_util.vc_arr DEFAULT g_vc_arr + , p_value IN owa_util.vc_arr DEFAULT g_vc_arr ); + -- +PROCEDURE ins_or_upd_cont_opt(p_cont_id IN contract_options.cont_id%TYPE, + p_ind_deadline_for_nom_submit IN contract_options.ind_deadline_for_nom_submit%TYPE, + p_shipper IN contract_options.shipper%TYPE, + p_auto_gen_conf IN contract_options.auto_gen_conf%TYPE, + p_conf_type IN contract_options.conf_type%TYPE, + p_com_conf_subject IN contract_options.com_conf_subject%TYPE, + p_com_conf_content IN contract_options.com_conf_content%TYPE, + p_nom_conf_subject IN contract_options.nom_conf_subject%TYPE, + p_nom_conf_content IN contract_options.nom_conf_content%TYPE, + p_ind_deadline_hr IN contract_options.ind_deadline_for_nom_submit%TYPE, + p_ind_deadline_mi IN contract_options.ind_deadline_for_nom_submit%TYPE, + p_int_subject IN contract_options.int_subject%TYPE, + p_int_content IN contract_options.int_content%TYPE, + p_int_sms_content IN contract_options.int_sms_content%TYPE); + +PROCEDURE ins_or_upd_contract_p1( p_ins_or_upd IN VARCHAR2 DEFAULT 'INSERT' + , p_contract_id IN contracts.cont_id%TYPE DEFAULT 0 + , p_contract_number IN VARCHAR2 DEFAULT NULL + , p_pre_contract_id IN contracts.prev_cont_id%TYPE DEFAULT 0 + , p_customer_id IN customers.cust_id%TYPE DEFAULT 0 + , p_template_id IN contract_templates.cote_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 NULL + , 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_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 ); + + +PROCEDURE ins_or_upd_template_p1( p_ins_or_upd IN VARCHAR2 DEFAULT NULL + , p_template_id IN NUMBER DEFAULT 0 + , p_template_name IN VARCHAR2 DEFAULT NULL + , p_template_desc IN VARCHAR2 DEFAULT NULL + , p_emo IN VARCHAR2 DEFAULT NULL + , p_cate_id IN owa_util.vc_arr DEFAULT g_vc_arr + , p_pars_id IN owa_util.vc_arr DEFAULT g_vc_arr ); + -- + -- Procedure to copy an existing contract + -- + PROCEDURE copy_contract ( p_cont_id_from contracts.cont_id%TYPE + , p_cont_number_to contracts.contract_number%TYPE + ); + -- + PROCEDURE efnow050$copy ( p_contract_id IN NUMBER DEFAULT NULL + , p_contract_name IN VARCHAR2 DEFAULT NULL + , p_action IN VARCHAR2 DEFAULT NULL + ); + -- + -- Function to check if a contract is an Entry Mandatory Offer contract + FUNCTION emo_contract( p_contract_id IN NUMBER ) + RETURN VARCHAR2; + -- Function to check if a contract network point is a virtual network point + FUNCTION virtual_nepo( p_conp_id IN NUMBER ) + RETURN BOOLEAN; + -- Function to check if a network poinr is being used by a contract + FUNCTION nepo_in_contract ( p_nepo_id IN network_points.nepo_id%TYPE ) + RETURN BOOLEAN; +/** +-- FUNCTION about -- +-- %return A textual description of the version number and VSS header for this package +*/ +FUNCTION about RETURN VARCHAR2; +-- +END efno_contracts; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_interruption.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_interruption.bdy new file mode 100644 index 0000000..2815c2e --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efno_interruption.bdy @@ -0,0 +1,908 @@ +CREATE OR REPLACE PACKAGE BODY efno_interruption IS + -- + FUNCTION j_writeworkbook(p_spreadsheet_id IN VARCHAR2 + ,p_sheet_name IN VARCHAR2) RETURN NUMBER AS + LANGUAGE JAVA NAME 'advantica.oracle.accessmanager.amfr_excel_j.amfr_excel_j.writeWorkBook(java.lang.String, java.lang.String) return long'; + -- + PROCEDURE replace_text_tags( p_int_id IN interruptions.int_id%TYPE + , p_cust_id IN customers.cust_id%TYPE DEFAULT NULL + , p_text IN OUT VARCHAR2 + ) IS + -- + c_cust_name CONSTANT VARCHAR2(100) := '{CUSTOMER_NAME}'; + c_start_date CONSTANT VARCHAR2(100) := '{START_DATE}'; + c_end_date CONSTANT VARCHAR2(100) := '{END_DATE}'; + -- + CURSOR cur_int ( p_int_id IN interruptions.int_id%TYPE ) IS + SELECT int.gas_day_start + ,int.gas_day_end + FROM interruptions int + WHERE int.int_id = p_int_id; + -- + lr_interruption cur_int%ROWTYPE; + -- + BEGIN + -- + OPEN cur_int ( p_int_id => p_int_id ); + FETCH cur_int + INTO lr_interruption; + CLOSE cur_int; + -- + p_text := REPLACE(p_text, c_cust_name, caco_utilities.get_cust_name(p_cust_id)); + p_text := REPLACE(p_text, c_start_date, TO_CHAR(lr_interruption.gas_day_start, cout_system_configuration.get_configuration_item('G_DATE_FORMAT'))); + p_text := REPLACE(p_text, c_end_date, NVL(TO_CHAR(lr_interruption.gas_day_end, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')),' ')); + -- + END replace_text_tags; + -- + -- + -- + FUNCTION return_int_ss ( p_int_id IN interruptions.int_id%TYPE + , p_cont_id IN contracts.cont_id%TYPE + ) RETURN BLOB IS + -- + -- + -- + c_spte_id CONSTANT spreadsheet_templates.spte_id%TYPE := 90; + -- + -- Generated Document + -- + l_return BLOB; + -- + -- Generic spreadsheet variables + -- + l_spreadsheet_id gtt_spreadsheet.spreadsheet_id%TYPE; + l_docu_id documents.docu_id%TYPE; + l_cust_id customers.cust_id%TYPE; + -- + -- Generic value for tag replacement + -- + l_value VARCHAR2(1000); + l_start_date DATE; + l_num_days NUMBER; + l_offset_reduction NUMBER := 0; + -- + -- Known tags + -- + c_cust_name CONSTANT VARCHAR2(100) := '{CUSTOMER_NAME}'; + c_cont_name CONSTANT VARCHAR2(100) := '{CONTRACT_NAME}'; + c_start_date CONSTANT VARCHAR2(100) := '{START_DATE}'; + c_end_date CONSTANT VARCHAR2(100) := '{END_DATE}'; + c_nepo_code CONSTANT VARCHAR2(100) := '{NETWORK_POINT_CODE}'; + c_nepo_name CONSTANT VARCHAR2(100) := '{NETWORK_POINT_NAME}'; + c_cate_name CONSTANT VARCHAR2(100) := '{CATE_NAME}'; + c_cate_units CONSTANT VARCHAR2(100) := '{CATE_UNITS}'; + c_iccv_placeholder CONSTANT VARCHAR2(100) := '{INT_CONT_CAT_VALS}'; + -- + -- Combination cursor - confirmation template and nomination type, it is correct! + -- + CURSOR cur_spte ( p_spte_id IN spreadsheet_templates.spte_id%TYPE ) IS + SELECT l_spreadsheet_id + ,sptv.x_axis + ,sptv.y_axis + ,sptv.cell_value + ,sptv.cell_datatype + ,sptv.cell_format_mask + ,sptv.cell_border + ,sptv.cell_background + ,sptv.cell_merge + ,sptv.cell_font + ,sptv.cell_fontsize + ,sptv.cell_align + ,sptv.col_width + ,sptv.row_height + ,sptv.cell_wrap + ,spte.name + FROM spreadsheet_templates spte + ,spreadsheet_template_values sptv + WHERE spte.spte_id = sptv.spte_id + AND sptv.spte_id = c_spte_id; + -- + l_r_spte cur_spte%ROWTYPE; + -- + CURSOR cur_int (p_int_id IN interruptions.int_id%TYPE) IS + SELECT int.* + FROM interruptions int + WHERE int.int_id = p_int_id; + -- + lr_int cur_int%ROWTYPE; + -- + CURSOR cur_grid ( p_int_id IN interruptions.int_id%TYPE ) IS + SELECT iccv.iccv_id + , cust.code cust + , iccv.conp_id + , coca.cate_id + , iccv.send_to_customer + , iccv.contracted_value + , iccv.interrupted_value + , iccv.confirmed_value + ,nepo.name||':'||cust.name neponame + ,ROW_NUMBER() OVER (PARTITION BY cate.name ORDER BY cust.code NULLS LAST) grid_row + FROM int_conp_coca_vals iccv + ,contract_categories coca + ,categories cate + ,cont_network_points conp + ,network_points nepo + ,contracts cont + ,customers cust + WHERE iccv.int_id = p_int_id + AND iccv.coca_id = coca.coca_id + AND coca.cate_id = cate.cate_id + AND iccv.conp_id = conp.conp_id + AND coca.cont_id = cont.cont_id + AND conp.nepo_id = nepo.nepo_id + AND cont.cust_id = cust.cust_id + AND cont.cont_id = p_cont_id + ORDER BY cust.code + ,nepo.code + ,cate.display_sequence; + -- + lr_grid_row cur_grid%ROWTYPE; + -- + PROCEDURE insert_cell ( p_r_spte IN cur_spte%ROWTYPE + , p_value_overload IN VARCHAR2 DEFAULT NULL + , 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 + -- + l_x_axis := CHR(ASCII(p_r_spte.x_axis)+p_x_increment); + -- + END IF; + -- + 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_r_spte.l_spreadsheet_id + , NVL(l_x_axis, p_r_spte.x_axis) + , p_r_spte.y_axis + p_y_increment + , NVL(p_value_overload, p_r_spte.cell_value) + , p_r_spte.cell_datatype + , p_r_spte.cell_format_mask + , p_r_spte.cell_border + , p_r_spte.cell_background + , NVL(p_span, p_r_spte.cell_merge) + , p_r_spte.cell_font + , p_r_spte.cell_fontsize + , p_r_spte.cell_align + , p_r_spte.col_width + , p_r_spte.row_height + , p_r_spte.cell_wrap + ); + -- + END insert_cell; + -- + BEGIN + -- + -- Get the details from interruptions + -- + OPEN cur_int(p_int_id => p_int_id); + FETCH cur_int + INTO lr_int; + CLOSE cur_int; + -- + -- + -- Get the next sequence value + -- + SELECT spte_seq.NEXTVAL + INTO l_spreadsheet_id + FROM DUAL; + -- + -- Get the cust ID + -- + SELECT cont.cust_id + INTO l_cust_id + FROM contracts cont + WHERE cont.cont_id = p_cont_id; + -- + -- Now loop around the template + -- + OPEN cur_spte ( c_spte_id ); + -- + LOOP + -- + FETCH cur_spte + INTO l_r_spte; + -- + EXIT WHEN cur_spte%NOTFOUND; + -- + IF l_r_spte.cell_value LIKE '{%}' THEN + -- + -- Candidate for tag replacement, loop through our known tags + -- + -- {CAT_NAME} + -- {CAT_UNITS} + -- {CONTRACT_ID} + -- {CUSTOMER_NAME} + -- {CONTRACT_NAME} + -- {CUSTOMER_EMAIL} + -- {CUSTOMER_FAX} + -- {GAS_DAY} + -- {NETWORK_POINT_CODE} + -- {NETWORK_POINT_NAME} + -- {INT_CONT_CAT_VALS} + -- + l_value := NULL; + -- + IF INSTR(l_r_spte.cell_value, c_cust_name) > 0 THEN + -- + SELECT cust.name + INTO l_value + FROM customers cust + ,contracts cont + WHERE cont.cust_id = cust.cust_id + AND cont.cont_id = p_cont_id; + -- + l_value := REPLACE(l_r_spte.cell_value, c_cust_name, l_value); + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => l_value + ); + -- + END IF; + -- + IF INSTR(l_r_spte.cell_value, c_cont_name) > 0 THEN + -- + SELECT cont.contract_number + INTO l_value + FROM customers cust + ,contracts cont + WHERE cont.cust_id = cust.cust_id + AND cont.cont_id = p_cont_id; + -- + l_value := REPLACE(l_r_spte.cell_value, c_cont_name, l_value); + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => l_value + ); + -- + END IF; + -- + IF INSTR(l_r_spte.cell_value, c_start_date) > 0 OR INSTR(l_r_spte.cell_value, c_end_date) > 0 THEN + -- + l_value := l_r_spte.cell_value; + -- + l_value := REPLACE(l_value, c_start_date, NVL(TO_CHAR( lr_int.gas_day_start, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')),'')); + l_value := REPLACE(l_value, c_end_date, NVL(TO_CHAR( lr_int.gas_day_end, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')),'')); + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => l_value + ); + -- + -- + ELSIF INSTR(l_r_spte.cell_value, c_start_date) > 0 THEN + -- + l_value := NVL(TO_CHAR( lr_int.gas_day_start, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')),''); + -- + l_value := REPLACE(l_r_spte.cell_value, c_start_date, l_value); + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => l_value + ); + -- + ELSIF INSTR(l_r_spte.cell_value, c_end_date) > 0 THEN + -- + l_value := NVL(TO_CHAR( lr_int.gas_day_end, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')),''); + -- + l_value := REPLACE(l_r_spte.cell_value, c_end_date, l_value); + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => l_value + ); + -- + END IF; + -- + IF l_r_spte.cell_value = c_nepo_code THEN + -- + FOR site_rec IN ( SELECT site + ,rownum FROM ( + SELECT nepo.code AS site + FROM int_conp_coca_vals int + ,cont_network_points conp + ,network_points nepo + WHERE int.int_id = p_int_id + AND int.conp_id = conp.conp_id + AND conp.nepo_id = nepo.nepo_id + AND conp.cont_id = p_cont_id + GROUP BY nepo.code + ORDER BY nepo.code + ) + ) LOOP + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => site_rec.site + , p_y_increment => (site_rec.rownum - 1) + ); + -- + END LOOP; + -- + END IF; + -- + IF l_r_spte.cell_value = c_nepo_name THEN + -- + FOR site_rec IN ( SELECT site + ,rownum FROM ( + SELECT nepo.name AS site + FROM int_conp_coca_vals int + ,cont_network_points conp + ,network_points nepo + WHERE int.int_id = p_int_id + AND int.conp_id = conp.conp_id + AND conp.nepo_id = nepo.nepo_id + AND conp.cont_id = p_cont_id + GROUP BY nepo.name + ,nepo.code + ORDER BY nepo.code + ) + ) LOOP + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => site_rec.site + , p_y_increment => (site_rec.rownum - 1) + ); + -- + END LOOP; + -- + END IF; + -- + IF l_r_spte.cell_value = c_cate_name THEN + -- + -- Populate cell with Category Name + -- + FOR cat IN ( SELECT rownum, cate_id, name FROM (SELECT coca.cate_id + , cate.name + , cate.display_sequence + FROM int_conp_coca_vals iccv + ,contract_categories coca + ,categories cate + WHERE iccv.int_id = p_int_id + AND iccv.coca_id = coca.coca_id + AND coca.cate_id = cate.cate_id + GROUP BY coca.cate_id + , cate.name + , cate.display_sequence + ORDER BY cate.display_sequence + )) LOOP + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => cat.name + , p_x_increment => cat.rownum - 1 + ); + -- + END LOOP; + -- + END IF; + -- + IF l_r_spte.cell_value = c_cate_units THEN + -- + -- Populate cell with Category Units + -- + FOR cat IN ( SELECT rownum, cate_id, name, units FROM (SELECT coca.cate_id + , cate.name + , cate.units + , cate.display_sequence + FROM int_conp_coca_vals iccv + ,contract_categories coca + ,categories cate + WHERE iccv.int_id = p_int_id + AND iccv.coca_id = coca.coca_id + AND coca.cate_id = cate.cate_id + GROUP BY coca.cate_id + , cate.name + , cate.units + , cate.display_sequence + ORDER BY cate.display_sequence + )) LOOP + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => cat.units + , p_x_increment => cat.rownum - 1 + ); + -- + END LOOP; + -- + END IF; + -- + IF l_r_spte.cell_value = c_iccv_placeholder THEN + -- + OPEN cur_grid(p_int_id => p_int_id); + FETCH cur_grid + INTO lr_grid_row; + -- + FOR custnepo IN ( SELECT rownum-1 AS yincr + ,sq.* FROM ( + SELECT cust.code cust + , nepo.code nepo + , nepo.name neponame + , iccv.conp_id conp + FROM int_conp_coca_vals iccv + ,cont_network_points conp + ,network_points nepo + ,contracts cont + ,customers cust + WHERE iccv.int_id = p_int_id + AND iccv.conp_id = conp.conp_id + AND conp.cont_id = cont.cont_id + AND conp.nepo_id = nepo.nepo_id + AND cont.cust_id = cust.cust_id + AND cont.cont_id = p_cont_id + GROUP BY cust.code + , nepo.code + , nepo.name + , iccv.conp_id + ORDER BY cust.code + ,nepo.code ) sq ) LOOP + -- + FOR griddetail IN (SELECT rownum-1 AS xincr, cate_id, name, inty_code FROM ( + SELECT coca.cate_id + , cate.name + , cate.display_sequence + , inty.code AS inty_code + FROM int_conp_coca_vals iccv + ,contract_categories coca + ,categories cate + ,interruption_types inty + WHERE iccv.int_id = p_int_id + AND iccv.coca_id = coca.coca_id + AND coca.cate_id = cate.cate_id + AND inty.cate_id (+) = cate.cate_id + AND inty.status (+) = 'A' + GROUP BY coca.cate_id + , cate.name + , cate.display_sequence + , inty.code + ORDER BY cate.display_sequence + )) LOOP + -- + -- fetch cursor + -- + IF lr_grid_row.cate_id = griddetail.cate_id + AND lr_grid_row.conp_id = custnepo.conp THEN + -- + IF lr_grid_row.send_to_customer = 'Y' THEN + -- + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => caco_utilities.to_thousand_separated(lr_grid_row.interrupted_value) + , p_x_increment => griddetail.xincr + , p_y_increment => custnepo.yincr + ); + ELSE + insert_cell ( p_r_spte => l_r_spte + , p_value_overload => caco_utilities.to_thousand_separated(lr_grid_row.contracted_value) + , p_x_increment => griddetail.xincr + , p_y_increment => custnepo.yincr + ); + + END IF; + -- + FETCH cur_grid + INTO lr_grid_row; + -- + END IF; + -- + END LOOP; --cate + -- + END LOOP;--custnepo + -- + CLOSE cur_grid; + -- + END IF; + -- + ELSE + -- + insert_cell ( p_r_spte => l_r_spte + ); + -- + END IF; + -- + END LOOP; + -- + CLOSE cur_spte; + -- + -- dbms_java.set_output(2000); + -- + l_docu_id := j_writeworkbook( l_spreadsheet_id + , caco_utilities.get_module_text(p_text_number => 3803) + ); + -- + -- Get the document into the return variable + -- + SELECT docu.blob_content + INTO l_return + FROM documents docu + WHERE docu_id = l_docu_id; + -- + -- Now remove the document + -- + DELETE + FROM documents d + WHERE d.docu_id = l_docu_id; + -- + -- And return + -- + RETURN l_return; + -- + EXCEPTION + WHEN OTHERS THEN + cout_err.report_and_go(p_exception_number => sqlcode, p_exception_message => sqlerrm); + END return_int_ss; + -- + PROCEDURE download ( p_remd_id IN rec_message_details.remd_id%TYPE ) IS + -- + l_document_contents documents.blob_content%TYPE; + l_mime_type documents.mime_type%TYPE; + -- + l_document_name documents.name%TYPE; + -- + BEGIN + -- + -- Get the document out of the table ready for direct transmission + -- + BEGIN + -- + SELECT remd.message_attachment + INTO l_document_contents + FROM rec_message_details remd + WHERE remd.remd_id = p_remd_id; + -- + EXCEPTION + WHEN OTHERS THEN + -- + NULL; + -- + END; + -- + l_document_name := caco_utilities.get_module_text(3803)||'.xls'; + l_mime_type := 'application/vnd.ms-excel'; + -- + owa_util.mime_header(l_mime_type, FALSE); + htp.p('Content-Length: '||dbms_lob.getlength(l_document_contents)); + htp.p('Content-Disposition: attachment; filename='||l_document_name); + owa_util.http_header_close; + -- + IF l_document_contents IS NOT NULL THEN + wpg_docload.download_file(l_document_contents); + END IF; + -- + END download; + -- + FUNCTION get_global( p_var IN VARCHAR2 ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(30); + -- + BEGIN + -- + IF p_var = 'g_query_id' THEN + -- + l_return := g_query_id; + -- + ELSIF p_var = 'g_query_start' THEN + -- + l_return := g_query_start; + -- + ELSIF p_var = 'g_query_end' THEN + -- + l_return := g_query_end; + -- + END IF; + -- + RETURN l_return; + -- + END get_global; + -- + PROCEDURE send_messages ( p_int_id IN interruptions.int_id%TYPE DEFAULT NULL + ) IS + -- + v_substitution_list caco_utilities.g_t_substitution_list; + -- + CURSOR cur_cust (p_cust_id IN customers.cust_id%TYPE ) IS + SELECT cust.int_subject + ,cust.int_content + ,cust.int_sms_content + FROM customers cust + WHERE cust.cust_id = p_cust_id; + -- + lr_cust_rec cur_cust%ROWTYPE; + -- + l_intr_ss BLOB; + -- + BEGIN + -- + -- security check - check for access to base package + -- + IF NOT caco_security.security_check('efnow210$') THEN + RETURN; + END IF; + -- + IF p_int_id IS NOT NULL THEN + -- + -- loop around all distinct recipients + -- + FOR cust_rec IN ( SELECT cont.cust_id + ,cont.cont_id + FROM int_conp_coca_vals iccv + , cont_network_points conp + , contracts cont + WHERE iccv.int_id = p_int_id + AND iccv.conp_id = conp.conp_id + AND conp.cont_id = cont.cont_id + AND iccv.send_to_customer = 'Y' + GROUP BY cont.cust_id + , cont.cont_id + ) LOOP + -- + -- Get static details + -- + OPEN cur_cust ( cust_rec.cust_id ); + FETCH cur_cust + INTO lr_cust_rec; + CLOSE cur_cust; + -- + -- Sustitute any tags + -- + replace_text_tags( p_int_id => p_int_id + , p_cust_id => cust_rec.cust_id + , p_text => lr_cust_rec.int_content + ); + -- + -- Generate details to be sent + -- + l_intr_ss := return_int_ss ( p_int_id => p_int_id + , p_cont_id => cust_rec.cont_id + ); + -- + -- Now send the details + -- + efno_msgsubs.send_recorded_messages( p_cust_id => cust_rec.cust_id + , p_suca_id => efno_msgsubs.get_suca_id( p_suca_group => 'Notification' + , p_suca_name => 'Commercial' ) + , p_message_type => 'Interruption' + , p_message_id => p_int_id + , p_email_content_en => lr_cust_rec.int_content + , p_email_subject_en => lr_cust_rec.int_subject + , p_sms_content_en => lr_cust_rec.int_sms_content + , p_file => l_intr_ss + , p_filename => caco_utilities.get_module_text(3803)||'.xls' + , p_file_mime_type => 'application/vnd.ms-excel' + ); + -- + END LOOP; -- cust_rec + -- + ELSE + -- + v_substitution_list(1) := 'p_int_id'; + -- + caco_utilities.raise_exception_error( p_exception_number => -20100 + , p_substitution_list => v_substitution_list + ); + -- + END IF; + -- + END send_messages; + -- + -- + -- + FUNCTION get_int_val ( p_val IN NUMBER + , p_conp_id IN NUMBER + , p_copa_id IN NUMBER + , p_gasday IN DATE + ) RETURN NUMBER IS + -- + l_return NUMBER; + -- + BEGIN + -- + l_return := p_val; + -- + FOR int IN (SELECT int.int_id + FROM interruptions int + WHERE p_gasday BETWEEN int.gas_day_start AND NVL(int.gas_day_end, p_gasday) + ) LOOP + -- + -- Interruption is in place on this gas day, check if value is reduced + -- + FOR iccv IN ( SELECT iccv.interrupted_value AS value + FROM int_conp_coca_vals iccv + ,contract_categories coca + ,parameters pars + ,contract_parameters copa + WHERE iccv.int_id = int.int_id + AND iccv.coca_id = coca.coca_id + AND coca.cate_id = pars.cate_id + AND pars.pars_id = copa.pars_id + AND copa.cont_id = coca.cont_id + AND iccv.conp_id = p_conp_id + AND copa.copa_id = p_copa_id + AND iccv.send_to_customer = 'Y' + AND (pars.code LIKE '%MAX' + OR pars.code LIKE '%CTR') + ) LOOP + -- + -- Only substitue MAX and contracted, and only if the interrupted value is lower + -- + l_return := LEAST(iccv.value, l_return); + -- + END LOOP; + -- + END LOOP; + -- + RETURN l_return; + -- + END get_int_val; + -- + FUNCTION am_i_interrrupted ( p_conp_id IN cont_network_points.conp_id%TYPE + , p_coca_id IN contract_categories.coca_id%TYPE + , p_gasday IN DATE + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + FOR int IN (SELECT int.int_id + FROM interruptions int + WHERE p_gasday BETWEEN int.gas_day_start AND NVL(int.gas_day_end, p_gasday) + ) LOOP + -- + -- Interruption is in place on this gas day, check if value is reduced + -- + FOR iccv IN ( SELECT iccv.interrupted_value AS int_val + ,iccv.contracted_value AS cont_val + FROM int_conp_coca_vals iccv + WHERE iccv.int_id = int.int_id + AND iccv.coca_id = p_coca_id + AND iccv.conp_id = p_conp_id + AND iccv.send_to_customer = 'Y' + ) LOOP + -- + -- Only substitue MAX and contracted, and only if the interrupted value is lower + -- +-- IF iccv.int_val < iccv.cont_val THEN -- quantity check removed in line with interruption comments received on 13/02/2008, AG + -- + l_return := TRUE; + -- +-- END IF; -- quantity check removed in line with interruption comments received on 13/02/2008, AG + -- + END LOOP; + -- + END LOOP; + -- + RETURN l_return; + -- + END am_i_interrrupted; + -- + -- + -- + PROCEDURE daily_message IS + -- + l_date DATE; + l_min_days NUMBER; + -- + CURSOR cur_inte ( p_inte_id IN interruptions.int_id%TYPE ) IS + SELECT MIN(incp.max_interruption_days) + FROM int_conp_coca_vals iccv + ,inty_conp_params incp + ,interruption_types inty + ,contract_categories coca + WHERE iccv.int_id = p_inte_id + AND inty.cate_id = coca.cate_id + AND incp.inty_id = inty.inty_id + AND iccv.coca_id = coca.coca_id + AND iccv.conp_id = incp.conp_id + AND inty.status = 'A'; + -- + BEGIN + -- + l_date := TRUNC(SYSDATE-cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24); + -- + FOR int IN ( SELECT inte.int_id + ,l_date - inte.gas_day_start AS days_so_far + FROM interruptions inte + WHERE l_date >= inte.gas_day_start + AND inte.gas_day_end IS NULL + ) LOOP + -- + OPEN cur_inte (int.int_id); + FETCH cur_inte + INTO l_min_days; + CLOSE cur_inte; + -- + IF int.days_so_far = l_min_days THEN + -- + FOR user_rec IN (SELECT DISTINCT syus_id + FROM user_profiles + WHERE sypr_id IN (SELECT sypr_id + FROM system_profiles + WHERE role_name LIKE 'EFT Admin' + OR role_name LIKE 'EFT User' + OR role_name LIKE '%KAM%')) LOOP + -- + efno_msgsubs.send_messages(p_syus_id => user_rec.syus_id + ,p_suca_id => efno_msgsubs.get_suca_id( p_suca_group => 'Notification' + , p_suca_name => 'Service' ) + ,p_email_content_en => caco_utilities.get_module_text(3849, caco_utilities.get_syus_lang(user_rec.syus_id)) + ,p_email_subject_en => caco_utilities.get_module_text(3848, caco_utilities.get_syus_lang(user_rec.syus_id)) + ,p_sms_content_en => caco_utilities.get_module_text(3849, caco_utilities.get_syus_lang(user_rec.syus_id)) + ); + -- + END LOOP; + -- + ELSIF int.days_so_far >= l_min_days THEN + -- + FOR user_rec IN (SELECT DISTINCT syus_id + FROM user_profiles + WHERE sypr_id IN (SELECT sypr_id + FROM system_profiles + WHERE role_name LIKE 'EFT Admin' + OR role_name LIKE 'EFT User' + OR role_name LIKE '%KAM%')) LOOP + -- + efno_msgsubs.send_messages(p_syus_id => user_rec.syus_id + ,p_suca_id => efno_msgsubs.get_suca_id( p_suca_group => 'Notification' + , p_suca_name => 'Service' ) + ,p_email_content_en => caco_utilities.get_module_text(3850, caco_utilities.get_syus_lang(user_rec.syus_id)) + ,p_email_subject_en => caco_utilities.get_module_text(3848, caco_utilities.get_syus_lang(user_rec.syus_id)) + ,p_sms_content_en => caco_utilities.get_module_text(3850, caco_utilities.get_syus_lang(user_rec.syus_id)) + ); + -- + END LOOP; + -- + END IF; + -- + END LOOP; + -- + END daily_message; + -- + -- + -- + PROCEDURE submit_job IS + -- + i_job binary_integer; + -- + BEGIN + -- + dbms_job.submit ( i_job + , 'efno_interruption.daily_message;' + , (TRUNC(SYSDATE-cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24) + 10/24) + , '(TRUNC(SYSDATE-cout_system_configuration.get_configuration_item(''GAS_DAY_OFFSET'')/24) + 10/24)+1' + ); + -- + END submit_job; + -- + /** + -- 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_revision || CHR(10) || g_header); + END about; + -- +-- +BEGIN + -- Initialization + NULL; + -- +END efno_interruption; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$.bdy new file mode 100644 index 0000000..8b1055e --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$.bdy @@ -0,0 +1,426 @@ +create or replace package body efnow050$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +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 + +-- contract_options +-- +-- + + + +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + efnow092$.g_package_name := 'efnow050$'; + -- + efnow092$.contract_options_P( p_contract_id => p_contract_id + , p_success => p_success + , p_error => p_error + , p_err_msg => p_err_msg ); + -- +END; +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 + +-- contract_rules +-- +-- + + + +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + efnow092$.g_package_name := 'efnow050$'; + -- + efnow092$.contract_rules( p_contract_id => p_contract_id + , p_success => p_success + , p_error => p_error + , p_err_msg => p_err_msg ); + -- +END; +PROCEDURE contract_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 VARCHAR2 DEFAULT NULL + , p_pre_contract_id IN contracts.prev_cont_id%TYPE DEFAULT 0 + , 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 efnow092$.g_vc_arr + , p_cate_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_pars_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr ) +IS + +-- contract_startup +-- +-- + + + +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- Set the package name in efnow092$ + efnow092$.g_package_name := 'efnow050$'; + -- + -- Call the contracts startup + efnow092$.startup( p_screen_type => p_screen_type + , p_ins_or_upd => p_ins_or_upd + , p_success => p_success + , p_contract_id => p_contract_id + , p_contract_number => p_contract_number + , p_template_id => p_template_id + , p_template_name => p_template_name + , p_template_desc => p_template_desc + , p_emo => p_emo + , p_customer_id => p_customer_id + , p_spte_id => p_spte_id + , p_ops_contact => p_ops_contact + , p_bus_contact => p_bus_contact + , p_status => p_status + , p_days_before => p_days_before + , p_date_from => p_date_from + , p_date_to => p_date_to + , p_val_window => p_val_window + , p_val_action => p_val_action + , p_val_exception => p_val_exception + , p_lookback_action => p_lookback_action + , p_template_changed => p_template_changed + , p_prev_template_id => p_prev_template_id + , p_error => p_error + , p_err_msg => p_err_msg + , p_nepo_id => p_nepo_id + , p_cate_id => p_cate_id + , p_pars_id => p_pars_id ); + -- +END contract_startup; +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_cnppv_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_value IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_data_error IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr ) +IS + +-- contract_values_p2 +-- +-- + + + +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- Set the package name + efnow092$.g_package_name := 'efnow050$'; + -- + -- Call efno092$ + efnow092$.contract_values_p2( p_contract_id => p_contract_id + , p_page_no => p_page_no + , p_success => p_success + , p_error => p_error + , p_err_msg => p_err_msg + , p_cnppv_id => p_cnppv_id + , p_value => p_value + , p_data_error => p_data_error ); + -- +END; +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 + +-- template_rules +-- +-- + + + +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + efnow092$.g_package_name := 'efnow050$'; + -- + efnow092$.template_rules( p_template_id => p_template_id + , p_success => p_success + , p_error => p_error + , p_err_msg => p_err_msg ); + -- +END; +-------------------------------------------------------------------------------- +-- Name: efnow050$.Startup +-- +-- Description: This procedure is the entry point for the 'efnow050$' +-- module. +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('efnow050$') then + return; + end if; + + WSGL.RegisterURL('efnow050$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, WSGL.MsgGetText(21,WSGLM.CAP021_TOP_LEVEL)); + efnow050$cont.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow050$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow050$.firstpage +-- +-- Description: This procedure creates the first page for the 'efnow050$' +-- module. +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('efnow050$') then + return; + end if; + + WSGL.OpenPageHead(''); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, 'EFNOW060', 0, 'efnow060$.startup',p_output_line=>FALSE, p_target=>'_top'); + WSGL.NavLinks(WSGL.MENU_LONG, 'EFNOW020', 0, 'efnow020$.startup',p_output_line=>FALSE, p_target=>'_top'); + WSGL.NavLinks(WSGL.MENU_LONG, 'EFNOW092', 0, 'efnow092$.startup',p_output_line=>FALSE, p_target=>'_top'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'efnow050$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow050$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow050$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'efnow050$' module. +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('efnow050$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('efnow050$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + + htp.para; + htp.p(' +$Revision: 1.4 $'); + htp.para; + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Nominations', 'EFNOW050', l_usr); + + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow050$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow050$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('efnow050$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow050$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow050$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'efnow050$' module. +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'efnow050$' + , pFirstTitle => '' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow050$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow050$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$.spc new file mode 100644 index 0000000..66156a6 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$.spc @@ -0,0 +1,68 @@ +create or replace package efnow050$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; +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 ); + +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 ); + +PROCEDURE contract_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 VARCHAR2 DEFAULT NULL + , p_pre_contract_id IN contracts.prev_cont_id%TYPE DEFAULT 0 + , 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 efnow092$.g_vc_arr + , p_cate_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_pars_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr ); + +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_cnppv_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_value IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_data_error IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr ); + +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 ); + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$cont.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$cont.bdy new file mode 100644 index 0000000..f052a54 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$cont.bdy @@ -0,0 +1,2117 @@ +create or replace package body efnow050$cont is + + function L_CUST_NAME_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + function BuildSQL( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function PreQuery( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null) return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + QF_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(3,WSGLM.CAP003_QF_FIND); + QF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(4,WSGLM.CAP004_QF_CLEAR); + QF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + QF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + QF_NUMBER_OF_COLUMNS constant number(4) := 1; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + RL_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + RL_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + RL_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + RL_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + RL_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + RL_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(24,WSGLM.CAP024_RL_QUERY); + RL_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + RL_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + RL_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + RL_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + RL_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + RL_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + RL_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + RL_RECORD_SET_SIZE constant number(4) := 0; + RL_TOTAL_COUNT_REQD constant boolean := FALSE; + RL_NUMBER_OF_COLUMNS constant number(4) := 1; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + type FORM_REC is record + (UI_CUST varchar2(24000) + ,UI_CONTRACT varchar2(24000) + ,UI_STATUS varchar2(24000) + ,UI_CONT_FROM varchar2(40) + ,UI_CONT_TO varchar2(40) + ,UI_EDIT_URL varchar2(24000) + ,UI_COPY_URL varchar2(24000) + ,VALID_UNTIL varchar2(12) + ,STATUS varchar2(36) + ,CONTRACT_NUMBER varchar2(180) + ,L_CUST_NAME varchar2(600) + ,CONT_ID varchar2(40) + ,CUST_ID varchar2(40) + ,VALID_FROM varchar2(12) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_UI_CUST WSGOC.ITEM_REF; + R_UI_CONTRACT WSGOC.ITEM_REF; + R_UI_STATUS WSGOC.ITEM_REF; + R_UI_CONT_FROM WSGOC.ITEM_REF; + R_UI_CONT_TO WSGOC.ITEM_REF; + R_UI_EDIT_URL WSGOC.ITEM_REF; + R_UI_COPY_URL WSGOC.ITEM_REF; + R_VALID_UNTIL WSGOC.ITEM_REF; + R_STATUS WSGOC.ITEM_REF; + R_CONTRACT_NUMBER WSGOC.ITEM_REF; + R_L_CUST_NAME WSGOC.ITEM_REF; + R_CONT_ID WSGOC.ITEM_REF; + R_CUST_ID WSGOC.ITEM_REF; + R_VALID_FROM WSGOC.ITEM_REF; + + + +FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- FormatDate +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date,v_mask),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDate; +procedure ncalendar + ( + 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 + +-- ncalendar +-- +-- + + + + + Field_Caption Varchar2 (2000); + + procedure Output_Calendar + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_VALUE in Varchar2, + Z_FIELD_FORMAT in Varchar2, + Page_Header in Varchar2, + Body_Attributes in Varchar2, + PKG_Name in Varchar2, + Close_But_Caption in Varchar2, + First_Part in Boolean, + Z_DEFAULT_FORMAT in varchar2 + ) is + day_of_week Integer := 0; + first_day_of_week Integer := 0; + +function CALJavaScript (field_value in varchar2, field_date_format in varchar2, default_format in varchar2) return varchar2 is + + l_date date; + in_date varchar2 (10); + the_date_field varchar2 (16); + l_valid_date boolean; + l_offset_unit varchar2(4); + l_offset number; + l_sysdate date; + l_territory_offset pls_integer; + +begin + l_valid_date := false; + begin + l_date := to_date( field_value, field_date_format ); + l_valid_date := true; + exception when others then + null; + end; + + if not l_valid_date then + begin + l_date := to_date( field_value, default_format ); + l_valid_date := true; + exception when others then + null; + end; + end if; + + if not l_valid_date then + begin + l_date := to_date( field_value ); + l_valid_date := true; + exception when others then + null; + end; + end if; + + if not l_valid_date then + if substr( field_value, 1, 1 ) in ('+',' ','-') then + l_offset_unit := upper( substr( field_value, 2, 1 ) ); + begin + if l_offset_unit not in ('D','M','Y') then + l_offset := to_number( substr( field_value, 2 ) ); + else + l_offset := to_number( substr( field_value, 3 ) ); + end if; + if substr( field_value, 1, 1 ) = '-' then + l_offset := -1 * l_offset; + end if; + if l_offset_unit = 'D' then + l_date := sysdate + l_offset; + l_valid_date := true; + elsif l_offset_unit = 'M' then + l_date := add_months( sysdate, l_offset ); + l_valid_date := true; + elsif l_offset_unit = 'Y' then + l_date := add_months( sysdate, 12 * l_offset ); + l_valid_date := true; + else + l_date := sysdate + l_offset; + l_valid_date := true; + end if; + exception when others then + null; + end; + end if; + end if; + + if not l_valid_date then + l_date := sysdate; + end if; + + -- Internal date format that MUST NOT be changed - this is the same format that the JS uses to + -- parse an incoming date from the field. + in_date := to_char (l_date, 'MM-DD-YYYY'); + + if in_date is null then + the_date_field := 'dateField.value'; + else + the_date_field := '''' || in_date || ''''; + end if; + + -- Calculate the offset necessary due to territorial differences in the first day of the week. + -- We know that 31st October 1999 is a Sunday, so we can see what day of the week the database thinks this is + select to_number(to_char(to_date('31-10-1999','DD-MM-YYYY'),'D'))-1 into l_territory_offset from dual; + + return ' +function setDate() { + this.dateField = opener.dateField; + this.inDate = ' || the_date_field || '; + + // SET DAY MONTH AND YEAR TO TODAYS DATE + var now = new Date(); + var day = now.getDate(); + var month = now.getMonth(); + var year = now.getFullYear(); + + // IF A DATE WAS PASSED IN THEN PARSE THAT DATE + if (inDate.indexOf(''-'')) { + var inMonth = inDate.substring(0,inDate.indexOf("-")); + if (inMonth.substring(0,1) == "0" && inMonth.length > 1) + inMonth = inMonth.substring(1,inMonth.length); + inMonth = parseInt(inMonth); + var inDay = inDate.substring(inDate.indexOf("-") + 1, inDate.lastIndexOf("-")); + if (inDay.substring(0,1) == "0" && inDay.length > 1) + inDay = inDay.substring(1,inDay.length); + inDay = parseInt(inDay); + var inYear = parseInt(inDate.substring(inDate.lastIndexOf("-") + 1, inDate.length)); + + if (inDay) { + day = inDay; + } + if (inMonth) { + month = inMonth-1; + } + if (inYear) { + year = inYear; + } + } + this.focusDay = day; + document.calControl.month.selectedIndex = month; + document.calControl.year.value = year; + displayCalendar(day, month, year); +} + + +function setToday() { + // SET DAY MONTH AND YEAR TO TODAYS DATE + var now = new Date(); + var day = now.getDate(); + var month = now.getMonth(); + var year = now.getFullYear(); + + this.focusDay = day; + document.calControl.month.selectedIndex = month; + document.calControl.year.value = year; + displayCalendar(day, month, year); +} + + +function isFourDigitYear(year) { + if (year.length != 4 || isNaN(year)) { + alert ("'||WSGL.MsgGetText(234,WSGLM.MSG234_FOUR_DIGIT_YEAR)||'"); + document.calControl.year.select(); + document.calControl.year.focus(); + } + else { + return true; + } +} + + +function selectDate() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + displayCalendar(day, month, year); + } +} + + +function setPreviousYear() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + year--; + document.calControl.year.value = year; + displayCalendar(day, month, year); + } +} + + +function setPreviousMonth() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + if (month == 0) { + month = 11; + if (year > 1000) { + year--; + document.calControl.year.value = year; + } + } + else { + month--; + } + document.calControl.month.selectedIndex = month; + displayCalendar(day, month, year); + } +} + + +function setNextMonth() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + if (month == 11) { + month = 0; + year++; + document.calControl.year.value = year; + } + else { + month++; + } + document.calControl.month.selectedIndex = month; + displayCalendar(day, month, year); + } +} + + +function setNextYear() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + year++; + document.calControl.year.value = year; + displayCalendar(day, month, year); + } +} + + +function displayCalendar(day, month, year) { + + day = parseInt(day); + month = parseInt(month); + year = parseInt(year); + var i = 0; + var offset = 11; + var now = new Date(); + + if (day == 0) { + var nowDay = now.getDate(); + } + else { + var nowDay = day; + } + var days = getDaysInMonth(month+1,year); + var firstOfMonth = new Date (year, month, 1); + var startingPos = (firstOfMonth.getDay()+'||l_territory_offset||')%7; + days += startingPos; + + // MAKE BEGINNING NON-DATE BUTTONS BLANK + for (i = 0; i < startingPos; i++) { + document.calControl.elements[i + offset].value = "__"; + } + + // SET VALUES FOR DAYS OF THE MONTH + for (i = startingPos; i < days; i++) + { + var datestr = (i-startingPos+1) + ""; + if ((i-startingPos+1) < 10) + { + datestr = "0" + datestr; + } + document.calControl.elements[i + offset].value = datestr; + document.calControl.elements[i + offset].onClick = "returnDate" + } + + // MAKE REMAINING NON-DATE BUTTONS BLANK + for (i=days; i<42; i++) { + document.calControl.elements[i + offset].value = "__"; + } + + // GIVE FOCUS TO CORRECT DAY + document.calControl.elements[focusDay+startingPos-1 + offset].focus(); + document.calControl.day.value = day; + +} + + +// GET NUMBER OF DAYS IN MONTH +function getDaysInMonth(month,year) { + var days; + if (month==1 || month==3 || month==5 || month==7 || month==8 || + month==10 || month==12) days=31; + else if (month==4 || month==6 || month==9 || month==11) days=30; + else if (month==2) { + if (isLeapYear(year)) { + days=29; + } + else { + days=28; + } + } + return (days); +} + + +// CHECK TO SEE IF YEAR IS A LEAP YEAR +function isLeapYear (Year) { + if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) { + return (true); + } + else { + return (false); + } +} + + +// SET FORM FIELD VALUE TO THE DATE SELECTED +function returnDate(inDay) +{ + var day = inDay; + var month = (document.calControl.month.selectedIndex)+1; + var year = document.calControl.year.value; + + if ((""+month).length == 1) + { + month="0"+month; + } + if ((""+day).length == 1) + { + day="0"+day; + } + if (day != "__") { + document.calControl.day.value = day; + document.calControl.submit(); + } +} +'; + +end CALJavaScript; + +begin + if First_Part + then + -- Output the HTML that needs to go before the user defined template header + wsgl.OpenPageHead (Page_Header); + htp.p (WSGJSL.OpenScript); + htp.p ('function Close_OnClick() { close(); }'); + htp.p (CALJavaScript (Z_FIELD_VALUE, Z_FIELD_FORMAT, Z_DEFAULT_FORMAT)); + htp.p (WSGJSL.CloseScript); + else + -- The rest of the calendar comes after the user defined template header + wsgl.ClosePageHead; + wsgl.OpenPageBody(FALSE, p_attributes => Body_Attributes || ' ONLOAD="setDate()"'); + htp.header(2, htf.italic(Page_Header)); + htp.formOpen(curl=> PKG_Name || '.nformat_cal_date', cattributes => 'name="calControl"'); + wsgl.HiddenField('Z_FIELD_NAME', Z_FIELD_NAME); + wsgl.HiddenField('Z_FIELD_FORMAT', Z_FIELD_FORMAT); + wsgl.HiddenField('day', 1); + htp.p(''); + -- Create the calendar + htp.p (' +
+ +'); + -- Now display the movement buttons + htp.p (' + + + +'); + -- Display the days of the week along the top of the calendar + htp.p (''); + -- Find the first day of the week + day_of_week := to_number (to_char (to_date ('1', 'DD'), 'D')); + first_day_of_week := (8 - day_of_week) + 1; + for i in first_day_of_week..(first_day_of_week + 6) + loop + htp.prn (''); + end loop; + htp.p (''); + -- Now display a button for each day on the calendar + -- The calendar is made up of 6 rows + for i in 1..6 + loop + htp.p (''); + for j in 1..7 + loop + -- 7 days in each row + htp.p (''); + end loop; -- j in 1..7 + htp.p (''); + end loop; -- i in 1..6 + htp.p ('
+
+'); + -- Create the month drop down + htp.formSelectOpen (cname => 'month', cattributes => 'onChange=''selectDate()'''||' ID="month"'); + -- Output the names of the months in the appropriate language for the database - NLS Compliance + for i in 1..12 + loop + htp.formSelectOption (initcap (to_char (to_date (i, 'MM'), 'MONTH'))); + end loop; + htp.formSelectClose; + -- Now the year field + htp.p (''); + -- Finish this part of the table + htp.p ('
+
+ + + + + +
+
'); + htp.prn (initcap (substr (to_char (to_date (i, 'DD'), 'DAY'), 1, 2))); + htp.p ('
'); + htp.formclose; + wsgl.ClosePageBody; + end if; -- First_Part +end Output_Calendar; + + + + 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('efnow050$cont.calendar'); + WSGL.AddURLParam('Z_FIELD_NAME', Z_FIELD_NAME); + WSGL.AddURLParam('Z_CALLER_URL', Z_CALLER_URL); + + if WSGL.NotLowerCase then + return; + end if; + + Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow050$cont', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow050$.TemplateHeader(TRUE,7); + + Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow050$cont', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow050$cont.calendar'); + end ncalendar; +procedure nformat_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ) IS + +-- nformat_cal_date +-- +-- + + + + + Field_Caption Varchar2 (2000) := initcap (replace (substr (Z_FIELD_NAME, 3, length (Z_FIELD_NAME) - 2), '_', ' ')); + l_day varchar2(15) := day; + l_date_fmt VARCHAR2(255) := NVL(cout_system_configuration.get_configuration_item('G_DATE_FORMAT'),'DD-MON-YYYY'); + +procedure Output_Format_Cal_JS + ( + Page_Header in Varchar2, + Body_Attributes in Varchar2, + Chosen_Date in Varchar2, + Field_Format in Varchar2 + ) is + -- This date format mask is internal and *intentional* DO NOT CHANGE + -- DD for day number + -- MONTH for actual text supplied by calendar drop down list + -- YYYY y2k compliant year + 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), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + --Z_FIELD_FORMAT + l_date_fmt + ); + +end nformat_cal_date; +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.L_CUST_NAME_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'L_CUST_NAME'. +-- +-- +-------------------------------------------------------------------------------- + function L_CUST_NAME_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT DISTINCT L_CUST.NAME L_CUST_NAME, + L_CUST.NAME CG$DISPLAY +FROM CUSTOMERS L_CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START CONT.L_CUST */ + (( EXISTS ( SELECT cust1.cust_id FROM customer_intermediaries cuin1 , customers cust1 , customer_types cuty WHERE cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND l_cust.cust_id = cust1.cust_id AND cuty.cuty_id = caco_utilities.cuty_id_for_user AND cust1.cust_id != caco_utilities.get_system_customer ) OR caco_utilities.user_has_system = 'Y' )) + /* CG$MDTU_QWC_END CONT.L_CUST */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START CONT.L_CUST */ + (( EXISTS ( SELECT cust1.cust_id FROM customer_intermediaries cuin1 , customers cust1 , customer_types cuty WHERE cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND l_cust.cust_id = cust1.cust_id AND cuty.cuty_id = caco_utilities.cuty_id_for_user AND cust1.cust_id != caco_utilities.get_system_customer ) OR caco_utilities.user_has_system = 'Y' )) + /* CG$MDTU_VWC_END CONT.L_CUST */ + ) + ) + ) +ORDER BY L_CUST.NAME +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return L_CUST_NAME_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return L_CUST_NAME_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return L_CUST_NAME_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return L_CUST_NAME_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return L_CUST_NAME_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_L_CUST_NAME', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_L_CUST_NAME'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_L_CUST_NAME', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_L_CUST_NAME'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.L_CUST_NAME) = P_VALUE) or c1rec.L_CUST_NAME = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_CUST_NAME)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_CUST_NAME)||'"'); + end if; + l_first := false; + end loop; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.L_CUST_NAME_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.InitialiseDomain +-- +-- Description: Initialises the Domain Record for the given Column Usage +-- +-- Parameters: P_ALIAS The alias of the column usage +-- +-------------------------------------------------------------------------------- + procedure InitialiseDomain(P_ALIAS in varchar2) is + begin + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + if P_ALIAS = 'STATUS' and not D_STATUS.Initialised then + D_STATUS.ColAlias := 'STATUS'; + D_STATUS.ControlType := WSGL.DV_LIST; + D_STATUS.DispWidth := 6; + D_STATUS.DispHeight := 1; + D_STATUS.MaxWidth := 6; + D_STATUS.UseMeanings := True; + D_STATUS.ColOptional := False; + D_STATUS.Vals(1) := 'O'; + D_STATUS.Meanings(1) := 'Open'; + D_STATUS.Abbreviations(1) := 'Open'; + D_STATUS.Vals(2) := 'C'; + D_STATUS.Meanings(2) := 'Closed'; + D_STATUS.Abbreviations(2) := 'Closed'; + D_STATUS.NumOfVV := 2; + D_STATUS.Initialised := True; + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.InitialseDomain'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow050$cont.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), + CAL_BODY_ATTRIBUTES, + 'efnow050$cont', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow050$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow050$cont', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow050$cont.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.Startup +-- +-- Description: Entry point for the 'CONT' module +-- component (#Maintain Contracts#2080#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + WSGL.RegisterURL('efnow050$cont.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, '#Maintain Contracts#2080#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'QUERY' then + FormQuery( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + if Z_FORM = 'LIST' then + QueryList( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + FormQuery( + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.ActionQuery +-- +-- Description: Called when a Query form is subitted to action the query request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionQuery( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2, + Z_CHK in varchar2 ) is + + L_CHK varchar2(10) := Z_CHK; + L_BUTCHK varchar2(100):= null; + l_dummy_bool boolean := false; + begin + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + end if; + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + QueryList( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM, + Z_START=>null, + Z_ACTION=>L_BUTCHK, + Z_DIRECT_CALL=>TRUE); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.ActionQuery'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2) return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow050$cont') then + return -1; + end if; + + if not BuildSQL(P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + return -1; + end if; + + if not PreQuery(P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Contracts#2080#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.BuildSQL +-- +-- Description: Builds the SQL for the 'CONT' module component (#Maintain Contracts#2080#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + InitialiseDomain('STATUS'); + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE CONT_ID = ' || to_char(CURR_VAL.CONT_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + WSGL.BuildWhere(WSGL.DomainValue(D_STATUS, P_STATUS), 'STATUS', WSGL.TYPE_CHAR, I_WHERE); + WSGL.BuildWhere(P_CONTRACT_NUMBER, 'CONTRACT_NUMBER', WSGL.TYPE_CHAR, I_WHERE); + WSGL.BuildWhere(P_L_CUST_NAME, 'L_CUST_NAME', WSGL.TYPE_CHAR, I_WHERE); + begin + WSGL.BuildWhere(P_VALID_FROM, U_VALID_FROM, 'VALID_FROM', WSGL.TYPE_DATE, I_WHERE, 'DD.MM.YYYY'); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_ERROR_QRY, SQLERRM, + ''||' : '||'#Maintain Contracts#2080#', DEF_BODY_ATTRIBUTES, NULL, + WSGL.MsgGetText(210,WSGLM.MSG210_INVALID_QRY,'#Valid From#2441#'), + WSGL.MsgGetText(211,WSGLM.MSG211_EXAMPLE_TODAY,to_char(sysdate, 'DD.MM.YYYY'))); + return false; + end; + + end if; + + ZONE_SQL := 'SELECT UI_CUST, + UI_CONTRACT, + UI_STATUS, + UI_CONT_FROM, + UI_CONT_TO, + UI_EDIT_URL, + UI_COPY_URL, + VALID_UNTIL, + STATUS, + CONTRACT_NUMBER, + L_CUST_NAME, + CONT_ID, + CUST_ID, + VALID_FROM + FROM ( SELECT L_CUST.NAME UI_CUST, + CONT.CONTRACT_NUMBER UI_CONTRACT, + DECODE(CONT.STATUS,''O'',''Open'',''Closed'') UI_STATUS, + CONT.VALID_FROM UI_CONT_FROM, + CONT.VALID_UNTIL UI_CONT_TO, + ''efnow050$.contract_startup?p_screen_type=CONTRACT&p_contract_id=''||CONT.CONT_ID UI_EDIT_URL, + ''efno_contracts.efnow050$copy?p_contract_id=''||CONT.CONT_ID UI_COPY_URL, + CONT.VALID_UNTIL VALID_UNTIL, + CONT.STATUS STATUS, + CONT.CONTRACT_NUMBER CONTRACT_NUMBER, + L_CUST.NAME L_CUST_NAME, + CONT.CONT_ID CONT_ID, + CONT.CUST_ID CUST_ID, + CONT.VALID_FROM VALID_FROM +FROM CONTRACTS CONT, + CUSTOMERS L_CUST +WHERE ( /* CG$MDTU_QWC_START CONT.L_CUST */ + (( EXISTS ( SELECT cust1.cust_id FROM customer_intermediaries cuin1 , customers cust1 , customer_types cuty WHERE cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND l_cust.cust_id = cust1.cust_id AND cuty.cuty_id = caco_utilities.cuty_id_for_user AND cust1.cust_id != caco_utilities.get_system_customer ) OR caco_utilities.user_has_system = ''Y'' )) + /* CG$MDTU_QWC_END CONT.L_CUST */ + ) AND + CONT.CUST_ID = L_CUST.CUST_ID + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY L_CUST_NAME, + VALID_FROM'; + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'CONT' module component (#Maintain Contracts#2080#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, NBT_VAL.UI_CUST, 4000); + dbms_sql.define_column(I_CURSOR, 2, NBT_VAL.UI_CONTRACT, 4000); + dbms_sql.define_column(I_CURSOR, 3, NBT_VAL.UI_STATUS, 4000); + dbms_sql.define_column(I_CURSOR, 4, NBT_VAL.UI_CONT_FROM); + dbms_sql.define_column(I_CURSOR, 5, NBT_VAL.UI_CONT_TO); + dbms_sql.define_column(I_CURSOR, 6, NBT_VAL.UI_EDIT_URL, 4000); + dbms_sql.define_column(I_CURSOR, 7, NBT_VAL.UI_COPY_URL, 4000); + dbms_sql.define_column(I_CURSOR, 8, CURR_VAL.VALID_UNTIL); + dbms_sql.define_column(I_CURSOR, 9, CURR_VAL.STATUS, 1); + dbms_sql.define_column(I_CURSOR, 10, CURR_VAL.CONTRACT_NUMBER, 30); + dbms_sql.define_column(I_CURSOR, 11, NBT_VAL.L_CUST_NAME, 100); + dbms_sql.define_column(I_CURSOR, 12, CURR_VAL.CONT_ID); + dbms_sql.define_column(I_CURSOR, 13, CURR_VAL.CUST_ID); + dbms_sql.define_column(I_CURSOR, 14, CURR_VAL.VALID_FROM); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + '', 'efnow050$cont.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'CONT' module component (#Maintain Contracts#2080#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, NBT_VAL.UI_CUST); + dbms_sql.column_value(I_CURSOR, 2, NBT_VAL.UI_CONTRACT); + dbms_sql.column_value(I_CURSOR, 3, NBT_VAL.UI_STATUS); + dbms_sql.column_value(I_CURSOR, 4, NBT_VAL.UI_CONT_FROM); + dbms_sql.column_value(I_CURSOR, 5, NBT_VAL.UI_CONT_TO); + dbms_sql.column_value(I_CURSOR, 6, NBT_VAL.UI_EDIT_URL); + dbms_sql.column_value(I_CURSOR, 7, NBT_VAL.UI_COPY_URL); + dbms_sql.column_value(I_CURSOR, 8, CURR_VAL.VALID_UNTIL); + dbms_sql.column_value(I_CURSOR, 9, CURR_VAL.STATUS); + dbms_sql.column_value(I_CURSOR, 10, CURR_VAL.CONTRACT_NUMBER); + dbms_sql.column_value(I_CURSOR, 11, NBT_VAL.L_CUST_NAME); + dbms_sql.column_value(I_CURSOR, 12, CURR_VAL.CONT_ID); + dbms_sql.column_value(I_CURSOR, 13, CURR_VAL.CUST_ID); + dbms_sql.column_value(I_CURSOR, 14, CURR_VAL.VALID_FROM); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.CONT_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + '', 'efnow050$cont.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.FormQuery +-- +-- Description: This procedure builds an HTML form for entry of query criteria. +-- The criteria entered are to restrict the query of the 'CONT' +-- module component (#Maintain Contracts#2080#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormQuery( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + L_SUCCESS boolean := TRUE; + begin + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + end if; + + L_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + WSGL.OpenPageHead(''||' : '||'#Maintain Contracts#2080#'); + WSGL.METATag; + efnow050$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>QF_BODY_ATTRIBUTES || 'onLoad="return CONT_OnLoad()"'); + efnow050$js$cont.CreateQueryJavaScript(LOV_FRAME,QF_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + htp.p(caco_system.menu); + efnow050$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + htp.p(WSGL.MsgGetText(116,WSGLM.DSP116_ENTER_QRY_CAPTION,'#Maintain Contracts#2080#')); + htp.para; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow050$cont.actionquery', cattributes => 'NAME="efnow050$cont$QForm"'); + + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + for i in 1..QF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(23, 'LEFT', NULL); + WSGL.LayoutHeader(40, 'LEFT', NULL); + end loop; + WSGL.LayoutRowEnd; + + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Status#2114#:')); + InitialiseDomain('STATUS'); + WSGL.LayoutData(WSGL.BuildDVControl(D_STATUS, WSGL.CTL_QUERY)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Contract Number#2013#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('CONTRACT_NUMBER', '30', FALSE, p_maxlength=>'30')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Name#116#:')); + WSGL.LayoutData(L_CUST_NAME_LOV(NULL, WSGL.CTL_QUERY, 'Q', true)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Valid From#2441#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('VALID_FROM', '11', TRUE, p_maxlength=>'10' + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_date_format => 'DD.MM.YYYY' + , p_cal_prompt => '#Valid From#2441#' + , p_form=>'efnow050$cont$QForm')); + WSGL.LayoutRowEnd; + + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', htf.escape_sc(QF_QUERY_BUT_CAPTION), 'btnQFQ', 'this.form.Z_ACTION.value=\''' || QF_QUERY_BUT_ACTION || '\'''); + htp.formReset(htf.escape_sc(QF_CLEAR_BUT_CAPTION), 'ID="'||htf.escape_sc(QF_CLEAR_BUT_CAPTION)||'"'); + + + WSGL.HiddenField('Z_CHK', to_char(WSGL.Checksum + (''))); + htp.formClose; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="QF$AIFormBottom"'); + htp.formClose; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + QF_BODY_ATTRIBUTES, 'efnow050$cont.FormQuery'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.QueryList +-- +-- Description: This procedure builds the Record list for the 'CONT' +-- module component (#Maintain Contracts#2080#). +-- +-- The Record List displays context information for records which +-- match the specified query criteria. +-- Sets of records are displayed (0 records at a time) +-- with Next/Previous buttons to get other record sets. +-- +-- Parameters: P_STATUS - #Status#2114# +-- P_CONTRACT_NUMBER - #Contract Number#2013# +-- P_L_CUST_NAME - #Name#116# +-- P_VALID_FROM - #Valid From#2441# +-- U_VALID_FROM - #Valid From#2441# (upper bound) +-- Z_START - First record to display +-- Z_ACTION - Next or Previous set +-- +-------------------------------------------------------------------------------- + procedure QueryList( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2 ) is + + I_VF_FRAME varchar2(20) := null; + I_WHERE varchar2(2000) := ''; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + I_TOTAL_ROWS integer := 0; + I_START number(38) := to_number(Z_START); + I_COUNT number(10) := 0; + I_OF_TOTAL_TEXT varchar2(200) := ''; + I_NEXT_BUT boolean; + I_PREV_BUT boolean; + I_COL_COUNT integer; + I_SUCCESS boolean := true; + l_row integer := 0; + l_id varchar2(35) := null; + -- Reset break group? + RSIG_CUST boolean := true; + -- Reset break group? + RSIG_REST boolean := true; + I_LAST_BASE CURR_VAL%TYPE; + I_LAST_NBT NBT_REC; + + + + begin + + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + + WSGL.RegisterURL('efnow050$cont.querylist'); + WSGL.AddURLParam('P_STATUS', P_STATUS); + WSGL.AddURLParam('P_CONTRACT_NUMBER', P_CONTRACT_NUMBER); + WSGL.AddURLParam('P_L_CUST_NAME', P_L_CUST_NAME); + WSGL.AddURLParam('P_VALID_FROM', P_VALID_FROM); + WSGL.AddURLParam('U_VALID_FROM', U_VALID_FROM); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if (not Z_DIRECT_CALL) then + + null; + + + end if; + if (Z_ACTION = RL_QUERY_BUT_ACTION) or (Z_ACTION = RL_QUERY_BUT_CAPTION) then + FormQuery( + Z_DIRECT_CALL=>TRUE); + return; + end if; + + -- Set up any master context values that may be required + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + + + WSGL.OpenPageHead(''||' : '||'#Maintain Contracts#2080#'); + WSGL.METATag; + efnow050$.TemplateHeader(TRUE,6); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>RL_BODY_ATTRIBUTES); + efnow050$js$cont.CreateListJavaScript(RL_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) or + (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + (RL_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + RL_TOTAL_COUNT_REQD then + I_OF_TOTAL_TEXT := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + I_START := 1; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + + if ZONE_SQL IS NULL then + if not BuildSQL( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + WSGL.ClosePageBody; + return; + end if; + end if; + + if not PreQuery( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Contracts#2080#', RL_BODY_ATTRIBUTES); + return; + end if; + + InitialiseDomain('STATUS'); + + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := 0; + end if; + I_TOTAL_ROWS := I_ROWS_FETCHED; + + if I_ROWS_FETCHED != 0 then + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, P_BORDER=>TRUE); + + WSGL.LayoutRowStart(p_attrs=>'class = cgrlheaderrow'); + for i in 1..RL_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(30, 'LEFT', '#Customer#1047#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Contract Name#2082#',''); + WSGL.LayoutHeader(10, 'LEFT', '#Status#2114#',''); + WSGL.LayoutHeader(11, 'LEFT', '#Valid From#2441#',''); + WSGL.LayoutHeader(11, 'LEFT', '#Valid To#2442#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Edit#2008#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Copy#3547#',''); + end loop; + WSGL.LayoutRowEnd; + + while I_ROWS_FETCHED <> 0 loop + + if I_TOTAL_ROWS >= I_START then + AssignZoneRow(I_CURSOR); + + if (NBT_VAL.UI_CUST != I_LAST_NBT.UI_CUST or (NBT_VAL.UI_CUST is null and I_LAST_NBT.UI_CUST is not null) or (NBT_VAL.UI_CUST is not null and I_LAST_NBT.UI_CUST is null) ) then + RSIG_CUST := true; + else + RSIG_CUST := false; + end if; + if (CURR_VAL.VALID_UNTIL != I_LAST_BASE.VALID_UNTIL or (CURR_VAL.VALID_UNTIL is null and I_LAST_BASE.VALID_UNTIL is not null) or (CURR_VAL.VALID_UNTIL is not null and I_LAST_BASE.VALID_UNTIL is null) ) or + (CURR_VAL.STATUS != I_LAST_BASE.STATUS or (CURR_VAL.STATUS is null and I_LAST_BASE.STATUS is not null) or (CURR_VAL.STATUS is not null and I_LAST_BASE.STATUS is null) ) or + (CURR_VAL.CONTRACT_NUMBER != I_LAST_BASE.CONTRACT_NUMBER or (CURR_VAL.CONTRACT_NUMBER is null and I_LAST_BASE.CONTRACT_NUMBER is not null) or (CURR_VAL.CONTRACT_NUMBER is not null and I_LAST_BASE.CONTRACT_NUMBER is null) ) or + (NBT_VAL.L_CUST_NAME != I_LAST_NBT.L_CUST_NAME or (NBT_VAL.L_CUST_NAME is null and I_LAST_NBT.L_CUST_NAME is not null) or (NBT_VAL.L_CUST_NAME is not null and I_LAST_NBT.L_CUST_NAME is null) ) or + (CURR_VAL.CONT_ID != I_LAST_BASE.CONT_ID or (CURR_VAL.CONT_ID is null and I_LAST_BASE.CONT_ID is not null) or (CURR_VAL.CONT_ID is not null and I_LAST_BASE.CONT_ID is null) ) or + (CURR_VAL.CUST_ID != I_LAST_BASE.CUST_ID or (CURR_VAL.CUST_ID is null and I_LAST_BASE.CUST_ID is not null) or (CURR_VAL.CUST_ID is not null and I_LAST_BASE.CUST_ID is null) ) or + (CURR_VAL.VALID_FROM != I_LAST_BASE.VALID_FROM or (CURR_VAL.VALID_FROM is null and I_LAST_BASE.VALID_FROM is not null) or (CURR_VAL.VALID_FROM is not null and I_LAST_BASE.VALID_FROM is null) ) or + (NBT_VAL.UI_CONTRACT != I_LAST_NBT.UI_CONTRACT or (NBT_VAL.UI_CONTRACT is null and I_LAST_NBT.UI_CONTRACT is not null) or (NBT_VAL.UI_CONTRACT is not null and I_LAST_NBT.UI_CONTRACT is null) ) or + (NBT_VAL.UI_STATUS != I_LAST_NBT.UI_STATUS or (NBT_VAL.UI_STATUS is null and I_LAST_NBT.UI_STATUS is not null) or (NBT_VAL.UI_STATUS is not null and I_LAST_NBT.UI_STATUS is null) ) or + (NBT_VAL.UI_CONT_FROM != I_LAST_NBT.UI_CONT_FROM or (NBT_VAL.UI_CONT_FROM is null and I_LAST_NBT.UI_CONT_FROM is not null) or (NBT_VAL.UI_CONT_FROM is not null and I_LAST_NBT.UI_CONT_FROM is null) ) or + (NBT_VAL.UI_CONT_TO != I_LAST_NBT.UI_CONT_TO or (NBT_VAL.UI_CONT_TO is null and I_LAST_NBT.UI_CONT_TO is not null) or (NBT_VAL.UI_CONT_TO is not null and I_LAST_NBT.UI_CONT_TO is null) ) or + (NBT_VAL.UI_EDIT_URL != I_LAST_NBT.UI_EDIT_URL or (NBT_VAL.UI_EDIT_URL is null and I_LAST_NBT.UI_EDIT_URL is not null) or (NBT_VAL.UI_EDIT_URL is not null and I_LAST_NBT.UI_EDIT_URL is null) ) or + (NBT_VAL.UI_COPY_URL != I_LAST_NBT.UI_COPY_URL or (NBT_VAL.UI_COPY_URL is null and I_LAST_NBT.UI_COPY_URL is not null) or (NBT_VAL.UI_COPY_URL is not null and I_LAST_NBT.UI_COPY_URL is null) ) then + RSIG_REST := true; + else + RSIG_REST := false; + end if; + if RSIG_CUST then + RSIG_REST := true; + end if; + + + I_LAST_NBT.UI_CUST := NBT_VAL.UI_CUST; + I_LAST_BASE.VALID_UNTIL := CURR_VAL.VALID_UNTIL; + I_LAST_BASE.STATUS := CURR_VAL.STATUS; + I_LAST_BASE.CONTRACT_NUMBER := CURR_VAL.CONTRACT_NUMBER; + I_LAST_NBT.L_CUST_NAME := NBT_VAL.L_CUST_NAME; + I_LAST_BASE.CONT_ID := CURR_VAL.CONT_ID; + I_LAST_BASE.CUST_ID := CURR_VAL.CUST_ID; + I_LAST_BASE.VALID_FROM := CURR_VAL.VALID_FROM; + I_LAST_NBT.UI_CONTRACT := NBT_VAL.UI_CONTRACT; + I_LAST_NBT.UI_STATUS := NBT_VAL.UI_STATUS; + I_LAST_NBT.UI_CONT_FROM := NBT_VAL.UI_CONT_FROM; + I_LAST_NBT.UI_CONT_TO := NBT_VAL.UI_CONT_TO; + I_LAST_NBT.UI_EDIT_URL := NBT_VAL.UI_EDIT_URL; + I_LAST_NBT.UI_COPY_URL := NBT_VAL.UI_COPY_URL; + l_row := l_row + 1; + + + WSGL.LayoutRowStart('TOP', p_attrs=>'class = cgrldatarow'); + l_id := '' || l_row; + if RSIG_CUST and NBT_VAL.UI_CUST is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_CUST), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_CONTRACT is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_CONTRACT), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_STATUS is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_STATUS), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_CONT_FROM is not null then + WSGL.LayoutData(p_text=>EFNOW050$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_FROM, 'DD-MON-RRRR')))), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_CONT_TO is not null then + WSGL.LayoutData(p_text=>EFNOW050$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_TO, 'DD-MON-RRRR')))), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_EDIT_URL is not null then + WSGL.LayoutData(p_text=>replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_EDIT_URL), '#Edit#2008#'), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_COPY_URL is not null then + WSGL.LayoutData(p_text=>replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_COPY_URL), '#Copy#3547#'), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + + WSGL.LayoutRowEnd; + + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + end if; + + I_TOTAL_ROWS := I_TOTAL_ROWS + I_ROWS_FETCHED; + + end loop; + + WSGL.LayoutClose; + + if I_START = I_TOTAL_ROWS then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_TOTAL_ROWS))||I_OF_TOTAL_TEXT); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(I_TOTAL_ROWS))|| + I_OF_TOTAL_TEXT); + end if; + htp.para; + else + htp.p(WSGL.MsgGetText(112,WSGLM.DSP112_NO_RECORDS)); + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + dbms_sql.close_cursor(I_CURSOR); + end if; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow050$cont.querylist', cattributes => 'NAME="efnow050$cont$LForm"'); + SaveState; + WSGL.HiddenField('P_STATUS', P_STATUS); + WSGL.HiddenField('P_CONTRACT_NUMBER', P_CONTRACT_NUMBER); + WSGL.HiddenField('P_L_CUST_NAME', P_L_CUST_NAME); + WSGL.HiddenField('P_VALID_FROM', P_VALID_FROM); + WSGL.HiddenField('U_VALID_FROM', U_VALID_FROM); + WSGL.HiddenField('Z_START', to_char(I_START)); + htp.p (''); + + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_FIRST_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_FIRST_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_PREV_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_PREV_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_NEXT_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_NEXT_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_LAST_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_LAST_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_REQUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_REQUERY_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_COUNT_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_COUNT_BUT_ACTION || '\''"'); + htp.para; + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_QUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_QUERY_BUT_ACTION || '\''"'); + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''))); + htp.formClose; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="RL$AIFormBottom"'); + htp.para; + WSGL.SubmitButton('Z_ACTION', '#New Contract#2085#', 'AI_NEW_CONTRACT', p_target=>'_top'); + htp.formClose; + WSGL.ReturnLinks('0.1', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + RL_BODY_ATTRIBUTES, 'efnow050$cont.QueryList'); + WSGL.ClosePageBody; + end; +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'CONT' module component (#Maintain Contracts#2080#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.CONT_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + '', 'efnow050$cont.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.SaveState +-- +-- Description: Saves the data state for the 'CONT' module component (#Maintain Contracts#2080#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + '', 'efnow050$cont.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.LoadCache +-- +-- Description: Populate the object cache with +-- 'CONT' module component (#Maintain Contracts#2080#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + InitialiseDomain('STATUS'); + + ref_Component := WSGOC.Component + ( pModule => efnow050$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'CONT' + , pTitle => '#Maintain Contracts#2080#' + , pSystemImagePath=> '/images/' + ); + + r_UI_CUST := WSGOC.Item + ( pName => 'UI_CUST' + , pPrompt => '#Customer#1047#' + , pIsContext=> true + ); + r_UI_CONTRACT := WSGOC.Item + ( pName => 'UI_CONTRACT' + , pPrompt => '#Contract Name#2082#' + , pIsContext=> true + ); + r_UI_STATUS := WSGOC.Item + ( pName => 'UI_STATUS' + , pPrompt => '#Status#2114#' + , pIsContext=> true + ); + r_UI_CONT_FROM := WSGOC.Item + ( pName => 'UI_CONT_FROM' + , pPrompt => '#Valid From#2441#' + , pIsContext=> true + ); + r_UI_CONT_TO := WSGOC.Item + ( pName => 'UI_CONT_TO' + , pPrompt => '#Valid To#2442#' + , pIsContext=> true + ); + r_UI_EDIT_URL := WSGOC.Item + ( pName => 'UI_EDIT_URL' + , pPrompt => '#Edit#2008#' + , pIsContext=> true + ); + r_UI_COPY_URL := WSGOC.Item + ( pName => 'UI_COPY_URL' + , pPrompt => '#Copy#3547#' + , pIsContext=> true + ); + r_VALID_UNTIL := WSGOC.Item + ( pName => 'VALID_UNTIL' + , pPrompt => '#Valid Until#2440#' + ); + r_STATUS := WSGOC.Item + ( pName => 'STATUS' + , pPrompt => '#Status#2114#' + ); + r_CONTRACT_NUMBER := WSGOC.Item + ( pName => 'CONTRACT_NUMBER' + , pPrompt => '#Contract Number#2013#' + ); + r_L_CUST_NAME := WSGOC.Item + ( pName => 'L_CUST_NAME' + , pPrompt => '#Name#116#' + ); + r_CONT_ID := WSGOC.Item + ( pName => 'CONT_ID' + , pPrompt => '#Cont Id#2443#' + ); + r_CUST_ID := WSGOC.Item + ( pName => 'CUST_ID' + , pPrompt => 'Cust Id' + ); + r_VALID_FROM := WSGOC.Item + ( pName => 'VALID_FROM' + , pPrompt => '#Valid From#2441#' + ); + + WSGOC.Add_Items(ref_Component, r_UI_CUST); + WSGOC.Add_Items(ref_Component, r_UI_CONTRACT); + WSGOC.Add_Items(ref_Component, r_UI_STATUS); + WSGOC.Add_Items(ref_Component, r_UI_CONT_FROM); + WSGOC.Add_Items(ref_Component, r_UI_CONT_TO); + WSGOC.Add_Items(ref_Component, r_UI_EDIT_URL); + WSGOC.Add_Items(ref_Component, r_UI_COPY_URL); + WSGOC.Add_Items(ref_Component, r_VALID_UNTIL); + WSGOC.Add_Items(ref_Component, r_STATUS); + WSGOC.Add_Items(ref_Component, r_CONTRACT_NUMBER); + WSGOC.Add_Items(ref_Component, r_L_CUST_NAME); + WSGOC.Add_Items(ref_Component, r_CONT_ID); + WSGOC.Add_Items(ref_Component, r_CUST_ID); + WSGOC.Add_Items(ref_Component, r_VALID_FROM); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_UI_CUST, replace(WSGL.EscapeItem(NBT_VAL.UI_CUST), ' +', '
+') ); + WSGOC.Set_Value( r_UI_CONTRACT, replace(WSGL.EscapeItem(NBT_VAL.UI_CONTRACT), ' +', '
+') ); + WSGOC.Set_Value( r_UI_STATUS, replace(WSGL.EscapeItem(NBT_VAL.UI_STATUS), ' +', '
+') ); + WSGOC.Set_Value( r_UI_CONT_FROM, EFNOW050$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_FROM, 'DD-MON-RRRR')))) ); + WSGOC.Set_Value( r_UI_CONT_TO, EFNOW050$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_TO, 'DD-MON-RRRR')))) ); + WSGOC.Set_Value( r_UI_EDIT_URL, replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_EDIT_URL), '#Edit#2008#'), ' +', '
+') ); + WSGOC.Set_Value( r_UI_COPY_URL, replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_COPY_URL), '#Copy#3547#'), ' +', '
+') ); + WSGOC.Set_Value( r_VALID_UNTIL, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.VALID_UNTIL, 'DD.MM.YYYY'))) ); + WSGOC.Set_Value( r_STATUS, replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)), ' +', '
+') ); + WSGOC.Set_Value( r_CONTRACT_NUMBER, replace(WSGL.EscapeItem(CURR_VAL.CONTRACT_NUMBER), ' +', '
+') ); + WSGOC.Set_Value( r_L_CUST_NAME, replace(WSGL.EscapeItem(NBT_VAL.L_CUST_NAME), ' +', '
+') ); + WSGOC.Set_Value( r_CONT_ID, WSGL.EscapeItem(CURR_VAL.CONT_ID) ); + WSGOC.Set_Value( r_CUST_ID, WSGL.EscapeItem(CURR_VAL.CUST_ID) ); + WSGOC.Set_Value( r_VALID_FROM, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.VALID_FROM, 'DD.MM.YYYY'))) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + '', 'efnow050$cont.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'CONT' module component (#Maintain Contracts#2080#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$cont.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'CONT' module component (#Maintain Contracts#2080#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + DEF_BODY_ATTRIBUTES, 'efnow050$cont.PostQuery'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$cont.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$cont.spc new file mode 100644 index 0000000..0d35924 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$cont.spc @@ -0,0 +1,110 @@ +create or replace package efnow050$cont is + + type NBT_REC is record + ( UI_CUST varchar2(24000) + , UI_CONTRACT varchar2(24000) + , UI_STATUS varchar2(24000) + , UI_CONT_FROM date + , UI_CONT_TO date + , UI_EDIT_URL varchar2(24000) + , UI_COPY_URL varchar2(24000) + , L_CUST_NAME CUSTOMERS.NAME%type + ); + + NBT_VAL NBT_REC; + CURR_VAL CONTRACTS%rowtype; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure ActionQuery( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null ); + + procedure FormQuery( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryList( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null, + Z_START in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null ); + function QueryHits( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null) return number; + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + procedure InitialiseDomain(P_ALIAS in varchar2); + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + D_STATUS WSGL.typDVRecord;FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + +procedure ncalendar + ( + 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 + ); + +procedure nformat_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$js$cont.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$js$cont.bdy new file mode 100644 index 0000000..e987ee0 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$js$cont.bdy @@ -0,0 +1,171 @@ +create or replace package body efnow050$js$cont is + + +-------------------------------------------------------------------------------- +-- Name: efnow050$js$cont.CreateQueryJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateQueryJavaScript ( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Query";'); + + + + WSGJSL.Output_Invoke_CAL_JS ('efnow050$cont', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('L_CUST_NAME','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + index = -1; + modeStr = "Q"; +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl, index, modeStr, "efnow050$cont.l_cust_name_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + + htp.p( +'// CAL +// +// + +function CAL(the_fieldname, the_value, the_format, the_prompt) { + var filter = ""; + var the_pathname = location.pathname; + var i = the_pathname.indexOf (''/:''); + var j = the_pathname.indexOf (''/'', ++i); + //var frmCAL; //B1777722 Needs to be global to remember state between calls. + + if (i != -1) + { + + // Syntactically incorrect url so it needs to be corrected + + the_pathname = the_pathname.substring (j, the_pathname.length); + + }; // (i != -1) + + // B1777722 and B1854252 for IE5 + if ( navigator.appName == "Microsoft Internet Explorer" && typeof frmCAL == "object" ) + { + frmCAL.close(); + } + + frmCAL = open ("efnow050$cont.ncalendar" + + "?Z_FIELD_NAME=" + escape(the_fieldname) + + "&Z_CALLER_URL=" + escape(location.protocol + ''//'' + location.host + the_pathname + location.search) + + "&Z_FIELD_VALUE=" + escape(the_value) + + "&Z_FIELD_FORMAT=" + escape(the_format) + + "&Z_FIELD_PROMPT=" + escape(the_prompt), + "winCAL", "scrollbars=no,resizable=no,width=320,height=350"); + + if (frmCAL.opener == null) + { + frmCAL.opener = self; + } +} '); + htp.p(WSGJSL.OpenEvent('CONT','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnQFQ','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + QF_BODY_ATTRIBUTES, 'efnow050$js$cont.CreateQueryJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow050$js$cont.CreateListJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateListJavaScript ( + RL_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow050$cont') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "List";'); + + + htp.p( 'var P_7 = new Array();' ); + + htp.p(WSGJSL.OpenEvent('AI_NEW_CONTRACT','OnClick')); + htp.p( +' +// AI_NEW_CONTRACT_OnClick +// +// +location.href = "efnow050$.contract_startup?p_screen_type=CONTRACT";'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Contracts#2080#', + RL_BODY_ATTRIBUTES, 'efnow050$js$cont.CreateListJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$js$cont.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$js$cont.spc new file mode 100644 index 0000000..73663f0 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow050$js$cont.spc @@ -0,0 +1,11 @@ +create or replace package efnow050$js$cont is + + procedure CreateQueryJavaScript( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2); + + procedure CreateListJavaScript( + RL_BODY_ATTRIBUTES in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$.bdy new file mode 100644 index 0000000..f5f4e8f --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$.bdy @@ -0,0 +1,266 @@ +create or replace package body efnow055$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +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_cnppv_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_value IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_data_error IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr ) +IS + +-- contract_values_ro +-- +-- + + + +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check('efnow050$') THEN + RETURN; + END IF; + -- + -- Set the package name + efnow092$.g_package_name := 'efnow050$'; + -- + -- Call efno092$ + efnow092$.contract_values_ro( p_contract_id => p_contract_id + , p_page_no => p_page_no + , p_success => p_success + , p_error => p_error + , p_err_msg => p_err_msg + , p_cnppv_id => p_cnppv_id + , p_value => p_value + , p_data_error => p_data_error ); + -- +END; + +-------------------------------------------------------------------------------- +-- Name: efnow055$.Startup +-- +-- Description: This procedure is the entry point for the 'efnow055$' +-- module. +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('efnow055$') then + return; + end if; + + WSGL.RegisterURL('efnow055$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, WSGL.MsgGetText(21,WSGLM.CAP021_TOP_LEVEL)); + efnow055$cont.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow055$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow055$.firstpage +-- +-- Description: This procedure creates the first page for the 'efnow055$' +-- module. +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('efnow055$') then + return; + end if; + + WSGL.OpenPageHead(''); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, 'EFNOW092', 0, 'efnow092$.startup',p_output_line=>FALSE, p_target=>'_top'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'efnow055$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow055$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow055$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'efnow055$' module. +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('efnow055$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('efnow055$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Nominations', 'EFNOW055', l_usr); + + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow055$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow055$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('efnow055$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow055$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow055$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'efnow055$' module. +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'efnow055$' + , pFirstTitle => '' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow055$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow055$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$.spc new file mode 100644 index 0000000..f92d654 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$.spc @@ -0,0 +1,23 @@ +create or replace package efnow055$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; +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_cnppv_id IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_value IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr + , p_data_error IN owa_util.vc_arr DEFAULT efnow092$.g_vc_arr ); + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$cont.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$cont.bdy new file mode 100644 index 0000000..0c49ff6 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$cont.bdy @@ -0,0 +1,2085 @@ +create or replace package body efnow055$cont is + + function L_CUST_NAME_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + function BuildSQL( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function PreQuery( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null) return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + QF_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(3,WSGLM.CAP003_QF_FIND); + QF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(4,WSGLM.CAP004_QF_CLEAR); + QF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + QF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + QF_NUMBER_OF_COLUMNS constant number(4) := 1; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + RL_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + RL_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + RL_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + RL_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + RL_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + RL_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(24,WSGLM.CAP024_RL_QUERY); + RL_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + RL_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + RL_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + RL_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + RL_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + RL_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + RL_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + RL_RECORD_SET_SIZE constant number(4) := 0; + RL_TOTAL_COUNT_REQD constant boolean := FALSE; + RL_NUMBER_OF_COLUMNS constant number(4) := 1; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + type FORM_REC is record + (UI_CUST varchar2(24000) + ,UI_CONTRACT varchar2(24000) + ,UI_STATUS varchar2(24000) + ,UI_CONT_FROM varchar2(40) + ,UI_CONT_TO varchar2(40) + ,UI_VIEW_URL varchar2(24000) + ,CONT_ID varchar2(40) + ,STATUS varchar2(36) + ,CONTRACT_NUMBER varchar2(180) + ,L_CUST_NAME varchar2(600) + ,VALID_UNTIL varchar2(12) + ,VALID_FROM varchar2(12) + ,CUST_ID varchar2(40) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_UI_CUST WSGOC.ITEM_REF; + R_UI_CONTRACT WSGOC.ITEM_REF; + R_UI_STATUS WSGOC.ITEM_REF; + R_UI_CONT_FROM WSGOC.ITEM_REF; + R_UI_CONT_TO WSGOC.ITEM_REF; + R_UI_VIEW_URL WSGOC.ITEM_REF; + R_CONT_ID WSGOC.ITEM_REF; + R_STATUS WSGOC.ITEM_REF; + R_CONTRACT_NUMBER WSGOC.ITEM_REF; + R_L_CUST_NAME WSGOC.ITEM_REF; + R_VALID_UNTIL WSGOC.ITEM_REF; + R_VALID_FROM WSGOC.ITEM_REF; + R_CUST_ID WSGOC.ITEM_REF; + + + +FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- FormatDate +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date,v_mask),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDate; +procedure ncalendar + ( + 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 + +-- ncalendar +-- +-- + + + + + Field_Caption Varchar2 (2000); + + procedure Output_Calendar + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_VALUE in Varchar2, + Z_FIELD_FORMAT in Varchar2, + Page_Header in Varchar2, + Body_Attributes in Varchar2, + PKG_Name in Varchar2, + Close_But_Caption in Varchar2, + First_Part in Boolean, + Z_DEFAULT_FORMAT in varchar2 + ) is + day_of_week Integer := 0; + first_day_of_week Integer := 0; + +function CALJavaScript (field_value in varchar2, field_date_format in varchar2, default_format in varchar2) return varchar2 is + + l_date date; + in_date varchar2 (10); + the_date_field varchar2 (16); + l_valid_date boolean; + l_offset_unit varchar2(4); + l_offset number; + l_sysdate date; + l_territory_offset pls_integer; + +begin + l_valid_date := false; + begin + l_date := to_date( field_value, field_date_format ); + l_valid_date := true; + exception when others then + null; + end; + + if not l_valid_date then + begin + l_date := to_date( field_value, default_format ); + l_valid_date := true; + exception when others then + null; + end; + end if; + + if not l_valid_date then + begin + l_date := to_date( field_value ); + l_valid_date := true; + exception when others then + null; + end; + end if; + + if not l_valid_date then + if substr( field_value, 1, 1 ) in ('+',' ','-') then + l_offset_unit := upper( substr( field_value, 2, 1 ) ); + begin + if l_offset_unit not in ('D','M','Y') then + l_offset := to_number( substr( field_value, 2 ) ); + else + l_offset := to_number( substr( field_value, 3 ) ); + end if; + if substr( field_value, 1, 1 ) = '-' then + l_offset := -1 * l_offset; + end if; + if l_offset_unit = 'D' then + l_date := sysdate + l_offset; + l_valid_date := true; + elsif l_offset_unit = 'M' then + l_date := add_months( sysdate, l_offset ); + l_valid_date := true; + elsif l_offset_unit = 'Y' then + l_date := add_months( sysdate, 12 * l_offset ); + l_valid_date := true; + else + l_date := sysdate + l_offset; + l_valid_date := true; + end if; + exception when others then + null; + end; + end if; + end if; + + if not l_valid_date then + l_date := sysdate; + end if; + + -- Internal date format that MUST NOT be changed - this is the same format that the JS uses to + -- parse an incoming date from the field. + in_date := to_char (l_date, 'MM-DD-YYYY'); + + if in_date is null then + the_date_field := 'dateField.value'; + else + the_date_field := '''' || in_date || ''''; + end if; + + -- Calculate the offset necessary due to territorial differences in the first day of the week. + -- We know that 31st October 1999 is a Sunday, so we can see what day of the week the database thinks this is + select to_number(to_char(to_date('31-10-1999','DD-MM-YYYY'),'D'))-1 into l_territory_offset from dual; + + return ' +function setDate() { + this.dateField = opener.dateField; + this.inDate = ' || the_date_field || '; + + // SET DAY MONTH AND YEAR TO TODAYS DATE + var now = new Date(); + var day = now.getDate(); + var month = now.getMonth(); + var year = now.getFullYear(); + + // IF A DATE WAS PASSED IN THEN PARSE THAT DATE + if (inDate.indexOf(''-'')) { + var inMonth = inDate.substring(0,inDate.indexOf("-")); + if (inMonth.substring(0,1) == "0" && inMonth.length > 1) + inMonth = inMonth.substring(1,inMonth.length); + inMonth = parseInt(inMonth); + var inDay = inDate.substring(inDate.indexOf("-") + 1, inDate.lastIndexOf("-")); + if (inDay.substring(0,1) == "0" && inDay.length > 1) + inDay = inDay.substring(1,inDay.length); + inDay = parseInt(inDay); + var inYear = parseInt(inDate.substring(inDate.lastIndexOf("-") + 1, inDate.length)); + + if (inDay) { + day = inDay; + } + if (inMonth) { + month = inMonth-1; + } + if (inYear) { + year = inYear; + } + } + this.focusDay = day; + document.calControl.month.selectedIndex = month; + document.calControl.year.value = year; + displayCalendar(day, month, year); +} + + +function setToday() { + // SET DAY MONTH AND YEAR TO TODAYS DATE + var now = new Date(); + var day = now.getDate(); + var month = now.getMonth(); + var year = now.getFullYear(); + + this.focusDay = day; + document.calControl.month.selectedIndex = month; + document.calControl.year.value = year; + displayCalendar(day, month, year); +} + + +function isFourDigitYear(year) { + if (year.length != 4 || isNaN(year)) { + alert ("'||WSGL.MsgGetText(234,WSGLM.MSG234_FOUR_DIGIT_YEAR)||'"); + document.calControl.year.select(); + document.calControl.year.focus(); + } + else { + return true; + } +} + + +function selectDate() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + displayCalendar(day, month, year); + } +} + + +function setPreviousYear() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + year--; + document.calControl.year.value = year; + displayCalendar(day, month, year); + } +} + + +function setPreviousMonth() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + if (month == 0) { + month = 11; + if (year > 1000) { + year--; + document.calControl.year.value = year; + } + } + else { + month--; + } + document.calControl.month.selectedIndex = month; + displayCalendar(day, month, year); + } +} + + +function setNextMonth() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + if (month == 11) { + month = 0; + year++; + document.calControl.year.value = year; + } + else { + month++; + } + document.calControl.month.selectedIndex = month; + displayCalendar(day, month, year); + } +} + + +function setNextYear() { + var year = document.calControl.year.value; + if (isFourDigitYear(year)) { + var day = 0; + var month = document.calControl.month.selectedIndex; + year++; + document.calControl.year.value = year; + displayCalendar(day, month, year); + } +} + + +function displayCalendar(day, month, year) { + + day = parseInt(day); + month = parseInt(month); + year = parseInt(year); + var i = 0; + var offset = 11; + var now = new Date(); + + if (day == 0) { + var nowDay = now.getDate(); + } + else { + var nowDay = day; + } + var days = getDaysInMonth(month+1,year); + var firstOfMonth = new Date (year, month, 1); + var startingPos = (firstOfMonth.getDay()+'||l_territory_offset||')%7; + days += startingPos; + + // MAKE BEGINNING NON-DATE BUTTONS BLANK + for (i = 0; i < startingPos; i++) { + document.calControl.elements[i + offset].value = "__"; + } + + // SET VALUES FOR DAYS OF THE MONTH + for (i = startingPos; i < days; i++) + { + var datestr = (i-startingPos+1) + ""; + if ((i-startingPos+1) < 10) + { + datestr = "0" + datestr; + } + document.calControl.elements[i + offset].value = datestr; + document.calControl.elements[i + offset].onClick = "returnDate" + } + + // MAKE REMAINING NON-DATE BUTTONS BLANK + for (i=days; i<42; i++) { + document.calControl.elements[i + offset].value = "__"; + } + + // GIVE FOCUS TO CORRECT DAY + document.calControl.elements[focusDay+startingPos-1 + offset].focus(); + document.calControl.day.value = day; + +} + + +// GET NUMBER OF DAYS IN MONTH +function getDaysInMonth(month,year) { + var days; + if (month==1 || month==3 || month==5 || month==7 || month==8 || + month==10 || month==12) days=31; + else if (month==4 || month==6 || month==9 || month==11) days=30; + else if (month==2) { + if (isLeapYear(year)) { + days=29; + } + else { + days=28; + } + } + return (days); +} + + +// CHECK TO SEE IF YEAR IS A LEAP YEAR +function isLeapYear (Year) { + if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) { + return (true); + } + else { + return (false); + } +} + + +// SET FORM FIELD VALUE TO THE DATE SELECTED +function returnDate(inDay) +{ + var day = inDay; + var month = (document.calControl.month.selectedIndex)+1; + var year = document.calControl.year.value; + + if ((""+month).length == 1) + { + month="0"+month; + } + if ((""+day).length == 1) + { + day="0"+day; + } + if (day != "__") { + document.calControl.day.value = day; + document.calControl.submit(); + } +} +'; + +end CALJavaScript; + +begin + if First_Part + then + -- Output the HTML that needs to go before the user defined template header + wsgl.OpenPageHead (Page_Header); + htp.p (WSGJSL.OpenScript); + htp.p ('function Close_OnClick() { close(); }'); + htp.p (CALJavaScript (Z_FIELD_VALUE, Z_FIELD_FORMAT, Z_DEFAULT_FORMAT)); + htp.p (WSGJSL.CloseScript); + else + -- The rest of the calendar comes after the user defined template header + wsgl.ClosePageHead; + wsgl.OpenPageBody(FALSE, p_attributes => Body_Attributes || ' ONLOAD="setDate()"'); + htp.header(2, htf.italic(Page_Header)); + htp.formOpen(curl=> PKG_Name || '.nformat_cal_date', cattributes => 'name="calControl"'); + wsgl.HiddenField('Z_FIELD_NAME', Z_FIELD_NAME); + wsgl.HiddenField('Z_FIELD_FORMAT', Z_FIELD_FORMAT); + wsgl.HiddenField('day', 1); + htp.p(''); + -- Create the calendar + htp.p (' +
+ +'); + -- Now display the movement buttons + htp.p (' + + + +'); + -- Display the days of the week along the top of the calendar + htp.p (''); + -- Find the first day of the week + day_of_week := to_number (to_char (to_date ('1', 'DD'), 'D')); + first_day_of_week := (8 - day_of_week) + 1; + for i in first_day_of_week..(first_day_of_week + 6) + loop + htp.prn (''); + end loop; + htp.p (''); + -- Now display a button for each day on the calendar + -- The calendar is made up of 6 rows + for i in 1..6 + loop + htp.p (''); + for j in 1..7 + loop + -- 7 days in each row + htp.p (''); + end loop; -- j in 1..7 + htp.p (''); + end loop; -- i in 1..6 + htp.p ('
+
+'); + -- Create the month drop down + htp.formSelectOpen (cname => 'month', cattributes => 'onChange=''selectDate()'''||' ID="month"'); + -- Output the names of the months in the appropriate language for the database - NLS Compliance + for i in 1..12 + loop + htp.formSelectOption (initcap (to_char (to_date (i, 'MM'), 'MONTH'))); + end loop; + htp.formSelectClose; + -- Now the year field + htp.p (''); + -- Finish this part of the table + htp.p ('
+
+ + + + + +
+
'); + htp.prn (initcap (substr (to_char (to_date (i, 'DD'), 'DAY'), 1, 2))); + htp.p ('
'); + htp.formclose; + wsgl.ClosePageBody; + end if; -- First_Part +end Output_Calendar; + + + + 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('efnow050$cont.calendar'); + WSGL.AddURLParam('Z_FIELD_NAME', Z_FIELD_NAME); + WSGL.AddURLParam('Z_CALLER_URL', Z_CALLER_URL); + + if WSGL.NotLowerCase then + return; + end if; + + Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow050$cont', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow050$.TemplateHeader(TRUE,7); + + Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow050$cont', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow050$cont.calendar'); + end ncalendar; + +procedure nformat_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ) IS + +-- nformat_cal_date +-- +-- + + + + + Field_Caption Varchar2 (2000) := initcap (replace (substr (Z_FIELD_NAME, 3, length (Z_FIELD_NAME) - 2), '_', ' ')); + l_day varchar2(15) := day; + l_date_fmt VARCHAR2(255) := NVL(cout_system_configuration.get_configuration_item('G_DATE_FORMAT'),'DD-MON-YYYY'); + +procedure Output_Format_Cal_JS + ( + Page_Header in Varchar2, + Body_Attributes in Varchar2, + Chosen_Date in Varchar2, + Field_Format in Varchar2 + ) is + -- This date format mask is internal and *intentional* DO NOT CHANGE + -- DD for day number + -- MONTH for actual text supplied by calendar drop down list + -- YYYY y2k compliant year + 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), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + --Z_FIELD_FORMAT + l_date_fmt + ); + +end nformat_cal_date; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.L_CUST_NAME_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'L_CUST_NAME'. +-- +-- +-------------------------------------------------------------------------------- + function L_CUST_NAME_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT DISTINCT L_CUST.NAME L_CUST_NAME, + L_CUST.NAME CG$DISPLAY +FROM CUSTOMERS L_CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START CONT.L_CUST */ + (( EXISTS ( SELECT cust1.cust_id FROM customer_intermediaries cuin1 , customers cust1 , customer_types cuty , intermediary_users inus WHERE cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND l_cust.cust_id = cust1.cust_id AND cuin1.inte_id = inus.inte_id AND inus.syus_id = caco_utilities.get_syus_id AND cuty.cuty_id = caco_utilities.cuty_id_for_user AND cust1.cust_id != caco_utilities.get_system_customer ) OR caco_utilities.user_has_system = 'Y' )) + /* CG$MDTU_QWC_END CONT.L_CUST */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START CONT.L_CUST */ + (( EXISTS ( SELECT cust1.cust_id FROM customer_intermediaries cuin1 , customers cust1 , customer_types cuty , intermediary_users inus WHERE cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND l_cust.cust_id = cust1.cust_id AND cuin1.inte_id = inus.inte_id AND inus.syus_id = caco_utilities.get_syus_id AND cuty.cuty_id = caco_utilities.cuty_id_for_user AND cust1.cust_id != caco_utilities.get_system_customer ) OR caco_utilities.user_has_system = 'Y' )) + /* CG$MDTU_VWC_END CONT.L_CUST */ + ) + ) + ) +ORDER BY L_CUST.NAME +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return L_CUST_NAME_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return L_CUST_NAME_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return L_CUST_NAME_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return L_CUST_NAME_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return L_CUST_NAME_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_L_CUST_NAME', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_L_CUST_NAME'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_L_CUST_NAME', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_L_CUST_NAME'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.L_CUST_NAME) = P_VALUE) or c1rec.L_CUST_NAME = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_CUST_NAME)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_CUST_NAME)||'"'); + end if; + l_first := false; + end loop; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.L_CUST_NAME_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.InitialiseDomain +-- +-- Description: Initialises the Domain Record for the given Column Usage +-- +-- Parameters: P_ALIAS The alias of the column usage +-- +-------------------------------------------------------------------------------- + procedure InitialiseDomain(P_ALIAS in varchar2) is + begin + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + if P_ALIAS = 'STATUS' and not D_STATUS.Initialised then + D_STATUS.ColAlias := 'STATUS'; + D_STATUS.ControlType := WSGL.DV_LIST; + D_STATUS.DispWidth := 6; + D_STATUS.DispHeight := 1; + D_STATUS.MaxWidth := 6; + D_STATUS.UseMeanings := True; + D_STATUS.ColOptional := False; + D_STATUS.Vals(1) := 'O'; + D_STATUS.Meanings(1) := 'Open'; + D_STATUS.Abbreviations(1) := 'Open'; + D_STATUS.Vals(2) := 'C'; + D_STATUS.Meanings(2) := 'Closed'; + D_STATUS.Abbreviations(2) := 'Closed'; + D_STATUS.NumOfVV := 2; + D_STATUS.Initialised := True; + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.InitialseDomain'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow055$cont.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), + CAL_BODY_ATTRIBUTES, + 'efnow055$cont', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow055$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow055$cont', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow055$cont.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.Startup +-- +-- Description: Entry point for the 'CONT' module +-- component (#View Contract Values#3980#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + WSGL.RegisterURL('efnow055$cont.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, '#View Contract Values#3980#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'QUERY' then + FormQuery( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + if Z_FORM = 'LIST' then + QueryList( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + FormQuery( + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.ActionQuery +-- +-- Description: Called when a Query form is subitted to action the query request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionQuery( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2, + Z_CHK in varchar2 ) is + + L_CHK varchar2(10) := Z_CHK; + L_BUTCHK varchar2(100):= null; + l_dummy_bool boolean := false; + begin + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + end if; + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + QueryList( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM, + Z_START=>null, + Z_ACTION=>L_BUTCHK, + Z_DIRECT_CALL=>TRUE); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.ActionQuery'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2) return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow055$cont') then + return -1; + end if; + + if not BuildSQL(P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + return -1; + end if; + + if not PreQuery(P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#View Contract Values#3980#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.BuildSQL +-- +-- Description: Builds the SQL for the 'CONT' module component (#View Contract Values#3980#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + InitialiseDomain('STATUS'); + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE CONT_ID = ' || to_char(CURR_VAL.CONT_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + WSGL.BuildWhere(WSGL.DomainValue(D_STATUS, P_STATUS), 'STATUS', WSGL.TYPE_CHAR, I_WHERE); + WSGL.BuildWhere(P_CONTRACT_NUMBER, 'CONTRACT_NUMBER', WSGL.TYPE_CHAR, I_WHERE); + WSGL.BuildWhere(P_L_CUST_NAME, 'L_CUST_NAME', WSGL.TYPE_CHAR, I_WHERE); + begin + WSGL.BuildWhere(P_VALID_FROM, U_VALID_FROM, 'VALID_FROM', WSGL.TYPE_DATE, I_WHERE, 'DD/MM/YYYY'); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_ERROR_QRY, SQLERRM, + ''||' : '||'#View Contract Values#3980#', DEF_BODY_ATTRIBUTES, NULL, + WSGL.MsgGetText(210,WSGLM.MSG210_INVALID_QRY,'#Valid From#2441#'), + WSGL.MsgGetText(211,WSGLM.MSG211_EXAMPLE_TODAY,to_char(sysdate, 'DD/MM/YYYY'))); + return false; + end; + + end if; + + ZONE_SQL := 'SELECT UI_CUST, + UI_CONTRACT, + UI_STATUS, + UI_CONT_FROM, + UI_CONT_TO, + UI_VIEW_URL, + CONT_ID, + STATUS, + CONTRACT_NUMBER, + L_CUST_NAME, + VALID_UNTIL, + VALID_FROM, + CUST_ID + FROM ( SELECT L_CUST.NAME UI_CUST, + CONT.CONTRACT_NUMBER UI_CONTRACT, + DECODE(CONT.STATUS,''O'',''Open'',''Closed'') UI_STATUS, + CONT.VALID_FROM UI_CONT_FROM, + CONT.VALID_UNTIL UI_CONT_TO, + ''efnow055$.contract_values_ro?p_contract_id=''||CONT.CONT_ID UI_VIEW_URL, + CONT.CONT_ID CONT_ID, + CONT.STATUS STATUS, + CONT.CONTRACT_NUMBER CONTRACT_NUMBER, + L_CUST.NAME L_CUST_NAME, + CONT.VALID_UNTIL VALID_UNTIL, + CONT.VALID_FROM VALID_FROM, + CONT.CUST_ID CUST_ID +FROM CONTRACTS CONT, + CUSTOMERS L_CUST +WHERE ( /* CG$MDTU_QWC_START CONT.L_CUST */ + (( EXISTS ( SELECT cust1.cust_id FROM customer_intermediaries cuin1 , customers cust1 , customer_types cuty , intermediary_users inus WHERE cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND l_cust.cust_id = cust1.cust_id AND cuin1.inte_id = inus.inte_id AND inus.syus_id = caco_utilities.get_syus_id AND cuty.cuty_id = caco_utilities.cuty_id_for_user AND cust1.cust_id != caco_utilities.get_system_customer ) OR caco_utilities.user_has_system = ''Y'' )) + /* CG$MDTU_QWC_END CONT.L_CUST */ + ) AND + CONT.CUST_ID = L_CUST.CUST_ID + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY L_CUST_NAME, + VALID_FROM'; + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'CONT' module component (#View Contract Values#3980#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, NBT_VAL.UI_CUST, 4000); + dbms_sql.define_column(I_CURSOR, 2, NBT_VAL.UI_CONTRACT, 4000); + dbms_sql.define_column(I_CURSOR, 3, NBT_VAL.UI_STATUS, 4000); + dbms_sql.define_column(I_CURSOR, 4, NBT_VAL.UI_CONT_FROM); + dbms_sql.define_column(I_CURSOR, 5, NBT_VAL.UI_CONT_TO); + dbms_sql.define_column(I_CURSOR, 6, NBT_VAL.UI_VIEW_URL, 4000); + dbms_sql.define_column(I_CURSOR, 7, CURR_VAL.CONT_ID); + dbms_sql.define_column(I_CURSOR, 8, CURR_VAL.STATUS, 1); + dbms_sql.define_column(I_CURSOR, 9, CURR_VAL.CONTRACT_NUMBER, 30); + dbms_sql.define_column(I_CURSOR, 10, NBT_VAL.L_CUST_NAME, 100); + dbms_sql.define_column(I_CURSOR, 11, CURR_VAL.VALID_UNTIL); + dbms_sql.define_column(I_CURSOR, 12, CURR_VAL.VALID_FROM); + dbms_sql.define_column(I_CURSOR, 13, CURR_VAL.CUST_ID); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + '', 'efnow055$cont.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'CONT' module component (#View Contract Values#3980#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, NBT_VAL.UI_CUST); + dbms_sql.column_value(I_CURSOR, 2, NBT_VAL.UI_CONTRACT); + dbms_sql.column_value(I_CURSOR, 3, NBT_VAL.UI_STATUS); + dbms_sql.column_value(I_CURSOR, 4, NBT_VAL.UI_CONT_FROM); + dbms_sql.column_value(I_CURSOR, 5, NBT_VAL.UI_CONT_TO); + dbms_sql.column_value(I_CURSOR, 6, NBT_VAL.UI_VIEW_URL); + dbms_sql.column_value(I_CURSOR, 7, CURR_VAL.CONT_ID); + dbms_sql.column_value(I_CURSOR, 8, CURR_VAL.STATUS); + dbms_sql.column_value(I_CURSOR, 9, CURR_VAL.CONTRACT_NUMBER); + dbms_sql.column_value(I_CURSOR, 10, NBT_VAL.L_CUST_NAME); + dbms_sql.column_value(I_CURSOR, 11, CURR_VAL.VALID_UNTIL); + dbms_sql.column_value(I_CURSOR, 12, CURR_VAL.VALID_FROM); + dbms_sql.column_value(I_CURSOR, 13, CURR_VAL.CUST_ID); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.CONT_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + '', 'efnow055$cont.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.FormQuery +-- +-- Description: This procedure builds an HTML form for entry of query criteria. +-- The criteria entered are to restrict the query of the 'CONT' +-- module component (#View Contract Values#3980#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormQuery( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + L_SUCCESS boolean := TRUE; + begin + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + end if; + + L_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + WSGL.OpenPageHead(''||' : '||'#View Contract Values#3980#'); + WSGL.METATag; + efnow055$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>QF_BODY_ATTRIBUTES || 'onLoad="return CONT_OnLoad()"'); + efnow055$js$cont.CreateQueryJavaScript(LOV_FRAME,QF_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + htp.p(caco_system.menu); + efnow055$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + htp.p(WSGL.MsgGetText(116,WSGLM.DSP116_ENTER_QRY_CAPTION,'#View Contract Values#3980#')); + htp.para; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow055$cont.actionquery', cattributes => 'NAME="efnow055$cont$QForm"'); + + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + for i in 1..QF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(23, 'LEFT', NULL); + WSGL.LayoutHeader(40, 'LEFT', NULL); + end loop; + WSGL.LayoutRowEnd; + + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Status#2114#:')); + InitialiseDomain('STATUS'); + WSGL.LayoutData(WSGL.BuildDVControl(D_STATUS, WSGL.CTL_QUERY)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Contract Number#2013#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('CONTRACT_NUMBER', '30', FALSE, p_maxlength=>'30')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Name#116#:')); + WSGL.LayoutData(L_CUST_NAME_LOV(NULL, WSGL.CTL_QUERY, 'Q', true)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Valid From#2441#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('VALID_FROM', '11', TRUE, p_maxlength=>'10' + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_date_format => 'DD/MM/YYYY' + , p_cal_prompt => '#Valid From#2441#' + , p_form=>'efnow055$cont$QForm')); + WSGL.LayoutRowEnd; + + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', htf.escape_sc(QF_QUERY_BUT_CAPTION), 'btnQFQ', 'this.form.Z_ACTION.value=\''' || QF_QUERY_BUT_ACTION || '\'''); + htp.formReset(htf.escape_sc(QF_CLEAR_BUT_CAPTION), 'ID="'||htf.escape_sc(QF_CLEAR_BUT_CAPTION)||'"'); + + + WSGL.HiddenField('Z_CHK', to_char(WSGL.Checksum + (''))); + htp.formClose; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + QF_BODY_ATTRIBUTES, 'efnow055$cont.FormQuery'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.QueryList +-- +-- Description: This procedure builds the Record list for the 'CONT' +-- module component (#View Contract Values#3980#). +-- +-- The Record List displays context information for records which +-- match the specified query criteria. +-- Sets of records are displayed (0 records at a time) +-- with Next/Previous buttons to get other record sets. +-- +-- Parameters: P_STATUS - #Status#2114# +-- P_CONTRACT_NUMBER - #Contract Number#2013# +-- P_L_CUST_NAME - #Name#116# +-- P_VALID_FROM - #Valid From#2441# +-- U_VALID_FROM - #Valid From#2441# (upper bound) +-- Z_START - First record to display +-- Z_ACTION - Next or Previous set +-- +-------------------------------------------------------------------------------- + procedure QueryList( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2 ) is + + I_VF_FRAME varchar2(20) := null; + I_WHERE varchar2(2000) := ''; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + I_TOTAL_ROWS integer := 0; + I_START number(38) := to_number(Z_START); + I_COUNT number(10) := 0; + I_OF_TOTAL_TEXT varchar2(200) := ''; + I_NEXT_BUT boolean; + I_PREV_BUT boolean; + I_COL_COUNT integer; + I_SUCCESS boolean := true; + l_row integer := 0; + l_id varchar2(35) := null; + -- Reset break group? + RSIG_CUST boolean := true; + -- Reset break group? + RSIG_REST boolean := true; + I_LAST_BASE CURR_VAL%TYPE; + I_LAST_NBT NBT_REC; + + + + begin + + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + + WSGL.RegisterURL('efnow055$cont.querylist'); + WSGL.AddURLParam('P_STATUS', P_STATUS); + WSGL.AddURLParam('P_CONTRACT_NUMBER', P_CONTRACT_NUMBER); + WSGL.AddURLParam('P_L_CUST_NAME', P_L_CUST_NAME); + WSGL.AddURLParam('P_VALID_FROM', P_VALID_FROM); + WSGL.AddURLParam('U_VALID_FROM', U_VALID_FROM); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if (not Z_DIRECT_CALL) then + + null; + + + end if; + if (Z_ACTION = RL_QUERY_BUT_ACTION) or (Z_ACTION = RL_QUERY_BUT_CAPTION) then + FormQuery( + Z_DIRECT_CALL=>TRUE); + return; + end if; + + -- Set up any master context values that may be required + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + + + WSGL.OpenPageHead(''||' : '||'#View Contract Values#3980#'); + WSGL.METATag; + efnow055$.TemplateHeader(TRUE,6); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>RL_BODY_ATTRIBUTES); + efnow055$js$cont.CreateListJavaScript(RL_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) or + (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + (RL_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + RL_TOTAL_COUNT_REQD then + I_OF_TOTAL_TEXT := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + I_START := 1; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + + if ZONE_SQL IS NULL then + if not BuildSQL( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + WSGL.ClosePageBody; + return; + end if; + end if; + + if not PreQuery( + P_STATUS, + P_CONTRACT_NUMBER, + P_L_CUST_NAME, + P_VALID_FROM, + U_VALID_FROM) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#View Contract Values#3980#', RL_BODY_ATTRIBUTES); + return; + end if; + + InitialiseDomain('STATUS'); + + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := 0; + end if; + I_TOTAL_ROWS := I_ROWS_FETCHED; + + if I_ROWS_FETCHED != 0 then + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, P_BORDER=>TRUE); + + WSGL.LayoutRowStart(p_attrs=>'class = cgrlheaderrow'); + for i in 1..RL_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(30, 'LEFT', '#Customer#1047#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Contract Name#2082#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Status#2114#',''); + WSGL.LayoutHeader(11, 'LEFT', '#Valid From#2441#',''); + WSGL.LayoutHeader(11, 'LEFT', '#Valid To#2442#',''); + WSGL.LayoutHeader(30, 'LEFT', '#View#2062#',''); + end loop; + WSGL.LayoutRowEnd; + + while I_ROWS_FETCHED <> 0 loop + + if I_TOTAL_ROWS >= I_START then + AssignZoneRow(I_CURSOR); + + if (NBT_VAL.UI_CUST != I_LAST_NBT.UI_CUST or (NBT_VAL.UI_CUST is null and I_LAST_NBT.UI_CUST is not null) or (NBT_VAL.UI_CUST is not null and I_LAST_NBT.UI_CUST is null) ) then + RSIG_CUST := true; + else + RSIG_CUST := false; + end if; + if (CURR_VAL.CONT_ID != I_LAST_BASE.CONT_ID or (CURR_VAL.CONT_ID is null and I_LAST_BASE.CONT_ID is not null) or (CURR_VAL.CONT_ID is not null and I_LAST_BASE.CONT_ID is null) ) or + (CURR_VAL.STATUS != I_LAST_BASE.STATUS or (CURR_VAL.STATUS is null and I_LAST_BASE.STATUS is not null) or (CURR_VAL.STATUS is not null and I_LAST_BASE.STATUS is null) ) or + (CURR_VAL.CONTRACT_NUMBER != I_LAST_BASE.CONTRACT_NUMBER or (CURR_VAL.CONTRACT_NUMBER is null and I_LAST_BASE.CONTRACT_NUMBER is not null) or (CURR_VAL.CONTRACT_NUMBER is not null and I_LAST_BASE.CONTRACT_NUMBER is null) ) or + (NBT_VAL.L_CUST_NAME != I_LAST_NBT.L_CUST_NAME or (NBT_VAL.L_CUST_NAME is null and I_LAST_NBT.L_CUST_NAME is not null) or (NBT_VAL.L_CUST_NAME is not null and I_LAST_NBT.L_CUST_NAME is null) ) or + (CURR_VAL.VALID_UNTIL != I_LAST_BASE.VALID_UNTIL or (CURR_VAL.VALID_UNTIL is null and I_LAST_BASE.VALID_UNTIL is not null) or (CURR_VAL.VALID_UNTIL is not null and I_LAST_BASE.VALID_UNTIL is null) ) or + (CURR_VAL.VALID_FROM != I_LAST_BASE.VALID_FROM or (CURR_VAL.VALID_FROM is null and I_LAST_BASE.VALID_FROM is not null) or (CURR_VAL.VALID_FROM is not null and I_LAST_BASE.VALID_FROM is null) ) or + (CURR_VAL.CUST_ID != I_LAST_BASE.CUST_ID or (CURR_VAL.CUST_ID is null and I_LAST_BASE.CUST_ID is not null) or (CURR_VAL.CUST_ID is not null and I_LAST_BASE.CUST_ID is null) ) or + (NBT_VAL.UI_CONTRACT != I_LAST_NBT.UI_CONTRACT or (NBT_VAL.UI_CONTRACT is null and I_LAST_NBT.UI_CONTRACT is not null) or (NBT_VAL.UI_CONTRACT is not null and I_LAST_NBT.UI_CONTRACT is null) ) or + (NBT_VAL.UI_STATUS != I_LAST_NBT.UI_STATUS or (NBT_VAL.UI_STATUS is null and I_LAST_NBT.UI_STATUS is not null) or (NBT_VAL.UI_STATUS is not null and I_LAST_NBT.UI_STATUS is null) ) or + (NBT_VAL.UI_CONT_FROM != I_LAST_NBT.UI_CONT_FROM or (NBT_VAL.UI_CONT_FROM is null and I_LAST_NBT.UI_CONT_FROM is not null) or (NBT_VAL.UI_CONT_FROM is not null and I_LAST_NBT.UI_CONT_FROM is null) ) or + (NBT_VAL.UI_CONT_TO != I_LAST_NBT.UI_CONT_TO or (NBT_VAL.UI_CONT_TO is null and I_LAST_NBT.UI_CONT_TO is not null) or (NBT_VAL.UI_CONT_TO is not null and I_LAST_NBT.UI_CONT_TO is null) ) or + (NBT_VAL.UI_VIEW_URL != I_LAST_NBT.UI_VIEW_URL or (NBT_VAL.UI_VIEW_URL is null and I_LAST_NBT.UI_VIEW_URL is not null) or (NBT_VAL.UI_VIEW_URL is not null and I_LAST_NBT.UI_VIEW_URL is null) ) then + RSIG_REST := true; + else + RSIG_REST := false; + end if; + if RSIG_CUST then + RSIG_REST := true; + end if; + + + I_LAST_NBT.UI_CUST := NBT_VAL.UI_CUST; + I_LAST_BASE.CONT_ID := CURR_VAL.CONT_ID; + I_LAST_BASE.STATUS := CURR_VAL.STATUS; + I_LAST_BASE.CONTRACT_NUMBER := CURR_VAL.CONTRACT_NUMBER; + I_LAST_NBT.L_CUST_NAME := NBT_VAL.L_CUST_NAME; + I_LAST_BASE.VALID_UNTIL := CURR_VAL.VALID_UNTIL; + I_LAST_BASE.VALID_FROM := CURR_VAL.VALID_FROM; + I_LAST_BASE.CUST_ID := CURR_VAL.CUST_ID; + I_LAST_NBT.UI_CONTRACT := NBT_VAL.UI_CONTRACT; + I_LAST_NBT.UI_STATUS := NBT_VAL.UI_STATUS; + I_LAST_NBT.UI_CONT_FROM := NBT_VAL.UI_CONT_FROM; + I_LAST_NBT.UI_CONT_TO := NBT_VAL.UI_CONT_TO; + I_LAST_NBT.UI_VIEW_URL := NBT_VAL.UI_VIEW_URL; + l_row := l_row + 1; + + + WSGL.LayoutRowStart('TOP', p_attrs=>'class = cgrldatarow'); + l_id := '' || l_row; + if RSIG_CUST and NBT_VAL.UI_CUST is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_CUST), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_CONTRACT is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_CONTRACT), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_STATUS is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_STATUS), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_CONT_FROM is not null then + WSGL.LayoutData(p_text=>EFNOW055$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_FROM, 'DD-MON-RRRR')))), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_CONT_TO is not null then + WSGL.LayoutData(p_text=>EFNOW055$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_TO, 'DD-MON-RRRR')))), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG_REST and NBT_VAL.UI_VIEW_URL is not null then + WSGL.LayoutData(p_text=>replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_VIEW_URL), '#View#2062#'), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + + WSGL.LayoutRowEnd; + + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + end if; + + I_TOTAL_ROWS := I_TOTAL_ROWS + I_ROWS_FETCHED; + + end loop; + + WSGL.LayoutClose; + + if I_START = I_TOTAL_ROWS then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_TOTAL_ROWS))||I_OF_TOTAL_TEXT); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(I_TOTAL_ROWS))|| + I_OF_TOTAL_TEXT); + end if; + htp.para; + else + htp.p(WSGL.MsgGetText(112,WSGLM.DSP112_NO_RECORDS)); + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + dbms_sql.close_cursor(I_CURSOR); + end if; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow055$cont.querylist', cattributes => 'NAME="efnow055$cont$LForm"'); + SaveState; + WSGL.HiddenField('P_STATUS', P_STATUS); + WSGL.HiddenField('P_CONTRACT_NUMBER', P_CONTRACT_NUMBER); + WSGL.HiddenField('P_L_CUST_NAME', P_L_CUST_NAME); + WSGL.HiddenField('P_VALID_FROM', P_VALID_FROM); + WSGL.HiddenField('U_VALID_FROM', U_VALID_FROM); + WSGL.HiddenField('Z_START', to_char(I_START)); + htp.p (''); + + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_FIRST_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_FIRST_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_PREV_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_PREV_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_NEXT_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_NEXT_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_LAST_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_LAST_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_REQUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_REQUERY_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_COUNT_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_COUNT_BUT_ACTION || '\''"'); + htp.para; + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_QUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_QUERY_BUT_ACTION || '\''"'); + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''))); + htp.formClose; + + WSGL.ReturnLinks('0.1', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + RL_BODY_ATTRIBUTES, 'efnow055$cont.QueryList'); + WSGL.ClosePageBody; + end; +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'CONT' module component (#View Contract Values#3980#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.CONT_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + '', 'efnow055$cont.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.SaveState +-- +-- Description: Saves the data state for the 'CONT' module component (#View Contract Values#3980#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + '', 'efnow055$cont.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.LoadCache +-- +-- Description: Populate the object cache with +-- 'CONT' module component (#View Contract Values#3980#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + InitialiseDomain('STATUS'); + + ref_Component := WSGOC.Component + ( pModule => efnow055$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'CONT' + , pTitle => '#View Contract Values#3980#' + , pSystemImagePath=> '/images/' + ); + + r_UI_CUST := WSGOC.Item + ( pName => 'UI_CUST' + , pPrompt => '#Customer#1047#' + , pIsContext=> true + ); + r_UI_CONTRACT := WSGOC.Item + ( pName => 'UI_CONTRACT' + , pPrompt => '#Contract Name#2082#' + , pIsContext=> true + ); + r_UI_STATUS := WSGOC.Item + ( pName => 'UI_STATUS' + , pPrompt => '#Status#2114#' + , pIsContext=> true + ); + r_UI_CONT_FROM := WSGOC.Item + ( pName => 'UI_CONT_FROM' + , pPrompt => '#Valid From#2441#' + , pIsContext=> true + ); + r_UI_CONT_TO := WSGOC.Item + ( pName => 'UI_CONT_TO' + , pPrompt => '#Valid To#2442#' + , pIsContext=> true + ); + r_UI_VIEW_URL := WSGOC.Item + ( pName => 'UI_VIEW_URL' + , pPrompt => '#View#2062#' + , pIsContext=> true + ); + r_CONT_ID := WSGOC.Item + ( pName => 'CONT_ID' + , pPrompt => '#Cont Id#2443#' + ); + r_STATUS := WSGOC.Item + ( pName => 'STATUS' + , pPrompt => '#Status#2114#' + ); + r_CONTRACT_NUMBER := WSGOC.Item + ( pName => 'CONTRACT_NUMBER' + , pPrompt => '#Contract Number#2013#' + ); + r_L_CUST_NAME := WSGOC.Item + ( pName => 'L_CUST_NAME' + , pPrompt => '#Name#116#' + ); + r_VALID_UNTIL := WSGOC.Item + ( pName => 'VALID_UNTIL' + , pPrompt => '#Valid Until#2440#' + ); + r_VALID_FROM := WSGOC.Item + ( pName => 'VALID_FROM' + , pPrompt => '#Valid From#2441#' + ); + r_CUST_ID := WSGOC.Item + ( pName => 'CUST_ID' + , pPrompt => 'Cust Id' + ); + + WSGOC.Add_Items(ref_Component, r_UI_CUST); + WSGOC.Add_Items(ref_Component, r_UI_CONTRACT); + WSGOC.Add_Items(ref_Component, r_UI_STATUS); + WSGOC.Add_Items(ref_Component, r_UI_CONT_FROM); + WSGOC.Add_Items(ref_Component, r_UI_CONT_TO); + WSGOC.Add_Items(ref_Component, r_UI_VIEW_URL); + WSGOC.Add_Items(ref_Component, r_CONT_ID); + WSGOC.Add_Items(ref_Component, r_STATUS); + WSGOC.Add_Items(ref_Component, r_CONTRACT_NUMBER); + WSGOC.Add_Items(ref_Component, r_L_CUST_NAME); + WSGOC.Add_Items(ref_Component, r_VALID_UNTIL); + WSGOC.Add_Items(ref_Component, r_VALID_FROM); + WSGOC.Add_Items(ref_Component, r_CUST_ID); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_UI_CUST, replace(WSGL.EscapeItem(NBT_VAL.UI_CUST), ' +', '
+') ); + WSGOC.Set_Value( r_UI_CONTRACT, replace(WSGL.EscapeItem(NBT_VAL.UI_CONTRACT), ' +', '
+') ); + WSGOC.Set_Value( r_UI_STATUS, replace(WSGL.EscapeItem(NBT_VAL.UI_STATUS), ' +', '
+') ); + WSGOC.Set_Value( r_UI_CONT_FROM, EFNOW055$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_FROM, 'DD-MON-RRRR')))) ); + WSGOC.Set_Value( r_UI_CONT_TO, EFNOW055$CONT.FORMATDATE(WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_CONT_TO, 'DD-MON-RRRR')))) ); + WSGOC.Set_Value( r_UI_VIEW_URL, replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_VIEW_URL), '#View#2062#'), ' +', '
+') ); + WSGOC.Set_Value( r_CONT_ID, WSGL.EscapeItem(CURR_VAL.CONT_ID) ); + WSGOC.Set_Value( r_STATUS, replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)), ' +', '
+') ); + WSGOC.Set_Value( r_CONTRACT_NUMBER, replace(WSGL.EscapeItem(CURR_VAL.CONTRACT_NUMBER), ' +', '
+') ); + WSGOC.Set_Value( r_L_CUST_NAME, replace(WSGL.EscapeItem(NBT_VAL.L_CUST_NAME), ' +', '
+') ); + WSGOC.Set_Value( r_VALID_UNTIL, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.VALID_UNTIL, 'DD/MM/YYYY'))) ); + WSGOC.Set_Value( r_VALID_FROM, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.VALID_FROM, 'DD/MM/YYYY'))) ); + WSGOC.Set_Value( r_CUST_ID, WSGL.EscapeItem(CURR_VAL.CUST_ID) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + '', 'efnow055$cont.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'CONT' module component (#View Contract Values#3980#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery( + P_STATUS in varchar2, + P_CONTRACT_NUMBER in varchar2, + P_L_CUST_NAME in varchar2, + P_VALID_FROM in varchar2, + U_VALID_FROM in varchar2) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$cont.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'CONT' module component (#View Contract Values#3980#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + DEF_BODY_ATTRIBUTES, 'efnow055$cont.PostQuery'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$cont.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$cont.spc new file mode 100644 index 0000000..d744f4f --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$cont.spc @@ -0,0 +1,109 @@ +create or replace package efnow055$cont is + + type NBT_REC is record + ( UI_CUST varchar2(24000) + , UI_CONTRACT varchar2(24000) + , UI_STATUS varchar2(24000) + , UI_CONT_FROM date + , UI_CONT_TO date + , UI_VIEW_URL varchar2(24000) + , L_CUST_NAME CUSTOMERS.NAME%type + ); + + NBT_VAL NBT_REC; + CURR_VAL CONTRACTS%rowtype; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure ActionQuery( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null ); + + procedure FormQuery( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryList( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null, + Z_START in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null ); + function QueryHits( + P_STATUS in varchar2 default null, + P_CONTRACT_NUMBER in varchar2 default null, + P_L_CUST_NAME in varchar2 default null, + P_VALID_FROM in varchar2 default null, + U_VALID_FROM in varchar2 default null) return number; + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + procedure InitialiseDomain(P_ALIAS in varchar2); + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + D_STATUS WSGL.typDVRecord;FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + +procedure ncalendar + ( + 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 + ); + +procedure nformat_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$js$cont.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$js$cont.bdy new file mode 100644 index 0000000..63936a8 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$js$cont.bdy @@ -0,0 +1,122 @@ +create or replace package body efnow055$js$cont is + + +-------------------------------------------------------------------------------- +-- Name: efnow055$js$cont.CreateQueryJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateQueryJavaScript ( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Query";'); + + + + WSGJSL.Output_Invoke_CAL_JS ('efnow055$cont', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('L_CUST_NAME','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + index = -1; + modeStr = "Q"; +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl, index, modeStr, "efnow055$cont.l_cust_name_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('CONT','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnQFQ','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + QF_BODY_ATTRIBUTES, 'efnow055$js$cont.CreateQueryJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow055$js$cont.CreateListJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateListJavaScript ( + RL_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow055$cont') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "List";'); + + + htp.p( 'var P_4 = new Array();' ); + + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Contract Values#3980#', + RL_BODY_ATTRIBUTES, 'efnow055$js$cont.CreateListJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$js$cont.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$js$cont.spc new file mode 100644 index 0000000..cf36069 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow055$js$cont.spc @@ -0,0 +1,11 @@ +create or replace package efnow055$js$cont is + + procedure CreateQueryJavaScript( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2); + + procedure CreateListJavaScript( + RL_BODY_ATTRIBUTES in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$.bdy new file mode 100644 index 0000000..eadc11b --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$.bdy @@ -0,0 +1,232 @@ +create or replace package body efnow070$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +-------------------------------------------------------------------------------- +-- Name: efnow070$.Startup +-- +-- Description: This procedure is the entry point for the 'efnow070$' +-- module. +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('efnow070$') then + return; + end if; + + WSGL.RegisterURL('efnow070$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, WSGL.MsgGetText(21,WSGLM.CAP021_TOP_LEVEL)); + efnow070$gttd.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow070$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow070$.firstpage +-- +-- Description: This procedure creates the first page for the 'efnow070$' +-- module. +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('efnow070$') then + return; + end if; + + WSGL.OpenPageHead(''); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'efnow070$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow070$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow070$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'efnow070$' module. +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('efnow070$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('efnow070$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + + htp.para; + htp.p(' +$Revision: 1.2 $'); + htp.para; + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Nominations', 'EFNOW070', l_usr); + + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow070$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow070$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('efnow070$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow070$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow070$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'efnow070$' module. +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'efnow070$' + , pFirstTitle => '' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow070$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow070$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$.spc new file mode 100644 index 0000000..746ae4d --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$.spc @@ -0,0 +1,14 @@ +create or replace package efnow070$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$gttd.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$gttd.bdy new file mode 100644 index 0000000..cf1dce0 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$gttd.bdy @@ -0,0 +1,1087 @@ +create or replace package body efnow070$gttd is + + function BuildSQL( + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function PreQuery return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + RL_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + RL_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + RL_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + RL_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + RL_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + RL_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + RL_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + RL_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + RL_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + RL_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + RL_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + RL_RECORD_SET_SIZE constant number(4) := 20; + RL_TOTAL_COUNT_REQD constant boolean := FALSE; + RL_NUMBER_OF_COLUMNS constant number(4) := 1; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + type FORM_REC is record + (UI_VALID_FROM varchar2(24000) + ,VALID_FROM varchar2(12) + ,UI_VALID_UNTIL varchar2(24000) + ,VALID_UNTIL varchar2(12) + ,CONTRACT_NUMBER varchar2(180) + ,STATUS varchar2(6) + ,UI_HYPERLINK varchar2(24000) + ,L_CUST_CODE varchar2(120) + ,CONT_ID varchar2(40) + ,CUST_ID varchar2(40) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_UI_VALID_FROM WSGOC.ITEM_REF; + R_VALID_FROM WSGOC.ITEM_REF; + R_UI_VALID_UNTIL WSGOC.ITEM_REF; + R_VALID_UNTIL WSGOC.ITEM_REF; + R_CONTRACT_NUMBER WSGOC.ITEM_REF; + R_STATUS WSGOC.ITEM_REF; + R_UI_HYPERLINK WSGOC.ITEM_REF; + R_L_CUST_CODE WSGOC.ITEM_REF; + R_CONT_ID WSGOC.ITEM_REF; + R_CUST_ID WSGOC.ITEM_REF; + + + +FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- formatdate +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date, 'DD/MM/YYYY HH24:MI'),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDate; +PROCEDURE get_template ( p_temp_id IN VARCHAR2 ) IS + +-- get_template +-- +-- + + + +BEGIN + amfr_excel.get_template( p_temp_id + , 'NOMINATION' + ); +END; +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.InitialiseDomain +-- +-- Description: Initialises the Domain Record for the given Column Usage +-- +-- Parameters: P_ALIAS The alias of the column usage +-- +-------------------------------------------------------------------------------- + procedure InitialiseDomain(P_ALIAS in varchar2) is + begin + if not caco_security.security_check('efnow070$gttd') then + return; + end if; + + if P_ALIAS = 'STATUS' and not D_STATUS.Initialised then + D_STATUS.ColAlias := 'STATUS'; + D_STATUS.ControlType := WSGL.DV_TEXT; + D_STATUS.DispWidth := 6; + D_STATUS.DispHeight := 1; + D_STATUS.MaxWidth := 1; + D_STATUS.UseMeanings := False; + D_STATUS.ColOptional := True; + D_STATUS.Vals(1) := 'O'; + D_STATUS.Meanings(1) := 'O'; + D_STATUS.Abbreviations(1) := 'Open'; + D_STATUS.Vals(2) := 'C'; + D_STATUS.Meanings(2) := 'C'; + D_STATUS.Abbreviations(2) := 'Closed'; + D_STATUS.NumOfVV := 2; + D_STATUS.Initialised := True; + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + DEF_BODY_ATTRIBUTES, 'efnow070$gttd.InitialseDomain'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow070$gttd.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), + CAL_BODY_ATTRIBUTES, + 'efnow070$gttd', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow070$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow070$gttd', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow070$gttd.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.Startup +-- +-- Description: Entry point for the 'GTTD' module +-- component (#Download Excel Template#2109#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow070$gttd') then + return; + end if; + + WSGL.RegisterURL('efnow070$gttd.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, '#Download Excel Template#2109#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'LIST' then + QueryList( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + QueryList( + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + DEF_BODY_ATTRIBUTES, 'efnow070$gttd.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow070$gttd') then + return -1; + end if; + + if not BuildSQL then + return -1; + end if; + + if not PreQuery then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Download Excel Template#2109#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + DEF_BODY_ATTRIBUTES, 'efnow070$gttd.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.BuildSQL +-- +-- Description: Builds the SQL for the 'GTTD' module component (#Download Excel Template#2109#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE CONT_ID = ' || to_char(CURR_VAL.CONT_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + + null; + end if; + + ZONE_SQL := 'SELECT UI_VALID_FROM, + VALID_FROM, + UI_VALID_UNTIL, + VALID_UNTIL, + CONTRACT_NUMBER, + STATUS, + UI_HYPERLINK, + L_CUST_CODE, + CONT_ID, + CUST_ID + FROM ( SELECT efnow070$gttd.formatdate(TO_CHAR(CONT.VALID_FROM,''DD/MM/YYYY HH24:MI'')) UI_VALID_FROM, + CONT.VALID_FROM VALID_FROM, + efnow070$gttd.formatdate(TO_CHAR(CONT.VALID_UNTIL,''DD/MM/YYYY HH24:MI'')) UI_VALID_UNTIL, + CONT.VALID_UNTIL VALID_UNTIL, + CONT.CONTRACT_NUMBER CONTRACT_NUMBER, + CONT.STATUS STATUS, + ''efnow070$gttd.get_template?p_temp_id=''||CONT.CONT_ID UI_HYPERLINK, + L_CUST.CODE L_CUST_CODE, + CONT.CONT_ID CONT_ID, + CONT.CUST_ID CUST_ID +FROM CONTRACTS CONT, + CUSTOMERS L_CUST +WHERE ( /* CG$MDTU_QWC_START GTTD.CONT */ + (CONT.VALID_UNTIL >= TRUNC(SYSDATE) AND CONT.STATUS = ''O'') + /* CG$MDTU_QWC_END GTTD.CONT */ + ) AND + ( /* CG$MDTU_QWC_START GTTD.L_CUST */ + (CONT.CUST_ID = caco_utilities.get_cust_id) + /* CG$MDTU_QWC_END GTTD.L_CUST */ + ) AND + CONT.CUST_ID = L_CUST.CUST_ID + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY VALID_FROM Desc '; + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + DEF_BODY_ATTRIBUTES, 'efnow070$gttd.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'GTTD' module component (#Download Excel Template#2109#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, NBT_VAL.UI_VALID_FROM, 4000); + dbms_sql.define_column(I_CURSOR, 2, CURR_VAL.VALID_FROM); + dbms_sql.define_column(I_CURSOR, 3, NBT_VAL.UI_VALID_UNTIL, 4000); + dbms_sql.define_column(I_CURSOR, 4, CURR_VAL.VALID_UNTIL); + dbms_sql.define_column(I_CURSOR, 5, CURR_VAL.CONTRACT_NUMBER, 30); + dbms_sql.define_column(I_CURSOR, 6, CURR_VAL.STATUS, 1); + dbms_sql.define_column(I_CURSOR, 7, NBT_VAL.UI_HYPERLINK, 4000); + dbms_sql.define_column(I_CURSOR, 8, NBT_VAL.L_CUST_CODE, 20); + dbms_sql.define_column(I_CURSOR, 9, CURR_VAL.CONT_ID); + dbms_sql.define_column(I_CURSOR, 10, CURR_VAL.CUST_ID); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + '', 'efnow070$gttd.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'GTTD' module component (#Download Excel Template#2109#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, NBT_VAL.UI_VALID_FROM); + dbms_sql.column_value(I_CURSOR, 2, CURR_VAL.VALID_FROM); + dbms_sql.column_value(I_CURSOR, 3, NBT_VAL.UI_VALID_UNTIL); + dbms_sql.column_value(I_CURSOR, 4, CURR_VAL.VALID_UNTIL); + dbms_sql.column_value(I_CURSOR, 5, CURR_VAL.CONTRACT_NUMBER); + dbms_sql.column_value(I_CURSOR, 6, CURR_VAL.STATUS); + dbms_sql.column_value(I_CURSOR, 7, NBT_VAL.UI_HYPERLINK); + dbms_sql.column_value(I_CURSOR, 8, NBT_VAL.L_CUST_CODE); + dbms_sql.column_value(I_CURSOR, 9, CURR_VAL.CONT_ID); + dbms_sql.column_value(I_CURSOR, 10, CURR_VAL.CUST_ID); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.CONT_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + '', 'efnow070$gttd.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.QueryList +-- +-- Description: This procedure builds the Record list for the 'GTTD' +-- module component (#Download Excel Template#2109#). +-- +-- The Record List displays context information for records which +-- match the specified query criteria. +-- Sets of records are displayed (20 records at a time) +-- with Next/Previous buttons to get other record sets. +-- +-- Parameters: Z_START - First record to display +-- Z_ACTION - Next or Previous set +-- +-------------------------------------------------------------------------------- + procedure QueryList( + Z_START in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2 ) is + + I_VF_FRAME varchar2(20) := null; + I_WHERE varchar2(2000) := ''; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + I_TOTAL_ROWS integer := 0; + I_START number(38) := to_number(Z_START); + I_COUNT number(10) := 0; + I_OF_TOTAL_TEXT varchar2(200) := ''; + I_NEXT_BUT boolean; + I_PREV_BUT boolean; + I_COL_COUNT integer; + I_SUCCESS boolean := true; + l_row integer := 0; + l_id varchar2(35) := null; + -- Reset break group? + RSGTTD boolean := true; + I_LAST_BASE CURR_VAL%TYPE; + I_LAST_NBT NBT_REC; + + + + begin + + if not caco_security.security_check('efnow070$gttd') then + return; + end if; + + + WSGL.RegisterURL('efnow070$gttd.querylist'); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if (not Z_DIRECT_CALL) then + + null; + + + end if; + -- Set up any master context values that may be required + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + + + WSGL.OpenPageHead(''||' : '||'#Download Excel Template#2109#'); + WSGL.METATag; + efnow070$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>RL_BODY_ATTRIBUTES); + efnow070$js$gttd.CreateListJavaScript(RL_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + efnow070$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) or + (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + (RL_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits; + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + RL_TOTAL_COUNT_REQD then + I_OF_TOTAL_TEXT := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + if Z_START IS NULL or (Z_ACTION = RL_FIRST_BUT_ACTION) or (Z_ACTION = RL_FIRST_BUT_CAPTION) then + I_START := 1; + elsif (Z_ACTION = RL_NEXT_BUT_ACTION) or (Z_ACTION = RL_NEXT_BUT_CAPTION) then + I_START := I_START + RL_RECORD_SET_SIZE; + elsif (Z_ACTION = RL_PREV_BUT_ACTION) or (Z_ACTION = RL_PREV_BUT_CAPTION) then + I_START := I_START - RL_RECORD_SET_SIZE; + elsif (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) then + I_START := 1 + (floor((I_COUNT-1)/RL_RECORD_SET_SIZE)*RL_RECORD_SET_SIZE); + elsif Z_ACTION is null and I_START = 1 then + null; + elsif Z_ACTION IS NULL then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(215,WSGLM.MSG215_NO_MULTIPLE_SUBMITS), + ''||' : '||'#Download Excel Template#2109#', RL_BODY_ATTRIBUTES); + WSGL.ClosePageBody; + return; + end if; + + if I_START < 1 then + I_START := 1; + end if; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + + if ZONE_SQL IS NULL then + if not BuildSQL then + WSGL.ClosePageBody; + return; + end if; + end if; + + if not PreQuery then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Download Excel Template#2109#', RL_BODY_ATTRIBUTES); + return; + end if; + + InitialiseDomain('STATUS'); + + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := 0; + end if; + I_TOTAL_ROWS := I_ROWS_FETCHED; + + if I_ROWS_FETCHED != 0 then + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, p_no_spacing=>true); + + WSGL.LayoutRowStart(p_attrs=>'class = cgrlheaderrow'); + for i in 1..RL_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(30, 'LEFT', '#Valid From#2441#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Valid Until#2440#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Contract Number#2013#','CONTRACT_NUMBER'); + WSGL.LayoutHeader(30, 'LEFT', '#Download Template#2446#',''); + end loop; + WSGL.LayoutRowEnd; + + while I_ROWS_FETCHED <> 0 loop + + if I_TOTAL_ROWS >= I_START then + AssignZoneRow(I_CURSOR); + + if (NBT_VAL.UI_VALID_FROM != I_LAST_NBT.UI_VALID_FROM or (NBT_VAL.UI_VALID_FROM is null and I_LAST_NBT.UI_VALID_FROM is not null) or (NBT_VAL.UI_VALID_FROM is not null and I_LAST_NBT.UI_VALID_FROM is null) ) or + (CURR_VAL.VALID_FROM != I_LAST_BASE.VALID_FROM or (CURR_VAL.VALID_FROM is null and I_LAST_BASE.VALID_FROM is not null) or (CURR_VAL.VALID_FROM is not null and I_LAST_BASE.VALID_FROM is null) ) or + (NBT_VAL.UI_VALID_UNTIL != I_LAST_NBT.UI_VALID_UNTIL or (NBT_VAL.UI_VALID_UNTIL is null and I_LAST_NBT.UI_VALID_UNTIL is not null) or (NBT_VAL.UI_VALID_UNTIL is not null and I_LAST_NBT.UI_VALID_UNTIL is null) ) or + (CURR_VAL.VALID_UNTIL != I_LAST_BASE.VALID_UNTIL or (CURR_VAL.VALID_UNTIL is null and I_LAST_BASE.VALID_UNTIL is not null) or (CURR_VAL.VALID_UNTIL is not null and I_LAST_BASE.VALID_UNTIL is null) ) or + (CURR_VAL.CONTRACT_NUMBER != I_LAST_BASE.CONTRACT_NUMBER or (CURR_VAL.CONTRACT_NUMBER is null and I_LAST_BASE.CONTRACT_NUMBER is not null) or (CURR_VAL.CONTRACT_NUMBER is not null and I_LAST_BASE.CONTRACT_NUMBER is null) ) or + (CURR_VAL.STATUS != I_LAST_BASE.STATUS or (CURR_VAL.STATUS is null and I_LAST_BASE.STATUS is not null) or (CURR_VAL.STATUS is not null and I_LAST_BASE.STATUS is null) ) or + (NBT_VAL.UI_HYPERLINK != I_LAST_NBT.UI_HYPERLINK or (NBT_VAL.UI_HYPERLINK is null and I_LAST_NBT.UI_HYPERLINK is not null) or (NBT_VAL.UI_HYPERLINK is not null and I_LAST_NBT.UI_HYPERLINK is null) ) or + (NBT_VAL.L_CUST_CODE != I_LAST_NBT.L_CUST_CODE or (NBT_VAL.L_CUST_CODE is null and I_LAST_NBT.L_CUST_CODE is not null) or (NBT_VAL.L_CUST_CODE is not null and I_LAST_NBT.L_CUST_CODE is null) ) or + (CURR_VAL.CONT_ID != I_LAST_BASE.CONT_ID or (CURR_VAL.CONT_ID is null and I_LAST_BASE.CONT_ID is not null) or (CURR_VAL.CONT_ID is not null and I_LAST_BASE.CONT_ID is null) ) or + (CURR_VAL.CUST_ID != I_LAST_BASE.CUST_ID or (CURR_VAL.CUST_ID is null and I_LAST_BASE.CUST_ID is not null) or (CURR_VAL.CUST_ID is not null and I_LAST_BASE.CUST_ID is null) ) then + RSGTTD := true; + else + RSGTTD := false; + end if; + + + I_LAST_NBT.UI_VALID_FROM := NBT_VAL.UI_VALID_FROM; + I_LAST_BASE.VALID_FROM := CURR_VAL.VALID_FROM; + I_LAST_NBT.UI_VALID_UNTIL := NBT_VAL.UI_VALID_UNTIL; + I_LAST_BASE.VALID_UNTIL := CURR_VAL.VALID_UNTIL; + I_LAST_BASE.CONTRACT_NUMBER := CURR_VAL.CONTRACT_NUMBER; + I_LAST_BASE.STATUS := CURR_VAL.STATUS; + I_LAST_NBT.UI_HYPERLINK := NBT_VAL.UI_HYPERLINK; + I_LAST_NBT.L_CUST_CODE := NBT_VAL.L_CUST_CODE; + I_LAST_BASE.CONT_ID := CURR_VAL.CONT_ID; + I_LAST_BASE.CUST_ID := CURR_VAL.CUST_ID; + l_row := l_row + 1; + + + WSGL.LayoutRowStart('TOP', p_attrs=>'class = cgrldatarow'); + l_id := '' || l_row; + if RSGTTD and NBT_VAL.UI_VALID_FROM is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_VALID_FROM), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSGTTD and NBT_VAL.UI_VALID_UNTIL is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_VALID_UNTIL), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := 'CONTRACT_NUMBER' || l_row; + if RSGTTD and CURR_VAL.CONTRACT_NUMBER is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(CURR_VAL.CONTRACT_NUMBER), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSGTTD and NBT_VAL.UI_HYPERLINK is not null then + WSGL.LayoutData(p_text=>replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_HYPERLINK), '#Download Template#2446#'), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + + WSGL.LayoutRowEnd; + + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + if I_TOTAL_ROWS = I_START + RL_RECORD_SET_SIZE - 1 then + if I_ROWS_FETCHED <> 0 then + I_NEXT_BUT := TRUE; + end if; + exit; + end if; + else + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + end if; + + I_TOTAL_ROWS := I_TOTAL_ROWS + I_ROWS_FETCHED; + + end loop; + + WSGL.LayoutClose; + + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + dbms_sql.close_cursor(I_CURSOR); + end if; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow070$gttd.querylist', cattributes => 'NAME="efnow070$gttd$LForm"'); + SaveState; + WSGL.HiddenField('Z_START', to_char(I_START)); + htp.p (''); + + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_REQUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_REQUERY_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_PREV_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_PREV_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_NEXT_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_NEXT_BUT_ACTION || '\''"'); + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''))); + htp.formClose; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + RL_BODY_ATTRIBUTES, 'efnow070$gttd.QueryList'); + WSGL.ClosePageBody; + end; +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'GTTD' module component (#Download Excel Template#2109#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.CONT_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + '', 'efnow070$gttd.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.SaveState +-- +-- Description: Saves the data state for the 'GTTD' module component (#Download Excel Template#2109#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + '', 'efnow070$gttd.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.LoadCache +-- +-- Description: Populate the object cache with +-- 'GTTD' module component (#Download Excel Template#2109#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + InitialiseDomain('STATUS'); + + ref_Component := WSGOC.Component + ( pModule => efnow070$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'GTTD' + , pTitle => '#Download Excel Template#2109#' + , pSystemImagePath=> '/images/' + ); + + r_UI_VALID_FROM := WSGOC.Item + ( pName => 'UI_VALID_FROM' + , pPrompt => '#Valid From#2441#' + , pIsContext=> true + ); + r_VALID_FROM := WSGOC.Item + ( pName => 'VALID_FROM' + , pPrompt => '#Valid From#2441#' + ); + r_UI_VALID_UNTIL := WSGOC.Item + ( pName => 'UI_VALID_UNTIL' + , pPrompt => '#Valid Until#2440#' + , pIsContext=> true + ); + r_VALID_UNTIL := WSGOC.Item + ( pName => 'VALID_UNTIL' + , pPrompt => '#Valid Until#2440#' + ); + r_CONTRACT_NUMBER := WSGOC.Item + ( pName => 'CONTRACT_NUMBER' + , pPrompt => '#Contract Number#2013#' + , pIsContext=> true + ); + r_STATUS := WSGOC.Item + ( pName => 'STATUS' + , pPrompt => '#Status#2114#' + ); + r_UI_HYPERLINK := WSGOC.Item + ( pName => 'UI_HYPERLINK' + , pPrompt => '#Download Template#2446#' + , pIsContext=> true + ); + r_L_CUST_CODE := WSGOC.Item + ( pName => 'L_CUST_CODE' + , pPrompt => '#Code#19#' + ); + r_CONT_ID := WSGOC.Item + ( pName => 'CONT_ID' + , pPrompt => '#Cont Id#2443#' + ); + r_CUST_ID := WSGOC.Item + ( pName => 'CUST_ID' + , pPrompt => 'Cust Id' + ); + + WSGOC.Add_Items(ref_Component, r_UI_VALID_FROM); + WSGOC.Add_Items(ref_Component, r_VALID_FROM); + WSGOC.Add_Items(ref_Component, r_UI_VALID_UNTIL); + WSGOC.Add_Items(ref_Component, r_VALID_UNTIL); + WSGOC.Add_Items(ref_Component, r_CONTRACT_NUMBER); + WSGOC.Add_Items(ref_Component, r_STATUS); + WSGOC.Add_Items(ref_Component, r_UI_HYPERLINK); + WSGOC.Add_Items(ref_Component, r_L_CUST_CODE); + WSGOC.Add_Items(ref_Component, r_CONT_ID); + WSGOC.Add_Items(ref_Component, r_CUST_ID); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_UI_VALID_FROM, replace(WSGL.EscapeItem(NBT_VAL.UI_VALID_FROM), ' +', '
+') ); + WSGOC.Set_Value( r_VALID_FROM, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.VALID_FROM, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_UI_VALID_UNTIL, replace(WSGL.EscapeItem(NBT_VAL.UI_VALID_UNTIL), ' +', '
+') ); + WSGOC.Set_Value( r_VALID_UNTIL, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.VALID_UNTIL, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_CONTRACT_NUMBER, replace(WSGL.EscapeItem(CURR_VAL.CONTRACT_NUMBER), ' +', '
+') ); + WSGOC.Set_Value( r_STATUS, replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)), ' +', '
+') ); + WSGOC.Set_Value( r_UI_HYPERLINK, replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_HYPERLINK), '#Download Template#2446#'), ' +', '
+') ); + WSGOC.Set_Value( r_L_CUST_CODE, replace(WSGL.EscapeItem(NBT_VAL.L_CUST_CODE), ' +', '
+') ); + WSGOC.Set_Value( r_CONT_ID, WSGL.EscapeItem(CURR_VAL.CONT_ID) ); + WSGOC.Set_Value( r_CUST_ID, WSGL.EscapeItem(CURR_VAL.CUST_ID) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + '', 'efnow070$gttd.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'GTTD' module component (#Download Excel Template#2109#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + DEF_BODY_ATTRIBUTES, 'efnow070$gttd.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow070$gttd.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'GTTD' module component (#Download Excel Template#2109#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + DEF_BODY_ATTRIBUTES, 'efnow070$gttd.PostQuery'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$gttd.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$gttd.spc new file mode 100644 index 0000000..0d185f1 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$gttd.spc @@ -0,0 +1,66 @@ +create or replace package efnow070$gttd is + + type NBT_REC is record + ( UI_VALID_FROM varchar2(24000) + , UI_VALID_UNTIL varchar2(24000) + , UI_HYPERLINK varchar2(24000) + , L_CUST_CODE CUSTOMERS.CODE%type + ); + + NBT_VAL NBT_REC; + CURR_VAL CONTRACTS%rowtype; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure QueryList( + Z_START in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null ); + function QueryHits return number; + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + procedure InitialiseDomain(P_ALIAS in varchar2); + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + D_STATUS WSGL.typDVRecord;FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + +PROCEDURE get_template ( p_temp_id IN VARCHAR2 ); + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$js$gttd.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$js$gttd.bdy new file mode 100644 index 0000000..8b1262f --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$js$gttd.bdy @@ -0,0 +1,33 @@ +create or replace package body efnow070$js$gttd is + + +-------------------------------------------------------------------------------- +-- Name: efnow070$js$gttd.CreateListJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateListJavaScript ( + RL_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow070$gttd') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "List";'); + + + htp.p( 'var P_8 = new Array();' ); + + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Download Excel Template#2109#', + RL_BODY_ATTRIBUTES, 'efnow070$js$gttd.CreateListJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$js$gttd.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$js$gttd.spc new file mode 100644 index 0000000..9e010e3 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow070$js$gttd.spc @@ -0,0 +1,7 @@ +create or replace package efnow070$js$gttd is + + procedure CreateListJavaScript( + RL_BODY_ATTRIBUTES in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow092$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow092$.bdy new file mode 100644 index 0000000..26ec663 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow092$.bdy @@ -0,0 +1,6821 @@ +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$; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow092$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow092$.spc new file mode 100644 index 0000000..7b34410 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow092$.spc @@ -0,0 +1,135 @@ +CREATE OR REPLACE PACKAGE efnow092$ IS + -- + g_package_name VARCHAR2(15) := 'efnow092$'; + g_title CONSTANT VARCHAR2(50) := caco_utilities.get_module_text(2271); -- Maintain Contract + g_header CONSTANT VARCHAR2(160) := '$Header: $'; + g_revision CONSTANT VARCHAR2(160) := '$Revision: $ Patch 0.3'; + -- + -- + g_vc_arr owa_util.vc_arr; + g_num_arr owa_util.num_arr; + -- + g_perc_split_en module_text.text%TYPE := caco_utilities.get_module_text(3921,'EN'); + g_perc_split_hu module_text.text%TYPE := caco_utilities.get_module_text(3921,'HU'); + -- + TYPE network_point_record IS RECORD ( nepo_id network_points.nepo_id%TYPE + , name network_points.name%TYPE ); + -- + TYPE network_point_array IS TABLE OF network_point_record INDEX BY BINARY_INTEGER; + -- + TYPE category_record IS RECORD ( cate_id categories.cate_id%TYPE + , name VARCHAR2(200) + , inherited VARCHAR2(1) ); + -- + TYPE category_array IS TABLE OF category_record INDEX BY BINARY_INTEGER; + -- + TYPE parameter_record IS RECORD ( pars_id parameters.pars_id%TYPE + , name parameters.name%TYPE + , inherited VARCHAR2(1) ); + -- + TYPE parameter_array IS TABLE OF parameter_record INDEX BY BINARY_INTEGER; + -- + -- + /** + -- Generic procedures for the date LOV, same as designer generated code + */ + 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 ); + -- + PROCEDURE format_cal_date( z_field_name IN VARCHAR2 + , z_field_format IN VARCHAR2 + , DAY IN VARCHAR2 + , MONTH IN VARCHAR2 + , YEAR IN VARCHAR2 ); + -- + -- + PROCEDURE optiontransfer_js; + PROCEDURE autocomplete_js; + PROCEDURE selectbox_js; + PROCEDURE contract_js; + PROCEDURE contractP2_js; + PROCEDURE contractRules_js; + PROCEDURE templateRules_js; + -- + PROCEDURE contractP1_css; + PROCEDURE contractP2_css; + PROCEDURE contractRules_css; + PROCEDURE templateRules_css; + -- + 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 ); + -- + 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 ); + -- + 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 ); + -- +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 ); + -- +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 ); + -- + -- +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 ); + -- + PROCEDURE export_to_excel ( p_contract_id IN NUMBER); + -- + PROCEDURE import_from_excel (p_contract_id IN NUMBER + ,p_spreadsheet IN VARCHAR2 DEFAULT NULL ); + -- + FUNCTION about RETURN VARCHAR2; + -- +END EFNOW092$; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow095$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow095$.bdy new file mode 100644 index 0000000..4ae26dd --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow095$.bdy @@ -0,0 +1,1195 @@ +CREATE OR REPLACE PACKAGE BODY efnow095$ IS +-- +-- +-- +PROCEDURE calendar( z_field_name IN VARCHAR2 + , z_caller_url IN VARCHAR2 + , z_field_value IN VARCHAR2 DEFAULT NULL + , z_field_format IN VARCHAR2 DEFAULT NULL + , z_field_prompt IN VARCHAR2 DEFAULT NULL ) +IS + -- + field_caption VARCHAR2(2000); + -- +BEGIN + -- + IF z_field_prompt IS NULL THEN + -- + field_caption := initcap(REPLACE( substr( z_field_name + , 3 + , length(z_field_name) - 2) + , '_' + , ' ' )); + -- + ELSE + -- + field_caption := initcap(REPLACE( z_field_prompt + , '_' + , ' ' )); + -- + END IF; + -- + wsgl.registerurl( g_package_name || '.calendar'); + wsgl.addurlparam( 'Z_FIELD_NAME', z_field_name ); + wsgl.addurlparam( 'Z_CALLER_URL', z_caller_url ); + -- + IF wsgl.notlowercase THEN + RETURN; + END IF; + -- + wsgl.output_calendar( z_field_name + , z_field_value + , z_field_format + , wsgl.msggettext( 123 + , wsglm.dsp128_cal_caption + , field_caption ) + , NULL + , g_package_name + , 'Close' + , TRUE + , 'DD-MON-RRRR' ); + -- + wsgl.output_calendar( z_field_name + , z_field_value + , z_field_format + , wsgl.msggettext( 123 + , wsglm.dsp128_cal_caption + , field_caption ) + , NULL + , g_package_name + , 'Close' + , FALSE + , 'DD-MON-RRRR' ); + -- +EXCEPTION + WHEN OTHERS THEN + wsgl.displaymessage( wsgl.mess_exception + , SQLERRM + , '' + , NULL + , g_package_name || '.calendar' ); +END calendar; +-- +-- +-- +PROCEDURE format_cal_date( z_field_name IN VARCHAR2 + , z_field_format IN VARCHAR2 + , DAY IN VARCHAR2 + , MONTH IN VARCHAR2 + , YEAR IN VARCHAR2 ) +IS + -- + field_caption VARCHAR2(2000) := initcap(REPLACE( substr( z_field_name + , 3 + , length(z_field_name) - 2 ) + , '_' + , ' ' )); + l_day VARCHAR2(15) := DAY; + -- + PROCEDURE output_format_cal_js( page_header IN VARCHAR2 + , body_attributes IN VARCHAR2 + , chosen_date IN VARCHAR2 + , field_format IN VARCHAR2 ) + IS + -- + -- Copied from WSGL + -- + the_date DATE := to_date(chosen_date, 'DD-MONTH-YYYY'); + -- + BEGIN + -- + wsgl.openpagehead(page_header); + wsgl.closepagehead; + wsgl.openpagebody(FALSE, p_attributes => body_attributes); + htp.p(''); + wsgl.closepagebody; + -- + END output_format_cal_js; +BEGIN + -- + IF l_day = '0' THEN + l_day := '01'; + END IF; + -- + output_format_cal_js( wsgl.msggettext( 123 + , wsglm.dsp128_cal_caption + , field_caption ) + , NULL + , l_day || '-' || MONTH || '-' || YEAR + , z_field_format ); + -- +END format_cal_date; +-- +-- +FUNCTION dad_path + RETURN VARCHAR2 +IS +BEGIN + RETURN(lower(owa_util.get_cgi_env('REQUEST_PROTOCOL') || '://' || + owa_util.get_cgi_env('HTTP_HOST') || + owa_util.get_cgi_env('SCRIPT_NAME') || '/')); +END dad_path; +-- +-- +-- +PROCEDURE approve_conf_css +IS +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check(g_package_name) THEN + RETURN; + END IF; + -- + htp.p(' + h2 { + color : #F21C0A; + } + + .confTable { + border : 1px solid; + } + + .confTable td { + border : 1px solid; + } + + .confTable th { + background-color : #D9D9D9; + border-left-width : 1px; + border-left-style : solid; + border-left-color : #F21C0A; + border-right-width : 1px; + border-right-style : solid; + border-right-color : #F21C0A; + border-top-width : 1px; + border-top-style : solid; + border-top-color : #F21C0A; + border-bottom-width : 1px; + border-bottom-style : solid; + border-bottom-color : #F21C0A; + } + + .confTH { + font-weight : normal; + padding : 2px; + background-color : #D9D9D9; + border-left-width : 1px; + border-left-style : solid; + border-left-color : #F21C0A; + border-right-width : 1px; + border-right-style : solid; + border-right-color : #F21C0A; + border-top-width : 1px; + border-top-style : solid; + border-top-color : #F21C0A; + border-bottom-width : 1px; + border-bottom-style : solid; + border-bottom-color : #F21C0A; + height : 20px; + } + + .confTHCreatedDate { + font-weight : normal; + padding : 2px; + background-color : #D9D9D9; + border-left-width : 1px; + border-left-style : solid; + border-left-color : #F21C0A; + border-right-width : 1px; + border-right-style : solid; + border-right-color : #F21C0A; + border-top-width : 1px; + border-top-style : solid; + border-top-color : #F21C0A; + border-bottom-width : 1px; + border-bottom-style : solid; + border-bottom-color : #F21C0A; + height : 20px; + width : 170px; + } + + .confTHCentre { + text-align : center; + padding : 2px; + font-weight : normal; + background-color : #D9D9D9; + border-left-width : 1px; + border-left-style : solid; + border-left-color : #F21C0A; + border-right-width : 1px; + border-right-style : solid; + border-right-color : #F21C0A; + border-top-width : 1px; + border-top-style : solid; + border-top-color : #F21C0A; + border-bottom-width : 1px; + border-bottom-style : solid; + border-bottom-color : #F21C0A; + height : 20px; + width : 50px; + } + + .smallTextButton { + font-size : smaller; + } + + .nomValidTR1 { + background-color : #FFFFFF; + border-style : none; + height : 20px; + } + + .nomValidTR2 { + background-color : #F5F5F5; + border-style : none; + height : 20px; + } + + .nomInvalid { + background-color : #FF9F98; + padding : 2px; + height : 20px; + } + + .nomTDCentre { + text-align : center; + padding : 2px; + } + + .nomTDGasDay { + text-align : center; + padding : 2px; + width : 100px + } + + .nomTDValid { + text-align : center; + padding : 2px; + width : 60px; + } + + '); +END approve_conf_css; +-- +-- +-- +PROCEDURE approve_conf_js +IS +BEGIN + -- Check we have permission to be using this module. + IF NOT caco_security.security_check(g_package_name) THEN + RETURN; + END IF; + -- + htp.p(' + function checkDateThenGo( dadPath ) { + var theDate = document.getElementById(''p_gas_day''); + + if ( theDate.value != "" ) { + location.href = dadPath + ''efnow095$.startup?p_gas_day='' + theDate.value; + } + else { + alert('''||caco_utilities.get_module_text(2422)||''');'); -- Select a Gas Day + htp.p(' } + } + + function changeCheckBox( obj ) { + var prevInput = obj.previousSibling; + + if (obj.checked) { + prevInput.value = "Y"; + } + else { + prevInput.value = "N"; + } + } + + function checkAll( field ) + { + var i=0 + var x=new Array() + while (document.getElementById(field+i)!=null){ + x[i]= document.getElementById(field+i) + i++ + } + + for (i = 0; i < x.length; i++) + { + x[i].checked = true; + changeCheckBox(x[i]); + } + } + + function setApp( obj ) { + var appItem = obj.previousSibling; + var allAppItems = document.getElementsByName( ''p_approve'' ); + var allDelItems = document.getElementsByName( ''p_delete'' ); + var appIndex = -1; // to hold the index of the approval item we are interested in + + for (i=0;i -1) { + if (obj.checked) { + appItem.value = ''Y''; + allDelItems[appIndex].value = ''N''; + allDelItems[appIndex].nextSibling.checked = false; + } + else { + appItem.value = ''N''; + } + } + } + + function setDel( obj ) { + var delItem = obj.previousSibling; + var allDelItems = document.getElementsByName( ''p_delete'' ); + var allAppItems = document.getElementsByName( ''p_approve'' ); + var delIndex = -1; // to hold the index of the delete item we are interested in + + for (i=0;i -1) { + if (obj.checked) { + delItem.value = ''Y''; + allAppItems[delIndex].value = ''N''; + allAppItems[delIndex].nextSibling.checked = false; + } + else { + delItem.value = ''N''; + } + } + } + + function checkAppAll( field ) + { + var i=0 + var x=new Array() + while (document.getElementById(field+i)!=null){ + x[i]= document.getElementById(field+i) + i++ + } + + for (i = 0; i < x.length; i++) + { + x[i].checked = true; + if (field == "p_approve_disp") { + setApp(x[i])} + else { + setDel(x[i])}; + + } + } + + + '); +END approve_conf_js; +-- +-- +PROCEDURE conf_approve_tabhead IS +BEGIN + htp.p('
+ + + + + '); -- Created On + htp.p(' '); -- Customer + htp.p(' '); -- Contract Number + htp.p(' '); -- Nomination ID + htp.p(' '); -- Gas Day + htp.p(' '); -- View + htp.p(' '); -- Send + htp.p(' '); -- Delete + htp.p(' '); +END conf_approve_tabhead; +-- +-- +PROCEDURE conf_approve_tabclose IS +BEGIN + htp.p(' +
'||caco_utilities.get_module_text(118)||' '||caco_utilities.get_module_text(1047)||' '||caco_utilities.get_module_text(2013)||' '||caco_utilities.get_module_text(2286)||' '||caco_utilities.get_module_text(1142)||' '||caco_utilities.get_module_text(2062)||''||caco_utilities.get_module_text(3559)||''||caco_utilities.get_module_text(838)||'
+

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

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

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

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

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

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

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

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

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

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

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

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

'); + END IF; + -- + htp.p(' + + '); -- Gas Day + htp.p(' + + +
'||caco_utilities.get_module_text(1142)||'   +
+ +
+
'); + -- + htp.p(wsgjsl.calbutton(field_name => 'p_gas_day' + ,p_calbut => htf.img(curl => caco_system.images_path||'lov.gif' + ,calign => 'TOP' + ,cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER') + ,field_format => cout_system_configuration.get_configuration_item('G_DATE_FORMAT') + ,p_field_prompt => caco_utilities.get_module_text(1142) )); -- Gas Day + -- + htp.p('
'); + -- + -- Now show the nominations that are available to confirm + IF gas_day_chosen THEN + -- Loop through each nomination found + -- Validate it and give a check box for the valid noms + -- need to ensure only select one nom for a given contract for a given day.. + -- + htp.p('
'); + -- + -- Lets just check if there is any data.... + FOR rec_contracts IN c_contracts( l_gas_day ) + LOOP + + OPEN cur_last_nomi (rec_contracts.contract_id + ,l_gas_day + ,NULL); + FETCH cur_last_nomi INTO l_last_nomi_rec; + IF cur_last_nomi%FOUND + THEN + l_noms_found := TRUE; + END IF; + CLOSE cur_last_nomi; + END LOOP; + -- + -- + IF l_noms_found THEN + -- + l_prev_contract := '~@?^$&'; + -- + -- Put out the gas day selected to pass to the commercial confirmation creation routine. + -- We know it is in the correct format or we wouldnt be here. + -- + htp.p(''); + -- Put the submit button at the top in case there are many nominations that overflow the visible page + htp.p('

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

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

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

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

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

'); + -- + + ELSE + -- Need a button to recall the screen with a chosen gas day + find_nom_button; + -- + END IF; -- gas day chosen + -- + -- Close the margin div + htp.p('
'); + -- + -- Close centrecontent div + htp.p(''); + -- + -- Close outer div + htp.p(''); + -- + wsgl.closepagebody; + -- +END startup; +-- +-- +/** +-- FUNCTION about -- +-- Returns the version number and VSS header for this package +-- +-- %return The version number and VSS header for this package +*/ +FUNCTION about RETURN VARCHAR2 IS +BEGIN + RETURN ( g_package_name || CHR(10) ||g_revision||chr(10)|| g_header ); +END about; +-- +-- +-- +BEGIN + -- Initialization + NULL; + -- +END efnow095$; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow098$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow098$.bdy new file mode 100644 index 0000000..6aaad85 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow098$.bdy @@ -0,0 +1,4210 @@ +CREATE OR REPLACE PACKAGE BODY efnow098$ IS + -- + -- Private + -- + g_cust_id customers.cust_id%TYPE; + g_cont_id contracts.cont_id%TYPE; + g_cont_num contracts.contract_number%TYPE; + g_cont_start_date contracts.valid_from%TYPE; + g_cont_end_date contracts.valid_until%TYPE; + g_active_time DATE := SYSDATE; + g_gas_day DATE := TRUNC(g_active_time-cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24); + -- + g_int_category BOOLEAN := FALSE; + -- + g_target_date DATE; + g_target_date_end DATE; + -- + g_error_point VARCHAR2(10) := NULL; + -- + FUNCTION is_number(l_val VARCHAR2) RETURN BOOLEAN IS + -- + l_n NUMBER; + -- + BEGIN + -- + l_n := l_val; + -- + RETURN true; + -- + EXCEPTION + WHEN OTHERS THEN + RETURN false; + END; + + PROCEDURE display_nnpcv_tab(p_nnpcv_tab IN gt_nnpcv_tab) IS + BEGIN + -- + FOR i IN 1..p_nnpcv_tab.COUNT LOOP + -- + caco_debug.putline('SP :'||i|| + ' nnpcv_id: '||p_nnpcv_tab(i).nnpcv_id|| + ' value: '||p_nnpcv_tab(i).value|| + ' gas_day: '||p_nnpcv_tab(i).gas_day|| + ' coca_id: '||p_nnpcv_tab(i).coca_id|| + ' nomi_id: '||p_nnpcv_tab(i).nomi_id|| + ' conp_id: '||p_nnpcv_tab(i).conp_id|| + ' created_by: '||p_nnpcv_tab(i).created_by|| + ' created_on: '||p_nnpcv_tab(i).created_on + ); + -- + END LOOP; + -- + END display_nnpcv_tab; + -- + PROCEDURE display_vc_arr(arr_name IN VARCHAR2, + arr IN owa_util.vc_arr) IS + BEGIN + -- + IF arr.COUNT > 0 THEN + caco_debug.putline('---------------------------------------'); + FOR i IN arr.FIRST..arr.LAST LOOP + caco_debug.putline(arr_name||': '||i||' = '||arr(i)); + END LOOP; + caco_debug.putline('---------------------------------------'); + END IF; + -- + END display_vc_arr; + -- + PROCEDURE get_cont_id ( p_cont_id IN contracts.cont_id%TYPE + ) IS + -- + BEGIN + -- + BEGIN + -- + SELECT cont.cont_id + ,cont.contract_number + ,cont.valid_from + ,cont.valid_until + INTO g_cont_id + ,g_cont_num + ,g_cont_start_date + ,g_cont_end_date + FROM contracts cont + WHERE cont.cont_id = p_cont_id + AND cont.status = 'O' + AND rownum < 2; + -- + EXCEPTION + WHEN OTHERS THEN + -- + g_cont_id := NULL; + g_cont_num := NULL; + -- + END; + -- + END get_cont_id; + -- + FUNCTION get_cv ( p_conp_id IN NUMBER + ) RETURN VARCHAR2 IS + -- + CURSOR cu_cv IS + SELECT NVL(cnppv.value,0) + FROM cont_net_point_param_vals cnppv, + cont_network_points conp2, + contract_parameters copa, + parameters pars, + contracts cont + WHERE conp2.conp_id = p_conp_id + AND conp2.conp_id = cnppv.conp_id + AND copa.copa_id = cnppv.copa_id + AND cont.cont_id = g_cont_id + AND copa.cont_id = cont.cont_id + AND pars.pars_id = copa.pars_id + AND pars.code = 'par_futoertek'; + -- + l_cv NUMBER; + -- + BEGIN + -- + OPEN cu_cv; + FETCH cu_cv INTO l_cv; + IF cu_cv%NOTFOUND THEN + l_cv := 0; + END IF; + CLOSE cu_cv; + -- + RETURN l_cv; + -- + END get_cv; + -- + PROCEDURE sort_nnpcv_array ( p_nnpcv_tab IN OUT gt_nnpcv_tab + , p_gas_days IN OUT owa_util.vc_arr + ) IS + -- + l_nnpcv_tab nnpcv_tab := nnpcv_tab(); + -- + BEGIN + -- + -- Extend type to cover requirements + -- + -- + l_nnpcv_tab.EXTEND(p_nnpcv_tab.COUNT); + -- + -- Convert index by table into type + -- + FOR idx IN 1..p_nnpcv_tab.COUNT LOOP + -- + l_nnpcv_tab(idx) := nnpcv_rec(nnpcv_id => p_nnpcv_tab(idx).nnpcv_id + ,VALUE => p_nnpcv_tab(idx).value + ,gas_day => TO_DATE(p_gas_days(CEIL(idx*(p_gas_days.COUNT/p_nnpcv_tab.COUNT))), cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + ,coca_id => p_nnpcv_tab(idx).coca_id + ,nomi_id => p_nnpcv_tab(idx).nomi_id + ,conp_id => p_nnpcv_tab(idx).conp_id + ,created_by => p_nnpcv_tab(idx).created_by + ,created_on => p_nnpcv_tab(idx).created_on + ); + -- + END LOOP; + -- + -- Now we have it in a type, sort it back into the array + -- + FOR rec IN ( SELECT gas_day + ,value + ,conp_id + ,coca_id + ,rownum AS idx + FROM (SELECT sq1.gas_day + ,sq1.value + ,sq1.conp_id + ,sq1.coca_id + FROM TABLE(CAST(l_nnpcv_tab AS nnpcv_tab)) sq1 + ,cont_network_points conp + ,network_points nepo + ,contract_categories coca + WHERE sq1.conp_id = conp.conp_id + AND conp.nepo_id = nepo.nepo_id + AND sq1.coca_id = coca.coca_id + ORDER BY nepo.code + ,gas_day + ,coca.display_sequence + ) + ) LOOP + -- + p_nnpcv_tab(rec.idx).value := rec.value; + p_nnpcv_tab(rec.idx).conp_id := rec.conp_id; + p_nnpcv_tab(rec.idx).coca_id := rec.coca_id; + -- + p_gas_days(CEIL(rec.idx*(p_gas_days.COUNT/p_nnpcv_tab.COUNT))) := TO_CHAR(rec.gas_day, cout_system_configuration.get_configuration_item('G_DATE_FORMAT')); + -- + END LOOP; + -- + -- Cleardown local variable + -- + l_nnpcv_tab.delete; + -- + END sort_nnpcv_array; + -- + PROCEDURE page_head IS + BEGIN + -- + htp.p(' '); + htp.p(' '); + -- + wsgl.openpagehead(g_title); + wsgl.metatag; + htp.p(' ' || + chr(10)); + htp.p(' ' || + chr(10)); + htp.p(' ' || chr(10)); + -- + htp.p(' '); + -- + htp.p(wsgjsl.openscript); + wsgjsl.output_invoke_cal_js(g_package_name + ,'scrollbars=no,resizable=no,width=320,height=350'); + htp.p(wsgjsl.closescript); + -- + wsgl.closepagehead; + wsgl.openpagebody(FALSE); + htp.p(caco_system.menu); + -- + htp.HEADER(nsize => 1 + ,cheader => g_title); + -- + END page_head; + -- + FUNCTION return_index ( p_search_var IN DATE + , p_array IN owa_util.vc_arr + ) RETURN NUMBER IS + -- + l_return NUMBER := 1; + -- + BEGIN + -- + FOR i IN 1..p_array.COUNT LOOP + -- + IF TO_DATE(p_array(i), g_date_format) = p_search_var THEN + -- + l_return := i; + EXIT; + -- + END IF; + -- + END LOOP; + -- + RETURN l_return; + -- + END return_index; + -- + FUNCTION in_a_renom_window( p_gas_day IN DATE + , p_window_time IN DATE + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + FOR i IN ( SELECT NULL + FROM nomination_windows nw + ,nom_window_contracts nwc + ,contracts con + WHERE nw.nowi_id = nwc.nowi_id + AND nwc.cont_id = con.cont_id + AND con.cust_id = caco_utilities.get_cust_id + AND nw.gas_day = TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24) + cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24 + AND SYSDATE BETWEEN nw.window_start AND nw.window_end + ) LOOP + -- + l_return := TRUE; + -- + EXIT; + -- + END LOOP; + -- + RETURN l_return; + -- + END in_a_renom_window; + -- + FUNCTION in_a_renom_window( p_gas_day IN DATE + , p_contract_id IN contracts.cont_id%TYPE + , p_window_time IN DATE + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + FOR i IN ( SELECT NULL + FROM nomination_windows nw + ,nom_window_contracts nwc + ,contracts con + WHERE nw.nowi_id = nwc.nowi_id + AND nwc.cont_id = con.cont_id + AND con.cust_id = caco_utilities.get_cust_id + AND nwc.cont_id = p_contract_id + AND nw.gas_day = TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24) + cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24 + AND SYSDATE BETWEEN nw.window_start AND nw.window_end + ) LOOP + -- + l_return := TRUE; + -- + EXIT; + -- + END LOOP; + -- + RETURN l_return; + -- + END in_a_renom_window; + -- + FUNCTION check_cont_date ( p_cont_id IN contracts.cont_id%TYPE + , p_date IN DATE + , p_message OUT VARCHAR2 + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + l_type VARCHAR2(100); + -- + BEGIN + -- + FOR i IN ( SELECT NULL + FROM contracts cont + WHERE cont.cont_id = p_cont_id + AND p_date BETWEEN cont.valid_from AND cont.valid_until ) LOOP + -- + l_return := TRUE; + -- + END LOOP; + -- + IF NOT l_return THEN + -- + caco_utilities.get_exception_message ( p_exception_number => -20512 + , p_message => p_message + , p_exme_type => l_type + ); + -- + END IF; + -- + RETURN l_return; + -- + END check_cont_date; + -- + FUNCTION check_gate_closure ( p_cont_id IN contracts.cont_id%TYPE + , p_date IN DATE + , p_message OUT VARCHAR2 + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := TRUE; + l_type VARCHAR2(100); + l_sub_list caco_utilities.g_t_substitution_list; + l_deadline VARCHAR2(5) := NULL; + l_active_date DATE := NULL; + -- + FUNCTION get_deadline ( p_cust_id IN customers.cust_id%TYPE ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(5) := NULL; + -- + BEGIN + -- + SELECT cust.ind_deadline_for_nom_submit + INTO l_return + FROM customers cust + WHERE cust.cust_id = p_cust_id; + -- + IF l_return IS NULL THEN + -- + l_return := cout_system_configuration.get_configuration_item('G_SUBMISSION_DEADLINE'); + -- + END IF; + -- + RETURN l_return; + -- + END get_deadline; + -- + BEGIN + -- + IF (TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24) + NVL(cout_system_configuration.get_configuration_item('G_NOM_DATE_OFFSET'),1)) = p_date THEN + -- + -- We are looking at nominating for tomorrow, need to check gate closure + -- + IF g_cust_id IS NULL THEN + IF p_cont_id IS NOT NULL THEN + SELECT cont.cust_id + INTO g_cust_id + FROM contracts cont + WHERE cont.cont_id = p_cont_id; + END IF; + END IF; + -- + l_deadline := get_deadline(p_cust_id => g_cust_id); + -- + IF l_deadline IS NOT NULL THEN + -- + IF TO_NUMBER(RTRIM(SUBSTR(l_deadline,1,2),':')) < cout_system_configuration.get_configuration_item(p_parameter => 'GAS_DAY_OFFSET') THEN + -- + -- Is tomorrow, add one to the date + -- + l_active_date := TO_DATE(TO_CHAR(TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24),'DD/MM/YYYY')||l_deadline, 'DD/MM/YYYYHH24:MI')+1; + -- + ELSE + -- + -- same calendar date, OK + -- + l_active_date := TO_DATE(TO_CHAR(TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24),'DD/MM/YYYY')||l_deadline, 'DD/MM/YYYYHH24:MI'); + -- + END IF; + -- + -- Determined what the deadline is, now check it + -- + IF SYSDATE > l_active_date THEN + -- + l_sub_list(1) := TO_CHAR( p_date, g_date_format); + l_sub_list(2) := TO_CHAR( l_active_date, g_date_format || ' HH24:MI'); + -- + caco_utilities.get_exception_message ( p_exception_number => -20513 -- Cannot nominate for after . + , p_message => p_message + , p_exme_type => l_type + , p_substitution_list => l_sub_list + ); + -- + l_return := FALSE; + -- + END IF; -- p_date > l_active_date + -- + END IF; -- l_deadline not null + -- + END IF; -- nominateing for tomorrow + -- + -- Renom window check + -- + IF (TRUNC(SYSDATE - cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24) + NVL(cout_system_configuration.get_configuration_item('G_NOM_DATE_OFFSET'),1) /* removed + cout_system_configuration.get_configuration_item('GAS_DAY_OFFSET')/24*/) > p_date THEN + -- + -- Nominating for today, check for renom window for the contract + -- + IF NOT in_a_renom_window( p_gas_day => NULL + , p_contract_id => p_cont_id + , p_window_time => NULL + ) THEN + -- + l_return := FALSE; + -- + caco_utilities.get_exception_message ( p_exception_number => -20514 -- renomination window is not open + , p_message => p_message + , p_exme_type => l_type + ); + -- + END IF; + -- + END IF; + -- + RETURN l_return; + -- + END check_gate_closure; + -- + FUNCTION process_spreadsheet_to_arrays ( p_gtsp_id gtt_spreadsheet.spreadsheet_id%TYPE + , p_cont_id contracts.cont_id%TYPE + , p_nomi_tab IN OUT gt_nomi_tab + , p_nnpcv_tab IN OUT gt_nnpcv_tab + , p_error IN OUT VARCHAR2 + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + lr_spte_row spreadsheet_templates%ROWTYPE; + -- + l_x_a VARCHAR2(100); + l_y_a VARCHAR2(100); + -- + l_x_a_start VARCHAR2(100); + -- + l_cont_identifier contracts.contract_number%TYPE; + l_cont_id contracts.cont_id%TYPE; + l_gas_day VARCHAR2(100); + l_gas_day_to VARCHAR2(100); + l_field_value VARCHAR2(100); + -- + l_start_date DATE; + l_end_date DATE; + l_exme_type VARCHAR2(10); + l_sub_list caco_utilities.g_t_substitution_list; + -- + -- Variables addded for network point validation + -- + l_nepo_x VARCHAR2(100); + l_nepo_y VARCHAR2(100); + l_nepo_code VARCHAR2(100); + l_nepo_y_start VARCHAR2(100); + l_nepo_rownum NUMBER := 0; + l_nepo_count NUMBER := 0; + -- + -- Tags to search for + -- + c_cont_placeholder CONSTANT VARCHAR2(100) := '{CONTRACT_ID}'; + c_gday_placeholder CONSTANT VARCHAR2(100) := '{GAS_DAY}'; + c_gday_placeholder2 CONSTANT VARCHAR2(100) := '{GAS_DAY_TO}'; + c_nnpcv_placeholder CONSTANT VARCHAR2(100) := '{NOM_NET_POINT_CAT_VALS}'; + c_nepo_code CONSTANT VARCHAR2(100) := '{NETWORK_POINT_CODE}'; + c_cate_name CONSTANT VARCHAR2(100) := '{CAT_NAME}'; + c_cate_units CONSTANT VARCHAR2(100) := '{CAT_UNITS}'; + -- + l_emo_contract VARCHAR2(1) := 'N'; + l_conp_id cont_network_points.conp_id%TYPE; + -- + PROCEDURE set_nom ( p_identifier IN VARCHAR2 + , p_cont_id IN contracts.cont_id%TYPE ) IS + BEGIN + -- + p_nomi_tab(1).status := 'A'; + p_nomi_tab(1).cont_id := p_cont_id; + p_nomi_tab(1).identifier := p_identifier; + -- + END set_nom; + -- + PROCEDURE set_nnpcv ( p_value IN VARCHAR2 + , p_gas_day IN DATE + , p_coca_id IN conf_net_point_cat_vals.coca_id%TYPE + , p_conp_id IN conf_net_point_cat_vals.conp_id%TYPE + ) IS + -- + l_nnpcv_idx NUMBER; + -- + BEGIN + -- + l_nnpcv_idx := NVL(p_nnpcv_tab.COUNT,0) + 1; + -- + p_nnpcv_tab(l_nnpcv_idx).conp_id := p_conp_id; + p_nnpcv_tab(l_nnpcv_idx).coca_id := p_coca_id; + p_nnpcv_tab(l_nnpcv_idx).value := p_value; + p_nnpcv_tab(l_nnpcv_idx).gas_day := p_gas_day; + -- + END set_nnpcv; + -- + FUNCTION get_token_location ( p_token IN VARCHAR2 + , p_spte_id IN spreadsheet_templates.spte_id%TYPE + , p_x_axis IN OUT spreadsheet_template_values.x_axis%TYPE + , p_y_axis IN OUT spreadsheet_template_values.y_axis%TYPE + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + -- Init grid locators + -- + p_x_axis := NULL; + p_y_axis := NULL; + -- + FOR i IN ( SELECT sptv.x_axis + ,sptv.y_axis + FROM spreadsheet_template_values sptv + WHERE sptv.spte_id = p_spte_id + AND sptv.cell_value = p_token + ) LOOP + -- + p_x_axis := i.x_axis; + p_y_axis := i.y_axis; + -- + l_return := TRUE; + EXIT; + -- + END LOOP; + -- + RETURN l_return; + -- + END get_token_location; + -- + FUNCTION get_spreadsheet_value ( p_gtsp_id IN gtt_spreadsheet.spreadsheet_id%TYPE + , p_x_axis IN spreadsheet_template_values.x_axis%TYPE + , p_y_axis IN spreadsheet_template_values.y_axis%TYPE + ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(100); + -- + BEGIN + -- + SELECT gtsp.cell_value + INTO l_return + FROM gtt_spreadsheet gtsp + WHERE gtsp.spreadsheet_id = p_gtsp_id + AND gtsp.x_axis = p_x_axis + AND gtsp.y_axis = p_y_axis - 1; + -- + --caco_debug.putline(p_x_axis||':'||p_y_axis||':'||l_return); + -- + RETURN l_return; + -- + EXCEPTION + WHEN OTHERS THEN + RETURN null; + END get_spreadsheet_value; + -- + FUNCTION max_ss_row ( p_gtsp_id IN gtt_spreadsheet.spreadsheet_id%TYPE ) RETURN NUMBER IS + -- + l_return NUMBER := 0; + -- + BEGIN + -- + SELECT MAX(gtts.y_axis) + INTO l_return + FROM gtt_spreadsheet gtts + WHERE gtts.spreadsheet_id = p_gtsp_id; + -- + RETURN l_return; + -- + END; + -- + BEGIN + -- + -- Get the template details + -- + g_error_point := 'P001'; + -- + -- Check if the contract is an entry mandatory offer contract + -- + IF efno_contracts.emo_contract(p_cont_id) = 'Y' THEN + l_emo_contract := 'Y'; + END IF; + -- + SELECT spte.* + INTO lr_spte_row + FROM contracts cont + ,spreadsheet_templates spte + WHERE spte.spte_id = cont.spte_id + AND spte.spte_type = 'NOST' + AND cont.cont_id = p_cont_id; + -- + g_error_point := 'P002'; + -- + IF UPPER(lr_spte_row.name) IN (UPPER(g_spte_single),UPPER(g_spte_smulti)) THEN + -- + -- Single gas day or Single-Multi Gas Day, find the location of useful stuff + -- + g_error_point := 'P100'; + -- + IF get_token_location ( p_token => c_gday_placeholder + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ) THEN + -- + -- Token is present in the template, let's get the value + -- + l_gas_day := get_spreadsheet_value ( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ); + -- + IF l_gas_day IS NOT NULL THEN + -- + BEGIN + -- + l_start_date := TO_DATE( l_gas_day + , cout_system_configuration.get_configuration_item('G_DATE_FORMAT')); + -- + EXCEPTION + -- + WHEN OTHERS THEN + -- + l_return := FALSE; + -- + l_sub_list(1) := l_gas_day; + l_sub_list(2) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- + caco_utilities.get_exception_message(p_exception_number => -20104 + ,p_message => p_error + ,p_exme_type => l_exme_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + RAISE; + -- + END; + -- + g_gas_days(1) := l_gas_day; + -- + END IF; + -- + END IF; + -- + IF get_token_location ( p_token => c_cont_placeholder + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ) THEN + -- + -- + -- Token is present in the template, let's get the value + -- + l_cont_identifier := get_spreadsheet_value ( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ); + -- + END IF; + -- + IF get_token_location ( p_token => c_gday_placeholder2 + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ) THEN + -- + -- Token is present in the template, let's get the value + -- + g_error_point := 'P205'; + g_target_date := TO_DATE(l_gas_day,g_date_format); + -- + l_gas_day_to := get_spreadsheet_value ( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ); + -- + IF l_gas_day_to IS NOT NULL THEN + -- + BEGIN + -- + l_end_date := TO_DATE( l_gas_day_to + , cout_system_configuration.get_configuration_item('G_DATE_FORMAT')); + -- + EXCEPTION + -- + WHEN OTHERS THEN + -- + l_return := FALSE; + -- + l_sub_list(1) := l_gas_day_to; + l_sub_list(2) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- + caco_utilities.get_exception_message(p_exception_number => -20104 + ,p_message => p_error + ,p_exme_type => l_exme_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + RAISE; + -- + END; + -- + END IF; + -- + g_target_date_end := to_date(l_gas_day_to,g_date_format); + -- + FOR i IN 0..(g_target_date_end-g_target_date) + 1 LOOP + -- + g_gas_days(i+1) := TO_CHAR(g_target_date+i,g_date_format); + -- + END LOOP; + -- + END IF; + -- + -- We need to find out which contract this nomination is for. + -- EFT no longer want the contract name on the spreadsheet to determine this. + -- The spreadsheet upload needs to be more flexible and determine + -- the cont_id for itself. + -- + FOR c IN ( SELECT cont.cont_id + FROM contracts cont + WHERE cont.cust_id = g_cust_id + AND l_start_date BETWEEN cont.valid_from AND cont.valid_until + AND ((l_end_date BETWEEN cont.valid_from AND cont.valid_until) OR + (l_end_date IS NULL)) + AND cont.status = 'O' + AND rownum < 2 ) LOOP + -- + l_cont_id := c.cont_id; + get_cont_id(l_cont_id); + -- + END LOOP; + -- + IF l_cont_id IS NULL THEN + caco_utilities.get_exception_message ( p_exception_number => -20512 + , p_message => p_error + , p_exme_type => l_exme_type + , p_language => caco_utilities.get_syus_lang + ); + END IF; + -- + -- Find the token location + -- + IF NOT get_token_location ( p_token => c_nepo_code + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_nepo_x + , p_y_axis => l_nepo_y_start + ) THEN + -- + -- No point raising any errors if there aren't any network points in the template + -- + NULL; + -- + END IF; + -- + -- Now on to the grid + -- + IF get_token_location ( p_token => c_nnpcv_placeholder + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a_start + , p_y_axis => l_y_a + ) THEN + -- + -- Values start at the above location, for the moment assume that everything is in the right order + -- + l_x_a := l_x_a_start; + l_nepo_y := l_nepo_y_start; + -- + FOR conp IN ( SELECT nepo.name + ,nepo.code + ,conp.conp_id + ,rownum AS sitenum + FROM cont_network_points conp + ,network_points nepo + WHERE nepo.nepo_id = conp.nepo_id + AND conp.cont_id = g_cont_id + AND ((nepo.nepo_type = 'V' AND l_emo_contract = 'Y') OR + l_emo_contract = 'N') + ORDER BY nepo.code + ) LOOP + -- + -- Find nepo_code in the spreadsheet. Order does not matter. + -- + LOOP + -- + l_nepo_code := get_spreadsheet_value( p_gtsp_id => p_gtsp_id + , p_x_axis => l_nepo_x + , p_y_axis => l_nepo_y + ); + -- + IF l_nepo_code IS NULL THEN + -- + l_return := FALSE; + p_error := caco_utilities.get_module_text(2519); + EXIT; + ELSIF l_nepo_code <> conp.code THEN + l_nepo_y := l_nepo_y + 1; + l_nepo_rownum := l_nepo_rownum + 1; + ELSE + -- l_nepo_code must equal conp.code + EXIT; + -- + END IF; + END LOOP; + -- + FOR conp_coca IN (SELECT coca.coca_id + FROM contract_categories coca + ,categories cate + WHERE cate.cate_id = coca.cate_id + AND coca.cont_id = g_cont_id + ORDER BY coca.display_sequence ) LOOP + -- + -- Look for the value in the spreadsheet + -- + l_field_value := get_spreadsheet_value( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + l_nepo_rownum + ); + -- + IF INSTR(l_field_value,'.') > 0 THEN + -- + l_field_value := RTRIM(RTRIM(l_field_value,'0'),'.'); + -- + END IF; + -- + set_nnpcv ( p_value => caco_utilities.thousand_separated_to_num(l_field_value) + , p_gas_day => TO_DATE( g_gas_days(1) + , cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , p_coca_id => conp_coca.coca_id + , p_conp_id => conp.conp_id + ); + -- + l_x_a := CHR(ASCII(l_x_a)+1); + -- + END LOOP; -- categories + -- + -- Increment network point count + -- + l_nepo_count := l_nepo_count + 1; + -- + -- Reset starting column + -- + l_x_a := l_x_a_start; + -- + -- Reset starting row + -- + l_nepo_y := l_nepo_y_start; + -- + -- Reset row number + -- + l_nepo_rownum := 0; + -- + END LOOP; -- network points + -- + IF get_spreadsheet_value( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + l_nepo_count + ) IS NOT NULL THEN + -- + l_return := FALSE; + p_error := caco_utilities.get_module_text(2519); + -- + END IF; + -- + END IF; + -- + IF l_cont_identifier <> g_cont_num + AND l_cont_identifier IS NOT NULL + THEN + p_error := REPLACE(REPLACE(caco_utilities.get_module_text(2519),'',g_cont_num),'',l_cont_identifier); + END IF; IF l_cont_identifier <> g_cont_num + AND l_cont_identifier IS NOT NULL + THEN + p_error := REPLACE(REPLACE(caco_utilities.get_module_text(3981),'',g_cont_num),'',l_cont_identifier); + END IF; + IF p_error IS NULL THEN + -- + l_return := TRUE; + -- + END IF; + -- + ELSIF UPPER(lr_spte_row.name) = UPPER(g_spte_multi) THEN + -- + -- Multiple gas day, find the location of useful stuff + -- + g_error_point := 'P200'; + -- + IF get_token_location ( p_token => c_cont_placeholder + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ) THEN + -- + g_error_point := 'P201'; + -- + -- Token is present in the template, let's get the value + -- + l_cont_identifier := get_spreadsheet_value ( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ); + -- + g_error_point := 'P202'; + -- + IF l_cont_identifier IS NOT NULL THEN + g_error_point := 'P203'; + -- + FOR c IN ( SELECT cont.cont_id + FROM contracts cont + WHERE cont.contract_number = l_cont_identifier + AND cont.cust_id = g_cust_id ) LOOP + -- + g_cont_id := c.cont_id; + -- + END LOOP; + -- + END IF; + -- + END IF; + -- + -- Multiple gas days - find the start + -- + g_error_point := 'P204'; + -- + IF get_token_location ( p_token => c_gday_placeholder + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ) THEN + -- + -- Token is present in the template, let's get the value + -- + g_target_date := NULL; + g_target_date_end := NULL; + -- + FOR i IN 0..max_ss_row(p_gtsp_id) LOOP + -- + g_error_point := 'P205'||l_x_a||TO_CHAR(l_y_a + i); + -- + l_gas_day := get_spreadsheet_value ( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + i + ); + -- + IF l_gas_day IS NOT NULL THEN + -- + BEGIN + -- + l_start_date := TO_DATE( l_gas_day + , cout_system_configuration.get_configuration_item('G_DATE_FORMAT')); + -- + EXCEPTION + -- + WHEN OTHERS THEN + -- + l_return := FALSE; + -- + l_sub_list(1) := l_gas_day; + l_sub_list(2) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- + caco_utilities.get_exception_message(p_exception_number => -20104 + ,p_message => p_error + ,p_exme_type => l_exme_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + RAISE; + -- + END; + g_gas_days(i+1) := TO_CHAR(TO_DATE(l_gas_day, g_date_format),g_date_format); + -- + g_target_date := LEAST(NVL(g_target_date, TO_DATE(g_gas_days(i+1), g_date_format)), TO_DATE(g_gas_days(i+1), g_date_format)); + g_target_date_end := GREATEST(NVL(g_target_date_end, TO_DATE(g_gas_days(i+1), g_date_format)), TO_DATE(g_gas_days(i+1), g_date_format)); + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + -- Find the token location + -- + IF NOT get_token_location ( p_token => c_nepo_code + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_nepo_x + , p_y_axis => l_nepo_y + ) THEN + -- + -- No point raising any errors if there aren't any network points in the template + -- + NULL; + -- + END IF; + -- + -- Now on to the grid + -- + g_error_point := 'P206'; + -- + IF get_token_location ( p_token => c_nnpcv_placeholder + , p_spte_id => lr_spte_row.spte_id + , p_x_axis => l_x_a_start + , p_y_axis => l_y_a + ) THEN + -- + g_error_point := 'P208'; + -- + l_x_a := l_x_a_start; + -- + FOR conp IN ( SELECT rownum AS sitenum + FROM cont_network_points conp + WHERE conp.cont_id = g_cont_id + ) LOOP + -- + FOR date_loop IN 1..(g_target_date_end-g_target_date)+1 LOOP + -- + -- Check nepo_code (c_nepo_code) against the spreadsheet to ensure the sites are in the correct order + -- + l_nepo_code := get_spreadsheet_value( p_gtsp_id => p_gtsp_id + , p_x_axis => l_nepo_x + , p_y_axis => l_nepo_y + ); + -- + l_conp_id := NULL; + -- + FOR conp IN ( SELECT conp.conp_id + FROM cont_network_points conp + ,network_points nepo + WHERE nepo.nepo_id = conp.nepo_id + AND conp.cont_id = g_cont_id + AND nepo.code = l_nepo_code + AND ((nepo.nepo_type = 'V' AND l_emo_contract = 'Y') OR + l_emo_contract = 'N') + ) LOOP + -- + l_conp_id := conp.conp_id; + -- + END LOOP; + -- + IF l_conp_id IS NULL + OR l_nepo_code IS NULL THEN + -- + l_return := FALSE; + p_error := caco_utilities.get_module_text(2519); + -- + END IF; + -- + l_nepo_y := l_nepo_y + 1; + -- + FOR conp_coca IN (SELECT coca.coca_id + FROM contract_categories coca + ,categories cate + WHERE cate.cate_id = coca.cate_id + AND coca.cont_id = g_cont_id + ORDER BY coca.display_sequence ) LOOP + -- + -- Look for the value in the spreadsheet + -- + g_error_point := 'P209'; + -- + l_field_value := get_spreadsheet_value( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ); + -- + g_error_point := 'P210'; + -- + IF INSTR(l_field_value,'.') > 0 THEN + -- + l_field_value := RTRIM(RTRIM(l_field_value,'0'),'.'); + -- + END IF; + -- + set_nnpcv ( p_value => caco_utilities.thousand_separated_to_num(l_field_value) + , p_gas_day => TO_DATE( g_gas_days(1) + , cout_system_configuration.get_configuration_item('G_DATE_FORMAT')) + , p_coca_id => conp_coca.coca_id + , p_conp_id => l_conp_id + ); + -- + g_error_point := 'P211'; + -- + l_x_a := CHR(ASCII(l_x_a)+1); + -- + END LOOP; -- categories + -- + -- Increment row number + -- + l_y_a := TO_NUMBER(l_y_a) + 1; + -- + -- Reset starting column + -- + l_x_a := l_x_a_start; + -- + END LOOP; -- dates + -- + END LOOP; -- network points + -- + IF get_spreadsheet_value( p_gtsp_id => p_gtsp_id + , p_x_axis => l_x_a + , p_y_axis => l_y_a + ) IS NOT NULL THEN + -- + l_return := FALSE; + p_error := caco_utilities.get_module_text(2519); + -- + END IF; + -- + g_error_point := 'P220'; + -- + END IF; + -- + -- Sort the details in case they have been loaded in the wrong order - will aid detection of missing values + -- + sort_nnpcv_array(p_nnpcv_tab + ,g_gas_days); + -- + -- + -- + IF p_error IS NULL THEN + -- + l_return := TRUE; + -- + END IF; + -- + ELSIF UPPER(lr_spte_row.name) = UPPER(g_spte_hourly) THEN + -- + NULL; + -- + ELSE + -- + -- Something else that we do not know about + -- + p_error := caco_utilities.get_module_text(p_text_number => 2330); -- Unexpected Error + l_return := FALSE; + -- + END IF; + -- + RETURN l_return; + -- + EXCEPTION + WHEN OTHERS THEN + -- + cout_err.report_and_go(p_exception_message => sqlerrm||' : '||g_error_point); + -- + p_error := NVL(p_error, caco_utilities.get_module_text(p_text_number => 2330)); -- Unexpected Error + l_return := FALSE; + -- + RETURN l_return; + -- + END process_spreadsheet_to_arrays; + -- + FUNCTION display_message ( p_mess IN VARCHAR2 + , p_type IN VARCHAR2 + ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(200); + -- + BEGIN + -- + IF p_type = wsgl.mess_success THEN + -- + l_return := htf.bold(''||htf.italic(wsgl.MsgGetText(121,WSGLM.DSP121_SUCCESS))|| + '
'||p_mess); + -- + ELSIF p_type = wsgl.mess_error THEN + -- + l_return := htf.bold(''||htf.italic(wsgl.MsgGetText(122,WSGLM.DSP122_ERROR))|| + '
'||p_mess); + -- + END IF; + -- + RETURN l_return; + -- + END display_message; + -- + FUNCTION send_nom_notification( p_cust_id IN customers.cust_id%TYPE + , p_nomi_identifier IN nominations.identifier%TYPE DEFAULT NULL + , p_gas_day_start IN DATE DEFAULT NULL + , p_gas_day_end IN DATE DEFAULT NULL + , p_timestamp IN DATE DEFAULT NULL + ) RETURN VARCHAR2 IS + -- + l_letter_content VARCHAR2(4000); + l_letter_subject VARCHAR2(4000); + -- + BEGIN + -- + g_error_point := 'S010'; + -- + FOR cust_rec IN ( SELECT cust.nom_conf_subject + ,cust.nom_conf_content + FROM customers cust + WHERE cust.cust_id = p_cust_id + ) LOOP + -- + g_error_point := 'S020'; + -- + l_letter_content := cust_rec.nom_conf_content; + l_letter_subject := cust_rec.nom_conf_subject; + -- + g_error_point := 'S030'; + -- + IF p_nomi_identifier IS NOT NULL THEN + -- + l_letter_content := REPLACE(l_letter_content, '{NOMINATION_IDENTIFIER}', p_nomi_identifier); + l_letter_subject := REPLACE(l_letter_subject, '{NOMINATION_IDENTIFIER}', p_nomi_identifier); + -- + END IF; + -- + g_error_point := 'S040'; + -- + IF p_gas_day_start IS NOT NULL THEN + -- + l_letter_content := REPLACE(l_letter_content, '{GAS_DAY_START}', TO_CHAR(p_gas_day_start, g_date_format)); + l_letter_subject := REPLACE(l_letter_subject, '{GAS_DAY_START}', TO_CHAR(p_gas_day_start, g_date_format)); + -- + END IF; + -- + g_error_point := 'S050'; + -- + IF p_gas_day_end IS NOT NULL THEN + -- + l_letter_content := REPLACE(l_letter_content, '{GAS_DAY_END}', TO_CHAR(p_gas_day_end, g_date_format)); + l_letter_subject := REPLACE(l_letter_subject, '{GAS_DAY_END}', TO_CHAR(p_gas_day_end, g_date_format)); + -- + END IF; + -- + g_error_point := 'S060'; + -- + IF p_timestamp IS NOT NULL THEN + -- + l_letter_content := REPLACE(l_letter_content, '{TIMESTAMP}', TO_CHAR(p_timestamp, g_date_format||' HH24:MI')); + l_letter_subject := REPLACE(l_letter_subject, '{TIMESTAMP}', TO_CHAR(p_timestamp, g_date_format||' HH24:MI')); + -- + END IF; + -- + g_error_point := 'S070'; + -- + efno_msgsubs.send_messages ( p_cust_id => p_cust_id + , p_suca_id => efno_msgsubs.get_suca_id( p_suca_group => gc_suca_msg_group_en + , p_suca_name => gc_suca_name_en + ) + , p_email_content_en => l_letter_content + , p_email_subject_en => l_letter_subject + , p_sms_content_en => l_letter_subject + ); + -- + END LOOP; + -- + g_error_point := 'S080'; + -- + RETURN l_letter_content; + -- + END; + -- + FUNCTION timestamp_nomi ( p_nomi_id IN nominations.nomi_id%TYPE + , p_nomi_details IN VARCHAR2 + ) RETURN DATE IS + -- + l_timestamp DATE; + l_empty_blob BLOB; + l_message_blob BLOB; + -- + BEGIN + -- + l_message_blob := l_empty_blob; + -- + l_message_blob := utl_raw.cast_to_raw(p_nomi_details); + -- + l_timestamp := amfr_timestamp.timestamp_document( p_identifier => p_nomi_id + , p_doctype => amfr_timestamp.c_nomination + , p_file_for_hash => l_message_blob + ); + -- + efno_nominations.upd_nomi_timestamp( p_nomi_id => p_nomi_id + , p_timestamp => l_timestamp + ); + -- + l_message_blob := l_empty_blob; + -- + RETURN l_timestamp; + -- + END timestamp_nomi; + -- + FUNCTION get_spte_name ( p_cont_id IN contracts.cont_id%TYPE ) RETURN VARCHAR2 IS + -- + l_return VARCHAR(100); + -- + BEGIN + -- + IF p_cont_id IS NOT NULL THEN + -- + SELECT UPPER(spte.name) + INTO l_return + FROM contracts cont + ,spreadsheet_templates spte + WHERE spte.spte_id = cont.spte_id + AND spte.spte_type = 'NOST' + AND cont.cont_id = p_cont_id; + -- + END IF; + -- + RETURN l_return; + -- + END get_spte_name; + -- + FUNCTION get_receive_before_start( p_cont_id IN contracts.cont_id%TYPE ) RETURN NUMBER IS + -- + l_return NUMBER; + -- + BEGIN + -- + SELECT receive_before_start + INTO l_return + FROM contracts + WHERE cont_id = p_cont_id; + -- + RETURN l_return; + -- + END get_receive_before_start; + -- + FUNCTION get_matrix_val ( p_conp_id IN conf_net_point_cat_vals.conp_id%TYPE + , p_coca_id IN contract_categories.coca_id%TYPE + , p_iteration IN NUMBER + , p_mode IN NUMBER DEFAULT 0 + ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(30) := '0'; + l_iteration NUMBER := 0; + l_MJ_cate_name categories.name%TYPE; + l_m3_coca_id NUMBER; + l_cv NUMBER; + -- + CURSOR cu_MJ_cate IS + SELECT cate.name + FROM categories cate, + contract_categories coca + WHERE coca.coca_id = p_coca_id + AND coca.cate_id = cate.cate_id + AND cate.units IN ('MJ/day','MJ/nap'); + -- + CURSOR cu_m3_coca (cp_cate_name categories.name%TYPE)IS + SELECT coca.coca_id + FROM categories cate, + contract_categories coca, + contracts cont + WHERE cate.name = cp_cate_name + AND cont.cont_id = g_cont_id + AND cont.cont_id = coca.cont_id + AND coca.cate_id = cate.cate_id + AND cate.units IN ('m3/day','m3/nap'); + -- + BEGIN + -- + IF g_nnpcv_tab.COUNT > 0 THEN + -- + -- Looks like we've comething to display, be it good or bad + -- + FOR idx IN 1..g_nnpcv_tab.COUNT LOOP + -- + IF g_nnpcv_tab(idx).conp_id = p_conp_id + AND g_nnpcv_tab(idx).coca_id = p_coca_id THEN + -- + -- Found a match, but is it the right one + -- + l_iteration := l_iteration + 1; + -- + IF l_iteration = p_iteration THEN + IF g_nnpcv_tab(idx).value = 0 OR g_nnpcv_tab(idx).value IS NULL THEN + -- + -- check to see if we are looking at a MJ/day energy value + -- + OPEN cu_MJ_cate; + FETCH cu_MJ_cate INTO l_MJ_cate_name; + IF cu_MJ_cate%FOUND THEN + -- + -- lets if there is a related volume category in the contract + -- + OPEN cu_m3_coca(l_MJ_cate_name); + FETCH cu_m3_coca INTO l_m3_coca_id; + IF cu_m3_coca%FOUND THEN + -- + -- lets get the cv value + -- + l_cv := get_cv(p_conp_id); + IF l_cv > 0 THEN + -- + -- lets get the volume value multiply by cv + -- + l_return := caco_utilities.thousand_separated_to_num(get_matrix_val(p_conp_id,l_m3_coca_id,p_iteration)) * l_cv; + -- + ELSE + l_return := g_nnpcv_tab(idx).value; + END IF; + ELSE + l_return := g_nnpcv_tab(idx).value; + END IF; + CLOSE cu_m3_coca; + ELSE + l_return := g_nnpcv_tab(idx).value; + END IF; + CLOSE cu_MJ_cate; + -- + ELSE + l_return := g_nnpcv_tab(idx).value; + END IF; + EXIT; + -- + END IF; + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + RETURN caco_utilities.to_thousand_separated(l_return); + -- + EXCEPTION + WHEN OTHERS THEN + -- + cout_err.report_and_stop(p_exception_message => sqlerrm||' : efnow098$.get_matrix_val'); + -- + END get_matrix_val; + -- + FUNCTION check_row_error ( p_row_number IN NUMBER + ) RETURN VARCHAR2 IS + -- + -- Function to check for the existance of a row error, and if present, return it + -- + l_return VARCHAR2(1000) := NULL; + -- + BEGIN + -- + IF g_row_error.EXISTS(p_row_number) THEN + -- + l_return := ' class="error" title='''||g_row_error(p_row_number)||''''; + -- + END IF; + -- + RETURN l_return; + -- + END check_row_error; + -- + FUNCTION check_cell_error ( p_conp_id IN conf_net_point_cat_vals.conp_id%TYPE + , p_coca_id IN contract_categories.coca_id%TYPE + , p_iteration IN NUMBER + ) RETURN VARCHAR2 IS + -- + -- Function to check for the existance of a row error, and if present, return it + -- + l_return VARCHAR2(1000); + -- + BEGIN + -- + FOR i IN 1..g_cell_error.COUNT LOOP + -- + -- Loop around all cell errors, should only be a few as an exception is raise soon after the error + -- + IF p_conp_id = g_cell_error(i).conp_id + AND p_coca_id = g_cell_error(i).coca_id + AND p_iteration = g_cell_error(i).iteration THEN + -- + -- Is a match, output the error + -- + l_return := ' class="error" title='''||g_cell_error(i).message||''''; + -- + END IF; + -- + END LOOP; + -- + IF l_return IS NULL THEN + -- + -- See if I'm interrupted + -- + IF efno_interruption.am_i_interrrupted ( p_conp_id => p_conp_id + , p_coca_id => p_coca_id + , p_gasday => (g_target_date + (p_iteration-1)) + ) THEN + -- + l_return := ' class="interruption" title='''||caco_utilities.get_module_text(3809)||''''; + -- + g_int_category := TRUE; + -- + ELSE + -- + l_return := ' class="r" '; + -- + END IF; + -- + END IF; + -- + RETURN l_return; + -- + END check_cell_error; + -- + PROCEDURE display_nom_details ( p_type IN VARCHAR2 DEFAULT 'TABLE' ) IS + -- + l_tab_head_1 VARCHAR2(4000); + l_tab_head_2 VARCHAR2(4000); + l_tab_line VARCHAR2(4000); + l_loop_counter NUMBER := 1; + l_gas_day DATE; + -- + l_num_hours NUMBER; + l_cont_long_day BOOLEAN; + l_only_short_day BOOLEAN; + -- + l_cv NUMBER; + l_MJ_coca_id NUMBER := 0; + -- + CURSOR cu_MJ_cate (cp_m3name categories.name%TYPE)IS + SELECT coca.coca_id + FROM categories cate, + contracts cont, + contract_categories coca + WHERE cate.name = cp_m3name + AND cont.cont_id = g_cont_id + AND cont.cont_id = coca.cont_id + AND coca.cate_id = cate.cate_id + AND cate.units IN ('MJ/day','MJ/nap'); + -- + FUNCTION get_element ( p_array IN owa_util.vc_arr + , p_index IN NUMBER + ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(100) := NULL; + -- + BEGIN + -- + IF p_array.COUNT >= p_index THEN + -- + l_return := p_array(p_index); + -- + END IF; + -- + RETURN l_return; + -- + END get_element; + -- + BEGIN + -- + IF g_cont_id IS NOT NULL THEN + -- + -- Contract is set, we can continue + -- + -- set the g_target_date? ** + -- + g_target_date := NVL(TO_DATE(get_element(g_gas_days,1),g_date_format), g_target_date); + -- + -- Sort out the start and end dates if looking at multi dates + -- + IF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN + -- +/* htp.p('**'||'g_cont_start_date: '||g_cont_start_date); + htp.p('
'); + htp.p('**'||'g_cont_end_date: '||g_cont_end_date); + htp.p('
'); + htp.p('**'||'g_target_date: '||g_target_date); + htp.p('
'); + htp.p('**'||'g_target_date_end: '||g_target_date_end); + htp.p('
');*/ + -- + -- Check the start date against the contract start date - this will effect the number of days + -- + IF g_target_date < g_cont_start_date OR g_target_date IS NULL THEN + -- + -- Target date is less than the start of the contract...what to do? + -- + g_target_date := g_cont_start_date; + -- + END IF; + -- + IF g_target_date > g_cont_end_date THEN + -- + g_target_date := g_cont_end_date; + -- + END IF; + -- + IF g_target_date_end IS NULL THEN + -- + g_target_date_end := g_target_date; + -- + END IF; + -- + IF g_target_date_end < g_target_date THEN + -- + g_target_date_end := g_target_date; + -- + END IF; + -- + IF g_target_date_end > g_cont_end_date THEN -- g_target_date < TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')) THEN + -- + g_target_date_end := g_cont_end_date; + -- + END IF; + -- + IF g_target_date_end < g_cont_start_date THEN + -- + g_target_date_end := g_cont_start_date; + -- + END IF; + -- + IF get_spte_name(g_cont_id) = UPPER(g_spte_multi) THEN + -- + l_loop_counter := (g_target_date_end - g_target_date) +1; + -- + END IF; + -- +/* htp.p('----------------------------'); + htp.p('
'); + htp.p('**'||'g_target_date: '||g_target_date); + htp.p('
'); + htp.p('**'||'g_target_date_end: '||g_target_date_end); + htp.p('
'); + htp.p('**Loop:'||l_loop_counter); + htp.p('
');*/ + -- + END IF; + -- + -- + htp.p(''); + -- + -- submit and verify buttons + -- + htp.p(''); + htp.p(''); + htp.p('
'); + htp.p('
'); + -- + -- Header Table + -- + htp.p(''); + -- + htp.p(''); + htp.p(''); + htp.p(''); + htp.p(''); + IF g_cont_num IS NOT NULL + THEN + htp.p(''); + htp.p(''); + htp.p(''); + htp.p(''); + END IF; + -- + IF get_spte_name(g_cont_id) = UPPER(g_spte_single) THEN + -- + htp.p(''|| + ' + + '); + -- + ELSIF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN + -- + htp.p(''|| + ' + '); + -- + htp.p(''); + -- + END IF; + -- + IF get_spte_name(g_cont_id) = UPPER(g_spte_smulti) THEN + -- + htp.p(''); + -- + END IF; + -- + htp.p('
'||caco_utilities.get_module_text(1145)||''||caco_utilities.get_cust_name||'
'||caco_utilities.get_module_text(3552)||''||g_cont_num||'
'||caco_utilities.get_module_text(1142)||' + + '); + -- + htp.p(wsgjsl.calbutton(field_name => 'gasday', + p_calbut => htf.img(curl => caco_system.images_path || + 'lov.gif', + calign => 'TOP', + cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER'), + p_form => 'forms[1]', + field_format => g_date_format, + p_field_prompt => caco_utilities.get_module_text(1142))); + -- + htp.p('
'||caco_utilities.get_module_text(2484)||' + '); + htp.p(''); + -- + htp.p(wsgjsl.calbutton(field_name => 'p_gasday_start', + p_calbut => htf.img(curl => caco_system.images_path || + 'lov.gif', + calign => 'TOP', + cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER'), + p_form => 'forms[1]', + field_format => g_date_format, + p_field_prompt => caco_utilities.get_module_text(1142))); + -- + htp.p('
'||caco_utilities.get_module_text(2485)||' + '); + htp.p(''); + -- + htp.p(wsgjsl.calbutton(field_name => 'p_gasday_end', + p_calbut => htf.img(curl => caco_system.images_path || + 'lov.gif', + calign => 'TOP', + cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER'), + p_form => 'forms[1]', + field_format => g_date_format, + p_field_prompt => caco_utilities.get_module_text(1142))); + htp.p('
'); + -- + htp.br; + -- + -- Work out if we need to worry about the long and short days + -- + l_only_short_day := FALSE; + l_cont_long_day := FALSE; + -- + -- Check to see if the period we are looking at contains the long day, or only contains the short day + -- + FOR i IN 1..l_loop_counter LOOP + -- + IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 25 THEN + l_cont_long_day := TRUE; + END IF; + -- + END LOOP; + -- + IF ( get_spte_name(g_cont_id) = UPPER(g_spte_single) + OR l_loop_counter = 1 ) + AND cout_dates.hours_in_gas_day(g_target_date) = 23 THEN + -- + l_only_short_day := TRUE; + -- + END IF; + -- + -- Data Table + -- + htp.p(''); + -- + FOR cate IN (SELECT coca.coca_id + ,cate.code + ,cate.name + ,cate.units + ,row_number() over (partition by cate.name order by coca.display_sequence) disp_head + ,sq1.span + ,cate.display_cond + FROM contract_categories coca + ,categories cate + , (SELECT cate2.name + ,count(*) as span + FROM contract_categories coca2 + ,categories cate2 + WHERE coca2.cont_id = g_cont_id + AND coca2.cate_id = cate2.cate_id + GROUP BY cate2.name) sq1 + WHERE cate.cate_id = coca.cate_id + AND coca.cont_id = g_cont_id + AND sq1.name = cate.name + ORDER BY coca.display_sequence ) LOOP + -- + IF (cate.display_cond = 'LO' AND l_cont_long_day) + OR (cate.display_cond = 'SH' AND NOT l_only_short_day) + OR cate.display_cond = 'AL' THEN + -- + IF cate.disp_head = 1 THEN + l_tab_head_1 := l_tab_head_1 || ''; + END IF; + -- + l_tab_head_2 := l_tab_head_2 || ''; + -- + END IF; + -- + END LOOP; + -- + IF get_spte_name(g_cont_id) IN (UPPER(g_spte_single),UPPER(g_spte_smulti)) THEN + -- + l_tab_head_1 := ''||l_tab_head_1||''; + l_tab_head_2 := ''||l_tab_head_2||''; + -- + ELSIF get_spte_name(g_cont_id) = UPPER(g_spte_multi) THEN + -- + l_tab_head_1 := ''||l_tab_head_1||''; + l_tab_head_2 := ''||l_tab_head_2||''; + -- + END IF; + -- + htp.p(l_tab_head_1); + htp.p(l_tab_head_2); + -- + FOR conp IN ( SELECT nepo.name + ,nepo.code + ,conp.conp_id + ,rownum AS sitenum + FROM cont_network_points conp + ,network_points nepo + WHERE nepo.nepo_id = conp.nepo_id + AND conp.cont_id = g_cont_id + AND ((nepo.nepo_type = 'V' AND efno_contracts.emo_contract(g_cont_id) = 'Y') OR + (nepo.nepo_type IN ('N','X') AND efno_contracts.emo_contract(g_cont_id) = 'N')) + --ORDER BY conp.display_sequence + ORDER BY nepo.code + ) LOOP + -- + htp.p(''); + -- + l_cv := get_cv(conp.conp_id); + -- + htp.p(''); + -- + FOR i IN 1..l_loop_counter LOOP + -- + l_num_hours := cout_dates.hours_in_gas_day(g_target_date + (i-1)); + -- + IF get_spte_name(g_cont_id) IN (UPPER(g_spte_single),UPPER(g_spte_smulti)) THEN + -- + l_tab_line := ''; + -- + ELSIF get_spte_name(g_cont_id) = UPPER(g_spte_multi) THEN + -- + l_tab_line := ''; + -- + ELSE + -- + l_tab_line := ''; + -- + END IF; + -- + -- For all sites + -- + FOR conp_coca IN (SELECT coca.coca_id + ,cate.display_cond + ,cate.units + ,cate.name + FROM contract_categories coca + ,categories cate + WHERE cate.cate_id = coca.cate_id + AND coca.cont_id = g_cont_id + ORDER BY coca.display_sequence ) LOOP + -- + --htp.p(''); + -- + l_MJ_coca_id := 0; + -- + -- check to see if this is a m3/day volume category and we have a non-zero cv value + -- + IF conp_coca.units IN ('m3/day','m3/nap') AND l_cv > 0 THEN + -- + -- check to see if we have an equivalent energy category in the contract + -- + OPEN cu_MJ_cate(conp_coca.name); + FETCH cu_MJ_cate INTO l_MJ_coca_id; + IF cu_MJ_cate%NOTFOUND THEN + l_MJ_coca_id := 0; + END IF; + CLOSE cu_MJ_cate; + -- + END IF; + -- + IF conp_coca.display_cond = 'AL' THEN + -- + -- check to see if we need to put an onchange js call to calculate the energy + -- + IF l_MJ_coca_id > 0 THEN + -- + l_tab_line := l_tab_line || ''; + -- + ELSE + -- + l_tab_line := l_tab_line || ''; + -- + END IF; + -- + ELSIF conp_coca.display_cond = 'SH' THEN + -- + -- this is a short day category + -- + IF l_num_hours = 23 THEN + -- + IF l_only_short_day THEN + -- + NULL; + -- + ELSE + -- + l_tab_line := l_tab_line || ''; + -- + END IF; + -- + ELSE + -- + -- check to see if we need to put an onchange js call to calculate the energy + -- + IF l_MJ_coca_id > 0 THEN + -- + l_tab_line := l_tab_line || ''; + -- + ELSE + -- + l_tab_line := l_tab_line || ''; + -- + END IF; + -- + END IF; + -- + ELSIF conp_coca.display_cond = 'LO' THEN + -- + -- this is a long day category + -- + IF l_num_hours = '25' THEN + -- + -- check to see if we need to put an onchange js call to calculate the energy + -- + IF l_MJ_coca_id > 0 THEN + -- + l_tab_line := l_tab_line || ''; + -- + ELSE + -- + l_tab_line := l_tab_line || ''; + -- + END IF; + -- + ELSIF l_cont_long_day THEN + -- + l_tab_line := l_tab_line || ''; + -- + ELSE + -- + NULL; + -- + END IF; + -- + END IF; + -- + END LOOP; + -- + l_tab_line := l_tab_line || ''; + htp.p(l_tab_line); + -- + END LOOP; + -- + END LOOP; + -- + htp.p('
'||cate.name||''||cate.units||'
'||caco_utilities.get_module_text(2113)||''||caco_utilities.get_module_text(2023)||'
'||caco_utilities.get_module_text(2113)||''||caco_utilities.get_module_text(2023)||''||caco_utilities.get_module_text(1142)||'
'||conp.code||''||conp.name||'
'||conp.code||''||conp.name||''||'
'||conp.name||''||conp.code||''||''||''||''||''||''||''||''||''||''||''||'
'); + -- + ELSE + -- + -- No contract identifier found - error! + -- + wsgl.displaymessage(p_type => WSGL.MESS_ERROR + ,p_mess => gc_no_cont_found + ); + -- + END IF; + -- + --caco_debug.putline('display_nom_details END'); + EXCEPTION + WHEN OTHERS THEN + -- + cout_err.report_and_stop(p_exception_message => sqlerrm||' : efnow098$.display_nom_details'); + -- + END display_nom_details; + -- + FUNCTION check_nomination ( p_nomination IN nominations.identifier%TYPE + , p_cust_id IN customers.cust_id%TYPE + ) RETURN BOOLEAN IS + -- + l_return BOOLEAN := FALSE; + -- + BEGIN + -- + FOR i IN ( SELECT noms.nomi_id + FROM nominations noms + ,contracts cont + WHERE noms.identifier = p_nomination + AND noms.cont_id = cont.cont_id + AND cont.cust_id = p_cust_id ) LOOP + -- + l_return := TRUE; + -- + EXIT; + -- + END LOOP; + -- + RETURN l_return; + -- + END; + -- + PROCEDURE page_foot ( p_rb IN VARCHAR2 + , p_contract IN VARCHAR2 DEFAULT NULL + , p_nomination IN VARCHAR2 DEFAULT NULL + , p_spreadsheet IN VARCHAR2 DEFAULT NULL + ) IS + -- + l_valid BOOLEAN := FALSE; + l_message VARCHAR2(1000) := NULL; + -- + l_gtsp_id gtt_spreadsheet.spreadsheet_id%TYPE; + -- + BEGIN + -- + --caco_debug.putline('-----page_foot'); + -- + -- Build the matrix if the correct parameters have been passed + -- + htp.p('
'); + -- + IF ( p_rb = '1' AND p_contract IS NOT NULL) + OR ( p_rb = '2' AND p_nomination IS NOT NULL) + OR ( p_rb = '3' AND p_spreadsheet IS NOT NULL) THEN + -- + -- Lets display the grid + -- + IF p_rb = '2' THEN + -- + -- Copying an existing nomination, check is valid for my user + -- + l_valid := check_nomination ( p_nomination => p_nomination + , p_cust_id => g_cust_id + ); + -- + IF l_valid THEN + -- + -- Appears to be valid, lets get the nomination + -- + SELECT * + BULK COLLECT + INTO g_nomi_tab + FROM nominations noms + WHERE noms.identifier = p_nomination; + -- + -- Now get the details + -- + SELECT * + BULK COLLECT + INTO g_nnpcv_tab + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = g_nomi_tab(1).nomi_id + ORDER BY nnpcv.gas_day + ,efno_nominations.get_conp(nnpcv.conp_id, 'DISPLAY_SEQUENCE') + ,efno_nominations.get_coca(nnpcv.coca_id, 'DISPLAY_SEQUENCE'); + -- + -- Set the target end date to the number of days in the nomination + -- + g_target_date_end := g_target_date + (g_nnpcv_tab(g_nnpcv_tab.LAST).gas_day - g_nnpcv_tab(1).gas_day); + -- + END IF; + -- + END IF; + -- + IF p_rb = '3' THEN + -- + -- Uploading a spreadsheet, find the document + -- + FOR i IN ( SELECT docu.docu_id + FROM documents docu + WHERE docu.name = p_spreadsheet ) 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 + -- + l_valid := FALSE; + -- + cout_err.report_and_go( p_exception_number => sqlcode + , p_exception_message => sqlerrm + ); + -- + l_valid := FALSE; + -- + END; + -- + IF l_gtsp_id IS NOT NULL AND l_gtsp_id != 0 THEN + -- + -- Spreadheet appears to be OK, continue processing + -- + caco_debug.putline('Read Spreadsheet gtsp: '||l_gtsp_id); + -- + FOR i IN ( SELECT COUNT(*) AS gcnt + FROM gtt_spreadsheet gtts + WHERE gtts.spreadsheet_id = l_gtsp_id) LOOP + -- + caco_debug.putline('Spreadsheet decoded to: '||i.gcnt||' cells.'); + -- + END LOOP; + -- + IF NOT process_spreadsheet_to_arrays ( p_gtsp_id => l_gtsp_id + , p_cont_id => g_cont_id + , p_nomi_tab => g_nomi_tab + , p_nnpcv_tab => g_nnpcv_tab + , p_error => l_message + ) THEN + -- + l_valid := FALSE; + -- + ELSE + -- + l_valid := TRUE; + -- + END IF; + -- + ELSE + -- + -- File doesn't appear to be in the correct format (that is, a spreadsheet) + -- + l_valid := FALSE; + l_message := gc_invalid_file_format; + -- + END IF; + -- + END LOOP; + -- + END IF; + -- + IF p_rb = '1' + OR l_valid THEN + -- + -- Build the form + -- + htp.p('
'); + -- + htp.p('
'); + -- + -- Display the details + -- + display_nom_details(p_type => 'TABLE'); + -- + htp.p('
'); + -- + -- submit and verify buttons + -- + htp.p(''); + htp.p(''); + -- + htp.p('
'); + -- + ELSE + -- + -- Must have invalid data - display any error + -- + wsgl.displaymessage(p_type => WSGL.MESS_ERROR + ,p_mess => l_message + ); + -- + END IF; + -- + ELSE + -- + -- Nothing to display - enter header details + -- + htp.p(gc_missing_details); + -- + END IF; + -- + -- Close the nommatrix div + -- + htp.p('
'); + -- + -- Interruption notes at footer of the page + -- + IF g_int_category THEN + -- + htp.br; + htp.p('

'||caco_utilities.get_module_text(3810)||'

'); + -- + END IF; + -- + caco_system.footer(p_closebody => TRUE); + -- + -- re-initialise the tables with empty tables in case they've been used + -- + g_nomi_tab := g_empty_nomi_tab; + g_nnpcv_tab := g_empty_nnpcv_tab; + -- + g_cell_error := g_empty_cell_error; + g_row_error := g_empty_row_error; + -- + END page_foot; + -- + FUNCTION pdecode ( p_decode_string IN VARCHAR2 + ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(4000); + -- + BEGIN + -- + EXECUTE IMMEDIATE 'SELECT '||p_decode_string||' FROM DUAL' into l_return; + -- + RETURN l_return; + -- + EXCEPTION + WHEN OTHERS THEN + htp.p(sqlerrm||p_decode_string); + RETURN NULL; + END pdecode; + -- + PROCEDURE get_cont_id ( p_cust_id IN customers.cust_id%TYPE + , p_contract_number IN contracts.contract_number%TYPE + ) IS + -- + BEGIN + -- + BEGIN + -- + SELECT cont.cont_id + ,cont.contract_number + ,cont.valid_from + ,cont.valid_until + INTO g_cont_id + ,g_cont_num + ,g_cont_start_date + ,g_cont_end_date + FROM contracts cont + WHERE cont.cust_id = p_cust_id + AND cont.status = 'O' + AND cont.contract_number = p_contract_number + AND rownum < 2; + -- + EXCEPTION + WHEN OTHERS THEN + -- + BEGIN + SELECT cont_id + ,contract_number + ,valid_from + ,valid_until + INTO g_cont_id + ,g_cont_num + ,g_cont_start_date + ,g_cont_end_date + FROM (SELECT cont.cont_id + ,cont.contract_number + ,cont.valid_from + ,cont.valid_until + FROM contracts cont + WHERE cont.cust_id = p_cust_id + AND cont.status = 'O' + AND cont.contract_number = NVL(p_contract_number,cont.contract_number) + ORDER BY cont.valid_from + ) + WHERE rownum < 2; + EXCEPTION + WHEN OTHERS THEN + -- + -- + g_cont_id := NULL; + g_cont_num := NULL; + END; + -- + END; + -- + END get_cont_id; + -- + -- Public + -- + 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; + -- + PROCEDURE noms_js IS + BEGIN + -- + owa_util.mime_header('application/x-javascript' + ,TRUE); + -- + htp.p(' function showtr(trid)'); + htp.p(' {'); + htp.p(' obj = document.getElementsByTagName(''TR'');'); + htp.p(' for (i=0; i= g_gas_day + ORDER BY c.valid_from; + -- + BEGIN + -- + --caco_debug.putline('-----nom_header'); + -- + get_cont_id ( p_contract_number => p_contract + , p_cust_id => g_cust_id ); + -- +/*caco_debug.putline('g_target_date: '||to_char(g_target_date,g_date_format)); +caco_debug.putline('g_gas_day: '||to_char(g_gas_day,g_date_format)); +caco_debug.putline('g_cust_id: '||g_cust_id); +caco_debug.putline('g_cont_start_date: '||to_char(g_cont_start_date,g_date_format));*/ + -- + IF NOT caco_security.security_check(p_package_name => g_package_name) THEN + -- + NULL; + -- + ELSE + -- + -- Display the page head + -- + page_head; + -- + -- Security Check OK, now build the form + -- + htp.p(' '); + htp.p('
'); + -- + -- Display any error or information messages + -- + IF g_error_message IS NOT NULL THEN + -- + htp.p(''||g_error_message||''); + -- + END IF; + -- + -- If appropriate, build the bottom of the screen + -- + IF ( p_rb = 1 AND l_contract IS NOT NULL) + OR ( p_rb = 2 AND p_nomination IS NOT NULL) + OR ( p_rb = 3 AND p_spreadsheet IS NOT NULL) THEN + -- + page_foot ( p_rb + , l_contract + , p_nomination + , p_spreadsheet + ); + -- + END IF; + -- + END IF; + -- + END nom_header; + -- + PROCEDURE nomination_lov(z_filter IN VARCHAR2 DEFAULT NULL + ,z_mode IN VARCHAR2 DEFAULT NULL + ,z_caller_url IN VARCHAR2 DEFAULT NULL + ,z_formrow IN NUMBER DEFAULT NULL + ,z_long_list IN VARCHAR2 DEFAULT NULL + ,z_issue_wait IN VARCHAR2 DEFAULT NULL + ) IS + -- + lb_first BOOLEAN := TRUE; + l_cust_id customers.cust_id%TYPE; + -- + BEGIN + -- + IF NOT caco_security.security_check(p_package_name => g_package_name) THEN + -- + RETURN; + -- + END IF; + htp.p('z_filter: '||'*'||z_filter||'*'); + -- + htp.p(' + + + + + + + + + + +

+ '); + + htp.p('

'); + htp.p('

'); + htp.p('Search criterion for Identifier:'); + htp.p('

'); + htp.p(''); + htp.p(''); + htp.p(''); + htp.p('

'); + htp.p('

'); + l_cust_id := caco_utilities.get_cust_id; + FOR f IN (SELECT * + FROM (SELECT n.IDENTIFIER + ,c.contract_number + ,wsgl.gettext(caco_utilities.cgrefmeaning('STATUS' + ,n.status)) AS status + ,TO_CHAR(MIN(ncv.gas_day) + ,g_date_format) AS start_day + ,TO_CHAR(MAX(ncv.gas_day) + ,g_date_format) AS end_day + FROM nominations n + ,contracts c + ,nom_net_point_cat_vals ncv + WHERE c.cont_id IN (SELECT cont2.cont_id + FROM contracts cont2 + CONNECT BY PRIOR cont2.prev_cont_id = cont2.cont_id + START WITH cont2.cont_id = g_cont_id) + AND c.cust_id = l_cust_id + AND n.cont_id = c.cont_id + AND n.nomi_id = ncv.nomi_id + AND (n.IDENTIFIER LIKE z_filter OR z_filter IS NULL) + GROUP BY n.IDENTIFIER + ,c.contract_number + ,caco_utilities.cgrefmeaning('STATUS' + ,n.status) + ORDER BY MIN(ncv.gas_day) DESC + ,2) + WHERE ROWNUM < 50) LOOP + -- + IF lb_first THEN + -- + -- Print table header - we have some data + -- + htp.p(''); + htp.p(''); + htp.p(''); + htp.p(''); + -- + htp.p(''); + -- + lb_first := FALSE; + -- + END IF; + -- + htp.p(''); + -- + END LOOP; + -- + IF lb_first THEN + -- + -- No rows returned, display no data found + -- + htp.p(display_message ( p_mess => gc_no_data_found + , p_type => wsgl.mess_error + )); + -- + ELSE + -- + -- Rows returned, close the table + -- + htp.p(''); + htp.p('
IdentifierContract NumberStatusStart DateEnd Date
' || f.IDENTIFIER || + '' || f.contract_number || + '' || f.status || + '' || f.start_day || + '' || f.end_day || '
'); + -- + END IF; + -- + htp.p('

'); + -- + END nomination_lov; + -- + PROCEDURE redisplay (p_contract IN VARCHAR2 DEFAULT NULL + ,p_nomination IN VARCHAR2 DEFAULT NULL + ,p_spreadsheet IN VARCHAR2 DEFAULT NULL + ,p_rb IN VARCHAR2 DEFAULT 1 + ) IS + BEGIN + -- + --caco_debug.putline('-----redisplay'); + -- + g_cont_num := p_contract; + -- + nom_header(p_contract => p_contract + ,p_nomination => p_nomination + ,p_spreadsheet => p_spreadsheet + ,p_rb => p_rb + ); + -- + END redisplay; + -- + PROCEDURE submit_nomination ( val IN owa_util.vc_arr + , gasday IN owa_util.vc_arr + , coca IN owa_util.vc_arr + , conp IN owa_util.vc_arr + , cv IN owa_util.vc_arr + , cont_id IN contracts.cont_id%TYPE + , action IN VARCHAR2 DEFAULT NULL + , p_gasday_start IN VARCHAR2 DEFAULT NULL + , p_gasday_end IN VARCHAR2 DEFAULT NULL + ) IS + -- + -- Parameters are short intentionally + -- + l_message VARCHAR2(1000); + l_mess_type VARCHAR2(1000); + l_sub_list caco_utilities.g_t_substitution_list; + -- + e_ude EXCEPTION; + l_date DATE; + -- + l_nomi_id nominations.nomi_id%TYPE; + -- + lr_cell_error gr_cell_error; + -- + l_nomi_details VARCHAR2(4000); + l_timestamp DATE; + l_letter VARCHAR2(4000); + -- + l_c_nnpcv_tab efno_confirmations.nnpcv_tab; + l_rule_results BOOLEAN := TRUE; + -- + l_cnp_count NUMBER; + -- + l_idx NUMBER := NULL; + -- + l_rcve_b4_start NUMBER := 0; -- Contract receive before start + -- + l_multi_day_iter NUMBER := 7; + -- + l_num_format VARCHAR2(50); + -- + l_tot_perc_split NUMBER := 0; + -- + -- dbms_lock values + -- + l_noms_lock NUMBER; + l_noms_release NUMBER; + -- + -- local variables for input array manipulation for multi day noms + l_val owa_util.vc_arr; + l_gasday owa_util.vc_arr; + l_gd DATE; + l_nom_days NUMBER := 0; + l_i NUMBER := 0; + l_r NUMBER := 0; + val_i NUMBER := 0; + val_r NUMBER := 0; + -- + -- array to contain val array contents with no thousand separators + l_val_no_thou_sep owa_util.vc_arr; + -- + l_loop_counter NUMBER := 1; + l_coca_id NUMBER; + -- + CURSOR cu_coca(c_disp_cond IN categories.display_cond%TYPE) IS + SELECT coca.coca_id + FROM contract_categories coca + ,categories cate + WHERE cate.cate_id = coca.cate_id + AND coca.cont_id = g_cont_id + AND cate.display_cond = c_disp_cond; + -- + BEGIN + -- + --caco_debug.putline('-----submit_nomination'); + -- + -- Security check + -- + IF caco_security.security_check(p_package_name => g_package_name) THEN + -- + -- Attempt to lock nominations table + caco_debug.putline('Entered default_values'); + -- + l_noms_lock := dbms_lock.request(id => 128 + ,lockmode => 6 + ,timeout => 180); + caco_debug.putline('default_values DBMS_LOCK id 128 request value l_noms_lock is ' || + l_noms_lock); + -- + IF l_noms_lock = 0 THEN + BEGIN + -- + -- Set the initial error point + -- + g_error_point := 'A005'; + -- + -- 02/12/09 SP Modification to multi-day nominations + -- Manipulate the input arrays for single-multi day nominations to simulate noms entered + -- for each day. + -- + l_nom_days := (to_date(p_gasday_end,g_date_format) - to_date(p_gasday_start,g_date_format))+1; + -- +/* caco_debug.putline('p_gasday_start: '||p_gasday_start); + caco_debug.putline('p_gasday_end: '||p_gasday_end); + caco_debug.putline('l_nom_days: '||l_nom_days); + display_vc_arr('val before',val); + display_vc_arr('gasday before',gasday);*/ + -- + -- remove thousand separators from val array + -- + l_val_no_thou_sep := caco_utilities.thousand_separated_to_char(val); + --IF p_gasday_start IS NOT NULL AND p_gasday_end IS NOT NULL THEN + IF get_spte_name(cont_id) = UPPER(g_spte_smulti) THEN + FOR r IN 1..conp.count LOOP + l_gd := to_date(p_gasday_start,g_date_format); + --caco_debug.putline('l_gd1: '||l_gd); + FOR i IN 1..l_nom_days LOOP + -- enter values in the gasday array + --caco_debug.putline('l_gd: '||l_gd); + l_i := l_i + 1; + l_gasday(l_i) := to_char(l_gd,g_date_format); + l_gd := l_gd + 1; + END LOOP; + END LOOP; + -- + IF l_val_no_thou_sep.COUNT > 0 THEN + FOR r IN 1..conp.COUNT LOOP + FOR i IN 1..l_nom_days LOOP + FOR y IN 1..coca.COUNT LOOP + val_r := val_i + y; + l_r := l_r + 1; + -- enter values in the values array + l_val(l_r) := l_val_no_thou_sep(val_r); + END LOOP; + END LOOP; + val_i := val_i + coca.COUNT; + END LOOP; + END IF; + ELSE + -- must be single day or multiple day nomination + l_val := l_val_no_thou_sep; + l_gasday := gasday; + END IF; + -- +/* display_vc_arr('val after',l_val); + display_vc_arr('gasday after',l_gasday);*/ + -- + -- Anonymous block to handle exceptions + -- + IF action IN (caco_utilities.get_module_text(1149/* Verify */), caco_utilities.get_module_text(840/* Insert */)) THEN + -- + -- Nomination Identifier looks OK, set it globally + -- + g_error_point := 'A015'; + -- + -- Now validate the details, set the global + -- + g_error_point := 'A025'; + -- + g_gas_days := l_gasday; + -- + -- Pre-populate the arrays based on screen values without any validation + -- so earlier validation failures do not 'wipe-out' screen values. + -- + g_error_point := 'A035'; + -- + -- Check the number of categories and sites is in the same ballpark as the number of values supplied (multiplication factor) + -- + IF MOD(l_val.COUNT,(conp.COUNT*coca.COUNT))=0 THEN + -- + -- only proceed if balanced, otherwise, how would we know... + -- + g_error_point := 'A036'; + -- + FOR i IN 1..l_val.COUNT LOOP + -- + -- Pre-populate the variables in case of any errors + -- + g_error_point := 'A037'; + -- + g_nnpcv_tab(i).conp_id := conp(TRUNC((i-1)/(coca.COUNT*(l_val.COUNT/(conp.COUNT*coca.COUNT))))+1); + g_error_point := 'A038'; + g_nnpcv_tab(i).coca_id := coca(MOD((i-1),coca.COUNT)+1); + g_error_point := 'A039'; + g_nnpcv_tab(i).value := l_val(i); + -- + END LOOP; + -- + END IF; + -- + g_error_point := 'A045'; + -- + -- Verify the nomination + -- + IF cont_id IS NOT NULL THEN + -- + -- Ensure that we have a contract before proceeding + -- + g_error_point := 'A095'; + -- + get_cont_id(p_cont_id => cont_id); + -- + -- Get the "Receive Before Start" parameter for the contract + l_rcve_b4_start := get_receive_before_start(g_cont_id); + -- + g_error_point := 'A115'; + -- + IF get_spte_name(g_cont_id) = UPPER(g_spte_single) THEN + -- + -- Looking at a single gas day + -- + IF g_gas_days(1) IS NULL THEN + -- + l_sub_list(1) := caco_utilities.get_module_text(1142); + -- + caco_utilities.get_exception_message(p_exception_number => -20506 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + g_error_point := 'A120'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A125'; + -- + BEGIN + -- + l_date := TO_DATE(g_gas_days(1), g_date_format); + -- + EXCEPTION + -- + WHEN OTHERS THEN + -- + l_sub_list(1) := g_gas_days(1); + -- + caco_utilities.get_exception_message(p_exception_number => -20102 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + g_error_point := 'A130'; + -- + RAISE e_ude; + -- + END; + -- + g_error_point := 'A135'; + -- + -- Established it is a valid date, but is it in the correct timeframe? + -- + IF l_date < g_target_date -1 THEN + -- + l_sub_list(1) := TO_CHAR(l_date, g_date_format); + l_sub_list(2) := TO_CHAR(g_target_date, g_date_format); + -- + caco_utilities.get_exception_message(p_exception_number => -20509 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + g_error_point := 'A140'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A145'; + -- + -- Check date against contract range + -- + IF NOT check_cont_date ( p_cont_id => g_cont_id + , p_date => l_date + , p_message => l_message + ) THEN + -- + g_error_point := 'A150'; + -- + RAISE e_ude; + -- + END IF; + -- + -- Check the date against the "Receive Before Start" parameter + -- + IF ( l_date - TRUNC(SYSDATE) ) > l_rcve_b4_start THEN + -- + -- it is too early to nominate for this gas day. + caco_utilities.get_exception_message(p_exception_number => -20527 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + g_error_point := 'A152'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A155'; + -- + -- Check the gate closure + -- + IF NOT check_gate_closure ( p_cont_id => g_cont_id + , p_date => l_date + , p_message => l_message + ) THEN + -- + g_error_point := 'A160'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A165'; + -- + ELSIF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN + -- + -- Looking at multiple gas days + -- + g_error_point := 'A167'; + -- + SELECT COUNT(*) + INTO l_cnp_count + FROM cont_network_points conp + ,network_points nepo + WHERE conp.cont_id = g_cont_id + AND conp.nepo_id = nepo.nepo_id + AND ((nepo.nepo_type = 'V' AND efno_contracts.emo_contract(g_cont_id) = 'Y') OR + (nepo.nepo_type IN ('N','X') AND efno_contracts.emo_contract(g_cont_id) = 'N')); + -- + g_target_date := TO_DATE(p_gasday_start, g_date_format); + g_target_date_end := TO_DATE(p_gasday_end, g_date_format); + -- + IF g_target_date < g_cont_start_date THEN + -- + -- Target date is less than the start of the contract...what to do? + -- + l_multi_day_iter := l_multi_day_iter - MOD(7-(TO_CHAR(g_cont_start_date,'D')-g_day_at_start_of_week),7)+1; + -- + g_target_date := g_cont_start_date; + -- + END IF; + -- + /* IF g_cont_end_date - g_target_date < TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')) THEN + -- + -- End of contract occurs during week, shorten the days displayed + -- + l_multi_day_iter := l_multi_day_iter - (TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')-(g_cont_end_date - g_target_date)))+1; + -- + IF l_multi_day_iter < 0 THEN + -- + l_multi_day_iter := 0; + -- + END IF; + -- + END IF; */ + -- + IF MOD(l_gasday.COUNT, l_cnp_count) <> 0 THEN + -- + -- The same number of days should be specified for each network point + -- + l_sub_list(1) := caco_utilities.get_module_text(1142); + -- + caco_utilities.get_exception_message(p_exception_number => -20506 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + FOR i IN 1..(TO_NUMBER(l_multi_day_iter) * l_cnp_count) LOOP + -- + g_row_error(i) := l_message; + -- + END LOOP; + -- + g_error_point := 'A170'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A175'; + -- + FOR i IN 1..l_gasday.COUNT LOOP + -- + -- Check each date is a valid date + -- + BEGIN + -- + l_date := TO_DATE(g_gas_days(i), g_date_format); + -- + EXCEPTION + -- + WHEN OTHERS THEN + -- + l_sub_list(1) := g_gas_days(i); + -- + caco_utilities.get_exception_message(p_exception_number => -20102 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + g_row_error(i) := l_message; + -- + g_error_point := 'A180'; + -- + RAISE e_ude; + -- + END; + -- + g_error_point := 'A185'; + -- + -- Check date is in the future + -- + IF l_date < g_target_date -1 THEN + -- + l_sub_list(1) := TO_CHAR(l_date, g_date_format); + l_sub_list(2) := TO_CHAR(g_target_date+(i-1), g_date_format); + -- + caco_utilities.get_exception_message(p_exception_number => -20509 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + g_row_error(i) := l_message; + -- + g_error_point := 'A190'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A195'; + -- + -- Check date against contract range + -- + IF NOT check_cont_date ( p_cont_id => g_cont_id + , p_date => l_date + , p_message => l_message + ) THEN + -- + g_row_error(i) := l_message; + -- + g_error_point := 'A200'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A205'; + -- + -- Check the gate closure + -- + IF NOT check_gate_closure ( p_cont_id => g_cont_id + , p_date => l_date + , p_message => l_message + ) THEN + -- + g_row_error(i) := l_message; + -- + g_error_point := 'A210'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A215'; + -- + -- Check date sequence + -- + IF MOD(i-1, g_gas_days.COUNT/l_cnp_count) > 0 THEN + -- + -- If we're not looking at the first date + -- + IF TO_DATE(g_gas_days(i), g_date_format) -1 <> TO_DATE(g_gas_days(i-1), g_date_format) THEN + -- + caco_utilities.get_exception_message(p_exception_number => -20510 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + g_row_error(i) := l_message; + -- + g_error_point := 'A220'; + -- + RAISE e_ude; + -- + END IF; + -- + END IF; + -- + -- Check the date against the "Receive Before Start" parameter + -- + IF ( l_date - TRUNC(SYSDATE) ) > l_rcve_b4_start THEN + -- + -- it is too early to nominate for this gas day. + caco_utilities.get_exception_message(p_exception_number => -20527 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + g_row_error(i) := l_message; + -- + g_error_point := 'A222'; + -- + RAISE e_ude; + -- + END IF; + -- + -- + g_error_point := 'A225'; + -- + END LOOP; + -- + -- If a multi-day range contains a long/short day and the contract + -- has a long/short day category and the contract is using the single-multi day input format + -- then output an error/warning + l_loop_counter := (g_target_date_end - g_target_date) +1; + IF l_loop_counter > 1 AND get_spte_name(cont_id) = UPPER(g_spte_smulti) THEN + -- check for long day category + OPEN cu_coca('LO'); + FETCH cu_coca INTO l_coca_id; + IF cu_coca%FOUND THEN + FOR i IN 1..l_loop_counter LOOP + -- + -- check for long day + IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 25 THEN + l_message := wsgl.msggettext(p_msgno => NULL + ,p_dflttext => caco_utilities.get_module_text(3935) + ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); + -- + g_error_message := display_message( p_type => WSGL.MESS_ERROR + , p_mess => l_message + ); + RAISE e_ude; + END IF; + END LOOP; + END IF; + CLOSE cu_coca; + -- + -- check for short day category + OPEN cu_coca('SH'); + FETCH cu_coca INTO l_coca_id; + IF cu_coca%FOUND THEN + FOR i IN 1..l_loop_counter LOOP + -- + -- check for short day + IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 23 THEN + l_message := wsgl.msggettext(p_msgno => NULL + ,p_dflttext => caco_utilities.get_module_text(3936) + ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); + -- + g_error_message := display_message( p_type => WSGL.MESS_ERROR + , p_mess => l_message + ); + RAISE e_ude; + END IF; + END LOOP; + END IF; + CLOSE cu_coca; + END IF; + ELSE + -- + -- Looking at something else? + -- + NULL; + -- + END IF; + -- + g_error_point := 'A227'; + -- + -- Dates look OK, move on to numbers + -- + IF MOD(l_val.COUNT,(conp.COUNT*coca.COUNT))=0 THEN --id.COUNT = val.COUNT THEN + -- + -- Now go through the values - this way we can redisplay any errors + -- + FOR i IN 1..l_val.COUNT LOOP + -- + IF l_val(i) IS NULL THEN + -- + l_sub_list(1) := caco_utilities.get_module_text(2022); + -- + caco_utilities.get_exception_message(p_exception_number => -20506 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + lr_cell_error.conp_id := g_nnpcv_tab(i).conp_id; + lr_cell_error.coca_id := g_nnpcv_tab(i).coca_id; + lr_cell_error.iteration := CEIL(i/(l_val.COUNT/l_gasday.COUNT)); + lr_cell_error.message := l_message; + -- + g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; + -- + g_error_point := 'A230'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A235'; + -- + BEGIN + -- + -- Anon block to check for numeric conversion + -- + g_nnpcv_tab(i).value := TO_NUMBER(REPLACE(l_val(i),',','')); + -- + EXCEPTION + WHEN OTHERS THEN + -- + caco_utilities.get_exception_message(p_exception_number => -20511 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + lr_cell_error.conp_id := g_nnpcv_tab(i).conp_id; + lr_cell_error.coca_id := g_nnpcv_tab(i).coca_id; + lr_cell_error.iteration := CEIL(i/(l_val.COUNT/l_gasday.COUNT)); + lr_cell_error.message := l_message; + -- + g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; + -- + g_error_point := 'A240'; + -- + RAISE e_ude; + -- + END; + -- + -- Check number format + -- + g_error_point := 'A241'; + -- + IF INSTR(TO_CHAR(g_nnpcv_tab(i).value),'.') > 0 THEN + -- + -- Number entered has a decimal, lets check it's within range, lookup format + -- + g_error_point := 'A242'; + -- + l_num_format := NULL; + -- + SELECT c.number_format + INTO l_num_format + FROM categories c + ,contract_categories cc + WHERE c.cate_id = cc.cate_id + AND cc.coca_id = g_nnpcv_tab(i).coca_id; + -- + -- Now compare the number formats + -- + IF (LENGTH(TO_CHAR(g_nnpcv_tab(i).value)) - INSTR(TO_CHAR(g_nnpcv_tab(i).value),'.')) > (LENGTH(l_num_format) - INSTR(l_num_format||'.','.')) THEN + -- + -- Number of decimals in supplied format greater than number of decimals in format mask + -- + g_error_point := 'A243'; + -- + l_message := display_message(p_type => WSGL.MESS_ERROR + ,p_mess => NVL(l_message + ,caco_utilities.get_module_text(p_text_number => 2240 ) + ) + ); + l_message := caco_utilities.get_module_text(p_text_number => 2240 ); + -- + lr_cell_error.conp_id := g_nnpcv_tab(i).conp_id; + lr_cell_error.coca_id := g_nnpcv_tab(i).coca_id; + --lr_cell_error.iteration := CEIL(i/(val.COUNT/gasday.COUNT)); + IF MOD(CEIL(i/(l_val.count/l_gasday.count)),(l_gasday.count/l_cnp_count)) = 0 THEN + -- + -- MOD returns zero when I'd like # of gasdays + -- + lr_cell_error.iteration := (l_gasday.count/l_cnp_count); + ELSE + -- + -- otherwise, works OK + -- + lr_cell_error.iteration := MOD(CEIL(i/(l_val.count/l_gasday.count)),(l_gasday.count/l_cnp_count)); + END IF; + lr_cell_error.message := l_message; + -- + g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; + -- + RAISE e_ude; + -- + END IF; + -- + END IF; + -- + g_error_point := 'A245'; + -- + -- Have validated gas days already + -- + IF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN + -- + g_nnpcv_tab(i).gas_day := TO_DATE(l_gasday(CEIL(i/(l_val.COUNT/l_gasday.COUNT))),g_date_format); + -- + ELSE + -- + g_nnpcv_tab(i).gas_day := TO_DATE(l_gasday(1), g_date_format); + -- + END IF; + -- + g_error_point := 'A246'; + -- + END LOOP; + -- + IF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN + -- + g_target_date_end := g_nnpcv_tab(g_nnpcv_tab.LAST).gas_day; + -- + END IF; + -- + g_error_point := 'A247'; + -- + ELSE + -- + -- Identifiers and values not balanced + -- + g_error_point := 'A248'; + -- + l_message := display_message(p_type => WSGL.MESS_ERROR + ,p_mess => NVL(l_message + ,caco_utilities.get_module_text(p_text_number => 2330 ) + ) + ); + -- + FOR i IN 1..TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')) LOOP + -- + g_row_error(i) := l_message; + -- + END LOOP; + -- + g_error_point := 'A250'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A251'; + -- + ELSE + -- + -- Null Contract, raise error + -- + g_error_point := 'A255'; + -- + l_sub_list(1) := caco_utilities.get_module_text(2137); + -- + caco_utilities.get_exception_message(p_exception_number => -20506 + ,p_message => l_message + ,p_exme_type => l_mess_type + ,p_substitution_list => l_sub_list + ,p_language => caco_utilities.get_syus_lang + ); + -- + g_error_point := 'A260'; + -- + RAISE e_ude; + -- + END IF; + -- + g_error_point := 'A270'; + -- + -- Because rules are based on data in the nominations table, we need to insert it here... + -- + DBMS_TRANSACTION.SAVEPOINT(g_cont_id); + -- + -- Insert the nomination header + -- + INSERT INTO nominations ( status + , identifier + , cont_id + ) + VALUES ( 'A' + , 1 + , g_cont_id + ) + RETURNING nomi_id INTO l_nomi_id; + -- + UPDATE nominations + SET identifier = l_nomi_id + WHERE nomi_id = l_nomi_id; + -- + g_error_point := 'A280'; + -- + l_nomi_details := 'NOM:'||l_nomi_id||' ID:'||l_nomi_id||' CONT:'||g_cont_id||'DETAILS:'; + -- + -- check if it is an entry mandatory offer contract + IF efno_contracts.emo_contract(g_cont_id) = 'Y' THEN + -- + OPEN c_tot_perc_split(g_cont_id); + FETCH c_tot_perc_split INTO l_tot_perc_split; + CLOSE c_tot_perc_split; + -- + IF l_tot_perc_split = 0 THEN + IF caco_utilities.user_has_EFT_admin = 'Y' THEN + -- Percentage split contract parameters have not been set up correctly + l_message := caco_utilities.get_module_text(3917); + ELSE + -- A more customer friendly error message.. + -- An error has occurred in validating this nomination. Please contact support. + l_message := caco_utilities.get_module_text(3923); + END IF; + g_error_point := 'A282'; + RAISE e_ude; + END IF; + -- + FOR nnpcv_idx IN g_nnpcv_tab.FIRST..g_nnpcv_tab.LAST LOOP + -- + -- check that it is a virtual network point + IF efno_contracts.virtual_nepo(g_nnpcv_tab(nnpcv_idx).conp_id) THEN + -- insert a record for each non virtual network point assigned to the contract + -- using the virtual nepo nominated values and percentage split parameter + FOR i IN c_conp(g_cont_id) LOOP + -- + INSERT INTO nom_net_point_cat_vals ( value + , gas_day + , coca_id + , nomi_id + , conp_id + ) + VALUES ( ROUND((i.perc_split/l_tot_perc_split)*g_nnpcv_tab(nnpcv_idx).value) + , g_nnpcv_tab(nnpcv_idx).gas_day + , g_nnpcv_tab(nnpcv_idx).coca_id + , l_nomi_id + , i.conp_id + ); + END LOOP; + ELSE + -- Nominations for Entry Manadatory Offer Contracts must be against a virtual network point + l_message := caco_utilities.get_module_text(3916); + g_error_point := 'A285'; + RAISE e_ude; + END IF; + -- + END LOOP; + -- + END IF; + -- + FOR nnpcv_idx IN g_nnpcv_tab.FIRST..g_nnpcv_tab.LAST LOOP + -- + -- Would only use forall if it wasn't for pls-00436... + -- + -- + g_error_point := 'A290'; + -- + INSERT INTO nom_net_point_cat_vals ( value + , gas_day + , coca_id + , nomi_id + , conp_id + ) + VALUES ( g_nnpcv_tab(nnpcv_idx).value + , g_nnpcv_tab(nnpcv_idx).gas_day + , g_nnpcv_tab(nnpcv_idx).coca_id + , l_nomi_id + , g_nnpcv_tab(nnpcv_idx).conp_id + ); + -- + l_nomi_details := SUBSTR(l_nomi_details||' Day:'||g_nnpcv_tab(nnpcv_idx).gas_day||' Cat:'||g_nnpcv_tab(nnpcv_idx).coca_id||' Net:'||g_nnpcv_tab(nnpcv_idx).conp_id||' Val:'||g_nnpcv_tab(nnpcv_idx).value + ,1 + ,4000 + ); + -- + END LOOP; + -- + -- + g_error_point := 'A300'; + -- + -- Now enact the rules + -- + l_rule_results := efno_nominations.rule_loops( l_nomi_id + , g_cont_id + , l_message + , l_c_nnpcv_tab + ); + -- + g_error_point := 'A310'; + -- + -- Check the status of the rules + -- + IF l_rule_results THEN + -- + g_error_point := 'A320'; + -- + -- questionable results + -- + IF l_message IS NULL THEN + -- + l_message := caco_utilities.get_module_text(2270); + -- + END IF; + -- + l_idx := l_c_nnpcv_tab.FIRST; + -- + g_error_point := 'A330'; + -- + FOR i IN 1..l_c_nnpcv_tab.COUNT LOOP + -- + g_error_point := 'A331'; + -- + IF l_c_nnpcv_tab(l_idx).in_error THEN + -- + g_error_point := 'A332'; + -- + lr_cell_error.conp_id := l_c_nnpcv_tab(l_idx).conp_id; + lr_cell_error.coca_id := l_c_nnpcv_tab(l_idx).coca_id; + lr_cell_error.iteration := return_index(l_c_nnpcv_tab(l_idx).gas_day, l_gasday); + lr_cell_error.message := l_message; + -- + -- Now add to the end of the stack + -- + g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; + -- + END IF; + -- + l_idx := l_c_nnpcv_tab.NEXT(l_idx); + -- + END LOOP; + -- + -- Raise as an error + -- + g_error_point := 'A350'; + -- + RAISE e_ude; + -- + END IF; + -- + -- Now determine what we should be doing, be it verify or insert + -- + IF action = caco_utilities.get_module_text(1149/*Verify*/) THEN + -- + g_error_point := 'A360'; + -- + -- We do not want to save it, rollback. + -- + DBMS_TRANSACTION.ROLLBACK_SAVEPOINT(g_cont_id); + -- + l_message := caco_utilities.get_module_text( p_text_number => 2341 ); + -- + g_error_message := display_message( p_type => WSGL.MESS_SUCCESS + , p_mess => l_message + ); + -- + END IF; + -- + IF action IN (caco_utilities.get_module_text(840/* Insert */)) THEN + -- + g_error_point := 'A370'; + -- + -- Update existing nominations to inactive + -- + l_idx := g_nnpcv_tab.COUNT; -- not sure why we can't imbed this in the SQL below, but we can't + -- + UPDATE nominations nomi + SET nomi.status = 'I' + WHERE nomi.cont_id = g_cont_id + AND nomi.nomi_id <> l_nomi_id + AND EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + AND nnpcv.gas_day BETWEEN g_nnpcv_tab(1).gas_day AND g_nnpcv_tab(l_idx).gas_day + ) + AND NOT EXISTS ( SELECT NULL + FROM nom_net_point_cat_vals nnpcv + WHERE nnpcv.nomi_id = nomi.nomi_id + AND nnpcv.gas_day NOT BETWEEN g_nnpcv_tab(1).gas_day AND g_nnpcv_tab(l_idx).gas_day + ); + + -- + g_error_point := 'A371'; + -- + -- Timestamp + -- + l_timestamp := timestamp_nomi ( p_nomi_id => l_nomi_id + , p_nomi_details => l_nomi_details + ); + -- + g_error_point := 'A372'; + -- + -- Notification + -- + l_letter := send_nom_notification ( p_cust_id => g_cust_id + , p_nomi_identifier => l_nomi_id + , p_gas_day_start => g_nnpcv_tab(1).gas_day + , p_gas_day_end => g_nnpcv_tab(g_nnpcv_tab.COUNT).gas_day + , p_timestamp => l_timestamp + ); + -- + g_error_point := 'A373'; + -- + -- Create confimation + -- + INSERT INTO confirmations ( confirmation_type + , confirmation_sent + , confirmation + , nomi_id + , confirmation_text + , approved + ) + VALUES ( 'NO' + , l_timestamp + , NULL -- will add later + , l_nomi_id + , l_letter + , 'Y' + ); + -- + g_error_point := 'A374'; + -- + -- Save Spreadsheet + -- + IF NVL(cout_system_configuration.get_configuration_item('G_SAVE_NOM_TEMPLATE'),'Y') = 'Y' THEN + -- + amfr_excel.get_template(p_id => g_cont_id + ,p_type => amfr_excel.gc_nomination + ,p_nomi_conf_id => l_nomi_id + ,p_mode => 'INSERT' + ); + -- + END IF; + -- + g_error_point := 'A375'; + -- + l_message := caco_utilities.get_module_text( p_text_number => 2342 ); + -- + g_error_message := display_message( p_type => WSGL.MESS_SUCCESS + , p_mess => l_message + ); + -- + END IF; + -- + ELSE + -- + -- We must be changing the date, keep existing data + -- + get_cont_id(cont_id); + -- + g_error_point := 'A376'; + -- + IF l_gasday.COUNT > 0 THEN + -- + g_target_date := TO_DATE(l_gasday(1),g_date_format); + -- + END IF; + -- + IF p_gasday_start IS NOT NULL THEN + -- + g_target_date := TO_DATE(p_gasday_start,g_date_format); + -- + END IF; + -- + g_target_date_end := GREATEST(GREATEST(TO_DATE(NVL(p_gasday_end, g_target_date),g_date_format), g_target_date),(TO_DATE(p_gasday_start,g_date_format) + (TO_DATE(l_gasday(l_gasday.COUNT), g_date_format)-TO_DATE(l_gasday(1),g_date_format)))); + -- + g_error_point := 'A377'; + -- + FOR i IN 1..l_val.COUNT LOOP + -- + g_nnpcv_tab(i).value := l_val(i); + g_nnpcv_tab(i).gas_day := TO_DATE(l_gasday(CEIL(i/(l_val.count/l_gasday.count))),g_date_format); + -- + IF MOD(i,coca.COUNT) = 0 THEN + g_nnpcv_tab(i).coca_id := coca(coca.COUNT); + ELSE + g_nnpcv_tab(i).coca_id := coca(MOD(i,coca.COUNT)); + END IF; + -- + g_nnpcv_tab(i).conp_id := conp(CEIL(CEIL(i/coca.COUNT)/((TO_DATE(l_gasday(l_gasday.COUNT), g_date_format)+1)-TO_DATE(l_gasday(1),g_date_format)))); + -- + END LOOP; + -- + g_target_date_end := TO_DATE(p_gasday_end, g_date_format); + -- + --display_nnpcv_tab(g_nnpcv_tab); + -- + -- If a multi-day range contains a long/short day and the contract + -- has a long/short day category and the contract is using the single-multi day input format + -- then output an error/warning + l_loop_counter := (g_target_date_end - g_target_date) +1; + IF l_loop_counter > 1 AND get_spte_name(cont_id) = UPPER(g_spte_smulti) THEN + -- check for long day category + OPEN cu_coca('LO'); + FETCH cu_coca INTO l_coca_id; + IF cu_coca%FOUND THEN + FOR i IN 1..l_loop_counter LOOP + -- + -- check for long day + IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 25 THEN + l_message := wsgl.msggettext(p_msgno => NULL + ,p_dflttext => caco_utilities.get_module_text(3935) + ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); + -- + g_error_message := display_message( p_type => WSGL.MESS_ERROR + , p_mess => l_message + ); + EXIT; + END IF; + END LOOP; + END IF; + CLOSE cu_coca; + -- + -- check for short day category + OPEN cu_coca('SH'); + FETCH cu_coca INTO l_coca_id; + IF cu_coca%FOUND THEN + FOR i IN 1..l_loop_counter LOOP + -- + -- check for short day + IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 23 THEN + l_message := wsgl.msggettext(p_msgno => NULL + ,p_dflttext => caco_utilities.get_module_text(3936) + ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); + -- + g_error_message := display_message( p_type => WSGL.MESS_ERROR + , p_mess => l_message + ); + EXIT; + END IF; + END LOOP; + END IF; + CLOSE cu_coca; + END IF; + -- + END IF; + -- + EXCEPTION + WHEN OTHERS THEN + -- + -- Rollback the transaction just in case... + -- + BEGIN + DBMS_TRANSACTION.ROLLBACK_SAVEPOINT(g_cont_id); + EXCEPTION + WHEN OTHERS THEN + NULL; + END; + -- + g_error_message := display_message(p_type => WSGL.MESS_ERROR + ,p_mess => NVL(l_message + ,caco_utilities.get_module_text(p_text_number => 2330 ) + ) + ); + -- + cout_err.report_and_go(p_exception_number => sqlcode + ,p_exception_message => g_error_point||' : '||sqlerrm + ); + -- + END; + -- + -- release lock on nominations table + -- + l_noms_release := dbms_lock.release(id => 128); + caco_debug.putline('default_values DBMS_LOCK id 128 release value l_noms_release is ' || + l_noms_release); + END IF; + -- + -- Now verified, let us rebuild the screen + -- + redisplay ( p_contract => g_cont_num + ); + -- + END IF; -- security check + -- + END submit_nomination; + -- + PROCEDURE startup IS + BEGIN + -- + -- Startup the screen with the contract for the target date + -- + -- nom_header( p_contract => g_cont_num ); + --caco_debug.putline('-----startup'); + -- + nom_header( p_contract => NULL ); + -- + END startup; + -- + FUNCTION get_exception_message( p_exception_number IN NUMBER ) RETURN VARCHAR2 IS + -- + l_return VARCHAR2(1000); + l_type VARCHAR2(1000); + -- + BEGIN + -- + caco_utilities.get_exception_message(p_exception_number => p_exception_number + ,p_message => l_return + ,p_exme_type => l_type + ); + -- + RETURN l_return; + -- + END get_exception_message; + -- + /** + -- 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 + -- + -- Initialisation + -- + --caco_debug.putline('-----Initialisation'); + -- + gc_no_data_found := get_exception_message(-20521); + gc_missing_details := get_exception_message(-20516); + gc_invalid_file_format := get_exception_message(-20517); + gc_no_cont_found := get_exception_message(-20518); + gc_nom_id_null := get_exception_message(-20519); + gc_dup_nom_identifier := get_exception_message(-20520); + -- + g_day_at_start_of_week := cout_system_configuration.get_configuration_item('G_DAY_AT_START_OF_WEEK'); + -- + IF g_cust_id IS NULL THEN + -- + g_cust_id := caco_utilities.get_cust_id; + -- + END IF; + -- + IF g_cust_id IS NOT NULL THEN + -- + get_cont_id ( p_contract_number => g_cont_num + , p_cust_id => g_cust_id ); + -- + IF in_a_renom_window(p_gas_day => g_gas_day + ,p_window_time => g_active_time) THEN + -- + -- In a renomination window + -- + g_target_date := g_gas_day; + -- + ELSE + -- + -- Not in renom window, default to gasday + offset + -- + g_target_date := g_gas_day + NVL(cout_system_configuration.get_configuration_item('G_NOM_DATE_OFFSET'),1); + -- + END IF; + -- + g_target_date := GREATEST(g_target_date, g_cont_start_date); + g_target_date_end := g_target_date; + -- +/*caco_debug.putline('g_target_date: '||to_char(g_target_date,g_date_format)); +caco_debug.putline('g_gas_day: '||to_char(g_gas_day,g_date_format)); +caco_debug.putline('g_cust_id: '||g_cust_id); +caco_debug.putline('g_cont_start_date: '||to_char(g_cont_start_date,g_date_format));*/ + -- + END IF; + -- +END efnow098$; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$.bdy new file mode 100644 index 0000000..f3727c2 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$.bdy @@ -0,0 +1,460 @@ +create or replace package body efnow101$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +PROCEDURE get_nomi ( p_nomi_id IN nominations.nomi_id%TYPE ) IS + +-- get_nomi +-- +-- + + + +BEGIN + -- + IF NOT caco_security.security_check('efnow101$') THEN + -- + RETURN; + -- + END IF; + -- + FOR nomi_rec IN ( SELECT NULL + FROM nominations nomi + ,contracts cont + WHERE nomi.nomi_id = p_nomi_id + AND nomi.cont_id = cont.cont_id + AND cont.cust_id = caco_utilities.get_cust_id + ) LOOP + -- + amfr_excel.download(p_nomi_id => p_nomi_id); + -- + EXIT; + -- + END LOOP; + -- +END; +PROCEDURE nomi_css IS + +-- nomi_css +-- +-- + + + +BEGIN + -- + IF NOT caco_security.security_check('efnow101$') THEN + -- + RETURN; + -- + END IF; + -- + htp.p(' + h2 { + color : #FF3030; + } + + .nomiTR { + height : 20px; + } + + #nomiTextDiv { + width : 95%; + white-space : pre; + overflow-x : scroll; + border : 1px solid; + margin-left : 5px; + margin-right : 5px; + padding : 5px; + } + '); + -- +END; +PROCEDURE view_details(p_nomi_id IN nominations.nomi_id%TYPE) IS + +-- view_details +-- +-- + + + + -- + CURSOR c_nomi IS + SELECT cust.name customer_name + ,cont.contract_number contract_number + ,nomi.identifier nomi_identifier + ,conf.CONFIRMATION_SENT AS tsa_timestamp + ,nomi.nomi_id + FROM nominations nomi, + contracts cont, + customers cust, + confirmations conf + WHERE cust.cust_id = cont.cust_id + AND cont.cont_id = nomi.cont_id + AND nomi.nomi_id = p_nomi_id + AND nomi.nomi_id = conf.nomi_id + AND conf.confirmation_type = 'NO'; + -- + l_nomi_rec c_nomi%ROWTYPE; + -- + l_nomi_text_clob CLOB; + l_nomi_text_temp VARCHAR2(4000); + l_text_pos NUMBER := 1; + l_text_length NUMBER := 0; + -- + l_success BOOLEAN := TRUE; + -- +BEGIN + -- + IF NOT caco_security.security_check('efnow101$') THEN + -- + RETURN; + -- + END IF; + -- + htp.p(' '); + -- + wsgl.openpagehead(caco_utilities.get_module_text(2405)); + --wsgl.metatag; + --htp.p(''); + caco_system.content_type; + htp.p(''); + htp.p(' '); + -- + wsgl.closepagehead; + wsgl.openpagebody(FALSE); + htp.p(caco_system.menu); + -- + htp.p(' +

+
+

' || caco_utilities.get_module_text(2405) || '

'); -- View Nominations + -- + OPEN c_nomi; + FETCH c_nomi + INTO l_nomi_rec; + CLOSE c_nomi; + -- + htp.p(' + + + '); -- Customer Name + htp.p(' + + + '); -- Contract Number + htp.p(' + + + '); -- Nomination Identifier + htp.p(' + + + '); -- Created On + htp.p(' + +
' || caco_utilities.get_module_text(1145) || + ':  ' || l_nomi_rec.customer_name || + '
' || caco_utilities.get_module_text(2013) || + ':  ' || l_nomi_rec.contract_number || + '
' || caco_utilities.get_module_text(2060) || + ':  ' || l_nomi_rec.nomi_identifier || + '
' || caco_utilities.get_module_text(118) || + ':  ' || + EFNOW101$NOMI.FORMATDATETIME(TO_CHAR(l_nomi_rec.tsa_timestamp,'DD/MM/YYYY HH24:MI')) || + '
'); + -- + -- We want a button to call the spreadsheet download routine + -- + htp.p('
'); + -- + htp.p('

' || caco_utilities.get_module_text(2065) || '

'); -- Confirmation Text + -- + -- Loop through all of the clob and display it in chunks...... + -- Create a width limmited dive for putting it in + htp.p('
');
+    --
+    -- Get the CLOB
+    BEGIN
+      SELECT conf.confirmation_text
+      INTO   l_nomi_text_clob
+      FROM   confirmations conf
+      WHERE  conf.nomi_id = p_nomi_id
+      AND    conf.confirmation_type = 'NO';
+    EXCEPTION
+      WHEN OTHERS THEN
+        l_success := FALSE;
+    END;
+    --
+    IF l_success THEN
+      -- Get the length of the Confirmation text CLOB
+      l_text_length := DBMS_LOB.GETLENGTH(l_nomi_text_clob);
+      --
+      -- Loop through the clob in chunks of 4000
+      WHILE l_text_pos <= l_text_length LOOP
+        --
+        l_nomi_text_temp := DBMS_LOB.SUBSTR(l_nomi_text_clob,
+                                            4000,
+                                            l_text_pos);
+        --
+        htp.p(l_nomi_text_temp);
+        --
+        l_text_pos := l_text_pos + 4000;
+        --
+      END LOOP;
+      --
+    ELSE
+      --
+      -- Error
+      wsgl.displaymessage(p_type => WSGL.MESS_ERROR
+                         ,p_mess => caco_utilities.get_module_text(2330)
+                         );
+      --
+    END IF;
+    -- Close nomiText
+    htp.p('
'); + -- + -- Close the margin div + htp.p('
'); + -- + -- Close centrecontent div + htp.p('
'); + -- + -- Close outer div + htp.p(''); + -- + wsgl.closepagebody; + -- + END; +-------------------------------------------------------------------------------- +-- Name: efnow101$.Startup +-- +-- Description: This procedure is the entry point for the 'efnow101$' +-- module. +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('efnow101$') then + return; + end if; + + WSGL.RegisterURL('efnow101$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, WSGL.MsgGetText(21,WSGLM.CAP021_TOP_LEVEL)); + efnow101$nomi.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow101$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow101$.firstpage +-- +-- Description: This procedure creates the first page for the 'efnow101$' +-- module. +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('efnow101$') then + return; + end if; + + WSGL.OpenPageHead(''); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'efnow101$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow101$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow101$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'efnow101$' module. +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('efnow101$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('efnow101$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + + htp.para; + htp.p(' +$Revision: 1.5 $'); + htp.para; + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Nominations', 'EFNOW101', l_usr); + + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow101$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow101$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('efnow101$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow101$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow101$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'efnow101$' module. +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'efnow101$' + , pFirstTitle => '' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow101$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow101$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$.spc new file mode 100644 index 0000000..656f53e --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$.spc @@ -0,0 +1,20 @@ +create or replace package efnow101$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; +PROCEDURE get_nomi ( p_nomi_id IN nominations.nomi_id%TYPE ); + +PROCEDURE nomi_css; + +PROCEDURE view_details(p_nomi_id IN nominations.nomi_id%TYPE); + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$js$nomi.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$js$nomi.bdy new file mode 100644 index 0000000..db12796 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$js$nomi.bdy @@ -0,0 +1,122 @@ +create or replace package body efnow101$js$nomi is + + +-------------------------------------------------------------------------------- +-- Name: efnow101$js$nomi.CreateQueryJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateQueryJavaScript ( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Query";'); + + + + WSGJSL.Output_Invoke_CAL_JS ('efnow101$nomi', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('L_CONT_CONTRACT_NUMBER','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + index = -1; + modeStr = "Q"; +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl, index, modeStr, "efnow101$nomi.l_cont_contract_number_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('NOMI','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnQFQ','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + QF_BODY_ATTRIBUTES, 'efnow101$js$nomi.CreateQueryJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$js$nomi.CreateListJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateListJavaScript ( + RL_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "List";'); + + + htp.p( 'var P_12 = new Array();' ); + + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + RL_BODY_ATTRIBUTES, 'efnow101$js$nomi.CreateListJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$js$nomi.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$js$nomi.spc new file mode 100644 index 0000000..1a3895e --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$js$nomi.spc @@ -0,0 +1,11 @@ +create or replace package efnow101$js$nomi is + + procedure CreateQueryJavaScript( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2); + + procedure CreateListJavaScript( + RL_BODY_ATTRIBUTES in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$nomi.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$nomi.bdy new file mode 100644 index 0000000..7ea6189 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$nomi.bdy @@ -0,0 +1,1644 @@ +create or replace package body efnow101$nomi is + + function L_CONT_CONTRACT_NUMBER_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + function BuildSQL( + P_UI_CONTRACT_STATUS in varchar2 default null, + P_L_CONT_CONTRACT_NUMBER in varchar2 default null, + P_STATUS in varchar2 default null, + P_UI_START_DATE_QRY in varchar2 default null, + P_UI_END_DATE_QRY in varchar2 default null, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function PreQuery( + P_UI_CONTRACT_STATUS in varchar2 default null, + P_L_CONT_CONTRACT_NUMBER in varchar2 default null, + P_STATUS in varchar2 default null, + P_UI_START_DATE_QRY in varchar2 default null, + P_UI_END_DATE_QRY in varchar2 default null) return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; +-- define_globals +-- +-- + +g_ui_start_date_qry DATE; +g_ui_end_date_qry DATE; +g_ui_contract_status VARCHAR2(100); + + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + QF_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(3,WSGLM.CAP003_QF_FIND); + QF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(4,WSGLM.CAP004_QF_CLEAR); + QF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + QF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + QF_NUMBER_OF_COLUMNS constant number(4) := 1; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + RL_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + RL_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + RL_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + RL_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + RL_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + RL_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(24,WSGLM.CAP024_RL_QUERY); + RL_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + RL_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + RL_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + RL_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + RL_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + RL_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + RL_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + RL_RECORD_SET_SIZE constant number(4) := 0; + RL_TOTAL_COUNT_REQD constant boolean := FALSE; + RL_NUMBER_OF_COLUMNS constant number(4) := 1; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + type FORM_REC is record + (UI_CONTRACT_STATUS varchar2(32760) + ,L_CONT_CONTRACT_NUMBER varchar2(180) + ,IDENTIFIER varchar2(180) + ,UI_START_DATE varchar2(24000) + ,UI_END_DATE varchar2(24000) + ,UI_TIMESTAMP varchar2(24000) + ,STATUS varchar2(48) + ,UI_URL varchar2(24000) + ,UI_START_DATE_DATE varchar2(40) + ,UI_START_DATE_QRY varchar2(40) + ,UI_END_DATE_QRY varchar2(40) + ,CONT_ID varchar2(40) + ,NOMI_ID varchar2(40) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_UI_CONTRACT_STATUS WSGOC.ITEM_REF; + R_L_CONT_CONTRACT_NUMBER WSGOC.ITEM_REF; + R_IDENTIFIER WSGOC.ITEM_REF; + R_UI_START_DATE WSGOC.ITEM_REF; + R_UI_END_DATE WSGOC.ITEM_REF; + R_UI_TIMESTAMP WSGOC.ITEM_REF; + R_STATUS WSGOC.ITEM_REF; + R_UI_URL WSGOC.ITEM_REF; + R_UI_START_DATE_DATE WSGOC.ITEM_REF; + R_UI_START_DATE_QRY WSGOC.ITEM_REF; + R_UI_END_DATE_QRY WSGOC.ITEM_REF; + R_CONT_ID WSGOC.ITEM_REF; + R_NOMI_ID WSGOC.ITEM_REF; + + + +FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- FormatDate +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date, 'DD/MM/YYYY HH24:MI'),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDate; +FUNCTION FormatDateTime ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- FormatDateTime +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI'; + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date, 'DD/MM/YYYY HH24:MI'),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDateTime; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'NOMI' module component (#View Nominations#2405#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery( + P_UI_CONTRACT_STATUS in varchar2, + P_L_CONT_CONTRACT_NUMBER in varchar2, + P_STATUS in varchar2, + P_UI_START_DATE_QRY in varchar2, + P_UI_END_DATE_QRY in varchar2) return boolean is + L_RET_VAL boolean := TRUE; + begin +-- PQ_set_globals +-- +-- + +BEGIN + g_ui_start_date_qry := TO_DATE(P_UI_START_DATE_QRY,cout_system_configuration.get_configuration_item('G_DATE_FORMAT')); + g_ui_end_date_qry := TO_DATE(P_UI_END_DATE_QRY,cout_system_configuration.get_configuration_item('G_DATE_FORMAT')); + g_ui_contract_status := p_ui_contract_status; +END; + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.PreQuery'); + return FALSE; + end; +FUNCTION get_contract_status RETURN VARCHAR2 IS + +-- get_contract_status +-- +-- + + + +BEGIN + RETURN g_ui_contract_status; +END; +FUNCTION get_end_date RETURN DATE IS + +-- get_end_date +-- +-- + + + +BEGIN + RETURN g_ui_end_date_qry; +END; +FUNCTION get_latest_cont RETURN contracts.contract_number%TYPE IS + +-- get_latest_cont +-- +-- + + + + CURSOR cur_cont IS + SELECT contract_number + FROM contracts + WHERE cust_id = caco_utilities.get_cust_id + ORDER BY valid_from desc; + l_ret contracts.contract_number%TYPE; +BEGIN + -- + OPEN cur_cont; + FETCH cur_cont INTO l_ret; + CLOSE cur_cont; + -- + RETURN l_ret; + -- +END; +FUNCTION get_start_date RETURN DATE IS + +-- get_start_date +-- +-- + + + +BEGIN + RETURN g_ui_start_date_qry; +END; +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.L_CONT_CONTRACT_NUMBER_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'L_CONT_CONTRACT_NUMBER'. +-- +-- +-------------------------------------------------------------------------------- + function L_CONT_CONTRACT_NUMBER_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT DISTINCT L_CONT.CONTRACT_NUMBER L_CONT_CONTRACT_NUMBER, +-- SELECT L_CONT.CONTRACT_NUMBER L_CONT_CONTRACT_NUMBER, + L_CONT.CONTRACT_NUMBER CG$DISPLAY,L_CONT.VALID_FROM +FROM CONTRACTS L_CONT, + CUSTOMERS L_CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START NOMI.L_CUST */ + (L_CUST.CUST_ID=caco_utilities.get_cust_id and L_CONT.status = DECODE(NVL(efnow101$nomi.get_contract_status,'A'),'A',L_CONT.status,efnow101$nomi.get_contract_status)) + /* CG$MDTU_QWC_END NOMI.L_CUST */ + ) + ) + OR + ( NOT Z_MODE='Q') + ) AND + L_CONT.CUST_ID = L_CUST.CUST_ID AND + L_CONT.CONTRACT_NUMBER <> NVL(get_latest_cont,-1) +--ORDER BY L_CONT.CONTRACT_NUMBER +ORDER BY L_CONT.VALID_FROM DESC +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return L_CONT_CONTRACT_NUMBER_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return L_CONT_CONTRACT_NUMBER_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return L_CONT_CONTRACT_NUMBER_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return L_CONT_CONTRACT_NUMBER_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return L_CONT_CONTRACT_NUMBER_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_L_CONT_CONTRACT_NUMBER', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_L_CONT_CONTRACT_NUMBER'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_L_CONT_CONTRACT_NUMBER', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_L_CONT_CONTRACT_NUMBER'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(get_latest_cont, 'SELECTED'); + --L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + -- Add NULL option + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(''), null, + cattributes=>'VALUE="'||WSGL.EscapeItem('')||'"'); + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.L_CONT_CONTRACT_NUMBER) = P_VALUE) or c1rec.L_CONT_CONTRACT_NUMBER = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_CONT_CONTRACT_NUMBER)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_CONT_CONTRACT_NUMBER)||'"'); + end if; + l_first := false; + end loop; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.L_CONT_CONTRACT_NUMBER_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.InitialiseDomain +-- +-- Description: Initialises the Domain Record for the given Column Usage +-- +-- Parameters: P_ALIAS The alias of the column usage +-- +-------------------------------------------------------------------------------- + procedure InitialiseDomain(P_ALIAS in varchar2) is + begin + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + if P_ALIAS = 'UI_CONTRACT_STATUS' and not D_UI_CONTRACT_STATUS.Initialised then + D_UI_CONTRACT_STATUS.ColAlias := 'UI_CONTRACT_STATUS'; + D_UI_CONTRACT_STATUS.ControlType := WSGL.DV_LIST; + D_UI_CONTRACT_STATUS.DispWidth := 20; + D_UI_CONTRACT_STATUS.DispHeight := 1; + D_UI_CONTRACT_STATUS.MaxWidth := 32760; + D_UI_CONTRACT_STATUS.UseMeanings := True; + D_UI_CONTRACT_STATUS.ColOptional := False; + D_UI_CONTRACT_STATUS.Vals(1) := 'O'; + D_UI_CONTRACT_STATUS.Meanings(1) := 'Open'; + D_UI_CONTRACT_STATUS.Abbreviations(1) := 'O'; + D_UI_CONTRACT_STATUS.Vals(2) := 'C'; + D_UI_CONTRACT_STATUS.Meanings(2) := 'Closed'; + D_UI_CONTRACT_STATUS.Abbreviations(2) := 'C'; + D_UI_CONTRACT_STATUS.Vals(3) := 'A'; + D_UI_CONTRACT_STATUS.Meanings(3) := 'All'; + D_UI_CONTRACT_STATUS.Abbreviations(3) := 'A'; + D_UI_CONTRACT_STATUS.NumOfVV := 3; + D_UI_CONTRACT_STATUS.Initialised := True; + end if; + + if P_ALIAS = 'STATUS' and not D_STATUS.Initialised then + D_STATUS.ColAlias := 'STATUS'; + D_STATUS.ControlType := WSGL.DV_LIST; + D_STATUS.DispWidth := 8; + D_STATUS.DispHeight := 1; + D_STATUS.MaxWidth := 8; + D_STATUS.UseMeanings := True; + D_STATUS.ColOptional := False; + WSGL.LoadDomainValues('CG_REF_CODES', 'STATUS', D_STATUS); + D_STATUS.Initialised := True; + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.InitialseDomain'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow101$nomi.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), + CAL_BODY_ATTRIBUTES, + 'efnow101$nomi', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow101$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow101$nomi', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow101$nomi.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.Startup +-- +-- Description: Entry point for the 'NOMI' module +-- component (#View Nominations#2405#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + WSGL.RegisterURL('efnow101$nomi.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, '#View Nominations#2405#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'QUERY' then + FormQuery( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + if Z_FORM = 'LIST' then + QueryList( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + FormQuery( + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.ActionQuery +-- +-- Description: Called when a Query form is subitted to action the query request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionQuery( + P_UI_CONTRACT_STATUS in varchar2, + P_L_CONT_CONTRACT_NUMBER in varchar2, + P_STATUS in varchar2, + P_UI_START_DATE_QRY in varchar2, + P_UI_END_DATE_QRY in varchar2, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2, + Z_CHK in varchar2 ) is + + L_CHK varchar2(10) := Z_CHK; + L_BUTCHK varchar2(100):= null; + l_dummy_bool boolean := false; + begin + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + end if; + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + QueryList( + P_UI_CONTRACT_STATUS, + P_L_CONT_CONTRACT_NUMBER, + P_STATUS, + P_UI_START_DATE_QRY, + P_UI_END_DATE_QRY, + Z_START=>null, + Z_ACTION=>L_BUTCHK, + Z_DIRECT_CALL=>TRUE); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.ActionQuery'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits( + P_UI_CONTRACT_STATUS in varchar2, + P_L_CONT_CONTRACT_NUMBER in varchar2, + P_STATUS in varchar2, + P_UI_START_DATE_QRY in varchar2, + P_UI_END_DATE_QRY in varchar2) return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow101$nomi') then + return -1; + end if; + + if not BuildSQL(P_UI_CONTRACT_STATUS, + P_L_CONT_CONTRACT_NUMBER, + P_STATUS, + P_UI_START_DATE_QRY, + P_UI_END_DATE_QRY) then + return -1; + end if; + + if not PreQuery(P_UI_CONTRACT_STATUS, + P_L_CONT_CONTRACT_NUMBER, + P_STATUS, + P_UI_START_DATE_QRY, + P_UI_END_DATE_QRY) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#View Nominations#2405#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.BuildSQL +-- +-- Description: Builds the SQL for the 'NOMI' module component (#View Nominations#2405#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + P_UI_CONTRACT_STATUS in varchar2, + P_L_CONT_CONTRACT_NUMBER in varchar2, + P_STATUS in varchar2, + P_UI_START_DATE_QRY in varchar2, + P_UI_END_DATE_QRY in varchar2, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + InitialiseDomain('UI_CONTRACT_STATUS'); + InitialiseDomain('STATUS'); + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE NOMI_ID = ' || to_char(CURR_VAL.NOMI_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + WSGL.BuildWhere(P_L_CONT_CONTRACT_NUMBER, 'L_CONT_CONTRACT_NUMBER', WSGL.TYPE_CHAR, I_WHERE); + WSGL.BuildWhere(WSGL.DomainValue(D_STATUS, P_STATUS), 'STATUS', WSGL.TYPE_CHAR, I_WHERE); + + end if; + + ZONE_SQL := 'SELECT L_CONT_CONTRACT_NUMBER, + IDENTIFIER, + UI_START_DATE, + UI_END_DATE, + UI_TIMESTAMP, + STATUS, + UI_URL, + UI_START_DATE_DATE, + CONT_ID, + NOMI_ID + FROM ( SELECT L_CONT.CONTRACT_NUMBER L_CONT_CONTRACT_NUMBER, + NOMI.IDENTIFIER IDENTIFIER, + (SELECT EFNOW101$NOMI.FORMATDATE(TO_CHAR(MIN(nnpcv.gas_day),''DD/MM/YYYY HH24:MI'')) FROM nom_net_point_cat_vals nnpcv WHERE nnpcv.nomi_id = NOMI.NOMI_ID) UI_START_DATE, + (SELECT EFNOW101$NOMI.FORMATDATE(TO_CHAR(MAX(nnpcv.gas_day),''DD/MM/YYYY HH24:MI'')) FROM nom_net_point_cat_vals nnpcv WHERE nnpcv.nomi_id = NOMI.NOMI_ID) UI_END_DATE, + (SELECT EFNOW101$NOMI.FORMATDATETIME(TO_CHAR(MAX(conf.CONFIRMATION_SENT),''DD/MM/YYYY HH24:MI'')) FROM confirmations conf WHERE conf.nomi_id = NOMI.NOMI_ID AND conf.confirmation_type = ''NO'') UI_TIMESTAMP, + NOMI.STATUS STATUS, + ''efnow101$.view_details?p_nomi_id=''||NOMI.NOMI_ID UI_URL, + (SELECT MIN(nnpcv.gas_day) FROM nom_net_point_cat_vals nnpcv WHERE nnpcv.nomi_id = NOMI.NOMI_ID) UI_START_DATE_DATE, + NOMI.CONT_ID CONT_ID, + NOMI.NOMI_ID NOMI_ID +FROM NOMINATIONS NOMI, + CONTRACTS L_CONT, + CUSTOMERS L_CUST +WHERE ( /* CG$MDTU_QWC_START NOMI.NOMI */ + (NOMI.NOMI_ID IN (SELECT nnpcv.nomi_id FROM nom_net_point_cat_vals nnpcv WHERE (nnpcv.gas_day BETWEEN efnow101$nomi.get_start_date AND efnow101$nomi.get_end_date) OR (nnpcv.gas_day >= efnow101$nomi.get_start_date AND efnow101$nomi.get_end_date IS NULL) OR (nnpcv.gas_day <= efnow101$nomi.get_end_date AND efnow101$nomi.get_start_date IS NULL) OR (efnow101$nomi.get_start_date IS NULL AND efnow101$nomi.get_end_date IS NULL)) AND EXISTS (SELECT 1 FROM contracts cont WHERE cont.cont_id = NOMI.CONT_ID AND cont.status = DECODE(NVL(efnow101$nomi.get_contract_status,''A''),''A'',cont.status,efnow101$nomi.get_contract_status))) + /* CG$MDTU_QWC_END NOMI.NOMI */ + ) AND + NOMI.CONT_ID = L_CONT.CONT_ID AND + ( /* CG$MDTU_QWC_START NOMI.L_CUST */ + (L_CUST.CUST_ID=caco_utilities.get_cust_id and L_CONT.status = DECODE(NVL(efnow101$nomi.get_contract_status,''A''),''A'',L_CONT.status,efnow101$nomi.get_contract_status)) + /* CG$MDTU_QWC_END NOMI.L_CUST */ + ) AND + L_CONT.CUST_ID = L_CUST.CUST_ID + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY UI_START_DATE_DATE Desc , + UI_TIMESTAMP Desc , + IDENTIFIER'; + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'NOMI' module component (#View Nominations#2405#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, NBT_VAL.L_CONT_CONTRACT_NUMBER, 30); + dbms_sql.define_column(I_CURSOR, 2, CURR_VAL.IDENTIFIER, 30); + dbms_sql.define_column(I_CURSOR, 3, NBT_VAL.UI_START_DATE, 4000); + dbms_sql.define_column(I_CURSOR, 4, NBT_VAL.UI_END_DATE, 4000); + dbms_sql.define_column(I_CURSOR, 5, NBT_VAL.UI_TIMESTAMP, 4000); + dbms_sql.define_column(I_CURSOR, 6, CURR_VAL.STATUS, 1); + dbms_sql.define_column(I_CURSOR, 7, NBT_VAL.UI_URL, 4000); + dbms_sql.define_column(I_CURSOR, 8, NBT_VAL.UI_START_DATE_DATE); + dbms_sql.define_column(I_CURSOR, 9, CURR_VAL.CONT_ID); + dbms_sql.define_column(I_CURSOR, 10, CURR_VAL.NOMI_ID); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + '', 'efnow101$nomi.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'NOMI' module component (#View Nominations#2405#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, NBT_VAL.L_CONT_CONTRACT_NUMBER); + dbms_sql.column_value(I_CURSOR, 2, CURR_VAL.IDENTIFIER); + dbms_sql.column_value(I_CURSOR, 3, NBT_VAL.UI_START_DATE); + dbms_sql.column_value(I_CURSOR, 4, NBT_VAL.UI_END_DATE); + dbms_sql.column_value(I_CURSOR, 5, NBT_VAL.UI_TIMESTAMP); + dbms_sql.column_value(I_CURSOR, 6, CURR_VAL.STATUS); + dbms_sql.column_value(I_CURSOR, 7, NBT_VAL.UI_URL); + dbms_sql.column_value(I_CURSOR, 8, NBT_VAL.UI_START_DATE_DATE); + dbms_sql.column_value(I_CURSOR, 9, CURR_VAL.CONT_ID); + dbms_sql.column_value(I_CURSOR, 10, CURR_VAL.NOMI_ID); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.NOMI_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + '', 'efnow101$nomi.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.FormQuery +-- +-- Description: This procedure builds an HTML form for entry of query criteria. +-- The criteria entered are to restrict the query of the 'NOMI' +-- module component (#View Nominations#2405#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormQuery( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + L_SUCCESS boolean := TRUE; + begin + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + end if; + + L_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + WSGL.OpenPageHead(''||' : '||'#View Nominations#2405#'); + WSGL.METATag; + efnow101$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>QF_BODY_ATTRIBUTES || 'onLoad="return NOMI_OnLoad()"'); + efnow101$js$nomi.CreateQueryJavaScript(LOV_FRAME,QF_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + htp.p(caco_system.menu); + efnow101$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + htp.p(WSGL.MsgGetText(116,WSGLM.DSP116_ENTER_QRY_CAPTION,'#View Nominations#2405#')); + htp.para; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow101$nomi.actionquery', cattributes => 'NAME="efnow101$nomi$QForm"'); + + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + for i in 1..QF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(25, 'LEFT', NULL); + WSGL.LayoutHeader(30, 'LEFT', NULL); + end loop; + WSGL.LayoutRowEnd; + + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Contract Status#3977#:')); + InitialiseDomain('UI_CONTRACT_STATUS'); + WSGL.LayoutData(WSGL.BuildDVControl(D_UI_CONTRACT_STATUS, WSGL.CTL_QUERY)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Contract Number#2013#:')); + WSGL.LayoutData(L_CONT_CONTRACT_NUMBER_LOV(NULL, WSGL.CTL_QUERY, 'Q', true)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Nomination Status#3978#:')); + InitialiseDomain('STATUS'); + WSGL.LayoutData(WSGL.BuildDVControl(D_STATUS, WSGL.CTL_QUERY)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Start Date#2489#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('UI_START_DATE_QRY', '11', FALSE, p_maxlength=>'40' + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_date_format => 'DD-MON-RRRR' + , p_cal_prompt => '#Start Date#2489#' + , p_form=>'efnow101$nomi$QForm')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#End Date#2490#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('UI_END_DATE_QRY', '11', FALSE, p_maxlength=>'40' + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_date_format => 'DD-MON-RRRR' + , p_cal_prompt => '#End Date#2490#' + , p_form=>'efnow101$nomi$QForm')); + WSGL.LayoutRowEnd; + + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', htf.escape_sc(QF_QUERY_BUT_CAPTION), 'btnQFQ', 'this.form.Z_ACTION.value=\''' || QF_QUERY_BUT_ACTION || '\'''); + htp.formReset(htf.escape_sc(QF_CLEAR_BUT_CAPTION), 'ID="'||htf.escape_sc(QF_CLEAR_BUT_CAPTION)||'"'); + + + WSGL.HiddenField('Z_CHK', to_char(WSGL.Checksum + (''))); + htp.formClose; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + QF_BODY_ATTRIBUTES, 'efnow101$nomi.FormQuery'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.QueryList +-- +-- Description: This procedure builds the Record list for the 'NOMI' +-- module component (#View Nominations#2405#). +-- +-- The Record List displays context information for records which +-- match the specified query criteria. +-- Sets of records are displayed (0 records at a time) +-- with Next/Previous buttons to get other record sets. +-- +-- Parameters: P_UI_CONTRACT_STATUS - #Contract Status#3977# +-- P_L_CONT_CONTRACT_NUMBER - #Contract Number#2013# +-- P_STATUS - #Nomination Status#3978# +-- P_UI_START_DATE_QRY - #Start Date#2489# +-- P_UI_END_DATE_QRY - #End Date#2490# +-- Z_START - First record to display +-- Z_ACTION - Next or Previous set +-- +-------------------------------------------------------------------------------- + procedure QueryList( + P_UI_CONTRACT_STATUS in varchar2, + P_L_CONT_CONTRACT_NUMBER in varchar2, + P_STATUS in varchar2, + P_UI_START_DATE_QRY in varchar2, + P_UI_END_DATE_QRY in varchar2, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2 ) is + + I_VF_FRAME varchar2(20) := null; + I_WHERE varchar2(2000) := ''; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + I_TOTAL_ROWS integer := 0; + I_START number(38) := to_number(Z_START); + I_COUNT number(10) := 0; + I_OF_TOTAL_TEXT varchar2(200) := ''; + I_NEXT_BUT boolean; + I_PREV_BUT boolean; + I_COL_COUNT integer; + I_SUCCESS boolean := true; + l_row integer := 0; + l_id varchar2(35) := null; + -- Reset break group? + RSIG1 boolean := true; + -- Reset break group? + RSIG2 boolean := true; + I_LAST_BASE CURR_VAL%TYPE; + I_LAST_NBT NBT_REC; + + + + begin + + if not caco_security.security_check('efnow101$nomi') then + return; + end if; + + + WSGL.RegisterURL('efnow101$nomi.querylist'); + WSGL.AddURLParam('P_UI_CONTRACT_STATUS', P_UI_CONTRACT_STATUS); + WSGL.AddURLParam('P_L_CONT_CONTRACT_NUMBER', P_L_CONT_CONTRACT_NUMBER); + WSGL.AddURLParam('P_STATUS', P_STATUS); + WSGL.AddURLParam('P_UI_START_DATE_QRY', P_UI_START_DATE_QRY); + WSGL.AddURLParam('P_UI_END_DATE_QRY', P_UI_END_DATE_QRY); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if (not Z_DIRECT_CALL) then + + null; + + + end if; + if (Z_ACTION = RL_QUERY_BUT_ACTION) or (Z_ACTION = RL_QUERY_BUT_CAPTION) then + FormQuery( + Z_DIRECT_CALL=>TRUE); + return; + end if; + + -- Set up any master context values that may be required + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + + + WSGL.OpenPageHead(''||' : '||'#View Nominations#2405#'); + WSGL.METATag; + efnow101$.TemplateHeader(TRUE,6); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>RL_BODY_ATTRIBUTES); + efnow101$js$nomi.CreateListJavaScript(RL_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) or + (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + (RL_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_UI_CONTRACT_STATUS, + P_L_CONT_CONTRACT_NUMBER, + P_STATUS, + P_UI_START_DATE_QRY, + P_UI_END_DATE_QRY); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + RL_TOTAL_COUNT_REQD then + I_OF_TOTAL_TEXT := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + I_START := 1; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + + if ZONE_SQL IS NULL then + if not BuildSQL( + P_UI_CONTRACT_STATUS, + P_L_CONT_CONTRACT_NUMBER, + P_STATUS, + P_UI_START_DATE_QRY, + P_UI_END_DATE_QRY) then + WSGL.ClosePageBody; + return; + end if; + end if; + + if not PreQuery( + P_UI_CONTRACT_STATUS, + P_L_CONT_CONTRACT_NUMBER, + P_STATUS, + P_UI_START_DATE_QRY, + P_UI_END_DATE_QRY) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#View Nominations#2405#', RL_BODY_ATTRIBUTES); + return; + end if; + + InitialiseDomain('STATUS'); + + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := 0; + end if; + I_TOTAL_ROWS := I_ROWS_FETCHED; + + if I_ROWS_FETCHED != 0 then + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, P_BORDER=>TRUE); + + WSGL.LayoutRowStart(p_attrs=>'class = cgrlheaderrow'); + for i in 1..RL_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(30, 'LEFT', '#Contract Number#2013#','CONTRACT_NUMBER'); + WSGL.LayoutHeader(30, 'LEFT', '#Nomination Identifier#2060#','IDENTIFIER'); + WSGL.LayoutHeader(30, 'LEFT', '#Start Date#2489#',''); + WSGL.LayoutHeader(30, 'LEFT', '#End Date#2490#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Timestamp#1152#',''); + WSGL.LayoutHeader(8, 'LEFT', '#Nomination Status#3978#','STATUS'); + WSGL.LayoutHeader(30, 'LEFT', '#View#2062#',''); + end loop; + WSGL.LayoutRowEnd; + + while I_ROWS_FETCHED <> 0 loop + + if I_TOTAL_ROWS >= I_START then + AssignZoneRow(I_CURSOR); + + if (NBT_VAL.UI_CONTRACT_STATUS != I_LAST_NBT.UI_CONTRACT_STATUS or (NBT_VAL.UI_CONTRACT_STATUS is null and I_LAST_NBT.UI_CONTRACT_STATUS is not null) or (NBT_VAL.UI_CONTRACT_STATUS is not null and I_LAST_NBT.UI_CONTRACT_STATUS is null) ) or + (NBT_VAL.L_CONT_CONTRACT_NUMBER != I_LAST_NBT.L_CONT_CONTRACT_NUMBER or (NBT_VAL.L_CONT_CONTRACT_NUMBER is null and I_LAST_NBT.L_CONT_CONTRACT_NUMBER is not null) or (NBT_VAL.L_CONT_CONTRACT_NUMBER is not null and I_LAST_NBT.L_CONT_CONTRACT_NUMBER is null) ) then + RSIG1 := true; + else + RSIG1 := false; + end if; + if (NBT_VAL.UI_START_DATE_QRY != I_LAST_NBT.UI_START_DATE_QRY or (NBT_VAL.UI_START_DATE_QRY is null and I_LAST_NBT.UI_START_DATE_QRY is not null) or (NBT_VAL.UI_START_DATE_QRY is not null and I_LAST_NBT.UI_START_DATE_QRY is null) ) or + (NBT_VAL.UI_END_DATE_QRY != I_LAST_NBT.UI_END_DATE_QRY or (NBT_VAL.UI_END_DATE_QRY is null and I_LAST_NBT.UI_END_DATE_QRY is not null) or (NBT_VAL.UI_END_DATE_QRY is not null and I_LAST_NBT.UI_END_DATE_QRY is null) ) or + (CURR_VAL.CONT_ID != I_LAST_BASE.CONT_ID or (CURR_VAL.CONT_ID is null and I_LAST_BASE.CONT_ID is not null) or (CURR_VAL.CONT_ID is not null and I_LAST_BASE.CONT_ID is null) ) or + (CURR_VAL.NOMI_ID != I_LAST_BASE.NOMI_ID or (CURR_VAL.NOMI_ID is null and I_LAST_BASE.NOMI_ID is not null) or (CURR_VAL.NOMI_ID is not null and I_LAST_BASE.NOMI_ID is null) ) or + (CURR_VAL.IDENTIFIER != I_LAST_BASE.IDENTIFIER or (CURR_VAL.IDENTIFIER is null and I_LAST_BASE.IDENTIFIER is not null) or (CURR_VAL.IDENTIFIER is not null and I_LAST_BASE.IDENTIFIER is null) ) or + (NBT_VAL.UI_START_DATE != I_LAST_NBT.UI_START_DATE or (NBT_VAL.UI_START_DATE is null and I_LAST_NBT.UI_START_DATE is not null) or (NBT_VAL.UI_START_DATE is not null and I_LAST_NBT.UI_START_DATE is null) ) or + (NBT_VAL.UI_END_DATE != I_LAST_NBT.UI_END_DATE or (NBT_VAL.UI_END_DATE is null and I_LAST_NBT.UI_END_DATE is not null) or (NBT_VAL.UI_END_DATE is not null and I_LAST_NBT.UI_END_DATE is null) ) or + (NBT_VAL.UI_TIMESTAMP != I_LAST_NBT.UI_TIMESTAMP or (NBT_VAL.UI_TIMESTAMP is null and I_LAST_NBT.UI_TIMESTAMP is not null) or (NBT_VAL.UI_TIMESTAMP is not null and I_LAST_NBT.UI_TIMESTAMP is null) ) or + (CURR_VAL.STATUS != I_LAST_BASE.STATUS or (CURR_VAL.STATUS is null and I_LAST_BASE.STATUS is not null) or (CURR_VAL.STATUS is not null and I_LAST_BASE.STATUS is null) ) or + (NBT_VAL.UI_URL != I_LAST_NBT.UI_URL or (NBT_VAL.UI_URL is null and I_LAST_NBT.UI_URL is not null) or (NBT_VAL.UI_URL is not null and I_LAST_NBT.UI_URL is null) ) or + (NBT_VAL.UI_START_DATE_DATE != I_LAST_NBT.UI_START_DATE_DATE or (NBT_VAL.UI_START_DATE_DATE is null and I_LAST_NBT.UI_START_DATE_DATE is not null) or (NBT_VAL.UI_START_DATE_DATE is not null and I_LAST_NBT.UI_START_DATE_DATE is null) ) then + RSIG2 := true; + else + RSIG2 := false; + end if; + if RSIG1 then + RSIG2 := true; + end if; + + + I_LAST_NBT.UI_CONTRACT_STATUS := NBT_VAL.UI_CONTRACT_STATUS; + I_LAST_NBT.L_CONT_CONTRACT_NUMBER := NBT_VAL.L_CONT_CONTRACT_NUMBER; + I_LAST_NBT.UI_START_DATE_QRY := NBT_VAL.UI_START_DATE_QRY; + I_LAST_NBT.UI_END_DATE_QRY := NBT_VAL.UI_END_DATE_QRY; + I_LAST_BASE.CONT_ID := CURR_VAL.CONT_ID; + I_LAST_BASE.NOMI_ID := CURR_VAL.NOMI_ID; + I_LAST_BASE.IDENTIFIER := CURR_VAL.IDENTIFIER; + I_LAST_NBT.UI_START_DATE := NBT_VAL.UI_START_DATE; + I_LAST_NBT.UI_END_DATE := NBT_VAL.UI_END_DATE; + I_LAST_NBT.UI_TIMESTAMP := NBT_VAL.UI_TIMESTAMP; + I_LAST_BASE.STATUS := CURR_VAL.STATUS; + I_LAST_NBT.UI_URL := NBT_VAL.UI_URL; + I_LAST_NBT.UI_START_DATE_DATE := NBT_VAL.UI_START_DATE_DATE; + l_row := l_row + 1; + + + WSGL.LayoutRowStart('TOP', p_attrs=>'class = cgrldatarow'); + l_id := 'CONTRACT_NUMBER' || l_row; + if RSIG1 and NBT_VAL.L_CONT_CONTRACT_NUMBER is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.L_CONT_CONTRACT_NUMBER), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := 'IDENTIFIER' || l_row; + if RSIG2 and CURR_VAL.IDENTIFIER is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(CURR_VAL.IDENTIFIER), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG2 and NBT_VAL.UI_START_DATE is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_START_DATE), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG2 and NBT_VAL.UI_END_DATE is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_END_DATE), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG2 and NBT_VAL.UI_TIMESTAMP is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_TIMESTAMP), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := 'STATUS' || l_row; + if RSIG2 and CURR_VAL.STATUS is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSIG2 and NBT_VAL.UI_URL is not null then + WSGL.LayoutData(p_text=>replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_URL), '#View#2062#'), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + + WSGL.LayoutRowEnd; + + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + end if; + + I_TOTAL_ROWS := I_TOTAL_ROWS + I_ROWS_FETCHED; + + end loop; + + WSGL.LayoutClose; + + if I_START = I_TOTAL_ROWS then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_TOTAL_ROWS))||I_OF_TOTAL_TEXT); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(I_TOTAL_ROWS))|| + I_OF_TOTAL_TEXT); + end if; + htp.para; + else + htp.p(WSGL.MsgGetText(112,WSGLM.DSP112_NO_RECORDS)); + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + dbms_sql.close_cursor(I_CURSOR); + end if; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow101$nomi.querylist', cattributes => 'NAME="efnow101$nomi$LForm"'); + SaveState; + WSGL.HiddenField('P_UI_CONTRACT_STATUS', P_UI_CONTRACT_STATUS); + WSGL.HiddenField('P_L_CONT_CONTRACT_NUMBER', P_L_CONT_CONTRACT_NUMBER); + WSGL.HiddenField('P_STATUS', P_STATUS); + WSGL.HiddenField('P_UI_START_DATE_QRY', P_UI_START_DATE_QRY); + WSGL.HiddenField('P_UI_END_DATE_QRY', P_UI_END_DATE_QRY); + WSGL.HiddenField('Z_START', to_char(I_START)); + htp.p (''); + + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_FIRST_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_FIRST_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_PREV_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_PREV_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_NEXT_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_NEXT_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_LAST_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_LAST_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_REQUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_REQUERY_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_COUNT_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_COUNT_BUT_ACTION || '\''"'); + htp.para; + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_QUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_QUERY_BUT_ACTION || '\''"'); + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''))); + htp.formClose; + + WSGL.ReturnLinks('0.1', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + RL_BODY_ATTRIBUTES, 'efnow101$nomi.QueryList'); + WSGL.ClosePageBody; + end; +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'NOMI' module component (#View Nominations#2405#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.NOMI_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + '', 'efnow101$nomi.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.SaveState +-- +-- Description: Saves the data state for the 'NOMI' module component (#View Nominations#2405#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + '', 'efnow101$nomi.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.LoadCache +-- +-- Description: Populate the object cache with +-- 'NOMI' module component (#View Nominations#2405#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + InitialiseDomain('UI_CONTRACT_STATUS'); + InitialiseDomain('STATUS'); + + ref_Component := WSGOC.Component + ( pModule => efnow101$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'NOMI' + , pTitle => '#View Nominations#2405#' + , pSystemImagePath=> '/images/' + ); + + r_UI_CONTRACT_STATUS := WSGOC.Item + ( pName => 'UI_CONTRACT_STATUS' + , pPrompt => '#Contract Status#3977#' + ); + r_L_CONT_CONTRACT_NUMBER := WSGOC.Item + ( pName => 'L_CONT_CONTRACT_NUMBER' + , pPrompt => '#Contract Number#2013#' + , pIsContext=> true + ); + r_IDENTIFIER := WSGOC.Item + ( pName => 'IDENTIFIER' + , pPrompt => '#Nomination Identifier#2060#' + , pIsContext=> true + ); + r_UI_START_DATE := WSGOC.Item + ( pName => 'UI_START_DATE' + , pPrompt => '#Start Date#2489#' + , pIsContext=> true + ); + r_UI_END_DATE := WSGOC.Item + ( pName => 'UI_END_DATE' + , pPrompt => '#End Date#2490#' + , pIsContext=> true + ); + r_UI_TIMESTAMP := WSGOC.Item + ( pName => 'UI_TIMESTAMP' + , pPrompt => '#Timestamp#1152#' + , pIsContext=> true + ); + r_STATUS := WSGOC.Item + ( pName => 'STATUS' + , pPrompt => '#Nomination Status#3978#' + , pIsContext=> true + ); + r_UI_URL := WSGOC.Item + ( pName => 'UI_URL' + , pPrompt => '#View#2062#' + , pIsContext=> true + ); + r_UI_START_DATE_DATE := WSGOC.Item + ( pName => 'UI_START_DATE_DATE' + , pPrompt => '' + ); + r_UI_START_DATE_QRY := WSGOC.Item + ( pName => 'UI_START_DATE_QRY' + , pPrompt => '#Start Date#2489#' + ); + r_UI_END_DATE_QRY := WSGOC.Item + ( pName => 'UI_END_DATE_QRY' + , pPrompt => '#End Date#2490#' + ); + r_CONT_ID := WSGOC.Item + ( pName => 'CONT_ID' + , pPrompt => '#Cont Id#2443#' + ); + r_NOMI_ID := WSGOC.Item + ( pName => 'NOMI_ID' + , pPrompt => '#Nomi Id#2481#' + ); + + WSGOC.Add_Items(ref_Component, r_UI_CONTRACT_STATUS); + WSGOC.Add_Items(ref_Component, r_L_CONT_CONTRACT_NUMBER); + WSGOC.Add_Items(ref_Component, r_IDENTIFIER); + WSGOC.Add_Items(ref_Component, r_UI_START_DATE); + WSGOC.Add_Items(ref_Component, r_UI_END_DATE); + WSGOC.Add_Items(ref_Component, r_UI_TIMESTAMP); + WSGOC.Add_Items(ref_Component, r_STATUS); + WSGOC.Add_Items(ref_Component, r_UI_URL); + WSGOC.Add_Items(ref_Component, r_UI_START_DATE_DATE); + WSGOC.Add_Items(ref_Component, r_UI_START_DATE_QRY); + WSGOC.Add_Items(ref_Component, r_UI_END_DATE_QRY); + WSGOC.Add_Items(ref_Component, r_CONT_ID); + WSGOC.Add_Items(ref_Component, r_NOMI_ID); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_L_CONT_CONTRACT_NUMBER, replace(WSGL.EscapeItem(NBT_VAL.L_CONT_CONTRACT_NUMBER), ' +', '
+') ); + WSGOC.Set_Value( r_IDENTIFIER, replace(WSGL.EscapeItem(CURR_VAL.IDENTIFIER), ' +', '
+') ); + WSGOC.Set_Value( r_UI_START_DATE, replace(WSGL.EscapeItem(NBT_VAL.UI_START_DATE), ' +', '
+') ); + WSGOC.Set_Value( r_UI_END_DATE, replace(WSGL.EscapeItem(NBT_VAL.UI_END_DATE), ' +', '
+') ); + WSGOC.Set_Value( r_UI_TIMESTAMP, replace(WSGL.EscapeItem(NBT_VAL.UI_TIMESTAMP), ' +', '
+') ); + WSGOC.Set_Value( r_STATUS, replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)), ' +', '
+') ); + WSGOC.Set_Value( r_UI_URL, replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_URL), '#View#2062#'), ' +', '
+') ); + WSGOC.Set_Value( r_UI_START_DATE_DATE, WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_START_DATE_DATE, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_CONT_ID, WSGL.EscapeItem(CURR_VAL.CONT_ID) ); + WSGOC.Set_Value( r_NOMI_ID, WSGL.EscapeItem(CURR_VAL.NOMI_ID) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + '', 'efnow101$nomi.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow101$nomi.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'NOMI' module component (#View Nominations#2405#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#View Nominations#2405#', + DEF_BODY_ATTRIBUTES, 'efnow101$nomi.PostQuery'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$nomi.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$nomi.spc new file mode 100644 index 0000000..2dbf3f6 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow101$nomi.spc @@ -0,0 +1,104 @@ +create or replace package efnow101$nomi is + + type NBT_REC is record + ( UI_CONTRACT_STATUS varchar2(32760) + , L_CONT_CONTRACT_NUMBER CONTRACTS.CONTRACT_NUMBER%type + , UI_START_DATE varchar2(24000) + , UI_END_DATE varchar2(24000) + , UI_TIMESTAMP varchar2(24000) + , UI_URL varchar2(24000) + , UI_START_DATE_DATE date + , UI_START_DATE_QRY date + , UI_END_DATE_QRY date + ); + + NBT_VAL NBT_REC; + CURR_VAL NOMINATIONS%rowtype; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure ActionQuery( + P_UI_CONTRACT_STATUS in varchar2 default null, + P_L_CONT_CONTRACT_NUMBER in varchar2 default null, + P_STATUS in varchar2 default null, + P_UI_START_DATE_QRY in varchar2 default null, + P_UI_END_DATE_QRY in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null ); + + procedure FormQuery( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryList( + P_UI_CONTRACT_STATUS in varchar2 default null, + P_L_CONT_CONTRACT_NUMBER in varchar2 default null, + P_STATUS in varchar2 default null, + P_UI_START_DATE_QRY in varchar2 default null, + P_UI_END_DATE_QRY in varchar2 default null, + Z_START in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null ); + function QueryHits( + P_UI_CONTRACT_STATUS in varchar2 default null, + P_L_CONT_CONTRACT_NUMBER in varchar2 default null, + P_STATUS in varchar2 default null, + P_UI_START_DATE_QRY in varchar2 default null, + P_UI_END_DATE_QRY in varchar2 default null) return number; + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + procedure InitialiseDomain(P_ALIAS in varchar2); + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + D_UI_CONTRACT_STATUS WSGL.typDVRecord; + D_STATUS WSGL.typDVRecord;FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + +FUNCTION FormatDateTime ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + +FUNCTION get_contract_status RETURN VARCHAR2; + +FUNCTION get_end_date RETURN DATE; + +FUNCTION get_latest_cont RETURN contracts.contract_number%TYPE; + +FUNCTION get_start_date RETURN DATE; + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$.bdy new file mode 100644 index 0000000..8c0177a --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$.bdy @@ -0,0 +1,232 @@ +create or replace package body efnow110$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +-------------------------------------------------------------------------------- +-- Name: efnow110$.Startup +-- +-- Description: This procedure is the entry point for the 'efnow110$' +-- module. +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('efnow110$') then + return; + end if; + + WSGL.RegisterURL('efnow110$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, WSGL.MsgGetText(21,WSGLM.CAP021_TOP_LEVEL)); + efnow110$cust.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow110$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$.firstpage +-- +-- Description: This procedure creates the first page for the 'efnow110$' +-- module. +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('efnow110$') then + return; + end if; + + WSGL.OpenPageHead(''); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'efnow110$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow110$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow110$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'efnow110$' module. +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('efnow110$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('efnow110$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' '); + + htp.para; + htp.p(' +$ Revision: %'); + htp.para; + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Nominations', 'EFNOW110', l_usr); + + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow110$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('efnow110$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow110$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'efnow110$' module. +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'efnow110$' + , pFirstTitle => '' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + '', 'efnow110$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow110$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$.spc new file mode 100644 index 0000000..254ceab --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$.spc @@ -0,0 +1,14 @@ +create or replace package efnow110$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cuin.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cuin.bdy new file mode 100644 index 0000000..62298a8 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cuin.bdy @@ -0,0 +1,2600 @@ +create or replace package body efnow110$cuin is +function PCG$LK_INS_CUIN_INTE_FK_Proces( + P_L_INTERMEDIARIES_NAME2 in varchar2, + Z_MODE in varchar2 ) return boolean; + + function L_INTERMEDIARIES_NAME2_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + procedure FormView(Z_FORM_STATUS in number, + Q_CUST_ID in varchar2 default null, + Z_POST_DML in boolean default false, + Z_MULTI_PAGE in boolean default true, + Z_ACTION in varchar2 default null, + Z_START in varchar2 default '1'); + procedure FormDelete; + function BuildSQL( + P_CUST_ID in varchar2 default null, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function Validate(Z_MODE in varchar2, Z_FORCE_UPDATE in out boolean) return boolean; + function PreInsert return boolean; + function PostInsert return boolean; + function PreDelete return boolean; + function PostDelete return boolean; + function PreQuery( + P_CUST_ID in varchar2 default null) return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + VF_UPDATE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(6,WSGLM.CAP006_VF_UPDATE); + VF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(8,WSGLM.CAP008_VF_REVERT); + VF_DELETE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(7,WSGLM.CAP007_VF_DELETE); + VF_INSERT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(23,WSGLM.CAP023_NEW); + VF_INSERT_BUT_ACTION constant varchar2(10) := 'INSERT'; + VF_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + VF_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + VF_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + VF_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + VF_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + VF_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + VF_NTOM_BUT_CAPTION constant varchar2(100) := '%s -> %e'; + VF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + VF_UPDATE_BUT_ACTION constant varchar2(10) := 'UPDATE'; + VF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + VF_DELETE_BUT_ACTION constant varchar2(10) := 'DELETE'; + VF_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + VF_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + VF_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + VF_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + VF_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + VF_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + VF_NTOM_BUT_ACTION constant varchar2(10) := 'NTOM'; + VF_VERIFIED_DELETE constant varchar2(100) := 'VerifiedDelete'; + VF_NUMBER_OF_COLUMNS constant number(4) := 2; + VF_RECORD_SET_SIZE constant number(5) := 1; + + VF_TOTAL_COUNT_REQD constant boolean := FALSE; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_INSERT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(9,WSGLM.CAP009_IF_INSERT); + IF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(10,WSGLM.CAP010_IF_CLEAR); + IF_INSERT_BUT_ACTION constant varchar2(10) := 'INSERT'; + IF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + IF_NUMBER_OF_COLUMNS constant number(4) := 2; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + RL_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + RL_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + RL_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + RL_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + RL_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + RL_INSERT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(23,WSGLM.CAP023_NEW); + RL_INSERT_BUT_ACTION constant varchar2(10) := 'INSERT'; + RL_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + RL_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + RL_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + RL_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + RL_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + RL_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + RL_RECORD_SET_SIZE constant number(4) := 10; + RL_TOTAL_COUNT_REQD constant boolean := FALSE; + RL_NUMBER_OF_COLUMNS constant number(4) := 1; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + CURR_IND CG$CUSTOMER_INTERMEDIARIES.CG$IND_TYPE; + CURR_PK CG$CUSTOMER_INTERMEDIARIES.CG$PK_TYPE; + PREV_VAL CG$CUSTOMER_INTERMEDIARIES.CG$ROW_TYPE; + PREV_IND CG$CUSTOMER_INTERMEDIARIES.CG$IND_TYPE; + NULL_VAL CG$CUSTOMER_INTERMEDIARIES.CG$ROW_TYPE; + NULL_IND CG$CUSTOMER_INTERMEDIARIES.CG$IND_TYPE; + + type FORM_REC is record + (L_INTERMEDIARIES_NAME2 varchar2(600) + ,CUST_ID varchar2(40) + ,INTE_ID varchar2(40) + ,CREATED_BY varchar2(40) + ,CREATED_ON varchar2(12) + ,UPDATED_BY varchar2(40) + ,UPDATED_ON varchar2(12) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + type IF_FORMARRAY is table of FORM_REC index by binary_integer; + IF_FORM_ERRORS IF_FORMARRAY; + IF_ROWS_INSERTED integer := 0; + IF_ROWS_ERROR integer := 0; + VF_ROWS_UPDATED integer := 0; + VF_ROWS_DELETED integer := 0; + VF_ROWS_ERROR integer := 0; + type CTX_REC is record + ( L_INTERMEDIARIES_NAME2 varchar2(600) + ); + type CTX_REC_ARR is table of CTX_REC index by binary_integer; + VF_DELETED_ROWS CTX_REC_ARR; + type ROW_REC is record + ( F_L_INTERMEDIARIES_NAME2 varchar2(600) + , F_CUST_ID varchar2(40) + , F_INTE_ID varchar2(40) + , F_CREATED_BY varchar2(40) + , F_CREATED_ON varchar2(12) + , F_UPDATED_BY varchar2(40) + , F_UPDATED_ON varchar2(12) + , SUCCESS_FLAG boolean + , ROW_DELETED boolean + , ROW_NOT_LOCKED boolean + , ROW_ID rowid + ); + type ROW_SET_TYPE is table of ROW_REC index by binary_integer; + VF_ROW_SET ROW_SET_TYPE; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_L_INTERMEDIARIES_NAME2 WSGOC.ITEM_REF; + R_CUST_ID WSGOC.ITEM_REF; + R_INTE_ID WSGOC.ITEM_REF; + R_CREATED_BY WSGOC.ITEM_REF; + R_CREATED_ON WSGOC.ITEM_REF; + R_UPDATED_BY WSGOC.ITEM_REF; + R_UPDATED_ON WSGOC.ITEM_REF; + + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.L_INTERMEDIARIES_NAME2_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'L_INTERMEDIARIES_NAME2'. +-- +-- +-------------------------------------------------------------------------------- + function L_INTERMEDIARIES_NAME2_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT DISTINCT L_INTE.NAME L_INTERMEDIARIES_NAME2, + L_INTE.NAME CG$DISPLAY +FROM INTERMEDIARIES L_INTE +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START CUIN.L_INTE */ + ((EXISTS (SELECT 1 FROM customer_intermediaries cuin1, customers cust1, customer_types cuty WHERE l_inte.inte_id = cuin1.inte_id AND cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND cuty.code = caco_utilities.cuty_code_for_user) OR caco_utilities.user_has_system = 'Y') and L_INTE.inte_id <> cout_system_configuration.get_configuration_item('INTE_ID')) + /* CG$MDTU_QWC_END CUIN.L_INTE */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START CUIN.L_INTE */ + ((EXISTS (SELECT 1 FROM customer_intermediaries cuin1, customers cust1, customer_types cuty WHERE l_inte.inte_id = cuin1.inte_id AND cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND cuty.code = caco_utilities.cuty_code_for_user) OR caco_utilities.user_has_system = 'Y') and L_INTE.inte_id <> cout_system_configuration.get_configuration_item('INTE_ID')) + /* CG$MDTU_VWC_END CUIN.L_INTE */ + ) + ) + ) +ORDER BY L_INTE.NAME +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return L_INTERMEDIARIES_NAME2_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return L_INTERMEDIARIES_NAME2_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return L_INTERMEDIARIES_NAME2_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return L_INTERMEDIARIES_NAME2_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return L_INTERMEDIARIES_NAME2_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_L_INTERMEDIARIES_NAME2', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_L_INTERMEDIARIES_NAME2'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_L_INTERMEDIARIES_NAME2', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_L_INTERMEDIARIES_NAME2'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.L_INTERMEDIARIES_NAME2) = P_VALUE) or c1rec.L_INTERMEDIARIES_NAME2 = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_INTERMEDIARIES_NAME2)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CG$DISPLAY), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.L_INTERMEDIARIES_NAME2)||'"'); + end if; + l_first := false; + end loop; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + DEF_BODY_ATTRIBUTES, 'efnow110$cuin.L_INTERMEDIARIES_NAME2_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PCG$LK_INS_CUIN_INTE_FK_Proces +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- +function PCG$LK_INS_CUIN_INTE_FK_Proces( + P_L_INTERMEDIARIES_NAME2 in varchar2, + Z_MODE in varchar2 ) return boolean +is + anyRows boolean := false; + cursor c1 is +SELECT L_INTE.INTE_ID INTE_ID, + L_INTE.NAME L_INTERMEDIARIES_NAME2 +FROM INTERMEDIARIES L_INTE +WHERE ( /* CG$MDTU_VWC_START CUIN.L_INTE */ + ((EXISTS (SELECT 1 FROM customer_intermediaries cuin1, customers cust1, customer_types cuty WHERE l_inte.inte_id = cuin1.inte_id AND cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND cuty.code = caco_utilities.cuty_code_for_user) OR caco_utilities.user_has_system = 'Y') and L_INTE.inte_id <> cout_system_configuration.get_configuration_item('INTE_ID')) + /* CG$MDTU_VWC_END CUIN.L_INTE */ + ) AND + + L_INTE.NAME = NBT_VAL.L_INTERMEDIARIES_NAME2 +; +begin + NBT_VAL.L_INTERMEDIARIES_NAME2 := P_L_INTERMEDIARIES_NAME2; + for c1rec in c1 loop + if (not anyRows) then + anyRows := true; + CURR_VAL.INTE_ID := c1rec.INTE_ID; + NBT_VAL.L_INTERMEDIARIES_NAME2 := c1rec.L_INTERMEDIARIES_NAME2; + else + exit; + end if; + end loop; + + if (not anyRows) then + cg$errors.push('Name: '|| + WSGL.MsgGetText(226,WSGLM.MSG226_INVALID_FK), + 'E', 'WSG', SQLCODE, 'efnow110$cuin.PCG$LK_INS_CUIN_INTE_FK_Proces'); + return false; + else + return true; + end if; + +exception + when others then + cg$errors.push(SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cuin.PCG$LK_INS_CUIN_INTE_FK_Proces'); + return FALSE; +end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow110$cuin.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), + CAL_BODY_ATTRIBUTES, + 'efnow110$cuin', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow110$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow110$cuin', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow110$cuin.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.Validate +-- +-- Description: Provides validation of the 'CUIN' module component +-- (#Intermediaries#1059#). +-- +-- Parameters: Z_MODE Ins(ert) or Upd(ate) +-- Z_FORCE_UPDATE Set this to TRUE within this event to force +-- Pre and Post-Update triggers to fire even if +-- no base item values have changed. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function Validate(Z_MODE in varchar2, Z_FORCE_UPDATE in out boolean) return boolean is + L_ERROR_MESS varchar2(1000); + L_RET_VAL boolean := TRUE; + begin + + + + -- Validation for CG$LK_INS_CUIN_INTE_FK + if Z_MODE = 'INS' then + if PCG$LK_INS_CUIN_INTE_FK_Proces( + P_L_INTERMEDIARIES_NAME2=>FORM_VAL.L_INTERMEDIARIES_NAME2, + Z_MODE=>'D') then + CURR_IND.INTE_ID := TRUE; + null; + else + L_RET_VAL := FALSE; + return L_RET_VAL; + end if; + end if; + + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.Validate'); + return FALSE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.Startup +-- +-- Description: Entry point for the 'CUIN' module +-- component (#Intermediaries#1059#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + P_CUST_ID in varchar2, + P_2 in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + WSGL.RegisterURL('efnow110$cuin.startup'); + WSGL.AddURLParam('P_CUST_ID', P_CUST_ID); + WSGL.AddURLParam('P_2',P_2); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + WSGL.StoreURLLink(2, '#Intermediaries#1059#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'LIST' then + QueryList( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + if Z_FORM = 'INSERT' then + FormInsert( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + QueryList( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + DEF_BODY_ATTRIBUTES, 'efnow110$cuin.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits( + P_CUST_ID in varchar2) return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow110$cuin') then + return -1; + end if; + + if not BuildSQL(P_CUST_ID) then + return -1; + end if; + + if not PreQuery(P_CUST_ID) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + DEF_BODY_ATTRIBUTES, 'efnow110$cuin.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.BuildSQL +-- +-- Description: Builds the SQL for the 'CUIN' module component (#Intermediaries#1059#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + P_CUST_ID in varchar2, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE CUST_ID = ' || to_char(CURR_VAL.CUST_ID) || ' AND INTE_ID = ' || to_char(CURR_VAL.INTE_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + begin + WSGL.BuildWhere(P_CUST_ID, 'CUST_ID', WSGL.TYPE_NUMBER, I_WHERE); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_ERROR_QRY, SQLERRM, + ''||' : '||'#Intermediaries#1059#', DEF_BODY_ATTRIBUTES, NULL, + WSGL.MsgGetText(210,WSGLM.MSG210_INVALID_QRY,'#Cust Id#1065#')); + return false; + end; + + end if; + + ZONE_SQL := 'SELECT L_INTERMEDIARIES_NAME2, + CUST_ID, + INTE_ID, + CREATED_BY, + CREATED_ON, + UPDATED_BY, + UPDATED_ON + FROM ( SELECT L_INTE.NAME L_INTERMEDIARIES_NAME2, + CUIN.CUST_ID CUST_ID, + CUIN.INTE_ID INTE_ID, + CUIN.CREATED_BY CREATED_BY, + CUIN.CREATED_ON CREATED_ON, + CUIN.UPDATED_BY UPDATED_BY, + CUIN.UPDATED_ON UPDATED_ON +FROM CUSTOMER_INTERMEDIARIES CUIN, + INTERMEDIARIES L_INTE +WHERE ( /* CG$MDTU_QWC_START CUIN.L_INTE */ + ((EXISTS (SELECT 1 FROM customer_intermediaries cuin1, customers cust1, customer_types cuty WHERE l_inte.inte_id = cuin1.inte_id AND cust1.cust_id = cuin1.cust_id AND cust1.cuty_id = cuty.cuty_id AND cuty.code = caco_utilities.cuty_code_for_user) OR caco_utilities.user_has_system = ''Y'') and L_INTE.inte_id <> cout_system_configuration.get_configuration_item(''INTE_ID'')) + /* CG$MDTU_QWC_END CUIN.L_INTE */ + ) AND + CUIN.INTE_ID = L_INTE.INTE_ID + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY 1'; + + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + DEF_BODY_ATTRIBUTES, 'efnow110$cuin.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, NBT_VAL.L_INTERMEDIARIES_NAME2, 100); + dbms_sql.define_column(I_CURSOR, 2, CURR_VAL.CUST_ID); + dbms_sql.define_column(I_CURSOR, 3, CURR_VAL.INTE_ID); + dbms_sql.define_column(I_CURSOR, 4, CURR_VAL.CREATED_BY); + dbms_sql.define_column(I_CURSOR, 5, CURR_VAL.CREATED_ON); + dbms_sql.define_column(I_CURSOR, 6, CURR_VAL.UPDATED_BY); + dbms_sql.define_column(I_CURSOR, 7, CURR_VAL.UPDATED_ON); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + '', 'efnow110$cuin.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, NBT_VAL.L_INTERMEDIARIES_NAME2); + dbms_sql.column_value(I_CURSOR, 2, CURR_VAL.CUST_ID); + dbms_sql.column_value(I_CURSOR, 3, CURR_VAL.INTE_ID); + dbms_sql.column_value(I_CURSOR, 4, CURR_VAL.CREATED_BY); + dbms_sql.column_value(I_CURSOR, 5, CURR_VAL.CREATED_ON); + dbms_sql.column_value(I_CURSOR, 6, CURR_VAL.UPDATED_BY); + dbms_sql.column_value(I_CURSOR, 7, CURR_VAL.UPDATED_ON); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.CUST_ID + || CURR_VAL.INTE_ID + || to_char(efnow110$cust.CURR_VAL.CUST_ID) + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + '', 'efnow110$cuin.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.FormView +-- +-- Description: This procedure builds an HTML form for view/update of fields in +-- the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: Z_FORM_STATUS Status of the form +-- +-------------------------------------------------------------------------------- + procedure FormView(Z_FORM_STATUS in number, + Q_CUST_ID in varchar2, + Z_POST_DML in boolean, + Z_MULTI_PAGE in boolean, + Z_ACTION in varchar2, + Z_START in varchar2) is + + I_COUNT integer; + l_row integer := 0; + l_rowset_row integer := null; + l_error varchar2(2000); + l_rows_ret integer; + l_row_deleted boolean := false; + l_row_no_lock boolean := false; + l_total_rows integer := 0; + I_START number(38) := to_number(Z_START); + I_PREV_BUT boolean := false; + I_NEXT_BUT boolean := false; + l_total_text varchar2(200) := ''; + l_ntom_butstr varchar2(2000) := VF_NTOM_BUT_CAPTION; + l_force_upd boolean := false; + l_success boolean := true; + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + l_success := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => true + ); + if not l_success and Z_FORM_STATUS != WSGL.FORM_STATUS_UPD then + -- No rows returned from the query. Manually raise an exception to handle this and + -- display the correct message. + raise NO_DATA_FOUND; + end if; + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => true + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + + WSGL.OpenPageHead(''||' : '||'#Intermediaries#1059#'); + WSGL.METATag; + htp.script('FormType = "Update";'); + efnow110$.TemplateHeader(TRUE,4); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>VF_BODY_ATTRIBUTES || 'onLoad="return CUIN_OnLoad()"'); + + efnow110$js$cuin.CreateViewJavaScript( + VF_ROWS_UPDATED, + VF_ROWS_DELETED, + VF_ROWS_ERROR, + VF_BODY_ATTRIBUTES, + IF_ROWS_INSERTED, + IF_ROWS_ERROR, + RL_REQUERY_BUT_ACTION, + LOV_FRAME + ); + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + + + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="VF$AIFormTop"'); + htp.formClose; + + + htp.para; + htp.p(htf.header(2,''||WSGL.EscapeItem(NBT_VAL.L_INTERMEDIARIES_NAME2)||'')); + + if Z_FORM_STATUS = WSGL.FORM_STATUS_ERROR then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + htp.script('DataChangeErrors = true;'); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_UPD then + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(207, WSGLM.MSG207_ROW_UPDATED), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + htp.script('DataChange = true;'); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_INS then + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(208, WSGLM.MSG208_ROW_INSERTED), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_NO_UPD then + htp.p( ''||WSGL.MsgGetText(136,WSGLM.DSP136_NO_ROW_UPDATED)||'
' ); + end if; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cuin.actionview', cattributes => 'NAME="efnow110$cuin$VForm"'); + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + + WSGL.LayoutRowStart; + WSGL.LayoutHeader(40, 'LEFT', htf.bold('Name')); + WSGL.LayoutRowEnd; + if Z_MULTI_PAGE then + if (Z_ACTION = VF_LAST_BUT_ACTION) or (Z_ACTION = VF_LAST_BUT_CAPTION) or + (Z_ACTION = VF_COUNT_BUT_ACTION) or (Z_ACTION = VF_COUNT_BUT_CAPTION) or + (VF_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_CUST_ID=>Q_CUST_ID); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = VF_COUNT_BUT_ACTION) or (Z_ACTION = VF_COUNT_BUT_CAPTION) or (VF_TOTAL_COUNT_REQD) then + l_total_text := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + + if Z_START IS NULL or (Z_ACTION = VF_FIRST_BUT_ACTION) or (Z_ACTION = VF_FIRST_BUT_CAPTION) then + I_START := 1; + elsif (Z_ACTION = VF_NEXT_BUT_ACTION) or (Z_ACTION = VF_NEXT_BUT_CAPTION) then + I_START := I_START + VF_RECORD_SET_SIZE; + elsif (Z_ACTION = VF_PREV_BUT_ACTION) or (Z_ACTION = VF_PREV_BUT_CAPTION) then + I_START := I_START - VF_RECORD_SET_SIZE; + elsif (Z_ACTION = VF_LAST_BUT_ACTION) or (Z_ACTION = VF_LAST_BUT_CAPTION) then + I_START := 1 + (floor((I_COUNT-1)/VF_RECORD_SET_SIZE)*VF_RECORD_SET_SIZE); + end if; + + if I_START < 1 then + I_START := 1; + end if; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + end if; + l_total_rows := 1; + l_row := 1; + while true loop + FORM_VAL.L_INTERMEDIARIES_NAME2 := WSGL.EscapeItem(NBT_VAL.L_INTERMEDIARIES_NAME2); + FORM_VAL.CUST_ID := WSGL.EscapeItem(CURR_VAL.CUST_ID); + FORM_VAL.INTE_ID := WSGL.EscapeItem(CURR_VAL.INTE_ID); + FORM_VAL.CREATED_BY := WSGL.EscapeItem(CURR_VAL.CREATED_BY); + FORM_VAL.CREATED_ON := WSGL.EscapeItem(ltrim(to_char(CURR_VAL.CREATED_ON, 'DD-MON-RRRR'))); + FORM_VAL.UPDATED_BY := WSGL.EscapeItem(CURR_VAL.UPDATED_BY); + FORM_VAL.UPDATED_ON := WSGL.EscapeItem(ltrim(to_char(CURR_VAL.UPDATED_ON, 'DD-MON-RRRR'))); + + l_force_upd := false; + if not PostQuery(Z_POST_DML, l_force_upd) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + end if; + if not l_row_deleted then + WSGL.HiddenField('P_CUST_ID', CURR_VAL.CUST_ID); + WSGL.HiddenField('P_INTE_ID', CURR_VAL.INTE_ID); + WSGL.HiddenField('O_CUST_ID', CURR_VAL.CUST_ID); + WSGL.HiddenField('O_INTE_ID', CURR_VAL.INTE_ID); + end if; + WSGL.HiddenField('H_L_INTERMEDIARIES_NAME2', NBT_VAL.L_INTERMEDIARIES_NAME2); + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(FORM_VAL.L_INTERMEDIARIES_NAME2); + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + + + + + if not (l_row_deleted) then + htp.p(WSGJSL.OpenScript); + if l_force_upd then + htp.p('document.write('''');'); + else + htp.p('document.write('''');'); + end if; + htp.p(WSGJSL.CloseScript); + WSGL.HiddenField('O_CREATED_BY', CURR_VAL.CREATED_BY); + WSGL.HiddenField('O_CREATED_ON', to_char(CURR_VAL.CREATED_ON,'JSSSSS')); + WSGL.HiddenField('O_UPDATED_BY', CURR_VAL.UPDATED_BY); + WSGL.HiddenField('O_UPDATED_ON', to_char(CURR_VAL.UPDATED_ON,'JSSSSS')); + + end if; + + exit; + end loop; + WSGL.LayoutClose; + + if l_row < 3 then + WSGL.HiddenField('P_CUST_ID',''); + WSGL.HiddenField('P_INTE_ID',''); + WSGL.HiddenField('O_CREATED_BY', ''); + WSGL.HiddenField('O_CREATED_ON', ''); + WSGL.HiddenField('O_UPDATED_BY', ''); + WSGL.HiddenField('O_UPDATED_ON', ''); + WSGL.HiddenField('H_L_INTERMEDIARIES_NAME2',''); + WSGL.HiddenField('z_modified','dummy_row'); + end if; + + + if l_rows_ret > 0 then + I_NEXT_BUT := true; + end if; + + if l_total_rows = 0 then + htp.p(WSGL.MsgGetText(112, WSGLM.DSP112_NO_RECORDS)); + htp.para; + elsif Z_MULTI_PAGE then + if I_START = l_total_rows or VF_RECORD_SET_SIZE = 1 then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_START))||l_total_text); + else + if I_NEXT_BUT then + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(l_total_rows - 1))||l_total_text); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(l_total_rows))||l_total_text); + end if; + end if; + htp.para; + end if; + + WSGL.SubmitButton('Z_ACTION', VF_DELETE_BUT_CAPTION, 'btnVFD', 'this.form.Z_ACTION.value=\''' || VF_DELETE_BUT_ACTION || '\'''); + + WSGL.SubmitButton('Z_ACTION', VF_INSERT_BUT_CAPTION, 'btnVFI', 'this.form.Z_ACTION.value=\''' || VF_INSERT_BUT_ACTION || '\'''); + if Z_MULTI_PAGE and VF_ROW_SET.count = 0 then + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', VF_FIRST_BUT_CAPTION, WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_FIRST_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', VF_PREV_BUT_CAPTION, WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_PREV_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', VF_NEXT_BUT_CAPTION, WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_NEXT_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', VF_LAST_BUT_CAPTION, WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_LAST_BUT_ACTION || '\'', true)"', + p_type_button=>true); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', VF_REQUERY_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_REQUERY_BUT_ACTION || '\'', true)"', + p_type_button=>true); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', VF_COUNT_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_COUNT_BUT_ACTION || '\'', true)"', + p_type_button=>true); + end if; + + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''||CURR_VAL.CUST_ID||CURR_VAL.INTE_ID||to_char(efnow110$cust.CURR_VAL.CUST_ID)))); + + WSGL.HiddenField('Q_CUST_ID', Q_CUST_ID); + + WSGL.HiddenField('Z_START', to_char(I_START)); + + htp.formClose; + + + WSGL.ReturnLinks('0.1.2', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when NO_DATA_FOUND then + if Z_FORM_STATUS = WSGL.FORM_STATUS_ERROR or Z_FORM_STATUS = WSGL.FORM_STATUS_OK then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(204, WSGLM.MSG204_ROW_DELETED), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + else + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(235, WSGLM.MSG235_ROW_REQUERY_FAILURE), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + end if; + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.FormView'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.QueryView +-- +-- Description: Queries the details of a single row in preparation for display. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryView( + K_CUST_ID in varchar2, + K_INTE_ID in varchar2, + P_2 in varchar2, + P_CUST_ID in varchar2, + Z_EXECUTE_QUERY in varchar2, + Z_POST_DML in boolean, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_CHK in varchar2) is + L_ROW_ID ROWID; + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + + + WSGL.RegisterURL('efnow110$cuin.queryview'); + WSGL.AddURLParam('K_CUST_ID', K_CUST_ID); + WSGL.AddURLParam('K_INTE_ID', K_INTE_ID); + WSGL.AddURLParam('P_2', P_2); + WSGL.AddURLParam('P_CUST_ID', P_CUST_ID); + WSGL.AddURLParam('Z_EXECUTE_QUERY', Z_EXECUTE_QUERY); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + if not Z_DIRECT_CALL then + + null; + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + + end if; + + + + + null; + + + + if K_CUST_ID is not null then + CURR_VAL.CUST_ID := K_CUST_ID; + end if; + if K_INTE_ID is not null then + CURR_VAL.INTE_ID := K_INTE_ID; + end if; + if (Z_ACTION = VF_INSERT_BUT_ACTION) or (Z_ACTION = VF_INSERT_BUT_CAPTION) then + FormInsert( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + if Z_EXECUTE_QUERY is null then + if VF_ROW_SET.count = 0 then + if BuildSQL( Z_QUERY_BY_KEY=>true) then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Q_CUST_ID=>P_CUST_ID, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>false, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + else + if BuildSQL( z_bind_row_id=>true ) then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Q_CUST_ID=>P_CUST_ID, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>false, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + end if; + + else + if not PreQuery( + P_CUST_ID=>P_CUST_ID) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + return; + end if; + + if BuildSQL + (P_CUST_ID=>P_CUST_ID + ) + then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Q_CUST_ID=>P_CUST_ID, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>true, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + + end if; + + exception + when NO_DATA_FOUND then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(204, WSGLM.MSG204_ROW_DELETED), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.QueryView'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.QueryViewByKey +-- +-- Description: Queries the details of a single row in preparation for display. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryViewByKey( + P_CUST_ID in varchar2, + P_INTE_ID in varchar2, + P_2 in varchar2, + Z_POST_DML in boolean, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is +begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + QueryView( + K_CUST_ID=>P_CUST_ID, + K_INTE_ID=>P_INTE_ID, + P_2=>P_2, + Z_EXECUTE_QUERY=>null, + Z_POST_DML=>Z_POST_DML, + Z_FORM_STATUS=>Z_FORM_STATUS, + Z_DIRECT_CALL=>Z_DIRECT_CALL, + Z_CHK=>Z_CHK); +end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.FormInsert +-- +-- Description: This procedure builds an HTML form for insert of data in +-- the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormInsert( + P_CUST_ID in varchar2, + P_2 in varchar2, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) + is + l_row integer; + l_error varchar2(2000); + l_error_num integer := IF_ROWS_ERROR; + l_success boolean := true; + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + + end if; + + + WSGL.OpenPageHead(''||' : '||'#Intermediaries#1059#'); + WSGL.METATag; + + efnow110$.TemplateHeader(TRUE,5); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>IF_BODY_ATTRIBUTES || 'onLoad="return CUIN_OnLoad()"'); + efnow110$js$cuin.CreateInsertJavaScript( + IF_ROWS_INSERTED, + IF_ROWS_ERROR, + IF_BODY_ATTRIBUTES, + RL_REQUERY_BUT_ACTION, + LOV_FRAME + ); + l_success := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + + if Z_FORM_STATUS = WSGL.FORM_STATUS_OK then + FORM_VAL.L_INTERMEDIARIES_NAME2 := null; + FORM_VAL.CUST_ID := null; + FORM_VAL.INTE_ID := null; + FORM_VAL.CREATED_BY := null; + FORM_VAL.CREATED_ON := null; + FORM_VAL.UPDATED_BY := null; + FORM_VAL.UPDATED_ON := null; + else + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', IF_BODY_ATTRIBUTES); + end if; + + if IF_ROWS_INSERTED > 0 then + htp.p( ''||WSGL.MsgGetText(130,WSGLM.DSP130_ROWS_INSERTED)||' '||to_char(IF_ROWS_INSERTED)||'
' ); + end if; + if IF_ROWS_ERROR > 0 then + htp.p( ''||WSGL.MsgGetText(131,WSGLM.DSP131_ROWS_NOT_INSERTED)||' '||to_char(IF_ROWS_ERROR)||'
' ); + end if; + htp.p(WSGL.MsgGetText(117, WSGLM.DSP117_ENTER_NEW_ROW, '#Intermediaries#1059#')); + htp.para; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cuin.actioninsert', cattributes => 'NAME="efnow110$cuin$IForm"'); + SaveState; + + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + WSGL.LayoutHeader(40, 'LEFT', htf.bold('Name')); + WSGL.LayoutRowEnd; + for l_row in 1..IF_ROWS_ERROR + 1 loop + if l_error_num > 0 and cg$errors.pop_head( l_error ) then + WSGL.LayoutTextLine(htf.bold(''||htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + -- FORM_VAL := IF_FORM_ERRORS( l_row ); + FORM_VAL.L_INTERMEDIARIES_NAME2 := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).L_INTERMEDIARIES_NAME2); + FORM_VAL.CUST_ID := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CUST_ID); + FORM_VAL.INTE_ID := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).INTE_ID); + FORM_VAL.CREATED_BY := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CREATED_BY); + FORM_VAL.CREATED_ON := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CREATED_ON); + FORM_VAL.UPDATED_BY := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UPDATED_BY); + FORM_VAL.UPDATED_ON := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UPDATED_ON); + + l_error_num := l_error_num - 1; + else + if (l_row = IF_ROWS_ERROR + 1) and (IF_ROWS_ERROR <> 0) then + WSGL.LayoutTextLine(' '); + end if; + end if; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(L_INTERMEDIARIES_NAME2_LOV(FORM_VAL.L_INTERMEDIARIES_NAME2, null, 'D', (FORM_VAL.L_INTERMEDIARIES_NAME2 is null), p_row=>1 +)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.HiddenField('P_CUST_ID', P_CUST_ID); + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + + WSGL.HiddenField('z_modified','Y'); + end loop; + WSGL.HiddenField( 'z_modified', 'dummy_row' ); + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', IF_INSERT_BUT_CAPTION, 'btnIFI', 'this.form.Z_ACTION.value=\''' || IF_INSERT_BUT_ACTION || '\'''); + if Z_FORM_STATUS != WSGL.FORM_STATUS_ERROR then + htp.formReset(IF_CLEAR_BUT_CAPTION, 'ID="'||IF_CLEAR_BUT_CAPTION||'"'); + else + WSGL.SubmitButton('Z_ACTION', IF_CLEAR_BUT_CAPTION, 'btnIFR', 'this.form.Z_ACTION.value=\''' || IF_CLEAR_BUT_ACTION || '\'''); + end if; + + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''||P_CUST_ID||to_char(efnow110$cust.CURR_VAL.CUST_ID)))); + WSGL.HiddenField('P_L_INTERMEDIARIES_NAME2', ''); + WSGL.HiddenField('P_CUST_ID', ''); + + htp.formClose; + WSGL.ReturnLinks('0.1.2', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + IF_BODY_ATTRIBUTES, 'efnow110$cuin.FormInsert'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.FormDelete +-- +-- Description: Builds a form for confirmation of a delete request in the +-- 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure FormDelete is + I_CURSOR integer; + I_VOID integer; + l_success boolean := true; + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + + WSGL.OpenPageHead(''||' : '||'#Intermediaries#1059#'); + WSGL.METATag; + efnow110$.TemplateHeader(TRUE,4); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>VF_BODY_ATTRIBUTES); + + l_success := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => true + ); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => true + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if not BuildSQL(Z_QUERY_BY_KEY=>true)then + return; + end if; + OpenZoneSql(I_CURSOR); + + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + AssignZoneRow(I_CURSOR); + dbms_sql.close_cursor(I_CURSOR); + + htp.para; + htp.p(htf.header(2,''||NBT_VAL.L_INTERMEDIARIES_NAME2||'')); + htp.para; + htp.p(WSGL.MsgGetText(118, WSGLM.DSP118_CONFIRM_DELETE)); + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cuin.actiondelete', cattributes => 'NAME="efnow110$cuin$DForm"'); + SaveState; + WSGL.HiddenField('P_CUST_ID', CURR_VAL.CUST_ID); + WSGL.HiddenField('P_INTE_ID', CURR_VAL.INTE_ID); + WSGL.HiddenField('O_CREATED_BY', PREV_VAL.CREATED_BY); + WSGL.HiddenField('O_CREATED_ON', to_char(PREV_VAL.CREATED_ON,'JSSSSS')); + WSGL.HiddenField('O_UPDATED_BY', PREV_VAL.UPDATED_BY); + WSGL.HiddenField('O_UPDATED_ON', to_char(PREV_VAL.UPDATED_ON,'JSSSSS')); + + htp.p (''); + htp.p (''); + + if WSGL.IsSupported ('NOSCRIPT') + then + + htp.p (''); + + end if; + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''||CURR_VAL.CUST_ID||CURR_VAL.INTE_ID||to_char(efnow110$cust.CURR_VAL.CUST_ID)))); + htp.formClose; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when NO_DATA_FOUND then + WSGL.DisplayMessage(WSGL.MESS_ERROR,WSGL.MsgGetText(204, WSGLM.MSG204_ROW_DELETED), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + WSGL.ClosePageBody; + + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.FormDelete'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.QueryList +-- +-- Description: This procedure builds the Record list for the 'CUIN' +-- module component (#Intermediaries#1059#). +-- +-- The Record List displays context information for records which +-- match the specified query criteria. +-- Sets of records are displayed (10 records at a time) +-- with Next/Previous buttons to get other record sets. +-- +-- The first context column will be created as a link to the +-- efnow110$cuin.FormView procedure for display of more details +-- of that particular row. +-- +-- Parameters: P_CUST_ID - #Cust Id#1065# +-- Z_START - First record to display +-- Z_ACTION - Next or Previous set +-- +-------------------------------------------------------------------------------- + procedure QueryList( + P_CUST_ID in varchar2, + P_2 in varchar2, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2 ) is + + I_VF_FRAME varchar2(20) := null; + I_WHERE varchar2(2000) := ''; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + I_TOTAL_ROWS integer := 0; + I_START number(38) := to_number(Z_START); + I_COUNT number(10) := 0; + I_OF_TOTAL_TEXT varchar2(200) := ''; + I_NEXT_BUT boolean; + I_PREV_BUT boolean; + I_COL_COUNT integer; + I_SUCCESS boolean := true; + l_row integer := 0; + l_id varchar2(35) := null; + -- Reset break group? + RSCUIN boolean := true; + I_LAST_BASE CURR_VAL%TYPE; + I_LAST_NBT NBT_REC; + + + + begin + + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + + WSGL.RegisterURL('efnow110$cuin.querylist'); + WSGL.AddURLParam('P_CUST_ID', P_CUST_ID); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if (not Z_DIRECT_CALL) then + + null; + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + + + end if; + if (Z_ACTION = RL_INSERT_BUT_ACTION) or (Z_ACTION = RL_INSERT_BUT_CAPTION) then + FormInsert( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + -- Set up any master context values that may be required + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + + + WSGL.OpenPageHead(''||' : '||'#Intermediaries#1059#'); + WSGL.METATag; + efnow110$.TemplateHeader(TRUE,6); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>RL_BODY_ATTRIBUTES); + efnow110$js$cuin.CreateListJavaScript(RL_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) or + (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + (RL_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_CUST_ID); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + RL_TOTAL_COUNT_REQD then + I_OF_TOTAL_TEXT := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + if Z_START IS NULL or (Z_ACTION = RL_FIRST_BUT_ACTION) or (Z_ACTION = RL_FIRST_BUT_CAPTION) then + I_START := 1; + elsif (Z_ACTION = RL_NEXT_BUT_ACTION) or (Z_ACTION = RL_NEXT_BUT_CAPTION) then + I_START := I_START + RL_RECORD_SET_SIZE; + elsif (Z_ACTION = RL_PREV_BUT_ACTION) or (Z_ACTION = RL_PREV_BUT_CAPTION) then + I_START := I_START - RL_RECORD_SET_SIZE; + elsif (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) then + I_START := 1 + (floor((I_COUNT-1)/RL_RECORD_SET_SIZE)*RL_RECORD_SET_SIZE); + elsif Z_ACTION is null and I_START = 1 then + null; + elsif Z_ACTION IS NULL then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(215,WSGLM.MSG215_NO_MULTIPLE_SUBMITS), + ''||' : '||'#Intermediaries#1059#', RL_BODY_ATTRIBUTES); + WSGL.ClosePageBody; + return; + end if; + + if I_START < 1 then + I_START := 1; + end if; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + + if ZONE_SQL IS NULL then + if not BuildSQL( + P_CUST_ID) then + WSGL.ClosePageBody; + return; + end if; + end if; + + if not PreQuery( + P_CUST_ID) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', RL_BODY_ATTRIBUTES); + return; + end if; + + + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := 0; + end if; + I_TOTAL_ROWS := I_ROWS_FETCHED; + + if I_ROWS_FETCHED != 0 then + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, P_BORDER=>TRUE); + + WSGL.LayoutRowStart(p_attrs=>'class = cgrlheaderrow'); + for i in 1..RL_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(40, 'LEFT', '','NAME'); + end loop; + WSGL.LayoutRowEnd; + + while I_ROWS_FETCHED <> 0 loop + + if I_TOTAL_ROWS >= I_START then + AssignZoneRow(I_CURSOR); + + if (NBT_VAL.L_INTERMEDIARIES_NAME2 != I_LAST_NBT.L_INTERMEDIARIES_NAME2 or (NBT_VAL.L_INTERMEDIARIES_NAME2 is null and I_LAST_NBT.L_INTERMEDIARIES_NAME2 is not null) or (NBT_VAL.L_INTERMEDIARIES_NAME2 is not null and I_LAST_NBT.L_INTERMEDIARIES_NAME2 is null) ) or + (CURR_VAL.CUST_ID != I_LAST_BASE.CUST_ID or (CURR_VAL.CUST_ID is null and I_LAST_BASE.CUST_ID is not null) or (CURR_VAL.CUST_ID is not null and I_LAST_BASE.CUST_ID is null) ) or + (CURR_VAL.INTE_ID != I_LAST_BASE.INTE_ID or (CURR_VAL.INTE_ID is null and I_LAST_BASE.INTE_ID is not null) or (CURR_VAL.INTE_ID is not null and I_LAST_BASE.INTE_ID is null) ) or + (CURR_VAL.CREATED_BY != I_LAST_BASE.CREATED_BY or (CURR_VAL.CREATED_BY is null and I_LAST_BASE.CREATED_BY is not null) or (CURR_VAL.CREATED_BY is not null and I_LAST_BASE.CREATED_BY is null) ) or + (CURR_VAL.CREATED_ON != I_LAST_BASE.CREATED_ON or (CURR_VAL.CREATED_ON is null and I_LAST_BASE.CREATED_ON is not null) or (CURR_VAL.CREATED_ON is not null and I_LAST_BASE.CREATED_ON is null) ) or + (CURR_VAL.UPDATED_BY != I_LAST_BASE.UPDATED_BY or (CURR_VAL.UPDATED_BY is null and I_LAST_BASE.UPDATED_BY is not null) or (CURR_VAL.UPDATED_BY is not null and I_LAST_BASE.UPDATED_BY is null) ) or + (CURR_VAL.UPDATED_ON != I_LAST_BASE.UPDATED_ON or (CURR_VAL.UPDATED_ON is null and I_LAST_BASE.UPDATED_ON is not null) or (CURR_VAL.UPDATED_ON is not null and I_LAST_BASE.UPDATED_ON is null) ) then + RSCUIN := true; + else + RSCUIN := false; + end if; + + + I_LAST_NBT.L_INTERMEDIARIES_NAME2 := NBT_VAL.L_INTERMEDIARIES_NAME2; + I_LAST_BASE.CUST_ID := CURR_VAL.CUST_ID; + I_LAST_BASE.INTE_ID := CURR_VAL.INTE_ID; + I_LAST_BASE.CREATED_BY := CURR_VAL.CREATED_BY; + I_LAST_BASE.CREATED_ON := CURR_VAL.CREATED_ON; + I_LAST_BASE.UPDATED_BY := CURR_VAL.UPDATED_BY; + I_LAST_BASE.UPDATED_ON := CURR_VAL.UPDATED_ON; + l_row := l_row + 1; + + + WSGL.LayoutRowStart('TOP', p_attrs=>'class = cgrldatarow'); + l_id := 'NAME' || l_row; + if RSCUIN and NBT_VAL.L_INTERMEDIARIES_NAME2 is not null then + WSGL.LayoutData(p_text=>htf.anchor2('efnow110$cuin.QueryViewByKey?P_CUST_ID='||CURR_VAL.CUST_ID||'&P_INTE_ID='||CURR_VAL.INTE_ID||'&P_2='||to_char(efnow110$cust.CURR_VAL.CUST_ID)||'&Z_CHK='||ZONE_CHECKSUM, replace(WSGL.EscapeItem(NBT_VAL.L_INTERMEDIARIES_NAME2), ' +', '
+'), ctarget=>I_VF_FRAME), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + + WSGL.LayoutRowEnd; + + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + if I_TOTAL_ROWS = I_START + RL_RECORD_SET_SIZE - 1 then + if I_ROWS_FETCHED <> 0 then + I_NEXT_BUT := TRUE; + end if; + exit; + end if; + else + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + end if; + + I_TOTAL_ROWS := I_TOTAL_ROWS + I_ROWS_FETCHED; + + end loop; + + WSGL.LayoutClose; + + if I_START = I_TOTAL_ROWS then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_TOTAL_ROWS))||I_OF_TOTAL_TEXT); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(I_TOTAL_ROWS))|| + I_OF_TOTAL_TEXT); + end if; + htp.para; + else + htp.p(WSGL.MsgGetText(112,WSGLM.DSP112_NO_RECORDS)); + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + dbms_sql.close_cursor(I_CURSOR); + end if; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cuin.querylist', cattributes => 'NAME="efnow110$cuin$LForm"'); + SaveState; + WSGL.HiddenField('P_CUST_ID', P_CUST_ID); + WSGL.HiddenField('Z_START', to_char(I_START)); + htp.p (''); + + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', RL_FIRST_BUT_CAPTION, WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_FIRST_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', RL_PREV_BUT_CAPTION, WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_PREV_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', RL_NEXT_BUT_CAPTION, WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_NEXT_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', RL_LAST_BUT_CAPTION, WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_LAST_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', RL_REQUERY_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_REQUERY_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', RL_COUNT_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_COUNT_BUT_ACTION || '\''"'); + htp.para; + + WSGL.RecordListButton(TRUE, 'Z_ACTION', RL_INSERT_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_INSERT_BUT_ACTION || '\''"'); + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''||P_CUST_ID||to_char(efnow110$cust.CURR_VAL.CUST_ID)))); + WSGL.HiddenField('P_CUST_ID', ''); + htp.formClose; + + WSGL.ReturnLinks('0.1.2', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + RL_BODY_ATTRIBUTES, 'efnow110$cuin.QueryList'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.QueryFirst +-- +-- Description: Finds the first row which matches the given search criteria +-- (if any), and calls QueryView for that row +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryFirst( + P_CUST_ID in varchar2, + P_2 in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + WSGL.RegisterURL('efnow110$cuin.queryfirst'); + WSGL.AddURLParam('P_CUST_ID', P_CUST_ID); + WSGL.AddURLParam('P_2', P_2); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if not Z_DIRECT_CALL then + null; + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + end if; + + if Z_ACTION = 'BLANK' then + WSGL.EmptyPage(VF_BODY_ATTRIBUTES); + return; + end if; + + if Z_ACTION = 'INSERT' then + efnow110$cuin.FormInsert( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + + if not BuildSQL( + P_CUST_ID) then + return; + end if; + + if not PreQuery( + P_CUST_ID) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + return; + end if; + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + -- If insert allowed, call form insert, otherwise WSGL.EmptyPage + if Z_ACTION = 'INSERTIFNONE' then + efnow110$cuin.FormInsert( + P_CUST_ID=>P_CUST_ID, + Z_DIRECT_CALL=>TRUE); + return; + else + WSGL.EmptyPage(VF_BODY_ATTRIBUTES); + end if; + else + AssignZoneRow(I_CURSOR); + efnow110$cuin.QueryView(Z_DIRECT_CALL=>TRUE); + end if; + + dbms_sql.close_cursor(I_CURSOR); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.QueryFirst'); + WSGL.ClosePageBody; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.ActionView +-- +-- Description: This procedure is called when the View Form is submitted to +-- action an update, delete or requery request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionView( + P_CUST_ID in owa_text.vc_arr, + P_INTE_ID in owa_text.vc_arr, + P_2 in varchar2, + O_CUST_ID in owa_text.vc_arr, + O_INTE_ID in owa_text.vc_arr, + O_CREATED_BY in owa_text.vc_arr, + O_CREATED_ON in owa_text.vc_arr, + O_UPDATED_BY in owa_text.vc_arr, + O_UPDATED_ON in owa_text.vc_arr, + H_L_INTERMEDIARIES_NAME2 in owa_text.vc_arr, + Q_CUST_ID in varchar2, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2, + Z_START in varchar2, + Z_CHK in varchar2 ) is +-- + l_row integer; + l_row_failed boolean := false; + l_success boolean; + l_rowset_row integer := 1; + l_delset_row integer := 1; + l_cbcount integer; + l_do_delete boolean := false; + l_record_lck boolean := false; + l_dummy_bool boolean := false; + + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + +if (Z_ACTION = VF_COUNT_BUT_ACTION or Z_ACTION = VF_COUNT_BUT_CAPTION) or + (Z_ACTION = VF_FIRST_BUT_ACTION or Z_ACTION = VF_FIRST_BUT_CAPTION) or + (Z_ACTION = VF_PREV_BUT_ACTION or Z_ACTION = VF_PREV_BUT_CAPTION) or + (Z_ACTION = VF_NEXT_BUT_ACTION or Z_ACTION = VF_NEXT_BUT_CAPTION) or + (Z_ACTION = VF_LAST_BUT_ACTION or Z_ACTION = VF_LAST_BUT_CAPTION) or + (Z_ACTION = VF_REQUERY_BUT_ACTION or Z_ACTION = VF_REQUERY_BUT_CAPTION) or + (Z_ACTION = VF_NTOM_BUT_ACTION or Z_ACTION = VF_NTOM_BUT_CAPTION) then + QueryView(Z_EXECUTE_QUERY=>'Y', + P_CUST_ID=>Q_CUST_ID, + Z_POST_DML=>FALSE, + Z_DIRECT_CALL=>TRUE, + Z_ACTION=>Z_ACTION, + Z_START=>Z_START); +end if; + + + FORM_VAL.CUST_ID := P_CUST_ID( P_CUST_ID.first ); + FORM_VAL.INTE_ID := P_INTE_ID( P_INTE_ID.first ); + FORM_VAL.L_INTERMEDIARIES_NAME2 := H_L_INTERMEDIARIES_NAME2( H_L_INTERMEDIARIES_NAME2.first ); + + PREV_VAL.CUST_ID := P_CUST_ID( P_CUST_ID.first ); + PREV_IND.CUST_ID := TRUE; + PREV_VAL.INTE_ID := P_INTE_ID( P_INTE_ID.first ); + PREV_IND.INTE_ID := TRUE; + PREV_VAL.CREATED_BY := O_CREATED_BY( O_CREATED_BY.first ); + PREV_IND.CREATED_BY := TRUE; + PREV_VAL.CREATED_ON := to_date(O_CREATED_ON( O_CREATED_ON.first ), 'JSSSSS'); + PREV_IND.CREATED_ON := TRUE; + PREV_VAL.UPDATED_BY := O_UPDATED_BY( O_UPDATED_BY.first ); + PREV_IND.UPDATED_BY := TRUE; + PREV_VAL.UPDATED_ON := to_date(O_UPDATED_ON( O_UPDATED_ON.first ), 'JSSSSS'); + PREV_IND.UPDATED_ON := TRUE; + + CURR_VAL := PREV_VAL; + CURR_PK.CUST_ID := CURR_VAL.CUST_ID; + CURR_PK.INTE_ID := CURR_VAL.INTE_ID; + + if (Z_ACTION = VF_CLEAR_BUT_ACTION) or (Z_ACTION = VF_CLEAR_BUT_CAPTION) then + + QueryView(Z_EXECUTE_QUERY=>null, Z_POST_DML=>TRUE, Z_DIRECT_CALL=>TRUE); + + elsif Z_ACTION = VF_VERIFIED_DELETE then + + ActionDelete(Z_DIRECT_CALL=>TRUE); + + elsif (Z_ACTION = VF_DELETE_BUT_ACTION) or (Z_ACTION = VF_DELETE_BUT_CAPTION) then + + FormDelete; + + + elsif (Z_ACTION = VF_INSERT_BUT_ACTION) or (Z_ACTION = VF_INSERT_BUT_CAPTION) then + + FormInsert( + P_CUST_ID=>PREV_VAL.CUST_ID, + Z_DIRECT_CALL=>TRUE); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.ActionView'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.ActionInsert +-- +-- Description: Called when the Insert Form is submitted to process the insert. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionInsert( + P_L_INTERMEDIARIES_NAME2 in owa_text.vc_arr, + P_CUST_ID in varchar2, + P_2 in varchar2, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + + I_ERROR_MESS varchar2(2000) := null; + l_row integer; + l_row_failed boolean := false; + l_cbcount integer; + l_dummy_bool boolean := false; + + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + end if; + if (Z_ACTION = IF_CLEAR_BUT_ACTION) or (Z_ACTION = IF_CLEAR_BUT_CAPTION) then + FormInsert(P_CUST_ID, + Z_FORM_STATUS=>WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + cg$errors.clear; + l_row := z_modified.first; + while l_row is not null loop + if z_modified( l_row ) = 'Y' then + l_row_failed := false; + CURR_VAL := NULL_VAL; + CURR_IND := NULL_IND; + FORM_VAL.L_INTERMEDIARIES_NAME2 := P_L_INTERMEDIARIES_NAME2( l_row ); + CURR_VAL.CUST_ID := P_CUST_ID; + CURR_IND.CUST_ID := TRUE; + + if not Validate('INS', l_dummy_bool) then + rollback; + FormInsert(P_CUST_ID, + Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + if not l_row_failed then + if not PreInsert then + rollback; + FormInsert(P_CUST_ID, + Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + end if; + + if not l_row_failed then + begin + CG$CUSTOMER_INTERMEDIARIES.Ins(CURR_VAL, CURR_IND); + exception + when cg$errors.cg$error then + rollback; + FormInsert(P_CUST_ID, + Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + when others then + raise; + end; + end if; + + if not l_row_failed then + if not PostInsert then + rollback; + FormInsert(P_CUST_ID, + Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + end if; + + if not l_row_failed then + commit; + IF_ROWS_INSERTED := IF_ROWS_INSERTED + 1; + end if; + end if; + l_row := z_modified.next( l_row ); + end loop; + QueryView( + K_CUST_ID=>CURR_VAL.CUST_ID, + K_INTE_ID=>CURR_VAL.INTE_ID, + P_CUST_ID=>P_CUST_ID, + Z_POST_DML=>TRUE, + Z_FORM_STATUS=>WSGL.FORM_STATUS_INS, + Z_DIRECT_CALL=>TRUE , + Z_CHK=>to_char(WSGL.Checksum + ('' || CURR_VAL.CUST_ID|| CURR_VAL.INTE_ID||to_char(efnow110$cust.CURR_VAL.CUST_ID)))); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + IF_BODY_ATTRIBUTES, 'efnow110$cuin.ActionInsert'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.ActionDelete +-- +-- Description: Called when the Delete confirmation form is submitted to process +-- the delete request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionDelete( + P_2 in varchar2, + P_CUST_ID in varchar2, + P_INTE_ID in varchar2, + O_CREATED_BY in varchar2, + O_CREATED_ON in varchar2, + O_UPDATED_BY in varchar2, + O_UPDATED_ON in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) + is + + I_ERROR_MESS varchar2(2000) := null; + I_RETURN number(6); + I_CURSOR integer; + I_VOID integer; + I_SUCCESS boolean := true; + + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + if ( not Z_DIRECT_CALL ) then + efnow110$cust.CURR_VAL.CUST_ID:= to_number(P_2); + end if; + + if P_CUST_ID is not null then + PREV_VAL.CUST_ID := P_CUST_ID; + PREV_IND.CUST_ID := TRUE; + CURR_PK.CUST_ID := P_CUST_ID; + end if; + if P_INTE_ID is not null then + PREV_VAL.INTE_ID := P_INTE_ID; + PREV_IND.INTE_ID := TRUE; + CURR_PK.INTE_ID := P_INTE_ID; + end if; + if O_CREATED_BY is not null then + PREV_VAL.CREATED_BY := O_CREATED_BY; + PREV_IND.CREATED_BY := TRUE; + end if; + if O_CREATED_ON is not null then + PREV_VAL.CREATED_ON := to_date(O_CREATED_ON, 'JSSSSS'); + PREV_IND.CREATED_ON := TRUE; + end if; + if O_UPDATED_BY is not null then + PREV_VAL.UPDATED_BY := O_UPDATED_BY; + PREV_IND.UPDATED_BY := TRUE; + end if; + if O_UPDATED_ON is not null then + PREV_VAL.UPDATED_ON := to_date(O_UPDATED_ON, 'JSSSSS'); + PREV_IND.UPDATED_ON := TRUE; + end if; + begin + cg$errors.clear; + CG$CUSTOMER_INTERMEDIARIES.Lck(PREV_VAL, PREV_IND); + exception + when cg$errors.cg$error then + QueryView(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + when others then + raise; + end; + + -- Set up the primary key for the component + CURR_VAL.CUST_ID := CURR_PK.CUST_ID; + CURR_VAL.INTE_ID := CURR_PK.INTE_ID; + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 0 + , Z_RESTORE_OWN_ROW => true + ); + + FORM_VAL.L_INTERMEDIARIES_NAME2 := WSGL.EscapeItem(NBT_VAL.L_INTERMEDIARIES_NAME2); + + if not PreDelete then + rollback; + QueryView(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + begin + cg$errors.clear; + CG$CUSTOMER_INTERMEDIARIES.Del(CURR_PK); + exception + when cg$errors.cg$error then + QueryView(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + when others then + raise; + end; + + + if not PostDelete then + rollback; + QueryView(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + commit; + WSGL.OpenPageHead(''||' : '||'#Intermediaries#1059#'); + WSGL.METATag; + htp.script('FormType = "PostDelete";'); + efnow110$.TemplateHeader(TRUE,4); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>VF_BODY_ATTRIBUTES || 'onLoad="return CUIN_OnLoad()"'); + efnow110$js$cuin.CreateViewJavaScript + ( + VF_ROWS_UPDATED, + VF_ROWS_DELETED, + VF_ROWS_ERROR, + VF_BODY_ATTRIBUTES, + IF_ROWS_INSERTED, + IF_ROWS_ERROR, + RL_REQUERY_BUT_ACTION, + LOV_FRAME + ); + htp.p(caco_system.menu); + htp.para; + WSGL.DefaultPageCaption('#Intermediaries#1059#'); + htp.para; + htp.p(htf.header(2,''||NBT_VAL.L_INTERMEDIARIES_NAME2||'')); + + htp.para; + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(216,WSGLM.MSG216_ROW_DELETED), + ''||' : '||'#Intermediaries#1059#', VF_BODY_ATTRIBUTES); + htp.script('DataChange=true'); + WSGL.ReturnLinks('0.1.2', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.ActionDelete'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.CUST_ID is null or CURR_VAL.INTE_ID is null + ) then + return FALSE; + end if; + end if; + + -- Build master context values + I_REMAINING_DEPTH := Z_MAX_DEPTH - Z_CURR_DEPTH; + + -- Always build master's context because of a dependency on it + if ( I_REMAINING_DEPTH < 99 ) then + I_REMAINING_DEPTH := 99; + end if; + I_SUCCESS := efnow110$cust.RestoreState + ( Z_CURR_DEPTH => Z_CURR_DEPTH + 1 + , Z_MAX_DEPTH => Z_CURR_DEPTH + I_REMAINING_DEPTH + , Z_RESTORE_OWN_ROW => true + ); + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + '', 'efnow110$cuin.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.SaveState +-- +-- Description: Saves the data state for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + -- Save all master context uids as hidden fields + WSGL.HiddenField( 'P_2', efnow110$cust.CURR_VAL.CUST_ID ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + '', 'efnow110$cuin.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.LoadCache +-- +-- Description: Populate the object cache with +-- 'CUIN' module component (#Intermediaries#1059#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + + ref_Component := WSGOC.Component + ( pModule => efnow110$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'CUIN' + , pTitle => '#Intermediaries#1059#' + , pSystemImagePath=> '/images/' + ); + + r_L_INTERMEDIARIES_NAME2 := WSGOC.Item + ( pName => 'L_INTERMEDIARIES_NAME2' + , pPrompt => 'Name' + , pIsContext=> true + ); + r_CUST_ID := WSGOC.Item + ( pName => 'CUST_ID' + , pPrompt => '#Cust Id#1065#' + ); + r_INTE_ID := WSGOC.Item + ( pName => 'INTE_ID' + , pPrompt => '#Inte Id#1055#' + ); + r_CREATED_BY := WSGOC.Item + ( pName => 'CREATED_BY' + , pPrompt => 'Created By' + ); + r_CREATED_ON := WSGOC.Item + ( pName => 'CREATED_ON' + , pPrompt => 'Created On' + ); + r_UPDATED_BY := WSGOC.Item + ( pName => 'UPDATED_BY' + , pPrompt => 'Updated By' + ); + r_UPDATED_ON := WSGOC.Item + ( pName => 'UPDATED_ON' + , pPrompt => 'Updated On' + ); + + WSGOC.Add_Items(ref_Component, r_L_INTERMEDIARIES_NAME2); + WSGOC.Add_Items(ref_Component, r_CUST_ID); + WSGOC.Add_Items(ref_Component, r_INTE_ID); + WSGOC.Add_Items(ref_Component, r_CREATED_BY); + WSGOC.Add_Items(ref_Component, r_CREATED_ON); + WSGOC.Add_Items(ref_Component, r_UPDATED_BY); + WSGOC.Add_Items(ref_Component, r_UPDATED_ON); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_L_INTERMEDIARIES_NAME2, htf.anchor2('efnow110$cuin.QueryViewByKey?P_CUST_ID='||CURR_VAL.CUST_ID||'&P_INTE_ID='||CURR_VAL.INTE_ID||'&P_2='||to_char(efnow110$cust.CURR_VAL.CUST_ID)||'&Z_CHK='||ZONE_CHECKSUM, replace(WSGL.EscapeItem(NBT_VAL.L_INTERMEDIARIES_NAME2), ' +', '
+'), ctarget=>I_VF_FRAME) ); + WSGOC.Set_Value( r_CUST_ID, WSGL.EscapeItem(CURR_VAL.CUST_ID) ); + WSGOC.Set_Value( r_INTE_ID, WSGL.EscapeItem(CURR_VAL.INTE_ID) ); + WSGOC.Set_Value( r_CREATED_BY, WSGL.EscapeItem(CURR_VAL.CREATED_BY) ); + WSGOC.Set_Value( r_CREATED_ON, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.CREATED_ON, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_UPDATED_BY, WSGL.EscapeItem(CURR_VAL.UPDATED_BY) ); + WSGOC.Set_Value( r_UPDATED_ON, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.UPDATED_ON, 'DD-MON-RRRR'))) ); + + end if; + + -- Only build master's context if asked to + if ( Z_MAX_DEPTH > Z_CURR_DEPTH ) then + efnow110$cust.LoadCache + ( Z_CURR_DEPTH => Z_CURR_DEPTH + 1 + , Z_MAX_DEPTH => Z_MAX_DEPTH + , Z_OWN_ROW_VALUES => true + , Z_CONTEXT_FOR => REF_COMPONENT + , Z_BRANCH => Z_BRANCH + ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + '', 'efnow110$cuin.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery( + P_CUST_ID in varchar2) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + DEF_BODY_ATTRIBUTES, 'efnow110$cuin.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + DEF_BODY_ATTRIBUTES, 'efnow110$cuin.PostQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PreInsert +-- +-- Description: Provides place holder for code to be run prior to an insert +-- for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreInsert return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + IF_BODY_ATTRIBUTES, 'efnow110$cuin.PreInsert'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PostInsert +-- +-- Description: Provides place holder for code to be run after an insert +-- for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostInsert return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + IF_BODY_ATTRIBUTES, 'efnow110$cuin.PostInsert'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PreDelete +-- +-- Description: Provides place holder for code to be run prior to a delete +-- for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreDelete return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.PreDelete'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cuin.PostDelete +-- +-- Description: Provides place holder for code to be run after a delete +-- for the 'CUIN' module component (#Intermediaries#1059#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostDelete return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$cuin.PostDelete'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cuin.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cuin.spc new file mode 100644 index 0000000..e6052ea --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cuin.spc @@ -0,0 +1,133 @@ +create or replace package efnow110$cuin is + + type NBT_REC is record + ( L_INTERMEDIARIES_NAME2 INTERMEDIARIES.NAME%type + ); + + NBT_VAL NBT_REC; + CURR_VAL CG$CUSTOMER_INTERMEDIARIES.CG$ROW_TYPE; + + + procedure Startup( + P_CUST_ID in varchar2, + P_2 in varchar2, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure FormInsert( + P_CUST_ID in varchar2 default null, + P_2 in varchar2 default null, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryView( + K_CUST_ID in varchar2 default null, + K_INTE_ID in varchar2 default null, + P_2 in varchar2 default null, + P_CUST_ID in varchar2 default null, + Z_EXECUTE_QUERY in varchar2 default null, + Z_POST_DML in boolean default false, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_START in varchar2 default '1', + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null); + procedure QueryList( + P_CUST_ID in varchar2 default null, + P_2 in varchar2 default null, + Z_START in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null ); + procedure QueryFirst( + P_CUST_ID in varchar2 default null, + P_2 in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + function QueryHits( + P_CUST_ID in varchar2 default null) return number; + + procedure ActionView( + P_CUST_ID in owa_text.vc_arr, + P_INTE_ID in owa_text.vc_arr, + P_2 in varchar2 default null, + O_CUST_ID in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_INTE_ID in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CREATED_BY in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CREATED_ON in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_UPDATED_BY in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_UPDATED_ON in owa_text.vc_arr default WSGL.EmptyVCArrLong, + H_L_INTERMEDIARIES_NAME2 in owa_text.vc_arr default WSGL.EmptyVCArrLong, + Q_CUST_ID in varchar2 default null, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2 default null, + Z_START in varchar2 default '1', + Z_CHK in varchar2 default null ); + procedure ActionInsert( + P_L_INTERMEDIARIES_NAME2 in owa_text.vc_arr, + P_CUST_ID in varchar2 default null, + P_2 in varchar2, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + procedure ActionDelete( + P_2 in varchar2 default null, + P_CUST_ID in varchar2 default null, + P_INTE_ID in varchar2 default null, + O_CREATED_BY in varchar2 default null, + O_CREATED_ON in varchar2 default null, + O_UPDATED_BY in varchar2 default null, + O_UPDATED_ON in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryViewByKey( + P_CUST_ID in varchar2 default null, + P_INTE_ID in varchar2 default null, + P_2 in varchar2 default null, + Z_POST_DML in boolean default false, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cust.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cust.bdy new file mode 100644 index 0000000..8065c57 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cust.bdy @@ -0,0 +1,4433 @@ +create or replace package body efnow110$cust is +function PCG$LK_KAM_SYUS_ID_Process( + P_UI_KAM_MGR_NAME in varchar2, + Z_MODE in varchar2 ) return boolean; +function PCG$LK_CUST_CUTY_FK_Process( + P_CUTY_ID in varchar2, + Z_MODE in varchar2 ) return boolean; + + function EFLV_CUST_NAME1_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + function EFLV_CUST_CODE1_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + procedure FormView(Z_FORM_STATUS in number, + Q_UI_CODE in varchar2 default null, + Q_UI_NAME in varchar2 default null, + Z_POST_DML in boolean default false, + Z_MULTI_PAGE in boolean default true, + Z_ACTION in varchar2 default null, + Z_START in varchar2 default '1'); + function BuildSQL( + P_UI_CODE in varchar2 default null, + P_UI_NAME in varchar2 default null, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + + procedure ActionUpdate (p_row in integer default 0 + ,p_row_success in out boolean + ,p_row_lck in out boolean + ); + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function Validate(Z_MODE in varchar2, Z_FORCE_UPDATE in out boolean) return boolean; + function PreUpdate return boolean; + function PostUpdate return boolean; + function PreInsert return boolean; + function PostInsert return boolean; + function PreQuery( + P_UI_CODE in varchar2 default null, + P_UI_NAME in varchar2 default null) return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; +-- define_globals +-- +-- + +g_ui_code CUSTOMERS.CODE%TYPE; +g_ui_name CUSTOMERS.NAME%TYPE; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + QF_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(3,WSGLM.CAP003_QF_FIND); + QF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(4,WSGLM.CAP004_QF_CLEAR); + QF_INSERT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(23,WSGLM.CAP023_NEW); + QF_INSERT_BUT_ACTION constant varchar2(10) := 'INSERT'; + QF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + QF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + QF_NUMBER_OF_COLUMNS constant number(4) := 1; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + VF_UPDATE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(6,WSGLM.CAP006_VF_UPDATE); + VF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(8,WSGLM.CAP008_VF_REVERT); + VF_DELETE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(7,WSGLM.CAP007_VF_DELETE); + VF_INSERT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(23,WSGLM.CAP023_NEW); + VF_INSERT_BUT_ACTION constant varchar2(10) := 'INSERT'; + VF_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + VF_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + VF_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + VF_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + VF_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + VF_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + VF_NTOM_BUT_CAPTION constant varchar2(100) := '%s -> %e'; + VF_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(24,WSGLM.CAP024_RL_QUERY); + VF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + VF_UPDATE_BUT_ACTION constant varchar2(10) := 'UPDATE'; + VF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + VF_DELETE_BUT_ACTION constant varchar2(10) := 'DELETE'; + VF_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + VF_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + VF_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + VF_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + VF_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + VF_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + VF_NTOM_BUT_ACTION constant varchar2(10) := 'NTOM'; + VF_VERIFIED_DELETE constant varchar2(100) := 'VerifiedDelete'; + VF_NUMBER_OF_COLUMNS constant number(4) := 2; + VF_RECORD_SET_SIZE constant number(5) := 1; + + VF_TOTAL_COUNT_REQD constant boolean := FALSE; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_INSERT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(9,WSGLM.CAP009_IF_INSERT); + IF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(10,WSGLM.CAP010_IF_CLEAR); + IF_INSERT_BUT_ACTION constant varchar2(10) := 'INSERT'; + IF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + IF_NUMBER_OF_COLUMNS constant number(4) := 2; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + CURR_IND CG$CUSTOMERS.CG$IND_TYPE; + CURR_PK CG$CUSTOMERS.CG$PK_TYPE; + PREV_VAL CG$CUSTOMERS.CG$ROW_TYPE; + PREV_IND CG$CUSTOMERS.CG$IND_TYPE; + NULL_VAL CG$CUSTOMERS.CG$ROW_TYPE; + NULL_IND CG$CUSTOMERS.CG$IND_TYPE; + + type FORM_REC is record + (UI_CODE varchar2(32760) + ,UI_NAME varchar2(32760) + ,CUST_ID varchar2(40) + ,CODE varchar2(120) + ,NAME varchar2(600) + ,PRIMARY_CONTACT varchar2(300) + ,PRIMARY_CONTACT_TEL varchar2(180) + ,CUTY_ID varchar2(50) + ,STATUS varchar2(60) + ,EMAIL_ADDRESS varchar2(480) + ,DESCRIPTION varchar2(32760) + ,TELEPHONE varchar2(180) + ,FAX varchar2(180) + ,KAM_MANAGER varchar2(40) + ,UI_KAM_MGR_NAME varchar2(32760) + ,KAM_TELEPHONE varchar2(180) + ,CREATED_BY varchar2(180) + ,CREATED_ON varchar2(12) + ,UPDATED_BY varchar2(180) + ,UPDATED_ON varchar2(12) + ,PERIOD_START varchar2(12) + ,PERIOD_END varchar2(12) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + type IF_FORMARRAY is table of FORM_REC index by binary_integer; + IF_FORM_ERRORS IF_FORMARRAY; + IF_ROWS_INSERTED integer := 0; + IF_ROWS_ERROR integer := 0; + VF_ROWS_UPDATED integer := 0; + VF_ROWS_DELETED integer := 0; + VF_ROWS_ERROR integer := 0; + type CTX_REC is record + ( NAME varchar2(600) + ); + type CTX_REC_ARR is table of CTX_REC index by binary_integer; + VF_DELETED_ROWS CTX_REC_ARR; + type ROW_REC is record + ( F_UI_CODE varchar2(32760) + , F_UI_NAME varchar2(32760) + , F_CUST_ID varchar2(40) + , F_CODE varchar2(120) + , F_NAME varchar2(600) + , F_PRIMARY_CONTACT varchar2(300) + , F_PRIMARY_CONTACT_TEL varchar2(180) + , F_CUTY_ID varchar2(50) + , F_STATUS varchar2(60) + , F_EMAIL_ADDRESS varchar2(480) + , F_DESCRIPTION varchar2(32760) + , F_TELEPHONE varchar2(180) + , F_FAX varchar2(180) + , F_KAM_MANAGER varchar2(40) + , F_UI_KAM_MGR_NAME varchar2(32760) + , F_KAM_TELEPHONE varchar2(180) + , F_CREATED_BY varchar2(180) + , F_CREATED_ON varchar2(12) + , F_UPDATED_BY varchar2(180) + , F_UPDATED_ON varchar2(12) + , F_PERIOD_START varchar2(12) + , F_PERIOD_END varchar2(12) + , SUCCESS_FLAG boolean + , ROW_DELETED boolean + , ROW_NOT_LOCKED boolean + , ROW_ID rowid + ); + type ROW_SET_TYPE is table of ROW_REC index by binary_integer; + VF_ROW_SET ROW_SET_TYPE; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_UI_CODE WSGOC.ITEM_REF; + R_UI_NAME WSGOC.ITEM_REF; + R_CUST_ID WSGOC.ITEM_REF; + R_CODE WSGOC.ITEM_REF; + R_NAME WSGOC.ITEM_REF; + R_PRIMARY_CONTACT WSGOC.ITEM_REF; + R_PRIMARY_CONTACT_TEL WSGOC.ITEM_REF; + R_CUTY_ID WSGOC.ITEM_REF; + R_STATUS WSGOC.ITEM_REF; + R_EMAIL_ADDRESS WSGOC.ITEM_REF; + R_DESCRIPTION WSGOC.ITEM_REF; + R_TELEPHONE WSGOC.ITEM_REF; + R_FAX WSGOC.ITEM_REF; + R_KAM_MANAGER WSGOC.ITEM_REF; + R_UI_KAM_MGR_NAME WSGOC.ITEM_REF; + R_KAM_TELEPHONE WSGOC.ITEM_REF; + R_CREATED_BY WSGOC.ITEM_REF; + R_CREATED_ON WSGOC.ITEM_REF; + R_UPDATED_BY WSGOC.ITEM_REF; + R_UPDATED_ON WSGOC.ITEM_REF; + R_PERIOD_START WSGOC.ITEM_REF; + R_PERIOD_END WSGOC.ITEM_REF; + + +FUNCTION Check_Dates(p_start_date IN DATE, + p_end_date IN DATE) RETURN BOOLEAN; + + +FUNCTION Check_Dates(p_start_date IN DATE, + p_end_date IN DATE) RETURN BOOLEAN IS + +-- Check_Dates +-- +-- + + + + -- + l_ok BOOLEAN; + -- +BEGIN + -- + IF p_start_date <= NVL(p_end_date,p_start_date) THEN + -- + l_ok := TRUE; + -- + ELSE + -- + l_ok := caco_utilities.raise_error(-20515); + -- + END IF; + -- + RETURN (l_ok); + -- +END; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin +-- PoQ_get_Ind_Sub_time +-- +-- + +DECLARE + -- + CURSOR c_syus IS + SELECT syus.first_name||' '||syus.last_name + FROM system_users syus + WHERE curr_val.kam_manager_syus_id = syus.syus_id; + -- + --l_sub_time VARCHAR2(255); + l_kam_mgr_name VARCHAR2(255); + -- +BEGIN + -- + OPEN c_syus; + FETCH c_syus INTO l_kam_mgr_name; + CLOSE c_syus; + -- + -- The time ids stored with a ':', SUBSTR around this to present on the screen + -- + + -- + --form_val.ui_dummy := l_sub_time; + --l_sub_time := curr_val.ind_deadline_for_nom_submit; + --htp.p('Time is : '|| l_sub_time); + + -- + nbt_val.ui_kam_mgr_name := l_kam_mgr_name; + form_val.ui_kam_mgr_name := l_kam_mgr_name; + -- + --nbt_val.ui_hours := SUBSTR(l_sub_time,1,2); + --form_val.ui_hours := SUBSTR(l_sub_time,1,2); + -- + --nbt_val.ui_mins := SUBSTR(l_sub_time,4,2); + --form_val.ui_mins := SUBSTR(l_sub_time,4,2); + -- +END; + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.PostQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PreInsert +-- +-- Description: Provides place holder for code to be run prior to an insert +-- for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreInsert return boolean is + L_RET_VAL boolean := TRUE; + begin +-- PrI_set_ind_sub_time +-- +-- + +DECLARE + -- + C_DATE_FORMAT CONSTANT VARCHAR2(255) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + l_ret_val := Check_dates(TO_DATE(form_val.period_start, C_DATE_FORMAT), + TO_DATE(form_val.period_end, C_DATE_FORMAT)); + -- + --IF l_ret_val THEN + -- + --IF form_val.ui_hours IS NOT NULL THEN + --curr_val.ind_deadline_for_nom_submit := form_val.ui_hours||':'||NVL(form_val.ui_mins,'00'); + --curr_ind.ind_deadline_for_nom_submit := TRUE; + --ELSIF form_val.ui_hours IS NULL THEN + --curr_val.ind_deadline_for_nom_submit := NULL; + --curr_ind.ind_deadline_for_nom_submit := TRUE; + --END IF; + -- + --END IF; +END; + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + IF_BODY_ATTRIBUTES, 'efnow110$cust.PreInsert'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery( + P_UI_CODE in varchar2, + P_UI_NAME in varchar2) return boolean is + L_RET_VAL boolean := TRUE; + begin +-- PQ_set_globals +-- +-- + +BEGIN + g_ui_code := P_UI_CODE; + g_ui_name := P_UI_NAME; +END; + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PreUpdate +-- +-- Description: Provides place holder for code to be run prior to an update +-- for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreUpdate return boolean is + L_RET_VAL boolean := TRUE; + begin +-- PrU_set_ind_sub_time +-- +-- + +DECLARE + -- + C_DATE_FORMAT CONSTANT VARCHAR2(255) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + l_ret_val := Check_dates(TO_DATE(form_val.period_start, C_DATE_FORMAT), + TO_DATE(form_val.period_end, C_DATE_FORMAT)); + -- + -- + --IF l_ret_val THEN + -- + --IF form_val.ui_hours IS NOT NULL THEN + --curr_val.ind_deadline_for_nom_submit := form_val.ui_hours||':'||NVL(form_val.ui_mins,'00'); + --curr_ind.ind_deadline_for_nom_submit := TRUE; + --ELSIF form_val.ui_hours IS NULL THEN + --curr_val.ind_deadline_for_nom_submit := NULL; + --curr_ind.ind_deadline_for_nom_submit := TRUE; + --END IF; + -- + --END IF; + -- +END; + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.PreUpdate'); + return FALSE; + end; +FUNCTION get_cust_code RETURN VARCHAR2 IS + +-- get_cust_code +-- +-- + + + +BEGIN + RETURN g_ui_code; +END; +FUNCTION get_cust_name RETURN VARCHAR2 IS + +-- get_cust_name +-- +-- + + + +BEGIN + RETURN g_ui_name; +END; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.KAM_SYUS_ID_LOV +-- +-- Description: This procedure displays the 'KAM_SYUS_ID' LOV +-- +-------------------------------------------------------------------------------- + procedure KAM_SYUS_ID_LOV( + Z_FILTER in varchar2, + Z_MODE in varchar2, + Z_CALLER_URL in varchar2, + Z_FORMROW in number, + Z_LONG_LIST in varchar2, + Z_ISSUE_WAIT in varchar2) is + L_SEARCH_STRING varchar2(1000); + L_ABORT boolean := FALSE; + L_INVALID_DEPENDENT boolean := FALSE; + L_ANY boolean := FALSE; + L_BODY_ATTRIBUTES VarChar2 (1000) := LOV_BODY_ATTRIBUTES; + L_SUCCESS boolean := TRUE ; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + WSGL.RegisterURL('efnow110$cust.KAM_SYUS_ID_LOV'); + WSGL.AddURLParam('Z_FILTER', Z_FILTER); + WSGL.AddURLParam('Z_MODE', Z_MODE); + WSGL.AddURLParam('Z_CALLER_URL', Z_CALLER_URL); + WSGL.AddURLParam('Z_FORMROW', Z_FORMROW); + if WSGL.NotLowerCase then + return; + end if; + + + WSGL.OpenPageHead; + WSGL.METATag; + htp.p(' + + '); + if Z_ISSUE_WAIT is not null then + + htp.p (''); + + L_BODY_ATTRIBUTES := L_BODY_ATTRIBUTES || ' OnLoad="RefreshMe()"'; + + else + if Z_FORMROW = -1 then + htp.p(''); + end if; + + efnow110$.TemplateHeader(TRUE,7); + + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>L_BODY_ATTRIBUTES); + + + htp.p(' + + '); + + if Z_ISSUE_WAIT is not null then + htp.p(WSGL.MsgGetText(127,WSGLM.DSP127_LOV_PLEASE_WAIT)); + WSGL.ClosePageBody; + return; + end if; + htp.formOpen(lower('efnow110$cust.KAM_SYUS_ID_LOV')); + WSGL.HiddenField('Z_CALLER_URL', Z_CALLER_URL); + WSGL.HiddenField('Z_MODE', Z_MODE); + SaveState; + WSGL.HiddenField('Z_FORMROW',Z_FORMROW); + + L_SEARCH_STRING := rtrim(Z_FILTER); + if L_SEARCH_STRING is not null then + if ((instr(Z_FILTER,'%') = 0) and (instr(Z_FILTER,'_') = 0)) then + L_SEARCH_STRING := L_SEARCH_STRING || '%'; + end if; + else + L_SEARCH_STRING := '%'; + end if; + + htp.para; + htp.p(WSGL.MsgGetText(19,WSGLM.CAP019_LOV_FILTER_CAPTION,'KAM Name')); + htp.para; + htp.formText('Z_FILTER', cvalue=>L_SEARCH_STRING); + htp.p(''); + if LOV_FRAME is null then + htp.p(''); + end if; + htp.formClose; + if L_INVALID_DEPENDENT then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + '', LOV_BODY_ATTRIBUTES); + end if; + + if Z_LONG_LIST is not null then + if not L_ABORT and L_SEARCH_STRING is null then + htp.p(WSGL.MsgGetText(124,WSGLM.DSP124_LOV_ENTER_SEARCH)); + L_ABORT := TRUE; + end if; + end if; + + if not L_ABORT then + + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, TRUE); + + WSGL.LayoutRowStart; + WSGL.LayoutHeader(1, 'LEFT', 'KAM Name'); + WSGL.LayoutHeader(1, 'LEFT', 'First Name'); + WSGL.LayoutHeader(1, 'LEFT', 'Last Name'); + WSGL.LayoutRowEnd; + declare + l_uu varchar2(100); + l_ul varchar2(100); + l_lu varchar2(100); + l_ll varchar2(100); + l_retval number; + cursor c_lov + ( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT SYUS.FIRST_NAME||' '||SYUS.LAST_NAME UI_NAME, + SYUS.FIRST_NAME FIRST_NAME, + SYUS.LAST_NAME LAST_NAME, + SYUS.SYUS_ID SYUS_ID +FROM SYSTEM_USERS SYUS +WHERE /* CG$LOVI_WC_START KAM_SYUS_ID 30 */ + (SYUS.SYUS_ID <> caco_utilities.get_system_user AND SYUS.SYUS_ID IN ( SELECT uspr.syus_id FROM user_profiles uspr, system_profiles sypr WHERE uspr.sypr_id = sypr.sypr_id AND UPPER(sypr.name) like '%KAM%') AND SYUS.SYUS_ID IN (SELECT inus.syus_id FROM intermediary_users inus WHERE inus.inte_id IN (SELECT cbcv.inte_id FROM cust_by_cuty_v cbcv))) + /* CG$LOVI_WC_END KAM_SYUS_ID 30 */ AND + (SYUS.FIRST_NAME||' '||SYUS.LAST_NAME like z_uu||'%' or SYUS.FIRST_NAME||' '||SYUS.LAST_NAME like z_ul||'%' or SYUS.FIRST_NAME||' '||SYUS.LAST_NAME like z_lu||'%' or SYUS.FIRST_NAME||' '||SYUS.LAST_NAME like z_ll||'%') and upper(SYUS.FIRST_NAME||' '||SYUS.LAST_NAME) like upper(z_filter) +ORDER BY UI_NAME +; + begin + l_retval := WSGL.SearchComponents(L_SEARCH_STRING,l_uu,l_ul,l_lu,l_ll); + for c1rec in c_lov(Z_MODE, L_SEARCH_STRING,l_uu,l_ul,l_lu,l_ll) loop + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(''||WSGL.EscapeItem(c1rec.UI_NAME)||''); + WSGL.LayoutData(replace(WSGL.EscapeItem(c1rec.FIRST_NAME),'"','"')); + WSGL.LayoutData(replace(WSGL.EscapeItem(c1rec.LAST_NAME),'"','"')); + WSGL.LayoutRowEnd; + l_any := true; + end loop; + WSGL.LayoutClose; + if not l_any then + htp.p(WSGL.MsgGetText(224,WSGLM.MSG224_LOV_NO_ROWS)); + end if; + end; + end if; + + htp.p(''); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + LOV_BODY_ATTRIBUTES, 'efnow110$cust.KAM_SYUS_ID_LOV'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.EFLV_CUST_CODE_LOV +-- +-- Description: This procedure displays the 'EFLV_CUST_CODE' LOV +-- +-------------------------------------------------------------------------------- + procedure EFLV_CUST_CODE_LOV( + Z_FILTER in varchar2, + Z_MODE in varchar2, + Z_CALLER_URL in varchar2, + Z_FORMROW in number, + Z_LONG_LIST in varchar2, + Z_ISSUE_WAIT in varchar2) is + L_SEARCH_STRING varchar2(1000); + L_ABORT boolean := FALSE; + L_INVALID_DEPENDENT boolean := FALSE; + L_ANY boolean := FALSE; + L_BODY_ATTRIBUTES VarChar2 (1000) := LOV_BODY_ATTRIBUTES; + L_SUCCESS boolean := TRUE ; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + WSGL.RegisterURL('efnow110$cust.EFLV_CUST_CODE_LOV'); + WSGL.AddURLParam('Z_FILTER', Z_FILTER); + WSGL.AddURLParam('Z_MODE', Z_MODE); + WSGL.AddURLParam('Z_CALLER_URL', Z_CALLER_URL); + WSGL.AddURLParam('Z_FORMROW', Z_FORMROW); + if WSGL.NotLowerCase then + return; + end if; + + + WSGL.OpenPageHead; + WSGL.METATag; + htp.p(' + + '); + if Z_ISSUE_WAIT is not null then + + htp.p (''); + + L_BODY_ATTRIBUTES := L_BODY_ATTRIBUTES || ' OnLoad="RefreshMe()"'; + + else + if Z_FORMROW = -1 then + htp.p(''); + end if; + + efnow110$.TemplateHeader(TRUE,7); + + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>L_BODY_ATTRIBUTES); + + + htp.p(' + + '); + + if Z_ISSUE_WAIT is not null then + htp.p(WSGL.MsgGetText(127,WSGLM.DSP127_LOV_PLEASE_WAIT)); + WSGL.ClosePageBody; + return; + end if; + htp.formOpen(lower('efnow110$cust.EFLV_CUST_CODE_LOV')); + WSGL.HiddenField('Z_CALLER_URL', Z_CALLER_URL); + WSGL.HiddenField('Z_MODE', Z_MODE); + SaveState; + WSGL.HiddenField('Z_FORMROW',Z_FORMROW); + + L_SEARCH_STRING := rtrim(Z_FILTER); + if L_SEARCH_STRING is not null then + if ((instr(Z_FILTER,'%') = 0) and (instr(Z_FILTER,'_') = 0)) then + L_SEARCH_STRING := L_SEARCH_STRING || '%'; + end if; + else + L_SEARCH_STRING := '%'; + end if; + + htp.para; + htp.p(WSGL.MsgGetText(19,WSGLM.CAP019_LOV_FILTER_CAPTION,'Code')); + htp.para; + htp.formText('Z_FILTER', cvalue=>L_SEARCH_STRING); + htp.p(''); + if LOV_FRAME is null then + htp.p(''); + end if; + htp.formClose; + if L_INVALID_DEPENDENT then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + '', LOV_BODY_ATTRIBUTES); + end if; + + if Z_LONG_LIST is not null then + if not L_ABORT and L_SEARCH_STRING is null then + htp.p(WSGL.MsgGetText(124,WSGLM.DSP124_LOV_ENTER_SEARCH)); + L_ABORT := TRUE; + end if; + end if; + + if not L_ABORT then + + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, TRUE); + + WSGL.LayoutRowStart; + WSGL.LayoutHeader(1, 'LEFT', 'Code'); + WSGL.LayoutHeader(1, 'LEFT', 'Name'); + WSGL.LayoutRowEnd; + declare + l_uu varchar2(100); + l_ul varchar2(100); + l_lu varchar2(100); + l_ll varchar2(100); + l_retval number; + cursor c_lov + ( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT CUST.CODE CODE, + CUST.NAME NAME +FROM CUSTOMERS CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START EFLV_CUST_CODE.CUST */ + ((CUST.cuty_id = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_QWC_END EFLV_CUST_CODE.CUST */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START EFLV_CUST_CODE.CUST */ + ((CUST.cuty_id = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_VWC_END EFLV_CUST_CODE.CUST */ + ) + ) + ) AND + /* CG$LOVI_WC_START EFLV_CUST_CODE 50 */ + (CUST.cust_id <> cout_system_configuration.get_configuration_item('CUST_ID')) + /* CG$LOVI_WC_END EFLV_CUST_CODE 50 */ AND + (CUST.CODE like z_uu||'%' or CUST.CODE like z_ul||'%' or CUST.CODE like z_lu||'%' or CUST.CODE like z_ll||'%') and upper(CUST.CODE) like upper(z_filter) +ORDER BY CODE +; + begin + l_retval := WSGL.SearchComponents(L_SEARCH_STRING,l_uu,l_ul,l_lu,l_ll); + for c1rec in c_lov(Z_MODE, L_SEARCH_STRING,l_uu,l_ul,l_lu,l_ll) loop + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(''||WSGL.EscapeItem(c1rec.CODE)||''); + WSGL.LayoutData(replace(WSGL.EscapeItem(c1rec.NAME),'"','"')); + WSGL.LayoutRowEnd; + l_any := true; + end loop; + WSGL.LayoutClose; + if not l_any then + htp.p(WSGL.MsgGetText(224,WSGLM.MSG224_LOV_NO_ROWS)); + end if; + end; + end if; + + htp.p(''); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + LOV_BODY_ATTRIBUTES, 'efnow110$cust.EFLV_CUST_CODE_LOV'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.EFLV_CUST_NAME_LOV +-- +-- Description: This procedure displays the 'EFLV_CUST_NAME' LOV +-- +-------------------------------------------------------------------------------- + procedure EFLV_CUST_NAME_LOV( + Z_FILTER in varchar2, + Z_MODE in varchar2, + Z_CALLER_URL in varchar2, + Z_FORMROW in number, + Z_LONG_LIST in varchar2, + Z_ISSUE_WAIT in varchar2) is + L_SEARCH_STRING varchar2(1000); + L_ABORT boolean := FALSE; + L_INVALID_DEPENDENT boolean := FALSE; + L_ANY boolean := FALSE; + L_BODY_ATTRIBUTES VarChar2 (1000) := LOV_BODY_ATTRIBUTES; + L_SUCCESS boolean := TRUE ; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + WSGL.RegisterURL('efnow110$cust.EFLV_CUST_NAME_LOV'); + WSGL.AddURLParam('Z_FILTER', Z_FILTER); + WSGL.AddURLParam('Z_MODE', Z_MODE); + WSGL.AddURLParam('Z_CALLER_URL', Z_CALLER_URL); + WSGL.AddURLParam('Z_FORMROW', Z_FORMROW); + if WSGL.NotLowerCase then + return; + end if; + + + WSGL.OpenPageHead; + WSGL.METATag; + htp.p(' + + '); + if Z_ISSUE_WAIT is not null then + + htp.p (''); + + L_BODY_ATTRIBUTES := L_BODY_ATTRIBUTES || ' OnLoad="RefreshMe()"'; + + else + if Z_FORMROW = -1 then + htp.p(''); + end if; + + efnow110$.TemplateHeader(TRUE,7); + + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>L_BODY_ATTRIBUTES); + + + htp.p(' + + '); + + if Z_ISSUE_WAIT is not null then + htp.p(WSGL.MsgGetText(127,WSGLM.DSP127_LOV_PLEASE_WAIT)); + WSGL.ClosePageBody; + return; + end if; + htp.formOpen(lower('efnow110$cust.EFLV_CUST_NAME_LOV')); + WSGL.HiddenField('Z_CALLER_URL', Z_CALLER_URL); + WSGL.HiddenField('Z_MODE', Z_MODE); + SaveState; + WSGL.HiddenField('Z_FORMROW',Z_FORMROW); + + L_SEARCH_STRING := rtrim(Z_FILTER); + if L_SEARCH_STRING is not null then + if ((instr(Z_FILTER,'%') = 0) and (instr(Z_FILTER,'_') = 0)) then + L_SEARCH_STRING := L_SEARCH_STRING || '%'; + end if; + else + L_SEARCH_STRING := '%'; + end if; + + htp.para; + htp.p(WSGL.MsgGetText(19,WSGLM.CAP019_LOV_FILTER_CAPTION,'Name')); + htp.para; + htp.formText('Z_FILTER', cvalue=>L_SEARCH_STRING); + htp.p(''); + if LOV_FRAME is null then + htp.p(''); + end if; + htp.formClose; + if L_INVALID_DEPENDENT then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + '', LOV_BODY_ATTRIBUTES); + end if; + + if Z_LONG_LIST is not null then + if not L_ABORT and L_SEARCH_STRING is null then + htp.p(WSGL.MsgGetText(124,WSGLM.DSP124_LOV_ENTER_SEARCH)); + L_ABORT := TRUE; + end if; + end if; + + if not L_ABORT then + + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, TRUE); + + WSGL.LayoutRowStart; + WSGL.LayoutHeader(1, 'LEFT', 'Name'); + WSGL.LayoutHeader(1, 'LEFT', 'Code'); + WSGL.LayoutRowEnd; + declare + l_uu varchar2(100); + l_ul varchar2(100); + l_lu varchar2(100); + l_ll varchar2(100); + l_retval number; + cursor c_lov + ( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT CUST.NAME NAME, + CUST.CODE CODE +FROM CUSTOMERS CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START EFLV_CUST_NAME.CUST */ + ((CUST.cuty_id = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_QWC_END EFLV_CUST_NAME.CUST */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START EFLV_CUST_NAME.CUST */ + ((efnow110$cust.CURR_VAL.CUTY_ID = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_VWC_END EFLV_CUST_NAME.CUST */ + ) + ) + ) AND + /* CG$LOVI_WC_START EFLV_CUST_NAME 40 */ + (CUST.cust_id <> cout_system_configuration.get_configuration_item('CUST_ID')) + /* CG$LOVI_WC_END EFLV_CUST_NAME 40 */ AND + (CUST.NAME like z_uu||'%' or CUST.NAME like z_ul||'%' or CUST.NAME like z_lu||'%' or CUST.NAME like z_ll||'%') and upper(CUST.NAME) like upper(z_filter) +ORDER BY NAME +; + begin + l_retval := WSGL.SearchComponents(L_SEARCH_STRING,l_uu,l_ul,l_lu,l_ll); + for c1rec in c_lov(Z_MODE, L_SEARCH_STRING,l_uu,l_ul,l_lu,l_ll) loop + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(''||WSGL.EscapeItem(c1rec.NAME)||''); + WSGL.LayoutData(replace(WSGL.EscapeItem(c1rec.CODE),'"','"')); + WSGL.LayoutRowEnd; + l_any := true; + end loop; + WSGL.LayoutClose; + if not l_any then + htp.p(WSGL.MsgGetText(224,WSGLM.MSG224_LOV_NO_ROWS)); + end if; + end; + end if; + + htp.p(''); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + LOV_BODY_ATTRIBUTES, 'efnow110$cust.EFLV_CUST_NAME_LOV'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.EFLV_CUST_NAME1_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'EFLV_CUST_NAME1'. +-- +-- +-------------------------------------------------------------------------------- + function EFLV_CUST_NAME1_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT CUST.NAME NAME, + CUST.CODE CODE +FROM CUSTOMERS CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START EFLV_CUST_NAME.CUST */ + ((CUST.cuty_id = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_QWC_END EFLV_CUST_NAME.CUST */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START EFLV_CUST_NAME.CUST */ + ((efnow110$cust.CURR_VAL.CUTY_ID = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_VWC_END EFLV_CUST_NAME.CUST */ + ) + ) + ) AND + (CUST.NAME like z_uu||'%' or CUST.NAME like z_ul||'%' or CUST.NAME like z_lu||'%' or CUST.NAME like z_ll||'%') and upper(CUST.NAME) like upper(z_filter) +ORDER BY NAME, + NAME +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return UI_NAME_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return UI_NAME_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return UI_NAME_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return UI_NAME_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return UI_NAME_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_UI_NAME', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_UI_NAME'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_UI_NAME', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_UI_NAME'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.NAME) = P_VALUE) or c1rec.NAME = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.NAME), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.NAME)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.NAME), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.NAME)||'"'); + end if; + l_first := false; + end loop; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.EFLV_CUST_NAME1_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.EFLV_CUST_CODE1_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'EFLV_CUST_CODE1'. +-- +-- +-------------------------------------------------------------------------------- + function EFLV_CUST_CODE1_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT CUST.CODE CODE, + CUST.NAME NAME +FROM CUSTOMERS CUST +WHERE ( + ( ( Z_MODE='Q') + AND ( /* CG$MDTU_QWC_START EFLV_CUST_CODE.CUST */ + ((CUST.cuty_id = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_QWC_END EFLV_CUST_CODE.CUST */ + ) + ) + OR + ( ( NOT Z_MODE='Q') + AND ( /* CG$MDTU_VWC_START EFLV_CUST_CODE.CUST */ + ((CUST.cuty_id = caco_utilities.cuty_id_for_user OR caco_utilities.user_has_system = 'Y')) + /* CG$MDTU_VWC_END EFLV_CUST_CODE.CUST */ + ) + ) + ) AND + (CUST.CODE like z_uu||'%' or CUST.CODE like z_ul||'%' or CUST.CODE like z_lu||'%' or CUST.CODE like z_ll||'%') and upper(CUST.CODE) like upper(z_filter) +ORDER BY CODE, + CODE +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return UI_CODE_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return UI_CODE_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return UI_CODE_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return UI_CODE_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return UI_CODE_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_UI_CODE', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_UI_CODE'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_UI_CODE', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_UI_CODE'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.CODE) = P_VALUE) or c1rec.CODE = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CODE), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.CODE)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CODE), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.CODE)||'"'); + end if; + l_first := false; + end loop; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.EFLV_CUST_CODE1_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PCG$LK_KAM_SYUS_ID_Process +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- +function PCG$LK_KAM_SYUS_ID_Process( + P_UI_KAM_MGR_NAME in varchar2, + Z_MODE in varchar2 ) return boolean +is + anyRows boolean := false; + cursor c1 is +SELECT CG$LK.SYUS_ID KAM_MANAGER, CG$LK.UI_NAME UI_KAM_MGR_NAME +FROM ( SELECT SYUS.FIRST_NAME||' '||SYUS.LAST_NAME UI_NAME, + SYUS.FIRST_NAME FIRST_NAME, + SYUS.LAST_NAME LAST_NAME, + SYUS.SYUS_ID SYUS_ID + FROM SYSTEM_USERS SYUS + WHERE /* CG$LOVI_WC_START KAM_SYUS_ID 30 */ + (SYUS.SYUS_ID <> caco_utilities.get_system_user AND SYUS.SYUS_ID IN ( SELECT uspr.syus_id FROM user_profiles uspr, system_profiles sypr WHERE uspr.sypr_id = sypr.sypr_id AND UPPER(sypr.name) like '%KAM%') AND SYUS.SYUS_ID IN (SELECT inus.syus_id FROM intermediary_users inus WHERE inus.inte_id IN (SELECT cbcv.inte_id FROM cust_by_cuty_v cbcv))) + /* CG$LOVI_WC_END KAM_SYUS_ID 30 */ + ) CG$LK +WHERE CG$LK.UI_NAME = NBT_VAL.UI_KAM_MGR_NAME; +begin + if ( + P_UI_KAM_MGR_NAME is null + ) + then + CURR_VAL.KAM_MANAGER_SYUS_ID := null; + NBT_VAL.UI_KAM_MGR_NAME := null; + return true; + end if; + NBT_VAL.UI_KAM_MGR_NAME := P_UI_KAM_MGR_NAME; + for c1rec in c1 loop + if (not anyRows) then + anyRows := true; + CURR_VAL.KAM_MANAGER_SYUS_ID := c1rec.KAM_MANAGER; + NBT_VAL.UI_KAM_MGR_NAME := c1rec.UI_KAM_MGR_NAME; + else + exit; + end if; + end loop; + + if (not anyRows) then + cg$errors.push('#KAM Manager Name#2185#: '|| + WSGL.MsgGetText(226,WSGLM.MSG226_INVALID_FK), + 'E', 'WSG', SQLCODE, 'efnow110$cust.PCG$LK_KAM_SYUS_ID_Process'); + return false; + else + return true; + end if; + +exception + when others then + cg$errors.push(SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.PCG$LK_KAM_SYUS_ID_Process'); + return FALSE; +end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PCG$LK_CUST_CUTY_FK_Process +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- +function PCG$LK_CUST_CUTY_FK_Process( + P_CUTY_ID in varchar2, + Z_MODE in varchar2 ) return boolean +is + anyRows boolean := false; + cursor c1 is +SELECT CG$LOOKUP.CUTY_ID CUTY_ID +FROM CUSTOMER_TYPES CG$LOOKUP +WHERE CG$LOOKUP.CUTY_ID = CURR_VAL.CUTY_ID +; +begin + if CURR_IND.CUTY_ID = FALSE then + CURR_VAL.CUTY_ID := to_number(P_CUTY_ID); + end if; + for c1rec in c1 loop + if (not anyRows) then + anyRows := true; + CURR_VAL.CUTY_ID := c1rec.CUTY_ID; + else + exit; + end if; + end loop; + + if (not anyRows) then + cg$errors.push('#Customer Type#2478#: '|| + WSGL.MsgGetText(226,WSGLM.MSG226_INVALID_FK), + 'E', 'WSG', SQLCODE, 'efnow110$cust.PCG$LK_CUST_CUTY_FK_Process'); + return false; + else + return true; + end if; + +exception + when others then + cg$errors.push(SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.PCG$LK_CUST_CUTY_FK_Process'); + return FALSE; +end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.InitialiseDomain +-- +-- Description: Initialises the Domain Record for the given Column Usage +-- +-- Parameters: P_ALIAS The alias of the column usage +-- +-------------------------------------------------------------------------------- + procedure InitialiseDomain(P_ALIAS in varchar2) is + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + if P_ALIAS = 'CUTY_ID' and not D_CUTY_ID.Initialised then + D_CUTY_ID.ColAlias := 'CUTY_ID'; + D_CUTY_ID.ControlType := WSGL.DV_LIST; + D_CUTY_ID.DispWidth := 50; + D_CUTY_ID.DispHeight := 1; + D_CUTY_ID.MaxWidth := 50; + D_CUTY_ID.UseMeanings := True; + D_CUTY_ID.ColOptional := False; + WSGL.LoadDomainValues('CG_REF_CODES', 'CUSTOMERS.CUTY_ID', D_CUTY_ID); + D_CUTY_ID.Initialised := True; + end if; + + if P_ALIAS = 'STATUS' and not D_STATUS.Initialised then + D_STATUS.ColAlias := 'STATUS'; + D_STATUS.ControlType := WSGL.DV_LIST; + D_STATUS.DispWidth := 10; + D_STATUS.DispHeight := 1; + D_STATUS.MaxWidth := 10; + D_STATUS.UseMeanings := True; + D_STATUS.ColOptional := False; + WSGL.LoadDomainValues('CG_REF_CODES', 'CUSTOMERS.STATUS', D_STATUS); + D_STATUS.Initialised := True; + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.InitialseDomain'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow110$cust.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), + CAL_BODY_ATTRIBUTES, + 'efnow110$cust', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow110$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow110$cust', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow110$cust.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.Validate +-- +-- Description: Provides validation of the 'CUST' module component +-- (#Maintain Customer#1058#). +-- +-- Parameters: Z_MODE Ins(ert) or Upd(ate) +-- Z_FORCE_UPDATE Set this to TRUE within this event to force +-- Pre and Post-Update triggers to fire even if +-- no base item values have changed. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function Validate(Z_MODE in varchar2, Z_FORCE_UPDATE in out boolean) return boolean is + L_ERROR_MESS varchar2(1000); + L_RET_VAL boolean := TRUE; + begin + + + begin + CURR_VAL.CODE := FORM_VAL.CODE; + CURR_IND.CODE := TRUE; + exception + when others then + cg$errors.push('#Short Name*#2464#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.NAME := FORM_VAL.NAME; + CURR_IND.NAME := TRUE; + exception + when others then + cg$errors.push('#Full Name*#2461#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.PRIMARY_CONTACT := FORM_VAL.PRIMARY_CONTACT; + CURR_IND.PRIMARY_CONTACT := TRUE; + exception + when others then + cg$errors.push('#Primary Contact*#2472#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.PRIMARY_CONTACT_TEL := FORM_VAL.PRIMARY_CONTACT_TEL; + CURR_IND.PRIMARY_CONTACT_TEL := TRUE; + exception + when others then + cg$errors.push('#Primary Contact Tel.*#2473#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + declare + L_VAL VARCHAR2(50) := FORM_VAL.CUTY_ID; + begin + InitialiseDomain('CUTY_ID'); + if WSGL.ValidDomainValue(D_CUTY_ID, L_VAL) then + CURR_VAL.CUTY_ID := L_VAL; + CURR_IND.CUTY_ID := TRUE; + else + cg$errors.push('#Customer Type#2478#: ' || WSGL.MsgGetText(209,WSGLM.MSG209_INVALID_DV), + 'E', 'WSG', 0, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end if; + end; + declare + L_VAL VARCHAR2(60) := FORM_VAL.STATUS; + begin + InitialiseDomain('STATUS'); + if WSGL.ValidDomainValue(D_STATUS, L_VAL) then + CURR_VAL.STATUS := L_VAL; + CURR_IND.STATUS := TRUE; + else + cg$errors.push('#Status*#2476#: ' || WSGL.MsgGetText(209,WSGLM.MSG209_INVALID_DV), + 'E', 'WSG', 0, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end if; + end; + begin + CURR_VAL.EMAIL_ADDRESS := FORM_VAL.EMAIL_ADDRESS; + CURR_IND.EMAIL_ADDRESS := TRUE; + exception + when others then + cg$errors.push('#Email Address*#2462#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.DESCRIPTION := FORM_VAL.DESCRIPTION; + CURR_IND.DESCRIPTION := TRUE; + exception + when others then + cg$errors.push('#Description#20#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.TELEPHONE := FORM_VAL.TELEPHONE; + CURR_IND.TELEPHONE := TRUE; + exception + when others then + cg$errors.push('#Telephone*#2463#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.FAX := FORM_VAL.FAX; + CURR_IND.FAX := TRUE; + exception + when others then + cg$errors.push('#Fax*#2465#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + CURR_VAL.KAM_TELEPHONE := FORM_VAL.KAM_TELEPHONE; + CURR_IND.KAM_TELEPHONE := TRUE; + exception + when others then + cg$errors.push('#KAM Manager Tel.#2186#: ' || SQLERRM, + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + declare + try_no_fm boolean := false; + begin + begin + CURR_VAL.PERIOD_START := to_date(FORM_VAL.PERIOD_START, 'DD/MM/YYYY'); + exception + when others then + try_no_fm := true; + end; + if try_no_fm then + CURR_VAL.PERIOD_START := to_date(FORM_VAL.PERIOD_START); + end if; + end; + CURR_IND.PERIOD_START := TRUE; + exception + when others then + cg$errors.push('#Period Start*#2460#: ' || SQLERRM||' '||WSGL.MsgGetText(212,WSGLM.MSG212_FOMAT_MASK, 'DD/MM/YYYY'), + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + begin + declare + try_no_fm boolean := false; + begin + begin + CURR_VAL.PERIOD_END := to_date(FORM_VAL.PERIOD_END, 'DD/MM/YYYY'); + exception + when others then + try_no_fm := true; + end; + if try_no_fm then + CURR_VAL.PERIOD_END := to_date(FORM_VAL.PERIOD_END); + end if; + end; + CURR_IND.PERIOD_END := TRUE; + exception + when others then + cg$errors.push('#Period End#27#: ' || SQLERRM||' '||WSGL.MsgGetText(212,WSGLM.MSG212_FOMAT_MASK, 'DD/MM/YYYY'), + 'E', 'WSG', SQLCODE, 'efnow110$cust.Validate'); + L_RET_VAL := FALSE; + end; + + + -- Validation for CG$LK_KAM_SYUS_ID + if Z_MODE = 'INS' then + if PCG$LK_KAM_SYUS_ID_Process( + P_UI_KAM_MGR_NAME=>FORM_VAL.UI_KAM_MGR_NAME, + Z_MODE=>'D') then + CURR_IND.KAM_MANAGER_SYUS_ID := TRUE; + null; + else + L_RET_VAL := FALSE; + return L_RET_VAL; + end if; + end if; + + -- Validation for CG$LK_CUST_CUTY_FK + if Z_MODE = 'INS' then + if PCG$LK_CUST_CUTY_FK_Process( + P_CUTY_ID=>FORM_VAL.CUTY_ID, + Z_MODE=>'D') then + CURR_IND.CUTY_ID := TRUE; + null; + else + L_RET_VAL := FALSE; + return L_RET_VAL; + end if; + end if; + + -- Validation for CG$LK_KAM_SYUS_ID + if Z_MODE = 'UPD' then + if PCG$LK_KAM_SYUS_ID_Process( + P_UI_KAM_MGR_NAME=>FORM_VAL.UI_KAM_MGR_NAME, + Z_MODE=>'D') then + CURR_IND.KAM_MANAGER_SYUS_ID := TRUE; + null; + else + L_RET_VAL := FALSE; + return L_RET_VAL; + end if; + end if; + + -- Validation for CG$LK_CUST_CUTY_FK + if Z_MODE = 'UPD' then + if PCG$LK_CUST_CUTY_FK_Process( + P_CUTY_ID=>FORM_VAL.CUTY_ID, + Z_MODE=>'D') then + CURR_IND.CUTY_ID := TRUE; + null; + else + L_RET_VAL := FALSE; + return L_RET_VAL; + end if; + end if; + + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.Validate'); + return FALSE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.Startup +-- +-- Description: Entry point for the 'CUST' module +-- component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + WSGL.RegisterURL('efnow110$cust.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, '#Maintain Customer#1058#'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'QUERY' then + FormQuery( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + if Z_FORM = 'INSERT' then + FormInsert( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + FormQuery( + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.ActionQuery +-- +-- Description: Called when a Query form is subitted to action the query request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionQuery( + P_UI_CODE in varchar2, + P_UI_NAME in varchar2, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2, + Z_CHK in varchar2 ) is + + L_CHK varchar2(10) := Z_CHK; + L_BUTCHK varchar2(100):= null; + l_dummy_bool boolean := false; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + end if; + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + if (Z_ACTION = QF_INSERT_BUT_ACTION) or (Z_ACTION = QF_INSERT_BUT_CAPTION) then + L_BUTCHK :=QF_INSERT_BUT_ACTION; + end if; + if (Z_ACTION = QF_INSERT_BUT_ACTION) or (Z_ACTION = QF_INSERT_BUT_CAPTION) then + FormInsert( + Z_DIRECT_CALL=>TRUE + ); + else + + + + QueryView( + P_UI_CODE=>P_UI_CODE, + P_UI_NAME=>P_UI_NAME, + Z_EXECUTE_QUERY=>'Y', + Z_DIRECT_CALL=>TRUE + ); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.ActionQuery'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits( + P_UI_CODE in varchar2, + P_UI_NAME in varchar2) return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow110$cust') then + return -1; + end if; + + if not BuildSQL(P_UI_CODE, + P_UI_NAME) then + return -1; + end if; + + if not PreQuery(P_UI_CODE, + P_UI_NAME) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Customer#1058#', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.BuildSQL +-- +-- Description: Builds the SQL for the 'CUST' module component (#Maintain Customer#1058#). +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + P_UI_CODE in varchar2, + P_UI_NAME in varchar2, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE CUST_ID = ' || to_char(CURR_VAL.CUST_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + + null; + end if; + + ZONE_SQL := 'SELECT CUST_ID, + CODE, + NAME, + PRIMARY_CONTACT, + PRIMARY_CONTACT_TEL, + CUTY_ID, + STATUS, + EMAIL_ADDRESS, + DESCRIPTION, + TELEPHONE, + FAX, + KAM_MANAGER, + KAM_TELEPHONE, + CREATED_BY, + CREATED_ON, + UPDATED_BY, + UPDATED_ON, + PERIOD_START, + PERIOD_END + FROM ( SELECT CUST.CUST_ID CUST_ID, + CUST.CODE CODE, + CUST.NAME NAME, + CUST.PRIMARY_CONTACT PRIMARY_CONTACT, + CUST.PRIMARY_CONTACT_TEL PRIMARY_CONTACT_TEL, + CUST.CUTY_ID CUTY_ID, + CUST.STATUS STATUS, + CUST.EMAIL_ADDRESS EMAIL_ADDRESS, + CUST.DESCRIPTION DESCRIPTION, + CUST.TELEPHONE TELEPHONE, + CUST.FAX FAX, + CUST.KAM_MANAGER_SYUS_ID KAM_MANAGER, + CUST.KAM_TELEPHONE KAM_TELEPHONE, + CUST.CREATED_BY CREATED_BY, + CUST.CREATED_ON CREATED_ON, + CUST.UPDATED_BY UPDATED_BY, + CUST.UPDATED_ON UPDATED_ON, + CUST.PERIOD_START PERIOD_START, + CUST.PERIOD_END PERIOD_END, + CUST.ROWID CG$ROW_ID +FROM CUSTOMERS CUST +WHERE ( /* CG$MDTU_QWC_START CUST.CUST */ + (CUST.CUST_ID <> cout_system_configuration.get_configuration_item(''CUST_ID'') AND (CUST.CODE = efnow110$cust.get_cust_code AND CUST.NAME = efnow110$cust.get_cust_name) OR (CUST.CODE = efnow110$cust.get_cust_code AND efnow110$cust.get_cust_name IS NULL) OR (efnow110$cust.get_cust_code IS NULL AND CUST.NAME = efnow110$cust.get_cust_name) OR (efnow110$cust.get_cust_code IS NULL AND efnow110$cust.get_cust_name IS NULL)) + /* CG$MDTU_QWC_END CUST.CUST */ + ) + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY NAME'; + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + DEF_BODY_ATTRIBUTES, 'efnow110$cust.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, CURR_VAL.CUST_ID); + dbms_sql.define_column(I_CURSOR, 2, CURR_VAL.CODE, 20); + dbms_sql.define_column(I_CURSOR, 3, CURR_VAL.NAME, 100); + dbms_sql.define_column(I_CURSOR, 4, CURR_VAL.PRIMARY_CONTACT, 50); + dbms_sql.define_column(I_CURSOR, 5, CURR_VAL.PRIMARY_CONTACT_TEL, 30); + dbms_sql.define_column(I_CURSOR, 6, CURR_VAL.CUTY_ID); + dbms_sql.define_column(I_CURSOR, 7, CURR_VAL.STATUS, 10); + dbms_sql.define_column(I_CURSOR, 8, CURR_VAL.EMAIL_ADDRESS, 80); + dbms_sql.define_column(I_CURSOR, 9, CURR_VAL.DESCRIPTION, 80); + dbms_sql.define_column(I_CURSOR, 10, CURR_VAL.TELEPHONE, 30); + dbms_sql.define_column(I_CURSOR, 11, CURR_VAL.FAX, 30); + dbms_sql.define_column(I_CURSOR, 12, CURR_VAL.KAM_MANAGER_SYUS_ID); + dbms_sql.define_column(I_CURSOR, 13, CURR_VAL.KAM_TELEPHONE, 30); + dbms_sql.define_column(I_CURSOR, 14, CURR_VAL.CREATED_BY, 30); + dbms_sql.define_column(I_CURSOR, 15, CURR_VAL.CREATED_ON); + dbms_sql.define_column(I_CURSOR, 16, CURR_VAL.UPDATED_BY, 30); + dbms_sql.define_column(I_CURSOR, 17, CURR_VAL.UPDATED_ON); + dbms_sql.define_column(I_CURSOR, 18, CURR_VAL.PERIOD_START); + dbms_sql.define_column(I_CURSOR, 19, CURR_VAL.PERIOD_END); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + '', 'efnow110$cust.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, CURR_VAL.CUST_ID); + dbms_sql.column_value(I_CURSOR, 2, CURR_VAL.CODE); + dbms_sql.column_value(I_CURSOR, 3, CURR_VAL.NAME); + dbms_sql.column_value(I_CURSOR, 4, CURR_VAL.PRIMARY_CONTACT); + dbms_sql.column_value(I_CURSOR, 5, CURR_VAL.PRIMARY_CONTACT_TEL); + dbms_sql.column_value(I_CURSOR, 6, CURR_VAL.CUTY_ID); + dbms_sql.column_value(I_CURSOR, 7, CURR_VAL.STATUS); + dbms_sql.column_value(I_CURSOR, 8, CURR_VAL.EMAIL_ADDRESS); + dbms_sql.column_value(I_CURSOR, 9, CURR_VAL.DESCRIPTION); + dbms_sql.column_value(I_CURSOR, 10, CURR_VAL.TELEPHONE); + dbms_sql.column_value(I_CURSOR, 11, CURR_VAL.FAX); + dbms_sql.column_value(I_CURSOR, 12, CURR_VAL.KAM_MANAGER_SYUS_ID); + dbms_sql.column_value(I_CURSOR, 13, CURR_VAL.KAM_TELEPHONE); + dbms_sql.column_value(I_CURSOR, 14, CURR_VAL.CREATED_BY); + dbms_sql.column_value(I_CURSOR, 15, CURR_VAL.CREATED_ON); + dbms_sql.column_value(I_CURSOR, 16, CURR_VAL.UPDATED_BY); + dbms_sql.column_value(I_CURSOR, 17, CURR_VAL.UPDATED_ON); + dbms_sql.column_value(I_CURSOR, 18, CURR_VAL.PERIOD_START); + dbms_sql.column_value(I_CURSOR, 19, CURR_VAL.PERIOD_END); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.CUST_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + '', 'efnow110$cust.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.FormQuery +-- +-- Description: This procedure builds an HTML form for entry of query criteria. +-- The criteria entered are to restrict the query of the 'CUST' +-- module component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormQuery( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + L_SUCCESS boolean := TRUE; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + end if; + + L_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + WSGL.OpenPageHead(''||' : '||'#Maintain Customer#1058#'); + WSGL.METATag; + efnow110$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>QF_BODY_ATTRIBUTES || 'onLoad="return CUST_OnLoad()"'); + efnow110$js$cust.CreateQueryJavaScript(LOV_FRAME,QF_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + htp.p(caco_system.menu); + efnow110$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + htp.p(WSGL.MsgGetText(116,WSGLM.DSP116_ENTER_QRY_CAPTION,'#Maintain Customer#1058#')); + htp.para; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cust.actionquery', cattributes => 'NAME="efnow110$cust$QForm"'); + + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + for i in 1..QF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(19, 'LEFT', NULL); + WSGL.LayoutHeader(30, 'LEFT', NULL); + end loop; + WSGL.LayoutRowEnd; + + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Short Name*#2464#:')); + WSGL.LayoutData(EFLV_CUST_CODE1_LOV(NULL, WSGL.CTL_QUERY, 'Q', true)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Full Name*#2461#:')); + WSGL.LayoutData(EFLV_CUST_NAME1_LOV(NULL, WSGL.CTL_QUERY, 'Q', true)); + WSGL.LayoutRowEnd; + + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', QF_QUERY_BUT_CAPTION, 'btnQFQ', 'this.form.Z_ACTION.value=\''' || QF_QUERY_BUT_ACTION || '\'''); + htp.formReset(QF_CLEAR_BUT_CAPTION, 'ID="'||QF_CLEAR_BUT_CAPTION||'"'); + + htp.p (''); + + if WSGL.IsSupported ('NOSCRIPT') + then + + htp.p (''); + + end if; + + WSGL.HiddenField('Z_CHK', to_char(WSGL.Checksum + (''))); + htp.formClose; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="QF$AIFormBottom"'); + htp.formClose; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + QF_BODY_ATTRIBUTES, 'efnow110$cust.FormQuery'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.FormView +-- +-- Description: This procedure builds an HTML form for view/update of fields in +-- the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: Z_FORM_STATUS Status of the form +-- +-------------------------------------------------------------------------------- + procedure FormView(Z_FORM_STATUS in number, + Q_UI_CODE in varchar2, + Q_UI_NAME in varchar2, + Z_POST_DML in boolean, + Z_MULTI_PAGE in boolean, + Z_ACTION in varchar2, + Z_START in varchar2) is + + C_CUIN varchar2(10); + I_CURSOR integer; + I_VOID integer; + I_COUNT integer; + l_row integer := 0; + l_rowset_row integer := null; + l_error varchar2(2000); + l_rows_ret integer; + l_row_deleted boolean := false; + l_row_no_lock boolean := false; + l_total_rows integer := 0; + I_START number(38) := to_number(Z_START); + I_PREV_BUT boolean := false; + I_NEXT_BUT boolean := false; + l_total_text varchar2(200) := ''; + l_ntom_butstr varchar2(2000) := VF_NTOM_BUT_CAPTION; + l_force_upd boolean := false; + l_success boolean := true; + l_skip_data boolean := false; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + l_success := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + + WSGL.OpenPageHead(''||' : '||'#Maintain Customer#1058#'); + WSGL.METATag; + htp.script('FormType = "Update";'); + efnow110$.TemplateHeader(TRUE,4); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>VF_BODY_ATTRIBUTES || 'onLoad="return CUST_OnLoad()"'); + + efnow110$js$cust.CreateViewJavaScript( + VF_ROWS_UPDATED, + VF_ROWS_DELETED, + VF_ROWS_ERROR, + VF_BODY_ATTRIBUTES, + IF_ROWS_INSERTED, + IF_ROWS_ERROR, + LOV_FRAME + ); + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + + InitialiseDomain('CUTY_ID'); + InitialiseDomain('STATUS'); + + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="VF$AIFormTop"'); + htp.formClose; + + + + if Z_FORM_STATUS = WSGL.FORM_STATUS_ERROR then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Customer#1058#', VF_BODY_ATTRIBUTES); + htp.script('DataChangeErrors = true;'); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_UPD then + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(207, WSGLM.MSG207_ROW_UPDATED), + ''||' : '||'#Maintain Customer#1058#', VF_BODY_ATTRIBUTES); + htp.script('DataChange = true;'); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_INS then + WSGL.DisplayMessage(WSGL.MESS_SUCCESS, WSGL.MsgGetText(208, WSGLM.MSG208_ROW_INSERTED), + ''||' : '||'#Maintain Customer#1058#', VF_BODY_ATTRIBUTES); + elsif Z_FORM_STATUS = WSGL.FORM_STATUS_NO_UPD then + htp.p( ''||WSGL.MsgGetText(136,WSGLM.DSP136_NO_ROW_UPDATED)||'
' ); + end if; + if VF_ROWS_UPDATED > 0 then + htp.p(htf.bold(htf.br || WSGL.MsgGetText(137,WSGLM.DSP137_ROWS_UPDATED)) || ' ' ||to_char(VF_ROWS_UPDATED) ); + end if; + if VF_ROWS_ERROR > 0 then + htp.p(htf.bold(htf.br || WSGL.MsgGetText(138,WSGLM.DSP138_ERRORS)) || ' ' ||to_char(VF_ROWS_ERROR) ); + end if; + if VF_ROWS_DELETED > 0 then + htp.p(htf.bold(htf.br || WSGL.MsgGetText(139,WSGLM.DSP139_ROWS_DELETED)) || ' ' ||to_char(VF_ROWS_DELETED) ); + end if; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cust.actionview', cattributes => 'NAME="efnow110$cust$VForm"'); + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + + WSGL.LayoutRowStart; + for i in 1..VF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(29, 'LEFT', NULL); + WSGL.LayoutHeader(50, 'LEFT', NULL); + end loop; + + + WSGL.LayoutHeader(2,'LEFT',null); + + WSGL.LayoutHeader(10, 'LEFT', null); + WSGL.LayoutRowEnd; + if Z_MULTI_PAGE then + if (Z_ACTION = VF_LAST_BUT_ACTION) or (Z_ACTION = VF_LAST_BUT_CAPTION) or + (Z_ACTION = VF_COUNT_BUT_ACTION) or (Z_ACTION = VF_COUNT_BUT_CAPTION) or + (VF_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_UI_CODE=>Q_UI_CODE, + P_UI_NAME=>Q_UI_NAME); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = VF_COUNT_BUT_ACTION) or (Z_ACTION = VF_COUNT_BUT_CAPTION) or (VF_TOTAL_COUNT_REQD) then + l_total_text := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + + if Z_START IS NULL or (Z_ACTION = VF_FIRST_BUT_ACTION) or (Z_ACTION = VF_FIRST_BUT_CAPTION) then + I_START := 1; + elsif (Z_ACTION = VF_NEXT_BUT_ACTION) or (Z_ACTION = VF_NEXT_BUT_CAPTION) then + I_START := I_START + VF_RECORD_SET_SIZE; + elsif (Z_ACTION = VF_PREV_BUT_ACTION) or (Z_ACTION = VF_PREV_BUT_CAPTION) then + I_START := I_START - VF_RECORD_SET_SIZE; + elsif (Z_ACTION = VF_LAST_BUT_ACTION) or (Z_ACTION = VF_LAST_BUT_CAPTION) then + I_START := 1 + (floor((I_COUNT-1)/VF_RECORD_SET_SIZE)*VF_RECORD_SET_SIZE); + end if; + + if I_START < 1 then + I_START := 1; + end if; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + end if; + OpenZoneSql(I_CURSOR); + l_row := 0; + if VF_ROW_SET.count = 0 then + I_VOID := dbms_sql.execute(I_CURSOR); + end if; + while true loop + if not l_row_deleted then + l_row := l_row + 1; + end if; + + l_row_deleted := false; + l_row_no_lock := false; + if VF_ROW_SET.count > 0 then + if l_rowset_row is null then + l_rowset_row := VF_ROW_SET.first; + else + l_rowset_row := VF_ROW_SET.next( l_rowset_row ); + end if; + if l_rowset_row is not null then + if not VF_ROW_SET( l_rowset_row ).ROW_DELETED then + dbms_sql.bind_variable(I_CURSOR, 'b_row_id', rowidtochar(VF_ROW_SET( l_rowset_row ).ROW_ID)); + I_VOID := dbms_sql.execute(I_CURSOR); + else + l_row_deleted := true; + end if; + if not VF_ROW_SET( l_rowset_row ).ROW_NOT_LOCKED then + FORM_VAL.CODE := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_CODE); + FORM_VAL.NAME := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_NAME); + FORM_VAL.PRIMARY_CONTACT := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_PRIMARY_CONTACT); + FORM_VAL.PRIMARY_CONTACT_TEL := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_PRIMARY_CONTACT_TEL); + FORM_VAL.CUTY_ID := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_CUTY_ID); + FORM_VAL.STATUS := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_STATUS); + FORM_VAL.EMAIL_ADDRESS := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_EMAIL_ADDRESS); + FORM_VAL.DESCRIPTION := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_DESCRIPTION); + FORM_VAL.TELEPHONE := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_TELEPHONE); + FORM_VAL.FAX := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_FAX); + FORM_VAL.KAM_TELEPHONE := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_KAM_TELEPHONE); + FORM_VAL.PERIOD_START := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_PERIOD_START); + FORM_VAL.PERIOD_END := WSGL.EscapeItem(VF_ROW_SET( l_rowset_row ).F_PERIOD_END); + l_force_upd := false; + if not PostQuery(Z_POST_DML, l_force_upd) then + if cg$errors.pop(l_error) then + WSGL.LayoutTextLine(htf.bold(''|| + htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + end if; + end if; + + else + l_row_no_lock := true; + end if; + if VF_ROW_SET( l_rowset_row ).SUCCESS_FLAG then + htp.script('DataChange = true;'); + end if; + if not VF_ROW_SET( l_rowset_row ).SUCCESS_FLAG and cg$errors.pop_head( l_error ) then + htp.script('DataChangeErrors = true;'); + WSGL.LayoutTextLine(htf.bold(''||htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + end if; + else + exit; + end if; + end if; + + if not (l_row_deleted) then + if Z_MULTI_PAGE then + while l_total_rows < I_START - 1 loop + l_rows_ret := dbms_sql.fetch_rows(I_CURSOR); + l_total_rows := l_total_rows + l_rows_ret; + if l_rows_ret = 0 then + exit; + end if; + end loop; + end if; + l_rows_ret := dbms_sql.fetch_rows(I_CURSOR); + l_total_rows := l_total_rows + l_rows_ret; + + if (l_rows_ret > 0) and (l_total_rows < (I_START + VF_RECORD_SET_SIZE)) then + AssignZoneRow(I_CURSOR); + else + exit; + end if; + end if; + if (VF_ROW_SET.count = 0 and Z_FORM_STATUS != WSGL.FORM_STATUS_ERROR) or l_row_no_lock then + FORM_VAL.CODE := WSGL.EscapeItem(CURR_VAL.CODE); + FORM_VAL.NAME := WSGL.EscapeItem(CURR_VAL.NAME); + FORM_VAL.PRIMARY_CONTACT := WSGL.EscapeItem(CURR_VAL.PRIMARY_CONTACT); + FORM_VAL.PRIMARY_CONTACT_TEL := WSGL.EscapeItem(CURR_VAL.PRIMARY_CONTACT_TEL); + FORM_VAL.CUTY_ID := WSGL.EscapeItem(WSGL.DomainMeaning(D_CUTY_ID, CURR_VAL.CUTY_ID)); + FORM_VAL.STATUS := WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)); + FORM_VAL.EMAIL_ADDRESS := WSGL.EscapeItem(CURR_VAL.EMAIL_ADDRESS); + FORM_VAL.DESCRIPTION := WSGL.EscapeItem(CURR_VAL.DESCRIPTION); + FORM_VAL.TELEPHONE := WSGL.EscapeItem(CURR_VAL.TELEPHONE); + FORM_VAL.FAX := WSGL.EscapeItem(CURR_VAL.FAX); + FORM_VAL.KAM_TELEPHONE := WSGL.EscapeItem(CURR_VAL.KAM_TELEPHONE); + FORM_VAL.PERIOD_START := WSGL.EscapeItem(ltrim(to_char(CURR_VAL.PERIOD_START, 'DD/MM/YYYY'))); + FORM_VAL.PERIOD_END := WSGL.EscapeItem(ltrim(to_char(CURR_VAL.PERIOD_END, 'DD/MM/YYYY'))); + end if; + FORM_VAL.CUST_ID := WSGL.EscapeItem(CURR_VAL.CUST_ID); + FORM_VAL.KAM_MANAGER := WSGL.EscapeItem(CURR_VAL.KAM_MANAGER_SYUS_ID); + FORM_VAL.CREATED_BY := WSGL.EscapeItem(CURR_VAL.CREATED_BY); + FORM_VAL.CREATED_ON := WSGL.EscapeItem(ltrim(to_char(CURR_VAL.CREATED_ON, 'DD-MON-RRRR'))); + FORM_VAL.UPDATED_BY := WSGL.EscapeItem(CURR_VAL.UPDATED_BY); + FORM_VAL.UPDATED_ON := WSGL.EscapeItem(ltrim(to_char(CURR_VAL.UPDATED_ON, 'DD-MON-RRRR'))); + + if l_row > 1 then + WSGL.Separator('class = cgupseparator'); + end if; + l_force_upd := false; + if not PostQuery(Z_POST_DML, l_force_upd) then + if cg$errors.pop(l_error) then + WSGL.LayoutTextLine(htf.bold(''|| + htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + end if; + end if; + if not l_row_deleted then + WSGL.HiddenField('P_CUST_ID', CURR_VAL.CUST_ID); + WSGL.HiddenField('O_CUST_ID', CURR_VAL.CUST_ID); + end if; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Short Name*#2464#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.CODE); + else + WSGL.LayoutData(WSGL.BuildTextControl('CODE', '10', '1', '20',FORM_VAL.CODE, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Full Name*#2461#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.NAME); + else + WSGL.LayoutData(WSGL.BuildTextControl('NAME', '38', '1', '100',FORM_VAL.NAME, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if ( l_skip_data ) then + WSGL.SkipData; + else + WSGL.LayoutData(' '); + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutData(' '); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Primary Contact*#2472#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.PRIMARY_CONTACT); + else + WSGL.LayoutData(WSGL.BuildTextControl('PRIMARY_CONTACT', '38', '1', '50',FORM_VAL.PRIMARY_CONTACT, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Primary Contact Tel.*#2473#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.PRIMARY_CONTACT_TEL); + else + WSGL.LayoutData(WSGL.BuildTextControl('PRIMARY_CONTACT_TEL', '38', '1', '30',FORM_VAL.PRIMARY_CONTACT_TEL, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if ( l_skip_data ) then + WSGL.SkipData; + else + WSGL.LayoutData(' '); + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutData(' '); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Customer Type#2478#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.CUTY_ID); + else + WSGL.LayoutData(WSGL.BuildDVControl(D_CUTY_ID, WSGL.CTL_UPDATABLE, FORM_VAL.CUTY_ID, p_onchange=>TRUE, p_row=>(l_row), p_multirow=>true, p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Status*#2476#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.STATUS); + else + WSGL.LayoutData(WSGL.BuildDVControl(D_STATUS, WSGL.CTL_UPDATABLE, FORM_VAL.STATUS, p_onchange=>TRUE, p_row=>(l_row), p_multirow=>true, p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if ( l_skip_data ) then + WSGL.SkipData; + else + WSGL.LayoutData(' '); + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutData(' '); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Email Address*#2462#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.EMAIL_ADDRESS); + else + WSGL.LayoutData(WSGL.BuildTextControl('EMAIL_ADDRESS', '38', '1', '80',FORM_VAL.EMAIL_ADDRESS, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Description#20#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.DESCRIPTION); + else + WSGL.LayoutData(WSGL.BuildTextControl('DESCRIPTION', '30', '4', '32760',FORM_VAL.DESCRIPTION, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if ( l_skip_data ) then + WSGL.SkipData; + else + WSGL.LayoutData(' '); + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutData(' '); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Telephone*#2463#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.TELEPHONE); + else + WSGL.LayoutData(WSGL.BuildTextControl('TELEPHONE', '38', '1', '30',FORM_VAL.TELEPHONE, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Fax*#2465#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.FAX); + else + WSGL.LayoutData(WSGL.BuildTextControl('FAX', '38', '1', '30',FORM_VAL.FAX, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if ( l_skip_data ) then + WSGL.SkipData; + else + WSGL.LayoutData(' '); + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutData(' '); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#KAM Manager Name#2185#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.UI_KAM_MGR_NAME); + else + WSGL.LayoutData(WSGL.BuildTextControl('UI_KAM_MGR_NAME', '20', '1', '32760',FORM_VAL.UI_KAM_MGR_NAME, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/') || ' ' || + WSGJSL.LOVButton('UI_KAM_MGR_NAME',LOV_BUTTON_TEXT,'efnow110$cust$VForm', (l_row - 1))); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#KAM Manager Tel.#2186#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.KAM_TELEPHONE); + else + WSGL.LayoutData(WSGL.BuildTextControl('KAM_TELEPHONE', '38', '1', '30',FORM_VAL.KAM_TELEPHONE, p_onchange=>TRUE, p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if ( l_skip_data ) then + WSGL.SkipData; + else + WSGL.LayoutData(' '); + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutData(' '); + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Period Start*#2460#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.PERIOD_START); + else + WSGL.LayoutData(WSGL.BuildTextControl('PERIOD_START', '11', '1', '10',FORM_VAL.PERIOD_START, p_onchange=>TRUE , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_prompt => '#Period Start*#2460#' + , p_cal_date_format => 'DD/MM/YYYY' + , p_form => 'efnow110$cust$VForm', p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + l_skip_data := false; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Period End#27#:')); + if (l_row_deleted) then + WSGL.LayoutData(FORM_VAL.PERIOD_END); + else + WSGL.LayoutData(WSGL.BuildTextControl('PERIOD_END', '11', '1', '10',FORM_VAL.PERIOD_END, p_onchange=>TRUE , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_prompt => '#Period End#27#' + , p_cal_date_format => 'DD/MM/YYYY' + , p_form => 'efnow110$cust$VForm', p_row=>(l_row), p_img_path=>'/images/')); + end if; + WSGL.LayoutRowEnd; + if (l_row_deleted) then + WSGL.LayoutData(' '); + else + WSGL.LayoutData(''); + end if; + WSGL.LayoutRowEnd; + + -- Calculate Checksums for details + C_CUIN := to_char(WSGL.Checksum + ( CURR_VAL.CUST_ID + || to_char(efnow110$cust.CURR_VAL.CUST_ID) + )); + + + WSGL.HiddenField('C_CUIN', C_CUIN); + + + htp.script('P_CUST_ID[' || (l_row - 1) ||'] = "' || WSGL.EscapeURLParam(nvl(to_char(CURR_VAL.CUST_ID), '')) || '";' ); + htp.script('P_2[' || (l_row - 1) ||'] = "' || WSGL.EscapeURLParam(nvl(to_char(efnow110$cust.CURR_VAL.CUST_ID), '')) || '";' ); + htp.script('CUIN_CHK_VALUE[' || (l_row - 1) ||'] = ' || C_CUIN || ';' ); + + + + + + WSGL.LayoutData( + WSGL.ReturnSubmitButton('Z_ACTION', '#Intermediaries#1059#', 'AI_INTE', p_target=>'_top', p_index=>(l_row-1)) +); + WSGL.LayoutRowEnd; + + + if not (l_row_deleted) then + htp.p(WSGJSL.OpenScript); + if l_force_upd then + htp.p('document.write('''');'); + else + htp.p('document.write('''');'); + end if; + htp.p(WSGJSL.CloseScript); + WSGL.HiddenField('O_CODE', CURR_VAL.CODE); + WSGL.HiddenField('O_NAME', CURR_VAL.NAME); + WSGL.HiddenField('O_PRIMARY_CONTACT', CURR_VAL.PRIMARY_CONTACT); + WSGL.HiddenField('O_PRIMARY_CONTACT_TEL', CURR_VAL.PRIMARY_CONTACT_TEL); + WSGL.HiddenField('O_CUTY_ID', CURR_VAL.CUTY_ID); + WSGL.HiddenField('O_STATUS', CURR_VAL.STATUS); + WSGL.HiddenField('O_EMAIL_ADDRESS', CURR_VAL.EMAIL_ADDRESS); + WSGL.HiddenField('O_DESCRIPTION', CURR_VAL.DESCRIPTION); + WSGL.HiddenField('O_TELEPHONE', CURR_VAL.TELEPHONE); + WSGL.HiddenField('O_FAX', CURR_VAL.FAX); + WSGL.HiddenField('O_KAM_MANAGER', CURR_VAL.KAM_MANAGER_SYUS_ID); + WSGL.HiddenField('O_KAM_TELEPHONE', CURR_VAL.KAM_TELEPHONE); + WSGL.HiddenField('O_CREATED_BY', CURR_VAL.CREATED_BY); + WSGL.HiddenField('O_CREATED_ON', to_char(CURR_VAL.CREATED_ON,'JSSSSS')); + WSGL.HiddenField('O_UPDATED_BY', CURR_VAL.UPDATED_BY); + WSGL.HiddenField('O_UPDATED_ON', to_char(CURR_VAL.UPDATED_ON,'JSSSSS')); + WSGL.HiddenField('O_PERIOD_START', to_char(CURR_VAL.PERIOD_START,'JSSSSS')); + WSGL.HiddenField('O_PERIOD_END', to_char(CURR_VAL.PERIOD_END,'JSSSSS')); + + end if; + + end loop; + WSGL.LayoutClose; + + if l_row < 3 then + WSGL.HiddenField('P_CUST_ID',''); + WSGL.HiddenField('P_CODE',''); + WSGL.HiddenField('P_NAME',''); + WSGL.HiddenField('P_PRIMARY_CONTACT',''); + WSGL.HiddenField('P_PRIMARY_CONTACT_TEL',''); + WSGL.HiddenField('P_CUTY_ID',''); + WSGL.HiddenField('P_STATUS',''); + WSGL.HiddenField('P_EMAIL_ADDRESS',''); + WSGL.HiddenField('P_DESCRIPTION',''); + WSGL.HiddenField('P_TELEPHONE',''); + WSGL.HiddenField('P_FAX',''); + WSGL.HiddenField('P_UI_KAM_MGR_NAME',''); + WSGL.HiddenField('P_KAM_TELEPHONE',''); + WSGL.HiddenField('P_PERIOD_START',''); + WSGL.HiddenField('P_PERIOD_END',''); + WSGL.HiddenField('O_CODE', ''); + WSGL.HiddenField('O_NAME', ''); + WSGL.HiddenField('O_PRIMARY_CONTACT', ''); + WSGL.HiddenField('O_PRIMARY_CONTACT_TEL', ''); + WSGL.HiddenField('O_CUTY_ID', ''); + WSGL.HiddenField('O_STATUS', ''); + WSGL.HiddenField('O_EMAIL_ADDRESS', ''); + WSGL.HiddenField('O_DESCRIPTION', ''); + WSGL.HiddenField('O_TELEPHONE', ''); + WSGL.HiddenField('O_FAX', ''); + WSGL.HiddenField('O_KAM_MANAGER', ''); + WSGL.HiddenField('O_KAM_TELEPHONE', ''); + WSGL.HiddenField('O_CREATED_BY', ''); + WSGL.HiddenField('O_CREATED_ON', ''); + WSGL.HiddenField('O_UPDATED_BY', ''); + WSGL.HiddenField('O_UPDATED_ON', ''); + WSGL.HiddenField('O_PERIOD_START', ''); + WSGL.HiddenField('O_PERIOD_END', ''); + WSGL.HiddenField('z_modified','dummy_row'); + end if; + + WSGL.HiddenField('C_CUIN', ''); + dbms_sql.close_cursor(I_CURSOR); + + if l_rows_ret > 0 then + I_NEXT_BUT := true; + end if; + + if l_total_rows = 0 then + htp.p(WSGL.MsgGetText(112, WSGLM.DSP112_NO_RECORDS)); + htp.para; + elsif Z_MULTI_PAGE then + if I_START = l_total_rows or VF_RECORD_SET_SIZE = 1 then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_START))||l_total_text); + else + if I_NEXT_BUT then + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(l_total_rows - 1))||l_total_text); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(l_total_rows))||l_total_text); + end if; + end if; + htp.para; + end if; + + WSGL.SubmitButton('Z_ACTION', VF_UPDATE_BUT_CAPTION, 'btnVFU', 'this.form.Z_ACTION.value=\''' || VF_UPDATE_BUT_ACTION || '\'''); + htp.formReset(VF_CLEAR_BUT_CAPTION, cattributes=>'ID="'||VF_CLEAR_BUT_CAPTION||'"'||' onClick="return JSLRevertForm( this.form, '|| l_row ||' )"'); + + + if VF_ROW_SET.count > 0 then + I_START := nvl(I_START, 1); + l_ntom_butstr := replace(l_ntom_butstr, '%s', to_char(I_START)); + l_ntom_butstr := replace(l_ntom_butstr, '%e', to_char(I_START + VF_RECORD_SET_SIZE - 1)); + WSGL.RecordListButton(TRUE, 'Z_ACTION', l_ntom_butstr, p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_NTOM_BUT_ACTION || '\'', true)"', + p_type_button=>true); + end if; + + WSGL.SubmitButton('Z_ACTION', VF_INSERT_BUT_CAPTION, 'btnVFI', 'this.form.Z_ACTION.value=\''' || VF_INSERT_BUT_ACTION || '\'''); + if Z_MULTI_PAGE and VF_ROW_SET.count = 0 then + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', VF_FIRST_BUT_CAPTION, WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_FIRST_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', VF_PREV_BUT_CAPTION, WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_PREV_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', VF_NEXT_BUT_CAPTION, WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_NEXT_BUT_ACTION || '\'', true)"', + p_type_button=>true); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', VF_LAST_BUT_CAPTION, WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="return JSLCheckModified( this.form, \''' || VF_LAST_BUT_ACTION || '\'', true)"', + p_type_button=>true); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', VF_REQUERY_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_REQUERY_BUT_ACTION || '\'', true)"', + p_type_button=>true); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', VF_COUNT_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_COUNT_BUT_ACTION || '\'', true)"', + p_type_button=>true); + htp.para; + + WSGL.RecordListButton(TRUE, 'Z_ACTION', VF_QUERY_BUT_CAPTION,p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_QUERY_BUT_ACTION || '\'', true)"', + p_type_button=>true); + end if; + + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''||CURR_VAL.CUST_ID))); + + WSGL.HiddenField('Q_UI_CODE', Q_UI_CODE); + WSGL.HiddenField('Q_UI_NAME', Q_UI_NAME); + + WSGL.HiddenField('Z_START', to_char(I_START)); + + htp.formClose; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cust.actionview', ctarget=>'_parent', cattributes => 'NAME="efnow110$cust$VFormQry"'); + SaveState; + htp.p (''); + WSGL.HiddenField('z_modified','dummy_row'); + WSGL.HiddenField('P_CUST_ID',''); + if VF_ROW_SET.count = 0 and not Z_MULTI_PAGE then + WSGL.RecordListButton(TRUE, 'Z_ACTION', VF_QUERY_BUT_CAPTION, p_dojs=>FALSE, + buttonJS => 'onClick="return JSLCheckModified( this.form, \''' || VF_QUERY_BUT_ACTION || '\'', true)"', + p_type_button=>true); + end if; + htp.formClose; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="VF$AIFormBottom"'); + htp.formClose; + WSGL.ReturnLinks('0.1', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.FormView'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.QueryView +-- +-- Description: Queries the details of a single row in preparation for display. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryView( + K_CUST_ID in varchar2, + P_UI_CODE in varchar2, + P_UI_NAME in varchar2, + Z_EXECUTE_QUERY in varchar2, + Z_POST_DML in boolean, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_CHK in varchar2) is + L_ROW_ID ROWID; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + + + WSGL.RegisterURL('efnow110$cust.queryview'); + WSGL.AddURLParam('K_CUST_ID', K_CUST_ID); + WSGL.AddURLParam('P_UI_CODE', P_UI_CODE); + WSGL.AddURLParam('P_UI_NAME', P_UI_NAME); + WSGL.AddURLParam('Z_EXECUTE_QUERY', Z_EXECUTE_QUERY); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + if not Z_DIRECT_CALL then + + null; + + end if; + + + + + null; + + + + if K_CUST_ID is not null then + CURR_VAL.CUST_ID := K_CUST_ID; + end if; + if (Z_ACTION = VF_INSERT_BUT_ACTION) or (Z_ACTION = VF_INSERT_BUT_CAPTION) then + FormInsert( + Z_DIRECT_CALL=>TRUE); + return; + end if; + + if Z_EXECUTE_QUERY is null then + if VF_ROW_SET.count = 0 then + if BuildSQL( Z_QUERY_BY_KEY=>true) then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Q_UI_CODE=>P_UI_CODE, + Q_UI_NAME=>P_UI_NAME, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>false, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + else + if BuildSQL( z_bind_row_id=>true ) then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Q_UI_CODE=>P_UI_CODE, + Q_UI_NAME=>P_UI_NAME, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>false, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + end if; + + else + if not PreQuery( + P_UI_CODE=>P_UI_CODE, + P_UI_NAME=>P_UI_NAME) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Customer#1058#', VF_BODY_ATTRIBUTES); + return; + end if; + + if BuildSQL + (P_UI_CODE=>P_UI_CODE + ,P_UI_NAME=>P_UI_NAME + ) + then + FormView(Z_FORM_STATUS=>Z_FORM_STATUS, + Q_UI_CODE=>P_UI_CODE, + Q_UI_NAME=>P_UI_NAME, + Z_POST_DML=>Z_POST_DML, Z_MULTI_PAGE=>true, Z_ACTION=>Z_ACTION, Z_START=>Z_START); + end if; + + end if; + + exception + when NO_DATA_FOUND then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(204, WSGLM.MSG204_ROW_DELETED), + ''||' : '||'#Maintain Customer#1058#', VF_BODY_ATTRIBUTES); + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.QueryView'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.QueryViewByKey +-- +-- Description: Queries the details of a single row in preparation for display. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure QueryViewByKey( + P_CUST_ID in varchar2, + Z_POST_DML in boolean, + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is +begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + QueryView( + K_CUST_ID=>P_CUST_ID, + Z_EXECUTE_QUERY=>null, + Z_POST_DML=>Z_POST_DML, + Z_FORM_STATUS=>Z_FORM_STATUS, + Z_DIRECT_CALL=>Z_DIRECT_CALL, + Z_CHK=>Z_CHK); +end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.FormInsert +-- +-- Description: This procedure builds an HTML form for insert of data in +-- the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormInsert( + Z_FORM_STATUS in number, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) + is + l_row integer; + l_error varchar2(2000); + l_error_num integer := IF_ROWS_ERROR; + l_success boolean := true; + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + + end if; + + + WSGL.OpenPageHead(''||' : '||'#Maintain Customer#1058#'); + WSGL.METATag; + + efnow110$.TemplateHeader(TRUE,5); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>IF_BODY_ATTRIBUTES || 'onLoad="return CUST_OnLoad()"'); + efnow110$js$cust.CreateInsertJavaScript( + IF_ROWS_INSERTED, + IF_ROWS_ERROR, + IF_BODY_ATTRIBUTES, + LOV_FRAME + ); + l_success := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + WSGOC.Set_AfterText(REF_COMPONENT,' +'||htf.nl||htf.nl||htf.italic('''*'''||caco_utilities.get_module_text(2202))||' +'); + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + InitialiseDomain('CUTY_ID'); + InitialiseDomain('STATUS'); + + if Z_FORM_STATUS = WSGL.FORM_STATUS_OK then + FORM_VAL.UI_CODE := null; + FORM_VAL.UI_NAME := null; + FORM_VAL.CUST_ID := null; + FORM_VAL.CODE := null; + FORM_VAL.NAME := null; + FORM_VAL.PRIMARY_CONTACT := null; + FORM_VAL.PRIMARY_CONTACT_TEL := null; + FORM_VAL.CUTY_ID := null; + FORM_VAL.STATUS := WSGL.DomainMeaning(efnow110$cust.D_STATUS, 'R'); + FORM_VAL.EMAIL_ADDRESS := null; + FORM_VAL.DESCRIPTION := null; + FORM_VAL.TELEPHONE := null; + FORM_VAL.FAX := null; + FORM_VAL.KAM_MANAGER := null; + FORM_VAL.UI_KAM_MGR_NAME := null; + FORM_VAL.KAM_TELEPHONE := null; + FORM_VAL.CREATED_BY := null; + FORM_VAL.CREATED_ON := null; + FORM_VAL.UPDATED_BY := null; + FORM_VAL.UPDATED_ON := null; + FORM_VAL.PERIOD_START := null; + FORM_VAL.PERIOD_END := null; + else + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + ''||' : '||'#Maintain Customer#1058#', IF_BODY_ATTRIBUTES); + end if; + + if IF_ROWS_INSERTED > 0 then + htp.p( ''||WSGL.MsgGetText(130,WSGLM.DSP130_ROWS_INSERTED)||' '||to_char(IF_ROWS_INSERTED)||'
' ); + end if; + if IF_ROWS_ERROR > 0 then + htp.p( ''||WSGL.MsgGetText(131,WSGLM.DSP131_ROWS_NOT_INSERTED)||' '||to_char(IF_ROWS_ERROR)||'
' ); + end if; + htp.p(WSGL.MsgGetText(117, WSGLM.DSP117_ENTER_NEW_ROW, '#Maintain Customer#1058#')); + htp.para; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow110$cust.actioninsert', cattributes => 'NAME="efnow110$cust$IForm"'); + SaveState; + + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + for i in 1..IF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(29, 'LEFT', NULL); + WSGL.LayoutHeader(50, 'LEFT', NULL); + end loop; + WSGL.LayoutRowEnd; + for l_row in 1..IF_ROWS_ERROR + 1 loop + if l_error_num > 0 and cg$errors.pop_head( l_error ) then + WSGL.LayoutTextLine(htf.bold(''||htf.italic(WSGL.MsgGetText(122,WSGLM.DSP122_ERROR))|| ' '||l_error)); + -- FORM_VAL := IF_FORM_ERRORS( l_row ); + FORM_VAL.UI_CODE := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UI_CODE); + FORM_VAL.UI_NAME := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UI_NAME); + FORM_VAL.CUST_ID := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CUST_ID); + FORM_VAL.CODE := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CODE); + FORM_VAL.NAME := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).NAME); + FORM_VAL.PRIMARY_CONTACT := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).PRIMARY_CONTACT); + FORM_VAL.PRIMARY_CONTACT_TEL := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).PRIMARY_CONTACT_TEL); + FORM_VAL.CUTY_ID := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CUTY_ID); + FORM_VAL.STATUS := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).STATUS); + FORM_VAL.EMAIL_ADDRESS := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).EMAIL_ADDRESS); + FORM_VAL.DESCRIPTION := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).DESCRIPTION); + FORM_VAL.TELEPHONE := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).TELEPHONE); + FORM_VAL.FAX := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).FAX); + FORM_VAL.KAM_MANAGER := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).KAM_MANAGER); + FORM_VAL.UI_KAM_MGR_NAME := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UI_KAM_MGR_NAME); + FORM_VAL.KAM_TELEPHONE := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).KAM_TELEPHONE); + FORM_VAL.CREATED_BY := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CREATED_BY); + FORM_VAL.CREATED_ON := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).CREATED_ON); + FORM_VAL.UPDATED_BY := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UPDATED_BY); + FORM_VAL.UPDATED_ON := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).UPDATED_ON); + FORM_VAL.PERIOD_START := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).PERIOD_START); + FORM_VAL.PERIOD_END := WSGL.EscapeItem(IF_FORM_ERRORS( l_row ).PERIOD_END); + + l_error_num := l_error_num - 1; + else + if (l_row = IF_ROWS_ERROR + 1) and (IF_ROWS_ERROR <> 0) then + WSGL.LayoutTextLine(' '); + end if; + end if; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Short Name*#2464#:')); + WSGL.LayoutData(WSGL.BuildTextControl('CODE', '10', '1', '20',FORM_VAL.CODE, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Full Name*#2461#:')); + WSGL.LayoutData(WSGL.BuildTextControl('NAME', '38', '1', '100',FORM_VAL.NAME, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Primary Contact*#2472#:')); + WSGL.LayoutData(WSGL.BuildTextControl('PRIMARY_CONTACT', '38', '1', '50',FORM_VAL.PRIMARY_CONTACT, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Primary Contact Tel.*#2473#:')); + WSGL.LayoutData(WSGL.BuildTextControl('PRIMARY_CONTACT_TEL', '38', '1', '30',FORM_VAL.PRIMARY_CONTACT_TEL, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Customer Type#2478#:')); + WSGL.LayoutData(WSGL.BuildDVControl(D_CUTY_ID, WSGL.CTL_INSERTABLE, FORM_VAL.CUTY_ID, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Status*#2476#:')); + WSGL.LayoutData(WSGL.BuildDVControl(D_STATUS, WSGL.CTL_INSERTABLE, FORM_VAL.STATUS, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Email Address*#2462#:')); + WSGL.LayoutData(WSGL.BuildTextControl('EMAIL_ADDRESS', '38', '1', '80',FORM_VAL.EMAIL_ADDRESS, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Description#20#:')); + WSGL.LayoutData(WSGL.BuildTextControl('DESCRIPTION', '30', '4', '32760',FORM_VAL.DESCRIPTION, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Telephone*#2463#:')); + WSGL.LayoutData(WSGL.BuildTextControl('TELEPHONE', '38', '1', '30',FORM_VAL.TELEPHONE, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Fax*#2465#:')); + WSGL.LayoutData(WSGL.BuildTextControl('FAX', '38', '1', '30',FORM_VAL.FAX, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#KAM Manager Name#2185#:')); + WSGL.LayoutData(WSGL.BuildTextControl('UI_KAM_MGR_NAME', '20', '1', '32760',FORM_VAL.UI_KAM_MGR_NAME, p_row=>1 +, p_img_path=>'/images/') || ' ' || + WSGJSL.LOVButton('UI_KAM_MGR_NAME',LOV_BUTTON_TEXT,'efnow110$cust$IForm')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#KAM Manager Tel.#2186#:')); + WSGL.LayoutData(WSGL.BuildTextControl('KAM_TELEPHONE', '38', '1', '30',FORM_VAL.KAM_TELEPHONE, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Period Start*#2460#:')); + WSGL.LayoutData(WSGL.BuildTextControl('PERIOD_START', '11', '1', '10',FORM_VAL.PERIOD_START + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_prompt => '#Period Start*#2460#' + , p_cal_date_format => 'DD/MM/YYYY' + , p_form => 'efnow110$cust$IForm' +, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Period End#27#:')); + WSGL.LayoutData(WSGL.BuildTextControl('PERIOD_END', '11', '1', '10',FORM_VAL.PERIOD_END + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_prompt => '#Period End#27#' + , p_cal_date_format => 'DD/MM/YYYY' + , p_form => 'efnow110$cust$IForm' +, p_row=>1 +, p_img_path=>'/images/')); + WSGL.LayoutRowEnd; + + WSGL.HiddenField('z_modified','Y'); + end loop; + WSGL.HiddenField( 'z_modified', 'dummy_row' ); + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', IF_INSERT_BUT_CAPTION, 'btnIFI', 'this.form.Z_ACTION.value=\''' || IF_INSERT_BUT_ACTION || '\'''); + if Z_FORM_STATUS != WSGL.FORM_STATUS_ERROR then + htp.formReset(IF_CLEAR_BUT_CAPTION, 'ID="'||IF_CLEAR_BUT_CAPTION||'"'); + else + WSGL.SubmitButton('Z_ACTION', IF_CLEAR_BUT_CAPTION, 'btnIFR', 'this.form.Z_ACTION.value=\''' || IF_CLEAR_BUT_ACTION || '\'''); + end if; + + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''))); + WSGL.HiddenField('P_CODE', ''); + WSGL.HiddenField('P_NAME', ''); + WSGL.HiddenField('P_PRIMARY_CONTACT', ''); + WSGL.HiddenField('P_PRIMARY_CONTACT_TEL', ''); + WSGL.HiddenField('P_CUTY_ID', ''); + WSGL.HiddenField('P_STATUS', ''); + WSGL.HiddenField('P_EMAIL_ADDRESS', ''); + WSGL.HiddenField('P_DESCRIPTION', ''); + WSGL.HiddenField('P_TELEPHONE', ''); + WSGL.HiddenField('P_FAX', ''); + WSGL.HiddenField('P_UI_KAM_MGR_NAME', ''); + WSGL.HiddenField('P_KAM_TELEPHONE', ''); + WSGL.HiddenField('P_PERIOD_START', ''); + WSGL.HiddenField('P_PERIOD_END', ''); + + htp.formClose; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="IF$AIFormBottom"'); + htp.formClose; + WSGL.ReturnLinks('0.1', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + IF_BODY_ATTRIBUTES, 'efnow110$cust.FormInsert'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.ActionView +-- +-- Description: This procedure is called when the View Form is submitted to +-- action an update, delete or requery request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionView( + P_CUST_ID in owa_text.vc_arr, + P_CODE in owa_text.vc_arr, + P_NAME in owa_text.vc_arr, + P_PRIMARY_CONTACT in owa_text.vc_arr, + P_PRIMARY_CONTACT_TEL in owa_text.vc_arr, + P_CUTY_ID in owa_text.vc_arr, + P_STATUS in owa_text.vc_arr, + P_EMAIL_ADDRESS in owa_text.vc_arr, + P_DESCRIPTION in owa_text.vc_arr, + P_TELEPHONE in owa_text.vc_arr, + P_FAX in owa_text.vc_arr, + P_UI_KAM_MGR_NAME in owa_text.vc_arr, + P_KAM_TELEPHONE in owa_text.vc_arr, + P_PERIOD_START in owa_text.vc_arr, + P_PERIOD_END in owa_text.vc_arr, + O_CUST_ID in owa_text.vc_arr, + O_CODE in owa_text.vc_arr, + O_NAME in owa_text.vc_arr, + O_PRIMARY_CONTACT in owa_text.vc_arr, + O_PRIMARY_CONTACT_TEL in owa_text.vc_arr, + O_CUTY_ID in owa_text.vc_arr, + O_STATUS in owa_text.vc_arr, + O_EMAIL_ADDRESS in owa_text.vc_arr, + O_DESCRIPTION in owa_text.vc_arr, + O_TELEPHONE in owa_text.vc_arr, + O_FAX in owa_text.vc_arr, + O_KAM_MANAGER in owa_text.vc_arr, + O_KAM_TELEPHONE in owa_text.vc_arr, + O_CREATED_BY in owa_text.vc_arr, + O_CREATED_ON in owa_text.vc_arr, + O_UPDATED_BY in owa_text.vc_arr, + O_UPDATED_ON in owa_text.vc_arr, + O_PERIOD_START in owa_text.vc_arr, + O_PERIOD_END in owa_text.vc_arr, + Q_UI_CODE in varchar2, + Q_UI_NAME in varchar2, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2, + Z_START in varchar2, + Z_CHK in varchar2 , + C_CUIN in owa_text.vc_arr default WSGL.EmptyVCArrLong ) is +-- + l_row integer; + l_row_failed boolean := false; + l_success boolean; + l_rowset_row integer := 1; + l_delset_row integer := 1; + l_cbcount integer; + l_do_delete boolean := false; + l_record_lck boolean := false; + l_dummy_bool boolean := false; + + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + +if (Z_ACTION = VF_COUNT_BUT_ACTION or Z_ACTION = VF_COUNT_BUT_CAPTION) or + (Z_ACTION = VF_FIRST_BUT_ACTION or Z_ACTION = VF_FIRST_BUT_CAPTION) or + (Z_ACTION = VF_PREV_BUT_ACTION or Z_ACTION = VF_PREV_BUT_CAPTION) or + (Z_ACTION = VF_NEXT_BUT_ACTION or Z_ACTION = VF_NEXT_BUT_CAPTION) or + (Z_ACTION = VF_LAST_BUT_ACTION or Z_ACTION = VF_LAST_BUT_CAPTION) or + (Z_ACTION = VF_REQUERY_BUT_ACTION or Z_ACTION = VF_REQUERY_BUT_CAPTION) or + (Z_ACTION = VF_NTOM_BUT_ACTION or Z_ACTION = VF_NTOM_BUT_CAPTION) then + QueryView(Z_EXECUTE_QUERY=>'Y', + P_UI_CODE=>Q_UI_CODE, + P_UI_NAME=>Q_UI_NAME, + Z_POST_DML=>FALSE, + Z_DIRECT_CALL=>TRUE, + Z_ACTION=>Z_ACTION, + Z_START=>Z_START); +end if; + +if (Z_ACTION = VF_INSERT_BUT_ACTION) or (Z_ACTION = VF_INSERT_BUT_CAPTION) then + FormInsert( + Z_DIRECT_CALL=>TRUE); +end if; +if (Z_ACTION = VF_QUERY_BUT_ACTION) or (Z_ACTION = VF_QUERY_BUT_CAPTION) then + FormQuery( + Z_DIRECT_CALL=>TRUE); +end if; +if (Z_ACTION = VF_UPDATE_BUT_ACTION) or (Z_ACTION = VF_UPDATE_BUT_CAPTION) or ltrim(Z_ACTION) is null then + l_row := z_modified.first; + while l_row is not null loop + l_do_delete := false; + if z_modified( l_row ) = 'Y' or l_do_delete then + PROCESSING_VIEW := true; + FORM_VAL.CUST_ID := P_CUST_ID( l_row ); + FORM_VAL.CODE := P_CODE( l_row ); + FORM_VAL.NAME := P_NAME( l_row ); + FORM_VAL.PRIMARY_CONTACT := P_PRIMARY_CONTACT( l_row ); + FORM_VAL.PRIMARY_CONTACT_TEL := P_PRIMARY_CONTACT_TEL( l_row ); + FORM_VAL.CUTY_ID := P_CUTY_ID( l_row ); + FORM_VAL.STATUS := P_STATUS( l_row ); + FORM_VAL.EMAIL_ADDRESS := P_EMAIL_ADDRESS( l_row ); + FORM_VAL.DESCRIPTION := P_DESCRIPTION( l_row ); + FORM_VAL.TELEPHONE := P_TELEPHONE( l_row ); + FORM_VAL.FAX := P_FAX( l_row ); + FORM_VAL.UI_KAM_MGR_NAME := P_UI_KAM_MGR_NAME( l_row ); + FORM_VAL.KAM_TELEPHONE := P_KAM_TELEPHONE( l_row ); + FORM_VAL.PERIOD_START := P_PERIOD_START( l_row ); + FORM_VAL.PERIOD_END := P_PERIOD_END( l_row ); + + PREV_VAL.CUST_ID := P_CUST_ID( l_row ); + PREV_IND.CUST_ID := TRUE; + PREV_VAL.CODE := O_CODE( l_row ); + PREV_IND.CODE := TRUE; + PREV_VAL.NAME := O_NAME( l_row ); + PREV_IND.NAME := TRUE; + PREV_VAL.PRIMARY_CONTACT := O_PRIMARY_CONTACT( l_row ); + PREV_IND.PRIMARY_CONTACT := TRUE; + PREV_VAL.PRIMARY_CONTACT_TEL := O_PRIMARY_CONTACT_TEL( l_row ); + PREV_IND.PRIMARY_CONTACT_TEL := TRUE; + PREV_VAL.CUTY_ID := O_CUTY_ID( l_row ); + PREV_IND.CUTY_ID := TRUE; + PREV_VAL.STATUS := O_STATUS( l_row ); + PREV_IND.STATUS := TRUE; + PREV_VAL.EMAIL_ADDRESS := O_EMAIL_ADDRESS( l_row ); + PREV_IND.EMAIL_ADDRESS := TRUE; + PREV_VAL.DESCRIPTION := O_DESCRIPTION( l_row ); + PREV_IND.DESCRIPTION := TRUE; + PREV_VAL.TELEPHONE := O_TELEPHONE( l_row ); + PREV_IND.TELEPHONE := TRUE; + PREV_VAL.FAX := O_FAX( l_row ); + PREV_IND.FAX := TRUE; + PREV_VAL.KAM_MANAGER_SYUS_ID := O_KAM_MANAGER( l_row ); + PREV_IND.KAM_MANAGER_SYUS_ID := TRUE; + PREV_VAL.KAM_TELEPHONE := O_KAM_TELEPHONE( l_row ); + PREV_IND.KAM_TELEPHONE := TRUE; + PREV_VAL.CREATED_BY := O_CREATED_BY( l_row ); + PREV_IND.CREATED_BY := TRUE; + PREV_VAL.CREATED_ON := to_date(O_CREATED_ON( l_row ), 'JSSSSS'); + PREV_IND.CREATED_ON := TRUE; + PREV_VAL.UPDATED_BY := O_UPDATED_BY( l_row ); + PREV_IND.UPDATED_BY := TRUE; + PREV_VAL.UPDATED_ON := to_date(O_UPDATED_ON( l_row ), 'JSSSSS'); + PREV_IND.UPDATED_ON := TRUE; + PREV_VAL.PERIOD_START := to_date(O_PERIOD_START( l_row ), 'JSSSSS'); + PREV_IND.PERIOD_START := TRUE; + PREV_VAL.PERIOD_END := to_date(O_PERIOD_END( l_row ), 'JSSSSS'); + PREV_IND.PERIOD_END := TRUE; + CURR_IND := NULL_IND; + CURR_VAL := PREV_VAL; + CURR_PK.CUST_ID := CURR_VAL.CUST_ID; + ActionUpdate( p_row=>l_row, p_row_success=>l_success, p_row_lck=>l_record_lck ); + + if ( not l_do_delete ) or ( l_do_delete and not l_success ) then + VF_ROW_SET( l_rowset_row ).ROW_DELETED := false; + begin + select ROWID + into VF_ROW_SET( l_rowset_row ).ROW_ID + from CUSTOMERS + where CUST_ID = CURR_VAL.CUST_ID; + exception when no_data_found then + l_success := false; + VF_ROW_SET( l_rowset_row ).ROW_DELETED := true; + end; + VF_ROW_SET( l_rowset_row ).SUCCESS_FLAG := l_success; + VF_ROW_SET( l_rowset_row ).ROW_NOT_LOCKED := ( not l_record_lck ); + VF_ROW_SET( l_rowset_row ).F_UI_CODE := FORM_VAL.UI_CODE; + VF_ROW_SET( l_rowset_row ).F_UI_NAME := FORM_VAL.UI_NAME; + VF_ROW_SET( l_rowset_row ).F_CUST_ID := FORM_VAL.CUST_ID; + VF_ROW_SET( l_rowset_row ).F_CODE := FORM_VAL.CODE; + VF_ROW_SET( l_rowset_row ).F_NAME := FORM_VAL.NAME; + VF_ROW_SET( l_rowset_row ).F_PRIMARY_CONTACT := FORM_VAL.PRIMARY_CONTACT; + VF_ROW_SET( l_rowset_row ).F_PRIMARY_CONTACT_TEL := FORM_VAL.PRIMARY_CONTACT_TEL; + VF_ROW_SET( l_rowset_row ).F_CUTY_ID := FORM_VAL.CUTY_ID; + VF_ROW_SET( l_rowset_row ).F_STATUS := FORM_VAL.STATUS; + VF_ROW_SET( l_rowset_row ).F_EMAIL_ADDRESS := FORM_VAL.EMAIL_ADDRESS; + VF_ROW_SET( l_rowset_row ).F_DESCRIPTION := FORM_VAL.DESCRIPTION; + VF_ROW_SET( l_rowset_row ).F_TELEPHONE := FORM_VAL.TELEPHONE; + VF_ROW_SET( l_rowset_row ).F_FAX := FORM_VAL.FAX; + VF_ROW_SET( l_rowset_row ).F_KAM_MANAGER := FORM_VAL.KAM_MANAGER; + VF_ROW_SET( l_rowset_row ).F_UI_KAM_MGR_NAME := FORM_VAL.UI_KAM_MGR_NAME; + VF_ROW_SET( l_rowset_row ).F_KAM_TELEPHONE := FORM_VAL.KAM_TELEPHONE; + VF_ROW_SET( l_rowset_row ).F_CREATED_BY := FORM_VAL.CREATED_BY; + VF_ROW_SET( l_rowset_row ).F_CREATED_ON := FORM_VAL.CREATED_ON; + VF_ROW_SET( l_rowset_row ).F_UPDATED_BY := FORM_VAL.UPDATED_BY; + VF_ROW_SET( l_rowset_row ).F_UPDATED_ON := FORM_VAL.UPDATED_ON; + VF_ROW_SET( l_rowset_row ).F_PERIOD_START := FORM_VAL.PERIOD_START; + VF_ROW_SET( l_rowset_row ).F_PERIOD_END := FORM_VAL.PERIOD_END; + if l_success then + VF_ROWS_UPDATED := VF_ROWS_UPDATED + 1; + else + VF_ROWS_ERROR := VF_ROWS_ERROR + 1; + end if; + l_rowset_row := l_rowset_row + 1; + end if; + end if; + l_row := z_modified.next( l_row ); + end loop; + + if VF_ROW_SET.count > 0 then + QueryView(Z_EXECUTE_QUERY=>null, + P_UI_CODE=>Q_UI_CODE, + P_UI_NAME=>Q_UI_NAME, + Z_POST_DML=>TRUE, + Z_DIRECT_CALL=>TRUE, + Z_START=>Z_START, + Z_ACTION=>Z_ACTION); + else + QueryView(Z_EXECUTE_QUERY=>'Y', + P_UI_CODE=>Q_UI_CODE, + P_UI_NAME=>Q_UI_NAME, + Z_POST_DML=>FALSE, + Z_DIRECT_CALL=>TRUE, + Z_START=>Z_START, + Z_ACTION=>Z_ACTION); + end if; +end if; + + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.ActionView'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.ActionUpdate +-- +-- Description: Called from ActionView to process an update request +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionUpdate (p_row in integer default 0 + ,p_row_success in out boolean + ,p_row_lck in out boolean + ) + is + + I_ERROR_MESS varchar2(2000) := null; + I_RETURN number(6); + l_force_upd boolean := false; + + begin + p_row_success := true; + p_row_lck := true; + begin + CG$CUSTOMERS.Lck(PREV_VAL, PREV_IND); + exception + when cg$errors.cg$error then + p_row_success := false; + p_row_lck := false; + return; + when others then + raise; + end; + + + if not Validate('UPD', l_force_upd) then + rollback; + p_row_success := false; + return; + end if; + + + if not PreUpdate then + rollback; + p_row_success := false; + return; + end if; + + begin + CG$CUSTOMERS.Upd(CURR_VAL, CURR_IND); + exception + when cg$errors.cg$error then + p_row_success := false; + rollback; + return; + when others then + raise; + end; + + if not PostUpdate then + rollback; + p_row_success := false; + return; + end if; + + commit; + + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.ActionUpdate'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.ActionInsert +-- +-- Description: Called when the Insert Form is submitted to process the insert. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionInsert( + P_CODE in owa_text.vc_arr, + P_NAME in owa_text.vc_arr, + P_PRIMARY_CONTACT in owa_text.vc_arr, + P_PRIMARY_CONTACT_TEL in owa_text.vc_arr, + P_CUTY_ID in owa_text.vc_arr, + P_STATUS in owa_text.vc_arr, + P_EMAIL_ADDRESS in owa_text.vc_arr, + P_DESCRIPTION in owa_text.vc_arr, + P_TELEPHONE in owa_text.vc_arr, + P_FAX in owa_text.vc_arr, + P_UI_KAM_MGR_NAME in owa_text.vc_arr, + P_KAM_TELEPHONE in owa_text.vc_arr, + P_PERIOD_START in owa_text.vc_arr, + P_PERIOD_END in owa_text.vc_arr, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + + I_ERROR_MESS varchar2(2000) := null; + l_row integer; + l_row_failed boolean := false; + l_cbcount integer; + l_dummy_bool boolean := false; + + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + end if; + if (Z_ACTION = IF_CLEAR_BUT_ACTION) or (Z_ACTION = IF_CLEAR_BUT_CAPTION) then + FormInsert(Z_FORM_STATUS=>WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + InitialiseDomain('CUTY_ID'); + InitialiseDomain('STATUS'); + cg$errors.clear; + l_row := z_modified.first; + while l_row is not null loop + if z_modified( l_row ) = 'Y' then + l_row_failed := false; + CURR_VAL := NULL_VAL; + CURR_IND := NULL_IND; + FORM_VAL.CODE := P_CODE( l_row ); + FORM_VAL.NAME := P_NAME( l_row ); + FORM_VAL.PRIMARY_CONTACT := P_PRIMARY_CONTACT( l_row ); + FORM_VAL.PRIMARY_CONTACT_TEL := P_PRIMARY_CONTACT_TEL( l_row ); + FORM_VAL.CUTY_ID := P_CUTY_ID( l_row ); + FORM_VAL.STATUS := P_STATUS( l_row ); + FORM_VAL.EMAIL_ADDRESS := P_EMAIL_ADDRESS( l_row ); + FORM_VAL.DESCRIPTION := P_DESCRIPTION( l_row ); + FORM_VAL.TELEPHONE := P_TELEPHONE( l_row ); + FORM_VAL.FAX := P_FAX( l_row ); + FORM_VAL.UI_KAM_MGR_NAME := P_UI_KAM_MGR_NAME( l_row ); + FORM_VAL.KAM_TELEPHONE := P_KAM_TELEPHONE( l_row ); + FORM_VAL.PERIOD_START := P_PERIOD_START( l_row ); + FORM_VAL.PERIOD_END := P_PERIOD_END( l_row ); + + if not Validate('INS', l_dummy_bool) then + rollback; + FormInsert(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + + if not l_row_failed then + if not PreInsert then + rollback; + FormInsert(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + end if; + + if not l_row_failed then + begin + CG$CUSTOMERS.Ins(CURR_VAL, CURR_IND); + exception + when cg$errors.cg$error then + rollback; + FormInsert(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + when others then + raise; + end; + end if; + + if not l_row_failed then + if not PostInsert then + rollback; + FormInsert(Z_FORM_STATUS=>WSGL.FORM_STATUS_ERROR, + Z_DIRECT_CALL=>TRUE); + return; + end if; + end if; + + if not l_row_failed then + commit; + IF_ROWS_INSERTED := IF_ROWS_INSERTED + 1; + end if; + end if; + l_row := z_modified.next( l_row ); + end loop; + QueryView( + K_CUST_ID=>CURR_VAL.CUST_ID, + Z_POST_DML=>TRUE, + Z_FORM_STATUS=>WSGL.FORM_STATUS_INS, + Z_DIRECT_CALL=>TRUE , + Z_CHK=>to_char(WSGL.Checksum + ('' || CURR_VAL.CUST_ID))); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + IF_BODY_ATTRIBUTES, 'efnow110$cust.ActionInsert'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.CUST_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + '', 'efnow110$cust.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.SaveState +-- +-- Description: Saves the data state for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + '', 'efnow110$cust.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.LoadCache +-- +-- Description: Populate the object cache with +-- 'CUST' module component (#Maintain Customer#1058#). +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + InitialiseDomain('CUTY_ID'); + InitialiseDomain('STATUS'); + + ref_Component := WSGOC.Component + ( pModule => efnow110$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'CUST' + , pTitle => '#Maintain Customer#1058#' + , pSystemImagePath=> '/images/' + ); + + r_UI_CODE := WSGOC.Item + ( pName => 'UI_CODE' + , pPrompt => '#Short Name*#2464#' + ); + r_UI_NAME := WSGOC.Item + ( pName => 'UI_NAME' + , pPrompt => '#Full Name*#2461#' + ); + r_CUST_ID := WSGOC.Item + ( pName => 'CUST_ID' + , pPrompt => '#Cust Id#1065#' + ); + r_CODE := WSGOC.Item + ( pName => 'CODE' + , pPrompt => '#Short Name*#2464#' + ); + r_NAME := WSGOC.Item + ( pName => 'NAME' + , pPrompt => '#Full Name*#2461#' + , pIsContext=> true + ); + r_PRIMARY_CONTACT := WSGOC.Item + ( pName => 'PRIMARY_CONTACT' + , pPrompt => '#Primary Contact*#2472#' + ); + r_PRIMARY_CONTACT_TEL := WSGOC.Item + ( pName => 'PRIMARY_CONTACT_TEL' + , pPrompt => '#Primary Contact Tel.*#2473#' + ); + r_CUTY_ID := WSGOC.Item + ( pName => 'CUTY_ID' + , pPrompt => '#Customer Type#2478#' + ); + r_STATUS := WSGOC.Item + ( pName => 'STATUS' + , pPrompt => '#Status*#2476#' + ); + r_EMAIL_ADDRESS := WSGOC.Item + ( pName => 'EMAIL_ADDRESS' + , pPrompt => '#Email Address*#2462#' + ); + r_DESCRIPTION := WSGOC.Item + ( pName => 'DESCRIPTION' + , pPrompt => '#Description#20#' + ); + r_TELEPHONE := WSGOC.Item + ( pName => 'TELEPHONE' + , pPrompt => '#Telephone*#2463#' + ); + r_FAX := WSGOC.Item + ( pName => 'FAX' + , pPrompt => '#Fax*#2465#' + ); + r_KAM_MANAGER := WSGOC.Item + ( pName => 'KAM_MANAGER' + , pPrompt => '#KAM Manger#2474#' + ); + r_UI_KAM_MGR_NAME := WSGOC.Item + ( pName => 'UI_KAM_MGR_NAME' + , pPrompt => '#KAM Manager Name#2185#' + ); + r_KAM_TELEPHONE := WSGOC.Item + ( pName => 'KAM_TELEPHONE' + , pPrompt => '#KAM Manager Tel.#2186#' + ); + r_CREATED_BY := WSGOC.Item + ( pName => 'CREATED_BY' + , pPrompt => '#Created By#119#' + ); + r_CREATED_ON := WSGOC.Item + ( pName => 'CREATED_ON' + , pPrompt => '#Created On#118#' + ); + r_UPDATED_BY := WSGOC.Item + ( pName => 'UPDATED_BY' + , pPrompt => '#Updated By#1115#' + ); + r_UPDATED_ON := WSGOC.Item + ( pName => 'UPDATED_ON' + , pPrompt => '#Updated On#1064#' + ); + r_PERIOD_START := WSGOC.Item + ( pName => 'PERIOD_START' + , pPrompt => '#Period Start*#2460#' + ); + r_PERIOD_END := WSGOC.Item + ( pName => 'PERIOD_END' + , pPrompt => '#Period End#27#' + ); + + WSGOC.Add_Items(ref_Component, r_UI_CODE); + WSGOC.Add_Items(ref_Component, r_UI_NAME); + WSGOC.Add_Items(ref_Component, r_CUST_ID); + WSGOC.Add_Items(ref_Component, r_CODE); + WSGOC.Add_Items(ref_Component, r_NAME); + WSGOC.Add_Items(ref_Component, r_PRIMARY_CONTACT); + WSGOC.Add_Items(ref_Component, r_PRIMARY_CONTACT_TEL); + WSGOC.Add_Items(ref_Component, r_CUTY_ID); + WSGOC.Add_Items(ref_Component, r_STATUS); + WSGOC.Add_Items(ref_Component, r_EMAIL_ADDRESS); + WSGOC.Add_Items(ref_Component, r_DESCRIPTION); + WSGOC.Add_Items(ref_Component, r_TELEPHONE); + WSGOC.Add_Items(ref_Component, r_FAX); + WSGOC.Add_Items(ref_Component, r_KAM_MANAGER); + WSGOC.Add_Items(ref_Component, r_UI_KAM_MGR_NAME); + WSGOC.Add_Items(ref_Component, r_KAM_TELEPHONE); + WSGOC.Add_Items(ref_Component, r_CREATED_BY); + WSGOC.Add_Items(ref_Component, r_CREATED_ON); + WSGOC.Add_Items(ref_Component, r_UPDATED_BY); + WSGOC.Add_Items(ref_Component, r_UPDATED_ON); + WSGOC.Add_Items(ref_Component, r_PERIOD_START); + WSGOC.Add_Items(ref_Component, r_PERIOD_END); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_CUST_ID, WSGL.EscapeItem(CURR_VAL.CUST_ID) ); + WSGOC.Set_Value( r_CODE, replace(WSGL.EscapeItem(CURR_VAL.CODE), ' +', '
+') ); + WSGOC.Set_Value( r_NAME, replace(WSGL.EscapeItem(CURR_VAL.NAME), ' +', '
+') ); + WSGOC.Set_Value( r_PRIMARY_CONTACT, replace(WSGL.EscapeItem(CURR_VAL.PRIMARY_CONTACT), ' +', '
+') ); + WSGOC.Set_Value( r_PRIMARY_CONTACT_TEL, replace(WSGL.EscapeItem(CURR_VAL.PRIMARY_CONTACT_TEL), ' +', '
+') ); + WSGOC.Set_Value( r_CUTY_ID, WSGL.EscapeItem(WSGL.DomainMeaning(D_CUTY_ID, CURR_VAL.CUTY_ID)) ); + WSGOC.Set_Value( r_STATUS, replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_STATUS, CURR_VAL.STATUS)), ' +', '
+') ); + WSGOC.Set_Value( r_EMAIL_ADDRESS, replace(WSGL.EscapeItem(CURR_VAL.EMAIL_ADDRESS), ' +', '
+') ); + WSGOC.Set_Value( r_DESCRIPTION, replace(WSGL.EscapeItem(CURR_VAL.DESCRIPTION), ' +', '
+') ); + WSGOC.Set_Value( r_TELEPHONE, replace(WSGL.EscapeItem(CURR_VAL.TELEPHONE), ' +', '
+') ); + WSGOC.Set_Value( r_FAX, replace(WSGL.EscapeItem(CURR_VAL.FAX), ' +', '
+') ); + WSGOC.Set_Value( r_KAM_MANAGER, WSGL.EscapeItem(CURR_VAL.KAM_MANAGER_SYUS_ID) ); + WSGOC.Set_Value( r_KAM_TELEPHONE, replace(WSGL.EscapeItem(CURR_VAL.KAM_TELEPHONE), ' +', '
+') ); + WSGOC.Set_Value( r_CREATED_BY, replace(WSGL.EscapeItem(CURR_VAL.CREATED_BY), ' +', '
+') ); + WSGOC.Set_Value( r_CREATED_ON, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.CREATED_ON, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_UPDATED_BY, replace(WSGL.EscapeItem(CURR_VAL.UPDATED_BY), ' +', '
+') ); + WSGOC.Set_Value( r_UPDATED_ON, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.UPDATED_ON, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_PERIOD_START, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.PERIOD_START, 'DD/MM/YYYY'))) ); + WSGOC.Set_Value( r_PERIOD_END, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.PERIOD_END, 'DD/MM/YYYY'))) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + '', 'efnow110$cust.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PostUpdate +-- +-- Description: Provides place holder for code to be run after an update +-- for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostUpdate return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$cust.PostUpdate'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$cust.PostInsert +-- +-- Description: Provides place holder for code to be run after an insert +-- for the 'CUST' module component (#Maintain Customer#1058#). +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostInsert return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + IF_BODY_ATTRIBUTES, 'efnow110$cust.PostInsert'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cust.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cust.spc new file mode 100644 index 0000000..f3dbc17 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$cust.spc @@ -0,0 +1,180 @@ +create or replace package efnow110$cust is + + type NBT_REC is record + ( UI_CODE varchar2(32760) + , UI_NAME varchar2(32760) + , UI_KAM_MGR_NAME varchar2(32760) + ); + + NBT_VAL NBT_REC; + CURR_VAL CG$CUSTOMERS.CG$ROW_TYPE; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure ActionQuery( + P_UI_CODE in varchar2 default null, + P_UI_NAME in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null ); + + procedure FormQuery( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + procedure KAM_SYUS_ID_LOV( + Z_FILTER in varchar2, + Z_MODE in varchar2, + Z_CALLER_URL in varchar2, + Z_FORMROW in number default 0, + Z_LONG_LIST in varchar2 default null, + Z_ISSUE_WAIT in varchar2 default null); + procedure EFLV_CUST_CODE_LOV( + Z_FILTER in varchar2, + Z_MODE in varchar2, + Z_CALLER_URL in varchar2, + Z_FORMROW in number default 0, + Z_LONG_LIST in varchar2 default null, + Z_ISSUE_WAIT in varchar2 default null); + procedure EFLV_CUST_NAME_LOV( + Z_FILTER in varchar2, + Z_MODE in varchar2, + Z_CALLER_URL in varchar2, + Z_FORMROW in number default 0, + Z_LONG_LIST in varchar2 default null, + Z_ISSUE_WAIT in varchar2 default null); + + procedure FormInsert( + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryView( + K_CUST_ID in varchar2 default null, + P_UI_CODE in varchar2 default null, + P_UI_NAME in varchar2 default null, + Z_EXECUTE_QUERY in varchar2 default null, + Z_POST_DML in boolean default false, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_START in varchar2 default '1', + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null); + function QueryHits( + P_UI_CODE in varchar2 default null, + P_UI_NAME in varchar2 default null) return number; + + procedure ActionView( + P_CUST_ID in owa_text.vc_arr, + P_CODE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_NAME in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_PRIMARY_CONTACT in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_PRIMARY_CONTACT_TEL in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_CUTY_ID in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_STATUS in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_EMAIL_ADDRESS in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_DESCRIPTION in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_TELEPHONE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_FAX in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_UI_KAM_MGR_NAME in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_KAM_TELEPHONE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_PERIOD_START in owa_text.vc_arr default WSGL.EmptyVCArrLong, + P_PERIOD_END in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CUST_ID in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CODE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_NAME in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_PRIMARY_CONTACT in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_PRIMARY_CONTACT_TEL in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CUTY_ID in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_STATUS in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_EMAIL_ADDRESS in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_DESCRIPTION in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_TELEPHONE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_FAX in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_KAM_MANAGER in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_KAM_TELEPHONE in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CREATED_BY in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_CREATED_ON in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_UPDATED_BY in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_UPDATED_ON in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_PERIOD_START in owa_text.vc_arr default WSGL.EmptyVCArrLong, + O_PERIOD_END in owa_text.vc_arr default WSGL.EmptyVCArrLong, + Q_UI_CODE in varchar2 default null, + Q_UI_NAME in varchar2 default null, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2 default null, + Z_START in varchar2 default '1', + Z_CHK in varchar2 default null , + C_CUIN in owa_text.vc_arr default WSGL.EmptyVCArrLong ); + procedure ActionInsert( + P_CODE in owa_text.vc_arr, + P_NAME in owa_text.vc_arr, + P_PRIMARY_CONTACT in owa_text.vc_arr, + P_PRIMARY_CONTACT_TEL in owa_text.vc_arr, + P_CUTY_ID in owa_text.vc_arr, + P_STATUS in owa_text.vc_arr, + P_EMAIL_ADDRESS in owa_text.vc_arr, + P_DESCRIPTION in owa_text.vc_arr, + P_TELEPHONE in owa_text.vc_arr, + P_FAX in owa_text.vc_arr, + P_UI_KAM_MGR_NAME in owa_text.vc_arr, + P_KAM_TELEPHONE in owa_text.vc_arr, + P_PERIOD_START in owa_text.vc_arr, + P_PERIOD_END in owa_text.vc_arr, + z_modified in owa_text.vc_arr, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + procedure QueryViewByKey( + P_CUST_ID in varchar2 default null, + Z_POST_DML in boolean default false, + Z_FORM_STATUS in number default WSGL.FORM_STATUS_OK, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + procedure InitialiseDomain(P_ALIAS in varchar2); + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); + + D_CUTY_ID WSGL.typDVRecord; + D_STATUS WSGL.typDVRecord;FUNCTION get_cust_code RETURN VARCHAR2; + +FUNCTION get_cust_name RETURN VARCHAR2; + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cuin.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cuin.bdy new file mode 100644 index 0000000..683df53 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cuin.bdy @@ -0,0 +1,273 @@ +create or replace package body efnow110$js$cuin is + + +-------------------------------------------------------------------------------- +-- Name: efnow110$js$cuin.CreateViewJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateViewJavaScript( + VF_ROWS_UPDATED in integer, + VF_ROWS_DELETED in integer, + VF_ROWS_ERROR in integer, + VF_BODY_ATTRIBUTES in varchar2, + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + RL_REQUERY_BUT_ACTION in varchar2, + LOV_FRAME in varchar2) is + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var index = 0;'); + if IF_ROWS_INSERTED > 0 then + htp.p( 'var DataChange = true;' ); + else + htp.p( 'var DataChange = false;' ); + end if; + if IF_ROWS_ERROR > 0 then + htp.p( 'var DataChangeErrors = true;' ); + else + htp.p( 'var DataChangeErrors = false;' ); + end if; + + if to_char(efnow110$cust.CURR_VAL.CUST_ID) is not null then + htp.p( 'var P_CUST_ID = new Array();' ); + htp.p( 'P_CUST_ID[0] = "' || WSGL.EscapeURLParam(to_char(efnow110$cust.CURR_VAL.CUST_ID)) || '";' ); + end if; + htp.p( 'var P_2 = new Array();' ); + htp.p( 'P_2[0] = "' || WSGL.EscapeURLParam(nvl(to_char(efnow110$cust.CURR_VAL.CUST_ID), '')) || '";' ); + htp.p( 'var CUIN_CHK_VALUE = new Array();' ); + htp.p( 'CUIN_CHK_VALUE[0] = ' || to_char(WSGL.Checksum(''|| to_char(efnow110$cust.CURR_VAL.CUST_ID)|| to_char(efnow110$cust.CURR_VAL.CUST_ID))) || ';' ); + + htp.p( 'var P_23 = new Array();' ); + htp.p( 'P_23[0] = "' || WSGL.EscapeURLParam(to_char(efnow110$cuin.CURR_VAL.CUST_ID)) || '";' ); + htp.p( 'var P_24 = new Array();' ); + htp.p( 'P_24[0] = "' || WSGL.EscapeURLParam(to_char(efnow110$cuin.CURR_VAL.INTE_ID)) || '";' ); + + htp.p(WSGJSL.RtnCheckModified); + htp.p(WSGJSL.RtnRevertForm); + htp.p(WSGJSL.RtnFlagRow); + htp.p(WSGJSL.OpenEvent('CUIN','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFU','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFD','OnClick')); + htp.p(WSGJSL.VerifyDelete(WSGL.MsgGetText(118, WSGLM.DSP118_CONFIRM_DELETE))); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFR','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFI','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + VF_BODY_ATTRIBUTES, 'efnow110$js$cuin.CreateViewJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$js$cuin.CreateInsertJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateInsertJavaScript( + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + IF_BODY_ATTRIBUTES in varchar2, + RL_REQUERY_BUT_ACTION in varchar2, + LOV_FRAME in varchar2) is + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Insert";'); + htp.p('var index = 0;'); + if IF_ROWS_INSERTED > 0 then + htp.p( 'var DataChange = true;' ); + else + htp.p( 'var DataChange = false;' ); + end if; + if IF_ROWS_ERROR > 0 then + htp.p( 'var DataChangeErrors = true;' ); + else + htp.p( 'var DataChangeErrors = false;' ); + end if; + + if to_char(efnow110$cust.CURR_VAL.CUST_ID) is not null then + htp.p( 'var P_CUST_ID = new Array();' ); + htp.p( 'P_CUST_ID[0] = "' || WSGL.EscapeURLParam(to_char(efnow110$cust.CURR_VAL.CUST_ID)) || '";' ); + end if; + htp.p( 'var P_2 = new Array();' ); + htp.p( 'P_2[0] = "' || WSGL.EscapeURLParam(nvl(to_char(efnow110$cust.CURR_VAL.CUST_ID), '')) || '";' ); + if (to_char(efnow110$cust.CURR_VAL.CUST_ID) is not null ) then + htp.p( 'var CUIN_CHK_VALUE = new Array();' ); + htp.p( 'CUIN_CHK_VALUE[0] = ' || to_char(WSGL.Checksum(''|| to_char(efnow110$cust.CURR_VAL.CUST_ID)|| to_char(efnow110$cust.CURR_VAL.CUST_ID))) || ';' ); + end if; + + htp.p(WSGJSL.RtnCheckModified); + htp.p(WSGJSL.RtnRevertForm); + htp.p(WSGJSL.RtnFlagRow); + htp.p(WSGJSL.OpenEvent('L_INTERMEDIARIES_NAME2','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + if (index == null) + index = 0; + if (ctl[index].form.name.search(/VForm$/) == -1) + { + modeStr = "INS"; + } + else + { + modeStr = "UPD"; + } + depStr = depStr + "&P_2=" + escape(ctl[index].form.P_2.value); +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl[index], index, modeStr, "efnow110$cuin.l_intermediaries_name2_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + WSGJSL.Output_Invoke_CAL_JS ('efnow110$cuin', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('CUIN','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnIFI','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnIFR','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + IF_BODY_ATTRIBUTES, 'efnow110$js$cuin.CreateInsertJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$js$cuin.CreateListJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateListJavaScript ( + RL_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow110$cuin') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "List";'); + + if to_char(efnow110$cust.CURR_VAL.CUST_ID) is not null then + htp.p( 'var P_CUST_ID = new Array();' ); + htp.p( 'P_CUST_ID[0] = "' || WSGL.EscapeURLParam(to_char(efnow110$cust.CURR_VAL.CUST_ID)) || '";' ); + end if; + htp.p( 'var P_2 = new Array();' ); + htp.p( 'P_2[0] = "' || WSGL.EscapeURLParam(nvl(to_char(efnow110$cust.CURR_VAL.CUST_ID), '')) || '";' ); + if (to_char(efnow110$cust.CURR_VAL.CUST_ID) is not null ) then + htp.p( 'var CUIN_CHK_VALUE = new Array();' ); + htp.p( 'CUIN_CHK_VALUE[0] = ' || to_char(WSGL.Checksum(''|| to_char(efnow110$cust.CURR_VAL.CUST_ID)|| to_char(efnow110$cust.CURR_VAL.CUST_ID))) || ';' ); + end if; + + htp.p( 'var P_23 = new Array();' ); + htp.p( 'var P_24 = new Array();' ); + + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Intermediaries#1059#', + RL_BODY_ATTRIBUTES, 'efnow110$js$cuin.CreateListJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cuin.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cuin.spc new file mode 100644 index 0000000..2f27bc6 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cuin.spc @@ -0,0 +1,24 @@ +create or replace package efnow110$js$cuin is + + procedure CreateListJavaScript( + RL_BODY_ATTRIBUTES in varchar2); + + procedure CreateViewJavaScript( + VF_ROWS_UPDATED in integer, + VF_ROWS_DELETED in integer, + VF_ROWS_ERROR in integer, + VF_BODY_ATTRIBUTES in varchar2, + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + RL_REQUERY_BUT_ACTION in varchar2, + LOV_FRAME in varchar2); + + procedure CreateInsertJavaScript( + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + IF_BODY_ATTRIBUTES in varchar2, + RL_REQUERY_BUT_ACTION in varchar2, + LOV_FRAME in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cust.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cust.bdy new file mode 100644 index 0000000..f21f90e --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cust.bdy @@ -0,0 +1,978 @@ +create or replace package body efnow110$js$cust is + + +-------------------------------------------------------------------------------- +-- Name: efnow110$js$cust.CreateViewJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateViewJavaScript( + VF_ROWS_UPDATED in integer, + VF_ROWS_DELETED in integer, + VF_ROWS_ERROR in integer, + VF_BODY_ATTRIBUTES in varchar2, + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + LOV_FRAME in varchar2) is + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var index = 0;'); + if IF_ROWS_INSERTED > 0 then + htp.p( 'var DataChange = true;' ); + else + htp.p( 'var DataChange = false;' ); + end if; + if IF_ROWS_ERROR > 0 then + htp.p( 'var DataChangeErrors = true;' ); + else + htp.p( 'var DataChangeErrors = false;' ); + end if; + + + htp.p( 'var P_CUST_ID = new Array();' ); + htp.p( 'var P_2 = new Array();' ); + htp.p( 'var CUIN_CHK_VALUE = new Array();' ); + + htp.p(WSGJSL.RtnOpenLOV); + htp.p(WSGJSL.RtnNotNull); + htp.p(WSGJSL.RtnChkMaxLength); + htp.p(WSGJSL.RtnCheckModified); + htp.p(WSGJSL.RtnRevertForm); + htp.p(WSGJSL.RtnFlagRow); + htp.p(WSGJSL.RtnFindTargetFrame); + + WSGJSL.Output_Invoke_CAL_JS ('efnow110$cust', 'scrollbars=no,resizable=no,width=320,height=350'); + + + efnow110$cust.InitialiseDomain('CUTY_ID'); + efnow110$cust.InitialiseDomain('STATUS'); + + htp.p(' +function ResetRadios( form, num_rows ) +{ + return; +}; +'); + + htp.p(WSGJSL.OpenEvent('CODE','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('NAME','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('PRIMARY_CONTACT','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('PRIMARY_CONTACT_TEL','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('CUTY_ID','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('STATUS','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('EMAIL_ADDRESS','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('DESCRIPTION','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('TELEPHONE','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('FAX','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('UI_KAM_MGR_NAME','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + if (index == null) + index = 0; + if (ctl[index].form.name.search(/VForm$/) == -1) + { + modeStr = "INS"; + } + else + { + modeStr = "UPD"; + } +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl[index], index, modeStr, "efnow110$cust.kam_syus_id_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('UI_KAM_MGR_NAME','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('KAM_TELEPHONE','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('PERIOD_START','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('PERIOD_END','OnChange')); htp.p(' + if (ctl != null) + { + ctl.form.z_modified[index].value = "Y"; + }'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('CUST','Validate')); + htp.p('var index = 0;'); +htp.p(' +for (index = 0; index < ctl.form.P_PRIMARY_CONTACT.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallNotNull('ctl.form.P_PRIMARY_CONTACT[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Primary Contact*#2472#:'), true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_PRIMARY_CONTACT_TEL.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallNotNull('ctl.form.P_PRIMARY_CONTACT_TEL[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Primary Contact Tel.*#2473#:'), true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_EMAIL_ADDRESS.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallNotNull('ctl.form.P_EMAIL_ADDRESS[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Email Address*#2462#:'), true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_DESCRIPTION.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallChkMaxLength('ctl.form.P_DESCRIPTION[index]', 80, WSGL.MsgGetText(230, WSGLM.MSG230_MAXLEN_ERROR, '#Description#20#:', '80') +, true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_TELEPHONE.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallNotNull('ctl.form.P_TELEPHONE[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Telephone*#2463#:'), true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_FAX.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallNotNull('ctl.form.P_FAX[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Fax*#2465#:'), true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_UI_KAM_MGR_NAME.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_KAM_TELEPHONE.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_PERIOD_START.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + + htp.p(WSGJSL.CallNotNull('ctl.form.P_PERIOD_START[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Period Start*#2460#:'), true)); +htp.p(' +}'); +htp.p(' +for (index = 0; index < ctl.form.P_PERIOD_END.length; index++) +{'); +htp.p(' if (!(ctl.form.z_modified[index].value == "Y")) { continue;};'); + +htp.p(' +}'); + + htp.p(WSGJSL.CloseEvent); + htp.p( +'// emailCheck +// +// + +function emailCheck (emailObj,lang) { + +function fieldFocus() { + emailObj.focus(); +} +/* The following variable tells the rest of the function whether or not +to verify that the address ends in a two-letter country or well-known +TLD. 1 means check it, 0 means don''''t. */ + +var checkTLD=1; +var emailStr = emailObj.value; + +/* The following is the list of known TLDs that an e-mail address must end with. */ + +var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; + +/* The following pattern is used to check if the entered e-mail address +fits the user@domain format. It also is used to separate the username +from the domain. */ + +var emailPat=/^(.+)@(.+)$/; + +/* The following string represents the pattern for matching all special +characters. We don''''t want to allow special characters in the address. +These characters include ( ) < > @ , ; : \ " . [ ] */ + +/* +other chars: +!%/=*-#&{}?$| +*/ + +var specialChars="\\(\\)\\>\\<\\@\\,\\;\\:\\+\\!\\%\\/\\=\\*\\#\\&\\{\\}\\?\\$|\\\\\\\"\\.\\[\\]"; + +/* The following string represents the range of characters allowed in a +username or domainname. It really states which chars aren''''t allowed.*/ + +var validChars="\[^\\s" + specialChars + "\]"; +/*var validChars="\[^\\s" + "\]";*/ + +/* The following pattern applies if the "user" is a quoted string (in +which case, there are no rules about which characters are allowed +and which aren''''t; anything goes). E.g. "jiminy cricket"@disney.com +is a legal e-mail address. */ + +var quotedUser="(\"[^\"]*\")"; + +/* The following pattern applies for domains that are IP addresses, +rather than symbolic names. E.g. joe@[123.124.233.4] is a legal +e-mail address. NOTE: The square brackets are required. */ + +var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; + +/* The following string represents an atom (basically a series of non-special characters.) */ + +var atom=validChars + ''''+''''; + +/* The following string represents one word in the typical username. +For example, in john.doe@somewhere.com, john and doe are words. +Basically, a word is either an atom or quoted string. */ + +var word="(" + atom + "|" + quotedUser + ")"; + +// The following pattern describes the structure of the user + +var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); + +/* The following pattern describes the structure of a normal symbolic +domain, as opposed to ipDomainPat, shown above. */ + +var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); + +/* Finally, let''''s start trying to figure out if the supplied address is valid. */ + +/* Begin with the coarse pattern to simply break up user@domain into +different pieces that are easy to analyze. */ + +var matchArray=emailStr.match(emailPat); + +if (matchArray==null) { + +/* Too many/few @''''s or something; basically, this address doesn''''t +even fit the general mould of a valid e-mail address. */ +setTimeout( fieldFocus , 100 ); + +if (lang=="HU") { +alert("Helytelen Email cím (ellenorizze a @ és . karaktereket)"); +} +else { +alert("Email address seems incorrect (check @ and .''''s)"); +} +return false; +} +var user=matchArray[1]; +var domain=matchArray[2]; + +// Start by checking that only basic ASCII characters are in the strings (0-127). + +for (i=0; i127) { +alert("This username contains invalid characters."); +emailObj.focus(); +return false; + } +} +for (i=0; i127) { +alert("This domain name contains invalid characters."); +emailObj.focus(); +return false; + } +} + +// See if "user" is valid + +if (user.match(userPat)==null) { + +// user is not valid +if (lang=="HU") { +alert("A felhasználónév nem tunik érvényesnek."); +} +else { +alert("The username doesn''''t seem to be valid."); +} +emailObj.focus(); +return false; +} + +/* if the e-mail address is at an IP address (as opposed to a symbolic +host name) make sure the IP address is valid. */ + +var IPArray=domain.match(ipDomainPat); +if (IPArray!=null) { + +// this is an IP address + +for (var i=1;i<=4;i++) { +if (IPArray[i]>255) { +alert("Destination IP address is invalid!"); +emailObj.focus(); +return false; + } +} +return true; +} + +// Domain is symbolic name. Check if it''''s valid. + +var atomPat=new RegExp("^" + atom + "$"); +var domArr=domain.split("."); +var len=domArr.length; +for (i=0;i'); + htp.p(WSGJSL.OpenEvent('CUST','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFU','OnClick')); + htp.p(' if (!CUST_Validate(ctl)) { return false; }'); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFD','OnClick')); + htp.p(WSGJSL.VerifyDelete(WSGL.MsgGetText(118, WSGLM.DSP118_CONFIRM_DELETE))); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFR','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnVFI','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('AI_INTE','OnClick')); + htp.p(' + var TargetFrame = JSLFindTargetFrame( "_top"); + var Url = "EFNOW110$CUIN.startup?Z_FORM=QUERY&P_CUST_ID=" + P_CUST_ID[index] + "&P_2=" + P_2[index] + "&Z_CHK=" + CUIN_CHK_VALUE[index]; + if (TargetFrame) + { + TargetFrame.location = Url; + } + else + { + location = Url; + } + return false;'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + VF_BODY_ATTRIBUTES, 'efnow110$js$cust.CreateViewJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$js$cust.CreateInsertJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateInsertJavaScript( + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + IF_BODY_ATTRIBUTES in varchar2, + LOV_FRAME in varchar2) is + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Insert";'); + htp.p('var index = 0;'); + if IF_ROWS_INSERTED > 0 then + htp.p( 'var DataChange = true;' ); + else + htp.p( 'var DataChange = false;' ); + end if; + if IF_ROWS_ERROR > 0 then + htp.p( 'var DataChangeErrors = true;' ); + else + htp.p( 'var DataChangeErrors = false;' ); + end if; + + + htp.p(WSGJSL.RtnOpenLOV); + htp.p(WSGJSL.RtnNotNull); + htp.p(WSGJSL.RtnChkMaxLength); + htp.p(WSGJSL.RtnCheckModified); + htp.p(WSGJSL.RtnRevertForm); + htp.p(WSGJSL.RtnFlagRow); + htp.p(WSGJSL.RtnFindTargetFrame); + + WSGJSL.Output_Invoke_CAL_JS ('efnow110$cust', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('UI_KAM_MGR_NAME','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + if (index == null) + index = 0; + if (ctl[index].form.name.search(/VForm$/) == -1) + { + modeStr = "INS"; + } + else + { + modeStr = "UPD"; + } +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl[index], index, modeStr, "efnow110$cust.kam_syus_id_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('CUST','Validate')); + htp.p( +' +// CheckEmail +// +// +return emailCheck(ctl.form.P_EMAIL_ADDRESS[0]);');htp.p('var index = 0;'); + + + htp.p(WSGJSL.CallNotNull('ctl.form.P_PRIMARY_CONTACT[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Primary Contact*#2472#:'))); + + + htp.p(WSGJSL.CallNotNull('ctl.form.P_PRIMARY_CONTACT_TEL[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Primary Contact Tel.*#2473#:'))); + + + htp.p(WSGJSL.CallNotNull('ctl.form.P_EMAIL_ADDRESS[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Email Address*#2462#:'))); + + htp.p(WSGJSL.CallChkMaxLength('ctl.form.P_DESCRIPTION[index]', 80, WSGL.MsgGetText(230, WSGLM.MSG230_MAXLEN_ERROR, '#Description#20#:', '80') +)); + + + htp.p(WSGJSL.CallNotNull('ctl.form.P_TELEPHONE[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Telephone*#2463#:'))); + + + htp.p(WSGJSL.CallNotNull('ctl.form.P_FAX[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Fax*#2465#:'))); + + + + + htp.p(WSGJSL.CallNotNull('ctl.form.P_PERIOD_START[index]', WSGL.MsgGetText(219, WSGLM.MSG219_MISSING_MANDATORY, '#Period Start*#2460#:'))); + + + htp.p(WSGJSL.CloseEvent); + htp.p( +'// emailCheck +// +// + +function emailCheck (emailObj,lang) { + +function fieldFocus() { + emailObj.focus(); +} +/* The following variable tells the rest of the function whether or not +to verify that the address ends in a two-letter country or well-known +TLD. 1 means check it, 0 means don''''t. */ + +var checkTLD=1; +var emailStr = emailObj.value; + +/* The following is the list of known TLDs that an e-mail address must end with. */ + +var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; + +/* The following pattern is used to check if the entered e-mail address +fits the user@domain format. It also is used to separate the username +from the domain. */ + +var emailPat=/^(.+)@(.+)$/; + +/* The following string represents the pattern for matching all special +characters. We don''''t want to allow special characters in the address. +These characters include ( ) < > @ , ; : \ " . [ ] */ + +/* +other chars: +!%/=*-#&{}?$| +*/ + +var specialChars="\\(\\)\\>\\<\\@\\,\\;\\:\\+\\!\\%\\/\\=\\*\\#\\&\\{\\}\\?\\$|\\\\\\\"\\.\\[\\]"; + +/* The following string represents the range of characters allowed in a +username or domainname. It really states which chars aren''''t allowed.*/ + +var validChars="\[^\\s" + specialChars + "\]"; +/*var validChars="\[^\\s" + "\]";*/ + +/* The following pattern applies if the "user" is a quoted string (in +which case, there are no rules about which characters are allowed +and which aren''''t; anything goes). E.g. "jiminy cricket"@disney.com +is a legal e-mail address. */ + +var quotedUser="(\"[^\"]*\")"; + +/* The following pattern applies for domains that are IP addresses, +rather than symbolic names. E.g. joe@[123.124.233.4] is a legal +e-mail address. NOTE: The square brackets are required. */ + +var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; + +/* The following string represents an atom (basically a series of non-special characters.) */ + +var atom=validChars + ''''+''''; + +/* The following string represents one word in the typical username. +For example, in john.doe@somewhere.com, john and doe are words. +Basically, a word is either an atom or quoted string. */ + +var word="(" + atom + "|" + quotedUser + ")"; + +// The following pattern describes the structure of the user + +var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); + +/* The following pattern describes the structure of a normal symbolic +domain, as opposed to ipDomainPat, shown above. */ + +var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); + +/* Finally, let''''s start trying to figure out if the supplied address is valid. */ + +/* Begin with the coarse pattern to simply break up user@domain into +different pieces that are easy to analyze. */ + +var matchArray=emailStr.match(emailPat); + +if (matchArray==null) { + +/* Too many/few @''''s or something; basically, this address doesn''''t +even fit the general mould of a valid e-mail address. */ +setTimeout( fieldFocus , 100 ); + +if (lang=="HU") { +alert("Helytelen Email cím (ellenorizze a @ és . karaktereket)"); +} +else { +alert("Email address seems incorrect (check @ and .''''s)"); +} +return false; +} +var user=matchArray[1]; +var domain=matchArray[2]; + +// Start by checking that only basic ASCII characters are in the strings (0-127). + +for (i=0; i127) { +alert("This username contains invalid characters."); +emailObj.focus(); +return false; + } +} +for (i=0; i127) { +alert("This domain name contains invalid characters."); +emailObj.focus(); +return false; + } +} + +// See if "user" is valid + +if (user.match(userPat)==null) { + +// user is not valid +if (lang=="HU") { +alert("A felhasználónév nem tunik érvényesnek."); +} +else { +alert("The username doesn''''t seem to be valid."); +} +emailObj.focus(); +return false; +} + +/* if the e-mail address is at an IP address (as opposed to a symbolic +host name) make sure the IP address is valid. */ + +var IPArray=domain.match(ipDomainPat); +if (IPArray!=null) { + +// this is an IP address + +for (var i=1;i<=4;i++) { +if (IPArray[i]>255) { +alert("Destination IP address is invalid!"); +emailObj.focus(); +return false; + } +} +return true; +} + +// Domain is symbolic name. Check if it''''s valid. + +var atomPat=new RegExp("^" + atom + "$"); +var domArr=domain.split("."); +var len=domArr.length; +for (i=0;i'); + htp.p(WSGJSL.OpenEvent('CUST','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnIFI','OnClick')); + htp.p(' if (!CUST_Validate(ctl)) { return false; }'); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnIFR','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + IF_BODY_ATTRIBUTES, 'efnow110$js$cust.CreateInsertJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow110$js$cust.CreateQueryJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateQueryJavaScript ( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow110$cust') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Query";'); + + + htp.p(WSGJSL.OpenEvent('UI_CODE','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + index = -1; + modeStr = "Q"; +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl, index, modeStr, "efnow110$cust.eflv_cust_code1_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + WSGJSL.Output_Invoke_CAL_JS ('efnow110$cust', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('UI_NAME','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + index = -1; + modeStr = "Q"; +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl, index, modeStr, "efnow110$cust.eflv_cust_name1_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('CUST','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnQFQ','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'#Maintain Customer#1058#', + QF_BODY_ATTRIBUTES, 'efnow110$js$cust.CreateQueryJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cust.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cust.spc new file mode 100644 index 0000000..d847a52 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow110$js$cust.spc @@ -0,0 +1,23 @@ +create or replace package efnow110$js$cust is + + procedure CreateQueryJavaScript( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2); + + procedure CreateViewJavaScript( + VF_ROWS_UPDATED in integer, + VF_ROWS_DELETED in integer, + VF_ROWS_ERROR in integer, + VF_BODY_ATTRIBUTES in varchar2, + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + LOV_FRAME in varchar2); + + procedure CreateInsertJavaScript( + IF_ROWS_INSERTED in integer, + IF_ROWS_ERROR in integer, + IF_BODY_ATTRIBUTES in varchar2, + LOV_FRAME in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$.bdy new file mode 100644 index 0000000..ebcb6d9 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$.bdy @@ -0,0 +1,232 @@ +create or replace package body efnow120$ is + private_ModuleRef WSGOC.MODULE_REF; + + + procedure CreateStartupJavaScript; +-------------------------------------------------------------------------------- +-- Name: efnow120$.Startup +-- +-- Description: This procedure is the entry point for the 'efnow120$' +-- module (#View Commercial Confirmations#2480#). +-- +-- Parameters: None +-- +-------------------------------------------------------------------------------- + procedure Startup + is + begin + if not caco_security.security_check('efnow120$') then + return; + end if; + + WSGL.RegisterURL('efnow120$.startup'); + if WSGL.NotLowerCase then + return; + end if; + WSGL.StoreURLLink(0, '#View Commercial Confirmations#2480#'); + efnow120$conf.startup( + Z_DIRECT_CALL => TRUE + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#', + '', 'efnow120$.Startup'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow120$.firstpage +-- +-- Description: This procedure creates the first page for the 'efnow120$' +-- module (#View Commercial Confirmations#2480#). +-- +-- Parameters: Z_DIRECT_CALL + +-- +-------------------------------------------------------------------------------- + procedure FirstPage(Z_DIRECT_CALL in boolean + +) is + begin + if not caco_security.security_check('efnow120$') then + return; + end if; + + WSGL.OpenPageHead('#View Commercial Confirmations#2480#'); + WSGL.METATag; + WSGL.ClosePageHead; + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + CreateStartupJavaScript; + + WSGL.DefaultPageCaption('#View Commercial Confirmations#2480#', 1); + htp.formOpen(curl => 'ActionItem', cattributes => 'NAME="SP$AIForm"'); + WSGL.NavLinks(WSGL.MENU_LONG, WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT), 0, 'efnow120$.showabout', '_top', p_output_line=>FALSE); + WSGL.NavLinks; + htp.formClose; + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#', + '', 'efnow120$.FirstPage'); + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow120$.showabout +-- +-- Description: This procedure is used to display an 'About' page for the +-- 'efnow120$' module (#View Commercial Confirmations#2480#). +-- +-------------------------------------------------------------------------------- + procedure showabout is + l_usr varchar2(255) := null; + begin + if not caco_security.security_check('efnow120$') then + return; + end if; + l_usr := caco_security.get_user; + + WSGL.RegisterURL('efnow120$.showabout'); + if WSGL.NotLowerCase then + return; + end if; + + WSGL.OpenPageHead(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' #View Commercial Confirmations#2480#'); + WSGL.METATag; + TemplateHeader(TRUE,2); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>''); + + htp.p(caco_system.menu); + + WSGL.DefaultPageCaption(WSGL.MsgGetText(107,WSGLM.DSP107_ABOUT)||' #View Commercial Confirmations#2480#'); + + htp.para; + htp.p(' +$Revision: 1.4 $'); + htp.para; + + htp.para; + + htp.p(WSGL.MsgGetText(108,WSGLM.DSP108_GENERATED_BY, 'PL/SQL Web Generator', '10.1.2.6.18')); + htp.para; + + WSGL.Info(FALSE, 'Nominations', 'EFNOW120', l_usr); + + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#', + '', 'efnow120$.ShowAbout'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow120$.TemplateHeader +-- +-- Description: +-- +-------------------------------------------------------------------------------- + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number) is + begin + if not caco_security.security_check('efnow120$') then + return; + end if; + + if Z_TEMPLATE_ID = 1 then + -- Template defined in \\loordv01\framework\css2\css_content.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 2 then + -- Template defined in \\loordv01\framework\css2\css_about.htm + htp.p(' '); + elsif Z_TEMPLATE_ID = 3 then + -- Template defined in \\loordv01\framework\css2\css_query.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 4 then + -- Template defined in \\loordv01\framework\css2\css_view.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 5 then + -- Template defined in \\loordv01\framework\css2\css_insert.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 6 then + -- Template defined in \\loordv01\framework\css2\css_recordlist.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 7 then + -- Template defined in \\loordv01\framework\css2\css_lov.htm + htp.p(' + +'); + elsif Z_TEMPLATE_ID = 8 then + -- Template defined in \\loordv01\framework\css2\css_text.htm + htp.p(' + +'); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#', + '', 'efnow120$.TemplateHeader'); + end; +-------------------------------------------------------------------------------- +-- Name: efnow120$.GetRef +-- +-- Description: Returns a handle to the display data for the +-- 'efnow120$' module (#View Commercial Confirmations#2480#). +-- If the display object does not exist then it creates it first. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + function GetRef return WSGOC.MODULE_REF + is + begin + if ( WSGOC.Is_Null(private_ModuleRef)) then + private_ModuleRef := WSGOC.Module + ( pShortName => 'efnow120$' + , pFirstTitle => '#View Commercial Confirmations#2480#' + ); + end if; + return private_ModuleRef; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#', + '', 'efnow120$.GetRef'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow120$.CreateStartupJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateStartupJavaScript is + begin + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Startup";'); + htp.p(WSGJSL.CloseScript); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$.spc new file mode 100644 index 0000000..0496ece --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$.spc @@ -0,0 +1,14 @@ +create or replace package efnow120$ is + + procedure Startup +; + procedure FirstPage(Z_DIRECT_CALL in boolean + +); + procedure ShowAbout; + procedure TemplateHeader(Z_DIRECT_CALL in boolean, + Z_TEMPLATE_ID in number); + function GetRef return WSGOC.MODULE_REF; + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$conf.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$conf.bdy new file mode 100644 index 0000000..51670c4 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$conf.bdy @@ -0,0 +1,1539 @@ +create or replace package body efnow120$conf is + + function CUST_CONT_LOV( + P_VALUE in varchar2 default null, + P_CTRL in number default 0, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean default false, + p_onchange in boolean default false, + p_onblur in boolean default false, + p_onfocus in boolean default false, + p_onselect in boolean default false, + p_row in number default null) return varchar2; + function BuildSQL( + P_L_CONT2_CONTRACT_NUMBER in varchar2 default null, + P_L_NOMI_IDENTIFIER in varchar2 default null, + P_CONFIRMATION_SENT in varchar2 default null, + U_CONFIRMATION_SENT in varchar2 default null, + P_GAS_DAY in varchar2 default null, + U_GAS_DAY in varchar2 default null, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean; + procedure OpenZoneSql ( I_CURSOR OUT integer ); + procedure AssignZoneRow( I_CURSOR IN integer ); + + function PreQuery( + P_L_CONT2_CONTRACT_NUMBER in varchar2 default null, + P_L_NOMI_IDENTIFIER in varchar2 default null, + P_CONFIRMATION_SENT in varchar2 default null, + U_CONFIRMATION_SENT in varchar2 default null, + P_GAS_DAY in varchar2 default null, + U_GAS_DAY in varchar2 default null) return boolean; + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean; + + QF_BODY_ATTRIBUTES constant varchar2(500) := ''; + QF_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(3,WSGLM.CAP003_QF_FIND); + QF_CLEAR_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(4,WSGLM.CAP004_QF_CLEAR); + QF_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + QF_CLEAR_BUT_ACTION constant varchar2(10) := 'CLEAR'; + QF_NUMBER_OF_COLUMNS constant number(4) := 1; + VF_BODY_ATTRIBUTES constant varchar2(500) := ''; + IF_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_BODY_ATTRIBUTES constant varchar2(500) := ''; + RL_NEXT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(11,WSGLM.CAP011_RL_NEXT); + RL_PREV_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(12,WSGLM.CAP012_RL_PREVIOUS); + RL_FIRST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(13,WSGLM.CAP013_RL_FIRST); + RL_LAST_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(14,WSGLM.CAP014_RL_LAST); + RL_COUNT_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(15,WSGLM.CAP015_RL_COUNT); + RL_REQUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(16,WSGLM.CAP016_RL_REQUERY); + RL_QUERY_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(24,WSGLM.CAP024_RL_QUERY); + RL_QUERY_BUT_ACTION constant varchar2(10) := 'QUERY'; + RL_NEXT_BUT_ACTION constant varchar2(10) := 'NEXT'; + RL_PREV_BUT_ACTION constant varchar2(10) := 'PREV'; + RL_FIRST_BUT_ACTION constant varchar2(10) := 'FIRST'; + RL_LAST_BUT_ACTION constant varchar2(10) := 'LAST'; + RL_COUNT_BUT_ACTION constant varchar2(10) := 'COUNT'; + RL_REQUERY_BUT_ACTION constant varchar2(10) := 'REQUERY'; + RL_RECORD_SET_SIZE constant number(4) := 10; + RL_TOTAL_COUNT_REQD constant boolean := FALSE; + RL_NUMBER_OF_COLUMNS constant number(4) := 1; + LOV_BODY_ATTRIBUTES constant varchar2(500) := ''; + LOV_FIND_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(17,WSGLM.CAP017_LOV_FIND); + LOV_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP018_LOV_CLOSE); + LOV_FIND_BUT_ACTION constant varchar2(10) := 'FIND'; + LOV_CLOSE_BUT_ACTION constant varchar2(10) := 'CLOSE'; + LOV_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + LOV_FRAME constant varchar2(20) := null; + CAL_BUTTON_TEXT constant varchar2(100) := htf.img('/framework/images/lov.gif','TOP','List Values',NULL,'WIDTH=18 HEIGHT=22 BORDER=0'); + CAL_CLOSE_BUT_CAPTION constant varchar2(100) := WSGL.MsgGetText(18,WSGLM.CAP025_CAL_CLOSE); + CAL_BODY_ATTRIBUTES constant varchar2(500) := ''; + TF_BODY_ATTRIBUTES constant varchar2(500) := ''; + DEF_BODY_ATTRIBUTES constant varchar2(500) := ''; + + type FORM_REC is record + (L_CUST2_NAME varchar2(600) + ,L_CONT2_CONTRACT_NUMBER varchar2(180) + ,L_NOMI_IDENTIFIER varchar2(180) + ,UI_GAS_DAY varchar2(24000) + ,CONFIRMATION_SENT varchar2(19) + ,UI_CONF_SENT varchar2(24000) + ,UI_URL varchar2(24000) + ,CONF_ID varchar2(40) + ,NOMI_ID varchar2(40) + ,UI_GAS_DAY_DATE varchar2(40) + ,GAS_DAY varchar2(12) + ,CONT_ID varchar2(40) + ); + FORM_VAL FORM_REC; + + PROCESSING_VIEW boolean := false; + ZONE_SQL varchar2(32767) := null; + ZONE_CHECKSUM varchar2(10); + + REF_COMPONENT WSGOC.COMPONENT_REF; + R_L_CUST2_NAME WSGOC.ITEM_REF; + R_L_CONT2_CONTRACT_NUMBER WSGOC.ITEM_REF; + R_L_NOMI_IDENTIFIER WSGOC.ITEM_REF; + R_UI_GAS_DAY WSGOC.ITEM_REF; + R_CONFIRMATION_SENT WSGOC.ITEM_REF; + R_UI_CONF_SENT WSGOC.ITEM_REF; + R_UI_URL WSGOC.ITEM_REF; + R_CONF_ID WSGOC.ITEM_REF; + R_NOMI_ID WSGOC.ITEM_REF; + R_UI_GAS_DAY_DATE WSGOC.ITEM_REF; + R_GAS_DAY WSGOC.ITEM_REF; + R_CONT_ID WSGOC.ITEM_REF; + + + +FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- FormatDate +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT'); + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date, v_mask),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDate; +FUNCTION FormatDateTime ( p_date IN VARCHAR2 ) RETURN VARCHAR2 IS + +-- FormatDateTime +-- +-- + + + + -- + v_return VARCHAR2(100); + v_mask VARCHAR2(34) := cout_system_configuration.get_configuration_item('G_DATE_FORMAT')||' HH24:MI:SS'; + -- +BEGIN + -- + v_return := TO_CHAR(TO_DATE(p_date, v_mask||' HH24:MI:SS'),v_mask); + -- + RETURN v_return; + -- +EXCEPTION + WHEN OTHERS THEN + RETURN p_date; +END FormatDateTime; +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.CUST_CONT_LOV +-- +-- Description: Builds a GUI control to display the values returned by +-- LOV 'CUST_CONT'. +-- +-- +-------------------------------------------------------------------------------- + function CUST_CONT_LOV( + P_VALUE in varchar2, + P_CTRL in number, + P_MODE in varchar2 default 'Q', + p_select_first in boolean default false, + p_onclick in boolean, + p_onchange in boolean, + p_onblur in boolean, + p_onfocus in boolean, + p_onselect in boolean, + p_row in number) return varchar2 is + + L_RET_VALUE varchar2(32766) := null; + l_events varchar2(1000) := null; + l_valid boolean := false; + l_first boolean := true; + + cursor c1( z_mode in varchar2 + , z_filter in varchar2 + , z_uu in varchar2 + , z_ul in varchar2 + , z_lu in varchar2 + , z_ll in varchar2 + ) + is + SELECT CONT.CONTRACT_NUMBER CONTRACT_NUMBER +FROM CONTRACTS CONT +WHERE /* CG$LOVI_WC_START CUST_CONT 10 */ + (CONT.cust_id = caco_utilities.get_cust_id) + /* CG$LOVI_WC_END CUST_CONT 10 */ AND + (CONT.CONTRACT_NUMBER like z_uu||'%' or CONT.CONTRACT_NUMBER like z_ul||'%' or CONT.CONTRACT_NUMBER like z_lu||'%' or CONT.CONTRACT_NUMBER like z_ll||'%') and upper(CONT.CONTRACT_NUMBER) like upper(z_filter) +; + + l_rownum_txt varchar2(30); + begin + if p_row is not null then + l_rownum_txt := ', ' || to_char(p_row - 1); + end if; + if p_onclick then + l_events := l_events || ' onClick="return L_CONT2_CONTRACT_NUMBER_OnClick(this'||l_rownum_txt||')"'; + end if; + if p_onchange then + l_events := l_events || ' onChange="return L_CONT2_CONTRACT_NUMBER_OnChange(this'||l_rownum_txt||')"'; + end if; + if p_onblur then + l_events := l_events || ' onBlur="return L_CONT2_CONTRACT_NUMBER_OnBlur(this'||l_rownum_txt||')"'; + end if; + if p_onfocus then + l_events := l_events || ' onFocus="return L_CONT2_CONTRACT_NUMBER_OnFocus(this'||l_rownum_txt||')"'; + end if; + if p_onselect then + l_events := l_events || ' onSelect="return L_CONT2_CONTRACT_NUMBER_OnSelect(this'||l_rownum_txt||')"'; + end if; + + -- IDs Feature: + if P_CTRL = WSGL.CTL_QUERY and 1 <> 1 then + L_RET_VALUE := htf.formSelectOpen('P_L_CONT2_CONTRACT_NUMBER', + nsize=>'1', + cattributes=>'MULTIPLE CLASS = cglovlist'||l_events||' ID="'||'P_L_CONT2_CONTRACT_NUMBER'||'"'); + else + L_RET_VALUE := htf.formSelectOpen('P_L_CONT2_CONTRACT_NUMBER', + nsize=>'1', + cattributes=>'CLASS = cglovlist'||l_events||' ID="'||'P_L_CONT2_CONTRACT_NUMBER'||'"'); + end if; + + if P_CTRL = WSGL.CTL_QUERY and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(' ', 'SELECTED'); + l_first := false; + l_valid := true; + end if; + + for c1rec in c1( P_MODE, '%',null,null,null,null) loop + if ((WSGL.EscapeItem(c1rec.CONTRACT_NUMBER) = P_VALUE) or c1rec.CONTRACT_NUMBER = P_VALUE) or (p_select_first and l_first) then + l_valid := true; + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CONTRACT_NUMBER), 'SELECTED', + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.CONTRACT_NUMBER)||'"'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.EscapeItem(c1rec.CONTRACT_NUMBER), null, + cattributes=>'VALUE="'||WSGL.EscapeItem(c1rec.CONTRACT_NUMBER)||'"'); + end if; + l_first := false; + end loop; + + if P_CTRL = WSGL.CTL_QUERY then + if l_first and p_select_first then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(1,WSGLM.CAP001_UNKNOWN), 'SELECTED'); + else + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(1,WSGLM.CAP001_UNKNOWN)); + end if; + end if; + + if not l_valid then + L_RET_VALUE := L_RET_VALUE || htf.formSelectOption(WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL), 'SELECTED', + 'VALUE="'||WSGL.MsgGetText(28,WSGLM.CAP028_INVALID_VAL)||'"'); + end if; + L_RET_VALUE := L_RET_VALUE || htf.formSelectClose; + + return L_RET_VALUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.CUST_CONT_LOV'); + return L_RET_VALUE; + end; +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.calendar +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + + 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('efnow120$conf.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), + CAL_BODY_ATTRIBUTES, + 'efnow120$conf', + CAL_CLOSE_BUT_CAPTION, + True, + 'DD-MON-RRRR' + ); + + efnow120$.TemplateHeader(TRUE,7); + + WSGL.Output_Calendar + ( + Z_FIELD_NAME, + Z_FIELD_VALUE, + Z_FIELD_FORMAT, + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + 'efnow120$conf', + CAL_CLOSE_BUT_CAPTION, + False, + 'DD-MON-RRRR' + ); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '', + CAL_BODY_ATTRIBUTES, 'efnow120$conf.calendar'); + end calendar; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.format_cal_date +-- +-- Description: Converts the chosen date into the correct format using the format mask assigned +-- to the field that the calendar was popped up for +-- +-------------------------------------------------------------------------------- + +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; + +begin + + if l_day = '0' then + l_day := '01'; + end if; + + WSGL.Output_Format_Cal_JS + ( + WSGL.MsgGetText(123,WSGLM.DSP128_CAL_CAPTION, Field_Caption), + CAL_BODY_ATTRIBUTES, + l_day || '-' || month || '-' || year, + Z_FIELD_FORMAT + ); + +end format_cal_date; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.Startup +-- +-- Description: Entry point for the 'CONF' module +-- component . +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure Startup( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2, + Z_FORM in varchar2) is + l_Foundform boolean := FALSE; + l_fs_text varchar2(32767) := '' ; + begin + if not caco_security.security_check('efnow120$conf') then + return; + end if; + + WSGL.RegisterURL('efnow120$conf.startup'); + WSGL.AddURLParam('Z_CHK', Z_CHK); + + + WSGL.StoreURLLink(1, 'CONF'); + + -- Either no frames are being used or the query form is on a + -- separate page. + if Z_FORM is not null then + null; + -- Work out which form is required, and check if that is possible + if Z_FORM = 'QUERY' then + FormQuery( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + if Z_FORM = 'LIST' then + QueryList( + Z_DIRECT_CALL=>TRUE); + l_Foundform := TRUE; + end if; + end if; + if l_Foundform = FALSE then + FormQuery( + Z_DIRECT_CALL=>TRUE); + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.Startup'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.ActionQuery +-- +-- Description: Called when a Query form is subitted to action the query request. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure ActionQuery( + P_L_CONT2_CONTRACT_NUMBER in varchar2, + P_L_NOMI_IDENTIFIER in varchar2, + P_CONFIRMATION_SENT in varchar2, + U_CONFIRMATION_SENT in varchar2, + P_GAS_DAY in varchar2, + U_GAS_DAY in varchar2, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2, + Z_CHK in varchar2 ) is + + L_CHK varchar2(10) := Z_CHK; + L_BUTCHK varchar2(100):= null; + l_dummy_bool boolean := false; + begin + if not caco_security.security_check('efnow120$conf') then + return; + end if; + + if not Z_DIRECT_CALL then + null; + end if; + + l_dummy_bool := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + QueryList( + P_L_CONT2_CONTRACT_NUMBER, + P_L_NOMI_IDENTIFIER, + P_CONFIRMATION_SENT, + U_CONFIRMATION_SENT, + P_GAS_DAY, + U_GAS_DAY, + Z_START=>null, + Z_ACTION=>L_BUTCHK, + Z_DIRECT_CALL=>TRUE); + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.ActionQuery'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.QueryHits +-- +-- Description: Returns the number or rows which matches the given search +-- criteria (if any). +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function QueryHits( + P_L_CONT2_CONTRACT_NUMBER in varchar2, + P_L_NOMI_IDENTIFIER in varchar2, + P_CONFIRMATION_SENT in varchar2, + U_CONFIRMATION_SENT in varchar2, + P_GAS_DAY in varchar2, + U_GAS_DAY in varchar2) return number is + I_QUERY varchar2(32767) := ''; + I_CURSOR integer; + I_VOID integer; + I_FROM_POS integer := 0; + I_COUNT number(10); + begin + if not caco_security.security_check('efnow120$conf') then + return -1; + end if; + + if not BuildSQL(P_L_CONT2_CONTRACT_NUMBER, + P_L_NOMI_IDENTIFIER, + P_CONFIRMATION_SENT, + U_CONFIRMATION_SENT, + P_GAS_DAY, + U_GAS_DAY) then + return -1; + end if; + + if not PreQuery(P_L_CONT2_CONTRACT_NUMBER, + P_L_NOMI_IDENTIFIER, + P_CONFIRMATION_SENT, + U_CONFIRMATION_SENT, + P_GAS_DAY, + U_GAS_DAY) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + '#View Commercial Confirmations#2480#'||' : '||'', DEF_BODY_ATTRIBUTES); + return -1; + end if; + + I_FROM_POS := instr(upper(ZONE_SQL), ' FROM '); + + if I_FROM_POS = 0 then + return -1; + end if; + + I_QUERY := 'SELECT count(*)' || + substr(ZONE_SQL, I_FROM_POS); + + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, I_QUERY, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, I_COUNT); + I_VOID := dbms_sql.execute(I_CURSOR); + I_VOID := dbms_sql.fetch_rows(I_CURSOR); + dbms_sql.column_value(I_CURSOR, 1, I_COUNT); + dbms_sql.close_cursor(I_CURSOR); + + return I_COUNT; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.QueryHits'); + return -1; + end; +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.BuildSQL +-- +-- Description: Builds the SQL for the 'CONF' module component. +-- This incorporates all query criteria and Foreign key columns. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function BuildSQL( + P_L_CONT2_CONTRACT_NUMBER in varchar2, + P_L_NOMI_IDENTIFIER in varchar2, + P_CONFIRMATION_SENT in varchar2, + U_CONFIRMATION_SENT in varchar2, + P_GAS_DAY in varchar2, + U_GAS_DAY in varchar2, + Z_QUERY_BY_KEY in boolean default false, + Z_ROW_ID in ROWID default null, + Z_BIND_ROW_ID in boolean default false) return boolean is + + I_WHERE varchar2(32767); + row_idx integer; + begin + + + -- Build up the Where clause + if Z_QUERY_BY_KEY then + I_WHERE := 'WHERE CONF_ID = ' || to_char(CURR_VAL.CONF_ID) || ' '; + elsif Z_ROW_ID is not null then + I_WHERE := 'WHERE CG$ROW_ID = ''' || rowidtochar( Z_ROW_ID ) || ''''; + elsif Z_BIND_ROW_ID then + I_WHERE := 'WHERE CG$ROW_ID = :b_row_id'; + else + WSGL.BuildWhere(P_L_CONT2_CONTRACT_NUMBER, 'L_CONT2_CONTRACT_NUMBER', WSGL.TYPE_CHAR, I_WHERE); + WSGL.BuildWhere(P_L_NOMI_IDENTIFIER, 'L_NOMI_IDENTIFIER', WSGL.TYPE_CHAR, I_WHERE); + begin + WSGL.BuildWhere(P_CONFIRMATION_SENT, U_CONFIRMATION_SENT, 'CONFIRMATION_SENT', WSGL.TYPE_DATE, I_WHERE, 'DD/MM/YYYY HH24:MI:SS'); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_ERROR_QRY, SQLERRM, + '#View Commercial Confirmations#2480#'||' : '||'', DEF_BODY_ATTRIBUTES, NULL, + WSGL.MsgGetText(210,WSGLM.MSG210_INVALID_QRY,'#Confirmation Sent#2482#'), + WSGL.MsgGetText(211,WSGLM.MSG211_EXAMPLE_TODAY,to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS'))); + return false; + end; + begin + WSGL.BuildWhere(P_GAS_DAY, U_GAS_DAY, 'GAS_DAY', WSGL.TYPE_DATE, I_WHERE, 'DD/MM/YYYY'); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_ERROR_QRY, SQLERRM, + '#View Commercial Confirmations#2480#'||' : '||'', DEF_BODY_ATTRIBUTES, NULL, + WSGL.MsgGetText(210,WSGLM.MSG210_INVALID_QRY,'#Gas Day#1142#'), + WSGL.MsgGetText(211,WSGLM.MSG211_EXAMPLE_TODAY,to_char(sysdate, 'DD/MM/YYYY'))); + return false; + end; + + end if; + + ZONE_SQL := 'SELECT L_CUST2_NAME, + L_CONT2_CONTRACT_NUMBER, + L_NOMI_IDENTIFIER, + UI_GAS_DAY, + CONFIRMATION_SENT, + UI_CONF_SENT, + UI_URL, + CONF_ID, + NOMI_ID, + UI_GAS_DAY_DATE, + GAS_DAY, + CONT_ID + FROM ( SELECT L_CUST2.NAME L_CUST2_NAME, + L_CONT2.CONTRACT_NUMBER L_CONT2_CONTRACT_NUMBER, + L_NOMI.IDENTIFIER L_NOMI_IDENTIFIER, + ( SELECT EFNOW120$CONF.FORMATDATE(TO_CHAR(MIN(gas_day),cout_system_configuration.get_configuration_item(''G_DATE_FORMAT''))) FROM conf_net_point_cat_vals WHERE conf_id = CONF.CONF_ID ) UI_GAS_DAY, + CONF.CONFIRMATION_SENT CONFIRMATION_SENT, + ( SELECT EFNOW120$CONF.FORMATDATETIME(TO_CHAR(CONF.CONFIRMATION_SENT, cout_system_configuration.get_configuration_item(''G_DATE_FORMAT'')||'' HH24:MI:SS'')) FROM dual ) UI_CONF_SENT, + ''efnow099$.startup?p_conf_id=''||CONF.CONF_ID UI_URL, + CONF.CONF_ID CONF_ID, + CONF.NOMI_ID NOMI_ID, + ( SELECT MIN(gas_day) FROM conf_net_point_cat_vals WHERE conf_id = CONF.CONF_ID ) UI_GAS_DAY_DATE, + CONF.GAS_DAY GAS_DAY, + CONF.CONT_ID CONT_ID +FROM CONFIRMATIONS CONF, + NOMINATIONS L_NOMI, + CONTRACTS L_CONT2, + CUSTOMERS L_CUST2 +WHERE ( /* CG$MDTU_QWC_START CONF.CONF */ + (NVL(CONF.approved,''N'') = ''Y'' and CONF.confirmation_type = ''CO'') + /* CG$MDTU_QWC_END CONF.CONF */ + ) AND + CONF.NOMI_ID = L_NOMI.NOMI_ID (+) AND + CONF.CONT_ID = L_CONT2.CONT_ID (+) AND + ( /* CG$MDTU_QWC_START CONF.L_CUST2 */ + (L_CUST2.CUST_ID = caco_utilities.get_cust_id) + /* CG$MDTU_QWC_END CONF.L_CUST2 */ + ) AND + L_CONT2.CUST_ID = L_CUST2.CUST_ID (+) + ) '; + ZONE_SQL := ZONE_SQL || I_WHERE; + ZONE_SQL := ZONE_SQL || ' ORDER BY UI_GAS_DAY_DATE Desc '; + return true; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.BuildSQL'); + return false; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.OpenZoneSql +-- +-- Description: Open's the cursor for the zone SQL of +-- 'CONF' module component. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure OpenZoneSql + ( I_CURSOR OUT integer + ) + is + begin + I_CURSOR := dbms_sql.open_cursor; + dbms_sql.parse(I_CURSOR, ZONE_SQL, dbms_sql.v7); + dbms_sql.define_column(I_CURSOR, 1, NBT_VAL.L_CUST2_NAME, 100); + dbms_sql.define_column(I_CURSOR, 2, NBT_VAL.L_CONT2_CONTRACT_NUMBER, 30); + dbms_sql.define_column(I_CURSOR, 3, NBT_VAL.L_NOMI_IDENTIFIER, 30); + dbms_sql.define_column(I_CURSOR, 4, NBT_VAL.UI_GAS_DAY, 4000); + dbms_sql.define_column(I_CURSOR, 5, CURR_VAL.CONFIRMATION_SENT); + dbms_sql.define_column(I_CURSOR, 6, NBT_VAL.UI_CONF_SENT, 4000); + dbms_sql.define_column(I_CURSOR, 7, NBT_VAL.UI_URL, 4000); + dbms_sql.define_column(I_CURSOR, 8, CURR_VAL.CONF_ID); + dbms_sql.define_column(I_CURSOR, 9, CURR_VAL.NOMI_ID); + dbms_sql.define_column(I_CURSOR, 10, NBT_VAL.UI_GAS_DAY_DATE); + dbms_sql.define_column(I_CURSOR, 11, CURR_VAL.GAS_DAY); + dbms_sql.define_column(I_CURSOR, 12, CURR_VAL.CONT_ID); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + '', 'efnow120$conf.OpenZoneSql'); + raise; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.AssignZoneRow +-- +-- Description: Assign's a row of data and calculates the check sum from the +-- zone SQL of 'CONF' module component. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure AssignZoneRow + ( I_CURSOR IN integer + ) + is + begin + dbms_sql.column_value(I_CURSOR, 1, NBT_VAL.L_CUST2_NAME); + dbms_sql.column_value(I_CURSOR, 2, NBT_VAL.L_CONT2_CONTRACT_NUMBER); + dbms_sql.column_value(I_CURSOR, 3, NBT_VAL.L_NOMI_IDENTIFIER); + dbms_sql.column_value(I_CURSOR, 4, NBT_VAL.UI_GAS_DAY); + dbms_sql.column_value(I_CURSOR, 5, CURR_VAL.CONFIRMATION_SENT); + dbms_sql.column_value(I_CURSOR, 6, NBT_VAL.UI_CONF_SENT); + dbms_sql.column_value(I_CURSOR, 7, NBT_VAL.UI_URL); + dbms_sql.column_value(I_CURSOR, 8, CURR_VAL.CONF_ID); + dbms_sql.column_value(I_CURSOR, 9, CURR_VAL.NOMI_ID); + dbms_sql.column_value(I_CURSOR, 10, NBT_VAL.UI_GAS_DAY_DATE); + dbms_sql.column_value(I_CURSOR, 11, CURR_VAL.GAS_DAY); + dbms_sql.column_value(I_CURSOR, 12, CURR_VAL.CONT_ID); + ZONE_CHECKSUM := to_char(WSGL.Checksum + ( '' + || CURR_VAL.CONF_ID + ) ); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + '', 'efnow120$conf.AssignZoneRow'); + raise; + end; + + + + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.FormQuery +-- +-- Description: This procedure builds an HTML form for entry of query criteria. +-- The criteria entered are to restrict the query of the 'CONF' +-- module component. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure FormQuery( + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2) is + L_SUCCESS boolean := TRUE; + begin + if not caco_security.security_check('efnow120$conf') then + return; + end if; + + if not Z_DIRECT_CALL then + + null; + end if; + + L_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + WSGL.OpenPageHead('#View Commercial Confirmations#2480#'||' : '||''); + WSGL.METATag; + efnow120$.TemplateHeader(TRUE,1); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>QF_BODY_ATTRIBUTES || 'onLoad="return CONF_OnLoad()"'); + efnow120$js$conf.CreateQueryJavaScript(LOV_FRAME,QF_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + htp.p(caco_system.menu); + efnow120$.FirstPage(Z_DIRECT_CALL => TRUE + + ); + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + htp.p(WSGL.MsgGetText(115,WSGLM.DSP115_ENTER_QRY)); + htp.para; + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow120$conf.actionquery', cattributes => 'NAME="efnow120$conf$QForm"'); + + SaveState; + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); + WSGL.LayoutRowStart; + for i in 1..QF_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(29, 'LEFT', NULL); + WSGL.LayoutHeader(30, 'LEFT', NULL); + end loop; + WSGL.LayoutRowEnd; + + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Contract Number#2013#:')); + WSGL.LayoutData(CUST_CONT_LOV(NULL, WSGL.CTL_QUERY, 'Q', true)); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Nomination Identifier#2060#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('L_NOMI_IDENTIFIER', '30', FALSE, p_maxlength=>'30')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Confirmation Sent#2482#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('CONFIRMATION_SENT', '11', TRUE, p_maxlength=>'19' + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_date_format => 'DD/MM/YYYY HH24:MI:SS' + , p_cal_prompt => '#Confirmation Sent#2482#' + , p_form=>'efnow120$conf$QForm')); + WSGL.LayoutRowEnd; + WSGL.LayoutRowStart('TOP'); + WSGL.LayoutData(htf.bold('#Gas Day#1142#:')); + WSGL.LayoutData(WSGL.BuildQueryControl('GAS_DAY', '11', TRUE, p_maxlength=>'10' + , p_cal_but_text => CAL_BUTTON_TEXT + , p_cal_date_format => 'DD/MM/YYYY' + , p_cal_prompt => '#Gas Day#1142#' + , p_form=>'efnow120$conf$QForm')); + WSGL.LayoutRowEnd; + + WSGL.LayoutClose; + + WSGL.SubmitButton('Z_ACTION', htf.escape_sc(QF_QUERY_BUT_CAPTION), 'btnQFQ', 'this.form.Z_ACTION.value=\''' || QF_QUERY_BUT_ACTION || '\'''); + htp.formReset(htf.escape_sc(QF_CLEAR_BUT_CAPTION), 'ID="'||htf.escape_sc(QF_CLEAR_BUT_CAPTION)||'"'); + + + WSGL.HiddenField('Z_CHK', to_char(WSGL.Checksum + (''))); + htp.formClose; + + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + QF_BODY_ATTRIBUTES, 'efnow120$conf.FormQuery'); + WSGL.ClosePageBody; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.QueryList +-- +-- Description: This procedure builds the Record list for the 'CONF' +-- module component. +-- +-- The Record List displays context information for records which +-- match the specified query criteria. +-- Sets of records are displayed (10 records at a time) +-- with Next/Previous buttons to get other record sets. +-- +-- Parameters: P_L_CONT2_CONTRACT_NUMBER - #Contract Number#2013# +-- P_L_NOMI_IDENTIFIER - #Nomination Identifier#2060# +-- P_CONFIRMATION_SENT - #Confirmation Sent#2482# +-- U_CONFIRMATION_SENT - #Confirmation Sent#2482# (upper bound) +-- P_GAS_DAY - #Gas Day#1142# +-- U_GAS_DAY - #Gas Day#1142# (upper bound) +-- Z_START - First record to display +-- Z_ACTION - Next or Previous set +-- +-------------------------------------------------------------------------------- + procedure QueryList( + P_L_CONT2_CONTRACT_NUMBER in varchar2, + P_L_NOMI_IDENTIFIER in varchar2, + P_CONFIRMATION_SENT in varchar2, + U_CONFIRMATION_SENT in varchar2, + P_GAS_DAY in varchar2, + U_GAS_DAY in varchar2, + Z_START in varchar2, + Z_ACTION in varchar2, + Z_DIRECT_CALL in boolean, + Z_CHK in varchar2 ) is + + I_VF_FRAME varchar2(20) := null; + I_WHERE varchar2(2000) := ''; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer := 0; + I_TOTAL_ROWS integer := 0; + I_START number(38) := to_number(Z_START); + I_COUNT number(10) := 0; + I_OF_TOTAL_TEXT varchar2(200) := ''; + I_NEXT_BUT boolean; + I_PREV_BUT boolean; + I_COL_COUNT integer; + I_SUCCESS boolean := true; + l_row integer := 0; + l_id varchar2(35) := null; + -- Reset break group? + RSCONF boolean := true; + I_LAST_BASE CURR_VAL%TYPE; + I_LAST_NBT NBT_REC; + + + + begin + + if not caco_security.security_check('efnow120$conf') then + return; + end if; + + + WSGL.RegisterURL('efnow120$conf.querylist'); + WSGL.AddURLParam('P_L_CONT2_CONTRACT_NUMBER', P_L_CONT2_CONTRACT_NUMBER); + WSGL.AddURLParam('P_L_NOMI_IDENTIFIER', P_L_NOMI_IDENTIFIER); + WSGL.AddURLParam('P_CONFIRMATION_SENT', P_CONFIRMATION_SENT); + WSGL.AddURLParam('U_CONFIRMATION_SENT', U_CONFIRMATION_SENT); + WSGL.AddURLParam('P_GAS_DAY', P_GAS_DAY); + WSGL.AddURLParam('U_GAS_DAY', U_GAS_DAY); + WSGL.AddURLParam('Z_START', Z_START); + WSGL.AddURLParam('Z_ACTION', Z_ACTION); + WSGL.AddURLParam('Z_CHK', Z_CHK); + if (not Z_DIRECT_CALL) then + + null; + + + end if; + if (Z_ACTION = RL_QUERY_BUT_ACTION) or (Z_ACTION = RL_QUERY_BUT_CAPTION) then + FormQuery( + Z_DIRECT_CALL=>TRUE); + return; + end if; + + -- Set up any master context values that may be required + I_SUCCESS := RestoreState + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 99 + , Z_RESTORE_OWN_ROW => false + ); + + + + WSGL.OpenPageHead('#View Commercial Confirmations#2480#'||' : '||''); + WSGL.METATag; + efnow120$.TemplateHeader(TRUE,6); + WSGL.ClosePageHead; + + WSGL.OpenPageBody(FALSE, p_attributes=>RL_BODY_ATTRIBUTES); + efnow120$js$conf.CreateListJavaScript(RL_BODY_ATTRIBUTES); + + LoadCache + ( Z_CURR_DEPTH => 0 + , Z_MAX_DEPTH => 2 + , Z_OWN_ROW_VALUES => false + , Z_CONTEXT_FOR => REF_COMPONENT + ); + + + + htp.p(caco_system.menu); + + WSGMC_OUTPUT2.Before(REF_COMPONENT,2); + + if (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) or + (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + (RL_TOTAL_COUNT_REQD) + then + + I_COUNT := QueryHits( + P_L_CONT2_CONTRACT_NUMBER, + P_L_NOMI_IDENTIFIER, + P_CONFIRMATION_SENT, + U_CONFIRMATION_SENT, + P_GAS_DAY, + U_GAS_DAY); + if I_COUNT = -1 then + WSGL.ClosePageBody; + return; + end if; + end if; + + if (Z_ACTION = RL_COUNT_BUT_ACTION) or (Z_ACTION = RL_COUNT_BUT_CAPTION) or + RL_TOTAL_COUNT_REQD then + I_OF_TOTAL_TEXT := ' '||WSGL.MsgGetText(111,WSGLM.DSP111_OF_TOTAL, to_char(I_COUNT)); + end if; + if Z_START IS NULL or (Z_ACTION = RL_FIRST_BUT_ACTION) or (Z_ACTION = RL_FIRST_BUT_CAPTION) then + I_START := 1; + elsif (Z_ACTION = RL_NEXT_BUT_ACTION) or (Z_ACTION = RL_NEXT_BUT_CAPTION) then + I_START := I_START + RL_RECORD_SET_SIZE; + elsif (Z_ACTION = RL_PREV_BUT_ACTION) or (Z_ACTION = RL_PREV_BUT_CAPTION) then + I_START := I_START - RL_RECORD_SET_SIZE; + elsif (Z_ACTION = RL_LAST_BUT_ACTION) or (Z_ACTION = RL_LAST_BUT_CAPTION) then + I_START := 1 + (floor((I_COUNT-1)/RL_RECORD_SET_SIZE)*RL_RECORD_SET_SIZE); + elsif Z_ACTION is null and I_START = 1 then + null; + elsif Z_ACTION IS NULL then + WSGL.DisplayMessage(WSGL.MESS_ERROR, WSGL.MsgGetText(215,WSGLM.MSG215_NO_MULTIPLE_SUBMITS), + '#View Commercial Confirmations#2480#'||' : '||'', RL_BODY_ATTRIBUTES); + WSGL.ClosePageBody; + return; + end if; + + if I_START < 1 then + I_START := 1; + end if; + + I_PREV_BUT := TRUE; + I_NEXT_BUT := FALSE; + if I_START = 1 or Z_ACTION IS NULL then + I_PREV_BUT := FALSE; + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + + if ZONE_SQL IS NULL then + if not BuildSQL( + P_L_CONT2_CONTRACT_NUMBER, + P_L_NOMI_IDENTIFIER, + P_CONFIRMATION_SENT, + U_CONFIRMATION_SENT, + P_GAS_DAY, + U_GAS_DAY) then + WSGL.ClosePageBody; + return; + end if; + end if; + + if not PreQuery( + P_L_CONT2_CONTRACT_NUMBER, + P_L_NOMI_IDENTIFIER, + P_CONFIRMATION_SENT, + U_CONFIRMATION_SENT, + P_GAS_DAY, + U_GAS_DAY) then + WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, + '#View Commercial Confirmations#2480#'||' : '||'', RL_BODY_ATTRIBUTES); + return; + end if; + + + + OpenZoneSql( I_CURSOR ); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + else + I_ROWS_FETCHED := 0; + end if; + I_TOTAL_ROWS := I_ROWS_FETCHED; + + if I_ROWS_FETCHED != 0 then + WSGL.LayoutOpen(WSGL.LAYOUT_TABLE, P_BORDER=>TRUE); + + WSGL.LayoutRowStart(p_attrs=>'class = cgrlheaderrow'); + for i in 1..RL_NUMBER_OF_COLUMNS loop + WSGL.LayoutHeader(40, 'LEFT', '#Customer Name#1145#','NAME'); + WSGL.LayoutHeader(30, 'LEFT', '#Contract Number#2013#','CONTRACT_NUMBER'); + WSGL.LayoutHeader(30, 'LEFT', '#Nomination Identifier#2060#','IDENTIFIER'); + WSGL.LayoutHeader(30, 'LEFT', '#Gas Day#1142#',''); + WSGL.LayoutHeader(30, 'LEFT', '#Confirmation Sent#2482#',''); + WSGL.LayoutHeader(30, 'LEFT', '#View#2062#',''); + end loop; + WSGL.LayoutRowEnd; + + while I_ROWS_FETCHED <> 0 loop + + if I_TOTAL_ROWS >= I_START then + AssignZoneRow(I_CURSOR); + + if (NBT_VAL.L_CUST2_NAME != I_LAST_NBT.L_CUST2_NAME or (NBT_VAL.L_CUST2_NAME is null and I_LAST_NBT.L_CUST2_NAME is not null) or (NBT_VAL.L_CUST2_NAME is not null and I_LAST_NBT.L_CUST2_NAME is null) ) or + (NBT_VAL.L_CONT2_CONTRACT_NUMBER != I_LAST_NBT.L_CONT2_CONTRACT_NUMBER or (NBT_VAL.L_CONT2_CONTRACT_NUMBER is null and I_LAST_NBT.L_CONT2_CONTRACT_NUMBER is not null) or (NBT_VAL.L_CONT2_CONTRACT_NUMBER is not null and I_LAST_NBT.L_CONT2_CONTRACT_NUMBER is null) ) or + (NBT_VAL.L_NOMI_IDENTIFIER != I_LAST_NBT.L_NOMI_IDENTIFIER or (NBT_VAL.L_NOMI_IDENTIFIER is null and I_LAST_NBT.L_NOMI_IDENTIFIER is not null) or (NBT_VAL.L_NOMI_IDENTIFIER is not null and I_LAST_NBT.L_NOMI_IDENTIFIER is null) ) or + (NBT_VAL.UI_GAS_DAY != I_LAST_NBT.UI_GAS_DAY or (NBT_VAL.UI_GAS_DAY is null and I_LAST_NBT.UI_GAS_DAY is not null) or (NBT_VAL.UI_GAS_DAY is not null and I_LAST_NBT.UI_GAS_DAY is null) ) or + (CURR_VAL.CONFIRMATION_SENT != I_LAST_BASE.CONFIRMATION_SENT or (CURR_VAL.CONFIRMATION_SENT is null and I_LAST_BASE.CONFIRMATION_SENT is not null) or (CURR_VAL.CONFIRMATION_SENT is not null and I_LAST_BASE.CONFIRMATION_SENT is null) ) or + (NBT_VAL.UI_CONF_SENT != I_LAST_NBT.UI_CONF_SENT or (NBT_VAL.UI_CONF_SENT is null and I_LAST_NBT.UI_CONF_SENT is not null) or (NBT_VAL.UI_CONF_SENT is not null and I_LAST_NBT.UI_CONF_SENT is null) ) or + (NBT_VAL.UI_URL != I_LAST_NBT.UI_URL or (NBT_VAL.UI_URL is null and I_LAST_NBT.UI_URL is not null) or (NBT_VAL.UI_URL is not null and I_LAST_NBT.UI_URL is null) ) or + (CURR_VAL.CONF_ID != I_LAST_BASE.CONF_ID or (CURR_VAL.CONF_ID is null and I_LAST_BASE.CONF_ID is not null) or (CURR_VAL.CONF_ID is not null and I_LAST_BASE.CONF_ID is null) ) or + (CURR_VAL.NOMI_ID != I_LAST_BASE.NOMI_ID or (CURR_VAL.NOMI_ID is null and I_LAST_BASE.NOMI_ID is not null) or (CURR_VAL.NOMI_ID is not null and I_LAST_BASE.NOMI_ID is null) ) or + (NBT_VAL.UI_GAS_DAY_DATE != I_LAST_NBT.UI_GAS_DAY_DATE or (NBT_VAL.UI_GAS_DAY_DATE is null and I_LAST_NBT.UI_GAS_DAY_DATE is not null) or (NBT_VAL.UI_GAS_DAY_DATE is not null and I_LAST_NBT.UI_GAS_DAY_DATE is null) ) or + (CURR_VAL.GAS_DAY != I_LAST_BASE.GAS_DAY or (CURR_VAL.GAS_DAY is null and I_LAST_BASE.GAS_DAY is not null) or (CURR_VAL.GAS_DAY is not null and I_LAST_BASE.GAS_DAY is null) ) or + (CURR_VAL.CONT_ID != I_LAST_BASE.CONT_ID or (CURR_VAL.CONT_ID is null and I_LAST_BASE.CONT_ID is not null) or (CURR_VAL.CONT_ID is not null and I_LAST_BASE.CONT_ID is null) ) then + RSCONF := true; + else + RSCONF := false; + end if; + + + I_LAST_NBT.L_CUST2_NAME := NBT_VAL.L_CUST2_NAME; + I_LAST_NBT.L_CONT2_CONTRACT_NUMBER := NBT_VAL.L_CONT2_CONTRACT_NUMBER; + I_LAST_NBT.L_NOMI_IDENTIFIER := NBT_VAL.L_NOMI_IDENTIFIER; + I_LAST_NBT.UI_GAS_DAY := NBT_VAL.UI_GAS_DAY; + I_LAST_BASE.CONFIRMATION_SENT := CURR_VAL.CONFIRMATION_SENT; + I_LAST_NBT.UI_CONF_SENT := NBT_VAL.UI_CONF_SENT; + I_LAST_NBT.UI_URL := NBT_VAL.UI_URL; + I_LAST_BASE.CONF_ID := CURR_VAL.CONF_ID; + I_LAST_BASE.NOMI_ID := CURR_VAL.NOMI_ID; + I_LAST_NBT.UI_GAS_DAY_DATE := NBT_VAL.UI_GAS_DAY_DATE; + I_LAST_BASE.GAS_DAY := CURR_VAL.GAS_DAY; + I_LAST_BASE.CONT_ID := CURR_VAL.CONT_ID; + l_row := l_row + 1; + + + WSGL.LayoutRowStart('TOP', p_attrs=>'class = cgrldatarow'); + l_id := 'NAME' || l_row; + if RSCONF and NBT_VAL.L_CUST2_NAME is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.L_CUST2_NAME), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := 'CONTRACT_NUMBER' || l_row; + if RSCONF and NBT_VAL.L_CONT2_CONTRACT_NUMBER is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.L_CONT2_CONTRACT_NUMBER), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := 'IDENTIFIER' || l_row; + if RSCONF and NBT_VAL.L_NOMI_IDENTIFIER is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.L_NOMI_IDENTIFIER), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSCONF and NBT_VAL.UI_GAS_DAY is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_GAS_DAY), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSCONF and NBT_VAL.UI_CONF_SENT is not null then + WSGL.LayoutData(p_text=>replace(WSGL.EscapeItem(NBT_VAL.UI_CONF_SENT), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + l_id := '' || l_row; + if RSCONF and NBT_VAL.UI_URL is not null then + WSGL.LayoutData(p_text=>replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_URL), '#View#2062#'), ' +', '
+'), p_id=>l_id); + else + WSGL.LayoutData(p_text=>' ', p_id=>l_id); + end if; + + WSGL.LayoutRowEnd; + + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + if I_TOTAL_ROWS = I_START + RL_RECORD_SET_SIZE - 1 then + if I_ROWS_FETCHED <> 0 then + I_NEXT_BUT := TRUE; + end if; + exit; + end if; + else + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + end if; + + I_TOTAL_ROWS := I_TOTAL_ROWS + I_ROWS_FETCHED; + + end loop; + + WSGL.LayoutClose; + + if I_START = I_TOTAL_ROWS then + htp.p(WSGL.MsgGetText(109,WSGLM.DSP109_RECORD, to_char(I_TOTAL_ROWS))||I_OF_TOTAL_TEXT); + else + htp.p(WSGL.MsgGetText(110,WSGLM.DSP110_RECORDS_N_M, + to_char(I_START), to_char(I_TOTAL_ROWS))|| + I_OF_TOTAL_TEXT); + end if; + htp.para; + else + htp.p(WSGL.MsgGetText(112,WSGLM.DSP112_NO_RECORDS)); + end if; + + if nvl(Z_ACTION, 'X') != 'DONTQUERY' then + dbms_sql.close_cursor(I_CURSOR); + end if; + + WSGL.ResetForMultipleForms ; + htp.formOpen(curl => 'efnow120$conf.querylist', cattributes => 'NAME="efnow120$conf$LForm"'); + SaveState; + WSGL.HiddenField('P_L_CONT2_CONTRACT_NUMBER', P_L_CONT2_CONTRACT_NUMBER); + WSGL.HiddenField('P_L_NOMI_IDENTIFIER', P_L_NOMI_IDENTIFIER); + WSGL.HiddenField('P_CONFIRMATION_SENT', P_CONFIRMATION_SENT); + WSGL.HiddenField('U_CONFIRMATION_SENT', U_CONFIRMATION_SENT); + WSGL.HiddenField('P_GAS_DAY', P_GAS_DAY); + WSGL.HiddenField('U_GAS_DAY', U_GAS_DAY); + WSGL.HiddenField('Z_START', to_char(I_START)); + htp.p (''); + + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_FIRST_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_FIRST_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_PREV_BUT, 'Z_ACTION', htf.escape_sc(RL_PREV_BUT_CAPTION), WSGL.MsgGetText(213,WSGLM.MSG213_AT_FIRST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_PREV_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_NEXT_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_NEXT_BUT_ACTION || '\''"'); + WSGL.RecordListButton(I_NEXT_BUT,'Z_ACTION', htf.escape_sc(RL_LAST_BUT_CAPTION), WSGL.MsgGetText(214,WSGLM.MSG214_AT_LAST), FALSE, + 'onClick="this.form.Z_ACTION.value=\''' || RL_LAST_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_REQUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_REQUERY_BUT_ACTION || '\''"'); + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_COUNT_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_COUNT_BUT_ACTION || '\''"'); + htp.para; + + WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(RL_QUERY_BUT_CAPTION),p_dojs=>FALSE, + buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_QUERY_BUT_ACTION || '\''"'); + WSGL.HiddenField('Z_CHK', + to_char(WSGL.Checksum(''))); + htp.formClose; + + WSGL.ReturnLinks('0.1', WSGL.MENU_LONG, p_target=>'_top'); + WSGL.NavLinks; + WSGMC_OUTPUT2.After(REF_COMPONENT,2); + + htp.p(caco_system.footer); + + WSGL.ClosePageBody; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + RL_BODY_ATTRIBUTES, 'efnow120$conf.QueryList'); + WSGL.ClosePageBody; + end; +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.RestoreState +-- +-- Description: Restore the data state and optional meta data for the +-- 'CONF' module component. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean ) return boolean + is + I_REMAINING_DEPTH integer; + I_CURSOR integer; + I_VOID integer; + I_ROWS_FETCHED integer; + I_FETCH_ERROR boolean := FALSE; + I_SUCCESS boolean := TRUE; + begin + if Z_RESTORE_OWN_ROW then + if ( CURR_VAL.CONF_ID is null + ) then + return FALSE; + end if; + end if; + + if ( Z_RESTORE_OWN_ROW ) then + + -- Use the CURR_VAL fields for UID to get the other values + + if not BuildSQL( Z_QUERY_BY_KEY => true ) then + return FALSE; + end if; + + OpenZoneSql(I_CURSOR); + I_VOID := dbms_sql.execute(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED = 0 then + I_FETCH_ERROR := TRUE; + else + + AssignZoneRow(I_CURSOR); + I_ROWS_FETCHED := dbms_sql.fetch_rows(I_CURSOR); + + if I_ROWS_FETCHED != 0 then + I_FETCH_ERROR := TRUE; + end if; + + end if; + + dbms_sql.close_cursor(I_CURSOR); + if I_FETCH_ERROR then + return FALSE; + end if; + + end if; + return TRUE; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + '', 'efnow120$conf.RestoreState'); + raise; + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.SaveState +-- +-- Description: Saves the data state for the 'CONF' module component. +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure SaveState + is + begin + + + null; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + '', 'efnow120$conf.SaveState'); + raise; + end; + + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.GetRef +-- +-- Description: Returns a handle to the component object +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + function GetRef return WSGOC.COMPONENT_REF + is + begin + return ref_Component; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.LoadCache +-- +-- Description: Populate the object cache with +-- 'CONF' module component. +-- +-------------------------------------------------------------------------------- + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF + , Z_BRANCH in WSGOC.BRANCH_REF + ) + is + I_VF_FRAME varchar2(20) := null; + begin + + -- Is cache already loaded + if not WSGOC.Is_Null(ref_Component) then + return; + end if; + + + ref_Component := WSGOC.Component + ( pModule => efnow120$.GetRef + , pBranch => Z_BRANCH + , pContext_For=> Z_CONTEXT_FOR + , pName => 'CONF' + , pSystemImagePath=> '/images/' + ); + + r_L_CUST2_NAME := WSGOC.Item + ( pName => 'L_CUST2_NAME' + , pPrompt => '#Customer Name#1145#' + , pIsContext=> true + ); + r_L_CONT2_CONTRACT_NUMBER := WSGOC.Item + ( pName => 'L_CONT2_CONTRACT_NUMBER' + , pPrompt => '#Contract Number#2013#' + , pIsContext=> true + ); + r_L_NOMI_IDENTIFIER := WSGOC.Item + ( pName => 'L_NOMI_IDENTIFIER' + , pPrompt => '#Nomination Identifier#2060#' + , pIsContext=> true + ); + r_UI_GAS_DAY := WSGOC.Item + ( pName => 'UI_GAS_DAY' + , pPrompt => '#Gas Day#1142#' + , pIsContext=> true + ); + r_CONFIRMATION_SENT := WSGOC.Item + ( pName => 'CONFIRMATION_SENT' + , pPrompt => '#Confirmation Sent#2482#' + ); + r_UI_CONF_SENT := WSGOC.Item + ( pName => 'UI_CONF_SENT' + , pPrompt => '#Confirmation Sent#2482#' + , pIsContext=> true + ); + r_UI_URL := WSGOC.Item + ( pName => 'UI_URL' + , pPrompt => '#View#2062#' + , pIsContext=> true + ); + r_CONF_ID := WSGOC.Item + ( pName => 'CONF_ID' + , pPrompt => '#Conf Id#2483#' + ); + r_NOMI_ID := WSGOC.Item + ( pName => 'NOMI_ID' + , pPrompt => '#Nomi Id#2481#' + ); + r_UI_GAS_DAY_DATE := WSGOC.Item + ( pName => 'UI_GAS_DAY_DATE' + , pPrompt => '' + ); + r_GAS_DAY := WSGOC.Item + ( pName => 'GAS_DAY' + , pPrompt => '#Gas Day#1142#' + ); + r_CONT_ID := WSGOC.Item + ( pName => 'CONT_ID' + , pPrompt => 'Cont Id' + ); + + WSGOC.Add_Items(ref_Component, r_L_CUST2_NAME); + WSGOC.Add_Items(ref_Component, r_L_CONT2_CONTRACT_NUMBER); + WSGOC.Add_Items(ref_Component, r_L_NOMI_IDENTIFIER); + WSGOC.Add_Items(ref_Component, r_UI_GAS_DAY); + WSGOC.Add_Items(ref_Component, r_CONFIRMATION_SENT); + WSGOC.Add_Items(ref_Component, r_UI_CONF_SENT); + WSGOC.Add_Items(ref_Component, r_UI_URL); + WSGOC.Add_Items(ref_Component, r_CONF_ID); + WSGOC.Add_Items(ref_Component, r_NOMI_ID); + WSGOC.Add_Items(ref_Component, r_UI_GAS_DAY_DATE); + WSGOC.Add_Items(ref_Component, r_GAS_DAY); + WSGOC.Add_Items(ref_Component, r_CONT_ID); + + + if ( Z_OWN_ROW_VALUES ) then + + -- Set the display value for each item + -- ( As would be displayed on the Record List ) + WSGOC.Set_Value( r_L_CUST2_NAME, replace(WSGL.EscapeItem(NBT_VAL.L_CUST2_NAME), ' +', '
+') ); + WSGOC.Set_Value( r_L_CONT2_CONTRACT_NUMBER, replace(WSGL.EscapeItem(NBT_VAL.L_CONT2_CONTRACT_NUMBER), ' +', '
+') ); + WSGOC.Set_Value( r_L_NOMI_IDENTIFIER, replace(WSGL.EscapeItem(NBT_VAL.L_NOMI_IDENTIFIER), ' +', '
+') ); + WSGOC.Set_Value( r_UI_GAS_DAY, replace(WSGL.EscapeItem(NBT_VAL.UI_GAS_DAY), ' +', '
+') ); + WSGOC.Set_Value( r_CONFIRMATION_SENT, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.CONFIRMATION_SENT, 'DD/MM/YYYY HH24:MI:SS'))) ); + WSGOC.Set_Value( r_UI_CONF_SENT, replace(WSGL.EscapeItem(NBT_VAL.UI_CONF_SENT), ' +', '
+') ); + WSGOC.Set_Value( r_UI_URL, replace(wsgl.anchor2(WSGL.EscapeItem(NBT_VAL.UI_URL), '#View#2062#'), ' +', '
+') ); + WSGOC.Set_Value( r_CONF_ID, WSGL.EscapeItem(CURR_VAL.CONF_ID) ); + WSGOC.Set_Value( r_NOMI_ID, WSGL.EscapeItem(CURR_VAL.NOMI_ID) ); + WSGOC.Set_Value( r_UI_GAS_DAY_DATE, WSGL.EscapeItem(ltrim(to_char(NBT_VAL.UI_GAS_DAY_DATE, 'DD-MON-RRRR'))) ); + WSGOC.Set_Value( r_GAS_DAY, WSGL.EscapeItem(ltrim(to_char(CURR_VAL.GAS_DAY, 'DD/MM/YYYY'))) ); + WSGOC.Set_Value( r_CONT_ID, WSGL.EscapeItem(CURR_VAL.CONT_ID) ); + + end if; + + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + '', 'efnow120$conf.LoadCache'); + raise; + end; + + + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.PreQuery +-- +-- Description: Provides place holder for code to be run prior to a query +-- for the 'CONF' module component . +-- +-- Parameters: None +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PreQuery( + P_L_CONT2_CONTRACT_NUMBER in varchar2, + P_L_NOMI_IDENTIFIER in varchar2, + P_CONFIRMATION_SENT in varchar2, + U_CONFIRMATION_SENT in varchar2, + P_GAS_DAY in varchar2, + U_GAS_DAY in varchar2) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.PreQuery'); + return FALSE; + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$conf.PostQuery +-- +-- Description: Provides place holder for code to be run after a query +-- for the 'CONF' module component . +-- +-- Parameters: Z_POST_DML Flag indicating if Query after insert or update +-- Z_UPDATE_ROW Can be set to mark that row as modified when a +-- multirow form is displayed, causing it to be +-- updated when the form is submitted. +-- +-- Returns: True If success +-- False Otherwise +-- +-------------------------------------------------------------------------------- + function PostQuery(Z_POST_DML in boolean, Z_UPDATE_ROW in out boolean) return boolean is + L_RET_VAL boolean := TRUE; + begin + return L_RET_VAL; + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + DEF_BODY_ATTRIBUTES, 'efnow120$conf.PostQuery'); + return FALSE; + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$conf.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$conf.spc new file mode 100644 index 0000000..ca5a7eb --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$conf.spc @@ -0,0 +1,94 @@ +create or replace package efnow120$conf is + + type NBT_REC is record + ( L_CUST2_NAME CUSTOMERS.NAME%type + , L_CONT2_CONTRACT_NUMBER CONTRACTS.CONTRACT_NUMBER%type + , L_NOMI_IDENTIFIER NOMINATIONS.IDENTIFIER%type + , UI_GAS_DAY varchar2(24000) + , UI_CONF_SENT varchar2(24000) + , UI_URL varchar2(24000) + , UI_GAS_DAY_DATE date + ); + + NBT_VAL NBT_REC; + CURR_VAL CONFIRMATIONS%rowtype; + + + procedure Startup( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null, + Z_FORM in varchar2 default null); + procedure ActionQuery( + P_L_CONT2_CONTRACT_NUMBER in varchar2 default null, + P_L_NOMI_IDENTIFIER in varchar2 default null, + P_CONFIRMATION_SENT in varchar2 default null, + U_CONFIRMATION_SENT in varchar2 default null, + P_GAS_DAY in varchar2 default null, + U_GAS_DAY in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_ACTION in varchar2 default null, + Z_CHK in varchar2 default null ); + + procedure FormQuery( + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null); + + procedure QueryList( + P_L_CONT2_CONTRACT_NUMBER in varchar2 default null, + P_L_NOMI_IDENTIFIER in varchar2 default null, + P_CONFIRMATION_SENT in varchar2 default null, + U_CONFIRMATION_SENT in varchar2 default null, + P_GAS_DAY in varchar2 default null, + U_GAS_DAY in varchar2 default null, + Z_START in varchar2 default null, + Z_ACTION in varchar2 default null, + Z_DIRECT_CALL in boolean default false, + Z_CHK in varchar2 default null ); + function QueryHits( + P_L_CONT2_CONTRACT_NUMBER in varchar2 default null, + P_L_NOMI_IDENTIFIER in varchar2 default null, + P_CONFIRMATION_SENT in varchar2 default null, + U_CONFIRMATION_SENT in varchar2 default null, + P_GAS_DAY in varchar2 default null, + U_GAS_DAY in varchar2 default null) return number; + procedure LoadCache + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_OWN_ROW_VALUES in boolean default false + , Z_CONTEXT_FOR in WSGOC.COMPONENT_REF default null + , Z_BRANCH in WSGOC.BRANCH_REF default null + ); + function RestoreState + ( Z_CURR_DEPTH in number + , Z_MAX_DEPTH in number + , Z_RESTORE_OWN_ROW in boolean default true + ) return boolean; + procedure SaveState; + function GetRef return WSGOC.COMPONENT_REF; + + + + 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 + ); + + procedure format_cal_date + ( + Z_FIELD_NAME in Varchar2, + Z_FIELD_FORMAT in varchar2, + day in varchar2, + month in varchar2, + year in varchar2 + ); +FUNCTION FormatDate ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + +FUNCTION FormatDateTime ( p_date IN VARCHAR2 ) RETURN VARCHAR2; + + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$js$conf.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$js$conf.bdy new file mode 100644 index 0000000..6379ab0 --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$js$conf.bdy @@ -0,0 +1,122 @@ +create or replace package body efnow120$js$conf is + + +-------------------------------------------------------------------------------- +-- Name: efnow120$js$conf.CreateQueryJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateQueryJavaScript ( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow120$conf') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "Query";'); + + + + WSGJSL.Output_Invoke_CAL_JS ('efnow120$conf', 'scrollbars=no,resizable=no,width=320,height=350'); + + + htp.p(WSGJSL.OpenEvent('L_CONT2_CONTRACT_NUMBER','LOV')); htp.p(' + var depStr = ""; + var modeStr = "" + index = -1; + modeStr = "Q"; +'); + + if LOV_FRAME is not null then + htp.p(' var lovFra = "'||LOV_FRAME||'";'); + htp.p(' var winpar = "";'); + else + htp.p(' var lovFra = "winLOV";'); + htp.p(' var winpar = "scrollbars=yes,resizable=yes,width=400,height=400";'); + end if; + htp.p(' var filterprompt = "";'); + htp.p(' + + var lovTitle = "'||replace('','"','\"')||'"; + window.current_lov_title = lovTitle; + + JSLOpenLOV( ctl, index, modeStr, "efnow120$conf.cust_cont_lov", depStr, lovFra, winpar, filterprompt ); + +'); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('CONF','OnLoad')); + htp.p(' + if ( FormType != "PostDelete") + { + form_num=0; + do + { + elem_num=0; + len = document.forms[form_num].elements.length; + if (len > 0) + { + while (elem_num < len && + document.forms[form_num].elements[elem_num].type != "text" && + document.forms[form_num].elements[elem_num].type != "textarea") + { + elem_num++; + } + if (elem_num < len) + { + document.forms[form_num].elements[elem_num].focus(); + break; + } + } + form_num++; + } while ( form_num < document.forms.length ); + } +'); + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.OpenEvent('btnQFQ','OnClick')); + htp.p(WSGJSL.StandardSubmit(false)); + + htp.p(WSGJSL.CloseEvent); + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + QF_BODY_ATTRIBUTES, 'efnow120$js$conf.CreateQueryJavaScript'); + end; + +-------------------------------------------------------------------------------- +-- Name: efnow120$js$conf.CreateListJavaScript +-- +-- Description: +-- +-- Parameters: +-- +-------------------------------------------------------------------------------- + procedure CreateListJavaScript ( + RL_BODY_ATTRIBUTES in varchar2) + is + begin + if not caco_security.security_check('efnow120$conf') then + return; + end if; + + htp.p(WSGJSL.OpenScript); + htp.p('var FormType = "List";'); + + + htp.p( 'var P_7 = new Array();' ); + + htp.p(WSGJSL.CloseScript); + exception + when others then + WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, '#View Commercial Confirmations#2480#'||' : '||'', + RL_BODY_ATTRIBUTES, 'efnow120$js$conf.CreateListJavaScript'); + end; +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$js$conf.spc b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$js$conf.spc new file mode 100644 index 0000000..079970b --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow120$js$conf.spc @@ -0,0 +1,11 @@ +create or replace package efnow120$js$conf is + + procedure CreateQueryJavaScript( + LOV_FRAME in varchar2, + QF_BODY_ATTRIBUTES in varchar2); + + procedure CreateListJavaScript( + RL_BODY_ATTRIBUTES in varchar2); + +end; +/ diff --git a/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow131$.bdy b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow131$.bdy new file mode 100644 index 0000000..9ee9fff --- /dev/null +++ b/Data/BulkLoad/EFT/Nominations/Changes/Aug_2010/efnow131$.bdy @@ -0,0 +1,976 @@ +CREATE OR REPLACE PACKAGE BODY efnow131$ IS + -- + -- Text constants + -- + c_heading CONSTANT NUMBER := 1141; + c_gas_day CONSTANT NUMBER := 1142; + c_window_open CONSTANT NUMBER := 1143; + c_window_close CONSTANT NUMBER := 1144; + c_customer_name CONSTANT NUMBER := 1145; + c_contract_name CONSTANT NUMBER := 2082; + c_include_exclude CONSTANT NUMBER := 1146; + c_submit CONSTANT NUMBER := 1147; + c_selectall CONSTANT NUMBER := 1148; + c_message CONSTANT NUMBER := 1150; + c_customers CONSTANT NUMBER := 1045; + c_contracts CONSTANT NUMBER := 2401; + c_timestamp CONSTANT NUMBER := 1152; + c_subject CONSTANT NUMBER := 2148; + -- + -- Other Constants + -- + c_gas_day_start CONSTANT NUMBER := cout_system_configuration.get_configuration_item(p_parameter => 'GAS_DAY_OFFSET'); + c_timecomp_format CONSTANT VARCHAR2(2) := '00'; + c_yes CONSTANT VARCHAR2(1) := 'Y'; + c_date_format CONSTANT VARCHAR2(255) := g_date_format; + c_datetime_format CONSTANT VARCHAR2(255) := c_date_format || + ' HH24:MI:SS'; + c_nom_wdw_format CONSTANT VARCHAR2(255) := c_date_format || ' HH24:MI'; + c_renom_window CONSTANT VARCHAR2(1) := 'R'; + c_time_format CONSTANT VARCHAR2(255) := 'HH24:MI'; + -- + -- Global variables + -- + g_gas_day_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_gas_day); + g_subject_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_subject); + g_message_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_message); + g_customers VARCHAR2(255) := caco_utilities.get_module_text(c_customers); + g_contracts VARCHAR2(255) := caco_utilities.get_module_text(c_contracts); + g_wdw_open_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_window_open); + g_wdw_close_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_window_close); + g_timestamp_lbl VARCHAR2(255) := caco_utilities.get_module_text(c_timestamp); + -- + -- standard web calendar package + -- + PROCEDURE calendar(z_field_name IN VARCHAR2 + ,z_caller_url IN VARCHAR2 + ,z_field_value IN VARCHAR2 DEFAULT NULL + ,z_field_format IN VARCHAR2 DEFAULT NULL + ,z_field_prompt IN VARCHAR2 DEFAULT NULL) IS + -- + field_caption VARCHAR2(2000); + -- + BEGIN + -- + IF z_field_prompt IS NULL THEN + -- + field_caption := INITCAP(REPLACE(SUBSTR(z_field_name + ,3 + ,LENGTH(z_field_name) - 2) + ,'_' + ,' ')); + -- + ELSE + -- + field_caption := INITCAP(REPLACE(z_field_prompt + ,'_' + ,' ')); + -- + END IF; + -- + wsgl.registerurl(g_package_name || '.calendar'); + wsgl.addurlparam('Z_FIELD_NAME' + ,z_field_name); + wsgl.addurlparam('Z_CALLER_URL' + ,z_caller_url); + -- + IF wsgl.notlowercase THEN + RETURN; + END IF; + -- + wsgl.output_calendar(z_field_name + ,z_field_value + ,z_field_format + ,wsgl.msggettext(123 + ,wsglm.dsp128_cal_caption + ,field_caption) + ,NULL + ,g_package_name + ,'Close' + ,TRUE + ,g_date_format); + -- + wsgl.output_calendar(z_field_name + ,z_field_value + ,z_field_format + ,wsgl.msggettext(123 + ,wsglm.dsp128_cal_caption + ,field_caption) + ,NULL + ,g_package_name + ,'Close' + ,FALSE + ,g_date_format); + -- + EXCEPTION + WHEN OTHERS THEN + wsgl.displaymessage(wsgl.mess_exception + ,SQLERRM + ,'' + ,NULL + ,g_package_name || '.calendar'); + END calendar; + -- + -- Standard web formatting package for submitted dates + -- + PROCEDURE format_cal_date(z_field_name IN VARCHAR2 + ,z_field_format IN VARCHAR2 + ,DAY IN VARCHAR2 + ,MONTH IN VARCHAR2 + ,YEAR IN VARCHAR2) IS + -- + field_caption VARCHAR2(2000) := INITCAP(REPLACE(SUBSTR(z_field_name + ,3 + ,LENGTH(z_field_name) - 2) + ,'_' + ,' ')); + l_day VARCHAR2(15) := DAY; + -- + PROCEDURE output_format_cal_js(page_header IN VARCHAR2 + ,body_attributes IN VARCHAR2 + ,chosen_date IN VARCHAR2 + ,field_format IN VARCHAR2) IS + -- + -- Copied from WSGL + -- + the_date DATE := TO_DATE(chosen_date + ,'DD-MONTH-YYYY'); + -- + BEGIN + -- + wsgl.openpagehead(page_header); + wsgl.closepagehead; + wsgl.openpagebody(FALSE + ,p_attributes => body_attributes); + htp.p(''); + wsgl.closepagebody; + -- + END output_format_cal_js; + -- + BEGIN + -- + IF l_day = '0' THEN + l_day := '01'; + END IF; + -- + output_format_cal_js(wsgl.msggettext(123 + ,wsglm.dsp128_cal_caption + ,field_caption) + ,NULL + ,l_day || '-' || MONTH || '-' || YEAR + ,z_field_format); + -- + END format_cal_date; + -- + -- Produce the hour poplist + -- + PROCEDURE hour_option_list IS + -- + l_hour NUMBER; + -- + BEGIN + -- + -- + -- Start at the gas day begining.... + -- + l_hour := c_gas_day_start; + -- + FOR i IN 1 .. 24 LOOP + -- + -- Reset the counter to do hours from midnight to 5 + -- + IF l_hour > 23 THEN + -- + l_hour := 0; + -- + END IF; + -- + IF TO_NUMBER(TO_CHAR(l_hour + ,c_timecomp_format)) = + TO_NUMBER(TO_CHAR((SYSDATE + 1 / 24) + ,'HH24')) THEN + -- + htp.p('