

    <form id="searchUser" class="form-search"  method="post" action="<?php echo site_url('settings/user-management/users/'. $showUsers) ?>">
      <input id="searchInput" class="input-large" type="text" name="search" value="<?= isset($search) ? htmlspecialchars($search) : "" ?>" />

      <button type="submit" class="btn btn-large searchsubmit">Search</button>

      <?php
        $showUsers=isset($showUsers)?$showUsers:'internal';
        if ($showUsers!='external')
        {
            if (isActionAllowed('user.put'))
            {
        ?>
              <a data-toggle="modal" role="button" id="add_user" class="btn btn-large btn-primary" href="javascript:void(0)">Add user</a>
       <?php }
        }
      ?>
      <span class="help-block">Find user (regex)</span>
    </form>


        <!--<?php if ($this->setting_lib->if_ldap_enabled()){?>-->

        <div class="margin-bottom">
          <label class="radio inline margin-right">
            <input class="userToggle" type="radio" name="usertype" value="internal" id="showLocalUsers" checked>
            Local Users
          </label>
           <label class="radio inline">
            <input class="userToggle" type="radio" name="usertype" value="external" id="showLdapUsers">
            LDAP Users
          </label>
        </div>

        <!-- <?php }?>-->

<script type="text/javascript">
    $( document ).ready(function() {
        $('#add_user').click(function() {
            $("<div></div>")
                .dialog_modal({
                    passedArgs: ['', [],
                        {
                            header: "<h2>Add new user</h2>",
                            body_url: MP_SITE_URL + '/auth/create_user'
                        }],
                    addBodyClass: 'form-buttons'
                })
        })

        $('.userToggle').click(function(){

          var url = "<?php echo site_url('settings/user-management') ?>";
          var rows = "<?php echo $number_of_rows ?>";
          url = url+"/users/"+ this.value +"/rows/" + rows;

          $("#searchUser").attr("action", url);
          $('#searchUser').submit();

          common.globalSpinner.show();
        });

        if("<?php echo $showUsers ?>") {
          $('input:radio[name=usertype]').filter('[value="<?= htmlspecialchars($showUsers) ?>"]').attr('checked',true);
        }



    });
</script>
