itemSvc.add_copies_to_bucket([$scope.args.copyId]);
}
+ $scope.add_records_to_bucket = function() {
+ itemSvc.add_records_to_bucket([$scope.args.recordId], 'biblio');
+ }
+
$scope.show_in_catalog = function() {
- window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/catalog', '_blank');
+ window.open('/eg2/staff/catalog/record/' + $scope.args.recordId, '_blank');
}
$scope.print_labels = function() {
itemSvc.manage_reservations([$scope.args.copyBarcode]);
}
- $scope.findAcquisition = function() {
- var acqData;
- var promises = [];
- $scope.openAcquisitionLineItem([$scope.args.copyId]);
- }
-
- $scope.openAcquisitionLineItem = function (cp_list) {
- var hasResults = false;
- var promises = [];
-
- angular.forEach(cp_list, function (copyId) {
- promises.push(
- egNet.request(
- 'open-ils.acq',
- 'open-ils.acq.lineitem.retrieve.by_copy_id',
- egCore.auth.token(),
- copyId
- ).then(function (acqData) {
- if (acqData) {
- if (acqData.a) {
- acqData = egCore.idl.toHash(acqData);
- var url = '/eg/acq/po/view/' + acqData.purchase_order + '/' + acqData.id;
- $timeout(function () { $window.open(url, '_blank') });
- hasResults = true;
- }
- }
- })
- )
- });
-
- $q.all(promises).then(function () {
- !hasResults ? alert('There is no corresponding purchase order for this item.') : false;
- });
- }
-
$scope.requestItems = function() {
itemSvc.requestItems([$scope.args.copyId],[$scope.args.recordId]);
}
}
$scope.show_record_holds = function() {
- window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/holds', '_blank');
+ window.open('/eg2/staff/catalog/record/' + $scope.args.recordId + '/holds', '_blank');
}
$scope.add_item_alerts = function() {
};
$scope.$watch('barcodesFromFile', function(newVal, oldVal) {
+ $scope.context.itemsNotFound = [];
+ $scope.context.fileDoneLoading = false;
+ $scope.context.numBarcodesInFile = 0;
if (newVal && newVal != oldVal) {
$scope.args.barcode = '';
var barcodes = [];
if(itemSvc.copies[0]){ // Were any copies actually retrieved
copyGrid.selectItems([itemSvc.copies[0].index]);
}
+ $scope.context.fileDoneLoading = true;
return;
}
- itemSvc.fetch(barcode).then(fetch_next_copy);
+ itemSvc.fetch(barcode).then(function(item) {
+ if (!item) {
+ $scope.context.itemsNotFound.push(barcode);
+ }
+ fetch_next_copy();
+ })
}
if (barcodes.length) {
+ $scope.context.numBarcodesInFile = barcodes.length;
egProgressDialog.open({value: 0, max: barcodes.length});
fetch_next_copy();
}
}
});
- $scope.context.search = function(args) {
- if (!args.barcode) return;
+ $scope.context.search = function(args, noGridRefresh) {
+ if (!args.barcode) return $q.when();
$scope.context.itemNotFound = false;
- itemSvc.fetch(args.barcode).then(function(res) {
- if (res) {
- copyGrid.refresh();
- copyGrid.selectItems([res.index]);
- $scope.args.barcode = '';
- } else {
- $scope.context.itemNotFound = true;
- egCore.audio.play('warning.item_status.itemNotFound');
- }
- $scope.context.selectBarcode = true;
- })
+
+ //check to see if there are multiple barcodes in CSV format
+ var barcodes = [];
+ //split on commas and clean up barcodes
+ angular.forEach(args.barcode.split(/,/), function(line) {
+ //remove all whitespace and commas
+ line = line.replace(/[\s,]+/g,'');
+
+ //Or remove leading/trailing whitespace
+ //line = line.replace(/(^[\s,]+|[\s,]+$/g,'');
+
+ if (!line) return;
+ barcodes.push(line);
+ });
+
+ if(barcodes.length > 1){
+ //convert to newline seperated list and send to barcodesFromFile processor
+ $scope.barcodesFromFile = barcodes.join('\n');
+ //console.log('Barcodes: ',barcodes);
+ return $q.when();
+
+ } else {
+ //Single Barcode
+ return itemSvc.fetch(args.barcode).then(function(res) {
+ if (res) {
+ if (!noGridRefresh) {
+ copyGrid.refresh();
+ }
+ copyGrid.selectItems([res.index]);
+ $scope.args.barcode = '';
+ } else {
+ $scope.context.itemNotFound = true;
+ egCore.audio.play('warning.item_status.itemNotFound');
+ }
+ $scope.context.selectBarcode = true;
+ })
+ }
}
- var add_barcode_to_list = function (b) {
- //console.log('listCtrl: add_barcode_to_list',b);
- $scope.context.search({barcode:b});
+ var add_barcode_to_list = function (b, noGridRefresh) {
+ // console.log('listCtrl: add_barcode_to_list',b);
+ return $scope.context.search({barcode:b}, noGridRefresh);
}
itemSvc.add_barcode_to_list = add_barcode_to_list;
return cp_id_list;
}
+ function gatherSelectedHoldingsRecords() {
+ var record_id_list = [];
+ angular.forEach(
+ copyGrid.selectedItems(),
+ function (item) {
+ record_id_list.push(item['call_number.record.id']);
+ }
+ )
+ return record_id_list;
+ }
+
$scope.refreshGridData = function() {
var chain = $q.when();
var all_items = itemSvc.copies.map(function(item) {
itemSvc.add_copies_to_bucket(copy_list);
}
+ $scope.add_records_to_bucket = function() {
+ var record_list = gatherSelectedHoldingsRecords();
+ itemSvc.add_copies_to_bucket(record_list, 'biblio');
+ }
+
$scope.locateAcquisition = function() {
if (gatherSelectedHoldingsIds) {
var cp_list = gatherSelectedHoldingsIds();
}
$scope.selectedHoldingsMissing = function () {
- itemSvc.selectedHoldingsMissing(copyGrid.selectedItems());
+ egProgressDialog.open();
+ itemSvc.selectedHoldingsMissing(copyGrid.selectedItems())
+ .then(function() {
+ egProgressDialog.close();
+ console.debug('Marking missing complete, refreshing grid');
+ copyGrid.refresh();
+ });
}
$scope.checkin = function () {
$scope.showBibHolds = function () {
angular.forEach(gatherSelectedRecordIds(), function (r) {
- var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
+ var url = '/eg2/staff/catalog/record/' + r + '/holds';
$timeout(function() { $window.open(url, '_blank') });
});
}
* Detail view -- shows one copy
*/
.controller('ViewCtrl',
- ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling','egCirc',
-function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling , egCirc) {
+ ['$scope','$q','egGridDataProvider','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling','egCirc',
+function($scope , $q , egGridDataProvider , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling , egCirc) {
var copyId = $routeParams.id;
$scope.args.copyId = copyId;
$scope.tab = $routeParams.tab || 'summary';
$scope.context.page = 'detail';
$scope.summaryRecord = null;
-
+ $scope.courseModulesOptIn = fetchCourseOptIn();
+ $scope.has_course_perms = fetchCoursePerms();
$scope.edit = false;
if ($scope.tab == 'edit') {
$scope.tab = 'summary';
$scope.edit = true;
}
-
// use the cached record info
if (itemSvc.copy) {
$scope.copy_alert_count = itemSvc.copy.copy_alerts().filter(function(aca) {
});
}
+ // Check for Course Modules Opt-In to enable Course Info tab
+ function fetchCourseOptIn() {
+ return egCore.org.settings(
+ 'circ.course_materials_opt_in'
+ ).then(function(set) {
+ $scope.courseModulesOptIn = set['circ.course_materials_opt_in'];
+
+ return $scope.courseModulesOptIn;
+ });
+ }
+
+ function fetchCoursePerms() {
+ return egCore.perm.hasPermAt('MANAGE RESERVES', true).then(function(orgIds) {
+ if(orgIds.indexOf(egCore.auth.user().ws_ou()) != -1){
+ $scope.has_course_perms = true;
+
+ return $scope.has_course_perms;
+ }
+ });
+ }
+
$scope.addBilling = function(circ) {
egBilling.showBillDialog({
xact_id : circ.id(),
})
}
+ function loadCourseInfo() {
+ delete $scope.courses;
+ delete $scope.instructors;
+ delete $scope.course_ids;
+ delete $scope.instructors_exist;
+ if (!copyId) return;
+ $scope.course_ids = [];
+ $scope.courses = [];
+ $scope.instructors = {};
+
+ egCore.pcrud.search('acmcm', {
+ item: copyId
+ }, {
+ flesh: 3,
+ flesh_fields: {
+ acmcm: ['course']
+ }, order_by: {acmc : 'id desc'}
+ }).then(null, null, function(material) {
+
+ $scope.courses.push(material.course());
+ egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.course_users.retrieve',
+ material.course().id()
+ ).then(null, null, function(instructors) {
+ angular.forEach(instructors, function(instructor) {
+ var patron_id = instructor.patron_id.toString();
+ if (!$scope.instructors[patron_id]) {
+ $scope.instructors[patron_id] = instructor;
+ $scope.instructors_exist = true;
+ $scope.instructors[patron_id]._linked_course = [];
+ }
+ $scope.instructors[patron_id]._linked_course.push({
+ role: instructor.usr_role,
+ course: material.course().name()
+ });
+ });
+ });
+ });
+ }
+
// we don't need all data on all tabs, so fetch what's needed when needed.
function loadTabData() {
loadMostRecentTransit();
break;
+ case 'course':
+ loadCourseInfo();
+ break;
+
case 'triggered_events':
var url = $location.absUrl().replace(/\/staff.*/, '/actor/user/event_log');
url += '?copy_id=' + encodeURIComponent(copyId);