text: function delete_institution(id){
      swal({
          title: "Are you sure?",
          text: "Once deleted, you will not be able to recover this institution!",
          icon: "warning",
          buttons: true,
          dangerMode: true,
      })
          .then((willDelete) => {
          if (willDelete) {
              $.ajaxSetup({
                  headers: {
                      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                  }
              });
  
              $.ajax({
                  type: "GET",
                  url: 'institutions/delete/'+id,
                  cache: false,
                  success: function(response) {
                      if(response==1)
                      {
                          $('#'+id).remove();
                          swal("Completed! Institution has successfully been deleted!", {
                              icon: "success",
                          });
                      }
                      else
                      {
                          swal("Cancelled", "Something went wrong! Try again later.", {
                              icon: "error",
                          });
                      }
                  }
              });
          } else {
              swal("Institution is safe!");
  }
  });
  }
  
  function check_number_of_users(institution_id){
  
      $.ajaxSetup({
          headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
      });
      $.ajax({
          type: "GET",
          url: "/institutions/users/checkUsersNumber/"+institution_id,
          cache: false,
          error:function (xhr,status) {
              swal("Error", "An error occurred, please try again!.", {
                  icon: "error",
              });
          },
          success: function(response) {
              var numbersArray= response.split(';');
              if(parseInt(numbersArray[0])>parseInt(numbersArray[1])){
                  window.location.href= "institutions/users/create/"+institution_id;
              }
              else
              {
                  swal("Error", "You can not add new users based on the product purchased. Product number of users: "+parseInt(numbersArray[0]), {
                      icon: "error",
                  });
  
              }
          }
      });
  
  }
  
  function purchase_product(pid,iid,type){
  
      $.ajaxSetup({
          headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
      });
      $.ajax({
          type: "POST",
          url: 'payment/'+pid+'/'+iid+'/'+type,
          cache: false,
          success: function(response) {
              if(response)
              {
                  swal("Completed! You have successfully purchased this product!", {
                      icon: "success",
                  });
                  window.location.href= "/institutions";
  
              }
              else
              {
                  swal("Error", "Something went wrong! Try again later.", {
                      icon: "error",
                  });
              }
          }
      });
  }