lead edit page

b3
Suvodip 2024-05-08 17:57:11 +05:30
parent 56fb4cb4fe
commit 25df82ac8c
7 changed files with 1142 additions and 39 deletions

View File

@ -173,7 +173,7 @@
</div>
</div>
</form>
<div class="flex flex-col div-custom-margin">
<div class="flex flex-col div-custom-margin" style="" >
<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>
@ -286,6 +286,17 @@
$stmt->bindParam(':leadid', $_GET['id']);
$stmt->execute();
$appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$appt_rowCount = count($appt_data);
if($appt_rowCount > 0){
foreach($appt_data as $apptID){
$apptID = $apptID['id'];
}
}else{
$apptID = 1;
}
// echo $apptID;
// Custom function to compare appointment dates
function compareAppointmentDates($a, $b) {
@ -311,9 +322,8 @@
// Sort appointments based on appointment date
usort($appt_data, 'compareAppointmentDates');
foreach($appt_data as $appt){
$apptID = $appt['id'];
// echo $appt['name'];
foreach($appt_data as $appt){
$apptDate = explode(" ", $appt['appt_date']);
$currentDateTime = new DateTime();
$appointmentDateTime = new DateTime($appt['appt_date']);

View File

@ -1,4 +1,5 @@
<style>
/* Quick action Sub menu */
.xzmdropdown-wrapper {
position: relative;
display: inline-block;
@ -113,12 +114,10 @@
}
?>
<?php
if(isset($_POST['delete_records'])) {
if(isset($_POST['delete_records']) && isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'admin') {
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) {
@ -193,7 +192,6 @@
</div>
</th>';
?>
<th class="text-center border-b-2 p-3">BV</th>
<th class="text-center border-b-2 p-3">Quick Action</th>
<th class="text-center border-b-2 p-3">Name</th>
<th class="text-center border-b-2 p-3">ID</th>
@ -207,8 +205,6 @@
<?php
//?bv=teenybeans&start_date=2024-05-04&end_date=2024-05-18
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$searchTerm =isset($_GET['search']) ? $_GET['search'] : "%";
$businessVertical =isset($_GET['bv']) ? $_GET['bv'] : "%";
// echo $businessVertical;
@ -223,36 +219,31 @@
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
//first query to get the total number for pagination
$sql = "SELECT COUNT(*) FROM cleads
WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND business_type LIKE 'iimtt'";
$sql= "SELECT COUNT(*) FROM cleads WHERE business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':searchTerm', "%$searchTerm%");
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->bindValue(':businessVertical', $businessVertical);
$stmt->bindValue(':searchTerm', "%".$searchTerm."%");
$stmt->bindValue(':start_date', $start_date);
$stmt->bindValue(':end_date', $end_date);
// $stmt->bindValue(':businessVertical', $businessVertical);
$stmt->execute();
$totalRows = $stmt->fetchColumn();
// second & final query to get the page_view data
$sql = "SELECT * FROM cleads
WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND business_type LIKE 'iimtt'
ORDER BY id DESC LIMIT :limit OFFSET :offset";
$sql = "SELECT * FROM cleads WHERE business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ORDER BY id DESC LIMIT :limit OFFSET :offset";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':businessVertical', $businessVertical, PDO::PARAM_STR );
$stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->bindValue(':start_date', $start_date);
$stmt->bindValue(':end_date', $end_date);
// $stmt->bindValue(':businessVertical', $businessVertical);
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalResults = count($leads);
$totalPages = ceil($totalRows / $resultsPerPage);
echo "<p class='px-4'>Total ".$totalRows." Rows Found</p>";
if($resultsPerPage <= $totalRows) echo "<p class='px-4'>".$resultsPerPage." Out of ".$totalRows." Leads </p>";
else echo "<p class='px-4'>".$totalRows." Leads </p>";
// Status Conditional Color
foreach($leads as $lead){
$only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available';
@ -266,7 +257,6 @@
// 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><?php echo $lead['business_type'] ?></td>
<td class="border-y-2 p-2">
<div class="flex flex-row justify-center place-items-center">
<div class="xzmdropdown-wrapper">
@ -330,20 +320,15 @@
$getParams = $_GET; unset($getParams['page']); $getParams['page'] = $page-1; $backPage= http_build_query($getParams); unset($getParams['page']);
$getParams['page'] = $page+1; $nextkPage= http_build_query($getParams);
echo'
<div class="bg-white p-4 flex items-center flex-wrap">
<nav aria-label="Page navigation">
<ul class="flex flex-row ">
<li><button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-l-lg" > &nbsp;'; if($page>1) echo '<a href="?',$backPage,'">&lt;','</a>'; echo ' &nbsp; </button></li>
<li><button class="px-4 py-2 text-white border-y border-[#443780]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);"> &nbsp; '.$page.' &nbsp; </button></li>
<li><button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-r-lg" > &nbsp;'; if($page<$totalPages) echo '<a href="?',$nextkPage,'">&gt;','</a>'; echo ' &nbsp;</button></li>
</ul>
</nav>
</div>
';
// echo $totalPages;
echo'<div class="flex flex-row justify-end">
<button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-l-lg" > &nbsp;'; if($page>1) echo '<a href="?',$backPage,'">&lt;','</a>'; echo ' &nbsp; </button>
<button class="px-4 py-2 text-white border-y border-[#443780]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);"> &nbsp; '.$page.' &nbsp; </button>
<button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-r-lg" > &nbsp;'; if($page<$totalPages) echo '<a href="?',$nextkPage,'">&gt;','</a>'; echo ' &nbsp;</button>
</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;">
@ -517,7 +502,7 @@ echo'
});
function deleteCofermation(){
let deleteButton = document.getElementById('delete-button');
let leadID = document.getElementById('<?php echo $lead['id']; ?>').value; //getting Err: here
let leadID = document.getElementById('<?php if(isset($lead['id'])) echo $lead['id']; ?>').value; //getting Err: here
if(leadID != null){
if(deleteButton.style.display === 'flex'){
deleteButton.style.display = 'none';

View File

@ -24,6 +24,7 @@
$_SESSION["log_status"] = 1;
$_SESSION["user_type"] = $row['type'];
$_SESSION["access"] = $row['access'];
$_SESSION["states"] = $row['states'];
$_SESSION["name"] = $row['name'];
$_SESSION["email"] = $row['email'];
echo '<script>window.location.href = "/leads";</script>';

508
.hta_slug/my-leads.php Normal file
View File

@ -0,0 +1,508 @@
<style>
/* Quick action Sub menu */
.xzmdropdown-wrapper {
position: relative;
display: inline-block;
}
.xzmdropdown-content {
display: none;
position: absolute;
background-color: #EAEAEA;
min-width: 120px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
z-index: 1;
border: 1px solid #939393;
border-radius: 5px;
}
.xzmdropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.xzmdropdown-content a:hover {
background-color: #B2B0FF;
}
.xzmdropdown-wrapper:hover .xzmdropdown-content {
display: block;
}
.xzmdropdown-submenu {
position: absolute;
top: 0;
left: 100%;
margin-top: 105px;
display: none;
background-color: #EAEAEA; /* Background color for submenu */
min-width: 120px; /* Adjust width as needed */
border: 1px solid #939393;
border-radius: 5px;
}
.xzmdropdown-content .xzmdropdown-item:hover .xzmdropdown-submenu {
display: block;
}
.xzmdropdown-submenu a {
padding: 10px 16px; /* Padding for submenu items */
display: block;
}
.xzmdropdown-submenu a:hover {
background-color: #c0c0c0; /* Hover background color for submenu items */
}
</style>
<?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']) && isset($_POST['name']) && isset($_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 id="page-body" class="flex flex-row place-content-between px-4">
<dialog>
<button style="float: right; color: #FF0000; font-size: 25px; padding: 6px;">&#10008;</button>
<div class="flex flex-row">
<div class="flex flex-col p-6 space-y-4">
<a href="/leads?start_date=<?php echo $today_date ?>&end_date=<?php echo $next_day ?>">Today</a>
<a href="/leads?start_date=<?php echo $yesterday ?>&end_date=<?php echo $today_date ?>">Yesterday</a>
<a href="/leads?start_date=<?php echo $this_week ?>&end_date=<?php echo $today_date ?>">This Week</a>
<a href="/leads?start_date=<?php echo $firstDayOfCurrentMonth ?>&end_date=<?php echo $today_date ?>">This Month</a>
<a href="/leads?start_date=<?php echo $prev_month_date ?>&end_date=<?php echo $today_date ?>">Last Month</a>
<a href="/leads?start_date=<?php echo $firstDateOfYear ?>&end_date=<?php echo $today_date ?>">This Year</a>
<a href="/leads?start_date=<?php echo $firstDateOfPreviousYear ?>&end_date=<?php echo $today_date ?>">Last Year</a>
<a href="/leads">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> &nbsp; | &nbsp;
<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 h-fit 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 h-fit 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>
<th class="text-center border-b-2 p-3">BV</th>
<th class="text-center border-b-2 p-3">Quick Action</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>
</tr>
</thead>
<tbody >
<?php
//?bv=teenybeans&start_date=2024-05-04&end_date=2024-05-18
try {
$searchTerm =isset($_GET['search']) ? $_GET['search'] : "%";
$businessVertical =isset($_GET['bv']) ? $_GET['bv'] : "%";
// echo $businessVertical;
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '2014-05-05';
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d');
$start_time = microtime(true);
$resultsPerPage = 100;
$page =isset($_GET['page']) ? $_GET['page'] : 1;
$offset = ($page - 1) * $resultsPerPage ;
$accessArray = explode(",", $_SESSION['access']);
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
//first query to get the total number for pagination
$sql= "SELECT COUNT(*) FROM cleads WHERE state IN (".$_SESSION["states"].") AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':businessVertical', $businessVertical);
$stmt->bindValue(':searchTerm', "%".$searchTerm."%");
$stmt->bindValue(':start_date', $start_date);
$stmt->bindValue(':end_date', $end_date);
$stmt->execute();
$totalRows = $stmt->fetchColumn();
// second & final query to get the page_view data
//SELECT * FROM cleads WHERE state IN ('HR', 'TR', 'MP', 'CT', 'LA', 'international');
$sql = "SELECT * FROM cleads WHERE business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ORDER BY id DESC LIMIT :limit OFFSET :offset";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':businessVertical', $businessVertical, PDO::PARAM_STR );
$stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed
$stmt->bindValue(':start_date', $start_date);
$stmt->bindValue(':end_date', $end_date);
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalResults = count($leads);
$totalPages = ceil($totalRows / $resultsPerPage);
if($resultsPerPage <= $totalRows) echo "<p class='px-4'>".$resultsPerPage." Out of ".$totalRows." Leads </p>";
else echo "<p class='px-4'>".$totalRows." Leads </p>";
var_dump($_SESSION["states"]);
// Status Conditional Color
foreach($leads as $lead){
$only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available';
$lead_id = $lead['id'];
if($lead['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
elseif($lead['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
elseif($lead['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
elseif($lead['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
elseif($lead['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 $lead['business_type'] ?></td>
<td class="border-y-2 p-2">
<div class="flex flex-row justify-center place-items-center">
<div class="xzmdropdown-wrapper">
<button class="xzmdropdown-btn"><i class="fa fa-envelope" style="font-size: 20px"></i></button>
<div class="xzmdropdown-content">
<a href="#">UNO</a>
<a href="#">Primero</a>
<div class="xzmdropdown-item">
<a href="#">ILC</a>
<a href="#">Complete package</a>
<a href="#">Bespoke</a>
<div class="xzmdropdown-submenu">
<a href="#">Academic</a>
<a href="#">Buzzapp</a>
<a href="#">Design Solution</a>
</div>
</div>
</div>
</div>
<div>
<a href="https://wa.me/<?php echo $lead['phone'] ?>?text=Hello%2C%20how%20are%20you%3F"><i class="fab fa-whatsapp" style="font-size: 20px"></i></a>
</div>
</div>
</td>
<?php if(isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'admin'){?>
<td class="border-y-2 p-2">
<input type="checkbox" name="selected_records[]" value="<?php echo $lead['id']; ?>" id="<?php echo $lead['id']; ?>" />
</td>
<?php }?>
<td class="border-y-2 p-2"><label for="<?php echo $lead['id']; ?>"><?php echo $lead['name'] ?></label></td>
<td class="border-y-2 p-2 text-blue-500 hover:text-blue-700 hover:underline"><a href="/edit-lead/?id=<?php echo $lead['id'] ?>"><?php echo $lead['id'] ?></a></td>
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $lead['status'];?></div></td>
<!-- <td class="border-y-2 p-2">
<p><i class="fa fa-envelope">&nbsp;<?php // echo $lead['email'] ?></i></p>
<p><i class="fa fa-phone">&nbsp;<?php // echo $lead['phone'] ?></i></p>
</td> -->
<td class="border-y-2 p-2"><?php echo $lead['formname'] ?></td>
<td class="border-y-2 p-2"><?php echo $only_date; ?></td>
</tr>
<?php
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
$end_time = microtime(true);
// Calculate execution time
$execution_time = ($end_time - $start_time);
// Output execution time
// echo "Page executed in: " . $execution_time . " seconds";
?>
</tbody>
</table>
</form>
<!-- Pagination Links -->
<?php
$getParams = $_GET; unset($getParams['page']); $getParams['page'] = $page-1; $backPage= http_build_query($getParams); unset($getParams['page']);
$getParams['page'] = $page+1; $nextkPage= http_build_query($getParams);
echo'
<div class="bg-white p-4 flex items-center flex-wrap">
<nav aria-label="Page navigation">
<ul class="flex flex-row ">
<li><button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-l-lg" > &nbsp;'; if($page>1) echo '<a href="?',$backPage,'">&lt;','</a>'; echo ' &nbsp; </button></li>
<li><button class="px-4 py-2 text-white border-y border-[#443780]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%);"> &nbsp; '.$page.' &nbsp; </button></li>
<li><button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-r-lg" > &nbsp;'; if($page<$totalPages) echo '<a href="?',$nextkPage,'">&gt;','</a>'; echo ' &nbsp;</button></li>
</ul>
</nav>
</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%;">&#10008;</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>
<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');
console.log(element);
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';
}
}
});
</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: 999;
height: 100%;
animation: slideInRight 0.5s forwards; /* Animation to slide in */
/* overflow-x: auto; */
}
@keyframes slideInRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0%);
}
}
</style>

3
.hta_slug/tmp.php Normal file
View File

@ -0,0 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Get Select Option Text</title></head><body><select id="mySelect"><option value="1">Option 1</option><option value="2">Option 2</option><option value="3">Option 3</option></select>
<button onclick="!function(){var e=document.getElementById('mySelect'),t=e.options[e.selectedIndex].textContent;alert('Selected Option Text: '+t)}()">Get Selected Option Text</button>
</body></html>

View File

@ -131,7 +131,7 @@
?>
<li>
<?php if(isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'user'){ ?>
<a href="/cleads/my-leads">
<a href="/my-leads">
<i class="fa fa-2x"><img src="/assets/my-lead.png" alt="" /></i>
<!-- <i class="fa fa-square fa-2x"></i> -->
<span class="nav-text">

596
t.php Normal file
View File

@ -0,0 +1,596 @@
<style>
.xzmdropdown-wrapper {
position: relative;
display: inline-block;
}
.xzmdropdown-content {
display: none;
position: absolute;
background-color: #EAEAEA;
min-width: 120px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
z-index: 1;
border: 1px solid #939393;
border-radius: 5px;
}
.xzmdropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.xzmdropdown-content a:hover {
background-color: #B2B0FF;
}
.xzmdropdown-wrapper:hover .xzmdropdown-content {
display: block;
}
.xzmdropdown-submenu {
position: absolute;
top: 0;
left: 100%;
margin-top: 105px;
display: none;
background-color: #EAEAEA; /* Background color for submenu */
min-width: 120px; /* Adjust width as needed */
border: 1px solid #939393;
border-radius: 5px;
}
.xzmdropdown-content .xzmdropdown-item:hover .xzmdropdown-submenu {
display: block;
}
.xzmdropdown-submenu a {
padding: 10px 16px; /* Padding for submenu items */
display: block;
}
.xzmdropdown-submenu a:hover {
background-color: #c0c0c0; /* Hover background color for submenu items */
}
</style>
<?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']) && isset($_POST['name']) && isset($_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;">&#10008;</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> &nbsp; | &nbsp;
<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">Quick Action</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>
</tr>
</thead>
<tbody >
<?php
//?bv=teenybeans&start_date=2024-05-04&end_date=2024-05-18
// 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);
$searchTerm =isset($_GET['search']) ? $_GET['search'] : "%";
$businessVertical =isset($_GET['bv']) ? $_GET['bv'] : "%";
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '2014-05-05';
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d');
$start_time = microtime(true);
$resultsPerPage = 100;
$page =isset($_GET['page']) ? $_GET['page'] : 1;
$offset = ($page - 1) * $resultsPerPage ;
$accessArray = explode(",", $_SESSION['access']);
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
//first query to get the total number for pagination
$sql = "SELECT COUNT(*) FROM cleads
WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND verticals LIKE :businessVertical";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':searchTerm', "%$searchTerm%");
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->bindValue(':start_date', $start_date);
$stmt->bindValue(':end_date', $end_date);
$stmt->bindValue(':businessVertical', $businessVertical);
$stmt->execute();
$totalRows = $stmt->fetchColumn();
// second & final query to get the page_view data
$sql = "SELECT * FROM cleads
WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND verticals LIKE :businessVertical
ORDER BY id DESC LIMIT :limit OFFSET :offset";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->bindValue(':start_date', $start_date);
$stmt->bindValue(':end_date', $end_date);
$stmt->bindValue(':businessVertical', $businessVertical);
$stmt->execute();
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalResults = count($leads);
$totalPages = ceil($totalRows / $resultsPerPage);
echo "<p class='px-4'>Total ".$totalRows." Rows Found</p>";
// Status Conditional Color
foreach($leads as $lead){
$only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available';
$lead_id = $lead['id'];
if($lead['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
elseif($lead['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
elseif($lead['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
elseif($lead['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
elseif($lead['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">
<div class="flex flex-row justify-center place-items-center">
<div class="xzmdropdown-wrapper">
<button class="xzmdropdown-btn"><i class="fa fa-envelope" style="font-size: 20px"></i></button>
<div class="xzmdropdown-content">
<a href="#">UNO</a>
<a href="#">Primero</a>
<div class="xzmdropdown-item">
<a href="#">ILC</a>
<a href="#">Complete package</a>
<a href="#">Bespoke</a>
<div class="xzmdropdown-submenu">
<a href="#">Academic</a>
<a href="#">Buzzapp</a>
<a href="#">Design Solution</a>
</div>
</div>
</div>
</div>
<div>
<a href="https://wa.me/<?php echo $lead['phone'] ?>?text=Hello%2C%20how%20are%20you%3F"><i class="fab fa-whatsapp" style="font-size: 20px"></i></a>
</div>
</div>
</td>
<?php if($_SESSION['user_type'] == 'admin'){?>
<td class="border-y-2 p-2">
<input type="checkbox" name="selected_records[]" value="<?php echo $lead['id']; ?>" id="<?php echo $lead['id']; ?>" />
</td>
<?php }?>
<td class="border-y-2 p-2"><label for="<?php echo $lead['id']; ?>"><?php echo $lead['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 $lead['id'] ?>"><?php echo $lead['id'] ?></a></td>
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $lead['status'];?></div></td>
<!-- <td class="border-y-2 p-2">
<p><i class="fa fa-envelope">&nbsp;<?php // echo $lead['email'] ?></i></p>
<p><i class="fa fa-phone">&nbsp;<?php // echo $lead['phone'] ?></i></p>
</td> -->
<td class="border-y-2 p-2"><?php echo $lead['formname'] ?></td>
<td class="border-y-2 p-2"><?php echo $only_date; ?></td>
</tr>
<?php
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
$end_time = microtime(true);
// Calculate execution time
$execution_time = ($end_time - $start_time);
// Output execution time
echo "Page executed in: " . $execution_time . " seconds";
?>
</tbody>
</table>
</form>
<!-- Pagination Links -->
<?php
// $totalPages = ceil($totalRows / $resultsPerPage);
// echo "<div>";
// echo "<h3>Pages:</h3>-",$page,'-';
// for ($i = 1; $i <= $totalPages; $i++) {
// echo "<a href='?page=$i'>$i</a> ";
// }
// echo "</div>";
?>
<?php
$getParams = $_GET; unset($getParams['page']); $getParams['page'] = $page-1; $backPage= http_build_query($getParams); unset($getParams['page']); $getParams['page'] = $page+1; $nextkPage= http_build_query($getParams);
echo'
<div class="bg-white p-4 flex items-center flex-wrap">
<nav aria-label="Page navigation">
<ul class="inline-flex">
<li><button class="px-4 py-2 text-green-600 transition-colors duration-150 bg-white border border-r-0 border-green-600 rounded-l-lg focus:shadow-outline hover:bg-green-100"> &nbsp;'; if($page>1) echo '<a href="?',$backPage,'">&lt;','</a>'; echo ' &nbsp; </button></li>
<li><button class="px-4 py-2 text-white transition-colors duration-150 bg-green-600 border border-r-0 border-green-600 focus:shadow-outline"> &nbsp; '.$page.' &nbsp; </button></li>
<li><button class="px-4 py-2 text-green-600 transition-colors duration-150 bg-white border border-green-600 rounded-r-lg focus:shadow-outline hover:bg-green-100"> &nbsp;'; if($page<$totalPages) echo '<a href="?',$nextkPage,'">&gt;','</a>'; echo ' &nbsp;</button></li>
</ul>
</nav>
</div>
';
?>
<!-- <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%;">&#10008;</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>
<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; //getting Err: here
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%);
}
}
.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>