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