From 1ba7ea57eb9c693466d7c4510d3394e336460a73 Mon Sep 17 00:00:00 2001 From: Suvodip Date: Wed, 8 May 2024 22:07:11 +0530 Subject: [PATCH] c --- .hta_slug/edit-lead.php | 149 +++++++++++++++++++----------- .hta_slug/my-leads.php | 95 ++++++++++++++----- .hta_slug/notifications/_home.php | 43 +++++---- 3 files changed, 194 insertions(+), 93 deletions(-) diff --git a/.hta_slug/edit-lead.php b/.hta_slug/edit-lead.php index e33c227..454db12 100644 --- a/.hta_slug/edit-lead.php +++ b/.hta_slug/edit-lead.php @@ -51,7 +51,8 @@ foreach($rows as $row){ $nameParts = explode(" ", $row['name']); $firstInitial = substr($nameParts[0], 0, 1); - $lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1); + $lastInitial = substr($nameParts[1], 0, 1); + // $lastInitial = substr($nameParts[count($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;';} @@ -59,8 +60,8 @@ 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;';} ?> -
-
+
+
@@ -90,20 +91,42 @@

+
-
-

Country

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

@@ -168,6 +191,37 @@

Follow Update

+
+

Assign to

+ +
@@ -175,10 +229,10 @@
-
+
-

Comments:

+

Comments:

@@ -246,7 +300,6 @@ $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(); @@ -414,45 +467,38 @@ copyButtons.forEach(button => { const inputId = button.getAttribute('data-input-id'); const inputElement = document.getElementById(inputId); if (inputElement && inputElement.value) { - navigator.clipboard.writeText(inputElement.value) - .then(() => { - button.classList.add('copied'); - setTimeout(() => { - button.classList.remove('copied'); - }, 1000); - }) - .catch(err => { - console.error('Unable to copy:', err); - }); + navigator.clipboard.writeText(inputElement.value) + .then(() => { + button.classList.add('copied'); + setTimeout(() => { + button.classList.remove('copied'); + }, 1000); + }) + .catch(err => { + console.error('Unable to copy:', err); + }); } }); }); - // Function to fetch countries and populate the country dropdown - function fetchCountries() { - fetch('https://api.siliconpin.com/v3/list/country/') - .then(res => res.json()) - .then(data => { - const countryDropdown = document.getElementById('country'); - countryDropdown.innerHTML = ''; - data.forEach(country => { - const option = document.createElement('option'); - option.value = country.iso2; - option.text = country.name; - countryDropdown.appendChild(option); - }); - }); - } - function myCountry() { - let getCountryNameFrom = document.getElementById('country'); - let selectedOption = getCountryNameFrom.options[getCountryNameFrom.selectedIndex].text; - document.getElementById('getCountryName').value = selectedOption; - // console.log(selectedOption); - } + + // function fetchCountries() { + // fetch('https://api.siliconpin.com/v3/list/country/') + // .then(res => res.json()) + // .then(data => { + // const countryDropdown = document.getElementById('country'); + // countryDropdown.innerHTML = ''; + // data.forEach(country => { + // const option = document.createElement('option'); + // option.value = country.iso2; + // option.text = country.name; + // countryDropdown.appendChild(option); + // }); + // }); + // } function fetchStates() { - myCountry(); const selectedCountry = document.getElementById('country').value; fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${selectedCountry}`) .then(res => res.json()) @@ -467,15 +513,8 @@ copyButtons.forEach(button => { }); }); } - function myState() { - let getCountryNameFrom = document.getElementById('state'); - let selectedOption = getCountryNameFrom.options[getCountryNameFrom.selectedIndex].text; - document.getElementById('getStateName').value = selectedOption; - // console.log(selectedOption); - } function fetchCities() { - myState(); 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}`) @@ -491,7 +530,7 @@ copyButtons.forEach(button => { }); }); } - fetchCountries(); + // fetchCountries(); let nameID = document.getElementById('name'); let addressID = document.getElementById('address'); let countryID = document.getElementById('country'); diff --git a/.hta_slug/my-leads.php b/.hta_slug/my-leads.php index e71957e..168feb0 100644 --- a/.hta_slug/my-leads.php +++ b/.hta_slug/my-leads.php @@ -60,6 +60,7 @@ require_once('.hta_config/crm_config.php'); require_once('.htac_header.php'); require_once('.htac_nav.php'); + // deleteCofermation() $today_date = date("Y-m-d"); $next_day = date("Y-m-d", strtotime("+1 day")); $yesterday = date("Y-m-d", strtotime("-1 day")); @@ -111,6 +112,23 @@ echo "Error: " . $e->getMessage(); } } +?> +prepare("DELETE FROM cleads WHERE id IN ($delete_placeholders)"); + foreach($selectedIds as $key => $id) { + $stmt->bindValue($key + 1, $id, PDO::PARAM_INT); + } + $stmt->execute(); + } catch(PDOException $e) { + echo "Error: " . $e->getMessage(); + } + } + } ?>

Lead Management

@@ -150,6 +168,11 @@
+ Delete

