mirror of https://github.com/itflow-org/itflow
Operation Cleanup Round 1 - Remove Mailing list functionality, there are many projects that can handle this
This commit is contained in:
parent
55567df92e
commit
14953fe171
247
campaign.php
247
campaign.php
|
|
@ -1,247 +0,0 @@
|
|||
<?php include("inc_all.php");
|
||||
|
||||
if(isset($_GET['campaign_id'])){
|
||||
$campaign_id = intval($_GET['campaign_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$campaign_name = $row['campaign_name'];
|
||||
$campaign_subject = $row['campaign_subject'];
|
||||
$campaign_from_name = $row['campaign_from_name'];
|
||||
$campaign_from_email = $row['campaign_from_email'];
|
||||
$campaign_content = $row['campaign_content'];
|
||||
$campaign_status = $row['campaign_status'];
|
||||
$campaign_scheduled_at = $row['campaign_scheduled_at'];
|
||||
$campaign_created_at = $row['campaign_created_at'];
|
||||
|
||||
//Set Badge color based off of campaign status
|
||||
if($campaign_status == "Sent"){
|
||||
$campaign_badge_color = "success";
|
||||
}elseif($campaign_status == "Queued"){
|
||||
$campaign_badge_color = "info";
|
||||
}elseif($campaign_status == "Sending"){
|
||||
$campaign_badge_color = "primary";
|
||||
}else{
|
||||
$campaign_badge_color = "secondary";
|
||||
}
|
||||
|
||||
//Get Stat Counts
|
||||
//Subscribers
|
||||
$subscriber_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_campaign_id = $campaign_id"));
|
||||
//Sent
|
||||
$sent_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_sent_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
//Opem
|
||||
$open_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_opened_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
//Click
|
||||
$click_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_clicked_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
//Fail
|
||||
$fail_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_bounced_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
|
||||
?>
|
||||
|
||||
<ol class="breadcrumb elevation-2">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="campaigns.php">Campaigns</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active"><?php echo $campaign_name; ?></li>
|
||||
</ol>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="card card-body elevation-2">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<a class="text-secondary" href="#" data-toggle="modal" data-target="#campaignEditModal<?php echo $campaign_id; ?>"><i class="fa fa-fw fa-edit ml-2 float-right"></i></a>
|
||||
<a class="text-secondary" href="#" data-toggle="modal" data-target="#campaignCopyModal<?php echo $campaign_id; ?>"><i class="fa fa-fw fa-copy ml-2 float-right"></i></a>
|
||||
<a class="text-secondary" href="#" data-toggle="modal" data-target="#campaignTestModal<?php echo $campaign_id; ?>"><i class="fa fa-fw fa-wrench ml-2 float-right"></i></a>
|
||||
<h6 class="text-secondary">CAMPAIGN</h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5><?php echo $campaign_name; ?></h5>
|
||||
<div class="p-2 badge badge-pill badge-<?php echo $campaign_badge_color; ?>">
|
||||
<?php echo $campaign_status; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="card card-body elevation-2">
|
||||
<h6 class="text-secondary">DETAILS</h6>
|
||||
<div class="mb-1"><i class="fa fa-fw fa-bullhorn text-secondary mr-2"></i><strong><?php echo $campaign_subject; ?></strong></div>
|
||||
<div class="mb-1"><i class="fa fa-fw fa-user text-secondary mr-2"></i><strong><?php echo $campaign_from_name; ?></strong> (<?php echo $campaign_from_email; ?>)</div>
|
||||
<div class="mb-1"><i class="fa fa-fw fa-clock text-secondary mr-2"></i><strong><?php echo $campaign_created_at; ?></strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1">
|
||||
<div class="card card-body card-outline card-success text-center elevation-2">
|
||||
<h6 class="text-success">Sent</h6>
|
||||
<h3><?php echo "$sent_count/$subscriber_count"; ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1">
|
||||
<div class="card card-body card-outline card-secondary text-center elevation-2">
|
||||
<h6 class="text-secondary">Opened</h6>
|
||||
<h3><?php echo "$open_count/$subscriber_count"; ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1">
|
||||
<div class="card card-body card-outline card-info text-center elevation-2">
|
||||
<h6 class="text-info">Clicked</h6>
|
||||
<h3><?php echo "$click_count/$subscriber_count"; ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1">
|
||||
<div class="card card-body card-outline card-danger text-center elevation-2">
|
||||
<h6 class="text-danger">Failed</h6>
|
||||
<h3><?php echo "$fail_count/$subscriber_count"; ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
//Paging
|
||||
if(isset($_GET['p'])){
|
||||
$p = intval($_GET['p']);
|
||||
$record_from = (($p)-1)*$_SESSION['records_per_page'];
|
||||
$record_to = $_SESSION['records_per_page'];
|
||||
}else{
|
||||
$record_from = 0;
|
||||
$record_to = $_SESSION['records_per_page'];
|
||||
$p = 1;
|
||||
}
|
||||
|
||||
if(isset($_GET['q'])){
|
||||
$q = mysqli_real_escape_string($mysqli,$_GET['q']);
|
||||
}else{
|
||||
$q = "";
|
||||
}
|
||||
|
||||
if(!empty($_GET['sb'])){
|
||||
$sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
|
||||
}else{
|
||||
$sb = "message_id";
|
||||
}
|
||||
|
||||
if(isset($_GET['o'])){
|
||||
if($_GET['o'] == 'ASC'){
|
||||
$o = "ASC";
|
||||
$disp = "DESC";
|
||||
}else{
|
||||
$o = "DESC";
|
||||
$disp = "ASC";
|
||||
}
|
||||
}else{
|
||||
$o = "DESC";
|
||||
$disp = "ASC";
|
||||
}
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM campaign_messages
|
||||
LEFT JOIN contacts ON contact_id = message_contact_id
|
||||
LEFT JOIN clients ON primary_contact = contact_id
|
||||
WHERE (contact_name LIKE '%$q%' OR contact_email LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND message_campaign_id = $campaign_id
|
||||
AND campaign_messages.company_id = $session_company_id
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
||||
$total_found_rows = $num_rows[0];
|
||||
$total_pages = ceil($total_found_rows / 10);
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark elevation-3">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fa fa-fw fa-envelope"></i> Messages</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="mb-4" autocomplete="off">
|
||||
<input type="hidden" name="campaign_id" value="<?php echo $campaign_id; ?>">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search Messages">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_name&o=<?php echo $disp; ?>">Client Name</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=contact_name&o=<?php echo $disp; ?>">Contact Name</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=contact_email&o=<?php echo $disp; ?>">Email</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=message_sent_at&o=<?php echo $disp; ?>">Sent</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=message_opened_at&o=<?php echo $disp; ?>">Opened</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=message_ip&o=<?php echo $disp; ?>">IP</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$message_id = $row['message_id'];
|
||||
$message_ip = $row['message_ip'];
|
||||
$message_user_agent = $row['message_user_agent'];
|
||||
$message_sent_at = $row['message_sent_at'];
|
||||
$message_opened_at = $row['message_opened_at'];
|
||||
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$contact_id = $row['contact_id'];
|
||||
$contact_name = $row['contact_name'];
|
||||
$contact_email = $row['contact_email'];
|
||||
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $client_name; ?></td>
|
||||
<td><?php echo $contact_name; ?></td>
|
||||
<td><?php echo $contact_email; ?></td>
|
||||
<td><?php echo $message_sent_at; ?></td>
|
||||
<td><?php echo $message_opened_at; ?></td>
|
||||
<td><?php echo $message_ip; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php include("pagination.php"); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
//include("campaign_copy_modal.php"); --Doesnt Exist Yet
|
||||
include("campaign_edit_modal.php");
|
||||
include("campaign_test_modal.php");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
<div class="modal" id="campaignAddModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-envelope"></i> New Campaign</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<ul class="nav nav-pills nav-justified mb-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-campaign">Campaign</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-content">Content</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-recipients">Recipients</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<div class="tab-pane fade show active" id="pills-campaign">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Campaign Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-paper-plane"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Campaign Name" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Email Subject <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-smile-wink"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="subject" placeholder="Email Subject" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="from_name" placeholder="From Name" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Email <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="from_email" placeholder="From Email" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Schedule <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="scheduled_at" placeholder="Schedule Date and Time">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Set Status <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-smile-wink"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="status">
|
||||
<option>Draft</option>
|
||||
<option>Queued</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-content">
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control summernote" name="content"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-recipients">
|
||||
|
||||
<label>Select Tags <strong class="text-danger">*</strong></label>
|
||||
|
||||
<ul class="list-group mb-3">
|
||||
|
||||
<?php
|
||||
$sql_tags_select = mysqli_query($mysqli,"SELECT * FROM tags WHERE tag_type = 1 AND company_id = $session_company_id ORDER BY tag_name ASC");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_tags_select)){
|
||||
$tag_id_select = $row['tag_id'];
|
||||
$tag_name_select = $row['tag_name'];
|
||||
//Get Contact Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT(*) AS client_count FROM clients, client_tags
|
||||
WHERE clients.client_id = client_tags.client_id
|
||||
AND tag_id = $tag_id_select
|
||||
AND company_id = $session_company_id
|
||||
"));
|
||||
$client_count = $row['client_count'];
|
||||
|
||||
?>
|
||||
<li class="list-group-item">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="tags[]" value="<?php echo $tag_id_select; ?>">
|
||||
<label class="form-check-label ml-2"><?php echo $tag_name_select; ?> (<?php echo $client_count; ?> subscribers)</label>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_campaign" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
<div class="modal" id="campaignEditModal<?php echo $campaign_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-envelope"></i> <?php echo $campaign_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="campaign_id" value="<?php echo $campaign_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<ul class="nav nav-pills nav-justified mb-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-campaign<?php echo $campaign_id; ?>">Campaign</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-content<?php echo $campaign_id; ?>">Content</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-recipients<?php echo $campaign_id; ?>">Recipients</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<div class="tab-pane fade show active" id="pills-campaign<?php echo $campaign_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Campaign Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-paper-plane"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Campaign Name" value="<?php echo $campaign_name; ?>" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Email Subject <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-smile-wink"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="subject" placeholder="Email Subject" value="<?php echo $campaign_subject; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="from_name" placeholder="From Name" value="<?php echo $campaign_from_name; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Email <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="from_email" placeholder="From Email" value="<?php echo $campaign_from_email; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Schedule <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="scheduled_at" placeholder="Schedule Date and Time" value="<?php echo $campaign_scheduled_at; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Set Status <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-smile-wink"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="status">
|
||||
<option <?php if($campaign_status == 'Draft'){ echo "selected"; } ?>>Draft</option>
|
||||
<option <?php if($campaign_status == 'Queued'){ echo "selected"; } ?>>Queued</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-content<?php echo $campaign_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control summernote" name="content"><?php echo $campaign_content; ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-recipients<?php echo $campaign_id; ?>">
|
||||
|
||||
<label>Select Recipients <strong class="text-danger">*</strong></label>
|
||||
|
||||
<ul class="list-group mb-3">
|
||||
|
||||
<?php
|
||||
$sql_tags_select = mysqli_query($mysqli,"SELECT * FROM tags WHERE tag_type = 1 AND company_id = $session_company_id ORDER BY tag_name ASC");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_tags_select)){
|
||||
$tag_id_select = $row['tag_id'];
|
||||
$tag_name_select = $row['tag_name'];
|
||||
$tag_color_select = $row['tag_color'];
|
||||
$tag_icon_select = $row['tag_icon'];
|
||||
//Get Contact Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT(*) AS client_count FROM clients, client_tags
|
||||
WHERE clients.client_id = client_tags.client_id
|
||||
AND tag_id = $tag_id_select
|
||||
AND company_id = $session_company_id
|
||||
"));
|
||||
$client_count = $row['client_count'];
|
||||
|
||||
?>
|
||||
<li class="list-group-item">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="tags[]" value="<?php echo $tag_id_select; ?>">
|
||||
<label class="form-check-label ml-2 badge bg-<?php echo $tag_color_select; ?>"><?php echo "<i class='fa fw fa-$tag_icon_select'></i>"; ?> <?php echo $tag_name_select; ?></label><span class="right badge badge-light"><?php echo $client_count; ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_campaign" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<div class="modal" id="campaignTestModal<?php echo $campaign_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-envelope"></i> <?php echo $campaign_name; ?> - Send a test email</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="campaign_id" value="<?php echo $campaign_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name_to" placeholder="Name of the Person">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Email <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="email_to" placeholder="Send test email to" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="test_campaign" class="btn btn-primary">Send</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
include("config.php");
|
||||
include("functions.php");
|
||||
|
||||
// Create an image, 1x1 pixel in size
|
||||
$im = imagecreate(1,1);
|
||||
|
||||
// Set the background colour
|
||||
$white = imagecolorallocate($im,255,255,255);
|
||||
|
||||
// Allocate the background colour
|
||||
imagesetpixel($im,1,1,$white);
|
||||
|
||||
// Set the image type
|
||||
header("content-type:image/jpg");
|
||||
|
||||
// Create a JPEG file from the image
|
||||
imagejpeg($im);
|
||||
|
||||
// Free memory associated with the image
|
||||
imagedestroy($im);
|
||||
|
||||
if(isset($_GET['message_id'])){
|
||||
|
||||
$message_id = intval($_GET['message_id']);
|
||||
$message_hash = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['message_hash'])));
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_id = $message_id AND message_hash = '$message_hash'");
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
// Server variables
|
||||
$ip = trim(strip_tags(mysqli_real_escape_string($mysqli,get_ip())));
|
||||
mysqli_query($mysqli,"UPDATE campaign_messages SET message_ip = '$ip', message_opened_at = NOW() WHERE message_id = $message_id");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
230
campaigns.php
230
campaigns.php
|
|
@ -1,230 +0,0 @@
|
|||
<?php include("inc_all.php");
|
||||
|
||||
if(!empty($_GET['sb'])){
|
||||
$sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
|
||||
}else{
|
||||
$sb = "campaign_created_at";
|
||||
}
|
||||
|
||||
if(empty($_GET['canned_date'])){
|
||||
//Prevents lots of undefined variable errors.
|
||||
// $dtf and $dtt will be set by the below else to 0000-00-00 / 9999-00-00
|
||||
$_GET['canned_date'] = 'custom';
|
||||
}
|
||||
|
||||
//Date Filter
|
||||
if($_GET['canned_date'] == "custom" && !empty($_GET['dtf'])){
|
||||
$dtf = mysqli_real_escape_string($mysqli,$_GET['dtf']);
|
||||
$dtt = mysqli_real_escape_string($mysqli,$_GET['dtt']);
|
||||
}elseif($_GET['canned_date'] == "today"){
|
||||
$dtf = date('Y-m-d');
|
||||
$dtt = date('Y-m-d');
|
||||
}elseif($_GET['canned_date'] == "yesterday"){
|
||||
$dtf = date('Y-m-d',strtotime("yesterday"));
|
||||
$dtt = date('Y-m-d',strtotime("yesterday"));
|
||||
}elseif($_GET['canned_date'] == "thisweek"){
|
||||
$dtf = date('Y-m-d',strtotime("monday this week"));
|
||||
$dtt = date('Y-m-d');
|
||||
}elseif($_GET['canned_date'] == "lastweek"){
|
||||
$dtf = date('Y-m-d',strtotime("monday last week"));
|
||||
$dtt = date('Y-m-d',strtotime("sunday last week"));
|
||||
}elseif($_GET['canned_date'] == "thismonth"){
|
||||
$dtf = date('Y-m-01');
|
||||
$dtt = date('Y-m-d');
|
||||
}elseif($_GET['canned_date'] == "lastmonth"){
|
||||
$dtf = date('Y-m-d',strtotime("first day of last month"));
|
||||
$dtt = date('Y-m-d',strtotime("last day of last month"));
|
||||
}elseif($_GET['canned_date'] == "thisyear"){
|
||||
$dtf = date('Y-01-01');
|
||||
$dtt = date('Y-m-d');
|
||||
}elseif($_GET['canned_date'] == "lastyear"){
|
||||
$dtf = date('Y-m-d',strtotime("first day of january last year"));
|
||||
$dtt = date('Y-m-d',strtotime("last day of december last year"));
|
||||
}else{
|
||||
$dtf = "0000-00-00";
|
||||
$dtt = "9999-00-00";
|
||||
}
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM campaigns
|
||||
WHERE (campaign_name LIKE '%$q%' OR campaign_subject LIKE '%$q%' OR campaign_status LIKE '%$q%')
|
||||
AND DATE(campaign_created_at) BETWEEN '$dtf' AND '$dtt'
|
||||
AND company_id = $session_company_id
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
||||
$total_found_rows = $num_rows[0];
|
||||
$total_pages = ceil($total_found_rows / 10);
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark elevation-3">
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-envelope"></i> Mailing Campaigns</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#campaignAddModal"><i class="fas fa-fw fa-plus"></i> New Campaign</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form class="mb-4" autocomplete="off">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search Campaigns">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="float-right">
|
||||
<a href="#" class="btn btn-lg btn-default"><i class="fa fa-fw fa-pencil-ruler"></i> Draft</a>
|
||||
<a href="#" class="btn btn-lg btn-default"><i class="fa fa-fw fa-clock"></i> Queued</a>
|
||||
<a href="#" class="btn btn-lg btn-default"><i class="fa fa-fw fa-paper-plane"></i> Sent</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse mt-3 <?php if(!empty($_GET['dtf'])){ echo "show"; } ?>" id="advancedFilter">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Canned Date</label>
|
||||
<select class="form-control select2" name="canned_date">
|
||||
<option <?php if($_GET['canned_date'] == "custom"){ echo "selected"; } ?> value="custom">Custom</option>
|
||||
<option <?php if($_GET['canned_date'] == "today"){ echo "selected"; } ?> value="today">Today</option>
|
||||
<option <?php if($_GET['canned_date'] == "yesterday"){ echo "selected"; } ?> value="yesterday">Yesterday</option>
|
||||
<option <?php if($_GET['canned_date'] == "thisweek"){ echo "selected"; } ?> value="thisweek">This Week</option>
|
||||
<option <?php if($_GET['canned_date'] == "lastweek"){ echo "selected"; } ?> value="lastweek">Last Week</option>
|
||||
<option <?php if($_GET['canned_date'] == "thismonth"){ echo "selected"; } ?> value="thismonth">This Month</option>
|
||||
<option <?php if($_GET['canned_date'] == "lastmonth"){ echo "selected"; } ?> value="lastmonth">Last Month</option>
|
||||
<option <?php if($_GET['canned_date'] == "thisyear"){ echo "selected"; } ?> value="thisyear">This Year</option>
|
||||
<option <?php if($_GET['canned_date'] == "lastyear"){ echo "selected"; } ?> value="lastyear">Last Year</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Date From</label>
|
||||
<input type="date" class="form-control" name="dtf" value="<?php echo $dtf; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Date To</label>
|
||||
<input type="date" class="form-control" name="dtt" value="<?php echo $dtt; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=campaign_name&o=<?php echo $disp; ?>">Name</a></th>
|
||||
<th class="text-center">Subscribers</th>
|
||||
<th class="text-center">Sent</th>
|
||||
<th class="text-center">Opened</th>
|
||||
<th class="text-center">Clicked</th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=campaign_created_at&o=<?php echo $disp; ?>">Created</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=campaign_scheduled_at&o=<?php echo $disp; ?>">Scheduled</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=campaign_status&o=<?php echo $disp; ?>">Status</a></th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$campaign_id = $row['campaign_id'];
|
||||
$campaign_name = $row['campaign_name'];
|
||||
$campaign_subject = $row['campaign_subject'];
|
||||
$campaign_from_name = $row['campaign_from_name'];
|
||||
$campaign_from_email = $row['campaign_from_email'];
|
||||
$campaign_content = $row['campaign_content'];
|
||||
$campaign_status = $row['campaign_status'];
|
||||
$campaign_scheduled_at = $row['campaign_scheduled_at'];
|
||||
$campaign_created_at = $row['campaign_created_at'];
|
||||
|
||||
//Set Badge color based off of campaign status
|
||||
if($campaign_status == "Sent"){
|
||||
$campaign_badge_color = "success";
|
||||
}elseif($campaign_status == "Queued"){
|
||||
$campaign_badge_color = "info";
|
||||
}elseif($campaign_status == "Sending"){
|
||||
$campaign_badge_color = "primary";
|
||||
}else{
|
||||
$campaign_badge_color = "secondary";
|
||||
}
|
||||
|
||||
//Get Stat Counts
|
||||
//Subscribers
|
||||
$subscriber_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_campaign_id = $campaign_id"));
|
||||
//Sent
|
||||
$sent_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_sent_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
//Opem
|
||||
$open_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_opened_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
//Click
|
||||
$click_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_clicked_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
//Fail
|
||||
$fail_count = mysqli_num_rows(mysqli_query($mysqli,"SELECT message_id FROM campaign_messages WHERE message_bounced_at IS NOT NULL AND message_campaign_id = $campaign_id"));
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="campaign.php?campaign_id=<?php echo $campaign_id; ?>"><?php echo $campaign_name; ?></a></td>
|
||||
<td class="text-primary text-center"><?php echo $subscriber_count; ?></td>
|
||||
<td class="text-success text-center"><?php echo $sent_count; ?></td>
|
||||
<td class="text-secondary text-center"><?php echo $open_count; ?></td>
|
||||
<td class="text-info text-center"><?php echo $click_count; ?></td>
|
||||
<td><?php echo $campaign_created_at; ?></td>
|
||||
<td><?php echo $campaign_scheduled_at; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $campaign_badge_color; ?>">
|
||||
<?php echo $campaign_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#campaignTestModal<?php echo $campaign_id; ?>">Test</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php if($campaign_status == 'Draft' || $campaign_status == 'Queued'){ ?>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#campaignEditModal<?php echo $campaign_id; ?>">Edit</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item" href="post.php?copy_campaign=<?php echo $campaign_id; ?>">Copy</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="post.php?delete_campaign=<?php echo $campaign_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
//include("campaign_copy_modal.php"); --doesnt exist yet
|
||||
include("campaign_edit_modal.php");
|
||||
include("campaign_test_modal.php");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php include("pagination.php"); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("campaign_add_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
103
cron-mailer.php
103
cron-mailer.php
|
|
@ -1,103 +0,0 @@
|
|||
<?php include("config.php"); ?>
|
||||
<?php include("functions.php"); ?>
|
||||
<?php
|
||||
|
||||
require("plugins/PHPMailer/src/PHPMailer.php");
|
||||
require("plugins/PHPMailer/src/SMTP.php");
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
$sql_companies = mysqli_query($mysqli,"SELECT * FROM companies, settings WHERE companies.company_id = settings.company_id");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_companies)){
|
||||
$company_id = $row['company_id'];
|
||||
$company_name = $row['company_name'];
|
||||
$company_phone = formatPhoneNumber($row['company_phone']);
|
||||
$company_email = $row['company_email'];
|
||||
$company_website = $row['company_website'];
|
||||
$config_smtp_host = $row['config_smtp_host'];
|
||||
$config_smtp_username = $row['config_smtp_username'];
|
||||
$config_smtp_password = $row['config_smtp_password'];
|
||||
$config_smtp_port = $row['config_smtp_port'];
|
||||
$config_smtp_encryption = $row['config_smtp_encryption'];
|
||||
$config_base_url = $row['config_base_url'];
|
||||
|
||||
$sql_campaigns = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE company_id = $company_id AND campaign_status = 'Queued' AND campaign_scheduled_at < NOW()");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_campaigns)){
|
||||
$campaign_id = $row['campaign_id'];
|
||||
$campaign_id = $row['campaign_id'];
|
||||
$campaign_subject = $row['campaign_subject'];
|
||||
$campaign_from_name = $row['campaign_from_name'];
|
||||
$campaign_from_email = $row['campaign_from_email'];
|
||||
$campaign_content = $row['campaign_content'];
|
||||
$campaign_status = $row['campaign_status'];
|
||||
|
||||
mysqli_query($mysqli,"UPDATE campaigns SET campaign_status = 'Sending' WHERE campaign_id = $campaign_id");
|
||||
|
||||
$sql_messages = mysqli_query($mysqli,"SELECT * FROM campaign_messages
|
||||
LEFT JOIN contacts ON contact_id = message_contact_id
|
||||
LEFT JOIN clients ON primary_contact = contact_id
|
||||
WHERE message_sent_at IS NULL
|
||||
AND message_campaign_id = $campaign_id
|
||||
AND campaign_messages.company_id = $company_id
|
||||
");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_messages)){
|
||||
$message_id = $row['message_id'];
|
||||
$message_hash = $row['message_hash'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$contact_id = $row['contact_id'];
|
||||
$contact_name = $row['contact_name'];
|
||||
$contact_email = $row['contact_email'];
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try{
|
||||
|
||||
//Mail Server Settings
|
||||
|
||||
$mail->SMTPDebug = 2; // Enable verbose debug output
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $config_smtp_host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $config_smtp_username; // SMTP username
|
||||
$mail->Password = $config_smtp_password; // SMTP password
|
||||
$mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $config_smtp_port; // TCP port to connect to
|
||||
|
||||
//Recipients
|
||||
$mail->setFrom($campaign_from_email, $campaign_from_name);
|
||||
$mail->addAddress("$contact_email", "$contact_name"); // Add a recipient
|
||||
|
||||
// Content
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
|
||||
$mail->Subject = "$campaign_subject";
|
||||
$mail->Body = "Hello $contact_name,<br><br>$campaign_content
|
||||
<br><br>
|
||||
<img src='https://$config_base_url/campaign_track.php?message_id=$message_id&message_hash=$message_hash'>
|
||||
|
||||
<br><br><br>~<br>$company_name<br>$company_phone";
|
||||
|
||||
$mail->send();
|
||||
|
||||
mysqli_query($mysqli,"UPDATE campaign_messages SET message_sent_at = NOW() WHERE message_id = $message_id");
|
||||
|
||||
}catch (Exception $e) {
|
||||
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
mysqli_query($mysqli,"UPDATE campaign_messages SET message_bounced_at = NOW() WHERE message_id = $message_id");
|
||||
} //End Mail Try
|
||||
|
||||
}
|
||||
mysqli_query($mysqli,"UPDATE campaigns SET campaign_status = 'Sent' WHERE campaign_id = $campaign_id");
|
||||
}
|
||||
} //End Company Loop through
|
||||
|
||||
?>
|
||||
|
|
@ -289,14 +289,22 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){
|
|||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.5'");
|
||||
}
|
||||
|
||||
//if(CURRENT_DATABASE_VERSION == '0.1.5'){
|
||||
if(CURRENT_DATABASE_VERSION == '0.1.5'){
|
||||
// Insert queries here required to update to DB version 0.1.6
|
||||
// Remove Mailing List Tables
|
||||
mysqli_query($mysqli, "DROP TABLE campaigns");
|
||||
mysqli_query($mysqli, "DROP TABLE campaign_messages");
|
||||
|
||||
// Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.6'");
|
||||
//}
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.6'");
|
||||
}
|
||||
|
||||
// etc
|
||||
//if(CURRENT_DATABASE_VERSION == '0.1.6'){
|
||||
// Insert queries here required to update to DB version 0.1.7
|
||||
|
||||
// Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.7'");
|
||||
//}
|
||||
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
* It is used in conjunction with database_updates.php
|
||||
*/
|
||||
|
||||
DEFINE("LATEST_DATABASE_VERSION", "0.1.5");
|
||||
DEFINE("LATEST_DATABASE_VERSION", "0.1.6");
|
||||
58
db.sql
58
db.sql
|
|
@ -1,8 +1,8 @@
|
|||
-- MariaDB dump 10.19 Distrib 10.5.16-MariaDB, for debian-linux-gnu (x86_64)
|
||||
-- MariaDB dump 10.19 Distrib 10.5.17-MariaDB, for debian-linux-gnu (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: itflow_dev
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 10.5.16-MariaDB-1:10.5.16+maria~focal
|
||||
-- Server version 10.5.17-MariaDB-1:10.5.17+maria~ubu2004
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
|
|
@ -152,58 +152,6 @@ CREATE TABLE `calendars` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `campaign_messages`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `campaign_messages`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `campaign_messages` (
|
||||
`message_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`message_hash` varchar(250) NOT NULL,
|
||||
`message_ip` varchar(200) DEFAULT NULL,
|
||||
`message_referer` varchar(250) DEFAULT NULL,
|
||||
`message_user_agent` varchar(250) DEFAULT NULL,
|
||||
`message_queued_at` datetime DEFAULT NULL,
|
||||
`message_sent_at` datetime DEFAULT NULL,
|
||||
`message_delivered_at` datetime DEFAULT NULL,
|
||||
`message_bounced_at` datetime DEFAULT NULL,
|
||||
`message_opened_at` datetime DEFAULT NULL,
|
||||
`message_clicked_at` datetime DEFAULT NULL,
|
||||
`message_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`message_client_tag_id` int(11) NOT NULL,
|
||||
`message_contact_id` int(11) NOT NULL,
|
||||
`message_campaign_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`message_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `campaigns`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `campaigns`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `campaigns` (
|
||||
`campaign_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`campaign_name` varchar(255) NOT NULL,
|
||||
`campaign_subject` varchar(255) NOT NULL,
|
||||
`campaign_from_name` varchar(200) NOT NULL,
|
||||
`campaign_from_email` varchar(200) NOT NULL,
|
||||
`campaign_content` longtext NOT NULL,
|
||||
`campaign_status` varchar(20) NOT NULL,
|
||||
`campaign_scheduled_at` datetime DEFAULT NULL,
|
||||
`campaign_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`campaign_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
`campaign_archived_at` datetime DEFAULT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`campaign_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `categories`
|
||||
--
|
||||
|
|
@ -1546,4 +1494,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2022-05-25 15:44:58
|
||||
-- Dump completed on 2022-09-17 16:34:13
|
||||
|
|
|
|||
227
post.php
227
post.php
|
|
@ -699,8 +699,6 @@ if(isset($_GET['delete_company'])){
|
|||
mysqli_query($mysqli,"DELETE FROM assets WHERE company_id = $company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM calendars WHERE company_id = $company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM notifications WHERE company_id = $company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM campaigns WHERE company_id = $company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM campaign_messages WHERE company_id = $company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM categories WHERE company_id = $company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM certificates WHERE company_id = $company_id");
|
||||
|
||||
|
|
@ -1913,231 +1911,6 @@ if(isset($_GET['export_client_vendors_csv'])){
|
|||
exit;
|
||||
}
|
||||
|
||||
// Campaigns
|
||||
if(isset($_POST['add_campaign'])){
|
||||
|
||||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$subject = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject'])));
|
||||
$from_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['from_name'])));
|
||||
$from_email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['from_email'])));
|
||||
$content = trim(mysqli_real_escape_string($mysqli,$_POST['content']));
|
||||
$status = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['status'])));
|
||||
$scheduled_at = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scheduled_at'])));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO campaigns SET campaign_name = '$name', campaign_subject = '$subject', campaign_from_name = '$from_name', campaign_from_email = '$from_email', campaign_content = '$content', campaign_status = '$status', campaign_scheduled_at = '$scheduled_at', company_id = $session_company_id");
|
||||
|
||||
$campaign_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Create Recipient List based off tags selected
|
||||
if(isset($_POST['tags'])){
|
||||
foreach($_POST['tags'] as $tag){
|
||||
$tag = intval($tag);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients
|
||||
LEFT JOIN contacts ON contacts.contact_id = clients.primary_contact
|
||||
LEFT JOIN client_tags ON clients.client_id = client_tags.client_id
|
||||
WHERE client_tags.tag_id = $tag
|
||||
AND clients.company_id = $session_company_id
|
||||
");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$contact_id = $row['contact_id'];
|
||||
$contact_name = $row['contact_name'];
|
||||
$contact_email = $row['contact_email'];
|
||||
|
||||
//Check to see if the email has already been added if so don't add it
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT(message_id) AS count FROM campaign_messages WHERE message_contact_id = $contact_id AND message_campaign_id = $campaign_id"));
|
||||
$count = $row['count'];
|
||||
if($count == 0){
|
||||
//Generate Unique hash
|
||||
$message_hash = keygen();
|
||||
mysqli_query($mysqli,"INSERT INTO campaign_messages SET message_hash = '$message_hash', message_client_tag_id = $tag, message_contact_id = $contact_id, message_campaign_id = $campaign_id, company_id = $session_company_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Campaign', log_action = 'Create', log_description = '$session_name created mail campaign $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Campaign <strong>$name</strong> created";
|
||||
|
||||
//header("Location: campaign_details.php?campaign_id=$campaign_id");
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_campaign'])){
|
||||
|
||||
$campaign_id = intval($_POST['campaign_id']);
|
||||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$subject = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject'])));
|
||||
$from_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['from_name'])));
|
||||
$from_email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['from_email'])));
|
||||
$content = trim(mysqli_real_escape_string($mysqli,$_POST['content']));
|
||||
$status = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['status'])));
|
||||
$scheduled_at = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scheduled_at'])));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE campaigns SET campaign_name = '$name', campaign_subject = '$subject', campaign_from_name = '$from_name', campaign_from_email = '$from_email', campaign_content = '$content', campaign_status = '$status', campaign_scheduled_at = '$scheduled_at' WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
|
||||
//Create Recipient List based off tags selected
|
||||
if(isset($_POST['tags'])){
|
||||
foreach($_POST['tags'] as $tag){
|
||||
$tag = intval($tag);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients
|
||||
LEFT JOIN contacts ON contacts.contact_id = clients.primary_contact
|
||||
LEFT JOIN client_tags ON clients.client_id = client_tags.client_id
|
||||
WHERE client_tags.tag_id = $tag
|
||||
AND clients.company_id = $session_company_id
|
||||
");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$contact_id = $row['contact_id'];
|
||||
$contact_name = $row['contact_name'];
|
||||
$contact_email = $row['contact_email'];
|
||||
|
||||
//Check to see if the email has already been added if so don't add it
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT(message_id) AS count FROM campaign_messages WHERE message_contact_id = $contact_id AND message_campaign_id = $campaign_id"));
|
||||
$count = $row['count'];
|
||||
if($count == 0){
|
||||
//Generate Unique hash
|
||||
$message_hash = keygen();
|
||||
mysqli_query($mysqli,"INSERT INTO campaign_messages SET message_hash = '$message_hash', message_client_tag_id = $tag, message_contact_id = $contact_id, message_campaign_id = $campaign_id, company_id = $session_company_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Campaign', log_action = 'Modify', log_description = '$session_name modified mail campaign $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Campaign <strong>$name</strong> modified";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if(isset($_GET['copy_campaign'])){
|
||||
|
||||
$campaign_id = intval($_GET['copy_campaign']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$name = $row['campaign_name'];
|
||||
$subject = $row['campaign_subject'];
|
||||
$from_name = $row['campaign_from_name'];
|
||||
$from_email = $row['campaign_from_email'];
|
||||
$content = $row['campaign_content'];
|
||||
$status = $row['campaign_status'];
|
||||
$scheduled_at = $row['campaign_scheduled_at'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO campaigns SET campaign_name = '$name (COPY)', campaign_subject = '$subject', campaign_from_name = '$from_name', campaign_from_email = '$from_email', campaign_content = '$content', campaign_status = 'Draft', campaign_scheduled_at = '$scheduled_at', company_id = $session_company_id");
|
||||
|
||||
$new_campaign_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Campaign', log_action = 'Copy', log_description = '$session_name copied mail campaign $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Campaign <strong>$campaign_name</strong> copied";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if(isset($_GET['archive_campaign'])){
|
||||
$campaign_id = intval($_GET['archive_campaign']);
|
||||
|
||||
//Get Campaign Name
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$campaign_name = $row['campaign_name'];
|
||||
|
||||
mysqli_query($mysqli,"UPDATE campaigns SET campaign_archived_at = NOW() WHERE campaign_id = $campaign_id");
|
||||
|
||||
//logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Campaign', log_action = 'Archive', log_description = '$session_name archived mail campaign $campaign_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Campaign <strong>$campaign_name</strong> archived";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_campaign'])){
|
||||
$campaign_id = intval($_GET['delete_campaign']);
|
||||
|
||||
//Get Campaign Name
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$campaign_name = $row['campaign_name'];
|
||||
|
||||
//Delete Campaign
|
||||
mysqli_query($mysqli,"DELETE FROM campaigns WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
//Delete Messages Related to the Campaign
|
||||
mysqli_query($mysqli,"DELETE FROM campaign_messages WHERE message_campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
|
||||
//logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Campaign', log_action = 'Delete', log_description = '$session_name deleted mail campaign $campaign_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Campaign <strong>$campaign_name</strong> deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if(isset($_POST['test_campaign'])){
|
||||
$campaign_id = intval($_POST['campaign_id']);
|
||||
$name_to = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name_to'])));
|
||||
$email_to = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email_to'])));
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE campaign_id = $campaign_id AND company_id = $session_company_id");
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$campaign_name = $row['campaign_name'];
|
||||
$campaign_subject = $row['campaign_subject'];
|
||||
$campaign_from_name = $row['campaign_from_name'];
|
||||
$campaign_from_email = $row['campaign_from_email'];
|
||||
$campaign_content = $row['campaign_content'];
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
//Mail Server Settings
|
||||
|
||||
//$mail->SMTPDebug = 2; // Enable verbose debug output
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $config_smtp_host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $config_smtp_username; // SMTP username
|
||||
$mail->Password = $config_smtp_password; // SMTP password
|
||||
$mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $config_smtp_port; // TCP port to connect to
|
||||
|
||||
//Recipients
|
||||
$mail->setFrom("$campaign_from_email", "$campaign_from_name");
|
||||
$mail->addAddress("$email_to", "$name_to"); // Add a recipient
|
||||
|
||||
// Content
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
$mail->Subject = "[Test] $campaign_subject";
|
||||
$mail->Body = "Hi $name_to,<br><br>$campaign_content";
|
||||
|
||||
$mail->send();
|
||||
echo 'Message has been sent';
|
||||
|
||||
//logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Campaign', log_action = 'Test', log_description = 'Sent a test campaign named $campaign_name to $email_to', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Test email to <strong>$email_to</strong> for <strong>$campaign_name</strong> sent successfully";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
// Products
|
||||
if(isset($_POST['add_product'])){
|
||||
|
||||
|
|
|
|||
|
|
@ -96,13 +96,6 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="campaigns.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "campaigns.php" || basename($_SERVER["PHP_SELF"]) == "campaign.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-envelope"></i>
|
||||
<p>Campaigns</p>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if($session_user_role == 1 OR $session_user_role == 3 && $config_module_enable_accounting == 1){ ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue