s.PAYMENT_OVER_MAX = "[% l('Payments over $[_1] are denied by policy.', '{{max_amount}}') %]";
s.PATRON_NOTE_DELETE_CONFIRM_TITLE = "[% l('Delete Note?') %]";
s.PATRON_NOTE_DELETE_CONFIRM = "[% l('Delete the note titled \"[_1]\" created on [_2]?', '{{note_title}}', '{{create_date | date}}') %]";
+ s.PATRON_PURGE_CONFIRM_TITLE = "[% l('Completely Purge Patron Account?') %]";
+ s.PATRON_PURGE_CONFIRM = "[% l('Completely OBLITERATE this patron account, including bills, payments, bookbags, etc? This is IRREVERSIBLE.') %]";
+ s.PATRON_PURGE_LAST_CHANCE = "[% l('Last chance, are you sure you want to completely delete this account?') %]";
+ s.PATRON_PURGE_STAFF_PROMPT = "[% l('The account you are attempting to delete has STAFF_LOGIN privileges. Please enter the barcode for a destination account to receive miscellaneous staff artifacts (reports, etc.) from the account to be deleted.') %]";
+ s.PATRON_PURGE_STAFF_BAD_BARCODE = "[% l('Could not retrieve a destination account with the barcode provided. Aborting the purge...') %]";
+ s.PATRON_PURGE_OVERRIDE_PROMPT = "[% l('The account has open transactions (circulations and/or unpaid bills). Purge anyway?') %]";
s.OPT_IN_DIALOG_TITLE = "[% l('Verify Permission to Share Personal Information') %]";
s.OPT_IN_DIALOG = "[% l('Does patron [_1], [_2] from [_3] ([_4]) consent to having their personal information shared with your library?', '{{family_name}}', '{{first_given_name}}', '{{org_name}}', '{{org_shortname}}') %]";
}]);
[% l('Booking: Return Reservations') %]
</a>
</li>
+ <li>
+ <a href ng-click="purge_account()" a-disabled="patron().super_user() == 't' || patron().id() == auth_user_id">
+ [% l('Completely Purge Account') %]
+ </a>
+ </li>
</ul>
</li>
<li ng-class="{active : tab == 'search'}" class="pull-right">
*
* */
.controller('PatronCtrl',
- ['$scope','$q','$location','$filter','egCore','egUser','patronSvc',
-function($scope, $q, $location , $filter, egCore, egUser, patronSvc) {
+ ['$scope','$q','$location','$filter','egCore','egNet','egUser','egAlertDialog','egConfirmDialog','egPromptDialog','patronSvc',
+function($scope, $q , $location , $filter , egCore , egNet , egUser , egAlertDialog , egConfirmDialog , egPromptDialog , patronSvc) {
$scope.is_patron_edit = function() {
return Boolean($location.path().match(/patron\/\d+\/edit$/));
console.log('init tab ' + tab);
$scope.tab = tab;
$scope.aous = egCore.env.aous;
+ $scope.auth_user_id = egCore.auth.user().id();
if (patron_id) {
$scope.patron_id = patron_id;
return $scope.tab != 'search' && $scope.collapsePatronSummary;
}
+ function _purge_account(dest_usr,override) {
+ egNet.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.delete' + (override ? '.override' : ''),
+ egCore.auth.token(),
+ $scope.patron().id(),
+ dest_usr
+ ).then(function(resp){
+ if (evt = egCore.evt.parse(resp)) {
+ if (evt.code == '2004' /* ACTOR_USER_DELETE_OPEN_XACTS */) {
+ egConfirmDialog.open(
+ egCore.strings.PATRON_PURGE_CONFIRM_TITLE, egCore.strings.PATRON_PURGE_OVERRIDE_PROMPT,
+ {ok : function() {
+ _purge_account(dest_usr,true);
+ }}
+ );
+ } else {
+ alert(js2JSON(evt));
+ }
+ } else {
+ location.href = egCore.env.basePath + '/circ/patron/search';
+ }
+ });
+ }
+
+ function _purge_account_with_destination(dest_barcode) {
+ egCore.pcrud.search('ac', {barcode : dest_barcode})
+ .then(function(card) {
+ if (!card) {
+ egAlertDialog.open(egCore.strings.PATRON_PURGE_STAFF_BAD_BARCODE);
+ } else {
+ _purge_account(card.usr());
+ }
+ });
+ }
+
+ $scope.purge_account = function() {
+ egConfirmDialog.open(
+ egCore.strings.PATRON_PURGE_CONFIRM_TITLE, egCore.strings.PATRON_PURGE_CONFIRM,
+ {ok : function() {
+ egConfirmDialog.open(
+ egCore.strings.PATRON_PURGE_CONFIRM_TITLE, egCore.strings.PATRON_PURGE_LAST_CHANCE,
+ {ok : function() {
+ egNet.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.has_work_perm_at',
+ egCore.auth.token(), 'STAFF_LOGIN', $scope.patron().id()
+ ).then(function(resp) {
+ var is_staff = resp.length > 0;
+ if (is_staff) {
+ egPromptDialog.open(
+ egCore.strings.PATRON_PURGE_STAFF_PROMPT,
+ null, // TODO: this would be cool if it worked: egCore.auth.user().card().barcode(),
+ {ok : function(barcode) {_purge_account_with_destination(barcode)}}
+ );
+ } else {
+ _purge_account();
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
egCore.hatch.getItem('eg.circ.patron.summary.collapse')
.then(function(val) {$scope.collapsePatronSummary = Boolean(val)});
}])