Skip to content
Snippets Groups Projects
Commit 5bc29dcc authored by Tim Clark's avatar Tim Clark
Browse files

Makes it easy to join student ids to signup ids

parent b783d40f
No related branches found
No related tags found
No related merge requests found
<?php
// Config options
$permission="staff";
// DEV: UNSTICK THIS BEFORE DEPLOY
if (isset($session->groups[$permission])) {
$smarty->assign("staff",TRUE);
// connect to sucs database
$sucsDB = NewADOConnection('postgres8');
$sucsDB->Connect('dbname=sucs');
$sucsDB->SetFetchMode(ADODB_FETCH_ASSOC);
//get unused signup slips
$query = "SELECT id, sid, type, issuedby, card FROM signup";
$query .= " WHERE";
$query .= " activated is NULL";
$query .= " or username is NULL";
$query .= " ORDER BY id";
$query .= ";";
$data = $sucsDB->GetAll($query);
// process responces
if(isset($_POST['command'])){
if($_POST['command']=='update'){
$changed = 0;
$upquery = "UPDATE signup";
$upquery .= " SET sid = ?";
$upquery .= " WHERE id = ?";
$upquery .= ";";
foreach($data as $value){
if(array_key_exists('sid:'.$value['id'],$_POST) && $_POST['sid:'.$value['id']]!=$value['sid']){
$uparray = array($_POST['sid:'.$value['id']],$value['id']);
$sucsDB->query($upquery,$uparray);
$changed++;
}
}
message_flash($changed." record(s) updated");
}
}
$data = $sucsDB->GetAll($query);
//set smarty stuff
$smarty->assign("signups",$data);
$smarty->assign("self",$baseurl.$path.$getout);
}
$body = $smarty->fetch("signup-admin.tpl");
$smarty->assign('title', "Signup Slip Admin");
$smarty->assign('body', $body);
?>
{if $staff == TRUE}
<form action="" method="post">
<table border='1'>
<tr><th>ID</th><th>SID</th><th>Type</th><th>Issued By</th><th>Card Number</th></tr>
{foreach name=signups from=$signups item=signup}
<tr>
<td>{$signup.id|escape}</td>
<td><input type="text" size="10" name="sid:{$signup.id|escape}" value="{$signup.sid|escape}" /></td>
<td>{$signup.type|escape}</td>
<td>{$signup.issuedby|escape}</td>
<td>{$signup.card|escape}</td>
</tr>
{/foreach}
</table>
<input type='hidden' name='command' value='update' />
<input type='submit' value='Update Records'/>
<input type='reset' value='Reset'/>
</form>
{else}
<div class="errorbar">
<div><div><div>
You must be logged in and be a staff member to modify signup details;
</div></div></div>
</div>
{/if}
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