<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript("deleteUsers",  "function deleteUsers(id){
    var r = confirm('Are you sure to delete this?');
        if(r==true)
        {
            jQuery.ajax({
              'type'  : 'post',
              'data'  : 'id=' + id,
              'url'  : $('#liveSite').val()+'index.php?r=users/DeleteUsers',
              'cache': false,
              'success':function(data){
                if(data=='fail'){
                    t8.error('Error while Delete');
                }else {
                    location.href=$('#liveSite').val()+'index.php?r=users/index';
       
                    t8.success('Users deleted SuccessFully');
                }
               }
            });
        }

   
};", CClientScript::POS_HEAD);
$cs = Yii::app()->getClientScript();
$baseUrl = Yii::app()->baseUrl;

$cs->registerScript("loadUsers", '
        $(document).ready(function() {

        var table_id ="#tbl_user_details";
        var table = $(table_id).DataTable({
            scrollY         : "380px",
            pageLength      : 50,
			processing: true,
            ajax: {
                url: "' . Yii::app()->createUrl('users/GetList') . '",
                type: "POST",
                cache : false,
                "data": function ( params ) {
                    params.YII_CSRF_TOKEN = "'.Yii::app()->request->csrfToken.'";
                }
            },
            serverSide:     true,
            fixedColumns:   true,
			processing: true,
        } );
    });', CClientScript::POS_HEAD);
    ?>
    <section class="panel">
        <header class="panel-heading clearfix panel-theame">
            <i class="fa fa-users"></i> USERS  
            <div class="pull-right">                      
                <button class="btn btn-sm btn-theme" onclick="loadPopupModal('users/create','Add New User','lg')"><i class="fa fa-plus"></i> ADD</button>
        </header>
        <div class="panel-body">
            <div class="custom-data-table">
                <table class="table table-hover table-bordered personal-task" id="tbl_user_details">
                    <thead>
                        <tr>
                            <th>Username</th>
                            <th>Name</th>
                            <th>Usergroup</th>
                            <th>Status</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </section>
