From 2ee61a386eadba11e215930e25234fa17066aefb Mon Sep 17 00:00:00 2001 From: Suvodip Date: Fri, 24 May 2024 13:31:52 +0530 Subject: [PATCH] c --- .hta_slug/edit-lead.php | 389 +++++++++++++++++++++++++++------------- 1 file changed, 264 insertions(+), 125 deletions(-) diff --git a/.hta_slug/edit-lead.php b/.hta_slug/edit-lead.php index 1dce1ad..acc6f9e 100644 --- a/.hta_slug/edit-lead.php +++ b/.hta_slug/edit-lead.php @@ -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 @@
-
-
+
  |  
-
-
- - - - -
- - -
- - - - -
- - -
-
- - - - -
- - -
- - - - -
- - Bespoke -
-
- - - - -
- -
- - - - -
- -
- - - - -
- -
-
-
+
@@ -529,6 +474,48 @@ ?> +
+
+
+

Communication:

+

+
+
+
+ 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 + ?> +
+
+

+
+
+

Mail Send by

+
+

+

+
+
+
+ Error: " . $e->getMessage() . "

"; + } + ?> +
+
@@ -556,78 +543,195 @@ + $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 ''; + // echo $response; + } + // Close the file pointer + fclose($fp); + } + } +?>