var Bizgaze;(function(n){let t;(function(t){let i;(function(t){let i;(function(t){let i;(function(t){class i extends Unibase.Platform.Core.BaseComponent{cssFiles(){return["libs/tabulator-tables/css/bootstrap/tabulator_bootstrap4.min.css"]}jsFiles(){return["libs/tabulator/js/tabulator.min.js"]}html(){return""}loadCustHtml(n){const t=`
Customer Target VS Achive
`;$("#"+n).html(t)}loadEmpHtml(n){const t=`
Employee Target VS Achive
`;$("."+n).html(t)}load(){}init(t){var i=this,r=Unibase.Themes.Providers.DetailHelper.installedAppId,u=Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(n=>n.Key=="hf_"+r+"_allowothercontacts").Value);i.fileCacheHelper.loadCssFile("libs/tabulator-tables/css/bootstrap/tabulator_bootstrap4.min.css",null);i.fileCacheHelper.loadJsFiles(["libs/tabulator/js/tabulator.min.js"],function(){u==1?(n.Apps.TM.Targets.Components.CustomerTargetVSAchive.Instance().loadEmpHtml(t),i.employeewisetargetvsachive()):(n.Apps.TM.Targets.Components.CustomerTargetVSAchive.Instance().loadCustHtml(t),i.loadCustTabulator(""),i.customerwisetargetvsachive())})}customerwisetargetvsachive(){var i=Unibase.Themes.Providers.DetailHelper.installedAppId,r=Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(n=>n.Key=="hf_"+i+"_targetdefinitionid").Value),u=Unibase.Platform.Membership.Infos.Identity.getCurrentUser(),t=this;t.fileCacheHelper.loadJsFile("apps/tm/targets/managers/targetmanager.js",function(){n.Apps.TM.Targets.Managers.TargetManager.Instance().loadCustomerTargetvsAchive(u.sessionId,r).then(function(n){if(n!=null){var i=n.result;t.customerData.setData(i)}})})}employeewisetargetvsachive(){var r=Unibase.Themes.Providers.DetailHelper.installedAppId,u=Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(n=>n.Key=="hf_"+r+"_targetdefinitionid").Value),i=Unibase.Platform.Membership.Infos.Identity.getCurrentUser(),t=this;t.fileCacheHelper.loadJsFile("apps/tm/targets/managers/targetmanager.js",function(){n.Apps.TM.Targets.Managers.TargetManager.Instance().loadEmployeeTargetvsAchive(i.sessionId,u).then(function(r){var e=[],o=r.result,f,u;t.employeetotaldata=r.result;t.totalEmployeeResponse=jQuery.extend(!0,[],r.result);f=!1;u=r.result.filter(function(n){return n.EmployeeId===i.userId+"p"});u.length>0&&(f=!0,u[0]._children=[]);e.push(u[0]);n.Apps.TM.Targets.Components.CustomerTargetVSAchive.Instance().loadTabulator(e,f,r)})})}loadTabulator(t,i){var r=this,u=function(n){var t=n.getRow(),i=t.getPosition(!1);return i+1},f=function(){return"<\/i>"};r.initialEmployeeData=t;r.employeeData=new Tabulator("#Employee_Table",{placeholder:"
No data available<\/div>",data:t,layout:"fitDataFill",columns:[{title:"EmployeeId",field:"EmployeeId",visible:!1},{title:"EmployeeName",field:"EmployeeName"},{title:"Target Value",field:"TargetValue"},{title:"Achived Value",field:"AchievedTarget",cellClick:function(t,i){r.currentRow=i.getRow();r.fileCacheHelper.loadJsFile("apps/tm/targets/components/w_tagwisetarget.js",function(){r.currentRow._row.data.EmployeeId.includes("p")||n.Apps.TM.Targets.Components.TagWiseTarget.Instance().loadForm(0,i.getRow().getData().EmployeeId,0,null,0)})},formatter:function(n){r.currentRow=n.getRow();var t=n.getValue();return r.currentRow._row.data.EmployeeId.includes("p")?t:""+t+"<\/span>"}},{title:"Percentage",field:"Percentage"},],dataTree:i,dataTreeSelectPropagate:!0,dataTreeChildIndent:15,dataTreeRowExpanded:function(n){var f=n.getData().EmployeeId,t,u,e;for(f.includes("p")&&(f=f.replace("p","")),t=r.employeetotaldata.filter(function(n){return n.ParentId===Number(f)}),u=0;u0&&(i=!0,t[u]._children=[]);n.getData()._children=t;n.getData().isExpanded=!0;n.update(n.getData());r.employeeData.redraw(!0);r.initialEmployeeData=r.employeeData.getData()},dataTreeRowCollapsed:function(n){n.getData().isExpanded=!1},dataTreeStartExpanded:function(n){return n.getData().isExpanded}})}loadCustTabulator(){var t=this,i=function(n){var t=n.getRow(),i=t.getPosition(!1);return i+1},r=function(){return"<\/i>"};t.customerData=new Tabulator("#Customer_Table",{placeholder:"
No data available<\/div>",data:[],layout:"fitDataFill",columns:[{title:"EmployeeId",field:"EmployeeId",visible:!1},{title:"Customer Name",field:"EmployeeName"},{title:"ParentId",field:"ParentId",visible:!1},{title:"Target Value",field:"TargetValue"},{title:"Achived Value",field:"AchievedTarget",cellClick:function(i,r){t.currentRow=r.getRow();t.fileCacheHelper.loadJsFile("apps/tm/targets/components/w_tagwisetarget.js",function(){n.Apps.TM.Targets.Components.TagWiseTarget.Instance().loadForm(0,r.getRow().getData().EmployeeId,0,null,0)})},formatter:function(n){t.currentRow=n.getRow();var i=n.getValue();return""+i+"<\/span>"}},{title:"Percentage",field:"Percentage"},],pagination:"local",paginationSize:15,dataTree:!1,dataTreeSelectPropagate:!0})}targetTabulatorSearch(n){const t=this,i=$(`#${n}`),e=i.find(".target-search-input"),f=i.find(".main-search-loader"),u=i.find(".target-search-clear");let r=t.employeeData,o=t.totalEmployeeResponse,s=t.initialEmployeeData;clearTimeout(t.searchTimer);f.removeClass("d-none");u.addClass("d-none");t.searchTimer=setTimeout(function(){let n=e.val();if(n=n.trim().toLowerCase(),n){if(i.find("#CustomerTargetAchiveWidget").length>0)t.customerData.setFilter("EmployeeName","like",n);else{const t=o.filter(t=>t.EmployeeName.toLowerCase().includes(n)&&!t.EmployeeId.includes("p"));r.replaceData(t);r.redraw(!0)}u.removeClass("d-none")}else i.find("#CustomerTargetAchiveWidget").length===0&&(r.replaceData(s),r.redraw(!0)),u.addClass("d-none");f.addClass("d-none")},1e3)}clearTargetSearch(n){const t=this,i=$(`#${n}`);let r=t.initialEmployeeData;if(i.find(".target-search-input").val(""),i.find(".target-search-clear,.main-search-loader").addClass("d-none"),i.find("#CustomerTargetAchiveWidget").length>0){t.customerData.setFilter("EmployeeName","like","");return}t.employeeData.replaceData(r);t.employeeData.redraw(!0)}static Instance(){return this.instance===undefined&&(this.instance=new i),this.instance}}t.CustomerTargetVSAchive=i})(i=t.Components||(t.Components={}))})(i=t.Targets||(t.Targets={}))})(i=t.TM||(t.TM={}))})(t=n.Apps||(n.Apps={}))})(Bizgaze||(Bizgaze={}));