'; + } + ?>
@@ -157,7 +180,18 @@ - + + + '; + ?> @@ -185,33 +219,37 @@ $placeholderString = implode(',', array_fill(0, count($accessArray), '?')); //first query to get the total number for pagination - $sql= "SELECT COUNT(*) FROM cleads WHERE state IN (".$_SESSION["states"].") AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date "; + $parts = explode(',', $_SESSION["states"]); + $quotedParts = array_map(function($item) { return "'" . $item . "'";}, $parts); + $newStr = implode(',', $quotedParts); + + $sql= "SELECT COUNT(*) FROM cleads WHERE state IN ($newStr) OR user LIKE :user AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date "; $stmt = $conn->prepare($sql); $stmt->bindValue(':businessVertical', $businessVertical); $stmt->bindValue(':searchTerm', "%".$searchTerm."%"); $stmt->bindValue(':start_date', $start_date); $stmt->bindValue(':end_date', $end_date); + $stmt->bindValue(':user', $_SESSION["email"]); $stmt->execute(); $totalRows = $stmt->fetchColumn(); // second & final query to get the page_view data - //SELECT * FROM cleads WHERE state IN ('HR', 'TR', 'MP', 'CT', 'LA', 'international'); - $sql = "SELECT * FROM cleads WHERE business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ORDER BY id DESC LIMIT :limit OFFSET :offset"; + + $sql = "SELECT * FROM cleads WHERE state IN ($newStr) OR user LIKE :user AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ORDER BY id DESC LIMIT :limit OFFSET :offset"; $stmt = $conn->prepare($sql); $stmt->bindValue(':businessVertical', $businessVertical, PDO::PARAM_STR ); $stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed $stmt->bindValue(':start_date', $start_date); $stmt->bindValue(':end_date', $end_date); + $stmt->bindValue(':user', $_SESSION["email"]); $stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $leads = $stmt->fetchAll(PDO::FETCH_ASSOC); $totalResults = count($leads); $totalPages = ceil($totalRows / $resultsPerPage); - if($resultsPerPage <= $totalRows) echo "

".$resultsPerPage." Out of ".$totalRows." Leads

"; else echo "

".$totalRows." Leads

"; - var_dump($_SESSION["states"]); // Status Conditional Color foreach($leads as $lead){ $only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available'; @@ -225,7 +263,6 @@ // if($row['status'] == 'Warm'){$conditional_status = '

'.$row['status'].'

';}elseif($row['status'] != 'Warm'){$conditional_status = $row['status'];} ?> -
BVQuick Action Name ID
@@ -278,7 +315,7 @@ $execution_time = ($end_time - $start_time); // Output execution time - // echo "Page executed in: " . $execution_time . " seconds"; + echo "Page executed in: " . $execution_time . " seconds"; ?>
@@ -289,20 +326,15 @@ $getParams = $_GET; unset($getParams['page']); $getParams['page'] = $page-1; $backPage= http_build_query($getParams); unset($getParams['page']); $getParams['page'] = $page+1; $nextkPage= http_build_query($getParams); -echo' -
- -
-'; + +// echo $totalPages; +echo'
+ + + +
'; ?> -
@@ -474,7 +506,17 @@ echo' } } }); - + function deleteCofermation(){ + let deleteButton = document.getElementById('delete-button'); + let leadID = document.getElementById('').value; //getting Err: here + if(leadID != null){ + if(deleteButton.style.display === 'flex'){ + deleteButton.style.display = 'none'; + }else{ + deleteButton.style.display = 'flex' + } + } + } \ No newline at end of file diff --git a/.hta_slug/notifications/_home.php b/.hta_slug/notifications/_home.php index 9925fb8..d733a40 100644 --- a/.hta_slug/notifications/_home.php +++ b/.hta_slug/notifications/_home.php @@ -28,20 +28,6 @@
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $stmt = $conn->prepare("UPDATE appointment SET view_status = 1 WHERE id = :status_id AND email = :email"); - $stmt->bindParam(':status_id', $_POST['status_id']); - $stmt->bindParam(':email', $_SESSION['email']); - $stmt->execute(); - $saved_message = "Appointment updated successfully"; - } 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); @@ -52,19 +38,26 @@ $stmt->execute(); $appt_data = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($appt_data as $appt){ + $leadID = json_decode($appt['leadid']); if($appt['view_status'] == 0){ $notification_bg = 'background: #F5F4FFE8;'; $notification_batch = '
'; + $clickButton = ''; }elseif($appt['view_status'] == 1){ $notification_bg = 'background: #fff;'; $notification_batch = '
'; + $clickButton = 'disabled'; } ?>
- @@ -77,5 +70,21 @@ echo "

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

"; }; + + if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['status_id']) && $_POST['status_id']){ + 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 view_status = 1 WHERE id = :status_id AND email = :email"); + $stmt->bindParam(':status_id', $_POST['status_id']); + $stmt->bindParam(':email', $_SESSION['email']); + $stmt->execute(); + // $saved_message = "Appointment upd ated successfully"; + echo ''; + } catch(PDOException $e) { + echo "Error: " . $e->getMessage(); + } + }; + ?>
\ No newline at end of file