'UNKNOWN_ERROR' : 'An unhandled exception occurred with error code ${0}',
'MAX_RENEWALS' : 'No more renewals allowed for item ${0}',
'ITEM_NOT_CATALOGED' : 'Item ${0} was not found in the system. Try re-scanning the item.',
- 'WORKSTATION_REQUIRED' : 'Workstation is required. Set the workstation name with URL param "ws"'
+ 'WORKSTATION_REQUIRED' : 'A workstation is required to log in to selfcheck. You can set the workstation name with URL param "ws". \n\nWould you like to register a new workstation for this self-check interface?',
+ 'WORKSTATION_EXISTS' : 'This workstation has already been registered. Would you like to use it for this self-check station?'
}
dojo.require('openils.User');
dojo.require('openils.Event');
dojo.require('openils.widget.ProgressDialog');
+dojo.require('openils.widget.OrgUnitFilteringSelect');
dojo.requireLocalization('openils.circ', 'selfcheck');
var localeStrings = dojo.i18n.getLocalization('openils.circ', 'selfcheck');
// workstation is required but none provided
if(this.orgSettings[SET_WORKSTATION_REQUIRED] && !this.workstation) {
- alert(dojo.string.substitute(localeStrings.WORKSTATION_REQUIRED));
+ if(confirm(dojo.string.substitute(localeStrings.WORKSTATION_REQUIRED))) {
+ this.registerWorkstation();
+ }
return;
}
}
}
+
+/**
+ * Registers a new workstion
+ */
+SelfCheckManager.prototype.registerWorkstation = function() {
+
+ oilsSelfckWsDialog.show();
+
+ new openils.User().buildPermOrgSelector(
+ 'REGISTER_WORKSTATION',
+ oilsSelfckWsLocSelector,
+ this.staff.home_ou()
+ );
+
+
+ var self = this;
+ dojo.connect(oilsSelfckWsSubmit, 'onClick',
+
+ function() {
+ oilsSelfckWsDialog.hide();
+ var name = oilsSelfckWsLocSelector.attr('displayedValue') + '-' + oilsSelfckWsName.attr('value');
+
+ var res = fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.workstation.register'],
+ { params : [
+ self.authtoken, name, oilsSelfckWsLocSelector.attr('value')
+ ]
+ }
+ );
+
+ if(evt = openils.Event.parse(res)) {
+ if(evt.textcode == 'WORKSTATION_NAME_EXISTS') {
+ if(confirm(localeStrings.WORKSTATION_EXISTS)) {
+ location.href = location.href.replace(/\?.*/, '') + '?ws=' + name;
+ } else {
+ self.registerWorkstation();
+ }
+ return;
+ } else {
+ alert(evt);
+ }
+ } else {
+ location.href = location.href.replace(/\?.*/, '') + '?ws=' + name;
+ }
+ }
+ );
+}
+
/**
* Loads the org unit settings
*/
[% INCLUDE 'default/circ/selfcheck/summary.tt2' %]
</div>
</div>
-<div dojoType='openils.widget.ProgressDialog' jsId='progressDialog'/>
+<div dojoType='openils.widget.ProgressDialog' jsId='progressDialog'></div>
+<div dojoType="dijit.Dialog" jsId='oilsSelfckWsDialog' class='oils-login-dialog' style='display:none;'>
+ <form>
+ <table>
+ <tr>
+ <td>Choose a location</td>
+ <td><div dojoType='openils.widget.OrgUnitFilteringSelect' jsId='oilsSelfckWsLocSelector'
+ searchAttr='shortname' labelAttr='shortname'/></td>
+ </tr>
+ <tr>
+ <td>Enter a workstation name</td>
+ <td><input dojoType='dijit.form.TextBox' jsId='oilsSelfckWsName'/></td>
+ </tr>
+ <tr>
+ <td colspan='2' align='center'>
+ <button jsId='oilsSelfckWsSubmit' dojoType='dijit.form.Button'>Submit</button>
+ </td>
+ </tr>
+ </table>
+ </form>
+</div>
[% END %]