1113 lines
66 KiB
PHP
1113 lines
66 KiB
PHP
<?php
|
|
require_once('.hta_config/crm_config.php');
|
|
require_once('.htac_header.php');
|
|
require_once('.htac_nav.php');
|
|
|
|
$getLeadID = $_GET['id'];
|
|
// echo $_GET['id'];
|
|
// Below two fetch for edit data
|
|
|
|
// this is count notifications
|
|
$stmt = $conn->prepare("SELECT COUNT(*) FROM comments WHERE leadid = :leadid");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->execute();
|
|
$totalRecords = $stmt->fetchColumn();
|
|
// echo $totalRecords;
|
|
if($_SERVER['REQUEST_METHOD']=="POST" && isset($_POST['update_data']) && $_POST['update_data']){
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("UPDATE cleads SET name = :name, email = :email, phone = :phone, date = :date, status = :status, user = :user, country = :country, state= :state, city = :city, address = :address, profession = :profession, coupon_code = :coupon_code, gender = :gender, warm_status = :warm_status WHERE id = :id");
|
|
$stmt->bindParam(':name', $_POST['name']);
|
|
$stmt->bindParam(':email', $_POST['email']);
|
|
$stmt->bindParam(':phone', $_POST['phone']);
|
|
$stmt->bindParam(':date', $_POST['date']);
|
|
$stmt->bindParam(':status', $_POST['status']);
|
|
$stmt->bindParam(':user', $_POST['user']);
|
|
$stmt->bindParam(':country', $_POST['country']);
|
|
$stmt->bindParam(':state', $_POST['state']);
|
|
$stmt->bindParam(':city', $_POST['city']);
|
|
$stmt->bindParam(':address', $_POST['address']);
|
|
$stmt->bindParam(':profession', $_POST['profession']);
|
|
$stmt->bindParam(':coupon_code', $_POST['coupon_code']);
|
|
$stmt->bindParam(':gender', $_POST['gender']);
|
|
$stmt->bindParam(':warm_status', $_POST['warm_status']);
|
|
$stmt->bindParam(':id', $_GET['id']);
|
|
$stmt->execute();
|
|
|
|
echo "Record Updated successfully";
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
};
|
|
try {
|
|
// $password = md5($_POST['pass']);
|
|
// $email = $_POST['email'];
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("SELECT * FROM cleads WHERE id = :id");
|
|
$stmt->bindParam(':id', $_GET['id']);
|
|
$stmt->execute();
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
// var_dump($rows);
|
|
foreach($rows as $row){
|
|
$usersEmailForSendMessage = $row['email'];
|
|
$usersNameforSendMessage = $row['name'];
|
|
$usersNumberforSendMessage = $row['phone'];
|
|
$nameParts = explode(" ", $row['name']);
|
|
$firstInitial = substr($nameParts[0], 0, 1);
|
|
$lastInitial = isset($nameParts[1]) ? substr($nameParts[1], 0, 1) : '';
|
|
$name_letter = $firstInitial . $lastInitial;
|
|
|
|
if($row['status'] == 'New'){$conditional_background_color = 'background-color: #D4FFFF; border: 1px solid #2C9C9C; border-radius: 5px; color: #2C9C9C;';}
|
|
elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D0E9FF; border: 1px solid #1A91FF; border-radius: 5px; color: #1A91FF;';}
|
|
elseif($row['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 1px solid #3F4254; border-radius: 5px; color: #3F4254;';}
|
|
elseif($row['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 1px solid #40916C; border-radius: 5px; color: #40916C;';}
|
|
elseif($row['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 1px solid #FB5555; border-radius: 5px; color: #FB5555;';}
|
|
elseif($row['status'] == 'Inactive'){$conditional_background_color = 'background-color: #FFD9D9; border: 1px solid #FB5555; border-radius: 5px; color: #FB5555;';}
|
|
?>
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 p-6 space-x-4">
|
|
<form method="post" class="w-full lg:col-span-2">
|
|
<div class="flex flex-col">
|
|
<div class="flex flex-col bg-[#F6F6F6] rounded-xl">
|
|
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<div class="flex flex-row justify-center place-items-center">
|
|
<p class="h-fit p-[10px] rounded-l-full uppercase" style="background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%); font-size: 20px; color: #fff; font-weight: bold;"><?php echo $name_letter; ?></p>
|
|
<div class="flex flex-row justify-center place-items-center items-center rounded-r-[5px]" style="border: 1px solid #D9D9D9; padding: 6px;">
|
|
<input class="w-full rounded-r-[6px]" type="text" name="name" id="name" value="<?php echo $row['name']; ?>" style="background-color: #f6f6f6; border: none;" />
|
|
<button class="copy-btn fa fa-copy" data-input-id="name"></button>
|
|
</div>
|
|
</div>
|
|
<div class="flex flex-row justify-center place-items-center items-center" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
<input class="w-full" type="text" name="email" id="email" value="<?php echo $row['email']; ?>" style="background-color: #f6f6f6; border: none;" />
|
|
<button class="copy-btn fa fa-copy" data-input-id="email"></button>
|
|
</div>
|
|
<div class="flex flex-row justify-center place-items-center items-center" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
<input class="w-full" type="text" name="phone" id="phone" value="<?php echo $row['phone']; ?>" style="background-color: #f6f6f6; border: none;" />
|
|
<button class="copy-btn fa fa-copy" data-input-id="phone"></button>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<div>
|
|
<p><b>Client ID</b></p>
|
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['id']; ?></p>
|
|
</div>
|
|
<div class="" >
|
|
<p><b>Quick Action</b></p>
|
|
<div class="flex flex-row place-items-center " style="border: 1px solid #939393; background-color: #D9D9D9; border-radius: 6px">
|
|
<select onchange="changeBvValue();" name="bv" id="businessVerticals" style="width: 100px; border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
<option value="0">-Select-</option>
|
|
<?php
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("SELECT bv FROM business_verticals");
|
|
$stmt->execute();
|
|
$verticalsRows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$selectedBV = [];
|
|
foreach($usersCleads as $userEmail){
|
|
$selectedBV[] = $userEmail['user'];
|
|
}
|
|
foreach($verticalsRows as $verticalsData){
|
|
$isUserSelected = in_array($verticalsData['bv'], $selectedBV) ? 'selected' : '';
|
|
echo '<option value="'.$verticalsData['bv'].'" '.$isUserSelected.'>'.$verticalsData['bv'].'</option>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
?>
|
|
<option value="bip">BIP</option>
|
|
</select>
|
|
<div class="xzmdropdown-wrapper ">
|
|
<button class="xzmdropdown-btn"><i class="fa fa-envelope" style="font-size: 20px"></i></button>
|
|
<div id="templateList" class="xzmdropdown-content"></div>
|
|
</div> |
|
|
<div>
|
|
<div class="xzmdropdown-wrapper ">
|
|
<button class="xzmdropdown-btn px-4"><i class="fab fa-whatsapp" style="font-size: 20px"></i></button>
|
|
<div id="templateWhatsappList" class="xzmdropdown-content"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<p><b>Form Name</b></p>
|
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['formname']; ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<?php
|
|
$countryapiUrl = 'https://api.siliconpin.com/v3/list/country/';
|
|
$countryhandle = fopen($countryapiUrl, 'rb');
|
|
if ($countryhandle === false) {
|
|
echo 'Unable to open URL';
|
|
} else {
|
|
$jsonResponse = stream_get_contents($countryhandle);
|
|
fclose($countryhandle);
|
|
$countrys = json_decode($jsonResponse, true);
|
|
if ($countrys === null) {
|
|
echo 'Error decoding JSON from API';
|
|
} else {
|
|
$lead_country = $conn->prepare("SELECT `country` FROM `cleads` WHERE `id` = :id");
|
|
$lead_country->bindParam(':id', $_GET["id"]);
|
|
$lead_country->execute();
|
|
$lcountry = $lead_country->fetch(PDO::FETCH_COLUMN);
|
|
$country = json_decode($lcountry);
|
|
echo '<div>
|
|
<p><b>Country</b></p>
|
|
<select onchange="fetchStates();" id="country" name="country" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px; width: 100%;"><option value="0">-Select-</option>';
|
|
foreach ($countrys as $countryItem) {
|
|
$isSelected = $countryItem["iso2"] === $lcountry;
|
|
echo '<option id="country" '.($isSelected ? 'selected' : '').' value="'.$countryItem["iso2"].'">'.$countryItem["name"].'</option>';
|
|
}
|
|
echo '</select>
|
|
</div>';
|
|
}
|
|
}
|
|
?>
|
|
<div>
|
|
<p><b>State</b></p>
|
|
<select class="w-full" name="state" id="state" onchange="fetchCities()" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
<option selected value="<?php echo $row['state']; ?>"><?php echo $row['state']; ?></option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<p><b>City</b></p>
|
|
<select class="w-full" name="city" id="city" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
<option selected value="<?php echo $row['city']; ?>"><?php echo $row['city']; ?></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<div>
|
|
<p><b>Address</b></p>
|
|
<input class="w-full" type="text" name="address" id="address" value="<?php echo $row['address']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div>
|
|
<p><b>Profession</b></p>
|
|
<input class="w-full" type="text" name="profession" id="profession" value="<?php echo $row['profession']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<div>
|
|
<p><b>Origin</b></p>
|
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['origin'] ?: "No origin"; ?></p>
|
|
</div>
|
|
<div>
|
|
<p><b>Lead Status</b></p>
|
|
<div class="flex flex-row">
|
|
<select class="w-full" name="status" id="status" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px; <?php echo $conditional_background_color; ?>">
|
|
<?php
|
|
$statusOptions = ['New', 'Contacted', 'Warm', 'Converted', 'Inactive', 'Disqualified'];
|
|
foreach ($statusOptions as $option) {
|
|
$selected = ($row['status'] === $option) ? 'selected' : '';
|
|
echo '<option value="' . $option . '" ' . $selected . '>' . ucfirst($option) . '</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
<?php
|
|
if ($row['status'] == 'Warm') {
|
|
echo '<select class="w-full" name="warm_status" id="warm_status" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><option value="0">-Select-</option>';
|
|
$options = array("Proposal Sent", "Meeting Conducted", "Interested");
|
|
foreach ($options as $option) {
|
|
$selected = ($option == $row['warm_status']) ? 'selected' : '';
|
|
echo '<option value="' . $option . '" ' . $selected . '>' . $option . '</option>';
|
|
}
|
|
echo '</select>';
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<div>
|
|
<p><b>Coupon Code</b></p>
|
|
<input class="w-full" type="text" name="coupon_code" id="coupon_code" value="<?php echo $row['coupon_code']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div>
|
|
<p><b>Time</b></p>
|
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;"><?php echo $row['time']; ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 md:grid-cols-3 p-3 border-b-2 border-[#D9D9D9] space-x-6" style="text-align: left;">
|
|
<div>
|
|
<p><b>Followup Date</b></p>
|
|
<input class="w-full" type="date" name="date" id="date" value="<?php echo $row['date']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div>
|
|
<p><b>Assign to</b></p>
|
|
<select id="user" name="user" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px; width: 100%;">
|
|
<option value="0">-Select-</option>
|
|
<?php
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("SELECT email FROM users");
|
|
$stmt->execute();
|
|
$usersRows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$stmtCleads = $conn->prepare("SELECT user FROM cleads WHERE id = :id");
|
|
$stmtCleads->bindParam(':id', $_GET['id']);
|
|
$stmtCleads->execute();
|
|
$usersCleads = $stmtCleads->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$selectedEmails = [];
|
|
foreach($usersCleads as $userEmail){
|
|
$selectedEmails[] = $userEmail['user'];
|
|
}
|
|
foreach($usersRows as $userData){
|
|
$isUserSelected = in_array($userData['email'], $selectedEmails) ? 'selected' : '';
|
|
echo '<option value="'.$userData['email'].'" '.$isUserSelected.'>'.$userData['email'].'</option>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div style="padding: 10px; ">
|
|
<input type="submit" id="update_data" name="update_data" value="Update" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; border-radius: 6px; padding: 10px 30px 10px 30px; float: right; cursor: pointer;" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<?php
|
|
if (isset($_GET['send-email-id']) && $_GET['send-email-id']) {
|
|
$url = "https://api.brevo.com/v3/smtp/email";
|
|
$apiKey = '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';
|
|
$data = [
|
|
"to" => [
|
|
[
|
|
"email" => $usersEmailForSendMessage,
|
|
"name" => $usersNameforSendMessage
|
|
]
|
|
],
|
|
"templateId" => (int)$_GET['send-email-id'], // Ensure this is an integer
|
|
"batchId" => "5c6cfa04-eed9-42c2-8b5c-6d470d978e9d"
|
|
];
|
|
$jsonData = json_encode($data);
|
|
|
|
$options = [
|
|
'http' => [
|
|
'header' => "Content-Type: application/json\r\n" .
|
|
"api-key: $apiKey\r\n",
|
|
'method' => 'POST',
|
|
'content' => $jsonData,
|
|
],
|
|
];
|
|
|
|
$context = stream_context_create($options);
|
|
$fp = @fopen($url, 'r', false, $context); // Suppress warnings to handle them manually
|
|
|
|
if ($fp === FALSE) {
|
|
$error = error_get_last();
|
|
echo 'Error occurred: ' . $error['message'];
|
|
} else {
|
|
$response = stream_get_contents($fp);
|
|
$http_response_header = $http_response_header ?? [];
|
|
$response_code = (int)substr($http_response_header[0], 9, 3);
|
|
|
|
if ($response === FALSE || $response_code >= 400) {
|
|
echo 'Error reading response: ' . $response;
|
|
} else {
|
|
$templateName = $_GET['send-email-id'];
|
|
$messageMethod = 'Email';
|
|
try {
|
|
$stmt = $conn->prepare("INSERT INTO communication (leadid, useremail, username, templateid, method) VALUES (:leadid, :useremail, :username, :templateid, :method)");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->bindParam(':useremail', $_SESSION['email']);
|
|
$stmt->bindParam(':username', $_SESSION['name']);
|
|
$stmt->bindParam(':templateid', $templateName);
|
|
$stmt->bindParam(':method', $messageMethod);
|
|
$stmt->execute();
|
|
$sendSuccessMessage = "Email Sent successfully";
|
|
echo '<script>window.location.href = "/edit-lead/?id='.$_GET['id'].'"</script>';
|
|
} catch (PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
}
|
|
// Close the file pointer
|
|
fclose($fp);
|
|
}
|
|
} elseif (isset($_GET['send-whatsapp-id']) && $_GET['send-whatsapp-id']) {
|
|
$url = "https://api.interakt.ai/v1/public/message/";
|
|
$apiKey = 'Basic {{OTgyajd4bHFUSXItSW9PN1BTdzhOenNDaS0ya0NQeXByRE0tMnRyQ3FrUTo=}}';
|
|
$data = [
|
|
"fullPhoneNumber" => $usersNumberforSendMessage,
|
|
"callbackData" => "some text here",
|
|
"type" => "Template",
|
|
"template" => [
|
|
"name" => "boost_conversion",
|
|
"languageCode" => "en",
|
|
"headerValues" => [
|
|
"header_variable_value"
|
|
],
|
|
"bodyValues" => [
|
|
$usersNameforSendMessage
|
|
]
|
|
]
|
|
];
|
|
$jsonData = json_encode($data);
|
|
|
|
$options = [
|
|
'http' => [
|
|
'header' => "Content-Type: application/json\r\n" .
|
|
"Authorization: $apiKey\r\n" .
|
|
"Content-Length: " . strlen($jsonData) . "\r\n",
|
|
'method' => 'POST',
|
|
'content' => $jsonData,
|
|
],
|
|
];
|
|
|
|
$context = stream_context_create($options);
|
|
$fp = fopen($url, 'r', false, $context);
|
|
if ($fp === FALSE) {
|
|
echo 'Error occurred';
|
|
} else {
|
|
$response = stream_get_contents($fp);
|
|
|
|
if ($response === FALSE) {
|
|
echo 'Error reading response';
|
|
} else {
|
|
if(isset($_GET['send-whatsapp-id'])){
|
|
$templateName = $_GET['send-whatsapp-id'];
|
|
} elseif(isset($_GET['send-email-id'])){
|
|
$templateName = $_GET['send-email-id'];
|
|
}
|
|
$messageMethod = 'WhatsApp';
|
|
try {
|
|
$stmt = $conn->prepare("INSERT INTO communication (leadid, useremail, username, templateid, method) VALUES (:leadid, :useremail, :username, :templateid, :method)");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->bindParam(':useremail', $_SESSION['email']);
|
|
$stmt->bindParam(':username', $_SESSION['name']);
|
|
$stmt->bindParam(':templateid', $templateName);
|
|
$stmt->bindParam(':method', $messageMethod);
|
|
$stmt->execute();
|
|
$sendSuccessMessage = "WhatsApp Sent successfully";
|
|
echo '<script>window.location.href = "/edit-lead/?id='.$_GET['id'].'"</script>';
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
// echo '<script>window.location.href="/edit-lead/?id='.$_GET['id'].'"</script>';
|
|
// echo $response;
|
|
}
|
|
fclose($fp);
|
|
}
|
|
}
|
|
?>
|
|
<div class="flex flex-col div-custom-margin" style="width: 100%;" >
|
|
<div class="bg-[#F6F6F6] rounded-xl p-3">
|
|
<div class="flex-container-x2y place-content-between" style="border-bottom: 2px solid #7E8299; border-style: dashed; padding-bottom: 3px;">
|
|
<p style="font-size: 25px; font-weight: bold;">Comments: <span><?php echo $totalRecords; ?></span></p>
|
|
<button id="toggleButton" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; border-radius: 6px; padding: 6px 20px 6px 20px;">Add Comment</button>
|
|
</div>
|
|
<div>
|
|
<?php
|
|
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['save_comment']) && $_POST['save_comment'] && isset($_POST['comments']) && $_POST['comments']){
|
|
try {
|
|
$local_lang = 'en';
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("INSERT INTO comments (comments, user, locale, leadid) VALUES (:comments, :user, :locale, :leadid)");
|
|
$stmt->bindParam(':comments', $_POST['comments']);
|
|
$stmt->bindParam(':user', $_SESSION['email']);
|
|
$stmt->bindParam(':locale', $local_lang);
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->execute();
|
|
echo "New Comment save successfully";
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
};
|
|
?>
|
|
<form class="" method="post" id="content" style="display: none;">
|
|
<div class="flex flex-col space-y-4" style="margin-top: 10px; border-bottom: 2px solid #7E8299; padding-bottom: 10px;">
|
|
<textarea class="rounded-md focus:outline-none w-full" rows="4" type="text" name="comments" id="comments" style="border: 2px solid #363650; padding: 6px;" ></textarea>
|
|
<input class="rounded-md focus:outline-none" type="submit" value="Save" name="save_comment" id="save_comment" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; padding: 8px 20px 8px 20px;" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div style="max-height: 265px; overflow-y: auto;">
|
|
<?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 comments WHERE leadid = :leadid ORDER BY created_at DESC");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->execute();
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
foreach($rows as $row){
|
|
$commenter_name_parts = explode("@", $row['user']);
|
|
$commenter_first_name_letter = substr($commenter_name_parts[0], 0, 1);
|
|
$commenter_last_name_letter = substr($commenter_name_parts[count($commenter_name_parts) - 1], 0, 1);
|
|
?>
|
|
<div style="">
|
|
<div class="flex flex-row place-items-center" style="margin-top: 3px;">
|
|
<p class=" p-2" style="background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%); border-radius: 50%; font-size: 20px; color: #fff; font-weight: bold; text-transform: uppercase;"><?php echo $commenter_first_name_letter.$commenter_last_name_letter; ?></p>
|
|
<p ><b style="font-size: 16px;"> <?php echo $row['user'] ?></b><br><?php echo date("Y-m-d", strtotime($row['created_at'])) ?></p>
|
|
<p style=""></p>
|
|
</div>
|
|
<p style="margin-top: 10px;"><?php echo $row['comments']; ?></p>
|
|
</div>
|
|
<?php
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
$saved_message = "";
|
|
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['appt_comment']) && $_POST['appt_comment'] && isset($_POST['appt_date']) && $_POST['appt_date'] ){
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("INSERT INTO appointment (appt_date, email, name, leadid, comment) VALUES (:appt_date, :email, :name, :leadid, :comment)");
|
|
$stmt->bindParam(':appt_date', $_POST['appt_date']);
|
|
$stmt->bindParam(':email', $_SESSION['email']);
|
|
$stmt->bindParam(':name', $_SESSION['name']);
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->bindParam(':comment', $_POST['comment']);
|
|
$stmt->execute();
|
|
$saved_message = "New Appointment save successfully";
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
};
|
|
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['appt_comment_update']) && $_POST['appt_comment_update'] && isset($_POST['appt_date']) && $_POST['appt_date'] ){
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("UPDATE appointment SET appt_date = :appt_date, comment = :comment WHERE id = :appointment_id AND leadid = :leadid");
|
|
$stmt->bindParam(':appt_date', $_POST['appt_date']);
|
|
$stmt->bindParam(':comment', $_POST['comment']);
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->bindParam(':appointment_id', $_POST['appointment_id']);
|
|
$stmt->execute();
|
|
|
|
$saved_message = "Appointment updated successfully";
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
};
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="flex flex-col mt-3 bg-[#F6F6F6] rounded-xl">
|
|
<div class="flex flex-row place-content-between p-3" style="border-bottom: 2px solid #7E8299; border-style: dashed;">
|
|
<div class="flex flex-col">
|
|
<p style="font-size: 20px; font-weight: bold;">Add Appointment</p>
|
|
<p><?php echo $saved_message; ?></p>
|
|
</div>
|
|
<button onclick="apptModal();" style="background: linear-gradient(180deg, #7875F4 0%, #46448E 100%); color: #fff; font-size: 20px; border-radius: 50%; padding: 0px 8px 0px 8px; height: fit-content;">+</button>
|
|
</div>
|
|
<div class="" style="max-height: 265px; overflow-y: auto;">
|
|
<?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 appointment WHERE leadid = :leadid");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->execute();
|
|
$appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$appt_rowCount = count($appt_data);
|
|
|
|
if($appt_rowCount > 0){
|
|
foreach($appt_data as $apptID){
|
|
$apptID = $apptID['id'];
|
|
}
|
|
}else{
|
|
$apptID = 1;
|
|
}
|
|
// echo $apptID;
|
|
|
|
// Custom function to compare appointment dates
|
|
function compareAppointmentDates($a, $b) {
|
|
$dateA = new DateTime($a['appt_date']);
|
|
$dateB = new DateTime($b['appt_date']);
|
|
$currentDateTime = new DateTime();
|
|
|
|
// Compare appointment dates
|
|
if ($dateA == $dateB) {
|
|
return 0;
|
|
}
|
|
|
|
// Check if appointments are in the future or past
|
|
if ($dateA > $currentDateTime && $dateB > $currentDateTime) {
|
|
return ($dateA < $dateB) ? -1 : 1; // Sort by ascending date
|
|
} elseif ($dateA < $currentDateTime && $dateB < $currentDateTime) {
|
|
return ($dateA < $dateB) ? 1 : -1; // Sort by descending date
|
|
} else {
|
|
// One appointment is in the future and one is in the past
|
|
return ($dateA > $dateB) ? -1 : 1; // Sort the future appointment first
|
|
}
|
|
}
|
|
|
|
// Sort appointments based on appointment date
|
|
usort($appt_data, 'compareAppointmentDates');
|
|
foreach($appt_data as $appt){
|
|
|
|
$apptDate = explode(" ", $appt['appt_date']);
|
|
$currentDateTime = new DateTime();
|
|
$appointmentDateTime = new DateTime($appt['appt_date']);
|
|
|
|
if ($appointmentDateTime > $currentDateTime) {
|
|
$app_status = 'Next Appointment';
|
|
} elseif ($appointmentDateTime < $currentDateTime) {
|
|
$app_status = 'Expired Appointment';
|
|
} else {
|
|
$app_status = 'Today\'s Appointment';
|
|
}
|
|
?>
|
|
<div class="flex flex-col px-6" style="border-bottom: 2px solid #D9D9D9; ">
|
|
<div class="flex flex-row place-content-between align-items-center">
|
|
<p style="font-size: 15px; font-weight: bold;"><?php echo $app_status; ?></p>
|
|
<button style="color:#6F6BFF; font-weight: bold;" onclick="apptEditModal(<?php echo $apptID; ?>)">Edit</button>
|
|
</div>
|
|
<div class="grid grid-cols-3">
|
|
<p><?php echo $appt['comment']; ?></p>
|
|
<div class="flex flex-col" style="border-left: 3px solid #7875F4;">
|
|
<p style="font-weight: bold; padding-left: 6px;"><?php echo $apptDate[0]; ?></p>
|
|
<p style="padding-left: 6px;"><?php echo $apptDate[1]; ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="appt-edit-modal<?php echo $apptID; ?>" class="add-appt-edit-modal">
|
|
<div class="p-4">
|
|
<p onclick="apptEditModal(<?php echo $apptID; ?>)" style="font-size: 16px; color: #464E5F; border: 2px solid #464E5F; border-radius: 50%; float: right; padding: 2px 6px 2px 6px; cursor: pointer;">✘</p>
|
|
</div>
|
|
<form method="post" enctype="multipart/form-data" class="p-6 space-y-4">
|
|
<div class="flex flex-col">
|
|
<label for="appt_date">Appointment Date</label>
|
|
<input type="datetime-local" name="appt_date" id="appt_date" value="<?php echo $appt['appt_date'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<input type="hidden" name="appointment_id" id="appointment_id" value="<?php echo $appt['id']; ?>">
|
|
<div class="flex flex-col">
|
|
<label for="appt-comment">Description (if needed)</label>
|
|
<input type="text" name="comment" id="appt-comment" value="<?php echo $appt['comment'] ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<input class="rounded-xl focus:outline-none" type="submit" value="Update" name="appt_comment_update" id="appt_comment_update" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; padding: 8px 20px 8px 20px; cursor: pointer;" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="flex flex-col mt-3 bg-[#F6F6F6] rounded-xl">
|
|
<div class="flex flex-row place-content-between p-3" style="border-bottom: 2px solid #7E8299; border-style: dashed;">
|
|
<div class="flex flex-col">
|
|
<p style="font-size: 20px; font-weight: bold;">Communication:</p>
|
|
<p><?php echo $saved_message; ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="" style="max-height: 265px; overflow-y: auto;">
|
|
<?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 communication WHERE leadid = :leadid ORDER BY time DESC");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->execute();
|
|
$appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
$appt_rowCount = count($appt_data);
|
|
|
|
foreach ($appt_data as $appt) {
|
|
// Assuming 'comment' and 'date' fields are in the appointments table
|
|
$apptDate = explode(' ', $appt['time']); // Split date and time
|
|
if (is_numeric($appt['templateid'])) {
|
|
$templateNameForPrint = 'Email Template ID ' . $appt['templateid'];
|
|
} else {
|
|
$templateNameForPrint = $appt['templateid'];
|
|
}
|
|
?>
|
|
<div class="flex flex-col px-6" style="border-bottom: 2px solid #D9D9D9;">
|
|
<div class="flex flex-row place-content-between align-items-center">
|
|
<p style="font-size: 15px; font-weight: bold;"><?php echo $templateNameForPrint; ?></p>
|
|
</div>
|
|
<div class="grid grid-cols-2">
|
|
<p class="text-[#7E8299] "><?php echo $appt['method']; ?> Send by <?php echo $appt['username']; ?></p>
|
|
<div class="flex flex-col" style="border-left: 3px solid #7875F4;">
|
|
<p style="font-weight: bold; padding-left: 6px;"><?php echo $apptDate[0]; ?></p>
|
|
<p style="padding-left: 6px;"><?php echo $apptDate[1]; ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<!-- This IS Right Side DIV -->
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
|
|
?>
|
|
<div id="appt-modal" class="add-appt-modal">
|
|
<p onclick="apptModal();" style="font-size: 16px; color: #464E5F; border: 2px solid #464E5F; border-radius: 50%; float: right; padding: 2px 6px 2px 6px; cursor: pointer;">✘</p>
|
|
<form method="post" enctype="multipart/form-data" class="p-6 space-y-4">
|
|
<div class="flex flex-col">
|
|
<label for="appt_date">Appointment Date</label>
|
|
<input type="datetime-local" name="appt_date" id="appt_date" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<label for="appt-comment">Description (if needed)</label>
|
|
<input type="text" name="comment" id="appt-comment" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<input class="rounded-xl focus:outline-none" type="submit" value="Add" name="appt_comment" id="appt_comment" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; padding: 8px 20px 8px 20px; cursor: pointer;" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<p><?php if(isset($sendSuccessMessage)){echo $sendSuccessMessage;} ?></p>
|
|
<script>
|
|
function changeBvValue(){
|
|
let verticalsDropDown = document.getElementById('businessVerticals');
|
|
let bvValue = verticalsDropDown.value;
|
|
|
|
let atheneumWhatsAppData = [
|
|
{templateName : "AG_Welcome",templateID : "boost_conversion_gn",verticals : "atheneum"},
|
|
{templateName : "AG_introduction", templateID : "boost_conversion", verticals : "atheneum"},
|
|
{templateName : "AG_DNP", templateID : "may_offer_tb", verticals : "atheneum"}
|
|
];
|
|
|
|
let teenybeansWhatsAppData = [
|
|
{templateName : "Introduction_TEENY Beans",templateID : "boost_conversion_gn",verticals : "teenybeans"},
|
|
{templateName : "TB_DNP", templateID : "boost_conversion", verticals : "teenybeans"},
|
|
{templateName : "TB_UNO", templateID : "may_offer_tb", verticals : "teenybeans"}
|
|
];
|
|
let buzzappWhatsAppData = [
|
|
{templateName : "crm_buzzapp_Introduction",templateID : "boost_conversion_gn",verticals : "buzzapp"},
|
|
{templateName : "Buzzapp_crm_followup", templateID : "boost_conversion", verticals : "buzzapp"}
|
|
];
|
|
let iimttWhatsAppData = [
|
|
{templateName : "IIMTT_B2B Introduction New",templateID : "boost_conversion_gn",verticals : "iimtt"},
|
|
{templateName : "IIMTT_B2B_Followup", templateID : "boost_conversion", verticals : "iimtt"},
|
|
{templateName : "IIMTT_B2C Introduction New", templateID : "boost_conversion", verticals : "iimtt"},
|
|
{templateName : "IIMTT_B2C Followup", templateID : "boost_conversion", verticals : "iimtt"}
|
|
];
|
|
let bipWhatsAppData = [
|
|
{templateName : "crm_bip__introduction",templateID : "boost_conversion_gn",verticals : "bip"},
|
|
{templateName : "crm_bip_school visit invitation", templateID : "boost_conversion", verticals : "bip"}
|
|
];
|
|
|
|
let atheneumData = [
|
|
{templateName: "Welcome mail", templateID: "33", verticals: "atheneum"},
|
|
{templateName: "Introduction mail", templateID: "5", verticals: "atheneum"},
|
|
{templateName: "DNP", templateID: "21", verticals: "atheneum"},
|
|
{templateName: "MTT", templateID: "16", verticals: "atheneum"},
|
|
{templateName: "SEN", templateID: "22", verticals: "atheneum"},
|
|
{templateName: "PPTTC", templateID: "20", verticals: "atheneum"},
|
|
{templateName: "NTT", templateID: "19", verticals: "atheneum"},
|
|
{templateName: "CDA", templateID: "24", verticals: "atheneum"},
|
|
{templateName: "TEFL", templateID: "26", verticals: "atheneum"},
|
|
{templateName: "TESOL LEVEL 7", templateID: "25", verticals: "atheneum"},
|
|
{templateName: "TESOL", templateID: "30", verticals: "atheneum"},
|
|
{templateName: "ECCE", templateID: "27", verticals: "atheneum"},
|
|
{templateName: "Education administration & management", templateID: "30", verticals: "atheneum"},
|
|
{templateName: "10% OFF", templateID: "34", verticals: "atheneum"},
|
|
{templateName: "15% OFF", templateID: "36", verticals: "atheneum"}
|
|
];
|
|
let teenybeansData = [
|
|
{templateName: "UNO", templateID: "19", verticals: "teenybeans"},
|
|
{templateName: "PRIMERO", templateID: "17", verticals: "teenybeans"},
|
|
{templateName: "ILC", templateID: "27", verticals: "teenybeans"},
|
|
{templateName: "Complete Package", templateID: "28", verticals: "teenybeans"},
|
|
{templateName: "Bespoke- Marketing solution", templateID: "32", verticals: "teenybeans"},
|
|
{templateName: "Bespoke- Design solution", templateID: "31", verticals: "teenybeans"},
|
|
{templateName: "Bespoke- Academic solution", templateID: "30", verticals: "teenybeans"}
|
|
];
|
|
let iimttData = [
|
|
{templateName: "B2B- Introduction", templateID: "25", verticals: "iimtt"},
|
|
{templateName: "B2B- Followup", templateID: "18", verticals: "iimtt"},
|
|
{templateName: "B2C- Introduction", templateID: "22", verticals: "iimtt"},
|
|
{templateName: "B2C-Followup", templateID: "23", verticals: "iimtt"},
|
|
];
|
|
let bipData = [
|
|
{templateName: "Introduction", templateID: "24", verticals: "bip"},
|
|
{templateName: "School visit invitation", templateID: "26", verticals: "bip"}
|
|
];
|
|
let buzzappData = [
|
|
{templateName: "Introduction", templateID: "20", verticals: "buzzapp"},
|
|
{templateName: "Follow up", templateID: "29", verticals: "buzzapp"}
|
|
];
|
|
|
|
let templateWhatsappList = document.getElementById('templateWhatsappList');
|
|
templateWhatsappList.innerHTML = ''; // Clear the previous list items
|
|
|
|
let templateList = document.getElementById('templateList');
|
|
templateList.innerHTML = ''; // Clear the previous list items
|
|
|
|
let selectedData;
|
|
let whatsAppSelectdeData;
|
|
if (bvValue === 'atheneum') {
|
|
selectedData = atheneumData;
|
|
whatsAppSelectdeData = atheneumWhatsAppData;
|
|
} else if (bvValue === 'teenybeans') {
|
|
selectedData = teenybeansData;
|
|
whatsAppSelectdeData = teenybeansWhatsAppData;
|
|
} else if(bvValue === 'iimtt') {
|
|
selectedData = iimttData;
|
|
whatsAppSelectdeData = iimttWhatsAppData;
|
|
} else if(bvValue === 'buzzapp') {
|
|
selectedData = buzzappData;
|
|
whatsAppSelectdeData = buzzappWhatsAppData;
|
|
} else if(bvValue === 'bip') {
|
|
selectedData = bipData;
|
|
whatsAppSelectdeData = bipWhatsAppData;
|
|
} else {
|
|
selectedData = []; // No data for other selections, you can add more datasets as needed
|
|
whatsAppSelectdeData = []; // No data for other selections, you can add more datasets as needed
|
|
}
|
|
|
|
selectedData.forEach(data => {
|
|
const anchorLink = document.createElement('a');
|
|
anchorLink.text = data.templateName;
|
|
anchorLink.href = `?id=<?php echo $getLeadID ?>&send-email-id=${data.templateID}`;
|
|
templateList.appendChild(anchorLink);
|
|
});
|
|
whatsAppSelectdeData.forEach(data => {
|
|
const anchorLink = document.createElement('a');
|
|
anchorLink.text = data.templateName;
|
|
anchorLink.href = `?id=<?php echo $getLeadID ?>&send-whatsapp-id=${data.templateID}`;
|
|
templateWhatsappList.appendChild(anchorLink);
|
|
});
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const copyButtons = document.querySelectorAll('.copy-btn');
|
|
|
|
copyButtons.forEach(button => {
|
|
button.addEventListener('click', event => {
|
|
event.preventDefault();
|
|
const inputId = button.getAttribute('data-input-id');
|
|
const inputElement = document.getElementById(inputId);
|
|
if (inputElement && inputElement.value) {
|
|
if (navigator.clipboard) {
|
|
navigator.clipboard.writeText(inputElement.value)
|
|
.then(() => {
|
|
button.classList.add('copied');
|
|
setTimeout(() => {
|
|
button.classList.remove('copied');
|
|
inputElement.blur(); // Remove focus from input element
|
|
}, 1000);
|
|
})
|
|
.catch(err => {
|
|
console.error('Unable to copy using clipboard API:', err);
|
|
});
|
|
} else {
|
|
// Fallback method for older browsers
|
|
inputElement.select();
|
|
inputElement.setSelectionRange(0, inputElement.value.length); // For mobile devices
|
|
try {
|
|
document.execCommand('copy');
|
|
button.classList.add('copied');
|
|
setTimeout(() => {
|
|
button.classList.remove('copied');
|
|
inputElement.blur(); // Remove focus from input element
|
|
}, 1000);
|
|
} catch (err) {
|
|
console.error('Fallback: Unable to copy', err);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
// 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 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);
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
// function senWhatsapp() {
|
|
// fetch('https://api.interakt.ai/v1/public/message/', {
|
|
// method: 'POST',
|
|
// headers: {
|
|
// 'Content-Type': 'application/json',
|
|
// 'Authorization': 'Basic {{OTgyajd4bHFUSXItSW9PN1BTdzhOenNDaS0ya0NQeXByRE0tMnRyQ3FrUTo=}}'
|
|
// },
|
|
// body: JSON.stringify({
|
|
// "countryCode": "+91",
|
|
// "phoneNumber": "8343820536",
|
|
// "callbackData": "some text here",
|
|
// "type": "Template",
|
|
// "template": {
|
|
// "name": "boost_conversion",
|
|
// "languageCode": "en",
|
|
// "headerValues": [
|
|
// "header_variable_value"
|
|
// ],
|
|
// "bodyValues": [
|
|
// "body_variable_value_1"
|
|
// ]
|
|
// }
|
|
// })
|
|
// })
|
|
// .then(response => response.json())
|
|
// .then(data => {
|
|
// console.log('Success:', data);
|
|
// })
|
|
// .catch((error) => {
|
|
// console.error('Error:', error);
|
|
// });
|
|
// }
|
|
|
|
// fetchCountries();
|
|
let nameID = document.getElementById('name');
|
|
let addressID = document.getElementById('address');
|
|
let countryID = document.getElementById('country');
|
|
let stateID = document.getElementById('state');
|
|
let cityID = document.getElementById('city');
|
|
let phoneID = document.getElementById('phone');
|
|
let emailID = document.getElementById('email');
|
|
let professionID = document.getElementById('profession');
|
|
let statusID = document.getElementById('status');
|
|
let coupon_codeID = document.getElementById('coupon_code');
|
|
let dateID = document.getElementById('date');
|
|
// document.getElementById('editButton').addEventListener('click', function() {
|
|
// fetchCountries();
|
|
// nameID.disabled = false;
|
|
// addressID.disabled = false;
|
|
// countryID.disabled = false;
|
|
// stateID.disabled = false;
|
|
// cityID.disabled = false;
|
|
// phoneID.disabled = false;
|
|
// emailID.disabled = false;
|
|
// professionID.disabled = false;
|
|
// statusID.disabled = false;
|
|
// coupon_codeID.disabled = false;
|
|
// dateID.disabled = false;
|
|
// });
|
|
|
|
const toggleButton = document.getElementById('toggleButton');
|
|
const content = document.getElementById('content');
|
|
|
|
toggleButton.addEventListener('click', function() {
|
|
if (content.style.display === 'none') {
|
|
content.style.display = 'block';
|
|
toggleButton.textContent = 'Cancel';
|
|
} else {
|
|
content.style.display = 'none';
|
|
toggleButton.textContent = 'Add Comment';
|
|
}
|
|
});
|
|
function apptModal(){
|
|
let apptForm = document.getElementById('appt-modal');
|
|
if(apptForm.style.display === 'block'){
|
|
apptForm.style.display = 'none'
|
|
}else{
|
|
apptForm.style.display = 'block'
|
|
}
|
|
}
|
|
function apptEditModal(id){
|
|
let apptEditForm = document.getElementById('appt-edit-modal' + id);
|
|
if(apptEditForm.style.display === 'block'){
|
|
apptEditForm.style.display = 'none'
|
|
}else{
|
|
apptEditForm.style.display = 'block'
|
|
}
|
|
}
|
|
document.addEventListener('keydown', function(event){
|
|
if(event.keyCode === 27){
|
|
var apptModal = document.getElementById('appt-modal');
|
|
if(apptModal.style.display === 'block'){
|
|
apptModal.style.display = 'none';
|
|
};
|
|
var apptEditModal = document.getElementById('appt-edit-modal<?php echo $apptID; ?>');
|
|
if(apptEditModal.style.display === 'block'){
|
|
apptEditModal.style.display = 'none';
|
|
}
|
|
}
|
|
})
|
|
document.addEventListener('keydown', function(event) {
|
|
if (event.key === 'Escape') {
|
|
let editModals = document.querySelectorAll('.add-appt-edit-modal');
|
|
editModals.forEach(function(modal) {
|
|
modal.style.display = 'none';
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
<style>
|
|
#name::selection {
|
|
background-color: transparent;
|
|
}
|
|
#name:focus, #email:focus, #phone:focus {
|
|
/* outline: none; */
|
|
}
|
|
.flex-container-x2y {
|
|
display: flex;
|
|
}
|
|
|
|
@media only screen and (max-width: 600px) {
|
|
.flex-container-x2y {
|
|
flex-direction: column;
|
|
}
|
|
}
|
|
|
|
@media only screen and (min-width: 601px) {
|
|
.flex-container-x2y {
|
|
flex-direction: row;
|
|
}
|
|
}
|
|
.add-appt-modal, .add-appt-edit-modal{
|
|
background-color: #F8F8F8;
|
|
display: none;
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
width: 100%;
|
|
max-width: 600px;
|
|
box-shadow: 0px 0px 20px 0px #443780;
|
|
border-radius: 10px;
|
|
}
|
|
.copied {
|
|
background: linear-gradient(180deg, #E4C1F9 0%, rgba(129, 126, 242, 0.91) 100%);
|
|
border-radius: 5px;
|
|
color: #fff;
|
|
}
|
|
.responsive-flex {
|
|
display: flex;
|
|
flex-direction: row; /* Default value for screens wider than 1150px */
|
|
}
|
|
|
|
/* Media query for screens narrower than 1150px */
|
|
@media (max-width: 1150px) {
|
|
.responsive-flex {
|
|
flex-direction: column;
|
|
}
|
|
.div-custom-margin{
|
|
margin-top: 1rem;
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
.xzmdropdown-wrapper {
|
|
position: relative;
|
|
display: inline-block;
|
|
font-size: 15px;
|
|
|
|
}
|
|
.xzmdropdown-content {
|
|
display: none;
|
|
position: absolute;
|
|
background-color: #EAEAEA;
|
|
min-width: 120px;
|
|
width: 260px;
|
|
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
|
|
z-index: 1;
|
|
border: 1px solid #939393;
|
|
border-radius: 5px;
|
|
}
|
|
|
|
.xzmdropdown-content a, input[type='submit'] {
|
|
color: black;
|
|
padding: 8px 8px;
|
|
text-decoration: none;
|
|
display: block;
|
|
}
|
|
|
|
.xzmdropdown-content a:hover, input[type='submit']:hover {
|
|
background-color: #B2B0FF;
|
|
}
|
|
|
|
.xzmdropdown-wrapper:hover .xzmdropdown-content {
|
|
display: block;
|
|
}
|
|
|
|
.xzmdropdown-item {
|
|
position: relative;
|
|
}
|
|
|
|
.xzmdropdown-submenu {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 100%;
|
|
display: none;
|
|
background-color: #EAEAEA;
|
|
margin-top: 65px;
|
|
min-width: 120px;
|
|
width: 150px;
|
|
border: 1px solid #939393;
|
|
border-radius: 5px;
|
|
}
|
|
|
|
.xzmdropdown-submenu:hover {
|
|
display: block;
|
|
}
|
|
|
|
.bespoke-trigger:hover + .xzmdropdown-submenu {
|
|
display: block;
|
|
}
|
|
|
|
.xzmdropdown-submenu a {
|
|
padding: 8px 8px;
|
|
display: block;
|
|
}
|
|
|
|
.xzmdropdown-submenu a:hover {
|
|
background-color: #c0c0c0;
|
|
}
|
|
</style>
|