This commit is contained in:
dev sp
2024-04-29 12:55:11 +00:00
commit ca6af2f5e2
67 changed files with 6792 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
?>

View File

@@ -0,0 +1,273 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$select_access = ['beanstalk', 'inhouse', 'teenybeans', 'iimtt', 'buzzapp', 'atheneum', 'teenybeans_curriculum'];
$access_values_array = [];
foreach ($select_access as $access) {
if (isset($_POST[$access])) {
$access_values_array[] = $_POST[$access];
}
}
$access_value = implode(',', $access_values_array);
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = md5($_POST['pass']);
$selected_states = implode(',', $_POST['states']); // Collect selected state values
try {
$stmt = $conn->prepare("INSERT INTO users (name, email, mobile, access, pass, states) VALUES (:name, :email, :mobile, :access, :pass, :states)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mobile', $phone);
$stmt->bindParam(':access', $access_value);
$stmt->bindParam(':pass', $password);
$stmt->bindParam(':states', $selected_states); // Bind selected states
$stmt->execute();
echo "Record added successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 30px; margin-bottom: 30px;">
<form action="" method="post" style="width: 600px; max-width: 600px; border: 1px solid #36365050; padding: 20px; border-radius: 20px; box-shadow: 0px 0px 10px 0px #363650;">
<p style="font-size: 25px; font-weight: bold; margin-top: 10px; margin-bottom: 10px;">Add new user</p>
<div style="display: flex; flex-direction: column;">
<label for="name">Name:</label>
<input type="text" name="name" id="name" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<label>
Country:
</label>
<label for="national">National
<input type="radio" name="country" id="national" onchange="checkCountry()" />
</label>
<label for="international">International
<input type="radio" name="country" id="international" onchange="checkCountry()" />
</label>
</div>
<!-- <div style="display: flex; flex-direction: column;">
<label for="country">Country:</label>
<select name="country" id="country" onchange="checkCountry();" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
<option value="">Select Country</option>
</select>
</div> -->
<div style="display: flex; flex-direction: column;">
<p>Access:</p>
<?php
try {
$stmt = $conn->prepare("SELECT * FROM business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){ ?>
<div>
<input type="checkbox" name="<?php echo $row['bv']; ?>" id="<?php echo $row['bv']; ?>" value="<?php echo $row['bv']; ?>" />
<label for="<?php echo $row['bv']; ?>" style="text-transform: uppercase;"><?php echo $row['bv']; ?></label>
</div>
<?php
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</div>
<div style="display: none; flex-direction: column;" id="state-access">
<p style="font-size: 16px; font-weight: bold; margin-top: 10px;">Access by state:</p>
<div id="selectedStateDisplay"></div>
<div class="dropdown">
<button class="dropbtn" id="selectStatesBtn">Select States</button>
<div class="dropdown-content" id="stateDropdown">
<!-- State options will be populated here -->
</div>
</div>
</div>
<div style="display: flex; flex-direction: column;">
<label for="pass">Password:</label>
<input type="text" name="pass" id="pass" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<input type="submit" name="submit" id="submit" value="Submit" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 10px 20px 10px 20px; color: #fff; border-radius: 6px; float: right; margin-top: 30px;" />
</div>
</form>
</div>
<script>
function fetchCountries() {
fetch('https://api.siliconpin.com/v3/list/country/')
.then(res => res.json())
.then(data => {
const countryDropdown = document.getElementById('country');
countryDropdown.innerHTML = '<option id="" value="">Select Country</option>';
data.forEach(country => {
const option = document.createElement('option');
option.value = country.iso2;
option.text = country.name;
countryDropdown.appendChild(option);
});
});
}
fetchCountries();
// function checkCountry(){
// let getCountry = document.getElementById('country').value;
// console.log(getCountry);
// if(getCountry === "national"){
// document.getElementById('state-access').style.display = 'flex';
// } else{
// document.getElementById('state-access').style.display = 'none';
// }
// }
function checkCountry() {
if (document.getElementById('national').checked) {
document.getElementById('state-access').style.display = 'flex';
} else {
document.getElementById('state-access').style.display = 'none';
}
}
function fetchStates() {
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=IN`)
.then(res => res.json())
.then(data => {
const dropdownContent = document.getElementById('stateDropdown');
dropdownContent.innerHTML = ''; // Clear previous content
data.forEach(state => {
const checkboxDiv = document.createElement('div');
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.name = 'states[]'; // You might want to use an array here if submitting form
checkbox.value = state.iso2;
checkbox.id = state.iso2;
const label = document.createElement('label');
label.textContent = state.name;
label.style = 'text-transform: uppercase';
label.setAttribute('for', state.iso2);
checkboxDiv.appendChild(checkbox);
checkboxDiv.appendChild(label);
dropdownContent.appendChild(checkboxDiv);
// Add event listener to checkbox change
checkbox.addEventListener('change', function() {
updateSelectedStateDisplay();
});
});
});
}
function toggleDropdown() {
const dropdownContent = document.getElementById('stateDropdown');
dropdownContent.classList.toggle('show');
}
// Update the selected state display
function updateSelectedStateDisplay() {
const selectedStates = Array.from(document.querySelectorAll('input[name="states[]"]:checked'))
.map(checkbox => checkbox.parentNode.querySelector('label').textContent);
const selectedStateDisplay = document.getElementById('selectedStateDisplay');
selectedStateDisplay.textContent = 'Selected States: ' + selectedStates.join(', ');
}
// Add an event listener to the button
document.getElementById('selectStatesBtn').addEventListener('click', function(event) {
// Prevent the default form submission behavior
event.preventDefault();
// Toggle the dropdown visibility
toggleDropdown();
});
fetchStates();
</script>
<style>
.dropdown {
position: relative;
display: inline-block;
border: 1px solid #363650;
border-radius: 5px;
width: 100%;
}
.dropbtn {
border: 1px solid #363650;
padding: 6px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
/* min-width: 160px; */
width: 100%;
overflow-y: auto;
max-height: 230px; /* Adjust as needed */
border: 1px solid #ddd;
z-index: 1;
}
.dropdown-content div {
display: flex;
align-items: center;
padding: 5px;
}
.dropdown-content div label {
margin-left: 5px;
}
.dropdown-content div:hover {
background-color: #ddd;
}
.show {
display: block;
}
/* For small screens */
@media screen and (max-width: 767px) {
#stateCheckboxes {
display: grid;
grid-template-columns: repeat(2, 1fr); /* 2 columns */
gap: 10px; /* Adjust the gap as needed */
}
}
/* For large screens */
@media screen and (min-width: 768px) {
#stateCheckboxes {
display: grid;
grid-template-columns: repeat(3, 1fr); /* 3 columns */
gap: 10px; /* Adjust the gap as needed */
}
}
</style>

View File

@@ -0,0 +1,138 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$select_access = ['beanstalk', 'inhouse', 'teenybeans', 'iimtt', 'buzzapp', 'atheneum', 'teenybeans_curriculum'];
$access_values_array = [];
foreach ($select_access as $access) {
if (isset($_POST[$access])) {
$access_values_array[] = $_POST[$access];
}
}
$access_value = implode(',', $access_values_array);
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = md5($_POST['pass']);
$selected_states = implode(',', $_POST['selectedStates']); // Collect selected state values
try {
$stmt = $conn->prepare("INSERT INTO users (name, email, mobile, access, pass, states) VALUES (:name, :email, :mobile, :access, :pass, :states)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mobile', $phone);
$stmt->bindParam(':access', $access_value);
$stmt->bindParam(':pass', $password);
$stmt->bindParam(':states', $selected_states); // Bind selected states
$stmt->execute();
echo "Record added successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 30px; margin-bottom: 30px;">
<form action="" method="post" style="width: 600px; max-width: 600px; border: 1px solid #36365050; padding: 20px; border-radius: 20px; box-shadow: 0px 0px 10px 0px #363650;">
<p style="font-size: 25px; font-weight: bold; margin-top: 10px; margin-bottom: 10px;">Add new user</p>
<div style="display: flex; flex-direction: column;">
<label for="name">Name:</label>
<input type="text" name="name" id="name" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<p>Access:</p>
<?php
try {
$stmt = $conn->prepare("SELECT * FROM business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){ ?>
<div>
<input type="checkbox" name="<?php echo $row['bv']; ?>" id="<?php echo $row['bv']; ?>" value="<?php echo $row['bv']; ?>" />
<label for="<?php echo $row['bv']; ?>" style="text-transform: uppercase;"><?php echo $row['bv']; ?></label>
</div>
<?php
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</div>
<div style="display: flex; flex-direction: column;">
<p style="font-size: 16px; font-weight: bold; margin-top: 10px;">Access by state:</p>
<div class="" id="stateList"><!-- State checkboxes will be dynamically added here --></div>
</div>
<div style="display: flex; flex-direction: column;">
<label for="pass">Password:</label>
<input type="text" name="pass" id="pass" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<input type="submit" name="submit" id="submit" value="Submit" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 10px 20px 10px 20px; color: #fff; border-radius: 6px; float: right; margin-top: 30px;" />
</div>
</form>
</div>
<script>
// JavaScript code to fetch data and populate checkboxes
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=IN`)
.then(res => res.json())
.then(data => {
const stateList = document.getElementById('stateList');
data.forEach(state => {
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.value = state.iso2;
checkbox.name = 'selectedStates[]'; // Adjust name as per your form's needs
const label = document.createElement('label');
label.appendChild(checkbox);
label.appendChild(document.createTextNode('\u00A0' + state.name)); // Adding a non-breaking space before the state name
stateList.appendChild(label);
});
});
</script>
<style>
/* For small screens */
@media screen and (max-width: 767px) {
#stateList {
display: grid;
grid-template-columns: repeat(2, 1fr); /* 2 columns */
gap: 10px; /* Adjust the gap as needed */
}
}
/* For large screens */
@media screen and (min-width: 768px) {
#stateList {
display: grid;
grid-template-columns: repeat(2, 1fr); /* 3 columns */
gap: 10px; /* Adjust the gap as needed */
}
}
</style>

View File

@@ -0,0 +1,127 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['bv'] && $_POST['save_lead'] ){
try {
$lowercase_bv = strtolower($_POST['bv']);
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("INSERT INTO business_verticals (bv) VALUES (:bv)");
$stmt->bindParam(':bv', $lowercase_bv);
$stmt->execute();
echo "Record added successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<div>
<button onclick="toggleDisplay();" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 10px 20px 10px 20px; color: #fff; border-radius: 6px; float: right; margin-top: 100px; margin-bottom: 30px;">Add Business Verticals</button>
</div>
<div class="add-bv-form" id="add-bv-form">
<div class="flex flex-row place-content-between" style="border-bottom: 2px solid #464E5F; border-style: dashed;">
<h3 style="font-size: 25px; font-weight: bold;">Add new Business Verticals</h3>
<p onclick="toggleDisplay();" class="rounded-lg px-1.5 text-[#464E5F] text-[25px] cursor-pointer" style="border: 2px solid #464E5F; border-radius: 50%;">&#10008;</p>
</div>
<form method="post">
<div class="flex flex-col mt-4">
<label for="bv">Business Verticals Name:</label>
<input type="text" name="bv" id="bv" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div>
<input type="submit" name="save_lead" id="submit" value="Save" style="color:#fff; border-radius: 6px; background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; margin-top: 10px; padding: 10px 20px 10px 20px;" />
</div>
</form>
</div>
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="">
<thead>
<tr>
<th class="text-center border-b-2 p-3">Serial</th>
<th class="text-center border-b-2 p-3">Business Verticals</th>
<th class="text-center border-b-2 p-3">Time</th>
<th class="text-center border-b-2 p-3">Action</th>
</tr>
</thead>
<tbody>
<?php
try {
$bv_counter = 1;
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM business_verticals ORDER BY time DESC");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row){
?>
<tr>
<td class="border-y-2 p-2 text-center"><?php echo $bv_counter; ?></td>
<td class="border-y-2 p-2 uppercase"><?php echo $row['bv']; ?></td>
<td class="border-y-2 p-2 text-center"><?php echo $row['time']; ?></td>
<td class="border-y-2 p-2">
<div class="flex flex-row justify-center">
<a href="/admin/edit-business-verticals/?id=<?php echo $row['id']; ?>">Edit</a> &nbsp; | &nbsp;
<a href="/admin/delete-business-verticals/?id=<?php echo $row['id']; ?>">Delete</a>
</div>
</td>
</tr>
<?php $bv_counter++; }
$num_rows = $stmt->rowCount();
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</tbody>
</table>
<script>
function toggleDisplay() {
var element = document.getElementById('add-bv-form');
if (element.style.display === 'block') {
element.style.display = 'none';
} else {
element.style.display = 'block';
element.classList.add('slide-in-animation'); // Add class to trigger animation
}
}
// Event listener for the Esc key
document.addEventListener('keydown', function(event) {
if (event.keyCode === 27) {
var modal = document.getElementById('add-bv-form');
if (modal.style.display === 'block') {
modal.style.display = 'none';
}
}
});
</script>
<style>
.add-bv-form {
background-color: #F8F8F8;
display: none;
position: fixed;
top: 0%;
right: 0%;
transform: translateX(100%);
/* transform: translate(-0%, -50%); */
width: 100%;
max-width: 500px;
box-shadow: 0px 0px 20px 0px #443780;
border-radius: 2px;
z-index: 100;
height: 100%;
padding: 10px 20px 10px 20px;
animation: slideInRight 0.5s forwards; /* Animation to slide in */
/* overflow-x: auto; */
}
@keyframes slideInRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0%);
}
}
</style>

