<?php 
require_once("config/configDB.php"); 
require "userPermission.php";

require_once("config/configDB.php");

?>
<!DOCTYPE html>
<html>
<head>
    <title>Collection Dashboard</title>
    <?php require 'header.php' ?>
    

</head>
<body>
    <?php require 'menu.php' ?>

<div class="container-fluid text-right col-sm-12 sale-dashboard-add"> 
<?php if($accOver_Add==1) {  ?>    
<a href="paypurchaseAdd.php" class="btn btn-primary">Add</a>

<?php  } ?>
</div>

<div class="container col-sm-12">

<table id="collectionDashboard" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Cash No</th>
                <th>Date</th>
                <th>Supplier Name</th>
                <th>Pending Amount</th>
                <th>Payment Type</th>
                <th>Amount</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
    <?php require 'footer.php' ?>
 <script type="text/javascript">var base_url = "<?= $base_url ?>";</script> <script type="text/javascript" language="javascript" src="js/userpermisson.js"></script>
    <script>
$(document).ready(function() {
    var dataTable =  $('#collectionDashboard').DataTable( {
        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,
        ajax: { 
            url:"paypurchasegriddata.php",
            type: 'POST',
            data:  {
                userpermissionEdit   : "<?php echo $accOver_Edit; ?>",
                userpermissionDelete : "<?php echo $accOver_Delete; ?>"
            }
        }
    });
});
function ConfirmCCDelete(ccid){	
	        if(confirm('Are you sure?'))	
	{			
		console.log("Data has been Delected ");
            $.ajax({
				url: base_url+'fetchPagesData/deletepaypurchaseGridData.php?ccid='+ccid,		
		dataType: "json",	
			type: 'GET',    
    				success: function(data) {
						
						
					
					console.log("Data has been Delected ");			
					
					
					},				
error: function() {				
	console.log('An error has occurred');				}        			
});			
        
		window.location.href = "paypurchaseDashboard.php";	
		}			    }

</script>
</body>
</html>