124 lines
3.4 KiB
PHP
124 lines
3.4 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-STAFF-UPLOAD');
|
|
$ButtonText = getLanguageText('TEXT-UPLOAD-FILE');
|
|
|
|
?>
|
|
<br>
|
|
<form method='post' 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'> </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("staff_upload.txt","r");
|
|
$entry = trim(fgets($fp,1000));
|
|
|
|
$data_fields = array();
|
|
$count = 0;
|
|
$fields = "";
|
|
|
|
while (!feof($fp)) {
|
|
if (strlen($entry) == 0) break;
|
|
|
|
list($field,$prompt) = preg_split('/:/',$entry);
|
|
$data_fields[$count]['field'] = $field;
|
|
if (strlen($fields)) $fields .= ",";
|
|
$fields .= $field;
|
|
|
|
$code = "TEXT-" . str_replace(" ","-",strtoupper($prompt));
|
|
$text = getLanguageText($code);
|
|
$data_fields[$count]['prompt'] = $text;
|
|
|
|
$entry = trim(fgets($fp,1000));
|
|
$count++;
|
|
}
|
|
|
|
for ($i = 0; $i < count($data_fields); $i++) {
|
|
$prompt = $data_fields[$i]['prompt'];
|
|
$field = $data_fields[$i]['field'];
|
|
?>
|
|
<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($data_fields) + 5; $j++) {
|
|
$l = $j - 1;
|
|
$letter = $Letters[$l];
|
|
|
|
echo(" <option value='$j'>Column $j ($letter)</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$num = $i + 1;
|
|
}
|
|
?>
|
|
<tr>
|
|
<td colspan='2'> </td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-USER-ID'); ?>: </td>
|
|
<td align='left' valign='top'><?php BuildFileRadio("staff_upload.userid.txt","userid_source","First Name and Last Name","<br>") ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-PASSWORD'); ?>: </td>
|
|
<td align='left' valign='top'><?php BuildFileRadio("staff_upload.password.txt","password_source","First Name and Last Name","<br>") ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<br>
|
|
<input type='submit' class='btn btn--primary' value='<?php echo($ButtonText) ?>'>
|
|
<input type='hidden' name='action' value='staff'>
|
|
<input type='hidden' name='naction' value='upload'>
|
|
<input type='hidden' name='fields' value='<?php echo($fields) ?>'>
|
|
<input type='hidden' name='num_fields' value='<?php echo(count($data_fields)) ?>'>
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|