Add type reference table geraetetypen for geraete and anbaugeraete
[misc/kostenrechnung] / masks / arbeitsberichte.php
1 <?php
2
3 $jscode[] = <<<EOC
4
5 function select_gebiet_callback(data)
6 {
7     var obj = document.getElementById('edit_kostenstelle');
8     if (!obj) return;
9
10     obj.options.length = 0;
11
12     for (var i=0; i < data.info.length; i++)
13       obj.options[i] = new Option(data.info[i].kostenstelle,data.info[i].id,false,false);
14 }
15
16 function select_group(obj)
17 {
18   setvar(obj,'gebiet',false,false);
19
20   get_info('kostenstellen', {gebiet: obj.options[obj.selectedIndex].value}, select_gebiet_callback);
21 }
22 EOC;
23
24 function first_gebiet()
25 {
26   $sql = "SELECT id FROM gebiet ORDER BY gebiet LIMIT 1";
27
28   $sth = pg_query($sql);
29
30   if ($sth === false) return 0;
31
32   if ($row = pg_fetch_assoc($sth))
33     return $row['id'];
34
35   return 0;
36 }
37
38 if (empty($_SESSION['arbeitsberichte.gebiet'])) $_SESSION['arbeitsberichte.gebiet'] = first_gebiet();
39
40 $mask = array(
41               'table' => 'einsatz',
42               'title' => 'Arbeitsberichte',
43               'subtitle' => 'Eingabe und Übersicht',
44               'join' => array('personal ON einsatz.personal = personal.id',
45                               'gebiet ON einsatz.gebiet = gebiet.id',
46                               'gerate ON einsatz.geraet = gerate.id',
47                               'anbaugeraete ON einsatz.anbaugeraet = anbaugeraete.id',
48                               'arbeitsarten ON einsatz.arbeiten = arbeitsarten.id',
49                               'kostenstellen ON einsatz.kostenstelle = kostenstellen.id',
50                               ),
51               'where' => "arbeitsarten.arbeitsart <> 'Urlaub' AND arbeitsarten.arbeitsart <> 'Krank' AND arbeitsarten.arbeitsart <> 'Sonstige Fehltage'",
52               'variables' => array(
53                                    'gebiet' => array(),
54                                    ),
55               'list' => array(
56                               'id' => array(
57                                             'name' => 'ID',
58                                             'visible' => false,
59                                             'sql' => 'einsatz.id',
60                                             ),
61                               'datum' => array(
62                                             'name' => 'Datum',
63                                             'type' => 'date',
64                                             'width' => 70,
65                                             ),
66                               'kostenstelle' => array(
67                                             'name' => 'Gewässer',
68                                             'sql' => "kostenstellen.kostenstelle",
69                                             'width' => 200,
70                                             'specs' => "filterUI: 's'",
71                                             ),
72                               'gebiet' => array(
73                                             'name' => 'Gebiet',
74                                             'sql' => "gebiet.gebiet",
75                                             'width' => 150,
76                                             'specs' => "filterUI: 's'",
77                                             'visible' => false,
78                                             ),
79                               'name' => array(
80                                             'name' => 'Personal',
81                                             'sql' => "personal.vorname || ' ' || personal.name",
82                                             'width' => 150,
83                                             'specs' => "filterUI: 's'",
84                                             'visible' => false,
85                                             ),
86                               'geraet' => array(
87                                             'name' => 'Gerät',
88                                             'sql' => 'gerate.geraet',
89                                             'width' => 150,
90                                             'specs' => "filterUI: 's'",
91                                             ),
92                               'anbaugeraet' => array(
93                                             'name' => 'Anbaugerät',
94                                             'sql' => 'anbaugeraete.anbaugeraet',
95                                             'width' => 150,
96                                             'specs' => "filterUI: 's'",
97                                             ),
98                               'stunden' => array(
99                                             'name' => 'Stunden',
100                                             'type' => 'number',
101                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
102                                             'width' => 60,
103                                             'visible' => false,
104                                             ),
105                               'geraetstunden' => array(
106                                             'name' => 'Gerätstunden',
107                                             'type' => 'number',
108                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
109                                             'width' => 60,
110                                             'visible' => false,
111                                             ),
112                               ),
113               'edit' => array(
114                               'datum' => array(
115                                             'name' => 'Datum',
116                                             'type' => 'date',
117                                             ),
118                               'hhjahreinsatz' => array(
119                                             'name' => 'Haushaltsjahr',
120                                             'type' => 'select',
121                                             'options' => "SELECT id,hhjahr AS text FROM einstellungen ORDER BY text",
122                                             ),
123                               'personal' => array(
124                                             'name' => 'Mitarbeiter',
125                                             'type' => 'select',
126                                             'options' => "SELECT id,vorname || ' ' || name AS text FROM personal ORDER BY text",
127                                             ),
128                               'gebiet' => array(
129                                             'name' => 'Gebiet',
130                                             'type' => 'select',
131                                             'options' => "SELECT id,gebiet AS text FROM gebiet ORDER BY text",
132                                             'selected' => $_SESSION['arbeitsberichte.gebiet'],
133                                             'onchange' => 'select_group(this)',
134                                             ),
135                               'kostenstelle' => array(
136                                             'name' => 'Gewässer',
137                                             'type' => 'select',
138                                             'options' => "SELECT id,kostenstelle AS text FROM kostenstellen WHERE gebiet = " .
139                                                          intval($_SESSION['arbeitsberichte.gebiet']) .
140                                                          " ORDER BY text",
141                                             ),
142                               'geraet' => array(
143                                             'name' => 'Gerät',
144                                             'type' => 'select',
145                                             'options' => "SELECT id,geraet AS text FROM gerate ORDER BY text",
146                                             ),
147                               'anbaugeraet' => array(
148                                             'name' => 'Anbaugerät',
149                                             'type' => 'select',
150                                             'options' => "SELECT id,anbaugeraet AS text FROM anbaugeraete ORDER BY text",
151                                             ),
152                               'arbeiten' => array(
153                                             'name' => 'Arbeitsart',
154                                             'type' => 'select',
155                                             'options' => "SELECT id,arbeitsart AS text FROM arbeitsarten ORDER BY text",
156                                             ),
157                               'stunden' => array(
158                                             'name' => 'Stunden',
159                                             'type' => 'decimal',
160                                             'size' => 5,
161                                             ),
162                               'geraetstunden' => array(
163                                             'name' => 'Gerätstunden',
164                                             'type' => 'decimal',
165                                             'size' => 5,
166                                             ),
167                               'ordnung' => array(
168                                             'name' => 'Gewässerordnung',
169                                             'type' => 'select',
170                                             'options' => "SELECT id,name AS text FROM ordnungen ORDER BY text",
171                                             ),
172                               'akkord' => array(
173                                             'name' => 'Akkord',
174                                             'type' => 'boolean',
175                                             ),
176                               'bemerkung' => array(
177                                             'name' => 'Bemerkung',
178                                             'type' => 'textarea',
179                                             ),
180                               ),
181               'info' => array(
182                               'kostenstellen' => array(
183                                             'sql' => 'SELECT id,kostenstelle FROM kostenstellen WHERE gebiet = {gebiet}',
184                                             ),
185                                    ),
186               );
187
188 ?>