//Initialisation des graphiques var chart_navigateur; var chart_OS; var chart_month; var chart_year; var chart_week; var chart_qrcode; var chart_country; var chart_resolution; var qrcode_id = ''; var campaign_id = ''; var date = new Date(); var annee = date.getFullYear(); var annee_mois = date.getFullYear(); var mois = date.getMonth(); var nom_mois; $(function(){ $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=selectAccount", success: function(data){ var dates = $("#from, #to").datepicker({ maxDate: data['to'], minDate: data['from'], numberOfMonths: 3, dateFormat: "dd/mm/yy", onSelect: function( selectedDate ) { var option = this.id == "from" ? "minDate" : "maxDate", instance = $( this ).data( "datepicker" ); } }); } }); }); 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";} //Récupération de la variable GET si elle existe if(location.search != ''){ qrcode_id = getParamValue('code'); campaign_id = getParamValue('campaign'); if(qrcode_id!=''){ $("#container_6").css("display","none"); $("#over_container_6").css("display","none"); $("#container_9").css("display","none"); $("#over_container_9").css("display","none"); } if(campaign_id!=''){ $("#container_9").css("display","none"); $("#over_container_9").css("display","none"); } } function recreateCodeList(){ $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=selectCodeListByCampaign&code="+qrcode_id+"&campaign="+$("select[name='campaign'] option:selected").val(), success: function(data){ $("#code_choice").html(""); for(var i = 0; i"+data[i].name+""); } } }); } function getParamValue(param, url){ var u = url == undefined ? document.location.href : url; var reg = new RegExp('(\\?|&|^)'+param+'=(.*?)(&|$)'); matches = u.match(reg); return (matches != undefined && matches[2] != undefined) ? decodeURIComponent(matches[2]).replace(/\+/g,' ') : ''; } function loadChartMonthVisits(){ $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountDays&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ monthChartDisplay(msg['visitors'], msg['visits'], msg['date'],msg['pvs']); } }); } function loadChartMonthVisitsDashboard(){ //Graphique représentant le nombre de visiteurs par jour ( pendant 30 jours ) var categoriesData_Period = []; var dataArray_Period = []; var dataArray_UniquePeriod = []; var displayChart = false; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountVisitByNbDays&days=15", success: function(msg){ categoriesData_Period = msg['date']; dataArray_Period = msg['visits']; dataArray_UniquePeriod = msg['visitors']; dataArray_PVS = msg['pvs']; for(var j=0; j 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_Period, gridLineWidth: 0 }, yAxis: { title: { text: '' }, min : 0, minorGridLineWidth: 0, gridLineWidth: 0, alternateGridColor: null }, tooltip: { formatter: function() { return ''+ this.series.name + ' : ' + this.y +''; } }, plotOptions: { line: { dataLabels: { enabled: false }, enableMouseTracking: true } }, legend: { enabled: false }, series: [ { color: '#fff6d8', lineColor : '#f1c100', marker: { symbol: 'url(../js/libs/themes/codactiv/img/graph_jaune_symbole.png)' }, name: "Visiteurs uniques", data: dataArray_PVS }, { lineColor : '#E25663', color: '#f7ebec', marker: { symbol: 'url(../js/libs/themes/codactiv/img/graph_magenta_symbole.png)' }, name: "Scans", data: dataArray_Period }, { color: '#d3e9e7', lineColor : '#67c6cc', marker: { symbol: 'url(../js/libs/themes/codactiv/img/graph_bleu_symbole.png)' }, name: "Visiteurs uniques", data: dataArray_UniquePeriod } ] }); } else{ $("#container_3").css("display","none"); $("#noMonthDatas").show(); } } function loadChartRangeVisits(){ var categoriesData_Month = []; var dataArray_Month = []; var dataArray_UniqueMonth = []; var dataArray_PV = []; var displayChart = false; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountVisitByRange", success: function(msg){ categoriesData_Month = msg['date']; dataArray_Month = msg['visits']; dataArray_UniqueMonth = msg['visitors']; dataArray_PV = msg['pvs']; 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, gridLineWidth: 0 }, yAxis: { title: { text: '' }, min : 0, minorGridLineWidth: 0, gridLineWidth: 1, alternateGridColor: null }, tooltip: { formatter: function() { return ''+ this.series.name + ' : ' + this.y +''; } }, plotOptions: { line: { dataLabels: { enabled: false }, enableMouseTracking: true } }, legend: { enabled: true }, series: [ { marker : { symbol: 'url(../js/libs/themes/codactiv/img/graph_jaune_symbole.png)' }, color: '#fff6d8', lineColor : '#f1c100', name: "Pages vues", data: dataArray_PV }, { marker : { symbol: 'url(../js/libs/themes/codactiv/img/graph_magenta_symbole.png)' }, lineColor : '#E25663', name: "Scans", color: '#f7ebec', data: dataArray_Month }, { marker : { symbol: 'url(../js/libs/themes/codactiv/img/graph_bleu_symbole.png)' }, color: '#d3e9e7', lineColor : '#67c6cc', name: "Visiteurs uniques", data: dataArray_UniqueMonth } ] }); } else{ $("#container_3").css("display","none"); $("#noRangeDatas").show(); } $("#noMonthDatas").hide(); $("#noYearDatas").hide(); $("#noHourDatas").hide(); $("#noDayDatas").hide(); $("#container_7").css("display","none"); $("#container_4").css("display","none"); $("#container_5").css("display","none"); $("#overtitle_right").html(""); $("#over_container_3_4_5").html("Total des visites sur la période"); } function loadChartYearVisits(){ var categoriesData_Year = []; var dataArray_Year = []; var dataArray_UniqueYear = []; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountMonth&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ yearChartDisplay(msg['visitors'], msg['visits'], msg['date'],msg['pvs']); } }); } function loadChartHourVisits(){ // Graphique représentant la moyenne des visites par heure var dataArray_ByDay = []; var dataVisitorsArray_ByDay = []; var dataArrayPVS_ByDay = []; var displayChart = false; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountVisitsByHours&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ dataArray_ByDay = msg['visits']; dataArrayPVS_ByDay = msg['pvs']; for(var i=0; i 0){ displayChart = true; break; } } } }); if(displayChart){ $("#container_7").css("display","block"); $("#noDayDatas").hide(); chart_week = new Highcharts.Chart( { chart: { renderTo: 'container_7', defaultSeriesType: 'column' }, title: { text: '' }, xAxis: { categories: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18","19","20","21","22","23","24"] }, yAxis: { title: { text: '' }, min : 0 }, tooltip: { formatter: function() { return ''+ this.series.name + ' : ' + this.y +''; } }, series: [{ name: "Scans", data: dataArray_ByDay, dataLabels: { enabled: true, formatter: function() { if(this.y !=0) { return this.y; } }, style: { font: 'bold 13px Verdana, sans-serif' } } },{ name: "Pages vues", data: dataArrayPVS_ByDay, color : '#F6B37E', dataLabels: { enabled: true, formatter: function() { if(this.y !=0) { return this.y; } }, style: { font: 'bold 13px Verdana, sans-serif' } } } ] }); } else{ $("#container_7").css("display","none"); $("#noHourDatas").show(); } $("#btn_1").addClass("selected"); $("#btn_2").removeClass("selected"); $("#btn_3").removeClass("selected"); $("#noDayDatas").hide(); $("#noMonthDatas").hide(); $("#noYearDatas").hide(); $("#noRangeDatas").hide(); $("#container_3").css("display","none"); $("#container_4").css("display","none"); $("#container_5").css("display","none"); $("#over_container_3_4_5").html("Total des visites par heure"); $("#overtitle_right").html(""); } function loadChartWeekVisits(){ // Graphique représentant la moyenne des visites par jour de la seMaine var dataArray_ByDay = []; var dataVisitorsArray_ByDay = []; var displayChart = false; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountVisitsByDay&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ dataArray_ByDay = msg['visits']; dataVisitorsArray_ByDay = msg['visitors']; dataPVSArray_ByDay = msg['pvs']; for(var i=0; i 0){ displayChart = true; break; } } } }); if(displayChart){ $("#container_5").css("display","block"); $("#noDayDatas").hide(); chart_week = new Highcharts.Chart( { chart: { renderTo: 'container_5', defaultSeriesType: 'column' }, title: { text: '' }, xAxis: { categories: ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"] }, yAxis: { title: { text: '' }, min : 0 }, tooltip: { formatter: function() { return ''+ this.series.name + ' : ' + this.y +''; } }, series: [{ name: "Scans", data: dataArray_ByDay, dataLabels: { enabled: true, formatter: function() { if(this.y !=0) { return this.y; } }, style: { font: 'bold 13px Verdana, sans-serif' } } },/*{ name: "", data: dataVisitorsArray_ByDay, dataLabels: { enabled: true, formatter: function() { if(this.y !=0) { return this.y; } }, style: { font: 'bold 13px Verdana, sans-serif' } } }*/ { name: "Pages vues", data: dataPVSArray_ByDay, color : '#F6B37E', dataLabels: { enabled: true, formatter: function() { if(this.y !=0) { return this.y; } }, style: { font: 'bold 13px Verdana, sans-serif' } } }] }); } else{ $("#container_5").css("display","none"); $("#noDayDatas").show(); } $("#container_7").css("display","none"); $("#btn_1").addClass("selected"); $("#btn_2").removeClass("selected"); $("#btn_3").removeClass("selected"); $("#noMonthDatas").hide(); $("#noYearDatas").hide(); $("#noHourDatas").hide(); $("#noRangeDatas").hide(); $("#container_3").css("display","none"); $("#container_4").css("display","none"); $("#over_container_3_4_5").html("Total des visites par jour"); $("#overtitle_right").html(""); } function loadChartOS(){ //Graphique représentant le pourcentage des différents systèmes d'exploitation var osArray = []; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountOS&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ // generate an array of data for(i=0; i 0){ $("#container_2").css("display","block"); $("#noOsDatas").hide(); chart_OS = new Highcharts.Chart( { chart: { renderTo: 'container_2', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: '' }, tooltip: { formatter: function() { return ''+ this.point.name +': '+ this.y +' %'; } }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: Highcharts.theme.textColor || '#000000', connectorColor: Highcharts.theme.textColor || '#000000', formatter: function() { return ''+ this.point.name +': '+ this.y +' %'; } } } }, series: [{ type: 'pie', name: "Systèmes d'exploitation", data: osArray }] }); } else{ $("#container_2").css("display","none"); $("#noOsDatas").show(); } } function loadChartExplorer(){ // Graphique représentant le pourcentage des différents navigateurs var browserArray = []; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountBrowsers&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ // generate an array of data for(i=0;i 0){ $("#container").css("display","block"); $("#noBrowserDatas").hide(); chart_navigateur = new Highcharts.Chart( { chart: { renderTo: 'container', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: '' }, tooltip: { formatter: function() { return ''+ this.point.name +': '+ this.y +' %'; } }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: Highcharts.theme.textColor || '#000000', connectorColor: Highcharts.theme.textColor || '#000000', formatter: function() { return ''+ this.point.name +': '+ this.y +' %'; } } } }, series: [{ type: 'pie', name: "Navigateurs", data: browserArray }] }); } else{ $("#container").css("display","none"); $("#noBrowserDatas").show(); } } function loadChartVisitPerCode(){ //Graphique représentant le nombre de scans par QRcode var categorie_productArray = []; var data_productArray = []; var dataVisitors_productArray = []; var displayChart = false; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountVisitsByProduct&campaign="+campaign_id, success: function(msg){ categorie_productArray = msg['categories']; data_productArray = msg['visits']; dataVisitors_productArray = msg['visitors']; dataPVS_productArray = msg['pvs']; for(var i=0; i 0){ displayChart = true; break; } } } }); if(displayChart){ $("#container_6").css("display","block"); $("#noVisitPerCodeDatas").hide(); chart_qrcode = new Highcharts.Chart( { chart: { renderTo: 'container_6', defaultSeriesType: 'bar' }, title: { text: '' }, xAxis: { categories: categorie_productArray, 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_productArray },/*{ name: "", data: dataVisitors_productArray }*/ { name: "Pages vues", color:'#F6B37E', data: dataPVS_productArray } ] }); } else{ $("#container_6").css("display","none"); $("#noVisitPerCodeDatas").show(); } } function loadChartCountry(){ // Graphique représentant le pourcentage des différents pays var countryArray = []; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountCountry&code="+qrcode_id+"&campaign="+campaign_id, success: function(msg){ // generate an array of data for(i=0;i 0){ $("#container_7").css("display","block"); $("#noCountryDatas").hide(); chart_country = new Highcharts.Chart( { chart: { renderTo: 'container_7', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: '' }, tooltip: { formatter: function() { return ''+ this.point.name +': '+ this.y +' %'; } }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: Highcharts.theme.textColor || '#000000', connectorColor: Highcharts.theme.textColor || '#000000', formatter: function() { return ''+ this.point.name +': '+ this.y +' %'; } } } }, series: [{ type: 'pie', name: "Pays", data: countryArray }] }); } else{ $("#container_7").css("display","none"); $("#noCountryDatas").show(); } } function loadChartResolution(){ // Graphique représentant le pourcentage des différentes résolutions var categoriesData_Resolutions = []; var dataArray_UniqueResolutions = []; $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=CountResolutions&code="+qrcode_id+"&campaign="+campaign_id, success: function(resolutionArray){ for(var resolution in resolutionArray){ categoriesData_Resolutions.push(resolution); dataArray_UniqueResolutions.push(resolutionArray[resolution]); } } }); if(dataArray_UniqueResolutions.length > 0){ $("#container_8").css("display","block"); $("#noResolutionDatas").hide(); chart_resolution = new Highcharts.Chart( { chart: { renderTo: 'container_8', defaultSeriesType: 'column', margin: [ 30, 50, 50, 30], height : 250 }, title: { text: '' }, xAxis: { categories: categoriesData_Resolutions, labels: { rotation: -35, align: 'right' } }, yAxis: { title: { text: '' }, min : 0 }, legend: { enabled: false }, tooltip: { formatter: function() { return ''+ this.series.name + ' : ' + this.y +''; } }, series: [ { name: "Scans", data: dataArray_UniqueResolutions, dataLabels: { enabled: true, formatter: function() { if(this.y !=0) { return this.y; } }, style: { font: 'bold 13px Verdana, sans-serif' } } }] }); } else{ $("#container_8").css("display","none"); $("#noResolutionDatas").show(); } } function loadChartVisitedPages(){ $.ajax({ type: "POST", url: "stats.action.php", dataType: 'json', async:false, data: "action=VisitedPages", success: function(msg){ $.post('stats.action.php','action=countPagesViews',function(data){ for(var i=0;i'+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); }