<?php require('header.php'); require("connect.php"); ?>
<style>
td.sorting_1{
    cursor:pointer;
}
</style> 
<script>

    function get_details(id,pos){
        $.ajax({
            url:'cust_details.php',
            type:'POST',
            data: {cusid: id},
            dataType:'html',
            success: function(response){
                $('#view_content').html(response);
                $('#view_info').draggable();
                $('#view_info').css({'top': pos.top})
                $('#view_info').show();
            }
        });
    }

    function episk(pos){
        $('#view_content').load('episk.php');
        $('#view_info').draggable();
        $('#view_info').css({'top': pos.top})
        $('#view_info').show();
    }

    function close_window(){
        $('#view_info').hide();
    }
</script>
 
     
<div id="view_info" class="dataTables_wrapper">
    <div id="window_bar"><div id="view_close" onclick="close_window();">X</div></div>
    <div id="view_content"></div> 
</div>

    <div class="row">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <h2>Πελάτες</h2>

                    
                </div>
                <div class="box-content">
				<!--<table class="table table-striped table-bordered  datatable responsive">-->
                <table class="table table-striped table-bordered bootstrap-datatable datatable dataTable">
                        <thead>
                        <tr>
                            
							<!--<th>Id</th>-->
							<th>Όνομα πελάτη</th>
							<th></th>
                            
                           
                        </tr>
                        </thead>
						<tbody>
						
						<?php
					$query = "Select customers_id,customers_lastname from customers";
					$result = mysqli_query($dbC,$query) or die(mysqli_error());
					$y=0;
					 while($row = mysqli_fetch_array($result)){
                            $y++;
                            echo "<tr>";
                            //echo "<td>".$row['customers_id']."</td>";
                            echo "<td onclick='get_details(".$row['customers_id'].", $(this).offset());'>" . $row['customers_lastname'] ." </td>
                            <td><input type='button' onclick='window.location=\"episk.php?cID=".$row['customers_id']."\";' value='Επίσκεψη' />
                            <input type='button' onclick='window.location=\"products_list.php?cID=".$row['customers_id']."\";' value='Follow-Up' />
                            <input type='button' onclick='window.location=\"history.php?cID=".$row['customers_id']."\"' value='Ιστορικό' /></td>";
						    echo "</tr>";
					 }
					 ?>
                        </tr></tbody>
					  </table>
                        
                   
                </div>
            </div>
        </div>
    </div><!--/span-->

<?php require('footer.php'); ?>