Commit 232014a3 authored by okhin's avatar okhin 🚴

Merge branch 'Guinness/don-fix-admin-user-view' into 'preprod'

Guinness/don fix admin user view

Closes #26, #24, and #23

See merge request !55
parents 9b4639ad 727bd396
Pipeline #2237 failed with stages
in 4 minutes and 28 seconds
This diff is collapsed.
<?php <?php
namespace Controller; namespace Controller;
use LQDN\Command\UserUpdateCumulCommand;
use LQDN\Command\UserUpdateTotalCommand;
class Bank extends Controller class Bank extends Controller
{ {
/* We want to ignore the sanitizing on this page */ /* We want to ignore the sanitizing on this page */
...@@ -150,13 +153,13 @@ class Bank extends Controller ...@@ -150,13 +153,13 @@ class Bank extends Controller
$status = $res->fetch(\PDO::FETCH_ASSOC); $status = $res->fetch(\PDO::FETCH_ASSOC);
$status = $status['status']; $status = $status['status'];
$res = $db->query("SELECT * FROM users WHERE id='".$don['user_id']."';"); $user = $f3->get('container')['user_finder']->findById($don['user_id']);
$user = $res->fetch(\PDO::FETCH_ASSOC);
$cb_log->write("Utilisation d'un utilisateur existant"); $cb_log->write("Utilisation d'un utilisateur existant");
// Ajout du nouveau don au cumul actuel // Ajout du nouveau don au cumul actuel
if ($status!=101) { if ($status!=101) {
$cb_log->write("Ajout de ".$don['somme']); $cb_log->write("Ajout de ".$don['somme']);
$db->query("UPDATE users set cumul = cumul + " . $don['somme'] . ", total = total + " . $don['somme'] . " WHERE id='".$don['user_id']."'"); $f3->get('container')['command_handler']->handle(new UpdateUserTotalCommand($user['id'], (int) $user['total'] + $don['somme']));
$f3->get('container')['command_handler']->handle(new UpdateUserCumulCommand($user['id'], (int) $user['cumul'] + $don['cumul']));
} }
$result = $db->query("SELECT cumul FROM users WHERE id='".$don['user_id']."'"); $result = $db->query("SELECT cumul FROM users WHERE id='".$don['user_id']."'");
$cumul = $result->fetch(\PDO::FETCH_ASSOC); $cumul = $result->fetch(\PDO::FETCH_ASSOC);
...@@ -199,7 +202,7 @@ Toute l'équipe de La Quadrature du Net ...@@ -199,7 +202,7 @@ Toute l'équipe de La Quadrature du Net
")."\n\n"; ")."\n\n";
// Création de l'url d'administration // Création de l'url d'administration
$admin_url = "https://support.laquadrature.net/perso"; $admin_url = "https://don.laquadrature.net/perso";
foreach ($f3->get('languages') as $key => $language) { foreach ($f3->get('languages') as $key => $language) {
if ($lang==$language[1]) { if ($lang==$language[1]) {
$admin_url = "https://".$language[0].$f3->get('dev').".laquadrature.net/perso"; $admin_url = "https://".$language[0].$f3->get('dev').".laquadrature.net/perso";
......
<?php <?php
namespace Controller; namespace Controller;
use LQDN\Command\UserUpdateTotalCommand;
use LQDN\Command\UserCreateCommand;
use LQDN\Command\DonationCreateCommand;
class Campaign extends Controller class Campaign extends Controller
{ {
/* /*
...@@ -93,8 +97,7 @@ class Campaign extends Controller ...@@ -93,8 +97,7 @@ class Campaign extends Controller
$db = $f3->get('DB'); $db = $f3->get('DB');
// Si l'utilisateur est déjà connecté, on le récupère // Si l'utilisateur est déjà connecté, on le récupère
if ($f3->get('SESSION.user', true)) { if ($f3->get('SESSION.user', true)) {
$user = $db->query("SELECT * FROM users WHERE id = ".$f3->get('SESSION.id')); $user = $f3->get('container')['user_finder']->findById($f3->get('SESSION.id'));
$user = $user->fetch(\PDO::FETCH_ASSOC);
$email = $user['email']; $email = $user['email'];
$user_id = $user['id']; $user_id = $user['id'];
$cumul_id = $user['cumul']; $cumul_id = $user['cumul'];
...@@ -103,10 +106,9 @@ class Campaign extends Controller ...@@ -103,10 +106,9 @@ class Campaign extends Controller
$email = \Utils::asl($f3->get('email')); $email = \Utils::asl($f3->get('email'));
$hash = hash('sha256', $f3->get('password')); $hash = hash('sha256', $f3->get('password'));
$sql = "SELECT id FROM users WHERE email = '".\Utils::asl($email)."';"; $user = $f3->get('container')['user_finder']->findByEmail(\Utils::asl($email));
$result = $db->query($sql);
if ($result->fetchColumn() > 0) { if (len($user) > 0) {
// We have an existing user, we should try to login with the provided password // We have an existing user, we should try to login with the provided password
// or 403. // or 403.
$mapper = new \DB\SQL\Mapper($f3->get('DB'), 'users'); $mapper = new \DB\SQL\Mapper($f3->get('DB'), 'users');
...@@ -114,11 +116,6 @@ class Campaign extends Controller ...@@ -114,11 +116,6 @@ class Campaign extends Controller
$login = $auth->login($email, $hash); $login = $auth->login($email, $hash);
if (!$login) { if (!$login) {
$f3->error(403); $f3->error(403);
} else {
$result = $db->query("SELECT id, cumul FROM users WHERE email = '".\Utils::asl($email)."'");
$user = $result->fetch(\PDO::FETCH_ASSOC);
$user_id = $user['id'];
$cumul_id = $user['cumul'];
} }
} else { } else {
// The user does not exist, so let's create it // The user does not exist, so let's create it
......
...@@ -4,6 +4,11 @@ namespace Controller; ...@@ -4,6 +4,11 @@ namespace Controller;
use LQDN\Command\AddressCreateCommand; use LQDN\Command\AddressCreateCommand;
use LQDN\Command\AddressDeleteCommand; use LQDN\Command\AddressDeleteCommand;
use LQDN\Command\AddressUpdateCommand; use LQDN\Command\AddressUpdateCommand;
use LQDN\Command\CounterpartCreateCommand;
use LQDN\Command\CounterpartDeleteCommand;
use LQDN\Command\UserUpdateCumulCommand;
use LQDN\Command\UserUpdateTotalCommand;
use LQDN\Command\UserCreateCommand;
class Perso extends Controller class Perso extends Controller
{ {
...@@ -38,41 +43,14 @@ class Perso extends Controller ...@@ -38,41 +43,14 @@ class Perso extends Controller
{ {
// Chargement des informations de l'utilisateur // Chargement des informations de l'utilisateur
$db = $f3->get('DB'); $db = $f3->get('DB');
// Let's update the total first $user = $f3->get('container')['user_finder']->findById($f3->get('SESSION.id'));
$total = 0; $f3->set('infos', $user);
$total_res = $db->query("SELECT SUM(somme) as total FROM dons WHERE status in (1, 4, 101, 102) AND user_id='".$f3->get('SESSION.id')."'"); $result = $db->query("SELECT id, pdf, decimale FROM dons WHERE user_id='".$user['id']."' and pdf!='' ");
$total_res = $total_res->fetch(\PDO::FETCH_ASSOC);
$total = $total_res['total'];
// While we're at it, let's remove the price of each asked contreparties
// printed piplome is 30, pibag is 50, pishirt is 100 and hoodie is 250
// We first need to have the number of each counterpart claimed by the
// user
$cumul_counterpart = $db->query("SELECT sum(if(quoi='piplome', 1, 0)) as piplomes,
sum(if(quoi='pibag', 1, 0)) as pibags,
sum(if(quoi='pishirt', 1, 0)) as pishirts,
sum(if(quoi='hoodie', 1, 0)) as hoodies
FROM contreparties
WHERE user_id = '".$f3->get('SESSION.id')."';");
$cumul_counterpart = $cumul_counterpart->fetch(\PDO::FETCH_ASSOC);
foreach (['hoodies', 'pishirts', 'pibags', 'piplomes'] as $key) {
if (!array_key_exists($key, $cumul_counterpart)) {
$cumul_counterpart[$key] = 0;
}
}
$cumul = $cumul_counterpart['hoodies'] * 250 + max(($cumul_counterpart['pishirts'] - $cumul_counterpart['hoodies']), 0) * 100 + max(($cumul_counterpart['pibags'] - $cumul_counterpart['pishirts'] - $cumul_counterpart['hoodies']), 0) * 50 + max(($cumul_counterpart['piplomes'] - $cumul_counterpart['pibags'] - $cumul_counterpart['pishirts'] - $cumul_counterpart['hoodies']), 0) * 30;
$cumul = $total - $cumul;
$db->query("UPDATE users SET total = '".$total."', cumul = '".$cumul."' WHERE id = '".$f3->get('SESSION.id')."'");
$result = $db->query("SELECT id, pseudo, email, total, cumul FROM users WHERE id='".$f3->get('SESSION.id')."' ");
$data = $result->fetch(\PDO::FETCH_ASSOC);
$f3->set('infos', $data);
$result = $db->query("SELECT id, pdf, decimale FROM dons WHERE user_id='".$data['id']."' and pdf!='' ");
$pdfs = array(); $pdfs = array();
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) { foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
$pdfs[$row['pdf']] = $row; $pdfs[$row['pdf']] = $row;
} }
$addresse = $f3->get('container')['address_finder']->findByUserId((int) $data['id']); $addresse = $f3->get('container')['address_finder']->findByUserId((int) $user['id']);
$f3->set('adresse', $addresse); $f3->set('adresse', $addresse);
$f3->set('pdfs', $pdfs); $f3->set('pdfs', $pdfs);
} }
...@@ -80,25 +58,19 @@ class Perso extends Controller ...@@ -80,25 +58,19 @@ class Perso extends Controller
public function get_contreparties($f3) public function get_contreparties($f3)
{ {
// Chargement des contreparties de l'utilisateur // Chargement des contreparties de l'utilisateur
$db = $f3->get('DB'); $contreparties = $f3->get('container')['counterpart_finder']->findByUserId((int) $f3->get('SESSION.id'));
$result =$db->query("SELECT datec, status, quoi, taille, adresse_id FROM contreparties WHERE user_id='".$f3->get('SESSION.id')."' ORDER BY datec DESC"); $f3->set('contreparties', $contreparties);
$data = array();
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
$data[] = $row;
}
$f3->set('contreparties', $data);
} }
public function get_dons($f3) public function get_dons($f3)
{ {
// 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 DESC"); $dons = $f3->get('container')['donation_finder']->findByUserId((int) $f3->get('SESSION.id'));
$data = array(); $dons = array_filter($dons, function ($id) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) { return in_array((int) $id, [1, 4, 102]);
$data[] = $row; });
} $f3->set('dons', $dons);
$f3->set('dons', $data);
} }
public function get_recurrents($f3) public function get_recurrents($f3)
...@@ -115,8 +87,6 @@ class Perso extends Controller ...@@ -115,8 +87,6 @@ class Perso extends Controller
public function login($f3, $args) public function login($f3, $args)
{ {
$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') {
...@@ -240,8 +210,7 @@ class Perso extends Controller ...@@ -240,8 +210,7 @@ class Perso extends Controller
if ($f3->get('email')!='') { if ($f3->get('email')!='') {
// On vérifie que l'adresse mail n'existe pas // On vérifie que l'adresse mail n'existe pas
$db = $f3->get('DB'); $db = $f3->get('DB');
$query = $db->query("SELECT email FROM users WHERE email='".$f3->get('email')."';"); $user = $f3->get('container')['user_finder']->findByEmail($f3->get('email'));
$result = $query->fetch(\PDO::FETCH_ASSOC);
$cumul = 0; $cumul = 0;
if ($result['email']!=$f3->get('email')) { if ($result['email']!=$f3->get('email')) {
$hash = hash('sha256', $f3->get('password')); $hash = hash('sha256', $f3->get('password'));
...@@ -337,11 +306,8 @@ class Perso extends Controller ...@@ -337,11 +306,8 @@ class Perso extends Controller
if (!$f3->exists('SESSION.user')) { if (!$f3->exists('SESSION.user')) {
$f3->error('401'); $f3->error('401');
} }
// Récupération du cumul actuel de l'utilisateur
$db = $f3->get('DB'); $user = $f3->get('container')['user_finder']->findById($f3->get('SESSION.id'));
$result = $db->query("SELECT cumul FROM users WHERE id='".$f3->get('SESSION.id')."' ");
$me = $result->fetch(\PDO::FETCH_ASSOC);
$cumul = $me['cumul'];
// Récupération des valeurs du formulaire // Récupération des valeurs du formulaire
$adresse_id = $f3->get('adresse_id'); $adresse_id = $f3->get('adresse_id');
...@@ -351,7 +317,6 @@ class Perso extends Controller ...@@ -351,7 +317,6 @@ class Perso extends Controller
$piplome_id = intval(substr($f3->get('piplome_id'), 0, strpos($f3->get('piplome_id'), '_'))); $piplome_id = intval(substr($f3->get('piplome_id'), 0, strpos($f3->get('piplome_id'), '_')));
$taille = intval($f3->get('taille')); $taille = intval($f3->get('taille'));
$taille_h = intval($f3->get('taille_h')); $taille_h = intval($f3->get('taille_h'));
$f3->clear('SESSION.error');
switch ($quoi) { switch ($quoi) {
case 'piplome': case 'piplome':
$valeur = 30; $valeur = 30;
...@@ -368,24 +333,28 @@ class Perso extends Controller ...@@ -368,24 +333,28 @@ class Perso extends Controller
} }
// Ajout d'une demande de contrepartie pour chaque contrepartie // Ajout d'une demande de contrepartie pour chaque contrepartie
if ($cumul >= $valeur) { if ((int) $user['cumul'] >= $valeur) {
switch ($quoi) { switch ($quoi) {
case 'piplome': case 'piplome':
$db->query("INSERT INTO contreparties (user_id,datec,quoi,taille,adresse_id,status,commentaire) VALUES ('".$f3->get('SESSION.id')."',NOW(),'piplome','".\Utils::asl($piplome_id)."','".\Utils::asl($adresse_id)."',1, '".\Utils::asl($commentaire)."')"); $f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'piplome', \Utils::asl($piplome_id), 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire)));
break; break;
case 'pibag': case 'pibag':
$db->query("INSERT INTO contreparties (user_id,datec,quoi,taille,adresse_id,status,commentaire) VALUES ('".$f3->get('SESSION.id')."',NOW(),'pibag','','".\Utils::asl($adresse_id)."',1, '".\Utils::asl($commentaire)."')"); $f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'pibag', '', 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire)));
break; break;
case 'pishirt': case 'pishirt':
$db->query("INSERT INTO contreparties (user_id,datec,quoi,taille,adresse_id,status,commentaire) VALUES ('".$f3->get('SESSION.id')."',NOW(),'pishirt','".\Utils::asl($taille)."','".\Utils::asl($adresse_id)."',1, '".\Utils::asl($commentaire)."')"); $f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'pishirt', \Utils::asl($taille), 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire)));
break; break;
case 'hoopie': case 'hoopie':
$db->query("INSERT INTO contreparties (user_id,datec,quoi,taille,adresse_id,status,commentaire) VALUES ('".$f3->get('SESSION.id')."',NOW(),'hoodie','".\Utils::asl($taille_h)."','".\Utils::asl($adresse_id)."',1, '".\Utils::asl($commentaire)."')"); $f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'hoopie', \Utils::asl($taille_h), 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire)));
break;
} }
// Puis diminution du cumul de la valeur des contreparties
$f3->get('container')['command_handler']->handle(new UserUpdateCumulCommand($user['id'], $user['cumul'] - $valeur));
$f3->set('SESSION.message', _("Merci, vos contreparties seront envoyées dès que possible !".$valeur));
} else {
$f3->set('SESSION.error', _("Désolé, mais vous n'avez pas cumulé suffisament de dons pour avoir un ").$quoi);
$f3->clear('SESSION.message');
} }
// Puis diminution du cumul de la valeur des contreparties
$db->query("UPDATE users SET cumul = cumul - ".$valeur." WHERE id='".$f3->get('SESSION.id')."'");
$f3->set('SESSION.message', _("Merci, vos contreparties seront envoyées dès que possible !"));
$f3->reroute('/perso'); $f3->reroute('/perso');
} }
......
...@@ -27,6 +27,8 @@ GET|POST @admin:/admin=Controller\Admin->show ...@@ -27,6 +27,8 @@ GET|POST @admin:/admin=Controller\Admin->show
GET @add_support:/admin/support/add=Controller\Admin->support GET @add_support:/admin/support/add=Controller\Admin->support
GET @edit_support:/admin/support/edit/@id=Controller\Admin->support GET @edit_support:/admin/support/edit/@id=Controller\Admin->support
POST @modify_support:/admin/support/edit=Controller\Admin->support POST @modify_support:/admin/support/edit=Controller\Admin->support
GET @invalidate_support:/admin/support/invalidate/@id=Controller\Admin->invalidate
GET @validate_support:/admin/support/validate/@id=Controller\Admin->validate
GET|POST @admin_accounts:/admin/accounts=Controller\Admin->accounts GET|POST @admin_accounts:/admin/accounts=Controller\Admin->accounts
......
<include href="backend/header.html" /> <include href="backend/header.html" />
<include href="backend/toolbar.html" /> <include href="backend/toolbar.html" />
<include href="{{ @block_content }}" /> <include href="{{ @block_content }}" />
<include href="backend/footer.html" /> <!-- <include href="backend/footer.html" /> <!-- No need for scripts right now -->
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
<h2>Ajout d'une contrepartie</h2> <h2>Ajout d'une contrepartie</h2>
</false> </false>
</check> </check>
<form name="f" method="POST" action="{{ 'edit_counterpart', 'id='+@id | alias }}"> <form name="f" method="POST" action="{{ 'edit_counterpart', 'id='.@id | alias }}">
<input type="hidden" name="taille" id="taille" value="{{ @contrepartie.taille }}" /> <input type="hidden" name="taille" id="taille" value="{{ @contrepartie.taille }}" />
<input type="hidden" name="user_id" id="user_id" value="{{ @contrepartie.user_id }}" /> <input type="hidden" name="user_id" id="user_id" value="{{ @contrepartie.user_id }}" />
<input type="hidden" id="csrf" name="csrf" value="{{ @CSRF }}" /> <input type="hidden" id="csrf" name="csrf" value="{{ @CSRF }}" />
<label for="quoi">Quoi</label> <label for="quoi">Quoi</label>
<select id="quoi" name="quoi" onchange="select_span()"> <select id="quoi" name="quoi">
<option value="piplome" <check if="{{ @contrepartie.quoi=='piplome' }}">selected</check> >piplome</option> <option value="piplome" <check if="{{ @contrepartie.quoi=='piplome' }}">selected</check> >piplome</option>
<option value="pishirt" <check if="{{ @contrepartie.quoi=='pishirt' }}">selected</check> >pishirt</option> <option value="pishirt" <check if="{{ @contrepartie.quoi=='pishirt' }}">selected</check> >pishirt</option>
<option value="hoodie" <check if="{{ @contrepartie.quoi=='hoodie' }}">selected</check> >hoodie</option> <option value="hoodie" <check if="{{ @contrepartie.quoi=='hoodie' }}">selected</check> >hoodie</option>
...@@ -22,15 +22,15 @@ ...@@ -22,15 +22,15 @@
<span id="quoi_taille"> <span id="quoi_taille">
<label for="size">Taille</label> <label for="size">Taille</label>
<select id="size" name="size" onchange="select_taille()"> <select id="size" name="size">
<repeat group="{{ @TAILLES }}" key="{{ @key }}" value="{{ @value }}"> <repeat group="{{ @atailles }}" key="{{ @key }}" value="{{ @value }}">
<option value="{{ @key }}" <check if="{{ @contrepartie.taille==@key }}">selected</check> >{{ @value }}</option> <option value="{{ @key }}" <check if="{{ @contrepartie.taille==@key }}">selected</check> >{{ @value }}</option>
</repeat> </repeat>
</select> </select>
</span> </span>
<span id="quoi_pdf"> <span id="quoi_pdf">
<label for="url">Pdf</label> <label for="url">Pdf</label>
<select id="url" name="url" onchange="select_taille()"> <select id="url" name="url">
<repeat group="{{ @pdfs }}" value="{{ @pdf }}"> <repeat group="{{ @pdfs }}" value="{{ @pdf }}">
<option value="{{ @pdf.id }}" <check if="{{ @contrepartie.taille==@pdf.id }}">selected</check> >{{ @pdf.pdf }} / {{ @pdf.nom }}</option> <option value="{{ @pdf.id }}" <check if="{{ @contrepartie.taille==@pdf.id }}">selected</check> >{{ @pdf.pdf }} / {{ @pdf.nom }}</option>
</repeat> </repeat>
...@@ -43,7 +43,11 @@ ...@@ -43,7 +43,11 @@
<br /> <br />
<label for="adresse">Adresse</label> <label for="adresse">Adresse</label>
<textarea id="adresse" name="adresse" cols="30" rows="2">{{ @contrepartie.adresse }}</textarea> <input type="text" id="adresse" name="adresse" size="60" value="{{ @contrepartie.adresse }}">
<br />
<label for="adresse">Complément d'adresse</label>
<input type="text" id="adresse2" name="adresse2" size="60" value="{{ @contrepartie.adresse2 }}">
<br /> <br />
<label for="codepostal">Code postal</label> <label for="codepostal">Code postal</label>
...@@ -65,7 +69,7 @@ ...@@ -65,7 +69,7 @@
</select> </select>
<br /> <br />
<label for=commentaire">Commentaire</label> <label for="commentaire">Commentaire</label>
<textarea type="textarea" id="commentaire" name="commentaire" cols="30" rows="2">{{ @contrepartie.commentaire }}</textarea> <textarea type="textarea" id="commentaire" name="commentaire" cols="30" rows="2">{{ @contrepartie.commentaire }}</textarea>
<br /> <br />
......
...@@ -71,14 +71,14 @@ ...@@ -71,14 +71,14 @@
&nbsp; &nbsp;
</true> </true>
<false> <false>
{{ @TAILLES[@row.taille] }} {{ @atailles[@row.taille] }}
</false> </false>
</check> </check>
</false> </false>
</check> </check>
</td> </td>
<td> <td>
{{ @row.nom }}<br /> {{ @row.pseudo }}<br />
{{ @row.adresse }}<br /> {{ @row.adresse }}<br />
{{ @row.adresse2 }}<br /> {{ @row.adresse2 }}<br />
{{ @row.codepostal }} {{ @row.ville }}<br /> {{ @row.codepostal }} {{ @row.ville }}<br />
......
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
<tr> <tr>
<td>{{ @row.id }}</td> <td>{{ @row.id }}</td>
<td class="inline">{{ @row.datec }}</td> <td class="inline">{{ @row.datec }}</td>
<td>{{ @row.nom }}</td> <td>{{ @row.pseudo }}</td>
<td><a href="{{ 'user_info','id='.@row.user_id | alias }}">{{ @row.email }}</a></td> <td><a href="{{ 'user_info','id='.@row.user_id | alias }}">{{ @row.email }}</a></td>
<td>{{ @row.somme }}</td> <td>{{ @row.somme }}</td>
<td> <td>
{{ @row.adresse }}<br /> {{ @row.adresse }}<br />
...@@ -71,12 +71,12 @@ ...@@ -71,12 +71,12 @@
- -
<check if="{{ @row.status==0 || @row.status==100 }}" > <check if="{{ @row.status==0 || @row.status==100 }}" >
<true> <true>
<span class="lien" onclick="valid({{ @row.id }})">Valider</span> <a href="{{ 'validate_support', 'id='.@row.id | alias }}">Valider</a>
</true> </true>
<false> <false>
<span class="lien" onclick="invalid({{ @row.id }})">Invalider</span> <a href="{{ 'invalidate_support', 'id='.@row.id | alias }}">Invalider</a>
- -
<span class="lien" onclick="pdf({{ @row.id }})">PDF</span> <a href="{{ 'validate_support', 'id='.@row.id | alias }}">PDF</a>
</false> </false>
</check> </check>
</td> </td>
......
...@@ -35,52 +35,50 @@ ...@@ -35,52 +35,50 @@
<br /> <br />
</section> </section>
<section id="adresses"> <section id="adresses">
<h2>Adresses associées à cet utilisateur</h2> <h2>Adresse postale de cet utilisateur</h2>
<repeat group="{{ @user.adresses }}" value="{{ @adresse }}" counter="{{ @i }}"> <check if="@@user.adresse">
<h3>{{ @i }}&nbsp:{{ @adresse.alias }}</h3> <form name="addr_{{@id }}" method="POST" action="{{ 'adresse' |alias }}">
<form name="addr_{{@id }}" method="POST" action="{{ 'adresse' |alias }}"> <input type="hidden" id="csrf" name="csrf" value="{{ @CSRF }}" />
<input type="hidden" id="csrf" name="csrf" value="{{ @CSRF }}" /> <input type="hidden" name="id" id="id" value="{{ @@user.adresse.id }}" />
<input type="hidden" name="id" id="id" value="{{ @adresse.id }}" /> <input type="hidden" name="action" id="action" value="modify" />
<input type="hidden" name="action" id="action" value="modify" />
<label for="nom">Nom</label>
<label for="nom">Nom</label> <input type="text" id="nom" name="nom" size="30" value="{{ @@user.adresse.nom }}" />
<input type="text" id="nom" name="nom" size="30" value="{{ @adresse.nom }}" /> <br />
<br />
<label for="adresse">Adresse</label>
<label for="adresse">Adresse</label> <input type="text" id="adresse" name="adresse" size="100" value="{{ @@user.adresse.adresse }}" />
<input type="text" id="adresse" name="adresse" size="100" value="{{ @adresse.adresse }}" /> <br />
<br />
<label for="adresse2">Adresse (compl.)</label>
<label for="adresse2">Adresse (compl.)</label> <input type="text" id="adresse2" name="adresse2" size="100" value="{{ @@user.adresse.adresse2 }}" />
<input type="text" id="adresse2" name="adresse2" size="100" value="{{ @adresse.adresse2 }}" /> <br />
<br />
<label for="codepostal">Code Postal</label>
<label for="codepostal">Code Postal</label> <input type="text" id="codepostal" name="codepostal" size="10" value="{{ @@user.adresse.codepostal }}" />
<input type="text" id="codepostal" name="codepostal" size="10" value="{{ @adresse.codepostal }}" /> <br />
<br />
<label for="ville">Ville</label>
<label for="ville">Ville</label> <input type="text" id="ville" name="ville" size="50" value="{{ @@user.adresse.ville }}" />
<input type="text" id="ville" name="ville" size="50" value="{{ @adresse.ville }}" /> <br />
<br />
<label for="etat">Etat / Province / Comté</label>
<label for="etat">Etat / Province / Comté</label> <input type="text" id="etat" name="etat" size="50" value="{{ @@user.adresse.etat }}" />
<input type="text" id="etat" name="etat" size="50" value="{{ @adresse.etat }}" /> <br />
<br />
<label for="pays">Pays</label>
<label for="pays">Pays</label> <input type="text" id="pays" name="pays" size="30" value="{{ @@user.adresse.pays }}" />
<input type="text" id="pays" name="pays" size="30" value="{{ @adresse.pays }}" /> <br />
<br />
<input type="submit" value="Modifier l'adresse" />
<input type="submit" value="Modifier l'adresse" /> </form>
</form> <form name="del_addr_{{@id}}" method="POST" action="{{ 'adresse' | alias }}">
<form name="del_addr_{{@id}}" method="POST" action="{{ 'adresse' | alias }}"> <input type="hidden" id="csrf" name="csrf" value="{{ @CSRF }}" />
<input type="hidden" id="csrf" name="csrf" value="{{ @CSRF }}" /> <input type="hidden" name="id" id="id" value="{{ @@user.adresse.id }}" />
<input type="hidden" name="id" id="id" value="{{ @adresse.id }}" /> <input type="hidden" name="action" id="action" value="delete" />
<input type="hidden" name="action" id="action" value="delete" /> <input type="submit" value="Effacer l'adresse" />
<input type="submit" value="Effacer l'adresse" /> </form>
</form> </check>
</repeat>
</section> </section>
<section id="contreparties"> <section id="contreparties">
<check if="{{ count(@user.contreparties) > 0}}"> <check if="{{ count(@user.contreparties) > 0}}">
...@@ -123,7 +121,7 @@ ...@@ -123,7 +121,7 @@
<td> <td>
<check if="{{ @row.adresse_id != null }}"> <check if="{{ @row.adresse_id != null }}">
<true> <true>
{{ @user.adresses[@row.adresse_id].alias }} {{ @@user.adresses[@row.adresse_id].nom }}
</true> </true>
<false> <false>
- -
...@@ -174,7 +172,6 @@ ...@@ -174,7 +172,6 @@
<th>ID</th> <th>ID</th>
<th>Date</th> <th>Date</th>
<th>Don</th> <th>Don</th>
<th>Adresse</th>
<th>PDF</th> <th>PDF</th>
<th>Statut</th> <th>Statut</th>
<th>Actions</th> <th>Actions</th>
...@@ -186,35 +183,26 @@ ...@@ -186,35 +183,26 @@
<td class="inline">{{ @row.datec }}</td> <td class="inline">{{ @row.datec }}</td>
<td>{{ @row.somme }}</td> <td>{{ @row.somme }}</td>
<td> <td>
<check if="{{ array_key_exists(@row.adresse_id, @user.adresses)}}"> <check if="{{ @row.pdf == '' }}">
<true> <true>
{{ @user.adresses[@row.adresse_id].alias }} <a href="/cron/piplome/{{ @row.id }}">PDF</a>
</true> </true>
<false> <false>
&nbsp; <a href="{{ PIPLOME_URL }}/{{ @row.pdf }}.pdf" target="_blank">PDF</a>
</false> </false>
</check> </check>
</td> </td>
<td>
<check if="{{ @row.pdf != '' }}">
<true><a href="{{ @PIPLOME_URL }}{{ @row.pdf }}.pdf">{{ @row.pdf }}</a>( {{@user.adresses[@row.adresse_id].nom }})</td>
</true>
<false>
&nbsp;
</false>
</check>
<td class="inline">{{ @DONS_STATUTS[@row.status] }}</td> <td class="inline">{{ @DONS_STATUTS[@row.status] }}</td>
<td> <td>
<a href="{{ 'edit_support', 'id='.@row.id | alias }}">Editer</a> <a href="{{ 'edit_support', 'id='.@row.id | alias }}">Editer</a>
- -
<check if="{{ @row.status==0 || @row.status==100 }}" > <check if="{{ @row.status==0 || @row.status==100 }}" >
<true> <true>
<span class="lien" onclick="valid({{ @row.id }})">Valider</span> <a href="{{ 'validate_support', 'id='.@row.id | alias }}">Valider</a>
</true> </true>
<false> <false>
<span class="lien" onclick="invalid({{ @row.id }})">Invalider</span> <a href="{{ 'invalidate_support', 'id='.@row.id | alias }}">Invalider</a>
- -
<span class="lien" onclick="pdf({{ @row.id }})">PDF</span>
</false> </false>
</check> </check>
</td> </td>
......
<?php
namespace LQDN\Command;
class CounterpartChangeStateCommand
{
private $counterpartId;
private $state;
public function __construct($counterpartId, $state)
{
$this->counterpartId = $counterpartId;
$this->state = $state;
}