(35, 'usr.card'),
(35, 'pickup_lib')
;
+
+-- 0386.data.org-setting-patron-clone-copy-addr.sql
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+ 'circ.patron_edit.clone.copy_address',
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'Patron Registration: Cloned patrons get address copy',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'In the Patron editor, copy addresses from the cloned user instead of linking directly to the address',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+);
+
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0386');
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+ 'circ.patron_edit.clone.copy_address',
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'Patron Registration: Cloned patrons get address copy',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'In the Patron editor, copy addresses from the cloned user instead of linking directly to the address',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+);
+
+COMMIT;
var stageUser;
var optInSettings;
var allCardsTemplate;
+var uEditCloneCopyAddr; // if true, copy addrs on clone instead of link
var dupeUsrname = false;
var dupeBarcode = false;
'global.juvenile_age_threshold',
'patron.password.use_phone',
'ui.patron.default_inet_access_level',
- 'circ.holds.behind_desk_pickup_supported'
+ 'circ.holds.behind_desk_pickup_supported',
+ 'circ.patron_edit.clone.copy_address'
]);
+
for(k in orgSettings)
if(orgSettings[k])
orgSettings[k] = orgSettings[k].value;
+ uEditCloneCopyAddr = orgSettings['circ.patron_edit.clone.copy_address'];
uEditUsePhonePw = orgSettings['patron.password.use_phone'];
uEditFetchUserSettings(userId);
function uEditCopyCloneData(patron) {
cloneUserObj = uEditLoadUser(cloneUser);
- dojo.forEach( [
+ var cloneFields = [
'home_ou',
'day_phone',
'evening_phone',
'other_phone',
- 'billing_address',
- 'usrgroup',
- 'mailing_address' ],
+ 'usrgroup'
+ ];
+
+ if(!uEditCloneCopyAddr)
+ cloneFields = cloneFields.concat(['mailing_address', 'billing_address']);
+
+ dojo.forEach(
+ cloneFields,
function(field) {
patron[field](cloneUserObj[field]());
}
);
- // don't grab all addresses(). the only ones we can link to are billing/mailing
- if(patron.billing_address()) {
- var t = patron.addresses();
- if (!t) { t = []; }
- t.push(patron.billing_address());
- patron.addresses(t);
- }
+ if(uEditCloneCopyAddr) {
+ var billAddr, mailAddr;
+
+ // copy the billing and mailing addresses into new addresses
+ function cloneAddr(addr) {
+ var newAddr = addr.clone();
+ newAddr.isnew(true);
+ newAddr.id(uEditAddrVirtId--);
+ newAddr.usr(patron.id());
+ patron.addresses().push(newAddr);
+ return newAddr;
+ }
- if(patron.mailing_address() && (
- patron.addresses().length == 0 ||
- patron.mailing_address().id() != patron.billing_address().id()) ) {
- var t = patron.addresses();
- if (!t) { t = []; }
- t.push(patron.mailing_address());
- patron.addresses(t);
+ if(billAddr = cloneUserObj.billing_address())
+ patron.billing_address(cloneAddr(billAddr));
+
+ if(mailAddr = cloneUserObj.mailing_address()) {
+ if (billAddr && billAddr.id() == mailAddr.id()) {
+ patron.mailing_address(patron.billing_address());
+ } else {
+ patron.mailing_address(cloneAddr(mailAddr));
+ }
+ }
+
+ if(!billAddr) // if there was no billing addr, use the mailing addr
+ patron.billing_address(patron.mailing_address());
+
+ } else {
+
+ // link the billing and mailing addresses
+ if(patron.billing_address()) {
+ var t = patron.addresses();
+ if (!t) { t = []; }
+ t.push(patron.billing_address());
+ patron.addresses(t);
+ }
+
+ if(patron.mailing_address() && (
+ patron.addresses().length == 0 ||
+ patron.mailing_address().id() != patron.billing_address().id()) ) {
+ var t = patron.addresses();
+ if (!t) { t = []; }
+ t.push(patron.mailing_address());
+ patron.addresses(t);
+ }
}
}