c
This commit is contained in:
@@ -137,14 +137,14 @@
|
||||
<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>
|
||||
<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>
|
||||
@@ -162,19 +162,19 @@
|
||||
</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>
|
||||
<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 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>
|
||||
<?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>
|
||||
|
||||
<form method="post">
|
||||
@@ -182,7 +182,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
if($_SESSION['user_type'] == 'admin')
|
||||
if(isset($_SESSION['user_type']) && $_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>
|
||||
@@ -193,6 +193,7 @@
|
||||
</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>
|
||||
@@ -205,20 +206,12 @@
|
||||
<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'] : "%";
|
||||
// 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);
|
||||
@@ -231,21 +224,21 @@
|
||||
|
||||
//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";
|
||||
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'";
|
||||
$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->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
|
||||
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";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed
|
||||
@@ -253,7 +246,7 @@
|
||||
$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(':businessVertical', $businessVertical);
|
||||
$stmt->execute();
|
||||
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$totalResults = count($leads);
|
||||
@@ -273,6 +266,7 @@
|
||||
// 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">
|
||||
@@ -297,13 +291,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<?php if($_SESSION['user_type'] == 'admin'){?>
|
||||
<?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="/cleads/edit-lead/?id=<?php echo $lead['id'] ?>"><?php echo $lead['id'] ?></a></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"> <?php // echo $lead['email'] ?></i></p>
|
||||
@@ -334,14 +328,15 @@
|
||||
|
||||
<?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);
|
||||
$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"> '; if($page>1) echo '<a href="?',$backPage,'"><','</a>'; echo ' </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"> '.$page.' </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"> '; if($page<$totalPages) echo '<a href="?',$nextkPage,'">>','</a>'; echo ' </button></li>
|
||||
<ul class="flex flex-row ">
|
||||
<li><button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-l-lg" > '; if($page>1) echo '<a href="?',$backPage,'"><','</a>'; echo ' </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%);"> '.$page.' </button></li>
|
||||
<li><button class="px-4 py-2 text-[#443780] border border-[#443780] rounded-r-lg" > '; if($page<$totalPages) echo '<a href="?',$nextkPage,'">>','</a>'; echo ' </button></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
@@ -499,8 +494,10 @@ echo'
|
||||
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 {
|
||||
@@ -520,7 +517,7 @@ echo'
|
||||
});
|
||||
function deleteCofermation(){
|
||||
let deleteButton = document.getElementById('delete-button');
|
||||
let leadID = document.getElementById('<?php echo $row['id']; ?>').value; //getting Err: here
|
||||
let leadID = document.getElementById('<?php echo $lead['id']; ?>').value; //getting Err: here
|
||||
if(leadID != null){
|
||||
if(deleteButton.style.display === 'flex'){
|
||||
deleteButton.style.display = 'none';
|
||||
@@ -544,7 +541,7 @@ echo'
|
||||
max-width: 500px;
|
||||
box-shadow: 0px 0px 20px 0px #443780;
|
||||
border-radius: 2px;
|
||||
z-index: 100;
|
||||
z-index: 999;
|
||||
height: 100%;
|
||||
animation: slideInRight 0.5s forwards; /* Animation to slide in */
|
||||
/* overflow-x: auto; */
|
||||
|
||||
Reference in New Issue
Block a user