-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
239 lines (206 loc) · 11.4 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
if (isset($_POST['authorized_user'])) {
$authorized_user = $_POST['authorized_user']; //get authorized_user from toHome.php
}else{
$authorized_user = null; //page refreshed, so authorized_user is not taken from toHome.php
}
//ΠΣΔ user authentication to front-end
require_once ('server/system/config.php');
require_once ('server/libs/phpCAS/CAS.php');
if(!isset($casOptions["NoAuth"]) || $casOptions["NoAuth"] != true) {
//echo("eimai mesa stou index to if");
// initialize phpCAS using SAML
phpCAS::client(SAML_VERSION_1_1,$casOptions["Url"],$casOptions["Port"],'', false);
// no SSL validation for the CAS server, only for testing environments
phpCAS::setNoCasServerValidation();
// handle backend logout requests from CAS server
phpCAS::handleLogoutRequests(array($casOptions["Url"]));
if(isset($_GET['logout']) && $_GET['logout'] == 'true') {
phpCAS::logoutWithRedirectService($casOptions["LogoutURL"]);
exit();
} else {
// force CAS authentication
if (!phpCAS::checkAuthentication())
phpCAS::forceAuthentication();
}
// at this step, the user has been authenticated by the CAS server and the user's login name can be read with //phpCAS::getUser(). for this test, simply print who is the authenticated user and his attributes.
$user = phpCAS::getAttributes();
//var_dump($user['title']);//die();
}
$user['backendAuthorizationHash'] = base64_encode($frontendOptions['frontendUsername'].':'.$frontendOptions['frontendPassword']);
// echo "<pre>";
// var_dump($user); exit();
// echo "</pre>";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="client/config.js"></script>
<script src="client/libs/frameworks/telerik.kendoui.web.2014.1.318.open-source/js/jquery.js"></script>
<script>
baseURL = config.serverUrl;//"http://mmsch.teiath.gr/mylab/api/";
var user = JSON.parse(atob("<?php echo base64_encode(json_encode($user));?>"));
var user_url = encodeURIComponent(JSON.stringify(user));
var authorized_user= <?php
if( isset($authorized_user) ){
echo json_encode($authorized_user);
}else{
echo json_encode(null);
}
?>;
if(authorized_user === null){ // if user refreshed page home.php, make an additional user_permits request in order to populate authorized_user
$.ajax({
type: 'GET',
url: baseURL + 'user_permits',
data: { user: user },
dataType: "json",
beforeSend: function(req) {
req.setRequestHeader('Authorization', "Basic " + user.backendAuthorizationHash);
},
success: function(data){
if (data.status === 200){
authorized_user = data.data[0].user_role;
}
},
error: function (data){ console.log("GET user_permits error data: ", data);}
});
}
var search_xls = ["ΚΕΠΛΗΝΕΤ", "ΥΠΕΠΘ", "ΠΣΔ"];
var edit_lab_details = ["ΥΠΕΥΘΥΝΟΣ-ΔΙΑΤΑΞΗΣ", "ΔΙΕΥΘΥΝΤΗΣ", "ΤΟΜΕΑΡΧΗΣ"];
var edit_lab_worker = ["ΔΙΕΥΘΥΝΤΗΣ", "ΤΟΜΕΑΡΧΗΣ"];
var transit_lab = ["ΔΙΕΥΘΥΝΤΗΣ", "ΤΟΜΕΑΡΧΗΣ"];
var create_lab = ["ΔΙΕΥΘΥΝΤΗΣ", "ΤΟΜΕΑΡΧΗΣ"];
</script>
<?php require_once('includes.html'); ?>
<script>
$(document).ready(function() {
$.ajaxSetup({
data: { user: user },
beforeSend: function(req) {
req.setRequestHeader('Authorization', "Basic " + user.backendAuthorizationHash);
}
});
//BINDINGS
kendo.bind($("#labs_container"), LabsViewVM);
kendo.bind($("#labs_container").find(".k-grid-toolbar"), LabsViewVM);
kendo.bind($("#labs_view").find(".k-grid-toolbar>.export_to_xlsx"), SearchVM); //bind labs view toolbar 'export to xlsx button' to SearchVM
kendo.bind($("#labs_view").find(".k-grid-toolbar>.lab_grid_columns_btn"), LabsViewVM);
kendo.bind($("#labs_view").find(".k-grid-toolbar>.lab_refresh_btn"), LabsViewVM);
kendo.bind($("#school_units_container"), SchoolUnitsViewVM);
kendo.bind($("#school_units_view").find(".k-grid-toolbar>.export_to_xlsx"), SearchVM); // bind school units view toolbar 'export to xlsx button' to SearchVM
kendo.bind($("#school_units_view").find(".k-grid-toolbar>.school_unit_grid_columns_btn"), SchoolUnitsViewVM);
kendo.bind($("#school_units_view").find(".k-grid-toolbar>.school_unit_refresh_btn"), SchoolUnitsViewVM);
kendo.bind($("#search-container"), SearchVM);
kendo.bind($("#search-lab-workers-container"), SearchLabWorkersVM);
kendo.bind($("#switch_views"), LabsViewVM);
kendo.bind($("#school_unit_info_pane").find("#details-container"), SchoolUnitsViewVM);
kendo.bind($("#statistics-container"), StatisticsVM);
kendo.bind($("#info-container"), InfoVM);
kendo.bind($("#mylab_navigation_bar"), NavBarVM);
kendo.bind($("#lab_workers_container"), LabWorkersViewVM);
kendo.bind($("#lab_workers_view").find(".k-grid-toolbar>.export_to_xlsx"), SearchLabWorkersVM);
kendo.bind($("#lab_workers_view").find(".k-grid-toolbar>.lab_worker_grid_columns_btn"), LabWorkersViewVM);
kendo.bind($("#lab_workers_view").find(".k-grid-toolbar>.lab_worker_refresh_btn"), LabWorkersViewVM);
//NOTIFICATIONS
notification = $("#statistics_xls_publication_failure_notification").kendoNotification({
animation: {
open: {
effects: "slideIn:left",
duration:700
},
close: {
effects: "slideIn:left",
duration:1000,
reverse: true
}
},
position: {
pinned: true,
top: 70,
right: 30
},
allowHideAfter: 2000,
autoHideAfter: 5000, //0 for no auto hide
hideOnClick: true,
stacking: "down",
width:"25em"
}).data("kendoNotification");
// notification = $("#notification").kendoNotification({
// position: {
// pinned: true,
// top: 70,
// right: 30
// },
// allowHideAfter: 2000,
// autoHideAfter: 7000, //0
// hideOnClick: true,
// stacking: "down",
// templates: [{
// type: "error",
// template: $("#errorTemplate").html()
// }, {
// //type: "upload-success",
// type: "success",
// template: $("#successTemplate").html()
// }]
//
// }).data("kendoNotification");
//SCROLL-TOP
//depending on the .scrollTop() value fade in or out the scroll-to-top img
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
// scroll to top
$('.scrollup').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
/* call user_permits in order to populate user info */
$.ajax({
type: 'GET',
url: baseURL + 'user_permits',
dataType: "json",
success: function(data){
if (data.status === 200){
InfoVM.set("user", data.data[0].user_infos.user_name);
InfoVM.set("role", data.data[0].user_infos.ldap_role);
InfoVM.set("unit", data.data[0].user_infos.user_unit);
InfoVM.set("phone", data.data[0].user_infos.phone_number);
InfoVM.set("fax", data.data[0].user_infos.fax_number);
InfoVM.set("email", data.data[0].user_infos.email);
InfoVM.set("address", data.data[0].user_infos.street_address);
}
},
error: function (data){ console.log("GET user_permits error data: ", data);}
});
//index holds thr grid's row index in school units view, in order to expand it after lab creation
index= null;
//searchParameters holds search form filters in order to be used inside SearchVM's exportToXLSX
searchParameters = [];
searchWorkersParameters = [];
statisticParameters = [];
});
</script>
</head>
<body style="background-color: #fcfcfc;"> <!--#e6ece1-->
<?php require_once('navigation_bar.php'); //navigation bar ?>
<div style='height:90px'> </div>
<?php require_once('switch_views.php'); //switch views?>
<div style='height:50px'> </div>
<?php
require_once('search.html'); //search
require_once('search_lab_workers.html'); //search lab workers
require_once('labs_view_try.php'); //labs view
require_once('school_units_view_try.php'); //school units view
require_once('lab_workers_view.php'); //lab workers view
require_once('statistics.php'); //statistics
require_once('info.php'); //info
?>
<a href="#" class="scrollup">Scroll</a>
</body>
</html>