LOCAL cResp, cCmd

cTabla = 'catalogo'

*android (cTabla, nOp, cSepRow, nLimit, cPipeta)

TEXT TO cCmd1 NOSHOW TEXTMERGE 
	Select id+0 as id, 
	name, 
	nota,
	CAST(fini as char) as fini,
	CAST(ffin as char) as ffin,
	agotarstock,
	tipo_cliente
	from ghost_08 where !void and estado=1
ENDTEXT


TEXT TO cCmd2 NOSHOW TEXTMERGE 
Select 
	id+0 as id,
	id_ghost_08,
	cantbase,
	cantprom,
    descuento,
	precio,
	iditemprom+0 as iditemprom,
    tipo
	from ghost_08accion
	where id_ghost_08 in (select id from ghost_08 where !void and estado=1)
ENDTEXT

TEXT TO cCmd3 NOSHOW TEXTMERGE 
Select 
	id,
    id_ghost_08+0 as id_ghost_08,
	iditem+0 as iditem
	from ghost_08item 
	where id_ghost_08 in (select id from ghost_08 where !void and estado=1)
ENDTEXT

oApp.sqlexec(cCmd1,'cur_ghost08')
oApp.sqlexec(cCmd2,'cur_ghost08accion')
oApp.sqlexec(cCmd3,'cur_ghost08item')

cghost_08		= '['+oJs.android ('cur_ghost08')
cghost_08accion = '['+oJs.android ('cur_ghost08accion')
cghost_08item   = '['+oJs.android ('cur_ghost08item')



TEXT TO cCmd1 NOSHOW TEXTMERGE 
	Select id+0 as id, 
	name, 
	year
	from ghost_09 where estado=1
ENDTEXT


TEXT TO cCmd2 NOSHOW TEXTMERGE 
select
	id+0 as id,
	id_ghost_09+0 as id_ghost_09,
	source,
	idsource+0 as idsource,
	mes01, mes02, mes03, mes04, mes05, mes06, mes07, mes08, mes09, mes10, mes11, mes12
	from ghost_09accion
	where id_ghost_09 in (select id from ghost_09 where estado=1)
ENDTEXT

TEXT TO cCmd3 NOSHOW TEXTMERGE 
Select 
	id,
    id_ghost_09+0 as id_ghost_09,
	idsalesman+0 as idsalesman
	from ghost_09sales
	where id_ghost_09 in (select id from ghost_09 where estado=1)
ENDTEXT

oApp.sqlexec(cCmd1,'cur_ghost09')
oApp.sqlexec(cCmd2,'cur_ghost09accion')
oApp.sqlexec(cCmd3,'cur_ghost09sales')

cghost_09		= '['+oJs.android ('cur_ghost09')
cghost_09accion = '['+oJs.android ('cur_ghost09accion')
cghost_09sales  = '['+oJs.android ('cur_ghost09sales')


*STRTOFILE(cghost_08accion ,'\eddy1.txt')


TEXT TO cCmd NOSHOW TEXTMERGE 
	SELECT name, 'visitas' as tabla,id+0 as id,      0 as establa, 0 as valor FROM visitas 
	union all
	SELECT name, 'tipovisita' as tabla,id+0 as id,   0 as establa, 0 as valor FROM tipovisitas
	union all
	SELECT name, 'grupo' as tabla,id+0 as id,        0 as establa, 0 as valor FROM grupo 
	union all
	SELECT name, 'brand' as tabla,id+0 as id,        0 as establa, 0 as valor FROM brand 
	union all
	SELECT name, 'zonas' as tabla,id+0 as id,        0 as establa, 0 as valor FROM zonas 
	union all
	SELECT name, 'supplier' as tabla,id+0 as id,     0 as establa, 0 as valor FROM supplier WHERE aplica_pda 
	union all
	SELECT name, 'bank' as tabla,id+0 as id,         0 as establa, 0 as valor FROM bank WHERE istarjetacredito=0
	union all
	SELECT name, 'tarjetas' as tabla,id+0 as id,        0 as establa, 0 as valor FROM bank WHERE istarjetacredito=1
	union all
	SELECT name, 'bodega' as tabla,id+0 as id,         0 as establa, 0 as valor FROM bodega 
	union all
	SELECT concat(ctr," - ",descrip) as name,  'codigos_fte' as tabla,id+0 as id, 0 as establa, pret as valor FROM tsri_11 WHERE ingresa='S'
	union all
	SELECT name1 as name,  'codigosri' as tabla,expresion+0 as id, 0 as establa, valor FROM StockCond WHERE tipo=100
	union all
	SELECT name, 'formaspago' as tabla,id+0 as id,  0 as establa, 0 as valor FROM accountype WHERE id=1 OR id=2 OR id=3 OR id=4 OR id=7 OR id=8 OR id=9 OR id=10 OR id=16 or id=17 or id=31 
	union all
	(SELECT "<<cghost_08>>" as name,  'ghost_08' as tabla,100001 as id, 1 as establa, 0 as valor FROM brand limit 1)
	union all
	(SELECT "<<cghost_08accion>>" as name,  'ghost_08accion' as tabla, 100002 as id, 1 as establa, 0 as valor FROM brand limit 1)
	union all
	(SELECT "<<cghost_08item>>" as name, 'ghost_08item' as tabla, 100003 as id, 1 as establa, 0 as valor FROM brand limit 1)
	union all
	(SELECT "<<cghost_09>>" as name,  'ghost_09' as tabla,100007 as id, 1 as establa, 0 as valor FROM brand limit 1)
	union all
	(SELECT "<<cghost_09accion>>" as name,  'ghost_09accion' as tabla, 100008 as id, 1 as establa, 0 as valor FROM brand limit 1)
	union all
	(SELECT "<<cghost_09sales>>" as name, 'ghost_09sales' as tabla, 100009 as id, 1 as establa, 0 as valor FROM brand limit 1)
		
ENDTEXT

*STRTOFILE(cCmd,'\eddy_catalogo.txt')

oApp.sqlexec(cCmd,cTabla)

oJs.android_up(cTabla)
