Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
don
Commits
9a69761d
Commit
9a69761d
authored
Dec 14, 2020
by
Bastien Le Querrec
Browse files
met à jour le cumul et le total quand un don est ajouté depuis l'interface d'amin
parent
5619a40c
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/controller/admin.php
View file @
9a69761d
...
...
@@ -11,6 +11,7 @@ use LQDN\Command\DonationResetPdfCommand;
use
LQDN\Command\DonationCreateCommand
;
use
LQDN\Command\UserUpdateByAdminCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\UserUpdateTotalCommand
;
use
LQDN\Command\UserUpdateCumulCommand
;
use
LQDN\Command\AdminUpdateParentCommand
;
use
LQDN\Command\AdminUpdateTotalUsersCommand
;
...
...
@@ -299,13 +300,12 @@ class Admin extends Controller
// Mise à jour ou ajout du don
if
(
$id
==
''
)
{
// We need to check if there's already a user with this email
$result
=
$db
->
query
(
"SELECT id
$result
=
$db
->
query
(
"SELECT id
, cumul, total
FROM users
WHERE email='"
.
\
Utils
::
asl
(
$email
)
.
"'"
);
if
(
$result
)
{
// The user already exist, lets get the user_id
$user_id
=
$result
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
$user_id
=
$user_id
[
'id'
];
// The user already exist, lets get the user id
$user
=
$result
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
}
else
{
// Let's create the account first
$db
->
query
(
"INSERT INTO users
...
...
@@ -317,7 +317,9 @@ class Admin extends Controller
'"
.
\
Utils
::
asl
(
$pseudo
)
.
"',
'"
.
\
Utils
::
asl
(
$somme
)
.
"',
'0')"
);
$user_id
=
$db
->
lastInsertId
();
$user
[
'id'
]
=
$db
->
lastInsertId
();
$user
[
'cumul'
]
=
0
;
$user
[
'total'
]
=
0
;
}
$db
->
query
(
"INSERT INTO dons
(datec,
...
...
@@ -326,17 +328,22 @@ class Admin extends Controller
lang,
abo,
public,
cumul,
status)
VALUES
(now(),
'"
.
\
Utils
::
asl
(
$user
_id
)
.
"',
'"
.
\
Utils
::
asl
(
$user
[
'id'
]
)
.
"',
'"
.
\
Utils
::
asl
(
$somme
)
.
"',
'"
.
\
Utils
::
asl
(
$lang
)
.
"',
'"
.
\
Utils
::
asl
(
$abo
)
.
"',
'"
.
\
Utils
::
asl
(
$public
)
.
"',
'"
.
\
Utils
::
asl
(
$user
[
'cumul'
])
.
"',
1)"
);
// Récupération de l'id pour passage en mode édition
$id
=
$db
->
lastInsertId
();
$f3
->
get
(
'container'
)[
'command_handler'
]
->
handle
(
new
UserUpdateTotalCommand
(
$user
[
'id'
],
(
int
)
$user
[
'total'
]
+
$somme
));
$f3
->
get
(
'container'
)[
'command_handler'
]
->
handle
(
new
UserUpdateCumulCommand
(
$user
[
'id'
],
(
int
)
$user
[
'cumul'
]
+
$somme
));
}
else
{
// We will get the ids associated to the gift first
$result
=
$db
->
query
(
"SELECT adresse_id,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment