'use strict';var overlord=angular.module("overlord",["overlord.directive","overlord.filter","overlord.service","ngCookies"]).config(["$routeProvider","$locationProvider",function(a,c){a.when("/",{templateUrl:"/partial/home.html"}).when("/login",{templateUrl:"/partial/login.html",controller:LoginCtrl}).when("/logout",{templateUrl:"/partial/home.html",controller:LogoutCtrl}).when("/Journal",{templateUrl:"/partial/journal.html",controller:JournalCtrl,resolve:JournalCtrl.resolve}).when("/Journal/:id",
{templateUrl:"/partial/journal.html",controller:JournalCtrl,resolve:JournalCtrl.resolve}).when("/Payment",{templateUrl:"/partial/payment.html",controller:PaymentCtrl,resolve:PaymentCtrl.resolve}).when("/Payment/:id",{templateUrl:"/partial/payment.html",controller:PaymentCtrl,resolve:PaymentCtrl.resolve}).when("/Receipt",{templateUrl:"/partial/receipt.html",controller:ReceiptCtrl,resolve:ReceiptCtrl.resolve}).when("/Receipt/:id",{templateUrl:"/partial/receipt.html",controller:ReceiptCtrl,resolve:ReceiptCtrl.resolve}).when("/Purchase",
{templateUrl:"/partial/purchase.html",controller:PurchaseCtrl,resolve:PurchaseCtrl.resolve}).when("/Purchase/:id",{templateUrl:"/partial/purchase.html",controller:PurchaseCtrl,resolve:PurchaseCtrl.resolve}).when("/Return",{templateUrl:"/partial/purchase-return.html",controller:PurchaseReturnCtrl,resolve:PurchaseReturnCtrl.resolve}).when("/Return/:id",{templateUrl:"/partial/purchase-return.html",controller:PurchaseReturnCtrl,resolve:PurchaseReturnCtrl.resolve}).when("/Issue",{templateUrl:"/partial/issue.html",
controller:IssueCtrl,resolve:IssueCtrl.resolve}).when("/Issue/:id",{templateUrl:"/partial/issue.html",controller:IssueCtrl,resolve:IssueCtrl.resolve}).when("/Ledger",{templateUrl:"/partial/ledger.html",controller:LedgerCtrl,resolve:LedgerCtrl.resolve}).when("/Ledger/:id",{templateUrl:"/partial/ledger.html",controller:LedgerCtrl,resolve:LedgerCtrl.resolve}).when("/ProductLedger",{templateUrl:"/partial/product-ledger.html",controller:ProductLedgerCtrl,resolve:ProductLedgerCtrl.resolve}).when("/ProductLedger/:id",
{templateUrl:"/partial/product-ledger.html",controller:ProductLedgerCtrl,resolve:ProductLedgerCtrl.resolve}).when("/CashFlow",{templateUrl:"/partial/cash-flow.html",controller:CashFlowCtrl,resolve:CashFlowCtrl.resolve}).when("/CashFlow/:id",{templateUrl:"/partial/cash-flow.html",controller:CashFlowCtrl,resolve:CashFlowCtrl.resolve}).when("/RawMaterialCost",{templateUrl:"/partial/raw-material-cost.html",controller:RawMaterialCostCtrl,resolve:RawMaterialCostCtrl.resolve}).when("/RawMaterialCost/:id",
{templateUrl:"/partial/raw-material-cost-detail.html",controller:RawMaterialCostCtrl,resolve:RawMaterialCostCtrl.resolve}).when("/Attendance",{templateUrl:"/partial/attendance.html",controller:AttendanceCtrl,resolve:AttendanceCtrl.resolve}).when("/Attendance/:date",{templateUrl:"/partial/attendance.html",controller:AttendanceCtrl,resolve:AttendanceCtrl.resolve}).when("/EmployeeAttendance",{templateUrl:"/partial/employee-attendance.html",controller:EmployeeAttendanceCtrl,resolve:EmployeeAttendanceCtrl.resolve}).when("/EmployeeAttendance/:id",
{templateUrl:"/partial/employee-attendance.html",controller:EmployeeAttendanceCtrl,resolve:EmployeeAttendanceCtrl.resolve}).when("/Daybook",{templateUrl:"/partial/daybook.html",controller:DaybookCtrl,resolve:DaybookCtrl.resolve}).when("/Unposted",{templateUrl:"/partial/unposted.html",controller:UnpostedCtrl,resolve:UnpostedCtrl.resolve}).when("/ProfitLoss",{templateUrl:"/partial/profit-loss.html",controller:ProfitLossCtrl,resolve:ProfitLossCtrl.resolve}).when("/PurchaseEntries",{templateUrl:"/partial/purchase-entries.html",
controller:PurchaseEntriesCtrl,resolve:PurchaseEntriesCtrl.resolve}).when("/EmployeeFunctions",{templateUrl:"/partial/employee-functions.html",controller:EmployeeFunctionsCtrl}).when("/TrialBalance",{templateUrl:"/partial/trial-balance.html",controller:TrialBalanceCtrl,resolve:TrialBalanceCtrl.resolve}).when("/TrialBalance/:date",{templateUrl:"/partial/trial-balance.html",controller:TrialBalanceCtrl,resolve:TrialBalanceCtrl.resolve}).when("/ClosingStock",{templateUrl:"/partial/closing-stock.html",
controller:ClosingStockCtrl,resolve:ClosingStockCtrl.resolve}).when("/ClosingStock/:date",{templateUrl:"/partial/closing-stock.html",controller:ClosingStockCtrl,resolve:ClosingStockCtrl.resolve}).when("/Accounts",{templateUrl:"/partial/account-list.html",controller:AccountListCtrl,resolve:AccountListCtrl.resolve}).when("/Account",{templateUrl:"/partial/account-detail.html",controller:AccountCtrl,resolve:AccountCtrl.resolve}).when("/Account/:id",{templateUrl:"/partial/account-detail.html",controller:AccountCtrl,
resolve:AccountCtrl.resolve}).when("/Employees",{templateUrl:"/partial/employee-list.html",controller:EmployeeListCtrl,resolve:EmployeeListCtrl.resolve}).when("/Employee",{templateUrl:"/partial/employee-detail.html",controller:EmployeeCtrl,resolve:EmployeeCtrl.resolve}).when("/Employee/:id",{templateUrl:"/partial/employee-detail.html",controller:EmployeeCtrl,resolve:EmployeeCtrl.resolve}).when("/CostCenters",{templateUrl:"/partial/cost-center-list.html",controller:CostCenterListCtrl,resolve:CostCenterListCtrl.resolve}).when("/CostCenter",
{templateUrl:"/partial/cost-center-detail.html",controller:CostCenterCtrl,resolve:CostCenterCtrl.resolve}).when("/CostCenter/:id",{templateUrl:"/partial/cost-center-detail.html",controller:CostCenterCtrl,resolve:CostCenterCtrl.resolve}).when("/Products",{templateUrl:"/partial/product-list.html",controller:ProductListCtrl,resolve:ProductListCtrl.resolve}).when("/Product",{templateUrl:"/partial/product-detail.html",controller:ProductCtrl,resolve:ProductCtrl.resolve}).when("/Product/:id",{templateUrl:"/partial/product-detail.html",
controller:ProductCtrl,resolve:ProductCtrl.resolve}).when("/ProductGroups",{templateUrl:"/partial/product-group-list.html",controller:ProductGroupListCtrl,resolve:ProductGroupListCtrl.resolve}).when("/ProductGroup",{templateUrl:"/partial/product-group-detail.html",controller:ProductGroupCtrl,resolve:ProductGroupCtrl.resolve}).when("/ProductGroup/:id",{templateUrl:"/partial/product-group-detail.html",controller:ProductGroupCtrl,resolve:ProductGroupCtrl.resolve}).when("/Users",{templateUrl:"/partial/user-list.html",
controller:UserListCtrl,resolve:UserListCtrl.resolve}).when("/User",{templateUrl:"/partial/user-detail.html",controller:UserCtrl,resolve:UserCtrl.resolve}).when("/User/:id",{templateUrl:"/partial/user-detail.html",controller:UserCtrl,resolve:UserCtrl.resolve}).when("/Groups",{templateUrl:"/partial/group-list.html",controller:GroupListCtrl,resolve:GroupListCtrl.resolve}).when("/Group",{templateUrl:"/partial/group-detail.html",controller:GroupCtrl,resolve:GroupCtrl.resolve}).when("/Group/:id",{templateUrl:"/partial/group-detail.html",
controller:GroupCtrl,resolve:GroupCtrl.resolve}).when("/Clients",{templateUrl:"/partial/client-list.html",controller:ClientCtrl,resolve:ClientCtrl.resolve}).otherwise({templateUrl:"/partial/404.html"});c.html5Mode(!0).hashPrefix("!")}]).config(["$httpProvider",function(a){a.responseInterceptors.push("spinnerInterceptor");a.defaults.transformRequest.push(function(a,b){var d=angular.injector(["ng"]).get("$rootScope");"application/json"===b()["Content-Type"]&&d&&d.$broadcast("spinnerStart","http");return a})}]).factory("spinnerInterceptor",
["$q","$rootScope",function(a,c){return function(b){return b.then(function(a){"application/json; charset=utf-8"===a.headers()["content-type"]&&c.$broadcast("spinnerStop","http");return a},function(b){var e="application/json; charset=utf-8"===b.headers()["content-type"];e&&c.$broadcast("spinnerStop","http");401==b.status&&!e&&c.$broadcast("event:loginRequired");return a.reject(b)})}}]);
overlord.controller("BaseCtrl",["$rootScope","$scope","Auth","$location","$routeParams",function(a,c,b,d,e){a.spinner={http:0,route:!1};a.$on("event:loginRequired",function(){if(a.auth.isAuthenticated)d.path("/");else{var b=e.came_from;"undefined"===typeof b&&"/login"!==d.path()&&(b=d.path());d.path("/login").search({came_from:b})}});c.$on("spinnerStart",function(b,c){"http"===c?a.spinner.http+=1:a.spinner.route=!1;$("#spinner").show()});c.$on("spinnerStop",function(b,c){"http"===c?a.spinner.http-=
1:a.spinner.route=!1;0>=a.spinner.http&&!1===a.spinner.route&&$("#spinner").hide()});c.toasts=[];c.clearToast=function(a){var b=c.toasts.indexOf(a);-1!==b&&this.destroy(function(){c.toasts.splice(b,1)})};a.$on("$routeChangeStart",function(){a.$broadcast("spinnerStart","route");b.get(function(b){a.auth=b;a.perms=b.perms})});a.$on("$routeChangeSuccess",function(){a.$broadcast("spinnerStop","route")});a.$on("$routeChangeError",function(){a.$broadcast("spinnerStop","route")})}]);
var overlord_directive=angular.module("overlord.directive",[]);overlord_directive.directive("ngAutocomplete",["$q","$parse",function(a,c){return{restrict:"A",link:function(b,d,e){d.autocomplete({source:function(c,d){var f=angular.injector(["overlord.service"]).get(e.resource),h=a.defer();h.promise.then(function(a){d(a)});f.autocomplete({term:c.term,count:20},function(a){b.$apply(function(){h.resolve(a)})})},minLength:1,autoFocus:!0,select:function(a,d){var f=c(e.model).assign;f(b,d.item.model);b.$apply()}})}}}]);
overlord_directive.directive("datepicker",["$parse",function(a){return{restrict:"E",replace:!0,transclude:!0,template:'<input type="text" />',link:function(c,b,d){b.datepicker({dateFormat:"dd-M-yy",showOtherMonths:!0,selectOtherMonths:!0,onSelect:function(b){var g=a(d.model).assign;g(c,b);c.$apply()}})}}}]);overlord_directive.directive("fadey",function(){return{restrict:"A",link:function(a,c){c=jQuery(c);c.hide();c.fadeIn(500);a.destroy=function(b){c.fadeOut(500,function(){b&&b.apply(a)})}}}});
overlord_directive.directive("ngConfirm",["modal","$parse",function(a,c){return{restrict:"A",link:function(b,d,e){var g={};"undefined"!==typeof e.url?d.bind("click",function(){if("undefined"!==typeof e.before){var d=c(e.before);b.$apply(function(){d(b)})}a.template(e.url,e.onAction,e.onCancel,b,g)}):d.bind("click",function(){a.confirm(e.title,e.actionText,{text:e.actionButtonText,click:e.actionFunction,"class":e["class"]},{text:e.cancelButtonText,click:e.cancelFunction},b,g)})}}}]);
(function(){var a={transclude:"element",priority:1E3,terminal:!0,compile:function(a,b,d){return function(a,b,c){b[0].doNotMove=!0;var f,h;a.$watch(c.ngmIf,function(c){f&&(f.remove(),f=null);h&&h.$destroy();c&&(h=a.$new(),d(h,function(a){f=a;b.after(a)}));b.parent().trigger("$childrenChanged")})}}};overlord_directive.directive("ngmIf",function(){return a})})(angular);
overlord_directive.directive("journal-edit",function(){return{restrict:"A",replace:!0,transclude:!0,templateUrl:"/partial/journal-modal.html",link:function(a,c,b){c.bind("click",function(){modal.confirm(b.title,b.actionText,{text:b.actionButtonText,click:b.actionFunction,"class":b["class"]},{text:b.cancelButtonText,click:b.cancelFunction},a,options)})}}});
overlord_directive.directive("ngEditRepeat",["modal","$parse",function(a,c){return{restrict:"E",template:'<div class="btn-group">    <a class="btn btn-danger" ng-click="removeJournal(journal)"><i class="icon-trash icon-white"></i> Delete</a>    <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>    <ul class="dropdown-menu">        <li><a ng-confirm url="/partial/journal-modal.html" before="toggleEdit(journal)" on-action="toggleEdit(journal, true)" on-cancel="toggleEdit(journal, false)"><i class="icon-pencil"></i> Edit</a></li>    </ul></div>',link:function(b,
d,e){var g={};"undefined"!==typeof e.url?d.bind("click",function(){if("undefined"!==typeof e.before){var d=c(e.before);b.$apply(function(){d(b)})}a.template(e.url,e.onAction,e.onCancel,b,g)}):d.bind("click",function(){a.confirm(e.title,e.actionText,{text:e.actionButtonText,click:e.actionFunction,"class":e["class"]},{text:e.cancelButtonText,click:e.cancelFunction},b,g)})}}}]);
var AttendanceCtrl=["$scope","$location","Attendance","attendance_types","info",function(a,c,b,d,e){a.attendance_types=d;a.info=e;a.show=function(){c.path("/Attendance/"+a.info.Date)};a.save=function(){a.info.$save(function(b){a.toasts.push({Type:"Success",Message:b.Code})},function(b){a.toasts.push({Type:"Error",Message:b.data})})};$("#txtDate").focus()}];
AttendanceCtrl.resolve={info:["$q","$route","Attendance",function(a,c,b){var d=a.defer(),a=c.current.params.date,c=function(a){d.resolve(a)};"undefined"===typeof a?b.get({},c):b.get({date:a},c);return d.promise}],attendance_types:["$q","AttendanceTypes",function(a,c){var b=a.defer();c.query({},function(a){b.resolve(a)});return b.promise}]};var AccountListCtrl=["$scope","accounts",function(a,c){a.info=c}];
AccountListCtrl.resolve={accounts:["$q","$route","Account",function(a,c,b){var d=a.defer();b.query({},function(a){d.resolve(a)});return d.promise}]};
var AccountCtrl=["$scope","$location","account","account_types","cost_centers",function(a,c,b,d,e){a.account=b;a.account_types=d;a.cost_centers=e;a.save=function(){a.account.$save(function(){a.toasts.push({Type:"Success",Message:""});c.path("/Accounts")},function(b){a.toasts.push({Type:"Error",Message:b.data})})};a.delete=function(){a.account.$delete(function(){a.toasts.push({Type:"Success",Message:""});c.path("/Accounts")},function(b){a.toasts.push({Type:"Error",Message:b.data})})};$("#txtName").focus()}];
AccountCtrl.resolve={account:["$q","$route","Account",function(a,c,b){var d=a.defer();b.get({id:c.current.params.id},function(a){d.resolve(a)});return d.promise}],account_types:["$q","AccountType",function(a,c){var b=a.defer();c.query({},function(a){b.resolve(a)});return b.promise}],cost_centers:["$q","CostCenter",function(a,c){var b=a.defer();c.query({},function(a){b.resolve(a)});return b.promise}]};