<?php
$cs = Yii::app()->getClientScript();
$baseUrl = Yii::app()->baseUrl;

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

        var table_id = "#tbl_documentstorage_details";

        var table = $(table_id).DataTable({
            scrollY: "380px",
            pageLength: 50,
            processing: true,
            serverSide: true,
            fixedColumns: true,
            fixedHeader: {
                headerOffset: $("header.main").outerHeight()
            },
            ajax: {
                url: "' . Yii::app()->createUrl('documentstorage/GetListReport') . '",
                type: "POST",
                cache: false,
                data: function(params) {
                    params.YII_CSRF_TOKEN = "' . Yii::app()->request->csrfToken . '";

                    // Add filter dropdown values here:
                    params.category_id = $("#category_id").val();
                    params.document_year = $("#document_year").val();
                    params.document_month = $("#document_month").val();
                    params.document_fin_year = $("#document_fin_year").val();
                }
            }
        });

        $(".dataTables_scrollFoot").hide();

        // Trigger table reload when any filter changes
        $("#category_id, #document_year, #document_month, #document_fin_year").on("change", function() {
            table.ajax.reload();
        });

    });
', CClientScript::POS_HEAD);
?>
<section class="panel">
    <header class="panel-heading clearfix panel-theame">
        <i class="fa fa-tasks"></i> Document Download
        <div class="pull-right">
            <?php //if (isset(Yii::app()->user->havePermissionOn['master_categorytype_add']) ||  Yii::app()->user->authorised_user == 1) { ?>


            <?php //}  ?>


            <ul class="clearfix form-ul material">

                <li class="col-sm-4">
                    <?php
                    echo CHtml::dropDownList(
                            'category_id', // name attribute of the select
                            '', // selected value (can be prefilled)
                            MasDocumentCategory::getCategoryOptionGroup(0),
                            array(
                                'prompt' => 'All Category',
                                'data-label' => 'Category',
                                'data-search' => true,
                                'class' => 'form-control'
                            )
                    );
                    ?>
                </li>



                <!--                <li class="col-sm-2">
                <?php
//                    echo CHtml::dropDownList(
//                            'document_year',
//                            '',
//                            DocumentStorage::getYearList(),
//                            array(
//                                'prompt' => 'Year',
//                                'data-label' => 'Year',
//                                'data-search' => true,
//                                'class' => 'form-control'
//                            )
//                    );
                ?>
                                </li>-->
                <li class="col-sm-4">
                    <?php
                    $fin_array = DocumentStorage::getYearList();
                    foreach ($fin_array as $key => $value) {
//                        $fin_array[$key] = " April " . $key . " - March " . ($key + 1);
                        $fin_array[$key] = $key . " - " . ($key + 1);
                    }
                    echo CHtml::dropDownList('document_fin_year', "", $fin_array, array(
                        'prompt' => 'Financial Year',
                        'data-label' => 'Year',
                        'data-search' => true,
                        'class' => 'form-control'
                    ));
                    ?>
                </li>


                <li class="col-sm-3">
                    <?php
                    echo CHtml::dropDownList(
                            'document_month',
                            '',
                            DocumentStorage::getMonthList(),
                            array(
                                'prompt' => 'Month',
                                'data-label' => 'Document Month',
                                'data-search' => true,
                                'class' => 'form-control'
                            )
                    );
                    ?>
                </li>
            </ul>

        </div>
    </header>
    <div class="panel-body">
        <div class="custom-data-table">
            <table class="table table-hover table-bordered personal-task" id="tbl_documentstorage_details">
                <thead>
                    <tr>
                        <th>Sr. No</th>
                        <th>Report </th>
                        <th> Year</th>
                        <th>Month</th>
                        <th>Remarks</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th>Sr. No</th>
                        <th>Report</th>
                        <th> Year</th>
                        <th>Month</th>
                        <th>Remarks</th>
                        <th>Actions</th>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
</section>

<style>
    .material select {
        opacity: 1 !important;
    }
</style>