Display customer name instead of short code
[infodrom.org/service.infodrom.org] / src / InfoCon / stempel / index.wml
index 8303c2a..cda1025 100644 (file)
   $table_row = '<tr class="t%d"><td>%s</td><td align="center">%s</td><td align="center">%s</td><td><a href="edit.php?id=%d">%s</a></td></tr>';
   $table_sum = '<tr class="t%d"><td>&nbsp;</td><td align="center"><strong>%s</strong></td><td>&nbsp;</td><td><strong>Summe</strong></td></tr>';
 
-  $query = "SELECT stempel.oid,start,customer,time,task,kurz FROM stempel JOIN stempel_status ON (stempel.status = stempel_status.id) WHERE time IS NOT NULL ";
+  $query = <<<EOS
+SELECT stempel.oid,start,stempel_customer.name AS customer,time,task,kurz
+FROM stempel
+JOIN stempel_customer ON (stempel.customer = stempel_customer.short)
+JOIN stempel_status ON (stempel.status = stempel_status.id)
+WHERE time IS NOT NULL
+EOS;
   if (isset($month) && $month !== 'all')
-    $query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
-  $query .= "ORDER BY customer,start";
+    $query .= " AND cast(start AS TEXT) LIKE '".$month."-%'";
+  $query .= " ORDER BY customer,start";
 
   $sth = pg_exec ($dbh, $query);
 
@@ -57,7 +63,7 @@
         echo($table_foot);
       }
       $cname = $name[$row['customer']];
-      if (!strlen($cname)) $cname = ucfirst($row['customer']);
+      if (!strlen($cname)) $cname = $row['customer'];
       printf($table_head, $cname);
       $customer = $row['customer'];
       $sum = 0;