// JavaScript Document
//FUNCTION: SYSTEM EXIT FUNCTION
var loadFn_Exit = function(){
Ext.MessageBox.show({
title:'Salir de Trámites en Línea - SATCON',
msg: '¿Está seguro que desea salir del sistema?',
buttons: Ext.MessageBox.YESNO,
fn:function(btn, text){
if (btn == 'yes'){
location.href='index.php';
}
},
icon: Ext.MessageBox.QUESTION
});
};
var maskingAjax = new Ext.data.Connection({
listeners: {
'beforerequest': {
fn: function(con, opt){
Ext.get(document.body).mask('Consulatnado... un momento');
},
scope: this
},
'requestcomplete': {
fn: function(con, res, opt){
Ext.get(document.body).unmask();
},
scope: this
},
'requestexception': {
fn: function(con, res, opt){
Ext.get(document.body).unmask();
},
scope: this
}
}});
//SYSTEM REGISTRO DE NACIONALES FUNCTION SEARCH
var PresidentsDataStore; // this will be our datastore
var PresidentsColumnModel; // this will be our columnmodel
var PresidentListingEditorGrid;
var PresidentListingSelectedRow;
function onPresidentListingEditorGridContextMenu(grid, rowIndex, e) {
e.stopEvent();
var coords = e.getXY();
PresidentListingContextMenu.rowRecord = grid.store.getAt(rowIndex);
grid.selModel.selectRow(rowIndex);
PresidentListingSelectedRow=rowIndex;
PresidentListingContextMenu.showAt([coords[0], coords[1]]);
}
function editRNContextMenu(){
// Ext.example.msg('Vamos a....', 'Editar RN');
loadRN(PresidentListingEditorGrid.getSelectionModel().getSelected().data.registroUnmask);
action = 'update';
Ext.getCmp('content-panel').layout.setActiveItem('registro-panel');
Ext.getCmp('registro-panel').setPosition(0,0);
Ext.getCmp('registro-panel').cardPanel.getLayout().setActiveItem(1);
//this.cardPanel.getLayout().setActiveItem(1);
//alert();
}
function printRNContextMenu(){
openWindow('RN','');
}
PresidentListingContextMenu = new Ext.menu.Menu({
id: 'PresidentListingEditorGridContextMenu',
items: [
{ text: 'Modificar', handler: editRNContextMenu },'-',
{ text: 'Imprimir', handler: printRNContextMenu }
]
});
function listSearch(){
PresidentsDataStore.reload({params: {start: 0, limit: 20}});
if ( SearchLastNameItem.getValue() != ''){
task_value ='apellido';
query_value = SearchLastNameItem.getValue()
}else if(SearchDNIItem.getValue() != ''){
task_value ='dni';
query_value = SearchDNIItem.getValue()
}else if (SearchRegisterNumberItem.getValue() != ''){
task_value ='registro';
query_value = SearchRegisterNumberItem.getValue();
}else{
task_value ='';
query_value = '';
}
// change the store parameters
if(task_value != ''){
PresidentsDataStore.baseParams = {
task : task_value,
query : query_value
};
// Cause the datastore to do another query :
PresidentsDataStore.reload({params: {start: 0, limit: 20}});
}
}
function loadFn_SearchRn() {
//Ext.get(document.getElementById('pannels')).update('
');
SearchLastNameItem = new Ext.form.TextField({
id: 'apellidoField',
fieldLabel: 'Apellidos',
maxLength: 80,
width: 300,
defaultType: 'textfield',
//anchor : '25%',
maskRe: /([a-zA-Z0-9\s]+)$/
});
SearchDNIItem = new Ext.form.TextField({
fieldLabel: 'DNI',
maxLength: 80,
width: 150,
defaultType: 'textfield',
//anchor : '25%',
maskRe: /([a-zA-Z0-9\s]+)$/
});
SearchRegisterNumberItem = new Ext.form.TextField({
fieldLabel: 'No de Registro',
maxLength: 80,
width: 150,
defaultType: 'textfield',
//anchor : '25%',
maskRe: /([a-zA-Z0-9\s]+)$/
});
SearchLastNameItem.on('focus', function (){SearchDNIItem.setValue('');SearchRegisterNumberItem.setValue('');},this);
SearchDNIItem.on('focus', function (){SearchLastNameItem.setValue('');SearchRegisterNumberItem.setValue('');},this);
SearchRegisterNumberItem.on('focus', function (){SearchLastNameItem.setValue('');SearchDNIItem.setValue('');},this);
PresidentSearchForm = new Ext.FormPanel({
//width:100%,
buttonAlign: 'left',
labelWidth: 135,
height: 150,
frame:true,
border: false,
renderTo: "searchWrapper",
//title: 'Búsqueda de Registro de Nacionales',
bodyStyle:'padding:5px 5px 0',
items: [SearchLastNameItem, SearchDNIItem,SearchRegisterNumberItem], buttons: [{ text: 'Buscar', handler: listSearch }]
});
PresidentsDataStore = new Ext.data.Store({
id: 'PresidentsDataStore',
proxy: new Ext.data.HttpProxy({
url: '/includes/search/searchRn.php', // File to connect to
method: 'POST'
}),
baseParams:{task: "LISTING"}, // this parameter asks for listing
reader: new Ext.data.JsonReader({ // we tell the datastore where to get his data from
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'registroUnmask', type: 'string', mapping: 'id_regUnmask'},
{name: 'registro', type: 'string', mapping: 'id_registro_nac'},
{name: 'apellidos', type: 'string', mapping: 'apellidos'},
{name: 'nombres', type: 'string', mapping: 'dp_nombres'},
{name: 'fecha', type: 'string', mapping: 'fecha'},
{name: 'dni', type: 'string', mapping: 'ln_dni'},
{name: 'update_date', type: 'string', mapping: 'update_date'},
{name: 'update_by', type: 'string', mapping: 'update_by'},
{name: 'scan', type: 'string', mapping: 'scan'}
]),
sortInfo:{field: 'apellidos', direction: "ASC"}
});
PresidentsColumnModel = new Ext.grid.ColumnModel(
[{header: 'Registro', dataIndex: 'registro', width: 100},
{header: 'Apellidos', dataIndex: 'apellidos', width: 250},
{header: 'Nombres', dataIndex: 'nombres', width: 200},
{header: 'D.N.I.', dataIndex: 'dni'},
{header: 'Fecha Nacimiento', dataIndex: 'fecha'}
//{header: 'Fecha Ingreso', dataIndex: 'update_date', width: 140},
//{header: 'Ingresado Por', dataIndex: 'update_by', width: 185},
// {header: 'Escaneado', dataIndex: 'scan', width: 70}
]
);
PresidentsColumnModel.defaultSortable= true;
PresidentListingEditorGrid = new Ext.grid.EditorGridPanel({
id: 'PresidentListingEditorGrid',
// height:485,
store: PresidentsDataStore, // the datastore is defined here
cm: PresidentsColumnModel, // the columnmodel is defined here
enableColLock:false,
renderTo: "gridWrapper",
clicksToEdit:1,
stripeRows: 1,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: PresidentsDataStore,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2} registros',
emptyMsg: "No hay registros para mostrar"
})
});
PresidentListingEditorGrid.addListener('rowcontextmenu', onPresidentListingEditorGridContextMenu);
PresidentsDataStore.reload({params: {start: 0, limit: 20}}); // Load the data
PresidentListingEditorGrid.setHeight((Ext.getCmp('content-panel').getSize().height-177));
// Display our window
//alert(Ext.getCmp('content-panel').getSize().width);
//Ext.example.msg('Usted está....', 'Buscando en Registro de Nacionales');
}
function openWindow(section, param){
var parameters = "scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=1024,height=768,top=0%,left=0%, dependent=no";
var url = '';
switch(section){
case 'RN':
url = '/includes/printRN.php?'+param;
parameters = "scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=800,height=600,top=10%,left=15%";
break;
case 'RP':
url = '/includes/passRenovacion.php?'+param;
parameters = "scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=800,height=600,top=10%,left=15%";
break;
}
var randomnumber=Math.floor(Math.random()*11);
var name = section + '_' + randomnumber;
window.open(url, name, parameters);
}
function getAccountData(){
maskingAjax.request({
url : '/includes/actions.php' ,
params : { actions : 'getAccountData'},
method: 'GET',
success: function ( result, request) {
try {
var jsonData = Ext.util.JSON.decode(result.responseText);
//FIELDS ACCOUNT
Ext.getCmp('DNINumberCuenta').setValue(jsonData.DNINumber);
Ext.getCmp('dp_ape_patCuenta').setValue(jsonData.ape_pat);
Ext.getCmp('dp_ape_matCuenta').setValue(jsonData.ape_mat);
Ext.getCmp('dp_nombresCuenta').setValue(jsonData.nombres);
Ext.getCmp('userFieldCuenta').setValue(jsonData.usuario);
Ext.getCmp('user_emailCuenta').setValue(jsonData.email);
Ext.getCmp('passwordFieldCuenta').setValue(jsonData.password);
Ext.getCmp('passwordField2Cuenta').setValue(jsonData.password);
}
catch (err) {
Ext.MessageBox.alert('ERROR', 'Error en el sistema, datos devueltos por el servidor:
"' + err.description + '",
intente mas tarde.
'+result.responseText);
}
},
failure: function ( result, request) {
Ext.MessageBox.alert('Error', 'Erro en al buscar:
'+result.responseText);
}
});
}
//var printPasswordRenew = function(){
function printPasswordRenew(){
maskingAjax.request({
url : '/includes/actions.php' ,
headers: {'Content-Type':'content=application/xhtml+xml;charset=utf-8'},
params : {
actions: 'passwordRenew'
},
method: 'GET',
success: function ( result, request) {
if (result.responseText > 0){
//Ext.MessageBox.alert('Listo para imprimir', 'listo para imprimir');
openWindow('RP','idregnac='+result.responseText);
}else{
Ext.MessageBox.alert('No se puede imprimir', 'Debe actualizar los datos en el registro de nacionales [menu izquierdo], antes de poder imprimir este formulario');
}
},
failure: function ( result, request) {
Ext.MessageBox.alert('Error on_Failure', 'No se pudo generar el documento error: '+ result.responseText);
}
});
}
function saveDataAccount(){
maskingAjax.request({
url : '/includes/actions.php' ,
headers: {'Content-Type':'content=application/xhtml+xml;charset=utf-8'},
params : {
action: 'saveAccountData',
//DATOS DE CUENTA
user_email: Ext.getCmp('user_emailCuenta').getValue(),
userField: Ext.getCmp('userFieldCuenta').getValue(),
passwordField:Ext.getCmp('passwordField2Cuenta').getValue()
},
method: 'GET',
success: function ( result, request) {
if (result.responseText > 0){
Ext.MessageBox.alert('Cuenta actualizada', 'Su cuenta ha sido actualzada con éxito');
}else{
Ext.MessageBox.alert('Error al crear la cuenta', 'No se pudo guardar la informacion error: '+ result.responseText);
}
},
failure: function ( result, request) {
Ext.MessageBox.alert('Error on_Failure', 'No se pudo guardar la informacion error: '+ result.responseText);
}
});
}