Added summaries and privilege to view them.
authorLadislav Láska <laska@kam.mff.cuni.cz>
Tue, 26 Apr 2011 07:46:01 +0000 (09:46 +0200)
committerLadislav Láska <laska@kam.mff.cuni.cz>
Tue, 26 Apr 2011 07:46:01 +0000 (09:46 +0200)
classes/auth.php
controllers/summary_bikeroom.php [new file with mode: 0644]
controllers/summary_bikerooms.php [new file with mode: 0644]
controllers/summary_owners.php [new file with mode: 0644]
template/summaries.css [new file with mode: 0644]
template/summaries.php [new file with mode: 0644]
template/summary_bikeroom.inc [new file with mode: 0644]
template/summary_bikerooms.inc [new file with mode: 0644]
template/summary_owners.inc [new file with mode: 0644]

index 6fd0c433f35a53f242450c8db78b6f8ddf10e846..417e4e680ce9401f66d1c90db39aad91ed9f5f79 100644 (file)
@@ -7,6 +7,7 @@ define("P_USERMOD", 2);
 define("P_ADMIN", 2);
 define("P_GROUNDSMAN", 1);
 define("P_BIKEMOD", 1);
+define("P_SUMMARIES", 2);
 
 class User {
        private $data = array('login' => 'Anonymous', 'privileges' => -1, 'id' => -1);
diff --git a/controllers/summary_bikeroom.php b/controllers/summary_bikeroom.php
new file mode 100644 (file)
index 0000000..5b72566
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+       if (!$auth->verify(P_SUMMARIES)) redir(403);
+
+       $bikeroom = new Bikeroom($_GET['name']);
+
+       $datamine = Bike::listAll('bikeroom', $bikeroom);
+       include "template/summary_bikeroom.inc";
+?>
diff --git a/controllers/summary_bikerooms.php b/controllers/summary_bikerooms.php
new file mode 100644 (file)
index 0000000..495c9d8
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+       if (!$auth->verify(P_SUMMARIES)) redir(403);
+
+       $b = Bikeroom::listAll();
+       $datamine = $b;
+       include "template/summary_bikerooms.inc";
+?>
diff --git a/controllers/summary_owners.php b/controllers/summary_owners.php
new file mode 100644 (file)
index 0000000..0e68241
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+       if (!$auth->verify(P_SUMMARIES)) redir(403);
+
+       $datamine = Bike::listAll('ordered');
+       include "template/summary_owners.inc";
+?>
diff --git a/template/summaries.css b/template/summaries.css
new file mode 100644 (file)
index 0000000..56a2356
--- /dev/null
@@ -0,0 +1,11 @@
+table.summaries, table.summaries tr, table.summaries tr td, table.summaries tr th {
+    border-collapse: collapse;
+    border: 1px solid grey;
+}
+
+table.summaries tr td, table.summaries tr th {
+    padding: 2px 0.5em 2px 0.5em;
+}
+
+table.summaries td.full { color: red; }
+table.summaries td.free { color: green; }
diff --git a/template/summaries.php b/template/summaries.php
new file mode 100644 (file)
index 0000000..8e4c73f
--- /dev/null
@@ -0,0 +1,14 @@
+<h1><?=tr("Sestavy");?></h1>
+<p><?=tr("Na této stráce najdete výstupní sestavy ze systému. Nejsou určtené k editaci, k tomu prosím použijte konkrétní moduly systému.");?></p>
+<ul>
+       <li><?=href("summary_bikerooms", tr("Kolárny, jejich správci a obsazenost"))?></li>
+       <li><?=href("summary_owners", tr("Majitelé kol, kola"))?></li>
+       <li><?=tr("List kolárny:")?>
+       <?php
+               $d = "";
+               foreach (Bikeroom::listAll() as $b) {
+                       echo $d.href("summary_bikeroom&name=$b->name", $b->name);
+                       $d = ", ";
+               }?>
+       </li>
+</ul>
diff --git a/template/summary_bikeroom.inc b/template/summary_bikeroom.inc
new file mode 100644 (file)
index 0000000..61b40b9
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+       $props = array("userName" => tr("Majitel"), "description" => tr("Popis kola"));
+?>
+<h1><?=tr("List kolárny").' '.$bikeroom->name?></h1>
+<table class="summaries">
+<tr>
+<?php
+       foreach ($props as $key => $value) {
+               echo "<th>$value</th>";
+       }
+?>
+</tr>
+<?php
+       foreach ($datamine as $b) {
+               echo "<tr>\n";
+               foreach ($props as $prop => $name) 
+                       echo "<td>".$b->$prop."</td>";
+               echo "<tr>\n";
+       }
+?>
+</table>
diff --git a/template/summary_bikerooms.inc b/template/summary_bikerooms.inc
new file mode 100644 (file)
index 0000000..be102cf
--- /dev/null
@@ -0,0 +1,15 @@
+<h1><?=tr("Kolárny, jejich správci a obsazenost")?></h1>
+<table class="summaries">
+<tr><th><?=tr("Kolárna")?></th><th><?=tr("Správce")?></th><th><?=tr("Volno/Kapacita")?></th></tr>
+<?php
+       foreach ($datamine as $b) {
+?>
+       <tr>
+               <td><?=$b->name?></td>
+               <td><?=$b->groundsmanName?></td>
+               <td class="<?=($b->freeSpace > 0) ? "free" : "full" ?>"><?=$b->freeSpace?>/<?=$b->space?></td>
+       </tr>
+<?php
+       }
+?>
+</table>
diff --git a/template/summary_owners.inc b/template/summary_owners.inc
new file mode 100644 (file)
index 0000000..d7e4ce3
--- /dev/null
@@ -0,0 +1,21 @@
+<h1><?=tr("Majitelé kol, kola")?></h1>
+<?php
+       $props = array("userName" => tr("Majitel"), "description" => tr("Popis kola"), "bikeroomName" => tr("Kolárna"));
+?>
+<table class="summaries">
+<tr>
+<?php
+       foreach ($props as $key => $value) {
+               echo "<th>$value</th>";
+       }
+?>
+</tr>
+<?php
+       foreach ($datamine as $b) {
+               echo "<tr>\n";
+               foreach ($props as $prop => $name) 
+                       echo "<td>".$b->$prop."</td>";
+               echo "<tr>\n";
+       }
+?>
+</table>