Add sort column to improve listing
[misc/hallinta-metro] / utils.php
index 2afa57b..8e53ad0 100644 (file)
--- a/utils.php
+++ b/utils.php
@@ -8,6 +8,16 @@ define('FAXNUMBER','2002-364');
 define('ERROR_SAFT','joey@finlandia');
 define('ERROR_MAIL','joey@finlandia.infodrom.org');
 
+function is_done($id)
+{
+  global $db;
+
+  $query = sprintf('SELECT count(*) AS count FROM metro_ordersatz WHERE id = %d AND done IS NULL', $id);
+  $sth = $db->query($query);
+  $row = $sth->fetch();
+  return $row['count'] == 0;
+}
+
 function mk_tempdir()
 {
   $tmpdir = sprintf("%sarchive/%s/%s",
@@ -149,7 +159,7 @@ function ordersatz_write($id, $dir, $send)
                 "JOIN metro_abteilung ON abteilung = metro_abteilung.id " .
                 "JOIN metro_vpe ON vpe = metro_vpe.id " .
                 "WHERE ordersatz = %d AND anzahl IS NOT NULL " .
-                "ORDER BY gang,metro_abteilung.name,bezeichnung",
+                "ORDER BY sort,gang,metro_abteilung.name,bezeichnung",
                 $id);
 
   $result = query_db($sql);