-
Notifications
You must be signed in to change notification settings - Fork 2
/
bookingbug-angular-member.min.js
2 lines (2 loc) · 55 KB
/
bookingbug-angular-member.min.js
1
2
(function(){"use strict";angular.module("BBMember").config(["$logProvider",function($logProvider){"ngInject";$logProvider.debugEnabled(!0)}])}).call(this),function(){"use strict";angular.module("BBMember",["BB","BBMember.Directives","BBMember.Services","BBMember.Filters","BBMember.Controllers","BBMember.Models","trNgGrid","pascalprecht.translate"]),angular.module("BBMember.Directives",[]),angular.module("BBMember.Filters",[]),angular.module("BBMember.Models",[]),angular.module("BBMember.Services",["ngResource","ngSanitize"]),angular.module("BBMember.Controllers",["ngSanitize"]),angular.module("BBMemberMockE2E",["BBMember","BBAdminMockE2E"])}.call(this),function(){"use strict";angular.module("BBMember").run(["$q","$injector","BBModel",function($q,$injector,BBModel){"ngInject";var i,len,mfuncs,model,models;for(TrNgGrid.defaultColumnOptions.enableFiltering=!1,models=["Member","Booking","Wallet","WalletLog","Purchase","PurchaseItem","WalletPurchaseBand","PaymentItem"],mfuncs={},i=0,len=models.length;len>i;i++)model=models[i],mfuncs[model]=$injector.get("Member."+model+"Model");BBModel.Member=mfuncs}])}.call(this),function(){angular.module("BBMember").directive("bbMemberBooking",function(){return{templateUrl:"_member_booking.html",scope:{booking:"=bbMemberBooking"},require:["^?bbMemberUpcomingBookings","^?bbMemberPastBookings"],link:function(scope,element,attrs,controllers){var member_booking_controller,time_now;return scope.actions=[],member_booking_controller=controllers[0]?controllers[0]:controllers[1],time_now=moment(),scope.booking.on_waitlist&&!scope.booking.datetime.isBefore(time_now,"day")&&scope.actions.push({action:member_booking_controller.book,label:"Book",translation_key:"MEMBER_BOOKING_WAITLIST_ACCEPT",disabled:!scope.booking.settings.sent_waitlist}),scope.booking.paid<scope.booking.price&&scope.booking.datetime.isAfter(time_now)&&scope.actions.push({action:member_booking_controller.pay,label:"Pay"}),scope.actions.push({action:member_booking_controller.edit,label:"Details",translation_key:"MEMBER_BOOKING_EDIT"}),scope.booking.datetime.isBefore(time_now,"day")?void 0:scope.actions.push({action:member_booking_controller.cancel,label:"Cancel",translation_key:"MEMBER_BOOKING_CANCEL"})}}})}.call(this),function(){angular.module("BBMember").directive("memberBookings",["$rootScope",function($rootScope){return{templateUrl:"member_bookings_tabs.html",scope:{member:"="},link:function(scope,element,attrs){}}}])}.call(this),function(){angular.module("BBMember").directive("memberBookingsTable",["$uibModal","$log","ModalForm","BBModel",function($uibModal,$log,ModalForm,BBModel){var controller;return controller=function($scope,$uibModal,$document){var getBookings;return $scope.loading=!0,$scope.fields||($scope.fields=["date_order","details"]),$scope.$watch("member",function(member){return null!=member?getBookings($scope,member):void 0}),$scope.edit=function(id){var booking;return booking=_.find($scope.booking_models,function(b){return b.id===id}),booking.$getAnswers().then(function(answers){var answer,j,len,ref;for(ref=answers.answers,j=0,len=ref.length;len>j;j++)answer=ref[j],booking["question"+answer.question_id]=answer.value;return ModalForm.edit({model:booking,title:"Booking Details",templateUrl:"edit_booking_modal_form.html",success:function(b){var i;return b=new BBModel.Member.Booking(b),i=_.indexOf($scope.booking_models,function(b){return b.id===id}),$scope.booking_models[i]=b,$scope.setRows()}})})},$scope.cancel=function(id){var booking,modalInstance;return booking=_.find($scope.booking_models,function(b){return b.id===id}),modalInstance=$uibModal.open({templateUrl:"member_bookings_table_cancel_booking.html",controller:["$scope","$uibModalInstance","booking",function($scope,$uibModalInstance,booking){return $scope.booking=booking,$scope.booking.notify=!0,$scope.ok=function(){return $uibModalInstance.close($scope.booking)},$scope.close=function(){return $uibModalInstance.dismiss()}}],scope:$scope,resolve:{booking:function(){return booking}}}),modalInstance.result.then(function(booking){var params;return $scope.loading=!0,params={notify:booking.notify},booking.$post("cancel",params).then(function(){var i;return i=_.findIndex($scope.booking_models,function(b){return b.id===booking.id}),$scope.booking_models.splice(i,1),$scope.setRows(),$scope.loading=!1})})},$scope.setRows=function(){return $scope.bookings=_.map($scope.booking_models,function(booking){return{id:booking.id,date:moment(booking.datetime).format("YYYY-MM-DD"),date_order:moment(booking.datetime).format("x"),datetime:moment(booking.datetime),details:booking.full_describe}})},getBookings=function($scope,member){var params;return params={src:member,start_date:$scope.startDate.format("YYYY-MM-DD"),start_time:$scope.startTime?$scope.startTime.format("HH:mm"):void 0,end_date:$scope.endDate?$scope.endDate.format("YYYY-MM-DD"):void 0,end_time:$scope.endTime?$scope.endTime.format("HH:mm"):void 0},BBModel.Member.Booking.$query(member,params).then(function(bookings){var now;return now=moment.unix(),$scope.period&&"past"===$scope.period&&($scope.booking_models=_.filter(bookings.items,function(x){return x.datetime.unix()<now})),$scope.period&&"future"===$scope.period?$scope.booking_models=_.filter(bookings.items,function(x){return x.datetime.unix()>now}):$scope.booking_models=bookings.items,$scope.setRows(),$scope.loading=!1},function(err){return $log.error(err.data),$scope.loading=!1})},$scope.startDate||($scope.startDate=moment()),$scope.orderBy=$scope.defaultOrder,null==$scope.orderBy&&($scope.orderBy="date_order"),$scope.now=moment(),$scope.member?getBookings($scope,$scope.member):void 0},{controller:controller,templateUrl:"member_bookings_table.html",scope:{apiUrl:"@",fields:"=?",member:"=",startDate:"=?",startTime:"=?",endDate:"=?",endTime:"=?",defaultOrder:"=?",period:"=?"}}}])}.call(this),function(){angular.module("BBMember").directive("memberForm",["$rootScope","AlertService","PathSvc",function($rootScope,AlertService,PathSvc){return{templateUrl:function(el,attrs){return null!=attrs.bbCustomMemberForm?PathSvc.directivePartial("_member_form"):PathSvc.directivePartial("_member_schema_form")},scope:{apiUrl:"@",member:"=",onSuccessSave:"=",onFailSave:"=",onValidationError:"="},link:function(scope,element,attrs){var base,base1;return $rootScope.bb||($rootScope.bb={}),(base=$rootScope.bb).api_url||(base.api_url=attrs.apiUrl),(base1=$rootScope.bb).api_url||(base1.api_url="http://www.bookingbug.com"),null!=attrs.bbCustomMemberForm?scope.custom_member_form=!0:void 0},controller:["$scope","FormTransform",function($scope,FormTransform){var checkSchema,functionName;return $scope.loading=!0,checkSchema=function(schema){var base,base1,base2,base3,k,name,name1,ref,v,vals;ref=schema.properties;for(k in ref)v=ref[k],vals=k.split("."),"questions"===vals[0]&&vals.length>1&&((base=schema.properties).questions||(base.questions={type:"object",properties:{}}),(base1=schema.properties.questions.properties)[name=vals[1]]||(base1[name]={type:"object",properties:{answer:v}})),"client"===vals[0]&&vals.length>2&&((base2=schema.properties).client||(base2.client={type:"object",properties:{q:{type:"object",properties:{}}}}),schema.properties.client.properties&&((base3=schema.properties.client.properties.q.properties)[name1=vals[2]]||(base3[name1]={type:"object",properties:{answer:v}})));return schema},$scope.$watch("member",function(member){if(null!=member){if(member.$has("edit_member"))return member.$get("edit_member").then(function(member_schema){var model_type;return $scope.form=member_schema.form,model_type=functionName(member.constructor),FormTransform.edit[model_type]&&($scope.form=FormTransform.edit[model_type]($scope.form,member_schema.schema,member)),$scope.schema=checkSchema(member_schema.schema),$scope.loading=!1});if(member.$has("edit"))return member.$get("edit").then(function(member_schema){var model_type;return $scope.form=member_schema.form,model_type=functionName(member.constructor),FormTransform.edit[model_type]&&($scope.form=FormTransform.edit[model_type]($scope.form,member_schema.schema,member)),$scope.schema=checkSchema(member_schema.schema),$scope.loading=!1})}}),functionName=function(func){var result;return result=/^function\s+([\w\$]+)\s*\(/.exec(func.toString()),result?result[1]:""},$scope.submit=function(form,data){var i,item,len,ref;if($scope.$broadcast("schemaFormValidate"),form.$valid){if($scope.loading=!0,!$scope.custom_member_form)for(ref=data.questions,i=0,len=ref.length;len>i;i++)item=ref[i],item.answer=data.q[item.id].answer;return $scope.member.$put("self",{},data).then(function(member){return $scope.loading=!1,AlertService.raise("UPDATE_SUCCESS"),"function"==typeof $scope.onSuccessSave?$scope.onSuccessSave():void 0},function(err){return $scope.loading=!1,AlertService.raise("UPDATE_FAILED"),"function"==typeof $scope.onFailSave?$scope.onFailSave():void 0})}return"function"==typeof $scope.onValidationError?$scope.onValidationError():void 0}}]}}])}.call(this),function(){angular.module("BBMember").directive("loginMember",["$uibModal","$document","$log","$rootScope","MemberLoginService","$templateCache","$q","$sessionStorage","halClient",function($uibModal,$document,$log,$rootScope,MemberLoginService,$templateCache,$q,$sessionStorage,halClient){var link,loginMemberController,pickCompanyController;return loginMemberController=function($scope,$uibModalInstance,company_id){return $scope.title="Login",$scope.schema={type:"object",properties:{email:{type:"string",title:"Email"},password:{type:"string",title:"Password"}}},$scope.form=[{key:"email",type:"email",feedback:!1,autofocus:!0},{key:"password",type:"password",feedback:!1}],$scope.login_form={},$scope.submit=function(form){var options;return options={company_id:company_id},MemberLoginService.login(form,options).then(function(member){return member.email=form.email,member.password=form.password,$uibModalInstance.close(member)},function(err){return $uibModalInstance.dismiss(err)})},$scope.cancel=function(){return $uibModalInstance.dismiss("cancel")}},pickCompanyController=function($scope,$uibModalInstance,companies){var c;return $scope.title="Pick Company",$scope.schema={type:"object",properties:{company_id:{type:"integer",title:"Company"}}},$scope.schema.properties.company_id["enum"]=function(){var i,len,results;for(results=[],i=0,len=companies.length;len>i;i++)c=companies[i],results.push(c.id);return results}(),$scope.form=[{key:"company_id",type:"select",titleMap:function(){var i,len,results;for(results=[],i=0,len=companies.length;len>i;i++)c=companies[i],results.push({value:c.id,name:c.name});return results}(),autofocus:!0}],$scope.pick_company_form={},$scope.submit=function(form){return $uibModalInstance.close(form.company_id)},$scope.cancel=function(){return $uibModalInstance.dismiss("cancel")}},link=function(scope,element,attrs){var base,base1,loginModal,pickCompanyModal,session_member,tryLogin;return $rootScope.bb||($rootScope.bb={}),(base=$rootScope.bb).api_url||(base.api_url=scope.apiUrl),(base1=$rootScope.bb).api_url||(base1.api_url="http://www.bookingbug.com"),loginModal=function(){var modalInstance;return modalInstance=$uibModal.open({templateUrl:"login_modal_form.html",controller:loginMemberController,resolve:{company_id:function(){return scope.companyId}}}),modalInstance.result.then(function(result){return scope.memberEmail=result.email,scope.memberPassword=result.password,result.$has("members")?result.$get("members").then(function(members){var m;return scope.members=members,$q.all(function(){var i,len,results;for(results=[],i=0,len=members.length;len>i;i++)m=members[i],results.push(m.$get("company"));return results}()).then(function(companies){return pickCompanyModal(companies)})}):scope.member=result},function(){return loginModal()})},pickCompanyModal=function(companies){var modalInstance;return modalInstance=$uibModal.open({templateUrl:"pick_company_modal_form.html",controller:pickCompanyController,resolve:{companies:function(){return companies}}}),modalInstance.result.then(function(company_id){return scope.companyId=company_id,tryLogin()},function(){return pickCompanyModal()})},tryLogin=function(){var login_form,options;return login_form={email:scope.memberEmail,password:scope.memberPassword},options={company_id:scope.companyId},MemberLoginService.login(login_form,options).then(function(result){return result.$has("members")?result.$get("members").then(function(members){var m;return scope.members=members,$q.all(function(){var i,len,results;for(results=[],i=0,len=members.length;len>i;i++)m=members[i],results.push(m.$get("company"));return results}()).then(function(companies){return pickCompanyModal(companies)})}):scope.member=result},function(err){return loginModal()})},scope.memberEmail&&scope.memberPassword?tryLogin():$sessionStorage.getItem("login")?(session_member=$sessionStorage.getItem("login"),session_member=halClient.createResource(session_member),scope.member=session_member):loginModal()},{link:link,scope:{memberEmail:"@",memberPassword:"@",companyId:"@",apiUrl:"@",member:"="},transclude:!0,template:"<div ng-show='member' ng-transclude></div>"}}])}.call(this),function(){angular.module("BBMember").directive("bbMemberPastBookings",["$rootScope","PaginationService",function($rootScope,PaginationService){return{templateUrl:"member_past_bookings.html",scope:{member:"=",notLoaded:"=",setLoaded:"="},controller:"MemberBookings",link:function(scope,element,attrs){var getBookings;return scope.pagination=PaginationService.initialise({page_size:10,max_size:5}),getBookings=function(){return scope.getPastBookings().then(function(past_bookings){return past_bookings?PaginationService.update(scope.pagination,past_bookings.length):void 0})},scope.$watch("member",function(){return scope.member&&!scope.past_bookings?getBookings():void 0}),scope.member?getBookings():void 0}}}])}.call(this),function(){angular.module("BBMember").directive("bbMemberPrePaidBookings",["$rootScope","PaginationService",function($rootScope,PaginationService){return{templateUrl:"member_pre_paid_bookings.html",scope:{member:"="},controller:"MemberBookings",link:function(scope,element,attrs){var getBookings;return scope.pagination=PaginationService.initialise({page_size:10,max_size:5}),getBookings=function(){return scope.getPrePaidBookings({}).then(function(pre_paid_bookings){return PaginationService.update(scope.pagination,pre_paid_bookings.length)})},scope.$watch("member",function(){return scope.pre_paid_bookings?void 0:getBookings()}),scope.$on("booking:cancelled",function(event){return scope.getPrePaidBookings({}).then(function(pre_paid_bookings){return PaginationService.update(scope.pagination,pre_paid_bookings.length)})}),scope.member?getBookings():void 0}}}])}.call(this),function(){angular.module("BBMember").directive("bbMemberPurchases",["$rootScope","PaginationService",function($rootScope,PaginationService){return{templateUrl:"member_purchases.html",scope:!0,controller:"MemberPurchases",link:function(scope,element,attrs){return scope.member=scope.$eval(attrs.member),$rootScope.member&&(scope.member||(scope.member=$rootScope.member)),scope.pagination=PaginationService.initialise({page_size:10,max_size:5}),$rootScope.connection_started.then(function(){return scope.member?scope.getPurchases().then(function(purchases){return PaginationService.update(scope.pagination,purchases.length)}):void 0})}}}])}.call(this),function(){angular.module("BBMember").directive("memberSsoLogin",["$rootScope","LoginService","$sniffer","$timeout","QueryStringService",function($rootScope,LoginService,$sniffer,$timeout,QueryStringService){return{scope:{token:"@memberSsoLogin",company_id:"@companyId"},transclude:!0,template:"<div ng-if='member' ng-transclude></div>",link:function(scope,element,attrs){var data,options;return options={root:$rootScope.bb.api_url,company_id:scope.company_id},data={},scope.token&&(data.token=scope.token),data.token||(data.token=QueryStringService("sso_token")),$sniffer.msie&&$sniffer.msie<10&&$rootScope.iframe_proxy_ready===!1?$timeout(function(){return LoginService.ssoLogin(options,data).then(function(member){return scope.member=member})},2e3):LoginService.ssoLogin(options,data).then(function(member){return scope.member=member})}}}])}.call(this),function(){angular.module("BBMember").directive("bbMemberUpcomingBookings",["$rootScope","PaginationService","PurchaseService",function($rootScope,PaginationService,PurchaseService){return{templateUrl:"member_upcoming_bookings.html",scope:{member:"=",notLoaded:"=",setLoaded:"="},controller:"MemberBookings",link:function(scope,element,attrs){var getBookings;return scope.pagination=PaginationService.initialise({page_size:10,max_size:5}),getBookings=function(){return scope.getUpcomingBookings().then(function(upcoming_bookings){return PaginationService.update(scope.pagination,upcoming_bookings.length)})},scope.$on("updateBookings",function(){return scope.flushBookings(),getBookings()}),scope.$watch("member",function(){return scope.upcoming_bookings?void 0:getBookings()}),$rootScope.connection_started.then(function(){return getBookings()})}}}])}.call(this),function(){angular.module("BBMember").directive("bbWallet",["$rootScope",function($rootScope){return{scope:!0,controller:"Wallet",templateUrl:"wallet.html",link:function(scope,element,attrs){return scope.member=scope.$eval(attrs.member),$rootScope.member&&(scope.member||(scope.member=$rootScope.member)),scope.show_wallet_logs=!0,scope.show_topup_box=!1,$rootScope.connection_started.then(function(){return scope.member?scope.getWalletForMember(scope.member):void 0}),scope.$on("wallet:topped_up",function(event,wallet){return scope.wallet=wallet,scope.show_topup_box=!1,scope.show_wallet_logs=!0}),scope.$on("booking:cancelled",function(event){return scope.member?scope.getWalletForMember(scope.member):void 0})}}}])}.call(this),function(){angular.module("BBMember").directive("bbWalletLogs",["$rootScope","PaginationService",function($rootScope,PaginationService){return{templateUrl:"wallet_logs.html",scope:!0,controller:"Wallet",require:"^?bbWallet",link:function(scope,element,attrs,ctrl){var getWalletLogs;return scope.member=scope.$eval(attrs.member),$rootScope.member&&(scope.member||(scope.member=$rootScope.member)),scope.pagination=PaginationService.initialise({page_size:10,max_size:5}),getWalletLogs=function(){return scope.getWalletLogs().then(function(logs){return PaginationService.update(scope.pagination,logs.length)})},scope.$on("wallet:topped_up",function(event){return getWalletLogs()}),$rootScope.connection_started.then(function(){var deregisterWatch;return ctrl?deregisterWatch=scope.$watch("wallet",function(){return scope.wallet?(getWalletLogs(),deregisterWatch()):void 0}):scope.getWalletForMember(scope.member).then(function(){return getWalletLogs()})})}}}])}.call(this),function(){angular.module("BB.Directives").directive("bbWalletPayment",["$sce","$rootScope","$window","$location","GeneralOptions","AlertService",function($sce,$rootScope,$window,$location,GeneralOptions,AlertService){return{restrict:"A",controller:"Wallet",scope:!0,replace:!0,require:"^?bbWallet",link:function(scope,element,attrs,ctrl){var calculateAmount,getHost,one_pound,sendLoadEvent;return one_pound=100,scope.wallet_payment_options=scope.$eval(attrs.bbWalletPayment)||{},scope.member=scope.$eval(attrs.member),$rootScope.member&&(scope.member||(scope.member=$rootScope.member)),scope.wallet_payment_options.member&&(scope.member||(scope.member=scope.wallet_payment_options.member)),scope.amount_increment=scope.wallet_payment_options.amount_increment||one_pound,getHost=function(url){var a;return a=document.createElement("a"),a.href=url,a.protocol+"//"+a.host},sendLoadEvent=function(element,origin,scope){var custom_partial_url,custom_stylesheet,payload,referrer;return referrer=$location.protocol()+"://"+$location.host(),$location.port()&&(referrer+=":"+$location.port()),custom_stylesheet=scope.wallet_payment_options.custom_stylesheet?scope.wallet_payment_options.custom_stylesheet:null,custom_partial_url=scope.bb&&scope.bb.custom_partial_url?scope.bb.custom_partial_url:null,payload=JSON.stringify({type:"load",message:referrer,custom_partial_url:custom_partial_url,custom_stylesheet:custom_stylesheet,scroll_offset:GeneralOptions.scroll_offset}),element.find("iframe")[0].contentWindow.postMessage(payload,origin)},calculateAmount=function(){var amount_due;return scope.wallet_payment_options.basket_topup?(amount_due=scope.bb.basket.dueTotal()-scope.wallet.amount,amount_due>scope.wallet.min_amount?scope.amount=Math.ceil(amount_due/scope.amount_increment)*scope.amount_increment:scope.amount=scope.wallet.min_amount,scope.min_amount=scope.amount):scope.wallet.min_amount?(scope.amount=scope.wallet_payment_options.amount&&scope.wallet_payment_options.amount>scope.wallet.min_amount?scope.wallet_payment_options.amount:scope.wallet.min_amount,scope.min_amount=scope.wallet.min_amount):(scope.min_amount=0,scope.wallet_payment_options.amount?scope.amount=scope.wallet_payment_options.amount:void 0)},$rootScope.connection_started.then(function(){var deregisterWatch;return ctrl?deregisterWatch=scope.$watch("wallet",function(){return scope.wallet?(calculateAmount(),deregisterWatch()):void 0}):scope.getWalletForMember(scope.member).then(function(){return calculateAmount()})}),scope.$on("wallet:updated",function(event,wallet,band){return null==band&&(band=null),wallet.$has("new_payment")?(scope.notLoaded(scope),band&&(scope.amount=band.actual_amount),scope.wallet_payment_url=$sce.trustAsResourceUrl(wallet.$href("new_payment")),scope.show_payment_iframe=!0,element.find("iframe").bind("load",function(_this){return function(event){var origin,url;return scope.wallet_payment_url&&(url=scope.wallet_payment_url),origin=getHost(url),sendLoadEvent(element,origin,scope),scope.$apply(function(){return scope.setLoaded(scope)})}}(this))):void 0}),$window.addEventListener("message",function(_this){return function(event){var data;return angular.isObject(event.data)?data=event.data:event.data.match(/iFrameSizer/)||(data=JSON.parse(event.data)),scope.$apply(function(){if(data)switch(data.type){case"submitting":return scope.notLoaded(scope);case"error":return $rootScope.$broadcast("wallet:topup_failed"),scope.notLoaded(scope),document.getElementsByTagName("iframe")[0].src+="",AlertService.raise("PAYMENT_FAILED");case"payment_complete":case"wallet_payment_complete":case"basket_wallet_payment_complete":return scope.show_payment_iframe=!1,scope.wallet_payment_options.basket_topup?scope.basketWalletPaymentDone():scope.walletPaymentDone()}})}}(this),!1)}}}])}.call(this),function(){angular.module("BB.Directives").directive("bbWalletPurchaseBands",["$rootScope",function($rootScope){return{scope:!0,restrict:"AE",templateUrl:"wallet_purchase_bands.html",controller:"Wallet",require:"^?bbWallet",link:function(scope,attr,elem,ctrl){return scope.member=scope.$eval(attr.member),$rootScope.member&&(scope.member||(scope.member=$rootScope.member)),$rootScope.connection_started.then(function(){var deregisterWatch;return ctrl?deregisterWatch=scope.$watch("wallet",function(){return scope.wallet?(scope.getWalletPurchaseBandsForWallet(scope.wallet),deregisterWatch()):void 0}):scope.getWalletForMember(scope.member).then(function(){return scope.getWalletPurchaseBandsForWallet(scope.wallet)})})}}}])}.call(this),function(){"use strict";angular.module("BBMember").controller("MemberBookings",["$scope","$uibModal","$document","$log","$q","ModalForm","$rootScope","AlertService","PurchaseService","LoadingService","BBModel",function($scope,$uibModal,$document,$log,$q,ModalForm,$rootScope,AlertService,PurchaseService,LoadingService,BBModel){var bookWaitlistSucces,getBookings,loader,openPaymentModal,updateBookings;return loader=LoadingService.$loader($scope),$scope.getUpcomingBookings=function(){var defer,now,params;return defer=$q.defer(),now=moment(),params={start_date:now.toISODate()},getBookings(params).then(function(results){return $scope.upcoming_bookings=_.filter(results,function(result){return result.datetime.isAfter(now)}),defer.resolve($scope.upcoming_bookings)},function(err){return defer.reject([])}),defer.promise},$scope.getPastBookings=function(num,type){var date,defer,params;return defer=$q.defer(),date=num&&type?moment().subtract(num,type):moment().subtract(1,"year"),params={start_date:date.format("YYYY-MM-DD"),end_date:moment().add(1,"day").format("YYYY-MM-DD")},getBookings(params).then(function(past_bookings){return $scope.past_bookings=_.chain(past_bookings).filter(function(b){return b.datetime.isBefore(moment())}).sortBy(function(b){return-b.datetime.unix()}).value(),defer.resolve(past_bookings)},function(err){return defer.reject([])}),defer.promise},$scope.flushBookings=function(){var params;return params={start_date:moment().format("YYYY-MM-DD")},$scope.member.$flush("bookings",params)},updateBookings=function(){return $scope.getUpcomingBookings()},getBookings=function(params){var defer;return loader.notLoaded(),defer=$q.defer(),$scope.member.getBookings(params).then(function(bookings){return loader.setLoaded(),defer.resolve(bookings)},function(err){return $log.error(err.data),loader.setLoaded()}),defer.promise},$scope.cancelBooking=function(booking){var index;return index=_.indexOf($scope.upcoming_bookings,booking),_.without($scope.upcoming_bookings,booking),BBModel.Member.Booking.$cancel($scope.member,booking).then(function(){return AlertService.raise("BOOKING_CANCELLED"),$rootScope.$broadcast("booking:cancelled"),$scope.removeBooking?$scope.removeBooking(booking):void 0},function(err){return AlertService.raise("GENERIC"),$scope.upcoming_bookings.splice(index,0,booking)})},$scope.getPrePaidBookings=function(params){var defer;return defer=$q.defer(),$scope.member.$getPrePaidBookings(params).then(function(bookings){return $scope.pre_paid_bookings=bookings,defer.resolve(bookings)},function(err){return defer.reject([]),$log.error(err.data)}),defer.promise},bookWaitlistSucces=function(){return AlertService.raise("WAITLIST_ACCEPTED"),updateBookings()},openPaymentModal=function(booking,total){var modalInstance;return modalInstance=$uibModal.open({templateUrl:"booking_payment_modal.html",windowClass:"bbug",size:"lg",controller:["$scope","$uibModalInstance","booking","total",function($scope,$uibModalInstance,booking,total){return $scope.booking=booking,$scope.total=total,$scope.handlePaymentSuccess=function(){return $uibModalInstance.close(booking)},$scope.cancel=function(){return $uibModalInstance.dismiss("cancel")}}],resolve:{booking:function(){return booking},total:function(){return total}}}),modalInstance.result.then(function(booking){return bookWaitlistSucces()})},{edit:function(booking){return booking.$getAnswers().then(function(answers){var answer,i,len,ref;for(ref=answers.answers,i=0,len=ref.length;len>i;i++)answer=ref[i],booking["question"+answer.question_id]=answer.value;return ModalForm.edit({model:booking,title:"Booking Details",templateUrl:"edit_booking_modal_form.html",windowClass:"member_edit_booking_form",success:updateBookings})})},cancel:function(booking){var modalInstance;return modalInstance=$uibModal.open({templateUrl:"member_booking_delete_modal.html",windowClass:"bbug",controller:["$scope","$rootScope","$uibModalInstance","booking",function($scope,$rootScope,$uibModalInstance,booking){return $scope.booking=booking,$scope.confirm_delete=function(){return $uibModalInstance.close(booking)},$scope.cancel=function(){return $uibModalInstance.dismiss("cancel")}}],resolve:{booking:function(){return booking}}}),modalInstance.result.then(function(booking){return $scope.cancelBooking(booking)})},book:function(booking){var params;return loader.notLoaded(),params={purchase_id:booking.purchase_ref,url_root:$rootScope.bb.api_url,booking:booking},PurchaseService.bookWaitlistItem(params).then(function(purchase_total){return purchase_total.due_now>0?purchase_total.$has("new_payment")?openPaymentModal(booking,purchase_total):$log.error("total is missing new_payment link, this is usually caused by online payment not being configured correctly"):bookWaitlistSucces()},function(err){return AlertService.raise("NO_WAITLIST_SPACES_LEFT")}),loader.setLoaded()},pay:function(booking){var params;return params={url_root:$scope.$root.bb.api_url,purchase_id:booking.purchase_ref},PurchaseService.query(params).then(function(total){return openPaymentModal(booking,total)})}}}])}.call(this),function(){angular.module("BBMember").controller("MemberPurchases",["$scope","$q","$log","LoadingService","BBModel",function($scope,$q,$log,LoadingService,BBModel){return $scope.getPurchases=function(){var defer,loader;return loader=LoadingService.$loader($scope).notLoaded(),defer=$q.defer(),BBModel.Member.Purchase.$query($scope.member,{}).then(function(purchases){return $scope.purchases=purchases,loader.setLoaded(),defer.resolve(purchases)},function(err){return $log.error(err.data),loader.setLoaded(),defer.reject([])}),defer.promise}}])}.call(this),function(){angular.module("BBMember").controller("Wallet",["$scope","$rootScope","$q","$log","AlertService","LoadingService","BBModel",function($scope,$rootScope,$q,$log,AlertService,LoadingService,BBModel){var loader,updateClient;return loader=LoadingService.$loader($scope),$scope.getWalletForMember=function(member,params){var defer;return defer=$q.defer(),loader.notLoaded(),BBModel.Member.Wallet.$getWalletForMember(member,params).then(function(wallet){return loader.setLoaded(),$scope.wallet=wallet,updateClient(wallet),defer.resolve(wallet)},function(err){return loader.setLoaded(),defer.reject()}),defer.promise},$scope.getWalletLogs=function(){var defer;return defer=$q.defer(),loader.notLoaded(),BBModel.Member.Wallet.$getWalletLogs($scope.wallet).then(function(logs){return logs=_.sortBy(logs,function(log){return-moment(log.created_at).unix()}),loader.setLoaded(),$scope.logs=logs,defer.resolve(logs)},function(err){return loader.setLoaded(),$log.error(err.data),defer.reject([])}),defer.promise},$scope.getWalletPurchaseBandsForWallet=function(wallet){var defer;return defer=$q.defer(),loader.notLoaded(),BBModel.Member.Wallet.$getWalletPurchaseBandsForWallet(wallet).then(function(bands){return $scope.bands=bands,loader.setLoaded(),defer.resolve(bands)},function(err){return loader.setLoaded(),$log.error(err.data),defer.resolve([])}),defer.promise},$scope.createWalletForMember=function(member){return loader.notLoaded(),BBModel.Member.Wallet.$createWalletForMember(member).then(function(wallet){return loader.setLoaded(),$scope.wallet=wallet},function(err){return loader.setLoaded(),$log.error(err.data)})},$scope.updateWallet=function(member,amount,band){var params;return null==band&&(band=null),loader.notLoaded(),member?(params={},amount>0&&(params.amount=amount),$scope.wallet&&(params.wallet_id=$scope.wallet.id),$scope.total&&(params.total_id=$scope.total.id),$scope.deposit&&(params.deposit=$scope.deposit),$scope.basket&&(params.basket_total_price=$scope.basket.total_price),band&&(params.band_id=band.id),BBModel.Member.Wallet.$updateWalletForMember(member,params).then(function(wallet){return loader.setLoaded(),$scope.wallet=wallet,$rootScope.$broadcast("wallet:updated",wallet,band)},function(err){return loader.setLoaded(),$log.error(err.data)})):void 0},$scope.activateWallet=function(member){var params;return loader.notLoaded(),member?(params={status:1},$scope.wallet&&(params.wallet_id=$scope.wallet.id),BBModel.Member.Wallet.$updateWalletForMember(member,params).then(function(wallet){return loader.setLoaded(),$scope.wallet=wallet},function(err){return loader.setLoaded(),$log.error(err.date)})):void 0},$scope.deactivateWallet=function(member){var params;return loader.notLoaded(),member?(params={status:0},$scope.wallet&&(params.wallet_id=$scope.wallet.id),BBModel.Member.Wallet.$updateWalletForMember(member,params).then(function(wallet){return loader.setLoaded(),$scope.wallet=wallet},function(err){return loader.setLoaded(),$log.error(err.date)})):void 0},$scope.purchaseBand=function(band){return $scope.selected_band=band,
$scope.updateWallet($scope.member,band.wallet_amount,band)},$scope.walletPaymentDone=function(){return $scope.getWalletForMember($scope.member).then(function(wallet){return AlertService.raise("TOPUP_SUCCESS"),$rootScope.$broadcast("wallet:topped_up",wallet),$scope.wallet_topped_up=!0})},$scope.basketWalletPaymentDone=function(){return $scope.callSetLoaded(),$scope.decideNextPage("checkout")},$scope.error=function(message){return AlertService.warning("TOPUP_FAILED")},$scope.add=function(value){return value=value||$scope.amount_increment,$scope.amount+=value},$scope.subtract=function(value){return value=value||$scope.amount_increment,$scope.add(-value)},$scope.isSubtractValid=function(value){var new_amount;return $scope.wallet?(value=value||$scope.amount_increment,new_amount=$scope.amount-value,new_amount>=$scope.wallet.min_amount):!1},updateClient=function(wallet){return $scope.member.self===$scope.client.self?$scope.client.wallet_amount=wallet.amount:void 0}}])}.call(this),function(){"use strict";angular.module("BBMember").config(["$translateProvider",function($translateProvider){"ngInject";var translations;translations={MEMBER:{MODAL:{EDIT_BOOKING:{CANCEL_BTN:"@:COMMON.BTN.CANCEL",SAVE_BTN:"@:COMMON.BTN.SAVE"},LOGIN:{OK_BTN:"@:COMMON.BTN.OK",CANCEL_BTN:"@:COMMON.BTN.CANCEL"},DELETE_BOOKING:{TITLE:"@:COMMON.BTN.CANCEL_BOOKING",DESCRIPTION_LBL:"@:COMMON.TERMINOLOGY.BOOKING",WHEN_LBL:"@:COMMON.TERMINOLOGY.WHEN",CANCEL_BOOKING_BTN:"@:COMMON.BTN.CANCEL_BOOKING",CANCEL_BTN:"@:COMMON.BTN.DO_NOT_CANCEL_BOOKING"},BOOKINGS_TABLE_CANCEL_BOOKING:{TITLE:"@:COMMON.BTN.CANCEL_BOOKING",EMAIL_CUSTOMER_CHECKBOX_LBL:"Email customer?",CANCEL_BOOKING_BTN:"@:COMMON.BTN.CANCEL_BOOKING",CANCEL_BTN:"@:COMMON.BTN.DO_NOT_CANCEL_BOOKING"},PICK_COMPANY:{OK_BTN:"@:COMMON.BTN.OK",CANCEL_BTN:"@:COMMON.BTN.CANCEL"},BOOKING_PAYMENT:{DESCRIPTION:"Pay for your booking to confirm your place.",TIME_RANGE:"{{start}} - {{end}}",PAY_BTN:"@:COMMON.BTN.PAY"}},LOGIN:{EMAIL_LBL:"@:COMMON.TERMINOLOGY.EMAIL",EMAIL_PLACEHOLDER:"@:COMMON.TERMINOLOGY.EMAIL",PASSWORD_LBL:"@:COMMON.FORM.PASSWORD",PASSWORD_PLACEHOLDER:"@:COMMON.FORM.PASSWORD",LOGIN_BTN:"@:COMMON.BTN.LOGIN"},MEMBER_BOOKINGS_TABLE:{DETAILS_BTN:"@:COMMON.BTN.DETAILS",CANCEL_BTN:"@:COMMON.BTN.CANCEL"},BOOKING:{TOGGLE_DROPDOWN_BTN:"Toggle Dropdown"},BOOKING_TABS:{UPCOMING_BOOKINGS_TAB_HEADING:"Upcoming bookings",PAST_BOOKINGS_TAB_HEADING:"Past bookings",PURCHASES_TAB_HEADING:"Purchases"},MEMBER_PAST_BOOKINGS:{NO_PAST_BOOKINGS:"You don't currently have any past bookings."},PAST_BOOKINGS:{HEADING:"Past Bookings"},PREPAID_BOOKINGS:{NO_PREPAID_BOOKINGS:"You don't currently have any pre-paid bookings.",REMAINING_BOOKINGS:"{{remaining}} of {{total}} remaining",PREPAID_BOOKING_DATES:"Book By {{book_by}} | Use from {{use_from}} | Use by {{use_by}}"},PURCHASES:{YOUR_PURCHASES:"Your Purchases",NO_CURRENT_PURCHASES:"You don't currently have any purchases",PURCHASE_DATE_COL_HEADING:"Purchase Date",ITEMS_COL_HEADING:"Items",TOTAL_PRICE_COL_HEADING:"Total Price",LESS_DETAIL_BTN:"@:COMMON.BTN.LESS",MORE_DETAIL_BTN:"@:COMMON.BTN.MORE"},MEMBER_UPCOMING_BOOKINGS:{NO_UPCOMING_BOOKINGS:"You don't currently have any upcoming bookings.",ON_WAITLIST_HEADING:"On Waitlist",CONFIRMED_HEADING:"Confirmed"},UPCOMING_BOOKINGS:{HEADING:"Upcoming Bookings"},PICK_COMPANY:{DESCRIPTION:"Pick Company"},WAITLIST_PAYMENT:{DESCRIPTION:"Pay for your booking to confirm your place.",PAY_BTN:"@:COMMON.BTN.PAY"},WALLET:{BALANCE_LBL:"Balance:",WALLET_NO_CREDIT:"You don't have any credit in your wallet.",STATUS_LBL:"Status:",STATUS_INACTIVE:"Your wallet is not active.",STATUS_ACTIVE:"Active",ACTIVATE_BTN:"Activate",TOP_UP_BTN:"@:COMMON.BTN.TOP_UP",AMOUNT_LBL:"Amount",PAYMENT_IFRAME_HEADING:"Make Payment",TOP_UP_WALLET_BY:"Top up wallet by {{amount | currency}}",MIN_TOP_UP:"Minimum top up amount must be greater than {{min_amount | currency}}",TOPUP_AMOUNT_PLACEHOLDER:"Enter Top Up Amount"},WALLET_LOGS:{HEADING:"Wallet Transaction History",ACTION_COL_HEADING:"Action",AMOUNT_COL_HEADING:"Amount",BALANCE_COL_HEADING:"Balance",CHANGED_BY_COL_HEADING:"Changed By",DATE_TIME_COL_HEADING:"@:COMMON.TERMINOLOGY.DATE_TIME"},WALLET_PURCHASE_BANDS:{HEADING:"Wallet Purchase Bands",$X_FOR_$Y:"{{x | currency}} for {{y | currency}}",BUY_BTN:"@:COMMON.BTN.BUY"},PURCHASE_HISTORY:{HEADING:"Purchase History"}}},$translateProvider.translations("en",translations)}])}.call(this),function(){angular.module("BBMember.Services").factory("MemberBookingService",["$q","SpaceCollections","$rootScope","MemberService","BBModel",function($q,SpaceCollections,$rootScope,MemberService,BBModel){return{query:function(member,params){var deferred;return deferred=$q.defer(),params||(params={}),params.no_cache=!0,member.$has("bookings")?member.$get("bookings",params).then(function(_this){return function(bookings){var booking;return angular.isArray(bookings)?(bookings=function(){var i,len,results;for(results=[],i=0,len=bookings.length;len>i;i++)booking=bookings[i],results.push(new BBModel.Member.Booking(booking));return results}(),deferred.resolve(bookings)):(params.no_cache=!1,bookings.$get("bookings",params).then(function(bookings){return bookings=function(){var i,len,results;for(results=[],i=0,len=bookings.length;len>i;i++)booking=bookings[i],results.push(new BBModel.Member.Booking(booking));return results}(),deferred.resolve(bookings)},function(err){return deferred.reject(err)}))}}(this),function(err){return deferred.reject(err)}):deferred.reject("member does not have bookings"),deferred.promise},cancel:function(member,booking){var deferred;return deferred=$q.defer(),booking.$del("self").then(function(_this){return function(b){return booking.deleted=!0,b=new BBModel.Member.Booking(b),BBModel.Member.Member.$refresh(member).then(function(member){return member=member},function(err){}),deferred.resolve(b)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},update:function(booking){var deferred;return deferred=$q.defer(),booking.$put("self",{},booking).then(function(_this){return function(booking){var book;return book=new BBModel.Member.Booking(booking),SpaceCollections.checkItems(book),deferred.resolve(book)}}(this),function(_this){return function(err){return _.each(booking,function(value,key,booking){return"data"!==key&&"self"!==key?booking[key]=booking.data[key]:void 0}),deferred.reject(err,new BBModel.Member.Booking(booking))}}(this)),deferred.promise},flush:function(member,params){return member.$has("bookings")?member.$flush("bookings",params):void 0}}}])}.call(this),function(){angular.module("BBMember.Services").factory("MemberLoginService",["$q","$rootScope","$sessionStorage","halClient","BBModel",function($q,$rootScope,$sessionStorage,halClient,BBModel){return{login:function(form,options){var defer,url;return defer=$q.defer(),url=$rootScope.bb.api_url+"/api/v1/login",null!=options.company_id&&(url=url+"/member/"+options.company_id),halClient.$post(url,options,form).then(function(login){return login.$has("member")?login.$get("member").then(function(member){var auth_token;return member=new BBModel.Member.Member(member),auth_token=member._data.getOption("auth_token"),$sessionStorage.setItem("login",member.$toStore()),$sessionStorage.setItem("auth_token",auth_token),defer.resolve(member)}):login.$has("members")?defer.resolve(login):defer.reject("No member account for login")},function(_this){return function(err){var login;return 400===err.status?(login=halClient.$parse(err.data),login.$has("members")?defer.resolve(login):defer.reject(err)):defer.reject(err)}}(this)),defer.promise}}}])}.call(this),function(){angular.module("BBMember.Services").factory("MemberService",["$q","halClient","$rootScope","BBModel",function($q,halClient,$rootScope,BBModel){return{refresh:function(member){var deferred;return deferred=$q.defer(),member.$flush("self"),member.$get("self").then(function(_this){return function(member){return member=new BBModel.Member.Member(member),deferred.resolve(member)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},current:function(){var callback,deferred;return deferred=$q.defer(),callback=function(){return deferred.resolve($rootScope.member)},setTimeout(callback,200),deferred.promise},updateMember:function(member,params){var deferred;return deferred=$q.defer(),member.$put("self",{},params).then(function(_this){return function(member){return member=new BBModel.Member.Member(member),deferred.resolve(member)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},sendWelcomeEmail:function(member,params){var deferred;return deferred=$q.defer(),member.$post("send_welcome_email",params).then(function(_this){return function(member){return member=new BBModel.Member.Member(member),deferred.resolve(member)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){angular.module("BBMember.Services").factory("MemberPrePaidBookingService",["$q","BBModel",function($q,BBModel){return{query:function(member,params){var deferred;return deferred=$q.defer(),params||(params={}),params.no_cache=!0,member.$has("pre_paid_bookings")?member.$get("pre_paid_bookings",params).then(function(_this){return function(bookings){var booking;return angular.isArray(bookings)?(bookings=function(){var i,len,results;for(results=[],i=0,len=bookings.length;len>i;i++)booking=bookings[i],results.push(new BBModel.PrePaidBooking(booking));return results}(),deferred.resolve(bookings)):(params.no_cache=!1,bookings.$get("pre_paid_bookings",params).then(function(bookings){return bookings=function(){var i,len,results;for(results=[],i=0,len=bookings.length;len>i;i++)booking=bookings[i],results.push(new BBModel.PrePaidBooking(booking));return results}(),deferred.resolve(bookings)}))}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)):deferred.reject("member does not have pre paid bookings"),deferred.promise}}}])}.call(this),function(){angular.module("BBMember.Services").factory("MemberPurchaseService",["$q","$rootScope","BBModel",function($q,$rootScope,BBModel){return{query:function(member,params){var deferred;return params||(params={}),params.no_cache=!0,deferred=$q.defer(),member.$has("purchase_totals")?member.$get("purchase_totals",params).then(function(_this){return function(purchases){return params.no_cache=!1,purchases.$get("purchase_totals",params).then(function(purchases){var purchase;return purchases=function(){var i,len,results;for(results=[],i=0,len=purchases.length;len>i;i++)purchase=purchases[i],results.push(new BBModel.PurchaseTotal(purchase));return results}(),deferred.resolve(purchases)},function(err){return 404===err.status?deferred.resolve([]):deferred.reject(err)})}}(this),function(err){return 404===err.status?deferred.resolve([]):deferred.reject(err)}):deferred.reject("member does not have any purchases"),deferred.promise}}}])}.call(this),function(){angular.module("BBMember.Services").factory("BB.Service.payment_item",["$q","BBModel","UnwrapService",function($q,BBModel,UnwrapService){return{unwrap:function(resource){return UnwrapService.unwrapResource(BBModel.Member.PaymentItem,resource)}}}])}.call(this),function(){angular.module("BBMember.Services").factory("WalletService",["$q","BBModel",function($q,BBModel){return{getWalletForMember:function(member,params){var deferred;return params||(params={}),params.no_cache=!0,deferred=$q.defer(),member.$has("wallet")?member.$get("wallet",params).then(function(wallet){return wallet=new BBModel.Member.Wallet(wallet),deferred.resolve(wallet)},function(err){return deferred.reject(err)}):deferred.reject("Wallets are not turned on."),deferred.promise},getWalletLogs:function(wallet){var deferred,params;return params={no_cache:!0},deferred=$q.defer(),wallet.$has("logs")?wallet.$get("logs",params).then(function(resource){return resource.$get("logs").then(function(logs){var log;return logs=function(){var i,len,results;for(results=[],i=0,len=logs.length;len>i;i++)log=logs[i],results.push(new BBModel.Member.WalletLog(log));return results}(),deferred.resolve(logs)})},function(_this){return function(err){return deferred.reject(err)}}(this)):deferred.reject("No wallet transactions found"),deferred.promise},getWalletPurchaseBandsForWallet:function(wallet){var deferred;return deferred=$q.defer(),wallet.$has("purchase_bands")?wallet.$get("purchase_bands",{}).then(function(resource){return resource.$get("purchase_bands").then(function(bands){var band;return bands=function(){var i,len,results;for(results=[],i=0,len=bands.length;len>i;i++)band=bands[i],results.push(new BBModel.Member.WalletPurchaseBand(band));return results}(),deferred.resolve(bands)})},function(err){return deferred.reject(err)}):deferred.reject("No Purchase Bands"),deferred.promise},updateWalletForMember:function(member,params){var deferred;return deferred=$q.defer(),member.$has("wallet")?member.$put("wallet",{},params).then(function(wallet){return wallet=new BBModel.Member.Wallet(wallet),deferred.resolve(wallet)},function(err){return deferred.reject(err)}):deferred.reject("Wallets are not turned on."),deferred.promise},createWalletForMember:function(member){var deferred,params;return deferred=$q.defer(),params={},member.$has("wallet")?member.$post("wallet",{},params).then(function(wallet){return wallet=new BBModel.Member.Wallet(wallet),deferred.resolve(wallet)},function(err){return deferred.reject(err)}):deferred.reject("Wallets are not turned on."),deferred.promise}}}])}.call(this),function(){"use strict";var bind=function(fn,me){return function(){return fn.apply(me,arguments)}},extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.BookingModel",["$q","$window","$bbug","MemberBookingService","BBModel","BaseModel",function($q,$window,$bbug,MemberBookingService,BBModel,BaseModel){var Member_Booking;return Member_Booking=function(superClass){function Member_Booking(data){this.$getMember=bind(this.$getMember,this),Member_Booking.__super__.constructor.call(this,data),this.datetime=moment.parseZone(this.datetime),this.time_zone&&this.datetime.tz(this.time_zone),this.end_datetime=moment.parseZone(this.end_datetime),this.time_zone&&this.end_datetime.tz(this.time_zone),this.min_cancellation_time=moment(this.min_cancellation_time),this.min_cancellation_hours=this.datetime.diff(this.min_cancellation_time,"hours")}return extend(Member_Booking,superClass),Member_Booking.prototype.icalLink=function(){return this._data.$href("ical")},Member_Booking.prototype.webcalLink=function(){return this._data.$href("ical")},Member_Booking.prototype.gcalLink=function(){return this._data.$href("gcal")},Member_Booking.prototype.getGroup=function(){return this.group?this.group:this._data.$has("event_groups")?this._data.$get("event_groups").then(function(_this){return function(group){return _this.group=group,_this.group}}(this)):void 0},Member_Booking.prototype.getColour=function(){return this.getGroup()?this.getGroup().colour:"#FFFFFF"},Member_Booking.prototype.getCompany=function(){return this.company?this.company:this.$has("company")?this._data.$get("company").then(function(_this){return function(company){return _this.company=new BBModel.Company(company),_this.company}}(this)):void 0},Member_Booking.prototype.getAnswers=function(){var defer;return defer=$q.defer(),this.answers&&defer.resolve(this.answers),this._data.$has("answers")?this._data.$get("answers").then(function(_this){return function(answers){var a;return _this.answers=function(){var i,len,results;for(results=[],i=0,len=answers.length;len>i;i++)a=answers[i],results.push(new BBModel.Answer(a));return results}(),defer.resolve(_this.answers)}}(this)):defer.resolve([]),defer.promise},Member_Booking.prototype.printed_price=function(){return parseFloat(this.price)%1===0?"£"+this.price:$window.sprintf("£%.2f",parseFloat(this.price))},Member_Booking.prototype.$getMember=function(){var defer;return defer=$q.defer(),this.member&&defer.resolve(this.member),this._data.$has("member")&&this._data.$get("member").then(function(_this){return function(member){return _this.member=new BBModel.Member.Member(member),defer.resolve(_this.member)}}(this)),defer.promise},Member_Booking.prototype.canCancel=function(){return moment(this.min_cancellation_time).isAfter(moment())},Member_Booking.prototype.canMove=function(){return this.canCancel()},Member_Booking.prototype.$update=function(){return MemberBookingService.update(this)},Member_Booking.$query=function(member,params){return MemberBookingService.query(member,params)},Member_Booking.$cancel=function(member,booking){return MemberBookingService.cancel(member,booking)},Member_Booking.$update=function(booking){return MemberBookingService.update(booking)},Member_Booking.$flush=function(member,params){return MemberBookingService.flush(member,params)},Member_Booking}(BaseModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.MemberModel",["$q","MemberService","BBModel","BaseModel","ClientModel",function($q,MemberService,BBModel,BaseModel,ClientModel){var Member_Member;return Member_Member=function(superClass){function Member_Member(){return Member_Member.__super__.constructor.apply(this,arguments)}return extend(Member_Member,superClass),Member_Member.$refresh=function(member){return MemberService.refresh(member)},Member_Member.$current=function(){return MemberService.current()},Member_Member.$updateMember=function(member,params){return MemberService.updateMember(member,params)},Member_Member.$sendWelcomeEmail=function(member,params){return MemberService.sendWelcomeEmail(member,params)},Member_Member.prototype.getBookings=function(params){return BBModel.Member.Booking.$query(this,params)},Member_Member}(ClientModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.PaymentItemModel",["BBModel","BaseModel",function(BBModel,BaseModel){var Member_PaymentItem;return Member_PaymentItem=function(superClass){function Member_PaymentItem(data){Member_PaymentItem.__super__.constructor.call(this,data)}return extend(Member_PaymentItem,superClass),Member_PaymentItem}(BaseModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.PrePaidBookingModel",["BaseModel",function(BaseModel){var Member_PrePaidBooking;return Member_PrePaidBooking=function(superClass){function Member_PrePaidBooking(data){Member_PrePaidBooking.__super__.constructor.call(this,data)}return extend(Member_PrePaidBooking,superClass),Member_PrePaidBooking}(BaseModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.PurchaseModel",["$q","MemberPurchaseService","BBModel","BaseModel",function($q,MemberPurchaseService,BBModel,BaseModel){var Member_Purchase;return Member_Purchase=function(superClass){function Member_Purchase(data){Member_Purchase.__super__.constructor.call(this,data),this.created_at=moment.parseZone(this.created_at),this.time_zone&&this.created_at.tz(this.time_zone)}return extend(Member_Purchase,superClass),Member_Purchase.prototype.getItems=function(){var deferred;return deferred=$q.defer(),this._data.$get("purchase_items").then(function(items){var item;return this.items=function(){var i,len,results;for(results=[],i=0,len=items.length;len>i;i++)item=items[i],results.push(new BBModel.Member.PurchaseItem(item));return results}(),deferred.resolve(this.items)}),deferred.promise},Member_Purchase.$query=function(member,params){return MemberPurchaseService.query(member,params)},Member_Purchase}(BaseModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.PurchaseItemModel",["BBModel","BaseModel",function(BBModel,BaseModel){var Member_PurchaseItem;return Member_PurchaseItem=function(superClass){function Member_PurchaseItem(data){Member_PurchaseItem.__super__.constructor.call(this,data)}return extend(Member_PurchaseItem,superClass),Member_PurchaseItem}(BaseModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.WalletModel",["WalletService","BBModel","BaseModel",function(WalletService,BBModel,BaseModel){var Member_Wallet;return Member_Wallet=function(superClass){function Member_Wallet(data){Member_Wallet.__super__.constructor.call(this,data)}return extend(Member_Wallet,superClass),Member_Wallet.$getWalletForMember=function(member,params){return WalletService.getWalletForMember(member,params)},Member_Wallet.$getWalletLogs=function(wallet){return WalletService.getWalletLogs(wallet)},Member_Wallet.$getWalletPurchaseBandsForWallet=function(wallet){return WalletService.getWalletPurchaseBandsForWallet(wallet)},Member_Wallet.$updateWalletForMember=function(member,params){return WalletService.updateWalletForMember(member,params)},Member_Wallet.$createWalletForMember=function(member){return WalletService.createWalletForMember(member)},Member_Wallet}(BaseModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.WalletLogModel",["$q","BBModel","BaseModel",function($q,BBModel,BaseModel){var Member_WalletLog;return Member_WalletLog=function(superClass){function Member_WalletLog(data){Member_WalletLog.__super__.constructor.call(this,data),this.created_at=moment(this.created_at),this.payment_amount=100*parseFloat(this.amount),this.new_wallet_amount=100*parseFloat(this.new_wallet_amount)}return extend(Member_WalletLog,superClass),Member_WalletLog}(BaseModel)}])}.call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Member.WalletPurchaseBandModel",["BBModel","BaseModel",function(BBModel,BaseModel){var Member_WalletPurchaseBand;return Member_WalletPurchaseBand=function(superClass){function Member_WalletPurchaseBand(data){Member_WalletPurchaseBand.__super__.constructor.call(this,data)}return extend(Member_WalletPurchaseBand,superClass),Member_WalletPurchaseBand}(BaseModel)}])}.call(this);