b2 #1

Merged
kar merged 3 commits from b2 into master 2024-05-08 18:00:07 +00:00
5 changed files with 279 additions and 88 deletions

View File

@@ -51,16 +51,17 @@
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 = isset($nameParts[1]) ? substr($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;';}
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 1px solid #3F4254; border-radius: 5px; color: #3F4254;';} elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 1px solid #3F4254; border-radius: 5px; color: #3F4254;';}
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,13 +91,37 @@
<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="country" 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';
</div> } else {
$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="state" 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;">
@@ -166,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;" />
@@ -173,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>
@@ -244,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();
@@ -358,7 +413,7 @@
<label for="appt_date">Appointment Date</label> <label for="appt_date">Appointment Date</label>
<input type="datetime-local" name="appt_date" id="appt_date" value="<?php echo $appt['appt_date'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" /> <input type="datetime-local" name="appt_date" id="appt_date" value="<?php echo $appt['appt_date'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
</div> </div>
<input type="text" name="appointment_id" id="appointment_id" value="<?php echo $appt['id']; ?>"> <input type="hidden" name="appointment_id" id="appointment_id" value="<?php echo $appt['id']; ?>">
<div class="flex flex-col"> <div class="flex flex-col">
<label for="appt-comment">Description (if needed)</label> <label for="appt-comment">Description (if needed)</label>
<input type="text" name="comment" id="appt-comment" value="<?php echo $appt['comment'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" /> <input type="text" name="comment" id="appt-comment" value="<?php echo $appt['comment'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
@@ -405,54 +460,43 @@
</div> </div>
<script> <script>
// Get all copy buttons
const copyButtons = document.querySelectorAll('.copy-btn'); const copyButtons = document.querySelectorAll('.copy-btn');
// Attach click event listeners to each copy button
copyButtons.forEach(button => { copyButtons.forEach(button => {
button.addEventListener('click', event => { button.addEventListener('click', event => {
event.preventDefault(); // Prevent default button behavior event.preventDefault();
// Get the input ID associated with this button
const inputId = button.getAttribute('data-input-id'); const inputId = button.getAttribute('data-input-id');
// Get the input element by ID
const inputElement = document.getElementById(inputId); const inputElement = document.getElementById(inputId);
// Check if the input element exists and has a value
if (inputElement && inputElement.value) { if (inputElement && inputElement.value) {
// Copy the input value to the clipboard using Clipboard API
navigator.clipboard.writeText(inputElement.value) navigator.clipboard.writeText(inputElement.value)
.then(() => { .then(() => {
// Provide visual feedback to the user button.classList.add('copied');
button.classList.add('copied'); setTimeout(() => {
setTimeout(() => { button.classList.remove('copied');
button.classList.remove('copied'); }, 1000);
}, 1000); // Remove the 'copied' class after 2000ms })
}) .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 fetchStates() { function fetchStates() {
const selectedCountry = document.getElementById('country').value; const selectedCountry = document.getElementById('country').value;

View File

@@ -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,39 @@
$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 "; $states=$_SESSION["states"];
if( strlen($_SESSION["states"]) <2 ) $states='no_states_access_selected';
$parts = explode(',', $states);
$quotedParts = array_map(function($item) { return "'" . $item . "'";}, $parts);
$stateAcc = implode(',', $quotedParts);
$sql= "SELECT COUNT(*) FROM cleads WHERE state IN ($stateAcc) 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 ($stateAcc) 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 +265,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 +317,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 +328,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" > &nbsp;'; if($page>1) echo '<a href="?',$backPage,'">&lt;','</a>'; echo ' &nbsp; </button>
<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> <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><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> <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><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> </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 +508,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 +549,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>

View File

@@ -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 &nbsp;<span><?php echo $appt['name'] ?> </span>&nbsp; <?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 &nbsp;<?php echo $appt['name'].'&nbsp;&nbsp;'. $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>

83
.hta_slug/profile.php Normal file
View File

@@ -0,0 +1,83 @@
<?php
require_once('.hta_config/crm_config.php');
require_once('.htac_header.php');
require_once('.htac_nav.php');
$nameLetter = "";
?>
<section class="container mx-auto px-4 max-w-2xl rounded-xl mt-10 py-20 shadow-xl">
<p class="text-[25px] font-bold">Profile</p>
<div><?php echo $nameLetter; ?></div>
<form method="post" >
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$convertPass = md5($_POST['pass']);
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("UPDATE users SET name = :name, email = :email, pass = :pass WHERE email = :userID");
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':pass', $convertPass);
$stmt->bindParam(':userID', $_SESSION['email']);
$stmt->execute();
echo '<script>window.location.href="/logout"</script>';
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
};
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM users WHERE email = :email");
$stmt->bindParam(':email', $_SESSION['email']);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row){
$nameParts = explode(" ", $row['name']);
$firstInitial = substr($nameParts[0], 0, 1);
$lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1);
$nameLetter = $firstInitial.$lastInitial;
?>
<div class="flex justify-center text-[60px] font-bold" >
<p class="mb-20" 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: 15px 20px 15px 20px; border-radius: 50%;"><?php echo $nameLetter; ?></p>
</div>
<div class="grid grid-cols-2 gap-6">
<div class="flex flex-col">
<label for="name">Name:</label>
<input type="text" name="name" id="" value="<?php echo $row['name']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
</div>
<div class="flex flex-col">
<label for="name">Email:</label>
<input type="text" name="email" id="" value="<?php echo $row['email']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
</div>
<div class="flex flex-col">
<label for="name">Mobile:</label>
<input type="text" name="mobile" id="" value="<?php echo $row['mobile']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
</div>
<div class="flex flex-col">
<label for="name">Access State:</label>
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" ><?php echo $row['states']; ?></p>
</div>
<div class="flex flex-col">
<label for="name">Access Business Verticals:</label>
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" ><?php echo $row['access']; ?></p>
</div>
<div class="flex flex-col">
<label for="name">Password:</label>
<input type="password" name="pass" id="" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
</div>
</div>
<?php
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
};
?>
<input class="mt-10 float-right" type="submit" value="Update Profile" 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;">
</form>
<p class="text-center font-bold text-[#FB5555] mt-10">if change profile information then login again</p>
</section>

View File

@@ -51,7 +51,7 @@
$lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1); $lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1);
echo ' <div style="display: flex; flex-direction: row; place-items: center"> echo ' <div style="display: flex; flex-direction: row; place-items: center">
<p>Hi <span>'.$nameParts[0].'</span></p>&nbsp; <p>Hi <span>'.$nameParts[0].'</span></p>&nbsp;
<p class="p-2 uppercase" style="background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%); border-radius: 50%; font-size: 20px; color: #fff; font-weight: bold;">'.$firstInitial.$lastInitial.'</p> <a href="/profile" class="p-2 uppercase" style="background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%); border-radius: 50%; font-size: 20px; color: #fff; font-weight: bold;">'.$firstInitial.$lastInitial.'</a>
</div>'; </div>';
} }
} catch (PDOException $e) { } catch (PDOException $e) {