Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
var sql_h : N12 = 0
var sql_cmd : A2000
var rvc_name[ 40 ] : A20
var rvc_seq[ 40 ] : N9
var num_rvc : N2
var cur_page : N1
event inq : 1
if @InStandAloneMode = 1 or @InBackupMode = 1
exitwitherror "This function is not available while offline"
endif
Call LoadSQL
num_rvc = 0
format sql_cmd as "SELECT rvc_seq,name FROM MICROS.rvc_def ORDER BY obj_num"
Call sql_query( sql_cmd )
while sql_cmd <> "" and num_rvc < 40
num_rvc = num_rvc + 1
splitQ sql_cmd, ";", rvc_seq[ num_rvc ], rvc_name[ num_rvc ]
DLLCALL_CDECL sql_h, sqlGetNext( ref sql_cmd )
endwhile
cur_page = 1
forever
Call DrawCurrentPage
Call GetInput
endfor
endevent
sub GetInput
var InKey : key
var InData : A10
inputkey InKey, InData, "Select RVC"
//Exit SIM
if InKey = @Key_Clear
exitcontinue
endif
//Did they hit the next key?
if KeyNumber( InKey ) = 2
cur_page = cur_page + 1
return
endif
//Did they hit the previous key?
if KeyNumber( InKey ) = 1
cur_page = cur_page - 1
return
endif
if KeyNumber( InKey ) > 3000
var rvc_seq : A9 = KeyNumber( InKey ) - 3000
format sql_cmd as "UPDATE MICROS.uws_def SET rvc_seq = ", rvc_seq, " WHERE obj_num = ", @Wsid
Call sql_exec( sql_cmd )
infomessage "Workstation RVC Changed"
exitcontinue
endif
endsub
sub DrawCurrentPage
ClearIslTS
var KeyHeight : N1 = 6
var KeyWidth : N1 = 6
var NumPages : N5 = 1
while NumPages*10 < num_rvc
NumPages = NumPages + 1
endwhile
var FirstItem : N5 = (cur_page-1) * 10 + 1
//draw first row of results
var i : N5
for i = FirstItem to FirstItem + 4
if i > num_rvc
break
endif
SetIslTsKeyx 1,(i - FirstItem) * KeyWidth + 1,3,KeyWidth,1,key(1, 3000 + rvc_seq[ i ]), 0, "C", 10, rvc_name[ i ]
endfor
//draw second row of results
for i = i to FirstItem + 10
if i > num_rvc
break
endif
SetIslTsKeyx 4,(i - FirstItem - 5) * KeyWidth + 1,3,KeyWidth,1,key(1, 3000 + rvc_seq[ i ]), 0, "C", 10, rvc_name[ i ]
endfor
//draw some page keys
if cur_page > 1
setisltskeyx 11, 1, 2, 2, 1, key(1,1), 10388, "C", 10, ""
endif
if cur_page < NumPages
setisltskeyx 11, 3, 2, 2, 1, key(1,2), 10389, "C", 10, ""
endif
//Provide an escape route
SetIslTsKeyx 9,27,4, 4, 1, @Key_Clear, 10058, "L", 10, "Done/Exit"
DisplayIslTs
endsub
////////////////////////////////////////////
//// SQL SUBROUTINES ////
////////////////////////////////////////////
sub LoadSQL
Call LoadDLL
Call OpenSQL
endsub
sub LoadDLL
if sql_h = 0
DLLLoad sql_h, "MDSSysUtilsProxy.dll"
endif
if sql_h = 0
exitwitherror "Unable to load SQL DLL"
endif
endsub
sub OpenSQL
var con_status : N9
DLLCALL_CDECL sql_h, sqlIsConnectionOpen( ref con_status )
if con_status = 0
DLLCALL_CDECL sql_h, sqlInitConnection("micros", "ODBC;UID=custom;PWD=custom", "")
endif
DLLCALL_CDECL sql_h, sqlIsConnectionOpen( ref con_status )
if con_status = 0
exitwitherror "Cannot open SQL connection to server"
endif
endsub
sub sql_query( ref sql_cmd )
DLLCALL_CDECL sql_h, sqlGetRecordSet( sql_cmd )
sql_cmd = ""
DLLCALL_CDECL sql_h, sqlGetLastErrorString( ref sql_cmd )
if sql_cmd <> ""
errormessage "SQL Error: ", sql_cmd
endif
DLLCALL_CDECL sql_h, sqlGetNext( ref sql_cmd )
endsub
sub sql_exec( ref sql_cmd )
DLLCALL_CDECL sql_h, sqlExecuteQuery( sql_cmd )
sql_cmd = ""
DLLCALL_CDECL sql_h, sqlGetLastErrorString( ref sql_cmd )
if sql_cmd <> ""
errormessage "SQL Error: ", sql_cmd
endif
endsub
sub sql_recordset( ref sql_cmd )
DLLCALL_CDECL sql_h, sqlGetRecordSet( sql_cmd )
sql_cmd = ""
DLLCALL_CDECL sql_h, sqlGetLastErrorString( ref sql_cmd )
if sql_cmd <> ""
exitwitherror "SQL Error: ", sql_cmd
endif
endsub
format sql_cmd as "select count(*) from micros.emp_def e join micros.emp_class_def c on e.emp_class_seq = c.emp_class_seq where e.obj_num = ", @Tremp, " and ob_tpriv_change_uws_rvc = 'T'"
call sql_query(sql_cmd)
if sql_cmd = 0
exitwitherror "You are not privileged to change RVC's"
endif