jQuery(document).ready(function($) {
	$.extend({
		getLatestUsers: function(option) {
			$.ajax({
			    type: 'POST',
			    url: 'contents/plugins/eedu_portal/ajax.php',
			    data: {action: 'get_latest_users', people: option.people},
			}).done(function(data){
				try {
					data = JSON.parse(data);
					var container = $("#latest-"+option.people);
					$(container).html("");
					for(var key in data.latest) {
						var html = '<li><img class="img-72" src="';
						html += data.latest[key].profile_picture;
						html += '" alt="User Image"><a class="users-list-name" href="';
						if(option.people == 'students') {
							html += 'student-';
						}
						html += 'profile?id='+data.latest[key].id+'">';
						html += data.latest[key].surname+" "+data.latest[key].other_names;
						html += '</a><span class="users-list-date">';
						html += data.latest[key].date_created;
						html += '</span></li>';
						$(container).append(html);
					}
					if(option.people == 'staff') {
						$.getLatestUsers({people: 'students'});
					}
				}
				catch(err) {
					console.log(err);
					console.log(data);
				}
				finally {
					console.log(data);
				}
			});
		}
	})

	$.getLatestUsers({people: 'staff'});
})