Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Micros 3700 86/Item Availability Function 1

Status
Not open for further replies.

ryroanderson

Systems Engineer
Oct 18, 2017
19
US
I remapped some blank menu items to clear out clutter and to organize menu items into better groupings, and in doing so it seems I changed an item that a SIM was dependent on. Before remapping the 86/item availability function worked fine, now when I use that function it immediately pops up and says "menu item not found." This has me thinking that the SIM used for this functionality has a menu item number hard coded? When I went to check the isl file it is encrypted. I know there is no easy way to un-encrypt an isl file, but I'm hoping someone might be able to shed some light on creating a new one? Anyone willing to help?
 
I wonder if its this SIM:

Code:
////////////////////////////////////////////
////      VARIABLES WE NEED SIM WIDE    ////
////////////////////////////////////////////

var sql_h        : N12 = 0
var in_86_mode   : N1
var num_dtl_p    : N10
var entered_item : N1
var default_ts   : N10 = 501 //if there is no open check, the SIM will check this field. if it is 0, it will insist on an open check. otherwise, it will open a check and then pull to this screen
var menu_item    : N9 = 960018
var void_code    : N3 = 1

////////////////////////////////////////////
////  MAIN INQUIRY TO ACTIVATE 86 MODE  ////
////////////////////////////////////////////

event inq : 1

	if @instandalonemode = 1
		exitwitherror "This function does not support operations in Stand-Alone Mode"
	endif

	Call LoadSQL
	
	Call CheckPermission

	if in_86_mode = 1
		in_86_mode = 0
		infomessage "86 MODE IS NOW INACTIVE"
	else
		if default_ts = 0
			exitwitherror "No Landing Screen Defined"
		endif

		loadkybdmacro key(1, 458756), key(3, menu_item), makekeys(void_code), @KEY_ENTER, key(1, 458753), key(1, 458753)
		in_86_mode = 1
		var message : A200
		format message as "          86 MODE IS NOW ACTIVE.", chr(10), "To exit 86 Mode, cancel transaction"
		infomessage message
		entered_item = 0
		DisplayTouchscreen default_ts
	endif

endevent

event inq : 2
	Call FlipAnItem
endevent

event pickup_check

	if in_86_mode
		num_dtl_p = @numdtlt
	endif

endevent

event begin_check

	if in_86_mode
		num_dtl_p = 0
	endif

endevent

event dtl_changed

	if in_86_mode

		var i : N3 = @numdtlt
		var ReferenceRequired : N1 = 0

		if num_dtl_p = i
			exitcontinue
		elseif entered_item <= 0
			entered_item = entered_item + 1
			exitcontinue
		elseif @Dtl_type[ i ] = "R"
			ReferenceRequired = 1
			while @Dtl_type[ i ] <> "M"
				i = i - 1
			endwhile
		elseif  @Dtl_sequence[ i ] = 0
			exitcontinue
		endif


		Call LoadSQL

		var MISeq  : N7  = @Dtl_sequence[ i ]
		var MIObjN : N7  = @Dtl_object[ i ]
		var MIName : A16 = @Dtl_name[ i ]
		

		var MIStatus[ 2 ] : A1
		var MICount       : N10
		VoidDetail( i )
		Call GetAvailability( MISeq, MIStatus[], MICount )
		Call EditAvailability( MISeq, MIObjN, MIName, MICount, ReferenceRequired, MIStatus[] )
	endif

endevent



