function userDelete(id) {
  event.preventDefault();
  Swal.fire({
      title: 'Brisanje korisnika',
      text: "Nećete moći poništiti ovu akciju!",
      icon: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085D6',
      cancelButtonColor: '#D33',
      confirmButtonText: 'Da, obriši',
      cancelButtonText: 'Poništi'
  }).then((result) => {
      if (result.isConfirmed) {
        var idTag = id;
        var url = "helpers/delete-user.php";
        var params = "id="+idTag;
        var xhr = new XMLHttpRequest();
        xhr.open("GET", url+"?"+params, true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
            }
        };
        xhr.send();
        Swal.fire(
          'Obrisano!',
          'Korisnik je obrisan.',
          'success'
        ).then((result) => {
          if (result.isConfirmed) {
              location.reload();
          }
        })
      }
  })
}

function userAdmin(id) {
  Swal.fire({
    title: 'Izmjena prava',
    text: "Izmijeniti prava za korisnika?",
    icon: 'question',
    showCancelButton: true,
    confirmButtonColor: '#3085D6',
    cancelButtonColor: '#D33',
    confirmButtonText: 'Da, izmijeni',
    cancelButtonText: 'Poništi'
  }).then((result) => {
      if (result.isConfirmed) {
        var idTag = id;
        var url = "helpers/change-admin.php";
        var params = "id="+idTag;
        var xhr = new XMLHttpRequest();
        xhr.open("GET", url+"?"+params, true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
            }
        };
        xhr.send();
        Swal.fire(
          'Izmijenjeno!',
          'Prava su ažurirana.',
          'success'
        ).then((result) => {
          if (result.isConfirmed) {
              location.reload();
          }
        })
      }
  })
}
