-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
178 lines (152 loc) · 6.87 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
<?php if(!isset($Translation)){ @header('Location: index.php'); exit; } ?>
<?php include_once("{$currDir}/header.php"); ?>
<?php @include("{$currDir}/hooks/links-home.php"); ?>
<?php
/*
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
/* accessible tables */
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];
$tChkFF = array_search($tn, array());
$tChkHL = array_search($tn, array('order_details'));
$tChkAHAN = array_search($tn, array('orders','products'));
$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;", htmlspecialchars(strip_tags($tc[1]))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc[2] ? '<img src="' . $tc[2] . '">' : '');?><strong><?php echo $tc[0]; ?></strong></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 htmlspecialchars($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;", htmlspecialchars(strip_tags($tc[1]))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc[2] ? '<img src="' . $tc[2] . '">' : '');?><strong><?php echo $tc[0]; ?></strong></a>
<?php } ?>
<div class="panel-body-description"><?php echo $tc[1]; ?></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++;
}
}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().text() + ": <?php echo htmlspecialchars($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');
});
$j('.collapser').eq(0).click();
});
</script>
<?php include_once("$currDir/footer.php"); ?>