Skip to content
Snippets Groups Projects
Commit 31ae507b authored by Thomas Lake's avatar Thomas Lake :wrench:
Browse files

Add member list from SU API

parent f28d53f7
No related branches found
No related tags found
No related merge requests found
...@@ -244,6 +244,30 @@ if (isset($session->groups[$permission])) { ...@@ -244,6 +244,30 @@ if (isset($session->groups[$permission])) {
$smarty->assign("failusers", $failures); $smarty->assign("failusers", $failures);
$smarty->assign("successes", count($successes)); $smarty->assign("successes", count($successes));
} }
} else if ($mode == 'list') {
//Get list of members according to the SU
$url = "https://$suapi_user:$suapi_pass@hap.swansea-union.co.uk/memberships/Membership.asmx/GetMemberListData?GroupingId=6613";
$apiReq = curl_init();
curl_setopt($apiReq, CURLOPT_URL, $url);
curl_setopt($apiReq, CURLOPT_RETURNTRANSFER, TRUE);
$apiResult = curl_exec($apiReq);
$sumembers = su_response_decode($apiResult);
$matches = array();
foreach ($sumembers as $sumem) {
$sucsmem = get_sucs_record($sumem['uni_card_number']);
if ($sucsmem) {
$matches[]=array($sumem['firstName']." ".$sumem['lastName'], $sucsmem['realname'], $sumem['uni_card_number'], $sucsmem['username'], $sucsmem['paid']);
} else {
$matches[]=array($sumem['firstName']." ".$sumem['lastName'], "N/A", $sumem['uni_card_number'], "N/A", "Not signed up");
}
}
function sortbypaid($a, $b) {
//Lets us array sort by final column ('Paid')
return ($a[4] < $b[4]) ? -1 : 1;
}
usort($matches, 'sortbypaid');
$smarty->assign("matches", $matches);
} }
} }
......
div.susignup-admin-menu { div.susignup-admin-menu {
float: left; float: left;
width: 30%; width: 22%;
margin-left: 10px; margin-left: 10px;
background: #E76808; background: #E76808;
border-radius: 15px; border-radius: 15px;
......
...@@ -46,6 +46,20 @@ The following accounts failed to renew: ...@@ -46,6 +46,20 @@ The following accounts failed to renew:
{/if} {/if}
</div> </div>
</div> </div>
{elseif $mode == 'list'}
<table id='susignup-renewals'>
<thead>
<tr><th>Name (SU)</th><th>Name (SUCS)</th><th>Student ID</th><th>SUCS Username</th><th>Paid Until</th></tr>
</thead>
<tbody>
{foreach from=$matches item=match}
<tr><td>{$match[0]}</td><td>{$match[1]}</td><td class='centre'>{$match[2]}</td><td>{$match[3]}</td><td class='centre'>{$match[4]}</td></tr>
{foreachelse}
<tr><td colspan='6'><em>Oh Noes! No members found in the SU database</em></td></tr>
{/foreach}
</tbody>
</table>
{elseif $mode == 'search'} {elseif $mode == 'search'}
<div style='text-align: center'> <div style='text-align: center'>
<div class='cbb' style='text-align: left'> <div class='cbb' style='text-align: left'>
...@@ -67,6 +81,15 @@ This component allows staff members to sort out memberships and renewals that ha ...@@ -67,6 +81,15 @@ This component allows staff members to sort out memberships and renewals that ha
</p> </p>
<div style='text-align: center'> <div style='text-align: center'>
<div class='susignup-admin-menu cbb'> <div class='susignup-admin-menu cbb'>
<h3>Signup a newbie</h3>
<form action='{$componentpath}' method='post'>
<label for='sid'>Student Number:</label>
<input type='text' name='sid' id='sid' maxlength=6 />
<input type='hidden' name='mode' id='mode' value="search" />
<input type='submit' name='snsubmit' id='snsubmit' value="Start" />
</form>
</div>
<div class='susignup-admin-menu cbb'>
<h3>Renew existing account:</h3> <h3>Renew existing account:</h3>
<form action='{$componentpath}' method='post'> <form action='{$componentpath}' method='post'>
<label for='member'>Account:</label> <label for='member'>Account:</label>
...@@ -77,19 +100,18 @@ This component allows staff members to sort out memberships and renewals that ha ...@@ -77,19 +100,18 @@ This component allows staff members to sort out memberships and renewals that ha
</div> </div>
<div class='susignup-admin-menu cbb'> <div class='susignup-admin-menu cbb'>
<h3>Bulk Renewals</h3> <h3>Bulk Renewals</h3>
<p style='text-align: left'>This will query the SU API for all current SUCS members and generate a list of corresponding SUCS accounts to be renewed.<br /> This process can take a little while to run</p><br /> <p style='text-align: left'>This will query the SU API and generate a list of corresponding SUCS accounts to be renewed.<br /> This process can take a little while to run</p><br />
<form action='{$componentpath}' method='post'> <form action='{$componentpath}' method='post'>
<input type='submit' name='rwsubmit' id='rwsubmit' value='Generate List' /> <input type='submit' name='rwsubmit' id='rwsubmit' value='Generate List' />
<input type='hidden' name='mode' id='mode' value='renewals' /> <input type='hidden' name='mode' id='mode' value='renewals' />
</form> </form>
</div> </div>
<div class='susignup-admin-menu cbb'> <div class='susignup-admin-menu cbb'>
<h3>Signup a newbie</h3> <h3>SU Membership List</h3>
<p style='text-align: left'>This will query the SU API for all current SUCS members<br /> This process can take a little while to run</p><br />
<form action='{$componentpath}' method='post'> <form action='{$componentpath}' method='post'>
<label for='sid'>Student Number:</label> <input type='submit' name='lssubmit' id='lssubmit' value='View List' />
<input type='text' name='sid' id='sid' maxlength=6 /> <input type='hidden' name='mode' id='mode' value='list' />
<input type='hidden' name='mode' id='mode' value="search" />
<input type='submit' name='snsubmit' id='snsubmit' value="Start" />
</form> </form>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment