mig
This commit is contained in:
@@ -204,8 +204,8 @@
|
||||
</thead>
|
||||
<tbody >
|
||||
<?php
|
||||
// Number of records per page
|
||||
$recordsPerPage = 500;
|
||||
//?bv=teenybeans&start_date=2024-05-04&end_date=2024-05-18
|
||||
|
||||
|
||||
// Current page
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
@@ -217,63 +217,58 @@
|
||||
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'] : '';
|
||||
|
||||
$searchTerm =isset($_GET['search']) ? $_GET['search'] : "%";
|
||||
$businessVertical =isset($_GET['bv']) ? $_GET['bv'] : "%";
|
||||
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '2014-05-05';
|
||||
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d');
|
||||
$start_time = microtime(true);
|
||||
$resultsPerPage = 100;
|
||||
$page =isset($_GET['page']) ? $_GET['page'] : 1;
|
||||
$offset = ($page - 1) * $resultsPerPage ;
|
||||
$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{
|
||||
}
|
||||
}
|
||||
//first query to get the total number for pagination
|
||||
$sql = "SELECT COUNT(*) FROM cleads
|
||||
WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND verticals LIKE :businessVertical";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bindValue(':searchTerm', "%$searchTerm%");
|
||||
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':start_date', $start_date);
|
||||
$stmt->bindValue(':end_date', $end_date);
|
||||
$stmt->bindValue(':businessVertical', $businessVertical);
|
||||
$stmt->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>";
|
||||
$totalRows = $stmt->fetchColumn();
|
||||
|
||||
// second & final query to get the page_view data
|
||||
|
||||
$sql = "SELECT * FROM cleads
|
||||
WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND verticals LIKE :businessVertical
|
||||
ORDER BY id DESC LIMIT :limit OFFSET :offset";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed
|
||||
$stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':start_date', $start_date);
|
||||
$stmt->bindValue(':end_date', $end_date);
|
||||
$stmt->bindValue(':businessVertical', $businessVertical);
|
||||
$stmt->execute();
|
||||
$leads = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$totalResults = count($leads);
|
||||
$totalPages = ceil($totalRows / $resultsPerPage);
|
||||
|
||||
echo "<p class='px-4'>Total ".$totalRows." 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;';}
|
||||
foreach($leads as $lead){
|
||||
$only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available';
|
||||
$lead_id = $lead['id'];
|
||||
if($lead['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';}
|
||||
elseif($lead['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';}
|
||||
elseif($lead['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';}
|
||||
elseif($lead['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';}
|
||||
elseif($lead['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'];}
|
||||
?>
|
||||
@@ -298,36 +293,72 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<a href="https://wa.me/<?php echo $lead['phone'] ?>?text=Hello%2C%20how%20are%20you%3F"><i class="fab fa-whatsapp" style="font-size: 20px"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<?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']; ?>" />
|
||||
<input type="checkbox" name="selected_records[]" value="<?php echo $lead['id']; ?>" id="<?php echo $lead['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"><label for="<?php echo $lead['id']; ?>"><?php echo $lead['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 $lead['id'] ?>"><?php echo $lead['id'] ?></a></td>
|
||||
<td class="border-y-2 p-2"><div style="<?php echo $conditional_background_color; ?> font-weight: bold;"><?php echo $lead['status'];?></div></td>
|
||||
<!-- <td class="border-y-2 p-2">
|
||||
<p><i class="fa fa-envelope"> <?php // echo $row['email'] ?></i></p>
|
||||
<p><i class="fa fa-phone"> <?php // echo $row['phone'] ?></i></p>
|
||||
<p><i class="fa fa-envelope"> <?php // echo $lead['email'] ?></i></p>
|
||||
<p><i class="fa fa-phone"> <?php // echo $lead['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"><?php echo $lead['formname'] ?></td>
|
||||
<td class="border-y-2 p-2"><?php echo $only_date; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
|
||||
$end_time = microtime(true);
|
||||
|
||||
// Calculate execution time
|
||||
$execution_time = ($end_time - $start_time);
|
||||
|
||||
// Output execution time
|
||||
echo "Page executed in: " . $execution_time . " seconds";
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php
|
||||
|
||||
// $totalPages = ceil($totalRows / $resultsPerPage);
|
||||
// echo "<div>";
|
||||
// echo "<h3>Pages:</h3>-",$page,'-';
|
||||
// for ($i = 1; $i <= $totalPages; $i++) {
|
||||
// echo "<a href='?page=$i'>$i</a> ";
|
||||
// }
|
||||
// echo "</div>";
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
$getParams = $_GET; unset($getParams['page']); $getParams['page'] = $page-1; $backPage= http_build_query($getParams); unset($getParams['page']); $getParams['page'] = $page+1; $nextkPage= http_build_query($getParams);
|
||||
echo'
|
||||
<div class="bg-white p-4 flex items-center flex-wrap">
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="inline-flex">
|
||||
<li><button class="px-4 py-2 text-green-600 transition-colors duration-150 bg-white border border-r-0 border-green-600 rounded-l-lg focus:shadow-outline hover:bg-green-100"> '; if($page>1) echo '<a href="?',$backPage,'"><','</a>'; echo ' </button></li>
|
||||
<li><button class="px-4 py-2 text-white transition-colors duration-150 bg-green-600 border border-r-0 border-green-600 focus:shadow-outline"> '.$page.' </button></li>
|
||||
<li><button class="px-4 py-2 text-green-600 transition-colors duration-150 bg-white border border-green-600 rounded-r-lg focus:shadow-outline hover:bg-green-100"> '; if($page<$totalPages) echo '<a href="?',$nextkPage,'">>','</a>'; echo ' </button></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
';
|
||||
|
||||
?>
|
||||
<!-- <div class="pagination">
|
||||
<?php if ($currentPage > 1): ?>
|
||||
<a href="?page=<?php echo ($currentPage - 1); ?>">Previous</a>
|
||||
<?php endif; ?>
|
||||
@@ -339,7 +370,7 @@
|
||||
<?php if ($currentPage < $totalPages): ?>
|
||||
<a href="?page=<?php echo ($currentPage + 1); ?>">Next</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- New Lead Form Section -->
|
||||
<div id="add-lead-form" class="add-lead-form">
|
||||
@@ -414,26 +445,6 @@
|
||||
<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>
|
||||
@@ -532,7 +543,7 @@
|
||||
});
|
||||
function deleteCofermation(){
|
||||
let deleteButton = document.getElementById('delete-button');
|
||||
let leadID = document.getElementById('<?php echo $row['id']; ?>').value;
|
||||
let leadID = document.getElementById('<?php echo $row['id']; ?>').value; //getting Err: here
|
||||
if(leadID != null){
|
||||
if(deleteButton.style.display === 'flex'){
|
||||
deleteButton.style.display = 'none';
|
||||
@@ -570,20 +581,7 @@
|
||||
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;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require_once('.htac_header.php');
|
||||
require_once('.htac_nav.php');
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
// $name = $_POST['name'];
|
||||
// $email = $_POST['email'];
|
||||
|
||||
0
.hta_slug/admin/list_leads.php
Normal file
0
.hta_slug/admin/list_leads.php
Normal file
46
.hta_slug/admin/test.php
Normal file
46
.hta_slug/admin/test.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Database connection failed: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Pagination variables
|
||||
$limit = 10; // Number of records per page
|
||||
$page = isset($_GET['page']) ? $_GET['page'] : 1; // Current page number
|
||||
$offset = ($page - 1) * $limit; // Offset for pagination
|
||||
|
||||
// Fetch products with pagination
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT * FROM cleads LIMIT :limit OFFSET :offset");
|
||||
$stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Count total number of products
|
||||
$totalStmt = $pdo->query("SELECT COUNT(*) FROM products");
|
||||
$totalProducts = $totalStmt->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
die("Error fetching products: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Display products
|
||||
echo "<h1>Product List</h1>";
|
||||
|
||||
echo "<ul>";
|
||||
foreach ($products as $product) {
|
||||
echo "<li>{$product['id']} - {$product['name']}</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
// Pagination links
|
||||
$totalPages = ceil($totalProducts / $limit);
|
||||
echo "<div>";
|
||||
echo "<h3>Pages:</h3>";
|
||||
for ($i = 1; $i <= $totalPages; $i++) {
|
||||
echo "<a href='?page=$i'>$i</a> ";
|
||||
}
|
||||
echo "</div>";
|
||||
?>
|
||||
@@ -10,32 +10,70 @@
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
$mysqli = new mysqli($mariaServer, $mariaUser, $mariaPass, $mariaDb);
|
||||
if ($mysqli->connect_error) die("Connection failed: " . $mysqli->connect_error);
|
||||
$result = $mysqli->query("SELECT bv FROM business_verticals");
|
||||
if ($result) {
|
||||
$access_array = array();
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$access_array[] = $row['bv'];
|
||||
}
|
||||
}
|
||||
$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
|
||||
|
||||
// $access_array = ['beanstalk', 'inhouse', 'teenybeans', 'iimtt', 'buzzapp', 'atheneum', 'teenybeans_curriculum'];
|
||||
$access_values_array = [];
|
||||
foreach ($access_array as $access) {
|
||||
if (isset($_POST[$access])) {
|
||||
$access_values_array[] = $_POST[$access];
|
||||
}
|
||||
}
|
||||
$selected_access = implode(',', $access_values_array);
|
||||
|
||||
|
||||
$result->free();
|
||||
// print_r($access_array);
|
||||
} else { echo "Error: " . $mysqli->error; }
|
||||
$mysqli->close();
|
||||
|
||||
|
||||
|
||||
|
||||
$apiUrl = 'https://api.siliconpin.com/v3/list/country/state/?country=IN';
|
||||
$handle = fopen($apiUrl, 'rb');
|
||||
if ($handle === false) {
|
||||
echo 'Unable to open URL';
|
||||
} else {
|
||||
$jsonResponse = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
$states = json_decode($jsonResponse, true);
|
||||
if ($states === null) {
|
||||
echo 'Error decoding JSON from API';
|
||||
} else {
|
||||
$state_values_array = [];
|
||||
if (isset($_POST['international'])) $state_values_array[] ='international';
|
||||
foreach ($states as $state) {
|
||||
if (isset($_POST[$state['iso2']])) $state_values_array[] = $_POST[$state['iso2']];
|
||||
}
|
||||
$selected_states = implode(',', $state_values_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$pass=md5($_POST['pass']);
|
||||
$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(':name', $_POST['name']);
|
||||
$stmt->bindParam(':email', $_POST['email']);
|
||||
$stmt->bindParam(':mobile', $_POST['phone']);
|
||||
$stmt->bindParam(':access', $selected_access);
|
||||
$stmt->bindParam(':pass', $pass);
|
||||
$stmt->bindParam(':states', $selected_states); // Bind selected states
|
||||
$stmt->execute();
|
||||
|
||||
echo "Record added successfully";
|
||||
echo "A new user added.";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
@@ -136,11 +174,39 @@
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<hr> <br>
|
||||
<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>
|
||||
<p style="font-size: 16px; font-weight: bold; margin-top: 10px;"> Responsible Area:</p>
|
||||
<div class="flex flex-row">
|
||||
<input type="checkbox" name="international" id="international" value="international" />
|
||||
<label for="international" style="text-transform: uppercase;">international</label>
|
||||
</div>
|
||||
<hr><br>
|
||||
<div style="height:200px; overflow:scroll;white-space: nowrap; overflow-x: visible;">
|
||||
|
||||
<?php
|
||||
$apiUrl = 'https://api.siliconpin.com/v3/list/country/state/?country=IN';
|
||||
$handle = fopen($apiUrl, 'rb');
|
||||
if ($handle === false) {
|
||||
echo 'Unable to open URL';
|
||||
} else {
|
||||
$jsonResponse = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
$states = json_decode($jsonResponse, true);
|
||||
if ($states === null) {
|
||||
echo 'Error decoding JSON from API';
|
||||
} else {
|
||||
foreach ($states as $state) {
|
||||
echo '<input type="checkbox" id="'.$state["iso2"].'" name="'.$state["iso2"].'"'. ' value="' . $state["iso2"] . '" />';
|
||||
echo '<label for="' . $state["iso2"] . '">' . $state["name"] . '</label><br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="pass">Password:</label>
|
||||
@@ -153,23 +219,23 @@
|
||||
</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
|
||||
// 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
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
// stateList.appendChild(label);
|
||||
// });
|
||||
// });
|
||||
function toggleDisplay() {
|
||||
var element = document.getElementById('add-user-form');
|
||||
if (element.style.display === 'block') {
|
||||
|
||||
Reference in New Issue
Block a user