// JavaScript Document
// JavaScript Document
$(document).ready(function(){
$('[name=adjuntar]').live("click",function(){
var $dialog = get_ajax_dialog();
$dialog.dialog({
modal: true,
title: 'Adjuntar Recursos a Tarea',
width: '700px',
//Destroy on close. Required for some stacked modal functionality
close: function(ev, ui) {
$(this).remove();
}
});
//La ventana esta creada, ahora hay que cargar por AJAX los datos
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: './modajax/add_recurso_tarea.php',
success:function(datos)
{
$dialog.html('');
$dialog.append(datos);
},
timeout:12000,
error:function(){
$dialog.html('
Ha ocurrido un problema, si el error persiste contacte con el administrador
');
}
});
});
//Paginación con AJAX
$("[name=paginacionajax2]").live('click',function(e) {
e.preventDefault();
//la id esta en la forma pag1 pag2 pag3
var myid = $(this).attr("id");
var laid = myid.substring(4);
//alert(laid);
var pgn=$("#pgn1").attr("value");
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"pgn="+laid+"&op=actualiza",
beforeSend:function()
{
var x=$("#paginacion-content2");
x.html('');
},
success:function(datos){
$("#paginacion-content2").html(datos);
},
timeout:12000,
error:function(datos){
$("#paginacion-content2").html('Ha ocurrido un problema, por favor recarge la página
');
}
});
return false;
});
$('#creartarea').click(function(){
var $dialog = get_ajax_dialog();
$dialog.dialog({
modal: false,
title: 'Crear mi propia Tarea',
width: '300',
height: '270',
resizable: false,
//Destroy on close. Required for some stacked modal functionality
close: function(ev, ui) {
$(this).remove();
}
});
//La ventana esta creada, ahora hay que cargar por AJAX los datos
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=creatarea",
success:function(datos)
{
$dialog.html(datos);
$('#fecha_tarea').datepicker({dateFormat: 'yy-mm-dd'});
},
timeout:15000,
error:function()
{
$dialog.append('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
});
//Evento del boton enviar
$("[name=reporte]").live('click',function() {
var myid = $(this).attr("id");
var tmp = myid.split('-');
var idtarea = tmp[1];
var minombre = $('#Ntare'+idtarea).html();
var $dialog = get_ajax_dialog();
$dialog.dialog({
modal: false,
title: 'Reporte sobre - '+minombre,
width: '330',
height: '450',
resizable: false,
//Destroy on close. Required for some stacked modal functionality
close: function(ev, ui) {
$(this).remove();
}
});
$dialog.css({padding:0})
//La ventana esta creada, ahora hay que cargar por AJAX los datos
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=abrereporte&idtarea="+idtarea,
success:function(datos)
{
$dialog.append(datos);
$('#report').keydown(function(event){
if (event.which == 13) {
//Tenemos que guardar el reporte
event.preventDefault();
var reporte = $(this).attr('value');
$('#report').attr('value','');
reporte = reporte.replace(/€/g,'0XE282AC');
if(reporte=="")
{
alert("El reporte esta vacio");
$('#report').attr('value','');
return false;
}
else
{
var idtarea = $('#myreporte').attr('value');
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=insertreporte&idtarea="+idtarea+"&reporte="+reporte,
success:function(datos)
{
actualizareporte(idtarea);
$('#report').attr('value','');
},
timeout:15000,
error:function()
{
$dialog.append('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}
}
}); //Keydown
},
timeout:15000,
error:function()
{
$dialog.append('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
//Cada vez que hacemos click creamos el evento keydown
});
function actualizareporte(idtarea)
{
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=actreporte&idtarea="+idtarea,
success:function(datos)
{
$('#muroreporte').html(datos);
$("#muroreporte").scrollTop($("#muroreporte").scrollTop() + 3000)
},
timeout:15000,
error:function()
{
$('#muroreporte').append('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}
function checkForEnter (event) {
if (event.keyCode == 13) {
//Tenemos que guardar el reporte
var reporte = $('#idreport').attr('value');
alert("guardamos esto: "+reporte);
}
} //checkForenter
//Evento del boton enviar
$("[name=verresumen_tarea]").live('click',function() {
//La id es del tipo tarea0 tarea1 tarea2
var myid = $(this).attr("id");
var idtarea = myid.substring(5);
var minombre = $('#nombre'+idtarea).html();
var $dialog = get_ajax_dialog();
$dialog.dialog({
modal: true,
title: 'Resumen de - '+minombre,
width: '605',
height: '400',
//Destroy on close. Required for some stacked modal functionality
close: function(ev, ui) {
$(this).remove();
}
});
//La ventana esta creada, ahora hay que cargar por AJAX los datos
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=resumencerrada&idtarea="+idtarea,
success:function(datos)
{
$dialog.append(datos);
},
timeout:15000,
error:function()
{
$dialog.append('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
});
//Paginación con AJAX
$("[name=paginacionajax1]").live('click', function(e) {
e.preventDefault();
//la id esta en la forma pag1 pag2 pag3
var myid = $(this).attr("id");
var laid = myid.substring(3);
//alert(laid);
var pgn=$("#pgn1").attr("value");
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url:"./modajax/pagtareasusus.php",
data:"pgn="+laid+"&opcion=1",
beforeSend:function()
{
var x=$("#paginacion-content1");
x.html('');
},
success:function(datos){
$("#paginacion-content1").html(datos);
},
timeout:9000,
error:function()
{
$("#paginacion-content1").html('Ha ocurrido un problema en el servidor. Por favor inténtelo más tarde.Gracias');
}
});
return false;
}); //paginacion AJAX
$("[name=tiempos_tarea]").live('click',function() {
//La id es del tipo tarea0 tarea1 tarea2
var myid = $(this).attr("id");
var idtarea = myid.substring(5);
var minombre = $('#Ntare'+idtarea).html();
var loquetengo;
//La ventana esta creada, ahora hay que cargar por AJAX los datos
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=cargatiempos&idtarea="+idtarea,
beforeSend:function()
{
var x=$("#controltiempos");
loquetengo = x.html();
x.html('');
},
success:function(datos)
{
if(datos!="")
$('#controltiempos').html(datos);
else
$('#controltiempos').html(loquetengo);
},
timeout:15000,
error:function()
{
$('#controltiempos').html('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}); //Tiempos_tarea
//Boton de play
$("[name=play]").live('click',function() {
//La id es del tipo play0..
var myid = $(this).attr("id");
var idtarea = myid.substring(4);
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=play&idtarea="+idtarea,
beforeSend:function()
{
var x=$("#botonplay");
x.html('');
},
success:function(datos)
{
//Tenemos que analizar los datos que nos llegan
tmp = datos.split('-');
if(tmp[0]==1) //Todo ha ido bien
{
$('#botonplay').html('');
$('#botonpause').html('');
$('#botonstop').html('');
}
else if(tmp[0]==0)
$("#controltiempos").html('Ya existe una tarea activa');
else if(tmp[0]==2)
$("#controltiempos").html('Ha ocurrido un error, por favor inténtelo de nuevo. Gracias');
},
timeout:15000,
error:function()
{
$('#controltiempos').html('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}); //BOTON DE PLAY
//Funcion para parar las tareas
$('[name=parartarea]').live('click',function() {
//La id es del tipo stop0..
var myid = $(this).attr("id");
var idtarea = myid.substring(4);
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=stop&idtarea="+idtarea,
beforeSend:function()
{
var x=$("#botonstop");
x.html('');
},
success:function(datos)
{
//Tenemos que analizar los datos que nos llegan
tmp = datos.split('-');
if(tmp[0]==1) //Todo ha ido bien
{
$('#botonplay').html('');
$('#botonpause').html('');
$('#botonstop').html('');
}
else if(tmp[0]==2)
$("#controltiempos").html('Ha ocurrido un error, por favor inténtelo de nuevo. Gracias');
var $dialog = get_ajax_dialog();
$dialog.remove();
},
timeout:15000,
error:function()
{
$('#controltiempos').html('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}); //Funcion parar
//Boton de pause
$("[name=pause]").live('click',function() {
//La id es del tipo pause0..
var myid = $(this).attr("id");
var idtarea = myid.substring(5);
var $dialog = get_ajax_dialog();
$dialog.dialog({
modal: true,
title: 'żUna pausa?',
width: '300',
height: '200',
//Destroy on close. Required for some stacked modal functionality
close: function(ev, ui) {
$(this).remove();
}
});
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=ventanapausa&idtarea="+idtarea,
beforeSend:function()
{
$dialog.html('');
},
success:function(datos)
{
$dialog.html(datos);
},
timeout:15000,
error:function()
{
$dialog.html('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}); //BOTON DE PAUSE
//Boton de empezar pausa
$("[name=empezarpausa]").live('click',function() {
//La id es del tipo pause0..
var myid = $(this).attr("id");
var $dialog = get_ajax_dialog();
if(myid!="nada")
{
var idtarea = myid.substring(12);
var motivo = $('#motivopausa').val();
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=pause&idtarea="+idtarea+"&motivo="+motivo,
beforeSend:function()
{
$dialog.html('');
},
success:function(datos)
{
//Tenemos que analizar los datos que nos llegan
tmp = datos.split('-');
if(tmp[0]==1) //Todo ha ido bien
{
$('#botonplay').html('');
$('#botonpause').html('');
$('#botonstop').html('');
}
else if(tmp[0]==2)
$("#controltiempos").html('Ha ocurrido un error, por favor inténtelo de nuevo. Gracias');
$dialog.remove(); //Cerramos la venta que creamos para introducir el motivo de la pausa
},
timeout:15000,
error:function()
{
$dialog.html('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
} //id != nada
else
$dialog.remove(); //Cerramos la venta que creamos para introducir el motivo de la pausa
}); //EMPEZAR PAUSA
//Boton de detener pausa
$("[name=playpause]").live('click',function() {
//La id es del tipo pause0..
var myid = $(this).attr("id");
var idtarea = myid.substring(9);
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url: $(location).attr('href'),
data:"op=playpause&idtarea="+idtarea,
beforeSend:function()
{
$('#botonplay').html('');
},
success:function(datos)
{
//Tenemos que analizar los datos que nos llegan
tmp = datos.split('-');
if(tmp[0]==1) //Todo ha ido bien
{
$('#botonplay').html('');
$('#botonpause').html('');
$('#botonstop').html('');
}
else if(tmp[0]==2)
$("#controltiempos").html('Ha ocurrido un error, por favor inténtelo de nuevo. Gracias');
},
timeout:15000,
error:function()
{
$dialog.html('Ha ocurrido un problema con el servidor, por favor inténtelo más tarde. Gracias');
}
});
}); //detener PAUSA
});