<input type="hidden" name="frm" id="frm" value="<?php echo $frm; ?>">
<input type="hidden" name="" id="last_active_div">
<input type="hidden" name="" id="last_active_name">
<?php
$allPermissions = array();
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'masterreport-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
        ));
?>
<div class="panel-body">
<div id="rpt-submenu-lvl2" >
    <div class="panel">
        <header class="panel-heading clearfix">
            <span class="sub-menu-2" id="showSalesDiv" >
                <span class="rpt-sub-panel-title" id="span_sales_title">Reports</span>
                <span class="pull-right">
                    <select name='sel_sales' id="sel_sales" class="form-control" style="max-width: 150px;font-weight: normal;" onchange="loadMasterReportSearch(this.value, this.data - title)">
                        <option value=""  style="color: gray">Select</option>
                        <option value="filter_consolidated_supply_confirmation" data-title="Invoice List">Consolidated Supply Confirmation</option>
                         
                    </select>
                </span>
            </span>
            <div class="pull-right">
                <i class="fa fa-arrow-left back btn btn-theme btn-sm"></i>

            </div>
        </header>

        
            <div id="div_load_master_buttons"></div>
        

    </div>
</div>
<div class="panel-body">
    <div style="display:none;" id="div_master_report_load_content">
    </div>
</div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var frm = $('#frm').val();
        console.log(frm);
        if (frm == '1') {
            $('.back').addClass("hidden");
            $('#mainMenu').hide();
            $('#rpt-submenu-lvl2').show();
            $('#showSalesDiv').show();
            return false;
        }
        if (frm == '2') {
            $('.back').addClass("hidden");
            $('#mainMenu').hide();
            $('#rpt-submenu-lvl2').show();
            $('#showInventoryDiv').show();
            return false;
        }
        if (frm == '3') {
            $('.back').addClass("hidden");
            $('#mainMenu').hide();
            $('#rpt-submenu-lvl2').show();
            $('#showCustomerDiv').show();
            return false;
        }
        if (frm == '4') {
            $('.back').addClass("hidden");
            $('#mainMenu').hide();
            $('#rpt-submenu-lvl2').show();
            $('#showPurchaseDiv').show();
            return false;
        }
        if (frm == '5') {
            $('.back').addClass("hidden");
            $('#mainMenu').hide();
            $('#rpt-submenu-lvl2').show();
            $('#showFinanceDiv').show();
            return false;
        }
        if (frm == '6') {
            $('.back').addClass("hidden");
            $('#mainMenu').hide();
            $('#rpt-submenu-lvl2').show();
            $('#showHRDiv').show();
        }
        $('.master-rpt-btn').click(function () {
            var t_id = $(this).attr('data-id');
            //$('#is_hr').val(1);
            $('#mainMenu').hide();
            $('.mainHrMenu').hide();
            $('.back').removeClass("hidden");
            $(t_id).show();
            $('#div_load_master_report,#rpt-submenu-lvl2').show();
            return false;
        });
        $('.master-rpt-hr-btn').click(function () {
            //debugger;
            var t_id = $(this).attr('data-id');
            var data_name = $(this).attr('data-name').toString().toLowerCase();
            var is_hr = 0;
            if (data_name == 'hr') {
                is_hr = 1;
            }
            //$('#is_hr').val(is_hr);
            $('#mainMenu').hide();
            $('.hr_main_menu').hide();
            $('.back').removeClass("hidden");
            $(t_id).show();
            $('#div_load_master_report,#rpt-submenu-lvl2').show();
            return false;
        });

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

            if ($('#is_hr').val().toString() == "1") {
                $('.sub-menu-2 , #rpt-submenu-lvl2').hide();
                $('#div_load_master_report,#rpt-submenu-lvl2').show();
                $("#rpt-submenu-lvl2").show();
                $('#showHRDiv').show();
                if (frm == '6') {
                    $('.back').addClass("hidden");
                }
            } else {

                $('#mainMenu').show();
                $('.back').addClass("hidden");
                $('.sub-menu-2 , #rpt-submenu-lvl2').hide();
            }

            $('#div_load_master_buttons,#div_master_report_load_content').html('');

            $('.mainHrMenu').show();
            $('#is_hr').val(0);

            return false;
        });
    });
</script>


<?php $this->endWidget(); ?>
<?php
$cs = Yii::app()->getClientScript();
$baseUrl = Yii::app()->baseUrl;
$cs->registerScript("loadMasterReportSearch", "function loadMasterReportSearch(from, title)
{
console.log(from);
    $('#loader').show();
    $('#report_from').val(from);
   var from_year = $('#from_year').val(); 
        var from_month = $('#from_month').val();
        var to_year = $('#to_year').val(); 
        var to_month = $('#to_month').val();
    var pars = 'report_from='+from+'from_year='+from_year+'&from_month='+from_month+'&to_year='+to_year+'&to_month='+to_month+'&YII_CSRF_TOKEN=".Yii::app()->request->csrfToken."';
    var url = '" . Yii::app()->createUrl('reports/consolidatedsupplyconfirmationhtml') . "';
    jQuery.ajax({
        'type': 'post',
        'data': pars,
        'url': url,
        'cache': false,
        'success': function(data)
        {
            $('#loader').hide();
            $('#div_load_master_buttons').show();
            $('#span_purchase_title').html('Purchase');
            $('#span_sales_title').html('Sales');
             $('#span_inv_title').html('Inventory');
             $('#showfixed_assetdiv').html('Fixed Asset');
            $('#div_load_master_buttons').html(data);
            $('#div_master_report_load_content').hide();
        }
    });
$('#loader').hide();

}", CClientScript::POS_HEAD);
?>
<script>
    function printDiv(divName) {
        var originalContents = document.body.innerHTML;
        $("#" + divName + " .btn-theme").hide();
        var printContents = document.getElementById(divName).innerHTML;
        document.body.innerHTML = printContents;
        window.print();

        document.body.innerHTML = originalContents;
    }

</script>
<script>
    function loadMasterReport(page) {
        var par = $('form').serialize();
        var url = "index.php?r=reports/" + page;
        $.ajax({
            'url': url,
            data: par,
            'type': 'post',
            'cache': false,
            success: function (data, textStatus, jqXHR) {
                $('#loader').hide();
                $('#div_master_report_load_content').show();
                $('#div_master_report_load_content').html(data);
            },
            beforeSend: function (xhr) {
                $("#loader").show();
            },
            complete: function (jqXHR, textStatus) {
                $("#loader")
            }

        }
        );
    }
</script>