define('FNAME_VARS', 'ordersatz_vars.tex');
define('FNAME_ITEMS', 'ordersatz_items.tex');
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()
{
function latexspecialchars($string)
{
- $map = array(
- "#"=>"\\#",
- "$"=>"\\$",
- "%"=>"\\%",
- "&"=>"\\&",
- "~"=>"\\~{}",
- "_"=>"\\_",
- "^"=>"\\^{}",
- "\\"=>"\\textbackslash",
- "{"=>"\\{",
- "}"=>"\\}",
- );
- return preg_replace("/([\^\%~\\\\#\$%&_\{\}])/e", "\$map['$1']", $string);
+ return preg_replace_callback("/([\^\%~\\\\#\$%&_\{\}])/",
+ function($matches) {
+ $map = array(
+ "#"=>"\\#",
+ "$"=>"\\$",
+ "%"=>"\\%",
+ "&"=>"\\&",
+ "~"=>"\\~{}",
+ "_"=>"\\_",
+ "^"=>"\\^{}",
+ "\\"=>"\\textbackslash",
+ "{"=>"\\{",
+ "}"=>"\\}",
+ );
+ return $map[$matches[0]];
+ },
+ $string);
}
function latex_encode($text)
"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);
fclose($f);
- system("latex ordersatz > ordersatz.out 2>&1 && dvips ordersatz >> ordersatz.out 2>&1 && ps2pdf ordersatz.ps", $ret);
+ system("latex ordersatz > ordersatz.out 2>&1 && dvips ordersatz >> ordersatz.out 2>&1 && pdflatex ordersatz >> ordersatz.out", $ret);
- if ($ret !== 0)
+ if ($ret !== 0) {
+ $fname = sprintf("ordersatz-%d-%d.tar.bz2", $id, time());
+ $cmd = sprintf("tar cfj %s ordersatz.tex ordersatz_vars.tex ordersatz_items.tex ordersatz.out && " .
+ "mpack -s 'Probleme beim Compilieren des Ordersatzes %d' -d ordersatz.out %s %s && " .
+ "sendfile -Q -c='Probleme beim Compilieren des Ordersatzes %d' %s %s",
+ $fname,
+ $id, $fname, ERROR_MAIL,
+ $id, $fname, ERROR_SAFT);
+ system($cmd);
return "Probleme beim Compilieren des Ordersatzes";
+ }
if (!file_exists('ordersatz.ps'))
return "Postscript-Datei nicht erstellt";
$message = sprintf("Hallo %s!\n\nDer angehängte Ordersatz wurde gerade an Metro Oldenburg verschickt.\n" .
"Eine Bestätigung über den Versand kommt per Mail.\n\n",
- $satz[0]['koch']);
+ utf8_decode($satz[0]['koch']));
mail_attach($satz[0]['email'],
- mb_encode_mimeheader(utf8_decode('Ordersatz ' . $satz[0]['name']),'latin1'),
+ mb_encode_mimeheader('Ordersatz ' . $satz[0]['name'],'latin1'),
$satz[0]['email'],
- mb_encode_mimeheader(utf8_decode('Infodrom ' . $satz[0]['koch']),'latin1'),
+ mb_encode_mimeheader('Infodrom ' . $satz[0]['koch'],'latin1'),
array($dir . '/ordersatz.pdf'),
$message);