Last active
November 6, 2019 23:36
-
-
Save AdriC1705/fd2e57eb3472201192a163bf9ca6c702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('li#padre:not(:first-child)').on('click', function(){ | |
var user = $(this).attr('idusuario'); | |
console.log(user); | |
Organigrama(user); | |
}); | |
function Organigrama (user) { | |
$.ajax({ | |
type: "GET", | |
url: "../public/getChilds", | |
data: ({user:user, 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}), | |
contentType: "application/json", | |
dataType: "json", | |
success: function(response){ | |
$.each(response.base, function(i,item){ | |
$('ul.empleados').empty(); | |
$('<div class="title title-'+item.id+'" style="margin-left: 112px; margin-top: -35px;" iduser="'+item.id+'">').insertAfter($('.organigrama .title')).text(item.name+' '+item.last_name); | |
$('.title-'+item.id).append('<br><span>'+item.depto+'</span>'); | |
$('ul.empleados').append('<li idusuario='+item.id+' id="padre" class="link link-'+item.id+'">'); | |
$('li.link-'+item.id).append($('<img>').attr('src','../public'+item.image).attr('class', 'pp')).append($('<div class="data">'+item.name+' '+item.last_name+'<br><span>'+item.depto+'</span></div>')); | |
}); | |
$.each(response.data, function(i,item){ | |
if(item.parent == 1){ | |
$('ul.empleados').append('<li idusuario='+item.id+' id="padre" class="link link-'+item.id+'">'); | |
$('li.link-'+item.id).append($('<img>').attr('src','../public'+item.image).attr('class', 'pp')).append($('<div class="data">'+item.name+' '+item.last_name+'<br><span>'+item.depto+'</span></div>')); | |
}else { | |
$('ul.empleados').append('<li idusuario='+item.id+' class="">'); | |
$('li.link').append($('<img>').attr('src', '../public'+item.image).attr('class', 'pp')); | |
} | |
}); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment