text: $( document ).ready(function() {
      $('select[name="role"]').trigger('change');
  });
  
  $('select[name="kelompok_investasi[]"]').on('change',function(){
      if ($(this).val().length == 0) {
          $('select[name="portofolio[]"]').html('');
          $('select[name="portofolio[]"]').trigger('change');
      } else {
          $.ajax({
              url: base_url()+'master/get_portofolio',
              type: 'post',
              headers: {
                  'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
              },
              data: {
                  'id': $(this).val()
              },
              dataType: 'JSON',
              success: function(data) {
                  let new_row = '';
                  let data_existed = [];
                  for (i=0;i<data.portofolio.length;i++) {
                      if (data_existed.includes(data.portofolio[i].id) === false) {
                          new_row += '<option value="'+data.portofolio[i].id+'">'+data.portofolio[i].nama_portofolio+'</option>';
                          data_existed.push(data.portofolio[i].id);
                      }
                  }
                  $('select[name="portofolio[]"]').html(new_row);
                  $('select[name="portofolio[]"]').trigger('change');
              },
              error: function(xhr) {
                  console.log(xhr)
                  Swal.fire({
                      title: 'Oops!',
                      html: 'Gagal mengambil data portofolio.<br>Silahkan ulangi memilih kelompok investasi.',
                      icon: 'error',
                      allowOutsideClick: false
                  })
              }
          })
      }
  })
  
  $('select[name="role"]').on('change',function(){
      if ($(this).val() == '2') {
          $('#info_u').removeClass('d-none');
      } else {
          $('select[name="kelompok_investasi[]"]').val('').trigger('change');
          $('select[name="portofolio[]"]').val('').trigger('change');
          $('#info_u').addClass('d-none');
      }
  })