Update filter select elements after selecting a new year
[misc/kostenrechnung] / masks / overview_geraete.php
1 <?php
2
3 $jscode[] = <<<EOC
4
5 function select_year_calback(data)
6 {
7   grid_update(grid);
8   grid_update_filters(grid);
9 }
10
11 function select_year_status(obj, value, html)
12 {
13   if (value.length)
14     info('Jahr ' + value + ' ausgewählt');
15   else
16     info('');
17 }
18 EOC;
19
20 include_once($_SESSION['sys']['basedir'].'/lib/overview_utils.php');
21
22 if (empty($_SESSION['overview_geraete.year'])) $_SESSION['overview_geraete.year'] = 0;
23
24 $mask = array(
25               'table' => 'einsatz',
26               'title' => 'Einsatzübersicht pro Gerät',
27               'join' => array('gerate ON einsatz.geraet = gerate.id',
28                               'anbaugeraete ON einsatz.anbaugeraet = anbaugeraete.id',
29                               'arbeitsarten ON einsatz.arbeiten = arbeitsarten.id',
30                               ),
31               'where' => "arbeitsarten.arbeitsart <> 'Urlaub' AND arbeitsarten.arbeitsart <> 'Krank' AND arbeitsarten.arbeitsart <> 'Sonstige Fehltage'"
32                        . " AND date_part('year', datum) = " . $_SESSION['overview_geraete.year'],
33               'select' => array(
34                                 'title' => 'Auswahl',
35                                 'options' => discover_years(),
36                                 'default' => 'Jahr wählen',
37                                 'selected' => $_SESSION['overview_geraete.year'],
38                                 'onchange' => "setvar(this,'year',select_year_calback,select_year_status)",
39                                 ),
40               'variables' => array(
41                                    'year' => array(),
42                                    ),
43               'list' => array(
44                               'id' => array(
45                                             'name' => 'ID',
46                                             'visible' => false,
47                                             'sql' => 'einsatz.id',
48                                             ),
49                               'datum' => array(
50                                             'name' => 'Datum',
51                                             'type' => 'date',
52                                             'width' => 70,
53                                             ),
54                               'geraet' => array(
55                                             'name' => 'Gerät',
56                                             'sql' => "gerate.geraet",
57                                             'width' => 150,
58                                             'specs' => "filterUI: 's'",
59                                             ),
60                               'anbaugeraet' => array(
61                                             'name' => 'Anbaugerät',
62                                             'sql' => "anbaugeraete.anbaugeraet",
63                                             'width' => 150,
64                                             'specs' => "filterUI: 's'",
65                                             ),
66                               'arbeitsarten' => array(
67                                             'name' => 'Arbeiten',
68                                             'sql' => "arbeitsarten.arbeitsart",
69                                             'width' => 150,
70                                             'specs' => "filterUI: 's'",
71                                             ),
72                               'geraetstunden' => array(
73                                             'name' => 'Gerätstunden',
74                                             'type' => 'number',
75                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
76                                             'width' => 60,
77                                             ),
78                               'anbaugeraetstunden' => array(
79                                             'name' => 'Anbaugerätstunden',
80                                             'type' => 'number',
81                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
82                                             'width' => 60,
83                                             ),
84                               ),
85               );
86
87 ?>