LOCAL cResp, cCmd

cTabla = 'user'

&&cond = IIF(EMPTY(oJs.cParam), ' ', ' and id = '+oJs.cParam)

cond = ' and id = '+ oJs.cIdUser

oapp.sqlexec ('select * from user where 1 '+cond,'curUser')

cPrecioBaseB = "priced"
cPrecioBaseU = "pricec"


TEXT TO wParam NOSHOW textmerge
{
"porcdesc1":"<<curUser.porcdesc1>>",
"porcdesc2":"<<curUser.porcdesc2>>",
"porcdesc3":"<<curUser.porcdesc3>>",
"porcdesc4":"<<curUser.porcdesc4>>",
"n_copia_cobro":"<<curUser.n_copia_cobro>>",
"n_copia_venta":"<<curUser.n_copia_venta>>",
"tipo_prn":"<<curUser.tipo_prn>>",
"serie":"<<curUser.seriepv>>",
"frm_fc":"<<ALLTRIM(curUser.frm_fc)>>",
"frm_nv":"<<ALLTRIM(curUser.frm_nv)>>",
"frm_ne":"<<ALLTRIM(curUser.frm_ne)>>",
"frm_rec":"<<ALLTRIM(curUser.frm_rec)>>",
"pminb":"<<oApp.ghost_pminb>>",
"pminu":"<<oApp.ghost_pminu>>",
"pmaxb":"<<oApp.ghost_pmaxb>>",
"pmaxu":"<<oApp.ghost_pmaxu>>",
"habilitarpvp":"curUser.habilitarpvp>>",
"pvp":"curUser.pvp>>",
"campoPrecioBaseB":"<<cPrecioBaseB>>",
"campoPrecioBaseU":"<<cPrecioBaseU>>"
}
ENDTEXT



*wParam = ' '

*STRTOFILE(wParam ,'\temp\wParam.txt')

cNota1 = ALLTRIM(oApp.setup('nota1','C'))
cNota2 = ALLTRIM(oApp.setup('nota2','C'))
cNota3 = ALLTRIM(oApp.setup('nota3','C'))


*MESSAGEBOX('ghost_lcontrol_stock: '+TRANSFORM(oApp.ghost_lcontrol_stock))


&& MODIFICA_PRECIO = 3 aplica para Plastife

TEXT TO cCmd NOSHOW TEXTMERGE  
	SELECT 
		id+0 as id,
		name,
		login,
		TRIM(barras) as clave,
		"<<oApp.fixstr(oApp.cbEnterprise)>>" as nombre_empresa,
		"<<oApp.cbPhone>>" as telf_empresa,
		"<<oApp.cbWeb>>" as web_empresa,
		"<<oApp.fixstr(oApp.cbDireccion)>>" as direcc_empresa,
		"<<oApp.cbURLLogo>>" as url_logo,
		<<oApp.print_lin_factura>> as nro_lin_ped,
		<<IIF(oApp.ghost_lcontrol_stock,'1','0'))>> as lcontrol_stock,
		'0' as USAR_BODEGA,
		<<oApp.ghost_MODIFICA_PRECIO>> as MODIFICA_PRECIO,
		<<oApp.ghost_PORCENTAJE_PRECIO>> as PORCENTAJE_PRECIO,
		<<oApp.ghost_NOTIFICA_GESTION>> as NOTIFICA_GESTION,
		"<<oApp.ghost_MAIL_SUPERVISOR>>" as MAIL_SUPERVISOR,
		"<<oApp.ghost_CELULAR_SUPERVISOR>>" as CELULAR_SUPERVISOR,
		<<IIF(oApp.ghost_stock_linea,'1','0'))>> as stock_linea,
		CONTROL_VENCIMIENTO,
		"<<oApp.nIva>>" as iva,
		<<IIF(oApp.lGhostLocal,'1','0'))>> as lGhostLocal,
		lprint,
		1 as control_cupos,
		1 as cambia_pvp,
		crea_cliente,
		venta_en_linea,
		idclasereporte,
		0 as sincroniza_linea,
		120 as tiempo_sincronizacion,
		"<<cNota1>>" as nota1,
		"<<cNota2>>" as nota2,
		"<<cNota3>>" as nota3,
		idsalesman+0 as idsalesman,
		idcc+0 as idcc,
		idcp+0 as idcp,
		idbodega+0 as idbodega,
		bodegas,
		ROUND(PORCDESC1/100,2) as desc_max,
		SPACE(255) as parametros,
		0 as estado
	FROM user WHERE 1 <<cond>>
ENDTEXT	

** "" as bodegas,
*** estado
* 0 ok
* 1 bloqueado
* 2 eliminado
* 3 no registrado

*STRTOFILE(cCmd,'\temp\pda_user.txt')

oApp.sqlexec(cCmd,cTabla)
SELECT &cTabla
replace parametros WITH  wParam 
FLUSH
GO top

*BROWSE

oJs.android_up(cTabla)