----------------------------------------------------------------------------------
-- List of Values Interfaces
----------------------------------------------------------------------------------
--
-- Created 03/07/2002,
--
Procedure LOVEmbedJavaScript
Is
Begin
htp.p('
// GLOBAL VARS
// GET VALUE FROM PARENT
var lovType;
var targetObj;
var fctID;
var fieldName;
var enableATIFunc;
//
var NOT_FOUND_ALERT = false;
var ERROR_ALERT = false;
var ERROR_MSG = "";
//
var gbDone = false;
var gTheForm = document.frmLovSrch;
// ALERT NOT FOUND
function checkAlertFlag()
{
if ( !parent.isNew && NOT_FOUND_ALERT == true )
{
alert("No records were found.");
}
return;
}
// ALERT ERROR
function checkErrorFlag()
{
if ( !parent.isNew && ERROR_ALERT == true )
{
alert(ERROR_MSG);
}
ERROR_ALERT = false;
ERROR_MSG = "";
return;
}
// SET TARGET OBJECT
function setTarget(p_target, p_lovType)
{
lovType = p_lovType;
targetObj = p_target;
}
// SET DEFAULT VALUES
function setDefault()
{
gTheForm = document.frmLovSrch;
//
// Get Values From Parent.
//
targetObj = new Object();
//
// parent.targetObj sometimes is
// undefined...
//
if ( parent.targetObj )
{
targetObj = parent.targetObj;
}
else
{
alert("Please click on the list of values button [...] again.");
parent.close();
}
//
lovType = parent.lovType;
fctID = parent.fctID;
fieldName = parent.fieldName;
enableATIFunc = parent.enableATIFunc;
if (isEmpty(gTheForm.p_lookup.value)
&& parent.isNew)
{
gTheForm.p_lookup.value = targetObj.value.toUpperCase();
}
gTheForm.p_LovType.value = lovType;
gTheForm.p_fctID.value = fctID;
gTheForm.p_fieldName.value = fieldName;
gTheForm.p_enableATIFunc.value = enableATIFunc;
gTheForm.p_lookup.focus();
if ( parent.isNew )
{
submitQuery("Find");
parent.isNew = false;
}
}
////////////////////////////////////////////////////////////////////////
// FORM ACTION BUTTONS [ FIND ] [ CLEAR ] [ OK ] [ CANCEL ]
////////////////////////////////////////////////////////////////////////
// FIND
function submitQuery( sub_type )
{
if ( sub_type == "Find" )
{
gTheForm.p_lastIndx.value = 0;
}
else
{
gTheForm.p_lookup.value = gTheForm.p_lastVal.value;
}
//
// Set Hidden Values
//
gTheForm.p_LovType.value = lovType;
gTheForm.p_fctID.value = fctID;
gTheForm.p_fieldName.value = fieldName;
gTheForm.p_enableATIFunc.value = enableATIFunc;
//
// Not done, please wait...
//
if ( !gbDone )
{
return;
}
//
// Proceeding...
//
gTheForm.submit();
gTheForm.p_lookup.focus();
}
// CLEAR
function clearForm()
{
gTheForm.p_lookup.value = "";
gTheForm.p_lookup.focus();
gTheForm.p_list.length = 0;
}
// OK
function doOk()
{
var selVal ;
with ( gTheForm.p_list )
{
selVal = options[selectedIndex].value;
}
if ( gTheForm.p_list.selectedIndex < 0 )
{
selVal = "";
}
//
// Pass the Selected
// value to caller''s object
//
targetObj.value = selVal;
parent.targetObj.focus();
parent.close();
}
// APPEND
function doAppend()
{
var selVal ;
with ( gTheForm.p_list )
{
selVal = options[selectedIndex].value;
}
if ( gTheForm.p_list.selectedIndex < 0 )
{
selVal = "";
}
//
// Pass the Selected
// value to caller''s object
//
if ( isNotEmpty(targetObj.value) )
{
if ( targetObj.value.toUpperCase().indexOf(selVal.toUpperCase()) == -1 )
{
targetObj.value = targetObj.value + ", " + selVal;
}
}
else
{
targetObj.value = selVal;
}
parent.targetObj.focus();
parent.close();
}
// CANCEL
function doCancel()
{
parent.close();
}
');
End;
--
-- Created 03/07/2002,
--
Procedure ShowLovColumnCaption( p_LovType In Varchar2, p_FctID In Varchar2, p_FieldName In Varchar2 )
Is
Begin
-- < lt_supplier >
If ( p_LovType = LT_SUPPLIER )
Then
htp.tableData( cvalue=>htf.bold( '<U>' || ('Product Line') || '</U>'), ccolspan=>'2' ) ;
End If;
End;
--
-- Created 03/07/2002,
--
Function OpenCursorLov(
p_LovType In Varchar2,
p_FctID In Varchar2,
p_FieldName In Varchar2,
p_LikeValue In Varchar2
) Return CURTYPE
Is
v_acursor CURTYPE;
v_view varchar2(50);
v_value varchar2(50);
Begin
-- < lt_spcn_type >
sIf ( p_LovType = LT_SPCN_TYPE )
Then
Open v_acursor For
Select DISTINCT value as for_view,
value as the_value
From SNM_NOTICES_TYPES
Where UPPER(value) LIKE '%' || UPPER(p_LikeValue) || '%'
Order By value;
-- <unknow type>
Else
Open v_acursor For
Select NULL as for_view,
NULL as the_value
From DUAL;
End If;
Return v_acursor;
End;
--
-- Created 03/07/2002,
--
Procedure ListOfValues( p_lookUp In Varchar2 := Null -- Search value
, p_lovType In Varchar2 := Null -- Search type
, p_fctID In Varchar2 := Null -- FCT ID
, p_fieldName In Varchar2 := Null -- Field Name of FCT_ID
, p_list In Varchar2 := Null -- List Object on form
, p_lastVal In Varchar2 := Null -- Last search value
, p_lastIndx In Number := 0 -- Last display indx
, p_EnableATIFunc In Varchar2 := '0' -- 0 is off, 1 is on
, p_AppendToInput In Varchar2 := Null )
Is
--
-- Loc Vars
--
v_title varchar2(100);
v_lblSrch varchar2(200);
v_bar varchar2(100):= RPAD( '_', 55, '_' );
--
-- Rec Navg Prop
--
v_maxHit number := 50;
v_recCnt number := 0;
v_curIndx number := 0;
v_more boolean := FALSE;
--
v_LovCursor CURTYPE;
v_TheView varchar2(500);
v_TheValue varchar2(200);
v_SetSelected varchar2(10);
v_nColSpanNvgBtns number := 2;
Begin
v_lblSrch:= 'Find All Containing:';
htp.htmlOpen;
htp.headOpen;
htp.title( v_title );
-- STYLE
htp.p( '<STYLE>' || NEWLINE
|| 'td' || NEWLINE
|| '{ font-family: Arial, Helvetica, sans-serif;'
|| NEWLINE
|| ' font-style: normal;' || NEWLINE
|| ' font-size: 10pt;' || NEWLINE
|| ' color: black;' || NEWLINE
|| '}' || NEWLINE
|| '</STYLE>' || NEWLINE
);
--
htp.headClose;
--
-- JAVASCRIPT
--
Snm_Util.HtpJavascipt( p_source=>JSC_STRING_LIB );
--
Snm_Util.JavascriptOpen;
LOVEmbedJavaScript;
Snm_Util.JavascriptClose;
--
htp.bodyOpen( cattributes=>'BGCOLOR="WHITE" onLoad="setDefault();"' );
--
-- FORM
--
htp.formOpen(
curl=>owa_util.get_owa_service_path || 'SNM_QRY.ListOfValues'
, cmethod=>'POST'
, cattributes=>'NAME="frmLovSrch" onSubmit="submitQuery(''Find'')"'
);
--
htp.centerOpen;
htp.tableOpen(cattributes=>'WIDTH="350" BORDER="0" CELLPADDING="3" CELLSPACING="0"');
--
-- SEARCH EDIT-TEXT CONTROL
--
htp.tableRowOpen;
htp.tableData( cvalue=>htf.bold( v_lblSrch ), ccolspan=>'2' );
htp.tableRowClose;
htp.tableRowOpen;
htp.tableData(
cvalue=>
'<INPUT TYPE=TEXT NAME="p_lookup" VALUE="'
|| Upper(p_lookUp)
|| '"SIZE=25>',
calign=>'LEFT',
ccolspan=>'2'
);
htp.tableRowClose;
--
-- BUTTONS: [ Find ] [ Clear ] [ OK ] [ Cancel ]
--
htp.tableRowOpen;
htp.tableData(
cvalue=>
'<INPUT TYPE=Button VALUE=" Find " onClick="submitQuery(''Find'')">'
|| WK_SPACE
|| '<INPUT TYPE=Button VALUE=" Clear " onClick="clearForm()">',
calign=>'LEFT',
ccolspan=>'1'
);
--
-- Enable Append To Input Func
--
If ( p_EnableATIFunc = '1' )
Then
htp.tableData(
cvalue=>
WK_SPACE
|| '<INPUT TYPE=Button VALUE=" OK " NAME=ok onClick="doOk()">'
|| WK_SPACE
|| '<INPUT TYPE=Button VALUE=" Append " NAME=ok onClick="doAppend()">'
|| WK_SPACE
|| '<INPUT TYPE=Button NAME=cn VALUE= " Cancel " onClick="doCancel()">',
calign=>'RIGHT', ccolspan=>'1'
);
Else
htp.tableData(
cvalue=>
WK_SPACE
|| '<INPUT TYPE=Button VALUE=" OK " NAME=ok onClick="doOk()">'
|| WK_SPACE
|| '<INPUT TYPE=Button NAME=cn VALUE= " Cancel " onClick="doCancel()">',
calign=>'RIGHT', ccolspan=>'1'
);
End If;
htp.tableRowClose;
--
-- HOR LINE
--
htp.tableRowOpen;
htp.tableData( htf.hr( cattributes=>'SIZE=1 WIDTH=100% ALIGN=LEFT' ),
ccolspan=>'2' );
htp.tableRowClose;
--
-- COLUMN CAPTION
--
htp.tableRowOpen;
ShowLovColumnCaption(
p_LovType=>p_LovType,
p_FctId=>p_FctId,
p_FieldName=>p_FieldName
);
htp.tableRowClose;
--
htp.tableRowOpen;
htp.p('<TD COLSPAN=2 class=spec>');
--
-- SET FONT
--
htp.fontOpen( cface=>'Courier New, Lucida Console, courier, fixed, Arial, Helvetica, Sans-Serif', csize=>'2' );
--
-- LIST OPEN
--
htp.formSelectOpen( cname=>'p_list', nsize=>9 );
Begin
If ( v_LovCursor%ISOPEN )
Then
Close v_LovCursor;
End If;
v_LovCursor :=
openCursorLov(
p_LovType=>p_LovType,
p_FctID=>p_fctID,
p_FieldName=>p_FieldName,
p_LikeValue=>p_LookUp
);
Loop
Fetch v_LovCursor Into v_TheView, v_TheValue;
Exit When v_LovCursor%NOTFOUND;
If ( v_recCnt = 0 )
Then
v_SetSelected := 'SELECTED';
Else
v_SetSelected := '';
End If;
If ( v_curIndx >= p_lastIndx )
Then
htp.p('<OPTION VALUE="'
|| htf.escape_sc(v_TheValue)
|| '"'
|| ' '
|| v_SetSelected
|| '>'
|| v_TheView
);
--
v_recCnt := v_recCnt + 1;
End If;
v_curIndx := v_curIndx + 1;
If (v_recCnt >= v_MaxHit)
Then
v_more := TRUE;
Exit;
End If;
End Loop;
Close v_LovCursor;
Exception
When Others Then
--
-- CALL Javascript CheckErrorFlag()
--
Snm_Util.JavaScriptOpen;
If ( v_recCnt = 0 )
Then
htp.p( 'Javascript:ERROR_ALERT = true;' );
htp.p( 'Javascript:ERROR_MSG = "'
|| 'Error in module listOfValues() - \"'
|| REPLACE(SQLERRM, VK_RET, '\n') || '\"";' );
htp.p( 'Javascript:checkErrorFlag();' );
Else
htp.p( 'Javascript:ERROR_ALERT = false;' );
htp.p( 'Javascript:ERROR_MSG = "";' );
End If;
Snm_Util.JavaScriptClose;
NULL;
End;
--
-- DEFAULT OPTION
-- WHEN LOV NOT FOUND
--
If ( v_recCnt = 0 )
Then
htp.p( '<OPTION VALUE="" SELECTED>' || v_bar );
Else
htp.p( '<OPTION VALUE="">' || v_bar );
End If;
htp.formSelectClose;
htp.fontClose;
htp.p('</TD>');
--
-- NAV BUTTONS: [ << Back ] [ Next x Records >> ]
--
htp.tableRowOpen;
--
Snm_Util.JavascriptOpen;
htp.p( 'gbDone = false;' );
Snm_Util.JavascriptClose;
--
v_nColSpanNvgBtns := 2;
--
If ( v_more )
Then
If ( p_lastIndx > 0 )
Then
htp.tableData(
cvalue=>
'<INPUT TYPE="BUTTON" VALUE="<< Back "onClick = "history.back();"> '
|| '<INPUT TYPE=button VALUE=" Next '
|| v_maxHit
|| ' >>" onClick="submitQuery(''Next'')">',
calign=>'RIGHT',
ccolspan=>v_nColSpanNvgBtns
);
Else
htp.tableData(
cvalue=>'<INPUT TYPE=button VALUE=" Next '
|| v_maxHit
|| ' >>" onClick="submitQuery(''Next'')">'
,
calign=>'RIGHT',
ccolspan=>v_nColSpanNvgBtns
);
End If;
ElsIf ( v_curIndx > v_MaxHit )
Then
htp.tableData(
cvalue=>'<INPUT TYPE="BUTTON" VALUE="<< Back "onClick = "history.back();">',
calign=>'RIGHT',
ccolspan=>v_nColSpanNvgBtns
);
htp.tableRowClose;
End If;
htp.tableRowClose;
--
htp.tableClose;
htp.centerClose;
--
-- CALL CHECKALERTFLAG()
--
Snm_Util.JavascriptOpen;
If ( v_recCnt = 0 )
Then
htp.p( 'Javascript:NOT_FOUND_ALERT = true;' );
htp.p( 'Javascript:checkAlertFlag();' );
Else
htp.p( 'Javascript:NOT_FOUND_ALERT = false;' );
End If;
Snm_Util.JavascriptClose;
--
-- SAVE TRANS INFO
--
htp.formHidden(cname=>'p_lastVal', cvalue=>p_lookUp );
htp.formHidden(cname=>'p_lastIndx', cvalue=>v_curIndx );
htp.formHidden(cname=>'p_LovType', cvalue=>p_LovType );
htp.formHidden(cname=>'p_fctID', cvalue=>p_fctID );
htp.formHidden(cname=>'p_fieldName',cvalue=>p_fieldName );
htp.formHidden(cname=>'p_enableATIFunc',cvalue=>p_EnableATIFunc );
--
-- Added 01/15/2001,
--
Snm_Util.JavascriptOpen;
htp.p( 'gbDone = true;' );
htp.p( '//setDefault();' );
Snm_Util.JavascriptClose;
--
-- Close Tags
--
htp.formClose;
htp.bodyClose;
htp.htmlClose;
--
-- Win to Front
--
If ( v_recCnt > 0 )
Then
Snm_Util.JsWinToFront;
End If;
Exception
When Others Then
htp.p('Error in module listOfValues() : ' || SQLERRM);
End;