<?php include("_config/dbconfig.php");
include("_includes/head.php");?>
<title>Clients</title>
<?php include("_includes/header.php");


if(isset($_GET['del']) && !empty($_GET['del'])){
	
	$dd = base64_decode($_GET['del']);
	$obj_clients_class->deleteClientAndClientPersons($dd);
	echo "<script> window.location= 'clients.php'</script>";
    die();
	} 


    $all_clients = $obj_clients_class->getClients('', 1);
    
    /* echo '<pre>';
    print_r($all_clients); 
    echo '</pre>';  
    */
?>

<div class="col-sm-12 right_form">
        <div class="title">
            <div class="row">
                <div class="col-md-8 col-sm-12">
                    <h1>Clients</h1>
                </div>
                  <div class="col-md-4 col-sm-12">
			        <a href="client_controls.php" style="cursor: pointer;" class="btn btn-primary btn-o add-event"> Add New </a>
                </div>
            </div>
        </div>
        
        <ol class="breadcrumb white">
          <li><a href="dashboard.php">Dashboard</a></li>
          <li class="active">Clients</li>
          <?php  if($_SESSION['user_role_session']=="Admin" || $_SESSION['user_role_session']=="agent" ){ ?>
            <li class="right"><a href="client_import.php">Import Clients</a></li> 
          <?php  } ?>
        </ol>
</div>

<style>
    .modal-body table td{word-wrap: break-all;
       white-space: pre-wrap !important;} 
    strong {font-weight: 600; font-size: 13px;}


@media (min-width: 768px){
    .client-modal {
        width: 800px !important;
        margin: 30px auto;
    } 
}
.modal-body tr td {
    border-top: 1px solid #ddd !important;
}
</style>

<?php 
/*        echo "<pre>";
        print_r($all_clients);
        echo '</pre>';
   */     
?>
  	<div class="col-sm-12 form_inner">
			<div class="col-md-12 table_inner" style="padding:0;">
                <div class="table-responsive">
                    <table id="example" class="display nowrap lisitng_table" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                            	<th>Sr. </th>
                                <th style=" width:30% !important;">Company Name </th>
                                <th>Categories</th>
                                <!--<th>Product Category</th>-->
                                <th>City</th>
                                <th>Modify</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php $i=1; foreach($all_clients as $cat){ ?>
                            <tr>
                            	<td><?php echo $i ; ?></td>
                                <td><?php echo $cat['company_name']?> </td>
                                <td><?php echo $obj_category_class->getCategoriesName($cat['categories']);?></td>
                                <!--<td><?php // echo $cat['products']?> </td>-->
                                <td><?php echo $cat['city']?></td>
                                
                                <td>
                                    
 <a href="client_view.php?edit=<?php echo base64_encode($cat['client_id'])?>"> View Details  </a> | 
 <a href="client_controls.php?edit=<?php echo base64_encode($cat['client_id'])?>"> Edit  </a> |
 <a href="clients.php?del=<?php echo base64_encode($cat['client_id'])?>" onclick="return window.confirm('Are you sure you want to Deactive this Client?'); " > Delete  </a>
                                </td>
                                <td></td>
                            </tr>
                        <?php   $i++; } 
                        ?> 
                        </tbody>
    				</table>
                </div>
            </div>
		</div>


<?php include("_includes/footer.php"); ?>
<script>
$(document).ready(function() {
    $('#example').DataTable(); 
	
	/* {
        responsive: {
            details: {
                type: 'column',
                target: -1
            }
        },
        columnDefs: [ {
            className: 'control',
            orderable: false,
            targets:   -1
        }]
    });*/
	
});
</script>