c
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
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
|
||||
|
||||
@@ -49,6 +51,8 @@
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// var_dump($rows);
|
||||
foreach($rows as $row){
|
||||
$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) : '';
|
||||
@@ -115,71 +119,12 @@
|
||||
</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 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 class="xzmdropdown-content">
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="UNO">
|
||||
</form>
|
||||
<!-- <a href="#">UNO</a> -->
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="Primero">
|
||||
</form>
|
||||
|
||||
<!-- <a href="#">Primero</a> -->
|
||||
<div class="xzmdropdown-item">
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="ILC">
|
||||
</form>
|
||||
<!-- <a href="#">ILC</a> -->
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="Complete package">
|
||||
</form>
|
||||
<!-- <a href="#">Complete package</a> -->
|
||||
<a href="#" class="bespoke-trigger">Bespoke</a>
|
||||
<div class="xzmdropdown-submenu">
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="Academic">
|
||||
</form>
|
||||
<!-- <a href="#">Academic</a> -->
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="Buzzapp">
|
||||
</form>
|
||||
<!-- <a href="#">Buzzapp</a> -->
|
||||
<form method="post">
|
||||
<input type="hidden" name="leadid" value="<?php echo $_GET['id'] ?>" />
|
||||
<input type="hidden" name="useremail" value="<?php echo $_SESSION['email'] ?>" />
|
||||
<input type="hidden" name="templateid" value="" />
|
||||
<input type="submit" value="Design Solution">
|
||||
</form>
|
||||
<!-- <a href="#">Design Solution</a> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="templateWhatsappList" class="xzmdropdown-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -526,6 +471,48 @@
|
||||
} 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
|
||||
?>
|
||||
<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 $appt['templateid']; ?></p>
|
||||
</div>
|
||||
<div class="grid grid-cols-2">
|
||||
<p class="text-[#7E8299] ">Mail 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>
|
||||
@@ -556,11 +543,112 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
if(isset($_GET['send-whatsapp-id']) && $_GET['send-whatsapp-id']){
|
||||
$templateID = $_GET['send-whatsapp-id'];
|
||||
$usersNumberforSendMessagex = '917001601485';
|
||||
// echo $usersNameforSendMessage;
|
||||
// $usersNames = $usersNameforSendMessage;
|
||||
|
||||
$url = "https://api.interakt.ai/v1/public/message/";
|
||||
$apiKey = 'Basic {{OTgyajd4bHFUSXItSW9PN1BTdzhOenNDaS0ya0NQeXByRE0tMnRyQ3FrUTo=}}';
|
||||
$data = [
|
||||
"fullPhoneNumber" => $usersNumberforSendMessagex,
|
||||
"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);
|
||||
|
||||
// Check for errors
|
||||
if ($fp === FALSE) {
|
||||
echo 'Error occurred';
|
||||
} else {
|
||||
// Read the response
|
||||
$response = stream_get_contents($fp);
|
||||
|
||||
if ($response === FALSE) {
|
||||
echo 'Error reading response';
|
||||
} else {
|
||||
// Print the response
|
||||
if(isset($_GET['send-whatsapp-id'])){
|
||||
$templateName = $_GET['send-whatsapp-id'];
|
||||
} elseif(isset($_GET['send-email-id'])){
|
||||
$templateName = $_GET['send-email-id'];
|
||||
}
|
||||
try {
|
||||
$stmt = $conn->prepare("INSERT INTO communication (leadid, useremail, username, templateid) VALUES (:leadid, :useremail, :username, :templateid)");
|
||||
$stmt->bindParam(':leadid', $_GET['id']);
|
||||
$stmt->bindParam(':useremail', $_SESSION['email']);
|
||||
$stmt->bindParam(':username', $_SESSION['name']);
|
||||
$stmt->bindParam(':templateid', $templateName);
|
||||
$stmt->execute();
|
||||
echo "Message Sent successfully";
|
||||
} catch(PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
// echo '<script>window.location.href="/edit-lead/?id='.$_GET['id'].'"</script>';
|
||||
// echo $response;
|
||||
}
|
||||
// Close the file pointer
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<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"},
|
||||
@@ -602,30 +690,46 @@
|
||||
{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 = `?send-email-id=${data.templateID}`;
|
||||
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', () => {
|
||||
@@ -717,6 +821,41 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 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');
|
||||
|
||||
Reference in New Issue
Block a user