c
This commit is contained in:
@@ -141,12 +141,12 @@
|
||||
}
|
||||
}
|
||||
?>
|
||||
<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">
|
||||
<!-- <p class="text-[28px] font-bold p-4">Lead Management</p> -->
|
||||
|
||||
<dialog id="d" class="rounded-lg">
|
||||
<form method="dialog" class=""><button class="text-4xl text-[#ff0000] bg-[#05b3a410] hover:bg-[#05b3a450] duration-700 rounded-full px-2 float-right">✘</button></form>
|
||||
<div class="flex flex-row ">
|
||||
<div class="flex flex-col p-4 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>
|
||||
@@ -172,20 +172,22 @@
|
||||
</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 class="" style="">Select Date</button> -->
|
||||
<div id="" class="flex flex-row place-content-between w-full py-4 gap-x-2">
|
||||
<button onclick="d.showModal()" class="rounded-lg pl-2 h-fit bg-[#fff] text-[#464E5F] shadow-lg flex flex-row justify-center place-items-center">Select Date<span class="fa fa-calendar-o -ml-[17px] pt-1.5"></span></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-[170px] md: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>
|
||||
<?php
|
||||
if(isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'admin'){
|
||||
echo '<p onclick="deleteCofermation();" class="rounded-lg h-fit py-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 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>
|
||||
<button onclick="toggleDisplay();" class="rounded-lg px-2 h-fit text-[#fff] flex flex-row justify-center place-items-center" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;"><span style="font-size: 30px; font-weight: bold">+</span><span>Add Leads</span></button>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="width: 100%;" >
|
||||
@@ -193,7 +195,7 @@
|
||||
<tr>
|
||||
<?php
|
||||
if(isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'admin')
|
||||
echo ' <th class="text-center border-b-2 p-3">
|
||||
echo ' <th class=" 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">
|
||||
@@ -203,13 +205,12 @@
|
||||
</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>
|
||||
<th class="border-b-2 p-3 text-left">Name</th>
|
||||
<th class="border-b-2 p-3 text-left">ID</th>
|
||||
<th class="border-b-2 p-3 text-left">Status Update</th>
|
||||
<!-- <th class=" border-b-2 p-3">Contact Detail</th> -->
|
||||
<th class="border-b-2 p-3 text-left">Form Name</th>
|
||||
<th class="border-b-2 p-3 text-left">Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
@@ -222,7 +223,7 @@
|
||||
$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;
|
||||
$resultsPerPage = 200;
|
||||
$page =isset($_GET['page']) ? $_GET['page'] : 1;
|
||||
$offset = ($page - 1) * $resultsPerPage ;
|
||||
$accessArray = explode(",", $_SESSION['access']);
|
||||
@@ -253,8 +254,12 @@
|
||||
$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>";
|
||||
|
||||
$end_time = microtime(true);
|
||||
$execution_time = ($end_time - $start_time);
|
||||
$executionTime = substr($execution_time, 0, 6);
|
||||
// if($resultsPerPage <= $totalRows) echo "<p class='px-4'>".$resultsPerPage." Out of ".$totalRows." Leads in ".$executionTime." Seconds</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';
|
||||
@@ -268,46 +273,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 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="#" class="bespoke-trigger">Bespoke</a>
|
||||
<div class="xzmdropdown-submenu">
|
||||
<a href="#">Academic</a>
|
||||
<a href="#">Buzzapp</a>
|
||||
<a href="#">Design Solution</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="xzmdropdown-wrapper">
|
||||
<button class="xzmdropdown-btn"><i class="fab fa-whatsapp" 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="#" class="bespoke-trigger">Bespoke</a>
|
||||
<div class="xzmdropdown-submenu">
|
||||
<a href="#">Academic</a>
|
||||
<a href="#">Buzzapp</a>
|
||||
<a href="#">Design Solution</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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']; ?>" />
|
||||
@@ -324,19 +289,12 @@
|
||||
<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>
|
||||
@@ -344,15 +302,16 @@
|
||||
<!-- 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 $totalPages;
|
||||
echo'<div class="flex flex-row justify-end">
|
||||
echo'<div class="flex flex-row justify-between">
|
||||
<button onclick="downloadCSV(data, filename)" class="fa fa-download text-[#fff] rounded-lg py-2 " style="background: linear-gradient(90deg, rgba(70, 68, 142, 0.91) 0%, rgba(120, 117, 244, 0.91) 100%);"></button>
|
||||
<div class="flex flex-row justify-end">
|
||||
<button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-l-lg" > '; if($page>1) echo '<a href="?',$backPage,'"><','</a>'; echo ' </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%);"> '.$page.' </button>
|
||||
<button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-r-lg" > '; if($page<$totalPages) echo '<a href="?',$nextkPage,'">>','</a>'; echo ' </button>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
?>
|
||||
@@ -489,23 +448,8 @@ echo'<div class="flex flex-row justify-end">
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 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');
|
||||
@@ -538,6 +482,37 @@ echo'<div class="flex flex-row justify-end">
|
||||
}
|
||||
}
|
||||
}
|
||||
const data = <?php echo json_encode($leads); ?>;
|
||||
const filename = `leads_data.csv`;
|
||||
|
||||
function downloadCSV(data, filename) {
|
||||
const csv = convertToCSV(data);
|
||||
const blob = new Blob([csv], { type: 'text/csv' });
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
function convertToCSV(data) {
|
||||
const csvRows = [];
|
||||
const headers = Object.keys(data[0]);
|
||||
csvRows.push(headers.join(','));
|
||||
data.forEach(row => {
|
||||
const values = headers.map(header => {
|
||||
const escaped = ('' + row[header]).replace(/"/g, '\\"');
|
||||
return `"${escaped}"`;
|
||||
});
|
||||
csvRows.push(values.join(','));
|
||||
});
|
||||
|
||||
return csvRows.join('\n');
|
||||
|
||||
// downloadCSV(data, filename);
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user