//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]["author"]);if (userData["type"]!="profe" && userData["type"]!="admin"){var dataGrid= new Array();
dataGrid["id"]=(i+1).toString();dataGrid["nome"]=userData["userName"];dataGrid["usuario"]=data[i]["author"];dataGrid["curso"]=userData["course"];dataGrid["grupo"]=userData["group"];
dataGrid["palabra"]=data[i]["word"];dataGrid["texto"]=data[i]["describe"];dataGrid["idP"] = data[i]["idP"];mydata.push(dataGrid);}}}
$("#list47").jqGrid({data:mydata,datatype: "local",height: 250,rowNum: 20,rowList: [10,20,30],
colNames:["Nº","Alumnos e alumnas:", "Nome usuario/a","Curso","Grupo","Palabra","Texto","id"],
colModel:[{name:"id",index:"id", width:30, sorttype:"int"},{name:"nome",index:"nome", width:200},{name:"usuario",index:"usuario", width:100},{name:"curso",index:"curso", width:50},
{name:"grupo",index:"grupo", width:50},{name:"palabra",index:"palabra", width:100},{name:"texto",index:"texto", width:300, sortable:false},{name:"idP",index:"idP", width:20, sortable:false}],
pager: "#plist47",sortname: "nome",viewrecords: true,loadonce: true,editurl:"",caption: "Entradas",
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, "usuario");var idP=jQuery("#list47").jqGrid("getCell", gr, "idP");delJob(nome.trim(),parseInt(idP)+1);}},
{},{});}});});
function delJob(userJob,wordJob){$.ajax({type:"POST",dataType:"json",async:false,url: "ardoraAjaxJson.php",data: {"action": "deleteItem","item": wordJob,"author": 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;}
