Files
grzanieplus.pl/plugins/appAdsTrackerPlugin/modules/appAdsTrackerBackend/templates/adsTrackerCampaignEnteringStatsSuccess.php
2025-03-12 17:06:23 +01:00

331 lines
14 KiB
PHP

<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date', 'VisualEffect', 'stAdminGenerator') ?>
<?php echo st_admin_get_viewport_force_width(); ?>
<?php echo st_get_admin_head('appAdsTrackerPlugin', __('Raport wejść kampanii')) ?>
<?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/adsTrackerCampaignEnteringStats') ?>" 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>&nbsp;</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;">&nbsp;&nbsp;&nbsp;<?php echo __("porównaj z") ?>&nbsp;&nbsp;&nbsp;</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" style="max-width: 500px;">
<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 ?>;
// wejścia
var chart = $("#myChart1");
var data = {
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 options = {
responsive: true,
maintainAspectRatio: false,
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: false,
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: data,
options: options
});
});
</script>
<?php endif; ?>
</div>
<?php echo st_get_admin_foot() ?>