Connect masks to groups
[misc/kostenrechnung] / masks / sys_group_mask.php
1 <?php
2
3 $jscode[] = <<<EOC
4
5 Rico.moduleDependencies['checkboxDB'] = ['+LiveGrid', '../ricoTableColumnDB.js'];
6 Rico.loadModule('checkboxDB');
7
8 function select_group_calback(data)
9 {
10   grid_update(grid);
11 }
12
13 function select_group(obj)
14 {
15   if (!obj.options[obj.selectedIndex].value.length)
16     val = -1;
17   else
18     val = obj.options[obj.selectedIndex].value;
19
20   ajax_request('setvar','source=sys_group_mask&name=group&value='+val,select_group_calback);
21
22   if (obj.options[obj.selectedIndex].value.length)
23     info('Gruppe ' + obj.options[obj.selectedIndex].innerHTML + ' ausgewählt');
24   else
25     info('');
26 }
27 EOC;
28
29 if (empty($_SESSION['sys_group_mask.group'])) $_SESSION['sys_group_mask.group'] = 0;
30
31 $mask = array(
32               'table' => 'sys_mask',
33               'title' => 'Berechtigungen',
34               'select' => array(
35                                 'title' => 'Auswahl',
36                                 'options' => 'SELECT id,name AS text FROM sys_group ORDER BY name',
37                                 'default' => 'Gruppe wählen',
38                                 'selected' => $_SESSION['sys_group_mask.group'],
39                                 'onchange' => 'select_group(this)',
40                                 ),
41               'list' => array(
42                               'id' => array(
43                                             'name' => 'ID',
44                                             'sql' => 'sys_mask.id',
45                                             'visible' => false,
46                                             ),
47                               'menutitle' => array(
48                                             'name' => 'Menüpunkt',
49                                             'sql' => 'sys_mask.menutitle',
50                                             ),
51                               'title' => array(
52                                             'name' => 'Beschreibung',
53                                             'width' => 150,
54                                             'sql' => 'sys_mask.title',
55                                             ),
56                               'edit' => array(
57                                             'name' => 'Edit',
58                                             'width' => 40,
59                                             'specs' => "ClassName: 'aligncenter'",
60                                             'sql' => 'sys_mask.edit',
61                                             ),
62                               'option' => array(
63                                             'name' => 'Menü',
64                                             'width' => 40,
65                                             'sql' => '(SELECT count(*) FROM sys_group_mask WHERE gid = '
66                                                 . intval($_SESSION['sys_group_mask.group'])
67                                                 . ' AND mask = sys_mask.id)',
68                                             'control' => "new Rico.TableColumn.checkboxDB(0, 'ajax/ricoUpdateConnection.php')",
69                                             'specs' => "filterUI: 'c'",
70                                             'update' => array('table' => 'sys_group_mask',
71                                                               'basecol' => 'gid',
72                                                               'baseval' => $_SESSION['sys_group_mask.group'],
73                                                               'refcol' => 'mask',
74                                                               'reftable' => 'sys_mask',
75                                                               'refid' => 'id',
76                                                               ),
77                                             ),
78                               ),
79               'rows' => 20,
80               'variables' => array(
81                                    'group' => array(),
82                                    ),
83               );
84
85 ?>