Files
crm_php/.hta_slug/cleads/_home copy.php
dev sp ca6af2f5e2 init
2024-04-29 12:55:11 +00:00

82 lines
3.7 KiB
PHP

<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
// echo $_SESSION['access'];
?>
<?php
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) >= 1) {
foreach($rows as $row){
echo ' <div style="display: flex; flex-direction: row;">
<a href="/cleads/by-business-verticals/?bv='.$row['bv'].'">'.$row['bv'].'</a>
</div>';
}
} else {
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
<div>
<table style="overflow-x: auto;" id="myTable">
<thead>
<tr>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">ID</th>
<th style="text-align: center;">Status</th>
<th style="text-align: center;">Email</th>
<th style="text-align: center;">Phone</th>
<th style="text-align: center;">business_type</th>
<th style="text-align: center;">Time</th>
<th style="text-align: center;">Action</th>
</tr>
</thead>
<tbody>
<?php
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$accessArray = explode(",", $_SESSION['access']);
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type IN ($placeholders)");
foreach ($accessArray as $key => $value) {
$stmt->bindValue($key + 1, $value);
}
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){
echo ' <tr>
<td style="text-align: center;">'.$row['name'].'</td>
<td style="text-align: center;"><a href="/edit-lead/?id='.$row['id'].'">'.$row['id'].'</a></td>
<td style="text-align: center;">'.$row['status'].'</td>
<td style="text-align: center;">'.$row['email'].'</td>
<td style="text-align: center;">'.$row['phone'].'</td>
<td style="text-align: center;">'.$row['business_type'].'</td>
<td style="text-align: center;">'.$row['time'].'</td>
<td style="text-align: center;">Delete</td>
</tr>';
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</tbody>
</table>
</div>