},
templateUrl: './serials/t_view_items_grid',
controller:
- ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider',
+ ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider','orderByFilter',
'$uibModal','ngToast','egConfirmDialog','egPromptDialog','$timeout',
-function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
+function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByFilter ,
$uibModal , ngToast , egConfirmDialog , egPromptDialog , $timeout) {
$scope.svc = egSerialsCoreSvc;
});
}
+ $scope.do_print_routing_lists = false;
+ egCore.hatch.getItem('eg.serials.items.do_print_routing_lists').then(function(val) {
+ $scope.do_print_routing_lists = val;
+ });
+
$scope.receive_and_barcode = false;
- $scope.receive_barcode_checkbox_handler = function(item) {
+ egCore.hatch.getItem('eg.serials.items.receive_and_barcode').then(function(val) {
+ $scope.receive_and_barcode = val;
+ });
+
+ $scope.checkbox_handler = function(item) {
$scope[item.checkbox] = item.checked;
+ egCore.hatch.setItem('eg.serials.items.'+item.checkbox, item.checked);
}
$scope.receive_next = function () {
var deferred = $q.defer();
var current_promise = deferred.promise;
var last_promise;
- if (do_barcode || bind) { // supplying a barcode (unit) to new items
+ if (do_barcode || bind) {
+ var print_routing_lists = $scope.do_print_routing_lists;
last_promise = current_promise.then(function(){ return $uibModal.open({
templateUrl: './serials/t_batch_receive',
size: 'lg',
controller:
['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
+ $scope.print_routing_lists = print_routing_lists;
$scope.barcode_items = do_barcode;
$scope.force_bind = bind;
$scope.bind = bind;
$scope.acn_list = [];
$scope.acpl_list = [];
+ $scope.cannot_print = function (index) {
+ return $scope.items[index].stream().routing_list_users().length == 0 || ($scope.bind && index > 0);
+ }
+
+ $scope.bind_or_none = function (index) {
+ return !$scope.barcode_items || ($scope.bind && index > 0);
+ }
+
+ $scope.focus_next_barcode = function (index) {
+ index++;
+ $('#item_barcode_'+index).focus().select();
+ }
+
+ $scope.apply_template_overrides = function (e) {
+ if ($scope.selected_call_number) {
+ angular.forEach($scope.items, function (i) {
+ i._call_number = $scope.selected_call_number;
+ });
+ }
+ if ($scope.selected_circ_mod) {
+ angular.forEach($scope.items, function (i) {
+ i._circ_mod = $scope.selected_circ_mod;
+ });
+ }
+ if ($scope.selected_copy_location) {
+ angular.forEach($scope.items, function (i) {
+ i._copy_location = $scope.selected_copy_location;
+ });
+ }
+ }
+
+ $scope.ok = function(items) { $uibModalInstance.close(items) }
+ $scope.cancel = function () { $uibModalInstance.dismiss() }
+
var pile_o_promises = [$q.when()];
// let's gather what we need...
- angular.forEach(list, function (i) {
+ angular.forEach(list, function (i, index) {
if (i.unit()) {
i._barcode = i.unit().barcode();
pile_o_promises.push(
i._copy_location = i.stream().distribution()[mode + '_unit_template']().location();
i._circ_mod = i.stream().distribution()[mode + '_unit_template']().circ_modifier();
}
+
+ if ($scope.print_routing_lists && !$scope.cannot_print(index))
+ i._print_routing_list = true;
});
pile_o_promises.push(egCore.pcrud.search(
console.log('receive data collected');
});
- $scope.bind_or_none = function (index) {
- return !$scope.barcode_items || ($scope.bind && index > 0);
- }
-
- $scope.focus_next_barcode = function (index) {
- index++;
- $('#item_barcode_'+index).focus().select();
- }
-
- $scope.apply_template_overrides = function (e) {
- if ($scope.selected_call_number) {
- angular.forEach($scope.items, function (i) {
- i._call_number = $scope.selected_call_number;
- });
- }
- if ($scope.selected_circ_mod) {
- angular.forEach($scope.items, function (i) {
- i._circ_mod = $scope.selected_circ_mod;
- });
- }
- if ($scope.selected_copy_location) {
- angular.forEach($scope.items, function (i) {
- i._copy_location = $scope.selected_copy_location;
- });
- }
- }
-
$scope.$watch('barcode_items', function (n,o) {
if (n === undefined || n == o) return;
do_barcode = n;
$scope.$watch('bind', function (n,o) {
if (n === undefined || n == o) return;
bind = n;
+ if (bind) {
+ angular.forEach($scope.items, function (i,index) {
+ if (index > 0) i._print_routing_list = false;
+ });
+ }
});
$scope.$watch('auto_barcodes', function (n,o) {
});
});
- $scope.ok = function(items) { $uibModalInstance.close(items) }
- $scope.cancel = function () { $uibModalInstance.dismiss() }
+ $scope.$watch('print_routing_lists', function (n,o) {
+ if (n === undefined || n == o) return;
+
+ angular.forEach($scope.items, function(i, index) {
+ if (!$scope.cannot_print(index)) {
+ i._print_routing_list = n;
+ } else {
+ i._print_routing_list = false;
+ }
+ });
+ });
}]
}).result});
} else {
ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE);
} else {
ngToast.success(egCore.strings.SERIALS_ISSUANCE_SUCCESS_SAVE);
- return reload($scope.ssubId,_paging_filter);
+ return $scope.print_routing_lists_impl(items, do_barcode || bind)
+ .finally(function(){reload($scope.ssubId,_paging_filter)});
}
},
function(resp) {
return deferred.resolve();
}
+ $scope.menu_print_routing_lists = function (items) {
+ items = items.map(function(item) {
+ return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]);
+ });
+ return $scope.print_routing_lists_impl(items, false, true);
+ }
+
+ $scope.print_routing_lists_impl = function (items, check, force) {
+ if (!check && !$scope.do_print_routing_lists && !force) return $q.when();
+
+ return egCore.net.request(
+ 'open-ils.search',
+ 'open-ils.search.biblio.record.mods_slim.retrieve',
+ $scope.bibId
+ ).then(function(mvr) {
+
+ var by_issuance = {};
+ angular.forEach(items, function (i) {
+ if (check && !i._print_routing_list) return;
+ if (!by_issuance[i.issuance().id()])
+ by_issuance[i.issuance().id()] = [];
+ by_issuance[i.issuance().id()].push(i);
+ });
+
+ var issuance_matrix = [];
+ angular.forEach(by_issuance, function (list) {
+ issuance_matrix.push(list);
+ });
+
+ var deferred = $q.defer();
+ var promise = deferred.promise;
+
+ angular.forEach(issuance_matrix, function(item_list, index) {
+
+ promise = promise.then(function(){
+ return $uibModal.open({
+ templateUrl: './serials/t_print_routing_list',
+ size: 'lg',
+ windowClass: 'eg-wide-modal',
+ backdrop: 'static',
+ controller:
+ ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
+ var all_users = [];
+ var all_streams = [];
+
+ angular.forEach(item_list, function(i){
+ all_streams.push(i.stream());
+ all_users = all_users.concat(i.stream().routing_list_users());
+ });
+
+ $scope.xulg = {
+ show_print_button: true,
+ routing_list_data: {
+ streams : all_streams,
+ mvr : mvr,
+ issuance: item_list[0].issuance(),
+ users : orderByFilter(all_users, 'pos')
+ }
+ };
+
+ $scope.url = '/eg/serial/print_routing_list_users?ses=' + egCore.auth.token();
+ $scope.last = index == issuance_matrix.length - 1 ? true : false;
+ $scope.ok = function() { $uibModalInstance.close() }
+ }]
+ }).result;
+ });
+
+ });
+
+ return deferred.resolve();
+ });
+
+ }
+
$scope.add_issuances = function () {
var lastItem = egSerialsCoreSvc.itemList[egSerialsCoreSvc.itemList.length - 1];