<?php
	$tgl2=date("Y-m-d");
	$tgl_bawah2 = strtotime("-1 week +1 day",strtotime($tgl2));
	$hasil_tgl_bawah2 = date('Y-m-d', $tgl_bawah2);
	$tablestat = new PoTable('traffic');
    for ($i=3; $i <= 3; $i++){
      $tgl_pengujung = strtotime("+$i day",strtotime($hasil_tgl_bawah2));
      $hasil_tgl_pengujung = date('Y-m-d', $tgl_pengujung);
	  $currentStat3 = $tablestat->findStat(tanggal, $hasil_tgl_pengujung, ip);
    }
    for ($i=4; $i <= 4; $i++){
      $tgl_pengujung = strtotime("+$i day",strtotime($hasil_tgl_bawah2));
      $hasil_tgl_pengujung = date('Y-m-d', $tgl_pengujung);
	  $currentStat4 = $tablestat->findStat(tanggal, $hasil_tgl_pengujung, ip);
    }
    for ($i=5; $i <= 5; $i++){
      $tgl_pengujung = strtotime("+$i day",strtotime($hasil_tgl_bawah2));
      $hasil_tgl_pengujung = date('Y-m-d', $tgl_pengujung);
	  $currentStat5 = $tablestat->findStat(tanggal, $hasil_tgl_pengujung, ip);
    }
    for ($i=6; $i <= 6; $i++){
      $tgl_pengujung = strtotime("+$i day",strtotime($hasil_tgl_bawah2));
      $hasil_tgl_pengujung = date('Y-m-d', $tgl_pengujung);
	  $currentStat6 = $tablestat->findStat(tanggal, $hasil_tgl_pengujung, ip);
    }
?>

<?php
	$tgl3=date("Y-m-d");
	$tgl_bawah3 = strtotime("-1 week +1 day",strtotime($tgl3));
	$hasil_tgl_bawah3 = date('Y-m-d', $tgl_bawah3);
	$tablestatd = new PoTable('traffic');
    for ($i3=3; $i3 <= 3; $i3++){
      $tgl_hits = strtotime("+$i3 day",strtotime($hasil_tgl_bawah3));
      $hasil_tgl_hits = date('Y-m-d', $tgl_hits);
	  $sql_hits = $tablestatd->findStatd(hits, hitstoday, tanggal, $hasil_tgl_hits, tanggal);
	  if ($sql_hits==''){
		$sql_hits3='0';
	  }else{
		$sql_hits3=$sql_hits;
	  }
    }
    for ($i3=4; $i3 <= 4; $i3++){
      $tgl_hits = strtotime("+$i3 day",strtotime($hasil_tgl_bawah3));
      $hasil_tgl_hits = date('Y-m-d', $tgl_hits);
	  $sql_hits = $tablestatd->findStatd(hits, hitstoday, tanggal, $hasil_tgl_hits, tanggal);
	  if ($sql_hits==''){
		$sql_hits4='0';
	  }else{
		$sql_hits4=$sql_hits;
	  }
    }
    for ($i3=5; $i3 <= 5; $i3++){
      $tgl_hits = strtotime("+$i3 day",strtotime($hasil_tgl_bawah3));
      $hasil_tgl_hits = date('Y-m-d', $tgl_hits);
	  $sql_hits = $tablestatd->findStatd(hits, hitstoday, tanggal, $hasil_tgl_hits, tanggal);
	  if ($sql_hits==''){
		$sql_hits5='0';
	  }else{
		$sql_hits5=$sql_hits;
	  }
    }
    for ($i3=6; $i3 <= 6; $i3++){
      $tgl_hits = strtotime("+$i3 day",strtotime($hasil_tgl_bawah3));
      $hasil_tgl_hits = date('Y-m-d', $tgl_hits);
	  $sql_hits = $tablestatd->findStatd(hits, hitstoday, tanggal, $hasil_tgl_hits, tanggal);
	  if ($sql_hits==''){
		$sql_hits6='0';
	  }else{
		$sql_hits6=$sql_hits;
	  }
    }
?>

<script type="text/javascript">
$(document).ready(function () {
    if($("#main_chart").length > 0){

        /* CHART - 1*/       
                        
        var visitors = [[1, <?php echo $currentStat3; ?>], [2, <?php echo $currentStat4; ?>], [3, <?php echo $currentStat5; ?>], [4, <?php echo $currentStat6; ?>]];
        var hits = [[1, <?php echo $sql_hits3; ?>], [2, <?php echo $sql_hits4; ?>], [3, <?php echo $sql_hits5; ?>], [4, <?php echo $sql_hits6; ?>]];
        
        $.plot($("#main_chart"), [ { data: visitors, label: "visitors"}, { data: hits, label: "hits"} ], {
            
                series: {lines: { show: true }, points: { show: true }},
                grid: { hoverable: true, clickable: true },
                yaxis: { min: 1, max: 1000, tickLength: 0 },
                xaxis: { labelWidth: 7, tickLength: 0 }
                });

        /* eof CHART - 1*/
    
    }
});
</script>