Fix import and display issues

This commit is contained in:
patrick 2025-02-16 00:48:25 +00:00
parent 76f2d5c214
commit cefdfbe868
2 changed files with 13 additions and 12 deletions

View File

@ -98,7 +98,7 @@ if (get_value_from_array($_POST, 'save') == 'edit' || get_value_from_array($_POS
/* Get info about science head */
// FIX ME
$split = explode(' ', get_value_from_array($_POST, 'principal') ?? '', 2);
$split = explode(' ', get_value_from_array($_POST, 'principal', ''), 2);
if (count($split) === 2) {
list($first, $last) = $split;
@ -181,7 +181,7 @@ if (get_value_from_array($_POST, 'save') == 'edit' || get_value_from_array($_POS
$stmt->execute([
get_value_from_array($_POST, 'school'),
get_value_from_array($_POST, 'schoollang'),
get_value_from_array($_POST, 'designate'), // FIXED: Corrected key name
get_value_from_array($_POST, 'designate', ''),
get_value_from_array($_POST, 'schoollevel'),
get_value_from_array($_POST, 'board'),
get_value_from_array($_POST, 'district'),
@ -192,13 +192,13 @@ if (get_value_from_array($_POST, 'save') == 'edit' || get_value_from_array($_POS
get_value_from_array($_POST, 'schoolemail'),
get_value_from_array($_POST, 'phone'),
get_value_from_array($_POST, 'fax'),
get_value_from_array($_POST, 'registration_password'),
get_value_from_array($_POST, 'projectlimit'),
get_value_from_array($_POST, 'projectlimitper'),
get_value_from_array($_POST, 'registration_password', ''),
get_value_from_array($_POST, 'projectlimit', 0),
get_value_from_array($_POST, 'projectlimitper', 0),
get_value_from_array($_POST, 'accesscode'),
get_value_from_array($_POST, 'sciencehead'), // FIXED: Using function for consistency
get_value_from_array($_POST, 'sciencehead'),
get_value_from_array($_POST, 'principal'),
get_value_from_array($_POST, 'atrisk'),
get_value_from_array($_POST, 'atrisk', 'no'),
get_value_from_array($_POST, 'id')
]);
@ -263,6 +263,7 @@ if (get_value_from_array($_GET, 'action') == 'edit' || get_value_from_array($_GE
echo '<option value="">' . i18n('Choose') . "</option>\n";
foreach ($config['languages'] AS $k => $l) {
$sel = ($r->schoollang == $k) ? 'selected="selected"' : '';
echo "<option $sel value=\"$k\">" . i18n($l) . "</option>\n";
}
echo '</select>';

View File

@ -58,7 +58,7 @@ if (get_value_from_array($_POST, 'action') == 'import') {
$row = explode(',', $raw_row[0]);
for ($n = 0; $n < count($row); $n++) {
$row[$n] = trim($row[$n]);
$row[$n] = trim(trim($row[$n]), '"');
}
// $email = $row[16];
@ -110,23 +110,23 @@ if (get_value_from_array($_POST, 'action') == 'import') {
$stmt->bindParam(':registration_password', $row[13]);
$stmt->bindParam(':projectlimit', $row[14]);
$stmt->bindParam(':projectlimitper', $row[15]);
$stmt->bindParam(':year', $row[16]);
$stmt->bindParam(':year', $config['FAIRYEAR']);
$stmt->bindParam(':principal_uid', $principal['uid']);
$stmt->bindParam(':sciencehead_uid', $scienceHead['uid']);
$stmt->execute();
if (!$pdo->errorInfo())
if ($pdo->errorInfo() != '00000') {
$loaded++;
else
} else {
show_pdo_errors_if_any($pdo);
}
}
echo happy(i18n('Successfully loaded %1 schools', array($loaded)));
echo '<a href="schools.php">' . i18n('School Management') . '</a> <br />';
} else {
echo error(i18n('Found no CSV data in the uploaded file'));
}
print_r($data);
} else {
echo error(i18n('Please choose a valid CSV file to upload'));
$showform = true;