parent
41d431c1cb
commit
fa81bd0702
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace IQBall\App\Controller;
|
||||||
|
|
||||||
|
use IQBall\App\Session\SessionHandle;
|
||||||
|
use IQBall\App\ViewHttpResponse;
|
||||||
|
use IQBall\Core\Model\TacticModel;
|
||||||
|
use IQBall\Core\Model\TeamModel;
|
||||||
|
|
||||||
|
class TacticController
|
||||||
|
{
|
||||||
|
private TacticModel $tactics;
|
||||||
|
private ?TeamModel $teams;
|
||||||
|
|
||||||
|
public function __construct(TacticModel $tactics, ?TeamModel $teams = NULL) {
|
||||||
|
$this->tactics = $tactics;
|
||||||
|
$this->teams = $teams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayTactic(SessionHandle $session): ViewHttpResponse {
|
||||||
|
$results = $this->tactics->getAll($session->getAccount()->getId());
|
||||||
|
return ViewHttpResponse::twig("display_tactic.html.twig", ['tactics' => $results]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayTeam(int $tacticId, SessionHandle $session): ViewHttpResponse {
|
||||||
|
$results = $this->teams->getAll($session->getAccount()->getId());
|
||||||
|
return ViewHttpResponse::twig("display_user_teams.html.twig", ['teams' => $results, 'tactic' => $tacticId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayShareConfirmation(int $tacticId, int $teamId, SessionHandle $session) : ViewHttpResponse {
|
||||||
|
$team = $this->teams->getTeam($teamId);
|
||||||
|
$tactic = $this->tactics->get($tacticId);
|
||||||
|
return ViewHttpResponse::twig("display_share_confirmation.html.twig", ['team' => $teamId, 'tactic' => $tacticId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shareTacticToTeam(array $confirmation, int $tacticId, int $teamId, SessionHandle $session) : \IQBall\Core\Http\HttpResponse
|
||||||
|
{
|
||||||
|
if($confirmation['confirmation'] == "no") {
|
||||||
|
return ViewHttpResponse::redirect("/");
|
||||||
|
}
|
||||||
|
$this->teams->shareTacticToTeam($teamId, $tacticId);
|
||||||
|
return ViewHttpResponse::redirect("/");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Confirmation</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h2>Etes-vous sûr de vouloir partager la tactique ?</h2>
|
||||||
|
|
||||||
|
<form action="{{ path("/shareTactic/#{tactic}/team/#{team}") }}" method="POST">
|
||||||
|
<div>
|
||||||
|
<input type="radio" id="yes" name="confirmation" value="yes" />
|
||||||
|
<label for="yes">Oui</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="radio" id="no" name="confirmation" value="no" />
|
||||||
|
<label for="no">Non</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="submit" value="Confirmer">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Tactiques partageables</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1><a href="{{ path('/') }}">IQBall</a></h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{% for t in tactics %}
|
||||||
|
<div onclick="window.location.href = '{{ path("/shareTactic/#{t.id}") }}'">
|
||||||
|
<p> {{ t.name }} </p>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Twig view</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
{% if teams is empty %}
|
||||||
|
<p>Vous n'êtes dans aucune équipe</p>
|
||||||
|
{% else %}
|
||||||
|
{% for team in teams %}
|
||||||
|
<div class="team" onclick="window.location.href = '{{ path("/shareTactic/#{tactic}/team/#{team.id}") }}'">
|
||||||
|
<p>Nom de l'équipe : {{ team.name }}</p>
|
||||||
|
<img src="{{ team.picture }}" alt="logo de l'équipe">
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in new issue