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

59 lines
2.5 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 users WHERE email=:email");
// $stmt->bindParam(':email', $_SESSION['email']);
// $stmt->execute();
// $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// $num_rows = $stmt->rowCount();
// foreach($rows as $row){
// $user_access_data = explode(",", $row['access']);
// foreach($user_access_data as $access_data){
// echo '<div style="display: flex; flex-direction: row;"><a href="/cleads/by-business-verticals/?bv='.$access_data.'" style="margin: 10px;">'.$access_data.'</a></div>';
// }
// }
// } catch (PDOException $e) {
// echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
// }
?>
<?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 cleads WHERE business_type = :business_type ORDER BY time DESC");
$stmt->bindParam(':business_type', $_GET['bv']);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<div id="grid"></div>
<script>
const grid = new gridjs.Grid({
columns: ["Name", {name: "ID", formatter: (cell) => {return gridjs.html(`<a href="/cleads/edit-lead/?id=${cell}">${cell}</a>`);}},"Status", "Email", "Phone", "Time", {name: "ID", formatter: (cell) => {return gridjs.html(`<a href="/cleads/delete-lead/?id=${cell}">Delete</a>`);}}],
pagination: {limit: 100},
search: true,
sort: true,
resizable: true,
data: () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(<?php echo json_encode($rows); ?>);
}, 1000);
});
},
loading: true
});
grid.render(document.getElementById("grid"));
</script>
<?php
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>