eaiovnaovbqoebvqoeavibavo function reiniciar(){ $("#datos_actividades").empty(); $("#generadorA").css("display","block"); $("#cantidad_A").val(""); } function generar_inputsA(){ $("#generadorA").css("display","none"); var input = document.getElementById("cantidad_A").value; for(var i=0; iActividad ${(i+1)}


`); } } function enviar_actividad(event){ var vacio=0; var form = document.getElementById('form-actividades'); // Evitamos que el formulario se envíe event.preventDefault(); // Si el form no es valido if (!form.checkValidity()) { vacio=0; var elemento; [].forEach.call(form, (node, index) => { elemento=document.getElementById(node.id.toString()); if(node.value==="" || node.value===null || node.value==0){ if(node.name!="zona"){ try{ elemento.style.background="#ffccd5"; }catch(error){ console.log("error: "+ error); } vacio++; } } }); } if (form.checkValidity()) { vacio=0; var elemento; [].forEach.call(form, (node, index) => { elemento=document.getElementById(node.id.toString()); if(node.value==="" || node.value===null || node.value==0){ if(node.name!="cantidad_A" && node.name!="zona" && node.name!="punteo_antiguo"){ try{ elemento.style.background="#ffccd5"; vacio++; console.log(node.name); }catch(error){ console.log("error: "+ error); } } } }); } if(vacio>0){ swal({ icon: 'info', title: 'Atención', text: 'Hay campos sin completar', }); }else{ var zona = document.getElementById('zona').value; if(zona<50){ var formData= new FormData(document.getElementById('form-actividades')); formData.append('zona',zona) $('#loading-screen').css('display','block'); $.ajax({ type: "POST", url: "https://juliojodi.com/CEGSystem/Insertar/actividad", data: formData, cache: false, contentType: false, processData: false }).done(function(response){ var mensaje =JSON.parse(response); console.log(response); if(mensaje=="se pasa"){ swal({ icon: 'warning', title: 'Atención', text: '¡Las actividades que intenta crear sobrepasa los 50 puntos!', }).then(function () { location.reload(true); }); }else{ $('#loading-screen').css('display','none'); Toastify({ text: "LA PÁGINA SE ACTUALIZARÁ EN 10 SEGUNDOS, LEA LOS MENSAJES POR FAVOR", duration: 10000, close: true, gravity: "bottom", // `top` or `bottom` position: "right", // `left`, `center` or `right` stopOnFocus: true, // Prevents dismissing of toast on hover style: { background: "#1d25b8", }, onClick: function () { } // Callback after click }).showToast(); mensaje.forEach(message => { if(message.tipo=="error"){ Toastify({ text: message.mensaje, duration: 10000, close: true, gravity: "bottom", // `top` or `bottom` position: "right", // `left`, `center` or `right` stopOnFocus: true, // Prevents dismissing of toast on hover style: { background: "#db1818", }, onClick: function () { } // Callback after click }).showToast(); }else if(message.tipo=="success"){ Toastify({ text: message.mensaje, duration: 10000, close: true, gravity: "bottom", // `top` or `bottom` position: "right", // `left`, `center` or `right` stopOnFocus: true, // Prevents dismissing of toast on hover style: { background: "#0bbf59", }, onClick: function () { } // Callback after click }).showToast(); } }); setTimeout(() => { location.reload(); }, "10000"); } }); }else{ swal({ icon: 'warning', title: 'Atención', text: '¡Ya no puede crear más actividades, ha completado la zona con 50 puntos!', }).then(function () { location.reload(true); }); } } } function cargar(id){ var conteo=0; $("#cargar"+id).parents("tr").find("td").each(function(){ if(conteo==0){ document.form_actividadesA.id_actividad.value=$(this).html(); } if(conteo==1){ document.form_actividadesA.actividadA.value=$(this).html(); } if(conteo==2){ document.form_actividadesA.punteoA.value=$(this).html(); document.form_actividadesA.punteo_antiguo.value=$(this).html(); } if(conteo==3){ document.form_actividadesA.descripcion.value=$(this).html(); } if(conteo==4){ document.form_actividadesA.fecha_entrega.value=$(this).html(); } conteo++; }); } function actualizar_actividad(){ var formData= new FormData(document.getElementById('form_actividadesA')); var zona = document.getElementById("zona").value; var punteoAntiguo = document.getElementById("punteo_antiguo").value; var punteoNuevo = document.getElementById("punteoA").value; zona=zona-punteoAntiguo; console.log(zona); zona=zona+parseInt(punteoNuevo); console.log(zona + " " + punteoAntiguo+ " "+punteoNuevo); if(zona<=50){ $.ajax({ type: "POST", url: "https://juliojodi.com/CEGSystem/Modificar/actividad", data: formData, cache: false, contentType: false, processData: false }).done(function(response){ let mensaje = JSON.parse(response); if(mensaje == "success"){ $('#loading-screen').css('display','none'); swal({ icon: 'success', title: 'Atención', text: '¡Se ha actualizado correctamente!', }).then(function () { location.reload(true); }); }else{ Toastify({ text: "La actividad no pudo ser actualizada porque la cantidad de tareas alcanzó el máximo para entregar ese en la fecha seleccionada.", duration: 3000, close: true, gravity: "bottom", // `top` or `bottom` position: "right", // `left`, `center` or `right` stopOnFocus: true, // Prevents dismissing of toast on hover style: { background: "#db1818", }, onClick: function () { } // Callback after click }).showToast(); /* console.log(mensaje); */ } }); }else{ swal({ icon: 'warning', title: 'Atención', text: '¡El nuevo punteo sobrepasa los 50 puntos!', }).then(function () { location.reload(true); }); } } function actualizar_actividadI(){ var formData= new FormData(document.getElementById('form_actividadesA')); var zona = document.getElementById("zona").value; var punteoAntiguo = document.getElementById("punteo_antiguo").value; var punteoNuevo = document.getElementById("punteoA").value; zona=zona-punteoAntiguo; console.log(zona); zona=zona+parseInt(punteoNuevo); console.log(zona + " " + punteoAntiguo+ " "+punteoNuevo); if(zona<=50){ $.ajax({ type: "POST", url: "https://juliojodi.com/CEGSystem/Modificar/actividadI", data: formData, cache: false, contentType: false, processData: false }).done(function(response){ $('#loading-screen').css('display','none'); swal({ icon: 'success', title: 'Atención', text: '¡Se ha actualizado correctamente!', }).then(function () { location.reload(true); }); }); }else{ swal({ icon: 'warning', title: 'Atención', text: '¡El nuevo punteo sobrepasa los 50 puntos!', }).then(function () { location.reload(true); }); } } function mostrar_msg(id){ swal({ title: "¿Está seguro eliminar la actividad", text: "Esta acción es irreversible", icon: "warning", buttons: { confirm : {text:'Si deseo eliminarlo',className:'sweet-warning'}, cancel : 'Cancelar' }, dangerMode: true }) .then((willDelete) => { if (willDelete) { var formData= new FormData(); formData.append('id_actividad',id) $.ajax({ type: "post", url: "https://juliojodi.com/CEGSystem/Eliminar/actividad", data: formData, cache: false, contentType: false, processData: false }).done(function(response){ var mensaje = JSON.parse(response); console.log(mensaje); swal({ icon: 'success', title: 'Atención', text: 'Se ha eliminado el dato', }).then(function () { location.reload(true); }); }); } else { swal("No se eliminó el dato"); } }); } function mostrar_msgI(id){ swal({ title: "¿Está seguro eliminar la actividad", text: "Esta acción es irreversible", icon: "warning", buttons: { confirm : {text:'Si deseo eliminarlo',className:'sweet-warning'}, cancel : 'Cancelar' }, dangerMode: true }) .then((willDelete) => { if (willDelete) { var formData= new FormData(); formData.append('id_actividad',id) $.ajax({ type: "post", url: "https://juliojodi.com/CEGSystem/Eliminar/actividadI", data: formData, cache: false, contentType: false, processData: false }).done(function(response){ //var mensaje = JSON.parse(response); console.log(response); swal({ icon: 'success', title: 'Atención', text: 'Se ha eliminado el dato', }).then(function () { location.reload(true); }); }); } else { swal("No se eliminó el dato"); } }); } function enviar_actividadI(event){ var vacio=0; var form = document.getElementById('form-actividades'); // Evitamos que el formulario se envíe event.preventDefault(); // Si el form no es valido if (!form.checkValidity()) { vacio=0; var elemento; [].forEach.call(form, (node, index) => { elemento=document.getElementById(node.id.toString()); if(node.value==="" || node.value===null || node.value==0){ if(node.name!="zona"){ try{ elemento.style.background="#ffccd5"; }catch(error){ console.log("error: "+ error); } vacio++; } } }); } if (form.checkValidity()) { vacio=0; var elemento; [].forEach.call(form, (node, index) => { elemento=document.getElementById(node.id.toString()); if(node.value==="" || node.value===null || node.value==0){ if(node.name!="cantidad_A" && node.name!="zona" && node.name!="punteo_antiguo"){ try{ elemento.style.background="#ffccd5"; vacio++; console.log(node.name); }catch(error){ console.log("error: "+ error); } } } }); } if(vacio>0){ swal({ icon: 'info', title: 'Atención', text: 'Hay campos sin completar', }); }else{ var zona = document.getElementById('zona').value; if(zona<50){ var formData= new FormData(document.getElementById('form-actividades')); formData.append('zona',zona) $('#loading-screen').css('display','block'); $.ajax({ type: "POST", url: "https://juliojodi.com/CEGSystem/Insertar/actividadI", data: formData, cache: false, contentType: false, processData: false }).done(function(response){ var mensaje =JSON.parse(response); console.log(response); if(mensaje=="se pasa"){ swal({ icon: 'warning', title: 'Atención', text: '¡Las actividades que intenta crear sobrepasa los 50 puntos!', }).then(function () { location.reload(true); }); }else{ $('#loading-screen').css('display','none'); swal({ icon: 'success', title: 'Atención', text: '¡Se ha registrado correctamente!', }).then(function () { location.reload(true); }); } }); }else{ swal({ icon: 'warning', title: 'Atención', text: '¡Ya no puede crear más actividades, ha completado la zona con 50 puntos!', }).then(function () { location.reload(true); }); } } }