<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript("disableUserportal", "function disableUserportal(id){
    var r = confirm('Are you sure to block this Userportal?');
        if(r==true)
        {
            jQuery.ajax({
              'type'  : 'post',
              'data'  : 'id=' + id,
              'url'  : $('#liveSite').val()+'index.php?r=Userportal/BlockUserportal',
              'cache': false,
              'success':function(data){
                if(data=='fail'){
                    t8.error('Error while Delete');
                }else {
                     reloadTable('#tbl_Userportal_details');

                    t8.success('Userportal blocked SuccessFully');
                }
               }
            });
        }


};", CClientScript::POS_HEAD);
$cs->registerScript("enableUserportal", "function enableUserportal(id){
    var r = confirm('Are you sure to unblock this Userportal?');
        if(r==true)
        {
            jQuery.ajax({
                'type'  : 'post',
                'dataType'  : 'json',
                'data'  : 'id=' + id,
                'url'  : $('#liveSite').val()+'index.php?r=Userportal/UnBlockUserportal',
                'cache': false,
                'success':function(data){
                    if(data.status=='success'){
                        reloadTable('#tbl_Userportal_details');
                        t8.success('Userportal Unblocked SuccessFully!');

                    }else {
                        t8.error('This Userportal cant be Unblocked');
                    }
                 }
            });
        }
};", CClientScript::POS_END);
 
?>

<script>
    var imageBase64Logo = null;
    $(document).ready(function () {
        var table_id = "#tbl_Userportal_details";
        table = $(table_id).on("preXhr.dt", function (e, settings, data) {
            data.display_type = $("#display_type").val();
            data.user_id = $("#user_id").val();
            data.portal_id = $("#portal_id").val();
            return data;
        }).DataTable({
            //scrollY: "450px",
            pageLength: 50,
            processing: true,
            ajax: {
                url: "<?php echo Yii::app()->createUrl('Userportal/GetList') ?>",
                type: "POST",
                cache: false,
            },
            serverSide: true,
            fixedColumns: true,
            columnDefs: [
                       {
                          //"targets": [3],"visible": false,
                       },
            ],

            "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                if ( aData[4] == "N" )  
                {  
                   $("td", nRow).addClass("bg-danger");

                }
                         
                  
            }
        });

    });
    </script>



<section class="panel" style="background-color:#F6F3EE;">
    <header class="panel-heading clearfix panel-theame">
    <i class="material-icons">dashboard</i> User Portal     
        <div class="pull-right" style="display:flex">
        &nbsp;<?php
             echo CHtml::dropdownlist('user_id', '', User::getUser(), array('class' => 'form-control', 'prompt' => '---User---', 'onChange' => 'reloadTable("#tbl_Userportal_details")'));
        ?>
        &nbsp;<?php
             echo CHtml::dropdownlist('portal_id', '',MasPortal::getPortallist(), array('class' => 'form-control', 'prompt' => '---Portal---', 'onChange' => 'reloadTable("#tbl_Userportal_details")'));
        ?>
        &nbsp;<?php //if ((isset(Yii::app()->user->havePermissionOn['mas_Userportal_add']) || Yii::app()->user->authorised_user == 1)) { ?>

            <button class="btn btn-sm btn-theme" onclick="loadPopupModal('Userportal/create', 'Add New User Portal ', 'lg')"><i class="fa fa-plus"></i> ADD</button>
       
          <?php //} ?>
            </div>
    </header>
    <div class="panel-body">
        <div class="custom-data-table">
            <table class="table table-hover table-bordered personal-task" id="tbl_Userportal_details" style="font-size:13px;">
                <thead>
                    <tr>
                        <th>SI No</th>
                        <th>User</th>
                        <th>Portal</th>
						<th>Action</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</section>
