From bdd5a2ba23a97d7bbf68822addb1dffc5696dd09 Mon Sep 17 00:00:00 2001
From: Venny Larasati <venny_la@yahoo.com>
Date: Tue, 17 May 2016 21:14:49 +0700
Subject: [PATCH] statistik workingtapi legendanya masih jelek

---
 P3/controller/statistik_controller.php | 21 +++++++++++----------
 P3/index.php                           |  3 ++-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/P3/controller/statistik_controller.php b/P3/controller/statistik_controller.php
index e7b85b4..cce7e04 100644
--- a/P3/controller/statistik_controller.php
+++ b/P3/controller/statistik_controller.php
@@ -9,20 +9,21 @@ function getStatistik(){
 	$i = 0;
 	// hitung per skpd
 	foreach ($skpd as $skpd){
-		$res[$i]['nama'] = $skpd['nama'];
-		$res[$i]['sum'] = 0;
-		$res[$i]['count'] = 0;
-		$res[$i]['avg'] = 0;
+		$sum = 0;
+		$count = 0;
+		$avg = 0;
 		foreach($penilaian as $n){
-			if (strcmp($skpd['nama'], $n['unit_kerja'])) {
-				$res[$i]['sum'] += $n['nilai'];
-				$res[$i]['count']++;
+			if (strcmp($skpd['nama'], $n['unit_kerja']) == 0) {
+				$res[$i]['nama'] = $skpd['nama'];
+				$sum += $n['nilai'];
+				$count++;
 			}
 		}
-		if ($res[$i]['count'] != 0) {
-			$res[$i]['avg'] = $res[$i]['sum']/$res[$i]['count'];
+		if ($count != 0) {
+			$avg = $sum/$count;
+			$res[$i]['avg'] = $avg;
 			$i++;
-		}			
+		}	
 	}
 
 	return $res;
diff --git a/P3/index.php b/P3/index.php
index 414b19d..bcfa217 100644
--- a/P3/index.php
+++ b/P3/index.php
@@ -93,10 +93,11 @@
               </div>
               <div class="panel-body no-padder">
                 <div class="wrapper20 inline full-width">
+                  Keterangan:
                   <?php
                     $skpd = getStatistik();
                     foreach ($skpd as $skpd){
-                      echo $skpd['nama'] . "<br/>";
+                      echo "<li>". $skpd['nama'] . "</li>";
                     }
                   ?>
                 </div>
-- 
GitLab