PARAMETERS cBdd, cIdView, cIdServ


SET TALK off
SET STATUS BAR OFF
SET SYSMENU off
SET DELETED on
SET CONFIRM OFF
SET NOTIFY off
SET SAFETY off
SET CENTURY ON
SET DATE TO DMY
SET FIXED OFF
SET DECIMALS TO 5
SET ESCAPE On

_screen.WindowState = 1

SET PATH TO proj,json,classes, form,prg,class

_screen.Caption = 'Ghost - Manejador de Eventos '
_screen.AutoCenter= .T.
_screen.Icon = 'glib.ICO'
_screen.Width  = 700
_screen.height = 500

_screen.Closable = .f.
_screen.AutoCenter = .t.
_screen.Show
_screen.BorderStyle=3
_screen.MaxButton= .F.
_screen.ControlBox= .F.


IF EMPTY(cBdd)
	cBdd='fss1'
ENDIF

DECLARE Sleep IN Win32API INTEGER   

CLEAR 

? "Bienvenido al manejador de eventos del Ghost"
? ":::"
?

DO app.prg WITH cBdd



oApp.loadGhost()
oApp.setGhost()
oApp.host = oApp.hostjson

DO invoicer.prg
DO json\js.prg WITH cbdd, cIdView, cIdServ
DO json\json_cliente.prg
DO initdb.prg WITH 1

DO WHILE .T.

	IF INKEY() #0
		IF INKEY(0)=27
			thisform.lsalir =  (messagebox('Salir',32+4,'Ghost')=6)
			RETURN
		ENDIF
	ENDIF

	IF oApp.lGhostLocal 
		Sleep (80)
		oJs.descargarMensajesLocal()
	ELSE
		IF oApp.sqlexec('select gvfac from sysini where gvfac')>0
			oApp.sqlexec('update sysini set gvfac = 0')
			oJs.descargarMensajesWeb()
		ENDIF
	ENDIF
		
	oJs.procesar() && Ejecutar comandos
ENDDO 


_screen.ControlBox= .T.
_screen.MaxButton= .T.
_screen.Closable = .T.
_screen.WindowState = 2


