Commit d5a11e8b authored by okhin's avatar okhin 🚴

Merge branch '78-souci-sur-solde-des-donateurs' into 'preprod'

AUTO_INCREMENT returns the ID of the Next attribute, not the Last one

Closes #78

See merge request !88
parents f6e1fee9 44849044
Pipeline #2332 passed with stages
in 1 minute and 42 seconds
......@@ -440,7 +440,7 @@ class Admin extends Controller
if ($user['cumul'] >= $needed) {
// Assez de point, on crée
// On récupère le dernier ID inséré
$parent = $f3->get('container')['counterpart_finder']->getLastInsertedId() + 1;
$parent = $f3->get('container')['counterpart_finder']->getNextInsertedId();
$f3->get('container')['command_handler']->handle(new CounterpartCreateCommand($adresse['id'], $user['id'], $quoi, 1, 2, date("Y-m-d H:i:s"), 'Imported from a file', $parent));
// On mets à jour le cumul de l'utilisateur
$f3->get('container')['command_handler']->handle(new UserUpdateCumulCommand($user['id'], $user['cumul'] - $needed));
......
......@@ -337,7 +337,7 @@ class Perso extends Controller
// Ajout d'une demande de contrepartie pour chaque contrepartie
if ((int) $user['cumul'] >= $valeur) {
$parent = $f3->get('container')['counterpart_finder']->getLastInsertedId() + 1;
$parent = $f3->get('container')['counterpart_finder']->getNextInsertedId();
switch ($quoi) {
case 'hoodie':
$f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'hoodie', \Utils::asl($taille_h), 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire), $parent));
......
......@@ -43,6 +43,7 @@
<table cellspacing="0" cellpadding="0">
<theader>
<th>Id</th>
<th>Id du parent</th>
<th>Email</th>
<th>Date</th>
<th>Quoi</th>
......@@ -56,7 +57,8 @@
<repeat group="{{ @data }}" value="{{ @row }}">
<tr>
<td>{{ @row.id }}</td>
<td><a href="{{'user_info', 'id='.@row.user_id | alias }}">{{ @row.email }}</a></td>
<td>{{ @row.parent }}</td>
<td><a href="{{'user_info', 'id='.@row.user_id | alias }}">{{ @row.email }}</a></td>
<td>{{ @row.datec }}</td>
<td>{{ @row.quoi }}</td>
<td>
......
......@@ -95,6 +95,7 @@
<table cellspacing="0" cellpadding="0">
<theader>
<th>Id</th>
<th>Id du parent</th>
<th>Date</th>
<th>Quoi</th>
<th>Taille/Piplome</th>
......@@ -106,6 +107,7 @@
<repeat group="{{ @user.contreparties }}" value="{{ @row }}">
<tr>
<td>{{ @row.id }}</td>
<td>{{ @row.parent }}</td>
<td>{{ @row.datec }}</td>
<td>{{ @row.quoi }}</td>
<td>
......
......@@ -58,11 +58,11 @@ EOQ;
}
/**
* return the last inserted id
* return the id of the next item to be inserted
*
* @return int
*/
public function getLastInsertedId()
public function getNextInsertedId()
{
return (int) $this->connection->fetchColumn(
"SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'contreparties' AND table_schema = DATABASE()"
......
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