-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathround_input_ezw.php
242 lines (198 loc) · 8.22 KB
/
round_input_ezw.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
session_start();
/**
* Created by PhpStorm.
* User: paddy.
* Date: 2019-01-17
* Time: 20:06
*/
include('Html.php');
require "models/User.php";
require "models/Discipline.php";
require "models/Round.php";
require "models/Team.php";
require "models/SingleResult.php";
require "models/Shooter.php";
require "models/Verein.php";
//Worker::deleteCredentialsFromSession();
//print_r($_SESSION['user']);
//echo Worker::getCredentialsFromSession()->getEmail();
//print_r(Project::getDuration());
if(isset($_SESSION['user'])) {
$user = User::getCredentialsFromSession();
//die($worker->getEmail());
if ($user->isLoggedIn())
{
//
}
else
{
header("Location: login.php");
//Worker::deleteCredentialsFromSession();
exit();
}
}
else
{
header("Location: login.php");
//Worker::deleteCredentialsFromSession();
exit();
}
if(isset($_GET['disciplineId']))
{
$disciplineId = $_GET['disciplineId'];
}
if(isset($_SESSION['saison']))
{
$saison = $_SESSION['saison'];
}
if(isset($_SESSION['verein']))
{
$verein = $_SESSION['verein'];
}else{
$verein = $user->getUsrCode();
}
if(isset($_GET['roundId']))
{
$roundId = $_GET['roundId'];
}
$discipline = Discipline::get($disciplineId);
if(!empty($_POST))
{
$shooterNr = $_POST['shooter'];
$result = $_POST['result'];
if(!empty($shooterNr) && !empty($result)){
$currentDateTime = new DateTime('now');
$singleResult = new SingelResult(
null,
$roundId,
0,
$shooterNr,
$result,
0,
$saison,
$currentDateTime->format('Y-m-d H:i:s'),
$user->getId(),
$discipline->getSeason(),
$disciplineId
);
if($singleResult->validate())
{
$singleResult->create();
}
}
else if(!empty($_POST['singleResultId'])){
SingelResult::delete($discipline, $_POST['singleResultId']);
}
}
echo '<html>';
renderHeader("Ergebnisseingabe");
echo '<body>';
$singleResults = SingelResult::getBySeasonAndRoundIdAndUserCode($saison, $roundId, $verein);
?>
<section class="container-fluid">
<div class="row justify-content-center ">
<div class="col-11 rounded border shadow p-11 mb-11 bg-white " id="col-Login" >
<?php
headLine("Ergebnisseingabe Einzelwertung", $discipline, $saison);
userLine($user);
crumbBar(5, $user->getRight()>0, $disciplineId,$roundId);
seasonSelector($discipline);
infoTableStart();
$round = Round::get($roundId);
infoTableRow("Saison", $saison);
infoTableRow("DISZIPLIN", $discipline->getName());
infoTableRow("RUNDE", $round->getRound());
infoTableRow("Eingabe", getRoundRange($round, $user));
infoTableRow("Gilde", Verein::get( $verein)->getName());
infoTableEnd();
$disabled = $user->getRight() == 1 || strtotime($round->getStart()) < strtotime('now') && strtotime($round->getStop() . " 23:59:59") > strtotime('now')?"":"disabled";
?>
<form id="form" action="#" method="POST">
<p class="text-center"><strong>Erfasste Ergebnisse</strong></p>
<div class="container-fluid infoTable">
<div class="row">
<div class="col-8 col-md-8">
<strong>Name</strong>
</div>
<div class="col-4 col-md-4">
<strong>Ergebnis</strong>
</div>
</div>
<?php
foreach ($singleResults as $singleResult) {
$shooter = Shooter::getAllByPassNr($singleResult->getNumber());
?>
<div class="row">
<div class="col-8 col-md-8">
<?= utf8_convert($shooter[0]->getName())?>
</div>
<div class="col-4 col-md-4">
<?=$singleResult->getResult()?>
<div class="modal fade" id="staticBackdrop<?=$singleResult->getId()?>" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Ergebnis löschen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Wollen Sie das Ergebnis von <br/><strong>"<?= utf8_convert($shooter[0]->getName())?> (<?=$singleResult->getResult()?>) "</strong><br/>wirklich löschen?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
<button type="button" onClick="deleteSingleResult(<?=$singleResult->getId()?>)" class="btn btn-danger">Löschen</button>
</div>
</div>
</div>
</div>
<?php if(empty($disabled)){?>
<button type="button" class="btn btn-outline-secondary btn-sm" data-toggle="modal" data-target="#staticBackdrop<?=$singleResult->getId()?>">
<i class="fa fa-x fa-trash"></i>
</button>
<?php } ?>
</div>
</div>
<?php
}
echo "</div>";
if(empty($disabled)){
$shooters = Shooter::getAllByPassNrAndWithNoResultOfRound( $verein, $discipline->getWeapon(), $roundId, $saison);
echo '<p class="text-center wordWrap"><strong>Einzelwertungsergebnis hinzufügen</strong></p>';
echo '<div class="row">';
echo "<div class='col-8 col-md-8'><select class='shooterSelect form-control' name='shooter'>";
echo "<option value=''>Schütze auswählen</option>";
foreach ($shooters as $shooter)
{
echo "<option ";
echo "value='".$shooter->getPassNr()."'>".utf8_convert($shooter->getName())."</option>";
}
echo "</select></div>";
$step = $discipline->getZiroOne()? 0.1: 1;
echo "<div class='col-4 col-md-4'><input name='result' class='shooterResult form-control' type='number' min='0' max='".$discipline->getResultRange()."' step='".$step."' value=''/></div>";
echo '</div><br/>';
echo '<input type="submit" class="btn btn-success" href="#" value="Hinzufügen"/>';
echo '<input type="hidden" name="disciplineId" value="'.$disciplineId.'">';
echo '<input type="hidden" name="roundId" value="'.$roundId.'">';
echo '<input type="hidden" id="singleResultId" name="singleResultId" value="">';
}
backButton("teams.php?disciplineId=".$disciplineId."&roundId=".$roundId)
?>
</div>
</form>
</div>
</div>
</section>
<script type="text/javascript">
function deleteSingleResult(id){
$("#singleResultId").val(id);
$("#form").submit();
}
</script>
<?php
renderLogoutSection();
echo '</body>';
echo '</html>';
?>