X-Git-Url: https://git.infodrom.org/?p=misc%2Fhallinta-metro;a=blobdiff_plain;f=utils.php;h=5e58c4ba9345baaec70316c393e7c0ee0a4bf8c5;hp=1784accfd6428c4b85dfdca4e984bd3c74957d31;hb=07190e42214ce94e8fc1a45f4f666a49d0b36983;hpb=6b01bd18e6cb07451e429367eeb1fced70b1eb2e diff --git a/utils.php b/utils.php index 1784acc..5e58c4b 100644 --- a/utils.php +++ b/utils.php @@ -132,6 +132,8 @@ function ordersatz_write($id, $dir, $send) { global $db; + $weekdays = array('Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'); + $fname = sprintf("%smasks/%s/%s", $_SESSION['sys']['basedir'], MODULE, @@ -154,7 +156,8 @@ function ordersatz_write($id, $dir, $send) fwrite($f, sprintf('\newcommand{\uhrzeit}{%s}'."\n", latex_encode($satz[0]['uhrzeit']))); $d = explode('-', $satz[0]['datum']); - fwrite($f, sprintf('\newcommand{\datum}{%d.%d.%d}'."\n", $d[2], $d[1], $d[0])); + $time = mktime(10,0,0,$d[1], $d[2], $d[0]); + fwrite($f, sprintf('\newcommand{\datum}{%s, %d.%d.%d}'."\n", $weekdays[date('w', $time)], $d[2], $d[1], $d[0])); fclose($f); $sql = sprintf("SELECT artnr,gang,metro_vpe.short AS vpname,menge,bezeichnung,hinweis,hersteller,anzahl " . @@ -163,7 +166,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 sort,gang,metro_abteilung.name,bezeichnung", + "ORDER BY sort,gang,menge,bezeichnung", $id); $result = query_db($sql); @@ -173,17 +176,22 @@ function ordersatz_write($id, $dir, $send) $f = fopen(FNAME_ITEMS, 'w'); - foreach ($result as $row) { + $i = -1; + while (++$i < count($result)) { + $row = $result[$i]; + $bez = latex_encode($row['bezeichnung']); + if (strlen($row['menge'])) + $bez = latex_encode($row['menge']) . ' ' . $bez; if (strlen($row['hersteller'])) $bez .= ' (' . latex_encode($row['hersteller']) . ')'; if (strlen($row['hinweis'])) $bez .= sprintf("\\newline\\textbf{%s}", latex_encode($row['hinweis'])); - fwrite($f, sprintf('\order{%d}{%s}{%s %s}{%s}{%s}'."\n", + fwrite($f, sprintf('\order%s{%d}{%s}{%s}{%s}{%s}'."\n", + ($i+1 < count($result) && $result[$i+1]['gang'] != $row['gang']) ? '[l]' : '', $row['anzahl'], - $row['artnr'] ? (int)$row['artnr'] : '', - latex_encode($row['menge']), + ($row['artnr'] && $row['artnr'] != 4711) ? (int)$row['artnr'] : '', $bez, latex_encode($row['vpname']), latex_encode($row['gang'])));