//Creado con Ardora - www.webardora.net
//bajo licencia Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
//para otros usos contacte con el autor
var mydata= new Array();
$(document).ready(function(){var escollido="n9999";
$.ajax({type: "POST",dataType: "json",url: "ardoraAjaxJson.php",data: {"action": "all"},success: function(data) {if (data.length > 0) {
for (i = 0; i < data.length; i++) {var userData = getDataUser(data[i]["usr"]);if (userData["type"] != "profe" && userData["type"] != "admin") {
var dataGrid = new Array();dataGrid["id"] = data[i]["id"];;dataGrid["nome"] = userData["userName"];dataGrid["usr"] = data[i]["usr"];
dataGrid["curso"] = userData["course"];dataGrid["grupo"] = userData["group"];dataGrid["comment"] = data[i]["comment"];dataGrid["dt"] = data[i]["dt"];mydata.push(dataGrid);}}}
$("#list47").jqGrid({data:mydata,datatype: "local",height: 250,rowNum: 20,rowList: [10,20,30],
colNames:["Nº","Alumnos y alumnas:", "Nombre usuario/a","Curso","Grupo","Comentario","Fecha"],
colModel:[{name:"id",index:"id", width:30, sorttype:"int"},{name:"nome",index:"nome", width:200},{name:"usr",index:"usr", width:100},{name:"curso",index:"curso", width:50},
{name:"grupo",index:"grupo", width:50},{name:"comment",index:"comment",sorttype:"text",width:320},{name:"dt",index:"dt",  sorttype: "date",width:100}],
pager: "#plist47",sortname: "nome",viewrecords: true,loadonce: true,editurl:"",caption: "Trabajo del alumnado",
onSelectRow: function(){$("#list47").jqGrid("setGridParam", {editurl: "ardoraAjaxJson.php"});}});
$("#list47").jqGrid("navGrid", "#plist47", {add: false,del: true,refresh: true,edit: false,search: true},{},{},
{mtype: "post",width: "530px",reloadAfterSubmit: false,onclickSubmit: function (rp_ge,postdata) {var gr = jQuery("#list47").jqGrid("getGridParam", "selrow");
var nome = jQuery("#list47").jqGrid("getCell", gr, "usr");var idJ=jQuery("#list47").jqGrid("getCell", gr, "id");delJob(nome,idJ);}},
{},{});}});});
function delJob(userJob,idJob){$.ajax({type:"POST",dataType:"json",async:false,url: "deleComment.php",data: {"id": idJob,"user": userJob}});self.close();}
function getDataUser(user){var vec = new Array(); $.ajax({
type: "POST",dataType: "json",async: false,url: "ardoraAjaxJson.php",data: {"action": "getDataUser","author": user},
success: function(data) {vec=data;}});return vec;}
