Add page to view current members info.
authorSam White <webmaster@ycra.org.uk>
Wed, 10 Nov 2021 21:02:45 +0000 (21:02 +0000)
committerSam White <webmaster@ycra.org.uk>
Wed, 10 Nov 2021 21:02:45 +0000 (21:02 +0000)
public_html/members.php [new file with mode: 0644]

diff --git a/public_html/members.php b/public_html/members.php
new file mode 100644 (file)
index 0000000..b1db2aa
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+require_once('includes/utils.php');
+require_once('includes/html-templating.php');
+require_once('includes/database.php');
+require_once('includes/auth.php');
+
+function pre_html() {
+  session_start();
+}
+
+function page_title() {
+  return 'Members list';
+}
+
+function content() {
+  if (!check_logged_in()) {?>
+    <h1>Restricted access page</h1><?php
+    return;
+  }?>
+
+  <h1>YCRA Members</h1>
+
+  <p>Below is a list of members, listed in order of newest first. If the member
+  tried to submit the membership form more than once (with the same email
+  address), only the latest submitted information is shown.</p>
+
+  <p>Please note this is a work in progress and the membership records will be
+  fully reconciled at some point.</p><?php
+
+  $result = run_sql('SELECT * FROM members GROUP BY(email_address) ORDER BY id DESC');
+  $members_num = 0;?>
+
+  <table>
+    <tr>
+      <th>ID</th>
+      <th>Name</th>
+      <th>Email address</th>
+      <th>Date added</th>
+      <th>Date joined</th>
+      <th>Address</th>
+      <th>PayPal?</th>
+    </tr><?php
+    while ($member = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
+      $members_num++;?>
+      <tr>
+        <td><?php esc($member['id']);?></td>
+        <td><?php esc($member['first_name'] . ' ' . $member['surname']);?></td>
+        <td><?php esc($member['email_address']);?></td>
+        <td><?php
+          esc($member['date_added']
+                      ? date('j M Y', strtotime($member['date_added']))
+                      : '');?>
+        </td>
+        <td><?php
+          esc($member['date_joined']
+                      ? date('j M Y', strtotime($member['date_joined']))
+                      : '');?>
+        </td>
+        <td><?php
+          foreach (['address_line_1', 'address_line_2', 'city', 'region',
+                    'postcode', 'country'] as $k) {
+            esc($member[$k]);?> <br /><?php
+          }?>
+        </td>
+        <td><?php esc($member['paypal_attempt'] ? 'Yes' : 'No');?></td>
+      </tr><?php
+    }?>
+  </table><?php
+
+  esc('Total number of members: ' . $members_num);
+}
+
+require_once('includes/template.php');
+?>