function display_tables()
{
global $month;
+ global $cust;
global $status;
global $dbh;
global $stati;
$table_sum = '<tr class="t%d"><td> </td><td align="center">%s</td><td> </td><td>Summe</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 ";
- if (isset($month) && $month !== 'all')
+ if (isset($month) && strlen($month))
$query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
+ if (isset($cust) && strlen($cust))
+ $query .= "AND customer ='".$cust."' ";
+ // xxxxxxxxxxx
+
if (isset($status)) {
if ($status != 'all')
$query .= "AND status = $status ";
}
}
+ function find_customers()
+ {
+ global $dbh;
+
+ $a = array();
+ $query = "SELECT DISTINCT customer FROM stempel ORDER BY customer";
+ $sth = pg_exec ($dbh, $query);
+
+ while ($row = pg_fetch_array ($sth))
+ $a[] = $row[0];
+
+ return $a;
+ }
+
$dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
or die("Unable to connect to SQL server");
else
if (isset($_POST["filter"])) {
$month = $_POST["month"];
+ $cust = $_POST["customer"];
$status = $_POST["status"];
} else
$month = date('Y-m');
if (!is_array($months))
$months = find_months();
- printf('<option value="all"%s>alle</option>', $_POST['month']=='alle'?' selected':'');
+ printf('<option value=""%s>alle</option>', !strlen($_POST['month'])?' selected':'');
foreach ($months as $m) {
printf('<option value="%s"%s>%s</option>', $m, $_POST['month']==$m?' selected':'', $m);
}
?>
</select>
+<select name=customer>
+<?
+ if (!is_array($customers))
+ $customers = find_customers();
+
+ printf('<option value=""%s>alle</option>', !strlen($_POST['month'])?' selected':'');
+ foreach ($customers as $c) {
+ printf('<option value="%s"%s>%s</option>', $c, $_POST['customer']==$c?' selected':'', $c);
+ }
+?>
+</select>
+
<?
if (!is_array($stati))
$stati = find_status();