Commit 590963df authored by Guinness's avatar Guinness Committed by okhin

Remove an address from the admin page.

Refers #26
parent 0bd91f82
......@@ -755,6 +755,26 @@ class Admin extends Controller
$f3->set('block_content', 'backend/contrepartie.html');
}
public function adresse($f3, $args) {
$id = '';
$user_id = '';
$db = $f3->get('DB');
if ($f3->get('VERB') == 'POST') {
$id = \Utils::asl($f3->get('POST.id'));
}
$result = $db->query("SELECT user_id FROM adresses WHERE id = $id");
$result = $result->fetch(\PDO::FETCH_ASSOC);
$user_id = \Utils::asl($result["user_id"]);
$db->query("UPDATE dons SET adresse_id = NULL
WHERE user_id = $user_id");
$db->query("UPDATE contreparties SET adresse_id = NULL
WHERE user_id = $user_id");
$db->query("DELETE FROM adresses
WHERE id = $id"
);
$f3->reroute("/admin/users/$user_id");
}
public function user($f3, $args)
{
$id = array_key_exists('id', $args) ? \Utils::asl($args['id']) : '';
......
......@@ -196,13 +196,15 @@
</check>
</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>
<check if="{{ @row.pdf == '' }}">
<true>
<a href="/cron/piplome/{{ @row.id }}">PDF</a>
</true>
<false>
<a href="{{ PIPLOME_URL }}/{{ @row.pdf }}.pdf" target="_blank">PDF</a>
</false>
</check>
</td>
<td class="inline">{{ @DONS_STATUTS[@row.status] }}</td>
<td>
<a href="{{ 'edit_support', 'id='.@row.id | alias }}">Editer</a>
......@@ -214,12 +216,6 @@
<false>
<a href="{{ 'invalidate_support', 'id='.@row.id | alias }}">Invalider</a>
-
<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>
......
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