downloads leads with comments
This commit is contained in:
@@ -444,6 +444,33 @@ echo'<div class="flex flex-row justify-between">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
$leadsWithComments = []; // Initialize an array to hold leads with comments
|
||||
|
||||
foreach ($leads as $singleLead) {
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("SELECT * FROM comments WHERE leadid = :leadid ORDER BY created_at DESC");
|
||||
$stmt->bindParam(':leadid', $singleLead['id']);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$comments = [];
|
||||
foreach ($rows as $row) {
|
||||
$comments[] = $row['comments'];
|
||||
}
|
||||
$singleLead['comments'] = $comments;
|
||||
|
||||
$leadsWithComments[] = $singleLead;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
}
|
||||
|
||||
// Now $leadsWithComments contains all leads with their respective comments
|
||||
|
||||
?>
|
||||
<script>
|
||||
// Function to fetch countries and populate the country dropdown
|
||||
function fetchCountries() {
|
||||
@@ -528,7 +555,7 @@ echo'<div class="flex flex-row justify-between">
|
||||
}
|
||||
}
|
||||
}
|
||||
const data = <?php echo json_encode($leads); ?>;
|
||||
const data = <?php echo json_encode($leadsWithComments); ?>;
|
||||
const filename = `leads_data.csv`;
|
||||
|
||||
function downloadCSV(data, filename) {
|
||||
|
||||
Reference in New Issue
Block a user