});
}
- $scope.print_labels = function() {
- var cp_list = []
+ $scope.print_labels = function () {
+ var cp_list = [];
angular.forEach($scope.gridControls.selectedItems(), function (i) {
cp_list.push(i.id);
})
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.anon_cache.set_value',
- null, 'print-labels-these-copies', {
- copies : cp_list
- }
- ).then(function(key) {
- if (key) {
- var url = egCore.env.basePath + 'cat/printlabels/' + key;
- $timeout(function() { $window.open(url, '_blank') });
+ var cp_full = [], promises = [];
+ promises.push(
+ egCore.pcrud.search('ccbi', { bucket: bucketSvc.currentBucket.a[2], "target_copy": { "in": cp_list } }).then(
+ null
+ , null
+ , function (ccbi) {
+ cp_full.push(egCore.idl.toHash(ccbi, true));
+ }
+ )
+ );
+
+ $q.all(promises).then(function () {
+ if (cp_full.length > 0) {
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.anon_cache.set_value',
+ null, 'print-labels-these-copies', {
+ copies: cp_full
+ }
+ ).then(function (key) {
+ if (key) {
+ var url = egCore.env.basePath + 'cat/printlabels/' + key;
+ $timeout(function () { $window.open(url, '_blank') });
+ } else {
+ alert('Could not create anonymous cache key!');
+ }
+ });
} else {
- alert('Could not create anonymous cache key!');
+ alert('Could not create print label export.');
}
});
}
}
$scope.selectedHoldingsPrintLabels = function() {
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.anon_cache.set_value',
- null, 'print-labels-these-copies', {
- copies : gatherSelectedHoldingsIds()
- }
- ).then(function(key) {
- if (key) {
- var url = egCore.env.basePath + 'cat/printlabels/' + key;
- $timeout(function() { $window.open(url, '_blank') });
+ var cp_list = gatherSelectedHoldingsIds();
+
+ var cp_full = [], promises = [];
+ promises.push(
+ egCore.pcrud.search('ccbi', { bucket: $scope.bucket_id, "target_copy": { "in": cp_list } }).then(
+ null
+ , null
+ , function (ccbi) {
+ cp_full.push(egCore.idl.toHash(ccbi, true));
+ }
+ )
+ );
+
+ $q.all(promises).then(function () {
+ if (cp_full.length > 0) {
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.anon_cache.set_value',
+ null, 'print-labels-these-copies', {
+ copies: cp_full
+ }
+ ).then(function (key) {
+ if (key) {
+ var url = egCore.env.basePath + 'cat/printlabels/' + key;
+ $timeout(function () { $window.open(url, '_blank') });
+ } else {
+ alert('Could not create anonymous cache key!');
+ }
+ });
} else {
- alert('Could not create anonymous cache key!');
+ alert('Could not create print label export.');
}
});
}
$scope.transferItems = function (){
itemSvc.transferItems(copyGrid.selectedItems());
}
-
+
$scope.print_labels = function() {
+ var cp_list = gatherSelectedHoldingsIds();
+ !$scope.gridDataProvider.sort ? cp_list.reverse() : $scope.gridDataProvider.sort.length === 0 ? cp_list.reverse() : false;
+ var i = 1;
+ var cp_full = [];
+ angular.forEach(cp_list, function (copy) {
+ cp_full.push({id: i, target_copy: copy})
+ i++;
+ });
egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
null, 'print-labels-these-copies', {
- copies : gatherSelectedHoldingsIds()
+ copies : cp_full
}
).then(function(key) {
if (key) {
angular.forEach(data.copies, function (copy) {
promises.push(
- itemSvc.fetch(null, copy).then(function (res) {
+ itemSvc.fetch(null, copy.target_copy).then(function (res) {
var flat_copy = egCore.idl.toHash(res.copy, true);
+ flat_copy.copy_bucket_item_id = copy.id;
$scope.preview_scope.copies.push(flat_copy);
$scope.record_details[flat_copy['call_number.record.id']] = 1;
})
});
$q.all(promises2).then(function () {
+ // sort copies into the order they were entered into the bucket
+ $scope.preview_scope.copies.sort((a, b) => (a.copy_bucket_item_id > b.copy_bucket_item_id) ? 1 : ((b.copy_bucket_item_id > a.copy_bucket_item_id) ? -1 : 0));
// today, staff, current_location, etc.
egCore.print.fleshPrintScope($scope.preview_scope);
$scope.template_changed(); // load the default
function getPrintLabelStyle(index, settings) {
return index > 0 && (index % settings.page.label.set.size === 0) ? settings.page.label.gap.size : "";
-}
\ No newline at end of file
+}
).then(function(copy_ids) {
if (and_exit) {
$scope.dirty = false;
+ !$scope.completedGridDataProvider.sort ? copy_ids.reverse() : $scope.completedGridDataProvider.sort.length === 0 ? copy_ids.reverse() : false;
if ($scope.defaults.print_item_labels) {
+ var cp_full = [];
+ var i = 1;
+ angular.forEach(copy_ids, function (copy) {
+ cp_full.push({ id: i, target_copy: copy });
+ i++;
+ });
egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
null, 'print-labels-these-copies', {
- copies : copy_ids
+ copies : cp_full
}
).then(function(key) {
if (key) {
{ order_by : { 'acpt' : ['label'] } }, { atomic: true }
).then(function(list) {
return list.map(function(item) {
- return item.label() + " (" + egCore.org.get(item.owner()).shortname() + ")";
+ return item.label();
});
});
}
});
}
- $scope.printSpineLabels = function(items){
- var copy_ids = [];
+ $scope.printSpineLabels = function(items){
+ var copy_ids = [], cp_full;
angular.forEach(items, function(item) {
if (item.acp) copy_ids.push(item.acp.id());
});
- itemSvc.print_spine_labels(copy_ids);
+ !$scope.gridDataProvider.sort ? copy_ids.reverse() : $scope.gridDataProvider.sort.length === 0 ? copy_ids.reverse() : false;
+ var i = 0;
+ angular.forEach(copy_ids, function (copy) {
+ cp_full.push({ id: i, target_copy: copy });
+ i++;
+ });
+ itemSvc.print_spine_labels(cp_full);
}
$scope.addCopyAlerts = function(items) {