Update the status on save and on page load

This commit is contained in:
james 2009-11-26 18:29:03 +00:00
parent d954d148d6
commit dbad8ae320

View File

@ -63,7 +63,7 @@
'regexp' => '^[1-9][0-9]{2}-[1-9][0-9]{2}-[0-9]{4}$', 'regexp' => '^[1-9][0-9]{2}-[1-9][0-9]{2}-[0-9]{4}$',
'format' => '\'NNN-NNN-NNNN\'',), 'format' => '\'NNN-NNN-NNNN\'',),
'postalcode' => array('name' => $config['postalzip'], 'postalcode' => array('name' => $config['postalzip'],
'regexp' => '^(([A-Z][0-9][A-Z]( )?[0-9][A-Z][0-9])|([0-9]{5}))$', 'regexp' => '^(([A-Za-z][0-9][A-Za-z]( )?[0-9][A-Za-z][0-9])|([0-9]{5}))$',
'format' => '\'ANA NAN\' or \'ANANAN\' or \'NNNNN\'',), 'format' => '\'ANA NAN\' or \'ANANAN\' or \'NNNNN\'',),
); );
@ -81,6 +81,7 @@ if($eid != $_SESSION['users_id']) {
* a committee member */ * a committee member */
user_auth_required('committee','admin'); user_auth_required('committee','admin');
} }
$type = $_SESSION['users_type'];
$u = user_load($eid); $u = user_load($eid);
/* Load the fields the user can edit, and theones that are required */ /* Load the fields the user can edit, and theones that are required */
@ -160,12 +161,19 @@ case 'save':
user_save($u); user_save($u);
happy_("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname'])); happy_("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname']));
} }
//reload the user record because we dont know if we saved or didnt save above, we just want
//to know what the user looks like _now_
$u = user_load($users_id);
$newstatus=user_personal_info_status($u);
echo "<script type=\"text/javascript\">";
echo "personal_update_status('$newstatus');\n";
echo "</script>\n";
exit; exit;
} }
$type = $_SESSION['users_type'];
//send the header //send the header
if($_SESSION['embed'] == true) { if($_SESSION['embed'] == true) {
echo "<br/>"; echo "<br/>";
@ -179,6 +187,7 @@ case 'save':
); );
} }
$newstatus=user_personal_info_status($u);
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function personal_save() function personal_save()
@ -186,28 +195,22 @@ function personal_save()
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/user_personal.php?action=save", $("#personal_form").serializeArray()); $("#debug").load("<?=$config['SFIABDIRECTORY']?>/user_personal.php?action=save", $("#personal_form").serializeArray());
return false; return false;
} }
</script>
<? function personal_update_status(s) {
if(s!='complete') {
$("#personal_info_status").html('<?=error(i18n("Personal Information Incomplete"))?>');
foreach($errorfields as $f) {
echo error(i18n('\'%1\' must use the format: %2',
array(i18n($user_personal_fields[$f]['name']),
$user_personal_fields[$f]['format'])));
} }
if(count($errorfields)) {
echo error(i18n('Information will not be saved until the above errors are corrected'));
} else {
//output the current status
$newstatus=user_personal_info_status($u);
if($newstatus!='complete')
echo error(i18n("Personal Information Incomplete"));
else else
echo happy(i18n("Personal Information Complete")); $("#personal_info_status").html('<?=happy(i18n("Personal Information Complete"))?>');
} }
//when we're ready, output the status
$(document).ready( function() { personal_update_status('<?=$newstatus?>');});
</script>
<?
echo "<div id=\"personal_info_status\"></div>";
if(count($u['types']) > 1) { if(count($u['types']) > 1) {
$roles=''; $roles='';
foreach($u['types'] as $t) { foreach($u['types'] as $t) {