first commit
This commit is contained in:
@@ -0,0 +1,360 @@
|
||||
<?php use_helper('I18N', 'Text', 'stAdminGenerator', 'ObjectAdmin', 'stDate', 'stProductImage', 'stCurrency') ?>
|
||||
<?php use_helper('stGadget', 'stOrder'); ?>
|
||||
|
||||
<?php
|
||||
use_helper('I18N', 'stAdminGenerator', 'stJQueryTools','stCurrency', 'stOrder', 'stPrice', 'stJQueryTools', 'stProductImage', 'stDiscount','Validation', 'stDate');
|
||||
sfLoader::loadHelpers('stProduct', 'stProduct');
|
||||
?>
|
||||
|
||||
<div id="entering-widget">
|
||||
|
||||
|
||||
<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;
|
||||
}
|
||||
|
||||
#myChart2{
|
||||
width:100%;
|
||||
height: auto;
|
||||
/*max-height: 400px;*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<?php
|
||||
$datetime1 = date_create($from_date);
|
||||
$datetime2 = date_create($to_date);
|
||||
$interval = date_diff($datetime1, $datetime2);
|
||||
|
||||
$count_days = count($result['chart']['labels']);
|
||||
|
||||
//echo $interval;
|
||||
|
||||
?>
|
||||
|
||||
<form action="<?php echo url_for('appAdsTrackerWidgetBackend/adsTrackerEnteringWidget') ?>" method="post" style="margin-bottom: 10px">
|
||||
<div class="list_filters">
|
||||
|
||||
<?php
|
||||
/*echo "<pre>";
|
||||
print_r($filters);
|
||||
echo "</pre>";*/
|
||||
|
||||
$link_to_raport = "";
|
||||
|
||||
foreach ($platforms as $platform_id => $platform_label ){
|
||||
|
||||
if ( @$filters['platform'][$platform_label] == $platform_id) {
|
||||
$link_to_raport .= '&filters[platform]['.$platform_label.']='.$platform_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<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 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"></div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
if (appAdsTracker::chartDisplayType($from_date, $to_date)!="none"): ?>
|
||||
|
||||
<div style="text-align: center; font-size: 12px; top: 12px; position: relative;"><?php echo date('d-m-Y', strtotime($from_date)); ?> / <?php echo date('d-m-Y', strtotime($to_date)); ?></div>
|
||||
<div class="chart-container" style="position: relative; width: 100%; height: 240px">
|
||||
<canvas id="myChart2"></canvas>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?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):
|
||||
|
||||
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'];
|
||||
|
||||
endforeach;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<div style="width: 200px; float: left; padding: 15px;">
|
||||
<b><?php echo __('Wejścia') ?></b><br />
|
||||
|
||||
<?php echo __('Łączna ilość wejść') ?>: <?php echo $sum_total_entering ?><br />
|
||||
|
||||
<?php echo __('Średnia wejść dziennie') ?>: <?php echo round($sum_total_entering/$count_days) ?><br />
|
||||
</div>
|
||||
|
||||
|
||||
<div style="min-width: 300px; float: left; padding: 15px;">
|
||||
<b><?php echo __('Platformy') ?></b> <br />
|
||||
|
||||
<?php foreach ($result['platform'] as $platform): ?>
|
||||
|
||||
<?php echo appAdsTracker::langFilter($platform['name']) ?>: <?php echo $platform['total_entering'] ?><br />
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
|
||||
<?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($) {
|
||||
$('#trigger_filters_from_date, #trigger_filters_to_date').click(function() {
|
||||
console.log("wybrano custom");
|
||||
$("#filters_period_select").val("custom");
|
||||
});
|
||||
});
|
||||
</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";
|
||||
|
||||
|
||||
|
||||
|
||||
// wejścia
|
||||
|
||||
|
||||
var chart = $("#myChart2");
|
||||
|
||||
var data2 = {
|
||||
labels: <?php echo $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['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: 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: [{
|
||||
stacked: true,
|
||||
barPercentage: 0.5,
|
||||
maxBarThickness: 120,
|
||||
}],
|
||||
yAxes: [{
|
||||
stacked: true,
|
||||
ticks: {
|
||||
|
||||
beginAtZero:true,
|
||||
<?php if ($change_range_entering == 0): ?>
|
||||
stepSize: 50,
|
||||
<?php elseif ($sum_total_entering < 10): ?>
|
||||
stepSize: 1,
|
||||
<?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: false,
|
||||
text: '<?php echo __('Raport wejść') ?>'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var myLineChart = new Chart(chart.get(0), {
|
||||
type: 'bar',
|
||||
data: data2,
|
||||
options: options2
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user