<?php 
$leadList = $connection->query("SELECT * FROM lead ORDER BY timestamp DESC");
$leads = $leadList->fetchAll();

$campaigns = $connection->query("SELECT DISTINCT id,campaign_name FROM campaigns");
$campaignsData = $campaigns->fetchAll(PDO::FETCH_KEY_PAIR);
?>
<link href="assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
<div class="kt-container  kt-container--fluid  kt-grid__item kt-grid__item--fluid">
							<div class="kt-portlet kt-portlet--mobile">
								<div class="kt-portlet__head kt-portlet__head--lg">
									<div class="kt-portlet__head-label">
										<span class="kt-portlet__head-icon">
											<i class="kt-font-brand flaticon2-line-chart"></i>
										</span>
										<h3 class="kt-portlet__head-title">
											Lista lead raccolte
										</h3>
									</div>
									
								</div>
								<div class="kt-portlet__body">

									<!--begin: Datatable -->
									<table class="table table-striped- table-bordered table-hover table-checkable" id="kt_table_1">
										<thead>
											<tr>
												<th>Nome campagna</th>
												<th>Nome</th>
												<th>Cognome</th>
												<th>Sesso</th>
												<th>Nascita</th>
												<th>Email</th>
												<th>Cellulare</th>
												<th>Cap</th>
												<th>Città</th>
												<th>Indirizzo</th>
												<th>N. civico</th>
												<th>Flag privacy</th>
												<th></th>
											</tr>
										</thead>
										<tbody>
											
												<?php 
												for($l = 0; $l < count($leads); $l++)
												{
													$id = $leads[$l]['id'];
													$cid = $leads[$l]['campaignId'];

												?>
												<tr>
												<td><?php echo $campaignsData[$cid]; ?></td>
												<td><?php echo $leads[$l]['nome']; ?></td>	
												<td><?php echo $leads[$l]['cognome']; ?></td>	
												<td><?php echo $leads[$l]['sesso']; ?></td>	
												<td><?php echo $leads[$l]['nascita']; ?></td>		
												<td><?php echo $leads[$l]['email']; ?></td>	
												<td><?php echo $leads[$l]['cellulare']; ?></td>	
												<td><?php echo $leads[$l]['cap']; ?></td>	
												<td><?php echo $leads[$l]['citta']; ?></td>	
												<td><?php echo $leads[$l]['indirizzo']; ?></td>	
												<td><?php echo $leads[$l]['civico']; ?></td>	
												<td><?php echo $leads[$l]['privacy']; ?></td>		
												<!--<td><a href="?p=17&id=<?php echo $id; ?>"><button type="button" class="btn btn-info 	btn-custom">Dettagli</button></a></td>-->
												</tr>
												<?php	
												}
												?>
												
											</tr>

										</tbody>
									</table>

									<!--end: Datatable -->
								</div>
							</div>
						</div>
