|
<!-- Libreria JGrid -->
|
|
<link rel="stylesheet" type="text/css" media="screen" href="js/jquery/jdgrid/css/ui.jqgrid.css" />
|
|
<script src="js/jquery/jdgrid/grid.locale-sp.js" type="text/javascript"></script>
|
|
<script src="js/jquery/jdgrid/jquery.jqGrid.min.js" type="text/javascript"></script>
|
|
<script src="js/jquery/jdgrid/src/grid.common.js" type="text/javascript"></script>
|
|
<script src="js/jquery/jdgrid/src/grid.formedit.js" type="text/javascript"></script>
|
|
<script src="js/jquery/jdgrid/src/grid.custom.js" type="text/javascript"></script>
|
|
|
|
<script language="javascript">
|
|
$(function() {
|
|
$("#dialog-confirm").dialog({ autoOpen: false });
|
|
$("#dialog-alert").dialog({ autoOpen: false });
|
|
});
|
|
|
|
function print_grid(){
|
|
$("#list").jqGrid({
|
|
url:'hosts?action=list&type=ltsp',
|
|
mtype: 'POST',
|
|
datatype: "json",
|
|
colNames:['Nombre','IP','mac'],
|
|
colModel:[
|
|
{name:'cn',index:'cn', width:80, align:"center"},
|
|
{name:'ipHostNumber',index:'ipHostNumber', width:60, align:"center"},
|
|
{name:'macAddress',index:'macAddress', width:60, align:"center"}
|
|
],
|
|
rowNum:25,
|
|
height:335,
|
|
width: 800,
|
|
rowList:[25,50,75],
|
|
pager: '#pager',
|
|
sortname: 'cn',
|
|
autowidth: false,
|
|
viewrecords: true,
|
|
sortorder: "desc",
|
|
caption:"Servidores de Aula (LTSP)"
|
|
});
|
|
|
|
$("#list").jqGrid('navGrid','#pager',{add:false,edit:false,del:false,search:false,refresh:false});
|
|
$("#list").jqGrid('navButtonAdd','#pager',{
|
|
caption: "Insertar",
|
|
buttonicon :'ui-icon-plus',
|
|
onClickButton : function (){
|
|
addRecord();
|
|
}
|
|
});
|
|
$("#list").jqGrid('navButtonAdd','#pager',{
|
|
caption: "Modificar",
|
|
buttonicon :'ui-icon-pencil',
|
|
onClickButton : function (){
|
|
handleRecord('modify','Modificar Usuario');
|
|
}
|
|
});
|
|
$("#list").jqGrid('navButtonAdd','#pager',{
|
|
caption: "Borrar",
|
|
buttonicon :'ui-icon-trash',
|
|
onClickButton : function (){
|
|
deleteRecord();
|
|
}
|
|
});
|
|
|
|
$("#list").jqGrid('filterToolbar');
|
|
}
|
|
|
|
function rowSelected(){
|
|
var id = $("#list").jqGrid('getGridParam','selrow');
|
|
|
|
if( id == null ){
|
|
$( "#dialog-alert" ).dialog({
|
|
resizable: false,
|
|
height:150,
|
|
width:290,
|
|
modal: true,
|
|
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
|
|
}).dialog('open');
|
|
return false;
|
|
}
|
|
return id;
|
|
}
|
|
|
|
function handleRecord(action,title){
|
|
var id;
|
|
|
|
if(action=="modify"){
|
|
var id = rowSelected();
|
|
if(id==false)
|
|
return false;
|
|
}
|
|
|
|
|
|
$("#dialog-form").dialog({
|
|
resizable: false,
|
|
modal: true,
|
|
title: title,
|
|
open: function(event, ui) {
|
|
$("#dialog-form").html("");
|
|
$("#dialog-form").load("users/form.html", function() {
|
|
$("#form_data #action").val(action);
|
|
$("#form_data #id").val(id);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function deleteRecord(){
|
|
|
|
var id = rowSelected();
|
|
if(id==false)
|
|
return false;
|
|
|
|
$( "#dialog-confirm" ).dialog({
|
|
resizable: false,
|
|
height:160,
|
|
width:350,
|
|
modal: true,
|
|
buttons: {
|
|
"Borrar": function() {
|
|
$.post("users","idUser="+id+"&action=delete", function(data){
|
|
$( this ).dialog( "close" );
|
|
$("#list").trigger("reloadGrid");
|
|
});
|
|
},
|
|
"Cancelar": function() {
|
|
$( this ).dialog( "close" );
|
|
}
|
|
}
|
|
}).dialog('open');
|
|
}
|
|
|
|
function addRecord(){
|
|
|
|
$("#dialog-form").html("");
|
|
$("#dialog-form").load("ltsp/form.html", function() {
|
|
$("#form_data #action").val("add");
|
|
$("#form_data #messageForm").html("Todos los campos son obligatorios");
|
|
});
|
|
|
|
x = ($(window).width()-250)/2;
|
|
y = ($(window).height()-400)/2;
|
|
|
|
$("#dialog-form").dialog({
|
|
resizable: false,
|
|
position: top,
|
|
modal: true,
|
|
title: "Añadir Servidor de Aula (ltsp)"
|
|
}).dialog('option', 'position', [x, y]);
|
|
}
|
|
</script>
|
|
|
|
<div id="tabla_clientes">
|
|
<table width="100%">
|
|
<tr>
|
|
<td style="width:2%"></td>
|
|
<td><table id="list" width="100%"></table></td>
|
|
<td style="width:2%"></td>
|
|
</tr>
|
|
</table>
|
|
<div id="pager" style=""></div>
|
|
<div id="filter" style="margin-left:30%;display:none">Search Invoices</div>
|
|
</div>
|
|
|
|
<div id="dialog-form"></div>
|
|
|
|
<div id="dialog-confirm" title="¿Borrar el registro seleccionado?" style="display:none;">
|
|
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Este elemento quedará permanentemente eliminado. ¿Está seguro?</p>
|
|
</div>
|
|
|
|
<div id="dialog-alert" title="Atención" style="display:none;">
|
|
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Para operar sobre un registro debe seleccionarlo previamente.</p>
|
|
</div>
|
|
|
|
<script language="javascript"> print_grid();</script>
|