Separated all controllers into their own files
This commit is contained in:
1 parent
ec9798f401
commit
d05625ba39
36 files changed
+677
-680
No files matched your search
@@ -0,0 +1,80 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('AccountListController', AccountListController);
|
||||
|
||||
AccountListController.$inject = ['$scope', '$location', '$routeParams', 'Tokenizer', 'accounts'];
|
||||
function AccountListController($scope, $location, $routeParams, Tokenizer, accounts) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.info = accounts;
|
||||
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterAccounts(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
't': {'Col': 'Type', 'Comparator': 'text'},
|
||||
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
|
||||
'r': {'Col': 'IsReconcilable', 'Comparator': 'boolean'},
|
||||
'c': {'Col': 'CostCentre', 'Comparator': 'text'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'n': 'Name',
|
||||
't': 'Type',
|
||||
'a': 'IsActive',
|
||||
'r': 'IsReconcilable',
|
||||
'c': 'CostCentre'
|
||||
}
|
||||
};
|
||||
$scope.filterAccounts = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Accounts').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Accounts').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
|
||||
$scope.accounts = Tokenizer.doFilter(q, $scope.info, matches);
|
||||
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.accounts.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.accounts.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.accounts.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.accounts.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
AccountListResolver.$inject = ['Account'];
|
||||
function AccountListResolver(Account) {
|
||||
return Account.query({}).$promise;
|
||||
}
|
||||
@@ -1,91 +1,8 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('AccountListController', AccountListController);
|
||||
|
||||
AccountListController.$inject = ['$scope', '$location', '$routeParams', 'Tokenizer', 'accounts'];
|
||||
|
||||
function AccountListController($scope, $location, $routeParams, Tokenizer, accounts) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.info = accounts;
|
||||
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterAccounts(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
't': {'Col': 'Type', 'Comparator': 'text'},
|
||||
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
|
||||
'r': {'Col': 'IsReconcilable', 'Comparator': 'boolean'},
|
||||
'c': {'Col': 'CostCentre', 'Comparator': 'text'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'n': 'Name',
|
||||
't': 'Type',
|
||||
'a': 'IsActive',
|
||||
'r': 'IsReconcilable',
|
||||
'c': 'CostCentre'
|
||||
}
|
||||
};
|
||||
$scope.filterAccounts = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Accounts').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Accounts').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
|
||||
$scope.accounts = Tokenizer.doFilter(q, $scope.info, matches);
|
||||
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.accounts.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.accounts.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.accounts.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.accounts.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function AccountListResolver(Account) {
|
||||
return Account.query({}).$promise;
|
||||
}
|
||||
AccountListResolver.$inject = ['Account'];
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('AccountController', AccountController);
|
||||
|
||||
AccountController.$inject = ['$scope', '$location', '$uibModal', 'account', 'accountTypes', 'costCentres'];
|
||||
|
||||
function AccountController($scope, $location, $modal, account, accountTypes, costCentres) {
|
||||
$scope.account = account;
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('AttendanceSubController', AttendanceSubController);
|
||||
|
||||
AttendanceSubController.$inject = ['$scope'];
|
||||
function AttendanceSubController($scope) {
|
||||
$scope.original = {};
|
||||
angular.copy($scope.item, $scope.original);
|
||||
|
||||
$scope.isLabel = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
$scope.isError = function () {
|
||||
return $scope.item.Worked === 'Error';
|
||||
};
|
||||
|
||||
$scope.isGood = function () {
|
||||
return $scope.item.Worked === true;
|
||||
};
|
||||
|
||||
$scope.isBad = function () {
|
||||
return $scope.item.Worked === false;
|
||||
};
|
||||
|
||||
$scope.isDirty = function () {
|
||||
return !angular.equals($scope.original, $scope.item);
|
||||
};
|
||||
}
|
||||
@@ -27,37 +27,7 @@ function AttendanceController($scope, $location, asDate, Attendance, attendanceT
|
||||
$scope.foDate = true;
|
||||
}
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('AttendanceSubController', AttendanceSubController);
|
||||
|
||||
AttendanceSubController.$inject = ['$scope'];
|
||||
function AttendanceSubController($scope) {
|
||||
$scope.original = {};
|
||||
angular.copy($scope.item, $scope.original);
|
||||
|
||||
$scope.isLabel = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
$scope.isError = function () {
|
||||
return $scope.item.Worked === 'Error';
|
||||
};
|
||||
|
||||
$scope.isGood = function () {
|
||||
return $scope.item.Worked === true;
|
||||
};
|
||||
|
||||
$scope.isBad = function () {
|
||||
return $scope.item.Worked === false;
|
||||
};
|
||||
|
||||
$scope.isDirty = function () {
|
||||
return !angular.equals($scope.original, $scope.item);
|
||||
};
|
||||
}
|
||||
|
||||
AttendanceController.resolve = {
|
||||
tendanceController.resolve = {
|
||||
info: ['$route', 'Attendance', function ($route, Attendance) {
|
||||
var date = $route.current.params.date;
|
||||
if (angular.isUndefined(date)) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ClientListController', ClientListController);
|
||||
|
||||
ClientListController.$inject = ['$scope', 'clients'];
|
||||
function ClientListController($scope, clients) {
|
||||
$scope.info = clients;
|
||||
}
|
||||
|
||||
ClientListController.resolve = {
|
||||
clients: ['Client', function (Client) {
|
||||
return Client.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,19 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ClientListController', ClientListController);
|
||||
|
||||
ClientListController.$inject = ['$scope', 'clients'];
|
||||
function ClientListController($scope, clients) {
|
||||
$scope.info = clients;
|
||||
}
|
||||
|
||||
ClientListController.resolve = {
|
||||
clients: ['Client', function (Client) {
|
||||
return Client.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ClientController', ClientController);
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('CostCentreListController', CostCentreListController);
|
||||
|
||||
CostCentreListController.$inject = ['$scope', 'costCentres'];
|
||||
function CostCentreListController($scope, costCentres) {
|
||||
$scope.info = costCentres;
|
||||
}
|
||||
|
||||
CostCentreListController.resolve = {
|
||||
costCentres: ['CostCentre', function (CostCentre) {
|
||||
return CostCentre.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,19 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('CostCentreListController', CostCentreListController);
|
||||
|
||||
CostCentreListController.$inject = ['$scope', 'costCentres'];
|
||||
function CostCentreListController($scope, costCentres) {
|
||||
$scope.info = costCentres;
|
||||
}
|
||||
|
||||
CostCentreListController.resolve = {
|
||||
costCentres: ['CostCentre', function (CostCentre) {
|
||||
return CostCentre.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('CostCentreController', CostCentreController);
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('EmployeeListController', EmployeeListController);
|
||||
|
||||
EmployeeListController.$inject = ['$scope', '$location', '$routeParams', 'Tokenizer', 'employees'];
|
||||
function EmployeeListController($scope, $location, $routeParams, Tokenizer, employees) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.info = employees;
|
||||
|
||||
$scope.$watch('search', function (newValue, oldValue) {
|
||||
$scope.filterEmployees(newValue);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
'c': {'Col': 'Code', 'Comparator': 'numeric'},
|
||||
's': {'Col': 'Salary', 'Comparator': 'numeric'},
|
||||
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
|
||||
'des': {'Col': 'Designation', 'Comparator': 'text'},
|
||||
'dep': {'Col': 'CostCentre', 'Comparator': 'text'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'n': 'Name',
|
||||
'c': 'Code',
|
||||
's': 'Salary',
|
||||
'a': 'IsActive',
|
||||
'des': 'Designation',
|
||||
'dep': 'CostCentre'
|
||||
}
|
||||
};
|
||||
$scope.filterEmployees = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Employees').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Employees').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
|
||||
$scope.employees = Tokenizer.doFilter(q, $scope.info, matches);
|
||||
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.employees.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.employees.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.employees.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.employees.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
EmployeeListController.resolve = {
|
||||
employees: ['Employee', function (Employee) {
|
||||
return Employee.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,88 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('EmployeeListController', EmployeeListController);
|
||||
|
||||
EmployeeListController.$inject = ['$scope', '$location', '$routeParams', 'Tokenizer', 'employees'];
|
||||
function EmployeeListController($scope, $location, $routeParams, Tokenizer, employees) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.info = employees;
|
||||
|
||||
$scope.$watch('search', function (newValue, oldValue) {
|
||||
$scope.filterEmployees(newValue);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
'c': {'Col': 'Code', 'Comparator': 'numeric'},
|
||||
's': {'Col': 'Salary', 'Comparator': 'numeric'},
|
||||
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
|
||||
'des': {'Col': 'Designation', 'Comparator': 'text'},
|
||||
'dep': {'Col': 'CostCentre', 'Comparator': 'text'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'n': 'Name',
|
||||
'c': 'Code',
|
||||
's': 'Salary',
|
||||
'a': 'IsActive',
|
||||
'des': 'Designation',
|
||||
'dep': 'CostCentre'
|
||||
}
|
||||
};
|
||||
$scope.filterEmployees = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Employees').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Employees').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
|
||||
$scope.employees = Tokenizer.doFilter(q, $scope.info, matches);
|
||||
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.employees.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.employees.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.employees.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.employees.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
EmployeeListController.resolve = {
|
||||
employees: ['Employee', function (Employee) {
|
||||
return Employee.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('EmployeeController', EmployeeController);
|
||||
EmployeeController.$inject = ['$scope', '$routeParams', '$location', 'asDateFilter', '$uibModal', 'employee', 'costCentres', 'uibDateParser'];
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('GroupListController', GroupListController);
|
||||
GroupListController.$inject = ['$scope', 'groups'];
|
||||
function GroupListController($scope, groups) {
|
||||
$scope.info = groups;
|
||||
}
|
||||
|
||||
GroupListController.resolve = {
|
||||
groups: ['Group', function (Group) {
|
||||
return Group.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,18 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('GroupListController', GroupListController);
|
||||
GroupListController.$inject = ['$scope', 'groups'];
|
||||
function GroupListController($scope, groups) {
|
||||
$scope.info = groups;
|
||||
}
|
||||
|
||||
GroupListController.resolve = {
|
||||
groups: ['Group', function (Group) {
|
||||
return Group.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('GroupController', GroupController);
|
||||
GroupController.$inject = ['$scope', '$location', 'group'];
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('IssueModalController', IssueModalController);
|
||||
IssueModalController.$inject = ['$scope', '$uibModalInstance', 'edit', 'Batch'];
|
||||
function IssueModalController($scope, $modalInstance, edit, Batch) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Product = $scope.edit.Batch.Product;
|
||||
$scope.edit.Quantity = Number($scope.edit.Quantity);
|
||||
$scope.edit.Tax = $scope.edit.Batch.Tax;
|
||||
$scope.edit.Discount = $scope.edit.Batch.Discount;
|
||||
$scope.edit.Rate = $scope.edit.Batch.Rate;
|
||||
$scope.edit.Amount = $scope.edit.Quantity * $scope.edit.Rate * (1 + $scope.edit.Tax) * (1 - $scope.edit.Discount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
return Batch.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -292,26 +292,3 @@ IssueController.resolve = {
|
||||
return CostCentre.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('IssueModalController', IssueModalController);
|
||||
IssueModalController.$inject = ['$scope', '$uibModalInstance', 'edit', 'Batch'];
|
||||
function IssueModalController($scope, $modalInstance, edit, Batch) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Product = $scope.edit.Batch.Product;
|
||||
$scope.edit.Quantity = Number($scope.edit.Quantity);
|
||||
$scope.edit.Tax = $scope.edit.Batch.Tax;
|
||||
$scope.edit.Discount = $scope.edit.Batch.Discount;
|
||||
$scope.edit.Rate = $scope.edit.Batch.Rate;
|
||||
$scope.edit.Amount = $scope.edit.Quantity * $scope.edit.Rate * (1 + $scope.edit.Tax) * (1 - $scope.edit.Discount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
return Batch.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('JournalModalController', JournalModalController);
|
||||
JournalModalController.$inject = ['$scope', '$uibModalInstance', 'mathSolver', 'edit', 'Account'];
|
||||
function JournalModalController($scope, $modalInstance, mathSolver, edit, Account) {
|
||||
$scope.toggleDebit = function () {
|
||||
$scope.edit.Debit = ($scope.edit.Debit === 1) ? -1 : 1;
|
||||
};
|
||||
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = mathSolver($scope.edit.Amount);
|
||||
if ($scope.edit.Amount < 0) {
|
||||
$scope.edit.Debit *= -1;
|
||||
$scope.edit.Amount *= -1;
|
||||
}
|
||||
else if (Number.isNaN($scope.edit.Amount)) {
|
||||
$scope.edit.Amount = 0;
|
||||
}
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
return Account.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -213,32 +213,3 @@ JournalController.resolve = {
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('JournalModalController', JournalModalController);
|
||||
JournalModalController.$inject = ['$scope', '$uibModalInstance', 'mathSolver', 'edit', 'Account'];
|
||||
function JournalModalController($scope, $modalInstance, mathSolver, edit, Account) {
|
||||
$scope.toggleDebit = function () {
|
||||
$scope.edit.Debit = ($scope.edit.Debit === 1) ? -1 : 1;
|
||||
};
|
||||
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = mathSolver($scope.edit.Amount);
|
||||
if ($scope.edit.Amount < 0) {
|
||||
$scope.edit.Debit *= -1;
|
||||
$scope.edit.Amount *= -1;
|
||||
}
|
||||
else if (Number.isNaN($scope.edit.Amount)) {
|
||||
$scope.edit.Amount = 0;
|
||||
}
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
return Account.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -33,19 +33,3 @@ function LoginController($scope, $http, $location, $routeParams, $cookies) {
|
||||
};
|
||||
$scope.foUsername = true;
|
||||
}
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('LogoutController', LogoutController);
|
||||
LogoutController.$inject = ['$scope', '$http', '$location'];
|
||||
function LogoutController($scope, $http, $location) {
|
||||
$http.
|
||||
post('/logout').
|
||||
then(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Logged out'});
|
||||
$location.path('/');
|
||||
}).
|
||||
catch(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage.data});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('LogoutController', LogoutController);
|
||||
LogoutController.$inject = ['$scope', '$http', '$location'];
|
||||
function LogoutController($scope, $http, $location) {
|
||||
$http.
|
||||
post('/logout').
|
||||
then(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Logged out'});
|
||||
$location.path('/');
|
||||
}).
|
||||
catch(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage.data});
|
||||
});
|
||||
}
|
||||
@@ -40,4 +40,4 @@ NetTransactionsController.resolve = {
|
||||
return NetTransactions.get({StartDate: startDate, FinishDate: finishDate}).$promise;
|
||||
}
|
||||
}]
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('PaymentModalController', PaymentModalController);
|
||||
PaymentModalController.$inject = ['$scope', '$uibModalInstance', 'mathSolver', 'edit', 'Account'];
|
||||
function PaymentModalController($scope, $modalInstance, mathSolver, edit, Account) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = mathSolver($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
return Account.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -214,21 +214,3 @@ PaymentController.resolve = {
|
||||
return Account.autocomplete({term: '', type: 1}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('PaymentModalController', PaymentModalController);
|
||||
PaymentModalController.$inject = ['$scope', '$uibModalInstance', 'mathSolver', 'edit', 'Account'];
|
||||
function PaymentModalController($scope, $modalInstance, mathSolver, edit, Account) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = mathSolver($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
return Account.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ProductGroupListController', ProductGroupListController);
|
||||
ProductGroupListController.$inject = ['$scope', 'productGroups'];
|
||||
function ProductGroupListController($scope, productGroups) {
|
||||
$scope.info = productGroups;
|
||||
}
|
||||
|
||||
ProductGroupListController.resolve = {
|
||||
productGroups: ['ProductGroup', function (ProductGroup) {
|
||||
return ProductGroup.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,18 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ProductGroupListController', ProductGroupListController);
|
||||
ProductGroupListController.$inject = ['$scope', 'productGroups'];
|
||||
function ProductGroupListController($scope, productGroups) {
|
||||
$scope.info = productGroups;
|
||||
}
|
||||
|
||||
ProductGroupListController.resolve = {
|
||||
productGroups: ['ProductGroup', function (ProductGroup) {
|
||||
return ProductGroup.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ProductGroupController', ProductGroupController);
|
||||
ProductGroupController.$inject = ['$scope', '$location', 'productGroup'];
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ProductListController', ProductListController);
|
||||
ProductListController.$inject = ['$scope', '$location', '$routeParams', 'Tokenizer', 'products'];
|
||||
function ProductListController($scope, $location, $routeParams, Tokenizer, products) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.showExtended = false;
|
||||
$scope.info = products;
|
||||
$scope.product_groups = _.reduce(products, function (acculumator, item) {
|
||||
if (!acculumator.includes(item.ProductGroup)) {
|
||||
acculumator.push(item.ProductGroup);
|
||||
}
|
||||
return acculumator;
|
||||
}, []).sort();
|
||||
$scope.isPurchased = function (isPurchased) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._isPurchased;
|
||||
}
|
||||
$scope._isPurchased = isPurchased;
|
||||
var re = /(('[p]'|"[p]"|[p]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = isPurchased === 'null' ? '' : 'p:' + isPurchased,
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.isSold = function (isSold) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._isSold;
|
||||
}
|
||||
$scope._isSold = isSold;
|
||||
var re = /(('[s]'|"[s]"|[s]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = isSold === 'null' ? '' : 's:' + isSold,
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.productGroup = function (productGroup) {
|
||||
if (arguments.length === 0) {
|
||||
|
||||
return $scope._productGroup;
|
||||
}
|
||||
$scope._productGroup = productGroup;
|
||||
var re = /(('[t]'|"[t]"|[t]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = 't:"' + productGroup + '"',
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterProducts(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
'u': {'Col': 'Units', 'Comparator': 'text'},
|
||||
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
|
||||
's': {'Col': 'IsSold', 'Comparator': 'boolean'},
|
||||
'p': {'Col': 'IsPurchased', 'Comparator': 'boolean'},
|
||||
't': {'Col': 'ProductGroup', 'Comparator': 'text'},
|
||||
'y': {'Col': 'ProductYield', 'Comparator': 'numeric'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'c': 'Code',
|
||||
'n': 'Name',
|
||||
'u': 'Units',
|
||||
'p': 'Price',
|
||||
't': 'ProductGroup',
|
||||
'a': 'IsActive',
|
||||
'y': 'ProductYield',
|
||||
'f': 'Fraction',
|
||||
'fu': 'FractionUnits'
|
||||
},
|
||||
flags: {
|
||||
'e': 'boolean'
|
||||
}
|
||||
};
|
||||
$scope.filterProducts = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Products').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Products').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
|
||||
$scope.showExtended = 'e' in matches.f;
|
||||
$scope.products = Tokenizer.doFilter(q, $scope.info, matches);
|
||||
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.products.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.products.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.products.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.products.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ProductListController.resolve = {
|
||||
products: ['Product', function (Product) {
|
||||
return Product.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,138 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ProductListController', ProductListController);
|
||||
ProductListController.$inject = ['$scope', '$location', '$routeParams', 'Tokenizer', 'products'];
|
||||
function ProductListController($scope, $location, $routeParams, Tokenizer, products) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.showExtended = false;
|
||||
$scope.info = products;
|
||||
$scope.product_groups = _.reduce(products, function (acculumator, item) {
|
||||
if (!acculumator.includes(item.ProductGroup)) {
|
||||
acculumator.push(item.ProductGroup);
|
||||
}
|
||||
return acculumator;
|
||||
}, []).sort();
|
||||
$scope.isPurchased = function (isPurchased) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._isPurchased;
|
||||
}
|
||||
$scope._isPurchased = isPurchased;
|
||||
var re = /(('[p]'|"[p]"|[p]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = isPurchased === 'null' ? '' : 'p:' + isPurchased,
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.isSold = function (isSold) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._isSold;
|
||||
}
|
||||
$scope._isSold = isSold;
|
||||
var re = /(('[s]'|"[s]"|[s]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = isSold === 'null' ? '' : 's:' + isSold,
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.productGroup = function (productGroup) {
|
||||
if (arguments.length === 0) {
|
||||
|
||||
return $scope._productGroup;
|
||||
}
|
||||
$scope._productGroup = productGroup;
|
||||
var re = /(('[t]'|"[t]"|[t]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = 't:"' + productGroup + '"',
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterProducts(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
'u': {'Col': 'Units', 'Comparator': 'text'},
|
||||
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
|
||||
's': {'Col': 'IsSold', 'Comparator': 'boolean'},
|
||||
'p': {'Col': 'IsPurchased', 'Comparator': 'boolean'},
|
||||
't': {'Col': 'ProductGroup', 'Comparator': 'text'},
|
||||
'y': {'Col': 'ProductYield', 'Comparator': 'numeric'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'c': 'Code',
|
||||
'n': 'Name',
|
||||
'u': 'Units',
|
||||
'p': 'Price',
|
||||
't': 'ProductGroup',
|
||||
'a': 'IsActive',
|
||||
'y': 'ProductYield',
|
||||
'f': 'Fraction',
|
||||
'fu': 'FractionUnits'
|
||||
},
|
||||
flags: {
|
||||
'e': 'boolean'
|
||||
}
|
||||
};
|
||||
$scope.filterProducts = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Products').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Products').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
|
||||
$scope.showExtended = 'e' in matches.f;
|
||||
$scope.products = Tokenizer.doFilter(q, $scope.info, matches);
|
||||
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.products.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.products.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.products.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.products.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ProductListController.resolve = {
|
||||
products: ['Product', function (Product) {
|
||||
return Product.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ProductController', ProductController);
|
||||
ProductController.$inject = ['$scope', '$location', '$window', '$mdDialog', 'product', 'productGroups'];
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('PurchaseReturnModalController', PurchaseReturnModalController);
|
||||
PurchaseReturnModalController.$inject = ['$scope', '$uibModalInstance', 'edit', 'Batch'];
|
||||
function PurchaseReturnModalController($scope, $modalInstance, edit, Batch) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Product = $scope.edit.Batch.Product;
|
||||
$scope.edit.Quantity = Number($scope.edit.Quantity);
|
||||
$scope.edit.Tax = $scope.edit.Batch.Tax;
|
||||
$scope.edit.Discount = $scope.edit.Batch.Discount;
|
||||
$scope.edit.Rate = $scope.edit.Batch.Rate;
|
||||
$scope.edit.Amount = $scope.edit.Quantity * $scope.edit.Rate * (1 + $scope.edit.Tax) * (1 - $scope.edit.Discount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
return Batch.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -200,27 +200,3 @@ PurchaseReturnController.resolve = {
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('PurchaseReturnModalController', PurchaseReturnModalController);
|
||||
PurchaseReturnModalController.$inject = ['$scope', '$uibModalInstance', 'edit', 'Batch'];
|
||||
function PurchaseReturnModalController($scope, $modalInstance, edit, Batch) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Product = $scope.edit.Batch.Product;
|
||||
$scope.edit.Quantity = Number($scope.edit.Quantity);
|
||||
$scope.edit.Tax = $scope.edit.Batch.Tax;
|
||||
$scope.edit.Discount = $scope.edit.Batch.Discount;
|
||||
$scope.edit.Rate = $scope.edit.Batch.Rate;
|
||||
$scope.edit.Amount = $scope.edit.Quantity * $scope.edit.Rate * (1 + $scope.edit.Tax) * (1 - $scope.edit.Discount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
return Batch.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('PurchaseModalController', PurchaseModalController);
|
||||
PurchaseModalController.$inject = ['$scope', '$uibModalInstance', 'edit', 'Product'];
|
||||
function PurchaseModalController($scope, $modalInstance, edit, Product) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Quantity = Number(edit.Quantity);
|
||||
$scope.edit.Tax = ($scope.edit.Tax) ? Number($scope.edit.Tax) : 0;
|
||||
$scope.edit.Discount = ($scope.edit.Discount) ? Number($scope.edit.Discount) : 0;
|
||||
$scope.edit.Rate = Number($scope.edit.Rate);
|
||||
$scope.edit.Amount = $scope.edit.Quantity * $scope.edit.Rate * (1 + $scope.edit.Tax) * (1 - $scope.edit.Discount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.products = function ($viewValue) {
|
||||
return Product.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -203,25 +203,3 @@ PurchaseController.resolve = {
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('PurchaseModalController', PurchaseModalController);
|
||||
PurchaseModalController.$inject = ['$scope', '$uibModalInstance', 'edit', 'Product'];
|
||||
function PurchaseModalController($scope, $modalInstance, edit, Product) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Quantity = Number(edit.Quantity);
|
||||
$scope.edit.Tax = ($scope.edit.Tax) ? Number($scope.edit.Tax) : 0;
|
||||
$scope.edit.Discount = ($scope.edit.Discount) ? Number($scope.edit.Discount) : 0;
|
||||
$scope.edit.Rate = Number($scope.edit.Rate);
|
||||
$scope.edit.Amount = $scope.edit.Quantity * $scope.edit.Rate * (1 + $scope.edit.Tax) * (1 - $scope.edit.Discount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.products = function ($viewValue) {
|
||||
return Product.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ReceiptModalController', ReceiptModalController);
|
||||
ReceiptModalController.$inject = ['$scope', '$uibModalInstance', 'mathSolver', 'edit', 'Account'];
|
||||
function ReceiptModalController($scope, $modalInstance, mathSolver, edit, Account) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = mathSolver($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
return Account.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -213,21 +213,3 @@ ReceiptController.resolve = {
|
||||
return Account.autocomplete({term: '', type: 1}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('ReceiptModalController', ReceiptModalController);
|
||||
ReceiptModalController.$inject = ['$scope', '$uibModalInstance', 'mathSolver', 'edit', 'Account'];
|
||||
function ReceiptModalController($scope, $modalInstance, mathSolver, edit, Account) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = mathSolver($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
return Account.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('RecipeListController', RecipeListController);
|
||||
RecipeListController.$inject = ['$scope', 'recipes', '$location', '$routeParams', '$filter', 'Tokenizer'];
|
||||
function RecipeListController($scope, recipes, $location, $routeParams, $filter, Tokenizer) {
|
||||
$scope.info = recipes;
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.product_groups = _.reduce(recipes, function (acculumator, item) {
|
||||
if (!acculumator.includes(item.ProductGroup)){
|
||||
acculumator.push(item.ProductGroup);
|
||||
}
|
||||
return acculumator;
|
||||
},[]).sort();
|
||||
|
||||
$scope.startDate = function (startDate) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._startDate;
|
||||
}
|
||||
$scope._startDate = startDate;
|
||||
var re = /(('[s]'|"[s]"|[s]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = startDate === null ? '' : 's:>=' + moment(startDate).format('DD-MMM-YYYY');
|
||||
$scope.search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
};
|
||||
|
||||
$scope.finishDate = function (finishDate) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._finishDate;
|
||||
}
|
||||
$scope._finishDate = finishDate;
|
||||
var re = /(('[f]'|"[f]"|[f]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = finishDate === null ? '' : 'f:<=' + moment(finishDate).format('DD-MMM-YYYY');
|
||||
$scope.search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
};
|
||||
|
||||
$scope.productGroup = function (productGroup) {
|
||||
if (arguments.length === 0) {
|
||||
|
||||
return $scope._productGroup;
|
||||
}
|
||||
$scope._productGroup = productGroup;
|
||||
var re = /(('[t]'|"[t]"|[t]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = 't:"' + productGroup + '"',
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterRecipes(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
't': {'Col': 'ProductGroup', 'Comparator': 'text'},
|
||||
's': {'Col': 'Prices.ValidFrom', 'Comparator': 'date'},
|
||||
'f': {'Col': 'Prices.ValidTo', 'Comparator': 'date'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'n': 'Name',
|
||||
't': 'ProductGroup',
|
||||
's': 'Prices.ValidFrom',
|
||||
'f': 'Prices.ValidTo',
|
||||
'c': 'Prices.Costing',
|
||||
'cp': 'Prices.CostPrice',
|
||||
'sp': 'Prices.SalePrice'
|
||||
},
|
||||
flags: {}
|
||||
};
|
||||
|
||||
$scope.filterRecipes = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Recipes').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Recipes').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
$scope.recipes = $scope.doFilter(q);
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
$scope.doFilter = function (q) {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo),
|
||||
array = angular.copy($scope.info);
|
||||
|
||||
array = $scope.subFilter(null, array, matches.q, matches.o);
|
||||
array.forEach(function (prod) {
|
||||
prod.Prices = $scope.subFilter('Prices.', prod.Prices, matches.q, matches.o);
|
||||
});
|
||||
return array;
|
||||
};
|
||||
|
||||
$scope.subFilter = function (prefix, arr, q, o) {
|
||||
q = angular.copy(q);
|
||||
o = angular.copy(o);
|
||||
if (prefix === null) {
|
||||
q = q.filter(x => !x.Col.includes('.'));
|
||||
o = o.filter(x => !x.includes('.'));
|
||||
} else {
|
||||
q = q.filter(x => x.Col.startsWith(prefix));
|
||||
q.forEach(function (x) {x.Col = x.Col.substr(prefix.length)});
|
||||
o = o.filter(x => x.substr(1).startsWith(prefix)).map(x => x[0] + x.substr(prefix.length + 1));
|
||||
}
|
||||
if (q.length !== 0) {
|
||||
arr = arr.filter(item => q.every(exp => exp.Comparator(item[exp.Col], exp.Value)));
|
||||
}
|
||||
return $filter('orderBy')(arr, o);
|
||||
}
|
||||
}
|
||||
|
||||
RecipeListController.resolve = {
|
||||
recipes: ['Recipe', function (Recipe) {
|
||||
return Recipe.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,129 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('RecipeListController', RecipeListController);
|
||||
RecipeListController.$inject = ['$scope', 'recipes', '$location', '$routeParams', '$filter', 'Tokenizer'];
|
||||
function RecipeListController($scope, recipes, $location, $routeParams, $filter, Tokenizer) {
|
||||
$scope.info = recipes;
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.product_groups = _.reduce(recipes, function (acculumator, item) {
|
||||
if (!acculumator.includes(item.ProductGroup)){
|
||||
acculumator.push(item.ProductGroup);
|
||||
}
|
||||
return acculumator;
|
||||
},[]).sort();
|
||||
|
||||
$scope.startDate = function (startDate) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._startDate;
|
||||
}
|
||||
$scope._startDate = startDate;
|
||||
var re = /(('[s]'|"[s]"|[s]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = startDate === null ? '' : 's:>=' + moment(startDate).format('DD-MMM-YYYY');
|
||||
$scope.search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
};
|
||||
|
||||
$scope.finishDate = function (finishDate) {
|
||||
if (arguments.length === 0) {
|
||||
return $scope._finishDate;
|
||||
}
|
||||
$scope._finishDate = finishDate;
|
||||
var re = /(('[f]'|"[f]"|[f]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = finishDate === null ? '' : 'f:<=' + moment(finishDate).format('DD-MMM-YYYY');
|
||||
$scope.search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
};
|
||||
|
||||
$scope.productGroup = function (productGroup) {
|
||||
if (arguments.length === 0) {
|
||||
|
||||
return $scope._productGroup;
|
||||
}
|
||||
$scope._productGroup = productGroup;
|
||||
var re = /(('[t]'|"[t]"|[t]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))/gi,
|
||||
matches = $scope.search.match(re),
|
||||
st = 't:"' + productGroup + '"',
|
||||
search = (matches === null) ? $scope.search.trim() + ' ' + st : $scope.search.replace(re, st);
|
||||
$scope.search = search.trim();
|
||||
};
|
||||
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterRecipes(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
Tokenizer.doFilter.cache = {};
|
||||
});
|
||||
|
||||
$scope.searchInfo = {
|
||||
comparator: {
|
||||
'n': {'Col': 'Name', 'Comparator': 'text'},
|
||||
't': {'Col': 'ProductGroup', 'Comparator': 'text'},
|
||||
's': {'Col': 'Prices.ValidFrom', 'Comparator': 'date'},
|
||||
'f': {'Col': 'Prices.ValidTo', 'Comparator': 'date'}
|
||||
},
|
||||
def: 'n',
|
||||
sorter: {
|
||||
'n': 'Name',
|
||||
't': 'ProductGroup',
|
||||
's': 'Prices.ValidFrom',
|
||||
'f': 'Prices.ValidTo',
|
||||
'c': 'Prices.Costing',
|
||||
'cp': 'Prices.CostPrice',
|
||||
'sp': 'Prices.SalePrice'
|
||||
},
|
||||
flags: {}
|
||||
};
|
||||
|
||||
$scope.filterRecipes = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
$location.path('/Recipes').search('q', null).replace();
|
||||
} else {
|
||||
$location.path('/Recipes').search({'q': q}).replace();
|
||||
}
|
||||
$scope.$apply(function () {
|
||||
$scope.recipes = $scope.doFilter(q);
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
$scope.doFilter = function (q) {
|
||||
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo),
|
||||
array = angular.copy($scope.info);
|
||||
|
||||
array = $scope.subFilter(null, array, matches.q, matches.o);
|
||||
array.forEach(function (prod) {
|
||||
prod.Prices = $scope.subFilter('Prices.', prod.Prices, matches.q, matches.o);
|
||||
});
|
||||
return array;
|
||||
};
|
||||
|
||||
$scope.subFilter = function (prefix, arr, q, o) {
|
||||
q = angular.copy(q);
|
||||
o = angular.copy(o);
|
||||
if (prefix === null) {
|
||||
q = q.filter(x => !x.Col.includes('.'));
|
||||
o = o.filter(x => !x.includes('.'));
|
||||
} else {
|
||||
q = q.filter(x => x.Col.startsWith(prefix));
|
||||
q.forEach(function (x) {x.Col = x.Col.substr(prefix.length)});
|
||||
o = o.filter(x => x.substr(1).startsWith(prefix)).map(x => x[0] + x.substr(prefix.length + 1));
|
||||
}
|
||||
if (q.length !== 0) {
|
||||
arr = arr.filter(item => q.every(exp => exp.Comparator(item[exp.Col], exp.Value)));
|
||||
}
|
||||
return $filter('orderBy')(arr, o);
|
||||
}
|
||||
}
|
||||
|
||||
RecipeListController.resolve = {
|
||||
recipes: ['Recipe', function (Recipe) {
|
||||
return Recipe.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('RecipeController', RecipeController);
|
||||
RecipeController.$inject = ['$scope', '$location', '$window', '$uibModal', 'asDateFilter', 'Product', 'recipe'];
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('UserListController', UserListController);
|
||||
UserListController.$inject = ['$scope', 'users'];
|
||||
function UserListController($scope, users) {
|
||||
$scope.info = users;
|
||||
}
|
||||
|
||||
UserListController.resolve = {
|
||||
users: ['User', function (User) {
|
||||
return User.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
@@ -1,18 +1,4 @@
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('UserListController', UserListController);
|
||||
UserListController.$inject = ['$scope', 'users'];
|
||||
function UserListController($scope, users) {
|
||||
$scope.info = users;
|
||||
}
|
||||
|
||||
UserListController.resolve = {
|
||||
users: ['User', function (User) {
|
||||
return User.query({}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
angular
|
||||
.module('overlord')
|
||||
.controller('UserController', UserController);
|
||||
UserController.$inject = ['$scope', '$location', 'user'];
|
||||
|
||||
@@ -58,34 +58,50 @@
|
||||
|
||||
<script src="/app/overlord.app.js"></script>
|
||||
<script src="/app/account/account.controller.js"></script>
|
||||
<script src="/app/account/account-list.controller.js"></script>
|
||||
<script src="/app/attendance/attendance.controller.js"></script>
|
||||
<script src="/app/attendance/attendance-sub.controller.js"></script>
|
||||
<script src="/app/balance-sheet/balance-sheet.controller.js"></script>
|
||||
<script src="/app/cash-flow/cash-flow.controller.js"></script>
|
||||
<script src="/app/client/client.controller.js"></script>
|
||||
<script src="/app/client/client-list.controller.js"></script>
|
||||
<script src="/app/closing-stock/closing-stock.controller.js"></script>
|
||||
<script src="/app/cost-centre/cost-centre.controller.js"></script>
|
||||
<script src="/app/cost-centre/cost-centre-list.controller.js"></script>
|
||||
<script src="/app/daybook/daybook.controller.js"></script>
|
||||
<script src="/app/employee/employee.controller.js"></script>
|
||||
<script src="/app/employee/employee-list.controller.js"></script>
|
||||
<script src="/app/employee/employee-attendance.controller.js"></script>
|
||||
<script src="/app/employee/employee-functions.controller.js"></script>
|
||||
<script src="/app/group/group.controller.js"></script>
|
||||
<script src="/app/group/group-list.controller.js"></script>
|
||||
<script src="/app/issue/issue.controller.js"></script>
|
||||
<script src="/app/issue/issue-modal.controller.js"></script>
|
||||
<script src="/app/journal/journal.controller.js"></script>
|
||||
<script src="/app/journal/journal-modal.controller.js"></script>
|
||||
<script src="/app/ledger/ledger.controller.js"></script>
|
||||
<script src="/app/login/login.controller.js"></script>
|
||||
<script src="/app/login/logout.controller.js"></script>
|
||||
<script src="/app/net-transactions/net-transactions.controller.js"></script>
|
||||
<script src="/app/payment/payment.controller.js"></script>
|
||||
<script src="/app/payment/payment-modal.controller.js"></script>
|
||||
<script src="/app/product/product.controller.js"></script>
|
||||
<script src="/app/product/product-list.controller.js"></script>
|
||||
<script src="/app/product-group/product-group.controller.js"></script>
|
||||
<script src="/app/product-group/product-group-list.controller.js"></script>
|
||||
<script src="/app/product-ledger/product-ledger.controller.js"></script>
|
||||
<script src="/app/profit-loss/profit-loss.controller.js"></script>
|
||||
<script src="/app/purchase/purchase.controller.js"></script>
|
||||
<script src="/app/purchase/purchase-modal.controller.js"></script>
|
||||
<script src="/app/purchase-entries/purchase-entries.controller.js"></script>
|
||||
<script src="/app/purchase-return/purchase-return.controller.js"></script>
|
||||
<script src="/app/purchase-return/purchase-return-modal.controller.js"></script>
|
||||
<script src="/app/purchases/purchases.controller.js"></script>
|
||||
<script src="/app/raw-material-cost/raw-material-cost.controller.js"></script>
|
||||
<script src="/app/receipt/receipt.controller.js"></script>
|
||||
<script src="/app/receipt/receipt-modal.controller.js"></script>
|
||||
<script src="/app/recipe/recipe.controller.js"></script>
|
||||
<script src="/app/recipe/recipe-list.controller.js"></script>
|
||||
<script src="/app/reconcile/reconcile.controller.js"></script>
|
||||
<script src="/app/salary-deduction/salary-deduction.controller.js"></script>
|
||||
<script src="/app/service-charge/service-charge.controller.js"></script>
|
||||
@@ -94,6 +110,7 @@
|
||||
<script src="/app/trial-balance/trial-balance.controller.js"></script>
|
||||
<script src="/app/unposted/unposted.controller.js"></script>
|
||||
<script src="/app/user/user.controller.js"></script>
|
||||
<script src="/app/user/user-list.controller.js"></script>
|
||||
<script src="/app/home.controller.js"></script>
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user