-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
214 lines (182 loc) · 8.1 KB
/
home.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
if(!isset($Translation)) { @header('Location: index.php'); exit; }
$currDir = dirname(__FILE__);
include_once("{$currDir}/header.php");
@include("{$currDir}/hooks/links-home.php");
if(is_file("{$currDir}/hooks/home-custom.php")) {
include("{$currDir}/hooks/home-custom.php");
include_once("{$currDir}/footer.php");
exit;
}
/*
Classes of first and other blocks
---------------------------------
For possible classes, refer to the Bootstrap grid columns, panels and buttons documentation:
Grid columns: http://getbootstrap.com/css/#grid
Panels: http://getbootstrap.com/components/#panels
Buttons: http://getbootstrap.com/css/#buttons
*/
$block_classes = array(
'first' => array(
'grid_column' => 'col-sm-12 col-md-8 col-lg-6',
'panel' => 'panel-warning',
'link' => 'btn-warning'
),
'other' => array(
'grid_column' => 'col-sm-6 col-md-4 col-lg-3',
'panel' => 'panel-info',
'link' => 'btn-info'
)
);
?>
<style>
.panel-body-description{
margin-top: 10px;
height: 100px;
overflow: auto;
}
.panel-body .btn img{
margin: 0 10px;
max-height: 32px;
}
</style>
<?php
// get member info
$mi = getMemberInfo();
// get configured name of guest user
$admin_config = config('adminConfig');
$guest_username = $admin_config['anonymousMember'];
/* accessible tables */
$arrTables = get_tables_info();
if(is_array($arrTables) && count($arrTables)) {
/* how many table groups do we have? */
$groups = get_table_groups();
$multiple_groups = (count($groups) > 1 ? true : false);
/* construct $tg: table list grouped by table group */
$tg = array();
if(count($groups)) {
foreach($groups as $grp => $tables) {
foreach($tables as $tn) {
$tg[$tn] = $grp;
}
}
}
$i = 0; $current_group = '';
foreach($tg as $tn => $tgroup) {
$tc = $arrTables[$tn];
/* is the current table filter-first? */
$tChkFF = array_search($tn, array());
/* hide current table in homepage? */
$tChkHL = array_search($tn, array());
/* allow homepage 'add new' for current table? */
$tChkAHAN = array_search($tn, array('depots'));
/* homepageShowCount for current table? */
$count_badge = '';
if($tc['homepageShowCount'] && ($tChkHL === false || $tChkHL === null)) {
$sql_from = get_sql_from($tn, false, true);
$count_records = ($sql_from ? sqlValue("select count(1) from " . $sql_from) : 0);
$count_badge = '<span class="badge hspacer-lg text-bold">' . number_format($count_records) . '</span>';
}
$t_perm = getTablePermissions($tn);
$can_insert = $t_perm['insert'];
$searchFirst = (($tChkFF !== false && $tChkFF !== null) ? '?Filter_x=1' : '');
?>
<?php if(!$i && !$multiple_groups) { /* no grouping, begin row */ ?>
<div class="row table_links">
<?php } ?>
<?php if($multiple_groups && $current_group != $tgroup) { /* grouping, begin group & row */ ?>
<?php if($current_group != '') { /* not first group, so we should first end previous group */ ?>
</div><!-- /.table_links -->
<div class="row custom_links">
<?php
/* custom home links for current group, as defined in "hooks/links-home.php" */
echo get_home_links($homeLinks, $block_classes['other'], $current_group);
?>
</div>
</div><!-- /.collapse -->
<?php } ?>
<?php $current_group = $tgroup; ?>
<a class="btn btn-primary btn-block btn-lg collapser vspacer-lg" data-toggle="collapse" href="#group-<?php echo md5($tgroup); ?>"><?php echo $tgroup; ?> <i class="glyphicon glyphicon-chevron-right"></i></a>
<div class="collapse" id="group-<?php echo md5($tgroup); ?>">
<div class="row table_links">
<?php } ?>
<?php if($tChkHL === false || $tChkHL === null) { /* if table is not set as hidden in homepage */ ?>
<div id="<?php echo $tn; ?>-tile" class="<?php echo (!$i ? $block_classes['first']['grid_column'] : $block_classes['other']['grid_column']); ?>">
<div class="panel <?php echo (!$i ? $block_classes['first']['panel'] : $block_classes['other']['panel']); ?>">
<div class="panel-body">
<?php if($can_insert && $tChkAHAN !== false && $tChkAHAN !== null) { ?>
<div class="btn-group" style="width: 100%;">
<a style="width: 85%;" class="btn btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", html_attr(strip_tags($tc['Description']))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc['tableIcon'] ? '<img src="' . $tc['tableIcon'] . '">' : '');?><strong class="table-caption"><?php echo $tc['Caption']; ?></strong><?php echo $count_badge; ?></a>
<a id="<?php echo $tn; ?>_add_new" style="width: 15%;" class="btn btn-add-new btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo html_attr($Translation['Add New']); ?>" href="<?php echo $tn; ?>_view.php?addNew_x=1"><i style="vertical-align: bottom;" class="glyphicon glyphicon-plus"></i></a>
</div>
<?php }else{ ?>
<a class="btn btn-block btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", html_attr(strip_tags($tc['Description']))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc['tableIcon'] ? '<img src="' . $tc['tableIcon'] . '">' : '');?><strong class="table-caption"><?php echo $tc['Caption']; ?></strong><?php echo $count_badge; ?></a>
<?php } ?>
<div class="panel-body-description"><?php echo $tc['Description']; ?></div>
</div>
</div>
</div>
<?php } ?>
<?php if($i == (count($arrTables) - 1) && !$multiple_groups) { /* no grouping, end row */ ?>
</div> <!-- /.table_links -->
<div class="row custom_links" id="custom_links">
<?php
/* custom home links, as defined in "hooks/links-home.php" */
echo get_home_links($homeLinks, $block_classes['other'], '*');
?>
</div>
<?php } ?>
<?php if($i == (count($arrTables) - 1) && $multiple_groups) { /* grouping, end last group & row */ ?>
</div> <!-- /.table_links -->
<div class="row custom_links" id="custom_links">
<?php
/* custom home links for last table group, as defined in "hooks/links-home.php" */
echo get_home_links($homeLinks, $block_classes['other'], $tgroup);
/* custom home links having no table groups, as defined in "hooks/links-home.php" */
echo get_home_links($homeLinks, $block_classes['other']);
?>
</div>
</div><!-- /.collapse -->
<?php } ?>
<?php
$i++;
}
} elseif($mi['username'] && $mi['username'] != $guest_username) {
// non-guest user but no tables to access
die(error_message($Translation['no table access'], false));
} else {
?><script>window.location='index.php?signIn=1';</script><?php
}
?>
<script>
$j(function() {
var table_descriptions_exist = false;
$j('div[id$="-tile"] .panel-body-description').each(function() {
if($j.trim($j(this).html()).length) table_descriptions_exist = true;
});
if(!table_descriptions_exist) {
$j('div[id$="-tile"] .panel-body-description').css({height: 'auto'});
}
$j('.panel-body .btn').height(32);
$j('.btn-add-new').click(function() {
var tn = $j(this).attr('id').replace(/_add_new$/, '');
modal_window({
url: tn + '_view.php?addNew_x=1&Embedded=1',
size: 'full',
title: $j(this).prev().children('.table-caption').text() + ": <?php echo html_attr($Translation['Add New']); ?>"
});
return false;
});
/* adjust arrow directions on opening/closing groups, and initially open first group */
$j('.collapser').click(function() {
$j(this).children('.glyphicon').toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
});
/* hide empty table groups */
$j('.collapser').each(function() {
var target = $j(this).attr('href');
if(!$j(target + " .row div").length) $j(this).hide();
});
$j('.collapser:visible').eq(0).click();
});
</script>
<?php include_once("$currDir/footer.php"); ?>