create or replace package body efnow230$remd is procedure FormView(Z_FORM_STATUS in number, Q_REMD_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'); function BuildSQL( P_REMD_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 PreQuery( P_REMD_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) := ''; 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) := ''; 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_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) := 1; VF_RECORD_SET_SIZE constant number(5) := 1; 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) := ''; type FORM_REC is record (UI_URL varchar2(32760) ,MESSAGE_BODY varchar2(32760) ,REMD_ID varchar2(40) ,MESSAGE_TYPE varchar2(6) ); 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 ( MESSAGE_BODY varchar2(32760) ); 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_URL varchar2(32760) , F_MESSAGE_BODY varchar2(32760) , F_REMD_ID varchar2(40) , F_MESSAGE_TYPE varchar2(6) , 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_URL WSGOC.ITEM_REF; R_MESSAGE_BODY WSGOC.ITEM_REF; R_REMD_ID WSGOC.ITEM_REF; R_MESSAGE_TYPE WSGOC.ITEM_REF; -------------------------------------------------------------------------------- -- Name: efnow230$remd.PreQuery -- -- Description: Provides place holder for code to be run prior to a query -- for the 'REMD' module component . -- -- Parameters: None -- -- Returns: True If success -- False Otherwise -- -------------------------------------------------------------------------------- function PreQuery( P_REMD_ID in varchar2) return boolean is L_RET_VAL boolean := TRUE; begin -- PopURL -- -- BEGIN -- nbt_val.ui_url := 'a'; form_val.ui_url :='asdfasd'; -- END; return L_RET_VAL; exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.PreQuery'); return FALSE; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.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('efnow230$remd') then return; end if; if P_ALIAS = 'MESSAGE_TYPE' and not D_MESSAGE_TYPE.Initialised then D_MESSAGE_TYPE.ColAlias := 'MESSAGE_TYPE'; D_MESSAGE_TYPE.ControlType := WSGL.DV_TEXT; D_MESSAGE_TYPE.DispWidth := 1; D_MESSAGE_TYPE.DispHeight := 1; D_MESSAGE_TYPE.MaxWidth := 1; D_MESSAGE_TYPE.UseMeanings := False; D_MESSAGE_TYPE.ColOptional := True; D_MESSAGE_TYPE.Vals(1) := 'e'; D_MESSAGE_TYPE.Meanings(1) := 'e'; D_MESSAGE_TYPE.Abbreviations(1) := 'email'; D_MESSAGE_TYPE.Vals(2) := 's'; D_MESSAGE_TYPE.Meanings(2) := 's'; D_MESSAGE_TYPE.Abbreviations(2) := 'sms'; D_MESSAGE_TYPE.NumOfVV := 2; D_MESSAGE_TYPE.Initialised := True; end if; exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.InitialseDomain'); end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.Startup -- -- Description: Entry point for the 'REMD' 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('efnow230$remd') then return; end if; WSGL.RegisterURL('efnow230$remd.startup'); WSGL.AddURLParam('Z_CHK', Z_CHK); WSGL.StoreURLLink(2, 'REMD'); -- 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; end if; if l_Foundform = FALSE then ActionQuery( Z_DIRECT_CALL=>TRUE); end if; exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.Startup'); end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.ActionQuery -- -- Description: Called when a Query form is subitted to action the query request. -- -- Parameters: -- -------------------------------------------------------------------------------- procedure ActionQuery( P_REMD_ID 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('efnow230$remd') 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 ); QueryView( P_REMD_ID=>P_REMD_ID, Z_EXECUTE_QUERY=>'Y', Z_DIRECT_CALL=>TRUE ); exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.ActionQuery'); end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.QueryHits -- -- Description: Returns the number or rows which matches the given search -- criteria (if any). -- -- Parameters: -- -------------------------------------------------------------------------------- function QueryHits( P_REMD_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('efnow230$remd') then return -1; end if; if not BuildSQL(P_REMD_ID) then return -1; end if; if not PreQuery(P_REMD_ID) then WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, ''||' : '||'', 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, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.QueryHits'); return -1; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.BuildSQL -- -- Description: Builds the SQL for the 'REMD' module component. -- This incorporates all query criteria and Foreign key columns. -- -- Parameters: -- -------------------------------------------------------------------------------- function BuildSQL( P_REMD_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 REMD_ID = ' || to_char(CURR_VAL.REMD_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_REMD_ID, 'REMD_ID', WSGL.TYPE_NUMBER, I_WHERE); exception when others then WSGL.DisplayMessage(WSGL.MESS_ERROR_QRY, SQLERRM, ''||' : '||'', DEF_BODY_ATTRIBUTES, NULL, WSGL.MsgGetText(210,WSGLM.MSG210_INVALID_QRY,'Remd Id')); return false; end; end if; ZONE_SQL := 'SELECT MESSAGE_BODY, REMD_ID, MESSAGE_TYPE FROM ( SELECT REMD.MESSAGE_BODY MESSAGE_BODY, REMD.REMD_ID REMD_ID, REMD.MESSAGE_TYPE MESSAGE_TYPE FROM REC_MESSAGE_DETAILS REMD ) '; 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, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.BuildSQL'); return false; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.OpenZoneSql -- -- Description: Open's the cursor for the zone SQL of -- 'REMD' 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, CURR_VAL.MESSAGE_BODY, 2000); dbms_sql.define_column(I_CURSOR, 2, CURR_VAL.REMD_ID); dbms_sql.define_column(I_CURSOR, 3, CURR_VAL.MESSAGE_TYPE, 1); exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', '', 'efnow230$remd.OpenZoneSql'); raise; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.AssignZoneRow -- -- Description: Assign's a row of data and calculates the check sum from the -- zone SQL of 'REMD' module component. -- -- Parameters: -- -------------------------------------------------------------------------------- procedure AssignZoneRow ( I_CURSOR IN integer ) is begin dbms_sql.column_value(I_CURSOR, 1, CURR_VAL.MESSAGE_BODY); dbms_sql.column_value(I_CURSOR, 2, CURR_VAL.REMD_ID); dbms_sql.column_value(I_CURSOR, 3, CURR_VAL.MESSAGE_TYPE); ZONE_CHECKSUM := to_char(WSGL.Checksum ( '' || CURR_VAL.REMD_ID ) ); exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', '', 'efnow230$remd.AssignZoneRow'); raise; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.FormQuery -- -- Description: This procedure builds an HTML form for entry of query criteria. -- The criteria entered are to restrict the query of the 'REMD' -- 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('efnow230$remd') 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(''||' : '||''); WSGL.METATag; efnow230$.TemplateHeader(TRUE,3); WSGL.ClosePageHead; WSGL.OpenPageBody(FALSE, p_attributes=>QF_BODY_ATTRIBUTES || 'onLoad="return REMD_OnLoad()"'); efnow230$js$remd.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); WSGMC_OUTPUT2.Before(REF_COMPONENT,2); htp.p(WSGL.MsgGetText(115,WSGLM.DSP115_ENTER_QRY)); htp.para; WSGL.ResetForMultipleForms ; htp.formOpen(curl => 'efnow230$remd.actionquery', cattributes => 'NAME="efnow230$remd$QForm"'); SaveState; WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); WSGL.LayoutRowStart; for i in 1..QF_NUMBER_OF_COLUMNS loop WSGL.LayoutHeader(8, 'LEFT', NULL); WSGL.LayoutHeader(8, 'LEFT', NULL); end loop; WSGL.LayoutRowEnd; WSGL.LayoutRowStart('TOP'); WSGL.LayoutData(htf.bold('Remd Id:')); WSGL.LayoutData(WSGL.BuildQueryControl('REMD_ID', '8', FALSE, p_maxlength=>'40')); 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.ReturnLinks('0.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, ''||' : '||'', QF_BODY_ATTRIBUTES, 'efnow230$remd.FormQuery'); WSGL.ClosePageBody; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.FormView -- -- Description: This procedure builds an HTML form for view/update of fields in -- the 'REMD' module component. -- -- Parameters: Z_FORM_STATUS Status of the form -- -------------------------------------------------------------------------------- procedure FormView(Z_FORM_STATUS in number, Q_REMD_ID in varchar2, 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('efnow230$remd') 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(''||' : '||''); WSGL.METATag; htp.script('FormType = "Update";'); efnow230$.TemplateHeader(TRUE,4); WSGL.ClosePageHead; WSGL.OpenPageBody(FALSE, p_attributes=>VF_BODY_ATTRIBUTES || 'onLoad="return REMD_OnLoad()"'); efnow230$js$remd.CreateViewJavaScript( VF_ROWS_UPDATED, VF_ROWS_DELETED, VF_ROWS_ERROR, VF_BODY_ATTRIBUTES, LOV_FRAME ); htp.p(caco_system.menu); WSGMC_OUTPUT2.Before(REF_COMPONENT,2); InitialiseDomain('MESSAGE_TYPE'); 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, ''||' : '||'', 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), ''||' : '||'', 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), ''||' : '||'', 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 => 'efnow230$remd.actionview', cattributes => 'NAME="efnow230$remd$VForm"'); SaveState; WSGL.LayoutOpen(WSGL.LAYOUT_TABLE); WSGL.LayoutRowStart; for i in 1..VF_NUMBER_OF_COLUMNS loop WSGL.LayoutHeader(13, 'LEFT', NULL); WSGL.LayoutHeader(80, 'LEFT', NULL); end loop; 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( P_REMD_ID=>Q_REMD_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; 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 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; FORM_VAL.MESSAGE_BODY := WSGL.EscapeItem(CURR_VAL.MESSAGE_BODY); FORM_VAL.REMD_ID := WSGL.EscapeItem(CURR_VAL.REMD_ID); FORM_VAL.MESSAGE_TYPE := WSGL.EscapeItem(WSGL.DomainMeaning(D_MESSAGE_TYPE, CURR_VAL.MESSAGE_TYPE)); 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_REMD_ID', CURR_VAL.REMD_ID); WSGL.HiddenField('O_REMD_ID', CURR_VAL.REMD_ID); end if; l_skip_data := false; WSGL.HiddenField('H_UI_URL', NBT_VAL.UI_URL); WSGL.LayoutRowStart('TOP'); WSGL.LayoutData(wsgl.anchor2(FORM_VAL.UI_URL, '')); WSGL.LayoutData(' '); WSGL.LayoutRowEnd; if ( l_skip_data ) then WSGL.SkipData; else WSGL.LayoutData(' '); end if; WSGL.LayoutRowEnd; l_skip_data := false; WSGL.HiddenField('H_MESSAGE_BODY', CURR_VAL.MESSAGE_BODY); if CURR_VAL.MESSAGE_BODY is not null then WSGL.LayoutRowStart('TOP'); WSGL.LayoutData(htf.bold('Message Body:')); WSGL.LayoutData(replace(FORM_VAL.MESSAGE_BODY, ' ', '
')); WSGL.LayoutRowEnd; else WSGL.LayoutRowStart('TOP'); l_skip_data := true; wsgl.SkipData; wsgl.SkipData; WSGL.LayoutRowEnd; end if; 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_MESSAGE_BODY', CURR_VAL.MESSAGE_BODY); WSGL.HiddenField('O_MESSAGE_TYPE', CURR_VAL.MESSAGE_TYPE); end if; end loop; WSGL.LayoutClose; if l_row < 3 then WSGL.HiddenField('P_REMD_ID',''); WSGL.HiddenField('O_MESSAGE_BODY', ''); WSGL.HiddenField('O_MESSAGE_TYPE', ''); WSGL.HiddenField('H_UI_URL',''); WSGL.HiddenField('H_MESSAGE_BODY',''); 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; WSGL.HiddenField('Z_ACTION',''); 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(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); htp.para; WSGL.RecordListButton(TRUE, 'Z_ACTION', htf.escape_sc(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.REMD_ID))); WSGL.HiddenField('Q_REMD_ID', Q_REMD_ID); WSGL.HiddenField('Z_START', to_char(I_START)); htp.formClose; WSGL.ResetForMultipleForms ; htp.formOpen(curl => 'efnow230$remd.actionview', ctarget=>'_parent', cattributes => 'NAME="efnow230$remd$VFormQry"'); SaveState; htp.p (''); WSGL.HiddenField('z_modified','dummy_row'); WSGL.HiddenField('P_REMD_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.ReturnLinks('0.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, ''||' : '||'', VF_BODY_ATTRIBUTES, 'efnow230$remd.FormView'); WSGL.ClosePageBody; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.QueryView -- -- Description: Queries the details of a single row in preparation for display. -- -- Parameters: -- -------------------------------------------------------------------------------- procedure QueryView( K_REMD_ID in varchar2, P_REMD_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('efnow230$remd') then return; end if; WSGL.RegisterURL('efnow230$remd.queryview'); WSGL.AddURLParam('K_REMD_ID', K_REMD_ID); WSGL.AddURLParam('P_REMD_ID', P_REMD_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_REMD_ID is not null then CURR_VAL.REMD_ID := K_REMD_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, Q_REMD_ID=>P_REMD_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_REMD_ID=>P_REMD_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_REMD_ID=>P_REMD_ID) then WSGL.DisplayMessage(WSGL.MESS_ERROR, cg$errors.GetErrors, ''||' : '||'', VF_BODY_ATTRIBUTES); return; end if; if BuildSQL (P_REMD_ID=>P_REMD_ID ) then FormView(Z_FORM_STATUS=>Z_FORM_STATUS, Q_REMD_ID=>P_REMD_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), ''||' : '||'', VF_BODY_ATTRIBUTES); when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', VF_BODY_ATTRIBUTES, 'efnow230$remd.QueryView'); end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.QueryViewByKey -- -- Description: Queries the details of a single row in preparation for display. -- -- Parameters: -- -------------------------------------------------------------------------------- procedure QueryViewByKey( P_REMD_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('efnow230$remd') then return; end if; QueryView( K_REMD_ID=>P_REMD_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: efnow230$remd.ActionView -- -- Description: This procedure is called when the View Form is submitted to -- action an update, delete or requery request. -- -- Parameters: -- -------------------------------------------------------------------------------- procedure ActionView( P_REMD_ID in owa_text.vc_arr, O_MESSAGE_BODY in owa_text.vc_arr, O_REMD_ID in owa_text.vc_arr, O_MESSAGE_TYPE in owa_text.vc_arr, H_UI_URL in owa_text.vc_arr, H_MESSAGE_BODY in owa_text.vc_arr, Q_REMD_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('efnow230$remd') 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_REMD_ID=>Q_REMD_ID, Z_POST_DML=>FALSE, Z_DIRECT_CALL=>TRUE, Z_ACTION=>Z_ACTION, Z_START=>Z_START); end if; if (Z_ACTION = VF_QUERY_BUT_ACTION) or (Z_ACTION = VF_QUERY_BUT_CAPTION) then FormQuery( Z_DIRECT_CALL=>TRUE); end if; exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', VF_BODY_ATTRIBUTES, 'efnow230$remd.ActionView'); end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.RestoreState -- -- Description: Restore the data state and optional meta data for the -- 'REMD' 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.REMD_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, ''||' : '||'', '', 'efnow230$remd.RestoreState'); raise; return FALSE; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.SaveState -- -- Description: Saves the data state for the 'REMD' module component. -- -- Parameters: -- -------------------------------------------------------------------------------- procedure SaveState is begin null; exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', '', 'efnow230$remd.SaveState'); raise; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.GetRef -- -- Description: Returns a handle to the component object -- -- Parameters: -- -------------------------------------------------------------------------------- function GetRef return WSGOC.COMPONENT_REF is begin return ref_Component; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.LoadCache -- -- Description: Populate the object cache with -- 'REMD' 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; InitialiseDomain('MESSAGE_TYPE'); ref_Component := WSGOC.Component ( pModule => efnow230$.GetRef , pBranch => Z_BRANCH , pContext_For=> Z_CONTEXT_FOR , pName => 'REMD' , pSystemImagePath=> '/images/' ); r_UI_URL := WSGOC.Item ( pName => 'UI_URL' , pPrompt => '' ); r_MESSAGE_BODY := WSGOC.Item ( pName => 'MESSAGE_BODY' , pPrompt => 'Message Body' , pIsContext=> true ); r_REMD_ID := WSGOC.Item ( pName => 'REMD_ID' , pPrompt => 'Remd Id' ); r_MESSAGE_TYPE := WSGOC.Item ( pName => 'MESSAGE_TYPE' , pPrompt => 'Message Type' ); WSGOC.Add_Items(ref_Component, r_UI_URL); WSGOC.Add_Items(ref_Component, r_MESSAGE_BODY); WSGOC.Add_Items(ref_Component, r_REMD_ID); WSGOC.Add_Items(ref_Component, r_MESSAGE_TYPE); 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_MESSAGE_BODY, replace(WSGL.EscapeItem(CURR_VAL.MESSAGE_BODY), ' ', '
') ); WSGOC.Set_Value( r_REMD_ID, WSGL.EscapeItem(CURR_VAL.REMD_ID) ); WSGOC.Set_Value( r_MESSAGE_TYPE, replace(WSGL.EscapeItem(WSGL.DomainMeaning(D_MESSAGE_TYPE, CURR_VAL.MESSAGE_TYPE)), ' ', '
') ); end if; exception when others then WSGL.DisplayMessage(WSGL.MESS_EXCEPTION, SQLERRM, ''||' : '||'', '', 'efnow230$remd.LoadCache'); raise; end; -------------------------------------------------------------------------------- -- Name: efnow230$remd.PostQuery -- -- Description: Provides place holder for code to be run after a query -- for the 'REMD' 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, ''||' : '||'', DEF_BODY_ATTRIBUTES, 'efnow230$remd.PostQuery'); return FALSE; end; end; /