edit user
This commit is contained in:
@@ -2,25 +2,7 @@
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.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 `id` = '".$_GET["id"]."'");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach($rows as $row){
|
||||
$seletedState = explode(",", $row['states']);
|
||||
}
|
||||
}catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
// $name = $_POST['name'];
|
||||
|
||||
17
.hta_slug/leads.php
Normal file
17
.hta_slug/leads.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
if(isset($url[2])){
|
||||
$slug2="";
|
||||
if (strpos($url[2], "?") !== false) {
|
||||
$url2 = explode('?', $url[2]);
|
||||
$slug2=$url2[0];
|
||||
} else $slug2=$url[2];
|
||||
if($slug2=="") require_once('cleads/_home.php');
|
||||
elseif(file_exists(__DIR__."/cleads/".$slug2.".php")) include __DIR__."/cleads/".$slug2.".php";
|
||||
else require_once('cleads/.htac_404.php');
|
||||
}
|
||||
else require_once('cleads/_home.php');
|
||||
|
||||
// uri - slug handler ends
|
||||
?>
|
||||
68
.hta_slug/leads/_home copy 2.php
Normal file
68
.hta_slug/leads/_home copy 2.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.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>
|
||||
<?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) LIMIT 10");
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 1, $value);
|
||||
}
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
echo '
|
||||
<div id="example-table"></div>
|
||||
|
||||
<link href="https://unpkg.com/tabulator-tables@6.2.0/dist/css/tabulator.min.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@6.2.0/dist/js/tabulator.min.js"></script>
|
||||
<script>
|
||||
//define data
|
||||
var tabledata = '.json_encode($rows).';
|
||||
|
||||
//define table
|
||||
var table = new Tabulator("#example-table", {
|
||||
data:tabledata,
|
||||
autoColumns:true,
|
||||
});
|
||||
</script>
|
||||
';
|
||||
$num_rows = $stmt->rowCount();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
71
.hta_slug/leads/_home copy 3.php
Normal file
71
.hta_slug/leads/_home copy 3.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
// echo $_SESSION['access'];
|
||||
?>
|
||||
|
||||
<div>
|
||||
<a style="float: right; padding: 10px;" href="/cleads/add-lead">Add Leads</a>
|
||||
</div>
|
||||
<?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>";
|
||||
// };
|
||||
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
if($_SESSION['user_type'] == 'admin'){
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads ORDER BY time DESC");
|
||||
}else{
|
||||
$accessArray = explode(",", $_SESSION['access']);
|
||||
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type IN ($placeholders) ORDER BY time DESC");
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 1, $value);
|
||||
}
|
||||
// $stmt->bindValue(":user", $_SESSION['email']);
|
||||
}
|
||||
$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>";
|
||||
}
|
||||
?>
|
||||
|
||||
82
.hta_slug/leads/_home copy.php
Normal file
82
.hta_slug/leads/_home copy.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.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>
|
||||
548
.hta_slug/leads/_home.php
Normal file
548
.hta_slug/leads/_home.php
Normal file
@@ -0,0 +1,548 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
// deleteCofermation()
|
||||
$today_date = date("Y-m-d");
|
||||
$next_day = date("Y-m-d", strtotime("+1 day"));
|
||||
$yesterday = date("Y-m-d", strtotime("-1 day"));
|
||||
$this_week = date("Y-m-d", strtotime("-7 day"));
|
||||
$prev_month_date = date("Y-m-d", strtotime("first day of previous month", strtotime($today_date)));
|
||||
$firstDayOfCurrentMonth = date("Y-m-01");
|
||||
$firstDayOfLastMonth = date("Y-m-01", strtotime("first day of last month"));
|
||||
$firstDateOfYear = date("Y") . '-01-01';
|
||||
$previousYear = date("Y") - 1;
|
||||
$firstDateOfPreviousYear = $previousYear . '-01-01';
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['new_lead']) && $_POST['new_lead'] && isset($_POST['name']) && $_POST['name'] && isset($_POST['phone']) && $_POST['phone']) {
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
$phone = $_POST['phone'];
|
||||
$formname = 'crm-portal';
|
||||
$note = $_POST['note'];
|
||||
$origin = $_POST['origin'];
|
||||
$gender = $_POST['gender'];
|
||||
$profession = $_POST['profession'];
|
||||
$country = $_POST['country'];
|
||||
$state = $_POST['state'];
|
||||
$city = $_POST['city'];
|
||||
$address = $_POST['address'];
|
||||
$status = 'New';
|
||||
try {
|
||||
$stmt = $conn->prepare("INSERT INTO cleads (name, email, phone, formname, note, origin, status, gender, profession, country, state, city, address ) VALUES (:name, :email, :phone, :formname, :note, :origin, :status, :gender, :profession, :country, :state, :city, :address)");
|
||||
$stmt->bindParam(':name', $name);
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->bindParam(':phone', $phone);
|
||||
$stmt->bindParam(':formname', $formname);
|
||||
$stmt->bindParam(':note', $note);
|
||||
$stmt->bindParam(':origin', $origin);
|
||||
$stmt->bindParam(':status', $status);
|
||||
$stmt->bindParam(':gender', $gender);
|
||||
$stmt->bindParam(':profession', $profession);
|
||||
$stmt->bindParam(':country', $country);
|
||||
$stmt->bindParam(':state', $state);
|
||||
$stmt->bindParam(':city', $city);
|
||||
$stmt->bindParam(':address', $address);
|
||||
$stmt->execute();
|
||||
echo "Record added successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if(isset($_POST['delete_records'])) {
|
||||
if(isset($_POST['selected_records']) && !empty($_POST['selected_records'])) {
|
||||
$selectedIds = $_POST['selected_records'];
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$delete_placeholders = rtrim(str_repeat('?,', count($selectedIds)), ',');
|
||||
$stmt = $conn->prepare("DELETE FROM cleads WHERE id IN ($delete_placeholders)");
|
||||
foreach($selectedIds as $key => $id) {
|
||||
$stmt->bindValue($key + 1, $id, PDO::PARAM_INT);
|
||||
}
|
||||
$stmt->execute();
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p class="text-[28px] font-bold p-4">Lead Management</p>
|
||||
<div id="page-body" class="flex flex-row place-content-between px-4">
|
||||
<dialog>
|
||||
<button style="float: right; color: #FF0000; font-size: 25px; padding: 6px;">✘</button>
|
||||
<div class="flex flex-row">
|
||||
<div class="flex flex-col p-6 space-y-4">
|
||||
<a href="/cleads?start_date=<?php echo $today_date ?>&end_date=<?php echo $next_day ?>">Today</a>
|
||||
<a href="/cleads?start_date=<?php echo $yesterday ?>&end_date=<?php echo $today_date ?>">Yesterday</a>
|
||||
<a href="/cleads?start_date=<?php echo $this_week ?>&end_date=<?php echo $today_date ?>">This Week</a>
|
||||
<a href="/cleads?start_date=<?php echo $firstDayOfCurrentMonth ?>&end_date=<?php echo $today_date ?>">This Month</a>
|
||||
<a href="/cleads?start_date=<?php echo $prev_month_date ?>&end_date=<?php echo $today_date ?>">Last Month</a>
|
||||
<a href="/cleads?start_date=<?php echo $firstDateOfYear ?>&end_date=<?php echo $today_date ?>">This Year</a>
|
||||
<a href="/cleads?start_date=<?php echo $firstDateOfPreviousYear ?>&end_date=<?php echo $today_date ?>">Last Year</a>
|
||||
<a href="/cleads">All Time</a>
|
||||
</div>
|
||||
<form method="GET" class="p-6 flex flex-col pb-10">
|
||||
<p>Choose Date for filter</p>
|
||||
<div class="flex flex-row rounded-xl py-10">
|
||||
<div class="flex flex-row place-items-center">
|
||||
<label for="start_date">From Date</label>
|
||||
<input type="date" name="start_date" id="start_date" />
|
||||
</div> |
|
||||
<div class="flex flex-row place-items-center">
|
||||
<label for="end_date">To Date</label>
|
||||
<input type="date" name="end_date" id="end_date" />
|
||||
</div>
|
||||
</div>
|
||||
<button class="rounded-lg p-1 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;" type="submit"><p class="text-center p-1.5">Search</p></button>
|
||||
</form>
|
||||
</div>
|
||||
</dialog>
|
||||
<?php
|
||||
if($_SESSION['user_type'] == 'admin'){
|
||||
echo '<p onclick="deleteCofermation();" class="rounded-lg pt-2 px-6 text-[#fff] text-center" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); cursor: pointer;">Delete</p>';
|
||||
}
|
||||
?>
|
||||
<button class="rounded-lg p-2 bg-[#fff] text-[#464E5F] shadow-lg" style="">Select Date</button>
|
||||
<div class="flex flex-row">
|
||||
<form method="GET" action="" class="bg-[#fff] flex flex-row place-items-center">
|
||||
<input class="p-2.5 rounded-l-lg focus:outline-none w-[320px]" type="text" name="search" placeholder="Name, lead ID, Mobile, Email..." style="border: 2px solid #8E8E8E;">
|
||||
<button class="rounded-r-lg text-[#fff] p-1.5" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);" type="submit"><i class="fa fa-search"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
<button onclick="toggleDisplay();" class="rounded-lg p-2 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;">Add Leads</button>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="width: 100%;" >
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
if($_SESSION['user_type'] == 'admin')
|
||||
echo ' <th class="text-center border-b-2 p-3">
|
||||
<div class="delete-confirm" id="delete-button" style="display: none;">
|
||||
<p>Are you sure you want to delete this lead?</p>
|
||||
<div class="flex flex-row space-x-4">
|
||||
<p onclick="deleteCofermation();" class="rounded-lg p-2 text-[#443780] mr-4" style="border: 2px solid #443780; cursor: pointer;">No</p>
|
||||
<button class="rounded-lg p-3 text-[#fff]" type="submit" name="delete_records" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);">Yes</button>
|
||||
</div>
|
||||
</div>
|
||||
</th>';
|
||||
?>
|
||||
<th class="text-center border-b-2 p-3">Name</th>
|
||||
<th class="text-center border-b-2 p-3">ID</th>
|
||||
<th class="text-center border-b-2 p-3">Status Update</th>
|
||||
<!-- <th class="text-center border-b-2 p-3">Contact Detail</th> -->
|
||||
<th class="text-center border-b-2 p-3">Form Name</th>
|
||||
<th class="text-center border-b-2 p-3">Date</th>
|
||||
<th class="text-center border-b-2 p-3">Quick Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
<?php
|
||||
// Number of records per page
|
||||
$recordsPerPage = 500;
|
||||
|
||||
// Current page
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
$currentPage = intval($_GET['page']);
|
||||
} else {
|
||||
$currentPage = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$searchQuery = isset($_GET['search']) ? trim($_GET['search']) : '';
|
||||
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
|
||||
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';
|
||||
|
||||
$accessArray = explode(",", $_SESSION['access']);
|
||||
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
|
||||
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
|
||||
if (!empty($searchQuery)) {
|
||||
// this is keywords search
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE (id LIKE ? OR name LIKE ? OR email LIKE ? OR phone LIKE ?) AND business_type IN ($placeholders) ORDER BY time DESC LIMIT ?, ?");
|
||||
$stmt->bindValue(1, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(2, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(3, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(4, "%$searchQuery%", PDO::PARAM_STR);
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 5, $value);
|
||||
}
|
||||
$stmt->bindValue(count($accessArray) + 5, 0, PDO::PARAM_INT); // Offset for pagination
|
||||
$stmt->bindValue(count($accessArray) + 6, $recordsPerPage, PDO::PARAM_INT); // Records per page
|
||||
// this is for date serch
|
||||
}elseif (!empty($start_date) && !empty($end_date)) {
|
||||
$start_date = date('Y-m-d', strtotime($start_date));
|
||||
$end_date = date('Y-m-d', strtotime($end_date));
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE time BETWEEN ? AND ? AND business_type IN ($placeholders)");
|
||||
$stmt->bindValue(1, $start_date);
|
||||
$stmt->bindValue(2, $end_date);
|
||||
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 3, $value);
|
||||
}
|
||||
}else{
|
||||
// if user type admin then show all lead
|
||||
if($_SESSION['user_type'] == 'admin'){
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads");
|
||||
$stmt->execute();
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
|
||||
$totalPages = ceil($totalRecords / $recordsPerPage);
|
||||
|
||||
$offset = ($currentPage - 1) * $recordsPerPage;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads ORDER BY time DESC LIMIT :offset, :recordsPerPage");
|
||||
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':recordsPerPage', $recordsPerPage, PDO::PARAM_INT);
|
||||
}else{
|
||||
// if user type user then show only given access lead
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads WHERE business_type IN ($placeholders)");
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 1, $value);
|
||||
}
|
||||
$stmt->execute();
|
||||
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
$totalPages = ceil($totalRecords / $recordsPerPage);
|
||||
$offset = ($currentPage - 1) * $recordsPerPage;
|
||||
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type IN ($placeholders) ORDER BY time DESC LIMIT ?, ?");
|
||||
$paramCount = count($accessArray);
|
||||
for ($i = 0; $i < $paramCount; $i++) {
|
||||
$stmt->bindValue($i + 1, $accessArray[$i]);
|
||||
}
|
||||
$stmt->bindValue($paramCount + 1, $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue($paramCount + 2, $recordsPerPage, PDO::PARAM_INT);
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$row_count = count($rows);
|
||||
for ($i = 0; $i < $row_count; $i++) {
|
||||
// echo $row_count . " ";
|
||||
}
|
||||
echo "<p class='px-4'>Total ".$row_count." Rows Found</p>";
|
||||
// Status Conditional Color
|
||||
foreach($rows as $row){
|
||||
$only_date = explode(' ', $row['time']);
|
||||
$lead_id = $row['id'];
|
||||
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
|
||||
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
|
||||
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
|
||||
elseif($row['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
// if status = warm then select
|
||||
// if($row['status'] == 'Warm'){$conditional_status = '<div class="flex flex-row"><p>'.$row['status'].'</p><select class="focus: outline-none " style="'.$conditional_background_color.' border: none;"><option>Option 1</option><option>Option 2</option></select></div>';}elseif($row['status'] != 'Warm'){$conditional_status = $row['status'];}
|
||||
?>
|
||||
<tr>
|
||||
<?php if($_SESSION['user_type'] == 'admin'){?>
|
||||
<td class="border-y-2 p-2">
|
||||
<input type="checkbox" name="selected_records[]" value="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>" />
|
||||
</td>
|
||||
<?php }?>
|
||||
<td class="border-y-2 p-2"><label for="<?php echo $row['id']; ?>"><?php echo $row['name'] ?></label></td>
|
||||
<td class="border-y-2 p-2 text-blue-500 hover:text-blue-700 hover:underline"><a href="/cleads/edit-lead/?id=<?php echo $row['id'] ?>"><?php echo $row['id'] ?></a></td>
|
||||
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $row['status'];?></div></td>
|
||||
<!-- <td class="border-y-2 p-2">
|
||||
<p><i class="fa fa-envelope"> <?php // echo $row['email'] ?></i></p>
|
||||
<p><i class="fa fa-phone"> <?php // echo $row['phone'] ?></i></p>
|
||||
</td> -->
|
||||
<td class="border-y-2 p-2"><?php echo $row['formname'] ?></td>
|
||||
<td class="border-y-2 p-2"><?php echo $only_date[0]; ?></td>
|
||||
<td class="border-y-2 p-2">
|
||||
<div class="flex flex-row justify-center place-items-center">
|
||||
<a href="mailto:<?php echo $row['email'] ?>"><i class="fa fa-envelope" style="font-size: 20px"></i></a>
|
||||
<a href="https://wa.me/<?php echo $row['phone'] ?>?text=Hello%2C%20how%20are%20you%3F"><i class="fab fa-whatsapp" style="font-size: 20px"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php if ($currentPage > 1): ?>
|
||||
<a href="?page=<?php echo ($currentPage - 1); ?>">Previous</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
||||
<a href="?page=<?php echo $i; ?>" <?php if ($i === $currentPage) echo 'class="active"'; ?>><?php echo $i; ?></a>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if ($currentPage < $totalPages): ?>
|
||||
<a href="?page=<?php echo ($currentPage + 1); ?>">Next</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- New Lead Form Section -->
|
||||
<div id="add-lead-form" class="add-lead-form">
|
||||
<div class="flex flex-row place-content-between p-2" style="border-bottom: 2px solid #464E5F; border-style: dashed;">
|
||||
<p class="text-[25px] font-bold">Add Lead</p>
|
||||
<p onclick="toggleDisplay();" class="rounded-lg px-1.5 text-[#464E5F] text-[25px] cursor-pointer" style="border: 2px solid #464E5F; border-radius: 50%;">✘</p>
|
||||
</div>
|
||||
<form action="" method="post" class="p-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2">
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="country"> Country:</label>
|
||||
<select name="country" id="country" onchange="fetchStates()" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select Country</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="state"> State:</label>
|
||||
<select name="state" id="state" onchange="fetchCities()" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select State</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="city"> City:</label>
|
||||
<select name="city" id="city" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select City</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="address">Address:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="address" id="address" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="name">Name:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="name" id="name" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="gender">Gender:</label>
|
||||
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="gender" id="gender" >
|
||||
<option value="Male">Male</option>
|
||||
<option value="Female">Female</option>
|
||||
<option value="Others">Others</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="profession">Profession:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="profession" id="profession" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="email">E-mail:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="email" id="email" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="phone">Phone:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="phone" id="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row place-content-between p-2 text-[25px] font-bold" style="border-bottom: 2px solid #464E5F; border-style: dashed;">Lead Information</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2">
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="origin">Origin:</label>
|
||||
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="origin" id="origin" >
|
||||
<option value="Facebook Ads">Facebook Ads</option>
|
||||
<option value="Google Ads">Google Ads</option>
|
||||
<option value="Linkedin Ads">Linkedin Ads</option>
|
||||
<option value="Instagram">Instagram</option>
|
||||
<option value="Messenger">Messenger</option>
|
||||
<option value="Whatsapp">Whatsapp</option>
|
||||
<option value="GMB">GMB</option>
|
||||
<option value="Linkedin">Linkedin</option>
|
||||
<option value="Inbound Call">Inbound Call</option>
|
||||
<option value="Outbound Call">Outbound Call</option>
|
||||
<option value="Others">Others</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- <div class="flex flex-col mr-4">
|
||||
<label for="user">Lead Owner:</label>
|
||||
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="user" id="user" >
|
||||
<?php
|
||||
// $conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
// $stmt = $conn->prepare("SELECT * FROM users");
|
||||
// $stmt->execute();
|
||||
// $users_rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// $row_count = count($users_rows);
|
||||
// if($row_count > 0){
|
||||
// foreach($users_rows as $users_data){
|
||||
// echo '<option value="'.$users_data['email'].'">'.$users_data['email'].'</option>';
|
||||
// }
|
||||
// } else{
|
||||
// echo '<p>No users Found</p>';
|
||||
// }
|
||||
?>
|
||||
</select>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="note">Note:</label>
|
||||
<textarea type="text" name="note" id="note" rows="6" cols="10" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;"></textarea>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<input class="p-2" type="submit" name="new_lead" id="new_lead" value="Submit" style="color:#fff; border-radius: 6px; background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; margin-top: 10px;"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
// Function to fetch countries and populate the country dropdown
|
||||
function fetchCountries() {
|
||||
fetch('https://api.siliconpin.com/v3/list/country/')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const countryDropdown = document.getElementById('country');
|
||||
countryDropdown.innerHTML = '<option value="">Select Country</option>';
|
||||
data.forEach(country => {
|
||||
const option = document.createElement('option');
|
||||
option.value = country.iso2;
|
||||
option.text = country.name;
|
||||
countryDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchStates() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const stateDropdown = document.getElementById('state');
|
||||
stateDropdown.innerHTML = '<option value="">Select State</option>';
|
||||
data.forEach(state => {
|
||||
const option = document.createElement('option');
|
||||
option.value = state.iso2;
|
||||
option.text = state.name;
|
||||
stateDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Function to fetch cities based on selected country and state and populate the city dropdown
|
||||
function fetchCities() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
const selectedState = document.getElementById('state').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${selectedCountry}&state=${selectedState}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const cityDropdown = document.getElementById('city');
|
||||
cityDropdown.innerHTML = '<option value="">Select City</option>';
|
||||
data.forEach(city => {
|
||||
const option = document.createElement('option');
|
||||
option.value = city.name;
|
||||
option.text = city.name;
|
||||
cityDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Fetch countries on page load
|
||||
fetchCountries();
|
||||
|
||||
const dialog = document.querySelector("dialog");
|
||||
const showButton = document.querySelector("dialog + button");
|
||||
const closeButton = document.querySelector("dialog button");
|
||||
|
||||
// "Show the dialog" button opens the dialog modally
|
||||
showButton.addEventListener("click", () => {
|
||||
dialog.showModal();
|
||||
});
|
||||
|
||||
// "Close" button closes the dialog
|
||||
closeButton.addEventListener("click", () => {
|
||||
dialog.close();
|
||||
});
|
||||
function toggleDisplay() {
|
||||
var element = document.getElementById('add-lead-form');
|
||||
if (element.style.display === 'block') {
|
||||
element.style.display = 'none';
|
||||
} else {
|
||||
element.style.display = 'block';
|
||||
element.classList.add('slide-in-animation'); // Add class to trigger animation
|
||||
}
|
||||
}
|
||||
|
||||
// Event listener for the Esc key
|
||||
document.addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 27) {
|
||||
var modal = document.getElementById('add-lead-form');
|
||||
if (modal.style.display === 'block') {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
function deleteCofermation(){
|
||||
let deleteButton = document.getElementById('delete-button');
|
||||
let leadID = document.getElementById('<?php echo $row['id']; ?>').value;
|
||||
if(leadID != null){
|
||||
if(deleteButton.style.display === 'flex'){
|
||||
deleteButton.style.display = 'none';
|
||||
}else{
|
||||
deleteButton.style.display = 'flex'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.add-lead-form {
|
||||
background-color: #F8F8F8;
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0%;
|
||||
right: 0%;
|
||||
transform: translateX(100%);
|
||||
/* transform: translate(-0%, -50%); */
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 2px;
|
||||
z-index: 100;
|
||||
height: 100%;
|
||||
animation: slideInRight 0.5s forwards; /* Animation to slide in */
|
||||
/* overflow-x: auto; */
|
||||
}
|
||||
|
||||
@keyframes slideInRight {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateX(0%);
|
||||
}
|
||||
}
|
||||
/* .add-lead-form{
|
||||
background-color: #F8F8F8;
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
right: 0%;
|
||||
transform: translate(-0%, -50%);
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 5px;
|
||||
z-index: 100;
|
||||
height: 100%;
|
||||
} */
|
||||
.delete-confirm{
|
||||
position: fixed;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
background-color: #E6E5F4;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
padding: 40px 50px 40px 50px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
63
.hta_slug/leads/add-lead.php
Normal file
63
.hta_slug/leads/add-lead.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
$phone = $_POST['phone'];
|
||||
$formname = 'crm-portal';
|
||||
$note = $_POST['note'];
|
||||
$details = $_POST['details'];
|
||||
$status = 'New';
|
||||
try {
|
||||
$stmt = $conn->prepare("INSERT INTO cleads (name, email, phone, formname, note, details, status) VALUES (:name, :email, :phone, :formname, :note, :details, :status)");
|
||||
$stmt->bindParam(':name', $name);
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->bindParam(':phone', $phone);
|
||||
$stmt->bindParam(':formname', $formname);
|
||||
$stmt->bindParam(':note', $note);
|
||||
$stmt->bindParam(':details', $details);
|
||||
$stmt->bindParam(':status', $status);
|
||||
$stmt->execute();
|
||||
echo "Record added successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div style="max-width: 600px;">
|
||||
<form action="" method="post">
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" name="name" id="name" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="email">E-mail:</label>
|
||||
<input type="text" name="email" id="email" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="phone">Phone:</label>
|
||||
<input type="text" name="phone" id="phone" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="details">Details:</label>
|
||||
<input type="text" name="details" id="details" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="note">Note:</label>
|
||||
<textarea type="text" name="note" id="note" rows="6" cols="10"></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<input type="submit" name="submit" id="submit" value="Submit"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
28
.hta_slug/leads/bv.php
Normal file
28
.hta_slug/leads/bv.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.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>
|
||||
<a href="/cleads/by-business-verticals/?bv='.$row['bv'].'">'.$row['bv'].'</a>
|
||||
</div>'; ?>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text-danger'>Not Found any Data</p>";
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
?>
|
||||
59
.hta_slug/leads/by-business-verticals copy.php
Normal file
59
.hta_slug/leads/by-business-verticals copy.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.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>";
|
||||
}
|
||||
?>
|
||||
446
.hta_slug/leads/by-business-verticals.php
Normal file
446
.hta_slug/leads/by-business-verticals.php
Normal file
@@ -0,0 +1,446 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
|
||||
$today_date = date("Y-m-d");
|
||||
$next_day = date("Y-m-d", strtotime("+1 day"));
|
||||
$yesterday = date("Y-m-d", strtotime("-1 day"));
|
||||
$this_week = date("Y-m-d", strtotime("-7 day"));
|
||||
$prev_month_date = date("Y-m-d", strtotime("first day of previous month", strtotime($today_date)));
|
||||
$firstDayOfCurrentMonth = date("Y-m-01");
|
||||
$firstDayOfLastMonth = date("Y-m-01", strtotime("first day of last month"));
|
||||
$firstDateOfYear = date("Y") . '-01-01';
|
||||
$previousYear = date("Y") - 1;
|
||||
$firstDateOfPreviousYear = $previousYear . '-01-01';
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['new_lead']) && $_POST['new_lead'] && isset($_POST['name']) && $_POST['name'] && isset($_POST['phone']) && $_POST['phone']) {
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
$phone = $_POST['phone'];
|
||||
$formname = 'crm-portal';
|
||||
$note = $_POST['note'];
|
||||
$origin = $_POST['origin'];
|
||||
$gender = $_POST['gender'];
|
||||
$profession = $_POST['profession'];
|
||||
$country = $_POST['country'];
|
||||
$state = $_POST['state'];
|
||||
$city = $_POST['city'];
|
||||
$address = $_POST['address'];
|
||||
$status = 'New';
|
||||
try {
|
||||
$stmt = $conn->prepare("INSERT INTO cleads (name, email, phone, formname, note, origin, status, gender, profession, country, state, city, address ) VALUES (:name, :email, :phone, :formname, :note, :origin, :status, :gender, :profession, :country, :state, :city, :address)");
|
||||
$stmt->bindParam(':name', $name);
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->bindParam(':phone', $phone);
|
||||
$stmt->bindParam(':formname', $formname);
|
||||
$stmt->bindParam(':note', $note);
|
||||
$stmt->bindParam(':origin', $origin);
|
||||
$stmt->bindParam(':status', $status);
|
||||
$stmt->bindParam(':gender', $gender);
|
||||
$stmt->bindParam(':profession', $profession);
|
||||
$stmt->bindParam(':country', $country);
|
||||
$stmt->bindParam(':state', $state);
|
||||
$stmt->bindParam(':city', $city);
|
||||
$stmt->bindParam(':address', $address);
|
||||
$stmt->execute();
|
||||
echo "Record added successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p class="text-[28px] font-bold p-4">Lead Management</p>
|
||||
<div class="flex flex-row place-content-between pb-1 px-4">
|
||||
<dialog>
|
||||
<button style="float: right; color: #FF0000; font-size: 25px; padding: 6px;">✘</button>
|
||||
<div class="flex flex-row">
|
||||
<div class="flex flex-col p-6 space-y-4">
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $today_date ?>&end_date=<?php echo $next_day ?>">Today</a>
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $yesterday ?>&end_date=<?php echo $today_date ?>">Yesterday</a>
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $this_week ?>&end_date=<?php echo $today_date ?>">This Week</a>
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $firstDayOfCurrentMonth ?>&end_date=<?php echo $today_date ?>">This Month</a>
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $prev_month_date ?>&end_date=<?php echo $today_date ?>">Last Month</a>
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $firstDateOfYear ?>&end_date=<?php echo $today_date ?>">This Year</a>
|
||||
<a href="/cleads/by-business-verticals/?bv=<?php echo $_GET['bv']; ?>&start_date=<?php echo $firstDateOfPreviousYear ?>&end_date=<?php echo $today_date ?>">Last Year</a>
|
||||
<a href="/cleads">All Time</a>
|
||||
</div>
|
||||
<form method="GET" class="p-6 flex flex-col pb-10">
|
||||
<p>Choose Date for filter</p>
|
||||
<div class="flex flex-row rounded-xl py-10">
|
||||
<div class="flex flex-row place-items-center">
|
||||
<input type="text" name="bv" value="<?php echo $_GET['bv']; ?>">
|
||||
<label for="start_date">From Date</label>
|
||||
<input type="date" name="start_date" id="start_date" />
|
||||
</div> |
|
||||
<div class="flex flex-row place-items-center">
|
||||
<label for="end_date">To Date</label>
|
||||
<input type="date" name="end_date" id="end_date" />
|
||||
</div>
|
||||
</div>
|
||||
<button class="rounded-lg p-1 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;" type="submit"><p class="text-center p-1.5">Search</p></button>
|
||||
</form>
|
||||
</div>
|
||||
</dialog>
|
||||
<button class="rounded-lg p-2 bg-[#fff] text-[#464E5F] shadow-lg" style="">Select Date</button>
|
||||
<div class="flex flex-row">
|
||||
<form method="GET" action="" class="bg-[#fff] flex flex-row place-items-center">
|
||||
<input type="hidden" name="bv" id="bv" value="<?php echo $_GET['bv']; ?>">
|
||||
<input class="p-2.5 rounded-l-lg focus:outline-none w-[320px]" type="text" name="search" placeholder="Name / ID / Mobile / Email" style="border: 2px solid #8E8E8E;">
|
||||
<button class="rounded-r-lg text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);" type="submit"><i class="fa fa-search"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
<button onclick="toggleDisplay();" class="rounded-lg p-2 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;">Add Leads</button>
|
||||
<!-- <a class="rounded-lg p-2 text-[#fff]" href="/cleads/add-lead" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;">Add Leads</a> -->
|
||||
</div>
|
||||
|
||||
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center border-b-2 p-3">Name</th>
|
||||
<th class="text-center border-b-2 p-3">ID</th>
|
||||
<th class="text-center border-b-2 p-3">Status Update</th>
|
||||
<th class="text-center border-b-2 p-3">Contact Detail</th>
|
||||
<th class="text-center border-b-2 p-3">Form Name</th>
|
||||
<th class="text-center border-b-2 p-3">Date & Time</th>
|
||||
<th class="text-center border-b-2 p-3">Quick Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
<?php
|
||||
// Number of records per page
|
||||
$recordsPerPage = 500;
|
||||
|
||||
// Current page
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
$currentPage = intval($_GET['page']);
|
||||
} else {
|
||||
$currentPage = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$searchQuery = isset($_GET['search']) ? trim($_GET['search']) : '';
|
||||
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
|
||||
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';
|
||||
$accessArray = explode(",", $_SESSION['access']);
|
||||
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
|
||||
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
|
||||
if (!empty($searchQuery)) {
|
||||
// this is keywords search
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE (id LIKE ? OR name LIKE ? OR email LIKE ? OR phone LIKE ?) AND business_type = ? ORDER BY time DESC LIMIT ?, ?");
|
||||
$stmt->bindValue(1, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(2, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(3, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(4, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(5, $_GET['bv']);
|
||||
$stmt->bindValue(6, 0, PDO::PARAM_INT); // Offset for pagination
|
||||
$stmt->bindValue(7, $recordsPerPage, PDO::PARAM_INT); // Records per page
|
||||
// this is for date serch
|
||||
}elseif (!empty($start_date) && !empty($end_date)) {
|
||||
$start_date = date('Y-m-d', strtotime($start_date));
|
||||
$end_date = date('Y-m-d', strtotime($end_date));
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type = ? AND `time` BETWEEN ? AND ?");
|
||||
$stmt->bindValue(1, $_GET['bv']);
|
||||
$stmt->bindValue(2, $start_date);
|
||||
$stmt->bindValue(3, $end_date);
|
||||
}else{
|
||||
// if user type admin then show all lead
|
||||
if($_SESSION['user_type'] == 'admin'){
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads");
|
||||
$stmt->execute();
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
|
||||
$totalPages = ceil($totalRecords / $recordsPerPage);
|
||||
|
||||
$offset = ($currentPage - 1) * $recordsPerPage;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type = :business_type ORDER BY time DESC LIMIT :offset, :recordsPerPage");
|
||||
$stmt->bindParam(':business_type', $_GET['bv'], PDO::PARAM_INT);
|
||||
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':recordsPerPage', $recordsPerPage, PDO::PARAM_INT);
|
||||
}else{
|
||||
// if user type user then show only given access lead
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads WHERE business_type = ?");
|
||||
$stmt->bindValue(1, $_GET['bv']);
|
||||
$stmt->execute();
|
||||
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
$totalPages = ceil($totalRecords / $recordsPerPage);
|
||||
$offset = ($currentPage - 1) * $recordsPerPage;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type = :business_type ORDER BY time DESC LIMIT :offset, :recordsPerPage");
|
||||
$stmt->bindParam(':business_type', $_GET['bv']);
|
||||
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':recordsPerPage', $recordsPerPage, PDO::PARAM_INT);
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$row_count = count($rows);
|
||||
for ($i = 0; $i < $row_count; $i++) {
|
||||
// echo $row_count . " ";
|
||||
}
|
||||
echo "<p class='px-4'>Total ".$row_count." Rows Found</p>";
|
||||
// Status Conditional Color
|
||||
foreach($rows as $row){
|
||||
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
|
||||
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
|
||||
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
|
||||
elseif($row['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
// if status = warm then select
|
||||
if($row['status'] == 'Warm'){$conditional_status = '<div class="flex flex-row"><p>'.$row['status'].'</p><select class="focus: outline-none " style="'.$conditional_background_color.' border: none;"><option>Option 1</option><option>Option 2</option></select></div>';}elseif($row['status'] != 'Warm'){$conditional_status = $row['status'];}
|
||||
?>
|
||||
<tr>
|
||||
<td class="border-y-2 p-2"><?php echo $row['name'] ?></td>
|
||||
<td class="border-y-2 p-2"><a href="/cleads/edit-lead/?id=<?php echo $row['id'] ?>"><?php echo $row['id'] ?></a></td>
|
||||
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $conditional_status;?></div></td>
|
||||
<td class="border-y-2 p-2">
|
||||
<p><i class="fa fa-envelope"> <?php echo $row['email'] ?></i></p>
|
||||
<p><i class="fa fa-phone"> <?php echo $row['phone'] ?></i></p>
|
||||
</td>
|
||||
<td class="border-y-2 p-2"><?php echo $row['formname'] ?></td>
|
||||
<td class="border-y-2 p-2"><?php echo $row['time'] ?></td>
|
||||
<td class="border-y-2 p-2">
|
||||
<div class="flex flex-row">
|
||||
<a href="<?php echo $row['email'] ?>"><i class="fa fa-whatsapp"></a></i>
|
||||
<a href="<?php echo $row['phone'] ?>"><i class="fa fa-envelope"></a></i>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php if ($currentPage > 1): ?>
|
||||
<a href="?page=<?php echo ($currentPage - 1); ?>">Previous</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
||||
<a href="?page=<?php echo $i; ?>" <?php if ($i === $currentPage) echo 'class="active"'; ?>><?php echo $i; ?></a>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if ($currentPage < $totalPages): ?>
|
||||
<a href="?page=<?php echo ($currentPage + 1); ?>">Next</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- New Lead Form Section -->
|
||||
<div id="add-lead-form" class="add-lead-form">
|
||||
<div class="flex flex-row place-content-between p-2" style="border-bottom: 2px solid #464E5F; border-style: dashed;">
|
||||
<p class="text-[25px] font-bold">Add Lead</p>
|
||||
<p onclick="toggleDisplay();" class="rounded-lg px-1.5 text-[#464E5F] text-[25px] cursor-pointer" style="border: 2px solid #464E5F; border-radius: 50%;">✘</p>
|
||||
</div>
|
||||
<form action="" method="post" class="p-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2">
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="country"> Country:</label>
|
||||
<select name="country" id="country" onchange="fetchStates()" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select Country</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="state"> State:</label>
|
||||
<select name="state" id="state" onchange="fetchCities()" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select State</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="city"> City:</label>
|
||||
<select name="city" id="city" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select City</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="address">Address:</label>
|
||||
<input class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="address" id="address" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="name">Name:</label>
|
||||
<input class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="name" id="name" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="gender">Gender:</label>
|
||||
<select class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="gender" id="gender" >
|
||||
<option value="Male">Male</option>
|
||||
<option value="Female">Female</option>
|
||||
<option value="Others">Others</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="profession">Profession:</label>
|
||||
<input class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="profession" id="profession" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="email">E-mail:</label>
|
||||
<input class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="email" id="email" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="phone">Phone:</label>
|
||||
<input class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="phone" id="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row place-content-between p-2 text-[25px] font-bold" style="border-bottom: 2px solid #464E5F; border-style: dashed;">Lead Information</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2">
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="origin">Details:</label>
|
||||
<select class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="origin" id="origin" >
|
||||
<option value="Facebook Ads">Facebook Ads</option>
|
||||
<option value="Google Ads">Google Ads</option>
|
||||
<option value="Linkedin Ads">Linkedin Ads</option>
|
||||
<option value="Instagram">Instagram</option>
|
||||
<option value="Messenger">Messenger</option>
|
||||
<option value="Whatsapp">Whatsapp</option>
|
||||
<option value="GMB">GMB</option>
|
||||
<option value="Linkedin">Linkedin</option>
|
||||
<option value="Inbound Call">Inbound Call</option>
|
||||
<option value="Outbound Call">Outbound Call</option>
|
||||
<option value="Others">Others</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="user">Lead Owner:</label>
|
||||
<select class="" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="user" id="user" >
|
||||
<?php
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("SELECT * FROM users");
|
||||
$stmt->execute();
|
||||
$users_rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$row_count = count($users_rows);
|
||||
if($row_count > 0){
|
||||
foreach($users_rows as $users_data){
|
||||
echo '<option value="'.$users_data['email'].'">'.$users_data['email'].'</option>';
|
||||
}
|
||||
} else{
|
||||
echo '<p>No users Found</p>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="note">Note:</label>
|
||||
<textarea type="text" name="note" id="note" rows="6" cols="10" style="border: 2px solid #363650; border-radius: 5px; padding: 6px;"></textarea>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<input class="p-2" type="submit" name="new_lead" id="new_lead" value="Submit" style="color:#fff; border-radius: 6px; background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; margin-top: 10px;"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
// Function to fetch countries and populate the country dropdown
|
||||
function fetchCountries() {
|
||||
fetch('https://api.siliconpin.com/v3/list/country/')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const countryDropdown = document.getElementById('country');
|
||||
countryDropdown.innerHTML = '<option value="">Select Country</option>';
|
||||
data.forEach(country => {
|
||||
const option = document.createElement('option');
|
||||
option.value = country.iso2;
|
||||
option.text = country.name;
|
||||
countryDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchStates() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const stateDropdown = document.getElementById('state');
|
||||
stateDropdown.innerHTML = '<option value="">Select State</option>';
|
||||
data.forEach(state => {
|
||||
const option = document.createElement('option');
|
||||
option.value = state.iso2;
|
||||
option.text = state.name;
|
||||
stateDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Function to fetch cities based on selected country and state and populate the city dropdown
|
||||
function fetchCities() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
const selectedState = document.getElementById('state').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${selectedCountry}&state=${selectedState}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const cityDropdown = document.getElementById('city');
|
||||
cityDropdown.innerHTML = '<option value="">Select City</option>';
|
||||
data.forEach(city => {
|
||||
const option = document.createElement('option');
|
||||
option.value = city.name;
|
||||
option.text = city.name;
|
||||
cityDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Fetch countries on page load
|
||||
fetchCountries();
|
||||
|
||||
const dialog = document.querySelector("dialog");
|
||||
const showButton = document.querySelector("dialog + button");
|
||||
const closeButton = document.querySelector("dialog button");
|
||||
|
||||
// "Show the dialog" button opens the dialog modally
|
||||
showButton.addEventListener("click", () => {
|
||||
dialog.showModal();
|
||||
});
|
||||
|
||||
// "Close" button closes the dialog
|
||||
closeButton.addEventListener("click", () => {
|
||||
dialog.close();
|
||||
});
|
||||
// Function to toggle display of the modal
|
||||
function toggleDisplay() {
|
||||
var element = document.getElementById('add-lead-form');
|
||||
if (element.style.display === 'block') {
|
||||
element.style.display = 'none';
|
||||
} else {
|
||||
element.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
// Event listener for the Esc key
|
||||
document.addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 27) {
|
||||
var modal = document.getElementById('add-lead-form');
|
||||
if (modal.style.display === 'block') {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.add-lead-form{
|
||||
background-color: #F8F8F8;
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
27
.hta_slug/leads/delete-lead.php
Normal file
27
.hta_slug/leads/delete-lead.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$stmt = $conn->prepare("DELETE FROM cleads WHERE id = :id");
|
||||
$stmt->bindParam(':id', $_POST['id']);
|
||||
$stmt->execute();
|
||||
echo '<script>window.location.href = "/cleads";</script>';
|
||||
exit();
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div>
|
||||
<form method="post">
|
||||
<p>Confirm to Delete id <?php echo $_GET['id']; ?>? </p>
|
||||
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
|
||||
<input type="submit" name="submit" id="submit" value="YES" />
|
||||
<a href="/cleads">NO</a>
|
||||
</form>
|
||||
</div>
|
||||
171
.hta_slug/leads/edit-lead copy.php
Normal file
171
.hta_slug/leads/edit-lead copy.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
// echo $_GET['id'];
|
||||
// Below two fetch for edit data
|
||||
try {
|
||||
$password = md5($_POST['pass']);
|
||||
$email = $_POST['email'];
|
||||
$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 id = :id");
|
||||
$stmt->bindParam(':id', $_GET['id']);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// var_dump($rows);
|
||||
foreach($rows as $row){ ?>
|
||||
<div>
|
||||
<p>ID:<?php echo $row['id']; ?></p>
|
||||
<p>FormName:<?php echo $row['formname']; ?></p>
|
||||
<p>Name:<?php echo $row['name']; ?></p>
|
||||
<p>Email:<?php echo $row['email']; ?></p>
|
||||
<p>Phone:<?php echo $row['phone']; ?></p>
|
||||
<p>Subject:<?php echo $row['subject']; ?></p>
|
||||
<p>Message:<?php echo $row['message']; ?></p>
|
||||
<p>Details:<?php echo $row['details']; ?></p>
|
||||
<p>Origin:<?php echo $row['origin']; ?></p>
|
||||
<p>Time:<?php echo $row['time']; ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
};
|
||||
|
||||
if($_SERVER['REQUEST_METHOD']=="POST" && $_POST['update_data']){
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("UPDATE cleads SET name = :name, email = :email, phone = :phone, date = :date, status = :status, user = :user WHERE id = :id");
|
||||
$stmt->bindParam(':name', $_POST['name']);
|
||||
$stmt->bindParam(':email', $_POST['email']);
|
||||
$stmt->bindParam(':phone', $_POST['phone']);
|
||||
$stmt->bindParam(':date', $_POST['date']);
|
||||
$stmt->bindParam(':status', $_POST['status']);
|
||||
$stmt->bindParam(':user', $_POST['user']);
|
||||
$stmt->bindParam(':id', $_GET['id']);
|
||||
$stmt->execute();
|
||||
|
||||
echo "Record Updated successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div style="max-width: 500px;">
|
||||
<form method="post">
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" name="name" id="name" value="<?php echo $row['name']; ?>" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="email">E-mail:</label>
|
||||
<input type="text" name="email" id="email" value="<?php echo $row['email']; ?>" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="phone">Phone:</label>
|
||||
<input type="text" name="phone" id="phone" value="<?php echo $row['phone']; ?>" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="date">FOLLOW UPDATE:</label>
|
||||
<input type="date" name="date" id="date" value="<?php echo $row['date']; ?>" />
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="phone">Lead Status:</label>
|
||||
<select name="status" id="status" slec value="<?php echo $row['status']; ?>">
|
||||
<option value=""></option>
|
||||
<option value="new">New</option>
|
||||
<option value="contacted">Contacted</option>
|
||||
<option value="warm">Warm</option>
|
||||
<option value="converted">Converted</option>
|
||||
<option value="inactive">Inactive</option>
|
||||
<option value="disqualified">Disqualified</option>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
if($_SESSION['user_type'] == "admin"){?>
|
||||
<div>
|
||||
<label for="user">Attach this Lead to a user:</label><br>
|
||||
<select name="user" id="user">
|
||||
<option value="0">-Select-</option>
|
||||
<?php
|
||||
try {
|
||||
$password = md5($_POST['pass']);
|
||||
$email = $_POST['email'];
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("SELECT * FROM users");
|
||||
$stmt->execute();
|
||||
$users_lead = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// var_dump($rows);
|
||||
foreach($users_lead as $user_lead){ ?>
|
||||
<option value="<?php echo $user_lead['email']; ?>"><?php echo $user_lead['email']; ?></option>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
};
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<input type="submit" id="update_data" name="update_data" value="Update">
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
// This is for save comment
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['save_comment'] && $_POST['comments'] ){
|
||||
try {
|
||||
$local_lang = 'en';
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("INSERT INTO comments (comments, user, locale, leadid) VALUES (:comments, :user, :locale, :leadid)");
|
||||
$stmt->bindParam(':comments', $_POST['comments']);
|
||||
$stmt->bindParam(':user', $_SESSION['email']);
|
||||
$stmt->bindParam(':locale', $local_lang);
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->execute();
|
||||
echo "New Comment save successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
$password = md5($_POST['pass']);
|
||||
$email = $_POST['email'];
|
||||
$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', $_GET['id']);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// var_dump($rows);
|
||||
foreach($rows as $row){ ?>
|
||||
<div>
|
||||
<p><?php echo $row['comments']; ?></p>
|
||||
<p><?php echo $row['user'].' '.date("Y-m-d", strtotime($row['created_at'])) ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
};
|
||||
?>
|
||||
|
||||
<form method="post">
|
||||
<div>
|
||||
<label for="comments">Comment:</label><br>
|
||||
<textarea name="comments" id="comments" cols="50" rows="10"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Save Comment" name="save_comment" id="save_comment" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
588
.hta_slug/leads/edit-lead.php
Normal file
588
.hta_slug/leads/edit-lead.php
Normal file
@@ -0,0 +1,588 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
// echo $_GET['id'];
|
||||
// Below two fetch for edit data
|
||||
|
||||
// this is count notifications
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM comments WHERE leadid = :leadid");
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->execute();
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
// echo $totalRecords;
|
||||
if($_SERVER['REQUEST_METHOD']=="POST" && $_POST['update_data']){
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("UPDATE cleads SET name = :name, email = :email, phone = :phone, date = :date, status = :status, user = :user, country = :country, state= :state, city = :city, address = :address, profession = :profession, coupon_code = :coupon_code, gender = :gender, warm_status = :warm_status WHERE id = :id");
|
||||
$stmt->bindParam(':name', $_POST['name']);
|
||||
$stmt->bindParam(':email', $_POST['email']);
|
||||
$stmt->bindParam(':phone', $_POST['phone']);
|
||||
$stmt->bindParam(':date', $_POST['date']);
|
||||
$stmt->bindParam(':status', $_POST['status']);
|
||||
$stmt->bindParam(':user', $_POST['user']);
|
||||
$stmt->bindParam(':country', $_POST['country']);
|
||||
$stmt->bindParam(':state', $_POST['state']);
|
||||
$stmt->bindParam(':city', $_POST['city']);
|
||||
$stmt->bindParam(':address', $_POST['address']);
|
||||
$stmt->bindParam(':profession', $_POST['profession']);
|
||||
$stmt->bindParam(':coupon_code', $_POST['coupon_code']);
|
||||
$stmt->bindParam(':gender', $_POST['gender']);
|
||||
$stmt->bindParam(':warm_status', $_POST['warm_status']);
|
||||
$stmt->bindParam(':id', $_GET['id']);
|
||||
$stmt->execute();
|
||||
|
||||
echo "Record Updated successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
};
|
||||
try {
|
||||
$password = md5($_POST['pass']);
|
||||
$email = $_POST['email'];
|
||||
$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 id = :id");
|
||||
$stmt->bindParam(':id', $_GET['id']);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// var_dump($rows);
|
||||
foreach($rows as $row){
|
||||
$nameParts = explode(" ", $row['name']);
|
||||
$firstInitial = substr($nameParts[0], 0, 1);
|
||||
$lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1);
|
||||
$name_letter = $firstInitial.$lastInitial;
|
||||
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 1px solid #FB5555; border-radius: 5px; color: #FB5555;';}
|
||||
elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 1px solid #2C9C9C; border-radius: 5px; color: #2C9C9C;';}
|
||||
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 1px solid #3F4254; border-radius: 5px; color: #3F4254;';}
|
||||
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 1px solid #40916C; border-radius: 5px; color: #40916C;';}
|
||||
elseif($row['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 1px solid #FB5555; border-radius: 5px; color: #FB5555;';}
|
||||
?>
|
||||
<div class="responsive-flex p-6 space-x-4">
|
||||
<form method="post">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex flex-col bg-[#F6F6F6] rounded-xl">
|
||||
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div class="flex flex-row justify-center place-items-center">
|
||||
<p class="h-fit p-[10px] rounded-l-full" style="background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%); font-size: 20px; color: #fff; font-weight: bold;"><?php echo $name_letter; ?></p>
|
||||
<div class="flex flex-row justify-center place-items-center items-center rounded-r-[5px]" style="border: 1px solid #D9D9D9; padding: 6px;">
|
||||
<input class="w-full rounded-r-[6px]" type="text" name="name" id="name" value="<?php echo $row['name']; ?>" style="background-color: #f6f6f6; border: none;" />
|
||||
<button class="copy-btn fa fa-copy" data-input-id="name"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row justify-center place-items-center items-center" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
||||
<input class="w-full" type="text" name="email" id="email" value="<?php echo $row['email']; ?>" style="background-color: #f6f6f6; border: none;" />
|
||||
<button class="copy-btn fa fa-copy" data-input-id="email"></button>
|
||||
</div>
|
||||
<div class="flex flex-row justify-center place-items-center items-center" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
||||
<input class="w-full" type="text" name="phone" id="phone" value="<?php echo $row['phone']; ?>" style="background-color: #f6f6f6; border: none;" />
|
||||
<button class="copy-btn fa fa-copy" data-input-id="phone"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div>
|
||||
<p><b>Client ID</b></p>
|
||||
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['id']; ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<p><b>Form Name</b></p>
|
||||
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['formname']; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div>
|
||||
<p><b>Country</b></p>
|
||||
<select class="w-full" name="country" id="country" onchange="fetchStates()" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
||||
<option selected value="<?php echo $row['country']; ?>"><?php echo $row['country']; ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<p><b>State</b></p>
|
||||
<select class="w-full" name="state" id="state" onchange="fetchCities()" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
||||
<option selected value="<?php echo $row['state']; ?>"><?php echo $row['state']; ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<p><b>City</b></p>
|
||||
<select class="w-full" name="city" id="city" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
||||
<option selected value="<?php echo $row['city']; ?>"><?php echo $row['city']; ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div>
|
||||
<p><b>Address</b></p>
|
||||
<input class="w-full" type="text" name="address" id="address" value="<?php echo $row['address']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
<div>
|
||||
<p><b>Profession</b></p>
|
||||
<input class="w-full" type="text" name="profession" id="profession" value="<?php echo $row['profession']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div>
|
||||
<p><b>Origin</b></p>
|
||||
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['origin']; ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<p><b>Lead Status</b></p>
|
||||
<div class="flex flex-row">
|
||||
<select class="w-full" name="status" id="status" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px; <?php echo $conditional_background_color; ?>">
|
||||
<?php
|
||||
$statusOptions = ['New', 'Contacted', 'Warm', 'Converted', 'Inactive', 'Disqualified'];
|
||||
foreach ($statusOptions as $option) {
|
||||
$selected = ($row['status'] === $option) ? 'selected' : '';
|
||||
echo '<option value="' . $option . '" ' . $selected . '>' . ucfirst($option) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
if ($row['status'] == 'Warm') {
|
||||
echo '<select class="w-full" name="warm_status" id="warm_status" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">';
|
||||
$options = array("Proposal Sent", "Meeting Conducted", "Interested");
|
||||
foreach ($options as $option) {
|
||||
$selected = ($option == $row['warm_status']) ? 'selected' : '';
|
||||
echo '<option value="' . $option . '" ' . $selected . '>' . $option . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div>
|
||||
<p><b>Coupon Code</b></p>
|
||||
<input class="w-full" type="text" name="coupon_code" id="coupon_code" value="<?php echo $row['coupon_code']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
<div>
|
||||
<p><b>Time</b></p>
|
||||
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['time']; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||
<div>
|
||||
<p><b>Follow Update</b></p>
|
||||
<input class="w-full" type="date" name="date" id="date" value="<?php echo $row['date']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding: 10px; ">
|
||||
<input type="submit" id="update_data" name="update_data" value="Update" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; border-radius: 6px; padding: 10px 30px 10px 30px; float: right; cursor: pointer;" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="flex flex-col div-custom-margin">
|
||||
<div class="bg-[#F6F6F6] rounded-xl p-3">
|
||||
<div class="flex flex-row place-content-between" style="border-bottom: 2px solid #7E8299; border-style: dashed; padding-bottom: 3px;">
|
||||
<p style="font-size: 25px; font-weight: bold;">Comments: <span><?php echo$totalRecords; ?></span></p>
|
||||
<button id="toggleButton" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; border-radius: 6px; padding: 6px 20px 6px 20px;">Add Comment</button>
|
||||
</div>
|
||||
<div>
|
||||
<?php
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['save_comment'] && $_POST['comments'] ){
|
||||
try {
|
||||
$local_lang = 'en';
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("INSERT INTO comments (comments, user, locale, leadid) VALUES (:comments, :user, :locale, :leadid)");
|
||||
$stmt->bindParam(':comments', $_POST['comments']);
|
||||
$stmt->bindParam(':user', $_SESSION['email']);
|
||||
$stmt->bindParam(':locale', $local_lang);
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->execute();
|
||||
echo "New Comment save successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
};
|
||||
?>
|
||||
<form class="" method="post" id="content" style="display: none;">
|
||||
<div class="flex flex-row" style="margin-top: 10px; border-bottom: 2px solid #7E8299; padding-bottom: 10px;">
|
||||
<input class="rounded-l-xl focus:outline-none w-1/2" type="text" name="comments" id="comments" style="border: 2px solid #363650; padding: 6px;" />
|
||||
<input class="rounded-r-xl focus:outline-none" type="submit" value="Save" name="save_comment" id="save_comment" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; padding: 8px 20px 8px 20px;" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div style="max-height: 265px; overflow-y: auto;">
|
||||
<?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 comments WHERE leadid = :leadid ORDER BY created_at DESC");
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach($rows as $row){
|
||||
$commenter_name_parts = explode("@", $row['user']);
|
||||
$commenter_first_name_letter = substr($commenter_name_parts[0], 0, 1);
|
||||
$commenter_last_name_letter = substr($commenter_name_parts[count($commenter_name_parts) - 1], 0, 1);
|
||||
?>
|
||||
<div style="">
|
||||
<div class="flex flex-row place-items-center" style="margin-top: 3px;">
|
||||
<p class=" p-2" style="background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%); border-radius: 50%; font-size: 20px; color: #fff; font-weight: bold; text-transform: uppercase;"><?php echo $commenter_first_name_letter.$commenter_last_name_letter; ?></p>
|
||||
<p ><b style="font-size: 16px;"> <?php echo $row['user'] ?></b><br><?php echo date("Y-m-d", strtotime($row['created_at'])) ?></p>
|
||||
<p style=""></p>
|
||||
</div>
|
||||
<p style="margin-top: 10px;"><?php echo $row['comments']; ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
};
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['appt_comment'] && $_POST['appt_date'] ){
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("INSERT INTO appointment (appt_date, email, name, leadid, comment) VALUES (:appt_date, :email, :name, :leadid, :comment)");
|
||||
$stmt->bindParam(':appt_date', $_POST['appt_date']);
|
||||
$stmt->bindParam(':email', $_SESSION['email']);
|
||||
$stmt->bindParam(':name', $_SESSION['name']);
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->bindParam(':comment', $_POST['comment']);
|
||||
$stmt->execute();
|
||||
$saved_message = "New Appointment save successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
};
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['appt_comment_update'] && $_POST['appt_date'] ){
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("UPDATE appointment SET appt_date = :appt_date, comment = :comment WHERE id = :appointment_id AND leadid = :leadid");
|
||||
$stmt->bindParam(':appt_date', $_POST['appt_date']);
|
||||
$stmt->bindParam(':comment', $_POST['comment']);
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->bindParam(':appointment_id', $_POST['appointment_id']);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$saved_message = "Appointment updated successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
};
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col mt-3 bg-[#F6F6F6] rounded-xl">
|
||||
<div class="flex flex-row place-content-between p-3" style="border-bottom: 2px solid #7E8299; border-style: dashed;">
|
||||
<div class="flex flex-col">
|
||||
<p style="font-size: 20px; font-weight: bold;">Add Appointment</p>
|
||||
<p><?php echo $saved_message; ?></p>
|
||||
</div>
|
||||
<button onclick="apptModal()" style="background: linear-gradient(180deg, #7875F4 0%, #46448E 100%); color: #fff; font-size: 20px; border-radius: 50%; padding: 0px 8px 0px 8px; height: fit-content;">+</button>
|
||||
</div>
|
||||
<div style="max-height: 265px; overflow-y: auto;">
|
||||
<?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 appointment WHERE leadid = :leadid");
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->execute();
|
||||
$appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Custom function to compare appointment dates
|
||||
function compareAppointmentDates($a, $b) {
|
||||
$dateA = new DateTime($a['appt_date']);
|
||||
$dateB = new DateTime($b['appt_date']);
|
||||
$currentDateTime = new DateTime();
|
||||
|
||||
// Compare appointment dates
|
||||
if ($dateA == $dateB) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if appointments are in the future or past
|
||||
if ($dateA > $currentDateTime && $dateB > $currentDateTime) {
|
||||
return ($dateA < $dateB) ? -1 : 1; // Sort by ascending date
|
||||
} elseif ($dateA < $currentDateTime && $dateB < $currentDateTime) {
|
||||
return ($dateA < $dateB) ? 1 : -1; // Sort by descending date
|
||||
} else {
|
||||
// One appointment is in the future and one is in the past
|
||||
return ($dateA > $dateB) ? -1 : 1; // Sort the future appointment first
|
||||
}
|
||||
}
|
||||
|
||||
// Sort appointments based on appointment date
|
||||
usort($appt_data, 'compareAppointmentDates');
|
||||
foreach($appt_data as $appt){
|
||||
$apptID = $appt['id'];
|
||||
// echo $appt['name'];
|
||||
$apptDate = explode(" ", $appt['appt_date']);
|
||||
$currentDateTime = new DateTime();
|
||||
$appointmentDateTime = new DateTime($appt['appt_date']);
|
||||
|
||||
if ($appointmentDateTime > $currentDateTime) {
|
||||
$app_status = 'Next Appointment';
|
||||
} elseif ($appointmentDateTime < $currentDateTime) {
|
||||
$app_status = 'Expired Appointment';
|
||||
} else {
|
||||
$app_status = 'Today\'s Appointment';
|
||||
}
|
||||
?>
|
||||
<div class="flex flex-col px-6" style="border-bottom: 2px solid #D9D9D9; ">
|
||||
<div class="flex flex-row place-content-between align-items-center">
|
||||
<p style="font-size: 15px; font-weight: bold;"><?php echo $app_status; ?></p>
|
||||
<button style="color:#6F6BFF; font-weight: bold;" onclick="apptEditModal(<?php echo $apptID; ?>)">Edit</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-3">
|
||||
<p><?php echo $appt['comment']; ?></p>
|
||||
<div class="flex flex-col" style="border-left: 3px solid #7875F4;">
|
||||
<p style="font-weight: bold; padding-left: 6px;"><?php echo $apptDate[0]; ?></p>
|
||||
<p style="padding-left: 6px;"><?php echo $apptDate[1]; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="appt-edit-modal<?php echo $apptID; ?>" class="add-appt-edit-modal">
|
||||
<div class="p-4">
|
||||
<p onclick="apptEditModal(<?php echo $apptID; ?>)" style="font-size: 16px; color: #464E5F; border: 2px solid #464E5F; border-radius: 50%; float: right; padding: 2px 6px 2px 6px; cursor: pointer;">✘</p>
|
||||
</div>
|
||||
<form method="post" enctype="multipart/form-data" class="p-6 space-y-4">
|
||||
<div class="flex flex-col">
|
||||
<label for="appt_date">Appointment Date</label>
|
||||
<input type="datetime-local" name="appt_date" id="appt_date" value="<?php echo $appt['appt_date'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
<input type="text" name="appointment_id" id="appointment_id" value="<?php echo $appt['id']; ?>">
|
||||
<div class="flex flex-col">
|
||||
<label for="appt-comment">Description (if needed)</label>
|
||||
<input type="text" name="comment" id="appt-comment" value="<?php echo $appt['comment'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<input class="rounded-xl focus:outline-none" type="submit" value="Update" name="appt_comment_update" id="appt_comment_update" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; padding: 8px 20px 8px 20px; cursor: pointer;" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
};
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- This IS Right Side DIV -->
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
};
|
||||
|
||||
?>
|
||||
<div id="appt-modal" class="add-appt-modal">
|
||||
<p onclick="apptModal();" style="font-size: 16px; color: #464E5F; border: 2px solid #464E5F; border-radius: 50%; float: right; padding: 2px 6px 2px 6px; cursor: pointer;">✘</p>
|
||||
<form method="post" enctype="multipart/form-data" class="p-6 space-y-4">
|
||||
<div class="flex flex-col">
|
||||
<label for="appt_date">Appointment Date</label>
|
||||
<input type="datetime-local" name="appt_date" id="appt_date" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<label for="appt-comment">Description (if needed)</label>
|
||||
<input type="text" name="comment" id="appt-comment" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<input class="rounded-xl focus:outline-none" type="submit" value="Add" name="appt_comment" id="appt_comment" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; padding: 8px 20px 8px 20px; cursor: pointer;" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Get all copy buttons
|
||||
const copyButtons = document.querySelectorAll('.copy-btn');
|
||||
|
||||
// Attach click event listeners to each copy button
|
||||
copyButtons.forEach(button => {
|
||||
button.addEventListener('click', event => {
|
||||
event.preventDefault(); // Prevent default button behavior
|
||||
|
||||
// Get the input ID associated with this button
|
||||
const inputId = button.getAttribute('data-input-id');
|
||||
// Get the input element by ID
|
||||
const inputElement = document.getElementById(inputId);
|
||||
|
||||
// Check if the input element exists and has a value
|
||||
if (inputElement && inputElement.value) {
|
||||
// Copy the input value to the clipboard using Clipboard API
|
||||
navigator.clipboard.writeText(inputElement.value)
|
||||
.then(() => {
|
||||
// Provide visual feedback to the user
|
||||
button.classList.add('copied');
|
||||
setTimeout(() => {
|
||||
button.classList.remove('copied');
|
||||
}, 1000); // Remove the 'copied' class after 2000ms
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Unable to copy:', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Function to fetch countries and populate the country dropdown
|
||||
function fetchCountries() {
|
||||
fetch('https://api.siliconpin.com/v3/list/country/')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const countryDropdown = document.getElementById('country');
|
||||
countryDropdown.innerHTML = '<option value="">Select Country</option>';
|
||||
data.forEach(country => {
|
||||
const option = document.createElement('option');
|
||||
option.value = country.iso2;
|
||||
option.text = country.name;
|
||||
countryDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchStates() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const stateDropdown = document.getElementById('state');
|
||||
stateDropdown.innerHTML = '<option value="">Select State</option>';
|
||||
data.forEach(state => {
|
||||
const option = document.createElement('option');
|
||||
option.value = state.iso2;
|
||||
option.text = state.name;
|
||||
stateDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchCities() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
const selectedState = document.getElementById('state').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${selectedCountry}&state=${selectedState}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const cityDropdown = document.getElementById('city');
|
||||
cityDropdown.innerHTML = '<option value="">Select City</option>';
|
||||
data.forEach(city => {
|
||||
const option = document.createElement('option');
|
||||
option.value = city.name;
|
||||
option.text = city.name;
|
||||
cityDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
// fetchCountries();
|
||||
let nameID = document.getElementById('name');
|
||||
let addressID = document.getElementById('address');
|
||||
let countryID = document.getElementById('country');
|
||||
let stateID = document.getElementById('state');
|
||||
let cityID = document.getElementById('city');
|
||||
let phoneID = document.getElementById('phone');
|
||||
let emailID = document.getElementById('email');
|
||||
let professionID = document.getElementById('profession');
|
||||
let statusID = document.getElementById('status');
|
||||
let coupon_codeID = document.getElementById('coupon_code');
|
||||
let dateID = document.getElementById('date');
|
||||
// document.getElementById('editButton').addEventListener('click', function() {
|
||||
// fetchCountries();
|
||||
// nameID.disabled = false;
|
||||
// addressID.disabled = false;
|
||||
// countryID.disabled = false;
|
||||
// stateID.disabled = false;
|
||||
// cityID.disabled = false;
|
||||
// phoneID.disabled = false;
|
||||
// emailID.disabled = false;
|
||||
// professionID.disabled = false;
|
||||
// statusID.disabled = false;
|
||||
// coupon_codeID.disabled = false;
|
||||
// dateID.disabled = false;
|
||||
// });
|
||||
|
||||
const toggleButton = document.getElementById('toggleButton');
|
||||
const content = document.getElementById('content');
|
||||
|
||||
toggleButton.addEventListener('click', function() {
|
||||
if (content.style.display === 'none') {
|
||||
content.style.display = 'block';
|
||||
toggleButton.textContent = 'Cancel';
|
||||
} else {
|
||||
content.style.display = 'none';
|
||||
toggleButton.textContent = 'Add Comment';
|
||||
}
|
||||
});
|
||||
function apptModal(){
|
||||
let apptForm = document.getElementById('appt-modal');
|
||||
if(apptForm.style.display === 'block'){
|
||||
apptForm.style.display = 'none'
|
||||
}else{
|
||||
apptForm.style.display = 'block'
|
||||
}
|
||||
}
|
||||
function apptEditModal(id){
|
||||
let apptEditForm = document.getElementById('appt-edit-modal' + id);
|
||||
if(apptEditForm.style.display === 'block'){
|
||||
apptEditForm.style.display = 'none'
|
||||
}else{
|
||||
apptEditForm.style.display = 'block'
|
||||
}
|
||||
}
|
||||
document.addEventListener('keydown', function(event){
|
||||
if(event.keyCode === 27){
|
||||
var apptModal = document.getElementById('appt-modal');
|
||||
if(apptModal.style.display === 'block'){
|
||||
apptModal.style.display = 'none';
|
||||
};
|
||||
var apptEditModal = document.getElementById('appt-edit-modal<?php echo $apptID; ?>');
|
||||
if(apptEditModal.style.display === 'block'){
|
||||
apptEditModal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
})
|
||||
document.addEventListener('keydown', function(event) {
|
||||
if (event.key === 'Escape') {
|
||||
let editModals = document.querySelectorAll('.add-appt-edit-modal');
|
||||
editModals.forEach(function(modal) {
|
||||
modal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.add-appt-modal, .add-appt-edit-modal{
|
||||
background-color: #F8F8F8;
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.copied {
|
||||
background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%);
|
||||
border-radius: 5px;
|
||||
color: #fff;
|
||||
}
|
||||
.responsive-flex {
|
||||
display: flex;
|
||||
flex-direction: row; /* Default value for screens wider than 1150px */
|
||||
}
|
||||
|
||||
/* Media query for screens narrower than 1150px */
|
||||
@media (max-width: 1150px) {
|
||||
.responsive-flex {
|
||||
flex-direction: column;
|
||||
}
|
||||
.div-custom-margin{
|
||||
margin-top: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
568
.hta_slug/leads/my-leads.php
Normal file
568
.hta_slug/leads/my-leads.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
// deleteCofermation()
|
||||
$today_date = date("Y-m-d");
|
||||
$next_day = date("Y-m-d", strtotime("+1 day"));
|
||||
$yesterday = date("Y-m-d", strtotime("-1 day"));
|
||||
$this_week = date("Y-m-d", strtotime("-7 day"));
|
||||
$prev_month_date = date("Y-m-d", strtotime("first day of previous month", strtotime($today_date)));
|
||||
$firstDayOfCurrentMonth = date("Y-m-01");
|
||||
$firstDayOfLastMonth = date("Y-m-01", strtotime("first day of last month"));
|
||||
$firstDateOfYear = date("Y") . '-01-01';
|
||||
$previousYear = date("Y") - 1;
|
||||
$firstDateOfPreviousYear = $previousYear . '-01-01';
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['new_lead']) && $_POST['new_lead'] && isset($_POST['name']) && $_POST['name'] && isset($_POST['phone']) && $_POST['phone']) {
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
$phone = $_POST['phone'];
|
||||
$formname = 'crm-portal';
|
||||
$note = $_POST['note'];
|
||||
$origin = $_POST['origin'];
|
||||
$gender = $_POST['gender'];
|
||||
$profession = $_POST['profession'];
|
||||
$country = $_POST['country'];
|
||||
$state = $_POST['state'];
|
||||
$city = $_POST['city'];
|
||||
$address = $_POST['address'];
|
||||
$status = 'New';
|
||||
try {
|
||||
$stmt = $conn->prepare("INSERT INTO cleads (name, email, phone, formname, note, origin, status, gender, profession, country, state, city, address ) VALUES (:name, :email, :phone, :formname, :note, :origin, :status, :gender, :profession, :country, :state, :city, :address)");
|
||||
$stmt->bindParam(':name', $name);
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->bindParam(':phone', $phone);
|
||||
$stmt->bindParam(':formname', $formname);
|
||||
$stmt->bindParam(':note', $note);
|
||||
$stmt->bindParam(':origin', $origin);
|
||||
$stmt->bindParam(':status', $status);
|
||||
$stmt->bindParam(':gender', $gender);
|
||||
$stmt->bindParam(':profession', $profession);
|
||||
$stmt->bindParam(':country', $country);
|
||||
$stmt->bindParam(':state', $state);
|
||||
$stmt->bindParam(':city', $city);
|
||||
$stmt->bindParam(':address', $address);
|
||||
$stmt->execute();
|
||||
echo "Record added successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if(isset($_POST['delete_records'])) {
|
||||
if(isset($_POST['selected_records']) && !empty($_POST['selected_records'])) {
|
||||
$selectedIds = $_POST['selected_records'];
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$delete_placeholders = rtrim(str_repeat('?,', count($selectedIds)), ',');
|
||||
$stmt = $conn->prepare("DELETE FROM cleads WHERE id IN ($delete_placeholders)");
|
||||
foreach($selectedIds as $key => $id) {
|
||||
$stmt->bindValue($key + 1, $id, PDO::PARAM_INT);
|
||||
}
|
||||
$stmt->execute();
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p class="text-[28px] font-bold p-4">Lead Management</p>
|
||||
<div id="page-body" class="flex flex-row place-content-between px-4">
|
||||
<dialog>
|
||||
<button style="float: right; color: #FF0000; font-size: 25px; padding: 6px;">✘</button>
|
||||
<div class="flex flex-row">
|
||||
<div class="flex flex-col p-6 space-y-4">
|
||||
<a href="/cleads?start_date=<?php echo $today_date ?>&end_date=<?php echo $next_day ?>">Today</a>
|
||||
<a href="/cleads?start_date=<?php echo $yesterday ?>&end_date=<?php echo $today_date ?>">Yesterday</a>
|
||||
<a href="/cleads?start_date=<?php echo $this_week ?>&end_date=<?php echo $today_date ?>">This Week</a>
|
||||
<a href="/cleads?start_date=<?php echo $firstDayOfCurrentMonth ?>&end_date=<?php echo $today_date ?>">This Month</a>
|
||||
<a href="/cleads?start_date=<?php echo $prev_month_date ?>&end_date=<?php echo $today_date ?>">Last Month</a>
|
||||
<a href="/cleads?start_date=<?php echo $firstDateOfYear ?>&end_date=<?php echo $today_date ?>">This Year</a>
|
||||
<a href="/cleads?start_date=<?php echo $firstDateOfPreviousYear ?>&end_date=<?php echo $today_date ?>">Last Year</a>
|
||||
<a href="/cleads">All Time</a>
|
||||
</div>
|
||||
<form method="GET" class="p-6 flex flex-col pb-10">
|
||||
<p>Choose Date for filter</p>
|
||||
<div class="flex flex-row rounded-xl py-10">
|
||||
<div class="flex flex-row place-items-center">
|
||||
<label for="start_date">From Date</label>
|
||||
<input type="date" name="start_date" id="start_date" />
|
||||
</div> |
|
||||
<div class="flex flex-row place-items-center">
|
||||
<label for="end_date">To Date</label>
|
||||
<input type="date" name="end_date" id="end_date" />
|
||||
</div>
|
||||
</div>
|
||||
<button class="rounded-lg p-1 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;" type="submit"><p class="text-center p-1.5">Search</p></button>
|
||||
</form>
|
||||
</div>
|
||||
</dialog>
|
||||
<p onclick="deleteCofermation();" class="rounded-lg pt-2 px-6 text-[#fff] text-center" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); cursor: pointer;">Delete</p>
|
||||
<button class="rounded-lg p-2 bg-[#fff] text-[#464E5F] shadow-lg" style="">Select Date</button>
|
||||
<div class="flex flex-row">
|
||||
<form method="GET" action="" class="bg-[#fff] flex flex-row place-items-center">
|
||||
<input class="p-2.5 rounded-l-lg focus:outline-none w-[320px]" type="text" name="search" placeholder="Name / ID / Mobile / Email" style="border: 2px solid #8E8E8E;">
|
||||
<button class="rounded-r-lg text-[#fff] p-1.5" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);" type="submit"><i class="fa fa-search"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
<button onclick="toggleDisplay();" class="rounded-lg p-2 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;">Add Leads</button>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="width: 100%;" >
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if($_SESSION['user_type'] == 'admin')
|
||||
echo ' <th class="text-center border-b-2 p-3">
|
||||
<div class="delete-confirm" id="delete-button" style="display: none;">
|
||||
<p>Are you sure you want to delete this lead?</p>
|
||||
<div class="flex flex-row space-x-4">
|
||||
<p onclick="deleteCofermation();" class="rounded-lg p-2 text-[#443780] mr-4" style="border: 2px solid #443780; cursor: pointer;">No</p>
|
||||
<button class="rounded-lg p-3 text-[#fff]" type="submit" name="delete_records" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);">Yes</button>
|
||||
</div>
|
||||
</div>
|
||||
</th>';
|
||||
?>
|
||||
<th class="text-center border-b-2 p-3">Name</th>
|
||||
<th class="text-center border-b-2 p-3">ID</th>
|
||||
<th class="text-center border-b-2 p-3">Status Update</th>
|
||||
<!-- <th class="text-center border-b-2 p-3">Contact Detail</th> -->
|
||||
<th class="text-center border-b-2 p-3">Form Name</th>
|
||||
<th class="text-center border-b-2 p-3">Date & Time</th>
|
||||
<th class="text-center border-b-2 p-3">Quick Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
<?php
|
||||
// Number of records per page
|
||||
$recordsPerPage = 500;
|
||||
|
||||
// Current page
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
$currentPage = intval($_GET['page']);
|
||||
} else {
|
||||
$currentPage = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$searchQuery = isset($_GET['search']) ? trim($_GET['search']) : '';
|
||||
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
|
||||
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';
|
||||
$accessArray = explode(",", $_SESSION['access']);
|
||||
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
|
||||
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
|
||||
|
||||
$all_states = "WB, SK";
|
||||
$state_array = explode(',', $all_states);
|
||||
$state_placeholder = rtrim(str_repeat('?,', count($state_array)), ',');
|
||||
|
||||
if (!empty($searchQuery)) {
|
||||
// this is keywords search
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE (id LIKE ? OR name LIKE ? OR email LIKE ? OR phone LIKE ?) AND business_type IN ($placeholders) ORDER BY time DESC LIMIT ?, ?");
|
||||
$stmt->bindValue(1, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(2, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(3, "%$searchQuery%", PDO::PARAM_STR);
|
||||
$stmt->bindValue(4, "%$searchQuery%", PDO::PARAM_STR);
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 5, $value);
|
||||
}
|
||||
$stmt->bindValue(count($accessArray) + 5, 0, PDO::PARAM_INT); // Offset for pagination
|
||||
$stmt->bindValue(count($accessArray) + 6, $recordsPerPage, PDO::PARAM_INT); // Records per page
|
||||
// this is for date serch
|
||||
}elseif (!empty($start_date) && !empty($end_date)) {
|
||||
$start_date = date('Y-m-d', strtotime($start_date));
|
||||
$end_date = date('Y-m-d', strtotime($end_date));
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE time BETWEEN ? AND ? AND business_type IN ($placeholders)");
|
||||
$stmt->bindValue(1, $start_date);
|
||||
$stmt->bindValue(2, $end_date);
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 3, $value);
|
||||
}
|
||||
}else{
|
||||
// if user type admin then show all lead
|
||||
if($_SESSION['user_type'] == 'admin'){
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads");
|
||||
$stmt->execute();
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
|
||||
$totalPages = ceil($totalRecords / $recordsPerPage);
|
||||
|
||||
$offset = ($currentPage - 1) * $recordsPerPage;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads ORDER BY time DESC LIMIT :offset, :recordsPerPage");
|
||||
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':recordsPerPage', $recordsPerPage, PDO::PARAM_INT);
|
||||
}else{
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads WHERE business_type IN ($placeholders) AND state IN ($state_placeholder)");
|
||||
|
||||
// Bind values for business types
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 1, $value);
|
||||
}
|
||||
|
||||
// Bind values for states
|
||||
$statePlaceholderStartIndex = count($accessArray) + 1; // Start index for state placeholders
|
||||
foreach ($state_array as $key => $state_value) {
|
||||
$stmt->bindValue($statePlaceholderStartIndex + $key, $state_value);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$totalRecords = $stmt->fetchColumn();
|
||||
$totalPages = ceil($totalRecords / $recordsPerPage);
|
||||
$offset = ($currentPage - 1) * $recordsPerPage;
|
||||
|
||||
// Adjusting the SQL query to remove duplicate state placeholders
|
||||
$state_placeholders = implode(',', array_fill(0, count($state_array), '?')); // Generate placeholders for states
|
||||
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type IN ($placeholders) AND state IN ($state_placeholders) ORDER BY time DESC LIMIT ?, ?");
|
||||
|
||||
// Bind values for business types
|
||||
$paramCount = count($accessArray);
|
||||
for ($i = 0; $i < $paramCount; $i++) {
|
||||
$stmt->bindValue($i + 1, $accessArray[$i]);
|
||||
}
|
||||
|
||||
// Bind values for states
|
||||
$statePlaceholderStartIndex = $paramCount + 1; // Start index for state placeholders
|
||||
for ($i = 0; $i < count($state_array); $i++) {
|
||||
$stmt->bindValue($statePlaceholderStartIndex + $i, $state_array[$i]);
|
||||
}
|
||||
|
||||
// Bind the offset and recordsPerPage parameters
|
||||
$stmt->bindValue($paramCount + count($state_array) + 1, $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue($paramCount + count($state_array) + 2, $recordsPerPage, PDO::PARAM_INT);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
var_dump($rows);
|
||||
$row_count = count($rows);
|
||||
for ($i = 0; $i < $row_count; $i++) {
|
||||
// echo $row_count . " ";
|
||||
}
|
||||
echo "<p class='px-4'>Total ".$row_count." Rows Found</p>";
|
||||
// Status Conditional Color
|
||||
foreach($rows as $row){
|
||||
$lead_id = $row['id'];
|
||||
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
|
||||
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
|
||||
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
|
||||
elseif($row['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
// if status = warm then select
|
||||
// if($row['status'] == 'Warm'){$conditional_status = '<div class="flex flex-row"><p>'.$row['status'].'</p><select class="focus: outline-none " style="'.$conditional_background_color.' border: none;"><option>Option 1</option><option>Option 2</option></select></div>';}elseif($row['status'] != 'Warm'){$conditional_status = $row['status'];}
|
||||
?>
|
||||
<tr>
|
||||
<?php if($_SESSION['user_type'] == 'admin'){?>
|
||||
<td class="border-y-2 p-2">
|
||||
<input type="checkbox" name="selected_records[]" value="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>" />
|
||||
</td>
|
||||
<?php }?>
|
||||
<td class="border-y-2 p-2"><label for="<?php echo $row['id']; ?>"><?php echo $row['name'] ?></label></td>
|
||||
<td class="border-y-2 p-2 text-blue-500 hover:text-blue-700 hover:underline"><a href="/cleads/edit-lead/?id=<?php echo $row['id'] ?>"><?php echo $row['id'] ?></a></td>
|
||||
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $row['status'];?></div></td>
|
||||
<!-- <td class="border-y-2 p-2">
|
||||
<p><i class="fa fa-envelope"> <?php // echo $row['email'] ?></i></p>
|
||||
<p><i class="fa fa-phone"> <?php // echo $row['phone'] ?></i></p>
|
||||
</td> -->
|
||||
<td class="border-y-2 p-2"><?php echo $row['formname'] ?></td>
|
||||
<td class="border-y-2 p-2"><?php echo $row['time'] ?></td>
|
||||
<td class="border-y-2 p-2">
|
||||
<div class="flex flex-row justify-center place-items-center">
|
||||
<a href="mailto:<?php echo $row['email'] ?>"><i class="fa fa-envelope" style="font-size: 20px"></i></a>
|
||||
<a href="https://wa.me/<?php echo $row['phone'] ?>?text=Hello%2C%20how%20are%20you%3F"><i class="fab fa-whatsapp" style="font-size: 20px"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php if ($currentPage > 1): ?>
|
||||
<a href="?page=<?php echo ($currentPage - 1); ?>">Previous</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
||||
<a href="?page=<?php echo $i; ?>" <?php if ($i === $currentPage) echo 'class="active"'; ?>><?php echo $i; ?></a>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if ($currentPage < $totalPages): ?>
|
||||
<a href="?page=<?php echo ($currentPage + 1); ?>">Next</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- New Lead Form Section -->
|
||||
<div id="add-lead-form" class="add-lead-form">
|
||||
<div class="flex flex-row place-content-between p-2" style="border-bottom: 2px solid #464E5F; border-style: dashed;">
|
||||
<p class="text-[25px] font-bold">Add Lead</p>
|
||||
<p onclick="toggleDisplay();" class="rounded-lg px-1.5 text-[#464E5F] text-[25px] cursor-pointer" style="border: 2px solid #464E5F; border-radius: 50%;">✘</p>
|
||||
</div>
|
||||
<form action="" method="post" class="p-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2">
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="country"> Country:</label>
|
||||
<select name="country" id="country" onchange="fetchStates()" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select Country</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="state"> State:</label>
|
||||
<select name="state" id="state" onchange="fetchCities()" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select State</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="city"> City:</label>
|
||||
<select name="city" id="city" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
|
||||
<option value="">Select City</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="address">Address:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="address" id="address" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="name">Name:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="name" id="name" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="gender">Gender:</label>
|
||||
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="gender" id="gender" >
|
||||
<option value="Male">Male</option>
|
||||
<option value="Female">Female</option>
|
||||
<option value="Others">Others</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="profession">Profession:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="profession" id="profession" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="email">E-mail:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="email" id="email" />
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="phone">Phone:</label>
|
||||
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="phone" id="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row place-content-between p-2 text-[25px] font-bold" style="border-bottom: 2px solid #464E5F; border-style: dashed;">Lead Information</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2">
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="origin">Details:</label>
|
||||
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="origin" id="origin" >
|
||||
<option value="Facebook Ads">Facebook Ads</option>
|
||||
<option value="Google Ads">Google Ads</option>
|
||||
<option value="Linkedin Ads">Linkedin Ads</option>
|
||||
<option value="Instagram">Instagram</option>
|
||||
<option value="Messenger">Messenger</option>
|
||||
<option value="Whatsapp">Whatsapp</option>
|
||||
<option value="GMB">GMB</option>
|
||||
<option value="Linkedin">Linkedin</option>
|
||||
<option value="Inbound Call">Inbound Call</option>
|
||||
<option value="Outbound Call">Outbound Call</option>
|
||||
<option value="Others">Others</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="user">Lead Owner:</label>
|
||||
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="user" id="user" >
|
||||
<?php
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("SELECT * FROM users");
|
||||
$stmt->execute();
|
||||
$users_rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$row_count = count($users_rows);
|
||||
if($row_count > 0){
|
||||
foreach($users_rows as $users_data){
|
||||
echo '<option value="'.$users_data['email'].'">'.$users_data['email'].'</option>';
|
||||
}
|
||||
} else{
|
||||
echo '<p>No users Found</p>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col mr-4">
|
||||
<label for="note">Note:</label>
|
||||
<textarea type="text" name="note" id="note" rows="6" cols="10" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;"></textarea>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<input class="p-2" type="submit" name="new_lead" id="new_lead" value="Submit" style="color:#fff; border-radius: 6px; background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; margin-top: 10px;"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
// Function to fetch countries and populate the country dropdown
|
||||
function fetchCountries() {
|
||||
fetch('https://api.siliconpin.com/v3/list/country/')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const countryDropdown = document.getElementById('country');
|
||||
countryDropdown.innerHTML = '<option value="">Select Country</option>';
|
||||
data.forEach(country => {
|
||||
const option = document.createElement('option');
|
||||
option.value = country.iso2;
|
||||
option.text = country.name;
|
||||
countryDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchStates() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const stateDropdown = document.getElementById('state');
|
||||
stateDropdown.innerHTML = '<option value="">Select State</option>';
|
||||
data.forEach(state => {
|
||||
const option = document.createElement('option');
|
||||
option.value = state.iso2;
|
||||
option.text = state.name;
|
||||
stateDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Function to fetch cities based on selected country and state and populate the city dropdown
|
||||
function fetchCities() {
|
||||
const selectedCountry = document.getElementById('country').value;
|
||||
const selectedState = document.getElementById('state').value;
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${selectedCountry}&state=${selectedState}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const cityDropdown = document.getElementById('city');
|
||||
cityDropdown.innerHTML = '<option value="">Select City</option>';
|
||||
data.forEach(city => {
|
||||
const option = document.createElement('option');
|
||||
option.value = city.name;
|
||||
option.text = city.name;
|
||||
cityDropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Fetch countries on page load
|
||||
fetchCountries();
|
||||
|
||||
const dialog = document.querySelector("dialog");
|
||||
const showButton = document.querySelector("dialog + button");
|
||||
const closeButton = document.querySelector("dialog button");
|
||||
|
||||
// "Show the dialog" button opens the dialog modally
|
||||
showButton.addEventListener("click", () => {
|
||||
dialog.showModal();
|
||||
});
|
||||
|
||||
// "Close" button closes the dialog
|
||||
closeButton.addEventListener("click", () => {
|
||||
dialog.close();
|
||||
});
|
||||
function toggleDisplay() {
|
||||
var element = document.getElementById('add-lead-form');
|
||||
if (element.style.display === 'block') {
|
||||
element.style.display = 'none';
|
||||
} else {
|
||||
element.style.display = 'block';
|
||||
element.classList.add('slide-in-animation'); // Add class to trigger animation
|
||||
}
|
||||
}
|
||||
|
||||
// Event listener for the Esc key
|
||||
document.addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 27) {
|
||||
var modal = document.getElementById('add-lead-form');
|
||||
if (modal.style.display === 'block') {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
function deleteCofermation(){
|
||||
let deleteButton = document.getElementById('delete-button');
|
||||
let leadID = document.getElementById('<?php echo $row['id']; ?>').value;
|
||||
if(leadID != null){
|
||||
if(deleteButton.style.display === 'flex'){
|
||||
deleteButton.style.display = 'none';
|
||||
}else{
|
||||
deleteButton.style.display = 'flex'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.add-lead-form {
|
||||
background-color: #F8F8F8;
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0%;
|
||||
right: 0%;
|
||||
transform: translateX(100%);
|
||||
/* transform: translate(-0%, -50%); */
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 2px;
|
||||
z-index: 100;
|
||||
height: 100%;
|
||||
animation: slideInRight 0.5s forwards; /* Animation to slide in */
|
||||
/* overflow-x: auto; */
|
||||
}
|
||||
|
||||
@keyframes slideInRight {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateX(0%);
|
||||
}
|
||||
}
|
||||
/* .add-lead-form{
|
||||
background-color: #F8F8F8;
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
right: 0%;
|
||||
transform: translate(-0%, -50%);
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 5px;
|
||||
z-index: 100;
|
||||
height: 100%;
|
||||
} */
|
||||
.delete-confirm{
|
||||
position: fixed;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
background-color: #E6E5F4;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
padding: 40px 50px 40px 50px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
15
.hta_slug/leads/test.php
Normal file
15
.hta_slug/leads/test.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>WhatsApp Message Link</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Replace "1234567890" with the phone number and "Hello!" with the message you want to send -->
|
||||
<a href="https://wa.me/919635598420?text=Hello!" target="_blank">Click here to message</a>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
68
.hta_slug/leads/v3.php
Normal file
68
.hta_slug/leads/v3.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
require_once('.hta_config/crm_config.php');
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
// echo $_SESSION['access'];
|
||||
?>
|
||||
<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) LIMIT 2");
|
||||
foreach ($accessArray as $key => $value) {
|
||||
$stmt->bindValue($key + 1, $value);
|
||||
}
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// var_dump($rows);
|
||||
echo json_encode($rows);
|
||||
echo '
|
||||
<div id="example-table"></div>
|
||||
|
||||
<link href="https://unpkg.com/tabulator-tables@6.2.0/dist/css/tabulator.min.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@6.2.0/dist/js/tabulator.min.js"></script>
|
||||
<script>
|
||||
//define data
|
||||
var tabledata = '.json_encode($rows).';
|
||||
|
||||
//define table
|
||||
var table = new Tabulator("#example-table", {
|
||||
data:tabledata,
|
||||
autoColumns:true,
|
||||
});
|
||||
</script>
|
||||
';
|
||||
$num_rows = $stmt->rowCount();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- <script src="https://cdn.datatables.net/2.0.3/js/dataTables.js"></script>
|
||||
<script>
|
||||
let table = new DataTable('#myTable', {
|
||||
// options
|
||||
});
|
||||
</script> -->
|
||||
35
.hta_slug/leads/v4.php
Normal file
35
.hta_slug/leads/v4.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Grid.js Row Selection Example</title>
|
||||
<!-- Include Grid.js CDN link -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/gridjs/dist/gridjs.production.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridjs/dist/theme/mermaid.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="grid"></div>
|
||||
|
||||
<script>
|
||||
const grid = new gridjs.Grid({
|
||||
columns: ['ID', 'Name', 'Age'],
|
||||
data: [
|
||||
[1, 'John', 30],
|
||||
[2, 'Doe', 25],
|
||||
[3, 'Jane', 35]
|
||||
],
|
||||
plugins: [
|
||||
gridjs.plugins.selection({
|
||||
enabled: true,
|
||||
// Optional: handle selection change
|
||||
onChange: (selectedRows, selectedRowIds) => {
|
||||
console.log("Selected Rows:", selectedRows);
|
||||
console.log("Selected Row IDs:", selectedRowIds);
|
||||
}
|
||||
})
|
||||
]
|
||||
}).render(document.getElementById('grid'));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user