485 lines
22 KiB
PHP
485 lines
22 KiB
PHP
|
|
<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date', 'VisualEffect', 'stAdminGenerator') ?>
|
|
|
|
<?php echo st_get_admin_head('appAdsTrackerPlugin', __('Raport kampanii')) ?>
|
|
|
|
<?php echo st_admin_get_viewport_force_width(); ?>
|
|
|
|
<?php st_view_slot_start('application-menu') ?>
|
|
<?php st_include_component('appAdsTrackerBackend', 'listMenu') ?>
|
|
<?php st_view_slot_end() ?>
|
|
|
|
<?php st_include_partial('stAdminGenerator/message'); ?>
|
|
|
|
<script type="text/javascript" src="/js/backend/chart.min.js"></script>
|
|
|
|
<style>
|
|
|
|
.list_filters select, .list_filters input {
|
|
vertical-align: middle;
|
|
}
|
|
|
|
#filters_from_date, #filters_to_date {
|
|
width: 100px;
|
|
}
|
|
|
|
#date-filters {
|
|
display: inline-block;
|
|
}
|
|
|
|
#date-filters li {
|
|
display: inline-block;
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
<div id="sf_admin_content">
|
|
|
|
<form id="filter-campaign" action="<?php echo url_for('appAdsTrackerBackend/adsTrackerCampaignStats') ?>" method="post" style="margin-bottom: 10px">
|
|
<div class="list_filters">
|
|
|
|
<?php
|
|
// echo "<pre>";
|
|
// print_r($filters);
|
|
// echo "</pre>";
|
|
?>
|
|
|
|
<ul class="header">
|
|
<li>
|
|
<label><?php echo __("Zakres") ?></label>
|
|
<div id="filters_period">
|
|
<select id="filters_period_select" name="filters[period]">
|
|
<?php foreach ($periods as $period => $label): ?>
|
|
<option value="<?php echo $period ?>" <?php if ($filters['period']==$period): ?>selected<?php endif; ?>><?php echo appAdsTracker::langFilter($label) ?></option>
|
|
<?php endforeach ?>
|
|
</select>
|
|
</div>
|
|
</li>
|
|
|
|
<li>
|
|
<label><?php echo __("Zakres dat") ?></label>
|
|
<?php echo input_date_tag('filters[from_date]', $from_date, _parse_attributes(array (
|
|
'rich' => true,
|
|
'withtime' => false,
|
|
'culture' => $sf_user->getCulture(),
|
|
'calendar_button_img' => '/sf/sf_admin/images/date.png',
|
|
'readonly' => 'readonly',
|
|
'class' => 'filters_date_range',
|
|
))); ?>
|
|
-
|
|
<?php echo input_date_tag('filters[to_date]', $to_date, _parse_attributes(array (
|
|
'rich' => true,
|
|
'withtime' => false,
|
|
'culture' => $sf_user->getCulture(),
|
|
'calendar_button_img' => '/sf/sf_admin/images/date.png',
|
|
'readonly' => 'readonly',
|
|
'class' => 'filters_date_range',
|
|
))) ?>
|
|
|
|
</li>
|
|
<li class="filter-control">
|
|
<label> </label>
|
|
<button class="button button-search no-label with-icon" type="submit">
|
|
<span class="svg-icon svg-icon-search" style="-webkit-mask-image: url(/images/backend/icons/svg/search.svg?v=2); mask-image: url(/images/backend/icons/svg/search.svg?v=2); " title=""></span>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
<div class="clr" style="margin-bottom: 15px;"></div>
|
|
|
|
|
|
<?php asort($campaigns_1); ?>
|
|
<select name="filters[platform_campaign_1]" id="ads_tracker_list_platform_campaign_1" style="margin-top:5px;display: block;float: left;">
|
|
|
|
<?php
|
|
foreach ($campaigns_1 as $key => $value): ?>
|
|
<option value="<?php echo $key; ?>" <?php
|
|
if (@$selected_1== $key): ?> selected="selected"<?php endif; ?>><?php echo appAdsTracker::langFilter($value); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
|
|
<span style="margin-top: 8px;display: inline-block;"> <?php echo __("porównaj z") ?> </span>
|
|
|
|
<?php asort($campaigns_2); ?>
|
|
<select name="filters[platform_campaign_2]" id="ads_tracker_list_platform_campaign_2" style="margin-top:5px;display: block;float: left;">
|
|
<option value="none" <?php
|
|
if (@$selected_2== "none"): ?> selected="selected"<?php endif; ?>> -- <?php echo __("Wybierz kampanie") ?> -- </option>
|
|
<?php
|
|
foreach ($campaigns_2 as $key => $value): ?>
|
|
<option value="<?php echo $key; ?>" <?php
|
|
if (@$selected_2== $key): ?> selected="selected"<?php endif; ?>><?php echo appAdsTracker::langFilter($value); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
|
|
<div class="clr"></div>
|
|
|
|
</div>
|
|
</form>
|
|
|
|
<?php if (appAdsTracker::chartDisplayType($from_date, $to_date)!="none"): ?>
|
|
|
|
<div class="chart-container" style="position: relative; width: 100%; height: 270px">
|
|
<canvas id="myChart1"></canvas>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<?php endif; ?>
|
|
|
|
<form id="record_list_form" class="admin_form">
|
|
|
|
<table class="st_record_list record_list" cellspacing="0" cellpadding="0">
|
|
<thead>
|
|
<tr>
|
|
<th><?php echo __('Kampania') ?></th><th><?php echo __('Wejścia') ?></th><th><?php echo __('Konwersje') ?></th><th><?php echo __('CTR') ?></th><th><?php echo __('Wartość brutto') ?></th><th><?php echo __('Średnia') ?></th><!-- <th><?php // echo __('Zamówienia') ?></th> -->
|
|
</tr>
|
|
</thead>
|
|
<?php
|
|
$change_range_brutto = 0;
|
|
$change_range_entering = 0;
|
|
foreach ($result['campaign'] as $campaign):
|
|
?>
|
|
|
|
<?php
|
|
if($campaign['total_brutto']>0){
|
|
$change_range_brutto = 1;
|
|
}
|
|
|
|
if($campaign['total_entering']>0){
|
|
$change_range_entering = 1;
|
|
}
|
|
?>
|
|
|
|
<tr>
|
|
<td><?php echo appAdsTracker::langFilter($campaign['name']) ?></td>
|
|
<td><?php echo $campaign['total_entering'] ?></td>
|
|
<td><?php echo $campaign['conversion'] ?></td>
|
|
<td><?php echo $campaign['ctr'] ?>%</td>
|
|
<td><?php echo $campaign['total_brutto'] ?></td>
|
|
<td><?php echo $campaign['total_brutto_median'] ?></td>
|
|
<!-- <td><?php // echo $campaign['order_ids'] ?></td> -->
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
// echo "<pre>";
|
|
// print_r($result);
|
|
// echo "</pre>";
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
$chart_labels = json_encode(array_values($result['chart']['labels']));
|
|
$chart_data = json_encode(array_values($result['chart']['dates']));
|
|
|
|
?>
|
|
|
|
|
|
<script>
|
|
jQuery(function($) {
|
|
$('#filters_from_date, #filters_to_date').click(function() {
|
|
console.log("wybrano custom");
|
|
$("#filters_period_select").val("custom");
|
|
$("#filters_period_select").trigger('chosen:update');
|
|
});
|
|
|
|
$('#ads_tracker_list_platform_campaign_1').on('change',function() {
|
|
$('#filter-campaign').submit();
|
|
});
|
|
|
|
$('#ads_tracker_list_platform_campaign_2').on('change',function() {
|
|
$('#filter-campaign').submit();
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
<?php if (appAdsTracker::chartDisplayType($from_date, $to_date)!="none"): ?>
|
|
|
|
<script>
|
|
jQuery(function($) {
|
|
|
|
<?php
|
|
$i=0;
|
|
foreach ($result['chart']['campaign'] as $key => $value):
|
|
?>
|
|
|
|
var quantites<?php echo $i ?> = <?php echo json_encode(array_values($value['count'])); ?>
|
|
|
|
<?php
|
|
$i++;
|
|
endforeach;
|
|
?>
|
|
|
|
|
|
|
|
|
|
var chart_dates = <?php echo $chart_data ?>;
|
|
var display_type = "day";
|
|
|
|
var chart = $("#myChart1");
|
|
|
|
var data = {
|
|
labels: <?php echo appAdsTracker::langFilter($chart_labels) ?>,
|
|
datasets: [
|
|
|
|
|
|
<?php foreach ($result['chart']['campaign'] as $key => $value): ?>
|
|
|
|
{
|
|
label: "<?php echo appAdsTracker::langFilter($key) ?>",
|
|
fill: false,
|
|
lineTension: 0.1,
|
|
backgroundColor: "<?php echo '#'.$value['color'] ?>",
|
|
borderColor: "<?php echo '#'.$value['color'] ?>",
|
|
borderCapStyle: 'butt',
|
|
borderDash: [],
|
|
borderDashOffset: 0.0,
|
|
borderJoinStyle: 'miter',
|
|
pointBorderColor: "<?php echo '#'.$value['color'] ?>",
|
|
pointBackgroundColor: "#fff",
|
|
pointBorderWidth: 1,
|
|
pointHoverRadius: 5,
|
|
pointHoverBackgroundColor: "<?php echo '#'.$value['color'] ?>",
|
|
pointHoverBorderColor: "rgba(220,220,220,1)",
|
|
pointHoverBorderWidth: 2,
|
|
pointRadius: 3,
|
|
pointHitRadius: 10,
|
|
pointStyle: "circle",
|
|
data: <?php echo json_encode(array_values($value['amount'])); ?>,
|
|
},
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
]
|
|
};
|
|
|
|
var options = {
|
|
hover: {
|
|
onHover: function(data) {
|
|
if (display_type == "month") {
|
|
if (data.length && quantites[data[0]._index] > 0) {
|
|
chart.css({ cursor: 'pointer' });
|
|
} else {
|
|
chart.css({ cursor: 'default' });
|
|
}
|
|
}
|
|
}
|
|
},
|
|
onClick: function(e) {
|
|
if (display_type == "month") {
|
|
var elements = this.getElementsAtEvent(e);
|
|
|
|
if (elements.length && quantites[elements[0]._index] > 0) {
|
|
|
|
window.location = chart.closest('form').attr('action')+'?filters[filter_order_status]='+$('#filters_filter_order_status').val()+'&filters[expand_date]='+chart_dates[elements[0]._index];
|
|
}
|
|
}
|
|
},
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
legend: { display: true },
|
|
tooltips: {
|
|
enabled: true,
|
|
mode: 'single',
|
|
callbacks: {
|
|
beforeLabel: function(tooltipItems, data) {
|
|
|
|
if(tooltipItems.datasetIndex==0){
|
|
return "<?php echo __('ilość zamówień') ?>: "+quantites0[tooltipItems.index];
|
|
}
|
|
|
|
if(tooltipItems.datasetIndex==1){
|
|
return "<?php echo __('ilość zamówień') ?>: "+quantites1[tooltipItems.index];
|
|
}
|
|
|
|
},
|
|
label: function(tooltipItems, data) {
|
|
return "<?php echo __('brutto') ?>: "+tooltipItems.yLabel + ' PLN';
|
|
},
|
|
title: function(tooltipItems, data) {
|
|
return chart_dates[tooltipItems[0].index];
|
|
}
|
|
}
|
|
},
|
|
scales: {
|
|
xAxes: [{
|
|
barPercentage: 0.5,
|
|
maxBarThickness: 120,
|
|
}],
|
|
yAxes: [{
|
|
ticks: {
|
|
mirror: false,
|
|
<?php if($change_range_brutto == 0): ?>
|
|
stepSize: 50,
|
|
<?php endif; ?>
|
|
beginAtZero:true,
|
|
userCallback: function(value, index, values) {
|
|
value = Number(value);
|
|
return (options.scales.yAxes[0].ticks.stepSize == 1 || value > 10 || value == 0 ? value.toFixed(0) : value.toFixed(1)) + ' PLN';
|
|
}
|
|
},
|
|
afterDataLimits(scale) {
|
|
|
|
if(scale.max==1){
|
|
scale.max = 100;
|
|
|
|
}else{
|
|
var my_y = scale.max*0.2;
|
|
scale.max += my_y;
|
|
}
|
|
|
|
}
|
|
}]
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: '<?php echo __('Raport sprzedaży') ?>'
|
|
}
|
|
}
|
|
|
|
var myLineChart = new Chart(chart.get(0), {
|
|
type: 'bar',
|
|
data: data,
|
|
options: options
|
|
});
|
|
|
|
// wejścia
|
|
|
|
|
|
/* var chart = $("#myChart2");
|
|
|
|
var data2 = {
|
|
labels: <?php echo $chart_labels ?>,
|
|
datasets: [
|
|
|
|
|
|
<?php foreach ($result['chart']['campaign'] as $key => $value): ?>
|
|
|
|
{
|
|
label: "<?php echo appAdsTracker::langFilter($key) ?>",
|
|
fill: false,
|
|
lineTension: 0.1,
|
|
backgroundColor: "<?php echo '#'.$value['color'] ?>",
|
|
borderColor: "<?php echo '#'.$value['color'] ?>",
|
|
borderCapStyle: 'butt',
|
|
borderDash: [],
|
|
borderDashOffset: 0.0,
|
|
borderJoinStyle: 'miter',
|
|
pointBorderColor: "<?php echo '#'.$value['color'] ?>",
|
|
pointBackgroundColor: "#fff",
|
|
pointBorderWidth: 1,
|
|
pointHoverRadius: 5,
|
|
pointHoverBackgroundColor: "<?php echo '#'.$value['color'] ?>",
|
|
pointHoverBorderColor: "rgba(220,220,220,1)",
|
|
pointHoverBorderWidth: 2,
|
|
pointRadius: 3,
|
|
pointHitRadius: 10,
|
|
pointStyle: "circle",
|
|
data: <?php echo json_encode(array_values($value['entering'])); ?>,
|
|
},
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
]
|
|
};
|
|
|
|
var options2 = {
|
|
hover: {
|
|
onHover: function(data) {
|
|
if (display_type == "month") {
|
|
if (data.length && quantites[data[0]._index] > 0) {
|
|
chart.css({ cursor: 'pointer' });
|
|
} else {
|
|
chart.css({ cursor: 'default' });
|
|
}
|
|
}
|
|
}
|
|
},
|
|
onClick: function(e) {
|
|
if (display_type == "month") {
|
|
var elements = this.getElementsAtEvent(e);
|
|
|
|
if (elements.length && quantites[elements[0]._index] > 0) {
|
|
|
|
window.location = chart.closest('form').attr('action')+'?filters[filter_order_status]='+$('#filters_filter_order_status').val()+'&filters[expand_date]='+chart_dates[elements[0]._index];
|
|
}
|
|
}
|
|
},
|
|
responsive: false,
|
|
maintainAspectRatio: true,
|
|
legend: { display: true },
|
|
tooltips: {
|
|
enabled: true,
|
|
mode: 'single',
|
|
callbacks: {
|
|
label: function(tooltipItems, data2) {
|
|
return "<?php echo __('wejść') ?>: "+tooltipItems.yLabel;
|
|
},
|
|
title: function(tooltipItems, data2) {
|
|
return chart_dates[tooltipItems[0].index];
|
|
}
|
|
}
|
|
},
|
|
scales: {
|
|
xAxes: [{
|
|
barPercentage: 0.5,
|
|
maxBarThickness: 120,
|
|
}],
|
|
yAxes: [{
|
|
ticks: {
|
|
mirror: true,
|
|
beginAtZero:true,
|
|
<?php if($change_range_entering == 0): ?>
|
|
stepSize: 50,
|
|
<?php endif; ?>
|
|
userCallback: function(value, index, values) {
|
|
value = Number(value);
|
|
return value;
|
|
}
|
|
},
|
|
afterDataLimits(scale) {
|
|
|
|
if(scale.max==1){
|
|
scale.max = 10;
|
|
|
|
}else{
|
|
var my_y = scale.max*0.2;
|
|
scale.max += my_y;
|
|
}
|
|
|
|
}
|
|
}]
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: '<?php echo __('Raport wejść') ?>'
|
|
}
|
|
}
|
|
|
|
var myLineChart = new Chart(chart.get(0), {
|
|
type: 'bar',
|
|
data: data2,
|
|
options: options2
|
|
});*/
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php echo st_get_admin_foot() ?>
|