root/controlies/www/users/index.html @ 96
61 | manumora | ||
70 | manumora | <!-- Libreria Multiselect -->
|
|
<link rel="stylesheet" type="text/css" href="js/multiselect/jquery.multiselect.css" />
|
|||
<script language="javascript" src="js/multiselect/jquery.multiselect.min.js"></script>
|
|||
<script language="javascript" src="js/multiselect/jquery.multiselect.es.js"></script>
|
|||
61 | manumora | ||
70 | manumora | ||
61 | manumora | <script language="javascript">
|
|
$(function() {
|
|||
$("#dialog-confirm").dialog({ autoOpen: false });
|
|||
$("#dialog-alert").dialog({ autoOpen: false });
|
|||
});
|
|||
function print_grid(){
|
|||
$("#list").jqGrid({
|
|||
url:'users?action=list',
|
|||
mtype:'POST',
|
|||
datatype: "json",
|
|||
colNames:['Tipo Usuario','Nombre','Usuario','ID usuario','ID Grupo','Identificación'],
|
|||
colModel:[
|
|||
{name:'type',index:'type', width:60, align:"center", stype:'select', editoptions:{value:":Todo;Profesor:Profesores;Alumno:Alumnos"}},
|
|||
{name:'cn',index:'cn', width:140, align:"left"},
|
|||
{name:'uid',index:'uid', width:90, align:"center"},
|
|||
{name:'uidNumber',index:'uidNumber', width:70, align:"center"},
|
|||
{name:'gidNumber',index:'gidNumber', width:70, align:"center"},
|
|||
{name:'employeeNumber',index:'employeeNumber', width:80, align:"center"}
|
|||
],
|
|||
rowNum:25,
|
|||
height:335,
|
|||
89 | manumora | width: 900,
|
|
61 | manumora | rowList:[25,50,75],
|
|
pager: '#pager',
|
|||
sortname: 'cn',
|
|||
autowidth: false,
|
|||
viewrecords: true,
|
|||
sortorder: "desc",
|
|||
caption:"Usuarios"
|
|||
});
|
|||
$("#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 (){
|
|||
modifyRecord();
|
|||
}
|
|||
});
|
|||
$("#list").jqGrid('navButtonAdd','#pager',{
|
|||
caption: "Borrar",
|
|||
buttonicon :'ui-icon-trash',
|
|||
onClickButton : function (){
|
|||
deleteRecord();
|
|||
}
|
|||
});
|
|||
$("#list").jqGrid('filterToolbar');
|
|||
}
|
|||
function rowSelected(){
|
|||
var uid = $("#list").jqGrid('getGridParam','selrow');
|
|||
if( uid == null ){
|
|||
$( "#dialog-alert" ).dialog({
|
|||
resizable: false,
|
|||
height:150,
|
|||
width:290,
|
|||
modal: true,
|
|||
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
|
|||
}).dialog('open');
|
|||
return false;
|
|||
}
|
|||
return uid;
|
|||
}
|
|||
function addRecord(){
|
|||
84 | manumora | $("#messageLoading").show();
|
|
$("#dialog-form").html("").css("display","none");;
|
|||
61 | manumora | $("#dialog-form").load("users/form.html", function() {
|
|
64 | manumora | getAllGroups();
|
|
61 | manumora | $("#form_data #action").val("add");
|
|
84 | manumora | $("#form_data #messageForm").html("Todos los campos son obligatorios");
|
|
61 | manumora | ||
84 | manumora | x = ($(window).width()-300)/2;
|
|
y = ($(window).height()-500)/2;
|
|||
61 | manumora | ||
84 | manumora | $("#messageLoading").hide();
|
|
$("#dialog-form").dialog({
|
|||
resizable: false,
|
|||
position: top,
|
|||
modal: true,
|
|||
width: 300,
|
|||
title: "Añadir Usuario"
|
|||
}).dialog('option', 'position', [x, y]);
|
|||
});
|
|||
61 | manumora | }
|
|
function modifyRecord(){
|
|||
var uid;
|
|||
84 | manumora | ||
$("#messageLoading").show();
|
|||
61 | manumora | ||
var uid = rowSelected();
|
|||
if(uid==false)
|
|||
return false;
|
|||
84 | manumora | $("#dialog-form").html("").css("display","none");
|
|
61 | manumora | $("#dialog-form").load("users/form.html", function() {
|
|
62 | manumora | ||
64 | manumora | getAllGroups();
|
|
62 | manumora | ||
61 | manumora | $("#form_data #action").val("modify");
|
|
$("#form_data #user").attr("readonly","true");
|
|||
$("#form_data #user").css("background-color","#DDD");
|
|||
$("#form_data #messageForm").html("Si deja la contraseña en blanco no se modificará<br>El resto de campos son obligatorios");
|
|||
$.post('users', 'action=getUserData&user='+uid, function(data) {
|
|||
var result = $.parseJSON(data);
|
|||
62 | manumora | ||
if(result.response['type']=="teacher")
|
|||
var textType = "Profesor";
|
|||
else
|
|||
var textType = "Alumno";
|
|||
63 | manumora | ||
var dep = Array(result.response['groups']['departments']);
|
|||
62 | manumora | ||
$("#form_data #type").replaceWith(textType+"<input type='hidden' id='type' name='type' value='"+result.response['type']+"'/>");
|
|||
61 | manumora | $("#form_data #name").val(result.response['name']);
|
|
62 | manumora | $("#form_data #nif").val(result.response['nif']);
|
|
61 | manumora | $("#form_data #user").val(result.response['user']);
|
|
$("#form_data #surname").val(result.response['surname']);
|
|||
82 | manumora | ||
$("#form_data #photo").attr("src","data:image/png;base64,"+result.response['photo']);
|
|||
63 | manumora | ||
62 | manumora | $.each(result.response['groups']['departments'], function(i, l){
|
|
63 | manumora | $('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
|
62 | manumora | });
|
|
63 | manumora | ||
$.each(result.response['groups']['classrooms'], function(i, l){
|
|||
$('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
|||
});
|
|||
84 | manumora | ||
x = ($(window).width()-300)/2;
|
|||
y = ($(window).height()-500)/2;
|
|||
$("#messageLoading").hide();
|
|||
$("#dialog-form").dialog({
|
|||
resizable: false,
|
|||
modal: true,
|
|||
width: 300,
|
|||
title: "Modificar Usuario"
|
|||
}).dialog('option', 'position', [x, y]);
|
|||
61 | manumora | });
|
|
});
|
|||
}
|
|||
function deleteRecord(){
|
|||
var uid = rowSelected();
|
|||
if(uid==false)
|
|||
return false;
|
|||
$( "#dialog-confirm" ).dialog({
|
|||
resizable: false,
|
|||
height:160,
|
|||
width:350,
|
|||
modal: true,
|
|||
buttons: {
|
|||
"Borrar": function() {
|
|||
$.post("users","user="+uid+"&action=delete", function(data){
|
|||
$("#dialog-confirm").dialog( "close" );
|
|||
$("#list").trigger("reloadGrid");
|
|||
});
|
|||
},
|
|||
"Cancelar": function() {
|
|||
$(this).dialog( "close" );
|
|||
}
|
|||
}
|
|||
}).dialog('open');
|
|||
}
|
|||
64 | manumora | ||
function getAllGroups(){
|
|||
$.post('groups','action=getAllGroups', function(data) {
|
|||
var groups = $.parseJSON(data);
|
|||
$.each( groups.departments, function(i, l){
|
|||
$("#form_data #departments").append("<option value='"+l+"'>"+l+"</option>");
|
|||
});
|
|||
$.each( groups.classrooms, function(i, l){
|
|||
$("#form_data #classrooms").append("<option value='"+l+"'>"+l+"</option>");
|
|||
});
|
|||
$("#form_data #departments").multiselect();
|
|||
$("#form_data #classrooms").multiselect();
|
|||
});
|
|||
}
|
|||
61 | manumora | </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>
|