Skip to content

Commit

Permalink
add: Generate a "livre des recettes"
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Feb 3, 2021
1 parent f603281 commit c9f5576
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
48 changes: 48 additions & 0 deletions public/static/print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
body {
font-family: sans-serif;
}

h1 {
text-align: center;
}

table {
width: 100%;
max-width: 1200px;
margin: auto;

font-size: 90%;

border: 1px solid black;
border-collapse: collapse;
}

.cell {
padding: 5px;

border: 1px solid black;
}

.cell--date {
width: 100px;
}

.cell--ref {
width: 125px;
}

.cell--nature {
width: 125px;
}

.cell--amount {
width: 100px;
}

td.cell--amount {
text-align: right;
}

.cell--type {
width: 100px;
}
5 changes: 5 additions & 0 deletions src/admin/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function index($request)
'year' => $year,
'payments' => $payments,
]);
} elseif ($format === 'recettes') {
return \Minz\Response::ok('admin/payments/recettes.phtml', [
'year' => $year,
'payments' => $payments,
]);
} else {
return \Minz\Response::ok('admin/payments/index.phtml', [
'year' => $year,
Expand Down
16 changes: 16 additions & 0 deletions src/views/_layouts/print.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1.0" />
<link rel="stylesheet" href="<?= url_static('print.css') ?>">

<title><?= $title ?></title>
</head>

<body>
<h1><?= $title ?></h1>

<?= $this->safe('content') ?>
</body>
</html>
64 changes: 64 additions & 0 deletions src/views/admin/payments/recettes.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php $this->layout('print.phtml', ['title' => 'Livre des recettes']); ?>

<table>
<thead>
<tr>
<th class="cell cell--date">Date</th>
<th class="cell cell--ref">Référence</th>
<th class="cell cell--customer">Client</th>
<th class="cell cell--nature">Nature</th>
<th class="cell cell--amount">Montant</th>
<th class="cell cell--type">Règlement</th>
</tr>
</thead>

<tbody>
<?php foreach (array_reverse($payments) as $payment): ?>
<?php if (!$payment->completed_at) { continue; } ?>

<tr>
<td class="cell cell--date">
<?= format_date($payment->completed_at, '%d/%m/%Y') ?>
</td>

<td class="cell cell--ref">
<?= $payment->invoice_number ?>
</td>

<td class="cell cell--customer">
<?= $payment->address_first_name . ' ' . $payment->address_last_name ?>
</td>

<td class="cell cell--nature">
<?php if ($payment->type === 'subscription' && $payment->frequency === 'month'): ?>
abo. mensuel
<?php elseif ($payment->type === 'subscription' && $payment->frequency === 'year'): ?>
abo. annuel
<?php elseif ($payment->type === 'common_pot'): ?>
cagnotte
<?php elseif ($payment->type === 'credit'): ?>
crédit
<?php else: ?>
heu non…
<?php endif; ?>
</td>

<td class="cell cell--amount">
<?php if ($payment->type === 'credit'): ?>
-<?= $payment->amount / 100 ?>
<?php else: ?>
<?= $payment->amount / 100 ?>
<?php endif; ?>
</td>

<td class="cell cell--type">
<?php if ($payment->payment_intent_id): ?>
CB
<?php else: ?>
virement
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

0 comments on commit c9f5576

Please sign in to comment.