'+msg[i]['page']+' | '+msg[i]['pv']+' | '+Math.round((msg[i]['pv']/data)*100)+'% | ');
}
$('.column').equalHeight();
})
if(msg.length==0){
$('#noPageData').show();
}
}
});
}
function loadChartVisitPerCampaign()
{
//Graphique représentant le nombre de scans par campagne
var categorie_campaignArray = [];
var data_campaignArray = [];
var dataVisitors_campaignArray = [];
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountVisitsByCampaign",
success: function(msg){
categorie_campaignArray = msg['categories'];
data_campaignArray = msg['visits'];
dataVisitors_campaignArray = msg['visitors'];
dataPVS_campaignArray = msg['pvs'];
}
});
if(dataVisitors_campaignArray.length > 0){
$("#container_9").css("display","block");
$("#noVisitPerCampaignDatas").hide();
chart_qrcode = new Highcharts.Chart(
{
chart: {
renderTo: 'container_9',
defaultSeriesType: 'bar'
},
title: {
text: ''
},
xAxis: {
categories: categorie_campaignArray,
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
formatter: function() {
return ''+ this.series.name +': '+ this.y;
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
credits: {
enabled: false
},
series: [{
name: "Scans",
data: data_campaignArray
},/*{
name: "",
data: dataVisitors_campaignArray
},*/
{
color : '#F6B37E',
name: "Pages vues",
data: dataPVS_campaignArray
}
]
});
}
else{
$("#container_9").css("display","none");
$("#noVisitPerCampaignDatas").show();
}
}
function yearPrev()
{
annee = annee-1;
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountMonth&code="+qrcode_id+"&annee="+annee+"&campaign="+campaign_id,
success: function(msg){
yearChartDisplay(msg['visitors'], msg['visits'], msg['date'],msg['pvs']);
}
});
$("#overtitle_right").html("Année "+annee+"");
}
function yearSuiv()
{
annee = annee+1;
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountMonth&code="+qrcode_id+"&annee="+annee+"&campaign="+campaign_id,
success: function(msg){
yearChartDisplay(msg['visitors'], msg['visits'], msg['date'],msg['pvs']);
}
});
$("#overtitle_right").html("Année "+annee+"");
}
function monthPrev()
{
if(mois==0)
{
mois = 11;
annee_mois = annee_mois-1 ;
}
else mois = mois-1;
if(mois==0){nom_mois ="Janvier";}else if(mois==1){nom_mois ="Février";}else if(mois==2){nom_mois ="Mars";}else if(mois==3){nom_mois ="Avril";}else if(mois==4){nom_mois ="Mai";}else if(mois==5){nom_mois ="Juin";}else if(mois==6){nom_mois ="Juillet";}else if(mois==7){nom_mois ="Août";}else if(mois==8){nom_mois ="Septembre";}else if(mois==9){nom_mois ="Octobre";}else if(mois==10){nom_mois ="Novembre";}else if(mois==11){nom_mois ="Decembre";}
$("#overtitle_right").html("Pour le mois de "+nom_mois+" "+annee_mois+"");
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountDays&code="+qrcode_id+"&mois="+mois+"&annee_mois="+annee_mois+"&campaign="+campaign_id,
success: function(msg){
monthChartDisplay(msg['visitors'], msg['visits'], msg['date'],msg['pvs']);
}
});
}
function monthSuiv()
{
if(mois==11)
{
mois = 0;
annee_mois = annee_mois+1;
}
else mois = mois+1;
if(mois==0){nom_mois ="Janvier";}else if(mois==1){nom_mois ="Février";}else if(mois==2){nom_mois ="Mars";}else if(mois==3){nom_mois ="Avril";}else if(mois==4){nom_mois ="Mai";}else if(mois==5){nom_mois ="Juin";}else if(mois==6){nom_mois ="Juillet";}else if(mois==7){nom_mois ="Août";}else if(mois==8){nom_mois ="Septembre";}else if(mois==9){nom_mois ="Octobre";}else if(mois==10){nom_mois ="Novembre";}else if(mois==11){nom_mois ="Decembre";}
$("#overtitle_right").html("Pour le mois de "+nom_mois+" "+annee_mois+"");
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async: false,
data: "action=CountDays&code="+qrcode_id+"&mois="+mois+"&annee_mois="+annee_mois+"&campaign="+campaign_id,
success: function(msg){
monthChartDisplay(msg['visitors'], msg['visits'], msg['date'],msg['pvs']);
}
});
}
function monthChartDisplay(dataArray_UniqueMonth, dataArray_Month, categoriesData_Month, dataArray_pvs){
var displayChart = false;
for(var i=0; i 0){
displayChart = true;
break;
}
}
if(displayChart){
$("#container_3").css("display","block");
$("#noMonthDatas").hide();
chart_month = new Highcharts.Chart(
{
chart: {
renderTo: 'container_3',
defaultSeriesType: 'area',
},
title: {
text: ''
},
xAxis: {
categories: categoriesData_Month
},
yAxis: {
allowDecimals:false,
title: {
text: ''
},
min : 0
},
tooltip: {
formatter: function() {
return ''+ this.series.name + ' : ' + this.y +'';
}
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: true
}
},
series: [
{
marker : {
symbol: 'url(../js/libs/themes/codactiv/img/graph_jaune_symbole.png)'
},
color: '#fff6d8',
lineColor : '#f1c100',
name: "Pages vues",
data: dataArray_pvs
},
{
lineColor : '#E25663',
color: '#f7ebec',
marker: {
symbol: 'url(../js/libs/themes/codactiv/img/graph_magenta_symbole.png)'
},
name: "Scans",
data: dataArray_Month
}/*,
{
marker: {
symbol: 'url(../js/libs/themes/codactiv/img/graph_bleu_symbole.png)'
},
color: '#d3e9e7',
lineColor : '#67c6cc',
name: "",
data: dataArray_UniqueMonth
}*/]
});
}
else{
$("#container_3").css("display","none");
$("#noMonthDatas").show();
}
$("#btn_1").removeClass("selected");
$("#btn_2").addClass("selected");
$("#btn_3").removeClass("selected");
$("#noYearDatas").hide();
$("#noDayDatas").hide();
$("#noHourDatas").hide();
$("#noRangeDatas").hide();
$("#container_7").css("display","none");
$("#container_4").css("display","none");
$("#container_5").css("display","none");
$("#over_container_3_4_5").html("Total des visites sur le mois");
$("#overtitle_right").html("Pour le mois de "+nom_mois+" "+annee_mois+"");
}
function yearChartDisplay(dataArray_UniqueYear, dataArray_Year, categoriesData_Year, dataArray_Pvs){
var displayChart = false;
for(var i=0; i 0){
displayChart = true;
break;
}
}
if(displayChart){
$("#container_4").css("display","block");
$("#noYearDatas").hide();
chart_year = new Highcharts.Chart(
{
chart: {
renderTo: 'container_4',
defaultSeriesType: 'column'
},
title: {
text: ''
},
xAxis: {
categories: categoriesData_Year
},
yAxis: {
title: {
text: ''
},
min : 0
},
tooltip: {
formatter: function() {
return ''+ this.series.name + ' : ' + this.y +'';
}
},
series: [
{
name: "Scans",
data: dataArray_Year,
dataLabels: {
enabled: true,
formatter: function() {
if(this.y !=0)
{
return this.y;
}
},
style: {
font: 'bold 13px Verdana, sans-serif'
}
}
},
/*{
name: "",
data: dataArray_UniqueYear,
dataLabels: {
enabled: true,
formatter: function() {
if(this.y !=0)
{
return this.y;
}
},
style: {
font: 'bold 13px Verdana, sans-serif'
}
}
},*/
{
name: "Pages vues",
color: '#F6B37E',
data: dataArray_Pvs,
dataLabels: {
enabled: true,
formatter: function() {
if(this.y !=0)
{
return this.y;
}
},
style: {
font: 'bold 13px Verdana, sans-serif'
}
}
}
]
});
}
else{
$("#container_4").css("display","none");
$("#noYearDatas").show();
}
$("#btn_1").removeClass("selected");
$("#btn_2").removeClass("selected");
$("#btn_3").addClass("selected");
$("#noMonthDatas").hide();
$("#noDayDatas").hide();
$("#noHourDatas").hide();
$("#noRangeDatas").hide();
$("#container_3").css("display","none");
$("#container_5").css("display","none");
$("#container_7").css("display","none");
$("#over_container_3_4_5").html("Total des visites sur l'année");
$("#overtitle_right").html("Année "+annee+"");
}
function loadBrowserTable(){
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountBrowserTable&code="+qrcode_id+"&campaign="+campaign_id,
success: function(msg){
if(msg.length > 0){
$("#browserTable").show();
$("#noBrowserTableDatas").hide();
for(var i = 0; i < msg.length; i++){
$("#browserTable tbody").append(""+msg[i]['browser']+" | "+msg[i]['counter']+" |
");
}
}
else{
$("#browserTable").hide();
$("#noBrowserTableDatas").show();
}
}
});
}
function loadOsTable(){
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountOsTable&code="+qrcode_id+"&campaign="+campaign_id,
success: function(msg){
if(msg.length > 0){
$("#osTable").show();
$("#noOsTableDatas").hide();
for(var i = 0; i < msg.length; i++){
$("#osTable tbody").append(""+msg[i]['os']+" | "+msg[i]['counter']+" |
");
}
}
else{
$("#osTable").hide();
$("#noOsTableDatas").show();
}
}
});
}
function loadResolutionTable(){
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountResolutionTable&code="+qrcode_id+"&campaign="+campaign_id,
success: function(msg){
if(msg.length > 0){
$("#resolutionTable").show();
$("#noResolutionTableDatas").hide();
for(var i = 0; i < msg.length; i++){
$("#resolutionTable tbody").append(""+msg[i]['resolution']+" | "+msg[i]['counter']+" |
");
}
}
else{
$("#resolutionTable").hide();
$("#noResolutionTableDatas").show();
}
}
});
}
function loadCountryTable(){
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountCountryTable&code="+qrcode_id+"&campaign="+campaign_id,
success: function(msg){
if(msg.length > 0){
$("#countryTable").show();
$("#noCountryTableDatas").hide();
for(var i = 0; i < msg.length; i++){
$("#countryTable tbody").append(""+msg[i]['country']+" | "+msg[i]['counter']+" |
");
}
}
else{
$("#countryTable").hide();
$("#noCountryTableDatas").show();
}
}
});
}
function renderGraph(){
drawStreetsMap()
drawRegionsMap()
}
function drawStreetsMap() { // Drawing the street map
var infowindow;
var first_zoom;
var point;
var marker;
var MakerArray = new Array();
var myLatlng = new google.maps.LatLng(48.6332, 7.76802); // Map center
var myOptions = {
zoom: 2,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
Googlemap = new google.maps.Map(document.getElementById("geoGMap"), myOptions);
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=ListScans&code="+qrcode_id+"&campaign="+campaign_id,
success: function(msg){
if(msg.length > 0){ // If scans in db > 0
first_zoom = new google.maps.LatLng(msg[0]['latitude'], msg[0]['longitude']);
infowindow = new google.maps.InfoWindow({
content: "holding..."
});
for(var i = 0; iDétails :
'+"Code flashé le"+''+msg[i]['scan_date']+' '+"à"+' '+msg[i]['scan_time']+'
A proximité de '+msg[i]['address']+'
Navigateur : '+msg[i]['browser']+'
OS : '+msg[i]['os']+'
Résolution : '+msg[i]['resolution_screen']
});
MakerArray.push(marker); // Adding the markers to the map
}
for (var i = 0; i < MakerArray.length; i++){ // Adding the click handler to the markers
var marker = MakerArray[i];
google.maps.event.addListener(marker, 'click', function () {
infowindow.setContent(this.html); // Setting the content of the markers
infowindow.open(Googlemap, this);
});
marker.setMap(Googlemap)
}
}
else{ // If no scans where founnd
$("#geoGMap").hide();
$(".switch_map").click(function(e){
e.preventDefault();
})
}
}
});
}
function showGeoMap(){
$('#geoGMap').hide();
$('#geoChart').show();
}
function showGoogleMap(){
$('#geoChart').hide();
$('#geoGMap').show();
$("#densite").removeClass("active");
$("#geoloc").addClass("active");
}
function drawCountryMap(region) { // Drawing the country map
var AddedCountries = [];
var data = new google.visualization.DataTable();
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountCity&CountryCode="+region,
success: function(msg){
var data = new google.visualization.DataTable();
data.addRows(msg.length);
data.addColumn('string', "Ville");
data.addColumn('number', "Nombre de visiteurs");
for(var i = 0; i 0){ // If scans in db > 0
var data = new google.visualization.DataTable(); // Initialisation of the map
data.addRows(msg.length);
data.addColumn('string', 'Country');
data.addColumn('number', "Nombre de visiteurs");
for(var i = 0; i'+data[0]['counter']+' scan(s)';
listCities(e["region"],name);
NavigateToCountry(e["region"],name)
},'json');
});
}
else{ // If no scans
$(".noStatsDatas").show();
$(".message_list").hide();
$("#navigation_help").hide();
$("#geoGhart").hide();
}
$('.column').equalHeight();
}
});
}
function WorldMap(){ // Drawing the maps
drawRegionsMap();
$(".country_link").html("");
$(".country_link").removeClass('geoLocNav')
$(".city_list").html("");
$(".country_list").html("");
listCountries();
NavigateTo(null,2);
}
function listCountries(){ // Fetching all the countries
$.post("stats.action.php","action=CountTotalVisits",function(data){
$("#scansWorld").html(data+" scan(s)");
});
$(".country_list").html("");
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountCountryTable",
success: function(msg){
if(msg.length > 0){
for(var i = 0;i'+msg[i]['country_name']+''+msg[i]['counter']+' scan(s)');
}
$(".country").click(function(){ // Adding the click handler
NavigateToCountry($(this).attr('title'),$(this).html());
})
}
}
});
}
function listCities(countryCode,country){ // Fetching all the cities in a country
var countryLink = ''+country+'
';
$(".country_link").html("")
$(".country_link").append(countryLink);
$(".selectedCountry").click(function(){
NavigateToCountry($(this).attr('title'),$(this).html()); // Navigating to the selected country
});
$(".country_link").addClass('geoLocNav');
$(".city_list").html("");
$(".country_list").html("");
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
async:false,
data: "action=CountCity&CountryCode="+countryCode,
success: function(msg){
if(msg.length > 0){
for(var i = 0;i'+msg[i]['city']+''+msg[i]['counter']+' scan(s)');
}
$(".city").click(function(){
$(".city").removeClass("selected_city");
$(this).addClass("selected_city");
NavigateToCity($(this).attr('title')); // Navigate to a city on the map
showGoogleMap(); // Switching to the google map
});
}
}
});
}
function NavigateToCountry(countryCode,country){ // Navigate to a country on the map
var position;
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
data: "action=GetLatLng&CC="+countryCode, // Fetching the latitude and the longitude of the country
success: function(data){
listCities(countryCode,country);
NavigateTo(data,5); // Changing the map center (latitude+longitude,zoomlevel)
drawCountryMap(countryCode)
}
});
}
function NavigateToCity(cityName){ // Navigate to a city on the map
var position;
$.ajax({
type: "POST",
url: "stats.action.php",
dataType: 'json',
data: "action=GetLatLngCity&CityName="+cityName, // Fetching the latitude and the longitude of the city
success: function(data){
NavigateTo(data,13); // Changing the map center (latitude+longitude,zoomlevel)
}
});
}
function NavigateTo(position,zoom){ // Change the map center
if(position)
Googlemap.setCenter(new google.maps.LatLng(position['latitude'], position['longitude']));
else
Googlemap.setCenter(new google.maps.LatLng(0, 0));
Googlemap.setZoom(zoom);
}