Widen columns
[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' => 100,
41                                             'specs' => "ClassName: 'alignrightpad'",
42                                             ),
43                               'name' => array(
44                                             'name' => 'Name',
45                                             'width' => 290,
46                                             'specs' => "filterUI: 't'",
47                                             ),
48                               'koch' => array(
49                                             'name' => 'Kochbetreuer',
50                                             'width' => 100,
51                                             'specs' => "filterUI: 't'",
52                                             'visible' => false,
53                                             ),
54                               'datum' => array(
55                                             'name' => 'Einkauf am',
56                                             'width' => 100,
57                                             'sql' => "datum || ' ' || uhrzeit || ' Uhr'",
58                                             ),
59                               'link' => array(
60                                             'name' => 'Aktion',
61                                             'width' => 90,
62                                             'control' => $href,
63                                             'specs' => "ClassName: 'aligncenter'",
64                                             'sql' => "'bearbeiten'",
65                                             ),
66                               ),
67               'edit' => array(
68                               'owner' => array(
69                                             'type' => 'hidden',
70                                             'default' => $_SESSION['sys']['uid'],
71                                             'required' => true,
72                                             ),
73                               'erstellt' => array(
74                                             'type' => 'hidden',
75                                             'subtype' => 'string',
76                                             'default' => date('Y-m-d'),
77                                             'required' => true,
78                                             ),
79                               'name' => array(
80                                             'name' => 'Name',
81                                             'type' => 'text',
82                                             'size' => 25,
83                                             'required' => true,
84                                             ),
85                               'koch' => array(
86                                             'name' => 'Kochbetreuer',
87                                             'type' => 'text',
88                                             'size' => 25,
89                                             'required' => true,
90                                             ),
91                               'email' => array(
92                                             'name' => 'E-Mail',
93                                             'type' => 'text',
94                                             'size' => 25,
95                                             'null' => true,
96                                             ),
97                               'telefon' => array(
98                                             'name' => 'Telefon für Rückfragen',
99                                             'type' => 'text',
100                                             'size' => 25,
101                                             'required' => true,
102                                             ),
103                               'datum' => array(
104                                             'name' => 'Abholdatum',
105                                             'type' => 'date',
106                                             'size' => 8,
107                                             'required' => true,
108                                             ),
109                               'uhrzeit' => array(
110                                             'name' => 'Ungefähre Uhrzeit der Abholung',
111                                             'type' => 'text',
112                                             'size' => 3,
113                                             'required' => true,
114                                             ),
115                               ),
116               'buttons' => array('delete' => false),
117               'postinsert' => ordersatz_insert,
118               );
119
120 function ordersatz_insert($id)
121 {
122   global $db;
123
124   $sql = sprintf("INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT %d,id,%s,now() FROM metro_artikel",
125                  $id, $db->quote($_SESSION['sys']['login']));
126
127   $sth = $db->query($sql);
128 }
129
130 ?>