Import current development version
[misc/hallinta-metro] / ordersatz.php
1 <?php
2   /*
3    Küchenbetreuer:
4    E-Mail-Adresse für Kopie
5    Telefonnr für Rückfragen:
6    Abholung am:
7    Abholung um Uhrzeit:
8
9    - Ordersatz auswählen || neuen Ordersatz erstellen || Ordersatz kopieren
10    - Ordersatz abschließen = PDF-Datei erzeugen, archivieren, per Mail, per Fax
11    */
12
13
14 function get_title($id)
15 {
16   global $db;
17
18   $query = sprintf('SELECT name FROM metro_ordersatz WHERE id = %d', $id);
19   $sth = $db->query($query);
20   $row = $sth->fetch();
21   if ($row) return 'Ordersatz für ' . $row['name'];
22   else return 'Unbekannter Ordersatz';
23 }
24
25 $href = "new Rico.TableColumn.link('./?mask=metro__ordersatz_pos&id={0}')";
26
27 # INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT ORDERID,id,'joey',now() FROM metro_artikel;
28 # DELETE FROM metro_ordersatz_pos WHERE ordersatz = ORDERID AND anzahl IS NULL
29 $mask = array(
30               'table' => 'metro_ordersatz',
31               'title' => 'Ordersatz auswählen / erstellen',
32               'where' => sprintf('owner = %d AND done IS NULL', $_SESSION['sys']['uid']),
33               'list' => array(
34                               'id' => array(
35                                             'name' => 'ID',
36                                             'visible' => false,
37                                             ),
38                               'erstellt' => array(
39                                             'name' => 'Erstellt',
40                                             'width' => 70,
41                                             'specs' => "ClassName: 'alignrightpad', filterUI: 't'",
42                                             ),
43                               'name' => array(
44                                             'name' => 'Name',
45                                             'width' => 250,
46                                             'specs' => "filterUI: 't'",
47                                             ),
48                               'koch' => array(
49                                             'name' => 'Kochbetreuer',
50                                             'width' => 100,
51                                             'specs' => "filterUI: 't'",
52                                             ),
53                               'datum' => array(
54                                             'name' => 'Einkauf am',
55                                             'width' => 110,
56                                             'sql' => "datum || ' ' || uhrzeit || ' Uhr'",
57                                             ),
58                               'link' => array(
59                                             'name' => 'auswählen',
60                                             'width' => 90,
61                                             'control' => $href,
62                                             'specs' => "ClassName: 'aligncenter'",
63                                             'sql' => "'auswählen'",
64                                             ),
65                               ),
66               'edit' => array(
67                               'owner' => array(
68                                             'type' => 'hidden',
69                                             'default' => $_SESSION['sys']['uid'],
70                                             'required' => true,
71                                             ),
72                               'erstellt' => array(
73                                             'type' => 'hidden',
74                                             'subtype' => 'string',
75                                             'default' => date('Y-m-d'),
76                                             'required' => true,
77                                             ),
78                               'name' => array(
79                                             'name' => 'Name',
80                                             'type' => 'text',
81                                             'size' => 25,
82                                             'required' => true,
83                                             ),
84                               'koch' => array(
85                                             'name' => 'Kochbetreuer',
86                                             'type' => 'text',
87                                             'size' => 25,
88                                             'required' => true,
89                                             ),
90                               'email' => array(
91                                             'name' => 'E-Mail',
92                                             'type' => 'text',
93                                             'size' => 25,
94                                             'null' => true,
95                                             ),
96                               'telefon' => array(
97                                             'name' => 'Telefon für Rückfragen',
98                                             'type' => 'text',
99                                             'size' => 25,
100                                             'required' => true,
101                                             ),
102                               'datum' => array(
103                                             'name' => 'Abholdatum',
104                                             'type' => 'date',
105                                             'size' => 8,
106                                             'required' => true,
107                                             ),
108                               'uhrzeit' => array(
109                                             'name' => 'Ungefähre Uhrzeit der Abholung',
110                                             'type' => 'number',
111                                             'size' => 3,
112                                             'required' => true,
113                                             ),
114                               ),
115               'postinsert' => ordersatz_insert,
116               );
117
118 function ordersatz_insert($id)
119 {
120   global $db;
121
122   $sql = sprintf("INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT %d,id,%s,now() FROM metro_artikel",
123                  $id, $db->quote($_SESSION['sys']['login']));
124   error_log($sql);
125
126   $sth = $db->query($sql);
127 }
128
129 ?>