c
This commit is contained in:
@@ -51,7 +51,8 @@
|
|||||||
foreach($rows as $row){
|
foreach($rows as $row){
|
||||||
$nameParts = explode(" ", $row['name']);
|
$nameParts = explode(" ", $row['name']);
|
||||||
$firstInitial = substr($nameParts[0], 0, 1);
|
$firstInitial = substr($nameParts[0], 0, 1);
|
||||||
$lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1);
|
$lastInitial = substr($nameParts[1], 0, 1);
|
||||||
|
// $lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1);
|
||||||
$name_letter = $firstInitial.$lastInitial;
|
$name_letter = $firstInitial.$lastInitial;
|
||||||
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 1px solid #FB5555; border-radius: 5px; color: #FB5555;';}
|
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'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 1px solid #2C9C9C; border-radius: 5px; color: #2C9C9C;';}
|
||||||
@@ -59,8 +60,8 @@
|
|||||||
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 1px solid #40916C; border-radius: 5px; color: #40916C;';}
|
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;';}
|
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">
|
<div class="grid grid-cols-1 lg:grid-cols-3 p-6 space-x-4">
|
||||||
<form method="post">
|
<form method="post" class="w-full lg:col-span-2">
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="flex flex-col bg-[#F6F6F6] rounded-xl">
|
<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="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||||
@@ -90,20 +91,42 @@
|
|||||||
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['formname']; ?></p>
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['formname']; ?></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
||||||
<div>
|
<?php
|
||||||
<p><b>Country</b></p>
|
$countryapiUrl = 'https://api.siliconpin.com/v3/list/country/';
|
||||||
<select class="w-full" name="" id="country" onchange="fetchStates()" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
$countryhandle = fopen($countryapiUrl, 'rb');
|
||||||
<option selected value="<?php echo $row['country']; ?>"><?php echo $row['country']; ?></option>
|
if ($countryhandle === false) {
|
||||||
</select>
|
echo 'Unable to open URL';
|
||||||
<input type="hidden" name="country" id="getCountryName">
|
} else {
|
||||||
</div>
|
$jsonResponse = stream_get_contents($countryhandle);
|
||||||
|
fclose($countryhandle);
|
||||||
|
$countrys = json_decode($jsonResponse, true);
|
||||||
|
if ($countrys === null) {
|
||||||
|
echo 'Error decoding JSON from API';
|
||||||
|
} else {
|
||||||
|
$lead_country = $conn->prepare("SELECT `country` FROM `cleads` WHERE `id` = :id");
|
||||||
|
$lead_country->bindParam(':id', $_GET["id"]);
|
||||||
|
$lead_country->execute();
|
||||||
|
$lcountry = $lead_country->fetch(PDO::FETCH_COLUMN);
|
||||||
|
$country = json_decode($lcountry);
|
||||||
|
echo '<div>
|
||||||
|
<p><b>Country</b></p>
|
||||||
|
<select onchange="fetchStates();" id="country" name="country" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px; width: 100%;"><option value="0">-Select-</option>';
|
||||||
|
foreach ($countrys as $countryItem) {
|
||||||
|
$isSelected = $countryItem["iso2"] === $lcountry;
|
||||||
|
echo '<option id="country" '.($isSelected ? 'selected' : '').' value="'.$countryItem["iso2"].'">'.$countryItem["name"].'</option>';
|
||||||
|
}
|
||||||
|
echo '</select>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
<div>
|
<div>
|
||||||
<p><b>State</b></p>
|
<p><b>State</b></p>
|
||||||
<select class="w-full" name="" id="state" onchange="fetchCities()" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
<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>
|
<option selected value="<?php echo $row['state']; ?>"><?php echo $row['state']; ?></option>
|
||||||
</select>
|
</select>
|
||||||
<input type="hidden" name="state" id="getStateName">
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p><b>City</b></p>
|
<p><b>City</b></p>
|
||||||
@@ -168,6 +191,37 @@
|
|||||||
<p><b>Follow Update</b></p>
|
<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;" />
|
<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>
|
||||||
|
<p><b>Assign to</b></p>
|
||||||
|
<select id="user" name="user" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px; width: 100%;">
|
||||||
|
<option value="0">-Select-</option>
|
||||||
|
<?php
|
||||||
|
try {
|
||||||
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||||
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$stmt = $conn->prepare("SELECT email FROM users");
|
||||||
|
$stmt->execute();
|
||||||
|
$usersRows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmtCleads = $conn->prepare("SELECT user FROM cleads WHERE id = :id");
|
||||||
|
$stmtCleads->bindParam(':id', $_GET['id']);
|
||||||
|
$stmtCleads->execute();
|
||||||
|
$usersCleads = $stmtCleads->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$selectedEmails = [];
|
||||||
|
foreach($usersCleads as $userEmail){
|
||||||
|
$selectedEmails[] = $userEmail['user'];
|
||||||
|
}
|
||||||
|
foreach($usersRows as $userData){
|
||||||
|
$isUserSelected = in_array($userData['email'], $selectedEmails) ? 'selected' : '';
|
||||||
|
echo '<option value="'.$userData['email'].'" '.$isUserSelected.'>'.$userData['email'].'</option>';
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||||
|
};
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding: 10px; ">
|
<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;" />
|
<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;" />
|
||||||
@@ -175,10 +229,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="flex flex-col div-custom-margin" style="" >
|
<div class="flex flex-col div-custom-margin" style="width: 100%;" >
|
||||||
<div class="bg-[#F6F6F6] rounded-xl p-3">
|
<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;">
|
<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>
|
<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>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
@@ -246,7 +300,6 @@
|
|||||||
$stmt->bindParam(':leadid', $_GET['id']);
|
$stmt->bindParam(':leadid', $_GET['id']);
|
||||||
$stmt->bindParam(':comment', $_POST['comment']);
|
$stmt->bindParam(':comment', $_POST['comment']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$saved_message = "New Appointment save successfully";
|
$saved_message = "New Appointment save successfully";
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
echo "Error: " . $e->getMessage();
|
echo "Error: " . $e->getMessage();
|
||||||
@@ -414,45 +467,38 @@ copyButtons.forEach(button => {
|
|||||||
const inputId = button.getAttribute('data-input-id');
|
const inputId = button.getAttribute('data-input-id');
|
||||||
const inputElement = document.getElementById(inputId);
|
const inputElement = document.getElementById(inputId);
|
||||||
if (inputElement && inputElement.value) {
|
if (inputElement && inputElement.value) {
|
||||||
navigator.clipboard.writeText(inputElement.value)
|
navigator.clipboard.writeText(inputElement.value)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
button.classList.add('copied');
|
button.classList.add('copied');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
button.classList.remove('copied');
|
button.classList.remove('copied');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('Unable to copy:', err);
|
console.error('Unable to copy:', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Function to fetch countries and populate the country dropdown
|
|
||||||
function fetchCountries() {
|
// function fetchCountries() {
|
||||||
fetch('https://api.siliconpin.com/v3/list/country/')
|
// fetch('https://api.siliconpin.com/v3/list/country/')
|
||||||
.then(res => res.json())
|
// .then(res => res.json())
|
||||||
.then(data => {
|
// .then(data => {
|
||||||
const countryDropdown = document.getElementById('country');
|
// const countryDropdown = document.getElementById('country');
|
||||||
countryDropdown.innerHTML = '<option value="">Select Country</option>';
|
// countryDropdown.innerHTML = '<option value="">Select Country</option>';
|
||||||
data.forEach(country => {
|
// data.forEach(country => {
|
||||||
const option = document.createElement('option');
|
// const option = document.createElement('option');
|
||||||
option.value = country.iso2;
|
// option.value = country.iso2;
|
||||||
option.text = country.name;
|
// option.text = country.name;
|
||||||
countryDropdown.appendChild(option);
|
// countryDropdown.appendChild(option);
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
function myCountry() {
|
|
||||||
let getCountryNameFrom = document.getElementById('country');
|
|
||||||
let selectedOption = getCountryNameFrom.options[getCountryNameFrom.selectedIndex].text;
|
|
||||||
document.getElementById('getCountryName').value = selectedOption;
|
|
||||||
// console.log(selectedOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchStates() {
|
function fetchStates() {
|
||||||
myCountry();
|
|
||||||
const selectedCountry = document.getElementById('country').value;
|
const selectedCountry = document.getElementById('country').value;
|
||||||
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
|
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
@@ -467,15 +513,8 @@ copyButtons.forEach(button => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function myState() {
|
|
||||||
let getCountryNameFrom = document.getElementById('state');
|
|
||||||
let selectedOption = getCountryNameFrom.options[getCountryNameFrom.selectedIndex].text;
|
|
||||||
document.getElementById('getStateName').value = selectedOption;
|
|
||||||
// console.log(selectedOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchCities() {
|
function fetchCities() {
|
||||||
myState();
|
|
||||||
const selectedCountry = document.getElementById('country').value;
|
const selectedCountry = document.getElementById('country').value;
|
||||||
const selectedState = document.getElementById('state').value;
|
const selectedState = document.getElementById('state').value;
|
||||||
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${selectedCountry}&state=${selectedState}`)
|
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${selectedCountry}&state=${selectedState}`)
|
||||||
@@ -491,7 +530,7 @@ copyButtons.forEach(button => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fetchCountries();
|
// fetchCountries();
|
||||||
let nameID = document.getElementById('name');
|
let nameID = document.getElementById('name');
|
||||||
let addressID = document.getElementById('address');
|
let addressID = document.getElementById('address');
|
||||||
let countryID = document.getElementById('country');
|
let countryID = document.getElementById('country');
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
require_once('.hta_config/crm_config.php');
|
require_once('.hta_config/crm_config.php');
|
||||||
require_once('.htac_header.php');
|
require_once('.htac_header.php');
|
||||||
require_once('.htac_nav.php');
|
require_once('.htac_nav.php');
|
||||||
|
// deleteCofermation()
|
||||||
$today_date = date("Y-m-d");
|
$today_date = date("Y-m-d");
|
||||||
$next_day = date("Y-m-d", strtotime("+1 day"));
|
$next_day = date("Y-m-d", strtotime("+1 day"));
|
||||||
$yesterday = date("Y-m-d", strtotime("-1 day"));
|
$yesterday = date("Y-m-d", strtotime("-1 day"));
|
||||||
@@ -111,6 +112,23 @@
|
|||||||
echo "Error: " . $e->getMessage();
|
echo "Error: " . $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
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 {
|
||||||
|
$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>
|
<p class="text-[28px] font-bold p-4">Lead Management</p>
|
||||||
<div id="page-body" class="flex flex-row place-content-between px-4">
|
<div id="page-body" class="flex flex-row place-content-between px-4">
|
||||||
@@ -150,6 +168,11 @@
|
|||||||
<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>
|
<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>
|
</form>
|
||||||
</div>
|
</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>
|
<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>
|
</div>
|
||||||
|
|
||||||
@@ -157,7 +180,18 @@
|
|||||||
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="width: 100%;" >
|
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="width: 100%;" >
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center border-b-2 p-3">BV</th>
|
<?php
|
||||||
|
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>
|
||||||
|
<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">Quick Action</th>
|
||||||
<th class="text-center border-b-2 p-3">Name</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">ID</th>
|
||||||
@@ -185,33 +219,37 @@
|
|||||||
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
|
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
|
||||||
|
|
||||||
//first query to get the total number for pagination
|
//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 ";
|
$parts = explode(',', $_SESSION["states"]);
|
||||||
|
$quotedParts = array_map(function($item) { return "'" . $item . "'";}, $parts);
|
||||||
|
$newStr = implode(',', $quotedParts);
|
||||||
|
|
||||||
|
$sql= "SELECT COUNT(*) FROM cleads WHERE state IN ($newStr) OR user LIKE :user 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 = $conn->prepare($sql);
|
||||||
$stmt->bindValue(':businessVertical', $businessVertical);
|
$stmt->bindValue(':businessVertical', $businessVertical);
|
||||||
$stmt->bindValue(':searchTerm', "%".$searchTerm."%");
|
$stmt->bindValue(':searchTerm', "%".$searchTerm."%");
|
||||||
$stmt->bindValue(':start_date', $start_date);
|
$stmt->bindValue(':start_date', $start_date);
|
||||||
$stmt->bindValue(':end_date', $end_date);
|
$stmt->bindValue(':end_date', $end_date);
|
||||||
|
$stmt->bindValue(':user', $_SESSION["email"]);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$totalRows = $stmt->fetchColumn();
|
$totalRows = $stmt->fetchColumn();
|
||||||
|
|
||||||
// second & final query to get the page_view data
|
// 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";
|
$sql = "SELECT * FROM cleads WHERE state IN ($newStr) OR user LIKE :user 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 ORDER BY id DESC LIMIT :limit OFFSET :offset";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->bindValue(':businessVertical', $businessVertical, PDO::PARAM_STR );
|
$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(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed
|
||||||
$stmt->bindValue(':start_date', $start_date);
|
$stmt->bindValue(':start_date', $start_date);
|
||||||
$stmt->bindValue(':end_date', $end_date);
|
$stmt->bindValue(':end_date', $end_date);
|
||||||
|
$stmt->bindValue(':user', $_SESSION["email"]);
|
||||||
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
|
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$totalResults = count($leads);
|
$totalResults = count($leads);
|
||||||
$totalPages = ceil($totalRows / $resultsPerPage);
|
$totalPages = ceil($totalRows / $resultsPerPage);
|
||||||
|
|
||||||
if($resultsPerPage <= $totalRows) echo "<p class='px-4'>".$resultsPerPage." Out of ".$totalRows." Leads </p>";
|
if($resultsPerPage <= $totalRows) echo "<p class='px-4'>".$resultsPerPage." Out of ".$totalRows." Leads </p>";
|
||||||
else echo "<p class='px-4'>".$totalRows." Leads </p>";
|
else echo "<p class='px-4'>".$totalRows." Leads </p>";
|
||||||
var_dump($_SESSION["states"]);
|
|
||||||
// Status Conditional Color
|
// Status Conditional Color
|
||||||
foreach($leads as $lead){
|
foreach($leads as $lead){
|
||||||
$only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available';
|
$only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available';
|
||||||
@@ -225,7 +263,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'];}
|
// 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>
|
<tr>
|
||||||
<td class="border-y-2 p-2"><?php echo $lead['business_type'] ?></td>
|
|
||||||
<td class="border-y-2 p-2">
|
<td class="border-y-2 p-2">
|
||||||
<div class="flex flex-row justify-center place-items-center">
|
<div class="flex flex-row justify-center place-items-center">
|
||||||
<div class="xzmdropdown-wrapper">
|
<div class="xzmdropdown-wrapper">
|
||||||
@@ -278,7 +315,7 @@
|
|||||||
$execution_time = ($end_time - $start_time);
|
$execution_time = ($end_time - $start_time);
|
||||||
|
|
||||||
// Output execution time
|
// Output execution time
|
||||||
// echo "Page executed in: " . $execution_time . " seconds";
|
echo "Page executed in: " . $execution_time . " seconds";
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -289,20 +326,15 @@
|
|||||||
|
|
||||||
$getParams = $_GET; unset($getParams['page']); $getParams['page'] = $page-1; $backPage= http_build_query($getParams); unset($getParams['page']);
|
$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['page'] = $page+1; $nextkPage= http_build_query($getParams);
|
||||||
echo'
|
|
||||||
<div class="bg-white p-4 flex items-center flex-wrap">
|
// echo $totalPages;
|
||||||
<nav aria-label="Page navigation">
|
echo'<div class="flex flex-row justify-end">
|
||||||
<ul class="flex flex-row ">
|
<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><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>
|
<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><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>
|
<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><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>
|
</div>';
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
';
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- New Lead Form Section -->
|
<!-- New Lead Form Section -->
|
||||||
<div id="add-lead-form" class="add-lead-form">
|
<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;">
|
<div class="flex flex-row place-content-between p-2" style="border-bottom: 2px solid #464E5F; border-style: dashed;">
|
||||||
@@ -474,7 +506,17 @@ echo'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
function deleteCofermation(){
|
||||||
|
let deleteButton = document.getElementById('delete-button');
|
||||||
|
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';
|
||||||
|
}else{
|
||||||
|
deleteButton.style.display = 'flex'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -505,4 +547,15 @@ echo'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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>
|
</style>
|
||||||
@@ -28,20 +28,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['status_id']) && $_POST['status_id']){
|
|
||||||
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 view_status = 1 WHERE id = :status_id AND email = :email");
|
|
||||||
$stmt->bindParam(':status_id', $_POST['status_id']);
|
|
||||||
$stmt->bindParam(':email', $_SESSION['email']);
|
|
||||||
$stmt->execute();
|
|
||||||
$saved_message = "Appointment updated successfully";
|
|
||||||
} catch(PDOException $e) {
|
|
||||||
echo "Error: " . $e->getMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
@@ -52,19 +38,26 @@
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
foreach($appt_data as $appt){
|
foreach($appt_data as $appt){
|
||||||
|
$leadID = json_decode($appt['leadid']);
|
||||||
if($appt['view_status'] == 0){
|
if($appt['view_status'] == 0){
|
||||||
$notification_bg = 'background: #F5F4FFE8;';
|
$notification_bg = 'background: #F5F4FFE8;';
|
||||||
$notification_batch = '<div style="width: 8px; height: 8px; background-color: red; border-radius: 50%;"></div>';
|
$notification_batch = '<div style="width: 8px; height: 8px; background-color: red; border-radius: 50%;"></div>';
|
||||||
|
$clickButton = '';
|
||||||
}elseif($appt['view_status'] == 1){
|
}elseif($appt['view_status'] == 1){
|
||||||
$notification_bg = 'background: #fff;';
|
$notification_bg = 'background: #fff;';
|
||||||
$notification_batch = '<div style="width: 8px; height: 8px; background-color: #fff; border-radius: 50%;"></div>';
|
$notification_batch = '<div style="width: 8px; height: 8px; background-color: #fff; border-radius: 50%;"></div>';
|
||||||
|
$clickButton = 'disabled';
|
||||||
}
|
}
|
||||||
?> <div class="p-2">
|
?> <div class="p-2">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<button type="submit" class="w-full text-left">
|
<button type="submit" class="w-full text-left" <?php echo $clickButton; ?>>
|
||||||
<div class="flex flex-col w-full p-2 rounded-md shadow" style="border: 3px solid #F5F4FFE8; <?php echo $notification_bg; ?>">
|
<div class="flex flex-col w-full p-2 rounded-md shadow" style="border: 3px solid #F5F4FFE8; <?php echo $notification_bg; ?>">
|
||||||
<div class="flex flex-row place-items-center">🕑 Reminders for <span><?php echo $appt['name'] ?> </span> <?php echo $notification_batch; ?></div>
|
<div class="flex flex-row place-items-center justify-between">
|
||||||
<p><?php echo $appt['appt_date']; ?></p>
|
<div class="flex flex-row place-items-center">🕑 Reminders for <?php echo $appt['name'].' '. $notification_batch; ?></div>
|
||||||
|
|
||||||
|
<div><?php echo $appt['appt_date']; ?></div>
|
||||||
|
</div>
|
||||||
|
<p><?php echo $appt['date']; ?></p>
|
||||||
<input type="hidden" name="status_id" value="<?php echo $appt['id'] ?>" />
|
<input type="hidden" name="status_id" value="<?php echo $appt['id'] ?>" />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
@@ -77,5 +70,21 @@
|
|||||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['status_id']) && $_POST['status_id']){
|
||||||
|
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 view_status = 1 WHERE id = :status_id AND email = :email");
|
||||||
|
$stmt->bindParam(':status_id', $_POST['status_id']);
|
||||||
|
$stmt->bindParam(':email', $_SESSION['email']);
|
||||||
|
$stmt->execute();
|
||||||
|
// $saved_message = "Appointment upd ated successfully";
|
||||||
|
echo '<script>window.location.href="/edit-lead/?id='.$leadID.'" </script>';
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "Error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user