<?php 
	
	if($this->uri->segment('1')=='superadmin') 
		$link = 'superadmin';
	else		
		$link = 'admin';
	
	switch($type)
					{
					    case 1: {
					    			// "Dzienne"; 
										$year = date("Y");
										$month = date("m");
										$day = date("d");
										
										if($this->uri->segment(5) != null)
										{
											$year = $this->uri->segment(5);
										}
										
										if($this->uri->segment(6) != null)
										{
											$month = $this->uri->segment(6);
										}
										if($this->uri->segment(7) != null)
										{
											$day = $this->uri->segment(7);
										}
											
										for($i=1;$i<32;$i++)
										{
											$j=$i;
											if($i<10) $j='0'.$i;
											$data[$i] = '/'.$link.'/show_domain_statcounter/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$j.'';
										}
										
										echo $this->calendar->generate($year, $month,$data);
										
										echo br(2);
									   ///echo '<img src="/charts/chart_stat/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$day.'" />';
									   	echo '<div id="my_chart1">charts/flash_chart_stat/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$day.'</div><br/>';
										//echo '<img src="/charts/chart_stat_uniq/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$day.'" />';
										echo '<div id="my_chart2">charts/flash_chart_stat_uniq/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$day.'</div><br/>';
										echo br();
										//echo '<img src="/charts/chart_stat_returning/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$day.'" />';
										echo '<div id="my_chart3">charts/flash_chart_stat_returning/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$day.'</div>';
										
									
									break;
								}
					    case 2: {
					    			// "Tygodniowe"; 
																	
									if(@$_POST['year']!=null)
									{
										$this->session->set_userdata('rok', $_POST['year']);
										$rok = $this->session->userdata['rok'];
									}
									else 
									{
										if (!isset($this->session->userdata['rok']))
										{
											$actual_year = date("Y");
											$this->session->set_userdata('rok', $actual_year);
											$rok = $this->session->userdata['rok'];
										} $rok = $this->session->userdata['rok'];
									}
								 	
									echo '<b>ustaw rok</b><br />';
									echo '<form action="/'.$link.'/show_domain_statcounter/'.$domain_id.'/2" method="post">';
									echo '<table cellspacing="6">';
									echo '<tr><td>';
									echo '<select name="year">';
										  $cur_year = date("Y");
										  $roz = $cur_year - 2007;
										  for($i=$roz; $i>=0;$i--)
										  {								  	
											echo '<option value="'.$cur_year.'"'; 
											if ($rok==$cur_year) echo 'selected="selected"'; 
											echo '>'.$cur_year.'</option>';
											$cur_year--;
										  } 
									echo '</select>';
									echo '</td><td>';
									echo '<input type="submit" value="wybierz" />';
									echo '</td></tr></table>';	 
									echo '</form>';
									echo 'wybierz tydzień z roku: <b>'.$rok.'</b>';
									echo br();
									
									if($this->uri->segment(5) != null)
									{
										$week = $this->uri->segment(5);
									}else  $week = date("W",time()); 
																			 				
									$weeks_in_year = strftime("%W",strtotime("12/31/".$rok));
				
									for($i=1;$i<=$weeks_in_year;$i++)
									{
										echo '<a href="/'.$link.'/show_domain_statcounter/'.$domain_id.'/2/'.$i.'/'.$rok.'"/>'.$i.'</a>&nbsp;';
										if($i==round(($weeks_in_year/2))) echo '<br />';
									}
									
									echo br(2);
									    //echo '<img src="/charts/chart_stat_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'" />';
										echo '<div id="my_chart1">charts/flash_chart_stat_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'</div><br/>';
										//echo '<img src="/charts/chart_stat_uniq_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'" />';
										echo '<div id="my_chart2">charts/flash_chart_stat_uniq_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'</div><br/>';
										echo br();
										//echo '<img src="/charts/chart_stat_returning_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'" />';
										echo '<div id="my_chart3">charts/flash_chart_stat_returning_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'</div>';
										
										
												//echo '<img src="/charts/chart_stat_all_returning_weekly/'.$domain_id.'/2/'.$week.'/'.$rok.'" />';
									break;
								}
					    case 3: {
					    			// "Miesieczne";
									if(@$_POST['year']!=null)
									{
										$this->session->set_userdata('rok', $_POST['year']);
										$rok = $this->session->userdata['rok'];
									}
									else 
									{
										if (!isset($this->session->userdata['rok']))
										{
											$actual_year = date("Y");
											$this->session->set_userdata('rok', $actual_year);
											$rok = $this->session->userdata['rok'];
										} $rok = $this->session->userdata['rok'];
									}
									
									echo '<b>ustaw rok</b><br />';
									echo '<form action="/'.$link.'/show_domain_statcounter/'.$domain_id.'/3" method="post">';
									echo '<table cellspacing="6">';
									echo '<tr><td>';									
									echo '<select name="year">';
											$cur_year = date("Y");
											  $roz = $cur_year - 2007;
											  for($i=$roz; $i>=0;$i--)
											  {								  	
												echo '<option value="'.$cur_year.'"'; 
												if ($rok==$cur_year) echo 'selected="selected"'; 
												echo '>'.$cur_year.'</option>';
												$cur_year--;
											  } 
									echo '</select>';
									echo '</td><td>';										 
									echo '<input type="submit" value="wybierz" />';	 
									echo '</td></tr></table>';	 
									echo '</form>';									
									echo '</form>';
									echo 'wybierz miesiąc: ';
									echo br();
									
									$months = array('styczeń','luty','marzec','kwiecień','maj','czerwiec','lipiec','sierpień','wrzesień','październik','listopad','grudzień');
									//date('F',mktime(0,0,0,$i))
									//echo '<select id="month" name="month">';
    								for ($i = 1; $i <= 12; $i++)
									{
      									echo '<a href="/'.$link.'/show_domain_statcounter/'.$domain_id.'/3/';
										if ($i<10) echo '0';
										echo $i.'/'.$rok.'"/>'.$months[$i-1].'</a>&nbsp;';
									//echo '</select>';
									}
									
									if($this->uri->segment(5) != null)
									{
										$week = $this->uri->segment(5);
									}else  $week = date("m",time()); 
																			 				
									//$weeks_in_year = strftime("%W",strtotime("12/31/".$rok));
									
									echo br(2);
								    //echo '<img src="/charts/chart_stat_monthly/'.$domain_id.'/3/'.$week.'/'.$rok.'" />';
									echo '<div id="my_chart1">charts/flash_chart_stat_monthly/'.$domain_id.'/3/'.$week.'/'.$rok.'</div><br/>';
									//echo '<img src="/charts/chart_stat_monthly_uniq/'.$domain_id.'/3/'.$week.'/'.$rok.'" />';
									echo '<div id="my_chart2">charts/flash_chart_stat_monthly_uniq/'.$domain_id.'/3/'.$week.'/'.$rok.'</div>';
									echo br();
									break;
								}
					    case 4: {
					    			// "Roczne";
									
									$rok = date("Y");
									
									
									echo br(2);
								    //echo '<img src="/charts/chart_stat_yearly/'.$domain_id.'/4/'.$rok.'" />';
									echo '<div id="my_chart1">charts/flash_chart_stat_yearly/'.$domain_id.'/4/'.$rok.'</div><br/>';
									//echo '<img src="/charts/chart_stat_yearly_uniq/'.$domain_id.'/4/'.$rok.'" />';
									echo '<div id="my_chart2">charts/flash_chart_stat_yearly_uniq/'.$domain_id.'/4/'.$rok.'</div><br/>';
									echo br();
									break;
								}
					}
	
	
	 