////////////////////////////////////////////
////          SIM MENU SUBROUTINES      ////
////////////////////////////////////////////
sub EditAvailability( var MISeq : N7, var MIObjnum : N7, var MIName : A16, var MICount : N10, var RefReq : N1, ref MIStatus[])

	//MIStatus[1] is chk_mi_avail
	//MIStatus[2] is out_of_mi

	var key_pressed : key
	var data : A32
	var SET_AVAILABLE    : key = key(1, 16000)
	var SET_NOTAVAILABLE : key = key(1, 16100)
	var SET_LIMITEDAVAIL : key = key(1, 16200)
	var CHANGE_COUNT     : key = key(1, 16300)
	var ADD_TO_COUNT     : key = key(1, 16400)
	var ICONS[ 3 ] : N5
	var NumericScreen : N10
	var CountKey : key
	var CountNew : N10
	Call findNumericScreen( NumericScreen )

	var avail : A100

	Forever
		if (MIStatus[ 1 ] = "T" and MIStatus[ 2 ] = "F") or MICount > 0
			format avail as "Limited Availability (", MICount, ")"
		else
			format avail as "Limited Availability"
		endif
		
		ClearIslTs
			
			if MIStatus[ 1 ] = "F" and MIStatus[ 2 ] = "F"
				ICONS[ 1 ] = 10059
				ICONS[ 2 ] = 0
				ICONS[ 3 ] = 0
			elseif MIStatus[ 1 ] = "F" and MIStatus[ 2 ] = "T"
				ICONS[ 1 ] = 0
				ICONS[ 2 ] = 10059
				ICONS[ 3 ] = 0
			elseif MIStatus[ 1 ] = "T" and MIStatus[ 2 ] = "F"
				ICONS[ 1 ] = 0
				ICONS[ 2 ] = 0
				ICONS[ 3 ] = 10059
			endif
			SetIslTskeyx 2, 3, 4, 8, 2, SET_AVAILABLE, ICONS[ 1 ], "L", 10, "Currently Available"
			SetIslTskeyx 2, 12, 4, 8, 2, SET_NOTAVAILABLE, ICONS[ 2 ], "L", 10, "Not Available"
			SetIslTskeyx 2, 21, 4, 8, 2, SET_LIMITEDAVAIL, ICONS[ 3 ], "L", 10, avail
			if ICONS[ 3 ] <> 0
				SetIslTskeyx 6, 21, 2, 8, 2, CHANGE_COUNT, 0, "L", 10, "Change Count"
				SetIslTskeyx 8, 21, 2, 8, 2, ADD_TO_COUNT, 0, "L", 10, "Add to Count"
			endif
			setisltskeyx 9, 3, 4, 4, 1, @Key_Clear, 10058, "L", 10, "Done/Exit"

		DisplayIslTs

		inputkey key_pressed, data, "Select Option"

		if key_pressed = @Key_Clear or key_pressed = @Key_Cancel
			//if we do this, it at least forces an update on limited available items right away
			entered_item = -1
			if RefReq = 0
				loadkybdmacro key(3, MIObjnum), key(1, 458753)
			else
				loadkybdmacro key(3, MIObjnum), @Key_Enter, key(1, 458753)
			endif
			exitcontinue
		endif

		if key_pressed = SET_AVAILABLE
			Call SetAvailable( MISeq )
		elseif key_pressed = SET_NOTAVAILABLE
			Call SetNotAvailable( MISeq )
		elseif key_pressed = SET_LIMITEDAVAIL
			Call SetLimitedAvailable( MISeq )
		elseif key_pressed = CHANGE_COUNT
			touchscreen NumericScreen
			inputkey CountKey, CountNew, "Enter New Availability Count"
			if CountNew = 0 and CountKey = @Key_Enter
				errormessage "Warning: Menu Item Now Sold Out"
			endif
			if CountKey = @Key_Enter
				Call SetCount( MISeq, CountNew )
			endif
		elseif key_pressed = ADD_TO_COUNT
			touchscreen NumericScreen
			inputkey CountKey, CountNew, "How many to add to count?"
			if CountKey = @Key_Enter
				Call AddToCount( MISeq, CountNew )
			endif		
		endif
		Call GetAvailability( MISeq, MIStatus[], MICount )

	EndFor

endsub

////////////////////////////////////////////
////         MENU ITEM SUBROUTINES      ////
////////////////////////////////////////////

sub FlipAnItem
endsub

