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: #FFD9D9; border: 1px solid #FB5555; border-radius: 5px; color: #FB5555;';} elseif($row['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 1px solid #2C9C9C; border-radius: 5px; color: #2C9C9C;';} 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;';} ?>

Client ID

Quick Action

  |  

Form Name

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 '

Country

'; } } ?>

State

City

Address

Profession

Origin

Lead Status

'; $options = array("Proposal Sent", "Meeting Conducted", "Interested"); foreach ($options as $option) { $selected = ($option == $row['warm_status']) ? 'selected' : ''; echo ''; } echo ''; } ?>

Coupon Code

Time

Followup Date

Assign 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 ''; } 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 ''; } catch(PDOException $e) { echo "Error: " . $e->getMessage(); } // echo ''; // echo $response; } fclose($fp); } } ?>

Comments:

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(); } }; ?>
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); ?>


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

"; }; $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(); } }; ?>

Add Appointment

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'; } ?>

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

"; }; ?>

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 if (is_numeric($appt['templateid'])) { $templateNameForPrint = 'Email Template ID ' . $appt['templateid']; } else { $templateNameForPrint = $appt['templateid']; } ?>

Send by

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

"; } ?>
Error: " . $e->getMessage() . "

"; }; ?>