209 lines
12 KiB
PHP
209 lines
12 KiB
PHP
<?php
|
|
require_once('.hta_config/crm_config.php');
|
|
require_once('.htac_header.php');
|
|
require_once('.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 '<script> window.location.assign("/admin/users") </script>';
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
};
|
|
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("SELECT * FROM users WHERE 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 id="form_edit_user" 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"; ?> />
|
|
<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>
|
|
<hr> <br>
|
|
|
|
<div class="flex flex-row">
|
|
<input type="checkbox" name="international" id="international" value="international" />
|
|
<label for="international" style="text-transform: uppercase;">international</label>
|
|
</div>
|
|
<br> <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 {
|
|
// echo $state['iso2'] . '<br>';
|
|
// $states = array( array("id"=>4006, "name"=>"Meghalaya", "iso2"=>"ML"), array("id"=>4007, "name"=>"Haryana", "iso2"=>"HR"), array("id"=>4008, "name"=>"Maharashtra", "iso2"=>"MH"), array("id"=>4009, "name"=>"Goa", "iso2"=>"GA"), array("id"=>4010, "name"=>"Manipur", "iso2"=>"MN"), array("id"=>4011, "name"=>"Puducherry", "iso2"=>"PY"), array("id"=>4012, "name"=>"Telangana", "iso2"=>"TG"), array("id"=>4013, "name"=>"Odisha", "iso2"=>"OR"), array("id"=>4014, "name"=>"Rajasthan", "iso2"=>"RJ"), array("id"=>4015, "name"=>"Punjab", "iso2"=>"PB"), array("id"=>4016, "name"=>"Uttarakhand", "iso2"=>"UT"), array("id"=>4017, "name"=>"Andhra Pradesh", "iso2"=>"AP"), array("id"=>4018, "name"=>"Nagaland", "iso2"=>"NL"), array("id"=>4019, "name"=>"Lakshadweep", "iso2"=>"LD"), array("id"=>4020, "name"=>"Himachal Pradesh", "iso2"=>"HP"), array("id"=>4021, "name"=>"Delhi", "iso2"=>"DL"), array("id"=>4022, "name"=>"Uttar Pradesh", "iso2"=>"UP"), array("id"=>4023, "name"=>"Andaman and Nicobar Islands", "iso2"=>"AN"), array("id"=>4024, "name"=>"Arunachal Pradesh", "iso2"=>"AR"), array("id"=>4025, "name"=>"Jharkhand", "iso2"=>"JH"), array("id"=>4026, "name"=>"Karnataka", "iso2"=>"KA"), array("id"=>4027, "name"=>"Assam", "iso2"=>"AS"), array("id"=>4028, "name"=>"Kerala", "iso2"=>"KL"), array("id"=>4029, "name"=>"Jammu and Kashmir", "iso2"=>"JK"), array("id"=>4030, "name"=>"Gujarat", "iso2"=>"GJ"), array("id"=>4031, "name"=>"Chandigarh", "iso2"=>"CH"), array("id"=>4033, "name"=>"Dadra and Nagar Haveli and Daman and Diu", "iso2"=>"DH"), array("id"=>4034, "name"=>"Sikkim", "iso2"=>"SK"), array("id"=>4035, "name"=>"Tamil Nadu", "iso2"=>"TN"), array("id"=>4036, "name"=>"Mizoram", "iso2"=>"MZ"), array("id"=>4037, "name"=>"Bihar", "iso2"=>"BR"), array("id"=>4038, "name"=>"Tripura", "iso2"=>"TR"), array("id"=>4039, "name"=>"Madhya Pradesh", "iso2"=>"MP"), array("id"=>4040, "name"=>"Chhattisgarh", "iso2"=>"CT"), array("id"=>4852, "name"=>"Ladakh", "iso2"=>"LA"), array("id"=>4853, "name"=>"West Bengal", "iso2"=>"WB") );
|
|
$user_states = $conn->prepare("SELECT `states` FROM `users` WHERE `id` = '".$_GET["id"]."'");
|
|
$user_states->execute();
|
|
$ustate = $user_states->fetchAll(PDO::FETCH_COLUMN);
|
|
$ustate=explode(",", $ustate[0]);
|
|
foreach ($states as $state) {
|
|
|
|
|
|
foreach ($states as $state) {
|
|
$isChecked = in_array($state["iso2"], $ustate);
|
|
echo '<input type="checkbox" id="' . $state["iso2"] . '" name="' . $state["iso2"] . '"'; if($isChecked) echo "checked"; echo ' >';
|
|
echo '<label for="' . $state["iso2"] . '">' . $state["name"] . '</label><br>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
</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>";
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<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>
|