<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$bazowy = base_url();
$achowaj = 'SELECT u.username, u.email, u.first_name, u.last_name, zo.kompleksowosc, zo.zgodnosc, zo.atmosfera, zo.opiekun, zo.ocena_zadan FROM `zadania_oceny` zo 
LEFT JOIN staze_pracodawcy sp ON zo.id_staze = sp.id_staze
LEFT JOIN users u ON sp.id_users = u.id';

$zachowaj2 = 'SELECT u.username, u.email, u.first_name, u.company,  u.last_name, sum(zo.kompleksowosc) as sum_k, sum(zo.zgodnosc) as sum_z, sum(zo.atmosfera) as sum_a, sum(zo.opiekun) as sum_o, 
sum(zo.ocena_zadan) as sum_oz FROM `zadania_oceny` zo LEFT JOIN staze_pracodawcy sp ON zo.id_staze = sp.id_staze LEFT JOIN users u ON sp.id_users = u.id GROUP BY u.username ASC ORDER BY sum_k DESC';

?>

<?php if($komunikat): ?>
	<div class="container-fluid" id="komunikat">
		<div class="container">
			<div class="alert alert-<?= $komunikatTyp ?>">
				<p><?= $komunikatTresc ?></p>
			</div>
		</div>
	</div>
<?php endif; ?>

<div class="container-fluid" id="lista-zawodow">
	<div class="container minHeight">
        
		<div class="row">
            <h1 class="upper text-center section-title dash-both">Ranking Pracodawców</h1>
            <p><span class="wybierzZawod pointer"><strong></strong></span></p>
            <div class="col-sm-12 text-center">
                <div class="row pad20">              

                </div>              
            </div>        
        </div>


       
        
        

        
        <?php if(!empty($rankingPracodawcow) ): ?>
        <h1>Pracodawcy:</h1>
        <table class="table table-striped">
             <thead>
                <tr>
                    <th class="col-md-1">L.p.</th>
                    <th class="col-md-2">Imię i nazwisko</th>
                    <th class="col-md-2">Nazwa firmy</th>
                    <th class="col-md-1 text-center">Kompleksowość stażu <br /><a href="<?php echo $bazowy; ?>/Student/RankingPracodawcow/sum_k">Sortuj</a> </th>                  
                    <th class="col-md-1 text-center">Zgodność z harmonogramem <br /><a href="<?php echo $bazowy; ?>/Student/RankingPracodawcow/sum_z">Sortuj</a></th>
                    <th class="col-md-1 text-center">Atmosfera na stażu <br /><a href="<?php echo $bazowy; ?>/Student/RankingPracodawcow/sum_a">Sortuj</a></th>
                    <th class="col-md-1 text-center">opiekun stażu <br /><a href="<?php echo $bazowy; ?>/Student/RankingPracodawcow/sum_o">Sortuj</a></th>
                    <th class="col-md-1 text-center">Ocena zadań zawodowych <br /><a href="<?php echo $bazowy; ?>/Student/RankingPracodawcow/sum_oz">Sortuj</a></th>
                    <!--<th class="col-md-1 text-center">Łącznie</th>-->
                </tr>
              </thead>
              <tbody>
       <?php 
            $licz = 0;      
            foreach($rankingPracodawcow as $dane_show){
            $policz_sume = round($dane_show['sum_k']+$dane_show['sum_z']+$dane_show['sum_a']+$dane_show['sum_o']+$dane_show['sum_oz'],2);
            $licz++;
                $sum_k = round($dane_show['sum_k'],2);
                $sum_z = round($dane_show['sum_z'],2);
                $sum_a = round($dane_show['sum_a'],2);
                $sum_o = round($dane_show['sum_o'],2);
                $sum_oz = round($dane_show['sum_oz'],2);
            echo '
            <tr>
                <td scope="col">'.$licz.'</td>
                <td scope="col">'.$dane_show['first_name'].' '.$dane_show['last_name'].' ('.$dane_show['username'].')</td>
                <td scope="col">'.$dane_show['company'].'</td>
                <td scope="col" class="text-center">'.$sum_k.'</td>
                <td scope="col" class="text-center">'.$sum_z.'</td>
                <td scope="col" class="text-center">'.$sum_a.'</td>
                <td scope="col" class="text-center">'.$sum_o.'</td>
                <td scope="col" class="text-center">'.$sum_oz.'</td>
                <!--<td scope="col" class="text-center">'.$policz_sume.'</td>-->
                
            </tr>';
        }
        
        ?>
            </tbody>
        </table>
        <?php endif; ?>
   

	</div>
</div>
