-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookingbug-angular-admin.min.js
More file actions
2 lines (2 loc) · 60.8 KB
/
bookingbug-angular-admin.min.js
File metadata and controls
2 lines (2 loc) · 60.8 KB
1
2
(function(){"use strict";angular.module("BBAdmin").config(["$logProvider",function($logProvider){"ngInject";$logProvider.debugEnabled(!0)}]),angular.module("BB").config(["FormTransformProvider",function(FormTransformProvider){"ngInject";FormTransformProvider.setTransform("edit","Admin_Booking",function(form,schema,model){var disable_list;return disable_list=model&&3===model.status?["service","person_id","resource_id"]:["datetime","service","person_id","resource_id"],form[0].tabs?_.each(form[0].tabs[0].items,function(item){return _.indexOf(disable_list,item.key)>-1?item.readonly=!0:void 0}):_.each(form,function(item){return _.indexOf(disable_list,item.key)>-1?item.readonly=!0:void 0}),form})}])}).call(this),function(){"use strict";angular.module("BBAdmin",["BB","BBAdmin.Services","BBAdmin.Filters","BBAdmin.Directives","BBAdmin.Controllers","BBAdmin.Models","BBAdmin.Directives","trNgGrid"]),angular.module("BBAdmin.Directives",[]),angular.module("BBAdmin.Filters",[]),angular.module("BBAdmin.Models",[]),angular.module("BBAdmin.Services",["ngResource","ngSanitize"]),angular.module("BBAdmin.Controllers",["ngSanitize"])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").run(["$q","$injector","BBModel",function($q,$injector,BBModel){"ngInject";var afuncs,i,len,model,models;for(models=["Booking","Slot","User","Administrator","Schedule","Address","Resource","Person","Service","Login","EventChain","EventGroup","Event","Clinic","Company","Client"],afuncs={},i=0,len=models.length;len>i;i++)model=models[i],afuncs[model]=$injector.get("Admin"+model+"Model");BBModel.Admin=afuncs}])}.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;window.Collection.Booking=function(superClass){function Booking(){return Booking.__super__.constructor.apply(this,arguments)}return extend(Booking,superClass),Booking.prototype.checkItem=function(item){return Booking.__super__.checkItem.apply(this,arguments)},Booking.prototype.matchesParams=function(item){return null!=this.params.start_date&&item.start&&(null==this.start_date&&(this.start_date=moment(this.params.start_date)),this.start_date.isAfter(item.start))?!1:null!=this.params.end_date&&item.start&&(null==this.end_date&&(this.end_date=moment(this.params.end_date)),this.end_date.isBefore(item.start.clone().startOf("day")))?!1:this.params.include_cancelled||!item.is_cancelled},Booking}(window.Collection.Base),angular.module("BB.Services").provider("BookingCollections",function(){return{$get:function(){return new window.BaseCollections}}})}.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;window.Collection.Client=function(superClass){function Client(){return Client.__super__.constructor.apply(this,arguments)}return extend(Client,superClass),Client.prototype.checkItem=function(item){return Client.__super__.checkItem.apply(this,arguments)},Client}(window.Collection.Base),angular.module("BB.Services").provider("ClientCollections",function(){return{$get:function(){return new window.BaseCollections}}})}.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;window.Collection.Slot=function(superClass){function Slot(){return Slot.__super__.constructor.apply(this,arguments)}return extend(Slot,superClass),Slot.prototype.checkItem=function(item){return Slot.__super__.checkItem.apply(this,arguments)},Slot.prototype.matchesParams=function(item){return this.params.start_date&&(this.start_date||(this.start_date=moment(this.params.start_date)),this.start_date.isAfter(item.date))?!1:!this.params.end_date||(this.end_date||(this.end_date=moment(this.params.end_date)),!this.end_date.isBefore(item.date))},Slot}(window.Collection.Base),angular.module("BB.Services").provider("SlotCollections",function(){return{$get:function(){return new window.BaseCollections}}})}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("CalendarCtrl",["$scope","BBModel","$rootScope",function($scope,BBModel,$rootScope){return $scope.eventsF=function(start,end,tz,callback){var bookings,prms;return prms={company_id:21},prms.start_date=start.format("YYYY-MM-DD"),prms.end_date=end.format("YYYY-MM-DD"),bookings=BBModel.Admin.Booking.$query(prms),bookings.then(function(_this){return function(s){return callback(s.items),s.addCallback(function(booking){return $scope.myCalendar.fullCalendar("renderEvent",booking,!0)})}}(this))},$scope.dayClick=function(date,allDay,jsEvent,view){return $scope.$apply(function(_this){return function(){return $scope.alertMessage="Day Clicked "+date}}(this))},$scope.alertOnDrop=function(event,revertFunc,jsEvent,ui,view){return $scope.$apply(function(_this){return function(){return $scope.popupTimeAction({action:"move",booking:event,newdate:event.start,onCancel:revertFunc})}}(this))},$scope.alertOnResize=function(event,revertFunc,jsEvent,ui,view){return $scope.$apply(function(_this){return function(){return $scope.alertMessage="Event Resized "}}(this))},$scope.addRemoveEventSource=function(sources,source){var canAdd;return canAdd=0,angular.forEach(sources,function(_this){return function(value,key){return sources[key]===source?(sources.splice(key,1),canAdd=1):void 0}}(this)),0===canAdd?sources.push(source):void 0},$scope.addEvent=function(){var m,y;return y="",m="",$scope.events.push({title:"Open Sesame",start:new Date(y,m,28),end:new Date(y,m,29),className:["openSesame"]})},$scope.remove=function(index){return $scope.events.splice(index,1)},$scope.changeView=function(view){return $scope.myCalendar.fullCalendar("changeView",view)},$scope.eventClick=function(event,jsEvent,view){return $scope.$apply(function(_this){return function(){return $scope.selectBooking(event)}}(this))},$scope.selectTime=function(start,end,allDay){return $scope.$apply(function(_this){return function(){return $scope.popupTimeAction({start_time:moment(start),end_time:moment(end),allDay:allDay}),$scope.myCalendar.fullCalendar("unselect")}}(this))},$scope.uiConfig={calendar:{height:450,editable:!0,header:{left:"month agendaWeek agendaDay",center:"title",right:"today prev,next"},dayClick:$scope.dayClick,eventClick:$scope.eventClick,eventDrop:$scope.alertOnDrop,eventResize:$scope.alertOnResize,selectable:!0,selectHelper:!0,select:$scope.selectTime}},$scope.eventSources=[$scope.eventsF]}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("CategoryList",["$scope","$location","$rootScope","BBModel",function($scope,$location,$rootScope,BBModel){return $rootScope.connection_started.then(function(_this){return function(){return $scope.categories=BBModel.Category.$query($scope.bb.company),$scope.categories.then(function(items){})}}(this)),$scope.$watch("selectedCategory",function(_this){return function(newValue,oldValue){var items;return $rootScope.category=newValue,items=$(".inline_time").each(function(idx,e){return angular.element(e).scope().clear()})}}(this)),$scope.$on("Refresh_Cat",function(_this){return function(event,message){return $scope.$apply()}}(this))}])}.call(this),function(){"use strict";angular.module("BBAdmin.Directives").directive("bbAdminClients",function(){return{restrict:"AE",replace:!0,scope:!0,controller:"AdminClients",link:function(scope,element,attrs){}}}),angular.module("BBAdmin.Controllers").controller("AdminClients",["$scope","$rootScope","$q","$log","AlertService","LoadingService","BBModel",function($scope,$rootScope,$q,$log,AlertService,LoadingService,BBModel){var loader;return $scope.clientDef=$q.defer(),$scope.clientPromise=$scope.clientDef.promise,$scope.per_page=15,$scope.total_entries=0,$scope.clients=[],loader=LoadingService.$loader($scope),$scope.getClients=function(currentPage,filterBy,filterByFields,orderBy,orderByReverse){var clientDef;return clientDef=$q.defer(),$rootScope.connection_started.then(function(){var params;return loader.notLoaded(),params={company:$scope.bb.company,per_page:$scope.per_page,page:currentPage+1,filter_by:filterBy,filter_by_fields:filterByFields,order_by:orderBy,order_by_reverse:orderByReverse},BBModel.Admin.Client.$query(params).then(function(_this){return function(clients){return $scope.clients=clients.items,loader.setLoaded(),$scope.setPageLoaded(),$scope.total_entries=clients.total_entries,clientDef.resolve(clients.items)}}(this),function(err){return clientDef.reject(err),loader.setLoadedAndShowError(err,"Sorry, something went wrong")})}),!0},$scope.edit=function(item){return $log.info("not implemented")}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("CompanyList",["$scope","$rootScope","$location",function($scope,$rootScope,$location){return $scope.selectedCategory=null,$rootScope.connection_started.then(function(_this){return function(){var d,date,end,results;for(date=moment(),$scope.current_date=date,$scope.companies=$scope.bb.company.companies,$scope.companies&&0!==$scope.companies.length||($scope.companies=[$scope.bb.company]),$scope.dates=[],end=moment(date).add(21,"days"),$scope.end_date=end,d=moment(date),results=[];d.isBefore(end);)$scope.dates.push(d.clone()),results.push(d.add(1,"days"));return results}}(this)),$scope.selectCompany=function(item){return $location="/view/dashboard/pick_company/"+item.id},$scope.advance_date=function(num){var d,date,results;for(date=$scope.current_date.add(num,"days"),$scope.end_date=moment(date).add(21,"days"),$scope.current_date=moment(date),$scope.dates=[],d=date.clone(),results=[];d.isBefore($scope.end_date);)$scope.dates.push(d.clone()),results.push(d.add(1,"days"));return results},$scope.$on("Refresh_Comp",function(event,message){return $scope.$apply()})}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("DashboardContainer",["$scope","$rootScope","$location","$uibModal","$document",function($scope,$rootScope,$location,$uibModal,$document){var ModalInstanceCtrl;return $scope.selectedBooking=null,$scope.poppedBooking=null,$scope.selectBooking=function(booking){return $scope.selectedBooking=booking},$scope.popupBooking=function(booking){var modalInstance;return $scope.poppedBooking=booking,modalInstance=$uibModal.open({templateUrl:"full_booking_details",controller:ModalInstanceCtrl,scope:$scope,backdrop:!0,resolve:{items:function(_this){return function(){return{booking:booking}}}(this)}}),modalInstance.result.then(function(_this){return function(selectedItem){return $scope.selected=selectedItem}}(this),function(_this){return function(){return console.log("Modal dismissed at: "+new Date)}}(this))},ModalInstanceCtrl=function($scope,$uibModalInstance,items){return angular.extend($scope,items),$scope.ok=function(){return items.booking&&items.booking.self&&items.booking.$update(),$uibModalInstance.close()},$scope.cancel=function(){return $uibModalInstance.dismiss("cancel")}},$scope.popupTimeAction=function(prms){var modalInstance;return modalInstance=$uibModal.open({templateUrl:$scope.partial_url+"time_popup",controller:ModalInstanceCtrl,scope:$scope,backdrop:!1,resolve:{items:function(_this){return function(){return prms}}(this)}})}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("DashDayList",["$scope","$rootScope","$q","BBModel",function($scope,$rootScope,$q,BBModel){return $scope.init=function(_this){return function(company_id){var date,dayListDef,prms,weekListDef;return $scope.inline_items="",company_id&&($scope.bb.company_id=company_id),$scope.current_date||($scope.current_date=moment().startOf("month")),date=$scope.current_date,prms={date:date.format("DD-MM-YYYY"),company_id:$scope.bb.company_id},$scope.service_id&&(prms.service_id=$scope.service_id),$scope.end_date&&(prms.edate=$scope.end_date.format("DD-MM-YYYY")),dayListDef=$q.defer(),weekListDef=$q.defer(),$scope.dayList=dayListDef.promise,$scope.weeks=weekListDef.promise,prms.url=$scope.bb.api_url,BBModel.Admin.Day.$query(prms).then(function(days){return $scope.sdays=days,dayListDef.resolve(),$scope.category?$scope.update_days():void 0})}}(this),$scope.format_date=function(_this){return function(fmt){return $scope.current_date.format(fmt)}}(this),$scope.selectDay=function(_this){return function(day,dayBlock,e){var elm,seldate,xelm;return 0===day.spaces?!1:(seldate=moment($scope.current_date),seldate.date(day.day),$scope.selected_date=seldate,elm=angular.element(e.toElement),elm.parent().children().removeClass("selected"),elm.addClass("selected"),xelm=$("#tl_"+$scope.bb.company_id),$scope.service_id=dayBlock.service_id,$scope.service={id:dayBlock.service_id,name:dayBlock.name},$scope.selected_day=day,0===xelm.length?$scope.inline_items="/view/dash/time_small":xelm.scope().init(day))}}(this),$scope.$watch("current_date",function(_this){return function(newValue,oldValue){return newValue&&$scope.bb.company_id?$scope.init():void 0}}(this)),$scope.update_days=function(_this){return function(){var day,i,len,ref,results;for($scope.dayList=[],$scope.service_id=null,ref=$scope.sdays,results=[],i=0,len=ref.length;len>i;i++)day=ref[i],day.category_id===$scope.category.id?($scope.dayList.push(day),results.push($scope.service_id=day.id)):results.push(void 0);return results}}(this),$rootScope.$watch("category",function(_this){return function(newValue,oldValue){return newValue&&$scope.sdays?$scope.update_days():void 0}}(this))}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("EditBookingDetails",["$scope","$location","$rootScope",function($scope,$location,$rootScope){}])}.call(this),function(){"use strict";angular.module("BBAdmin.Directives").directive("bbAdminLogin",function(){return{restrict:"AE",replace:!0,scope:{onSuccess:"=",onCancel:"=",onError:"=",bb:"="},controller:"AdminLogin",template:'<div ng-include="login_template"></div>'}}),angular.module("BBAdmin.Controllers").controller("AdminLogin",["$scope","$rootScope","$q","$sessionStorage","BBModel",function($scope,$rootScope,$q,$sessionStorage,BBModel){return $scope.login_data={host:$sessionStorage.getItem("host"),email:null,password:null,selected_admin:null},$scope.login_template="login/admin_login.html",$scope.login=function(){var params;return $scope.alert="",params={email:$scope.login_data.email,password:$scope.login_data.password},BBModel.Admin.Login.$login(params).then(function(user){return null==user.company_id?user.$getAdministrators().then(function(administrators){return $scope.administrators=administrators,$scope.pickCompany()}):($scope.user=user,$scope.onSuccess?$scope.onSuccess():void 0)},function(err){return $scope.alert="Sorry, either your email or password was incorrect"})},$scope.pickCompany=function(){return $scope.login_template="login/admin_pick_company.html"},$scope.selectedCompany=function(){var params;return $scope.alert="",params={email:$scope.login_data.email,password:$scope.login_data.password},$scope.login_data.selected_admin.$post("login",{},params).then(function(login){return $scope.login_data.selected_admin.$getCompany().then(function(company){return $scope.bb.company=company,BBModel.Admin.Login.$setLogin($scope.login_data.selected_admin),$scope.onSuccess(company)})})}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("SelectedBookingDetails",["$scope","$location","$rootScope","BBModel",function($scope,$location,$rootScope,BBModel){return $scope.$watch("selectedBooking",function(_this){return function(newValue,oldValue){return newValue?($scope.booking=newValue,$scope.showItemView="/view/dash/booking_details"):void 0}}(this))}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("DashTimeList",["$scope","$rootScope","$location","$q","$element","AdminTimeService",function($scope,$rootScope,$location,$q,$element,AdminTimeService){var $loaded;return $loaded=null,$scope.init=function(_this){return function(day){var elem,prms,timeListDef;return $scope.selected_day=day,elem=angular.element($element),elem.attr("id","tl_"+$scope.bb.company_id),angular.element($element).show(),prms={company_id:$scope.bb.company_id,day:day},$scope.service_id&&(prms.service_id=$scope.service_id),timeListDef=$q.defer(),$scope.slots=timeListDef.promise,prms.url=$scope.bb.api_url,$scope.aslots=AdminTimeService.query(prms),$scope.aslots.then(function(res){var i,k,len,slot,slots,x,xres;for($scope.loaded=!0,slots={},i=0,len=res.length;len>i;i++)x=res[i],slots[x.time]||(slots[x.time]=x);xres=[];for(k in slots)slot=slots[k],xres.push(slot);return timeListDef.resolve(xres)})}}(this),$scope.selected_day&&$scope.init($scope.selected_day),$scope.format_date=function(_this){return function(fmt){return $scope.selected_date.format(fmt)}}(this),$scope.selectSlot=function(_this){return function(slot,route){return $scope.pickTime(slot.time),$scope.pickDate($scope.selected_date),$location.path(route)}}(this),$scope.highlighSlot=function(_this){return function(slot){return $scope.pickTime(slot.time),$scope.pickDate($scope.selected_date),$scope.setCheckout(!0)}}(this),$scope.clear=function(_this){return function(){return $scope.loaded=!1,$scope.slots=null,angular.element($element).hide()}}(this),$scope.popupCheckout=function(_this){return function(slot){var dHeight,dWidth,dlg,item,k,src,url,v,wHeight,wWidth;item={time:slot.time,date:$scope.selected_day.date,company_id:$scope.bb.company_id,duration:30,service_id:$scope.service_id,event_id:slot.id},url="/booking/new_checkout?";for(k in item)v=item[k],url+=k+"="+v+"&";return wWidth=$(window).width(),dWidth=.8*wWidth,wHeight=$(window).height(),dHeight=.8*wHeight,dlg=$("#dialog-modal"),src=dlg.html("<iframe frameborder=0 id='mod_dlg' onload='nowait();setTimeout(set_iframe_focus, 100);' width=100% height=99% src='"+url+"'></iframe>"),dlg.attr("title","Checkout"),dlg.dialog({my:"top",at:"top",height:dHeight,width:dWidth,modal:!0,overlay:{opacity:.1,background:"black"}})}}(this)}])}.call(this),function(){"use strict";angular.module("BBAdmin.Controllers").controller("TimeOptions",["$scope","$location","$rootScope","BBModel",function($scope,$location,$rootScope,BBModel){return BBModel.Admin.Resource.$query({company:$scope.bb.company}).then(function(resources){return $scope.resources=resources}),BBModel.Admin.Person.$query({company:$scope.bb.company}).then(function(people){return $scope.people=people}),$scope.block=function(){var params;return $scope.person&&(params={start_time:$scope.start_time,end_time:$scope.end_time},BBModel.Admin.Person.$block($scope.bb.company,$scope.person,params)),$scope.ok()}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Directives").directive("adminLogin",["$uibModal","$log","$rootScope","$q","$document","BBModel",function($uibModal,$log,$rootScope,$q,$document,BBModel){var link,loginAdminController,pickCompanyController;return loginAdminController=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},BBModel.Admin.Login.$login(form,options).then(function(admin){return admin.email=form.email,admin.password=form.password,$uibModalInstance.close(admin)},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,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:loginAdminController,resolve:{company_id:function(){return scope.companyId}}}),modalInstance.result.then(function(result){return scope.adminEmail=result.email,scope.adminPassword=result.password,result.$has("admins")?result.$get("admins").then(function(admins){var m;return scope.admins=admins,$q.all(function(){var i,len,results;for(results=[],i=0,len=admins.length;len>i;i++)m=admins[i],results.push(m.$get("company"));return results}()).then(function(companies){return pickCompanyModal(companies)})}):scope.admin=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.adminEmail,password:scope.adminPassword},options={company_id:scope.companyId},BBModel.Admin.Login.$login(login_form,options).then(function(result){return result.$has("admins")?result.$get("admins").then(function(admins){var a;return scope.admins=admins,$q.all(function(){var i,len,results;for(results=[],i=0,len=admins.length;len>i;i++)a=admins[i],results.push(a.$get("company"));return results}()).then(function(companies){return pickCompanyModal(companies)})}):scope.admin=result},function(err){return loginModal()})},scope.adminEmail&&scope.adminPassword?tryLogin():loginModal()},{link:link,scope:{adminEmail:"@",adminPassword:"@",companyId:"@",apiUrl:"@",admin:"="},transclude:!0,template:"<div ng-hide='admin'><img src='/BB_wait.gif' class=\"loader\"></div>\n<div ng-show='admin' ng-transclude></div>"}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Directives").directive("bbAdminSsoLogin",["$rootScope","BBModel","QueryStringService","halClient",function($rootScope,BBModel,QueryStringService,halClient){return{restrict:"EA",scope:{token:"@bbAdminSsoLogin",companyId:"@",apiUrl:"@"},transclude:!0,template:"<div ng-if='admin' ng-transclude></div>",link:function(scope,element,attrs){var api_host,data,url;return scope.qs=QueryStringService,data={},scope.qs&&(data.token=scope.qs("sso_token")),scope.token&&(data.token||(data.token=scope.token)),scope.apiUrl&&(api_host=scope.apiUrl),api_host||(api_host=$rootScope.bb.api_url),url=api_host+"/api/v1/login/admin_sso/"+scope.companyId,halClient.$post(url,{},data).then(function(login){var params;return params={auth_token:login.auth_token},login.$get("administrator",params).then(function(admin){return scope.admin=admin,BBModel.Admin.Login.$setLogin(admin)})})}}}])}.call(this),function(){"use strict";angular.module("BBAdmin").directive("bookingTable",["BBModel","ModalForm",function(BBModel,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","datetime"],$scope.getBookings=function(){var params;return params={company:$scope.company},BBModel.Admin.Booking.$query(params).then(function(bookings){return $scope.bookings=bookings.items})},$scope.newBooking=function(){return ModalForm["new"]({company:$scope.company,title:"New Booking",new_rel:"new_booking",post_rel:"bookings",success:function(booking){return $scope.bookings.push(booking)}})},$scope.edit=function(booking){return ModalForm.edit({model:booking,title:"Edit Booking"})}},link=function(scope,element,attrs){return scope.company?scope.getBookings():BBModel.Admin.Company.$query(attrs).then(function(company){return scope.company=company,scope.getBookings()})},{controller:controller,link:link,templateUrl:"booking_table_main.html"}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Directives").directive("bbPeopleList",["$rootScope",function($rootScope){return{restrict:"AE",replace:!0,scope:!0,controller:["$scope","$rootScope","PersonService","$q","BBModel","PersonModel",function($scope,$rootScope,PersonService,$q,BBModel,PersonModel){return $rootScope.connection_started.then(function(){return $scope.bb.company.$getPeople().then(function(people){var i,len,person,results;for($scope.people=people,results=[],i=0,len=people.length;len>i;i++)person=people[i],results.push(person.show=!0);return results})}),$scope.show_all_people=function(){var i,len,ref,results,x;for(ref=$scope.people,results=[],i=0,len=ref.length;len>i;i++)x=ref[i],results.push(x.show=!0);return results},$scope.hide_all_people=function(){var i,len,ref,results,x;for(ref=$scope.people,results=[],i=0,len=ref.length;len>i;i++)x=ref[i],results.push(x.show=!1);return results}}],link:function(scope,element,attrs){}}}]),angular.module("BBAdmin.Directives").directive("bbBookingList",function(){return{restrict:"AE",replace:!0,scope:{bookings:"=",cancelled:"=",params:"="},templateUrl:function(tElm,tAttrs){return tAttrs.template},controller:["$scope","$filter",function($scope,$filter){var status;return $scope.title=$scope.params.title,status=$scope.params.status,$scope.$watch(function(){return $scope.bookings},function(){var bookings,cancelled;return bookings=$scope.bookings,cancelled=$scope.cancelled,null==cancelled&&(cancelled=!1),null!=bookings&&(bookings=$filter("filter")(bookings,function(booking){var ret;return ret=booking.is_cancelled===cancelled,ret&=null!=status?booking.hasStatus(status):null==booking.multi_status||0===Object.keys(booking.multi_status).length,ret&=4===booking.status}),$scope.relevantBookings=$filter("orderBy")(bookings,"datetime")),null!=$scope.relevantBookings?$scope.relevantBookings:$scope.relevantBookings=[]})}]}})}.call(this),function(){"use strict";var bbAdminFilters;bbAdminFilters=angular.module("BBAdmin.Filters",[]),bbAdminFilters.filter("rag",function(){return function(value,v1,v2){return v1>=value?"red":v2>=value?"amber":"green"}}),bbAdminFilters.filter("gar",function(){return function(value,v1,v2){return v1>=value?"green":v2>=value?"amber":"red"}}),bbAdminFilters.filter("time",["$window",function($window){return function(v){return $window.sprintf("%02d:%02d",Math.floor(v/60),v%60)}}])}.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("AdminAdministratorModel",["$q","BBModel","BaseModel",function($q,BBModel,BaseModel){var Administrator;return Administrator=function(superClass){function Administrator(){return Administrator.__super__.constructor.apply(this,arguments)}return extend(Administrator,superClass),Administrator}(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("AdminBookingModel",["$q","BBModel","BaseModel","BookingCollections","$window",function($q,BBModel,BaseModel,BookingCollections,$window){var Admin_Booking;return Admin_Booking=function(superClass){function Admin_Booking(data){var k,ref,v;if(Admin_Booking.__super__.constructor.apply(this,arguments),this.datetime=moment(this.datetime),this.start=this.datetime,this.end=this.end_datetime,this.end||(this.end=this.datetime.clone().add(this.duration,"minutes")),this.title=this.full_describe,this.time=60*this.start.hour()+this.start.minute(),this.allDay=!1,this.duration_span&&86400===this.duration_span&&(this.allDay=!0),3===this.status?(this.startEditable=!0,this.durationEditable=!0,this.className="status_blocked"):4===this.status?this.className="status_booked":0===this.status&&(this.className="status_available"),this.multi_status){ref=this.multi_status;for(k in ref)v=ref[k],this.className+=" status_"+k}}return extend(Admin_Booking,superClass),Admin_Booking.prototype.useFullTime=function(){return this.using_full_time=!0,this.pre_time&&(this.start=this.datetime.clone().subtract(this.pre_time,"minutes")),this.post_time?this.end=this.datetime.clone().add(this.duration+this.post_time,"minutes"):void 0},Admin_Booking.prototype.getPostData=function(){var data,q;return data={},this.date&&this.time?(data.date=this.date.date.toISODate(),data.time=this.time.time,this.time.event_id?data.event_id=this.time.event_id:this.time.event_ids&&(data.event_ids=this.time.event_ids)):(this.datetime=this.start.clone(),this.using_full_time&&this.datetime.add(this.pre_time,"minutes"),data.date=this.datetime.format("YYYY-MM-DD"),data.time=60*this.datetime.hour()+this.datetime.minute()),data.duration=this.duration,data.id=this.id,data.pre_time=this.pre_time,data.post_time=this.post_time,data.person_id=this.person_id,data.resource_id=this.resource_id,data.child_client_ids=this.child_client_ids,data.people_ids=this.people_ids,this.questions&&(data.questions=function(){var i,len,ref,results;for(ref=this.questions,results=[],i=0,len=ref.length;len>i;i++)q=ref[i],results.push(q.getPostData());return results}.call(this)),data},Admin_Booking.prototype.hasStatus=function(status){return null!=this.multi_status[status]},Admin_Booking.prototype.statusTime=function(status){return this.multi_status[status]?moment(this.multi_status[status]):null},Admin_Booking.prototype.sinceStatus=function(status){var s;return s=this.statusTime(status),s?Math.floor((moment().unix()-s.unix())/60):0},Admin_Booking.prototype.sinceStart=function(options){var s,start;return start=this.datetime.unix(),options?options.later&&(s=this.statusTime(options.later).unix(),s>start)?Math.floor((moment().unix()-s)/60):options.earlier&&(s=this.statusTime(options.earlier).unix(),start>s)?Math.floor((moment().unix()-s)/60):Math.floor((moment().unix()-start)/60):Math.floor((moment().unix()-start)/60)},Admin_Booking.prototype.answer=function(q){var a,i,len,ref;if(this.answers_summary)for(ref=this.answers_summary,i=0,len=ref.length;len>i;i++)if(a=ref[i],a.name===q)return a.answer;return null},Admin_Booking.prototype.$update=function(data){var defer;return defer=$q.defer(),data&&(data.datetime=moment(data.datetime),data.datetime.tz(),data.datetime=data.datetime.format()),data||(data=this.getPostData()),this.$put("self",{},data).then(function(_this){return function(res){return _this.constructor(res),_this.using_full_time&&_this.useFullTime(),BookingCollections.checkItems(_this),defer.resolve(_this)}}(this),function(err){return defer.reject(err)}),defer.promise},Admin_Booking.prototype.$refetch=function(){var defer;return defer=$q.defer(),this.$flush("self"),this.$get("self").then(function(_this){
return function(res){return _this.constructor(res),_this.using_full_time&&_this.useFullTime(),BookingCollections.checkItems(_this),defer.resolve(_this)}}(this),function(err){return defer.reject(err)}),defer.promise},Admin_Booking.$query=function(params){var company,defer,existing,src;return params.slot&&(params.slot_id=params.slot.id),params.date&&(params.start_date=params.date,params.end_date=params.date),params.company&&(company=params.company,delete params.company,params.company_id=company.id),null==params.per_page&&(params.per_page=1024),null==params.include_cancelled&&(params.include_cancelled=!1),defer=$q.defer(),existing=BookingCollections.find(params),existing&&!params.skip_cache?defer.resolve(existing):(src=company,src||(src=params.src),params.src&&delete params.src,params.skip_cache&&(existing&&BookingCollections["delete"](existing),src.$flush("bookings",params)),src.$get("bookings",params).then(function(resource){var booking;return resource.$has("bookings")?resource.$get("bookings").then(function(bookings){var b,models,spaces;return models=function(){var i,len,results;for(results=[],i=0,len=bookings.length;len>i;i++)b=bookings[i],results.push(new BBModel.Admin.Booking(b));return results}(),spaces=new $window.Collection.Booking(resource,models,params),BookingCollections.add(spaces),defer.resolve(spaces)},function(err){return defer.reject(err)}):(booking=new BBModel.Admin.Booking(resource),defer.resolve(booking))},function(err){return defer.reject(err)})),defer.promise},Admin_Booking}(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("AdminClientModel",["ClientModel","$q","BBModel","$log","$window","ClientCollections","$rootScope","UriTemplate","halClient",function(ClientModel,$q,BBModel,$log,$window,ClientCollections,$rootScope,UriTemplate,halClient){var Admin_Client;return Admin_Client=function(superClass){function Admin_Client(data){Admin_Client.__super__.constructor.call(this,data)}return extend(Admin_Client,superClass),Admin_Client.$query=function(params){var company,defer,href,uri,url;return company=params.company,defer=$q.defer(),company.$has("client")?(url="",$rootScope.bb.api_url&&(url=$rootScope.bb.api_url),href=url+"/api/v1/admin/{company_id}/client{/id}{?page,per_page,filter_by,filter_by_fields,order_by,order_by_reverse,search_by_fields,default_company_id}",params.company_id=company.id,uri=new UriTemplate(href).fillFromObject(params||{}),params.flush&&halClient.clearCache(uri),halClient.$get(uri,{}).then(function(_this){return function(resource){var client;return resource.$has("clients")?resource.$get("clients").then(function(clients){var c,models;return models=function(){var i,len,results;for(results=[],i=0,len=clients.length;len>i;i++)c=clients[i],results.push(new BBModel.Admin.Client(c));return results}(),clients=new $window.Collection.Client(resource,models,params),clients.total_entries=resource.total_entries,ClientCollections.add(clients),defer.resolve(clients)},function(err){return defer.reject(err)}):(client=new BBModel.Admin.Client(resource),defer.resolve(client))}}(this),function(err){return defer.reject(err)})):($log.warn("company has no client link"),defer.reject("company has no client link")),defer.promise},Admin_Client}(ClientModel)}])}.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("AdminCompanyModel",["CompanyModel","AdminCompanyService","BookingCollections","$q","BBModel",function(CompanyModel,AdminCompanyService,BookingCollections,$q,BBModel){var Admin_Company;return Admin_Company=function(superClass){function Admin_Company(data){Admin_Company.__super__.constructor.call(this,data)}return extend(Admin_Company,superClass),Admin_Company.prototype.getBooking=function(id){var defer;return defer=$q.defer(),this.$get("bookings",{id:id}).then(function(booking){var model;return model=new BBModel.Admin.Booking(booking),BookingCollections.checkItems(model),defer.resolve(model)},function(err){return defer.reject(err)}),defer.promise},Admin_Company.$query=function(params){return AdminCompanyService.query(params)},Admin_Company}(CompanyModel)}])}.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("AdminLoginModel",["$q","AdminLoginService","BBModel","BaseModel",function($q,AdminLoginService,BBModel,BaseModel){var Admin_Login;return Admin_Login=function(superClass){function Admin_Login(data){Admin_Login.__super__.constructor.call(this,data)}return extend(Admin_Login,superClass),Admin_Login.$login=function(form,options){return AdminLoginService.login(form,options)},Admin_Login.$ssoLogin=function(options,data){return AdminLoginService.ssoLogin(options,data)},Admin_Login.$isLoggedIn=function(){return AdminLoginService.isLoggedIn()},Admin_Login.$setLogin=function(user){return AdminLoginService.setLogin(user)},Admin_Login.$user=function(){return AdminLoginService.user()},Admin_Login.$checkLogin=function(params){return AdminLoginService.checkLogin(params)},Admin_Login.$logout=function(){return AdminLoginService.logout()},Admin_Login.$getLogin=function(options){return AdminLoginService.getLogin(options)},Admin_Login.$companyLogin=function(company,params){return AdminLoginService.companyLogin(company,params)},Admin_Login.$memberQuery=function(params){return AdminLoginService.memberQuery(params)},Admin_Login.$setCompany=function(company_id){return AdminLoginService.setCompany(company_id)},Admin_Login}(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("AdminSlotModel",["$q","BBModel","BaseModel","TimeSlotModel","SlotCollections","$window",function($q,BBModel,BaseModel,TimeSlotModel,SlotCollections,$window){var Admin_Slot;return Admin_Slot=function(superClass){function Admin_Slot(data){var k,ref,v;if(Admin_Slot.__super__.constructor.call(this,data),this.title=this.full_describe,0===this.status&&(this.title="Available"),this.datetime=moment(this.datetime),this.start=this.datetime,this.end=this.end_datetime,this.end=this.datetime.clone().add(this.duration,"minutes"),this.time=60*this.start.hour()+this.start.minute(),this.title=this.full_describe,this.allDay=!1,this.duration_span&&86400===this.duration_span&&(this.allDay=!0),3===this.status?(this.startEditable=!0,this.durationEditable=!0,this.className="status_blocked"):4===this.status?this.className="status_booked":0===this.status&&(this.className="status_available"),this.multi_status){ref=this.multi_status;for(k in ref)v=ref[k],this.className+=" status_"+k}}return extend(Admin_Slot,superClass),Admin_Slot.prototype.useFullTime=function(){return this.using_full_time=!0,this.pre_time&&(this.start=this.datetime.clone().subtract(this.pre_time,"minutes")),this.post_time?this.end=this.datetime.clone().add(this.duration+this.post_time,"minutes"):void 0},Admin_Slot.prototype.$refetch=function(){var defer;return defer=$q.defer(),this.$flush("self"),this.$get("self").then(function(_this){return function(res){return _this.constructor(res),_this.using_full_time&&_this.useFullTime(),BookingCollections.checkItems(_this),defer.resolve(_this)}}(this),function(err){return defer.reject(err)}),defer.promise},Admin_Slot.$query=function(params){var company,defer,existing,src;return params.slot&&(params.slot_id=params.slot.id),params.date&&(params.start_date=params.date,params.end_date=params.date),params.company&&(company=params.company,delete params.company,params.company_id=company.id),null==params.per_page&&(params.per_page=1024),null==params.include_cancelled&&(params.include_cancelled=!1),defer=$q.defer(),existing=SlotCollections.find(params),existing&&!params.skip_cache?defer.resolve(existing):(src=company,src||(src=params.src),params.src&&delete params.src,params.skip_cache&&(existing&&SlotCollections["delete"](existing),src.$flush("slots",params)),src.$get("slots",params).then(function(resource){var slot;return resource.$has("slots")?resource.$get("slots").then(function(slots){var b,models,spaces;return models=function(){var i,len,results;for(results=[],i=0,len=slots.length;len>i;i++)b=slots[i],results.push(new BBModel.Admin.Slot(b));return results}(),spaces=new $window.Collection.Slot(resource,models,params),SlotCollections.add(spaces),defer.resolve(spaces)},function(err){return defer.reject(err)}):(slot=new BBModel.Admin.Slot(resource),defer.resolve(slot))},function(err){return defer.reject(err)})),defer.promise},Admin_Slot}(TimeSlotModel)}])}.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("AdminUserModel",["$q","BBModel","BaseModel",function($q,BBModel,BaseModel){var User;return User=function(superClass){function User(){return User.__super__.constructor.apply(this,arguments)}return extend(User,superClass),User}(BaseModel)}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminBookingService",["$q","$window","halClient","BookingCollections","BBModel","UriTemplate",function($q,$window,halClient,BookingCollections,BBModel,UriTemplate){return{query:function(prms){var company,deferred,existing,href,uri,url;return prms.slot&&(prms.slot_id=prms.slot.id),prms.date&&(prms.start_date=prms.date,prms.end_date=prms.date),prms.company&&(company=prms.company,delete prms.company,prms.company_id=company.id),null==prms.per_page&&(prms.per_page=1024),null==prms.include_cancelled&&(prms.include_cancelled=!1),deferred=$q.defer(),existing=BookingCollections.find(prms),existing&&!prms.skip_cache?deferred.resolve(existing):company?(prms.skip_cache&&(existing&&BookingCollections["delete"](existing),company.$flush("bookings",prms)),company.$get("bookings",prms).then(function(collection){return collection.$get("bookings").then(function(bookings){var b,models,spaces;return models=function(){var i,len,results;for(results=[],i=0,len=bookings.length;len>i;i++)b=bookings[i],results.push(new BBModel.Admin.Booking(b));return results}(),spaces=new $window.Collection.Booking(collection,models,prms),BookingCollections.add(spaces),deferred.resolve(spaces)},function(err){return deferred.reject(err)})},function(err){return deferred.reject(err)})):(url="",prms.url&&(url=prms.url),href=url+"/api/v1/admin/{company_id}/bookings{?slot_id,start_date,end_date,service_id,resource_id,person_id,page,per_page,include_cancelled,embed,client_id}",uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$get(uri,{}).then(function(_this){return function(found){return found.$get("bookings").then(function(items){var i,item,len,sitems,spaces;for(sitems=[],i=0,len=items.length;len>i;i++)item=items[i],sitems.push(new BBModel.Admin.Booking(item));return spaces=new $window.Collection.Booking(found,sitems,prms),BookingCollections.add(spaces),deferred.resolve(spaces)})}}(this),function(_this){return function(err){return deferred.reject(err)}}(this))),deferred.promise},getBooking:function(prms){var deferred,href,uri,url;return deferred=$q.defer(),prms.company&&!prms.company_id&&(prms.company_id=prms.company.id),url="",prms.url&&(url=prms.url),href=url+"/api/v1/admin/{company_id}/bookings/{id}{?embed}",uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$get(uri,{no_cache:!0}).then(function(item){var booking;return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},cancelBooking:function(prms,booking){var deferred,href,notify,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/bookings/{id}?notify={notify}",null==prms.id&&(prms.id=booking.id),notify=prms.notify,null==notify&&(notify=!0),uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$del(uri,{notify:notify}).then(function(item){return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},updateBooking:function(prms,booking){var deferred,href,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/bookings/{id}",null==prms.id&&(prms.id=booking.id),uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$put(uri,{},prms).then(function(item){return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},blockTimeForPerson:function(prms,person){var deferred,href,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/people/{person_id}/block",null==prms.person_id&&(prms.person_id=person.id),prms.booking=!0,uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$put(uri,{},prms).then(function(item){var booking;return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},addStatusToBooking:function(prms,booking,status){var deferred,href,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/bookings/{booking_id}/multi_status",null==prms.booking_id&&(prms.booking_id=booking.id),uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$put(uri,{},{status:status}).then(function(item){return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},addPrivateNoteToBooking:function(prms,booking,note){var deferred,href,noteParam,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/bookings/{booking_id}/private_notes",null==prms.booking_id&&(prms.booking_id=booking.id),null!=note.note&&(noteParam=note.note),null==noteParam&&(noteParam=note),uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$put(uri,{},{note:noteParam}).then(function(item){return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},updatePrivateNoteForBooking:function(prms,booking,note){var deferred,href,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/bookings/{booking_id}/private_notes/{id}",null==prms.booking_id&&(prms.booking_id=booking.id),null==prms.id&&(prms.id=note.id),uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$put(uri,{},{note:note.note}).then(function(item){return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},deletePrivateNoteFromBooking:function(prms,booking,note){var deferred,href,uri;return deferred=$q.defer(),href="/api/v1/admin/{company_id}/bookings/{booking_id}/private_notes/{id}",null==prms.booking_id&&(prms.booking_id=booking.id),null==prms.id&&(prms.id=note.id),uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$del(uri,{}).then(function(item){return booking=new BBModel.Admin.Booking(item),BookingCollections.checkItems(booking),deferred.resolve(booking)},function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("ColorPalette",function(){var colors;return colors=[{primary:"#001F3F",secondary:"#80BFFF"},{primary:"#FF4136",secondary:"#800600"},{primary:"#7FDBFF",secondary:"#004966"},{primary:"#3D9970",secondary:"#163728"},{primary:"#85144B",secondary:"#EB7AB1"},{primary:"#2ECC40",secondary:"#0E3E14"},{primary:"#FF851B",secondary:"#663000"}],{setColors:function(models){return _.each(models,function(model,i){var color;return color=colors[i%colors.length],model.color=color.primary,model.textColor=color.secondary})}}})}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminCompanyService",["$q","$rootScope","$sessionStorage","BBModel",function($q,$rootScope,$sessionStorage,BBModel){return{query:function(params){var base,base1,base2,defer;return defer=$q.defer(),$rootScope.bb||($rootScope.bb={}),(base=$rootScope.bb).api_url||(base.api_url=$sessionStorage.getItem("host")),(base1=$rootScope.bb).api_url||(base1.api_url=params.apiUrl),(base2=$rootScope.bb).api_url||(base2.api_url=""),BBModel.Admin.Login.$checkLogin(params).then(function(){var login_form,options;return $rootScope.user&&$rootScope.user.company_id?($rootScope.bb||($rootScope.bb={}),$rootScope.bb.company_id=$rootScope.user.company_id,$rootScope.user.$get("company").then(function(company){return defer.resolve(new BBModel.Admin.Company(company))},function(err){return defer.reject(err)})):(login_form={email:params.adminEmail,password:params.adminPassword},options={company_id:params.companyId},BBModel.Admin.Login.$login(login_form,options).then(function(user){return user.$get("company").then(function(company){return defer.resolve(new BBModel.Admin.Company(company))},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}))}),defer.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminDayService",["$q","$window","halClient","BBModel","UriTemplate",function($q,$window,halClient,BBModel,UriTemplate){return{query:function(prms){var deferred,href,uri,url;return url="",prms.url&&(url=prms.url),href=url+"/api/v1/{company_id}/day_data{?month,week,date,edate,event_id,service_id}",uri=new UriTemplate(href).fillFromObject(prms||{}),deferred=$q.defer(),halClient.$get(uri,{}).then(function(_this){return function(found){var item,j,len,mdays,ref;if(found.items){for(mdays=[],ref=found.items,j=0,len=ref.length;len>j;j++)item=ref[j],halClient.$get(item.uri).then(function(data){var days,dcol,i,k,len1,ref1;for(days=[],ref1=data.days,k=0,len1=ref1.length;len1>k;k++)i=ref1[k],i.type===prms.item&&days.push(new BBModel.Day(i));return dcol=new $window.Collection.Day(data,days,{}),mdays.push(dcol)});return deferred.resolve(mdays)}}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminLoginService",["$q","halClient","$rootScope","BBModel","$sessionStorage","$cookies","UriTemplate","shared_header",function($q,halClient,$rootScope,BBModel,$sessionStorage,$cookies,UriTemplate,shared_header){return{login:function(form,options){var deferred,url;return deferred=$q.defer(),url=$rootScope.bb.api_url+"/api/v1/login/admin",null!=options&&null!=options.company_id&&(url=url+"/"+options.company_id),halClient.$post(url,options,form).then(function(_this){return function(login){var login_model;return login.$has("administrator")?login.$get("administrator").then(function(user){return user=_this.setLogin(user),deferred.resolve(user)}):login.$has("administrators")?(login_model=new BBModel.Admin.Login(login),deferred.resolve(login_model)):deferred.reject("No admin account for login")}}(this),function(_this){return function(err){var login,login_model;return 400===err.status?(login=halClient.$parse(err.data),login.$has("administrators")?(login_model=new BBModel.Admin.Login(login),deferred.resolve(login_model)):deferred.reject(err)):deferred.reject(err)}}(this)),deferred.promise},ssoLogin:function(options,data){var deferred,url;return deferred=$q.defer(),url=$rootScope.bb.api_url+"/api/v1/login/sso/"+options.company_id,halClient.$post(url,{},data).then(function(_this){return function(login){var params;return params={auth_token:login.auth_token},login.$get("user").then(function(user){return user=_this.setLogin(user),deferred.resolve(user)})}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},isLoggedIn:function(){var deferred;return deferred=$q.defer(),this.checkLogin().then(function(){return $rootScope.user?deferred.resolve(!0):deferred.reject(!1)},function(err){return deferred.reject(!1)}),deferred.promise},setLogin:function(user){var auth_token;return user=new BBModel.Admin.User(user),auth_token=user.getOption("auth_token"),$sessionStorage.setItem("user",user.$toStore()),$sessionStorage.setItem("auth_token",auth_token),$rootScope.user=user,user},user:function(){return this.checkLogin().then(function(){return $rootScope.user})},checkLogin:function(params){var auth_token,defer,href,options,url,user;return null==params&&(params={}),defer=$q.defer(),$rootScope.user&&defer.resolve(),user=$sessionStorage.getItem("user"),user?($rootScope.user=new BBModel.Admin.User(halClient.createResource(user)),defer.resolve()):(auth_token=$cookies.get("Auth-Token"),auth_token?(url=$rootScope.bb.api_url?$rootScope.bb.api_url+"/api/v1/login{?id,role}":"/api/v1/login{?id,role}",params.id=params.companyId||params.company_id,params.role="admin",href=new UriTemplate(url).fillFromObject(params||{}),options={auth_token:auth_token},halClient.$get(href,options).then(function(_this){return function(login){return login.$has("administrator")?login.$get("administrator").then(function(user){return $rootScope.user=new BBModel.Admin.User(user),defer.resolve()}):defer.resolve()}}(this),function(){return defer.resolve()})):defer.resolve()),defer.promise},logout:function(){var defer,url;return defer=$q.defer(),url=$rootScope.bb.api_url+"/api/v1/login",halClient.$del(url)["finally"](function(){return $rootScope.user=null,$sessionStorage.removeItem("user"),$sessionStorage.removeItem("auth_token"),$cookies.remove("Auth-Token"),shared_header.del("auth_token"),defer.resolve()},function(){return defer.reject()}),defer.promise},getLogin:function(options){var defer,url;return defer=$q.defer(),url=$rootScope.bb.api_url+"/api/v1/login/admin/"+options.company_id,halClient.$get(url,options).then(function(_this){return function(login){return login.$has("administrator")?login.$get("administrator").then(function(user){return user=_this.setLogin(user),defer.resolve(user)},function(err){return defer.reject(err)}):defer.reject()}}(this),function(err){return defer.reject(err)}),defer.promise},setCompany:function(company_id){var defer,params,url;return defer=$q.defer(),url=$rootScope.bb.api_url+"/api/v1/login/admin",params={company_id:company_id},halClient.$put(url,{},params).then(function(_this){return function(login){return login.$has("administrator")?login.$get("administrator").then(function(user){return user=_this.setLogin(user),defer.resolve(user)},function(err){return defer.reject(err)}):defer.reject()}}(this),function(err){return defer.reject(err)}),defer.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminPurchaseService",["$q","halClient","BBModel",function($q,halClient,BBModel){return{query:function(params){var defer,uri;return defer=$q.defer(),uri=params.url_root+"/api/v1/admin/purchases/"+params.purchase_id,halClient.$get(uri,params).then(function(purchase){return purchase=new BBModel.Purchase.Total(purchase),defer.resolve(purchase)},function(err){return defer.reject(err)}),defer.promise},markAsPaid:function(params){var company_id,data,defer,uri;return defer=$q.defer(),params.purchase&¶ms.url_root?(params.company&&(company_id=params.company.id),uri=params.url_root+("/api/v1/admin/"+company_id+"/purchases/"+params.purchase.id+"/pay"),data={},params.company&&(data.company_id=params.company.id),params.notify_admin&&(data.notify_admin=params.notify_admin),params.payment_status&&(data.payment_status=params.payment_status),params.amount&&(data.amount=params.amount),params.notes&&(data.notes=params.notes),params.transaction_id&&(data.transaction_id=params.transaction_id),params.notify&&(data.notify=params.notify),params.payment_type&&(data.payment_type=params.payment_type),halClient.$put(uri,params,data).then(function(purchase){return purchase=new BBModel.Purchase.Total(purchase),defer.resolve(purchase)},function(err){return defer.reject(err)}),defer.promise):(defer.reject("invalid request"),defer.promise)}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminSlotService",["$q","$window","halClient","SlotCollections","BBModel","UriTemplate",function($q,$window,halClient,SlotCollections,BBModel,UriTemplate){return{query:function(prms){var deferred,existing,href,uri,url;return deferred=$q.defer(),existing=SlotCollections.find(prms),existing?deferred.resolve(existing):prms.user?prms.user.$get("company").then(function(company){return company.$get("slots",prms).then(function(slots_collection){return slots_collection.$get("slots").then(function(slots){var s,slot_models;return slot_models=function(){var i,len,results;for(results=[],i=0,len=slots.length;len>i;i++)s=slots[i],results.push(new BBModel.Admin.Slot(s));return results}(),deferred.resolve(slot_models)},function(err){return deferred.reject(err)})})}):(url="",prms.url&&(url=prms.url),href=url+"/api/v1/admin/{company_id}/slots{?start_date,end_date,date,service_id,resource_id,person_id,page,per_page}",uri=new UriTemplate(href).fillFromObject(prms||{}),halClient.$get(uri,{}).then(function(_this){return function(found){return found.$get("slots").then(function(items){var i,item,len,sitems,slots;for(sitems=[],i=0,len=items.length;len>i;i++)item=items[i],sitems.push(new BBModel.Admin.Slot(item));return slots=new $window.Collection.Slot(found,sitems,prms),SlotCollections.add(slots),deferred.resolve(slots)})}}(this),function(_this){return function(err){return deferred.reject(err)}}(this))),deferred.promise},create:function(prms,data){var deferred,href,uri,url;return url="",prms.url&&(url=prms.url),href=url+"/api/v1/admin/{company_id}/slots",uri=new UriTemplate(href).fillFromObject(prms||{}),deferred=$q.defer(),halClient.$post(uri,{},data).then(function(_this){return function(slot){return slot=new BBModel.Admin.Slot(slot),SlotCollections.checkItems(slot),deferred.resolve(slot)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},"delete":function(item){var deferred;return deferred=$q.defer(),item.$del("self").then(function(_this){return function(slot){return slot=new BBModel.Admin.Slot(slot),SlotCollections.deleteItems(slot),deferred.resolve(slot)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},update:function(item,data){var deferred;return deferred=$q.defer(),item.$put("self",{},data).then(function(_this){return function(slot){return slot=new BBModel.Admin.Slot(slot),SlotCollections.checkItems(slot),deferred.resolve(slot)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminTimeService",["$q","$window","halClient","BBModel","UriTemplate",function($q,$window,halClient,BBModel,UriTemplate){return{query:function(prms){var deferred,href,uri,url;return prms.day&&(prms.date=prms.day.date),!prms.edate&&prms.date&&(prms.edate=prms.date),url="",prms.url&&(url=prms.url),href=url+"/api/v1/{company_id}/time_data{?date,event_id,service_id,person_id}",uri=new UriTemplate(href).fillFromObject(prms||{}),deferred=$q.defer(),halClient.$get(uri,{no_cache:!1}).then(function(_this){return function(found){return found.$get("events").then(function(events){var event,eventItem,eventItems,i,j,len,len1,ref,time,ts;for(eventItems=[],i=0,len=events.length;len>i;i++){for(eventItem=events[i],event={},event.times=[],event.event_id=eventItem.event_id,event.person_id=found.person_id,ref=eventItem.times,j=0,len1=ref.length;len1>j;j++)time=ref[j],ts=new BBModel.TimeSlot(time),event.times.push(ts);eventItems.push(event)}return deferred.resolve(eventItems)})}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){"use strict";angular.module("BB.Services").factory("BB.Service.login",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Login(resource)}}}]),angular.module("BB.Services").factory("BB.Service.base_login",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Login(resource)}}}])}.call(this),function(){"use strict";angular.module("BBAdmin").config(["$translateProvider",function($translateProvider){"ngInject";var translations;translations={ADMIN:{CANCEL_BOOKING_MODAL:{TITLE:"Cancel Booking",REASON_LBL:"Cancel reason",SEND_EMAIL_LBL:"Send cancellation confirmation to {{email}}?",OK_BTN:"@:COMMON.BTN.OK",CLOSE_BTN:"@:COMMON.BTN.CLOSE"},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"},PICK_COMPANY:{STEP_SUMMARY:"Pick Company",SELECT_BTN:"@:COMMON.BTN.SELECT"},BOOKNG_TABLE:{NEW_BOOKING_BTN:"New booking",EDIT_BTN:"@:COMMON.BTN.EDIT"}}},$translateProvider.translations("en",translations)}])}.call(this);