/** * BEGIN - blockUI */ //$.blockUI.defaults.message = ; $.blockUI.defaults.message = '

Espere un momento, por favor...

'; /** * END - blockUI */ /** * Variable para cambiar los dialogos de contenedor sin borrarlos */ var idContenedorDialogo = null; var componenteTabJquery="#"; /** * BEGIN - Global functions */ $(function() { $(".labelForRequired").prepend('* '); }); function reset(language) { if (language) { if (language.toLowerCase().indexOf('en') == 0) { language = ''; } $(function() { $.datepicker.setDefaults($.datepicker.regional[language]); }); } } function saveLastAccessTime() { $.ajax({ url : contextPath + '/general.action?saveLastAccessTime=', cache : false }); } function aliveSignal() { $.ajax({ url : contextPath + '/general.action?aliveSignal=', cache : false }); } function logout() { $("#appletContainer").css("visibility", "hidden"); var title = getMessageFromFieldsBundle('app.log_out'); var content = getMessageFromFieldsBundle('app.log_out_confirmation'); var url = '/authentication.action'; var params = { 'logout' : '' }; var successUrl = '/general.action'; jqDialogSalir(title, content, url, params); } function logoutDirect() { var url = '/authentication.action'; var params = { 'logout' : '' }; var successUrl = '/general.action'; $.ajax({ async : false, type : 'post', url : contextPath + buildURL(url, params), success : function(data) { window.location = 'http://www.gob.mx'; } }); } function jqAlert(content, title, icon) { var ok = getMessageFromFieldsBundle('dialog.ok'); if (icon) { content = '' + content; } var buttons = {}; buttons[ok] = function() { $(this).dialog('close'); }; var options = { //'bgiFrame' : true, 'closeOnEscape' : false, 'height' : 'auto', 'modal' : true, //'position' : 'center', 'draggable' : false, 'resizable' : false, 'show' : 'slide', 'title' : (title ? title : ''), 'overlay' : { 'backgroundColor' : '#ffffff', 'opacity' : 0.5 }, 'buttons' : buttons, open : function(event, ui) { var dialog = $(event.target).parents(".ui-dialog.ui-widget"); var buttons = dialog.find(".ui-dialog-buttonpane").find("button"); var okButton = buttons[0]; $(okButton).removeClass("ui-button"); $(okButton).removeClass("ui-widget"); $(okButton).addClass("btn btn-primary"); $(dialog).css('overflow', 'hidden'); $(dialog).css('text-align','left'); $(".ui-dialog-titlebar-close").hide(); } }; $('
').hide().append(content).dialog(options); } function jqDialog(title, content, url, params, successUrl, successParams) { var yes = getMessageFromFieldsBundle('dialog.yes'); var no = getMessageFromFieldsBundle('dialog.no'); var buttons = {}; buttons[no] = function() { $(this).dialog('close'); }; buttons[yes] = function() { $.ajax({ async : false, type : 'post', url : contextPath + buildURL(url, params), success : function(data) { if (successUrl) { window.location = contextPath + buildURL(successUrl, successParams); } } }); }; var completeContent = '' + content; $('
').hide().append(completeContent).dialog({ bgiFrame : true, closeOnEscape : false, height : 'auto', modal : true, position : 'center', draggable : false, resizable : false, title : (title ? title : ''), overlay : { backgroundColor : '#ffffff', opacity : 0.5 }, buttons : buttons, open : function() { $(this).parents('.ui-dialog-buttonpane > button:first').focus(); } }); } function jqDialogSalir(title, content, url, params) { var yes = getMessageFromFieldsBundle('dialog.yes'); var no = getMessageFromFieldsBundle('dialog.no'); var buttons = {}; buttons[yes] = function() { var contextos = getContextos().split(','); for ( var index in contextos) { $.ajax({ async : false, type : 'post', url : '/' + contextos[index] + '/authentication.action?logout=', data : {}, error : function(data, status, e) { } }); } window.location = 'http://www.gob.mx'; }; buttons[no] = function() { $(this).dialog('close'); }; var completeContent = content; //alert(completeContent); $('
').hide().append(completeContent).dialog({ //bgiFrame : true, closeOnEscape : false, height : 'auto', modal : true, //position : 'center', draggable : false, resizable : false, title : (title ? title : ''), overlay : { backgroundColor : '#ffffff', opacity : 0.5 }, buttons : buttons, /**De comenta esta funcion para cambiar la clase de botones al cerrar la sesi�n**/ // open : function() { // $(this).parents('.ui-dialog-buttonpane > button:first').focus(); // }, open : function(event, ui) { var dialog = $(event.target).parents(".ui-dialog.ui-widget"); var buttons = dialog.find(".ui-dialog-buttonpane").find("button"); var yesButton = buttons[0]; var noButton = buttons[1]; $(yesButton).removeClass("ui-button"); $(yesButton).removeClass("ui-widget"); $(yesButton).addClass("btn btn-primary"); $(noButton).removeClass("ui-button"); $(noButton).removeClass("ui-widget"); $(noButton).addClass("btn btn-default"); $(".ui-dialog .ui-dialog-buttonpane button").css("float", "right"); dialog.css('zIndex',2000); }, close:function(){ $("#appletContainer").css("visibility", "visible"); $('#iframefirma').removeClass("disBlock"); $('.y').removeClass("disBlock"); $('#iframefirma').addClass("disNone"); $('.y').addClass("disNone"); } }); $('#iframefirma').addClass("disBlock"); $('.y').addClass("disBlock"); $('.ui-dialog').css('overflow-y','hidden'); $('.ui-dialog-titlebar-close').remove(); } function buildURL(url, params) { var result = url; if (params) { if (result.substr(-1) != '/') { result = result + '?'; var index = 0; for ( var key in params) { if (index > 0) { result = result + '&'; } result = result + encodeURIComponent(key) + '=' + encodeURIComponent(params[key]); index++; } } } return result; } function cleanValue(objectId) { $(objectId).val(''); } function getMessageFromFieldsBundle(key) { var message = ''; $.ajax({ url : contextPath + '/generalMessages.action?getMessageFromFieldsBundle=', data : { key : key }, async : false, success : function(data) { message = eval(data); }, cache : true }); return message; } function getContextos(key) { var contextos = new Array(); $.ajax({ url : contextPath + '/generalMessages.action?getContextos=', data : { key : key }, async : false, success : function(data) { contextos = eval(data); }, cache : true }); return contextos; } // BEGIN - Send JQGrid information to Front controller function sendGrid(tableId, uri, javaObject) { var row; var url = ""; var ids = new Array(); // getDataIDs // obtains an array of the id's in the current grid view. Empty array if no // data is available. // Error: this obtains only the rows in the current view, we must send all // rows ids = $('#' + tableId).getDataIDs(); for ( var index in ids) { row = $('#' + tableId).getRowData(ids[index]); url += buildRowURI(javaObject, index, row); } url = contextPath + uri + '&' + url; $.ajax({ url : url, async : false, cache : false }); } //envia un vector al controller function sendGridVector(vector, uri, javaObject) { var row; var url = ""; for(index = 0;index < vector.length;index++){ row = vector[index]; url += buildRowURI(javaObject, index, row); } url = contextPath + uri + '&' + url; $.ajax({ url : url, async : false, cache : false }); } function sendGridSel(tableId, uri, javaObject) { var row; var url = ""; var ids = new Array(); // getDataIDs // obtains an array of the id's in the current grid view. Empty array if no // data is available. // Error: this obtains only the rows in the current view, we must send all // rows ids = $('#' + tableId).jqGrid('getGridParam', 'selarrrow'); for ( var index in ids) { row = $('#' + tableId).getRowData(ids[index]); url += buildRowURI(javaObject, index, row); } url = contextPath + uri + '&' + url; $.ajax({ url : url, async : false, cache : false }); } function sendGridSelEncoding(tableId, uri, javaObject) { var row; var url = ""; var ids = new Array(); // getDataIDs // obtains an array of the id's in the current grid view. Empty array if no // data is available. // Error: this obtains only the rows in the current view, we must send all // rows ids = $('#' + tableId).jqGrid('getGridParam', 'selarrrow'); for ( var index in ids) { row2 = $('#' + tableId).getRowData(ids[index]); url += buildRowURIEncoding(javaObject, index, row2); } uri = contextPath + uri; $.ajax({ type : 'POST', url : uri, data : url, async : false, cache : false, contentType: "application/x-www-form-urlencoded;charset=UTF-8", dataType : 'script' }); } function buildRowURI(javaObject, index, row) { var rowURI = ""; var item; for ( var key in row) { item = row[key]; key = key.replace(/>/g, "."); rowURI += javaObject + '[' + index + '].' + key + '=' + item + '&'; } return rowURI; } // END - Send JQGrid information to Front controller // ----------------------------------------------------------- // Suk la version de send ajax por metodo POST function sendGridEx(tableId, uri, javaObject) { var row; var url = ""; var ids = new Array(); ids = $('#' + tableId).getDataIDs(); for ( var index in ids) { row = $('#' + tableId).getRowData(ids[index]); url += buildRowURIEx(javaObject, index, row); } uri = contextPath + uri; // alert(url); $.ajax({ type : 'POST', url : uri, data : url, async : false, cache : false, dataType : 'script' }); } function buildRowURIEx(javaObject, index, row) { var rowURI = ""; var item; for ( var key in row) { if (key == 'eliminar' || key == 'select') { // El boton eliminar no se envia continue; } item = row[key]; key = key.replace(/>/g, "."); rowURI += javaObject + '[' + index + '].' + key + '=' + item + '&'; } return rowURI; } // END ---------------------------------------------------- /** * END - Global functions */ /** * BEGIN - Qtip */ $(function() { initQtip(); }); function initQtip() { $('#tablaMenuLateral a[title]').qtip({ position : { corner : { target : 'rightMiddle', tooltip : 'leftMiddle' } }, style : { name : 'dark', tip : false, border : { radius : 0, color : 'black' } }, show : { effect : { type : 'slide' } }, hide : { effect : { type : 'slide' } } }); } /** * END - Qtip */ /** * BEGIN - jqGrid */ jQuery.extend(jQuery.jgrid.defaults, { altRows : true, altclass : 'ui-state-highlight', autowidth : false, loadtext: "Cargando...", loadui: 'block', height : 'auto', caption : '', cmTemplate: { title: false }, ignoreCase : true, prmNames : { page : 'gridParams.requestedPage', /* Requested page */ rows : 'gridParams.rowsPerPage', /* Rows per page */ sort : 'gridParams.sortColumn', /* Sort column */ order : 'gridParams.sortOrder', /* Sort order */ search : 'gridParams.aSearchWasRequested', /* A search was requested? */ nd : 'nd', id : 'gridParams.id', oper : 'gridParams.operation', /* Operation name (Add, edit, delete) */ editoper : 'edit', addoper : 'add', deloper : 'del', subgridid : 'id', npage : null, totalrows : 'totalrows' } }); $(function() { $('#dependenciasSeleccionadas').jqGrid({ datatype : 'xml', xmlReader : { root : 'rows', row : 'row', page : 'reader>page', total : 'reader>total', records : 'reader>records', repeatitems : false, id : 'id' }, colNames : [ 'Select', 'Id', 'Dependencia', 'Justificaci�n' ], colModel : [ { name : 'select', sortable : 'false', formatter : 'checkbox', formatoptions : { disabled : false }, editable : 'true', edittype : 'checkbox' }, { name : 'id', index : 'id', xmlmap : 'id', hidden : true }, { name : 'dependencia', index : 'dependencia', xmlmap : 'dependencia' }, { name : 'justificacion', index : 'justificacion', xmlmap : 'justificacion' } ] }); }); $(function() { $('#mercanciaDisponible').jqGrid({ datatype : function() { }, autowidth : false, xmlReader : { root : 'rows', row : 'row', page : 'reader>page', total : 'reader>total', records : 'reader>records', repeatitems : false, id : 'id' }, colNames : [ 'Select', 'Id', 'Nombre', 'Precio', 'Cantidad' ], colModel : [ { name : 'select', sortable : 'false', formatter : 'checkbox', formatoptions : { disabled : false }, editable : 'true', edittype : 'checkbox' }, { name : 'id', index : 'id', xmlmap : 'id', hidden : true }, { name : 'nombre', index : 'nombre', xmlmap : 'nombre' }, { name : 'precio', index : 'precio', xmlmap : 'precio' }, { name : 'cantidad', index : 'cantidad', xmlmap : 'cantidad' } ] }); $('#mercanciaSeleccionada').jqGrid({ datatype : 'xml', autowidth : false, xmlReader : { root : 'rows', row : 'row', page : 'reader>page', total : 'reader>total', records : 'reader>records', repeatitems : false, id : 'id' }, colNames : [ 'Select', 'Id', 'Nombre', 'Precio', 'Cantidad' ], colModel : [ { name : 'select', sortable : 'false', formatter : 'checkbox', formatoptions : { disabled : false }, editable : 'true', edittype : 'checkbox' }, { name : 'id', index : 'id', xmlmap : 'id', hidden : true }, { name : 'nombre', index : 'nombre', xmlmap : 'nombre' }, { name : 'precio', index : 'precio', xmlmap : 'precio' }, { name : 'cantidad', index : 'cantidad', xmlmap : 'cantidad' } ] }); $('#modificarMercancia').dialog({ autoOpen : false, bgiframe : true, closeOnEscape : false, width : 'auto', height : 'auto', modal : true, position : 'center', draggable : false, resizable : false, show : 'slide', overlay : { backgroundColor : '#ffffff', opacity : 0.5 } }); $("#seccionMercanciaDisponible").accordion({ autoHeight : false, collapsible : true, active : false }); $("#tabs").tabs({ active: localStorage.getItem("currentIdx") }); $('#tabspadre').tabs(); $('#plantas').jqGrid({ url : contextPath + '/poc.action?getPlantas=', datatype : 'xml', xmlReader : { root : 'rows', row : 'row', page : 'reader>page', total : 'reader>total', records : 'reader>records', repeatitems : false, id : 'id' }, colNames : [ 'Id', 'Nombre', 'Representaci�n fiscal' ], colModel : [ { name : 'id', index : 'id', xmlmap : 'id', hidden : true }, { name : 'nombre', index : 'nombre', xmlmap : 'nombre' }, { name : 'representacionFiscal', index : 'representacionFiscal', xmlmap : 'representacionFiscal', hidden : false } ], multiselect : true, viewrecords : true, pager : '#plantasPaging', rowNum : 10, rowList : [ 10, 20, 30 ], onSelectAll : function(rowIdsArray, status) { seleccionarRF(); }, onSelectRow : function(rowId, status) { seleccionarRF(); } }); $('#plantas').jqGrid('navGrid', '#plantasPaging', { add : false, edit : false, del : false, search : false }, {}, {}, {}, {}); }); function buscarMercancia() { $.ajax({ url : contextPath + '/poc.action?obtenerMercancia=', datatype : 'xml', success : function(data) { var xmlData = eval(data); $('#mercanciaDisponible')[0].addXmlData(xmlData); } }); } function seleccionarRF() { $('select[name="representacionesFiscales"]').find('option').remove(); var selection = $('#plantas').jqGrid('getGridParam', 'selarrrow'); var row; var item; var selected = new Array(); for ( var index in selection) { row = selection[index]; item = $('#plantas').jqGrid('getRowData', row); selected.push(item['representacionFiscal']); } selected = uniqueArray(selected).sort(); $.each(selected, function(index, value) { $('select[name="representacionesFiscales"]').append( $('