4 E-Mail-Adresse für Kopie
5 Telefonnr für Rückfragen:
9 - Ordersatz auswählen || neuen Ordersatz erstellen || Ordersatz kopieren
10 - Ordersatz abschließen = PDF-Datei erzeugen, archivieren, per Mail, per Fax
13 include_once($_SESSION['sys']['basedir'].'masks/metro/utils.php');
14 include_once($_SESSION['sys']['basedir'].'lib/mail.php');
16 if (substr($_SERVER["SCRIPT_FILENAME"],-10) == '/index.php' &&
18 $_SESSION['ordersatz'] = $_GET['id'];
21 grid_column_edit[1] = {
26 ['1 mal bestellen', '1', 1],
27 ['2 mal bestellen', '2', 2],
28 ['3 mal bestellen', '3', 3],
29 ['4 mal bestellen', '4', 4],
30 ['5 mal bestellen', '5', 5],
31 ['6 mal bestellen', '6', 6],
32 ['7 mal bestellen', '7', 7],
33 ['8 mal bestellen', '8', 8],
34 ['10 mal bestellen', '10', 10],
35 ['12 mal bestellen', '12', 12],
36 ['14 mal bestellen', '14', 14]
40 function build_pdf_callback(data)
43 window.open('ajax/ajax.php?tmpdir='+data.tmpdir+'&source=metro__ordersatz_pos&func=file&name=download','_blank');
48 var source = document.getElementById('source');
49 if (!source) return false;
51 var parms = 'source=' + source.innerHTML + '&callback=pdf&';
52 ajax_request('function', parms, build_pdf_callback);
58 <p style="margin-top: 0px; margin-bottom: 4px; text-align: center;">
59 <button onclick="return build_pdf()">PDF erstellen</button>
61 <button onclick="return finish()">Abschließen</button>
62 <br>Bei Abschluß wird ein Fax zu Metro und eine Kopie per Mail an den Koch geschickt.
66 function get_title($id)
70 $query = sprintf('SELECT name FROM metro_ordersatz WHERE id = %d', $id);
71 $sth = $db->query($query);
73 if ($row) return 'Ordersatz für ' . $row['name'];
74 else return 'Unbekannter Ordersatz';
77 # INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT ORDERID,id,'joey',now() FROM metro_artikel;
78 # DELETE FROM metro_ordersatz_pos WHERE ordersatz = ORDERID AND anzahl IS NULL
80 'table' => 'metro_ordersatz',
81 'join' => array('metro_ordersatz_pos ON ordersatz = metro_ordersatz.id',
82 'metro_artikel ON artikel = metro_artikel.id'),
83 'title' => get_title($_SESSION['ordersatz']),
84 'where' => sprintf('ordersatz = %d AND owner = %d AND done IS NULL', $_SESSION['ordersatz'], $_SESSION['sys']['uid']),
88 'sql' => 'metro_artikel.id',
94 'specs' => "ClassName: 'alignrightpad', filterUI: 't'",
99 'specs' => "filterUI: 't'",
104 'specs' => "ClassName: 'alignrightpad', filterUI: 't'",
106 'bezeichnung' => array(
107 'name' => 'Bezeichnung',
109 'specs' => "filterUI: 't'",
111 'hersteller' => array(
112 'name' => 'Hersteller',
114 'specs' => "filterUI: 't'",
119 'specs' => "ClassName: 'aligncenter', filterUI: 's'",
120 'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_vpe','id','name').", 0, '')",
122 'abteilung' => array(
123 'name' => 'Abteilung',
125 'specs' => "ClassName: 'aligncenter', filterUI: 's'",
126 'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_abteilung','id','name').", 0, '')",
131 'sql' => 'abteilung',
132 'specs' => "ClassName: 'aligncenter', filterUI: 's'",
133 'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_abteilung','id','gang').", 0, '')",
143 'callbacks' => array(
144 'cellsave' => cb_cellsave,
149 'download' => process_download,
153 function cb_cellsave()
157 if ($_POST['value'] == 0)
158 $sql = sprintf("UPDATE metro_ordersatz_pos SET anzahl = NULL, sys_user = %s, sys_edit = now() WHERE ordersatz = %d AND artikel = %d",
159 $db->quote($_SESSION['sys']['login']),
160 $_SESSION['ordersatz'], $_POST['id']);
162 $sql = sprintf("UPDATE metro_ordersatz_pos SET anzahl = %d, sys_user = %s, sys_edit = now() WHERE ordersatz = %d AND artikel = %d",
163 $_POST['value'], $db->quote($_SESSION['sys']['login']),
164 $_SESSION['ordersatz'], $_POST['id']);
166 $sth = $db->query($sql);
173 $tmpdir = mk_tempdir();
174 $result = ordersatz_write($_SESSION['ordersatz'], $tmpdir, false);
176 if ($result !== true)
177 return array('error' => $result);
179 return array('tmpdir' => substr($tmpdir,strlen($_SESSION['sys']['basedir'])));
182 function process_download()
184 if (strpos($_GET['tmpdir'], '..') !== false)
187 $fname = $_SESSION['sys']['basedir'] . $_GET['tmpdir'] . '/ordersatz.pdf';
189 if (!file_exists($fname) || !is_file($fname))
190 return 'File not found';
193 rm_tempdir($_SESSION['sys']['basedir'] . $_GET['tmpdir']);
198 $tmpdir = mk_tempdir();
199 $result = ordersatz_write($_SESSION['ordersatz'], $tmpdir, true);
201 if ($result !== true)
202 return array('error' => $result);
204 $fname = $tmpdir . '/ordersatz.pdf';