Commit 6f5fff2e authored by okhin's avatar okhin 🚴

Merge branch 'preprod' into 'master'

Preprod

See merge request !53
parents 6d8068aa 5e5afbee
...@@ -93,7 +93,7 @@ class Perso extends Controller ...@@ -93,7 +93,7 @@ class Perso extends Controller
{ {
// Chargement des dons de l'utilisateur // Chargement des dons de l'utilisateur
$db = $f3->get('DB'); $db = $f3->get('DB');
$result = $db->query("SELECT datec, somme, id, pdf, status FROM dons WHERE user_id='".$f3->get('infos.id')."' AND status IN (1,4,102) ORDER BY datec ASC"); $result = $db->query("SELECT datec, somme, id, pdf, status FROM dons WHERE user_id='".$f3->get('infos.id')."' AND status IN (1,4,102) ORDER BY datec DESC");
$data = array(); $data = array();
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) { foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
$data[] = $row; $data[] = $row;
...@@ -116,6 +116,7 @@ class Perso extends Controller ...@@ -116,6 +116,7 @@ class Perso extends Controller
public function login($f3, $args) public function login($f3, $args)
{ {
$f3->clear('SESSION.error'); $f3->clear('SESSION.error');
$f3->clear('SESSION.message');
$f3->set('form_visible', 'login'); $f3->set('form_visible', 'login');
if ($f3->get('action')=='renew_password') { if ($f3->get('action')=='renew_password') {
...@@ -268,7 +269,7 @@ class Perso extends Controller ...@@ -268,7 +269,7 @@ class Perso extends Controller
if ($f3->exists('SESSION.id')) { if ($f3->exists('SESSION.id')) {
// Let's firts check that both the password match // Let's firts check that both the password match
if ($f3->get('password') != $f3->get('password_confirmation')) { if ($f3->get('password') != $f3->get('password_confirmation')) {
$f3->set('SESSION.error', 'Passwords mismatch'); $f3->set('SESSION.error', _("Les mots de passe ne correspondent pas"));
} else { } else {
$sql = "UPDATE users SET email='".\Utils::asl($f3->get('email'))."', $sql = "UPDATE users SET email='".\Utils::asl($f3->get('email'))."',
pseudo='".\Utils::asl($f3->get('pseudo'))."'"; pseudo='".\Utils::asl($f3->get('pseudo'))."'";
...@@ -311,6 +312,7 @@ class Perso extends Controller ...@@ -311,6 +312,7 @@ class Perso extends Controller
$f3->set("error", _("Cette adresse existe déjà.")); $f3->set("error", _("Cette adresse existe déjà."));
$f3->error('403'); $f3->error('403');
} }
$f3->set('SESSION.message', _("Adresse ajoutée à votre profil"));
break; break;
case 'DELETE': case 'DELETE':
try { try {
...@@ -324,6 +326,7 @@ class Perso extends Controller ...@@ -324,6 +326,7 @@ class Perso extends Controller
$f3->set("error", _("Cette adresse est utilisée pour une de vos contreparties")); $f3->set("error", _("Cette adresse est utilisée pour une de vos contreparties"));
$f3->error('403'); $f3->error('403');
}; };
$f3->set('SESSION.message', _("Adresse supprimée de votre profil"));
break; break;
} }
$f3->reroute('/perso'); $f3->reroute('/perso');
...@@ -382,7 +385,7 @@ class Perso extends Controller ...@@ -382,7 +385,7 @@ class Perso extends Controller
} }
// Puis diminution du cumul de la valeur des contreparties // Puis diminution du cumul de la valeur des contreparties
$db->query("UPDATE users SET cumul = cumul - ".$valeur." WHERE id='".$f3->get('SESSION.id')."'"); $db->query("UPDATE users SET cumul = cumul - ".$valeur." WHERE id='".$f3->get('SESSION.id')."'");
$f3->set('msg', _("Merci, vos contreparties seront envoyées dès que possible !")); $f3->set('SESSION.message', _("Merci, vos contreparties seront envoyées dès que possible !"));
$f3->reroute('/perso'); $f3->reroute('/perso');
} }
...@@ -532,6 +535,7 @@ class Perso extends Controller ...@@ -532,6 +535,7 @@ class Perso extends Controller
user_id = '".$user_id."', user_id = '".$user_id."',
identifier = '".$identifier."', identifier = '".$identifier."',
cumul = 0;"); cumul = 0;");
$f3->set('SESSION.message', _("Don récurrent supprimé."));
$f3->reroute('/perso'); $f3->reroute('/perso');
} }
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
</form> </form>
<p>Erreur: </p> <p>Erreur: </p>
<repeat group="{{ @SESSION.errors }}" value="{{ @error }}">
<p>{{@error}}</p>
</repeat>
<section id="gift_holder"> <section id="gift_holder">
<!-- Différents affichages possibles --> <!-- Différents affichages possibles -->
<div id="no_cado" class="cadeaux" style="display:none"> <div id="no_cado" class="cadeaux" style="display:none">
......
<div class="modal-form <check if="{{ @@form_visible == 'login' }}">visible</check>" id="login"> <div class="modal-form <check if="{{ @@form_visible == 'login' }}">visible</check>" id="login">
<div class="modal-form-title modal-form-only"> <div class="modal-form-title modal-form-only">
<a class="close modal-form-only" href="/#"><span>{{ _("Fermer") }}</span></a> <a class="close modal-form-only" href="/#"><span>{{ _("Fermer") }}</span></a>
<h1>{{_("Se connecter")}}</h1> <h1>{{_("Connexion")}}</h1>
</div> </div>
<form method="POST" class="form-inline" action="{{ 'login' | alias }}"> <form method="POST" class="form-inline" action="{{ 'login' | alias }}">
<div class="modal-form-body"> <div class="modal-form-body">
<input type="hidden" name="csrf" id="csrf" value="{{ @CSRF }}" /> <input type="hidden" name="csrf" id="csrf" value="{{ @CSRF }}" />
<fieldset class="form-group modal-form-only"> <fieldset class="form-group modal-form-only">
<h3>{{ _("Le site de dons a changé. À présent, utilisez votre adresse e-mail comme identifiant.") }} </h3> <h3>{{ _("Le site de dons a changé. À présent, utilisez votre adresse e-mail comme identifiant.") }} </h3>
<check if="{{ @@SESSION.message }}">
<p class="modal-row alert alert-info">{{ @SESSION.message }}</p>
</check>
<check if="{{ @@SESSION.error }}">
<p class="modal-row alert alert-danger">{{ @SESSION.error }}</p>
</check>
<div class="modal-row form-group"> <div class="modal-row form-group">
<label for="email">{{ _("Adresse mail") }}</label> <label for="email">{{ _("Adresse mail") }}</label>
<input class="form-control" type="email" name="email" id="email" required> <input class="form-control" type="email" name="email" id="email" required>
...@@ -91,10 +97,10 @@ ...@@ -91,10 +97,10 @@
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<check if="{{ array_key_exists('user', @SESSION) }}"> <check if="{{ array_key_exists('user', @SESSION) }}">
<true><li><a href="{{ 'logout' | alias }}">{{ _("Se déconnecter") }}</a></li> <true><li><a href="{{ 'logout' | alias }}">{{ _("Déconnexion") }}</a></li>
<li><a href="{{ 'perso' | alias }}">{{ _("Réclamer les contreparties") }}</a></li></true> <li><a href="{{ 'perso' | alias }}">{{ _("Contreparties") }}</a></li></true>
<false><li><a href="#add-account">{{ _("Créer un compte")}}</a></li> <false><li><a href="#add-account">{{ _("Créer un compte")}}</a></li>
<li><a href="#login">{{ _("Se connecter")}}</a></li></false> <li><a href="#login">{{ _("Connexion")}}</a></li></false>
</check> </check>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
...@@ -125,7 +131,7 @@ ...@@ -125,7 +131,7 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<check if="{{ array_key_exists('user', @SESSION) }}"> <check if="{{ array_key_exists('user', @SESSION) }}">
<true><li class="pull-right collapsible-menu"><a href="#perso-menu">{{ _("Perso") }}</a></li></true> <true><li class="pull-right collapsible-menu"><a href="#perso-menu">{{ _("Perso") }}</a></li></true>
<false><li class="pull-right"><a href="#login">{{ _("Se connecter")}}</a></li></false> <false><li class="pull-right"><a href="#login">{{ _("Connexion")}}</a></li></false>
</check> </check>
<li class="pull-right collapsible-menu"><a href="#action-menu">{{ _("Menu") }}</a> <li class="pull-right collapsible-menu"><a href="#action-menu">{{ _("Menu") }}</a>
</li> </li>
...@@ -149,3 +155,12 @@ ...@@ -149,3 +155,12 @@
</div> </div>
</nav> </nav>
</div> </div>
<section id="messages">
<check if="{{ @@SESSION.message }}">
<p class="alert alert-info">{{ @SESSION.message }}</p>
</check>
<check if="{{ @@SESSION.error }}">
<p class="alert alert-danger">{{ @SESSION.error }}</p>
</check>
</section>
...@@ -149,9 +149,6 @@ ...@@ -149,9 +149,6 @@
</select></p> </select></p>
<input type="submit" class="big_button" value="Valider" <check if="{{ @adresse }}"><false>disabled</false>/</check>/> <input type="submit" class="big_button" value="Valider" <check if="{{ @adresse }}"><false>disabled</false>/</check>/>
</div> </div>
<check if="{{ @error!='' }}">
<p class="error">{{ @error }}</p>
</check>
</form> </form>
</check> </check>
</section> </section>
...@@ -32,12 +32,6 @@ ...@@ -32,12 +32,6 @@
<p><input type="button" onclick="document.forms['f1']['create_user'].value=1;document.forms['f1'].submit()" class="btn_password" value="{{ _('Créer un compte') }}" /></p> <p><input type="button" onclick="document.forms['f1']['create_user'].value=1;document.forms['f1'].submit()" class="btn_password" value="{{ _('Créer un compte') }}" /></p>
</form> </form>
<check if="{{ @error!='' }}">
<p class="error">{{ @error }}</p>
</check>
<check if="{{ @information!='' }}">
<p class="information">{{ @information }}</p>
</check>
</false> </false>
</check> </check>
</section> </section>
...@@ -139,14 +139,21 @@ ...@@ -139,14 +139,21 @@
<th>{{ _("Date") }}</th> <th>{{ _("Date") }}</th>
<th>{{ _("Dons") }}</th> <th>{{ _("Dons") }}</th>
<th>{{ _("Récurent") }}</th> <th>{{ _("Récurent") }}</th>
<th>{{ _("Contreparties") }}</th> <th>{{ _("Piplome") }}</th>
</tr> </tr>
<repeat group="{{ @dons_recurrents }}" value="{{ @don }}"> <repeat group="{{ @dons_recurrents }}" value="{{ @don }}">
<tr> <tr>
<td>{{ @don.datec }}</td> <td>{{ @don.datec }}</td>
<td>{{ @don.somme }}</td> <td>{{ @don.somme }}</td>
<td>{{ _("Oui")}}</td> <td>{{ _("Oui")}}</td>
<td></td> <td>
<check if="{{ @don.pdf == '' }}">
<a href="/cron/piplome/{{ @don.id }}">{{ _("Générer") }}</a>
<false>
<a href="{{ PIPLOME_URL }}/{{ @don.pdf }}.pdf" target="_blank">{{ @pdfs[@don.pdf].decimale }}.pdf</a>
</false>
</check>
</td>
</tr> </tr>
</repeat> </repeat>
<repeat group="{{ @dons }}" value="{{ @don }}"> <repeat group="{{ @dons }}" value="{{ @don }}">
...@@ -154,14 +161,26 @@ ...@@ -154,14 +161,26 @@
<td>{{ @don.datec }}</td> <td>{{ @don.datec }}</td>
<td>{{ @don.somme }}</td> <td>{{ @don.somme }}</td>
<td>{{ _("Non")}}</td> <td>{{ _("Non")}}</td>
<td></td> <td>
<check if="{{ @don.pdf == '' }}">
<a href="/cron/piplome/{{ @don.id }}">{{ _("Générer") }}</a>
<false>
<a href="{{ PIPLOME_URL }}/{{ @don.pdf }}.pdf" target="_blank">{{ @pdfs[@don.pdf].decimale }}.pdf</a>
</false>
</check>
</td>
</tr> </tr>
</repeat> </repeat>
</table>
<table class="table text-left">
<tr>
<th>{{ _("Date") }}</th>
<th>{{ _("Contreparties") }}</th>
</tr>
<repeat group="{{ @contreparties }}" value="{{ @contrepartie }}"> <repeat group="{{ @contreparties }}" value="{{ @contrepartie }}">
<tr> <tr>
<td>{{ @contrepartie.datec }}</td> <td>{{ @contrepartie.datec }}</td>
<td></td>
<td></td>
<td>{{ @contrepartie.quoi }}</td> <td>{{ @contrepartie.quoi }}</td>
</tr> </tr>
</repeat> </repeat>
......
...@@ -30,7 +30,7 @@ class CounterpartSeeder extends AbstractSeed ...@@ -30,7 +30,7 @@ class CounterpartSeeder extends AbstractSeed
'user_id' => 2, 'user_id' => 2,
'quoi' => 'piplome', // [piplome|pibag|pishirt|hoodie] 'quoi' => 'piplome', // [piplome|pibag|pishirt|hoodie]
'taille' => 2, 'taille' => 2,
'status' => 1, 'status' => 2,
'adresse_id' => null, 'adresse_id' => null,
), ),
); );
......
...@@ -92,7 +92,7 @@ EOF; ...@@ -92,7 +92,7 @@ EOF;
private function addressUsed($addressId) private function addressUsed($addressId)
{ {
$count = (int) $this->connection->fetchColumn( $count = (int) $this->connection->fetchColumn(
"SELECT count(1) FROM contreparties, dons WHERE contreparties.adresse_id = :id OR dons.adresse_id = :id", "SELECT count(1) FROM contreparties, dons WHERE contreparties.adresse_id = :id AND contreparties.status = 1;",
[ [
'id' => $addressId, 'id' => $addressId,
], ],
......
...@@ -20,7 +20,7 @@ class CounterpartFinderTest extends FunctionalTest ...@@ -20,7 +20,7 @@ class CounterpartFinderTest extends FunctionalTest
'datec' => '2016-06-22 12:34:00', 'datec' => '2016-06-22 12:34:00',
'quoi' => 'piplome', 'quoi' => 'piplome',
'taille' => '2', 'taille' => '2',
'status' => '1', 'status' => '2',
'adresse_id' => null, 'adresse_id' => null,
'pdf_id' => '1', 'pdf_id' => '1',
'pdf_nom' => 'Main', 'pdf_nom' => 'Main',
......
...@@ -16,6 +16,10 @@ class AddressHandlerTest extends FunctionalTest ...@@ -16,6 +16,10 @@ class AddressHandlerTest extends FunctionalTest
$this->setExpectedException('LQDN\Exception\AddressUsedException'); $this->setExpectedException('LQDN\Exception\AddressUsedException');
$this->container['command_handler']->handle(new AddressDeleteCommand(1, 1)); $this->container['command_handler']->handle(new AddressDeleteCommand(1, 1));
$this->container['command_handler']->handle(new AddressDeleteCommand(2, 1));
$this->assertFalse($this->addressExists(2));
} }
public function testAdressDelete() public function testAdressDelete()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment