(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[98],{"+U2y":function(e,t,a){},EqQS:function(e,t,a){},"O+Hj":function(e,t,a){},j17f:function(e,t,a){"use strict";a.r(t),a.d(t,"ReportsView",(function(){return tt})),a.d(t,"_ReportsView",(function(){return at}));var r=a("mwIZ"),o=a.n(r),n=a("q1tI"),s=a.n(n),i=a("/MKj"),l=a("XSU/"),c=a("2tEe"),m=a("55Ip"),p=a("Ty5D"),u=a("AAik"),d=a("P5Co"),h=a("Lqn+"),f=a("VyNe"),b=a("LCzB");class g extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("animalNumber"),field:"AnmID",valueFormatter:e=>Object(h.b)(e),excelFormatter:e=>Object(h.b)(e),filterType:d.a.STRING},{name:e("newReports.selection.selectionDate"),field:"EvTime",valueFormatter:e=>Object(h.e)(e),excelFormatter:e=>new Date(e),filterType:d.a.DATE,disableValueFormatterSort:!0},{name:e("newReports.selection.selectionReason"),field:"EvData.Reasn",valueFormatter:e=>Object(h.l)(e),excelFormatter:e=>Object(h.l)(e),filterType:d.a.STRING},{name:e("newReports.selection.location"),field:"EvData.PlcmntID",valueFormatter:e=>Object(h.g)(e),excelFormatter:e=>Object(h.g)(e),filterType:d.a.LOCATION},{name:e("comment"),field:"Comment",valueFormatter:e=>e||"-",excelFormatter:e=>e||"-",filterType:d.a.STRING}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,bottomPinnedRows:t=>t.length?[{"EvData.PlcmntID":e("newReports.selection.total"),Comment:t.length}]:[],saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Selections",initialSortColumn:a[0].name}))}}g=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(g);var E=Object(b.a)()(g),F=a("i7k/");class w extends n.Component{constructor(e){super(e),this.state={data:[]},this.rowClassName=e=>{if(e.idleDays<0)return"error"};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("newReports.idle.pigNo"),field:"AnmNo1",filterType:d.a.STRING,customSort:F.a},{name:e("newReports.idle.idleDay"),field:"idleDays",valueFormatter:e=>Math.round(e),filterType:d.a.NUMBER},{name:e("newReports.idle.repetition"),field:"repetition",valueFormatter:e=>Math.round(e),filterType:d.a.NUMBER},{name:e("newReports.idle.wasMommy"),field:"wasMommy",valueFormatter:e=>Math.round(e),filterType:d.a.NUMBER},{name:e("location"),field:"location",valueFormatter:e=>Object(h.g)(e),excelFormatter:e=>Object(h.g)(e),filterType:d.a.LOCATION}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,bottomPinnedRows:t=>t.length?[{repetition:(Object(h.k)(t,"repetition")/t.length).toFixed(2),wasMommy:(Object(h.k)(t,"wasMommy")/t.length).toFixed(2),idleDays:(Object(h.k)(t,"idleDays")/t.length).toFixed(2),AnmNo1:e("avg")}]:[],rowClassName:this.rowClassName,saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Idle Days",initialSortColumn:a[0].name}))}}w=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(w);var y=Object(b.a)()(w),O=a("J2iB"),v=a.n(O),R=a("pxzG"),T=a("eASP");class j extends n.Component{constructor(e){super(e),this.state={data:[]},this.weightFormatter=e=>v()(e)?void 0:Object(R.j)(e,{showUnit:!1,unit:T.a.MEDIUM,fixed:1,rawValue:!0});const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("newReports.sales.pigNo"),field:"anmNo",filterType:d.a.STRING,customSort:F.a},{name:e("animalType"),field:"anmType",valueFormatter:e=>Object(h.c)(e),excelFormatter:e=>Object(h.c)(e),filterType:d.a.STRING},{name:e("saleDate"),valueFormatter:e=>Object(h.e)(e),excelFormatter:e=>new Date(e),field:"saleDate",filterType:d.a.DATE},{name:e("client"),field:"buyer",valueFormatter:e=>Object(h.d)(e),excelFormatter:e=>Object(h.d)(e),filterType:d.a.STRING},{name:"".concat(e("weight")," (").concat(Object(R.l)("weight",T.a.MEDIUM),")"),field:"weight",valueFormatter:this.weightFormatter,excelFormatter:this.weightFormatter,filterType:d.a.NUMBER},{name:e("price"),field:"price",valueFormatter:e=>e||void 0,excelFormatter:e=>e||void 0,filterType:d.a.NUMBER}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,bottomPinnedRows:t=>t.length?[{price:Object(h.k)(t,"price"),weight:this.weightFormatter(Object(h.k)(t,"weight")),buyer:e("newReports.sales.total")}]:[],saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Sold",initialSortColumn:a[0].name}))}}j=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(j);var D=Object(b.a)()(j);class N extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("animalNumber"),field:"AnmNo1",filterType:d.a.STRING,customSort:F.a},{name:e("newReports.dead.dthSellTime"),field:"DtaDthTime",valueFormatter:e=>Object(h.e)(e),excelFormatter:e=>new Date(e),filterType:d.a.DATE,disableValueFormatterSort:!0}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,bottomPinnedRows:t=>t.length?[{AnmNo1:e("newReports.dead.total"),DtaDthTime:o()(t,"length",0)}]:[],saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Dead or Sold",initialSortColumn:a[0].name}))}}N=Object(i.connect)(e=>({language:e.language.lang,farm:e.location.farm,reports:e.raports.reports}))(N);var x=Object(b.a)()(N),S=a("BvFm");class I extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}weightFormatter(e){return v()(e)?void 0:Object(R.j)(e,{showUnit:!1,rawValue:!0,unit:T.a.MEDIUM,fixed:1})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("animalNumber"),field:"anmNo",filterType:d.a.STRING,customSort:F.a},{name:e("newReports.treatment.anmType"),valueFormatter:e=>Object(h.c)(e),excelFormatter:e=>Object(h.c)(e),field:"anmType",filterType:d.a.STRING},{name:e("newReports.treatment.treatmentDate"),valueFormatter:e=>Object(h.e)(e),field:"treatmentDate",filterType:d.a.DATE,disableValueFormatterSort:!0},{name:e("newReports.treatment.reason"),valueFormatter:e=>Object(h.f)(e),excelFormatter:e=>Object(h.f)(e),field:"reason",filterType:d.a.STRING},{name:e("newReports.treatment.who"),field:"who",filterType:d.a.STRING,valueFormatter:e=>Object(h.j)(e),excelFormatter:e=>Object(h.j)(e),shouldShow:()=>Object(S.c)()},{name:e("newReports.treatment.treatmentType"),valueFormatter:e=>Object(h.n)(e),excelFormatter:e=>Object(h.n)(e),field:"treatmentType",filterType:d.a.STRING},{name:e("medicine"),valueFormatter:e=>Object(h.i)(e),excelFormatter:e=>Object(h.i)(e),field:"medicine",filterType:d.a.STRING},{name:e("dosage"),valueFormatter:e=>Object(h.h)(e),excelFormatter:e=>Object(h.h)(e),field:"dose",filterType:d.a.STRING},{name:"".concat(e("newReports.treatment.weight")," (").concat(Object(R.l)("weight",T.a.MEDIUM),")"),valueFormatter:this.weightFormatter,excelFormatter:this.weightFormatter,field:"weight",filterType:d.a.NUMBER}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Treatment",initialSortColumn:a[0].name}))}}I=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(I);var C=Object(b.a)()(I);class V extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("newReports.birth.pigNo"),field:"AnmNo1",valueFormatter:e=>e||"?",filterType:d.a.NUMBER,customSort:F.a},{name:e("newReports.birth.parturitionDate"),field:"parturitionDate",valueFormatter:e=>Object(h.e)(e,{format:"DD-MM-YYYY"}),excelFormatter:e=>new Date(e),filterType:d.a.DATE,disableValueFormatterSort:!0,disableValueFormatterFilter:!0},{name:e("alive"),field:"HealthyCnt",filterType:d.a.NUMBER},{name:e("dead"),field:"DeadCnt",filterType:d.a.NUMBER},{name:e("mummies"),field:"MummyCnt",filterType:d.a.NUMBER},{name:e("avgLitterWeight"),field:"Weight",valueFormatter:e=>e/1e3+" kg",filterType:d.a.NUMBER}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Parturitions",initialSortColumn:a[0].name}))}}V=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(V);var U=Object(b.a)()(V),M=a("Xn1+"),P=a("3Z9Z"),k=a("JI6e"),Q=a("q17X"),_=a("XzT5");class A extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("lactation"),field:"lactation",filterType:d.a.NUMBER},{name:e("amountSows"),field:"sowsCnt",filterType:d.a.NUMBER}];return s.a.createElement(f.a,null,s.a.createElement(P.a,null,s.a.createElement(k.a,{xs:12},e("newReports.structure.technologyGroupSize"),": ",s.a.createElement("strong",null,Object(Q.getTechnologyGroupSize)()),s.a.createElement("span",{className:"ml-1 opacity-75"},_.a.t("newReports.structure.XweekCycle",{count:Object(Q.getTechnologyGroupWeeks)()}))),s.a.createElement(k.a,{lg:4},s.a.createElement(u.a,{data:t,headers:a,saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Herd Structure",initialSortColumn:a[0].name})),s.a.createElement(k.a,{lg:8},s.a.createElement(M.a,{data:t}))))}}A=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(A);var B=Object(b.a)()(A),G=a("Z0cm"),L=a.n(G);class Y extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=t.filter(e=>!L()(e.inseminator)),r=[{name:e("newReports.insemination.inseminator"),field:"inseminator",valueFormatter:e=>(L()(e)?e:[e]).map(e=>Object(h.j)(e)).join(",")||"?",excelFormatter:e=>(L()(e)?e:[e]).map(e=>Object(h.j)(e)).join(",")||"?",filterType:d.a.STRING,customSort:F.a,shouldShow:()=>Object(S.c)()},{name:e("newReports.insemination.inseminationsCnt"),field:"inseminationsCnt",filterType:d.a.NUMBER},{name:e("newReports.insemination.pendingCnt"),field:"pendingCnt",filterType:d.a.NUMBER},{name:e("newReports.insemination.wellInseminatedCnt"),field:"wellInseminatedCnt",filterType:d.a.NUMBER},{name:e("newReports.insemination.wrongInseminatedCnt"),field:"wrongInseminatedCnt",filterType:d.a.NUMBER}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:r,bottomPinnedRows:()=>a.length?[{inseminationsCnt:Object(h.k)(a,"inseminationsCnt"),pendingCnt:Object(h.k)(a,"pendingCnt"),wellInseminatedCnt:Object(h.k)(a,"wellInseminatedCnt"),wrongInseminatedCnt:Object(h.k)(a,"wrongInseminatedCnt"),inseminator:e("newReports.insemination.total")}]:[],saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Inseminations",initialSortColumn:r[0].name}))}}Y=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(Y);var H=Object(b.a)()(Y);class W extends n.Component{constructor(e){super(e),this.state={data:[]};const{match:{params:{id:t}}}=this.props;console.log(t);let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);console.log(a),a&&(this.state={data:a.data})}weightFormatter(e){return v()(e)?void 0:Object(R.j)(e,{showUnit:!1,rawValue:!0,unit:T.a.MEDIUM,fixed:1})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("newReports.separation.pigNo"),field:"anmNo",filterType:d.a.STRING},{name:e("newReports.separation.separationDate"),valueFormatter:e=>Object(h.e)(e),excelFormatter:e=>new Date(e),field:"separationDate",filterType:d.a.DATE,disableValueFormatterSort:!0},{name:e("newReports.separation.piCnt"),field:"piCnt",filterType:d.a.NUMBER},{name:"".concat(e("newReports.separation.piWeight")," (").concat(Object(R.l)("weight",T.a.MEDIUM),")"),valueFormatter:this.weightFormatter,excelFormatter:this.weightFormatter,field:"piWeight",filterType:d.a.NUMBER},{name:e("newGroupNumber"),valueFormatter:e=>Object(h.b)(e),excelFormatter:e=>Object(h.b)(e),field:"ChildAnmID",filterType:d.a.STRING}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,bottomPinnedRows:t=>{let a=Object(h.k)(t,"piCnt"),r=Object(h.k)(t,"piWeight");return t.length?[{anmNo:e("avg"),piCnt:a/t.length,piWeight:this.weightFormatter(r/t.length)},{anmNo:e("newReports.separation.total"),piCnt:a,piWeight:this.weightFormatter(r)}]:[]},saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Raport - Separation",initialSortColumn:a[0].name}))}}W=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(W);var q=Object(b.a)()(W),z=a("GQws"),J=a("KJ2v"),X=a("obOH"),Z=a("w2eH"),K=a("IWVJ"),$=a("9Z4+"),ee=a("IqJe"),te=a("A2aW"),ae=a("0c/6"),re=a("1/Ix"),oe=a("Pdmn"),ne=a("14zg"),se=a("fz7+"),ie=a("wd/R"),le=a.n(ie),ce=a("D7Yj"),me=a("CuyV"),pe=a("GUWk"),ue=a("f0zD"),de=a("ANjH"),he=a("42VQ"),fe=a("MV7L");function be(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function ge(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Ee extends s.a.Component{constructor(...e){super(...e),this.state={removing:[]},this.onClick=e=>{const{farm:t}=this.props;this.props.history.push("/".concat(t,"/reports/generate/").concat(e))},this.formatDate=e=>le.a.utc(e).format("DD.MM.YYYY"),this.formatDates=e=>this.formatDate(e.startDate)+" - "+this.formatDate(e.endDate),this.getName=e=>{const{t:t}=this.props;return o()(t("newReports.headers",{returnObjects:!0}),e,t("".concat(e)))||e},this.onRowClick=e=>{const{farm:t}=this.props;let a=e.QueryExecution.Status.State;this.state.removing.includes(e.FeturaQuery.FeturaQTime)&&(a=se.a.REMOVING),a===se.a.READY&&this.props.history.push("/".concat(t,"/reports/").concat(e.FeturaQuery.QueryCode,"/").concat(e.FeturaQuery.FeturaQTime))}}onRemoveClick(e,t){const{value:a}=t,{show:r,t:o}=this.props;r(he.a,{title:o("deleteReport"),text:_.a.t("newReports.headers.removeReportText",{type1:this.getName(a.FeturaQuery.QueryCode),type2:this.formatDates(a.FeturaQuery.QueryParams)}),confirmText:o("yes"),onConfirmed:e=>{this.setState(e=>{const t=e.removing.slice(0);return t.push(a.FeturaQuery.FeturaQTime),console.log(t),{removing:t}}),a.isLocal?(pe.a.removeReport(a),this.props.dispatch(Object(ce.b)(this.props.farm))):Object(fe.a)(a.LocalQTime).then(e=>{Object(fe.c)(e)}).catch(e=>{Object(fe.b)(e),this.setState(e=>({removing:e.removing.filter(e=>e!==a.FeturaQuery.FeturaQTime)}))}),e.handleHide()}}),e.stopPropagation()}canRemoveReport(e){let t=e.QueryExecution.Status.State;return this.state.removing.includes(e.FeturaQuery.FeturaQTime)&&(t=se.a.REMOVING),[se.a.READY,se.a.CANCELLED,se.a.FAILED,se.a.INVALID_QUERY_PARAMETERS,se.a.QUERY_EXECUTION_NOT_STARTED_FATAL].includes(t)}render(){const{t:e,reports:t}=this.props,a=[{name:e("designation"),field:"FeturaQuery.QueryCode",valueFormatter:this.getName,itemClassName:"text-left"},{name:e("newReports.headers.dateRange"),field:"FeturaQuery.QueryParams",valueFormatter:this.formatDates},{name:e("newReports.headers.created"),field:"FeturaQuery.FeturaQTime",valueFormatter:e=>le()(e).format("DD.MM.YYYY HH:mm")},{name:"",notSortable:!0,field:"",component:t=>{console.log(t);const{value:a}=t;let r=a.QueryExecution.Status.State;switch(this.state.removing.includes(a.FeturaQuery.FeturaQTime)&&(r=se.a.REMOVING),r){case se.a.READY:return s.a.createElement("span",null,s.a.createElement("i",{className:"fas fa-download"})," ",e("newReports.headers.download"));case se.a.QUERY_EXECUTION_NOT_STARTED_FATAL:case se.a.INVALID_QUERY_PARAMETERS:case se.a.FAILED:return s.a.createElement("span",null,s.a.createElement("i",{className:"fas fa-exclamation-circle"})," ",e("newReports.headers.errorInGenerating"));case se.a.CANCELLED:return s.a.createElement("span",null,s.a.createElement("i",{className:"fas fa-times"})," ",e("newReports.headers.canceled"));case se.a.REMOVING:return s.a.createElement("span",null,s.a.createElement("i",{className:"fas fa-circle-notch fa-spin"})," ",e("newReports.headers.removing"));case se.a.LOADING:default:return s.a.createElement(me.a,{tooltipContent:e("newReports.headers.tooltipContent")},s.a.createElement("span",null,s.a.createElement("i",{className:"fas fa-circle-notch fa-spin"})," ",e("newReports.headers.preparing")))}}},{name:"",field:"",headerClassName:"index",itemClassName:"index",notSortable:!0,component:e=>this.canRemoveReport(e.value)?s.a.createElement("i",{className:"fas fa-trash pointer",onClick:t=>this.onRemoveClick(t,e)}):null},{name:"",field:"QueryExecution.Status.State",headerClassName:"index",itemClassName:"index",notSortable:!0,component:e=>e.value===se.a.READY?s.a.createElement("i",{className:"fas fa-chevron-right"}):null}];return s.a.createElement(s.a.Fragment,null,s.a.createElement(f.a,null,s.a.createElement("h4",null,e("newReports.headers.generateReport")),s.a.createElement(z.a,{value:null,options:[{label:e("newReports.headers.birth"),value:se.b.BIRTH,svgPath:X.a},{label:e("idle"),value:se.b.IDLE,svgPath:K.a},{label:e("newReports.headers.insemination"),value:se.b.INSEMINATION,svgPath:re.a},{label:e("newReports.headers.separation"),value:se.b.SEPARATION,svgPath:te.a},{label:e("newReports.headers.structure"),value:se.b.STRUCTURE,svgPath:Z.a},{label:e("newReports.headers.selection"),value:se.b.SELECTION,svgPath:ee.a},{label:e("newReports.headers.dead"),value:se.b.DEAD,svgPath:J.a},{label:e("sale"),value:se.b.SALES,svgPath:$.a},{label:e("treatment"),value:se.b.TREATMENT,svgPath:ae.a},{label:e("newReports.headers.medicineConsumption"),value:se.b.MEDICINE_CONSUMPTION,svgPath:oe.a},{label:e("newReports.headers.Q03_sumoffeedings_by_devid"),value:se.b.DISPENSER_USAGE_Q03,svgPath:ne.a},{label:e("newReports.headers.Q49_forage_use_per_device"),value:se.b.DISPENSER_USAGE_Q49,svgPath:ne.a},{label:e("newReports.headers.Q51_feedings_for_animalid"),value:se.b.DISPENSER_USAGE_Q51,svgPath:ne.a}],showLabels:!0,onChange:this.onClick})),s.a.createElement(f.a,null,s.a.createElement("h4",null,e("newReports.headers.generatedReports")),s.a.createElement(u.a,{data:t,headers:a,showPagination:!0,paginationItems:10,onRowClick:this.onRowClick})))}}Ee=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}),e=>function(e){for(var t=1;te.FeturaQuery.FeturaQTime===+t);a&&(this.state={data:a.data})}render(){const{t:e}=this.props,{data:t}=this.state,a=[{name:e("medicine"),field:"Medicine",valueFormatter:e=>Object(h.i)(e),excelFormatter:e=>Object(h.i)(e),filterType:d.a.STRING},{name:e("newReports.medicineConsumption.consumption"),field:"consumption",filterType:d.a.NUMBER}];return s.a.createElement(f.a,null,s.a.createElement(u.a,{data:t,headers:a,saveToExcel:!0,isSortable:!0,shouldIndex:!0,showFilter:!0,excelFileName:"Report - Medicine",initialSortColumn:a[0].name}))}}Fe=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports,user:e.user}))(Fe);var we=Object(b.a)()(Fe),ye=(a("EqQS"),a("uSQv")),Oe=a("d/v1"),ve=a("pJVQ"),Re=a("26mJ");class Te extends n.Component{constructor(e){super(e),this.props.initialize({dateFrom:le.a.utc().startOf("day").subtract(1,"week"),dateTo:le.a.utc().endOf("day"),forDay:le.a.utc().endOf("day")})}getText(e){const{t:t}=this.props;return t("newReports.headers.".concat(e))}renderForm(e){const{t:t}=this.props;return e===se.b.STRUCTURE?s.a.createElement(P.a,null,s.a.createElement(k.a,{sm:6},s.a.createElement(Oe.a,{name:"forDay",component:Re.a,label:"Na dzie\u0144:",type:"date",parse:e=>e?le.a.utc(e):null,format:e=>e?e.format(le.a.HTML5_FMT.DATE):null}))):s.a.createElement(P.a,null,s.a.createElement(k.a,{sm:6},s.a.createElement(Oe.a,{name:"dateFrom",component:Re.a,label:t("dateFrom"),type:"date",parse:e=>e?le.a.utc(e):null,format:e=>e?e.format(le.a.HTML5_FMT.DATE):null})),s.a.createElement(k.a,{sm:6},s.a.createElement(Oe.a,{name:"dateTo",component:Re.a,label:t("dateTo"),type:"date",parse:e=>e?le.a.utc(e):null,format:e=>e?e.format(le.a.HTML5_FMT.DATE):null})))}render(){const{match:{params:{type:e}},t:t,handleSubmit:a}=this.props;return s.a.createElement(f.a,{className:"reports-generate"},this.getText(e),s.a.createElement("form",{onSubmit:a},this.renderForm(e),s.a.createElement(ye.a,{buttonColor:"success",icon:s.a.createElement("i",{className:"fas fa-file"}),onClick:this.generateReport},t("newReports.headers.generate"))))}}Te=Object(ve.a)({form:"generateReport",onSubmit:function(e,t,a){const{match:{params:{type:r}},farm:o,user:n}=a,{dateTo:s,dateFrom:i,forDay:l}=e;switch(s.endOf("day"),r){case se.b.BIRTH:t(Object(ce.e)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.IDLE:t(Object(ce.f)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.INSEMINATION:t(Object(ce.g)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.SEPARATION:t(Object(ce.l)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.STRUCTURE:t(Object(ce.d)(o,l.toDate().getTime()));break;case se.b.SELECTION:t(Object(ce.k)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.DEAD:t(Object(ce.c)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.SALES:t(Object(ce.j)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.TREATMENT:t(Object(ce.m)(o,i.toDate().getTime(),s.toDate().getTime()));break;case se.b.MEDICINE_CONSUMPTION:t(Object(ce.h)(o,i.toDate().getTime(),s.toDate().getTime()));break;default:t(Object(ce.a)(r,i.toDate().getTime(),s.toDate().getTime(),[o],n.ClientID,n.LocalUserID))}a.history.push("/".concat(o,"/reports"))},validate:function(e,t){const a={},{dateTo:r,dateFrom:o}=e;return o||(a.dateFrom=t.t("required")),r||(a.dateTo=t.t("required")),o&&r&&o.toDate().getTime()>r.toDate().getTime()&&(a.dateFrom=t.t("errors.mustBeBelowOrEqualStartTime")+r.format("DD.MM.YYYY")),a}})(Te),Te=Object(i.connect)((function(e){return{farm:e.location.farm,user:e.user.user}}))(Te);var je=Object(b.a)()(Te),De=a("udB/"),Ne=a("2wEF"),xe=a("vzZS"),Se=a("kCmh"),Ie=a("n7pt");function Ce(){return(Ce=Object.assign||function(e){for(var t=1;te=>{class t extends n.Component{constructor(e){super(e),this.state={report:null,loading:!0,error:null,data:[]};const{match:{params:{id:t}}}=this.props;let a=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+t);this.state=function(e){for(var t=1;t({reports:e.raports.reports,user:e.user.user}))(t)};class Pe extends s.a.Component{constructor(...e){super(...e),this.deviceValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;if(/^([a-z0-9-])*_\d{1,2}/gim.test(e)){let t=e.split("_"),a=t[0],r=+t[1],o=Se.a.getDeviceByID(a);return"".concat(o.Name," [").concat(r+1,"]")}{let t=Se.a.getDeviceByID(e);if(t)return t.Name}},this.weightValueFormatter=e=>Object(Q.isUsingFakeData)()?e:e?Object(R.j)(+e,{unit:T.a.MEDIUM,showUnit:!0}):void 0,this.placeValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;if(e){let t=[];for(let a of e){let e=Ie.a.getTreeByLocationID(a);e&&(e.box?t.push("".concat(e.chamber.CName," - ").concat(e.box.BoxesName)):t.push("".concat(e.chamber.CName)))}return t.join(",")}},this.bottomPinnedRows=e=>{let t=e.reduce((e,t)=>e+t.sumofconsumption,0),a=e.reduce((e,t)=>e+t.sumoffeedings,0);return[{plid:this.props.t("newReports.dispensersUsage.sum"),sumofconsumption:this.weightValueFormatter(t),sumoffeedings:this.weightValueFormatter(a)}]}}render(){const{loading:e,report:t,error:a,data:r,t:o}=this.props,n=[{name:o("placement"),field:"plid",valueFormatter:this.placeValueFormatter,filterType:d.a.LOCATION,disableValueFormatterFilter:!0,excelFormatter:this.placeValueFormatter},{name:o("newReports.dispensersUsage.dispenser"),field:"devid",valueFormatter:this.deviceValueFormatter,filterType:d.a.STRING,excelFormatter:this.deviceValueFormatter},{name:o("newReports.dispensersUsage.planned"),field:"sumofconsumption",valueFormatter:this.weightValueFormatter,filterType:d.a.NUMBER,excelFormatter:this.weightValueFormatter},{name:o("newReports.dispensersUsage.usage"),field:"sumoffeedings",valueFormatter:this.weightValueFormatter,filterType:d.a.NUMBER,excelFormatter:this.weightValueFormatter}];return t?s.a.createElement(f.a,{style:e?{minHeight:"10rem"}:null},s.a.createElement(De.a,{isLoading:e}),a&&s.a.createElement(xe.a,{boxColor:"error"},s.a.createElement("div",null,o("newReports.error")),s.a.createElement("div",null,a)),!a&&s.a.createElement(s.a.Fragment,null,s.a.createElement(u.a,{data:r,headers:n,shouldIndex:!0,showFilter:!0,initialSortColumn:n[0].name,bottomPinnedRows:!Object(Q.isUsingFakeData)()&&this.bottomPinnedRows,saveToExcel:!0,excelFileName:"dispenserUsage"}))):s.a.createElement(f.a,null,s.a.createElement(Ne.a,null))}}Pe=Object(b.a)()(Pe);var ke=Me()(Pe),Qe=a("i8MS"),_e=a("17x9"),Ae=a.n(_e),Be=(a("O+Hj"),a("ZRKa"));class Ge extends n.Component{forageValueFormatter(e){let t=Be.a.getSettingByID(e,{showDeleted:!0});return t?t.SetData.Name:"?"}render(){const{object:{anmid:e,forages:t,total_amount:a,total_amountofday:r},animalValueFormatter:o,weightValueFormatter:n,rfidValueFormatter:i,index:l}=this.props;return s.a.createElement("div",{className:"forage-for-animal-full-width"},s.a.createElement("div",{className:"table-item index"},l),s.a.createElement("div",{className:"table-item animal-number"},o(e)),s.a.createElement("div",{className:"table-item animal-number"},i(e)),s.a.createElement("div",{className:"table-item forages-list"},Object(Q.isUsingFakeData)()&&s.a.createElement("div",{className:"forage-item",key:l},s.a.createElement("div",{className:"table-item forage-name"},t),s.a.createElement("div",{className:"table-item"},a),s.a.createElement("div",{className:"table-item"},r)),!Object(Q.isUsingFakeData)()&&t.map((e,t)=>s.a.createElement("div",{className:"forage-item",key:t},s.a.createElement("div",{className:"table-item forage-name"},this.forageValueFormatter(e.fid)),s.a.createElement("div",{className:"table-item"},n(e.amount)),s.a.createElement("div",{className:"table-item"},e.amountofday)))))}}Ge.propTypes={animalValueFormatter:Ae.a.func.isRequired,weightValueFormatter:Ae.a.func.isRequired,rfidValueFormatter:Ae.a.func.isRequired};var Le=Ge;function Ye(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function He(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class We extends n.Component{constructor(...e){super(...e),this.animalValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;let t=Qe.a.getAnimalById(e);return t?t.AnmNo1:void 0},this.animalRFIDValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return"";let t=Qe.a.getAnimalById(e);return t?t.RFID:void 0},this.weightValueFormatter=e=>Object(Q.isUsingFakeData)()?e:e?Object(R.j)(+e,{unit:T.a.MEDIUM,showUnit:!0}):void 0,this.foragesValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;return e.map(e=>{let t=Be.a.getSettingByID(e.fid,{showDeleted:!0});return t?t.SetData.Name:"?"}).join(" ")},this.bottomPinnedRows=e=>{let t={};for(let n of e)for(let e of n.forages)t[e.fid]||(t[e.fid]={total_amount:0,total_amountofday:0}),t[e.fid].total_amount+=+e.amount,t[e.fid].total_amountofday+=+e.amountofday;let a=0,r=0,o=Object.keys(t).map((e,o)=>(a+=t[e].total_amount,r+=t[e].total_amountofday,0===o?s.a.createElement("div",{className:"table-row"},s.a.createElement("div",{className:"table-item index"}),s.a.createElement("div",{className:"table-item"},this.props.t("newReports.dispensersUsage.sum")),s.a.createElement("div",{className:"table-item"}),s.a.createElement("div",{className:"table-item"},this.foragesValueFormatter([{fid:e}])),s.a.createElement("div",{className:"table-item"},this.weightValueFormatter(t[e].total_amount)),s.a.createElement("div",{className:"table-item"},t[e].total_amountofday)):function(e){for(var t=1;t!0,fullWidthRow:s.a.createElement(Le,{animalValueFormatter:this.animalValueFormatter,weightValueFormatter:this.weightValueFormatter,rfidValueFormatter:this.animalRFIDValueFormatter}),saveToExcel:!0,excelFileName:"forageForAnimal",initialSortColumn:n[0].name,bottomPinnedRows:!Object(Q.isUsingFakeData)()&&this.bottomPinnedRows})))}}We=Object(b.a)()(We),We=Me()(We);var qe=Object(i.connect)((function(e){return{farm:e.location.farm}}))(We);a("+U2y");class ze extends n.Component{forageValueFormatter(e){let t=Be.a.getSettingByID(e,{showDeleted:!0});return t?t.SetData.Name:"?"}render(){const{index:e,object:{plid:t,devid:a,forages:r,total_workday:o,total_amount:n},placeValueFormatter:i,deviceValueFormatter:l,weightValueFormatter:c}=this.props;return s.a.createElement("div",{className:"forage-use-per-device-full-width"},s.a.createElement("div",{className:"table-item index"},e),s.a.createElement("div",{className:"table-item"},i(t)),s.a.createElement("div",{className:"table-item"},l(a)),s.a.createElement("div",{className:"table-item forages-list"},Object(Q.isUsingFakeData)()&&s.a.createElement("div",{className:"forage-item",key:e},s.a.createElement("div",{className:"table-item forage-name"},r),s.a.createElement("div",{className:"table-item"},n),s.a.createElement("div",{className:"table-item"},o)),!Object(Q.isUsingFakeData)()&&r.map((e,t)=>s.a.createElement("div",{className:"forage-item",key:t},s.a.createElement("div",{className:"table-item forage-name"},this.forageValueFormatter(e.fid)),s.a.createElement("div",{className:"table-item"},c(e.amount)),s.a.createElement("div",{className:"table-item"},e.workday)))))}}ze.propTypes={deviceValueFormatter:Ae.a.func.isRequired,weightValueFormatter:Ae.a.func.isRequired,placeValueFormatter:Ae.a.func.isRequired};var Je=ze;function Xe(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function Ze(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Ke extends n.Component{constructor(...e){super(...e),this.deviceValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;if(/^([a-z0-9-])*_\d{1,2}/gim.test(e)){let t=e.split("_"),a=t[0],r=+t[1],o=Se.a.getDeviceByID(a);return"".concat(o.Name," [").concat(r+1,"]")}{let t=Se.a.getDeviceByID(e);if(t)return t.Name}},this.placeValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;if(e){let t=[];for(let a of e){let e=Ie.a.getTreeByLocationID(a);e&&(e.box?t.push("".concat(e.chamber.CName," - ").concat(e.box.BoxesName)):t.push("".concat(e.chamber.CName)))}return t.join(",")}},this.weightValueFormatter=e=>Object(Q.isUsingFakeData)()?e:e?Object(R.j)(+e,{unit:T.a.MEDIUM,showUnit:!0}):void 0,this.foragesValueFormatter=e=>{if(Object(Q.isUsingFakeData)())return e;return e.map(e=>{let t=Be.a.getSettingByID(e.fid,{showDeleted:!0});return t?t.SetData.Name:"?"}).join(" ")},this.bottomPinnedRows=e=>{let t={};for(let n of e)for(let e of n.forages)t[e.fid]||(t[e.fid]={total_amount:0,total_workday:0}),t[e.fid].total_amount+=+e.amount,t[e.fid].total_workday+=+e.workday;let a=0,r=0,o=Object.keys(t).map((e,o)=>(a+=t[e].total_amount,r+=t[e].total_workday,function(e){for(var t=1;t!0,saveToExcel:!0,excelFileName:"forageUsePerDevice",initialSortColumn:n[0].name,bottomPinnedRows:!Object(Q.isUsingFakeData)()&&this.bottomPinnedRows})))}}Ke=Me()(Ke),Ke=Object(i.connect)((function(e){return{farm:e.location.farm}}))(Ke);var $e=Object(b.a)()(Ke);function et(){return(et=Object.assign||function(e){for(var t=1;t{const{history:r}=this.props;e&&r.push(e)},this.getHeaderName=()=>{const{t:e}=this.props;try{const{location:{pathname:t}}=this.props;let a=t.slice(1).split("/"),r=t.includes("generate")?a[3]:a[2];if(r){let t=o()(e("newReports.headers",{returnObjects:!0}),r,e("".concat(r))),n=this.props.reports.find(e=>e.FeturaQuery.FeturaQTime===+a[3]);return n?"".concat(e("newReports.reportsView.report"),": ").concat(t," (").concat(le.a.utc(n.FeturaQuery.QueryParams.startDate).format("DD.MM.YYYY")," - ").concat(le.a.utc(n.FeturaQuery.QueryParams.endDate).format("DD.MM.YYYY"),")"):"".concat(e("newReports.reportsView.report"),": ").concat(t)}return e("reports")}catch(t){return console.error(t),e("reports")}},e.dispatch(Object(ce.b)(e.farm))}render(){return s.a.createElement("div",{className:"raports-view"},s.a.createElement(l.a,{text:s.a.createElement(s.a.Fragment,null,this.props.history.location.pathname!=="/".concat(this.props.farm,"/reports")&&s.a.createElement(m.Link,{to:"/".concat(this.props.farm,"/reports")},s.a.createElement("i",{className:"fas fa-fw fa-arrow-left"})),this.getHeaderName())}),s.a.createElement(c.a,null,s.a.createElement(p.g,null,s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/selection/:id"),exact:!0,render:e=>s.a.createElement(E,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/sterilleDays/:id"),exact:!0,render:e=>s.a.createElement(y,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/sale/:id"),exact:!0,render:e=>s.a.createElement(D,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/dead/:id"),exact:!0,render:e=>s.a.createElement(x,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/treatment/:id"),exact:!0,render:e=>s.a.createElement(C,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/birth/:id"),exact:!0,render:e=>s.a.createElement(U,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/structure/:id"),exact:!0,render:e=>s.a.createElement(B,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/insemination/:id"),exact:!0,render:e=>s.a.createElement(H,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/separation/:id"),exact:!0,render:e=>s.a.createElement(q,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/medicineConsumption/:id"),exact:!0,render:e=>s.a.createElement(we,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/").concat(se.b.DISPENSER_USAGE_Q03,"/:id"),exact:!0,render:e=>s.a.createElement(ke,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/").concat(se.b.DISPENSER_USAGE_Q51,"/:id"),exact:!0,render:e=>s.a.createElement(qe,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/").concat(se.b.DISPENSER_USAGE_Q49,"/:id"),exact:!0,render:e=>s.a.createElement($e,e)}),s.a.createElement(p.d,{path:"/".concat(this.props.farm,"/reports/generate/:type"),exact:!0,render:e=>s.a.createElement(je,e)}),s.a.createElement(p.d,{render:e=>s.a.createElement(Ee,et({},e,{onSelect:this.select}))}))))}}const at=tt=Object(i.connect)(e=>({farm:e.location.farm,reports:e.raports.reports}))(tt);tt=Object(p.o)(tt);t.default=Object(b.a)()(tt)}}]); //# sourceMappingURL=main~e0e43b8b.cdead5c2.chunk.js.map