-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.php
More file actions
183 lines (153 loc) · 5.52 KB
/
settings.php
File metadata and controls
183 lines (153 loc) · 5.52 KB
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
<?php
session_start();
require_once 'global/functions/apicalls.php';
require_once 'global/functions/telegram.php';
require_once 'global/functions/header.php';
require_once 'global/functions/footer.php';
require_once 'global/functions/irm.php';
$config = require_once "config.php";
$tg_user = getTelegramUserData();
if(isset($_GET['emp'])){
$status = $_POST['empbsc'];
if(!isset($status)){
$status = "0";
}
$postfields = "{\n \"bsc\": \"$status\" \n}";
putCall($config->api_url . "users/" . $_SESSION['irmID'], $postfields);
header('Location: settings.php');
}
$menu = renderMenu();
$options['nav'] = $menu;
$options['title'] = "IRM | Settings";
$header = getHeader($options);
$footer = renderFooter();
echo $header;
?>
<div class="topspacer"></div>
<main role="main">
<div class="container">
<?php
if ($tg_user !== false) {
$tgID = $tg_user["id"];
$firstname = $tg_user["first_name"];
$lastname = $tg_user["last_name"];
$username = $tg_user["username"];
saveSessionArray($tg_user);
$access = $_SESSION['access'];
if($access > 2){
$a = true;
} else {
$a = false;
}
$userStations = json_decode(getCall($config->api_url . "userStation?transform=1&filter=telegramID,eq," . $tg_user["id"]),true);
$stations = json_decode(getCall($config->api_url . "stations?transform=1"), true);
$mycars = json_decode(getCall($config->api_url . "carUsers?transform=1&filter=telegramID,eq," . $tg_user["id"]), true);
if(empty($userStations["userStation"])){
echo '<div class="alert alert-danger" role="alert">
You need to register your self in the IRM-Database. Please contact an admin.
</div>';
} else {
echo '<h1>Hi, ' . $firstname . '!</h1>';
echo '<h2>Your username is: <a href="https://t.me/' . $username . '" target="_blank">@' . $username . '</a>.</h2>';
foreach($userStations["userStation"] as $userStation){
$_SESSION['irmID'] = $userStation['userID'];
$myacc = json_decode(getCall($config->api_url . "users/" .$_SESSION['irmID'] . "?transform=1"), true);
if($a){
?>
<div class="topspacer"></div>
<h3>EMP</h3>
<form method="POST" action="settings.php?emp=1" class="form-inline">
<div class="form-check mb-2 mr-sm-2">
<input type="checkbox" name="empbsc" value="1" class="form-check-input" id="empbsc" <?php if($myacc['bsc'] == "1"){echo "checked";}?>>
<label class="form-check-label" for="inlineFormCheck">
I'm a EMP-Backstage Club member
</label>
</div>
<button type="submit" class="btn btn-success mb-2">Submit</button>
</form>
<div class="topspacer"></div>
<?php } ?>
<h3>Select your station</h3>
<form method="POST" action="stationmgmt.php?upatestation=1" class="form-inline">
<div class="form-group mb-2">
<label for="userID" class="sr-only">User ID</label>
<input type="text" readonly class="form-control-plaintext" id="userID" value="<?php echo $tgID . ' // ' . $username; ?>">
</div>
<div class="form-group mx-sm-3 mb-2">
<label for="station" class="sr-only">Station</label>
<select class="form-control" name="station"><?php
foreach($stations["stations"] as $station){
if($station["station"] == $userStation["station"]){
$userStationID = $station['stationID'];
}
}
?>
<option value="<?php echo $userStationID;?>"><?php echo $userStation["station"]; ?></option>
<?php
foreach($stations["stations"] as $station){
if($station["station"] != $userStation["station"]){
echo '<option value="' . $station["stationID"] . '">' . $station["station"] . '</station>';
}
}
?>
</select>
</div>
<div class="form-check mb-2 mr-sm-2">
<input type="checkbox" name="publictransport" value="1" class="form-check-input" id="publictransport" <?php if($userStation['public_transport'] == "1"){echo "checked";}?>>
<label class="form-check-label" for="publictransport">I'm using public transport </label>
</div>
<button type="submit" class="btn btn-success mb-2">Confirm Station</button>
</form>
<div class="topspacer"></div>
<h3>Or provide a new one</h3>
<form method="POST" action="stationmgmt.php?addstation=1" class="">
<div class="form-group">
<input type="text" class="form-control" name="newStation" aria-describedby="stationHelp" placeholder="Station Name">
<small id="stationHelp" class="form-text text-muted">Please provide the name, as it is in the SBB mobile app.</small>
</div>
<button type="submit" class="btn btn-success mb-2">Add Station</button>
</form>
<?php
}
?>
<div class="topspacer"></div>
<h3>Your cars <a href="car.php?new=1"><i class="fa fa-plus-circle righticon" aria-hidden="true"></i></a></h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">Brand</th>
<th scope="col">Model</th>
<th scope="col">Color</th>
<th scope="col">Licence<htd>
<th scope="col">Seats</th>
<th scope="col">Options</th>
</thead>
<tbody>
<?php
if(!empty($mycars['carUsers'])){
foreach($mycars['carUsers'] as $car){
echo '<tr><td>' . $car["brand"] . '</td><td>' . $car["model"] . '</td><td>' . $car["color"] . '</td><td>' . $car["licence"] . '</td><td>' . $car["places"] . '</td><td><a href="car.php?edit=' . $car['carID'] . '" class="btn btn-success">Edit</button><a href="car.php?delete=' . $car['carID'] . '" class="btn btn-danger">Delete</button></td></tr>';
}}
?>
</tbody>
</table>
<?php
if(empty($mycars['carUsers'])){
echo '<div class="alert alert-warning" role="alert">
You have no cars. register a <a href="car.php?new=1">new one</a>
</div>';
}
?>
</div>
<?php
}
} else {
echo '
<div class="alert alert-danger" role="alert">
<strong>Error.</strong> You need to <a href="login.php">login</a> first
</div>
';
}
echo $footer;
?>