199 lines
10 KiB
PHP
199 lines
10 KiB
PHP
<?php
|
||
|
||
/**
|
||
* Provide a admin area view for the plugin
|
||
*
|
||
* This file is used to markup the admin-facing aspects of the plugin.
|
||
*
|
||
* @link http://secureprivacy.ai/
|
||
* @since 1.0.0
|
||
*
|
||
* @package Secureprivacy
|
||
* @subpackage Secureprivacy/admin/partials
|
||
*/
|
||
?>
|
||
|
||
<div class="wrap _s" id="page_settings_page" style="display:none;">
|
||
<div class="col-sm-9">
|
||
<div class="sp-tabs-bar">
|
||
<a href="<?php echo admin_url('admin.php?page=dashboard'); ?>" class="customisation"> Dashboard </a>
|
||
<a href="<?php echo admin_url('admin.php?page=settings'); ?>" class="customisation"> Settings </a>
|
||
<a href="<?php echo admin_url('admin.php?page=banners'); ?>" class="customisation"> Banners </a>
|
||
<a href="<?php echo admin_url('admin.php?page=priorConsent'); ?>" class="customisation"> Prior consent </a>
|
||
<!-- <a href="<?php echo admin_url('admin.php?page=privacyPolicy'); ?>" class="customisation"> Privacy policy </a> -->
|
||
<a href="<?php echo admin_url('admin.php?page=consentTracking'); ?>" class="customisation active-c"> Consent tracking </a>
|
||
|
||
<span id="loading_span" style="display:none;margin-top:15px;margin-right:15px;" class="pull-right bs-label bg-blue">Loading...</span>
|
||
</div>
|
||
<div class="clearfix"></div>
|
||
<div style="border: solid 1px #dddddd;padding: 15px;background: #fff;">
|
||
<div class="alert alert-warning" style="display:none;overflow:hidden;margin-bottom:20px;" id="updrade_consent">
|
||
<span style="line-height:34px;">Upgrade to enable cookie consent logging and documentation. <button class="pull-right btn btn-warning">Upgrade</a></span>
|
||
</div>
|
||
|
||
|
||
<form action="javascript:void(0);" id="consent-tracking-form">
|
||
|
||
<h4 class="settings-header" style="margin-bottom:20px;">Consent tracking</h4>
|
||
<img class="img img-responsive" style="display:none;" id="updrade_consent_image" src="<?php echo plugin_dir_url( __FILE__ ) . '../images/home-bacground.jpg'; ?>">
|
||
|
||
<div class="btn-group pull-right" style="margin-bottom:10px;">
|
||
<button type="button" id="btn_prev" class="btn btn-success">Previous</button>
|
||
<button type="button" id="btn_next" class="btn btn-success">Next</button>
|
||
</div>
|
||
<div class="clearfix"> </div>
|
||
<div id="consent-tracking-table" style="overflow-y:auto;"> </div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<div class="col-sm-3 information">
|
||
<div class="content-box">
|
||
<h3 class="content-box-header" style="background: #dddddd;">
|
||
Information
|
||
</h3>
|
||
<div class="content-box-wrapper support-articles">
|
||
<h2> Support</h2>
|
||
<a href="https://secureprivacysupport.zendesk.com/" target="_blank" class="btn btn-info">Get support</a>
|
||
|
||
<hr/>
|
||
<h2> Support articles</h2>
|
||
<div>
|
||
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013138852-How-to-add-privacy-policy-text-on-WordPress"
|
||
target="_blank" class="">How to add privacy policy text on WordPress</a>
|
||
</div>
|
||
<div>
|
||
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013137132-How-to-add-privacy-button-on-Wordpress-menu"
|
||
target="_blank" class="">How to add privacy button on Wordpress menu</a>
|
||
</div>
|
||
<div>
|
||
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360012912712-What-is-prior-consent-and-how-to-implement-it-"
|
||
target="_blank" class="">What is ‘prior consent’ and how to implement it?</a>
|
||
</div>
|
||
<div>
|
||
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360013137552-How-to-add-Prior-Consent-with-Google-Tag-Manager-GTM-"
|
||
target="_blank" class="">How to add Prior Consent with Google Tag Manager (GTM)?</a>
|
||
</div>
|
||
<div>
|
||
<a href="https://secureprivacysupport.zendesk.com/hc/en-us/articles/360015115112-Developer-guide-for-JavaScript-methods"
|
||
target="_blank" class="">Developer guide for JavaScript methods</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<form id="saveValueForm" action="options.php" method="post">
|
||
<?php
|
||
settings_fields( $this->plugin_name );
|
||
do_settings_sections( $this->plugin_name );
|
||
?>
|
||
</form>
|
||
<script>
|
||
//case of a fresh install
|
||
if (document.getElementById('outdated_notice_adminId').value === '' && document.getElementById('outdated_notice_sessionId').value === '') {
|
||
window.location.href = '<?php echo admin_url('admin.php?page=welcome'); ?>';
|
||
} else if (document.getElementById('outdated_notice_sessionId').value === '') {
|
||
window.location.href = '<?php echo admin_url('admin.php?page=login'); ?>';
|
||
} else {
|
||
document.getElementById('page_settings_page').style.display ='block';
|
||
}
|
||
getSupportedFeatures(window.document.getElementById('outdated_notice_planName').value);
|
||
|
||
(function ($) {
|
||
'use strict';
|
||
var totalResultsCount, totalResultsCount, table, visitorChartData, currentPageNumber;
|
||
|
||
|
||
function getConsents(pageNumber) {
|
||
$('#loading_span').show();
|
||
currentPageNumber = pageNumber;
|
||
|
||
table = '';
|
||
$('#consent-tracking-table').html('Loading...');
|
||
$('#btn_prev').prop("disabled", true);
|
||
$('#btn_next').prop("disabled", true);
|
||
$.ajax({
|
||
url: window.sp_baseContext + '/api/consent/admin/?PageNumber=' + pageNumber + '&Domain=' + $('#outdated_notice_domainId').val() + '&ResultsPerPage=50&MaxResults=50&OrderBy=-ConsentDate',
|
||
type: "GET",
|
||
headers: {
|
||
"Authorization": window.getAuthToken()
|
||
},
|
||
contentType: 'application/json; charset=utf-8',
|
||
dataType: "json",
|
||
success: function (allConsents) {
|
||
$('#loading_span').hide();
|
||
visitorChartData = allConsents.PagedResults;
|
||
totalResultsCount = allConsents.TotalResultsCount;
|
||
totalResultsCount = Math.ceil(allConsents.TotalResultsCount / 50);
|
||
visitorChartData.forEach(element => {
|
||
if (element.FingerPrint.Browser) {
|
||
element.OperatingSystem = element.FingerPrint.Browser.substring(element.FingerPrint.Browser.indexOf('(') + 1, element.FingerPrint.Browser.indexOf(')'));
|
||
}
|
||
element.ConsentDate = element.ConsentDate.replace('/Date(', '').replace(')/', '');
|
||
table += '<tr class="odd" role="row"><td style="white-space: nowrap;">' + element.ComplianceType + '</td>';
|
||
table += '<td style="white-space: nowrap;">' + element.FingerPrint.IP + '</td>';
|
||
table += '<td style="white-space: nowrap;">' + element.ComplianceType + '</td>';
|
||
if (element.ConsentGiven) {
|
||
table += '<td style="white-space: nowrap;"><span class="bs-label label-success">Agreed</span></td>';
|
||
|
||
} else {
|
||
table += '<td style="white-space: nowrap;"><span class="bs-label label-danger">Declined</span></td>';
|
||
}
|
||
table += '<td style="white-space: nowrap;">' + element.ClientId + '</td>';
|
||
table += '<td style="white-space: nowrap;">' + element.OperatingSystem + '</td>';
|
||
table += '<td style="white-space: nowrap;"><span >' + element.FingerPrint.City + '</span></td>';
|
||
table += '<td style="white-space: nowrap;">' + element.FingerPrint.Country + '</td>';
|
||
table += '<td style="white-space: nowrap;"><span >' + element.FingerPrint.State + '</span></td></tr>';
|
||
});
|
||
if (table === '') {
|
||
table= '<tr><td colspan="2">No consent recorded</td></tr>';
|
||
}
|
||
$('#consent-tracking-table').html('<table class="table"><tr role="row"><th style="white-space: nowrap;">Consent</th><th style="white-space: nowrap;">IP address</th><th style="white-space: nowrap;">Consent date</th><th style="white-space: nowrap;">Status</th><th style="white-space: nowrap;">Device Id</th><th style="white-space: nowrap;">Operating system</th><th style="white-space: nowrap;">City</th><th style="white-space: nowrap;">Country</th><th style="white-space: nowrap;">State</th></tr> '+ table + '</table>');
|
||
console.log(currentPageNumber);
|
||
if (currentPageNumber === 1) {
|
||
$('#btn_prev').prop("disabled", true);
|
||
} else if (currentPageNumber > 1) {
|
||
$('#btn_prev').prop("disabled", false);
|
||
}
|
||
|
||
if (((currentPageNumber + 1 ) * 50) > totalResultsCount) {
|
||
$('#btn_next').prop("disabled", true);
|
||
} else {
|
||
$('#btn_next').prop("disabled", false);
|
||
}
|
||
},
|
||
error: function (e,x,v) {
|
||
if (e.status === 401) {
|
||
window.location.href = '<?php echo admin_url('admin.php?page=login'); ?>' + '&redirectTo=' + window.location.href + '&sessionExpired=true';
|
||
}
|
||
}
|
||
});
|
||
}
|
||
$("#updrade_consent button").on("click", function () {
|
||
window.sp_upgradePlan();
|
||
});
|
||
if (window.sp_supportedFeatures.consentdashboard === true) {
|
||
getConsents(1);
|
||
$("#updrade_consent").hide();
|
||
$("#updrade_consent_image").hide();
|
||
} else {
|
||
$('#consent-tracking-form :button').prop('disabled', true);
|
||
$('#consent-tracking-form .btn-group').hide();
|
||
|
||
$("#updrade_consent").show();
|
||
$("#updrade_consent_image").show();
|
||
}
|
||
|
||
$("#btn_prev").on("click", function () {
|
||
getConsents(currentPageNumber - 1);
|
||
});
|
||
$("#btn_next").on("click", function () {
|
||
getConsents(currentPageNumber + 1);
|
||
});
|
||
|
||
window.resetPlan(false);
|
||
})(jQuery);
|
||
</script>
|