Update filter select elements after selecting a new year
[misc/kostenrechnung] / masks / kosten_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['kosten_geraete.year'])) $_SESSION['kosten_geraete.year'] = 0;
23
24 $mask = array(
25               'table' => 'einsatz',
26               'title' => 'Kostenaufwand für Geräte',
27               'join' => array('gerate ON einsatz.geraet = gerate.id',
28                               'anbaugeraete ON einsatz.anbaugeraet = anbaugeraete.id',
29                               'arbeitsarten ON einsatz.arbeiten = arbeitsarten.id',
30                               'kostenstellen ON einsatz.kostenstelle = kostenstellen.id',
31                               ),
32               'where' => "arbeitsarten.arbeitsart <> 'Urlaub' AND arbeitsarten.arbeitsart <> 'Krank' AND arbeitsarten.arbeitsart <> 'Sonstige Fehltage'"
33                        . " AND date_part('year', datum) = " . $_SESSION['kosten_geraete.year']
34                        . " GROUP BY gerate.id,gerate.geraet,kostenstellen.kostenstelle,laenge",
35               'select' => array(
36                                 'title' => 'Auswahl',
37                                 'options' => discover_years(),
38                                 'default' => 'Jahr wählen',
39                                 'selected' => $_SESSION['kosten_geraete.year'],
40                                 'onchange' => "setvar(this,'year',select_year_calback,select_year_status)",
41                                 ),
42               'variables' => array(
43                                    'year' => array(),
44                                    ),
45               'list' => array(
46                               'id' => array(
47                                             'name' => 'ID',
48                                             'visible' => false,
49                                             'sql' => 'gerate.id',
50                                             ),
51                               'geraet' => array(
52                                             'name' => 'Gerät',
53                                             'sql' => "gerate.geraet",
54                                             'width' => 170,
55                                             'specs' => "filterUI: 's'",
56                                             ),
57                               'kostenstelle' => array(
58                                             'name' => 'Kostenstelle',
59                                             'sql' => "kostenstellen.kostenstelle",
60                                             'width' => 200,
61                                             'specs' => "filterUI: 's'",
62                                             ),
63                               'laenge' => array(
64                                             'name' => 'Länge',
65                                             'type' => 'number',
66                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
67                                             'width' => 70,
68                                             ),
69                               'gesamtkosten' => array(
70                                             'name' => 'Gesamtkosten',
71                                             'type' => 'number',
72                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
73                                             'width' => 90,
74                                             'sql' => 'sum(geraetstunden * gerate.geraetkst_intern + ' .
75                                                      'geraetstunden * anbaugeraete.anbkst_intern)',
76                                             ),
77                               'prolfdm' => array(
78                                             'name' => 'pro lfdm',
79                                             'type' => 'number',
80                                             'specs' => "decPlaces: 2, ClassName: 'alignright', suffix: '&nbsp;', canSort: false",
81                                             'width' => 60,
82                                             'sql' => 'sum(geraetstunden * gerate.geraetkst_intern + ' .
83                                                      'geraetstunden * anbaugeraete.anbkst_intern) / laenge',
84                                             ),
85                               ),
86               );
87
88 ?>