forked from science-ation/science-ation
Add a Registration tab to the student editor (regnum, fair, status)
This commit is contained in:
parent
eb2f9e769f
commit
4739e3fdf0
@ -73,9 +73,11 @@ case 'delete':
|
||||
<ul>
|
||||
<li><a href="#editor_tab_students"><span><?=i18n('Students')?></span></a></li>
|
||||
<li><a href="#editor_tab_project"><span><?=i18n('Project')?></span></a></li>
|
||||
<li><a href="#editor_tab_reg"><span><?=i18n('Registration')?></span></a></li>
|
||||
</ul>
|
||||
<div id="editor_tab_students">Loading...</div>
|
||||
<div id="editor_tab_project">Loading...</div>
|
||||
<div id="editor_tab_reg">Loading...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -180,14 +182,6 @@ function update_project()
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
var id=sponsor_id;
|
||||
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=activityinfo_load&id="+id,
|
||||
function(json){
|
||||
$("#sponsor_id").val(json.id);
|
||||
});
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -205,6 +199,24 @@ function delete_registration(id)
|
||||
|
||||
}
|
||||
|
||||
function update_reg()
|
||||
{
|
||||
var id = registrations_id;
|
||||
$("#editor_tab_reg").load("student_editor.php?action=registration_load&id="+id, '',
|
||||
function(responseText, textStatus, XMLHttpRequest) {
|
||||
/* Attach to save button */
|
||||
$("#registration_save").click(function() {
|
||||
var id = registrations_id;
|
||||
$("#debug").load("student_editor.php?action=registration_save&id="+id, $("#registration_form").serializeArray());
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
@ -242,6 +254,9 @@ $(document).ready(function() {
|
||||
case 'editor_tab_project':
|
||||
update_project();
|
||||
break;
|
||||
case 'editor_tab_reg':
|
||||
update_reg();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -30,6 +30,14 @@ $registrations_id = intval($_GET['id']);
|
||||
$action = $_GET['action'];
|
||||
|
||||
switch($action) {
|
||||
case 'registration_load':
|
||||
registration_load();
|
||||
exit;
|
||||
|
||||
case 'registration_save':
|
||||
registration_save();
|
||||
exit;
|
||||
|
||||
case 'students_load':
|
||||
students_load();
|
||||
exit;
|
||||
@ -374,4 +382,86 @@ echo "<br />";
|
||||
}
|
||||
|
||||
|
||||
function registration_load()
|
||||
{
|
||||
global $registrations_id, $config;
|
||||
|
||||
/* Load reg data */
|
||||
$q = mysql_query("SELECT * FROM registrations WHERE id='$registrations_id'");
|
||||
if(mysql_num_rows($q) != 1)
|
||||
$r = array();
|
||||
else {
|
||||
$r = mysql_fetch_assoc($q);
|
||||
/* Get the fair from the project */
|
||||
$q = mysql_query("SELECT fairs_id FROM projects WHERE registrations_id='$registrations_id'");
|
||||
if(mysql_num_rows($q) == 1) {
|
||||
$p = mysql_fetch_assoc($q);
|
||||
$r['fairs_id'] = $p['fairs_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Load fairs */
|
||||
$fairs = array();
|
||||
$q = mysql_query("SELECT * FROM fairs WHERE type='feeder'");
|
||||
while(($f = mysql_fetch_assoc($q))) {
|
||||
$fairs[$f['id']] = $f;
|
||||
}
|
||||
|
||||
/* Print form */
|
||||
$status = array('new'=>'New', 'open'=>'Open','paymentpending'=>'Payment Pending', 'complete'=>'Complete');
|
||||
|
||||
?>
|
||||
<form id="registration_form">
|
||||
<table>
|
||||
<tr>
|
||||
<td><?=i18n("Registration Number")?>:</td>
|
||||
<td><input type="text" name="registration_num" value="<?=$r['num']?>"></td>
|
||||
</tr><tr>
|
||||
<td><?=i18n("Status")?>:</td>
|
||||
<td><select name="registration_status">
|
||||
<? foreach($status as $k=>$v) {
|
||||
$sel = ($k == $r['status']) ? 'selected="selected"' : '';
|
||||
echo "<option $sel value=\"$k\">$v</option>";
|
||||
}
|
||||
?> </select></td>
|
||||
</tr><tr>
|
||||
<td><?=i18n("Fair")?>:</td>
|
||||
<td><select name="registration_fair">
|
||||
<option value="0"><?=i18n('Independent/None')?></option>
|
||||
<? foreach($fairs as $fid=>$f) {
|
||||
$sel = ($fid == $r['fairs_id']) ? 'selected="selected"' : '';
|
||||
echo "<option $sel value=\"$fid\">{$f['name']}</option>";
|
||||
}
|
||||
?> </select></td>
|
||||
</tr></table>
|
||||
<br /><br />
|
||||
<button id="registration_save"><?=i18n('Save Registration Information')?></button>
|
||||
</form>
|
||||
<?
|
||||
}
|
||||
|
||||
function registration_save()
|
||||
{
|
||||
global $registrations_id, $config;
|
||||
$registration_num = intval($_POST['registration_num']);
|
||||
$registration_status = mysql_real_escape_string(stripslashes($_POST['registration_status']));
|
||||
$fairs_id = intval($_POST['registration_fair']);
|
||||
|
||||
/* Update registration */
|
||||
mysql_query("UPDATE registrations SET
|
||||
num='$registration_num',
|
||||
status='$registration_status'
|
||||
WHERE
|
||||
id='$registrations_id'");
|
||||
echo mysql_error();
|
||||
|
||||
/* And the fairs_id */
|
||||
mysql_query("UPDATE projects SET
|
||||
fairs_id='$fairs_id'
|
||||
WHERE
|
||||
registrations_id='$registrations_id'");
|
||||
echo mysql_error();
|
||||
happy_('Information Saved');
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user