lead edit page
This commit is contained in:
@@ -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" > '; 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>
|
||||
';
|
||||
|
||||
// echo $totalPages;
|
||||
echo'<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>';
|
||||
|
||||
?>
|
||||
|
||||
<!-- 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';
|
||||
|
||||
Reference in New Issue
Block a user