<?php
 
if(isset($_GET['clientid'])):

$parent = $_GET['clientid'];

?>

<div id = "client-review">
<h2>Klijenti</h2>

	<p><ul>
    
 <?php 
				
				$database->setBareQuery("SELECT id, name FROM client ORDER BY name");

				$clientid = $database->loadResultArray(0);
		
				$clientname = $database->loadResultArray(1);
		
				for($i = 0; $i < count($clientid); $i++): 
			
			?> 
            
            <li><a href="index.php?page=review&clientid=<?=$clientid[$i]?>"><?=$clientname[$i]?></a></li>
            
            <?php endfor; ?>
    </ul></p>
</div>

<div id = "project-review">
<h2>Projekti</h2>

	<p><ul>
    
 <?php 
				
				$database->setBareQuery("SELECT id, name FROM project WHERE parent = '$parent' ORDER BY name");

				$projid = $database->loadResultArray(0);
		
				$projname = $database->loadResultArray(1);
				
				if(count($projid) == 0):
				
				echo 'Klijentu još nisu dodeljeni projekti';
				
				else:
		
				for($i = 0; $i < count($projid); $i++): 
			
			?> 
            
            <li><?=$projname[$i]?></a></li>
            
            <?php endfor; endif; ?>
    </ul></p>
</div>

<div class="clear"></div>


<?php 

else:

?>
<h2>Klijenti</h2>

	<p><ul>
    
 <?php 
				
				$database->setBareQuery("SELECT id, name FROM client ORDER BY name");

				$clientid = $database->loadResultArray(0);
		
				$clientname = $database->loadResultArray(1);
		
				for($i = 0; $i < count($clientid); $i++): 
			
			?> 
            
            <li><a href="index.php?page=review&clientid=<?=$clientid[$i]?>"><?=$clientname[$i]?></a></li>
            
            <?php endfor; ?>
    </ul></p>
    
    <?php endif; ?>
    
