UNPKG

@rero/rero-ils-ui

Version:

User interface for RERO integrated library system (RERO ILS).

1 lines 232 kB
"use strict";(self.webpackChunkadmin=self.webpackChunkadmin||[]).push([[774],{774:(Yd,De,_)=>{_.r(De),_.d(De,{CirculationModule:()=>Gd});var g=_(177),E=_(9417),At=_(8524),h=_(2203),f=_(1728),Si=_(5992),Ut=_(810),Z=_(8580),$=_(52),z=_(7229),$e=_(6688),pt=_(7468),j=_(6354),k=_(2648),t=_(4438),A=_(779),m=_(3955);let Ii=(()=>{class n{constructor(e){this.modalService=e}setAction(e){this.action=e,this.closeModal()}checkinItemOnEnterKey(e){"Enter"===e.key&&this.setAction("item")}closeModal(){this.modalService.hide()}static#t=this.\u0275fac=function(o){return new(o||n)(t.rXU(A.I8))};static#e=this.\u0275cmp=t.VBU({type:n,selectors:[["admin-checkin-action"]],decls:21,vars:6,consts:[["role","dialog",1,"modal","show","d-block",3,"keypress"],["role","checkin",1,"modal-dialog","modal-dialog-centered"],[1,"modal-content"],[1,"modal-header"],["translate","",1,"modal-title"],["type","button","data-dismiss","modal","aria-label","Close",1,"close"],["aria-hidden","true","data-dismiss","modal",3,"click"],[1,"modal-body"],["translate","",1,"font-weight-bold"],[1,"modal-footer"],["id","action-patron","type","button",1,"btn","btn-outline-primary",3,"click"],[1,"fa","fa-user","mr-1"],["id","action-item","type","button",1,"btn","btn-primary",3,"click"],[1,"fa","fa-file-o","mr-1"]],template:function(o,a){1&o&&(t.j41(0,"div",0),t.bIt("keypress",function(r){return a.checkinItemOnEnterKey(r)},!1,t.tSv),t.j41(1,"div",1)(2,"div",2)(3,"div",3)(4,"h5",4),t.EFF(5,"Circulation action"),t.k0s(),t.j41(6,"button",5)(7,"span",6),t.bIt("click",function(){return a.closeModal()}),t.EFF(8,"\xd7"),t.k0s()()(),t.j41(9,"div",7)(10,"div",8),t.EFF(11," One item and one patron were found. "),t.k0s()(),t.j41(12,"div",9)(13,"button",10),t.bIt("click",function(){return a.setAction("patron")}),t.nrm(14,"i",11),t.EFF(15),t.nI1(16,"translate"),t.k0s(),t.j41(17,"button",12),t.bIt("click",function(){return a.setAction("item")}),t.nrm(18,"i",13),t.EFF(19),t.nI1(20,"translate"),t.k0s()()()()()),2&o&&(t.R7$(15),t.SpI(" ",t.bMT(16,2,"Patron account")," "),t.R7$(4),t.SpI(" ",t.bMT(20,4,"Checkin the item")," "))},dependencies:[m.Mm,m.D9],encapsulation:2})}return n})();var ht=_(7234),st=_(5794),K=_(1954),Ei=_(6865),Q=_.n(Ei),Oe=_(4412);let ft=(()=>{class n{constructor(){this.currentLibraryClosedDates$=new Oe.t([]),this._currentLibraryClosedDates=[]}get currentLibraryClosedDates(){return this._currentLibraryClosedDates}set currentLibraryClosedDates(e){this._currentLibraryClosedDates=e,this.currentLibraryClosedDates$.next(e)}incrementCirculationStatistic(e,o=1){return this.circulationInformations=this.circulationInformations||{messages:[],statistics:{}},this.circulationInformations.statistics[e]=(this.circulationInformations.statistics[e]||0)+o,this.circulationInformations.statistics[e]}decrementCirculationStatistic(e,o=1){if(this.circulationInformations=this.circulationInformations||{messages:[],statistics:{}},!(e in this.circulationInformations.statistics))return 0;const a=this.circulationInformations.statistics[e]-o;return this.circulationInformations.statistics[e]=a>0?a:0,this.circulationInformations.statistics[e]}addCirculationMessage(e){this.circulationInformations=this.circulationInformations||{messages:[],statistics:{}},this.circulationInformations.messages.push(e)}clear(){this.circulationInformations={messages:[],statistics:{}}}static#t=this.\u0275fac=function(o){return new(o||n)};static#e=this.\u0275prov=t.jDH({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();const Ri=n=>({"text-muted":n});function Mi(n,i){if(1&n&&(t.j41(0,"span",8),t.EFF(1),t.k0s()),2&n){const e=t.XpG(2);t.R7$(),t.SpI(", ",e.patron.first_name,"")}}function wi(n,i){if(1&n){const e=t.RV6();t.j41(0,"div",9)(1,"button",17),t.bIt("click",function(){t.eBV(e);const a=t.XpG(2);return t.Njj(a.clear())}),t.nrm(2,"i",18),t.k0s()()}}function Di(n,i){1&n&&(t.EFF(0," \xa0 "),t.nrm(1,"i",19))}function $i(n,i){if(1&n&&(t.EFF(0),t.nI1(1,"dateTranslate"),t.nI1(2,"translate"),t.DNE(3,Di,2,0,"i",19)),2&n){const e=t.XpG(2);t.E5c(" ",t.i5U(1,4,e.patron.birth_date,"mediumDate")," (",e.patronAge," ",t.bMT(2,7,"years old"),") "),t.R7$(3),t.vxM(3,e.isBirthday?3:-1)}}function Oi(n,i){1&n&&(t.j41(0,"div",13),t.EFF(1),t.k0s()),2&n&&(t.R7$(),t.JRh(i))}function ji(n,i){if(1&n&&(t.j41(0,"strong",20),t.EFF(1),t.k0s(),t.nrm(2,"p",21),t.nI1(3,"nl2br")),2&n){const e=i.$implicit;t.R7$(),t.JRh(e.type.toString()),t.R7$(),t.Y8G("innerHTML",t.bMT(3,2,e.content),t.npT)}}function Ni(n,i){if(1&n&&(t.j41(0,"div",15),t.Z7z(1,ji,4,4,null,null,t.fX1),t.k0s()),2&n){const e=t.XpG(2);t.R7$(),t.Dyx(e.patron.notes)}}function Li(n,i){if(1&n&&(t.nrm(0,"li",23),t.nI1(1,"nl2br")),2&n){const e=i.$implicit,o=t.XpG(4);t.ZvI("list-group-item list-group-item-",o.getBootstrapColor(e.type),""),t.Y8G("innerHTML",t.bMT(1,4,e.content),t.npT)}}function Pi(n,i){if(1&n&&t.Z7z(0,Li,2,6,"li",22,t.fX1),2&n){const e=t.XpG(3);t.Dyx(e.patron.circulation_informations.messages)}}function Gi(n,i){if(1&n&&(t.nrm(0,"li",23),t.nI1(1,"nl2br")),2&n){const e=i.$implicit,o=t.XpG(3);t.ZvI("list-group-item list-group-item-",o.getBootstrapColor(e.type),""),t.Y8G("innerHTML",t.bMT(1,4,e.content),t.npT)}}function Xi(n,i){if(1&n&&(t.j41(0,"ul",16),t.DNE(1,Pi,2,0),t.Z7z(2,Gi,2,6,"li",22,t.fX1),t.k0s()),2&n){const e=t.XpG(2);t.R7$(),t.vxM(1,e.patron.circulation_information?1:-1),t.R7$(),t.Dyx(e.circulationMessages)}}function Ai(n,i){if(1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3),t.nrm(4,"i",4),t.k0s(),t.j41(5,"div",5)(6,"div",1)(7,"div",5)(8,"h3")(9,"a",6)(10,"span",7),t.EFF(11),t.k0s(),t.DNE(12,Mi,2,1,"span",8),t.k0s()()(),t.DNE(13,wi,3,0,"div",9),t.k0s(),t.j41(14,"div",1)(15,"div",10)(16,"div",11),t.DNE(17,$i,4,9),t.k0s(),t.j41(18,"div",12),t.EFF(19),t.k0s()(),t.j41(20,"div",10),t.DNE(21,Oi,2,1,"div",13),t.nI1(22,"getRecord"),t.nI1(23,"async"),t.j41(24,"div",14),t.EFF(25),t.k0s()()()(),t.DNE(26,Ni,3,0,"div",15),t.k0s(),t.DNE(27,Xi,4,1,"ul",16),t.k0s()()),2&n){let e;const o=t.XpG();t.Y8G("ngClass",t.eq3(18,Ri,!o.clearPatronButton)),t.R7$(9),t.Y8G("routerLink",o.patronLink),t.R7$(2),t.JRh(o.patron.last_name),t.R7$(),t.vxM(12,o.patron.first_name?12:-1),t.R7$(),t.vxM(13,o.clearPatronButton?13:-1),t.R7$(4),t.vxM(17,o.patron.birth_date?17:-1),t.R7$(2),t.JRh(o.patron.city),t.R7$(2),t.vxM(21,(e=t.bMT(23,16,t.ii3(22,11,o.patron.patron.type.pid,"patron_types","string","name")))?21:-1,e),t.R7$(4),t.JRh(o.barcode),t.R7$(),t.vxM(26,o.patron.notes?26:-1),t.R7$(),t.vxM(27,o.displayCirculationMessages?27:-1)}}let je=(()=>{class n{get patronLink(){if(this.patron)return"detail"===this.linkMode?"/records/patrons/detail/"+this.patron.pid:"/circulation/patron/"+this.barcode+"/loan"}get patronAge(){if(this.patron&&this.patron.birth_date)return Q()().diff(this.patron.birth_date,"years")}get isBirthday(){if(this.patron&&this.patron.birth_date){const e=Q()().format("YYYY-MM-DD");return Q()(e).diff(this.patron.birth_date,"years",!0)%1==0}return!1}get circulationMessages(){return this.circulationService.hasOwnProperty("circulationInformations")?this.circulationService.circulationInformations.messages:[]}constructor(e){this.circulationService=e,this.displayCirculationMessages=!1,this.clearPatronButton=!0,this.linkMode="detail",this.clearPatron=new t.bkB}clear(){this.patron&&this.clearPatron.emit(this.patron)}getBootstrapColor(e){return function xi(n){switch(n){case"error":return"danger";case"warning":return"warning";case"debug":return"dark";default:return"info"}}(e)}static#t=this.\u0275fac=function(o){return new(o||n)(t.rXU(ft))};static#e=this.\u0275cmp=t.VBU({type:n,selectors:[["admin-circulation-patron-detailed"]],inputs:{patron:"patron",barcode:"barcode",displayCirculationMessages:"displayCirculationMessages",clearPatronButton:"clearPatronButton",linkMode:"linkMode"},outputs:{clearPatron:"clearPatron"},decls:1,vars:1,consts:[[1,"m-0",3,"ngClass"],[1,"row"],[1,"col","row"],[1,"col-md-2","user-icon"],["aria-hidden","true",1,"fa","fa-user","fa-5x"],[1,"col-md-10"],[3,"routerLink"],["id","patron-last-name"],["id","patron-first-name"],[1,"col-md-2"],[1,"col-md-6"],["id","patron-birth-date"],["id","patron-city"],["id","patron-type"],["id","patron-barcode"],["role","alert",1,"col","mt-2","alert","alert-warning"],[1,"col-6","list-group"],["id","clear-patron-button","type","button",1,"btn","btn-danger","pull-right",3,"click"],["aria-hidden","true",1,"fa","fa-close"],[1,"fa","fa-birthday-cake","text-warning","blink"],["translate","",1,"alert-heading"],[1,"mb-0","ml-3",3,"innerHTML"],[3,"class","innerHTML"],[3,"innerHTML"]],template:function(o,a){1&o&&t.DNE(0,Ai,28,20,"div",0),2&o&&t.vxM(0,null!=a.patron&&a.patron.patron?0:-1)},dependencies:[$.Wk,g.YU,m.Mm,g.Jj,h.yX,m.D9,h.HK,h.X1],styles:[".user-icon[_ngcontent-%COMP%]{line-height:90px}.user-icon[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{vertical-align:bottom}.blink[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_blink-animation 1s steps(5,start) infinite;-webkit-animation:_ngcontent-%COMP%_blink-animation 1s steps(5,start) infinite}@keyframes _ngcontent-%COMP%_blink-animation{to{visibility:hidden}}"]})}return n})();var x=_(3563),et=_(8264),Ui=_(1413),N=_(187),Vi=_(4427);let Rt=(()=>{class n{constructor(e,o,a,s,r){this._recordService=e,this._userService=o,this._routeToolService=a,this._toastService=s,this._translateService=r,this.patronTransactionsSubject$=new Oe.t([]),this.patronFeesOperationSubject$=new Ui.B}_buildQuery(e,o,a,s){const r=[];return void 0!==e&&r.push(`patron.pid:${e}`),void 0!==o&&r.push(`loan.pid:${o}`),void 0!==a&&r.push(`type:${a}`),void 0!==s&&r.push(`status:${s}`),r.join(" AND ")}_loadPatronTransactions(e,o="-creation_date"){return this._recordService.getRecords("patron_transactions",e,1,h.nO.MAX_REST_RESULTS_SIZE,void 0,void 0,void 0,o).pipe((0,j.T)(a=>a.hits),(0,j.T)(a=>0===this._recordService.totalHits(a.total)?[]:a.hits),(0,j.T)(a=>a.map(s=>new N.dh(s.metadata))))}patronTransactionsByLoan$(e,o,a){const s=this._buildQuery(void 0,e,o,a);return this._recordService.getRecords("patron_transactions",s,1,h.nO.MAX_REST_RESULTS_SIZE).pipe((0,j.T)(r=>r.hits),(0,j.T)(r=>0===this._recordService.totalHits(r.total)?[]:r.hits),(0,j.T)(r=>r.map(c=>new N.dh(c.metadata))))}patronTransactionsByPatron$(e,o,a){const s=this._buildQuery(e,void 0,o,a);return this._loadPatronTransactions(s)}emitPatronTransactionByPatron(e,o,a){this.patronTransactionsByPatron$(e,o,a).subscribe(s=>this.patronTransactionsSubject$.next(s))}loadTransactionHistory(e){this._recordService.getRecords("patron_transaction_events",`parent.pid:${e.pid}`,1,h.nO.MAX_REST_RESULTS_SIZE).pipe((0,j.T)(a=>a.hits),(0,j.T)(a=>0===this._recordService.totalHits(a.total)?[]:a.hits),(0,j.T)(a=>a.map(s=>new N.jL(s.metadata)))).subscribe(a=>e.events=a)}computeTotalTransactionsAmount(e){return e.reduce((o,a)=>a.status===N.Ju.OPEN?parseFloat((o+a.total_amount).toFixed(2)):o,0)}_buildTransactionEventsSkeleton(e){const o=this._userService.user;return{parent:{$ref:this._routeToolService.apiService.getRefEndpoint("patron_transactions",e.pid)},operator:{$ref:this._routeToolService.apiService.getRefEndpoint("patrons",o.patronLibrarian.pid)},library:{$ref:this._routeToolService.apiService.getRefEndpoint("libraries",o.currentLibrary)}}}payPatronTransaction(e,o,a){const s=this._buildTransactionEventsSkeleton(e);s.type=N.zP.PAYMENT,s.subtype=a,s.amount=o,this.patronFeesOperationSubject$.next(0-o),this._createTransactionEvent(s,e.patron.pid)}disputePatronTransaction(e,o){const a=this._buildTransactionEventsSkeleton(e);a.type=N.zP.DISPUTE,a.note=o,this._createTransactionEvent(a,e.patron.pid)}cancelPatronTransaction(e,o,a){const s=this._buildTransactionEventsSkeleton(e);s.type=N.zP.CANCEL,s.amount=o,s.note=a,this.patronFeesOperationSubject$.next(0-o),this._createTransactionEvent(s,e.patron.pid)}_createTransactionEvent(e,o){this._recordService.create("patron_transaction_events",e).subscribe(()=>{this.emitPatronTransactionByPatron(o,void 0,"open");const a=this._translateService.instant(e.type);this._toastService.success(this._translateService.instant("{{ type }} registered",{type:a}))},a=>{const s=a.hasOwnProperty("message")&&a.message().hasOwnProperty("message")?a.message.message:"Server error :: "+(a.title||a.toString()),r="["+a.status+" - "+a.statusText+"] "+s,c=this._translateService.instant(e.type);this._toastService.error(r,this._translateService.instant("{{ type }} creation failed!",{type:c}),{disableTimeOut:!0,closeButton:!0,enableHtml:!0})})}static#t=this.\u0275fac=function(o){return new(o||n)(t.KVO(h.nO),t.KVO(f.DL),t.KVO(Vi.F),t.KVO(st.tw),t.KVO(m.c$))};static#e=this.\u0275prov=t.jDH({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var Ne=_(6428);let qi=(()=>{class n{constructor(e){this._loanService=e}transform(e){return this._loanService.getCirculationPolicy(e.pid)}static#t=this.\u0275fac=function(o){return new(o||n)(t.rXU(Ne.a,16))};static#e=this.\u0275pipe=t.EJ8({name:"getLoanCipo",type:n,pure:!0})}return n})();const Yi=(n,i)=>({"callout callout-warning":n,"text-secondary":i}),Hi=n=>["/records","items","detail",n],Wi=n=>["/records","documents","detail",n],Bi=()=>({prefix:"item",suffix:"renew-button"}),Zi=(n,i)=>({"btn-expanded":n,"btn-collapsed":i}),Le=n=>["/circulation","patron",n,"loan"],Ji=n=>["/records","circ_policies","detail",n];function zi(n,i){if(1&n){const e=t.RV6();t.j41(0,"button",14),t.nI1(1,"idAttribute"),t.bIt("click",function(a){t.eBV(e);const s=t.XpG(2);return t.Njj(s.extendLoanClick(a))}),t.nrm(2,"i",15),t.EFF(3),t.nI1(4,"translate"),t.k0s()}if(2&n){const e=t.XpG(2);t.Y8G("disabled",!e.item.actions.includes(e.itemAction.extend_loan)),t.BMQ("id",t.i5U(1,3,e.item.barcode,t.lJ4(8,Bi))),t.R7$(3),t.SpI(" ",t.bMT(4,6,"Renew")," ")}}function Ki(n,i){if(1&n){const e=t.RV6();t.j41(0,"button",16),t.bIt("click",function(){t.eBV(e);const a=t.XpG(2);return t.Njj(a.isCollapsed=!a.isCollapsed)}),t.k0s()}if(2&n){const e=t.XpG(2);t.Y8G("ngClass",t.l_i(2,Zi,!e.isCollapsed,e.isCollapsed)),t.BMQ("aria-expanded",!e.isCollapsed)}}function Qi(n,i){if(1&n&&t.nrm(0,"shared-inherited-call-number",6),2&n){const e=t.XpG(2);t.Y8G("item",e.item)}}function to(n,i){1&n&&t.nrm(0,"i",17)}function eo(n,i){if(1&n&&t.DNE(0,to,1,0,"i",17),2&n){const e=t.XpG(2);t.vxM(0,e.item.actionDone===e.itemAction.checkin&&e.item.getNote("checkin_note")||e.item.actionDone===e.itemAction.checkout&&e.item.getNote("checkout_note")?0:-1)}}function no(n,i){1&n&&t.nrm(0,"i",17)}function io(n,i){if(1&n&&t.DNE(0,no,1,0,"i",17),2&n){const e=t.XpG(2);t.vxM(0,e.item.actions?-1:0)}}function oo(n,i){if(1&n&&(t.EFF(0),t.nI1(1,"mainTitle"),t.nI1(2,"truncateText"),t.nI1(3,"mainTitle")),2&n){const e=t.XpG(2);t.SpI(" ",e.isCollapsed?t.i5U(2,3,t.bMT(1,1,e.item.document.title),12):t.bMT(3,6,e.item.document.title)," ")}}function ao(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(3);t.SpI(" ",e.document.title[0]._text," ")}}function so(n,i){if(1&n&&t.DNE(0,ao,1,1),2&n){const e=t.XpG(2);t.vxM(0,e.document?0:-1)}}function ro(n,i){if(1&n&&(t.j41(0,"span",8),t.EFF(1),t.k0s()),2&n){const e=t.XpG(2);t.R7$(),t.JRh(e.item.enumerationAndChronology)}}function co(n,i){if(1&n&&t.nrm(0,"shared-contribution",9),2&n){const e=t.XpG(2);t.Y8G("contributions",null==e.document?null:e.document.contribution)}}function lo(n,i){if(1&n&&(t.j41(0,"li",20),t.EFF(1),t.nI1(2,"translate"),t.nrm(3,"i",21),t.j41(4,"span"),t.EFF(5),t.nI1(6,"dateTranslate"),t.k0s()()),2&n){const e=t.XpG(3);t.R7$(),t.SpI(" ",t.bMT(2,4,e.item.status)," "),t.R7$(3),t.AVh("text-warning",e.loan&&e.loan.expired),t.R7$(),t.SpI(" ",t.i5U(6,6,e.item.loan.dueDate,"shortDate")," ")}}function uo(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG();t.SpI(" ",e.metadata.pickup_name," ")}}function mo(n,i){if(1&n&&(t.EFF(0),t.nI1(1,"getRecord"),t.nI1(2,"async")),2&n){const e=t.XpG();t.SpI(" ",t.bMT(2,6,t.ii3(1,1,e.metadata.library.pid,"libraries","field","name"))," ")}}function po(n,i){if(1&n&&(t.EFF(0),t.nI1(1,"translate"),t.DNE(2,uo,1,1)(3,mo,3,8),t.EFF(4,") ")),2&n){const e=t.XpG(4);t.SpI(" (",t.bMT(1,2,"to")," "),t.R7$(2),t.vxM(2,e.item.loan&&"ITEM_IN_TRANSIT_FOR_PICKUP"===e.item.loan.state?2:3)}}function ho(n,i){if(1&n&&(t.j41(0,"li",20),t.EFF(1),t.nI1(2,"translate"),t.DNE(3,po,5,4),t.nI1(4,"getRecord"),t.nI1(5,"async"),t.k0s()),2&n){let e;const o=t.XpG(3);t.R7$(),t.SpI(" ",t.bMT(2,2,o.item.status)," "),t.R7$(2),t.vxM(3,(e=t.bMT(5,7,t.i5U(4,4,o.getTransitLocationPid(),"locations")))?3:-1,e)}}function fo(n,i){if(1&n&&(t.j41(0,"li",20),t.EFF(1),t.nI1(2,"translate"),t.k0s()),2&n){const e=t.XpG(3);t.R7$(),t.JRh(t.bMT(2,1,e.item.status))}}function _o(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(4);t.SpI(" (",e.item.loan.pickup_location.pickup_name,") ")}}function Co(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(4);t.SpI(" (",e.item.pending_loans[0].pickup_location.pickup_name,") ")}}function go(n,i){if(1&n&&(t.j41(0,"li"),t.EFF(1),t.nI1(2,"translate"),t.DNE(3,_o,1,1)(4,Co,1,1),t.k0s()),2&n){const e=t.XpG(3);t.R7$(),t.SpI(" ",t.bMT(2,3,e.item.status)," "),t.R7$(2),t.vxM(3,e.item.loan&&e.item.loan.pickup_location?3:-1),t.R7$(),t.vxM(4,!e.item.loan&&e.item.pending_loans&&e.item.pending_loans.length>0&&e.item.pending_loans[0].pickup_location?4:-1)}}function vo(n,i){if(1&n&&(t.j41(0,"li",20),t.EFF(1),t.nI1(2,"translate"),t.k0s()),2&n){const e=t.XpG(3);t.R7$(),t.JRh(t.bMT(2,1,e.item.status))}}function bo(n,i){if(1&n&&(t.j41(0,"span",18),t.nI1(1,"translate"),t.EFF(2),t.nrm(3,"i",22),t.k0s()),2&n){const e=t.XpG(3);t.FS9("title",t.bMT(1,2,"Renewals")),t.R7$(2),t.SpI(" ",e.item.loan.extension_count," ")}}function yo(n,i){if(1&n&&(t.j41(0,"span",19),t.nI1(1,"translate"),t.EFF(2),t.nI1(3,"currency"),t.k0s()),2&n){const e=t.XpG(3);t.FS9("title",t.bMT(1,2,"Fees")),t.R7$(2),t.SpI(" ",t.i5U(3,4,e.totalAmountOfFee,e.organisation.default_currency)," ")}}function ko(n,i){if(1&n&&(t.j41(0,"span",18),t.nI1(1,"translate"),t.nrm(2,"i",23),t.j41(3,"a",24),t.EFF(4),t.k0s()()),2&n){const e=t.XpG(3);t.FS9("title",t.bMT(1,3,"Requests")),t.R7$(3),t.Y8G("routerLink",t.eq3(5,Le,e.item.pending_loans[0].patron.barcode)),t.R7$(),t.SpI(" ",e.item.pending_loans[0].patron.name," ")}}function To(n,i){if(1&n&&(t.j41(0,"ul",11),t.DNE(1,lo,7,9)(2,ho,6,9)(3,fo,3,3)(4,go,5,5)(5,vo,3,3),t.j41(6,"li"),t.DNE(7,bo,4,4,"span",18)(8,yo,4,7,"span",19)(9,ko,5,7,"span",18),t.k0s()()),2&n){let e;const o=t.XpG(2);t.R7$(),t.vxM(1,"on_loan"===(e=o.item.status)?1:"in_transit"===e?2:"on_shelf"===e?3:"at_desk"===e?4:5),t.R7$(6),t.vxM(7,o.isCollapsed&&o.item.loan&&o.item.loan.extension_count&&(!o.item.actionDone||o.item.actionDone!==o.itemAction.checkin)?7:-1),t.R7$(),t.vxM(8,o.isCollapsed&&o.totalAmountOfFee>0?8:-1),t.R7$(),t.vxM(9,o.isCollapsed&&o.item.pending_loans&&o.item.pending_loans.length?9:-1)}}function Fo(n,i){if(1&n&&(t.EFF(0),t.nI1(1,"translate")),2&n){const e=t.XpG(2);t.SpI(" ",t.bMT(1,1,e.item.status)," ")}}function So(n,i){1&n&&(t.nrm(0,"i",25),t.j41(1,"span",26),t.EFF(2,"checked in"),t.k0s())}function Io(n,i){1&n&&(t.nrm(0,"i",27),t.j41(1,"span",26),t.EFF(2,"checked out"),t.k0s())}function Eo(n,i){1&n&&(t.nrm(0,"i",28),t.j41(1,"span",26),t.EFF(2,"renewed"),t.k0s())}function xo(n,i){if(1&n&&(t.j41(0,"span",29),t.EFF(1),t.nI1(2,"translate"),t.k0s()),2&n){const e=t.XpG(3);t.R7$(),t.JRh(t.bMT(2,1,e.item.actionDone))}}function Ro(n,i){if(1&n&&t.DNE(0,So,3,0)(1,Io,3,0)(2,Eo,3,0)(3,xo,3,3),2&n){let e;const o=t.XpG(2);t.vxM(0,(e=o.item.actionDone)===o.itemAction.checkin?0:e===o.itemAction.checkout?1:e===o.itemAction.extend_loan?2:3)}}function Mo(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Unit"),t.k0s(),t.j41(2,"dd",32),t.EFF(3),t.k0s()),2&n){const e=t.XpG(3);t.R7$(3),t.SpI(" ",e.item.enumerationAndChronology," ")}}function wo(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Location"),t.k0s(),t.j41(2,"dd",32),t.EFF(3),t.nI1(4,"getRecord"),t.nI1(5,"async"),t.k0s()),2&n){const e=i;t.R7$(3),t.Lme(" ",t.bMT(5,7,t.ii3(4,2,e.metadata.library.pid,"libraries","field","name")),": ",e.metadata.name," ")}}function Do(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Temporary location"),t.k0s(),t.j41(2,"dd",32),t.EFF(3),t.k0s()),2&n){const e=t.XpG(3);t.R7$(3),t.SpI(" ",e.item.temporary_location.name," ")}}function $o(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Exhibition/course"),t.k0s(),t.j41(2,"dd",32),t.EFF(3),t.k0s()),2&n){const e=t.XpG(3);t.R7$(3),t.SpI(" ",e.item.collections.join(", ")," ")}}function Oo(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Renewals"),t.k0s(),t.j41(2,"dd",35)(3,"span",36),t.EFF(4),t.nrm(5,"i",22),t.k0s()()),2&n){const e=t.XpG(3);t.R7$(4),t.SpI(" ",e.item.loan.extension_count," ")}}function jo(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Due date"),t.k0s(),t.j41(2,"dd",37),t.EFF(3),t.nI1(4,"dateTranslate"),t.k0s()),2&n){const e=t.XpG(3);t.R7$(3),t.SpI(" ",t.i5U(4,1,e.item.loan.last_end_date,"shortDate")," ")}}function No(n,i){if(1&n&&(t.j41(0,"dt",38),t.EFF(1,"Fees"),t.k0s(),t.j41(2,"dd",39)(3,"span",40),t.EFF(4),t.nI1(5,"currency"),t.k0s()()),2&n){const e=t.XpG(3);t.R7$(4),t.SpI(" ",t.i5U(5,1,e.totalAmountOfFee,e.organisation.default_currency)," ")}}function Lo(n,i){if(1&n&&(t.j41(0,"li")(1,"span",42),t.EFF(2),t.nI1(3,"dateTranslate"),t.nI1(4,"dateTranslate"),t.nI1(5,"translate"),t.k0s(),t.EFF(6),t.nI1(7,"translate"),t.k0s()),2&n){const e=i.$implicit;t.R7$(2),t.SpI(" ",e.metadata.process_date?t.i5U(3,2,e.metadata.process_date,"short"):t.i5U(4,5,e.metadata.creation_date,"shortDate")+"\xa0("+t.bMT(5,8,"Not yet sent")+")"," "),t.R7$(4),t.SpI(" \u2014 ",t.bMT(7,10,e.metadata.notification_type)," ")}}function Po(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Notifications"),t.k0s(),t.j41(2,"dd",41)(3,"ul",11),t.Z7z(4,Lo,8,12,"li",null,t.fX1),t.k0s()()),2&n){const e=t.XpG();t.R7$(4),t.Dyx(e)}}function Go(n,i){1&n&&t.DNE(0,Po,6,0),2&n&&t.vxM(0,i.length>0?0:-1)}function Xo(n,i){if(1&n&&(t.j41(0,"span",8),t.EFF(1),t.k0s(),t.nrm(2,"i",45)),2&n){const e=t.XpG(4);t.R7$(),t.JRh(e.item.pending_loans.length)}}function Ao(n,i){if(1&n&&(t.j41(0,"span",44),t.nrm(1,"i",23),t.j41(2,"a",24),t.EFF(3),t.k0s()()),2&n){const e=i.$implicit;t.R7$(2),t.Y8G("routerLink",t.eq3(2,Le,e.patron.barcode)),t.R7$(),t.JRh(e.patron.name)}}function Uo(n,i){if(1&n&&(t.j41(0,"dt",31),t.EFF(1,"Requests"),t.k0s(),t.j41(2,"dd",43),t.DNE(3,Xo,3,1),t.Z7z(4,Ao,4,4,"span",44,t.fX1),t.k0s()),2&n){const e=t.XpG(3);t.R7$(3),t.vxM(3,e.item.pending_loans.length>1?3:-1),t.R7$(),t.Dyx(e.item.pending_loans)}}function Vo(n,i){if(1&n&&(t.EFF(0),t.nI1(1,"translate")),2&n){const e=t.XpG().$implicit;t.SpI(" ",t.bMT(1,1,e.type)," ")}}function qo(n,i){1&n&&(t.EFF(0),t.nI1(1,"translate")),2&n&&t.SpI(" ",t.bMT(1,1,"Note")," ")}function Yo(n,i){if(1&n&&(t.j41(0,"dd",46),t.nrm(1,"i",47),t.k0s(),t.j41(2,"dt",48),t.DNE(3,Vo,2,3)(4,qo,2,3),t.k0s(),t.j41(5,"dd",49),t.EFF(6),t.k0s()),2&n){const e=i.$implicit,o=t.XpG(3);t.R7$(3),t.vxM(3,e.type!==o.NOTEAPI?3:4),t.R7$(3),t.JRh(e.content)}}function Ho(n,i){if(1&n&&(t.j41(0,"dd",52)(1,"pre",53),t.EFF(2),t.nI1(3,"json"),t.j41(4,"legend"),t.EFF(5,"\n "),t.j41(6,"a",54),t.EFF(7,"\n "),t.nrm(8,"i",55),t.EFF(9,"cipo\n "),t.k0s(),t.EFF(10,"\n "),t.k0s()()()),2&n){const e=i;t.R7$(2),t.JRh(t.bMT(3,2,e)),t.R7$(4),t.Y8G("routerLink",t.eq3(4,Ji,e.pid))}}function Wo(n,i){if(1&n&&(t.j41(0,"dd",52)(1,"pre",53),t.EFF(2),t.nI1(3,"json"),t.j41(4,"legend"),t.EFF(5,"loan"),t.k0s()()(),t.DNE(6,Ho,11,6,"dd",52),t.nI1(7,"getLoanCipo"),t.nI1(8,"async")),2&n){let e;const o=t.XpG(4);t.R7$(2),t.JRh(t.bMT(3,2,o.loan)),t.R7$(4),t.vxM(6,(e=t.bMT(8,6,t.bMT(7,4,o.loan)))?6:-1,e)}}function Bo(n,i){if(1&n&&(t.j41(0,"dd",52)(1,"pre",53),t.EFF(2),t.nI1(3,"json"),t.j41(4,"legend"),t.EFF(5,"item"),t.k0s()()()),2&n){const e=t.XpG(4);t.R7$(2),t.JRh(t.bMT(3,1,e.item))}}function Zo(n,i){if(1&n&&(t.j41(0,"dd",46),t.nrm(1,"i",50),t.k0s(),t.j41(2,"dt",51),t.EFF(3,"Debug"),t.k0s(),t.DNE(4,Wo,9,8)(5,Bo,6,3)),2&n){const e=t.XpG(3);t.R7$(4),t.vxM(4,e.loan?4:5)}}function Jo(n,i){if(1&n){const e=t.RV6();t.j41(0,"button",56),t.bIt("click",function(){t.eBV(e);const a=t.XpG(3);return t.Njj(a.debugMode=!a.debugMode)}),t.nrm(1,"i",57)(2,"i",58),t.k0s()}if(2&n){const e=t.XpG(3);t.AVh("btn-hover",e.debugMode),t.R7$(2),t.Y8G("ngClass",e.debugMode?"fa-toggle-on":"fa-toggle-off")}}function zo(n,i){if(1&n&&(t.j41(0,"div",13)(1,"dl",30)(2,"dt",31),t.EFF(3,"Call number"),t.k0s(),t.j41(4,"dd",32),t.nrm(5,"shared-inherited-call-number",33),t.k0s(),t.DNE(6,Mo,4,1)(7,wo,6,9),t.nI1(8,"getRecord"),t.nI1(9,"async"),t.DNE(10,Do,4,1)(11,$o,4,1)(12,Oo,6,1)(13,jo,5,4)(14,No,6,4)(15,Go,1,1),t.nI1(16,"async"),t.DNE(17,Uo,6,1),t.Z7z(18,Yo,7,2,null,null,t.fX1),t.DNE(20,Zo,6,1),t.k0s(),t.DNE(21,Jo,3,3,"button",34),t.k0s()),2&n){let e,o;const a=t.XpG(2);t.R7$(5),t.Y8G("item",a.item),t.R7$(),t.vxM(6,a.item.enumerationAndChronology?6:-1),t.R7$(),t.vxM(7,(e=t.bMT(9,15,t.i5U(8,12,a.item.location.pid,"locations")))?7:-1,e),t.R7$(3),t.vxM(10,a.item.temporary_location?10:-1),t.R7$(),t.vxM(11,a.item.collections&&a.item.collections.length>0?11:-1),t.R7$(),t.vxM(12,a.item.loan&&a.item.loan.extension_count?12:-1),t.R7$(),t.vxM(13,a.item.loan&&"checkin"===a.item.actionDone&&null!=a.item&&null!=a.item.loan&&a.item.loan.last_end_date?13:-1),t.R7$(),t.vxM(14,a.item.loan&&a.totalAmountOfFee>0?14:-1),t.R7$(),t.vxM(15,(o=t.bMT(16,17,a.item.loan&&a.notifications$))?15:-1,o),t.R7$(2),t.vxM(17,a.item.pending_loans?17:-1),t.R7$(),t.Dyx(a.getCirculationNoteForAction()),t.R7$(2),t.vxM(20,a.debugMode?20:-1),t.R7$(),t.vxM(21,a.canUseDebugMode?21:-1)}}function Ko(n,i){if(1&n&&(t.j41(0,"div",0)(1,"div",1),t.DNE(2,zi,5,9,"button",2),t.k0s(),t.j41(3,"div",3),t.DNE(4,Ki,1,5,"button",4),t.j41(5,"div")(6,"a",5),t.EFF(7),t.k0s(),t.DNE(8,Qi,1,1,"shared-inherited-call-number",6),t.k0s(),t.DNE(9,eo,1,1)(10,io,1,1),t.k0s(),t.j41(11,"div",7)(12,"a",5),t.DNE(13,oo,4,8)(14,so,1,1),t.k0s(),t.DNE(15,ro,2,1,"span",8)(16,co,1,1,"shared-contribution",9),t.k0s(),t.j41(17,"div",10),t.DNE(18,To,10,4,"ul",11)(19,Fo,2,3),t.k0s(),t.j41(20,"div",12),t.DNE(21,Ro,4,1),t.k0s(),t.DNE(22,zo,22,19,"div",13),t.k0s()),2&n){const e=t.XpG();t.Y8G("ngClass",t.l_i(14,Yi,e.needCallout(e.item,"warning")||e.item.actionDone===e.itemAction.checkin&&e.totalAmountOfFee>0||!e.item.loan,e.item.status!==e.ItemStatus.ON_LOAN)),t.R7$(2),t.vxM(2,e.patron?2:-1),t.R7$(2),t.vxM(4,!e.item.actions||e.item.loan||e.totalAmountOfFee||e.item.pending_loans||e.notifications$?4:-1),t.R7$(2),t.Y8G("routerLink",t.eq3(17,Hi,e.item.pid)),t.R7$(),t.JRh(e.item.barcode),t.R7$(),t.vxM(8,e.isCollapsed?8:-1),t.R7$(),t.vxM(9,e.item.actionDone?9:10),t.R7$(3),t.Y8G("routerLink",t.eq3(19,Wi,e.item.document.pid)),t.R7$(),t.vxM(13,null!=e.item.document&&e.item.document.title?13:14),t.R7$(2),t.vxM(15,e.item.enumerationAndChronology&&e.isCollapsed?15:-1),t.R7$(),t.vxM(16,e.document?16:-1),t.R7$(2),t.vxM(18,e.item.loan?18:19),t.R7$(3),t.vxM(21,e.item.actionDone?21:-1),t.R7$(),t.vxM(22,e.isCollapsed?-1:22)}}let Qo=(()=>{class n{get organisation(){return this.organisationService.organisation}get canUseDebugMode(){return this.permissionsService.canAccessDebugMode()}constructor(e,o,a,s,r,c){this.recordService=e,this.organisationService=o,this.patronTransactionService=a,this.itemService=s,this.permissionsService=r,this.userService=c,this.NOTEAPI=k.EC.API,this.isCollapsed=!0,this.hasFeesEmitter=new t.bkB,this.extendLoanClicked=new t.bkB,this.totalAmountOfFee=0,this.itemAction=k.sZ,this.document=void 0,this.ItemStatus=f.Kw,this.debugMode=!1}ngOnInit(){if(this.loan=this.item&&this.item.loan?new x.F7(this.item.loan):null,this.loan){const e=this.item.loan.pid;this.patronTransactionService.patronTransactionsByLoan$(e,"overdue","open").subscribe(o=>{this.totalAmountOfFee=this.patronTransactionService.computeTotalTransactionsAmount(o),this.totalAmountOfFee>0&&this.hasFeesEmitter.emit(!0)}),this.notifications$=this.recordService.getRecords("notifications",`context.loan.pid:${e}`,1,h.nO.MAX_REST_RESULTS_SIZE,[],{},null,"mostrecent").pipe((0,j.T)(o=>o.hits.hits))}this.item?.document?.pid&&this.recordService.getRecord("documents",this.item.document.pid,1,{Accept:"application/rero+json, application/json"}).subscribe(e=>this.document=e.metadata)}getTransitLocationPid(){if(this.patron||void 0===this.item.action_applied){if(this.item.loan&&this.item.loan.state===x.sl.ITEM_IN_TRANSIT_FOR_PICKUP)return this.item.loan.pickup_location_pid;if(this.item.loan&&this.item.loan.state===x.sl.ITEM_IN_TRANSIT_TO_HOUSE)return this.item.location.pid}else{const e=new x.F7(this.item.action_applied[k.sZ.validate]),o=new x.F7(this.item.action_applied[k.sZ.checkin]);if(e&&e.state===x.sl.ITEM_IN_TRANSIT_FOR_PICKUP)return e.pickup_location_pid;if(o&&o.state===x.sl.ITEM_IN_TRANSIT_TO_HOUSE)return this.item.location.pid}return null}getCirculationNoteForAction(){if(this.item.actionDone){const e=this.item.getNote(k.EC.CHECKIN);if(e&&(this.item.actionDone===this.itemAction.checkin||this.item.actionDone===this.itemAction.receive&&this.item.library.pid===this.userService.user.currentLibrary))return[e];const o=this.item.getNote(k.EC.CHECKOUT);if(o&&this.item.actionDone===this.itemAction.checkout)return[o]}else if(this.item.notes)return this.item?.notes.filter(e=>[k.EC.CHECKIN,k.EC.API].includes(e.type));return[]}extendLoanClick(e){this.extendLoanClicked.emit(this.item)}needCallout(e,o){return this.itemService.needCallout(e,o)}static#t=this.\u0275fac=function(o){return new(o||n)(t.rXU(h.nO),t.rXU(et.y),t.rXU(Rt),t.rXU(ht._),t.rXU(f.Kn),t.rXU(f.DL))};static#e=this.\u0275cmp=t.VBU({type:n,selectors:[["admin-item"]],inputs:{item:"item",patron:"patron",isCollapsed:"isCollapsed"},outputs:{hasFeesEmitter:"hasFeesEmitter",extendLoanClicked:"extendLoanClicked"},decls:1,vars:1,consts:[[1,"row","d-flex","align-items-start","item",3,"ngClass"],[1,"actions"],[1,"btn","btn-sm","btn-outline-secondary",3,"disabled"],["name","barcode",1,"col-2","d-flex"],["type","button","aria-controls","collapse",1,"btn-show-more",3,"ngClass"],[3,"routerLink"],[1,"d-block","small",3,"item"],["name","title",1,"col-lg-6"],[1,"badge","badge-info"],[3,"contributions"],["name","circ-info",1,"col-2"],[1,"list-unstyled","mb-0"],["name","action-done",1,"col-2"],["name","collapsed-details",1,"col-12","mt-2"],[1,"btn","btn-sm","btn-outline-secondary",3,"click","disabled"],[1,"fa","fa-refresh","pr-1"],["type","button","aria-controls","collapse",1,"btn-show-more",3,"click","ngClass"],[1,"fa","fa-exclamation-triangle","text-warning","mt-1","ml-auto"],[1,"badge","badge-secondary","font-weight-normal","mr-1",3,"title"],[1,"badge","badge-warning","font-weight-normal","mr-1",3,"title"],["name","status"],["aria-hidden","true",1,"fa","fa-arrow-right"],[1,"fa","fa-refresh"],[1,"fa","fa-shopping-basket","pr-1"],[1,"text-white",3,"routerLink"],["aria-hidden","true",1,"fa","fa-arrow-circle-o-down","text-success","align-baseline"],["translate","",1,"align-baseline","ml-1"],["aria-hidden","true",1,"fa","fa-arrow-circle-o-right","text-success","align-baseline"],["aria-hidden","true",1,"fa","fa-refresh","text-success","align-baseline"],[1,"align-baseline"],[1,"row"],["translate","",1,"offset-1","col-sm-3","col-md-2","col-lg-1","label-title"],[1,"col-sm-8","col-md-9","col-lg-10"],[3,"item"],[1,"float-right","btn","btn-sm","btn-outline-warning","mr-2",3,"btn-hover"],["name","renewals",1,"col-sm-8","col-md-9","col-lg-10"],[1,"badge","badge-secondary"],["name","due_date",1,"col-sm-8","col-md-9","col-lg-10"],["translate","",1,"offset-1","col-sm-3","col-md-getTransitLocationPid2","col-lg-1","label-title"],["name","fees",1,"col-sm-8","col-md-9","col-lg-10"],[1,"badge","badge-warning","font-weight-normal"],["name","notifications",1,"col-sm-8","col-md-9","col-lg-10"],[1,"text-secondary","small"],["name","request-for",1,"col-sm-8","col-md-9","col-lg-10"],[1,"badge","badge-secondary","font-weight-normal","mr-2"],[1,"fa","fa-long-arrow-right","px-2"],[1,"col-1","text-right","pr-1"],[1,"fa","fa-sticky-note-o","text-warning"],[1,"col-sm-3","col-md-2","col-lg-1","label-title"],["name","checkin-note",1,"col-sm-8","col-md-9","col-lg-10","text-justify"],[1,"fa","fa-bug","text-danger"],["translate","",1,"col-1","label-title","text-danger"],[1,"col-5"],[1,"border","p-3"],["target","_circulation",3,"routerLink"],[1,"fa","fa-external-link","pr-2"],[1,"float-right","btn","btn-sm","btn-outline-warning","mr-2",3,"click"],[1,"fa","fa-bug","pr-1"],[1,"fa",3,"ngClass"]],template:function(o,a){1&o&&t.DNE(0,Ko,23,21,"div",0),2&o&&t.vxM(0,a.item&&!a.item.loading?0:-1)},dependencies:[$.Wk,g.YU,m.Mm,f.Rt,f.KF,g.Jj,g.TG,g.oe,h.yX,m.D9,h._G,h.X1,f.OQ,f.kE,qi],styles:[".btn-hover[_ngcontent-%COMP%]{color:#000;background-color:#ffc107}.item[_ngcontent-%COMP%]{margin-bottom:.25rem!important;padding:.25rem!important;border:1px solid #dee2e6;border-radius:.25rem;position:relative}.item[_ngcontent-%COMP%]:hover{background-color:#f8f9fa}.item[_ngcontent-%COMP%] div.actions[_ngcontent-%COMP%]{position:absolute;top:.25rem;right:15px}"]})}return n})();const ta=(n,i)=>({"btn-expanded":n,"btn-collapsed":i}),Pe=()=>({prefix:"item"});function ea(n,i){1&n&&(t.j41(0,"div",0)(1,"span",1),t.EFF(2,"No loan for the current patron."),t.k0s()())}function na(n,i){if(1&n){const e=t.RV6();t.j41(0,"button",10),t.bIt("click",function(){t.eBV(e);const a=t.XpG(2);return t.Njj(a.extendAllLoansClick())}),t.EFF(1,"Renew all"),t.k0s()}if(2&n){const e=t.XpG(2);t.Y8G("disabled",e.loansToExtend.length<1)}}function ia(n,i){if(1&n){const e=t.RV6();t.j41(0,"admin-item",11),t.nI1(1,"idAttribute"),t.bIt("extendLoanClicked",function(a){const s=t.eBV(e).$implicit,r=t.XpG(2);return t.Njj(r.extendLoanClick(a,s))}),t.k0s()}if(2&n){const e=i.$implicit,o=t.XpG(2);t.Y8G("patron",o.patron)("item",e)("isCollapsed",o.allCollapsed),t.BMQ("id",t.i5U(1,4,e.barcode,t.lJ4(7,Pe)))}}function oa(n,i){if(1&n){const e=t.RV6();t.j41(0,"admin-item",12),t.nI1(1,"idAttribute"),t.bIt("hasFeesEmitter",function(a){t.eBV(e);const s=t.XpG(2);return t.Njj(s.hasFees(a))}),t.k0s()}if(2&n){const e=i.$implicit,o=t.XpG(2);t.Y8G("patron",o.patron)("item",e)("isCollapsed",o.allCollapsed),t.BMQ("id",t.i5U(1,4,e.barcode,t.lJ4(7,Pe)))}}function aa(n,i){if(1&n){const e=t.RV6();t.j41(0,"div",2)(1,"div",3)(2,"button",4),t.bIt("click",function(){t.eBV(e);const a=t.XpG();return t.Njj(a.allCollapsed=!a.allCollapsed)}),t.k0s(),t.EFF(3),t.nI1(4,"translate"),t.k0s(),t.j41(5,"div",5),t.EFF(6,"Document"),t.k0s(),t.j41(7,"div",6),t.EFF(8,"Circulation info"),t.k0s(),t.j41(9,"div",7),t.DNE(10,na,2,1,"button",8),t.k0s()(),t.Z7z(11,ia,2,8,"admin-item",9,t.fX1),t.Z7z(13,oa,2,8,"admin-item",9,t.fX1)}if(2&n){const e=t.XpG();t.R7$(2),t.Y8G("ngClass",t.l_i(6,ta,!e.allCollapsed,e.allCollapsed)),t.BMQ("aria-expanded",!e.allCollapsed),t.R7$(),t.SpI(" ",t.bMT(4,4,"Items")," "),t.R7$(7),t.vxM(10,e.patron?10:-1),t.R7$(),t.Dyx(e.checkedOutItems),t.R7$(2),t.Dyx(e.checkedInItems)}}let Ge=(()=>{class n{constructor(){this.extendAllLoansClicked=new t.bkB,this.extendLoanClicked=new t.bkB,this.hasFeesEmitter=new t.bkB,this.allCollapsed=!0}ngOnInit(){this.checkedOutItems=null}extendLoanClick(e,o){o.currentAction=k.sZ.extend_loan,this.extendLoanClicked.emit(o)}extendAllLoansClick(){this.extendAllLoansClicked.emit(this.loansToExtend.map(e=>(e.currentAction=k.sZ.extend_loan,e)))}get loansToExtend(){return this.checkedOutItems.filter(e=>e.actions.includes(k.sZ.extend_loan))}hasFees(e){return this.hasFeesEmitter.emit(e),e}static#t=this.\u0275fac=function(o){return new(o||n)};static#e=this.\u0275cmp=t.VBU({type:n,selectors:[["admin-circulation-items-list"]],inputs:{checkedOutItems:"checkedOutItems",checkedInItems:"checkedInItems",patron:"patron"},outputs:{extendAllLoansClicked:"extendAllLoansClicked",extendLoanClicked:"extendLoanClicked",hasFeesEmitter:"hasFeesEmitter"},decls:2,vars:2,consts:[[1,"mb-2"],["translate",""],[1,"row","mb-1","d-flex","align-items-center","bg-dark","text-white","rounded","p-1"],[1,"col-2"],["type","button","aria-controls","collapse",1,"btn-show-more",3,"click","ngClass"],["translate","",1,"col-6"],["translate","",1,"col-3"],[1,"col-1"],["id","renew-all-button","translate","",1,"btn","btn-primary","float-right","btn-sm","my-1",3,"disabled"],[3,"patron","item","isCollapsed"],["id","renew-all-button","translate","",1,"btn","btn-primary","float-right","btn-sm","my-1",3,"click","disabled"],[3,"extendLoanClicked","patron","item","isCollapsed"],[3,"hasFeesEmitter","patron","item","isCollapsed"]],template:function(o,a){1&o&&t.DNE(0,ea,3,0,"div",0)(1,aa,15,9),2&o&&(t.vxM(0,a.checkedOutItems&&0===a.checkedOutItems.length&&a.patron?0:-1),t.R7$(),t.vxM(1,a.checkedOutItems&&a.checkedOutItems.length>0||a.checkedInItems&&a.checkedInItems.length>0?1:-1))},dependencies:[g.YU,m.Mm,Qo,m.D9,f.OQ],styles:[".btn-show-more[_ngcontent-%COMP%]{background-color:transparent!important;color:#fff}"]})}return n})(),sa=(()=>{class n{constructor(e,o,a,s,r,c,l,u){this.userService=e,this.recordService=o,this.itemsService=a,this.router=s,this.translate=r,this.toastService=c,this.patronService=l,this.modalService=u,this.placeholder=(0,$e.x)("Please enter a patron card number or an item barcode."),this.searchText="",this.items=[],this.searchInputFocus=!0,this.searchInputDisabled=!1}ngOnInit(){this._loggedUser=this.userService.user,this.patronService.currentPatron$.subscribe(e=>this.patronInfo=e),this.currentLibraryPid=this._loggedUser.currentLibrary,this.patronInfo=null,this.barcode=null}searchValueUpdated(e){if(!e)return null;this.searchText=e,this.getPatronOrItem(this.searchText)}checkin(e){this.searchInputFocus=!1,this.searchInputDisabled=!0,this.itemsService.checkin(e,this._loggedUser.currentLibrary).subscribe(o=>{if(null===o||o.location.organisation.pid!==this._loggedUser.currentOrganisation)return this.toastService.error(this.translate.instant("Item or patron not found!"),this.translate.instant("Checkin")),void this._resetSearchInput();switch(o.hasRequests&&this.toastService.warning(this.translate.instant("The item contains requests"),this.translate.instant("Checkin")),o.actionDone){case k.sZ.return_missing:this.toastService.warning(this.translate.instant("The item has been returned from missing"),this.translate.instant("Checkin"));break;case k.sZ.checkin:this.displayCirculationInformation(o,k.EC.CHECKIN),o.action_applied&&o.action_applied.checkin&&this.getPatronInfo(o.action_applied.checkin.patron.barcode),o.status===f.Kw.IN_TRANSIT&&this.toastService.warning(this.translate.instant("The item is in transit to {{ destination }}",{destination:o.loan.item_destination.library_name}),this.translate.instant("Checkin"));break;case k.sZ.receive:o.library.pid===this.userService.user.currentLibrary&&this.displayCirculationInformation(o,k.EC.CHECKIN)}this.items.unshift(o),this._resetSearchInput()},o=>{this.item&&-1===this.items.findIndex(a=>a.barcode===this.item.barcode)&&this.itemsService.getItem(this.item.barcode).subscribe(a=>{delete a.actions,a.notes||(a.notes=[]),a.notes.push({content:o.error.status.replace(/^error:/,"").trim(),type:k.EC.API}),this.items.unshift(a),this._checkinErrorManagement(o,a)})})}getPatronInfo(e){e?(this.barcode=e,this.patronService.getPatron(e).subscribe(()=>{},o=>{this.toastService.error(o.message,this.translate.instant("Checkin"))})):(this.patronInfo=null,this.barcode=null)}getPatronOrItem(e){this.item=void 0;const s=this.recordService.getRecords("patrons",`patron.barcode:${e} AND organisation.pid:${this._loggedUser.currentOrganisation}`,1,1,[]).pipe((0,j.T)(c=>c.hits)),r=this.recordService.getRecords("items",`barcode:${e}`,1,1,[]).pipe((0,j.T)(c=>c.hits));(0,pt.p)([s,r]).subscribe(([c,l])=>{if(0===c.total.value&&0===l.total.value&&this.toastService.warning(this.translate.instant("Patron not found!"),this.translate.instant("Checkin")),c.total.value>1&&0===l.total.value&&this.toastService.warning(this.translate.instant("Found more than one patron."),this.translate.instant("Checkin")),1===c.total.value&&1===l.total.value){const u=this.modalService.show(Ii,{ignoreBackdropClick:!0,keyboard:!0});u.onHidden.subscribe(()=>{switch(u.content.action){case"patron":this.router.navigate(["/circulation","patron",e,"loan"]);break;case"item":this.checkin(e);break;default:this._resetSearchInput()}})}else 1===l.total.value?(this.item=l.hits[0].metadata,this.items.find(u=>u.barcode===e)?(this.toastService.warning(this.translate.instant("The item is already in the list."),this.translate.instant("Checkin")),this._resetSearchInput()):this.checkin(e)):1===c.total.value&&this.router.navigate(["/circulation","patron",e,"loan"])},c=>this.toastService.error(c.message,this.translate.instant("Checkin")))}displayCirculationInformation(e,o){let a=[];const s=e.getNote(o);if(null!=s&&a.push(s.content),e.library.pid===this.userService.user.currentLibrary){const r=this.displayCollectionsAndTemporaryLocation(e);r.length>0&&(a.length>0&&a.push("<br />"),a.push(r))}a.length>0&&this.toastService.warning(a.join(),this.translate.instant("Checkin"),{enableHtml:!0,closeButton:!0,disableTimeOut:!0,tapToDismiss:!1})}_checkinErrorManagement(e,o){let a=e.hasOwnProperty("error")&&e.error.hasOwnProperty("status")?e.error.status.replace(/^error:/,"").trim():e.message;if(a=this.translate.instant(a),a+=`<br/>${this.translate.instant("Status")}: ${this.translate.instant(o.status.toString())}`,o.status===f.Kw.IN_TRANSIT&&o.loan&&o.loan.item_destination){const{library_name:r}=o.loan.item_destination;a+=` (${this.translate.instant("to")} ${r})`}const s=o.getNote(k.EC.CHECKIN);if(s&&(a+=`<br/>${this.translate.instant("Note")}: ${s.content}`),o.library.pid===this.userService.user.currentLibrary){const r=this.displayCollectionsAndTemporaryLocation(o);r.length>0&&(a+=`<br />${r}`)}this.toastService.warning(a,this.translate.instant("Checkin"),{enableHtml:!0,closeButton:!0,disableTimeOut:!0,tapToDismiss:!1}),this._resetSearchInput()}displayCollectionsAndTemporaryLocation(e){let o=[];return e.collections&&e.collections.length>0&&(o.push(`${this.translate.instant("This item is in exhibition/course")} "${e.collections[0]}"`),e.collections.length>1&&o.push(` ${this.translate.instant("and {{ count }} other(s)",{count:e.collections.length-1})}`),o.push(".")),e.temporary_location&&o.push(`<br/>${this.translate.instant("This item is in temporary location")} "${e.temporary_location.name}".`),o.join("")}hasFees(e){e&&this.toastService.error(this.translate.instant("The item has fees"),this.translate.instant("Checkin"))}_resetSearchInput(){setTimeout(()=>{this.searchInputDisabled=!1,this.searchInputFocus=!0,this.searchText=""})}static#t=this.\u0275fac=function(o){return new(o||n)(t.rXU(f.DL),t.rXU(h.nO),t.rXU(ht._),t.rXU($.Ix),t.rXU(m.c$),t.rXU(st.tw),t.rXU(K.Q),t.rXU(A.I8))};static#e=this.\u0275cmp=t.VBU({type:n,selectors:[["admin-circulation-checkout"]],decls:12,vars:11,consts:[["translate",""],[1,"content"],[1,"row"],[1,"col","col-md-6","mb-4"],[3,"search","placeholder","searchText","focus","disabled"],[3,"patron","barcode","linkMode","clearPatronButton"],[1,"col-md-12"],[3,"hasFeesEmitter","checkedInItems"]],template:function(o,a){1&o&&(t.j41(0,"h4",0),t.EFF(1,"Checkout/checkin"),t.k0s(),t.j41(2,"section",1)(3,"div",2)(4,"div",3)(5,"ng-core-search-input",4),t.nI1(6,"translate"),t.bIt("search",function(r){return a.searchValueUpdated(r)}),t.k0s()(),t.j41(7,"div",3),t.nrm(8,"admin-circulation-patron-detailed",5),t.k0s()(),t.j41(9,"div",2)(10,"div",6)(11,"admin-circulation-items-list",7),t.bIt("hasFeesEmitter",function(r){return a.hasFees(r)}),t.k0s()()()()),2&o&&(t.R7$(5),t.Y8G("placeholder",t.bMT(6,9,a.placeholder))("searchText",a.searchText)("focus",a.searchInputFocus)("disabled",a.searchInputDisabled),t.R7$(3),t.Y8G("patron",a.patronInfo)("barcode",a.barcode)("linkMode","circulation")("clearPatronButton",!1),t.R7$(3),t.Y8G("checkedInItems",a.items))},dependencies:[m.Mm,h.i5,je,Ge,m.D9],encapsulation:2})}return n})();var _t=_(8359),ra=_(3236),ca=_(1584);const ua=(n,i)=>({"btn-expanded":n,"btn-collapsed":i}),da=n=>["/records","items","detail",n],ma=()=>({prefix:"item",suffix:"validate-button"}),pa=n=>["/records","documents","detail",n],ha=n=>["/circulation","patron",n];function fa(n,i){if(1&n){const e=t.RV6();t.j41(0,"button",12),t.nI1(1,"idAttribute"),t.bIt("click",function(){t.eBV(e);const a=t.XpG(2);return t.Njj(a.validateRequest())}),t.nrm(2,"i",13),t.EFF(3),t.nI1(4,"translate"),t.k0s()}if(2&n){const e=t.XpG(2);t.BMQ("id",t.i5U(1,2,e.item.barcode,t.lJ4(7,ma))),t.R7$(3),t.SpI(" ",t.bMT(4,5,"Validate")," ")}}function _a(n,i){if(1&n&&(t.j41(0,"a",5),t.EFF(1),t.k0s(),t.nrm(2,"br")),2&n){const e=t.XpG(2);t.Y8G("routerLink",t.eq3(2,pa,e.document.pid)),t.R7$(),t.SpI(" ",i," ")}}function Ca(n,i){if(1&n&&(t.j41(0,"dt",15),t.EFF(1,"Unit"),t.k0s(),t.j41(2,"dd",16),t.EFF(3),t.k0s()),2&n){const e=t.XpG(3);t.R7$(3),t.JRh(e.item.enumerationAndChronology)}}function ga(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(3);t.SpI(" ",e.item.temporary_location.name," ")}}function va(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(3);t.SpI(" ",e.item.location.name," ")}}function ba(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(3);t.SpI(" ",e.item.loan.pickup_location.pickup_name," ")}}function ya(n,i){if(1&n&&t.EFF(0),2&n){const e=t.XpG(3);t.Lme(" ",e.item.loan.pickup_location.library_name,": ",e.item.loan.pickup_location.name," ")}}function ka(n,i){if(1&n&&(t.j41(0,"div",11)(1,"dl",14),t.DNE(2,Ca,4,1),t.j41(3,"dt",15),t.EFF(4,"Requested by"),t.k0s(),t.j41(5,"dd",16)(6,"a",17),t.EFF(7),t.k0s()(),t.j41(8,"dt",15),t.EFF(9,"Location"),t.k0s(),t.j41(10,"dd",18),t.EFF(11),t.DNE(12,ga,1,1)(13,va,1,1),t.k0s(),t.j41(14,"dt",15),t.EFF(15,"Pick-up location"),t.k0s(),t.j41(16,"dd",19),t.nrm(17,"i",20)(18,"i",21),t.DNE(19,ba,1,1)(20,ya,1,2),t.k0s()()()),2&n){const e=t.XpG(2);t.R7$(2),t.vxM(2,e.item.enumerationAndChronology?2:-1),t.R7$(4),t.Y8G("routerLink",t.eq3(6,ha,e.item.loan.patron.barcode)),t.R7$(),t.SpI(" ",e.item.loan.patron.name," "),t.R7$(4),t.SpI(" ",e.item.library.name," - "),t.R7$(),t.vxM(12,null!=e.item.temporary_location&&e.item.temporary_location.name?12:13),t.R7$(7),t.vxM(19,e.item.loan.pickup_location.pickup_name?19:20)}}function Ta(n,i){if(1&n){const e=t.RV6();t.j41(0,"div",0)(1,"div",1),t.DNE(2,fa,5,8,"button",2),t.k0s(),t.j41(3,"div",3)(4,"button",4),t.bIt("click",function(){t.eBV(e);const a=t.XpG();return t.Njj(a.isCollapsed=!a.isCollapsed)}),t.k0s(),t.j41(5,"a",5),t.EFF(6),t.k0s()(),t.j41(7,"div",6),t.DNE(8,_a,3,4),t.nI1(9,"mainTitle"),t.nrm(10,"shared-contribution",7),t.k0s(),t.j41(11,"div",8),t.nrm(12,"shared-inherited-call-number",9),t.k0s(),t.j41(13,"div",10),t.EFF(14),t.nI1(15,"dateTranslate"),t.k0s(),t.DNE(16,ka,21,8,"div",11),t.k0s()}if(2&n){let e;const o=t.XpG();t.Mz_("id","request-",o.item.barcode,""),t.Y8G("ngClass",o.getCallout()),t.R7$(2),t.vxM(2,o.item.loan.state===o.LoanState.PENDING?2:-1),t.R7$(2),t.Y8G("ngClass",t.l_i(18,ua,!o.isCollapsed,o.isCollapsed)),t.BMQ("aria-expanded",!o.isCollapsed),t.R7$(),t.Y8G("routerLink",t.eq3(21,da,o.item.pid)),t.R7$(),t.JRh(o.item.barcode),t.R7$(2),t.vxM(8,(e=t.bMT(9,13,o.document.title))?8:-1,e),t.R7$(2),t.Y8G("contributions",null==o.document?null:o.document.contribution),t.R7$(2),t.Y8G("item",o.item),t.R7$(2),t.JRh(t.i5U(15,15,o.item.loan.creation_date,"medium")),t.R7$(2),t.vxM(16,o.isCollapsed?-1:16)}}let Fa=(()=>{class n{constructor(e){this.recordService=e,this.callout=null,this.requestValidated=new t.bkB,this.LoanState=x.sl}ngOnInit(){this.item&&this.recordService.getRecord("documents",this.item.loan.document_pid,1,{Accept:"application/rero+json, application/json"}).subscribe(e=>this.document=e.metadata)}validateRequest(){this.requestValidated.emit(this.item.barcode)}getCallout(){return null!==this.callout?`callout ${this.callout}`:"border rounded"}static#t=this.\u0275fac=function(o){return new(o||n)(t.rXU(h.nO))};static#e=this.\u0275cmp=t.VBU({type:n,selectors:[["admin-requested-item"]],inputs:{item:"item",isCollapsed:"isCollapsed",callout:"callout"},outputs:{requestValidated:"requestValidated"},decls:1,vars:1,consts:[[1,"row","p-2","mb-1","align-middle","item",3,"ngClass","id"],[1,"actions"],[1,"btn","btn-sm","btn-outline-secondary"],[1,"col-2"],["type","button","aria-controls","collapse",1,"btn-show-more",3,"click","ngClass"],[3,"routerLink"],["name","title",1,"col-lg-5"],[3,"contributions"],["name","call-number",1,"col-2"],[3,"item"],["name","transaction-date",1,"col-2"],[1,"col-12","mt-2"],[1,"btn","btn-sm","btn-outline-secondary",3,"click"],[1,"fa","fa-check","pr-1"],[1,"row"],["translate","",1,"col-2","label-title","text-right"],[1,"col-10"],["name","patron-name",3,"routerLink"],["name","location",1,"col-10"],["name","pickup-location",1,"col-10"],[1,"fa","fa-truck","fa-flip-horizontal"],[1,"fa","fa-long-arrow-right","mx-1"]],template:function(o,a){1&o&&t.DNE(0,Ta,17,23,"div",0),2&o&&t.vxM(0,a.document?0:-1)},dependencies:[$.Wk,g.YU,m.Mm,f.Rt,f.KF,m.D9,h.X1,f.OQ,f.kE],styles:[".item[_ngcontent-%COMP%]{margin-bottom:.25rem!important;padding:.25rem!important;border:1px solid #dee2e6;border-radius:.25rem;position:relative}.item[_ngcontent-%COMP%]:hover{background-color:#f8f9fa}.item[_ngcontent-%COMP%] div.actions[_ngcontent-%COMP%]{position:absolute;top:.25rem;right:15px}"]})}return n})();function Sa(n,i){if(1&n){const e=t.RV6();t.j41(0,"admin-requested-item",4),t.bIt("requestValidated",function(a){t.eBV(e);const s=t.XpG(3);return t.Njj(s.validateRequest(a))}),t.k0s()}if(2&n){const e=i.$implicit,o=t.XpG(3);t.Y8G("item",e)("isCollapsed",o.isCollapsed)("callout",o.getItemCallout(e))}}function Ia(n,i){if(1&n&&t.Z7z(0,Sa,1,3,"admin-requested-item",3,t.fX1),2&n){const e=t.XpG(2);t.Dyx(e.items)}}function Ea(n,i){1&n&&(t.EFF(0),t.nI1(1,"translate")),2&n&&t.SpI(" ",t.bMT(1,1,"no request to validate")," ")}function xa(n,i){if(1&n&&t.DNE(0,Ia,2,0)(1,Ea,2,3),2&n){const e=t.XpG();t.vxM(0,e.items.length>0?0:1)}}let Ra=(()=>{class n{constructor(){this.requestValidated=new t.bkB,this.knownItemBarcodes=null}ngOnChanges(e){e.hasOwnProperty("items")&&!e.items.firstChange&&e.items.previousValue&&(this.knownItemBarcodes=e.items.previousValue.map(o=>o.barcode))}getItemCallout(e){return e.loan.state!==x.sl.PENDING?"callout-success callout-bg-success":this.knownItemBarcodes&&!this.knownItemBarcodes.includes(e.barcode)?"callout-warning callout-bg-warning":null}validateRequest(e){this.requestValidated.emit(e)}static#t=this.\u0275fac=function(o){return new(o||n)}