Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var bd = Ext.getBody();
htmlCont = '
';
bd.createChild({tag: 'h2', html: htmlCont});
function deshabilitartecla(e,teclas){
teclas = (teclas!="")?teclas:'1234567890.,';
key = e.getCharCode();
valido = keyRestrict_extjs(key,teclas);
if(valido){return;}
// PARA LA EJECUCIÓN DE LOS EVENTOS
e.stopEvent();
}
//******************************************************************************************************
//************************************* FORMULARIO DE SELECCIÓN DE EMPRESA *****************************
//******************************************************************************************************
function mensajes_ext(titulo,texto){
Ext.MessageBox.show({
title: titulo,
msg: texto,
buttons: Ext.MessageBox.OK,
width: 300,
icon: 'covensol_icono'
});
}
janchocampocoment=250;
Ancho=500;
Alto=250;
AnchoEtiqueta = 100;
var dsconf = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method:'POST',
url: 'sss/covensol_sss_json_config.php'
}),
listeners:{
load:function(){}
},
reader: new Ext.data.JsonReader({
root: 'datos',
totalProperty: 'total',
id: 'id_conf'
}, [
{name: 'id_conf'},
{name: 'hostname'},
{name: 'port'},
{name: 'database'},
{name: 'login'},
{name: 'password'},
{name: 'gestor'},
{name: 'width'},
{name: 'height'},
{name: 'logo'},
{name: 'alias'}
])
});
dsconf.load();
var combobd = new Ext.form.ComboBox({
xtype:'combo',
store:dsconf,
displayField:'alias',
valueField:'id_conf',
fieldLabel: 'Base Datos',
labelAlign: 'right',
name:'cmbcombobd',
id:'cmbcombobd',
hiddenName:'hcmbcombobd',
hiddenId:'hcmbcombobd',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Seleccione',
valueNotFoundText: 'Seleccione',
selectOnFocus:true,
editable:false,
readOnly:false,
width:janchocampocoment,
style:'margin-bottom:0px; margin-top:0px;',
listeners: {
select: function(combo, records) {
comboorg.setValue("");
jtxtusuario.setValue("");
jtxtpasswd.setValue("");
ruta = 'sss/covensol_sss_json_login.php?id=' + records.get('id_conf');
dsemp.load({url:ruta});
}
},
doForce : function(){
if((this.el.dom.value.length > 0) && (this.el.dom.value != this.emptyText)){
this.el.dom.value =
this.lastSelectionText === undefined ? '' : this.lastSelectionText;
this.applyEmptyText();
}
}
});
var dsemp = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method:'POST',
url: 'sss/covensol_sss_json_login.php?id='
}),
listeners:{
load:function(){}
},
reader: new Ext.data.JsonReader({
root: 'datos',
totalProperty: 'total',
id: 'id_conf'
}, [
{name: 'codemp'},
{name: 'nombre'}
])
});
dsemp.load();
var comboorg = new Ext.form.ComboBox({
xtype:'combo',
store: dsemp,
displayField:'nombre',
valueField:'codemp',
fieldLabel: 'Organismo',
labelAlign: 'right',
name:'cmbcomboorg',
id:'cmbcomboorg',
hiddenName:'hcmbcomboorg',
hiddenId:'hcmbcomboorg',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Seleccione',
valueNotFoundText: 'Seleccione',
selectOnFocus:true,
editable:true,
readOnly:false,
width:janchocampocoment,
style:'margin-bottom:0px; margin-top:0px;',
listeners: {
select: function(combo, records) {
jtxtusuario.setValue("");
jtxtpasswd.setValue("");
},
},
doForce : function(){
if((this.el.dom.value.length > 0) && (this.el.dom.value != this.emptyText)){
this.el.dom.value =
this.lastSelectionText === undefined ? '' : this.lastSelectionText;
this.applyEmptyText();
}
}
});
var f_columna = new Ext.form.Label({
labelAlign: 'center',
name: 'etqcol',
id: 'etqcol',
//html:'
',
html:'
',
width: 150
});
var jtxtusuario = new Ext.form.TextField({
enableKeyEvents: true,
id:'txtusuario',
name:'txtusuario',
fieldLabel: 'Usuario',
labelAlign: 'right',
});
jtxtusuario.on('blur', function(obj,e) {
});
jtxtusuario.on('keypress', function(obj,e) {
if(comboorg.getValue()==""){ e.stopEvent(); mensajes_ext("MENSAJE DE SISTEMA","Seleccione la Base de Datos y el Organismo o Empresa !"); return;}
key = e.getCharCode();
if(key==13){EnviaDatosLogin();}
});
var jtxtpasswd = new Ext.form.TextField({
enableKeyEvents: true,
id:'txtpasswd',
name:'txtpasswd',
fieldLabel: 'Clave',
labelAlign: 'right',
inputType:'password'
});
jtxtpasswd.on('blur', function(obj,e) {
});
jtxtpasswd.on('keypress', function(obj,e) {
if(comboorg.getValue()==""){ e.stopEvent(); mensajes_ext("MENSAJE DE SISTEMA","Seleccione la Base de Datos y el Organismo o Empresa !"); return;}
if(jtxtusuario.getValue()==""){ e.stopEvent(); mensajes_ext("MENSAJE DE SISTEMA","Introduza el Usuario"); return;}
key = e.getCharCode();
if(key==13){EnviaDatosLogin();}
});
var setcampos = new Ext.form.FieldSet({
title:'',
labelWidth : AnchoEtiqueta,
width: Ancho-10,
height: Alto-40,
cls :'fondo',
style:'margin-bottom:0px; margin-top:0px;',
//autoHeight:true,
//border:false,
defaultType: 'textfield',
items :[f_columna,combobd,comboorg,jtxtusuario,jtxtpasswd],
buttons: [{
text: 'ACEPTAR',
handler: function(){
EnviaDatosLogin();
//alert(combobd.getValue() + " - " + comboorg.getValue());
}
}]
});
var formbd = new Ext.FormPanel({
labelAlign: 'top',
frame:true,
title: 'LOGIN: SIGICOV',
bodyStyle:'padding:0px 0px 0;',
width: Ancho,
height: Alto,
labelWidth : AnchoEtiqueta,
labelAlign: 'right',
listeners:{
load:function(){}
},
//tbar: [btn_nuevoact,btn_guradaract,btn_borraract,btn_buscaract],
items: [{
layout:'column',
items:[{
columnWidth:1,
layout: 'form',
labelWidth : AnchoEtiqueta,
items: [setcampos]
}]
}]
});
formbd.render("ContPrinc");
//******************************************************************************************************
//******************************************************************************************************
//******************************************************************************************************
function EnviaDatosLogin(){
datos = new Array;
datos['id_conf'] = combobd.getValue();
datos['codemp'] = comboorg.getValue();
datos['codusu'] = jtxtusuario.getValue();
datos['pwdusu'] = jtxtpasswd.getValue();
if(datos['id_conf']==""){mensajes_ext("VALIDACIÓN DE DATOS","Seleccione la Base de Datos!"); return;}
if(datos['codemp']==""){mensajes_ext("VALIDACIÓN DE DATOS","Seleccione el Organismo o Empresa!"); return;}
if(datos['codusu']==""){mensajes_ext("VALIDACIÓN DE DATOS","Introduzca el Usuario"); return;}
if(datos['pwdusu']==""){mensajes_ext("VALIDACIÓN DE DATOS","Introduzca la clave"); return;}
strdatos = 'id_conf=' + datos['id_conf'] +
'&codemp=' + datos['codemp'] +
'&codusu=' + datos['codusu'] +
'&pwdusu=' + datos['pwdusu'];
ruta = '';
Ext.getBody().mask('Salvando Datos…', 'x-mask-loading');
enviar_ajax(strdatos,'covensol_login_ajax.php','resultados','POST','',ruta);
Ext.getBody().unmask();
}
window.funcion_respuesta = function(x){
f=document.form1;
switch(x){
case 'ir_modulos':
if(jtxtusuario.getValue()=='ADMINISTRADOR'||jtxtusuario.getValue()=='COVENSOL'){window.location.href='index_modules.php';}
else{window.location.href='index_covensol.php';}
break;
}
}
});// FIN DE Ext.onReady