Add forgotton library
authorJoey Schulze <joey@infodrom.org>
Sun, 7 Mar 2010 15:47:20 +0000 (16:47 +0100)
committerJoey Schulze <joey@infodrom.org>
Sun, 7 Mar 2010 15:47:20 +0000 (16:47 +0100)
lib/overview_utils.php [new file with mode: 0644]

diff --git a/lib/overview_utils.php b/lib/overview_utils.php
new file mode 100644 (file)
index 0000000..6b6a6a3
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+$jscode[] = <<<EOC
+
+function select_year_calback(data)
+{
+  grid_update(grid);
+  grid_update_filters(grid);
+}
+
+function select_year_status(obj, value, html)
+{
+  if (value.length)
+    info('Jahr ' + value + ' ausgewählt');
+  else
+    info('');
+}
+EOC;
+
+function discover_years()
+{
+  if (!is_array($_SESSION['years'])) {
+    $sql = "SELECT DISTINCT date_part('year', datum) AS year FROM einsatz ORDER BY year";
+    $info = query_db($sql);
+    $_SESSION['years'] = array();
+    foreach ($info as $row)
+      $_SESSION['years'][] = $row['year'];
+  }
+
+  $options = array();
+  foreach ($_SESSION['years'] as $year)
+    $options[] = array('id' => $year,
+                      'text' => $year);
+
+  return $options;
+}
+
+?>
\ No newline at end of file