525
.hta_slug/admin/cleads.php Normal file
View File

@@ -0,0 +1,525 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
// deleteCofermation()
$today_date = date("Y-m-d");
$next_day = date("Y-m-d", strtotime("+1 day"));
$yesterday = date("Y-m-d", strtotime("-1 day"));
$this_week = date("Y-m-d", strtotime("-7 day"));
$prev_month_date = date("Y-m-d", strtotime("first day of previous month", strtotime($today_date)));
$firstDayOfCurrentMonth = date("Y-m-01");
$firstDayOfLastMonth = date("Y-m-01", strtotime("first day of last month"));
$firstDateOfYear = date("Y") . '-01-01';
$previousYear = date("Y") - 1;
$firstDateOfPreviousYear = $previousYear . '-01-01';
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['new_lead']) && $_POST['new_lead'] && isset($_POST['name']) && $_POST['name'] && isset($_POST['phone']) && $_POST['phone']) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$formname = 'crm-portal';
$note = $_POST['note'];
$origin = $_POST['origin'];
$gender = $_POST['gender'];
$profession = $_POST['profession'];
$country = $_POST['country'];
$state = $_POST['state'];
$city = $_POST['city'];
$address = $_POST['address'];
$status = 'New';
try {
$stmt = $conn->prepare("INSERT INTO cleads (name, email, phone, formname, note, origin, status, gender, profession, country, state, city, address ) VALUES (:name, :email, :phone, :formname, :note, :origin, :status, :gender, :profession, :country, :state, :city, :address)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':formname', $formname);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':origin', $origin);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':gender', $gender);
$stmt->bindParam(':profession', $profession);
$stmt->bindParam(':country', $country);
$stmt->bindParam(':state', $state);
$stmt->bindParam(':city', $city);
$stmt->bindParam(':address', $address);
$stmt->execute();
echo "Record added successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<?php
if(isset($_POST['delete_records'])) {
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) {
$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>
<div id="page-body" class="flex flex-row place-content-between px-4">
<dialog>
<button style="float: right; color: #FF0000; font-size: 25px; padding: 6px;">&#10008;</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>
</div>
<form method="GET" class="p-6 flex flex-col pb-10">
<p>Choose Date for filter</p>
<div class="flex flex-row rounded-xl py-10">
<div class="flex flex-row place-items-center">
<label for="start_date">From Date</label>
<input type="date" name="start_date" id="start_date" />
</div> &nbsp; | &nbsp;
<div class="flex flex-row place-items-center">
<label for="end_date">To Date</label>
<input type="date" name="end_date" id="end_date" />
</div>
</div>
<button class="rounded-lg p-1 text-[#fff]" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center;" type="submit"><p class="text-center p-1.5">Search</p></button>
</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>
<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>
</div>
<form method="post">
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold" style="width: 100%;" >
<thead>
<tr>
<?php
if($_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">Name</th>
<th class="text-center border-b-2 p-3">ID</th>
<th class="text-center border-b-2 p-3">Status Update</th>
<!-- <th class="text-center border-b-2 p-3">Contact Detail</th> -->
<th class="text-center border-b-2 p-3">Form Name</th>
<th class="text-center border-b-2 p-3">Date</th>
<th class="text-center border-b-2 p-3">Quick Action</th>
</tr>
</thead>
<tbody >
<?php
// Number of records per page
$recordsPerPage = 500;
// 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);
$searchQuery = isset($_GET['search']) ? trim($_GET['search']) : '';
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';
$accessArray = explode(",", $_SESSION['access']);
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
if (!empty($searchQuery)) {
// this is keywords search
$stmt = $conn->prepare("SELECT * FROM cleads WHERE (id LIKE ? OR name LIKE ? OR email LIKE ? OR phone LIKE ?) ORDER BY time DESC LIMIT ?, ?");
$stmt->bindValue(1, "%$searchQuery%", PDO::PARAM_STR);
$stmt->bindValue(2, "%$searchQuery%", PDO::PARAM_STR);
$stmt->bindValue(3, "%$searchQuery%", PDO::PARAM_STR);
$stmt->bindValue(4, "%$searchQuery%", PDO::PARAM_STR);
$stmt->bindValue( 5, 0, PDO::PARAM_INT); // Offset for pagination
$stmt->bindValue( 6, $recordsPerPage, PDO::PARAM_INT); // Records per page
// this is for date serch
}elseif (!empty($start_date) && !empty($end_date)) {
$start_date = date('Y-m-d', strtotime($start_date));
$end_date = date('Y-m-d', strtotime($end_date));
$stmt = $conn->prepare("SELECT * FROM cleads WHERE time BETWEEN ? AND ?");
$stmt->bindValue(1, $start_date);
$stmt->bindValue(2, $end_date);
}else{
// if user type admin then show all lead
if($_SESSION['user_type'] == 'admin'){
$stmt = $conn->prepare("SELECT COUNT(*) FROM cleads");
$stmt->execute();
$totalRecords = $stmt->fetchColumn();
$totalPages = ceil($totalRecords / $recordsPerPage);
$offset = ($currentPage - 1) * $recordsPerPage;
$stmt = $conn->prepare("SELECT * FROM cleads ORDER BY time DESC LIMIT :offset, :recordsPerPage");
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
$stmt->bindParam(':recordsPerPage', $recordsPerPage, PDO::PARAM_INT);
}else{
}
}
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$row_count = count($rows);
for ($i = 0; $i < $row_count; $i++) {
// echo $row_count . " ";
}
echo "<p class='px-4'>Total ".$row_count." Rows Found</p>";
// Status Conditional Color
foreach($rows as $row){
$only_date = explode(' ', $row['time']);
$lead_id = $row['id'];
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
elseif($row['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
// if status = warm then select
// 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>
<?php if($_SESSION['user_type'] == 'admin'){?>
<td class="border-y-2 p-2">
<input type="checkbox" name="selected_records[]" value="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>" />
</td>
<?php }?>
<td class="border-y-2 p-2"><label for="<?php echo $row['id']; ?>"><?php echo $row['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 $row['id'] ?>"><?php echo $row['id'] ?></a></td>
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $row['status'];?></div></td>
<!-- <td class="border-y-2 p-2">
<p><i class="fa fa-envelope">&nbsp;<?php // echo $row['email'] ?></i></p>
<p><i class="fa fa-phone">&nbsp;<?php // echo $row['phone'] ?></i></p>
</td> -->
<td class="border-y-2 p-2"><?php echo $row['formname'] ?></td>
<td class="border-y-2 p-2"><?php echo $only_date[0]; ?></td>
<td class="border-y-2 p-2">
<div class="flex flex-row justify-center place-items-center">
<i class="fa fa-envelope" style="font-size: 20px"></i>
<div>
<a href="https://wa.me/<?php echo $row['phone'] ?>?text=Hello%2C%20how%20are%20you%3F"><i class="fab fa-whatsapp" style="font-size: 20px"></i></a>
</div>
</td>
</tr>
<?php
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</tbody>
</table>
</form>
<!-- Pagination Links -->
<div class="pagination">
<?php if ($currentPage > 1): ?>
<a href="?page=<?php echo ($currentPage - 1); ?>">Previous</a>
<?php endif; ?>
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
<a href="?page=<?php echo $i; ?>" <?php if ($i === $currentPage) echo 'class="active"'; ?>><?php echo $i; ?></a>
<?php endfor; ?>
<?php if ($currentPage < $totalPages): ?>
<a href="?page=<?php echo ($currentPage + 1); ?>">Next</a>
<?php endif; ?>
</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;">
<p class="text-[25px] font-bold">Add Lead</p>
<p onclick="toggleDisplay();" class="rounded-lg px-1.5 text-[#464E5F] text-[25px] cursor-pointer" style="border: 2px solid #464E5F; border-radius: 50%;">&#10008;</p>
</div>
<form action="" method="post" class="p-4">
<div class="grid grid-cols-1 md:grid-cols-2">
<div class="flex flex-col mr-4">
<label for="country"> Country:</label>
<select name="country" id="country" onchange="fetchStates()" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
<option value="">Select Country</option>
</select>
</div>
<div class="flex flex-col mr-4">
<label for="state"> State:</label>
<select name="state" id="state" onchange="fetchCities()" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
<option value="">Select State</option>
</select>
</div>
<div class="flex flex-col mr-4">
<label for="city"> City:</label>
<select name="city" id="city" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;">
<option value="">Select City</option>
</select>
</div>
<div class="flex flex-col mr-4">
<label for="address">Address:</label>
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="address" id="address" />
</div>
<div class="flex flex-col mr-4">
<label for="name">Name:</label>
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="name" id="name" />
</div>
<div class="flex flex-col mr-4">
<label for="gender">Gender:</label>
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="gender" id="gender" >
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Others">Others</option>
</select>
</div>
<div class="flex flex-col mr-4">
<label for="profession">Profession:</label>
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="profession" id="profession" />
</div>
<div class="flex flex-col mr-4">
<label for="email">E-mail:</label>
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="email" id="email" />
</div>
<div class="flex flex-col mr-4">
<label for="phone">Phone:</label>
<input class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="phone" id="phone" />
</div>
</div>
<div class="flex flex-row place-content-between p-2 text-[25px] font-bold" style="border-bottom: 2px solid #464E5F; border-style: dashed;">Lead Information</div>
<div class="grid grid-cols-1 md:grid-cols-2">
<div class="flex flex-col mr-4">
<label for="origin">Details:</label>
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="origin" id="origin" >
<option value="Facebook Ads">Facebook Ads</option>
<option value="Google Ads">Google Ads</option>
<option value="Linkedin Ads">Linkedin Ads</option>
<option value="Instagram">Instagram</option>
<option value="Messenger">Messenger</option>
<option value="Whatsapp">Whatsapp</option>
<option value="GMB">GMB</option>
<option value="Linkedin">Linkedin</option>
<option value="Inbound Call">Inbound Call</option>
<option value="Outbound Call">Outbound Call</option>
<option value="Others">Others</option>
</select>
</div>
<div class="flex flex-col mr-4">
<label for="user">Lead Owner:</label>
<select class="" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" type="text" name="user" id="user" >
<?php
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM users");
$stmt->execute();
$users_rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$row_count = count($users_rows);
if($row_count > 0){
foreach($users_rows as $users_data){
echo '<option value="'.$users_data['email'].'">'.$users_data['email'].'</option>';
}
} else{
echo '<p>No users Found</p>';
}
?>
</select>
</div>
</div>
<div class="flex flex-col mr-4">
<label for="note">Note:</label>
<textarea type="text" name="note" id="note" rows="6" cols="10" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;"></textarea>
</div>
<div class="flex flex-col">
<input class="p-2" type="submit" name="new_lead" id="new_lead" value="Submit" style="color:#fff; border-radius: 6px; background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; margin-top: 10px;"/>
</div>
</form>
</div>
<script>
// 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 fetchStates() {
const selectedCountry = document.getElementById('country').value;
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`)
.then(res => res.json())
.then(data => {
const stateDropdown = document.getElementById('state');
stateDropdown.innerHTML = '<option value="">Select State</option>';
data.forEach(state => {
const option = document.createElement('option');
option.value = state.iso2;
option.text = state.name;
stateDropdown.appendChild(option);
});
});
}
// Function to fetch cities based on selected country and state and populate the city dropdown
function fetchCities() {
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}`)
.then(res => res.json())
.then(data => {
const cityDropdown = document.getElementById('city');
cityDropdown.innerHTML = '<option value="">Select City</option>';
data.forEach(city => {
const option = document.createElement('option');
option.value = city.name;
option.text = city.name;
cityDropdown.appendChild(option);
});
});
}
// Fetch countries on page load
fetchCountries();
const dialog = document.querySelector("dialog");
const showButton = document.querySelector("dialog + button");
const closeButton = document.querySelector("dialog button");
// "Show the dialog" button opens the dialog modally
showButton.addEventListener("click", () => {
dialog.showModal();
});
// "Close" button closes the dialog
closeButton.addEventListener("click", () => {
dialog.close();
});
function toggleDisplay() {
var element = document.getElementById('add-lead-form');
if (element.style.display === 'block') {
element.style.display = 'none';
} else {
element.style.display = 'block';
element.classList.add('slide-in-animation'); // Add class to trigger animation
}
}
// Event listener for the Esc key
document.addEventListener('keydown', function(event) {
if (event.keyCode === 27) {
var modal = document.getElementById('add-lead-form');
if (modal.style.display === 'block') {
modal.style.display = 'none';
}
}
});
function deleteCofermation(){
let deleteButton = document.getElementById('delete-button');
let leadID = document.getElementById('<?php echo $row['id']; ?>').value;
if(leadID != null){
if(deleteButton.style.display === 'flex'){
deleteButton.style.display = 'none';
}else{
deleteButton.style.display = 'flex'
}
}
}
</script>
<style>
.add-lead-form {
background-color: #F8F8F8;
display: none;
position: fixed;
top: 0%;
right: 0%;
transform: translateX(100%);
/* transform: translate(-0%, -50%); */
width: 100%;
max-width: 500px;
box-shadow: 0px 0px 20px 0px #443780;
border-radius: 2px;
z-index: 100;
height: 100%;
animation: slideInRight 0.5s forwards; /* Animation to slide in */
/* overflow-x: auto; */
}
@keyframes slideInRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0%);
}
}
/* .add-lead-form{
background-color: #F8F8F8;
display: none;
position: fixed;
top: 50%;
right: 0%;
transform: translate(-0%, -50%);
width: 100%;
max-width: 500px;
box-shadow: 0px 0px 20px 0px #443780;
border-radius: 5px;
z-index: 100;
height: 100%;
} */
.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>

View File

@@ -0,0 +1,43 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
if($_SERVER['REQUEST_METHOD'] == "POST"){
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("DELETE FROM business_verticals WHERE id = :id");
$stmt->bindParam(':id', $_POST['id']);
$stmt->execute();
echo '<script>window.location.href = "/admin/business-verticals";</script>';
exit();
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
}
?>
<div class="delete-div">
<form method="post">
<p style="font-size: 20px; padding: 10px 0px 10px 0px;">Confirm to Delete id <?php echo $_GET['id']; ?>? </p>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="submit" name="submit" id="submit" value="YES" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 9px 20px 9px 20px; color: #fff; border-radius: 6px; cursor: pointer;" />
<a href="/admin/business-verticals" style="border:3px solid #443780; text-align: center; padding: 10px 20px 10px 20px; color: #443780; border-radius: 6px;">NO</a>
</form>
</div>
<style>
.delete-div{
position: absolute;
margin: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #E6E5F4;
max-width: 500px;
min-width: 400px;
padding: 30px 50px 30px 50px;
border-radius: 9px
}
</style>

View File

@@ -0,0 +1,42 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
if($_SERVER['REQUEST_METHOD'] == "POST"){
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("DELETE FROM users WHERE id = :id");
$stmt->bindParam(':id', $_POST['id']);
$stmt->execute();
echo '<script>window.location.href = "/admin/users";</script>';
exit();
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
}
?>
<div class="delete-div">
<form method="post">
<p style="font-size: 20px; padding: 10px 0px 10px 0px;">Confirm to Delete id <?php echo $_GET['id']; ?>? </p>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="submit" name="submit" id="submit" value="YES" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 9px 20px 9px 20px; color: #fff; border-radius: 6px; cursor: pointer;" />
<a href="/admin/users" style="border:3px solid #443780; text-align: center; padding: 10px 20px 10px 20px; color: #443780; border-radius: 6px;">NO</a>
</form>
</div>
<style>
.delete-div{
position: absolute;
margin: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #E6E5F4;
max-width: 500px;
min-width: 400px;
padding: 30px 50px 30px 50px;
border-radius: 9px
}
</style>

View File

@@ -0,0 +1,43 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
if($_SERVER['REQUEST_METHOD']=="POST"){
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("UPDATE business_verticals SET bv = :bv WHERE id = :id");
$stmt->bindParam(':bv', $_POST['bv']);
$stmt->bindParam(':id', $_GET['id']);
$stmt->execute();
echo "Record Updated successfully";
} 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 business_verticals WHERE id=:id");
$stmt->bindParam(":id", $_GET['id']);
$stmt->execute();
$bvrows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($bvrows as $bvname){ ?>
<div>
<form method="post">
<input type="text" name="bv" id="bv" value="<?php echo $bvname['bv']; ?>" />
<input type="submit" value="Update" id="submit" name="submit" />
</form>
</div>
<?php
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>

View File

@@ -0,0 +1,130 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// $name = $_POST['name'];
// $email = $_POST['email'];
// $phone = $_POST['phone'];
// $password = md5($_POST['pass']);
try {
$select_access = ['beanstalk', 'inhouse', 'teenybeans', 'iimtt', 'buzzapp', 'atheneum', 'teenybeans_curriculum'];
$access_values_array = [];
foreach ($select_access as $access) {
if (isset($_POST[$access])) {
$access_values_array[] = $_POST[$access];
}
}
$access_value = implode(',', $access_values_array);
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = md5($_POST['pass']);
$user_id = $_GET['id'];
$stmt = $conn->prepare("UPDATE users SET name = :name, email = :email, mobile = :mobile, access = :access, pass = :pass WHERE id = :id");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mobile', $phone);
$stmt->bindParam(':access', $access_value);
$stmt->bindParam(':pass', $password);
$stmt->bindParam(':id', $user_id);
$stmt->execute();
echo "Record Updated successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<?php
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 id = :id");
$stmt->bindParam(':id', $_GET['id']);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){?>
<div style="max-width: 600px;">
<form action="" method="post">
<p>Edit User</p>
<div style="display: flex; flex-direction: column;">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="<?php echo $row['name'] ?>" />
</div>
<div style="display: flex; flex-direction: column;">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" value="<?php echo $row['email'] ?>" />
</div>
<div style="display: flex; flex-direction: column;">
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" value="<?php echo $row['mobile'] ?>" />
</div>
<div style="display: flex; flex-direction: column;">
<p>Access:</p>
<?php
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
$user_stmt = $conn->prepare("SELECT `access` FROM `users` WHERE `id` = '".$_GET["id"]."'");
$user_stmt->execute();
$user_bvs = $user_stmt->fetchAll(PDO::FETCH_COLUMN);
$user_bvs=explode(",", $user_bvs[0]); // you need to make the CSV to array.
foreach($rows as $row) {
$isChecked = in_array($row['bv'], $user_bvs);
?>
<div>
<input type="checkbox" name="<?php echo $row['bv']; ?>" id="<?php echo $row['bv']; ?>" value="<?php echo $row['bv']; ?>" <?php if($isChecked) echo "checked"; ?> />
<label for="<?php echo $row['bv']; ?>" style="text-transform: uppercase;"><?php echo $row['bv']; ?></label>
</div>
<?php
}
} else {
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</div>
<div style="display: flex; flex-direction: column;">
<label for="pass">Password:</label>
<input type="text" name="pass" id="pass" />
</div>
<div style="display: flex; flex-direction: column;">
<input type="submit" name="submit" id="submit" value="Submit"/>
</div>
</form>
</div>
<?php
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>

View File

@@ -0,0 +1,191 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
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 `id` = '".$_GET["id"]."'");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row){
$seletedState = explode(",", $row['states']);
}
}catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// $name = $_POST['name'];
// $email = $_POST['email'];
// $phone = $_POST['phone'];
// $password = md5($_POST['pass']);
try {
$select_access = ['beanstalk', 'inhouse', 'teenybeans', 'iimtt', 'buzzapp', 'atheneum', 'teenybeans_curriculum'];
$access_values_array = [];
foreach ($select_access as $access) {
if (isset($_POST[$access])) {
$access_values_array[] = $_POST[$access];
}
}
$access_value = implode(',', $access_values_array);
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = md5($_POST['pass']);
$user_id = $_GET['id'];
$stmt = $conn->prepare("UPDATE users SET name = :name, email = :email, mobile = :mobile, access = :access, pass = :pass WHERE id = :id");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mobile', $phone);
$stmt->bindParam(':access', $access_value);
$stmt->bindParam(':pass', $password);
$stmt->bindParam(':id', $user_id);
$stmt->execute();
echo "Record Updated successfully";
} 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 id = :id");
$stmt->bindParam(':id', $_GET['id']);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){?>
<div class="flex flex-col place-items-center mt-4">
<form action="" method="post" class="max-w-2xl shadow-xl p-4 rounded-lg">
<p class="my-4" style="border-bottom: 2px solid #464E5F; border-style: dashed; font-size: 20px; font-weight: bold" >Edit User</p>
<div style="display: flex; flex-direction: column;">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="<?php echo $row['name'] ?>" />
</div>
<div class="flex flex-row">
<div style="display: flex; flex-direction: column; width: 100%;">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" value="<?php echo $row['email'] ?>" />
</div>
<div style="display: flex; flex-direction: column; width: 100%;">
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" value="<?php echo $row['mobile'] ?>" />
</div>
</div>
<div style="display: flex; flex-direction: column;">
<p style="font-weight: bold; ">Access:</p>
<div class="bv-list">
<?php
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
$user_stmt = $conn->prepare("SELECT `access` FROM `users` WHERE `id` = '".$_GET["id"]."'");
$user_stmt->execute();
$user_bvs = $user_stmt->fetchAll(PDO::FETCH_COLUMN);
$user_bvs=explode(",", $user_bvs[0]); // you need to make the CSV to array.
foreach($rows as $row) {
$isChecked = in_array($row['bv'], $user_bvs);
?>
<div class="flex flex-row">
<input type="checkbox" name="<?php echo $row['bv']; ?>" id="<?php echo $row['bv']; ?>" value="<?php echo $row['bv']; ?>" <?php if($isChecked) echo "checked"; ?> />&nbsp;
<label for="<?php echo $row['bv']; ?>" style="text-transform: uppercase;"><?php echo $row['bv']; ?></label>
</div>
<?php
}
} else {
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</div>
</div>
<div style="display: flex; flex-direction: column;">
<p style="font-size: 16px; font-weight: bold; margin-top: 10px;">Access by state:</p>
<div class="flex" id="stateList"><!-- State checkboxes will be dynamically added here --></div>
</div>
<div style="display: flex; flex-direction: column;">
<label for="pass">Password:</label>
<input type="text" name="pass" id="pass" />
</div>
<div style="display: flex; flex-direction: column;">
<input type="submit" name="submit" id="submit" value="Submit" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 6px; color: #fff; border-radius: 6px; margin-top: 6px;" />
</div>
</form>
</div>
<?php
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
<script>
// JavaScript code to fetch data and populate checkboxes
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=IN`)
.then(res => res.json())
.then(data => {
const stateList = document.getElementById('stateList');
data.forEach(state => {
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.value = state.iso2;
checkbox.name = 'selectedStates[]'; // Adjust name as per your form's needs
const label = document.createElement('label');
label.appendChild(checkbox);
label.appendChild(document.createTextNode('\u00A0' + state.name)); // Adding a non-breaking space before the state name
<?php
foreach($seletedState as $pre_state){
?>
if("<?php echo $pre_state; ?>".includes(state.iso2)) {
checkbox.checked = true;
}
<?php } ?>
stateList.appendChild(label);
});
});
</script>
<style>
/* For small screens */
@media screen and (max-width: 767px) {
#stateList, .bv-list {
font-size: 15px;
display: grid;
grid-template-columns: repeat(2, 1fr); /* 2 columns */
gap: 6px; /* Adjust the gap as needed */
}
}
/* For large screens */
@media screen and (min-width: 768px) {
#stateList, .bv-list {
font-size: 15px;
display: grid;
grid-template-columns: repeat(3, 1fr); /* 3 columns */
gap: 6px; /* Adjust the gap as needed */
}
}
</style>

240
.hta_slug/admin/users.php Normal file
View File

@@ -0,0 +1,240 @@
<?php
require_once('/var/www/html/.hta_config/crm_config.php');
require_once('/var/www/html/.htac_header.php');
require_once('/var/www/html/.htac_nav.php');
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST['name'] && $_POST['pass'] && $_POST['email']) {
$select_access = ['beanstalk', 'inhouse', 'teenybeans', 'iimtt', 'buzzapp', 'atheneum', 'teenybeans_curriculum'];
$access_values_array = [];
foreach ($select_access as $access) {
if (isset($_POST[$access])) {
$access_values_array[] = $_POST[$access];
}
}
$access_value = implode(',', $access_values_array);
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = md5($_POST['pass']);
$selected_states = implode(',', $_POST['selectedStates']); // Collect selected state values
try {
$stmt = $conn->prepare("INSERT INTO users (name, email, mobile, access, pass, states) VALUES (:name, :email, :mobile, :access, :pass, :states)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mobile', $phone);
$stmt->bindParam(':access', $access_value);
$stmt->bindParam(':pass', $password);
$stmt->bindParam(':states', $selected_states); // Bind selected states
$stmt->execute();
echo "Record added successfully";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<div>
<button onclick="toggleDisplay();" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 10px 20px 10px 20px; color: #fff; border-radius: 6px; float: right; margin-top: 100px; margin-bottom: 30px;">Add Business Verticals</button>
<a href="/admin/add-user" class="" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 10px 20px 10px 20px; color: #fff; border-radius: 6px; float: right; margin-top: 30px;">Add User</a>
</div>
<table class="bg-[#fff] text-[#3F4254] rounded-lg font-bold">
<thead>
<tr>
<th class="text-center border-b-2 p-3">Name</th>
<th class="text-center border-b-2 p-3">Email</th>
<th class="text-center border-b-2 p-3">Mobile</th>
<th class="text-center border-b-2 p-3">Time</th>
<th class="text-center border-b-2 p-3">Access</th>
<th class="text-center border-b-2 p-3">Access by State</th>
<th class="text-center border-b-2 p-3">Action</th>
</tr>
</thead>
<tbody>
<?php
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");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row){
?>
<tr>
<td class="border-y-2 p-2"><?php echo $row['name']; ?></td>
<td class="border-y-2 p-2"><?php echo $row['email']; ?></td>
<td class="border-y-2 p-2"><?php echo $row['mobile']; ?></td>
<td class="border-y-2 p-2"><?php echo $row['time']; ?></td>
<td class="border-y-2 p-2"><?php echo $row['access']; ?></td>
<td class="border-y-2 p-2"><?php echo $row['states']; ?></td>
<td class="border-y-2 p-2">
<div class="flex flex-row justify-center">
<a href="/admin/edit-user/?id=<?php echo $row['id']; ?>">Edit</a> &nbsp; | &nbsp;
<a href="/admin/delete-user/?id=<?php echo $row['id']; ?>">Delete</a>
</div>
</td>
</tr>
<?php
}
$num_rows = $stmt->rowCount();
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</tbody>
</table>
<div class="add-user-form" id="add-user-form">
<form action="" method="post" style="">
<div class="flex flex-row place-content-between" style="border-bottom: 2px solid #464E5F; border-style: dashed;">
<p style="font-size: 25px; font-weight: bold;">Add new user</p>
<p onclick="toggleDisplay();" class="rounded-lg px-1.5 text-[#464E5F] text-[25px] cursor-pointer" style="border: 2px solid #464E5F; border-radius: 50%;">&#10008;</p>
</div>
<div style="display: flex; flex-direction: column;">
<label for="name">Name:</label>
<input type="text" name="name" id="name" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div class="flex flex-row space-x-2">
<div style="display: flex; flex-direction: column; width: 100%;">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column; width: 100%;">
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
</div>
<div style="display: flex; flex-direction: column; border-bottom: 1px solid #7E8299;">
<p>Access:</p>
<div class="bv-list">
<?php
try {
$stmt = $conn->prepare("SELECT * FROM business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){ ?>
<div class="flex flex-row">
<input type="checkbox" name="<?php echo $row['bv']; ?>" id="<?php echo $row['bv']; ?>" value="<?php echo $row['bv']; ?>" />&nbsp;
<label for="<?php echo $row['bv']; ?>" style="text-transform: uppercase;"><?php echo $row['bv']; ?></label>
</div>
<?php
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</div>
</div>
<div style="display: flex; flex-direction: column;">
<p style="font-size: 16px; font-weight: bold; margin-top: 10px;">Access by state:</p>
<div class="" id="stateList">
<!-- State checkboxes will be dynamically added here -->
</div>
</div>
<div style="display: flex; flex-direction: column;">
<label for="pass">Password:</label>
<input type="text" name="pass" id="pass" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
</div>
<div style="display: flex; flex-direction: column;">
<input type="submit" name="submit" id="submit" value="Submit" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 10px 20px 10px 20px; color: #fff; border-radius: 6px; float: right; margin-top: 30px;" />
</div>
</form>
</div>
<script>
// JavaScript code to fetch data and populate checkboxes
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=IN`)
.then(res => res.json())
.then(data => {
const stateList = document.getElementById('stateList');
data.forEach(state => {
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.value = state.iso2;
checkbox.name = 'selectedStates[]'; // Adjust name as per your form's needs
const label = document.createElement('label');
label.appendChild(checkbox);
label.appendChild(document.createTextNode('\u00A0' + state.name)); // Adding a non-breaking space before the state name
stateList.appendChild(label);
});
});
function toggleDisplay() {
var element = document.getElementById('add-user-form');
if (element.style.display === 'block') {
element.style.display = 'none';
} else {
element.style.display = 'block';
element.classList.add('slide-in-animation'); // Add class to trigger animation
}
}
// Event listener for the Esc key
document.addEventListener('keydown', function(event) {
if (event.keyCode === 27) {
var modal = document.getElementById('add-user-form');
if (modal.style.display === 'block') {
modal.style.display = 'none';
}
}
});
</script>
<style>
/* For small screens */
@media screen and (max-width: 767px) {
#stateList, .bv-list {
display: grid;
grid-template-columns: repeat(2, 1fr); /* 2 columns */
gap: 10px; /* Adjust the gap as needed */
}
}
/* For large screens */
@media screen and (min-width: 768px) {
#stateList, .bv-list {
display: grid;
grid-template-columns: repeat(3, 1fr); /* 3 columns */
gap: 10px; /* Adjust the gap as needed */
}
}
.add-user-form {
background-color: #F8F8F8;
display: none;
position: fixed;
top: 0%;
right: 0%;
transform: translateX(100%);
/* transform: translate(-0%, -50%); */
width: 100%;
max-width: 700px;
box-shadow: 0px 0px 20px 0px #443780;
border-radius: 2px;
z-index: 100;
height: 100%;
padding: 10px 20px 10px 20px;
animation: slideInRight 0.5s forwards; /* Animation to slide in */
overflow-y: scroll;
font-size: 15px;
}
@keyframes slideInRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0%);
}
}
</style>