-
Notifications
You must be signed in to change notification settings - Fork 0
/
leagues.php
executable file
·185 lines (160 loc) · 5.88 KB
/
leagues.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
<?php
require_once('includes/init.php');
$leagues = League::getAll();
$seasons = Season::getAll('label DESC');
$tmp = array();
foreach ($seasons as $season)
$tmp[$season->pr_league_id] []= $season;
$seasons = $tmp;
unset($tmp);
echoHTMLHead('Liste des championnats');
?>
<body>
<div class="container">
<?php echoMenu(); ?>
<h1>Liste des championnats</h1>
<?php if (!empty($_SESSION['user'])) { ?>
<button type="button" class="btn btn-primary nyroModal" href="<?=APPLICATION_URL?>ajax/add_league.php" rev="modal">Ajouter un championnat</button>
<?php } ?>
<table class="table table-bordered">
<thead>
<tr>
<th>Nom</th>
<th>Saison</th>
<?php if (!empty($_SESSION['user'])) { ?>
<th>Modifier</th>
<?php } ?>
<th>Equipes</th>
<th>Classement</th>
<th>Pronostics</th>
</tr>
</thead>
<tbody>
<?php if (count($leagues) != 0) { ?>
<?php foreach ($leagues as $league) { ?>
<?php if (empty($seasons[$league->id])) continue; ?>
<?php foreach ($seasons[$league->id] as $i => $season) { ?>
<tr>
<?php if ($i==0): ?>
<td rowspan="<?php echo count($seasons[$league->id]) ?>"><?php echo $league->name ?></td>
<?php endif; ?>
<td><?php echo $season->label ?></td>
<?php if (!empty($_SESSION['user'])) { ?>
<td class="center">
<a href="<?=APPLICATION_URL?>ajax/add_league.php?id=<?php echo $season->id ?>" class="nyroModal"><img src="<?=APPLICATION_URL?>images/edit.png" alt="[edit]" /></a>
</td>
<?php } ?>
<td>
<a href="<?=APPLICATION_URL?>ajax/show_teams.php?id=<?php echo $season->id ?>" class="nyroModal"><img src="<?=APPLICATION_URL?>images/link-external.png" alt="[edit]" /> voir/modifier les équipes</a>
</td>
<td>
<a href="<?=APPLICATION_URL?>ajax/show_rankings.php?id=<?php echo $season->id ?>" class="nyroModal"><img src="<?=APPLICATION_URL?>images/link-external.png" alt="[view]" /> classement des équipes</a>
</td>
<td>
<p><a href="<?=APPLICATION_URL?>scores/season-<?php echo $season->id ?>"><img src="<?=APPLICATION_URL?>images/link-external.png" alt="[view]" /> classement détaillé</a></p>
<p><a href="javascript:;" onclick="previewRankings(<?php echo $season->id ?>, -1);"><img src="<?=APPLICATION_URL?>images/link-external.png" alt="[view]" /> aperçu du classement</a></p>
<p><a href="<?=APPLICATION_URL?>evolution_classement/season-<?php echo $season->id ?>"><img src="<?=APPLICATION_URL?>images/link-external.png" alt="[view]" /> évolution du classement</a></p>
<p><a href="<?=APPLICATION_URL?>ajax/view_stats.php?id=<?php echo $season->id ?>" class="nyroModal"><img src="<?=APPLICATION_URL?>images/link-external.png" alt="[view]" /> statistiques</a></p>
</td>
</tr>
<?php } ?>
<?php } ?>
<?php } else { ?>
<tr><td colspan="5">Aucun résultat trouvé</td></tr>
<?php } ?>
</tbody>
</table>
</div>
<div id="popupImage" style="display:none"></div></div>
<div id="popup_large"><div id="popup_content"></div></div>
<script type="text/javascript">
function saveLeague()
{
$.ajax({
url: '<?=APPLICATION_URL?>ajax/save_league.php',
data: $('#ajaxForm').serialize(),
dataType: 'json',
success: function (response) {
if (response.success == 1)
window.location.reload();
else
$('#popup_message').html(response.message);
resizeModal();
}
});
}
function saveSeasonTeams()
{
$.ajax({
url: '<?=APPLICATION_URL?>ajax/save_season_teams.php',
data: $('#ajaxForm').serialize(),
dataType: 'json',
type: 'post',
success: function (response) {
if (response.success == 1)
window.location.reload();
else
$('#popup_message').html(response.message);
resizeModal();
}
});
}
function finishPreviewRankings()
{
if (!$('#classement')[0].complete || !$('.spinner')[0].complete)
{
setTimeout('finishPreviewRankings()', 500);
}
else
{
$.fn.nyroModalManual({content: $('#popupImage').html()});
}
}
function previewRankings(id)
{
$('#popupImage').html('<img src="<?=APPLICATION_URL?>classement/season-' + id + '.png" id="classement" />');
$.fn.nyroModalManual({content: '<?=SPINNER_TAG?>', endShowContent: finishPreviewRankings});
}
function addUser()
{
var selected = $('#user_select option:selected');
// check if user was already added
var oldLi = $('#li_box' + selected.val());
if (oldLi.length != 0)
return;
var li = $('<li class="li_box" id="li_box' + selected.val() + '"><span>' + selected.text() + '</span> <input type="hidden" name="users[]" value="' + selected.val() + '" /><a href="javascript:;" onclick="closeBox(' + selected.val() + ');" class="closeBox"></a></li>');
$('#users_holder').append(li);
li.corner();
$('#simplemodal-container').css('height', 'auto');
}
function closeBox(id)
{
$('#li_box' + id).remove();
}
function finishReloadGraph()
{
if ($('#evolutionImg').length == 0 || !$('#evolutionImg')[0].complete)
{
setTimeout('finishReloadGraph()', 500);
}
else
{
$('#evolutionGraph .spinner').remove();
resizeModal($('#evolutionImg').width() + 20, null);
}
}
function reloadGraph(seasonId)
{
var ids = '';
var inputs = $('#users_holder input[type=hidden]');
for (var i=0; i<inputs.length; i++)
ids += $(inputs[i]).val() + '|';
$('#evolutionGraph').html('<?=SPINNER_TAG?><img src="<?=APPLICATION_URL?>evolution/season-' + seasonId + '-users-' + ids + '.png" id="evolutionImg" />');
setTimeout('finishReloadGraph()', 500);
}
$(document).ready(function(){
});
</script>
<?php echoHTMLFooter();?>
</body>
</html>