Update module to new Hallinta system
[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 $href = "new Rico.TableColumn.link('./?mask=metro__ordersatz_pos&id={0}')";
15
16 # INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT ORDERID,id,'joey',now() FROM metro_artikel;
17 # DELETE FROM metro_ordersatz_pos WHERE ordersatz = ORDERID AND anzahl IS NULL
18 $mask = array(
19               'table' => 'metro_ordersatz',
20               'title' => 'Ordersatz auswählen / erstellen',
21               'where' => sprintf('owner = %d AND done IS NULL', $_SESSION['sys']['uid']),
22               'list' => array(
23                               'id' => array(
24                                             'name' => 'ID',
25                                             'visible' => false,
26                                             ),
27                               'erstellt' => array(
28                                             'name' => 'Erstellt',
29                                             'width' => 85,
30                                             ),
31                               'name' => array(
32                                             'name' => 'Name',
33                                             'width' => 290,
34                                             'filter' => 't',
35                                             ),
36                               'koch' => array(
37                                             'name' => 'Kochbetreuer',
38                                             'width' => 100,
39                                             'filter' => 't',
40                                             'visible' => false,
41                                             ),
42                               'datum' => array(
43                                             'name' => 'Einkauf am',
44                                             'width' => 130,
45                                             'sql' => "datum || ' ' || uhrzeit || ' Uhr'",
46                                             ),
47                               'link' => array(
48                                             'name' => 'Aktion',
49                                             'width' => 90,
50                                             'control' => $href,
51                                             'specs' => array('ClassName' => 'aligncenter'),
52                                             'sql' => "'bearbeiten'",
53                                             ),
54                               ),
55               'edit' => array(
56                               'owner' => array(
57                                             'type' => 'hidden',
58                                             'default' => $_SESSION['sys']['uid'],
59                                             'required' => true,
60                                             ),
61                               'erstellt' => array(
62                                             'type' => 'hidden',
63                                             'subtype' => 'string',
64                                             'default' => date('Y-m-d'),
65                                             'required' => true,
66                                             ),
67                               'name' => array(
68                                             'name' => 'Name',
69                                             'type' => 'text',
70                                             'size' => 21,
71                                             'required' => true,
72                                             ),
73                               'koch' => array(
74                                             'name' => 'Kochbetreuer',
75                                             'type' => 'text',
76                                             'size' => 21,
77                                             'required' => true,
78                                             ),
79                               'email' => array(
80                                             'name' => 'E-Mail',
81                                             'type' => 'text',
82                                             'size' => 21,
83                                             'null' => true,
84                                             ),
85                               'telefon' => array(
86                                             'name' => 'Telefon für Rückfragen',
87                                             'type' => 'text',
88                                             'size' => 21,
89                                             'required' => true,
90                                             ),
91                               'datum' => array(
92                                             'name' => 'Abholdatum',
93                                             'type' => 'date',
94                                             'size' => 8,
95                                             'required' => true,
96                                             ),
97                               'uhrzeit' => array(
98                                             'name' => 'Ungefähre Uhrzeit der Abholung',
99                                             'type' => 'text',
100                                             'size' => 3,
101                                             'required' => true,
102                                             ),
103                               ),
104               'buttons' => array('delete' => false),
105               'postinsert' => ordersatz_insert,
106               );
107
108 function ordersatz_insert($id)
109 {
110   global $db;
111
112   $sql = sprintf("INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT %d,id,%s,now() " .
113                  "FROM metro_artikel WHERE removed = 0",
114                  $id, $db->quote($_SESSION['sys']['login']));
115
116   $sth = $db->query($sql);
117 }
118
119 ?>