171 lines
7.7 KiB
PHP
171 lines
7.7 KiB
PHP
<?php
|
|
require_once('/var/www/html/.hta_config/crm_config.php');
|
|
require_once('/var/www/html/.htac_header.php');
|
|
require_once('/var/www/html/.htac_nav.php');
|
|
// echo $_GET['id'];
|
|
// Below two fetch for edit data
|
|
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){ ?>
|
|
<div>
|
|
<p>ID:<?php echo $row['id']; ?></p>
|
|
<p>FormName:<?php echo $row['formname']; ?></p>
|
|
<p>Name:<?php echo $row['name']; ?></p>
|
|
<p>Email:<?php echo $row['email']; ?></p>
|
|
<p>Phone:<?php echo $row['phone']; ?></p>
|
|
<p>Subject:<?php echo $row['subject']; ?></p>
|
|
<p>Message:<?php echo $row['message']; ?></p>
|
|
<p>Details:<?php echo $row['details']; ?></p>
|
|
<p>Origin:<?php echo $row['origin']; ?></p>
|
|
<p>Time:<?php echo $row['time']; ?></p>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
|
|
if($_SERVER['REQUEST_METHOD']=="POST" && $_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 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(':id', $_GET['id']);
|
|
$stmt->execute();
|
|
|
|
echo "Record Updated successfully";
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
}
|
|
?>
|
|
<div style="max-width: 500px;">
|
|
<form method="post">
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for="name">Name:</label>
|
|
<input type="text" name="name" id="name" value="<?php echo $row['name']; ?>" />
|
|
</div>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for="email">E-mail:</label>
|
|
<input type="text" name="email" id="email" value="<?php echo $row['email']; ?>" />
|
|
</div>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for="phone">Phone:</label>
|
|
<input type="text" name="phone" id="phone" value="<?php echo $row['phone']; ?>" />
|
|
</div>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for="date">FOLLOW UPDATE:</label>
|
|
<input type="date" name="date" id="date" value="<?php echo $row['date']; ?>" />
|
|
</div>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for="phone">Lead Status:</label>
|
|
<select name="status" id="status" slec value="<?php echo $row['status']; ?>">
|
|
<option value=""></option>
|
|
<option value="new">New</option>
|
|
<option value="contacted">Contacted</option>
|
|
<option value="warm">Warm</option>
|
|
<option value="converted">Converted</option>
|
|
<option value="inactive">Inactive</option>
|
|
<option value="disqualified">Disqualified</option>
|
|
</select>
|
|
</div>
|
|
<?php
|
|
if($_SESSION['user_type'] == "admin"){?>
|
|
<div>
|
|
<label for="user">Attach this Lead to a user:</label><br>
|
|
<select name="user" id="user">
|
|
<option value="0">-Select-</option>
|
|
<?php
|
|
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 users");
|
|
$stmt->execute();
|
|
$users_lead = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
// var_dump($rows);
|
|
foreach($users_lead as $user_lead){ ?>
|
|
<option value="<?php echo $user_lead['email']; ?>"><?php echo $user_lead['email']; ?></option>
|
|
<?php
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
?>
|
|
</select>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<input type="submit" id="update_data" name="update_data" value="Update">
|
|
</div>
|
|
</form>
|
|
<?php
|
|
// This is for save comment
|
|
if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['save_comment'] && $_POST['comments'] ){
|
|
try {
|
|
$local_lang = 'en';
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->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();
|
|
}
|
|
};
|
|
|
|
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 comments WHERE leadid = :leadid ORDER BY created_at DESC");
|
|
$stmt->bindParam(':leadid', $_GET['id']);
|
|
$stmt->execute();
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
// var_dump($rows);
|
|
foreach($rows as $row){ ?>
|
|
<div>
|
|
<p><?php echo $row['comments']; ?></p>
|
|
<p><?php echo $row['user'].' '.date("Y-m-d", strtotime($row['created_at'])) ?></p>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
?>
|
|
|
|
<form method="post">
|
|
<div>
|
|
<label for="comments">Comment:</label><br>
|
|
<textarea name="comments" id="comments" cols="50" rows="10"></textarea>
|
|
</div>
|
|
<div>
|
|
<input type="submit" value="Save Comment" name="save_comment" id="save_comment" />
|
|
</div>
|
|
</form>
|
|
</div>
|