var ActivitiesWithRefresh,ActivityPrice,AdditionalCost,AdditionalCostActivities,BudgetAgreementListing,BudgetView,Claims,ClientDateFilterKendo,ClientPlan,ClientBudgetView,ControlsHelper,DialogHelper,EmployeesWithStartEnd,ExceededBudgetActivities,LogServiceSchedule,MyActivities,PriceList,SelectAllCheckBox,ServiceEndTime,ServiceInvoice,ActivityLog,Serviceschedule,ServiceScheduleAndLogCommon,Serviceschedulelisting,ServiceScheduleRecurrence,ServiceType,SupportPrograms;(function(n){function t(){$("body").on("change",".activities-list .quantity input",function(){var t=$(this),r=t.val(),n=t.parents(".activities-list-row"),u;i(r)?(u=n.find(".costHiddenField input").val(),n.find(".total-price input").val((r*u).toFixed(2))):n.find(".total-price input").val("Invalid")})}function i(n){var t=/^\d+(.\d{1,2})?$/.test(n)||/^(.\d{1,2})?/.test(n);return n>0&&t?t:!1}function r(){$("body").on("click",".activities-list .delete a",function(n){var t=$(this),i=t.parents(".activities-list-row");i.remove();n.preventDefault()})}function u(n,i){var u=$("#refreshActivities");r();t();u.on("click",function(t){var r=[],f=$("#Schedule_ScheduleStartDate").val(),e=$("#service-log-form #Id").val(),o=$("#ServiceProviderId").val();if($(".activities-list-row").each(function(){r.push([$(this).find('input[type="hidden"][name*="BudgetAgreementActivityId"]').val(),$(this).find(".quantity").find('input[type="text"]').val()])}),i===0)$(".activities-list").empty();else{var s=function(n){$("#activities-container").empty().append(n);$(".activities-list-row").each(function(){for(var n=0;n<r.length;n++)r[n][0]===$(this).find('input[type="hidden"][name*="BudgetAgreementActivityId"]').val()&&$(this).find(".quantity").find('input[type="text"]').val(r[n][1]).change()});$("#ServiceLogNoCharge").is(":checked")&&$(".quantity input").each(function(){$(this).val(0);$(this).prop("disabled",!0)})},h=function(){$("p#ajax-response").hide();u.before("<p id='ajax-response' class='error-label-color'>There are no available support items that can be scheduled.<\/p>")},c={personId:i,scheduleStartDate:f,serviceLogId:e,serviceProviderId:o};execAjax("GET",n,c,"application/json","",s,h);t.preventDefault()}})}n.initIndex=u})(ActivitiesWithRefresh||(ActivitiesWithRefresh={})),function(n){var t=function(){function n(){this.errors=[]}return n.prototype.addError=function(n){var t=this.errors.indexOf(n);t===-1&&this.errors.push(n)},n.prototype.removeErrorById=function(n){var t=this.errors.indexOf(n);t>-1&&this.errors.splice(t)},n.prototype.clearErrors=function(){this.errors=[]},n.prototype.isValid=function(){return this.errors.length===0},n}();n.ModelState=t}(ActivityPrice||(ActivityPrice={}));$(function(){function u(){t.select2();i.select2();t.change(function(){r()});i.change(function(){r()})}function r(){var r=t.val(),u=i.val(),e;r>0&&u>0&&(e=$("#getActivityPricesUrl").data("getactivitypricesurl"),f(r,u,e),n.clearErrors())}function f(n,t,i){var r=function(n){$("#activities").empty().html(n);$("#hasEditPermission").val()=="false"&&disableInputs($("#activities"))},u=moment().format("YYYY/MM/DD");execAjax("GET",i,"region="+n+"&supportCategoryId="+t+"&date="+u,"","html",r,"","","","",!1)}function e(){$("body").on("blur",".org-price input",function(){var t=$(this),i=t.parents("tr"),r=parseFloat(t.val()),u=t.data("pricecontrol").toLowerCase(),f=parseFloat(t.data("ndisprice"));u==="maximum"&&(r>f?(n.addError(t.data("activityid")),i.addClass("error")):(n.removeErrorById(t.data("activityid")),i.removeClass("error")))})}function o(n){for(var i,t=0;t<n.length;t++)i="activity-"+n[t].Id,$("."+i).addClass("error")}function s(t){for(var i=0;i<t.length;i++)n.addError(t[i].Id)}var t=$("#PriceGuideRegions"),i=$("#SupportCategories"),n;if(t.length!==0&&i.length!==0){u();e();n=new ActivityPrice.ModelState;$("body").on("click","form.org-ndis-activities input#save-prices",function(){var i=$("div.alert-error"),t=$("p#ajax-response"),r,u;if(!n.isValid())return i.show(),t.hide(),!1;i.hide();r=$(this).parents("form");u=$(this);u.attr("disabled","disabled");var f=function(){t.html("Your activity prices have been saved.");t.show()},e=function(n){if(n){i.show();var r=n.responseJSON.activitiesWithErrors;o(r);s(r)}else t.html("We were unable to save your activity prices. Please try again or contact CTARS support.")},h=function(){u.prop("disabled",!1)};return execAjax("POST",r.attr("action"),r.serialize(),"","",f,e,"","",h),!1})}}),function(n){function t(n,t){$(".archive-btn").click(function(){var u=$(this),t=$(this).data("additional-cost-id"),i=function(){var n=$("#delete_"+t).parents("tr");n.remove()},r=function(){var r={id:t};execAjax("GET",n,r,"json","",i)};DialogHelper.confirmAndExecute("Are you sure you want to deactivate the selected Additional Cost Component?",r)});$(".activate-btn").click(function(){var u=$(this),n=$(this).data("additional-cost-id"),i=function(){var t=$("#delete_"+n).parents("tr");t.remove()},r=function(){var r={id:n};execAjax("GET",t,r,"json","",i)};DialogHelper.confirmAndExecute("Are you sure you want to activate the selected Additional Cost Component?",r)})}n.initIndex=t}(AdditionalCost||(AdditionalCost={})),function(n){function r(){$("body").on("change",".additional-costs .quantity input",function(){var t=$(this),i=t.val(),n=t.parents(".additional-cost-row"),r;u(i)?(r=n.find(".costHiddenField input").val(),n.find(".total-price input").val((i*r).toFixed(2))):n.find(".total-price input").val("Invalid")})}function u(n){var t=/^\d+(.\d{1,2})?$/.test(n)||/^(.\d{1,2})?/.test(n);return n>0&&t?t:!1}function f(n,r,u){var f=$("div.additional-costs");$.each(f.find("div.row"),function(n,i){t($(i),u)});$("body").on("click",".additional-costs .delete a",function(n){var f=$(this),t=f.parents(".additional-cost-row"),r=t.find("select option").get(0),u=r.innerText,e=r.value;u.toLowerCase()!="please select"&&i("div.additional-costs select",t.find("input").get(0).id,u,e);t.remove();n.preventDefault()});$("#add-additional-cost").click(function(i){var s=function(n){f.append(n);var i=f.find(".additional-cost-row").last();t(i,u)},h=$("div.additional-costs .select2-chosen"),e={SelectedFields:[]},o;h.length>0&&(o=0,e.SelectedFields=[],h.each(function(){e.SelectedFields.push({Id:o.toString(),FieldName:$(this).get(0).innerText});o++}));e.SelectedFields.length===0?execAjax("GET",n,"","html","",s):execAjax("POST",r,JSON.stringify(e),"application/json; charset=utf-8","",s);i.preventDefault()})}function t(n,t){var r=n.find("select"),f="Please select",u="";r.select2().on("select2-open",function(){u=$(this).prev().find("a > span.select2-chosen").get(0).innerText;f=r.find('option:contains("'+u+'")').val()});r.select2().on("change",function(){var s=function(t){n.find(".quantity input").val(1);n.find(".unit-of-measure input").val(t.UnitOfMeasure);n.find(".total-price input").val((t.Cost*1).toFixed(2));n.find(".costHiddenField input").val(t.Cost);o("div.additional-costs select",r.get(0).id,t.Name)},e={id:r.val()};e.id==0||$($(this).parents(".additional-cost-row").find(".quantity input").get(0)).is(":disabled")||execAjax("GET",t,e,"json","",s);u.toLowerCase()!="please select"?i("div.additional-costs select",r.get(0).id,u,f):u.toLowerCase()==="please select"&&$(this).find("option:contains('Please select')").remove()})}function e(n,t,i){r();f(n,t,i)}function i(n,t,i,r){$(n).each(function(){t!=$(this).get(0).id&&$(this).append($("<option>").val(r).text(i).get(0))})}function o(n,t,i){$(n).each(function(){t!=$(this).get(0).id&&$(this).find("option:contains("+i+")").remove()})}n.initIndex=e}(AdditionalCostActivities||(AdditionalCostActivities={})),function(n){function u(n){r=n=="False"}function f(n,i,r,u,f){t=new Permissions(n,i,r,u,f)}function e(n,t,r,u,f,e,o,s){i=new ActionUrls(n,t,r,u,f,e,o,s)}function o(n,r,u,f,e){var o="";return t.viewPermission&&(o+=KendoGridActionButtonHelper.generateViewLink(i.viewUrl+"/"+n.toString())),r||!t.editPermission||u||(o+=KendoGridActionButtonHelper.generateEditLink(i.editUrl+"/"+n.toString())),r||!t.publishPermission||u||(o+=KendoGridActionButtonHelper.generatePublishLink(n)),r&&t.revertPermission&&!u&&(o+=KendoGridActionButtonHelper.generateRevertLink(n)),t.viewPermission&&(o+=KendoGridActionButtonHelper.generatePrintLink(i.printUrl+"/"+n.toString()+"?fullName="+f)),t.archivePermission&&(o+=KendoGridActionButtonHelper.generateArchiveLink(n,u,i.activateUrl,i.archiveUrl,e)),o}var t,i,r;n.setArchiveStatus=u;n.setPermissions=f;n.setActionUrls=e;n.renderActions=o}(BudgetAgreementListing||(BudgetAgreementListing={})),function(n){function r(n,r){var u="";if(i.viewPermission)return u+=KendoGridActionButtonHelper.generateViewLink(t.viewUrl+"?clientId="+n.toString()+"&clientPlanId="+r.toString()),u+KendoGridActionButtonHelper.generateExportViaOnClickLink("BudgetView.exportClientBudgetData("+n.toString()+","+r.toString()+")")}function u(n,r){if(i.viewPermission)return""+KendoGridActionButtonHelper.generateViewLink(t.viewUrl+"?clientId="+n.toString()+"&program="+r.toString())}function f(n,t,r,u,f){i=new Permissions(n,t,r,u,f)}function e(n,i,r,u,f,e,o,s){t=new ActionUrls(n,i,r,u,f,e,o,s)}function o(n){function t(){i()}function i(t){var r=function(n){$("#divBudgetViewList").empty().html(n);renderCustomControls($("#divBudgetViewList"))},i="json";typeof t=="undefined"&&(t="",i="");execAjax("GET",n,t,"",i,r)}t()}function s(n,i){var r=function(n,t,i){if(n!=""){var r=i.getResponseHeader("content-disposition").substring(21,i.getResponseHeader("content-disposition").length);AjaxHelper.setupDownloadLink(r,"text/csv",n)}else DialogHelper.alertDialogBox("Sorry, we were unable to find any data for the selected client")};execAjax("GET",t.printUrl,"clientId="+n+"&clientPlanId="+i,"","",r)}var i,t;n.IndividualBudgetViewRenderActions=r;n.SummaryBudgetViewRenderActions=u;n.setPermissions=f;n.setActionUrls=e;n.BudgetView=o;n.exportClientBudgetData=s}(BudgetView||(BudgetView={})),function(n){function s(n,i,r,u,f){t=new Permissions(n,i,r,u,f)}function h(n,t,i,r,f,e,o,s){u=new ActionUrls(n,t,i,r,f,e,o,s)}function c(n){f=n}function l(n,i){var r="";return f&&(r+=KendoGridActionButtonHelper.generateViewInvoicesLink(n,f)),i?(t.revertPermission&&(r+=KendoGridActionButtonHelper.generateRevertLinkAddSelector(n,"mark-not-claimed-selector")),t.viewPermission&&(r+=KendoGridActionButtonHelper.generateDownloadWithoutLink("#"))):(t.publishPermission&&(r+=KendoGridActionButtonHelper.generateApproveLink(n,"mark-claimed-selector")),t.viewPermission&&(r+=KendoGridActionButtonHelper.generateDownloadWithoutLink("#"))),r}function a(n,t){var i=t.selector;$(n).is(":checked")?$(n).closest(".k-state-active").find("button"+i).attr("disabled")&&$(n).closest(".k-state-active").find("button"+i).removeAttr("disabled"):$(n).closest("tbody").find($("input[name='MultipleKendoGridCheckBox']:checked")).length===0&&$(n).closest(".k-state-active").find("button"+i).prop("disabled",!0)}function v(n,t,r,u,f){var o=[],s=0,e=0,v=f.selector,h,c,l,a;$.each($("input[name='MultipleKendoGridCheckBox']:checked"),function(){var n=$(this).parents("tr").find("td:nth-child(5)")[0].innerHTML;s++;n==="New"&&(e++,o.push(+$(this).val()))});h=function(){var s={claimIds:o},f=function(n){n.Success?$(v).data("kendoGrid").dataSource.read():DialogHelper.actionAlertDialogBox("<h4 class='modal-warning-header'>Something went wrong<\/h4>"+n.Result,function(){return i(),!0})},h=function(t){for(var c,o=!1,h=!1,i=0;i<t.length;i++)o=o||t[i].IsFinanceAPI,h=h||t[i].ExistsInFinanceSystem;o?h?DialogHelper.confirmAndExecute("Some of these claims already exists in XERO, by claiming it will update the status to claimed and will not be resent. \nAre you sure?",function(){for(var n=0;n<t.length;n++)n===t.length-1?t[n].ExistsInFinanceSystem?execAjax("POST",u,{claimId:t[n].claimId},"","",f):execAjax("POST",r,{claimId:t[n].claimId},"","",f):t[n].ExistsInFinanceSystem?execAjax("POST",u,{claimId:t[n].claimId},"",""):execAjax("POST",r,{claimId:t[n].claimId},"","")}):execAjax("POST",n,JSON.stringify(s),"application/json","",f):e===0?(c="The selected Payment Requests have already been claimed",DialogHelper.alertDialogBox(c)):execAjax("POST",n,JSON.stringify(s),"application/json","",f)};execAjax("POST",t,JSON.stringify(s),"application/json","",h);$("#generateClaimsButton").prop("disabled",!0)};c=function(){$("#generateClaimsButton").prop("disabled",!1)};e===0?(l="The selected Payment Requests have already been claimed",DialogHelper.alertDialogBox(l)):(a=e+" of "+s+" payment requests will be claimed. Are you sure?",DialogHelper.confirmAndExecute(a,h,c))}function y(n,t,r,u,f,e){var o=f.selector;$(o).on("click",n,function(){var n=$(this).data("id"),o=$(this).parent().parent().find("td:nth-child(3)")[0].innerHTML;$(this).prop("disabled",!0);var f=function(u){if(u.Success)i();else if(u.Error=="EXISTING_FINANCE_RECORD"){r||(r=t.replace("MarkAsClaimed","MarkAsClaimedNoApiCall"));var f=function(){i()},e=function(){execAjax("POST",r,{claimId:n},"","",f)};DialogHelper.confirmAndExecute(u.Result,e)}else DialogHelper.actionAlertDialogBox("<h4 class='modal-warning-header'>Something went wrong<\/h4>"+u.Result,function(){return i(),!0})},s=function(){if(o.length!==0){var i=function(i){i.IsFinanceAPI?i.ExistsInFinanceSystem?DialogHelper.confirmAndExecute("This claim already exists in XERO, by claiming it will update the status to claimed and will not be resent. \nAre you sure?",function(){execAjax("POST",r,{claimId:n},"","",f)}):execAjax("POST",t,{claimId:n},"","",f):execAjax("POST",r,{claimId:n},"","",f)};execAjax("POST",e,{claimId:n},"","",i)}else execAjax("POST",t,{claimId:n},"","",f);$(".sprite-approve-icon").prop("disabled",!1)},h=function(){$(".sprite-approve-icon").prop("disabled",!1)};DialogHelper.confirmAndExecute(u,s,h)})}function p(n,t,r,u){var f=u.selector;$(f).on("click",n,function(){var n=$(this).data("id");$(this).prop("disabled",!0);var u=function(){i()},f=function(){execAjax("POST",t,{claimId:n},"","",u);$(".sprite-revert-icon").prop("disabled",!1)},e=function(){$(".sprite-revert-icon").prop("disabled",!1)};DialogHelper.confirmAndExecute(r,f,e)})}function r(n,t){var i=n.selector;$(i).on("click",".listingcheckbox",function(){a(this,t)})}function e(n){t.revertPermission&&p(".mark-not-claimed-selector",u.revertUrl,"Do you want to revert the selected file to not claimed?",n);r(n,$(".download-button"))}function o(n,i,f,e,o,s){if(t.publishPermission&&y(".mark-claimed-selector",u.publishUrl,o,"Do you want to mark the selected file as claimed?",n,i),s!=undefined&&s.length>1)$("body").on("click",".generate-claims-button",function(){v(s,f,e,o,n)});r(n,$(".download-button"));r(n,$(".generate-claims-button"))}function w(n){o(n,"","","","","");e(n);r(n,$(".download-button"))}var i=CommonFunctions.reloadCurrentWindow,t,u,f;n.setPermissions=s;n.setActionUrls=h;n.setViewInvoicesActionUrl=c;n.renderActions=l;n.initClaimedPaymentRequest=e;n.initNewPaymentRequest=o;n.initAllPaymentRequestGrid=w}(Claims||(Claims={})),function(n){function r(n){$("#clienthiddenfield").select2({allowClear:!0,placeholder:"Select client",minimumInputLength:0,multiple:!0,ajax:{url:n,dataType:"json",delay:50,data:function(n,t){return{searchTerm:n,PageSize:15,Page:t}},results:function(n){return n}},formatSelection:function(n){return n.text}})}function u(n,t,r,u){$("#btn_Search").on("click",function(){i(n,t,r,u)})}function f(n){var t=n.data("kendoGrid");return t.dataSource.filter().filters}function i(n,t,i,r,u){var h,c,l,a,e,o,v,y;u===void 0&&(u=!1);var p=r.data("kendoGrid"),s=$("#clienthiddenfield").val(),f=[];if(s!=null&&s!=""){h=s.split(",");c=[];for(l in h)c.push({field:i,operator:"eq",value:h[l]});a={logic:"or",filters:c};f.push(a)}e=$("#ToDate__Editor").val();o=$("#FromDate__Editor").val();e!==""&&e!=null&&(v={field:n,operator:"lte",value:e,name:"DateTo"},f.push(v));o!==""&&o!=null&&(y={field:t,operator:"gte",value:o,name:"DateFrom"},f.push(y));p.dataSource.filter(f)}function e(n,i,r){$(n).on("change",function(){t(n,i,$("#dataViewListingGrid"))});$(n).on("keypress",function(r){if(r.keyCode==13)return t(n,i,$("#dataViewListingGrid")),!1});$(r).on("click",function(){t(n,i,$("#dataViewListingGrid"))})}function t(n,t,i){var u=i.data("kendoGrid"),r=[],f=$(n).val();r.push({field:t,operator:"contains",value:f});u.dataSource.filter(r)}n.ndisClientFilter=r;n.initSearchKendoGrid=u;n.getAppliedGridFilters=f;n.addFilterToSearchGrid=i;n.initSearchNameFilter=e;n.addNameFilterToSearchGrid=t}(ClientDateFilterKendo||(ClientDateFilterKendo={})),function(n){function b(n,t){var i=function(){hideConfirmationModal();var t=$("#delete_"+n).parents("tr");t.remove()},r={id:n};execAjax("POST",t+"/"+n,r,"","",i,"","","")}function k(n,t,i,r,u){$(n).on("click","a.archive-btn",function(){var f=$(this),t=$(this).data("id"),i=function(){$(n).data("kendoGrid").dataSource.read()},u=function(){var n={id:t};execAjax("POST",r,JSON.stringify(n),"application/json","",i)};DialogHelper.confirmAndExecute("Are you sure you want to deactivate the selected Budget Agreement?",u)});$(n).on("click","a.activate-btn",function(){var e=$(this),t=$(this).data("id"),i=function(){$(n).data("kendoGrid").dataSource.read()},r=function(n){n.status===409?DialogHelper.alertDialogBox("Unable to activate this Budget Agreement because it overlaps with another active Budget Agreement."):DialogHelper.alertDialogBox("Unable to activate this service schedule.")},f=function(){var n={id:t};execAjax("POST",u,JSON.stringify(n),"application/json","",i,r)};DialogHelper.confirmAndExecute("Are you sure you want to activate the selected Budget Agreement?",f)});$(n).on("click","a.sprite-revert-icon",function(){var t=$(this),n=t.data("id"),r=function(t){window.location.href=t.success?t.editUrl:i+"/?clientPlanId="+n},u=function(){var t={clientPlanId:n};execAjax("GET",i,t,"json","",r)};DialogHelper.confirmAndExecute("Do you want to revert the selected Budget Agreement?",u)});$(n).on("click","a.sprite-publish-icon",function(){var r=$(this),i=r.data("id"),u=function(r){r.success?$(n).data("kendoGrid").dataSource.read():window.location.href=t+"/?clientPlanId="+i},f=function(){var n={clientPlanId:i};execAjax("GET",t,n,"json","",u)};DialogHelper.confirmAndExecute("Do you want to publish the selected budget agreement?",f)})}function d(n,t,i,r,u,f,e,o,s,h,l){$("#validation-message").hide();var v=$("div.funded-support-wrapper"),y=$("div.my-activities-container"),p=$("div.additional-cost-container");c($("#selectProgramAndSupport"),f,e,o,$("#existingFundedSupports"),l);a($("#selectProgramPurposeCategoryItem"),f,e,o,s,$("#existingSupportItems"),h,l);bt(v,f,e,o,l);et(y,f,e,o,s,h,l);ct(p);ot();st();ht();tt(t,r,u);$("#clientId").val()==="0"?($("div.funded-support-wrapper").find("select").select2("enable",!1),$("div.my-activities-container").find("select").select2("enable",!1),$("div.additional-cost-container").find("select").select2("enable",!1),$("#selectProgramPurposeCategoryItem").select2("enable",!1),$("#selectProgramAndSupport").select2("enable",!1)):($("#clientId").trigger("change"),$("div.funded-support-wrapper").find("select").select2("enable",!0),$("div.my-activities-container").find("select").select2("enable",!0),$("div.additional-cost-container").find("select").select2("enable",!0),$("#selectProgramPurposeCategoryItem").select2("enable",!0),$("#selectProgramAndSupport").select2("enable",!0));n&&ControlsHelper.disableInputs($("form#ndis-plan-edit"))}function g(n){for(var i='<option value="0" selected="selected">Select nominee<\/option>',t=0;t<n.length;t++)i+='<option value="'+n[t].id+'">'+n[t].text+"<\/option>";$("select.activity-nominee-select").html(i);$("select.activity-nominee-select").select2();$("#additional-debtor-dropdown").html(i);$("#additional-debtor-dropdown").select2()}function nt(n){var t=$("select.activity-nominee-select").data("getnomineeslisturl");$.ajax({url:t,data:"personId="+n,success:g})}function tt(n,t,i){var r=$("#clientId");n&&r.prop("readonly",!0);r.select2({placeholder:"Select client",minimumInputLength:0,ajax:{url:t,dataType:"json",quietMillis:100,results:function(n){return{results:n.map(function(n){return{id:n.id,text:n.text}})}},data:function(n){return{searchText:n}}},initSelection:function(n,t){var i=$(n),r=i.val();t({id:r,text:i.data("client-name")})},formatSelection:function(n){return n.text}}).on("change",function(n){execAjax("GET",i,{clientId:$(n.currentTarget).val()},"","",function(n){$("input#PriceGuideRegion").val(n.clientNdisPriceGuide)});r.prop("readonly",!0);$("div.funded-support-wrapper").find("select").select2("enable",!0);$("div.my-activities-container").find("select").select2("enable",!0);$("div.additional-cost-container").find("select").select2("enable",!0);$("#selectProgramPurposeCategoryItem").select2("enable",!0);$("#selectProgramAndSupport").select2("enable",!0);nt(r.val())});$(function(){var n=$("#clientId").val()!=="0";$("#clientId").prop("readonly",n)})}function it(n){var t=n.find(".service-provider");t.select2()}function rt(n){var r=n.find(".biller-type"),u;r.select2().change(function(){var h=$(this).select2("val"),n=$(this).parents("div.activity-row"),f=n.find(".total-price input"),u=f.attr("id"),r=n.find("select.activity-debtor-select"),s=n.find("select.activity-debtor-select").data("getdebtorlisturl"),e,o;switch(h){case"Ndis":n.find(".activity-debtor").hide();r.attr("disabled","disabled");i(n,u,f);break;case"OrgFunded":n.find(".activity-debtor").hide();r.attr("disabled","disabled");i(n,u,f);break;case"Client":n.find(".activity-debtor").hide();r.attr("disabled","disabled");i(n,u,f);break;case"PlanManaged":n.find("select.activity-provider-select").removeAttr("disabled");n.find(".activity-debtor").show();r.removeAttr("disabled");t.removeActivityRow(u);e=function(n){for(var i='<option value="0" selected="selected">Select Debtor<\/option>',t=0;t<n.length;t++)i+='<option value="'+n[t].id+'">'+n[t].text+"<\/option>";r.html(i);r.select2()};$.ajax({url:s,data:"personId="+$("#clientId").val()+"&billerType=40",success:e});i(n,u,f);break;case"SelfFunded":n.find("select.activity-nominee-select").removeAttr("disabled");n.find(".activity-debtor").show();r.removeAttr("disabled");t.removeActivityRow(u);e=function(n){for(var i='<option value="0" selected="selected">Select Debtor<\/option>',t=0;t<n.length;t++)i+='<option value="'+n[t].id+'">'+n[t].text+"<\/option>";r.html(i);r.select2()};$.ajax({url:s,data:"personId="+$("#clientId").val()+"&billerType=30",success:e});i(n,u,f);break;default:n.find(".activity-debtor").hide();t.removeActivityRow(u)}o=$(this).find("option:selected").val();o!="0"&&o!=null&&$(this).find('option[value="0"]').remove()});u=r.select2().find("option:selected").text();u!="Select Biller Type"&&u!=null&&r.select2().find('option[value="0"]').remove()}function i(i,r,u){var o=i.find("select.support-category-select").val(),f=i.find("#selectProgramPurposeCategoryItem").val(),e=[];f!=null&&(e=f.split(","));var s=i.find("select.biller-type").val(),h=parseFloat(u.val()),c=new n.activityRow(r,o,e,h,s);t.addOrUpdateActivityRow(c)}function ut(n){var r=n.find("select.biller-type"),i=n.find(".additional-debtor"),t=n.find("#additional-debtor-select");r.select2().on("change",function(){var f=$(this).select2("val").toLowerCase(),u=n.find("select.additional-cost").data("getdebtorlisturl"),r;switch(f){case"client":t.prop("disabled",!0);i.hide();break;case"selffunded":i.show();t.removeAttr("disabled");r=function(n){for(var r='<option value="0" selected="selected">Select Debtor<\/option>',i=0;i<n.length;i++)r+='<option value="'+n[i].id+'">'+n[i].text+"<\/option>";t.html(r);t.select2()};$.ajax({url:u,data:"personId="+$("#clientId").val()+"&billerType=30",success:r});break;case"orgfunded":i.hide();break;case"planmanaged":i.show();t.removeAttr("disabled");r=function(n){for(var r='<option value="0" selected="selected">Select Debtor<\/option>',i=0;i<n.length;i++)r+='<option value="'+n[i].id+'">'+n[i].text+"<\/option>";t.html(r);t.select2()};$.ajax({url:u,data:"personId="+$("#clientId").val()+"&billerType=40",success:r});break;default:t.removeAttr("disabled")}})}function ft(){var n=$("div.funded-support-wrapper .support-budget-row");$.each(n,function(n,t){f($(t))})}function f(n){var u=n.find("div.budget input"),i=n.find(".remaining-budget input"),f=n.find("#selectProgramAndSupport").select2("val"),e=n.find("#supportBudgetBillerType").val(),o=u.val(),r=parseFloat(o)-t.getTotalExpenditureBySupportCategory(f,e);i.val(r.toFixed(2));i.toggleClass("warning",r<0);n.find(".field-validation-error").html("");n.find(".field-validation-error").removeClass()}function et(n,t,i,r,u,f,e){$.each(n.find("div.support-Item-row"),function(n,s){o($(s),t,i,r,u,f,e)});$("a.add-activity").on("click",function(){return lt($(this).data("url"),t,i,r,u,f,e),!1})}function ot(){var i=$("div.my-activities-container").find(".activity-row").not(".hide");$.each(i,function(i,r){var u=$(r),e=u.find("select#selectProgramAndSupport").val(),o=u.find("#selectProgramPurposeCategoryItem").select2("val"),f=u.find(".total-price input"),s=parseFloat(f.val()),h=f.attr("id"),c=u.find("select.biller-type").val(),l=new n.activityRow(h,e,o,s,c);t.addOrUpdateActivityRow(l,!0)});$("body").trigger(u)}function st(){$("body").on("click","div.activity-row div.delete a",function(){var i=$(this),n=i.parents("div.row"),r=n.find("div.total-price input").attr("id");t.removeActivityRow(r);n.remove()})}function ht(){$("body").on("click","div.support-budget-row div.delete a",function(){$(this).parents("div.row").remove()})}function o(n,t,i,r,u,f,e){at(n,t,i,r,u,f,e);s(n);yt(n);pt(n);rt(n);it(n)}function ct(n){s(n);ut(n)}function lt(n,t,i,r,u,f,e){var s=function(n){var s=$("div.my-activities-container"),h;s.append(n);h=s.find("div.activity-row").last();o(h,t,i,r,u,f,e)};execAjax("GET",n,"","application/json","html",s)}function at(n,t,i,r,u,f,e){var o=n.find("#selectProgramPurposeCategoryItem"),s=n.find("#existingSupportItems");a(o,t,i,r,u,s,f,e)}function s(n){var t=n.find("select.activity-debtor-select, select#additional-debtor-select");n.find(".activity-debtor option:selected, .additional-debtor option:selected").index()>0?(t.select2(),t.removeAttr("disabled")):n.find(".activity-debtor, .additional-debtor").hide()}function vt(n,t,i){var u=$(n),f=function(n){wt(u);u.find(".unit-of-measure input").val(n.UnitOfMeasure);u.find(".unit-price input").val(n.Price);u.find(".ratio").val(n.Ratio);r()},e="activityId="+t+"&effectiveDate="+moment().format("YYYY-MM-DD")+"&clientId="+$("input#clientId").val();execAjax("GET",i,e,"","",f)}function yt(i){$("div.number-of-weeks, div.qty-per-week, div.unit-price input").on("change",function(){var n=$(this).parents("div.activity-row");h(n)});$("div.total-price input").on("change",function(){var r=$(this).parents("div.activity-row"),c=r.find("select.support-category-select").val(),l=r.find("#selectProgramPurposeCategoryItem").select2("val"),a=r.find("select.biller-type").val(),e=parseFloat($(this).val()),v=$(this).attr("id"),y=new n.activityRow(v,c,l,e,a);t.addOrUpdateActivityRow(y);var o=parseFloat(r.find("#units-scheduled").val()),s=parseFloat(r.find("#cost-scheduled").val()),u=parseFloat(r.find("#units-logged").val()),f=parseFloat(r.find("#cost-logged").val()),p=r.find("#units-unscheduled"),w=r.find("#units-uncommitted"),b=r.find("#funds-unscheduled"),k=r.find("#funds-uncommitted"),d=r.find(".qty-per-week input"),g=i.find(".number-of-weeks input"),nt=parseFloat(g.val()),tt=parseFloat(d.val()),h=nt*tt;p.val((h-((isNaN(o)?0:o)+(isNaN(u)?0:u))).toFixed(2));w.val((h-(isNaN(u)?0:u)).toFixed(2));b.val((e-((isNaN(s)?0:s)+(isNaN(f)?0:f))).toFixed(2));k.val((e-(isNaN(f)?0:f)).toFixed(2))});h(i)}function h(n){var u=n.find("div.number-of-units input"),f=n.find("div.unit-price input"),t=n.find("div.total-price input"),i,r;try{i=parseFloat(u.val());r=parseFloat(f.val());isNaN(i)||isNaN(r)?t.val(0):t.val((i*r).toFixed(2))}catch(e){}t.trigger("change")}function pt(n){var t=n.find(".number-of-units"),i=n.find(".qty-per-week input"),r=n.find(".number-of-weeks input");n.find(".number-of-weeks input, .qty-per-week input").on("change",function(){var n=parseFloat(r.val()),u=parseFloat(i.val()),f;if(!n||!u||isNaN(n)||isNaN(u)){t.val("");return}f=n*u;isFinite(f)?t.val(f.toFixed(2)):t.val("")});t.trigger("change")}function wt(n){n.find("div.unit-of-measure input").val("");n.find("div.unit-price input").val("");n.find("div.number-of-units input").val("");n.find("div.total-price input").val("0");n.find("div.qty-per-week input").val("");n.find("div.number-of-weeks input").val("");n.find(".field-validation-error").html("");n.find(".field-validation-error").removeClass()}function c(n,t,i,u,f,e){var o=[];f.find("option").each(function(){o.push({id:$(this).attr("value"),text:$(this).text()})});$("#existingFundedSupports").hide();n.select2({allowClear:!0,placeholder:"Select Program ► Support Purpose ► Support Category",minimumInputLength:0,multiple:!0,maximumSelectionSize:5,formatNoMatches:function(){return"No Records found for the selection."},formatSelectionTooBig:function(){return"You can only select 3 items."},ajax:{url:function(){var r=n.select2("data");return v(r,n,i,u,t,null)},dataType:"json",quietMillis:50,results:function(n){return{results:n.map(function(n){return p(n)})}},data:function(t){var i=n.select2("data");return y(t,i)}},initSelection:function(n,t){t({id:"XYX",text:"testing@gmail.com"})},formatSelection:function(n){return n.text}}).select2("data",o);r();n.on("change",function(n){var t=n.val;if(n.val!=null&&n.val.length==1&&$.isNumeric(t[0])&&t[0]>0){var i=$(this).closest(".support-budget-row"),u=function(n){var t=[],r;$.each(n,function(n,i){i.Value!=0&&t.push({id:i.Value,text:i.Text})});r=i.find("#supportBudgetBillerType");r.reselect2({placeholder:"Select Biller Type",selectOptions:t});r.select2("val",t[0].id)},f={programId:t[0]};execAjax("GET",e,f,"","",u)}r()})}function bt(n,t,i,r,e){$.each(n.find("div.support-budget-row"),function(n,u){l($(u),t,i,r,e)});$("a.add-funded-support-category").on("click",function(){var u=function(u){$("div.funded-support-wrapper").append(u);var f=n.find("div.support-budget-row").last();l(f,t,i,r,e)};return execAjax("GET",$(this).data("url"),"","html","",u),!1});$("body").on("change",".budget input",function(){var n=$(this).parents("div.support-budget-row");f(n)});$("body").on(u,function(){ft()});$("body").on("change","#selectProgramAndSupport",function(){var n=$(this).parents("div.support-budget-row");f(n)})}function l(n,t,i,r,u){var e=n.find("#selectProgramAndSupport"),o=n.find("#existingFundedSupports");n.find(".biller-type").select2().change(function(){var n=$(this).parents("div.support-budget-row");f(n)});c(e,t,i,r,o,u)}function a(n,t,i,u,f,e,o,s){var h=[];e.find("option").each(function(){h.push({id:$(this).attr("value"),text:$(this).text()})});$("#existingSupportItems").hide();n.select2({allowClear:!0,placeholder:"Select Program ► Support Purpose ► Support Category ► Support Item",minimumInputLength:0,multiple:!0,maximumSelectionSize:7,formatNoMatches:function(){return"No Records found for the selection."},formatSelectionTooBig:function(){return"You can only select 4 items."},ajax:{url:function(){var r=n.select2("data");return v(r,n,i,u,t,f)},dataType:"json",quietMillis:50,results:function(n){return{results:n.map(function(n){return p(n)})}},data:function(t){var i=n.select2("data");return y(t,i)}},initSelection:function(n,t){t({id:"XYX",text:"testing@gmail.com"})},formatSelection:function(n){return n.text}}).select2("data",h);n.on("change",function(n){var t=n.val,i,u;if(t.length==7&&(i=t[6].split("-"),u=$(this).closest(".activity-row"),vt(u,i[1],o)),n.val!=null&&n.val.length==1&&$.isNumeric(t[0])&&t[0]>0){var f=$(this).closest(".activity-row"),e=function(n){var t=[],i;$.each(n,function(n,i){i.Value!=0&&t.push({id:i.Value,text:i.Text})});i=f.find("#supportItemBillerType");i.reselect2({placeholder:"Select Biller Type",selectOptions:t})},h={programId:t[0]};execAjax("GET",s,h,"","",e)}r()});r()}function v(n,t,i,r,u,f){return(f===void 0&&(f=null),n.length==1)?(n.push({id:-1,text:"►"}),n[0].hasSupportPurpose==!1&&(n.push({id:-2,text:"Support Purpose doesn't apply to this program"}),n[0].hasSupportCategories==!1&&(n.push({id:-3,text:"►"}),n.push({id:-4,text:"Support Category doesn't apply to this support Purpose"}))),t.select2("data",n,!0),i):n.length==2?(n.push({id:-1,text:"►"}),n[0].hasSupportPurpose==!1&&(n.push({id:-2,text:"Support Purpose doesn't apply to this program"}),n[0].hasSupportCategories==!1&&(n.push({id:-3,text:"►"}),n.push({id:-4,text:"Support Category doesn't apply to this support Purpose"})),t.select2("data",n,!0)),n[0].hasSupportPurposes!=!1)?i:"#":n.length==3||n.length==4?(n.length==3&&(n.push({id:-3,text:"►"}),t.select2("data",n,!0)),n[0].hasSupportCategories==!1&&(n.push({id:-4,text:"Support Category doesn't apply to this support Purpose"}),t.select2("data",n,!0)),n[0].hasSupportCategories!=!1)?r:"#":n.length==5||n.length==6?(n.length==5&&(n.push({id:-5,text:"►"}),t.select2("data",n,!0)),f):u}function y(n,t){var r=$("#clientId").val(),i,f,o,s;if(t!=null&&t.length>0){if(t.length==1||t.length==2)return{searchTerm:n,supportProgramId:t[0].id,personId:r};if(t.length==3||t.length==4)return i="0",t[2].id<0||(f=t[2].id.split("-"),i=f[1]),{searchTerm:n,supportPurposeId:i,personId:r};if(t.length==5||t.length==6){var u=0,e="0",i="0";return t[4].id<0?u=t[0].id:(o=t[4].id.split("-"),s=t[2].id.split("-"),i=s[1],e=o[1],u=t[0].id),{searchTerm:n,supportProgramId:u,supportPurposeId:i,supportCategoryId:e,personId:r}}}return{personId:r,searchTerm:n}}function p(n){return{id:n.id,text:n.text,hasSupportPurpose:n.hasSupportPurpose,hasSupportCategories:n.hasSupportCategories}}function r(){$(".select2-search-choice-close").remove();$('.select2-choices > li > div:contains("►")').closest("li").css({background:"white",border:"0px","font-size":"large",color:"green","padding-left":"16px"});$('.select2-choices > li > div:contains("►")').next("a").hide();$(".select2-search-choice").closest("li").css({"padding-right":"12px"})}var u="clientPlan.ledgerUpdated",w=function(){function t(){this.activityRows=[]}return t.prototype.addOrUpdateActivityRow=function(n,t){if(t===void 0&&(t=!1),n.id){var i=this.getActivityRowById(n.id);i?(i.supportCategoryId=n.supportCategoryId,i.totalPrice=n.totalPrice,i.activityId=n.activityId,i.billerType=n.billerType):this.addActivityRow(n);t||$("body").trigger(u)}},t.prototype.getActivityRowById=function(n){for(var t=0;t<this.activityRows.length;t++)if(this.activityRows[t].id===n)return this.activityRows[t]},t.prototype.addActivityRow=function(t){t instanceof n.activityRow&&this.activityRows.push(t)},t.prototype.removeActivityRow=function(n){for(var t=0;t<this.activityRows.length;t++)if(this.activityRows[t].id===n){this.activityRows.splice(t,1);$("body").trigger(u);return}},t.prototype.getActivityRows=function(){return this.activityRows.slice()},t.prototype.getTotalExpenditureBySupportCategory=function(n,t){for(var r,f,u=0,i=0;i<this.activityRows.length;i++)r=this.activityRows[i].activityId,f=this.activityRows[i].billerType,r[0]==n[0]&&r[2]==n[2]&&r[4]==n[4]&&f==t&&(u+=this.activityRows[i].totalPrice);return parseFloat(u.toFixed(2))},t}(),e,t;n.expenditureLedger=w;e=function(){function n(n,t,i,r,u){this.id=n;this.supportCategoryId=t;this.activityId=i;this.totalPrice=r;this.billerType=u}return n}();n.activityRow=e;n.onConfirmation=b;n.initIndex=k;t=new n.expenditureLedger;n.init=d}(ClientPlan||(ClientPlan={})),function(n){function t(n,t){function i(){}function r(t){var r=function(n){$("#divClientBudgetViewList").empty().html(n)},i="";typeof t=="undefined"&&(t="",i="");execAjax("GET",n,"personId="+t.PersonId+"&clientPlanId="+t.ClientPlanId,"",i,r)}i();typeof t!="undefined"&&t.ClientId!=0&&r(t)}n.ClientBudgetView=t}(ClientBudgetView||(ClientBudgetView={})),function(n){function t(n){n.find("input, select, textarea").filter(":not(.js-ignore-readonly)").attr("readonly","readonly").attr("disabled","disabled");n.find("a, button").filter(":not(.collapse-title, .select2-choice)").filter(":not(.js-ignore-disabledInputs)").filter(function(n,t){return $(t).closest(".js-ignore-readonly").length==0}).css({display:"none"});n.find(".btn-file").css({display:"none"})}n.disableInputs=t}(ControlsHelper||(ControlsHelper={})),function(n){function t(){var t=Math.floor(Math.random()*1e4+1),n="div"+t.toString(),i=$("body");return i.append("<div id='"+n+"'><\/div>"),n}function i(n,i,r,u,f,e,o){var s=t();$("#"+s).kendoConfirm({title:o,closable:!0,content:n,draggable:!0,messages:{okText:i,cancel:r},close:e}).data("kendoConfirm").result.done(function(){u!=null&&u()}).fail(function(){f!=null&&f()})}function u(n,t,r,u){i(n,"Confirm","Cancel",t,r,u,"Confirmation")}function f(n,t,r,u){i(n,"Yes","No",t,r,u,"Confirmation")}function e(n,i){var u=t(),f="<p>"+n+"<\/p>",r=i;r==null&&(r="Error");$("#"+u).kendoDialog({closable:!0,modal:!0,title:r,content:f,actions:[{text:"OK",primary:!0}]}).data("kendoDialog").open()}function o(n,i){var u=t(),f="<p>"+n+"<\/p>",e=$("#"+u).kendoDialog({closable:!0,modal:!0,content:f,actions:[{text:"OK",primary:!0,action:i}],close:function(){r()}}).data("kendoDialog").open()}function s(n,i){var r=t();return $("#"+r).kendoDialog({closable:!1,modal:!0,content:n,actions:[{text:"OK",primary:!0,action:i}]}).data("kendoDialog").open(),$("#"+r)}var r=CommonFunctions.reloadCurrentWindow;n.confirmAndExecuteCustomButtonText=i;n.confirmAndExecute=u;n.confirmRevertMedication=f;n.alertDialogBox=e;n.actionAlertDialogBox=o;n.actionHTMLOKDialogBox=s}(DialogHelper||(DialogHelper={})),function(n){function t(){$("body").on("click",".select-staff .delete a",function(n){var t=$(this),i=t.parents(".add-staff-row");i.remove();n.preventDefault()})}function i(n){var i=$("div.select-staff");$("#add-staff").click(function(t){var f=function(n){i.append(n);var t=i.find("div.row"),r=t.find("select");r.select2();renderCustomControls(i);$("p#ajax-response3").hide()},e=function(){$("p#ajax-response3").show();$("p#ajax-response3").html("We were unable to find staff.")},r=$("div.select-staff select"),o=$("#Schedule_ScheduleStartTime").val(),s=$("#Schedule_ScheduleEndTime").val(),u={SelectedStaffMembers:[],startTime:o,endTime:s};r.length>0&&r.each(function(n,t){u.SelectedStaffMembers.push({Id:$(t).val()})});execAjax("POST",n,JSON.stringify(u),"application/json; charset=utf-8","",f,e);t.preventDefault()});t()}function r(n){var t=$(".add-staff-row"),r=t.find("select");r.select2();i(n)}n.initIndex=r}(EmployeesWithStartEnd||(EmployeesWithStartEnd={})),function(n){function t(n,t){return n+" "+t}n.FormatQuantityAndUnitOfMeasure=t}(ExceededBudgetActivities||(ExceededBudgetActivities={})),function(n){function p(n,s,h,c,l,a,v,y){u=s;f=h;e=l;o=a;t=v;i=c;r=n;y.on("click",".log-schedules",function(n){n.preventDefault();w($(this),y)}).on("click",".log-schedule",function(n){n.preventDefault();k($(this),y)})}function w(n,u){var f=function(r){var f,p,w;if(!r.FormBuilderCompatible&&r.ConsolidateActivityLog)DialogHelper.alertDialogBox("Form Builder configuration is not compatible to create Activity Log For Service Schedule. Please configure your Activity Log Form Builder or in your organisation Settings Turn off Create Activity Log setting.");else{var b=$("#createServiceLog").data("kendoWindow"),o=n.parents("tr").find("#service-schedule-ids")[0].innerText.split("&serviceScheduleIds=")[0].split(","),a=[];for(f=0;f<o.length;f++)a.push(parseInt(o[f]));p=function(n){renderCustomControls($("#createServiceLog").empty().append(n));s($("#createServiceLog"),t,u);h($("#createServiceLog"),i);c($("#createServiceLog"));b.open().center();l();v();y()};w={scheduleIds:a};execAjax("POST",e,JSON.stringify(w),"application/json; charset=utf-8","",p)}};execAjax("GET",r,"","json","",f)}function b(n){var i=$("#createServiceLogAndActivityLog"),r;i.find("#saveServiceAndActivityLog").attr("disabled","disabled");r=function(t){var r;if(t.success==!1){i.find("#saveServiceAndActivityLog").removeAttr("disabled");var f=JSON.parse(t.errors),u=i.find(".validation-summary-errors"),e=u.find("ul");for(e.empty(),u.addClass("alert alert-danger"),r=0;r<f.length;r++)e.append("<li>"+f[r].ErrorMessage+"<\/li>");u.show();$("#createServiceLogAndActivityLog").find(".content-div").scrollTop(0)}else n.data("kendoGrid").dataSource.read(),$("#createServiceLog").off("click","#saveServiceAndActivityLog"),$("#createServiceLog").off("click","#add-staff"),$("#createServiceLog").data("kendoWindow").close(),$("p#ajax-response").hide(),$("#logServiceSchedules").attr("disabled","disabled")};execAjax("POST",t,i.serialize(),"","",r,"","","","")}function k(n,u){var f=function(r){if(!r.FormBuilderCompatible&&r.ConsolidateActivityLog)DialogHelper.alertDialogBox("Activity Log configuration is not compatible with Consolidation of Service Logs and Activity Logs.<br/>Please contact your CTARS administrator for further assistance.");else{var f=$("#createServiceLog").data("kendoWindow"),e=n.data("id"),a=function(n){renderCustomControls($("#createServiceLog").empty().append(n));s($("#createServiceLog"),t,u);h($("#createServiceLog"),i);c($("#createServiceLog"));f.open().center();l();v();y()},p={id:e};execAjax("GET",o,"id="+p.id,"json","",a)}};execAjax("GET",r,"","json","",f)}function s(n,t,i){n.off("click","#saveServiceAndActivityLog");n.off("click",".closeButton");n.on("click","#saveServiceAndActivityLog",function(n){if(n.preventDefault(),$("#createServiceLogAndActivityLog").valid())b(i);else{var t=$("#createServiceLogAndActivityLog"),r=t.find(".validation-summary-errors");r.addClass("alert alert-danger");$("#createServiceLog").find(".content-div").scrollTop(0)}});n.on("click",".closeButton",function(){$("#createServiceLog").off("click","#saveServiceAndActivityLog")})}function h(n,t){n.off("click",".closeButton");n.off("click","#add-staff");d(n,t);n.on("click",".closeButton",function(){n.data("kendoWindow").close()})}function c(n){n.off("click",".closeButton");n.off("change","#ClientAttended");n.on("change","#ClientAttended",function(){if($("#ClientAttended").is(":checked")){$(".cancelreason-dropdown").removeClass("hidden");$(".cancelreason-dropdown").show();var n=$("#ReasonForCancellation").val();EnumHelper.getEnumByName(n)=="Other"&&($(".cancelreason-other").show(),$(".cancelreason-other").removeClass("hidden"))}else $(".cancelreason-dropdown").hide(),$(".cancelreason-other").hide(),$("#ReasonForCancellationOther").val(""),$("#ReasonForCancellation").val(0).trigger("change")});$("#ReasonForCancellation").select2().on("change",function(){var n=$("#ReasonForCancellation").val();EnumHelper.getEnumByName(n)=="Other"?($(".cancelreason-other").show(),$(".cancelreason-other").removeClass("hidden")):($(".cancelreason-other").hide(),$("#ReasonForCancellationOther").val(""))});n.on("click",".closeButton",function(){n.data("kendoWindow").close()})}function d(n,t){var r="Please select",i="";n.on("click","#add-staff",function(n){var u=$("#createServiceLog").data("kendoWindow").wrapper.find("#select-staff"),o=function(n){u.append(n);var f=u.find("div.row"),t=f.find("select");if(t.select2(),renderCustomControls(u),$("p#ajax-response").hide(),$("div.select-staff select").length>0){$("div.select-staff select").on("change",function(){var n=$("div.select-staff #s2id_"+$(this).get(0).id+" .select2-chosen").get(0).innerText;i.toLowerCase()!="please select"&&i.toLowerCase()!=""&&(a("div.select-staff select",$(this).get(0).id,i,r),i="");nt("div.select-staff select",$(this).get(0).id,n)});$("div.select-staff select").on("select2-open",function(){i=$(this).prev().find("a > span.select2-chosen").get(0).innerText;r=t.find('option:contains("'+i+'")').val()})}},s=function(){$("#add-staff").before("<p id='ajax-response' class='error-label-color'>We were unable to find staff.<\/p>")},h=$("#LogStartTime").val(),c=$("#LogEndTime").val(),f=$("div.select-staff select"),e={SelectedStaffMembers:[],startTime:h,endTime:c},l;f.length>0&&(l=0,f.each(function(n,t){e.SelectedStaffMembers.push({Id:$(t).val()});n++}));execAjax("POST",t,JSON.stringify(e),"application/json; charset=utf-8","",o,s);n.preventDefault()});g()}function g(){$("body").on("click",".select-staff .delete a",function(n){var i=$(this),t=i.parents(".add-staff-row");tt(t,"div.select-staff select");t.remove();n.preventDefault()})}function l(){var n=$("#createServiceLog").data("kendoWindow").wrapper.find("#select-staff"),t=n.find("div.row"),i=t.find("select");i.select2()}function nt(n,t,i){$(n).each(function(){t!=$(this).get(0).id&&$(this).find("option:contains("+i+")").remove()})}function tt(n,t){var i=n.find(".select2-chosen").get(0).innerText,r=n.find("select").find("option:contains("+i+")").val(),u=n.find("select").get(0).id;r!="0"&&a(t,u,i,r)}function a(n,t,i,r){$(n).each(function(){t!=$(this).get(0).id&&$(this).append($("<option>").val(r).text(i).get(0))})}function v(){var n=$("#createServiceLog").data("kendoWindow").wrapper,r=n.find("#CreateActivityLog").val().toLowerCase(),t,i;r=="true"&&(n.find("#activityLogControls").removeClass("hidden"),t=n.find("#ActivityLogCategory"),i=function(n){for(var r=[],i=0;i<n.length;i++)r.push({id:n[i].Value,text:n[i].Text});t.reselect2({placeholder:"Select Category",selectOptions:r})},execAjax("GET",f,"","","",i,"","","",""))}function y(){var t=$("#createServiceLog").data("kendoWindow").wrapper,r=t.find("#CreateActivityLog").val().toLowerCase(),n,i;r==="true"&&(n=t.find("#ActivityLogActivity"),n.closest(".form-group").hide(),i=function(t){var r,i;if(t.length>0){for(n.closest(".form-group").show(),r=[],i=0;i<t.length;i++)r.push({id:t[i].Value,text:t[i].Text});n.reselect2({placeholder:"Select Activity",selectOptions:r})}},execAjax("GET",u,"","","",i,"","","",""))}var u,f,e,o,t,i,r;n.initLogServiceSchedule=p}(LogServiceSchedule||(LogServiceSchedule={})),function(n){function t(n,t){function u(){var n=window.location.hash.substring(1);return n||(n="scheduled"),n}function e(n){$("#tab"+n).addClass("active");$(".activitylog-tab li").click(function(){var n=$(this),t;n.hasClass("active")||($(".activitylog-tab li").removeClass("active"),n.addClass("active"),t=n.data("state"),r(t))})}function r(t){t=t?t.toLowerCase():"scheduled";o(t);f.ajaxHtmlLoad(n,{state:t})}function o(n){$(".activitylog-tab li").removeClass("active");$("#tab"+n).addClass("active")}var f=$("#divClientLogSummaryList"),i=u();window.location.hash=i;r(i);e(i);$(document).on("click",".open-action-modal",function(){var n=$(this),i=n.data("activity-log-id"),r=n.data("state");$("#ActivityLogActionModal").ajaxHtmlLoad(t,"activityLogId="+i+"&state="+r)});$("body").on("click",".update-activity-state",function(){var t=$(this),n=t.parents("form"),i=function(){$("#ActivityLogActionModal").modal("hide").empty();r(u())},f=function(){$(".modal-body #validation-message").removeClass("hidden")};return execAjax("POST",n.attr("action"),n.serialize(),"","",i,f,"","",""),!1})}n.initIndex=t}(MyActivities||(MyActivities={})),function(n){function a(n,i,r,u,f,e,o){t=new Permissions(n,i,r,u,f,null,e,o)}function v(n,t,r,u,f,e,o,s,h,c){i=new ActionUrls(n,t,r,u,f,e,o,s,h,c)}function y(n,i,r){var u="";return t.archivePermission&&(u+=KendoGridActionButtonHelper.generateActivateDeactivateLink(n,i)),t.publishPermission&&(u+=p(n,r)),u}function p(n,t){return"<a class='sprite sprite-lg sprite-publish-icon btn btn-table-view push-price' data-toggle='tooltip' data-placement='top' title='Update Budget Agreements with Your Price' data-id='"+n+"' data-externalid='"+t+"' type='button' href='#'><\/a>"}function w(n,t){return t?n+"<br><span class='draft-warning-color'>Inactive<\/div>":n}function b(n,t,i,e){r=n;l=t;f=i;u=e;var o=$("#dataViewListingGrid");o.hide();$("body").on("change","#support-programs",function(){st()}).on("change","#pricing-region",function(){ht()}).on("click","#export-price-list",function(){ct()}).on("click","#import-price-list",function(){lt()}).on("click",".activate-btn",function(){var n=$(this).data("id");d(n)}).on("click",".archive-btn",function(){var n=$(this).data("id");g(n)}).on("click",".push-price",function(){var n=$(this).data("id"),t=$(this).data("externalid");k(n,t)})}function k(n,t){var f=function(){var i=function(n){DialogHelper.actionHTMLOKDialogBox("The unit price for support item "+t+" has been updated to "+n.UnitPrice+" in all Budget Agreements.",null)},r=function(){DialogHelper.actionHTMLOKDialogBox("The support item "+t+" doesn't have any saved organisation price or pricelist price.",null)},f={id:n};execAjax("POST",u,f,"","",i,r)},i=(new Date).getFullYear(),e=(new Date).getMonth(),r;e<7&&(i=i-1);r="Would you like to publish the Price for this item?<br>Publishing this item will update the Support Item Price for all existing active Budget Agreements in the financial year starting 1 July "+i+". This will include updating the price for all Service Schedules & Logs that are using this item.<br/>This will not include updating existing Service Invoices.<br/><br/>Note: Publishing this item will override the individual unit price for the item in the Client’s Budget Agreement with the Your Price, if present, otherwise the Price List Price.<br/>This update cannot be reverted once completed.<br/>For further information please contact CTARS Support.";DialogHelper.confirmAndExecute(r,f)}function d(n){var t=function(){s(n)};DialogHelper.confirmAndExecute("Are you sure you want to activate the Support Item?",t)}function g(n){var t=function(){o(n)};DialogHelper.confirmAndExecute("Are you sure you want to deactivate the Support Item?",t)}function o(n){var t=function(){$("#dataViewListingGrid").data("kendoGrid").dataSource.read()},r={id:n};execAjax("POST",i.archiveUrl,r,"","",t)}function s(n){var t=function(){$("#dataViewListingGrid").data("kendoGrid").dataSource.read()},r={id:n};execAjax("POST",i.activateUrl,r,"","",t)}function nt(){$("#row-is-error").val("false")}function tt(){var u=$("#row-is-error").val(),i,n,t,r;u==="true"?(i=$("#row-error-message").val(),n=$("[data-uid='"+$("#row-id").val()+"']"),n.addClass("alert alert-danger"),n.attr("data-toggle","tooltip"),n.attr("data-placement","top"),n.attr("title",i)):(t=$("[data-uid='"+$("#row-id").val()+"']"),t.removeClass("alert alert-danger"),t.removeAttr("data-toggle"),t.removeAttr("data-placement"),t.removeAttr("title"));r=$("#dataViewListingGrid > div.k-grid-content > table").height()+10;$("#dataViewListingGrid > div.k-grid-content").height(r)}function it(n){var t="",i,r,f,u;if(n.errors){if(n.errors.OrganisationPriceListPrice)for(i=0,r=n.errors.OrganisationPriceListPrice.errors;i<r.length;i++)f=r[i],t.length>0&&(t+="<br>"),t+=f;u=$("#dataViewListingGrid").find(".k-dirty-cell").parent().data("uid");this._badRow=u;$("#row-id").val(u);$("#row-is-error").val("true");$("#row-error-message").val(t)}}function rt(){$("#updateBudgetAgreements").prop("checked",!1);$("#keepBudgetAgreementsInDraft").prop("checked",!1);$("#keepBudgetAgreementsInDraft").attr("disabled","")}function ut(n){n.data={supportProgramId:+$("#support-programs").data("kendoDropDownList").value(),pricingRegionId:+$("#pricing-region").data("kendoDropDownList").value(),updateBudgetAgreements:$("#updateBudgetAgreements").is(":checked"),keepBudgetAgreementsInDraft:$("#keepBudgetAgreementsInDraft").is(":checked")};$("#updateBudgetAgreements").attr("disabled","");$("#keepBudgetAgreementsInDraft").prop("disabled")||$("#keepBudgetAgreementsInDraft").attr("disabled","");$("#files").data("kendoUpload").enable(!1)}function ft(n){var i=n.XMLHttpRequest,t=$("#upload-response"),r,u;i.status===200?et(t,"Upload completed successfully!"):(r="<br><div id='error-grid'><\/div>",t.empty(),u="<div class='alert alert-danger'><strong>Upload Failed!<\/strong><br><br>The following errors prevented the upload from completing successfully:<br>"+r+"<\/div>",t.append(u),$("#error-grid").kendoGrid({dataSource:{data:JSON.parse(i.response),schema:{model:{fields:{ErrorMessage:{type:"string"}}}}},scrollable:!0,pageable:!1,columns:[{field:"ErrorMessage",title:"Errors"}]}).innerWidth(500));$("#PriceListUploadDiv").data("kendoWindow").center();$("#files").data("kendoUpload").enable(!0);$("#updateBudgetAgreements").removeAttr("disabled");$("#updateBudgetAgreements").prop("checked",!1);$("#keepBudgetAgreementsInDraft").prop("checked",!1);$("#updateBudgetAgreements").is(":checked")&&$("#keepBudgetAgreementsInDraft").removeAttr("disabled")}function et(n,t){n.empty();var i="<div class='alert alert-success'>"+t+"<\/div>";n.append(i)}function ot(){var n=$("#support-programs").data("kendoDropDownList").value();return{supportProgramId:+n}}function h(){return{supportProgramId:+$("#support-programs").data("kendoDropDownList").value(),pricingRegionId:+$("#pricing-region").data("kendoDropDownList").value()}}function st(){$("#pricing-region").data("kendoDropDownList").enable(!0);$("#pricing-region").data("kendoDropDownList").dataSource.read();+$("#pricing-region").data("kendoDropDownList").value()!=0&&$("#dataViewListingGrid").data("kendoGrid").dataSource.read();$("#support-programs").data("kendoDropDownList").text()==="Organisation"?($("#dataViewListingGrid").data("kendoGrid").hideColumn("SupportPurpose"),$("#dataViewListingGrid").data("kendoGrid").hideColumn("SupportCategory")):($("#dataViewListingGrid").data("kendoGrid").showColumn("SupportPurpose"),$("#dataViewListingGrid").data("kendoGrid").showColumn("SupportCategory"));$("#dataViewListingGrid").hide();$("#validation-message > ul").empty();$("#validation-message").hide()}function ht(){+$("#pricing-region").data("kendoDropDownList").value()!=0?$("#dataViewListingGrid").is(":visible")||($("#dataViewListingGrid").data("kendoGrid").dataSource.read(),$("#dataViewListingGrid").show()):($("#dataViewListingGrid").data("kendoGrid").dataSource.data([]),$("#dataViewListingGrid").hide());$("#validation-message > ul").empty();$("#validation-message").hide();$("#dataViewListingGrid").data("kendoGrid").dataSource.read()}function ct(){var t=function(n,t,i){var r=i.getResponseHeader("content-disposition").substring(22,i.getResponseHeader("content-disposition").length-1);AjaxHelper.setupDownloadLink(r,"text/csv",n)},n=h(),i=n.supportProgramId,u=n.pricingRegionId,f="?supportProgramId="+i+"&pricingRegionId="+u;execAjax("GET",r+f,"","","",t)}function lt(){var n=$("#PriceListUploadDiv").data("kendoWindow");n.open().center();$("#PriceListUploadDiv").on("click","#updateBudgetAgreements",function(){$(this).is(":checked")?($("#keepBudgetAgreementsInDraft").prop("checked",!1),$("#keepBudgetAgreementsInDraft").removeAttr("disabled")):($("#keepBudgetAgreementsInDraft").prop("checked",!1),$("#keepBudgetAgreementsInDraft").attr("disabled",""))})}function at(){$("#upload-response").empty();$("#files").data("kendoUpload").clearAllFiles();$("#dataViewListingGrid").data("kendoGrid").dataSource.read()}function vt(n){return n!==0&&n!==null?"$"+n.toFixed(2):""}function c(){var n=$("#dataViewListingGrid").data("kendoGrid").dataSource.filter(),t="",i;return n!=null&&(i=n.filters,$.each(i,function(n,i){i.field==="SupportPurpose"&&(t=i.value)})),t}function yt(n){n.field==="SupportCategory"&&(e=n.container,$(n.container).data("kendoPopup").bind("open",function(){var n=e.find("input"),t=c(),i=$("#support-programs").data("kendoDropDownList").value(),r=f+"?supportProgramId="+i+"&supportPurposeName="+t;KendoGridFilterHelpers.generalFilter(n,r)}));KendoGridFilterHelpers.removeOperatorDropdown(n)}var r,l,u,f,e,t,i;n.setPermissions=a;n.setActionUrls=v;n.renderActions=y;n.formatInactiveItem=w;n.init=b;n.archiveSupportItem=o;n.activateSupportItem=s;n.startHandler=nt;n.endHandler=tt;n.errorHandler=it;n.onFileClear=rt;n.onFileUpload=ut;n.onUploadSuccess=ft;n.getSupportProgramId=ot;n.getPriceListSupportItems=h;n.onDialogClose=at;n.formatNullNumberColumn=vt;n.getExistingSupportPurposeFilterValue=c;n.SupportCategoryFilterHandler=yt}(PriceList||(PriceList={})),function(n){function u(n){n===void 0&&(n=$("body"));n.on("click","#masterCheckBox, .select-all-checkbox",function(){var t=$(this);t.is(":checked")?n.find(".listingcheckbox").each(function(){$(this).prop("checked",!1);$(this).trigger("click")}):n.find(".listingcheckbox").each(function(){var n=$(this).prop("disabled");n||($(this).prop("checked",!0),$(this).trigger("click"))})})}function f(n){t(n);i(n);r(n)}function t(n){$(n.sender.element).find(".select-all-checkbox").prop("checked")&&$(n.sender.element).find("#masterCheckBox, .select-all-checkbox").trigger("click")}function i(n){n.sender.dataSource.total()===0?$(".export-filtered").prop("disabled",!0):$(".export-filtered").prop("disabled",!1)}function r(){$(".export-selected").prop("disabled",!0)}function e(n){n.sender.dataSource.total()===0?($(n.sender.element).find(".select-all-checkbox").prop("checked")&&($(n.sender.element).find(".select-all-checkbox").trigger("click"),$("#masterCheckBox").prop("checked",!1)),$(".export-filtered").prop("disabled",!0)):$(".export-filtered").prop("disabled",!1);$("#generateButton").prop("disabled",!0);$(".export-selected").prop("disabled",!0);$("#invoiceLogs").prop("disabled",!0);$("#publishLogs").prop("disabled",!0)}n.selectAllCheckBoxes=u;n.onGridChangeHandler=f;n.CheckboxHandler=t;n.FilteredDataHandler=i;n.SelectedDataHandler=r;n.deselectOnGridPopulation=e}(SelectAllCheckBox||(SelectAllCheckBox={})),function(n){function t(n,t){$("p#service-next-day").hide();n=convertTime12To24(n.toString().toLowerCase());t=convertTime12To24(t);var i=Date.parse(n),r=Date.parse(t);return i>=r&&i!=null&&r!=null?!0:!1}n.isServiceEndsNextDay=t}(ServiceEndTime||(ServiceEndTime={})),function(n){function u(n,i,r,u,f){t=new Permissions(n,i,r,u,f)}function f(n,t,r,u,f,e,o,s){i=new ActionUrls(n,t,r,u,f,e,o,s)}function e(n,r,u,f){var e="";return t.viewPermission&&(e+=KendoGridActionButtonHelper.generateViewLink(i.viewUrl+"/"+n.toString()),e+=KendoGridActionButtonHelper.generatePrintLink(i.printUrl+"/"+n.toString())),!t.archivePermission||u||f||EnumHelper.getEnumByNumber(r)==="Claimed"||(e+=KendoGridActionButtonHelper.generateActivateDeactivateLink(n,!1)),!t.revertPermission||u||f||EnumHelper.getEnumByNumber(r)!=="Claimed"||(e+=h()),t.publishPermission&&!u&&EnumHelper.getEnumByNumber(r)===EnumHelper.getEnumByName("Pending")&&(e+=s("#","Service Invoice")),e}function o(){var n="",i=$("#IsArchived").val();return t.publishPermission&&i=="False"&&(n+=KendoGridActionButtonHelper.generateGenerateLink("#","Service Invoice")),n}function s(n,t){return"<a class='sprite sprite-lg sprite-settings-icon btn-table-view generate-claims' data-toggle='tooltip' data-placement='top' title= 'Generate "+t+"' type= 'button'href = "+n+" ><\/a>"}function h(){return"<a class='sprite sprite-lg sprite-revert-icon btn-table-view unclaim-invoice' data-toggle='tooltip' data-placement='top' title= 'Revert Claimed Invoice' type= 'button' href=#><\/a>"}function c(n){$("#generateAllClaims").on("click",function(){var t=$("#grid_NewServiceInvoices").data("kendoGrid"),i=KendoGridExtractFilter.getDataSourceRequest($("#grid_NewServiceInvoices")),r=function(){t.dataSource.read();$("#ConfirmClaimCreation").data("kendoWindow").close()},u=function(){DialogHelper.alertDialogBox("No Unclaimed Invoices were found.")};$("#ConfirmClaimCreation").on("click","#confirm",function(){var t={GroupNDISByClient:$("#GroupNDISByClient").is(":checked"),GroupPlanManagedByClient:$("#GroupPlanManagedByClient").is(":checked"),GroupOrgFundedByClient:$("#GroupOrgFundedByClient").is(":checked"),GroupSelfFundedByClient:$("#GroupSelfFundedByClient").is(":checked"),GroupClientFundedByClient:$("#GroupClientFundedByClient").is(":checked")};execAjax("POST",n+"?dataSourceRequest="+i,JSON.stringify(t),"application/json; charset=utf-8","",r,u,"","")}).on("click","#closeButton",function(){$("#GroupNDISByClient").prop("checked",!1);$("#GroupPlanManagedByClient").prop("checked",!1);$("#GroupOrgFundedByClient").prop("checked",!1);$("#GroupSelfFundedByClient").prop("checked",!1);$("#GroupClientFundedByClient").prop("checked",!1);$("#ConfirmClaimCreation").data("kendoWindow").close()}).data("kendoWindow").open().center()})}function l(n){$("#generateButton").click(function(){var t=[],i,r;if($.each($("input[name='MultipleKendoGridCheckBox']:checked"),function(){t.push($(this).val())}),t.length===0)return kendo.alert("Please select invoices to claim!"),!1;i=function(n){n.Success?window.location.href=window.location.href:DialogHelper.alertDialogBox("Cannot generate claim <br/>["+n.Error+"]")};r=function(){execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",i,"","","")};DialogHelper.confirmAndExecute("Do you want to claim the selected invoice(s)?",r)})}function a(n){n.on("click",'input[name="MultipleKendoGridCheckBox"]',function(){if($(this).is(":checked"))$("#generateButton").attr("disabled")&&($("#generateButton").removeAttr("disabled"),$("#generateButton").removeClass("hidden"),$("#generateButton").show(),$("#generateAllClaims").hide(),$("#generateAllClaims").attr("disabled","disabled"));else{var t=n.find('input[name="MultipleKendoGridCheckBox"]:checked').length;t===0&&($("#generateButton").attr("disabled","disabled"),$("#generateButton").hide(),$("#generateAllClaims").show(),$("#generateAllClaims").removeAttr("disabled"))}})}function v(n,t){var r=t.data("kendoGrid"),i=[];n>0&&(i.push({field:"PaymentRequestId",operator:"eq",value:n}),r.dataSource.filter(i))}function y(n){n.on("click",".generate-claims",function(t){var u,i,f,e;t.preventDefault();u=$(this.closest("tr").firstChild.innerHTML).val();i=[];i.push(u);f=function(){n.data("kendoGrid").dataSource.read()};e=function(){execAjax("POST",r,JSON.stringify(i),"application/json; charset=utf-8","",f,"","","")};DialogHelper.confirmAndExecute("Do you want to claim the Service Invoice?",e)})}function p(){var n=$("#grid_NewServiceInvoices").data("kendoGrid");n.dataSource.total()===0?$("#generateAllClaims").attr("disabled","disabled"):$("#generateAllClaims").removeAttr("disabled")}function w(){l(r)}function b(n,t){r=n;c(t);w()}function k(n,t,i){var r=t.selector;$(r).on("click",".archive-btn",function(t){t.preventDefault();var e=$(r).data("kendoGrid"),o=e.dataItem($(this).closest("tr")),f=o.get("ServiceLogDetailDto.Id"),s={id:o.get("Id")},u,h=function(){var t={ids:u},i=function(){e.dataSource.read()},r=function(n){DialogHelper.alertDialogBox(n.statusText)};execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",i,r,"","")},c=function(n){u=n.references;var i=u.join(", "),t;t=u.length==1?"Service Log #"+f+" will be reverted to Draft. <\/br><\/br> Are you sure you want to deactivate this Service Invoice?":"Deactivating this Service Invoice will deactivate the following Service Invoice(s). <\/br> \n                        Reference #: "+i+". <\/br> Service Log #"+f+" will be reverted to Draft. <\/br><\/br> Are you sure you want to deactivate this Service Invoice?";DialogHelper.confirmAndExecute(t,h)},l=function(){DialogHelper.alertDialogBox("We can not deactivate this Service Invoice as its Service Log #"+f+" has invoices that have already been claimed.")};execAjax("POST",i,JSON.stringify(s),"application/json; charset=utf-8","",c,l,"","")})}function d(n,t){var i=t.selector;$(i).on("click",".unclaim-invoice",function(t){t.preventDefault();var s=$(i).data("kendoGrid"),r=s.dataItem($(this).closest("tr")),a=r.get("ServiceLogDetailDto.Id"),e=r.get("Id"),h=r.get("PaymentRequestId"),f=r.get("FinanceSystemName"),o=r.get("FinanceSystemReferenceNumber"),c=r.get("IsMarkedAsClaimed"),v={id:r.get("Id")},l=function(){var t={ids:[e]},i=function(){s.dataSource.read()},r=function(n){DialogHelper.alertDialogBox(n.statusText)};execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",i,r,"","")},u;u="Confirmation<br/>By pressing confirm, this Claimed Service Invoice will revert to New Service Invoice.<br/>Please note that the Claimed Service Invoice will be removed from any generated Payment Requests. Claiming this Service Invoice again will add it to a new Payment Request.<br/><br/>";c===!0&&(f==null||f===""?u+="Invoice #"+e+" is a part of Claim #"+h+" which has been marked as claimed.":(u+="Invoice #"+e+" has been sent to "+f+" as a part of Claim #"+h,o!=null&&o!==""&&(u+=" and the "+f+" reference number for the transaction is "+o)));u+="<br/><br/>Please review the reference to this Service Invoice in your other systems/existing exports.<br/><br/>Are you sure you want to revert this Service Invoice?";DialogHelper.confirmAndExecute(u,l)})}var t,i,r;n.setPermissions=u;n.setActionUrls=f;n.renderActions=e;n.renderGenerateActions=o;n.addCheckboxHandler=a;n.addClaimIdFilter=v;n.initGenerateSingleClaim=y;n.showClaimAllButton=p;n.initModule=b;n.attachArchiveAction=k;n.attachUnclaimAction=d}(ServiceInvoice||(ServiceInvoice={})),function(n){function u(n,i,r,u,f,e){t=new Permissions(n,i,r,u,f,e)}function f(n,t,r,u,f,e,o,s){i=new ActionUrls(n,t,r,u,f,e,o,s)}function e(n,r,u){var f="",e=EnumHelper.getEnumByNumber(r);return u?(t.viewPermission&&(f+=KendoGridActionButtonHelper.generateViewLink(i.viewUrl+"/"+n.toString()+"?viewOnly=true")),f):(t.viewPermission&&(f+=KendoGridActionButtonHelper.generateViewLink(i.viewUrl+"/"+n.toString()+"?viewOnly=true")),e===EnumHelper.getEnumByName("Draft")&&t.editPermission&&(f+=KendoGridActionButtonHelper.generateEditLink(i.editUrl+"/"+n.toString())),e===EnumHelper.getEnumByName("Draft")&&t.publishPermission&&(f+=KendoGridActionButtonHelper.generatePublishLink(n)),(e===EnumHelper.getEnumByName("Draft")||e===EnumHelper.getEnumByName("Approved"))&&t.archivePermission&&(f+=KendoGridActionButtonHelper.generateActivateDeactivateLink(n,!1)),e===EnumHelper.getEnumByName("Approved")&&t.invoicePermission&&(f+=KendoGridActionButtonHelper.generateInvoiceLink(n)),f)}function o(n){var t=n.selector;$(t).on("click",".listingcheckbox",function(){var f=$("#tabstrip").data("kendoTabStrip").select().index(),t=$(this),u=t.parents("tr"),i=u.find("td.current-state").text();t.is(":checked")?i==="Draft"&&$("#publishLogs").removeAttr("disabled"):r(n.selector)||$("#publishLogs").attr("disabled","disabled");t.is(":checked")?i==="Approved"&&$("#invoiceLogs").removeAttr("disabled"):r(n.selector)||$("#invoiceLogs").attr("disabled","disabled")})}function r(n){return!!$(""+n+" input[name='MultipleKendoGridCheckBox']:checked").length}function s(n,t){var i=function(t,i,r){execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",i,r,"","");$("#publishLogs").attr("disabled","disabled")};KendoHelper.confirmAndExecute(i,t,".publish-multiple-log","Do you want to publish the selected service logs?")}function h(n,t){var i=function(t,i,r){execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",i,r,"","");$("#invoiceLogs").attr("disabled","disabled")};KendoHelper.confirmAndExecute(i,t,".invoice-multiple-log","Do you want to invoice the selected service logs?")}function c(n,t){var i=t.selector;$(i).on("click",".sprite-publish-icon",function(){var i=$(this),r=i.data("id"),t=[];t.push(r);var u=function(){$("#publishLogs").attr("disabled","disabled");$(".k-grid").each(function(){$(this).data("kendoGrid").dataSource.read()})},f=function(){DialogHelper.alertDialogBox("One or more selected service log is already published / invoiced.")},e=function(){execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",u,f,"","")};DialogHelper.confirmAndExecute("Do you want to publish the selected service logs?",e)})}function l(n,t){var i=t.selector;$(i).on("click",".sprite-icon_invoice_generate",function(){var i=$(this).data("id"),t=[];t.push(i);var r=function(){$("#invoiceLogs").attr("disabled","disabled");$(".k-grid").each(function(){$(this).data("kendoGrid").dataSource.read()})},u=function(){$("p#ajax-response").hide();$("#inoviceErrorMessage").after("<p id='ajax-response' class='error-label-color'>One or more selected service log is already invoiced.<\/p>")},f=function(){execAjax("POST",n,JSON.stringify(t),"application/json; charset=utf-8","",r,u,"","")};DialogHelper.confirmAndExecute("Do you want to invoice the selected service logs?",f)})}function a(n,t){var i=t.selector;$(i).on("click",".archive-btn",function(){var r=$(i).data("kendoGrid"),t=r.dataItem($(this).closest("tr")),u={id:t.get("Id")},f=t.get("ServiceScheduleDetailDto.Id"),e=function(){var t=function(){$(".k-grid").each(function(){$(this).data("kendoGrid").dataSource.read()})},i=function(n){DialogHelper.alertDialogBox(n.statusText)};execAjax("POST",n,JSON.stringify(u),"application/json; charset=utf-8","",t,i,"","")},o="Service Schedule #"+f+" will be reinstated. <\/br> <\/br> Are you sure you want to deactivate this Service Log?";DialogHelper.confirmAndExecute(o,e)})}function v(){function r(n,t){function e(n){$("div.staff-timesheets-container").append(n)}var r=$("input#SelectedActivityLogStaffMemberIds").data("timesheet-pv-url"),i=$("#ScheduledStartDate").val(),u=$("#ScheduledStartTime").val(),f={StaffId:n,FirstName:t,StartTime:i,StartTimeOnly:u,EndTime:i};execAjax("POST",r,f,"","",e)}function u(n){$("div.staff-"+n).remove()}var t=$("#SelectedActivityLogStaffMemberIds"),i=t.data("get-employees-url");t.select2({multiple:!0,allowClear:!0,placeholder:"Select Staff",minimumInputLength:0,ajax:{url:i,dataType:"json",quietMillis:50,data:function(n){return{searchTerm:n}},results:function(n){return n}},initSelection:function(t,i){var u=[],r;if(n.staffMembers){for(r=0;r<n.staffMembers.length;r++)u.push({id:n.staffMembers[r].StaffId,text:n.staffMembers[r].FullName});u.length>0&&i(u)}},formatSelection:function(n){return n.text}}).select2("val",[]).on("change",function(n){n.added?r(n.added.id,n.added.text):n.removed&&u(n.removed.id)})}function y(n,t,i,r,u,f,e){var o=$("#service-type"),s,h;$(".cancelreason-other").addClass("hidden");o.select2();$("#NotAttendedReason").select2({placeholder:"Please Select Reason"}).on("change",function(){var n=$("#NotAttendedReason").val();EnumHelper.getEnumByName(n)=="Other"?($(".cancelreason-other").show(),$(".cancelreason-other").removeClass("hidden")):($(".cancelreason-other").hide(),$("#ReasonForNonAttendanceOther").val(""))});$("#service-type-id").val(o.val());o.select2("enable",!1);s=function(){if($("#ClientDidNotParticipate").is(":checked")){$("#warning-text").show();$(".cancelreason-dropdown").removeClass("hidden");$(".cancelreason-dropdown").show();var n=$("#NotAttendedReason").val();EnumHelper.getEnumByName(n)=="Other"&&($(".cancelreason-other").show(),$(".cancelreason-other").removeClass("hidden"))}else $("#warning-text").hide(),$(".cancelreason-dropdown").hide(),$(".cancelreason-other").hide(),$("#ReasonForNonAttendanceOther").val(""),$("#NotAttendedReason").val(0).trigger("change")};h=function(){$("#ServiceLogNoCharge").is(":checked")?$(".quantity input").each(function(){$(this).val(0);$(this).prop("disabled",!0)}):$(".quantity input").each(function(){$(this).prop("disabled",!1)})};$("#ClientDidNotParticipate").change(function(){s()});$("#ServiceLogNoCharge").change(function(){h()});s();h();EmployeesWithStartEnd.initIndex(i);ActivitiesWithRefresh.initIndex(r,t);AdditionalCostActivities.initIndex(u,f,e);n&&ControlsHelper.disableInputs($("#service-log-form"))}function p(n){var i=$("div."+n).find(".js-custom-datepicker"),t;$.each(i,function(n,t){initCustomDatePicker($(t))});t=$("div."+n).find(".js-custom-timepicker");$.each(t,function(n,t){$(t).timepicker()})}function w(n){$(n).data("kendoGrid").dataSource.total()>0&&$(".export-filtered").prop("disabled",!1)}var t,i;n.setPermissions=u;n.setActionUrls=f;n.renderActions=e;n.getMultipleLogsToPublish=o;n.publishMultipleLog=s;n.invoiceMultipleLog=h;n.publishSingleLog=c;n.invoiceSingleLog=l;n.attachArchiveAction=a;n.init=v;n.initDetails=y;n.initialiseStaffTimesheet=p;n.enableExportFiltered=w}(ActivityLog||(ActivityLog={})),function(n){function b(){$("body").on("click",".activities-list .delete a",function(n){var t=$(this),i=t.parents(".activities-list-row");i.remove();n.preventDefault()})}function k(){$("body").on("click",".select-staff .delete a",function(n){var i=$(this),t=i.parents(".add-staff-row");p(t,"div.select-staff select");t.remove();n.preventDefault()})}function d(n){var i=$("div.select-staff"),u=i.find("select"),r="Please select",t="";$("#add-staff").click(function(u){var o=function(n){i.append(n);var f=i.find("div.row"),u=f.find("select");if(u.select2(),renderCustomControls(i),$("p#ajax-response").hide(),$("div.select-staff select").length>0){$("div.select-staff select").on("change",function(){var n=$("div.select-staff #s2id_"+$(this).get(0).id+" .select2-chosen").get(0).innerText;t.toLowerCase()!="please select"&&t.toLowerCase()!=""?(s("div.select-staff select",$(this).get(0).id,t,r),t=""):t.toLowerCase()==="please select"&&$(this).find("option:contains('Please select')").remove();y("div.select-staff select",$(this).get(0).id,n)});$("div.select-staff select").on("select2-open",function(){t=$(this).prev().find("a > span.select2-chosen").get(0).innerText;r=u.find('option:contains("'+t+'")').val()})}},h=function(){$("#add-staff").before("<p id='ajax-response' class='error-label-color'>We were unable to find staff.<\/p>")},c=$("#ScheduleStartTime").val(),l=$("#ScheduleEndTime").val(),f=$("div.select-staff select"),e={SelectedStaffMembers:[],startTime:c,endTime:l};f.length>0&&f.each(function(n,t){e.SelectedStaffMembers.push({Id:$(t).val()})});execAjax("POST",n,JSON.stringify(e),"application/json; charset=utf-8","",o,h);u.preventDefault()});k()}function g(n,t){var i=$("div.additional-costs");$.each(i.find("div.row"),function(n,i){v($(i),t)});$("body").on("click",".additional-costs .delete a",function(n){var i=$(this),t=i.parents(".additional-cost-row");p(t,"div.additional-costs select");t.remove();n.preventDefault()});$("#add-additional-cost").click(function(r){var o=function(n){i.append(n);var r=i.find(".additional-cost-row").last();v(r,t)},f=$("div.additional-costs .select2-chosen"),e={SelectedFields:[]},u;f.length>0&&(u=0,f.each(function(){e.SelectedFields.push({Id:u.toString(),FieldName:$(this).get(0).innerText});u++}));execAjax("POST",n,JSON.stringify(e),"application/json; charset=utf-8","",o);r.preventDefault()})}function v(n,t){var i=n.find("select"),u="Please select",r="";i.select2().on("select2-open",function(){r=$(this).prev().find("a > span.select2-chosen").get(0).innerText;u=i.find('option:contains("'+r+'")').val()});i.select2().on("change",function(){var e=function(t){n.find(".quantity input").val(1);n.find(".unit-of-measure input").val(t.UnitOfMeasure);n.find(".total-price input").val((t.Cost*1).toFixed(2));n.find(".costHiddenField input").val(t.Cost);y("div.additional-costs select",i.get(0).id,t.Name)},f={id:i.val()};f.id!=0&&execAjax("GET",t,f,"json","",e);r.toLowerCase()!="please select"?s("div.additional-costs select",i.get(0).id,r,u):r.toLowerCase()==="please select"&&$(this).find("option:contains('Please select')").remove()})}function nt(n,i,s,a,v,y,p,w,k,nt,it,rt,ut,ft,et){function dt(n){var i=function(n){at.reselect2({placeholder:"Select Hierarchy",selectOptions:n});var i=0;n.length===1?(i=parseInt(n[0].id),at.val(i),at.trigger("change.select2"),e()):f();t(ht,a,ot,w,k,st,ct,lt)},r={clientId:n};execAjax("GET",rt,r,"application/json","",i,"")}var at=$("#unit-selector"),vt=$("#unit-selector"),ht=$("#refreshActivities"),yt=$("#days-of-week"),ot=$("#service-type"),pt=$(".add-staff-row"),ct=$("#add-additional-cost"),lt=$("#add-staff"),st=$("#client"),wt=$("#ScheduleStartDate__Editor"),bt=$("#serviceProviders"),kt=pt.find("select");kt.select2();yt.select2();vt.select2();b();ot.val()>0&&$("input:radio[name=SelectedActivity]:checked").val()!=null&&$("#Id").val()==0&&tt(ht,ct,lt,at);g(v,y);d(p);$(document).ready(function(){wt.off("change").on("change",function(){var n=st.val();n>0&&t(ht,a,ot,w,k,st,ct,lt);r(ht,a,ot,w,k,st,ct,lt)})});st.val()>0&&$("#client").attr("disabled","disabled");ot.val()==0&&h(ht,a,ot,w,k,st,ct,lt);$(".activity-radio-button").click(function(){$("#service-type-id").val(0);$("#typeOfServiceLabel").empty();h(ht,a,ot,w,k,st,ct,lt)});bt.select2().on("change",function(){var i=st.val(),n=ot.val();console.log(n);i>0?t(ht,a,ot,w,k,st,ct,lt):n!=0&&r(ht,a,ot,w,k,st,ct,lt)});ot.select2().on("change",function(){var n,t,i;r(ht,a,ot,w,k,st,ct,lt);n=ot.val();n!=0?(t=function(n){$("#typeOfServiceLabel").empty().text("Type of Service : "+n.Description);var t=EnumHelper.getEnumByNumber(n.Value,".type-of-service-values");$("#typeOfService").val(n.Value);ServiceScheduleAndLogCommon.showDateAndTimeControls(t,!0)},i={serviceTypeId:ot.val()},execAjax("GET",ut,i,"json","",t)):$("#typeOfServiceLabel").empty()});st.select2().on("change",function(n){var t=$("#client").val()!=null?parseInt($("#client").val()):0;t!==0?(n.preventDefault(),dt(t)):(at.val(0).trigger("change"),$(".activities-list").empty())});at.select2().on("change",function(){var n=at.val();n>0?e():f()});$("#billerType").attr("disabled","disabled");ht.on("click",function(n){var i=$("#client").val(),r=$("#ScheduleStartDate__Editor").val(),f=$("#service-schedule-form #Id").val(),e=$("#serviceProviders").val(),t=[];if(t=c(t),i===0)$(".activities-list").empty();else{var o=function(n){$(".activities-list").empty().append(n);l(t);u()},s=function(){$("p#ajax-response").hide();$(".activities-list").empty();ht.before("<p id='ajax-response' class='error-label-color'>We were unable to find planned activities for the selected client.<\/p>")},h={clientId:i,scheduleStartDate:r,serviceScheduleId:f,serviceProviderId:e};execAjax("GET",a,h,"json","",o,s);n.preventDefault()}});n==="True"?ControlsHelper.disableInputs($("#service-schedule-form")):o.initServiceScheduleEdit(nt,it,ft,et);u()}function s(n,t,i,r){$(n).each(function(){t!=$(this).get(0).id&&$(this).append($("<option>").val(r).text(i).get(0))})}function y(n,t,i){$(n).each(function(){t!=$(this).get(0).id&&$(this).find("option:contains("+i+")").remove()})}function p(n,t){var i=n.find(".select2-chosen").get(0).innerText,r=n.find("select").find("option:contains("+i+")").val(),u=n.find("select").get(0).id;r!="0"&&s(t,u,i,r)}function t(n,t,r,f,e,o,s,h){var a=$("#client").val();$("#selected-client-id").val(a);var v=$("#ScheduleStartDate__Editor").val(),y=$("#service-schedule-form #Id").val(),p=$("#serviceProviders").val();if(a==0||v==""||v==null)r.val()==0&&(i(n,s,h),$(".activities-list").empty(),$("#client").attr("disabled","disabled"));else{n.attr("disabled","disabled");var b=function(t){$("p#ajax-response").hide();var i=[];i=c(i);$(".activities-list").empty().append(t);l(i);n.removeAttr("disabled");s.removeAttr("disabled");h.removeAttr("disabled");$("#saveButton").removeAttr("disabled");$("#Id").val()==0&&$("#saveAndAddAnotherButton").removeAttr("disabled");$("#saveButton").removeAttr("disabled");$("#service-schedule-form :input").not(":input[type=submit]").removeAttr("disabled");w();o.attr("disabled","disabled");u()},k=function(){$("p#ajax-response").hide();$(".activities-list").empty();$("#saveButton").attr("disabled","disabled");$("#Id").val()==0&&$("#saveAndAddAnotherButton").attr("disabled","disabled");n.before("<p id='ajax-response' class='error-label-color'>There are no available support items that can be scheduled.<\/p>")},d={clientId:a,scheduleStartDate:v,serviceScheduleId:y,serviceProviderId:p};execAjax("GET",t,d,"json","",b,k)}}function r(n,r,u,f,e,o,s,h){$("#service-type-id").val(u.val());var c=$("#selected-client-id").val(),l=$("#ScheduleStartDate__Editor").val(),v=$("#serviceProviders").val();a()==="ThisSchedule"&&$("#scheduleSection :input").removeAttr("disabled");var y=function(r){if(c==0)o.reselect2({placeholder:"Select Client",selectOptions:r.clients}),$("p#ajax-response").hide(),r.clients.length<1?o.after("<p id='ajax-response' class='error-label-color'>We were unable to find any clients.<\/p>"):(i(n,s,h),$("#client").removeAttr("disabled"),t,$("#service-type").removeAttr("disabled"),o.val(c).trigger("change"),a()==="ThisSchedule"&&$("#scheduleSection :input").removeAttr("disabled"),$(".schedule-recurrence :input").removeAttr("disabled"),c==0&&$(".select2-input").removeAttr("disabled"));else{var u=r.clients.find(function(n){return n.id==c});u!=null&&(o.reselect2({placeholder:"Select Client",selectOptions:r.clients}),o.val(c).trigger("change"))}},p=function(){o.after("<p id='ajax-response' class='error-label-color'>We were unable to find any clients.<\/p>")},w={serviceTypeId:u.val(),scheduleStartDate:l,serviceProviderId:v};execAjax("GET",e,w,"json","",y,p)}function h(n,t,r,u,f,e,o,s){if($("input[name=SelectedActivity]:checked").length){var h=$("input[name=SelectedActivity]:checked").val(),c=function(t){r.reselect2({placeholder:"Select Service Type",selectOptions:t});$("p#ajax-response").hide();t.length<1?r.after("<p id='ajax-response' class='error-label-color'>We were unable to find service types for selected Individual/ Group Activity.<\/p>"):(i(n,o,s),$("#service-type").removeAttr("disabled"),$(".select2-input").removeAttr("disabled"),r.reselect2({placeholder:"Select Service Type",selectOptions:t}))},l=function(){r.after("<p id='ajax-response' class='error-label-color'>We were unable to find service types for selected Individual/ Group Activity.<\/p>")};execAjax("GET",u,"selectedActivity="+h,"","",c,l)}else i(n,o,s),$(".activities-list").empty()}function c(n){return $(".activities-list-row").each(function(){n.push([$(this).find('input[type="hidden"][name*="BudgetAgreementActivityId"]').val(),$(this).find(".quantity").find('input[type="text"]').val()])}),n}function l(n){return $(".activities-list-row").each(function(){for(var t=0;t<n.length;t++)n[t][0]===$(this).find('input[type="hidden"][name*="BudgetAgreementActivityId"]').val()&&$(this).find(".quantity").find('input[type="text"]').val(n[t][1]).change()}),n}function i(n,t,i){n.attr("disabled","disabled");t.attr("disabled","disabled");i.attr("disabled","disabled");$("#service-schedule-form :input").attr("disabled","disabled");$("#scheduleSection :input").attr("disabled","disabled");$(".schedule-recurrence").attr("disabled","disabled");$(".activity-radio-button").removeAttr("disabled")}function u(){$.each($(".activities-list .row.activities-list-row"),function(n,t){var i=$($(t).find("#billerType")[0]);i.attr("disabled","disabled")})}function w(){var n=a();n!=="ThisSchedule"?$("#scheduleSection :input").attr("disabled","true"):$("#scheduleSection :input").removeAttr("disabled");n!=="DateRange"?$(".recurrence-date").attr("disabled","true"):$(".recurrence-date").removeAttr("disabled")}function f(){$("#saveButton").attr("disabled","disabled");$("#saveAndAddAnotherButton").attr("disabled","disabled")}function e(){$("#saveButton").removeAttr("disabled");$("#saveAndAddAnotherButton").removeAttr("disabled")}function tt(n,t,i,r){n.attr("disabled","disabled");t.attr("disabled","disabled");i.attr("disabled","disabled");r.attr("disabled","disabled");f()}function a(){var n=$("input[name='EditType']:checked").val();return n==null&&(n="ThisSchedule"),n}var o;(function(n){function i(n,t,i,u){r(n,t,i,u)}function r(n,i,r,u){$("#service-schedule-form").on("click","#saveButton",function(f){f.preventDefault();t(n,i,r,u)});$("#service-schedule-form").on("click","#saveAndAddAnotherButton",function(f){f.preventDefault();t(n,i,r,u,!0)})}function t(n,t,i,r,e){e===void 0&&(e=!1);f();var o=$("#service-schedule-form");o.valid()&&u(n,o.serialize(),t,i,r,e)}function u(n,t,i,r,u,f){function o(n){var t,o;if(n!=="")n.length>0&&(t=function(){e();$("#service-schedule-form > div.validation-summary-errors").remove()},DialogHelper.actionHTMLOKDialogBox(n,t));else{function s(n){var t,i;e();t=$("<div/>").html(n).find(".validation-summary-errors").addClass("alert").addClass("alert-error");$("#service-schedule-form > div.validation-summary-errors").remove();$('#service-schedule-form input[name="__RequestVerificationToken"]').after(t[0]);t!=null&&t.length==0?f?(i=jQuery.param({scheduleStartDate:$("#ScheduleStartDate__Editor").val()+" "+$("#ScheduleStartTime").val(),scheduleEndDate:$("#ScheduleEndDate__Editor").val()+" "+$("#ScheduleEndTime").val(),serviceTypeId:$("#service-type-id").val(),groupOrIndividualActivity:$("input:radio[name=SelectedActivity]:checked").val(),serviceProviderId:$("#serviceProviders").val()}),window.location.href=u+"?"+i):window.location.href=r:$("html, body").animate({scrollTop:$("div.validation-summary-errors").offset().top},"fast")}o=$("#service-schedule-form").serialize();execAjax("POST",i,o,"","",s)}}execAjax("POST",n,t,"","",o)}n.initServiceScheduleEdit=i})(o||(o={}));n.initIndex=nt;n.getClientPlanActivities=t;n.getClients=r;n.getServiceTypes=h;n.saveExistingActivitiesQuantity=c;n.getExistingActivitiesQuantity=l;n.disableCommonControls=i;n.disableSupportItemBillerTypeDropDown=u;n.onEditTypeChanged=w}(Serviceschedule||(Serviceschedule={})),function(n){function i(n,i){i===void 0&&(i=!1);switch(n){case EnumHelper.getEnumByName("DirectSupportOrDayService",".type-of-service-values"):case EnumHelper.getEnumByName("Transport",".type-of-service-values"):case EnumHelper.getEnumByName("ReportWriting",".type-of-service-values"):case EnumHelper.getEnumByName("CoordinationOfSupports",".type-of-service-values"):case EnumHelper.getEnumByName("ClinicalTherapy",".type-of-service-values"):case EnumHelper.getEnumByName("NonFaceToFace",".type-of-service-values"):case EnumHelper.getEnumByName("Employment",".type-of-service-values"):case EnumHelper.getEnumByName("IrregularSILSupport",".type-of-service-values"):case EnumHelper.getEnumByName("TelehealthSupport",".type-of-service-values"):$(".scheudleEndDate").show();u();break;case EnumHelper.getEnumByName("AccommodationOrLongTerm",".type-of-service-values"):$(".scheudleEndTime").hide();$(".scheudleStartTime").hide();$(".scheudleEndDate").show();t(i);break;case EnumHelper.getEnumByName("ConsumablesOrFees",".type-of-service-values"):$(".scheudleEndTime").hide();$(".scheudleStartTime").hide();$(".scheudleEndDate").hide();t(i)}}function r(n,t){t=EnumHelper.getEnumByNumber(t,".type-of-service-values");switch(t){case EnumHelper.getEnumByName("DirectSupportOrDayService",".type-of-service-values"):case EnumHelper.getEnumByName("Transport",".type-of-service-values"):case EnumHelper.getEnumByName("ReportWriting",".type-of-service-values"):case EnumHelper.getEnumByName("CoordinationOfSupports",".type-of-service-values"):case EnumHelper.getEnumByName("ClinicalTherapy",".type-of-service-values"):case EnumHelper.getEnumByName("NonFaceToFace",".type-of-service-values"):case EnumHelper.getEnumByName("IrregularSILSupport",".type-of-service-values"):case EnumHelper.getEnumByName("TelehealthSupport",".type-of-service-values"):case EnumHelper.getEnumByName("Employment",".type-of-service-values"):return DateTimeHelper.formatDate(n);case EnumHelper.getEnumByName("AccommodationOrLongTerm",".type-of-service-values"):case EnumHelper.getEnumByName("ConsumablesOrFees",".type-of-service-values"):return DateTimeHelper.formatDateOnly(n)}}function u(){$(".scheudleEndTime").show();$(".scheudleStartTime").show()}function t(n){n&&($("#ScheduleEndTime").val("10:00am"),$("#ScheduleStartTime").val("09:00am"))}n.showDateAndTimeControls=i;n.formatDateForTypeOfService=r}(ServiceScheduleAndLogCommon||(ServiceScheduleAndLogCommon={})),function(n){function r(n,i,r,u,f,e,o){t=new Permissions(n,i,r,u,f,null,e,o)}function u(n,t,r,u,f,e,o,s){i=new ActionUrls(n,t,r,u,f,e,o,s)}function f(n,r){var u="";return t.viewPermission&&(u+=KendoGridActionButtonHelper.generateViewLink(i.viewUrl+"?id="+n.toString()+"&isArchived="+r)),t.editPermission&&(u+=KendoGridActionButtonHelper.generateEditLink(i.editUrl+"?id="+n.toString()+"&isArchived="+r)),t.archivePermission&&(u+=KendoGridActionButtonHelper.generateActivateDeactivateLink(n,r)),t.logPermission&&!r&&(u+=h(n)),u}function e(n,t,i){for(var o,u=$($("#"+n).parents(".k-detail-row")[0].previousSibling).find("#service-schedule-ids")[0].innerHTML.split(","),f=$("#"+t).data("kendoGrid"),e="",r=0;r<u.length;r++)e+=e.length==0?"?"+i+"="+u[r]:"&"+i+"="+u[r];o=f.dataSource.transport.options.read.url+e;f.dataSource.transport.options.read.url=o;f.dataSource.read()}function o(n){var i="";return t.logPermission&&!n&&(i+=c()),i}function s(n){for(var t="",i=0;i<n.length;i++)t=t+n[i],i!==n.length-1&&(t=t+", ");return t}function h(n){return"<span data-toggle='modal' data-target='#ActionModal'><a class='sprite sprite-lg sprite-addfile-icon entries-action log-schedule' data-toggle='tooltip' data-placement='top' title= '' data-original-title='Log' type= 'button' data-id='"+n+"' href = '#'><\/a><\/span>"}function c(){return"<span data-toggle='modal' data-target='#ActionModal'><a class='sprite sprite-lg sprite-addfile-icon entries-action log-schedules' data-toggle='tooltip' data-placement='top' title= '' data-original-title='Log' type= 'button' href = '#'><\/a><\/span>"}function l(n,t,i,r,u,f,e){e.on("click",".archive-btn",function(){p(t,r,u,f,e,$(this))}).on("click",".activate-btn",function(){w($(this),i,e)});$("body").on("click",".archiveServiceScheduleSubmit",function(t){t.preventDefault();y($(this),n,r,u,f,e)}).on("click",".archiveServiceScheduleRecurrenceSubmit",function(n){n.preventDefault();d(u,e)});g()}function a(){}function v(n){var t=$("#"+n);t.find("ul.k-reset.k-tabstrip-items")[0].remove()}function y(n,t,i,r,u,f){$(".archiveServiceScheduleSubmit").attr("disabled","disabled");var o=$("#archiveServiceSchedule").data("kendoWindow"),e=$("#validationArchiveReason.validation-summary-valid"),s=function(){o.close();f.data("kendoGrid").dataSource.read();f.data("kendoGrid").refresh()},h=function(n){var t=e.find("ul");t.empty();t.append(n.statusText);e.show()},c={id:$("#archiveReasonServiceScheduleId").val(),archiveReason:$("#archiveReason").val()};execAjax("POST",t,c,"","",s,h);$(".archiveServiceScheduleSubmit").removeAttr("disabled")}function p(n,t,i,r,u,f){var e=$(f.closest(".archive-btn")[0]).data("id"),s=$(f.parents("td")[0]).parent().find("#is-recurrence")[0].innerHTML=="true";if(s)b(t,e,i,r,u);else{var o=$("#archiveServiceSchedule"),h=function(n){o.data("kendoWindow").center().open();renderCustomControls(o.empty().append(n));$(".archiveServiceScheduleSubmit").removeAttr("disabled")},c={id:e};execAjax("GET",n,c,"","",h)}}function w(n,t,i){var r=n.data("id"),u=function(){i.data("kendoGrid").dataSource.read()},f=function(n,t,i){n.status>=400&&n.status<=500&&i!=null?DialogHelper.alertDialogBox(i):DialogHelper.alertDialogBox("Unable to activate this service schedule.")},e=function(){var n={id:r};execAjax("POST",t+"/"+r,n,"json","",u,f)};DialogHelper.confirmAndExecute("Are you sure you want to activate this Service Schedule?",e)}function b(n,t,i,r,u){var f=$("#RemoveInstances").data("kendoWindow"),h=this,e=function(n){renderCustomControls($("#RemoveInstances").empty().append(n));$("#RemoveInstances").off("click","#removeScheduleInstances");$("#RemoveInstances").off("click",".closeButton");$("#RemoveInstances").on("click","#removeScheduleInstances",function(n){k(n,i,r,u)});$("#RemoveInstances").on("click",".closeButton",function(){$(this).closest(".k-window-content").data("kendoWindow")&&$(this).closest(".k-window-content").data("kendoWindow").close()});f.open().center();$("p#ajax-response").hide()},o=function(){$("p#ajax-response").show();$("p#ajax-response").html("Selected schedule does not have any recurrence type.")},s={id:t};execAjax("GET",n,s,"json","",e,o)}function k(n,t,i,r){n.preventDefault();var u=$("#removeschedules").serialize(),o=function(){var n=function(n){if(n.success){var t=$("#RemoveInstances").data("kendoWindow");r.data("kendoGrid").dataSource.read();t.close()}}},f=function(n){if(n==null||n.includes("RemoveInstance"))renderCustomControls($("#RemoveInstances").empty().append(n));else{$(".archiveServiceScheduleRecurrenceSubmit").attr("disabled","disabled");var t=$("#archiveServiceSchedule");t.data("kendoWindow").center().open();renderCustomControls(t.empty().append(n));$(".archiveServiceScheduleRecurrenceSubmit").removeAttr("disabled")}},e=function(n){renderCustomControls($("#removeinstances").empty().append(n))};execAjax("POST",i,u,"","",f,e,"","","")}function d(n,t){$(".archiveServiceScheduleRecurrenceSubmit").attr("disabled","disabled");var r=$("#archiveServiceSchedule").data("kendoWindow"),u=$("#RemoveInstances").data("kendoWindow"),i=$("#validationArchiveReasonRecurrence.validation-summary-valid"),f=$("#archiveReasonRecurrence").val(),e=$("#schedule-recurrence-id").val(),o=$(".recurrenceStartDate").val(),s=$(".recurrenceEndDate").val(),h=function(){r.close();u.close();t.data("kendoGrid").dataSource.read();t.data("kendoGrid").refresh()},c=function(n){var t=i.find("ul");t.empty();t.append(n.statusText);i.show()},l={reason:f,scheduleRecurrenceId:e,recurrenceStartDate:o,recurrenceEndDate:s};execAjax("POST",n,l,"","",h,c);$(".archiveServiceScheduleRecurrenceSubmit").removeAttr("disabled")}function g(){$("body").on("click",".closeButton",function(){$(this).closest(".k-window-content").data("kendoWindow")&&$(this).closest(".k-window-content").data("kendoWindow").close()})}var t,i;n.setPermissions=r;n.setActionUrls=u;n.renderActions=f;n.getQueryString=e;n.renderTopLevelTabActions=o;n.renderStaffMembers=s;n.initIndex=l;n.attachRemoveInstancesListener=a;n.removeTabStripLabel=v}(Serviceschedulelisting||(Serviceschedulelisting={})),function(n){function f(n){$(document).ready(function(){var f="";u();$("#myModal").on("shown.bs.modal",function(){u()});$("#myModal").on("hide.bs.modal",function(t){var e,i,o,s,u;if(r(),$("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val()==="Daily")$("#RecurrenceFrequencyCountDaily").val()===""?($("#YearlyRecurEveryRequiredValidation").show(),$("#validation-message").show(),t.preventDefault()):parseInt($("#RecurrenceFrequencyCountDaily").val())>=100?($("#YearlyRecurEveryMaxValidation").show(),$("#validation-message").show(),t.preventDefault()):parseInt($("#RecurrenceFrequencyCountDaily").val())<1&&($("#YearlyRecurEveryMinValidation").show(),$("#validation-message").show(),t.preventDefault());else if($("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val()==="Weekly"){for(e=!1,i=0;i<n;i++)if(o="#DaysOfWeeks_"+i+"__IsSelected",s="DaysOfWeeks_"+i+"__IsSelected",$(o).prop("checked")){f+=$("label[for='"+s+"']").text()+", ";e=!0;break}$("#RecurrenceFrequencyCountWeekly").val()===""?($("#YearlyRecurEveryRequiredValidation").show(),$("#validation-message").show(),t.preventDefault()):parseInt($("#RecurrenceFrequencyCountWeekly").val())>=100?($("#YearlyRecurEveryMaxValidation").show(),$("#validation-message").show(),t.preventDefault()):parseInt($("#RecurrenceFrequencyCountWeekly").val())<1?($("#YearlyRecurEveryMinValidation").show(),$("#validation-message").show(),t.preventDefault()):e||($("#validation-message").show(),$("#WeeklyDayRequiredValidation").show(),t.preventDefault())}else if($("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val()==="Monthly")$("#ServiceScheduleReccurence_RecurrenceDayMonthly").val()===""?($("#YearDayRequiredValidation").show(),$("#validation-message").show(),t.preventDefault()):$("#RecurrenceFrequencyCountMonthly").val()===""?($("#YearlyRecurEveryRequiredValidation").show(),$("#validation-message").show(),t.preventDefault()):parseInt($("#RecurrenceFrequencyCountMonthly").val())>=100?($("#YearlyRecurEveryMaxValidation").show(),$("#validation-message").show(),t.preventDefault()):parseInt($("#RecurrenceFrequencyCountMonthly").val())<1&&($("#YearlyRecurEveryMinValidation").show(),$("#validation-message").show(),t.preventDefault());else if($("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val()==="Yearly")if($("#RecurrenceFrequencyCountYearly").val()==="")$("#YearlyRecurEveryRequiredValidation").show(),$("#validation-message").show(),t.preventDefault();else if(parseInt($("#RecurrenceFrequencyCountYearly").val())>=100)$("#YearlyRecurEveryMaxValidation").show(),$("#validation-message").show(),t.preventDefault();else if(parseInt($("#RecurrenceFrequencyCountYearly").val())<1)$("#YearlyRecurEveryMinValidation").show(),$("#validation-message").show(),t.preventDefault();else if($("#ServiceScheduleReccurence_RecurrenceDayYearly").val()==="")$("#YearDayRequiredValidation").show(),$("#validation-message").show(),t.preventDefault();else{u=!1;switch(Number($("#ServiceScheduleReccurence_SelectedMonth  option:selected").val())){case 2:($("#ServiceScheduleReccurence_RecurrenceDayYearly").val()!=""&&Number($("#ServiceScheduleReccurence_RecurrenceDayYearly").val())>28||Number($("#ServiceScheduleReccurence_RecurrenceDayYearly").val())<1)&&($("#SelectedMonthMaxDay").text("28"),u=!0);break;case 4:case 6:case 9:case 11:($("#ServiceScheduleReccurence_RecurrenceDayYearly").val()!=""&&Number($("#ServiceScheduleReccurence_RecurrenceDayYearly").val())>30||Number($("#ServiceScheduleReccurence_RecurrenceDayYearly").val())<1)&&($("#SelectedMonthMaxDay").text("30"),u=!0);break;default:($("#ServiceScheduleReccurence_RecurrenceDayYearly").val()!=""&&Number($("#ServiceScheduleReccurence_RecurrenceDayYearly").val())>31||Number($("#ServiceScheduleReccurence_RecurrenceDayYearly").val())<1)&&($("#SelectedMonthMaxDay").text("31"),u=!0)}u&&($("#SelectedMonth").text($("#ServiceScheduleReccurence_SelectedMonth  option:selected").text()),$("#validation-message").show(),$("#DayValidationMessage").show(),t.preventDefault())}});$("#RecurrenceOk").click(function(){var i=$("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val(),t,r,u,e,o;switch(i){case"None":f="";break;case"Daily":f="Recur every "+$("#RecurrenceFrequencyCountDaily").val()+" day(s)";$("#ServiceScheduleReccurence_RecurrenceDay").val("");$("#ServiceScheduleReccurence_RecurrenceFrequencyCount").val($("#RecurrenceFrequencyCountDaily").val());break;case"Weekly":for(f="Recur every week on ",t=0;t<n;t++)r="#DaysOfWeeks_"+t+"__IsSelected",u="DaysOfWeeks_"+t+"__IsSelected",$(r).prop("checked")&&(f+=$("label[for='"+u+"']").text()+", ");$("#ServiceScheduleReccurence_SelectedWeekDays").val("");$("#myModal input[type=checkbox]").each(function(){$($(this)).prop("checked")&&$("#ServiceScheduleReccurence_SelectedWeekDays").val($("#ServiceScheduleReccurence_SelectedWeekDays").val()+$("#"+$(this).attr("id").replace("IsSelected","ID")).val()+",")});$("#ServiceScheduleReccurence_RecurrenceFrequencyCount").val($("#RecurrenceFrequencyCountWeekly").val());break;case"Monthly":f="Recur on day "+$("#ServiceScheduleReccurence_RecurrenceDayMonthly").val()+" of every month";$("#ServiceScheduleReccurence_RecurrenceFrequencyCount").val($("#RecurrenceFrequencyCountMonthly").val());break;case"Yearly":f="Recur every year in "+$("#ServiceScheduleReccurence_SelectedMonth  option:selected").text()+", day "+$("#ServiceScheduleReccurence_RecurrenceDayYearly").val();$("#ServiceScheduleReccurence_RecurrenceFrequencyCount").val($("#RecurrenceFrequencyCountYearly").val())}i!=="None"&&(e=new Date($("#ServiceScheduleReccurence_RecurrenceEndDate").val()),o=kendo.format("{0:d}",e),f+=" until "+o);$("#RecurrenceText1").text(f);$("#ServiceScheduleReccurence_RecurrenceText").val(f)});$("#ServiceScheduleReccurence_RecurrenceDayMonthly").bind("input",function(){t(this);$(this).val()&&Number($(this).val())>28?($("#SelectedMonthMaxDay2").text($(this).val()),$("#DayValidationWarningMessage").show(),$("#validation-warning").show()):r()});$("#ServiceScheduleReccurence_RecurrenceDayMonthly").bind("change",function(){t(this)});$("#ServiceScheduleReccurence_RecurrenceDay").bind("change",function(){t(this)});$("#RecurrenceTypeSelection input[type=radio]").bind("change",function(){$("#None").show();$("#Daily").hide();$("#Weekly1").hide();$("#Day1Monthly").hide();$("#Yearly1").hide();i($(this).val());$("#WeeklyDayRequiredValidation").hide();$("#DayValidationMessage").hide();$("#validation-message").hide();$("#validation-warning").hide();$("#YearlyRecurEveryRequiredValidation").hide();$("#YearlyRecurEveryMaxValidation").hide();$("#YearlyRecurEveryMinValidation").hide()})})}var t=function(n){var t=parseInt($(n).attr("max")),i=parseInt($(n).attr("min"));$(n).val()>t?$(n).val(t):$(n).val()<i&&$(n).val(i)},i=function(n){switch(n.toString()){case"None":$("#None").show();$("#RecurrenceEndDateRow").hide();break;case"Daily":$("#Daily").toggle();$("#None").hide();$("#RecurrenceEndDateRow").show();break;case"Weekly":$("#Weekly1").toggle();$("#None").hide();$("#RecurrenceEndDateRow").show();break;case"Monthly":$("#Day1Monthly").toggle();$("#None").hide();$("#RecurrenceEndDateRow").show();break;case"Yearly":$("#Yearly1").toggle();$("#None").hide();$("#RecurrenceEndDateRow").show()}},r=function(){$("#DayValidationMessage").hide();$("#validation-message").hide();$("#YearDayRequiredValidation").hide();$("#MonthDayRequiredValidation").hide();$("#WeeklyDayRequiredValidation").hide();$("#DayValidationWarningMessage").hide();$("#validation-warning").hide();$("#YearlyRecurEveryRequiredValidation").hide();$("#YearlyRecurEveryMaxValidation").hide();$("#YearlyRecurEveryMinValidation").hide()},u=function(){if($("#Daily").hide(),$("#Weekly1").hide(),$("#Day1Monthly").hide(),$("#Yearly1").hide(),$("#RecurrenceEndDateRow").hide(),$("input[name='ServiceScheduleReccurence.RecurrenceType']:checked")&&$("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val()){var n="";$("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val().length===0?n="":(n=$("#ServiceScheduleReccurence_RecurrenceText").val(),i($("input[name='ServiceScheduleReccurence.RecurrenceType']:checked").val()));$("#RecurrenceText1").text(n)}};n.initRecurrence=f}(ServiceScheduleRecurrence||(ServiceScheduleRecurrence={})),function(n){function r(n,t){var i=function(){hideConfirmationModal();var t=$("#delete_"+n).parents("tr");t.remove()},r={id:n};execAjax("POST",t+"/"+n,r,"","",i,"","","")}function t(n,t){$("#client-selection").hide();var i=[];t!=null&&t.forEach(function(n){i.push({id:n.Value,text:n.Text})});$("input[name=SelectedActivity]:checked").val()==="GroupActivity"&&($("#client-selection").show(),$("#clienthiddenfield").select2({multiple:!0,allowClear:!0,placeholder:"Select Client",minimumInputLength:0,ajax:{url:n,dataType:"JSON",quietMillis:50,data:function(n){return{searchTerm:n}},results:function(n){return{results:n.map(function(n){return{id:n.Id,text:n.Name}})}}}}).select2("data",i))}function u(n,r,u,e){$("#categoryTypeDrowdown").select2();$("#typeOfServiceDropDown").select2();i=e;$("#service-type-id").val()>0&&$("#selectedActivity :input").prop({readonly:"readonly",disabled:"disabled"});var o=$("#typeOfServiceDropDown").val();o!=0&&$("#typeOfServiceDropDown").attr("disabled","disabled");$(".activity-radio-button").click(function(){t(n,r)});t(n,r);f();u=="True"&&($("#service-type-form :input").attr("disabled","disabled"),$("#clienthiddenfield").select2("enable",!1))}function f(){$("#typeOfServiceDropDown").on("change",function(){$("#typeOfService").val($("#typeOfServiceDropDown").val())})}var i;n.onConfirmation=r;n.initServiceTypeEdit=u}(ServiceType||(ServiceType={})),function(n){function f(n,t,i,u,f){r=new Permissions(n,t,i,u,f)}function e(n,t,r,u,f,e,o,s){i=new ActionUrls(n,t,r,u,f,e,o,s)}function o(n){var t="";return r.viewPermission&&(t+=KendoGridActionButtonHelper.generateViewLink(i.viewUrl+"?supportProgramId="+n.toString())),t}function s(n){u=n;ControlsHelper.disableInputs($("#program-configuration"));$("#back-btn").show();$(document).ready(function(){$("#save").on("click",function(n){n.preventDefault();h()})})}function h(){c()}function c(){var n=$("#program-id").val(),r=$("#ndis-id"),f=$("#clientFunded-id"),e=$("#nominee-id"),o=$("#planManaged-id"),s=$("#orgFunded-id"),h={Id:n,OrganisationId:$("#organisation-id").val(),Name:$("#support-program-name").val(),HasSupportPurpose:$("#support-category").is(":checked"),HasSupportCategory:$("#support-purposes").is(":checked"),SupportProgramBillerType:[new t(r.val()!=null?r.val():0,n,10,$("#ndis").is(":checked")),new t(f.val()!=null?f.val():0,n,20,$("#clientfunded").is(":checked")),new t(e.val()!=null?e.val():0,n,30,$("#nominee").is(":checked")),new t(o.val()!=null?o.val():0,n,40,$("#planmanaged").is(":checked")),new t(s.val()!=null?s.val():0,n,35,$("#organisationfunded").is(":checked"))]},c=function(){window.location.href=u};execAjax("POST",i.editUrl,JSON.stringify(h),"application/json","",c,"","","")}var r,i,u,t;n.setPermissions=f;n.setActionUrls=e;n.renderActions=o;n.initSupportProgramEdit=s;t=function(){function n(n,t,i,r){this.Id=n;this.SupportProgramId=t;this.BillerType=i;this.Checked=r}return n}()}(SupportPrograms||(SupportPrograms={}))