Wybierz okres za który chcesz zobaczyć swój zysk<br /><br />
<div id="rightBox_content"> 							
	<div class="mediumButton"><a class="gray_link" href="/afiliant/profit_from_clients/1">tygodniowe</a></div> 
	<div class="mediumButton"><a class="gray_link" href="/afiliant/profit_from_clients/2">miesięczne</a></div> 
	<div class="mediumButton"><a class="gray_link" href="/afiliant/profit_from_clients/3">roczne</a></div>  	
</div> 
<br /><br /> 

<?php

include_once('files/functions.php');
 		
	$link = 'afiliant';
	
	switch($type)
			{			    
			    case 1: {
			    			// "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.'/profit_from_clients/1" 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(4) != null)
							{
								$week = $this->uri->segment(4);
							}else  $week = date("W",time()); 
																	 				
							$weeks_in_year = strftime("%W",strtotime("12/31/".$rok));							
		
							for($i=1;$i<=$weeks_in_year;$i++)
							{
								$daty  = WeekToDate($i,$rok);
								echo '<a href="/'.$link.'/profit_from_clients/1/'.$i.'/'.$rok.'"/ title="'.$daty['r-m-d']['start'].' | '.$daty['r-m-d']['end'].'">'.$i.'</a>&nbsp;';
								if($i==round(($weeks_in_year/2))) echo '<br />';
							}
							
							echo '<br /><br /><br />';
							
							//print_r($clients);
							if(!empty($clients))
							{
								$domains = array();							
								
								foreach($clients as $c)
								{
									if(!in_array($c['domain'],$domains))
										$domains[] = $c['domain'];								 
								}
								
								foreach($domains as $d)
								{
									echo '<b>'.$d.':</b> ';
									echo '<div style="margin-left:80px;">';
									
									foreach($clients as $c)
									{
										//print_r($c);										
										if($d == $c['domain'])
										{
											echo '<br />- '.$c['keyword'].': '.round(($c['price']*$prowizja),2).' zł';
										}																		 
									}
									echo '</div>';
									echo '<br /><br />';	
								}
							}
							else
							{
								echo 'Brak dochodu w wybranym tygodniu';
							}
																																											
							break;
						}
			    case 2: {
			    			// "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.'/profit_from_clients/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 miesiąc: ';
							echo br(2);
							
							$months = array('styczeń','luty','marzec','kwiecień','maj','czerwiec','lipiec','sierpień','wrzesień','październik','listopad','grudzień');
							
							for ($i = 1; $i <= 12; $i++)
							{
									echo '<a href="/'.$link.'/profit_from_clients/2/';
								if ($i<10) echo '0';
								echo $i.'/'.$rok.'">'.$months[$i-1].'</a>&nbsp; &nbsp;';
							}
							
							echo '<br /><br /><br />';
														
							if(!empty($clients))
							{
								//print_r($clients);
								$domains = array();
																							
								foreach($clients as $c)
								{
									if(!in_array($c['domain'],$domains))
										$domains[] = $c['domain'];								 
								}
								
								foreach($domains as $d)
								{
									echo '<b>'.$d.':</b> ';
									echo '<div style="margin-left:80px;">';									
									
									foreach($clients as $c)
									{										
										//print_r($c);										
										if($d == $c['domain'])
										{
											echo '<br />- '.$c['keyword'].': '.round(($c['price']*$prowizja),2).' zł';																					
										}																																																 
									}									
																	
									echo '</div>';
									echo '<br /><br />';										
								}
							}
							else
							{
								echo 'Brak dochodu w wybranym miesiącu';
							}
							 
																	 				
							
							break;
						}
			    case 3: {
			    			// "Roczne";
							
							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.'/profit_from_clients/3/'.$rok.'" method="post">';
							echo '<table cellspacing="6">';
							echo '<tr><td>';									
								  $cur_year = date("Y");
								  $year = 2007;								  
								  for($i=$year; $i<=$cur_year;$i++)
								  {								  	
									echo '<a href="/'.$link.'/profit_from_clients/3/1/'.$year.'">'.$year.'</a>&nbsp; &nbsp;';									
									$year++;
								  } 							
							echo '</td><td>';										 
							echo '</td></tr></table>';	 
							echo '</form>';					
							
							echo '<br /><br /><br />';
														
							if(!empty($clients))
							{
								$domains = array();							
								
								foreach($clients as $c)
								{
									if(!in_array($c['domain'],$domains))
										$domains[] = $c['domain'];								 
								}
								
								foreach($domains as $d)
								{
									echo '<b>'.$d.':</b> ';
									echo '<div style="margin-left:80px;">';
									
									foreach($clients as $c)
									{
										//print_r($c);										
										if($d == $c['domain'])
										{
											echo '<br />- '.$c['keyword'].': '.round(($c['price']*$prowizja),2).' zł';
										}																		 
									}
									echo '</div>';
									echo '<br /><br />';	
								}
							}
							else
							{
								echo 'Brak dochodu w wybranym roku';
							}
							
							
							break;
						}
			}
	?>