173 lines
5.0 KiB
PHP
173 lines
5.0 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$PageTitle = getLanguageText('TEXT-STUDENT-UPDATE');
|
|
$ButtonText = getLanguageText('TEXT-UPLOAD-FILE');
|
|
|
|
?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
$("#upload-form").submit(function(e) {
|
|
var csvFile = $("#filename").val();
|
|
var grade = $("#grade").val();
|
|
var division = $("#division").val();
|
|
|
|
if (csvFile.length == 0) {
|
|
alert("<?php displayLanguageText('ERRORMSG-DATA-FILE-NOT-SPECIFIED'); ?>");
|
|
return false;
|
|
}
|
|
});
|
|
|
|
});
|
|
</script>
|
|
<br>
|
|
<form method='post' id='upload-form' enctype='multipart/form-data' action='/'>
|
|
<?php
|
|
$message_width = $default_form_width;
|
|
include "form.messages.php";
|
|
?>
|
|
<table width='<?php echo($default_form_width) ?>' class='content-table'>
|
|
<tr>
|
|
<td colspan='2' align='center' class='heading'><?php echo($PageTitle) ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<p><?php displayLanguageText('TEXT-UP-LOAD-FILE-FORMAT'); ?></p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td width='40%' align='right' valign='top'>File: </td>
|
|
<td align='left' valign='top'><input type='file' name='filename' id='filename' size='40'></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<br>
|
|
<p><?php displayLanguageText('TEXT-CSV-COLUMN-SELECTION'); ?></p>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$fp = fopen("students_update.txt","r");
|
|
$entry = trim(fgets($fp,1000));
|
|
|
|
$student_fields = array();
|
|
$count = 0;
|
|
$fields = "";
|
|
|
|
while (!feof($fp)) {
|
|
if (strlen($entry) == 0) break;
|
|
|
|
list($field,$prompt,$additional) = preg_split('/:/',$entry);
|
|
$student_fields[$count]['field'] = $field;
|
|
if (strlen($fields)) $fields .= ",";
|
|
$fields .= $field;
|
|
|
|
if (str_match("TEXT-",$prompt)) $code = $prompt;
|
|
else $code = "TEXT-" . str_replace(" ","-",strtoupper($prompt));
|
|
$text = getLanguageText($code);
|
|
$student_fields[$count]['prompt'] = $text;
|
|
|
|
$atext = "";
|
|
if (strlen($additional)) $atext = " (" . getLanguageText($additional) . ")";
|
|
$student_fields[$count]['additional'] = $atext;
|
|
|
|
$entry = trim(fgets($fp,1000));
|
|
$count++;
|
|
}
|
|
|
|
$colCount = 30;
|
|
if (count($student_fields) > 20) $colCount = count($student_fields) + 20;
|
|
|
|
for ($i = 0; $i < count($student_fields); $i++) {
|
|
$prompt = $student_fields[$i]['prompt'];
|
|
$field = $student_fields[$i]['field'];
|
|
$column = intval(db_getVal("SELECT column_num FROM upload_columns WHERE school_num = $school_num AND action = 'students-update' AND field = '$field'"));
|
|
?>
|
|
<tr>
|
|
<td align='right' valign='top'><?php echo($prompt) ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<select name='<?php echo($field) ?>' id='<?php echo($field) ?>'>
|
|
<option value='0'></option>
|
|
<?php
|
|
for ($j = 1; $j <= $colCount; $j++) {
|
|
$l = $j - 1;
|
|
$letter = $Letters[$l];
|
|
$selected = "";
|
|
if ($j == $column) $selected = " selected='selected'";
|
|
|
|
echo(" <option value='$j' $selected>Column $j ($letter)</option>\n");
|
|
}
|
|
?>
|
|
</select> <span class='small'><?php echo($student_fields[$i]['additional']) ?></span>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$num = $i + 1;
|
|
}
|
|
|
|
if ($school_record['user_defined_values'] == 'Y') {
|
|
$field = "user_defined_value";
|
|
$prompt = $school_record['user_defined_title'];
|
|
?>
|
|
<tr height='10'>
|
|
<td colspan='2'> </td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php echo($prompt) ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<select name='<?php echo($field) ?>'>
|
|
<option value='0'></option>
|
|
<?php
|
|
for ($j = 1; $j <= count($student_fields) + 10; $j++) {
|
|
$l++;
|
|
$letter = $Letters[$l];
|
|
echo(" <option value='$j'>Column $j ($letter)</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
<tr>
|
|
<td colspan='2'> </td>
|
|
</tr>
|
|
<?php
|
|
$skip_first_row = db_getVal("SELECT value FROM upload_columns WHERE school_num = $school_num AND action = 'students-update' AND field = 'skip_first_row'");
|
|
if (strlen($skip_first_row) == 0) $skip_first_row = "N";
|
|
?>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-SKIP-FIRST-ROW'); ?>: </td>
|
|
<td align='left' valign='top'><?php BuildFileRadio("yn.txt","skip_first_row","$skip_first_row") ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<br>
|
|
<input type='submit' id='submitButton' class='btn btn--primary' value='<?php echo($ButtonText) ?>'>
|
|
<input type='hidden' name='action' value='students'>
|
|
<input type='hidden' name='naction' value='students-update-upload'>
|
|
<input type='hidden' name='fields' value='<?php echo($fields) ?>'>
|
|
<input type='hidden' name='num_fields' value='<?php echo(count($student_fields)) ?>'>
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|