<?php
$cs = Yii::app()->getClientScript();
$baseUrl = Yii::app()->baseUrl;
$cs->registerScript("deleteStockDetails",  "function deleteStockDetails(id){
        var r = confirm('Are you sure to delete this?');
        if(r==true)
        {
            jQuery.ajax({
              'type'  : 'post',
              'data'  : 'id=' + id+'&YII_CSRF_TOKEN=".Yii::app()->request->csrfToken."',
              'url'  : $('#liveSite').val()+'index.php?r=inventoryreport/deleteStockDetails',
              'cache': false,
              'success':function(data){
                if(data=='success'){
                    reloadTable('#tbl_invreport_stock_details');
                    t8.success('YMGF_Stock Details Deleted SuccessFully');
                }else {
                    t8.error(data);
                }
               }
            });
        }
    
       
    };", CClientScript::POS_HEAD);
    $cs->registerScript("downloadRawFile", "function downloadRawFile(file){
        if(file!=''){
            window.open($('#liveSite').val()+'index.php?r=inventoryreport/downloadRawFile&file='+file, '_blank');   
        }else{
            t8.error('Please Select YMGF_Stock Details');
        }
    }", CClientScript::POS_HEAD);
$cs->registerScript("loadstock_details", '
        $(document).ready(function() {

        var table_id ="#tbl_invreport_stock_details";
        var table = $(table_id).DataTable({
            scrollY         : "380px",
           // scrollX         : "true",
           // scrollCollapse  : true,
            pageLength      : 50,
			processing: true,
            ajax: {
                url: "' . Yii::app()->createUrl('inventoryreport/GetstockList') . '",
                type: "POST",
                cache : false,
                "data": function ( params ) {
                    params.YII_CSRF_TOKEN = "'.Yii::app()->request->csrfToken.'";
                }
            },
            serverSide:     true,
            fixedColumns:   true,
			processing: true,
            fixedHeader: {
                headerOffset: $("header.main").outerHeight()
            }
        } );
        $(".dataTables_scrollFoot").hide();
    });', CClientScript::POS_HEAD);
    ?>
    <section class="panel">
        <header class="panel-heading clearfix panel-theame">
            <i class="fa fa-tasks"></i> Inventory Report - YMGF_StockDetails
            <div class="pull-right">
                <?php  //if (isset(Yii::app()->user->havePermissionOn['master_invreport_add']) ||  Yii::app()->user->authorised_user == 1) {?>

                 <button class="btn btn-sm btn-theme" onclick="loadPopupModal('inventoryreport/StockCreate','Upload YMGF_StockDetails','lg')"><i class="fa fa-arrow-up"></i> Upload</button> 
                <?php //} ?>
            </div>
        </header>
        <div class="panel-body">
            <div class="custom-data-table">
                <table class="table table-hover table-bordered personal-task" id="tbl_invreport_stock_details">
                    <thead>
                        <tr>
                            <th>Sl No</th>
                            <th>Month</th>
                            <th>Year</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
						    <th>Sl No</th>
                            <th>Month</th>
                            <th>Year</th>
                            <th>Actions</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </section>