var userCache = {};
var groupsCache = {};
var netLevelsCache = {};
+var guardianNote = null;
/* fetch the necessary data to start off */
req.send(true);
return req.result();
}
+
/* ------------------------------------------------------------------------------ */
if( ! patron.ident_value2() ) patron.ident_value2(null);
var req = new Request(UPDATE_PATRON, SESSION, patron);
+ req.alertEvent = false;
req.send(true);
var newuser = req.result();
return;
} else {
+
+ /* if it's a new user and a guardian note was created for this user,
+ create the note after we have the new user's id */
+ if( guardianNote ) {
+ guardianNote.usr( newuser.id() );
+ var req = new Request(CREATE_USER_NOTE, SESSION, guardianNote);
+ req.alertEvent = false;
+ req.send(true);
+ var resp = req.result();
+ if( checkILSEvent(resp) ) {
+ alertILSEvent(resp,
+ "Error creating patron guardian/parent note");
+ return;
+ }
+ }
+
alert($('ue_success').innerHTML);
}
<span class='hide_me' id='ue_cancel_confirm'>
Are you sure you wish to cancel this editing session?
Canceling will destroy any unsaved changes you have made thus far to the user.
- </span>
+ </span>
+ <span class='hide_me' id='ue_juv_guardian'>
+ This patron is under 18 years of age. Please enter the name
+ of the parent or guardian for this patron.
+ </span>
+ <span class='hide_me' id='ue_bad_date'>
+ The date provided is either in the future or invalid. We're expecting YYYY-MM-DD
+ </span>
</div>
-
</body>
</html>
const ZIP_SEARCH = 'open-ils.search:open-ils.search.zip';
const FETCH_ADDR_MEMS = 'open-ils.actor:open-ils.actor.address.members';
const FETCH_GRP_MEMS = 'open-ils.actor:open-ils.actor.usergroup.members.retrieve';
+const CREATE_USER_NOTE = 'open-ils.actor:open-ils.actor.note.create';
const defaultState = 'GA';
const defaultCountry = 'USA';
const defaultNetAccess = 'None';
const CSS_INVALID_DATA = 'invalid_value';
+const ADULT_AGE = 18;
+const GUARDIAN_NOTE = 'SYSTEM: Parent/Guardian';
/* if they don't have these perms, they shouldn't be here */
var myPerms = [ 'CREATE_USER', 'UPDATE_USER', 'CREATE_PATRON_STAT_CAT_ENTRY_MAP' ];
id : 'ue_dob',
regex : dateRegex,
type : 'input',
+ onpostchange : function(field) { uEditCheckDOB(field); },
+ onblur : function(field) { uEditCheckDOB(field); }
}
},
{
+var __lastdob;
+function uEditCheckDOB(field) {
+
+ var dob = uEditNodeVal(field);
+
+ /* don't bother if the data isn't valid */
+ if(!dob || !dob.match(field.widget.regex))
+ return;
+
+ if( dob == __lastdob ) return;
+
+ __lastdob = dob;
+
+ var parts = dob.split(/-/);
+ var d = new Date( parts[0], parts[1] - 1, parts[2] );
+
+ dob = buildDate( parts[0], parts[1], parts[2] );
+
+ var today = new Date();
+
+ if(!dob || dob > today) {
+ addCSSClass(field.widget.node, CSS_INVALID_DATA);
+ alertId('ue_bad_date');
+ return;
+ }
+
+ var base = new Date();
+ base.setYear( today.getYear() + 1900 - ADULT_AGE );
+
+ /* patron already exists or is at least 18 */
+ if( !patron.isnew() || dob < base ) return;
+
+ if( guardianNote ) return;
+
+ /* create a new note to represent the patron's guardian */
+ var note = new aun();
+ note.title(GUARDIAN_NOTE);
+ note.isnew(1);
+ note.creator(USER.id());
+ note.isnew(1);
+
+ var txt; /* get the guardian info from the staff */
+ while(!txt || txt == "")
+ txt = prompt($('ue_juv_guardian').innerHTML);
+
+ note.value(txt);
+ guardianNote = note;
+}
+