Ranking
diff --git a/bin/images/first.png b/bin/images/first.png
new file mode 100644
index 0000000..274937c
--- /dev/null
+++ b/bin/images/first.png
Binary files differ
diff --git a/bin/images/second.png b/bin/images/second.png
new file mode 100644
index 0000000..3d6ab84
--- /dev/null
+++ b/bin/images/second.png
Binary files differ
diff --git a/bin/images/third.png b/bin/images/third.png
new file mode 100644
index 0000000..394527c
--- /dev/null
+++ b/bin/images/third.png
Binary files differ
diff --git a/css/basic.css b/css/basic.css
index 88dfeb2..80e2345 100644
--- a/css/basic.css
+++ b/css/basic.css
@@ -5,7 +5,7 @@
}
* {
- font-family: Georgia, serif;
+ font-family: 'Open Sans';
}
#outter-container {
@@ -17,6 +17,7 @@
#inner-container {
background-color: rgba(255,255,255, 0.8);
padding: 5%;
+
}
input[type="text"], input[type="password"], select {
diff --git a/css/ranking.css b/css/ranking.css
new file mode 100644
index 0000000..122613a
--- /dev/null
+++ b/css/ranking.css
@@ -0,0 +1,63 @@
+#inner-container {
+ background-color: white;
+}
+
+p {
+ font-size: 16px;
+ text-align: justify;
+}
+
+table#ranking {
+ font-size: 18px;
+ text-align: center;
+
+ font-family: 'Open Sans';
+
+ margin: auto;
+ width: 100%;
+}
+
+table#ranking td {
+ padding: 10px;
+}
+
+tr.gold {
+ background-color: rgba(255, 225, 0, 0.3);
+}
+
+tr.silver {
+ background-color: rgba(200, 200, 200, 0.3);
+}
+
+tr.bronze {
+ background-color: rgba(200, 125, 50, 0.3);
+}
+
+tr.me {
+ background-color: rgba(50, 50, 255, 0.3);
+}
+
+tr.top3 td:first-child::before {
+ content: '';
+ background-size: 16px 16px;
+ width: 16px;
+ height: 16px;
+ float: left;
+ position: relative;
+ top: 0px;
+ left: 5px;
+}
+
+tr.gold td:first-child::before {
+ background-image: url('../bin/images/first.png');
+}
+
+
+tr.silver td:first-child::before {
+ background-image: url('../bin/images/second.png');
+}
+
+
+tr.bronze td:first-child::before {
+ background-image: url('../bin/images/third.png');
+}
diff --git a/css/ranking.php b/css/ranking.php
new file mode 100644
index 0000000..43dc484
--- /dev/null
+++ b/css/ranking.php
@@ -0,0 +1,3 @@
+.gold {
+ background-color: gold;
+}
diff --git a/index.php b/index.php
index 766b46a..c440472 100644
--- a/index.php
+++ b/index.php
@@ -37,7 +37,7 @@
<svg height="24px" viewBox="0 0 24 24" width="24px" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg>
</span>
<div class="md-google-search__field-container">
- <input id="search-input" class="md-google-search__field" required autocomplete="off" placeholder="Introdueix usuari..." value="" name="search" type="text" spellcheck="false" style="outline: none;">
+ <input id="search-input" class="md-google-search__field" required autocomplete="off" placeholder="Introdueix el teu nom..." value="" name="search" type="text" spellcheck="false" style="outline: none;">
</div>
<span class="md-google-search__empty-btn" style="display: none;">
<svg focusable="false" height="24px" viewBox="0 0 24 24" width="24px" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg>
diff --git a/ranking.php b/ranking.php
new file mode 100644
index 0000000..ff17962
--- /dev/null
+++ b/ranking.php
@@ -0,0 +1,73 @@
+<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
+ <link rel="stylesheet" href="./css/basic.css" />
+ <link rel="stylesheet" href="./css/ranking.css" />
+</head>
+
+<body>
+
+<?php
+ require './credentials.php';
+ require './php/utils.php';
+
+ // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi";
+ // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills, sum(CASE WHEN morts.grau = users.grau THEN 1 ELSE 2 END) AS kills_pondered FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY kills_pondered DESC";
+ // Mateix grau i curs => 1, Mateix grau diferent curs => 2, Diferent grau => 3
+ // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills, sum(CASE WHEN morts.grau = users.grau AND morts.curs = users.curs THEN 1 WHEN morts.grau = users.grau AND morts.curs != users.curs THEN 2 ELSE 3 END) AS kills_pondered FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY kills_pondered DESC";
+
+ // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200
+ $getranking = "SELECT morts.assassi AS id, users.nom, users.grau, users.curs, count(morts.assassi) AS kills,
+ sum(morts.grau = users.grau AND morts.curs = users.curs) AS companys_classe,
+ sum(morts.grau = users.grau AND morts.curs != users.curs) AS companys_grau,
+ sum(morts.grau != users.grau) AS companys_facu,
+ sum(CASE WHEN morts.grau = users.grau AND morts.curs = users.curs THEN 100 WHEN morts.grau = users.grau AND morts.curs != users.curs THEN 150 ELSE 200 END) AS score
+ FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY score DESC";
+
+ $results = query($getranking);
+?>
+
+<div id="outter-container">
+ <div id="inner-container">
+ <h1>Rànquing</h1>
+ <p>La puntuació de cada jugador es calcula com a una suma ponderada entre companys de classe (mateix curs, mateix grau), companys de grau (mateix grau) i companys de facultat (diferents grau). Amb puntuacions +100, +150 i +200; respectivament.</p>
+
+ <table id="ranking" cellspacing="0" cellpadding="0">
+ <tr id="header">
+ <th></th>
+ <th>Nom</th>
+ <th>Classe</th>
+ <th>Grau</th>
+ <th>Facu</th>
+ <th>Total</th>
+ <th>Punts</th>
+ </tr>
+ <?php
+ $id = 43;
+ $i = 1;
+
+ while ($row = $results->fetch_object()) {
+ if ($i == 1) echo "<tr class='gold top3'>";
+ else if ($i == 2) echo "<tr class='silver top3'>";
+ else if ($i == 3) echo "<tr class='bronze top3'>";
+ else if ($row->id == $id) echo "<tr class='me'>";
+ else echo "<tr>";
+
+ echo "<td>". ($i > 3 ? $i : '') ."</td>";
+ echo "<td>$row->nom</td>";
+ echo "<td>$row->companys_classe</td>";
+ echo "<td>$row->companys_grau</td>";
+ echo "<td>$row->companys_facu</td>";
+ echo "<td>$row->kills</td>";
+ echo "<td>$row->score</td>";
+ echo "</tr>";
+
+ $i = $i + 1;
+ }
+ ?>
+ </table>
+ </div>
+</div>
+
+</body>
+</html>