Révision a7b49c8f
b/admin/admin.php | ||
---|---|---|
43 | 43 |
if ($_POST['validation_championnat'] == "ajouter") $championnat = "validation_ajouter"; |
44 | 44 |
if ($_POST['validation_championnat'] == "modifier") $championnat = "validation_modifier"; |
45 | 45 |
if ($_POST['validation_penalites'] == "valider") $championnat = "validation_penalites"; |
46 |
if ($_POST['validation_ajustements'] == "valider") $championnat = "validation_ajustements"; |
|
46 | 47 |
|
47 | 48 |
if (isset($_POST['rencontre-ajouter'])) { |
48 | 49 |
$rencontre = "ajouter"; |
... | ... | |
53 | 54 |
$rencontreId = current($vars); |
54 | 55 |
} |
55 | 56 |
} |
57 |
{ |
|
58 |
$vars = preg_grep("/^adjust-/", array_keys($_POST)); |
|
59 |
if ($vars) { |
|
60 |
$championnat = "validation_ajustement"; |
|
61 |
switch ($_POST[current($vars)]) { |
|
62 |
case '↑': |
|
63 |
$action = "up"; |
|
64 |
break; |
|
65 |
case '↓': |
|
66 |
$action = "down"; |
|
67 |
break; |
|
68 |
default: |
|
69 |
$action = "unknown"; |
|
70 |
break; |
|
71 |
} |
|
72 |
list($prefix, $equipe) = explode("-", current($vars)); |
|
73 |
} |
|
74 |
} |
|
56 | 75 |
if ($_POST['validation_rencontre'] == "ajouter") $rencontre = "validation_ajouter"; |
57 | 76 |
if ($_POST['validation_rencontre'] == "modifier") $rencontre = "validation_modifier"; |
58 | 77 |
|
... | ... | |
129 | 148 |
case "pénalités": |
130 | 149 |
$Pen = getPenalites($path); |
131 | 150 |
$equipes = getEquipes($path); |
132 |
$journees = getJournees($path); |
|
151 |
break; |
|
152 |
case "ajustements": |
|
153 |
$Adjust = getAjustements($path); |
|
154 |
$equipes = getEquipes($path); |
|
133 | 155 |
break; |
134 | 156 |
case "modifier": |
135 | 157 |
if (file_exists("$path/equipes")) { |
... | ... | |
173 | 195 |
$message = "Les pénalités ont été mises à jour."; |
174 | 196 |
} |
175 | 197 |
break; |
198 |
case "validation_ajustements": |
|
199 |
$vars = preg_grep("/^adjust_/", array_keys($_POST)); |
|
200 |
if ($vars) { |
|
201 |
$ajustements = ""; |
|
202 |
foreach ($vars as $var) { |
|
203 |
if ($_POST[$var] != 0) { |
|
204 |
if (abs($_POST[$var]) <= 9) { |
|
205 |
list($prefix, $equipe) = explode("_", $var); |
|
206 |
$ajustements .= $equipe.":".$_POST[$var]."\n"; |
|
207 |
} else { |
|
208 |
$message = "Ajustement trop important (".$_POST[$var].")."; |
|
209 |
break 2; |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
$file = "$path/ajustements"; |
|
214 |
if ($ajustements) { |
|
215 |
my_file_put_contents($file, $ajustements); |
|
216 |
} else { |
|
217 |
if (file_exists($file)) unlink($file); |
|
218 |
} |
|
219 |
$message = "Les ajustements ont été mis à jour."; |
|
220 |
} |
|
221 |
break; |
|
222 |
case "validation_ajustement": |
|
223 |
$Adjust = getAjustements($path); |
|
224 |
$equipes = getEquipes($path); |
|
225 |
switch ($action) { |
|
226 |
case "up": |
|
227 |
$Adjust[$equipe]++; |
|
228 |
$message = "L'équipe ".$equipes[$equipe]." a été remontée d'une position."; |
|
229 |
break; |
|
230 |
case "down": |
|
231 |
$Adjust[$equipe] = $Adjust[$equipe] - 1; /* $var-- don't works with empty value */ |
|
232 |
$message = "L'équipe ".$equipes[$equipe]." a été redescendue d'une position."; |
|
233 |
break; |
|
234 |
default: |
|
235 |
break 2; |
|
236 |
} |
|
237 |
$ajustements = ""; |
|
238 |
foreach ($Adjust as $n => $val) { |
|
239 |
if ($val != 0) { |
|
240 |
if (abs($val) <= 9) { |
|
241 |
$ajustements .= "$n:$val\n"; |
|
242 |
} else { |
|
243 |
$message = "Ajustement trop important ($val)."; |
|
244 |
break 2; |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
$file = "$path/ajustements"; |
|
249 |
if ($ajustements) { |
|
250 |
my_file_put_contents($file, $ajustements); |
|
251 |
} else { |
|
252 |
if (file_exists($file)) unlink($file); |
|
253 |
} |
|
254 |
break; |
|
176 | 255 |
case "supprimer": |
177 | 256 |
// Suppression de tous les fichiers du répertoire |
178 | 257 |
if ($dir = opendir($path)) { |
... | ... | |
372 | 451 |
<input type="submit" name="validation_penalites" value="valider" /> |
373 | 452 |
</form> |
374 | 453 |
<?php retour("annuler"); ?> |
454 |
<?php } else if ($championnat == "ajustements") { ?> |
|
455 |
<form method="post" action="<?=$_SERVER['PHP_SELF']?>"> |
|
456 |
<table> |
|
457 |
<?php foreach ($equipes as $n => $e) { ?> |
|
458 |
<tr> |
|
459 |
<td><?=$e?></td> |
|
460 |
<td>:<input type="text" name="adjust_<?=$n?>" size="3" value="<?=($Adjust[$n] ? $Adjust[$n] : "0")?>" /></td> |
|
461 |
</tr> |
|
462 |
<?php } ?> |
|
463 |
</table> |
|
464 |
<?php hiddenVars() ?> |
|
465 |
<input type="submit" name="validation_ajustements" value="valider" /> |
|
466 |
</form> |
|
467 |
<?php retour("annuler"); ?> |
|
375 | 468 |
<?php } else if ($rencontre == "ajouter" || $rencontre == "modifier") { ?> |
376 | 469 |
<form method="post" action="<?=$_SERVER['PHP_SELF']?>"> |
377 | 470 |
<table border="0"> |
b/functions.php | ||
---|---|---|
108 | 108 |
return $Pen; |
109 | 109 |
} |
110 | 110 |
|
111 |
function getAjustements($path) { |
|
112 |
$Adjust = array(); |
|
113 |
$file = "$path/ajustements"; |
|
114 |
if (file_exists($file) && $ajustements = file($file)) { |
|
115 |
foreach ($ajustements as $a) { |
|
116 |
list($equipe, $ajustement) = explode(":", rtrim($a)); |
|
117 |
$Adjust[$equipe] = $ajustement; |
|
118 |
} |
|
119 |
} |
|
120 |
return $Adjust; |
|
121 |
} |
|
122 |
|
|
111 | 123 |
function backup(&$zip, $dir, $zipdir) { |
112 | 124 |
if ($dh = opendir($dir)) { |
113 | 125 |
while (($file = readdir($dh)) !== false) { |
b/index.php | ||
---|---|---|
113 | 113 |
|
114 | 114 |
// Récupération des pénalités |
115 | 115 |
$Pen = getPenalites($path); |
116 |
|
|
117 |
// Récupération des ajustements |
|
118 |
$Adjust = getAjustements($path); |
|
116 | 119 |
?> |
117 | 120 |
<html> |
118 | 121 |
<head> |
... | ... | |
242 | 245 |
?> |
243 | 246 |
<input type="submit" name="championnat" value="supprimer" onClick='return confirm("Voulez-vous vraiment effacer <?=$compet?> ?")' /> |
244 | 247 |
<input type="submit" name="championnat" value="pénalités" /> |
248 |
<input type="submit" name="championnat" value="ajustements" /> |
|
245 | 249 |
</div> |
246 | 250 |
<?php } ?> |
247 | 251 |
<?php } |
... | ... | |
281 | 285 |
if ($equipes) foreach ($equipes as $n => $e) { |
282 | 286 |
$Pts[$n] -= $Pen[$n]; |
283 | 287 |
$Diff[$n] = $PG[$n] - $PP[$n]; |
284 |
$Rang[$n] = $Pts[$n] + $Diff[$n]/1000; |
|
288 |
$Rang[$n] = $Pts[$n] + $Adjust[$n]/100 + $Diff[$n]/100000; |
|
285 | 289 |
} |
286 | 290 |
arsort($Rang); |
291 |
$sortKeys = array_keys($Rang); |
|
287 | 292 |
?> |
288 | 293 |
<div id="tabClassement"> |
289 | 294 |
<table> |
290 | 295 |
<tr> |
291 | 296 |
<th class="colClt">Clt</th> |
297 |
<?php if (IamAdmin()) { ?> |
|
298 |
<th class="colAdjust">Ajustement</th> |
|
299 |
<?php } ?> |
|
292 | 300 |
<th class="colEquipe">Equipe</th> |
293 | 301 |
<th class="colPts">Pts</th> |
294 | 302 |
<th class="colJoue">Joué</th> |
... | ... | |
302 | 310 |
<th class="colDiff">Diff</th> |
303 | 311 |
</tr> |
304 | 312 |
<?php |
305 |
$i = 0; |
|
306 |
if ($equipes) foreach ($Rang as $equipe => $r) { |
|
307 |
$i++; |
|
313 |
if ($equipes) foreach ($sortKeys as $i => $equipe) { |
|
314 |
$prev = ($i > 0) ? $sortKeys[$i-1] : -1; |
|
315 |
$next = ($i < count($sortKeys)-1) ? $sortKeys[$i+1] : -1; |
|
308 | 316 |
?> |
309 | 317 |
<tr> |
310 |
<td class="colClt"><?=(isset($last) && $last == $Pts[$equipe]) ? "-" : $i?></td> |
|
318 |
<td class="colClt"><?=($prev != -1 && $Pts[$prev] == $Pts[$equipe]) ? "-" : $i+1?></td> |
|
319 |
<?php if (IamAdmin()) { ?> |
|
320 |
<td class="colAdjust"> |
|
321 |
<?php if ($prev != -1 && $Pts[$prev] == $Pts[$equipe]) { ?> |
|
322 |
<input class="adjustBtn" type="submit" name="adjust-<?=$equipe?>" value="↑" /> |
|
323 |
<?php } ?> |
|
324 |
<?php if ($next != -1 && $Pts[$next] == $Pts[$equipe]) { ?> |
|
325 |
<input class="adjustBtn" type="submit" name="adjust-<?=$equipe?>" value="↓" /> |
|
326 |
<?php } ?> |
|
327 |
</td> |
|
328 |
<?php } ?> |
|
311 | 329 |
<td class="colEquipe"><?=$equipes[$equipe]?></td> |
312 | 330 |
<td class="colPts"><?=$Pts[$equipe]?></td> |
313 | 331 |
<td class="colJoue"><?=$Joue[$equipe]?></td> |
... | ... | |
320 | 338 |
<td class="colPP"><?=($PP[$equipe]) ? $PP[$equipe] : "0"?></td> |
321 | 339 |
<td class="colDiff"><?=($Diff[$equipe]) ? $Diff[$equipe] : "0"?></td> |
322 | 340 |
</tr> |
323 |
<?php |
|
324 |
$last = $Pts[$equipe]; |
|
325 |
} |
|
326 |
?> |
|
341 |
<?php } ?> |
|
327 | 342 |
</table> |
328 | 343 |
</div> |
329 | 344 |
<br /> |
330 | 345 |
<?php |
331 |
$j = 0; |
|
332 | 346 |
foreach ($rencontres as $j => $rencontre) { |
333 | 347 |
?> |
334 | 348 |
<div class="tabJournee"> |
b/style/fftt.css | ||
---|---|---|
29 | 29 |
margin: auto; |
30 | 30 |
} |
31 | 31 |
|
32 |
th.smallCol, th.colClt, th.colPts, th.colJoue, |
|
32 |
th.colClt, th.colAdjust, th.colPts, th.colJoue, |
|
33 | 33 |
th.colVic, th.colNul, th.colDef, th.colFft, th.colPen, |
34 | 34 |
th.colPG, th.colPP, th.colDiff { |
35 | 35 |
width: 30px; |
Formats disponibles : Unified diff