383 lines
16 KiB
PHP
383 lines
16 KiB
PHP
<?php
|
|
|
|
use_helper('I18N', 'stAdminGenerator', 'stJQueryTools','stCurrency', 'stOrder', 'stPrice', 'stJQueryTools', 'stProductImage', 'stDiscount','Validation', 'stDate');
|
|
sfLoader::loadHelpers('stProduct', 'stProduct');
|
|
echo st_admin_get_viewport_force_width();
|
|
?>
|
|
|
|
<?php echo st_get_admin_head('appAdsTrackerPlugin', __('Raport platformy')) ?>
|
|
<?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" style="margin-top: 5px;">
|
|
|
|
<?php
|
|
$datetime1 = date_create($from_date);
|
|
$datetime2 = date_create($to_date);
|
|
$interval = date_diff($datetime1, $datetime2);
|
|
|
|
?>
|
|
|
|
<form id="filter-platform" action="<?php echo url_for('appAdsTrackerBackend/adsTrackerPlatformStats') ?>" method="post" style="margin-bottom: 10px">
|
|
<div class="list_filters">
|
|
|
|
<?php
|
|
/*echo "<pre>";
|
|
print_r($filters);
|
|
echo "</pre>";*/
|
|
?>
|
|
<ul class="header">
|
|
<li>
|
|
<div id="filters_period">
|
|
<label><?php echo __("Zakres") ?></label>
|
|
<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 $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 echo "Platformy" ?>
|
|
<ul class="sf_admin_checklist" style="margin-bottom: 15px;">
|
|
<?php
|
|
foreach ($platforms as $platform_id => $platform_label ): ?>
|
|
|
|
<?php
|
|
if ( @$filters['platform'][$platform_label] == $platform_id) {
|
|
$checked = 1;
|
|
} else {
|
|
$checked = 0;
|
|
}
|
|
|
|
?>
|
|
<li style="margin-right: 30px;">
|
|
<?php echo st_admin_checkbox_tag('filters[platform]['.$platform_label.']', $platform_id, $checked, array("class"=>"platform-checkbox")); ?> <?php echo label_for('filters[platform]['.$platform_label.']', appAdsTracker::langFilter($platform_label)) ?>
|
|
</li>
|
|
|
|
<?php endforeach ?>
|
|
</ul>
|
|
|
|
<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 __('Platforma') ?></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;
|
|
|
|
$sum_total_entering = 0;
|
|
$sum_conversion = 0;
|
|
$sum_total_brutto = 0;
|
|
|
|
|
|
foreach ($result['platform'] as $platform):
|
|
?>
|
|
|
|
<?php
|
|
if($platform['total_brutto']>0){
|
|
$change_range_brutto = 1;
|
|
}
|
|
|
|
if($platform['total_entering']>0){
|
|
$change_range_entering = 1;
|
|
}
|
|
|
|
|
|
$sum_total_entering += $platform['total_entering'];
|
|
$sum_conversion += $platform['conversion'];
|
|
$sum_total_brutto += $platform['total_brutto'];
|
|
|
|
?>
|
|
|
|
<tr>
|
|
<td><?php echo appAdsTracker::langFilter($platform['name']) ?></td>
|
|
<td><?php echo $platform['total_entering'] ?></td>
|
|
<td><?php echo $platform['conversion'] ?></td>
|
|
<td><?php echo $platform['ctr'] ?>%</td>
|
|
<td><?php echo $platform['total_brutto'] ?></td>
|
|
<td><?php echo $platform['total_brutto_median'] ?></td>
|
|
|
|
<!-- <td><?php // echo $platform['order_ids'] ?></td> -->
|
|
</tr>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
<tfoot>
|
|
<tr style="background: #f1f1f1; font-weight: bold;">
|
|
<td style="font-weight: bold;"><?php echo __('Razem') ?></td>
|
|
<td style="font-weight: bold;"><?php echo $sum_total_entering ?></td>
|
|
<td style="font-weight: bold;"><?php echo $sum_conversion ?></td>
|
|
<td style="font-weight: bold;"><?php if ($sum_conversion==""){ echo "0%"; }else{ echo round(($sum_conversion/$sum_total_entering)*100,'2')."%";} ?></td>
|
|
<td style="font-weight: bold;"><?php echo number_format($sum_total_brutto, 2, '.', ''); ?></td>
|
|
<td style="font-weight: bold;"><?php if ($sum_total_brutto=="") { echo "0"; } else { echo round($sum_total_brutto/$sum_conversion,'2');} ?></td>
|
|
<!-- <td><?php // echo $platform['order_ids'] ?></td> -->
|
|
</tr>
|
|
</tfoot>
|
|
|
|
</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');
|
|
});
|
|
|
|
$('.platform-checkbox').on('change',function() {
|
|
$('#filter-platform').submit();
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
<?php if (appAdsTracker::chartDisplayType($from_date, $to_date)!="none"): ?>
|
|
|
|
<script>
|
|
|
|
jQuery(function($) {
|
|
|
|
var y_label_char = 0;
|
|
|
|
<?php
|
|
$i=0;
|
|
foreach ($result['chart']['platform'] 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']['platform'] 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 = {
|
|
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: [{
|
|
stacked: true,
|
|
barPercentage: 0.5,
|
|
maxBarThickness: 120,
|
|
}],
|
|
yAxes: [{
|
|
stacked: true,
|
|
ticks: {
|
|
mirror: false,
|
|
beginAtZero:true,
|
|
<?php if($change_range_brutto == 0): ?>
|
|
stepSize: 50,
|
|
<?php endif; ?>
|
|
userCallback: function(value, index, values) {
|
|
value = Number(value);
|
|
|
|
var ret = (options.scales.yAxes[0].ticks.stepSize == 1 || value > 10 || value == 0 ? value.toFixed(0) : value.toFixed(1)) + ' PLN';
|
|
|
|
return ret;
|
|
}
|
|
},
|
|
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
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php echo st_get_admin_foot() ?>
|