Commit 8dee8cbe authored by bensinober's avatar bensinober
Browse files

DEICH-5947 koha rfid checkin: add handling of deleted/unknown items

parent 1b0ec622
......@@ -314,10 +314,9 @@ class RFIDConnectorEventSource extends HTMLElement {
if (!/[0-9a-zA-Z]{8,}/.test(barcode)) { return }
if (event.type === "addTag") {
let res = this._inventory.get(barcode) || {}
var tagStatus = "red"
const { tags } = res
const item = res.item ? res.item : await this._itemStatus(barcode)
if (!item) { return }
var tagStatus = "red"
let checkInRes
if (tags.size === data.NumItems) {
tagStatus = "green"
......@@ -327,10 +326,14 @@ class RFIDConnectorEventSource extends HTMLElement {
device: `${this.branch}.feig.${this._readerState.Client}`,
location: `${this.branch}.staff.in`,
}
checkInRes = await this._checkIn(msg)
const itemStatus = await this._itemStatus(barcode)
this._updateCheckInTable(checkInRes, itemStatus)
await this._alarmOn() // TODO: check success first?
if (!item) {
this._updateCheckInTable({UnknownItem: true}, {item: { barcode: barcode} , biblio: { title: "ukjent"}})
} else {
checkInRes = await this._checkIn(msg)
const itemStatus = await this._itemStatus(barcode)
this._updateCheckInTable(checkInRes, itemStatus)
await this._alarmOn() // TODO: check success first?
}
} else {
const msg = `Forventet ${data.NumItems} brikker, fant ${tags.size}`
this._updateCheckInTable({DataCorrupted: msg}, item)
......@@ -490,13 +493,13 @@ class RFIDConnectorEventSource extends HTMLElement {
_updateCheckInTable(msg, item) {
const checkInItems = document.getElementById("rfidItems")
const newRow = document.createElement("tr")
const { title, author } = item.biblio
const { title, author } = item.biblio || {}
let mediatype = ""
if (item.metadata) {
mediatype = item.metadata.mediatype
}
const { itemcallnumber, location, timestamp, barcode } = item.item
const { WrongTransfer, WasTransfered, DataCorrupted, WasReturned, messages } = msg
const { itemcallnumber, location, timestamp, barcode } = item.item || {}
const { WrongTransfer, WasTransfered, DataCorrupted, WasReturned, UnknownItem, messages } = msg
var sortLabel, dateDue, message, alert, error, pickup, lastPatronLink, destBranch, illPatronLink
if (WrongTransfer) {
error = `Feil overføring: ${WrongTransfer}`
......@@ -504,6 +507,8 @@ class RFIDConnectorEventSource extends HTMLElement {
error = "Fikk ikke levert"
} else if (DataCorrupted) {
error = `Feil/manglede brikker: ${DataCorrupted}`
} else if (UnknownItem) {
error = "Ukjent eller slettet strekkode"
}
/* Destination is always calculated on checkin, based on location goes/co/lives, so we do not care about location */
if (item.destination) {
......@@ -545,15 +550,17 @@ class RFIDConnectorEventSource extends HTMLElement {
newRow.id = `checkin_${barcode}`
newRow.innerHTML = `
<td>${sortLabel}</td>
<td>${sortLabel || ""}</td>
<td>${item.reserve && item.reserve.pickupnumber ? item.reserve.pickupnumber : ""}</td>
<td>${item.destination && item.destination.destBranch ? item.destination.destBranch : item.destination.dest}&nbsp;${illPatronLink}</td>
<td>${item.destination
? item.destination.destBranch ? `${item.destination.destBranch}&nbsp;${illPatronLink}` : `${item.destination.dest}&nbsp;${illPatronLink}`
: ""}</td>
<td>${mediatype}</td>
<td><span title="dato">${dateDue ? new Date(Date.parse(dateDue)).toLocaleDateString() : ""}</span></td>
<td><strong>${title}</strong></a></td>
<td>${author || ""}</td>
<td>${itemcallnumber} - ${location}</td>
<td><a href="/cgi-bin/koha/catalogue/search.pl?q=${barcode}">${barcode}</a></td>
<td>${itemcallnumber ? `${itemcallnumber} - ${location}` : ""}</td>
<td>${barcode ? `<a href="/cgi-bin/koha/catalogue/search.pl?q=${barcode}">${barcode}</a>` : ""}</td>
<td>${lastPatronLink || ""}</td>
<td>${error || alert || ""}</td>
`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment