95 lines
2.5 KiB
PHP
95 lines
2.5 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Setup parameters
|
|
$CurrentTable = "schools";
|
|
$FormFile = "school.form.php";
|
|
$TitleText = getLanguageText('TEXT-SCHOOL-PROFILE');
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = $GlobalText['OrganizationProfile'];
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Communications Administrator','Administration Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
endTemplate();
|
|
exit();
|
|
}
|
|
|
|
|
|
$SchoolFormName = "school-form";
|
|
$ConfirmButtonID = "save-school-record";
|
|
|
|
include $FormFile;
|
|
?>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
$.ajax({
|
|
url: "ajax.DataRecord.Fetch.php",
|
|
data: {
|
|
table_name: "schools",
|
|
record_num: <?php echo($school_num) ?>
|
|
},
|
|
dataType: "json",
|
|
error:
|
|
function(jqXHR, exception) {
|
|
alert("Exception: "+jqXHR.status+' '+jqXHR.statusText);
|
|
}
|
|
}).done(
|
|
function(results) {
|
|
$("#school-form .form-field").each(function() {
|
|
var fname = $(this).attr('name');
|
|
$("#school-form #"+fname).val('');
|
|
$("#school-form #"+fname).val(results[fname]);
|
|
});
|
|
}
|
|
);
|
|
|
|
$(document).on('click touch', '#save-school-record', function(e) {
|
|
e.preventDefault();
|
|
|
|
var errmsg = "<?php displayLanguageText('TEXT-UNABLE-TO-UPDATE-DEMO-PROFILE'); ?>";
|
|
var rnum = '<?php echo($school_num) ?>';
|
|
$("#school-form #record_num").val(rnum);
|
|
|
|
<?php if ($_SESSION['UserInfo']['type'] != 'SuperUser') { ?>
|
|
if (rnum == 3) {
|
|
alert(errmsg);
|
|
return false;
|
|
}
|
|
|
|
<?php } ?>
|
|
var form_data = $("#school-form").serialize();
|
|
var data = form_data+"&table_name=schools&sequence=N*record_num="+rnum;
|
|
|
|
$.ajax({
|
|
url: "ajax.DataRecord.Update.php",
|
|
method: 'POST',
|
|
data: data,
|
|
dataType: "json"
|
|
}).done(function(data) {
|
|
alert("<?php displayLanguageText('TEXT-DATA-HAS-BEEN-SAVED'); ?>");
|
|
}
|
|
);
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
endTemplate();
|
|
?>
|