Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <html>
- <head>
- <link rel="shortcut icon" href="${ctx}/images/favicon.ico" type="image/x-icon">
- <style type="text/css">
- .accept {
- background-image: url(./resources/extjs/resources/images/default/icons/fam/accept.png) !important;
- }
- .delete {
- background-image: url(./resources/extjs/resources/images/default/icons/fam/delete.png) !important;
- }
- </style>
- <link rel="stylesheet" type="text/css" href="./resources/extjs/resources/css/ext-all.css">
- <link rel="stylesheet" type="text/css" href="./resources/extjs/resources/css/ext-tca.css">
- <link rel="stylesheet" type="text/css" href="./resources/extjs/ux/gridfilters/css/GridFilters.css">
- <link rel="stylesheet" type="text/css" href="./resources/extjs/ux/gridfilters/css/RangeMenu.css">
- <script type="text/javascript" src="./resources/extjs/adapter/ext/ext-base.js"></script>
- <script type="text/javascript" src="./resources/extjs/ext-all.js"></script>
- <script type="text/javascript" src="./resources/extjs/locale/ext-lang-es.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/GridFilters.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/menu/RangeMenu.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/menu/ListMenu.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/filter/Filter.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/filter/StringFilter.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/filter/DateFilter.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/filter/ListFilter.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/filter/NumericFilter.js"></script>
- <script type="text/javascript" src="./resources/extjs/ux/gridfilters/filter/BooleanFilter.js"></script>
- <script type="text/javascript" src="./js/UsuariosServicesGrid.js"></script>
- <link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon" />
- <script type="text/javascript">
- Ext.BLANK_IMAGE_URL = './resources/extjs/resources/images/default/s.gif';
- Ext.ns('Ext.ux');
- Ext.onReady(function () {
- var win;
- var rolAutog;
- var rolAutogRest;
- var rolFe;
- var scliSeleccionado;
- var cuit;
- Ext.QuickTips.init();
- var grid = new Ext.ux.UsuariosServicesGrid({
- renderTo: 'grid',
- width: 1000,
- height: 400,
- style: 'text-align: left;',
- title: 'Detalle de Usuarios',
- aprobar: function () {
- if (this.getSelectionModel().hasSelection()) {
- var record = this.getSelectionModel().getSelected();
- // llamar a una fx para recuperar el user seleccionado y traer la lista de roles
- showDataAccept(record);
- // recuperarRoles();
- // var params = {id: record.get('id')}
- // ajaxReq('./usuarios-aprobar.html', params, 'Usuario aprobado con éxito');
- } else {
- Ext.Msg.show({
- title: 'AVISO',
- msg: 'Debe seleccionar un usuario',
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.WARNING,
- width: 350
- });
- }
- }
- ,desaprobar: function () {
- if (this.getSelectionModel().hasSelection()) {
- var record = this.getSelectionModel().getSelected();
- showDataDecline(record);
- } else {
- Ext.Msg.show({
- title: 'AVISO',
- msg: 'Debe seleccionar un usuario',
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.WARNING,
- width: 350
- });
- }
- }
- });
- var store = grid.getStore();
- store.load({
- params: {
- start: 0,
- limit: 15
- },
- callback: loaded
- });
- function loaded(r, options, success) {
- if (!success) {
- Ext.Msg.show({
- title: 'ERROR'
- , msg: 'Error buscando datos'
- , modal: true
- , icon: Ext.Msg.ERROR
- , buttons: Ext.Msg.OK
- , width: 350
- });
- return;
- }
- if (this.getCount() == 0) {
- Ext.Msg.show({
- title: 'AVISO',
- msg: 'No hay usuarios pendientes ',
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.WARNING,
- width: 350
- });
- }
- }
- function ajaxReq(url, params, successMsg) {
- var msg = Ext.MessageBox.wait('Procesando...');
- Ext.Ajax.request({
- url: url,
- method: 'POST',
- params: params,
- success: function (response) {
- msg.hide();
- var result = Ext.decode(response.responseText);
- if (result.success) {
- if (url == './usuarios-desaprobar.html'){
- Ext.Msg.show({
- title: 'CONFIRMACION',
- msg: successMsg,
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.INFO,
- fn: function(){location.reload()},
- width: 350
- });
- }
- else{
- Ext.Msg.show({
- title: 'CONFIRMACION',
- msg: successMsg,
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.INFO,
- fn: redirect,
- width: 350
- });
- }
- } else {
- Ext.Msg.show({
- title: 'ERROR',
- msg: result.errors.code,
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.ERROR,
- width: 350
- });
- }
- },
- failure: function () {
- msg.hide();
- Ext.Msg.show({
- title: 'ERROR'
- , msg: 'Error procesando datos'
- , modal: true
- , icon: Ext.Msg.ERROR
- , buttons: Ext.Msg.OK
- });
- }
- });
- }
- function showDataAccept(record) {
- if (!win) {
- rolSeleccionado = null;
- scliSeleccionado = null;
- var u_id = record.get('id');
- var u_usuario = record.get('userName');
- var u_nombre = record.get('nombre');
- var u_apellido = record.get('apellido');
- var u_email = record.get('email');
- var u_numeroDocumento = record.get('tpo_Nro_Documento');
- //aca armo el panel
- var form = new Ext.form.FormPanel({
- border: false,
- frame: true,
- width: 1000,
- height: 400,
- bodyPadding: 20,
- fieldDefaults: {
- labelAlign: 'top',
- labelWidth: 300,
- labelStyle: 'font-weight:bold'
- },
- defaults: {
- margins: '20 0 20 0'
- },
- items: [{
- xtype: 'displayfield',
- name: 'displayfield1',
- fieldLabel: 'Usuario',
- value: '<span style="color:blue;">' + u_usuario + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield2',
- fieldLabel: 'Nombre',
- value: '<span style="color:blue;">' + u_nombre + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield3',
- fieldLabel: 'Apellido',
- value: '<span style="color:blue;">' + u_apellido + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield4',
- fieldLabel: 'Email',
- value: '<span style="color:blue;">' + u_email + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield5',
- fieldLabel: 'Documento',
- value: '<span style="color:blue;">' + u_numeroDocumento + '</span>'
- }, {
- xtype: 'checkboxgroup',
- fieldLabel: 'Roles',
- columns: 3,
- allowBlank: false,
- itemId: 'Roles',
- bodyPadding: 10,
- items: [
- {
- xtype: 'checkbox',
- boxLabel: 'Autogestion',
- name: 'autogestion',
- checked: true,
- inputValue: '14',
- id: 'autogestion'
- }, {
- xtype: 'checkbox',
- boxLabel: 'Restringido',
- name: 'restringido',
- inputValue: '38',
- id: 'restringido'
- }, {
- xtype: 'checkbox',
- boxLabel: 'Factura Electronica',
- name: 'fe',
- inputValue: '57',
- id: 'fe',
- handler: function () {
- if (Ext.getCmp('fe').checked) {
- Ext.getCmp('cuit').enable();
- Ext.getCmp('botonCuit').enable();
- Ext.getCmp('confirmar').disable();
- } else {
- Ext.getCmp('cuit').disable();
- Ext.getCmp('botonCuit').disable();
- Ext.getCmp('confirmar').enable();
- }
- }
- }
- ]
- }, {
- xtype: 'container',
- layout: 'hbox',
- fieldLabel: 'Cuit Cliente',
- id: 'containerCuit',
- items: [{
- xtype: 'textfield',
- width: 200,
- id: 'cuit',
- allowBlank: false
- }, {
- xtype: 'button',
- text: 'Buscar',
- id: 'botonCuit',
- handler: function () {
- cuit = document.getElementById("cuit");
- if (cuit.value.length > 0 && cuit.value.length == 11) {
- cuit = cuit.value;
- var paramCuit = { cuit: cuit };
- var respuesta = ajaxReqCliente('./buscarCliente.html', paramCuit, 'Cliente encontrado');
- Ext.getCmp('confirmar').enable();
- } else {
- Ext.getCmp('confirmar').disable();
- Ext.Msg.show({
- title: 'ERROR',
- // msg: result.errors.code,
- msg: 'Verifique la longitud del Cuit ingresado',
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.ERROR,
- width: 350
- });
- }
- }
- }]
- }, {
- xtype: 'container',
- layout: 'hbox',
- fieldLabel: 'Nombre Cliente',
- id: 'containerNombre',
- disabled: true,
- items: [{
- xtype: 'textfield',
- width: 200,
- id: 'nombre',
- style: { textTransform: "uppercase" },
- /* TODO: Esto se usaria si necesitamos buscar por nombre y que traiga una lista
- },{
- xtype: 'button',
- text: 'Buscar',
- handler: function() {
- var nombre = document.getElementById("nombre").value;
- var paramNombre = {nombre: nombre};
- var respuesta=ajaxReqCliente('./buscarCliente.html', paramNombre, 'Cliente encontrado');
- } */
- }]
- }
- ]
- });
- //aca lo confirma
- var win = new Ext.Window({
- title: 'Ud. va a procesar la aprobación del siguiente usuario'
- , modal: true
- , resizable: false
- , closable: false
- , width: 400
- , height: 350
- , items: form
- , renderTo: Ext.getBody()
- , layout: 'fit',
- buttons: [{
- text: 'Confirmar',
- id: 'confirmar',
- handler: function () {
- var params = { id: record.get('id') };
- if (document.getElementById("autogestion").checked) {
- rolAutog = document.getElementById("autogestion").value;
- params.rolAutog = rolAutog;
- }
- if (document.getElementById("restringido").checked) {
- rolAutogRest = document.getElementById("restringido").value;
- params.rolAutogRest = rolAutogRest;
- }
- if (document.getElementById("fe").checked) {
- rolFe = document.getElementById("fe").value;
- params.rolFe = rolFe;
- params.scli = scliSeleccionado;
- }
- var respuesta = ajaxReq('./usuarios-aprobar.html', params, 'Usuario aprobado con éxito');
- }
- }, {
- text: 'Cancelar',
- handler: function () {
- win.close();
- }
- }]
- });
- }
- Ext.getCmp('cuit').disable();
- Ext.getCmp('botonCuit').disable();
- win.show();
- }
- function showDataDecline(record){
- if (!win) {
- rolSeleccionado = null;
- scliSeleccionado = null;
- var u_id = record.get('id');
- var u_usuario = record.get('userName');
- var u_nombre = record.get('nombre');
- var u_apellido = record.get('apellido');
- var u_email = record.get('email');
- var u_numeroDocumento = record.get('tpo_Nro_Documento');
- //aca armo el panel
- var form = new Ext.form.FormPanel({
- border: false,
- frame: true,
- width: 1000,
- height: 400,
- bodyPadding: 20,
- fieldDefaults: {
- labelAlign: 'top',
- labelWidth: 300,
- labelStyle: 'font-weight:bold'
- },
- defaults: {
- margins: '20 0 20 0'
- },
- items: [{
- xtype: 'displayfield',
- name: 'displayfield1',
- fieldLabel: 'Usuario',
- value: '<span style="color:blue;">' + u_usuario + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield2',
- fieldLabel: 'Nombre',
- value: '<span style="color:blue;">' + u_nombre + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield3',
- fieldLabel: 'Apellido',
- value: '<span style="color:blue;">' + u_apellido + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield4',
- fieldLabel: 'Email',
- value: '<span style="color:blue;">' + u_email + '</span>'
- }, {
- xtype: 'displayfield',
- name: 'displayfield5',
- fieldLabel: 'Documento',
- value: '<span style="color:blue;">' + u_numeroDocumento + '</span>'
- }
- ]
- });
- //aca lo desaprueba
- var win = new Ext.Window({
- title: 'Ud. va a procesar la DESAPROBACIÓN del siguiente usuario'
- , modal: true
- , resizable: false
- , closable: false
- , width: 400
- , height: 200
- , items: form
- , renderTo: Ext.getBody()
- , layout: 'fit',
- buttons: [{
- text: 'Confirmar',
- id: 'confirmar',
- handler: function () {
- var params = { id: record.get('id') };
- var respuesta = ajaxReq('./usuarios-desaprobar.html', params, 'Usuario desaprobado con éxito');
- }
- }, {
- text: 'Cancelar',
- handler: function () {
- win.close();
- }
- }]
- });
- }
- win.show();
- }
- function redirect() {
- var record = grid.getSelectionModel().getSelected();
- var url = '/autogestion/tca-autogestion-web/admin/gestionarCliente.html?COD_GESTOR=' + record.get('userName') + '&aprobado=OK';
- document.location.href = url;
- }
- function ajaxReqCliente(url, params, successMsg) {
- var msg = Ext.MessageBox.wait('Buscando...');
- Ext.Ajax.request({
- url: url,
- method: 'POST',
- params: params,
- success: function (response) {
- msg.hide();
- var result = Ext.decode(response.responseText);
- if (result.success) {
- //vino un solo objeto
- // alert(result.data.numeroDocumento);
- // alert(result.data.nombre);
- document.getElementById("nombre").value = result.data.nombre;
- scliSeleccionado = result.data.scli;
- } else {
- Ext.Msg.show({
- title: 'ERROR',
- // msg: result.errors.code,
- msg: 'Error al buscar el cliente',
- buttons: Ext.Msg.OK,
- icon: Ext.Msg.ERROR,
- width: 350
- });
- }
- },
- failure: function () {
- msg.hide();
- Ext.Msg.show({
- title: 'ERROR'
- , msg: 'Error procesando datos'
- , modal: true
- , icon: Ext.Msg.ERROR
- , buttons: Ext.Msg.OK
- });
- }
- });
- }
- /* function validateCuit(value) {
- if(cuit.value.length > 0 && cuit.value.length == 11 ){
- return true;
- }else{
- return false;
- }
- } */
- });
- </script>
- </head>
- <body>
- <div id="grid" align="center"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement