<?php 
require_once("config/configDB.php"); 
//session_start();
require "userPermission.php";
require 'financial_year_calculation.php';
?>

<!DOCTYPE html>
<html>
<head>
    <?php 
        require 'meta.php';  
        require 'header.php'; 
    ?>
</head>
<body>
    <?php require 'menu.php' ?>

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

<?php } ?>
</div>

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

<!-- cname, city, pincode, mobile, gst_type, ccode, open_balance -->
    <div class="datatable-header ">
        <h3 class="text-center"><strong>supplier Master</strong></h3>
        <table id="supplierMasterDashboard" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
            <thead>
                <tr>				
                    <th>ID</th>
                    <th>supplier Name</th>
                    <th>Mobile</th>                    
                   <!--  <th>Address</th> 
                    <th>GSTIN</th> 
                    <th>Supplier Type</th>  -->
                    <th>Opening Balance</th> 
                                      
                    <th>Action</th>
                </tr>
            </thead>
            <tbody></tbody>
           
        </table>
    </div>

</div>



    <?php require 'footer.php' ?>
    <script type="text/javascript">var base_url = "<?= $base_url ?>";</script>
    <script>
    
$(document).ready(function() {
			   var dataTable =  $('#supplierMasterDashboard').DataTable( {
                    columnDefs: [{ "orderable": false, "targets": 4 } ],
			   	    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, 'desc']],
				//ajax: "test.js", // json datasource
				ajax: {
                    url : "supplierMastergriddata.php",
                    type: 'POST',
                    data:  {
                        userpermissionEdit   : <?php echo $supplierMaster_Edit; ?>,
                        userpermissionDelete : <?php echo $supplierMaster_Delete; ?>
                }
                }
			    } );
			} );

function ConfirmsupplierMasterDelete(supplierid) {
    //alert(supplierid);
    if(confirm('Are you sure?'))    
    {           
        console.log("Data has been Delected ");
        $.ajax({
            url: base_url+'supplierMasterDelete.php?supplierid='+supplierid,     
            dataType: "json",   
            type: 'GET',    
            success: function(data) {
                console.log("Data has been Delected "); 
                //window.location.href = "supplierMasterDashboard.php";       
            },
            error: function() {             
                console.log('An error has occurred');               
            }                   
        }); 
    }
     window.location.href = "supplierMasterDashboard.php";
}

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