sub GetAvailability( var MISeq : N7, ref MIDetails[], ref MICount )

	var sql_cmd : A2000
	format sql_cmd as 		"select def.ob_mi31_chk_mi_avail, status.ob_mi32_out_of_mi, status.available_count", 		" from micros.mi_def as def", 		" join micros.mi_status as status", 		" on def.mi_seq = status.mi_seq", 		" where def.mi_seq = ", MISeq
	Call sql_query( sql_cmd )

	splitQ sql_cmd, ";", MIDetails[ 1 ], MIDetails[ 2 ], MICount

endsub

sub SetAvailable( var MISeq : N7 )

	var sql_cmd : A2000
	format sql_cmd as 		"update micros.mi_def", 		" set ob_mi31_chk_mi_avail = 'F'", 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

	format sql_cmd as 		"update micros.mi_status", 		" set ob_mi32_out_of_mi = 'F'", 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

endsub

sub SetNotAvailable( var MISeq : N7 )

	var sql_cmd : A2000
	format sql_cmd as 		"update micros.mi_def", 		" set ob_mi31_chk_mi_avail = 'F'", 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

	format sql_cmd as 		"update micros.mi_status", 		" set ob_mi32_out_of_mi = 'T'", 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

endsub

sub SetLimitedAvailable( var MISeq : N7 )

	var sql_cmd : A2000
	format sql_cmd as 		"update micros.mi_def", 		" set ob_mi31_chk_mi_avail = 'T'", 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

	format sql_cmd as 		"update micros.mi_status", 		" set ob_mi32_out_of_mi = 'F'", 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

endsub

sub SetCount( var MISeq : N7, var MICount : N10 )

	var sql_cmd : A2000
	format sql_cmd as 		"update micros.mi_status", 		" set available_count = ", MICount, 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

endsub

sub AddToCount( var MISeq : N7, var MICount : N10 )

	var sql_cmd : A2000
	format sql_cmd as 		"update micros.mi_status", 		" set available_count = available_count + ", MICount, 		" where mi_seq = ", MISeq
	Call sql_exec( sql_cmd )

endsub

////////////////////////////////////////////
////          EMPLOYEE SUBROUTINES      ////
////////////////////////////////////////////

sub CheckPermission
	
	var sql_cmd : A2000
	format sql_cmd as 		"select ob_spriv13_mi_avail_proc from", 		" micros.emp_def as emp_def", 		" join micros.emp_class_def as emp_class", 		" on emp_def.emp_class_seq = emp_class.emp_class_seq", 		" where emp_def.obj_num = ", @Tremp

	Call sql_query( sql_cmd )

	if sql_cmd <> "T;"
		exitwitherror "Insufficient Permission to 86 Items'
	endif

endsub

sub GetDefaultTouchscreen( ref Touchscrn )

	var sql_cmd : A2000
	format sql_cmd as 		"select ts_scrn.obj_num from", 		" micros.emp_def as emp_def", 		" join micros.emp_class_def as emp_class", 		" on emp_def.emp_class_seq = emp_class.emp_class_seq", 		" join micros.ts_scrn_def as ts_scrn", 		" on emp_class.default_ts_scrn = ts_scrn.ts_scrn_seq", 		" where emp_def.obj_num = ", @Tremp
	//infomessage sql_cmd
	Call sql_query( sql_cmd )

	splitQ sql_cmd, ";", Touchscrn

endsub

////////////////////////////////////////////
////           MISC SUBROUTINES         ////
////////////////////////////////////////////

sub findNumericScreen( ref numericscreen )

	//function attempts to locate the numeric touch screen
	//numeric touchscreen is assigned through the configurator; Revenue Center -> RVC Touchscreens
	var sql_cmd : A2000
	format sql_cmd as "select screens.obj_num", 					  " from micros.ts_scrn_def as screens", 					  " join micros.rvc_add_def as rvc_screens", 					  " on rvc_screens.numeric_ts_scrn_seq = screens.ts_scrn_seq"
	Call sql_query( sql_cmd )
	numericscreen = sql_cmd
	
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top