<?php 

require_once("config/configDB.php"); 

require "userPermission.php";
require 'financial_year_calculation.php';


$userID = $_GET['id'];
?>
<!DOCTYPE html>
<html>
<head>
    
<?php 
        require 'meta.php';  
        require 'header.php'; 
    ?>
    
    <style>
    .dataTables_length, 
    .dataTables_filter, 
    .dataTables_info,
    .dataTables_paginate  {
        display:none;
    }
    </style>
</head>
<body>
    <?php require 'menu.php' ?>
<!-- <div class="container-fluid">
    <form class="form-horizontal" action="productsalepriceInsert.php" method="post">
 
 

</form>   
</div> -->
<input type="hidden" value="<?php echo $_GET['id'] ?>" name="userid">

<div class="container-fluid col-sm-10 table-responsive">

<!-- productcode, productname, purchase_rate, gst, hsn_code,prodct_description, create_date -->

<table id="userPermissonDashboard" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
        <caption ><h2>User Permission Dashboards</h2></caption>
        <thead>
            <tr>
                <th>Files Name</th>
                <th>View/Show </th>
                <th>Add</th>
                <th>Edit</th>
                <th>Delete </th>
                <th>Print</th>
                <th>ExcleFormat</th>
            </tr>
        </thead>
        <tbody>

                    
           
        </tbody>
       
    </table>
    
</div>





    <?php require 'footer.php' ?>
    <script type="text/javascript">var base_url = "<?= $base_url ?>";</script>
    

    <script>
    
    $(document).ready(function() {
                   var dataTable =  $('#userPermissonDashboard').DataTable( {
                    "pageLength": 30,   
                    responsive: {
                        details: {
                            renderer: function ( api, rowIdx ) {
                            var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
                                var header = $( api.column( cell.column ).header() );
                                return  '<p style="color:#00A">'+header.text()+' : '+api.cell( cell ).data()+'</p>';
                            } ).toArray().join('');
     
                            return data ?    $('<table/>').append( data ) :    false;
                            }
                        }
                        },
                    processing: true,
                    serverSide: true,
                    aaSorting: [[0, 'asc']],
                    ajax: {
                        url :"userMasterPermissiongriddata.php",
                        type: 'POST',
                        data:  {
                            userID: "<?php echo $_GET['id']; ?>"
                        }
                    }
                    
                    
                    } );
                } );

function permissionShow(uid,datashow,uID) {
    
    $.ajax({
        url: base_url+'fetchAjaxData/updateUsersMasterpermission.php?userpid='+uid+'&showvalue='+datashow+'&uid='+uID+'&ptype=show',
        dataType: "json",
        type: 'GET',        
        success: function(data) {
        
        },
        error: function() {
            console.log('An error has occurred');
        }        
    });    
}

function permissionAdd(uid,details,uID) {
    $.ajax({
        url: base_url+'fetchAjaxData/updateUsersMasterpermission.php?userpid='+uid+'&showvalue='+details+'&uid='+uID+'&ptype=add',
        dataType: "json",
        type: 'GET',        
        success: function(data) {
        
        },
        error: function() {
            console.log('An error has occurred');
        }        
    });    
}

function permissionEdit(uid,details,uID) {
    $.ajax({
        url: base_url+'fetchAjaxData/updateUsersMasterpermission.php?userpid='+uid+'&showvalue='+details+'&uid='+uID+'&ptype=edit',
        dataType: "json",
        type: 'GET',        
        success: function(data) {
        
        },
        error: function() {
            console.log('An error has occurred');
        }        
    });    
}

function permissionDelete(uid,details,uID) {
    $.ajax({
        url: base_url+'fetchAjaxData/updateUsersMasterpermission.php?userpid='+uid+'&showvalue='+details+'&uid='+uID+'&ptype=delete',
        dataType: "json",
        type: 'GET',        
        success: function(data) {
        
        },
        error: function() {
            console.log('An error has occurred');
        }        
    });    
}

function permissionPrint(uid,details,uID) {
    $.ajax({
        url: base_url+'fetchAjaxData/updateUsersMasterpermission.php?userpid='+uid+'&showvalue='+details+'&uid='+uID+'&ptype=print',
        dataType: "json",
        type: 'GET',        
        success: function(data) {
        
        },
        error: function() {
            console.log('An error has occurred');
        }        
    });    
}

function permissionExcelFormat(uid,details,uID) {
    $.ajax({
        url: base_url+'fetchAjaxData/updateUsersMasterpermission.php?userpid='+uid+'&showvalue='+details+'&uid='+uID+'&ptype=excelformat',
        dataType: "json",
        type: 'GET',        
        success: function(data) {
        
        },
        error: function() {
            console.log('An error has occurred');
        }        
    });    
}   
    </script>
</body>
</html>