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
0bd91f82
Commit
0bd91f82
authored
Oct 13, 2018
by
Guinness
Committed by
Okhin
Nov 12, 2018
Browse files
Validate, invalidate, PFD data in admin user page.
Refers
#26
Modify the pledges, and acces the pdf.
parent
7cfc2e76
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controller/admin.php
View file @
0bd91f82
...
...
@@ -109,6 +109,98 @@ class Admin extends Controller
$f3
->
set
(
'block_content'
,
'backend/dons.html'
);
}
public
function
validate
(
$f3
,
$args
)
{
$id
=
''
;
$error
=
''
;
$db
=
$f3
->
get
(
'DB'
);
if
(
$f3
->
get
(
'VERB'
)
==
'GET'
)
{
if
(
$f3
->
exists
(
'PARAMS.id'
))
{
$id
=
$f3
->
get
(
'PARAMS.id'
);
}
else
{
$error
=
'Pas d\'id associé à ce don'
;
}
if
(
$id
!=
''
)
{
$result
=
$db
->
query
(
"SELECT status,
somme,
adresse_id,
user_id
FROM dons
WHERE id = "
.
\
Utils
::
asl
(
$id
));
$result
=
$result
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
$user_amount
=
$db
->
query
(
"SELECT total, cumul FROM users
WHERE id = "
.
\
Utils
::
asl
(
$result
[
'user_id'
]));
$user_amount
=
$user_amount
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
}
if
(
$result
[
'status'
]
>=
100
)
{
$status
=
101
;
}
else
{
$status
=
1
;
}
$total
=
$user_amount
[
'total'
]
+
$result
[
'somme'
];
$cumul
=
$user_amount
[
'total'
]
+
$result
[
'somme'
];
}
if
(
$error
!=
''
)
{
}
else
{
$db
->
query
(
"UPDATE dons
SET status =
$status
WHERE id = "
.
\
Utils
::
asl
(
$id
)
);
$db
->
query
(
"UPDATE users
SET total =
$total
,
cumul =
$cumul
WHERE id = "
.
\
Utils
::
asl
(
$result
[
'user_id'
]));
}
$f3
->
reroute
(
"/admin/users/"
.
$result
[
'user_id'
]);
}
public
function
invalidate
(
$f3
,
$args
)
{
$id
=
''
;
$error
=
''
;
$db
=
$f3
->
get
(
'DB'
);
if
(
$f3
->
get
(
'VERB'
)
==
'GET'
)
{
if
(
$f3
->
exists
(
'PARAMS.id'
))
{
$id
=
$f3
->
get
(
'PARAMS.id'
);
}
else
{
$error
=
'Pas d\'id associé à ce don'
;
}
if
(
$id
!=
''
)
{
$result
=
$db
->
query
(
"SELECT status,
somme,
adresse_id,
user_id
FROM dons
WHERE id = "
.
\
Utils
::
asl
(
$id
));
$result
=
$result
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
$user_amount
=
$db
->
query
(
"SELECT total, cumul FROM users
WHERE id = "
.
\
Utils
::
asl
(
$result
[
'user_id'
]));
$user_amount
=
$user_amount
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
}
if
(
$result
[
'status'
]
>=
100
)
{
$status
=
100
;
}
else
{
$status
=
0
;
}
$total
=
$user_amount
[
'total'
]
-
$result
[
'somme'
];
$cumul
=
$user_amount
[
'total'
]
-
$result
[
'somme'
];
if
(
$cumul
<
0
)
{
$error
=
"Impossible d'invalider, une contrepartie a été demandée"
;
}
}
if
(
$error
!=
''
)
{
}
else
{
$db
->
query
(
"UPDATE dons
SET status =
$status
WHERE id = "
.
\
Utils
::
asl
(
$id
)
);
$db
->
query
(
"UPDATE users
SET total =
$total
,
cumul =
$cumul
WHERE id = "
.
\
Utils
::
asl
(
$result
[
'user_id'
]));
}
$f3
->
reroute
(
"/admin/users/"
.
$result
[
'user_id'
]);
}
public
function
support
(
$f3
,
$args
)
{
$id
=
''
;
...
...
app/routes.ini
View file @
0bd91f82
...
...
@@ -27,6 +27,8 @@ GET|POST @admin:/admin=Controller\Admin->show
GET
@add_support:/admin/support/
add
=
Controller
\A
dmin->support
GET
@edit_support:/admin/support/edit/@
id
=
Controller
\A
dmin->support
POST
@modify_support:/admin/support/
edit
=
Controller
\A
dmin->support
GET
@invalidate_support:/admin/support/invalidate/@
id
=
Controller
\A
dmin->invalidate
GET
@validate_support:/admin/support/validate/@
id
=
Controller
\A
dmin->validate
GET|POST
@admin_accounts:/admin/
accounts
=
Controller
\A
dmin->accounts
...
...
app/view/backend/user.html
View file @
0bd91f82
...
...
@@ -209,12 +209,17 @@
-
<check
if=
"{{ @row.status==0 || @row.status==100 }}"
>
<true>
<
span
class=
"lien"
onclick=
"valid({{ @row.id
}}
)
"
>
Valider
</
span
>
<
a
href=
"{{ 'validate_support', 'id='.@row.id | alias
}}"
>
Valider
</
a
>
</true>
<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>
<check
if=
"{{ @row.pdf == '' }}"
>
<a
href=
"/cron/piplome/{{ @row.id }}"
>
PDF
</a>
<false>
<a
href=
"{{ PIPLOME_URL }}/{{ @row.pdf }}.pdf"
target=
"_blank"
>
PDF
</a>
</false>
</check>
</false>
</check>
</td>
...
...
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