This commit is contained in:
Suvodip
2024-05-08 22:07:11 +05:30
parent 72f4f36cb5
commit 1ba7ea57eb
3 changed files with 194 additions and 93 deletions

View File

@@ -51,7 +51,8 @@
foreach($rows as $row){
$nameParts = explode(" ", $row['name']);
$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;
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;';}
@@ -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'] == '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">
<form method="post">
<div class="grid grid-cols-1 lg:grid-cols-3 p-6 space-x-4">
<form method="post" class="w-full lg:col-span-2">
<div class="flex flex-col">
<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;">
@@ -90,20 +91,42 @@
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['formname']; ?></p>
</div>
</div>
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
<div>
<p><b>Country</b></p>
<select class="w-full" name="" id="country" onchange="fetchStates()" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
<option selected value="<?php echo $row['country']; ?>"><?php echo $row['country']; ?></option>
</select>
<input type="hidden" name="country" id="getCountryName">
</div>
<?php
$countryapiUrl = 'https://api.siliconpin.com/v3/list/country/';
$countryhandle = fopen($countryapiUrl, 'rb');
if ($countryhandle === false) {
echo 'Unable to open URL';
} 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>
<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>
</select>
<input type="hidden" name="state" id="getStateName">
</div>
<div>
<p><b>City</b></p>
@@ -168,6 +191,37 @@
<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;" />
</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 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;" />
@@ -175,10 +229,10 @@
</div>
</div>
</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="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>
</div>
<div>
@@ -246,7 +300,6 @@
$stmt->bindParam(':leadid', $_GET['id']);
$stmt->bindParam(':comment', $_POST['comment']);
$stmt->execute();
$saved_message = "New Appointment save successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
@@ -414,45 +467,38 @@ copyButtons.forEach(button => {
const inputId = button.getAttribute('data-input-id');
const inputElement = document.getElementById(inputId);
if (inputElement && inputElement.value) {
navigator.clipboard.writeText(inputElement.value)
.then(() => {
button.classList.add('copied');
setTimeout(() => {
button.classList.remove('copied');
}, 1000);
})
.catch(err => {
console.error('Unable to copy:', err);
});
navigator.clipboard.writeText(inputElement.value)
.then(() => {
button.classList.add('copied');
setTimeout(() => {
button.classList.remove('copied');
}, 1000);
})
.catch(err => {
console.error('Unable to copy:', err);
});
}
});
});
// Function to fetch countries and populate the country dropdown
function fetchCountries() {
fetch('https://api.siliconpin.com/v3/list/country/')
.then(res => res.json())
.then(data => {
const countryDropdown = document.getElementById('country');
countryDropdown.innerHTML = '<option value="">Select Country</option>';
data.forEach(country => {
const option = document.createElement('option');
option.value = country.iso2;
option.text = country.name;
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 fetchCountries() {
// fetch('https://api.siliconpin.com/v3/list/country/')
// .then(res => res.json())
// .then(data => {
// const countryDropdown = document.getElementById('country');
// countryDropdown.innerHTML = '<option value="">Select Country</option>';
// data.forEach(country => {
// const option = document.createElement('option');
// option.value = country.iso2;
// option.text = country.name;
// countryDropdown.appendChild(option);
// });
// });
// }
function fetchStates() {
myCountry();
const selectedCountry = document.getElementById('country').value;
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
.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() {
myState();
const selectedCountry = document.getElementById('country').value;
const selectedState = document.getElementById('state').value;
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 addressID = document.getElementById('address');
let countryID = document.getElementById('country');