setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['new_lead']) && isset($_POST['name']) && isset($_POST['phone']) ) { $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $formname = 'crm-portal'; $note = $_POST['note']; $origin = $_POST['origin']; $gender = $_POST['gender']; $profession = $_POST['profession']; $country = $_POST['country']; $state = $_POST['state']; $city = $_POST['city']; $address = $_POST['address']; $status = 'New'; try { $stmt = $conn->prepare("INSERT INTO cleads (name, email, phone, formname, note, origin, status, gender, profession, country, state, city, address ) VALUES (:name, :email, :phone, :formname, :note, :origin, :status, :gender, :profession, :country, :state, :city, :address)"); $stmt->bindParam(':name', $name); $stmt->bindParam(':email', $email); $stmt->bindParam(':phone', $phone); $stmt->bindParam(':formname', $formname); $stmt->bindParam(':note', $note); $stmt->bindParam(':origin', $origin); $stmt->bindParam(':status', $status); $stmt->bindParam(':gender', $gender); $stmt->bindParam(':profession', $profession); $stmt->bindParam(':country', $country); $stmt->bindParam(':state', $state); $stmt->bindParam(':city', $city); $stmt->bindParam(':address', $address); $stmt->execute(); echo "Record added successfully"; } catch(PDOException $e) { echo "Error: " . $e->getMessage(); } } ?> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $delete_placeholders = rtrim(str_repeat('?,', count($selectedIds)), ','); $stmt = $conn->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

Choose Date for filter

  |  
Delete

'; } ?>
'; ?> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $searchTerm =isset($_GET['search']) ? $_GET['search'] : "%"; $businessVertical =isset($_GET['bv']) ? $_GET['bv'] : "%"; $start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '2014-05-05'; $end_date = isset($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d'); $start_time = microtime(true); $resultsPerPage = 100; $page =isset($_GET['page']) ? $_GET['page'] : 1; $offset = ($page - 1) * $resultsPerPage ; $accessArray = explode(",", $_SESSION['access']); $placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,? $placeholderString = implode(',', array_fill(0, count($accessArray), '?')); //first query to get the total number for pagination $sql = "SELECT COUNT(*) FROM cleads WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND verticals LIKE :businessVertical"; $stmt = $conn->prepare($sql); $stmt->bindValue(':searchTerm', "%$searchTerm%"); $stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->bindValue(':start_date', $start_date); $stmt->bindValue(':end_date', $end_date); $stmt->bindValue(':businessVertical', $businessVertical); $stmt->execute(); $totalRows = $stmt->fetchColumn(); // second & final query to get the page_view data $sql = "SELECT * FROM cleads WHERE name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm AND time BETWEEN :start_date AND :end_date AND verticals LIKE :businessVertical ORDER BY id DESC LIMIT :limit OFFSET :offset"; $stmt = $conn->prepare($sql); $stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed $stmt->bindValue(':limit', $resultsPerPage, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->bindValue(':start_date', $start_date); $stmt->bindValue(':end_date', $end_date); $stmt->bindValue(':businessVertical', $businessVertical); $stmt->execute(); $leads = $stmt->fetchAll(PDO::FETCH_ASSOC); $totalResults = count($leads); $totalPages = ceil($totalRows / $resultsPerPage); echo "

Total ".$totalRows." Rows Found

"; // Status Conditional Color foreach($leads as $lead){ $only_date =isset($lead['time']) ? substr($lead['time'], 0, 10): 'Not Available'; $lead_id = $lead['id']; if($lead['status'] == 'New'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';} elseif($lead['status'] == 'Contacted'){$conditional_background_color = 'background-color: #D4FFFF; border: 2px solid #2C9C9C; border-radius: 20px; text-align: center; color: #2C9C9C;';} elseif($lead['status'] == 'Disqualified'){$conditional_background_color = 'background-color: #CECECE; border: 2px solid #3F4254; border-radius: 20px; text-align: center; color: #3F4254;';} elseif($lead['status'] == 'Converted'){$conditional_background_color = 'background-color: #D4FDE7; border: 2px solid #40916C; border-radius: 20px; text-align: center; color: #40916C;';} elseif($lead['status'] == 'Warm'){$conditional_background_color = 'background-color: #FFD9D9; border: 2px solid #FB5555; border-radius: 20px; text-align: center; color: #FB5555;';} // if status = warm then select // if($row['status'] == 'Warm'){$conditional_status = '

'.$row['status'].'

';}elseif($row['status'] != 'Warm'){$conditional_status = $row['status'];} ?> Error: " . $e->getMessage() . "

"; } $end_time = microtime(true); // Calculate execution time $execution_time = ($end_time - $start_time); // Output execution time echo "Page executed in: " . $execution_time . " seconds"; ?>
Quick Action Name ID Status Update Form Name Date
"; // echo "

Pages:

-",$page,'-'; // for ($i = 1; $i <= $totalPages; $i++) { // echo "$i "; // } // echo ""; ?> '; ?>

Add Lead

Lead Information