Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15571 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
$currentUser    = $this->currentUserHelper();

$roleName = $currentUser->getUserTypeId();

$allowDownload  = $acl->isAllowed($roleName, 'reports/users-blocked/excel') ? 1 : 0;




$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));

$this->headStyle()->captureStart();
echo <<<CSS


#tableStudents {
    display: flex;
    flex-flow: column;
    width: 100%;
}

#tableStudents thead {
    flex: 0 0 auto;
}

#tableStudents tbody {
    flex: 1 1 auto;
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
}

#tableStudents tr {
    width: 100%;
    display: table;
    table-layout: fixed;
}
CSS;
$this->headStyle()->captureEnd();



$this->inlineScript()->captureStart();
echo <<<JS
jQuery( document ).ready(function( $ ) {


    $.fn.loadData = function() {
        NProgress.start(); 
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'get',
            'url'       :  $('#form-filter').attr('action'), 
            'data'      :  $('#form-filter').serialize(),
        }).done(function(response) {
            if(response['success']) {



               $('#gridTable tbody').empty();
                if(response['data']['items']) { 
                    
                    $('#gridTable tbody').append(
                        $( "#itemRowTemplate" ).render( response['data']['items'] )
    
                    );
        
                } else {
                    $('#gridTable tbody').append(
                        $( "#itemEmptyRowTemplate" ).render([])
                    );

                }

                if(response['data']['link_download']) {
                    $('button.btn-download').data('href', response['data']['link_download']);
                    $('button.btn-download').show();

                } else {
                     $('button.btn-download').hide();
                }

            } else {
                if(jQuery.type(response['data']) == 'string') {
                    $.fn.showError(response['data']);
                } else  {
                    $.each(response['data'], function( fieldname, errors ) {
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
                    });
                }
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });
        return false;
    }


    $('button.btn-download').click(function(e) {
        e.preventDefault();
        var action   = $(this).data('href');

        NProgress.start(); 
        $.ajax({
            'dataType'  : 'json',
            'method'    : 'get',
            'url'       :  action,
        }).done(function(response) {
            if(response['success']) {
                var anchor = window.document.createElement("a");
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
                anchor.download = response['data']['basename'];
                document.body.appendChild(anchor);
                anchor.click();  // IE: "Access is denied"; see: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
                document.body.removeChild(anchor);
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            showError(textStatus);
        }).always(function() {
            NProgress.done();
        });


    });


    $('button.btn-refresh').click(function(e) {
        e.preventDefault();
        $.fn.loadData();
    

    });



    $.fn.loadData();
    $('button.btn-download').hide();
        
});
JS;
$this->inlineScript()->captureEnd();
?>

<!-- Content Header (Page header) -->
<section class="content-header">
        <div class="container-fluid">
        <div class="row mb-2">
                <div class="col-sm-12">
                <h1>LABEL_REPORTS_USERS_BLOCKED</h1>
                        </div>
                </div>
        </div><!-- /.container-fluid -->
</section>

<section class="content">
        <div class="container-fluid">
        <div class="row">
                <div class="col-12">
                                <div class="card">        
                                        <div class="card-header">
                                                <div class="col-md-12 col-sm-12">
                                <div style="float:right;">
                                    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
                                    <?php if($allowDownload) :  ?>
                                    
                                                        <button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD  </button>
                                                        <?php endif;?>
                                </div>
                        </div>
                                        </div>            
                                        <div class="card-body">
                                <table id="gridTable" class="table   table-hover">
                                <thead>
                                                        <tr>
                                                                        <th style="width: 25%">LABEL_FIRST_NAME</th>
                                                                        <th style="width: 25%">LABEL_LAST_NAME</th>
                                                                        <th style="width: 30%">LABEL_EMAIL</th>
                                                                <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>


                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                        </table>
                        </div>
                        </div>
                </div>     
        </div>          
        </div>
</section> 
  



<script id="itemRowTemplate" type="text/x-jsrender">
    <tr>
        <td style="width: 25%">
            {{>first_name}}
        </td>
        <td style="width: 25%">
             {{>last_name}}
        </td>
        <td style="width: 30%">
            {{>email}}
        </td>
        <td style="width: 30%">
            {{>last_activity_on}}
        </td>

       

    </tr> 
</script>


<script id="itemEmptyRowTemplate" type="text/x-jsrender">
    <tr>
        <td colspan="4">
            LABEL_NOT_RECORDS_FOUND
        </td>
    </tr> 
</script>