Rebase: Moved the whole structure down one directory depth.
This commit is contained in:
1 parent
88b641b4f2
commit
bc7b4217cd
359 files changed
No files matched your search
@@ -0,0 +1,99 @@
|
||||
'use strict';
|
||||
|
||||
var AccountListCtrl = ['$scope', 'accounts', function ($scope, accounts) {
|
||||
$scope.info = accounts;
|
||||
}];
|
||||
AccountListCtrl.resolve = {
|
||||
accounts: ['$q', '$route', 'Account', function ($q, $route, Account) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Account.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var AccountCtrl = ['$scope', '$location', '$modal', 'account', 'account_types', 'cost_centers', function ($scope, $location, $modal, account, account_types, cost_centers) {
|
||||
$scope.account = account;
|
||||
|
||||
$scope.account_types = account_types;
|
||||
$scope.cost_centers = cost_centers;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.account.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Accounts')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.account.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Accounts')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Account";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$('#txtName').focus();
|
||||
}]
|
||||
|
||||
AccountCtrl.resolve = {
|
||||
account: ['$q', '$route', 'Account', function ($q, $route, Account) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Account.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
account_types: ['$q', 'AccountType', function ($q, AccountType) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
AccountType.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
cost_centers: ['$q', 'CostCenter', function ($q, CostCenter) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
CostCenter.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
'use strict';
|
||||
|
||||
var overlord_directive = angular.module('overlord.directive', []);
|
||||
overlord_directive.directive('fadey', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
var duration = 500;
|
||||
element = jQuery(element);
|
||||
element.hide();
|
||||
element.fadeIn(duration)
|
||||
|
||||
scope.destroy = function (complete) {
|
||||
element.fadeOut(duration, function () {
|
||||
if (complete) {
|
||||
complete.apply(scope);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
overlord_directive.directive('ngGrowl', ['growl', '$parse', function (growl, $parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
var options = {
|
||||
dismiss_function: attrs["toClose"]
|
||||
};
|
||||
growl.show(element, scope, options);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('aceEditor', ['$parse', function ($parse) {
|
||||
var ACE_EDITOR_CLASS = 'ace-editor';
|
||||
|
||||
function loadAceEditor(element, mode) {
|
||||
var editor = ace.edit(element);
|
||||
editor.session.setMode("ace/mode/" + mode);
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
||||
function valid(editor) {
|
||||
return (Object.keys(editor.getSession().getAnnotations()).length == 0);
|
||||
}
|
||||
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: '?ngModel',
|
||||
transclude: true,
|
||||
template: '<div class="transcluded" ng-transclude></div><div class="' + ACE_EDITOR_CLASS + '"></div>',
|
||||
link: function (scope, element, attrs, ngModel) {
|
||||
var language = attrs['aceEditor'] || 'markdown',
|
||||
editorElement = element.find('.' + ACE_EDITOR_CLASS)[0],
|
||||
editor = loadAceEditor(editorElement, language);
|
||||
|
||||
scope['ace'] = editor;
|
||||
editor.setTheme('ace/theme/chrome');
|
||||
$(editorElement).css("height", "250px");
|
||||
$(editorElement).css("border", "1px solid #ddd");
|
||||
$(editorElement).css("border-radius", "4px");
|
||||
|
||||
if (!ngModel) return; // do nothing if no ngModel
|
||||
|
||||
var getter = $parse(attrs['ngModel']);
|
||||
var setter = getter.assign;
|
||||
|
||||
editor.getSession().setValue(getter(scope));
|
||||
scope.$watch(attrs['ngModel'], function (newValue) {
|
||||
if (editor.getValue() !== newValue) {
|
||||
editor.getSession().setValue(newValue);
|
||||
}
|
||||
});
|
||||
|
||||
editor.getSession().on('change', function () {
|
||||
if (valid(editor)) {
|
||||
// ngModel.$setViewValue(editor.getValue());
|
||||
setter(scope, editor.getValue());
|
||||
scope.$apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chosen', ['$parse', function ($parse) {
|
||||
var linker = function (scope, element, attrs) {
|
||||
var model = attrs['ngModel'],
|
||||
list = attrs['chosen'],
|
||||
createFunction = attrs['createFunction'],
|
||||
options = {};
|
||||
|
||||
if (typeof createFunction !== 'undefined') {
|
||||
options['create_option'] = function (data) {
|
||||
var fn = $parse(attrs['createFunction'] + '("' + data + '")');
|
||||
scope.$apply(function () {
|
||||
fn(scope);
|
||||
});
|
||||
};
|
||||
}
|
||||
scope.$watch(list, function () {
|
||||
element.trigger('liszt:updated');
|
||||
}, true);
|
||||
|
||||
/* Added this in so that you could preselect items */
|
||||
scope.$watch(model, function () {
|
||||
element.trigger("liszt:updated");
|
||||
}, true);
|
||||
|
||||
element.chosen(options);
|
||||
};
|
||||
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: linker
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('keypress', [function () {
|
||||
return function (scope, element, attrs) {
|
||||
var attribute = scope.$eval(attrs.keypress || '{}');
|
||||
for (var k in attribute) {
|
||||
(function (k) {
|
||||
Mousetrap.bind(k, function () {
|
||||
return attribute[k](scope, element);
|
||||
});
|
||||
})(k);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('onReturn', function () {
|
||||
return function (scope, elm, attrs) {
|
||||
elm.bind("keypress", function (event) {
|
||||
if (event.which === 13) {
|
||||
scope.$apply(attrs.onReturn);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
overlord_directive.directive('tanSse', ['$parse', function ($parse) {
|
||||
return{
|
||||
restrict: 'EM',
|
||||
link: function ($scope, element, attrs) {
|
||||
var url = attrs.url,
|
||||
subScope = $scope.$new(),
|
||||
statusSetter = $parse($scope.status).assign;
|
||||
$scope.$on('$destroy', function () {
|
||||
subScope.close();
|
||||
subScope.$destroy();
|
||||
});
|
||||
|
||||
subScope.source = new EventSource(url);
|
||||
subScope.source.onopen = function (e) {
|
||||
statusSetter($scope, 'Open');
|
||||
subScope.$emit('sse:open');
|
||||
};
|
||||
subScope.source.onmessage = function (e) {
|
||||
var data = JSON.parse(e.data);
|
||||
subScope.$emit('sse:message', data);
|
||||
};
|
||||
subScope.source.onerror = function (e) {
|
||||
statusSetter($scope, 'Closed');
|
||||
subScope.$emit('sse:error');
|
||||
};
|
||||
source.addEventListener('message', function (e) {
|
||||
console.log(e.data);
|
||||
}, false);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
'use strict';
|
||||
|
||||
var overlord_filter = angular.module('overlord.filter', []);
|
||||
overlord_filter.filter('debit', function () {
|
||||
return function (input) {
|
||||
if (input == -1) {
|
||||
return 'Cr';
|
||||
} else if (input == 1) {
|
||||
return 'Dr';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('posted', function () {
|
||||
return function (input) {
|
||||
return input === true ? 'Posted' : 'Post';
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('md', function () {
|
||||
var converter = new Showdown.converter();
|
||||
return function (input) {
|
||||
return converter.makeHtml(input || '');
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('save_button', function () {
|
||||
return function (input) {
|
||||
return (!input) ? 'Save' : 'Update';
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('journalDebit', function () {
|
||||
return function (input, debit) {
|
||||
var list = [];
|
||||
if (typeof input !== 'undefined') {
|
||||
for (var i = 0, l = input.length; i < l; i++) {
|
||||
if (input[i].Debit === debit) {
|
||||
list.push(input[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('localTime', function () {
|
||||
var months = {
|
||||
Jan: 1,
|
||||
Feb: 2,
|
||||
Mar: 3,
|
||||
Apr: 4,
|
||||
May: 5,
|
||||
Jun: 6,
|
||||
Jul: 7,
|
||||
Aug: 8,
|
||||
Sep: 9,
|
||||
Oct: 10,
|
||||
Nov: 11,
|
||||
Dec: 12
|
||||
};
|
||||
var months_reverse = {
|
||||
1: 'Jan',
|
||||
2: 'Feb',
|
||||
3: 'Mar',
|
||||
4: 'Apr',
|
||||
5: 'May',
|
||||
6: 'Jun',
|
||||
7: 'Jul',
|
||||
8: 'Aug',
|
||||
9: 'Sep',
|
||||
10: 'Oct',
|
||||
11: 'Nov',
|
||||
12: 'Dec'
|
||||
};
|
||||
|
||||
function padNumber(input, width) {
|
||||
input = input + '';
|
||||
width = width || 2;
|
||||
return input.length >= width ? input : new Array(width - input.length + 1).join('0') + input;
|
||||
}
|
||||
|
||||
return function (input) {
|
||||
if (typeof input === 'undefined') {
|
||||
return '';
|
||||
}
|
||||
var d = input.match(/(\w+)/g);
|
||||
if (d.length !== 5) {
|
||||
return input;
|
||||
}
|
||||
var date = new Date(parseInt(d[2]), months[d[1]] - 1, parseInt(d[0]), parseInt(d[3]), parseInt(d[4])).getTime();
|
||||
date = new Date(date - (new Date().getTimezoneOffset() * 60000));
|
||||
var output = padNumber(date.getDate()) + '-' + months_reverse[date.getMonth() + 1] + '-' + date.getFullYear() + ' ' + padNumber(date.getHours()) + ':' + padNumber(date.getMinutes());
|
||||
return output;
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('percent', ['numberFilter', function (numberFilter) {
|
||||
return function (input) {
|
||||
if (!angular.isNumber(input)) {
|
||||
return input;
|
||||
}
|
||||
return numberFilter(input * 100, 2) + '%';
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_filter.filter('clr', function () {
|
||||
return function (input) {
|
||||
if (input === '\u20B9\u00A00.00' || input === '0.00') {
|
||||
return '';
|
||||
}
|
||||
return input;
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('accounting', ['currencyFilter', function (currencyFilter) {
|
||||
return function (amount) {
|
||||
amount = currencyFilter(amount);
|
||||
if (amount === '') {
|
||||
return '';
|
||||
}
|
||||
if (amount.indexOf('-') !== -1) {
|
||||
return amount.replace('-', '') + '\u00A0Cr';
|
||||
} else {
|
||||
return amount + '\u00A0Dr';
|
||||
}
|
||||
};
|
||||
}]);
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
'use strict';
|
||||
|
||||
var overlord_service = angular.module('overlord.service', ['ngResource']);
|
||||
|
||||
overlord_service.factory('IssueGrid', ['$resource', function ($resource) {
|
||||
return $resource('/api/Issues/Services/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Voucher', ['$resource', function ($resource) {
|
||||
return $resource('/api/Voucher/:id',
|
||||
{id: '@VoucherID'}, {
|
||||
post: {method: 'POST', params: {post: true}}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Account', ['$resource', function ($resource) {
|
||||
return $resource('/api/Account/:id',
|
||||
{id: '@LedgerID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Employee', ['$resource', function ($resource) {
|
||||
return $resource('/api/Employee/:id',
|
||||
{id: '@LedgerID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Ledger', ['$resource', function ($resource) {
|
||||
return $resource('/api/Ledger/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Reconcile', ['$resource', function ($resource) {
|
||||
return $resource('/api/Reconcile/:id', {id: '@Account.LedgerID'});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ProductLedger', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProductLedger/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('CostCenter', ['$resource', function ($resource) {
|
||||
return $resource('/api/CostCenter/:id',
|
||||
{id: '@CostCenterID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('AccountType', ['$resource', function ($resource) {
|
||||
return $resource('/api/AccountTypes');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('User', ['$resource', function ($resource) {
|
||||
return $resource('/api/User/:id',
|
||||
{id: '@UserID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
names: {method: 'GET', params: {names: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Group', ['$resource', function ($resource) {
|
||||
return $resource('/api/Group/:id',
|
||||
{id: '@GroupID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Client', ['$resource', function ($resource) {
|
||||
return $resource('/api/Client/:id',
|
||||
{id: '@ClientID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Product', ['$resource', function ($resource) {
|
||||
return $resource('/api/Product/:id',
|
||||
{id: '@ProductID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Batch', ['$resource', function ($resource) {
|
||||
return $resource('/api/Batch', {}, {
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ProductGroup', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProductGroup/:id',
|
||||
{id: '@ProductGroupID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('CostCenter', ['$resource', function ($resource) {
|
||||
return $resource('/api/CostCenter/:id',
|
||||
{id: '@CostCenterID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('TrialBalance', ['$resource', function ($resource) {
|
||||
return $resource('/api/TrialBalance/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ClosingStock', ['$resource', function ($resource) {
|
||||
return $resource('/api/ClosingStock/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('CashFlow', ['$resource', function ($resource) {
|
||||
return $resource('/api/CashFlow/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Daybook', ['$resource', function ($resource) {
|
||||
return $resource('/api/Daybook');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Unposted', ['$resource', function ($resource) {
|
||||
return $resource('/api/Unposted');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ProfitLoss', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProfitLoss');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('BalanceSheet', ['$resource', function ($resource) {
|
||||
return $resource('/api/BalanceSheet/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('NetTransactions', ['$resource', function ($resource) {
|
||||
return $resource('/api/NetTransactions');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('PurchaseEntries', ['$resource', function ($resource) {
|
||||
return $resource('/api/PurchaseEntries');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('RawMaterialCost', ['$resource', function ($resource) {
|
||||
return $resource('/api/RawMaterialCost/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Auth', ['$resource', function ($resource) {
|
||||
return $resource('/api/Auth', {}, {
|
||||
login: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Attendance', ['$resource', function ($resource) {
|
||||
return $resource('/api/Attendance/:date', {date: '@Date'});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('AttendanceTypes', ['$resource', function ($resource) {
|
||||
return $resource('/api/AttendanceTypes');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('EmployeeAttendance', ['$resource', function ($resource) {
|
||||
return $resource('/api/EmployeeAttendance/:id', {id: '@Employee.LedgerID'});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Account', ['$resource', function ($resource) {
|
||||
return $resource('/api/Account/:id',
|
||||
{id: '@LedgerID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
overlord_service.factory('Message', ['$resource', function ($resource) {
|
||||
return $resource('/api/Message/:id',
|
||||
{id: '@ThreadID'}, {
|
||||
query: {method: 'GET', params: {list: true}}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Tag', ['$resource', function ($resource) {
|
||||
return $resource('/api/Tags');
|
||||
}]);
|
||||
|
||||
overlord_service.service('EventSource', function () {
|
||||
this.status = 'Disconnected';
|
||||
this.Open = function (url) {
|
||||
if (url) {
|
||||
this.url = url;
|
||||
}
|
||||
if (this.url) {
|
||||
this.source = new EventSource(url);
|
||||
if (this.status !== 'Open') {
|
||||
this.source.addEventListener('open', function (e) {
|
||||
this.status = 'Open';
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.DataCallback = function (callback) {
|
||||
this.source.addEventListener('message', function (e) {
|
||||
var data = JSON.parse(e.data);
|
||||
callback(e);
|
||||
}, false);
|
||||
};
|
||||
this.source.addEventListener('error', function (e) {
|
||||
if (e.readyState == EventSource.CLOSED) {
|
||||
this.status = 'Error';
|
||||
}
|
||||
}, false);
|
||||
this.ErrorCallback = function (callback) {
|
||||
this.source.addEventListener('error', callback, false);
|
||||
}
|
||||
|
||||
this.EventCallback = function (event, callback) {
|
||||
this.source.addEventListener(event, callback, false);
|
||||
}
|
||||
|
||||
this.Close = function () {
|
||||
if (this.status === 'Open') {
|
||||
this.source.close();
|
||||
this.status = 'Closed'
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
var AttendanceCtrl = ['$scope', '$location', 'dateFilter', 'Attendance', 'attendance_types', 'info', function ($scope, $location, dateFilter, Attendance, attendance_types, info) {
|
||||
$scope.attendance_types = attendance_types;
|
||||
$scope.info = info;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.Date)) {
|
||||
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/Attendance/' + $scope.info.Date);
|
||||
};
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.info.Date)) {
|
||||
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.info.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: u.Code});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtDate').focus();
|
||||
}]
|
||||
|
||||
var AttendanceSubCtrl = ['$scope', function ($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)
|
||||
}
|
||||
}]
|
||||
|
||||
AttendanceCtrl.resolve = {
|
||||
info: ['$q', '$route', 'Attendance', function ($q, $route, Attendance) {
|
||||
var deferred = $q.defer();
|
||||
var date = $route.current.params.date;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof date === 'undefined') {
|
||||
Attendance.get({}, successCb);
|
||||
} else {
|
||||
Attendance.get({date: date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}],
|
||||
attendance_types: ['$q', 'AttendanceTypes', function ($q, AttendanceTypes) {
|
||||
var deferred = $q.defer();
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
AttendanceTypes.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var BalanceSheetCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, info) {
|
||||
$scope.info = info;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.Date)) {
|
||||
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/BalanceSheet/' + $scope.info.Date);
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}];
|
||||
|
||||
BalanceSheetCtrl.resolve = {
|
||||
info: ['$q', '$route', 'BalanceSheet', function ($q, $route, BalanceSheet) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var date = $route.current.params.date;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof date === 'undefined') {
|
||||
BalanceSheet.get({}, successCb);
|
||||
} else {
|
||||
BalanceSheet.get({date:date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
var CashFlowCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'cash_flow', function ($scope, $routeParams, $location, dateFilter, cash_flow) {
|
||||
$scope.info = cash_flow;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/CashFlow').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}]
|
||||
CashFlowCtrl.resolve = {
|
||||
cash_flow:['$q', '$route', 'CashFlow', function ($q, $route, CashFlow) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
CashFlow.get({}, successCb);
|
||||
} else if (typeof id === 'undefined') {
|
||||
CashFlow.get({StartDate:start_date, FinishDate:finish_date}, successCb);
|
||||
} else {
|
||||
CashFlow.get({id:id, StartDate:start_date, FinishDate:finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
angular.module('localytics.directives', []);
|
||||
|
||||
angular.module('localytics.directives').directive('chosen', ['$timeout', function ($timeout) {
|
||||
var CHOSEN_OPTION_WHITELIST = ['noResultsText', 'allowSingleDeselect', 'disableSearchThreshold', 'disableSearch'],
|
||||
NG_OPTIONS_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w\d]*)|(?:\(\s*([\$\w][\$\w\d]*)\s*,\s*([\$\w][\$\w\d]*)\s*\)))\s+in\s+(.*)$/;
|
||||
|
||||
var isEmpty = function (value) {
|
||||
var key, i, len;
|
||||
if (angular.isArray(value)) {
|
||||
return value.length === 0;
|
||||
} else if (angular.isObject(value)) {
|
||||
for (i = 0, len = value.length; i < len; i++) {
|
||||
key = value[i];
|
||||
if (value.hasOwnProperty(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
var snakeCase = function (input) {
|
||||
return input.replace(/[A-Z]/g, function ($1) {
|
||||
return "_" + ($1.toLowerCase());
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attr) {
|
||||
var match,
|
||||
options = scope.$eval(attr.chosen) || {},
|
||||
valuesExpr;
|
||||
|
||||
angular.forEach(attr, function (value, key) {
|
||||
if (CHOSEN_OPTION_WHITELIST.indexOf(key) > -1) {
|
||||
return options[snakeCase(key)] = scope.$eval(value);
|
||||
}
|
||||
});
|
||||
var startLoading = function () {
|
||||
return element.addClass('loading').attr('disabled', true).trigger('liszt:updated');
|
||||
};
|
||||
var stopLoading = function () {
|
||||
return element.removeClass('loading').attr('disabled', false).trigger('liszt:updated');
|
||||
};
|
||||
var disableWithMessage = function (message) {
|
||||
return element.empty().append("<option selected>" + message + "</option>").attr('disabled', true).trigger('liszt:updated');
|
||||
};
|
||||
$timeout(function () {
|
||||
return element.chosen(options);
|
||||
});
|
||||
if (attr.ngOptions) {
|
||||
match = attr.ngOptions.match(NG_OPTIONS_REGEXP);
|
||||
valuesExpr = match[7];
|
||||
if (angular.isUndefined(scope.$eval(valuesExpr))) {
|
||||
startLoading();
|
||||
}
|
||||
return scope.$watch(valuesExpr, function (newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
stopLoading();
|
||||
if (isEmpty(newVal)) {
|
||||
return disableWithMessage(options.no_results_text || 'No values available');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
@@ -0,0 +1,76 @@
|
||||
'use strict';
|
||||
|
||||
var ClientListCtrl = ['$scope', 'clients', function ($scope, clients) {
|
||||
$scope.info = clients;
|
||||
}]
|
||||
|
||||
ClientListCtrl.resolve = {
|
||||
clients: ['$q', 'Client', function ($q, Client) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Client.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var ClientCtrl = ['$scope', '$location', 'client', function ($scope, $location, client) {
|
||||
$scope.client = client;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.client.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Clients');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.client.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Clients');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Client";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
}]
|
||||
|
||||
ClientCtrl.resolve = {
|
||||
client: ['$q', '$route', 'Client', function ($q, $route, Client) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Client.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var ClosingStockCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, info) {
|
||||
$scope.info = info;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.Date)) {
|
||||
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/ClosingStock/' + $scope.info.Date);
|
||||
};
|
||||
$('#txtDate').focus();
|
||||
}];
|
||||
|
||||
ClosingStockCtrl.resolve = {
|
||||
info:['$q', '$route', 'ClosingStock', function ($q, $route, ClosingStock) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var date = $route.current.params.date;
|
||||
|
||||
var successCb = function(result){
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof date === 'undefined') {
|
||||
ClosingStock.get({}, successCb);
|
||||
} else {
|
||||
ClosingStock.get({date:date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var CostCenterListCtrl = ['$scope', 'cost_centers', function ($scope, cost_centers) {
|
||||
$scope.info = cost_centers;
|
||||
}]
|
||||
|
||||
CostCenterListCtrl.resolve = {
|
||||
cost_centers: ['$q', '$route', 'CostCenter', function ($q, $route, CostCenter) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
CostCenter.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var CostCenterCtrl = ['$scope', '$routeParams', '$location', 'cost_center', function ($scope, $routeParams, $location, cost_center) {
|
||||
$scope.cost_center = cost_center;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.cost_center.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/CostCenters')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.cost_center.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/CostCenters')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
}]
|
||||
|
||||
CostCenterCtrl.resolve = {
|
||||
cost_center: ['$q', '$route', 'CostCenter', function ($q, $route, CostCenter) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
CostCenter.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var DaybookCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, info) {
|
||||
$scope.info = info;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/Daybook').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}]
|
||||
DaybookCtrl.resolve = {
|
||||
info:['$q', '$route', 'Daybook', function ($q, $route, Daybook) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function(result){
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
Daybook.get({}, successCb);
|
||||
} else {
|
||||
Daybook.get({StartDate:start_date, FinishDate:finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
|
||||
var EmployeeAttendanceCtrl = ['$scope', '$location', '$q', '$routeParams', 'dateFilter', 'EmployeeAttendance', 'attendance_types', 'info', 'Employee', function ($scope, $location, $q, $routeParams, dateFilter, EmployeeAttendance, attendance_types, info, Employee) {
|
||||
$scope.attendance_types = attendance_types;
|
||||
$scope.info = info;
|
||||
$scope.show = function () {
|
||||
var id = $scope.info.Employee.LedgerID;
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
var start_date = $scope.info.StartDate;
|
||||
var finish_date = $scope.info.FinishDate;
|
||||
if (id == $routeParams.id && start_date == $routeParams.StartDate && finish_date == $routeParams.FinishDate) {
|
||||
EmployeeAttendance.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
|
||||
$scope.info = data;
|
||||
});
|
||||
}
|
||||
else {
|
||||
$location.path('/EmployeeAttendance/' + $scope.info.Employee.LedgerID).search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.employees = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Employee.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.info.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Saved!'});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtEmployee').focus();
|
||||
}]
|
||||
|
||||
var EmployeeAttendanceSubCtrl = ['$scope', function ($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)
|
||||
}
|
||||
}]
|
||||
EmployeeAttendanceCtrl.resolve = {
|
||||
info: ['$q', '$route', 'EmployeeAttendance', function ($q, $route, EmployeeAttendance) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
if (typeof id === 'undefined') {
|
||||
EmployeeAttendance.get({}, successCb);
|
||||
} else {
|
||||
EmployeeAttendance.get({id: id, StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}],
|
||||
attendance_types: ['$q', 'AttendanceTypes', function ($q, AttendanceTypes) {
|
||||
var deferred = $q.defer();
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
AttendanceTypes.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
var EmployeeFunctionsCtrl = ['$scope', '$http', 'dateFilter', function ($scope, $http, dateFilter) {
|
||||
$scope.record = {};
|
||||
$scope.creditSalary = function () {
|
||||
if (!angular.isDate($scope.salaryMonth)) {
|
||||
return;
|
||||
}
|
||||
var salary_month = dateFilter($scope.salaryMonth, 'dd-MMM-yyyy');
|
||||
$http.
|
||||
post('/api/CreditSalary', {Month: salary_month}).
|
||||
success(function (data) {
|
||||
$scope.toasts.push({Type: 'Success', Message: data.message});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.attendanceRecordUrl = function () {
|
||||
if (!$scope.record.StartDate || !$scope.record.FinishDate) {
|
||||
return;
|
||||
}
|
||||
var start_date = angular.isDate($scope.record.StartDate) ? dateFilter($scope.record.StartDate, 'dd-MMM-yyyy') : $scope.record.StartDate;
|
||||
var finish_date = angular.isDate($scope.record.FinishDate) ? dateFilter($scope.record.FinishDate, 'dd-MMM-yyyy') : $scope.record.FinishDate;
|
||||
|
||||
var url = '/AttendanceReport?StartDate=' + start_date + "&FinishDate=" + finish_date;
|
||||
return url;
|
||||
};
|
||||
$scope.setFile = function (element) {
|
||||
$scope.uploadedFile = element.files[0];
|
||||
};
|
||||
$scope.uploadFingerprints = function () {
|
||||
if (!$scope.uploadedFile) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: 'Please choose a file first!'});
|
||||
return;
|
||||
}
|
||||
var fd = new FormData();
|
||||
fd.append("uploadedFile", $scope.uploadedFile);
|
||||
$http
|
||||
.post('/api/Fingerprint', fd, {
|
||||
headers: {
|
||||
'Content-Type': undefined
|
||||
},
|
||||
transformRequest: angular.identity
|
||||
}).success(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Data uploaded'});
|
||||
}).error(function (data, status, headers, config) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data});
|
||||
});
|
||||
};
|
||||
}];
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
'use strict';
|
||||
|
||||
var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'employees', function ($scope, $location, $routeParams, employees) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.info = employees;
|
||||
var re = /((([^ ]+):\s*('[^':]+'|"[^":]+"|[^ ]+))|[^ ]+[^: '"]*)/g;
|
||||
|
||||
$scope.isTrue = function (value) {
|
||||
value = value.toLowerCase();
|
||||
return !_.any(['f', 'fa', 'fal', 'fals', 'false', 'n', 'no', '0'], function (item) {
|
||||
return item === value;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$watch('search', function (newValue, oldValue) {
|
||||
$scope.filterEmployees(newValue);
|
||||
}, true);
|
||||
|
||||
$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 () {
|
||||
$scope.employees = $scope.doFilter(q);
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
$scope.doFilter = _.memoize(function (q) {
|
||||
var matches = [], i, len;
|
||||
if (angular.isUndefined(q) || q === '') {
|
||||
return $scope.info;
|
||||
}
|
||||
var m = q.match(re);
|
||||
_.forEach(m, function (item) {
|
||||
item = item.toLowerCase();
|
||||
if (item.indexOf(':') === -1) {
|
||||
matches.push({'key': 'n', 'value': item});
|
||||
} else {
|
||||
var key = item.substr(0, item.indexOf(':')).toLowerCase();
|
||||
var value = item.substr(item.indexOf(':') + 1, item.length).trim().toLowerCase();
|
||||
if (value.indexOf("'") === 0 || value.indexOf('"') === 0) {
|
||||
value = value.substring(1, value.length - 2);
|
||||
}
|
||||
if (key !== '' && value !== '' && _.any(['w', 'dep', 'des', 'c'], function (item) {
|
||||
return item === key;
|
||||
})) {
|
||||
matches.push({'key': key, 'value': value});
|
||||
}
|
||||
}
|
||||
});
|
||||
return _.filter($scope.info, function (item) {
|
||||
len = matches.length;
|
||||
for (i = 0; i < len; i++) {
|
||||
var match = matches[i];
|
||||
if (match.key === 'n') {
|
||||
if (item.Name.toLowerCase().indexOf(match.value) === -1) {
|
||||
return false;
|
||||
}
|
||||
} else if (match.key === 'w') {
|
||||
if (item.IsActive !== $scope.isTrue(match.value)) {
|
||||
return false;
|
||||
}
|
||||
} else if (match.key === 'dep') {
|
||||
if (item.CostCenter.toLowerCase().indexOf(match.value) === -1) {
|
||||
return false;
|
||||
}
|
||||
} else if (match.key === 'des') {
|
||||
if (item.Designation.toLowerCase().indexOf(match.value) === -1) {
|
||||
return false;
|
||||
}
|
||||
} else if (match.key === 'c') {
|
||||
if (item.Code.toString().indexOf(match.value) === -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
}];
|
||||
|
||||
EmployeeListCtrl.resolve = {
|
||||
employees: ['$q', '$route', 'Employee', function ($q, $route, Employee) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Employee.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var EmployeeCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal', 'employee', 'cost_centers', function ($scope, $routeParams, $location, dateFilter, $modal, employee, cost_centers) {
|
||||
$scope.employee = employee;
|
||||
|
||||
$scope.cost_centers = cost_centers;
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.employee.JoiningDate)) {
|
||||
$scope.employee.JoiningDate = dateFilter($scope.employee.JoiningDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.employee.LeavingDate)) {
|
||||
$scope.employee.LeavingDate = dateFilter($scope.employee.LeavingDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.employee.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: u.Code});
|
||||
$location.path('/Employees');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.employee.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Employees');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Account";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$('#txtName').focus();
|
||||
}];
|
||||
|
||||
EmployeeCtrl.resolve = {
|
||||
employee: ['$q', '$route', 'Employee', function ($q, $route, Employee) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Employee.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
cost_centers: ['$q', '$route', 'CostCenter', function ($q, $route, CostCenter) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
CostCenter.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var GroupListCtrl = ['$scope', 'groups', function ($scope, groups) {
|
||||
$scope.info = groups;
|
||||
}]
|
||||
|
||||
GroupListCtrl.resolve = {
|
||||
groups: ['$q', 'Group', function ($q, Group) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Group.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var GroupCtrl = ['$scope', '$location', 'group', function ($scope, $location, group) {
|
||||
$scope.group = group;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.group.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Groups')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.group.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Groups')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
}]
|
||||
|
||||
GroupCtrl.resolve = {
|
||||
group: ['$q', '$route', 'Group', function ($q, $route, Group) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Group.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
overlord_service.factory('growl', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) {
|
||||
var growl = {};
|
||||
growl.default_options = {
|
||||
offset: {
|
||||
from: "top",
|
||||
amount: 20
|
||||
},
|
||||
align: "right",
|
||||
width: 250,
|
||||
duration:500,
|
||||
delay: 4000,
|
||||
stackup_spacing: 10
|
||||
};
|
||||
|
||||
growl.show = function (element, scope, options) {
|
||||
var options = jQuery.extend({}, growl.default_options, options);
|
||||
if (options.top_offset) {
|
||||
options.offset = {
|
||||
from: "top",
|
||||
amount: options.top_offset
|
||||
};
|
||||
}
|
||||
var offsetAmount = options.offset.amount;
|
||||
jQuery(".bootstrap-growl").each(function (index) {
|
||||
var offset = parseInt($(this).css(options.offset.from)) + $(this).outerHeight() + options.stackup_spacing;
|
||||
if (isNaN(offset)) {
|
||||
offset = 0;
|
||||
}
|
||||
return offsetAmount = Math.max(offsetAmount, offset);
|
||||
});
|
||||
element.css("position", "fixed");
|
||||
element.css("margin", 0);
|
||||
element.css("z-index", "9999");
|
||||
element.css("display", "none");
|
||||
element.css(options.offset.from, offsetAmount + "px");
|
||||
if (options.width !== "auto") {
|
||||
element.css("width", options.width + "px");
|
||||
}
|
||||
switch (options.align) {
|
||||
case "center":
|
||||
element.css("left", "50%");
|
||||
element.css("margin-left", "-" + (element.outerWidth() / 2) + "px");
|
||||
break;
|
||||
case "left":
|
||||
element.css("left", "20px");
|
||||
break;
|
||||
default:
|
||||
element.css("right", "20px");
|
||||
}
|
||||
element.fadeIn(options.duration);
|
||||
if (options.delay > 0) {
|
||||
$timeout(function () {
|
||||
element.fadeOut(options.duration, function() {
|
||||
scope.$eval(options.dismiss_function);
|
||||
});
|
||||
}, options.delay);
|
||||
}
|
||||
return element;
|
||||
};
|
||||
return growl;
|
||||
}])
|
||||
;
|
||||
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var HomeCtrl = ['$scope', '$location', 'messages', 'Message', function ($scope, $location, messages, Message) {
|
||||
$scope.chosen = messages.Type;
|
||||
$scope.info = messages.Threads;
|
||||
$scope.tags = messages.Tags
|
||||
$scope.getMessages = function (type) {
|
||||
Message.query({type: type}, function (result) {
|
||||
$scope.info = result.Threads;
|
||||
$scope.tags = result.Tags;
|
||||
$scope.chosen = result.Type;
|
||||
});
|
||||
}
|
||||
$scope.getTags = function (tag) {
|
||||
Message.query({type: $scope.Type, tag: tag}, function (result) {
|
||||
$scope.info = result.Threads;
|
||||
$scope.tags = result.Tags;
|
||||
$scope.chosen = result.Type;
|
||||
});
|
||||
}
|
||||
}];
|
||||
HomeCtrl.resolve = {
|
||||
messages: ['$q', '$route', 'Message', function ($q, $route, Message) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Message.query({type: 'open'}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,315 @@
|
||||
'use strict';
|
||||
|
||||
var IssueCtrl = ['$scope', '$routeParams', '$location', '$q', 'dateFilter', 'voucher', 'cost_centers', 'issue_grid', 'IssueGrid', 'Voucher', '$modal', 'Batch', function ($scope, $routeParams, $location, $q, dateFilter, voucher, cost_centers, issue_grid, IssueGrid, Voucher, $modal, Batch) {
|
||||
$scope.voucher = voucher;
|
||||
$scope.cost_centers = cost_centers;
|
||||
$scope.smallGrid = issue_grid;
|
||||
|
||||
if (typeof $routeParams.Source === 'undefined' && typeof $routeParams.Destination === 'undefined' && typeof $routeParams.id === 'undefined') {
|
||||
var date = $scope.voucher.Date;
|
||||
var source = getDebitCredit($scope.voucher.Journals, -1);
|
||||
var destination = getDebitCredit($scope.voucher.Journals, 1);
|
||||
$location.path('/Issue/' + date).search({Source: source, Destination: destination});
|
||||
}
|
||||
|
||||
function getOldInventory(productID, inventories) {
|
||||
for (var i = 0, l = inventories.length; i < l; i++) {
|
||||
if (inventories[i].Product.ProductID === productID) {
|
||||
return inventories[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
var oldInventory = getOldInventory($scope.batch.Product.ProductID, this.voucher.Inventories),
|
||||
quantity = Number($scope.quantity),
|
||||
consumption = (getDebitCredit($scope.voucher.Journals, -1) === '7b845f95-dfef-fa4a-897c-f0baf15284a3');
|
||||
|
||||
if (!$scope.batch || !$scope.batch.Product.ProductID || !quantity) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof oldInventory !== 'undefined' &&
|
||||
oldInventory.Batch.BatchID === $scope.batch.BatchID &&
|
||||
(!consumption || oldInventory.Quantity + quantity <= $scope.batch.QuantityRemaining)) {
|
||||
oldInventory.Quantity += quantity;
|
||||
delete $scope.batch;
|
||||
delete $scope.quantity;
|
||||
$('#txtBatch').focus();
|
||||
}
|
||||
|
||||
if (typeof oldInventory === 'undefined' && (!consumption || quantity <= $scope.batch.QuantityRemaining)) {
|
||||
this.voucher.Inventories.push(
|
||||
{
|
||||
Product: $scope.batch.Product,
|
||||
Quantity: quantity,
|
||||
Rate: $scope.batch.Rate,
|
||||
Tax: $scope.batch.Tax,
|
||||
Discount: $scope.batch.Discount,
|
||||
Amount: quantity * $scope.batch.Rate * (1 + $scope.batch.Tax) * (1 - $scope.batch.Discount),
|
||||
Batch: $scope.batch
|
||||
});
|
||||
delete $scope.batch;
|
||||
delete $scope.quantity;
|
||||
$('#txtBatch').focus();
|
||||
}
|
||||
};
|
||||
$scope.removeInventory = function (inventory) {
|
||||
var index = this.voucher.Inventories.indexOf(inventory);
|
||||
this.voucher.Inventories.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Date', function (newDate, oldDate) {
|
||||
var nDate = angular.isDate(newDate) ? dateFilter(newDate, 'dd-MMM-yyyy') : newDate,
|
||||
oDate = angular.isDate(oldDate) ? dateFilter(oldDate, 'dd-MMM-yyyy') : oldDate;
|
||||
|
||||
|
||||
if (nDate !== oDate && typeof nDate !== 'undefined') {
|
||||
if (typeof $routeParams.Source !== 'undefined' && typeof $routeParams.Destination !== 'undefined' && typeof $routeParams.id !== 'undefined') {
|
||||
$location.path('/Issue/' + nDate).search({Source: $routeParams.Source, Destination: $routeParams.Destination});
|
||||
} else {
|
||||
$scope.smallGrid = IssueGrid.query({date: nDate, Source: $routeParams.Source, Destination: $routeParams.Destination});
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
function getDebitCredit(journals, type) {
|
||||
for (var i = 0, l = journals.length; i < l; i++) {
|
||||
if (journals[i].Debit === type) {
|
||||
return journals[i].CostCenter.CostCenterID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$watch('voucher.Journals', function (newJournals, oldJournals) {
|
||||
if (typeof newJournals === 'undefined' || angular.equals(newJournals, oldJournals)) {
|
||||
return;
|
||||
}
|
||||
if (typeof oldJournals !== 'undefined') {
|
||||
if (getDebitCredit(oldJournals, -1) === getDebitCredit(newJournals, -1) && getDebitCredit(oldJournals, 1) === getDebitCredit(newJournals, 1)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof $routeParams.Source !== 'undefined' && typeof $routeParams.Destination !== 'undefined' && typeof $routeParams.id !== 'undefined') {
|
||||
$location.path('/Issue/' + $scope.voucher.Date).search({Source: getDebitCredit(newJournals, -1), Destination: getDebitCredit(newJournals, 1)});
|
||||
} else {
|
||||
$scope.smallGrid = IssueGrid.query({date: $scope.voucher.Date, Source: getDebitCredit(newJournals, -1), Destination: getDebitCredit(newJournals, 1)});
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.$watch('voucher.Inventories', function (newInventories, oldInventories) {
|
||||
if (typeof newInventories === 'undefined' || typeof oldInventories === 'undefined') {
|
||||
return;
|
||||
}
|
||||
var amount = 0;
|
||||
for (var i = 0, l = newInventories.length; i < l; i++) {
|
||||
amount += newInventories[i].Amount;
|
||||
}
|
||||
for (i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
|
||||
$scope.voucher.Journals[i].Amount = amount;
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.resetVoucher = function (voucherid) {
|
||||
var date = $scope.voucher.Date;
|
||||
var source = getDebitCredit($scope.voucher.Journals, -1);
|
||||
var destination = getDebitCredit($scope.voucher.Journals, 1);
|
||||
$location.path('/Issue/' + date).search({Source: source, Destination: destination});
|
||||
};
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Issue'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({id: voucherid}, function (u, putResponseHeaders) {
|
||||
$location.path('/Issue/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Issue'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$scope.redirectOnSave(u);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
var date = u.Date;
|
||||
var source = getDebitCredit(u.Journals, -1);
|
||||
var destination = getDebitCredit(u.Journals, 1);
|
||||
$location.path('/Issue/' + date).search({Source: source, Destination: destination}).replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$scope.redirectOnSave = function (voucher) {
|
||||
if (typeof $routeParams.Source !== 'undefined' && typeof $routeParams.Destination !== 'undefined' && typeof $routeParams.id !== 'undefined') {
|
||||
Voucher.get({type: 'Issue', Date: $routeParams.id, Source: $routeParams.Source, Destination: $routeParams.Destination}, function (u, putResponseHeaders) {
|
||||
$scope.voucher = u;
|
||||
});
|
||||
$scope.smallGrid = IssueGrid.query({date: $routeParams.id, Source: $routeParams.Source, Destination: $routeParams.Destination});
|
||||
} else {
|
||||
var date = voucher.Date;
|
||||
var source = getDebitCredit(voucher.Journals, -1);
|
||||
var destination = getDebitCredit(voucher.Journals, 1);
|
||||
$location.path('/Issue/' + date).search({Source: source, Destination: destination});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.modal = function (inventory) {
|
||||
$scope.selectedInventory = inventory;
|
||||
var edit = {};
|
||||
angular.copy($scope.selectedInventory, edit);
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/partial/issue-modal.html',
|
||||
controller: IssueModalCtrl,
|
||||
resolve: {edit: function () {
|
||||
return edit;
|
||||
}}
|
||||
});
|
||||
modalInstance.result.then(function (updated) {
|
||||
if (updated.Product.ProductID !== $scope.selectedInventory.Batch.Product.ProductID) {
|
||||
var oldInventory = getOldInventory(updated.Batch.Product.ProductID, $scope.voucher.Inventories);
|
||||
if (typeof oldInventory !== 'undefined') {
|
||||
delete $scope.selectedInventory;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
angular.copy(updated, $scope.selectedInventory);
|
||||
delete $scope.selectedInventory;
|
||||
}, function () {
|
||||
delete $scope.selectedInventory;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.batches = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
var params = {term: $viewValue, count: 20};
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
params.date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
} else {
|
||||
params.date = $scope.voucher.Date;
|
||||
}
|
||||
Batch.autocomplete(params, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
IssueCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var source = $route.current.params.Source;
|
||||
var destination = $route.current.params.Destination;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof source !== 'undefined' && typeof destination !== 'undefined' && typeof id !== 'undefined') {
|
||||
Voucher.get({type: 'Issue', Date: id, Source: source, Destination: destination}, successCb);
|
||||
} else if (typeof source === 'undefined' && typeof destination === 'undefined' && typeof id !== 'undefined') {
|
||||
Voucher.get({id: id}, successCb);
|
||||
} else {
|
||||
Voucher.get({type: 'Issue'}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}],
|
||||
issue_grid: ['$q', '$route', 'IssueGrid', function ($q, $route, IssueGrid) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var source = $route.current.params.Source;
|
||||
var destination = $route.current.params.Destination;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof source !== 'undefined' && typeof destination !== 'undefined' && typeof id !== 'undefined') {
|
||||
IssueGrid.query({date: id, Source: source, Destination: destination}, successCb);
|
||||
} else if (typeof source === 'undefined' && typeof destination === 'undefined' && typeof id !== 'undefined') {
|
||||
IssueGrid.query({date: id}, successCb);
|
||||
} else {
|
||||
deferred.resolve([]);
|
||||
}
|
||||
return deferred.promise;
|
||||
}],
|
||||
cost_centers: ['$q', 'CostCenter', function ($q, CostCenter) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
CostCenter.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var IssueModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Batch', function ($scope, $modalInstance, $q, 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) {
|
||||
var deferred = $q.defer();
|
||||
Batch.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}]
|
||||
@@ -0,0 +1,201 @@
|
||||
'use strict';
|
||||
|
||||
var JournalCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'Account', function ($scope, $location, $q, dateFilter, $modal, voucher, Account) {
|
||||
$('#txtAccount').focus();
|
||||
|
||||
$scope.voucher = voucher;
|
||||
$scope.debit = 1;
|
||||
function getOld(ledgerID, journals) {
|
||||
return _.find(journals, function (journal) {
|
||||
return journal.Ledger.LedgerID === ledgerID;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
if (!$scope.account || !$scope.account.LedgerID || !$scope.amount || Number(!$scope.amount)) {
|
||||
return;
|
||||
}
|
||||
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
|
||||
if (typeof oldJournal !== 'undefined') {
|
||||
var amount = (oldJournal.Debit * oldJournal.Amount) + (parseInt($scope.debit) * Number($scope.amount));
|
||||
if (amount < 0) {
|
||||
oldJournal.Debit = -1;
|
||||
oldJournal.Amount = amount * -1;
|
||||
} else {
|
||||
oldJournal.Debit = 1;
|
||||
oldJournal.Amount = amount;
|
||||
}
|
||||
} else {
|
||||
this.voucher.Journals.push({Debit: $scope.debit, Amount: Number($scope.amount), Ledger: $scope.account});
|
||||
}
|
||||
delete $scope.account;
|
||||
delete $scope.amount;
|
||||
$('#txtAccount').focus();
|
||||
};
|
||||
|
||||
$scope.removeJournal = function (journal) {
|
||||
var index = this.voucher.Journals.indexOf(journal);
|
||||
this.voucher.Journals.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Journals', function (journals, oldValue) {
|
||||
if (!angular.isArray(journals)) {
|
||||
return;
|
||||
}
|
||||
var amount = journals.reduce(function (previousValue, currentValue, index, array) {
|
||||
return previousValue + (currentValue.Amount * currentValue.Debit);
|
||||
}, 0);
|
||||
$scope.amount = Math.abs(amount);
|
||||
}, true);
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof $scope.perms === 'undefined') {
|
||||
return false;
|
||||
} else if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Journal'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID !== $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Journal'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Journal/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Journal').replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
$scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.modal = function (journal) {
|
||||
$scope.selectedJournal = journal;
|
||||
var edit = {};
|
||||
angular.copy($scope.selectedJournal, edit);
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/partial/journal-modal.html',
|
||||
controller: JournalModalCtrl,
|
||||
resolve: {edit: function () {
|
||||
return edit;
|
||||
}}
|
||||
});
|
||||
modalInstance.result.then(function (updated) {
|
||||
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
|
||||
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
|
||||
if (typeof oldJournal !== 'undefined') {
|
||||
delete $scope.selectedJournal;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
angular.copy(updated, $scope.selectedJournal);
|
||||
delete $scope.selectedJournal;
|
||||
}, function () {
|
||||
delete $scope.selectedJournal;
|
||||
}
|
||||
|
||||
)
|
||||
;
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, a: true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
JournalCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Voucher.get({type: 'Journal'}, successCb);
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var JournalModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Account', function ($scope, $modalInstance, $q, edit, Account) {
|
||||
$scope.toggleDebit = function () {
|
||||
$scope.edit.Debit = ($scope.edit.Debit === 1) ? -1 : 1;
|
||||
};
|
||||
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = Number($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
@@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
|
||||
var LedgerCtrl = ['$scope', '$routeParams', '$location', '$q', 'dateFilter', 'ledger', 'Ledger', 'Account', function ($scope, $routeParams, $location, $q, dateFilter, ledger, Ledger, Account) {
|
||||
$scope.info = ledger;
|
||||
$scope.show = function () {
|
||||
var id = $scope.info.Ledger.LedgerID;
|
||||
var start_date = angular.isDate($scope.info.StartDate) ? dateFilter($scope.info.StartDate, 'dd-MMM-yyyy') : $scope.info.StartDate;
|
||||
var finish_date = angular.isDate($scope.info.FinishDate) ? dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy') : $scope.info.FinishDate;
|
||||
if (id === $routeParams.id && start_date === $routeParams.StartDate && finish_date === $routeParams.FinishDate) {
|
||||
Ledger.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
|
||||
$scope.info = data;
|
||||
});
|
||||
} else {
|
||||
$location.path('/Ledger/' + id).search('StartDate', start_date).search('FinishDate', finish_date);
|
||||
}
|
||||
};
|
||||
$scope.downloadTable = function () {
|
||||
var table = $('#gvGrid'),
|
||||
html = table.clone().wrap('<div></div>').parent().html();
|
||||
html = html.replace(/á/g, 'á');
|
||||
window.open('data:application/vnd.ms-excel;charset=UTF-8,' + encodeURIComponent(html));
|
||||
};
|
||||
|
||||
if ($routeParams.id) {
|
||||
$('#gvGrid').focus();
|
||||
} else {
|
||||
$('#txtLedger').focus();
|
||||
}
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = index;
|
||||
};
|
||||
|
||||
$scope.shortcuts = {
|
||||
'up': function () {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected -= 1;
|
||||
});
|
||||
}
|
||||
},
|
||||
'down': function () {
|
||||
if ($scope.selected < $scope.info.Body.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected += 1;
|
||||
});
|
||||
}
|
||||
},
|
||||
'alt+r': function () {
|
||||
console.log('alt+r');
|
||||
},
|
||||
'enter': function () {
|
||||
var path = $scope.info.Body[$scope.selected].Url.replace(/^(?:\/\/|[^\/]+)*/, "");
|
||||
$scope.$apply(function () {
|
||||
$location.path(path).search('StartDate', null).search('FinishDate', null);
|
||||
});
|
||||
},
|
||||
'alt+u': function () {
|
||||
console.log('alt+u');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
LedgerCtrl.resolve = {
|
||||
ledger: ['$q', '$route', 'Ledger', function ($q, $route, Ledger) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Ledger.get({}, successCb);
|
||||
} else {
|
||||
Ledger.get({id: id, StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var LoginCtrl = ['$scope', '$http', '$location', '$routeParams', '$cookieStore', function ($scope, $http, $location, $routeParams, $cookieStore) {
|
||||
$scope.showOTP = false;
|
||||
$scope.submit = function () {
|
||||
if ($scope.showOTP) {
|
||||
var data = {username: $scope.username, password: $scope.password, otp: $scope.otp, ClientName: $scope.name};
|
||||
} else {
|
||||
var data = {username: $scope.username, password: $scope.password};
|
||||
}
|
||||
|
||||
|
||||
$http.
|
||||
post('/api/login', data).
|
||||
success(function () {
|
||||
var came_from = $routeParams.came_from;
|
||||
if (typeof came_from === 'undefined' || came_from === "" || came_from === "/login" || came_from === "/logout") {
|
||||
came_from = "/";
|
||||
}
|
||||
$location.path(came_from).search({});
|
||||
}).
|
||||
error(function (data, status, headers, config) {
|
||||
if (status === 403 && ['Unknown Client', 'OTP not supplied', 'OTP is wrong'].indexOf(data) !== -1) {
|
||||
$scope.showOTP = true;
|
||||
$scope.clientID = $cookieStore.get('ClientID');
|
||||
$scope.$apply();
|
||||
}
|
||||
$scope.toasts.push({Type: 'Danger', Message: data});
|
||||
});
|
||||
};
|
||||
$('#username').focus();
|
||||
}];
|
||||
|
||||
var LogoutCtrl = ['$scope', '$http', '$location', function ($scope, $http, $location) {
|
||||
$http.
|
||||
post('/logout').
|
||||
success(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Logged out'});
|
||||
$location.path('/')
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
|
||||
});
|
||||
}];
|
||||
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
overlord_service.factory('mdService', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) {
|
||||
var growl = {};
|
||||
growl.default_options = {
|
||||
offset: {
|
||||
from: "top",
|
||||
amount: 20
|
||||
},
|
||||
align: "right",
|
||||
width: 250,
|
||||
duration:500,
|
||||
delay: 4000,
|
||||
stackup_spacing: 10
|
||||
};
|
||||
|
||||
growl.show = function (element, scope, options) {
|
||||
var options = jQuery.extend({}, growl.default_options, options);
|
||||
if (options.top_offset) {
|
||||
options.offset = {
|
||||
from: "top",
|
||||
amount: options.top_offset
|
||||
};
|
||||
}
|
||||
var offsetAmount = options.offset.amount;
|
||||
jQuery(".bootstrap-growl").each(function (index) {
|
||||
var offset = parseInt($(this).css(options.offset.from)) + $(this).outerHeight() + options.stackup_spacing;
|
||||
if (isNaN(offset)) {
|
||||
offset = 0;
|
||||
}
|
||||
return offsetAmount = Math.max(offsetAmount, offset);
|
||||
});
|
||||
element.css("position", "fixed");
|
||||
element.css("margin", 0);
|
||||
element.css("z-index", "9999");
|
||||
element.css("display", "none");
|
||||
element.css(options.offset.from, offsetAmount + "px");
|
||||
if (options.width !== "auto") {
|
||||
element.css("width", options.width + "px");
|
||||
}
|
||||
switch (options.align) {
|
||||
case "center":
|
||||
element.css("left", "50%");
|
||||
element.css("margin-left", "-" + (element.outerWidth() / 2) + "px");
|
||||
break;
|
||||
case "left":
|
||||
element.css("left", "20px");
|
||||
break;
|
||||
default:
|
||||
element.css("right", "20px");
|
||||
}
|
||||
element.fadeIn(options.duration);
|
||||
if (options.delay > 0) {
|
||||
$timeout(function () {
|
||||
element.fadeOut(options.duration, function() {
|
||||
scope.$eval(options.dismiss_function);
|
||||
});
|
||||
}, options.delay);
|
||||
}
|
||||
return element;
|
||||
};
|
||||
return growl;
|
||||
}])
|
||||
;
|
||||
@@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
|
||||
var MessageCtrl = ['$scope', '$location', 'dateFilter', 'message', 'tags', 'users', 'priorities', function ($scope, $location, dateFilter, message, tags, users, priorities) {
|
||||
$scope.message = message;
|
||||
$scope.priorities = priorities
|
||||
$scope.tags = tags;
|
||||
$scope.users = users;
|
||||
|
||||
message.Posts.push({Readonly: false});
|
||||
|
||||
$scope.addTag = function (tag) {
|
||||
tags.push(tag);
|
||||
message.Tags.push(tag);
|
||||
};
|
||||
|
||||
$scope.edit = function (post) {
|
||||
post.Readonly = false;
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (!$scope.message.Title.length) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: 'Message Title Blank'});
|
||||
return;
|
||||
}
|
||||
for (var i = 0, l = $scope.message.Posts.length; i < l; i++) {
|
||||
if (angular.isDate($scope.message.Posts[i].Date)) {
|
||||
$scope.message.Posts[i].Date = dateFilter($scope.message.Posts[i].Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.message.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtTitle').focus();
|
||||
}];
|
||||
|
||||
MessageCtrl.resolve = {
|
||||
message: ['$q', '$route', 'Message', function ($q, $route, Message) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Message.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
tags: ['$q', 'Tag', function ($q, Tag) {
|
||||
var deferred = $q.defer();
|
||||
var successCb = function (result) {
|
||||
var len = result.length;
|
||||
var i = 0;
|
||||
var list = []
|
||||
for (i = 0; i < len; i++) {
|
||||
list.push(result[i].Name);
|
||||
}
|
||||
deferred.resolve(list);
|
||||
};
|
||||
Tag.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
users: ['$q', 'User', function ($q, User) {
|
||||
var deferred = $q.defer();
|
||||
var successCb = function (result) {
|
||||
var len = result.length;
|
||||
var i = 0;
|
||||
var list = []
|
||||
for (i = 0; i < len; i++) {
|
||||
list.push(result[i].Name);
|
||||
}
|
||||
deferred.resolve(list);
|
||||
};
|
||||
User.names({}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
priorities: ['$q', function ($q) {
|
||||
var deferred = $q.defer();
|
||||
deferred.resolve([
|
||||
{id: 1, name: 'Critical'},
|
||||
{id: 2, name: 'Urgent'},
|
||||
{id: 3, name: 'Semi-Urgent'},
|
||||
{id: 4, name: 'Normal'},
|
||||
{id: 5, name: 'Below-Normal'},
|
||||
{id: 6, name: 'Casual'}
|
||||
]);
|
||||
return deferred.promise;
|
||||
}]
|
||||
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
var NetTransactionsCtrl = ['$scope', '$location', 'dateFilter', 'net_transactions', function ($scope, $location, dateFilter, net_transactions) {
|
||||
$scope.info = net_transactions;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/NetTransactions').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}];
|
||||
|
||||
NetTransactionsCtrl.resolve = {
|
||||
net_transactions: ['$q', '$route', 'NetTransactions', function ($q, $route, NetTransactions) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
NetTransactions.get({}, successCb);
|
||||
} else {
|
||||
NetTransactions.get({StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,158 @@
|
||||
'use strict';
|
||||
|
||||
var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service', 'ngCookies', 'ngRoute', 'ui.bootstrap', 'chieffancypants.loadingBar'])
|
||||
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
|
||||
$routeProvider.
|
||||
when('/', {templateUrl: '/partial/home.html', controller: HomeCtrl, resolve: HomeCtrl.resolve}).
|
||||
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, reloadOnSearch:false}).
|
||||
when('/Payment/:id', {templateUrl: '/partial/payment.html', controller: PaymentCtrl, resolve: PaymentCtrl.resolve}).
|
||||
|
||||
when('/Receipt', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl, resolve: ReceiptCtrl.resolve, reloadOnSearch:false}).
|
||||
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('/SalaryDeduction', {templateUrl: '/partial/salary-deduction.html', controller: SalaryDeductionCtrl, resolve: SalaryDeductionCtrl.resolve}).
|
||||
when('/SalaryDeduction/:id', {templateUrl: '/partial/salary-deduction.html', controller: SalaryDeductionCtrl, resolve: SalaryDeductionCtrl.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('/Reconcile', {templateUrl: '/partial/reconcile.html', controller: ReconcileCtrl, resolve: ReconcileCtrl.resolve}).
|
||||
when('/Reconcile/:id', {templateUrl: '/partial/reconcile.html', controller: ReconcileCtrl, resolve: ReconcileCtrl.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('/NetTransactions', {templateUrl: '/partial/net-transactions.html', controller: NetTransactionsCtrl, resolve: NetTransactionsCtrl.resolve}).
|
||||
when('/PurchaseEntries', {templateUrl: '/partial/purchase-entries.html', controller: PurchaseEntriesCtrl, resolve: PurchaseEntriesCtrl.resolve}).
|
||||
when('/EmployeeFunctions', {templateUrl: '/partial/employee-functions.html', controller: EmployeeFunctionsCtrl}).
|
||||
|
||||
when('/BalanceSheet', {templateUrl: '/partial/balance-sheet.html', controller: BalanceSheetCtrl, resolve: BalanceSheetCtrl.resolve}).
|
||||
when('/BalanceSheet/:date', {templateUrl: '/partial/balance-sheet.html', controller: BalanceSheetCtrl, resolve: BalanceSheetCtrl.resolve}).
|
||||
|
||||
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, reloadOnSearch:false}).
|
||||
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: ClientListCtrl, resolve: ClientListCtrl.resolve}).
|
||||
when('/Client/:id', {templateUrl: '/partial/client-detail.html', controller: ClientCtrl, resolve: ClientCtrl.resolve}).
|
||||
|
||||
when('/Message', {templateUrl: '/partial/message-detail.html', controller: MessageCtrl, resolve: MessageCtrl.resolve}).
|
||||
when('/Message/:id', {templateUrl: '/partial/message-detail.html', controller: MessageCtrl, resolve: MessageCtrl.resolve}).
|
||||
|
||||
when('/Settings', {templateUrl: '/partial/settings.html', controller: SettingsCtrl, resolve: SettingsCtrl.resolve}).
|
||||
|
||||
otherwise({templateUrl: '/partial/404.html'});
|
||||
$locationProvider.html5Mode(true).hashPrefix('!');
|
||||
}])
|
||||
.config(['$httpProvider', function ($httpProvider) {
|
||||
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
}])
|
||||
.config(['$httpProvider', function ($httpProvider) {
|
||||
$httpProvider.interceptors.push('responseInterceptor');
|
||||
}])
|
||||
.factory('responseInterceptor', ['$q', '$rootScope', function ($q, $rootScope) {
|
||||
return {
|
||||
response: function (response) {
|
||||
return response;
|
||||
},
|
||||
responseError: function (response) {
|
||||
var headers = response.headers(),
|
||||
isResourceResponse = headers['content-type'] === "application/json; charset=utf-8",
|
||||
status = response.status;
|
||||
if (status === 401 && !isResourceResponse) {
|
||||
$rootScope.$broadcast('loginRequired');
|
||||
}
|
||||
// otherwise
|
||||
return $q.reject(response);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord.controller('BaseCtrl', ['$rootScope', '$scope', 'Auth', '$location', '$routeParams', function ($rootScope, $scope, Auth, $location, $routeParams) {
|
||||
$rootScope.$on('loginRequired', function () {
|
||||
if ($rootScope.auth.isAuthenticated) {
|
||||
$location.path('/');
|
||||
} else {
|
||||
var came_from = $routeParams.came_from;
|
||||
if (typeof came_from === 'undefined' && $location.path() !== '/login') {
|
||||
came_from = $location.path();
|
||||
}
|
||||
$location.path('/login').search({came_from: came_from});
|
||||
}
|
||||
});
|
||||
$scope.toasts = [];
|
||||
$scope.clearToast = function (item) {
|
||||
var idx = $scope.toasts.indexOf(item);
|
||||
if (idx !== -1) {
|
||||
$scope.toasts.splice(idx, 1);
|
||||
}
|
||||
};
|
||||
|
||||
$rootScope.$on("$routeChangeStart", function (event, next, current) {
|
||||
Auth.get(function (u, putResponseHeaders) {
|
||||
$rootScope.auth = u;
|
||||
$rootScope.perms = u.perms;
|
||||
});
|
||||
});
|
||||
}]);
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
'use strict';
|
||||
|
||||
var PaymentCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'ledgers', 'Account', function ($scope, $location, $q, dateFilter, $modal, voucher, ledgers, Account) {
|
||||
$('#txtAccount').focus();
|
||||
|
||||
$scope.voucher = voucher;
|
||||
$scope.ledgers = ledgers;
|
||||
function getOld(ledgerID, journals) {
|
||||
return _.find(journals, function (journal) {
|
||||
return journal.Ledger.LedgerID === ledgerID;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
if (!$scope.account || !$scope.account.LedgerID || !$scope.amount || Number(!$scope.amount)) {
|
||||
return;
|
||||
}
|
||||
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
|
||||
if (typeof oldJournal === 'undefined') {
|
||||
this.voucher.Journals.push({Debit: 1, Amount: Number($scope.amount), Ledger: $scope.account});
|
||||
} else {
|
||||
if (oldJournal.Debit === 1) {
|
||||
oldJournal.Amount = oldJournal.Amount + Number($scope.amount);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete $scope.account;
|
||||
delete $scope.amount;
|
||||
$('#txtAccount').focus();
|
||||
};
|
||||
|
||||
$scope.removeJournal = function (journal) {
|
||||
var index = this.voucher.Journals.indexOf(journal);
|
||||
this.voucher.Journals.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Journals', function (journals, oldValue) {
|
||||
var amount = _.chain(journals)
|
||||
.where({'Debit': 1})
|
||||
.reduce(function (sum, item) {
|
||||
return item.Amount + sum;
|
||||
}, 0).value();
|
||||
|
||||
var j = _.find(journals,{'Debit': -1});
|
||||
j.Amount = amount;
|
||||
if (_.find(oldValue, {'Debit': -1}).Ledger.LedgerID !== j.Ledger.LedgerID) {
|
||||
$location.path('/Payment').search({a: j.Ledger.LedgerID}).replace();
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof $scope.perms === 'undefined') {
|
||||
return false;
|
||||
} else if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Payment'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Payment'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Payment/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Payment').replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
$scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.modal = function (journal) {
|
||||
$scope.selectedJournal = journal;
|
||||
var edit = {};
|
||||
angular.copy($scope.selectedJournal, edit);
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/partial/payment-modal.html',
|
||||
controller: PaymentModalCtrl,
|
||||
resolve: {edit: function () {
|
||||
return edit;
|
||||
}}
|
||||
});
|
||||
modalInstance.result.then(function (updated) {
|
||||
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
|
||||
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
|
||||
if (typeof oldJournal !== 'undefined') {
|
||||
delete $scope.selectedJournal;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
angular.copy(updated, $scope.selectedJournal);
|
||||
delete $scope.selectedJournal;
|
||||
}, function () {
|
||||
delete $scope.selectedJournal;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, a: true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
PaymentCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var account = $route.current.params.a;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
var options = {type: 'Payment'};
|
||||
if (!angular.isUndefined(account)) {
|
||||
options.a = account;
|
||||
}
|
||||
Voucher.get(options, successCb);
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}],
|
||||
ledgers: ['$q', 'Account', function ($q, Account) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Account.autocomplete({term: '', type: 1}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
}
|
||||
|
||||
var PaymentModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Account', function ($scope, $modalInstance, $q, edit, Account) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = Number($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var ProductGroupListCtrl = ['$scope', 'product_groups', function ($scope, product_groups) {
|
||||
$scope.info = product_groups;
|
||||
}];
|
||||
|
||||
ProductGroupListCtrl.resolve = {
|
||||
product_groups: ['$q', 'ProductGroup', function ($q, ProductGroup) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
ProductGroup.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var ProductGroupCtrl = ['$scope', '$location', 'product_group', function ($scope, $location, product_group) {
|
||||
$scope.product_group = product_group;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.product_group.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/ProductGroups')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.product_group.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/ProductGroups')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
}];
|
||||
|
||||
ProductGroupCtrl.resolve = {
|
||||
product_group: ['$q', '$route', 'ProductGroup', function ($q, $route, ProductGroup) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
ProductGroup.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', '$q', 'dateFilter', 'product_ledger', 'ProductLedger', 'Product', function ($scope, $routeParams, $location, $q, dateFilter, product_ledger, ProductLedger, Product) {
|
||||
$scope.info = product_ledger;
|
||||
$scope.show = function () {
|
||||
var id = $scope.info.Product.ProductID;
|
||||
var start_date = angular.isDate($scope.info.StartDate) ? dateFilter($scope.info.StartDate, 'dd-MMM-yyyy') : $scope.info.StartDate;
|
||||
var finish_date = angular.isDate($scope.info.FinishDate) ? dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy') : $scope.info.FinishDate;
|
||||
|
||||
if (id === $routeParams.id && start_date === $routeParams.StartDate && finish_date === $routeParams.FinishDate) {
|
||||
ProductLedger.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
|
||||
$scope.info = data;
|
||||
});
|
||||
} else {
|
||||
$location.path('/ProductLedger/' + $scope.info.Product.ProductID).search('StartDate', start_date).search('FinishDate', finish_date);
|
||||
}
|
||||
};
|
||||
$scope.downloadTable = function () {
|
||||
var table = $('#gvGrid'),
|
||||
html = table.clone().wrap('<div></div>').parent().html();
|
||||
html = html.replace(/á/g, 'á');
|
||||
window.open('data:application/vnd.ms-excel;charset=UTF-8,' + encodeURIComponent(html));
|
||||
};
|
||||
|
||||
$scope.products = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Product.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
$('#txtProduct').focus();
|
||||
}];
|
||||
ProductLedgerCtrl.resolve = {
|
||||
product_ledger: ['$q', '$route', 'ProductLedger', function ($q, $route, ProductLedger) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
ProductLedger.get({}, successCb);
|
||||
} else {
|
||||
ProductLedger.get({id: id, StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
var ProductListCtrl = ['$scope', 'products', function ($scope, products) {
|
||||
$scope.info = products;
|
||||
}];
|
||||
|
||||
ProductListCtrl.resolve = {
|
||||
products: ['$q', '$route', 'Product', function ($q, $route, Product) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Product.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var ProductCtrl = ['$scope', '$location', 'product', 'product_groups', function ($scope, $location, product, product_groups) {
|
||||
$scope.product = product;
|
||||
$scope.product_groups = product_groups;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.product.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: u.Code});
|
||||
$location.path('/Products');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.product.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Products');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
}];
|
||||
|
||||
ProductCtrl.resolve = {
|
||||
product: ['$q', '$route', 'Product', function ($q, $route, Product) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Product.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}],
|
||||
product_groups: ['$q', 'ProductGroup', function ($q, ProductGroup) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
ProductGroup.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
var ProfitLossCtrl = ['$scope', '$location', 'dateFilter', 'profit_loss', function ($scope, $location, dateFilter, profit_loss) {
|
||||
$scope.info = profit_loss;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/ProfitLoss').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}];
|
||||
|
||||
ProfitLossCtrl.resolve = {
|
||||
profit_loss: ['$q', '$route', 'ProfitLoss', function ($q, $route, ProfitLoss) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
ProfitLoss.get({}, successCb);
|
||||
} else {
|
||||
ProfitLoss.get({StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
var PurchaseEntriesCtrl = ['$scope', '$location', 'dateFilter', 'purchase_entries', function ($scope, $location, dateFilter, purchase_entries) {
|
||||
$scope.info = purchase_entries;
|
||||
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/PurchaseEntries').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}];
|
||||
|
||||
PurchaseEntriesCtrl.resolve = {
|
||||
purchase_entries: ['$q', '$route', 'PurchaseEntries', function ($q, $route, PurchaseEntries) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
PurchaseEntries.get({}, successCb);
|
||||
} else {
|
||||
PurchaseEntries.get({StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
'use strict';
|
||||
|
||||
var PurchaseReturnCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'Account', 'Batch', function ($scope, $location, $q, dateFilter, $modal, voucher, Account, Batch) {
|
||||
$scope.voucher = voucher;
|
||||
$scope.rate = 0;
|
||||
function getOldInventory(productID, inventories) {
|
||||
for (var i = 0, l = inventories.length; i < l; i++) {
|
||||
if (inventories[i].Product.ProductID === productID) {
|
||||
return inventories[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
var oldInventory = getOldInventory($scope.batch.Product.ProductID, this.voucher.Inventories),
|
||||
quantity = Number($scope.quantity);
|
||||
|
||||
if (!$scope.batch || !$scope.batch.Product.ProductID || !quantity) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof oldInventory === 'undefined' && quantity <= $scope.batch.QuantityRemaining) {
|
||||
this.voucher.Inventories.push(
|
||||
{
|
||||
Product: $scope.batch.Product,
|
||||
Quantity: quantity,
|
||||
Rate: $scope.batch.Rate,
|
||||
Tax: $scope.batch.Tax,
|
||||
Discount: $scope.batch.Discount,
|
||||
Amount: quantity * $scope.batch.Rate * (1 + $scope.batch.Tax) * (1 - $scope.batch.Discount),
|
||||
Batch: $scope.batch
|
||||
});
|
||||
delete $scope.batch;
|
||||
delete $scope.quantity;
|
||||
$('#txtBatch').val('');
|
||||
$('#txtBatch').focus();
|
||||
}
|
||||
};
|
||||
$scope.removeInventory = function (inventory) {
|
||||
var index = this.voucher.Inventories.indexOf(inventory);
|
||||
this.voucher.Inventories.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Inventories', function (inventories, oldValue) {
|
||||
var amount = 0;
|
||||
if (typeof inventories !== 'undefined') {
|
||||
for (var i = 0, l = inventories.length; i < l; i++) {
|
||||
amount += Number(inventories[i].Amount);
|
||||
}
|
||||
}
|
||||
if (typeof $scope.voucher.Journals !== 'undefined') {
|
||||
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
|
||||
if ($scope.voucher.Journals[i].Debit === 1) {
|
||||
$scope.voucher.Journals[i].Amount = amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof $scope.perms === 'undefined') {
|
||||
return false;
|
||||
} else if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Purchase Return'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Purchase Return'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Return/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Return').replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
$scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.modal = function (inventory) {
|
||||
$scope.selectedInventory = inventory;
|
||||
var edit = {};
|
||||
angular.copy($scope.selectedInventory, edit);
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/partial/purchase-return-modal.html',
|
||||
controller: PurchaseReturnModalCtrl,
|
||||
resolve: {edit: function () {
|
||||
return edit;
|
||||
}}
|
||||
});
|
||||
modalInstance.result.then(function (updated) {
|
||||
if (updated.Product.ProductID !== $scope.selectedInventory.Batch.Product.ProductID) {
|
||||
var oldInventory = getOldInventory(updated.Batch.Product.ProductID, $scope.voucher.Inventories);
|
||||
if (typeof oldInventory !== 'undefined') {
|
||||
delete $scope.selectedInventory;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
angular.copy(updated, $scope.selectedInventory);
|
||||
delete $scope.selectedInventory;
|
||||
}, function () {
|
||||
delete $scope.selectedInventory;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
var params = {term: $viewValue, count: 20};
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
params.date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
} else {
|
||||
params.date = $scope.voucher.Date;
|
||||
}
|
||||
Batch.autocomplete(params, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
PurchaseReturnCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Voucher.get({type: 'Purchase Return'}, successCb);
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
var PurchaseReturnModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Batch', function ($scope, $modalInstance, $q, 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) {
|
||||
var deferred = $q.defer();
|
||||
Batch.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}]
|
||||
@@ -0,0 +1,221 @@
|
||||
'use strict';
|
||||
|
||||
var PurchaseCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'Account', 'Product', function ($scope, $location, $q, dateFilter, $modal, voucher, Account, Product) {
|
||||
$scope.voucher = voucher;
|
||||
function getOldInventory(productID, inventories) {
|
||||
if (angular.isUndefined(productID)) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0, l = inventories.length; i < l; i++) {
|
||||
if (inventories[i].Product.ProductID === productID) {
|
||||
return inventories[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
var oldInventory = getOldInventory($scope.product.ProductID, this.voucher.Inventories),
|
||||
quantity = Number($scope.quantity),
|
||||
tax = ($scope.tax) ? Number($scope.tax) : 0,
|
||||
discount = ($scope.discount) ? Number($scope.discount) : 0,
|
||||
price = Number($scope.product.Price);
|
||||
|
||||
if (!$scope.product || !$scope.product.ProductID || !quantity || !price) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof oldInventory === 'undefined') {
|
||||
this.voucher.Inventories.push(
|
||||
{
|
||||
Product: $scope.product,
|
||||
Quantity: quantity,
|
||||
Rate: price,
|
||||
Tax: tax,
|
||||
Discount: discount,
|
||||
Amount: quantity * price * (1 + tax) * (1 - discount)
|
||||
});
|
||||
delete $scope.product;
|
||||
delete $scope.quantity;
|
||||
delete $scope.tax;
|
||||
delete $scope.discount;
|
||||
$('#txtProduct').focus();
|
||||
}
|
||||
};
|
||||
$scope.removeInventory = function (inventory) {
|
||||
var index = this.voucher.Inventories.indexOf(inventory);
|
||||
this.voucher.Inventories.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Inventories', function (inventories, oldValue) {
|
||||
var amount = 0;
|
||||
if (typeof inventories !== 'undefined') {
|
||||
for (var i = 0, l = inventories.length; i < l; i++) {
|
||||
amount += Number(inventories[i].Amount);
|
||||
}
|
||||
}
|
||||
if (typeof $scope.voucher.Journals !== 'undefined') {
|
||||
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
|
||||
if ($scope.voucher.Journals[i].Debit === -1) {
|
||||
$scope.voucher.Journals[i].Amount = amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof $scope.perms === 'undefined') {
|
||||
return false;
|
||||
} else if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Purchase'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Purchase'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Purchase/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Purchase').replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
$scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.modal = function (inventory) {
|
||||
$scope.selectedInventory = inventory;
|
||||
var edit = {};
|
||||
angular.copy($scope.selectedInventory, edit);
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/partial/purchase-modal.html',
|
||||
controller: PurchaseModalCtrl,
|
||||
resolve: {edit: function () {
|
||||
return edit;
|
||||
}}
|
||||
});
|
||||
modalInstance.result.then(function (updated) {
|
||||
if (updated.Product.ProductID !== $scope.selectedInventory.Product.ProductID) {
|
||||
var oldInventory = getOldInventory(updated.Product.ProductID, $scope.voucher.Inventories);
|
||||
if (typeof oldInventory !== 'undefined') {
|
||||
delete $scope.selectedInventory;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
angular.copy(updated, $scope.selectedInventory);
|
||||
delete $scope.selectedInventory;
|
||||
}, function () {
|
||||
delete $scope.selectedInventory;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
$scope.products = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Product.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
PurchaseCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Voucher.get({type: 'Purchase'}, successCb);
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var PurchaseModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Product', function ($scope, $modalInstance, $q, 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) {
|
||||
var deferred = $q.defer();
|
||||
Product.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
}]
|
||||
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
var RawMaterialCostCtrl = ['$scope', '$location', 'dateFilter', 'raw_material_cost', function ($scope, $location, dateFilter, raw_material_cost) {
|
||||
$scope.info = raw_material_cost;
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.StartDate)) {
|
||||
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
if (angular.isDate($scope.info.FinishDate)) {
|
||||
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/RawMaterialCost').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}];
|
||||
RawMaterialCostCtrl.resolve = {
|
||||
raw_material_cost: ['$q', '$route', 'RawMaterialCost', function ($q, $route, RawMaterialCost) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
RawMaterialCost.get({}, successCb);
|
||||
} else if (typeof id === 'undefined') {
|
||||
RawMaterialCost.get({StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
} else {
|
||||
RawMaterialCost.get({id: id, StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,210 @@
|
||||
'use strict';
|
||||
|
||||
var ReceiptCtrl = ['$scope', '$routeParams', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'ledgers', 'Voucher', 'Account', function ($scope, $routeParams, $location, $q, dateFilter, $modal, voucher, ledgers, Voucher, Account) {
|
||||
$('#txtAccount').focus();
|
||||
|
||||
$scope.voucher = voucher;
|
||||
$scope.ledgers = ledgers;
|
||||
function getOld(ledgerID, journals) {
|
||||
return _.find(journals, function (journal) {
|
||||
return journal.Ledger.LedgerID === ledgerID;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
if (!$scope.account || !$scope.account.LedgerID || !$scope.amount || Number(!$scope.amount)) {
|
||||
return;
|
||||
}
|
||||
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
|
||||
if (typeof oldJournal === 'undefined') {
|
||||
this.voucher.Journals.push({Debit: -1, Amount: Number($scope.amount), Ledger: $scope.account});
|
||||
} else {
|
||||
if (oldJournal.Debit === -1) {
|
||||
oldJournal.Amount = oldJournal.Amount + Number($scope.amount);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete $scope.account;
|
||||
delete $scope.amount;
|
||||
$('#txtAccount').focus();
|
||||
};
|
||||
|
||||
$scope.removeJournal = function (journal) {
|
||||
var index = this.voucher.Journals.indexOf(journal);
|
||||
this.voucher.Journals.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Journals', function (journals, oldValue) {
|
||||
var amount = _.chain(journals)
|
||||
.where({'Debit': -1})
|
||||
.reduce(function (sum, item) {
|
||||
return item.Amount + sum;
|
||||
}, 0).value();
|
||||
|
||||
var j = _.find(journals, {'Debit': 1});
|
||||
j.Amount = amount;
|
||||
if (_.find(oldValue, {'Debit': 1}).Ledger.LedgerID !== j.Ledger.LedgerID) {
|
||||
$location.path('/Receipt').search({a: j.Ledger.LedgerID}).replace();
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof $scope.perms === 'undefined') {
|
||||
return false;
|
||||
} else if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Receipt'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Receipt'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Receipt/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Receipt').replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
$scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.modal = function (journal) {
|
||||
$scope.selectedJournal = journal;
|
||||
var edit = {};
|
||||
angular.copy($scope.selectedJournal, edit);
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/partial/receipt-modal.html',
|
||||
controller: ReceiptModalCtrl,
|
||||
resolve: {edit: function () {
|
||||
return edit;
|
||||
}}
|
||||
});
|
||||
modalInstance.result.then(function (updated) {
|
||||
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
|
||||
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
|
||||
if (typeof oldJournal !== 'undefined') {
|
||||
delete $scope.selectedJournal;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
angular.copy(updated, $scope.selectedJournal);
|
||||
delete $scope.selectedJournal;
|
||||
}, function () {
|
||||
delete $scope.selectedJournal;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, 'a': true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
ReceiptCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var account = $route.current.params.a;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
var options = {type: 'Receipt'};
|
||||
if (!angular.isUndefined(account)) {
|
||||
options.a = account;
|
||||
}
|
||||
Voucher.get(options, successCb);
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}],
|
||||
ledgers: ['$q', 'Account', function ($q, Account) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Account.autocomplete({term: '', type: 1}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var ReceiptModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Account', function ($scope, $modalInstance, $q, edit, Account) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Amount = Number($scope.edit.Amount);
|
||||
$modalInstance.close($scope.edit);
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
}]
|
||||
@@ -0,0 +1,110 @@
|
||||
'use strict';
|
||||
|
||||
var ReconcileCtrl = ['$scope', '$routeParams', '$location', '$q', 'dateFilter', 'reconcile', 'Reconcile', 'Account', function ($scope, $routeParams, $location, $q, dateFilter, reconcile, Reconcile, Account) {
|
||||
$scope.info = reconcile;
|
||||
$scope.show = function () {
|
||||
var id = $scope.info.Account.LedgerID;
|
||||
var start_date = angular.isDate($scope.info.StartDate) ? dateFilter($scope.info.StartDate, 'dd-MMM-yyyy') : $scope.info.StartDate;
|
||||
var finish_date = angular.isDate($scope.info.FinishDate) ? dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy') : $scope.info.FinishDate;
|
||||
if (id === $routeParams.id && start_date === $routeParams.StartDate && finish_date === $routeParams.FinishDate) {
|
||||
Reconcile.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
|
||||
$scope.info = data;
|
||||
});
|
||||
} else {
|
||||
$location.path('/Reconcile/' + id).search('StartDate', start_date).search('FinishDate', finish_date);
|
||||
}
|
||||
};
|
||||
$scope.save = function () {
|
||||
var i, l,
|
||||
len = $scope.info.Body.length;
|
||||
for (i = 0, l = len; i < l; i++) {
|
||||
if (angular.isDate($scope.info.Body[i].ReconcileDate)) {
|
||||
$scope.info.Body[i].ReconcileDate = dateFilter($scope.info.Body[i].ReconcileDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
}
|
||||
$scope.info.$save({StartDate: $routeParams.StartDate, FinishDate: $routeParams.FinishDate}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$scope.info = u;
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.downloadTable = function () {
|
||||
var table = $('#gvGrid'),
|
||||
html = table.clone().wrap('<div></div>').parent().html();
|
||||
html = html.replace(/á/g, 'á');
|
||||
window.open('data:application/vnd.ms-excel;charset=UTF-8,' + encodeURIComponent(html));
|
||||
};
|
||||
|
||||
if ($routeParams.id) {
|
||||
$('#gvGrid').focus();
|
||||
} else {
|
||||
$('#txtLedger').focus();
|
||||
}
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = index;
|
||||
};
|
||||
|
||||
$scope.shortcuts = {
|
||||
'up': function () {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected -= 1;
|
||||
});
|
||||
}
|
||||
},
|
||||
'down': function () {
|
||||
if ($scope.selected < $scope.info.Body.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected += 1;
|
||||
});
|
||||
}
|
||||
},
|
||||
'alt+r': function () {
|
||||
console.log('alt+r');
|
||||
},
|
||||
'enter': function () {
|
||||
var path = $scope.info.Body[$scope.selected].Url.replace(/^(?:\/\/|[^\/]+)*/, "");
|
||||
$scope.$apply(function () {
|
||||
$location.path(path).search('StartDate', null).search('FinishDate', null);
|
||||
});
|
||||
},
|
||||
'alt+u': function () {
|
||||
console.log('alt+u');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, r:true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
ReconcileCtrl.resolve = {
|
||||
reconcile: ['$q', '$route', 'Reconcile', function ($q, $route, Reconcile) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Reconcile.get({}, successCb);
|
||||
} else {
|
||||
Reconcile.get({id: id, StartDate: start_date, FinishDate: finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
'use strict';
|
||||
|
||||
var SalaryDeductionCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'Employee', function ($scope, $location, $q, dateFilter, $modal, voucher, Employee) {
|
||||
$scope.voucher = voucher;
|
||||
|
||||
function getOldItem(ledgerID, items) {
|
||||
for (var i = 0, l = items.length; i < l; i++) {
|
||||
if (items[i].Journal.Ledger.LedgerID === ledgerID) {
|
||||
return items[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function daysInMonthFunction(date) {
|
||||
if (angular.isDate(date)) {
|
||||
return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
||||
}
|
||||
|
||||
var months = {
|
||||
Jan: 1,
|
||||
Feb: 2,
|
||||
Mar: 3,
|
||||
Apr: 4,
|
||||
May: 5,
|
||||
Jun: 6,
|
||||
Jul: 7,
|
||||
Aug: 8,
|
||||
Sep: 9,
|
||||
Oct: 10,
|
||||
Nov: 11,
|
||||
Dec: 12
|
||||
};
|
||||
if (!date.match(/^\d{2}-[\w]{3}-[\d]{4}$/g)) {
|
||||
return;
|
||||
}
|
||||
var parts = date.split("-");
|
||||
return new Date(parseInt(parts[2], 10), months[parts[1]], 0).getDate();
|
||||
}
|
||||
|
||||
function getEsi(grossSalary, daysWorked, daysInMonth) {
|
||||
var limit = 15000,
|
||||
employee_rate = 0.0175,
|
||||
employer_rate = 0.0475,
|
||||
employee = (grossSalary > limit) ? 0 : Math.ceil(employee_rate * grossSalary * daysWorked / daysInMonth),
|
||||
employer = (grossSalary > limit) ? 0 : Math.ceil(employer_rate * grossSalary * daysWorked / daysInMonth);
|
||||
return {ee: employee, er: employer, both: employee + employer};
|
||||
}
|
||||
|
||||
function getPf(grossSalary, daysWorked, daysInMonth) {
|
||||
var limit = 6500,
|
||||
employee_rate = 0.12,
|
||||
employer_rate = 0.12 + 0.011 + 0.005 + 0.0001,
|
||||
employee = (grossSalary > limit) ? 0 : Math.ceil(employee_rate * grossSalary * daysWorked / daysInMonth),
|
||||
employer = (grossSalary > limit) ? 0 : Math.ceil(employer_rate * grossSalary * daysWorked / daysInMonth);
|
||||
return {ee: employee, er: employer, both: employee + employer};
|
||||
}
|
||||
|
||||
$scope.add = function () {
|
||||
var oldJournal = getOldItem($scope.employee.LedgerID, this.voucher.SalaryDeductions),
|
||||
grossSalary = parseInt($scope.grossSalary, 10),
|
||||
daysWorked = parseInt($scope.daysWorked, 10),
|
||||
daysInMonth = daysInMonthFunction($scope.voucher.Date),
|
||||
esi = getEsi(grossSalary, daysWorked, daysInMonth),
|
||||
pf = getPf(grossSalary, daysWorked, daysInMonth);
|
||||
|
||||
if (typeof oldJournal !== 'undefined') {
|
||||
$scope.toasts.push({Type: 'Danger', Message: 'Employee has already been added!'});
|
||||
} else {
|
||||
this.voucher.SalaryDeductions.push({
|
||||
Journal: {Ledger: $scope.employee},
|
||||
GrossSalary: grossSalary,
|
||||
DaysWorked: daysWorked,
|
||||
EsiEmployee: esi.ee,
|
||||
PfEmployee: pf.ee,
|
||||
EsiEmployer: esi.er,
|
||||
PfEmployer: pf.er
|
||||
});
|
||||
}
|
||||
delete $scope.employee;
|
||||
delete $scope.grossSalary;
|
||||
delete $scope.daysWorked;
|
||||
$('#txtEmployee').focus();
|
||||
};
|
||||
|
||||
$scope.remove = function (deduction) {
|
||||
var index = this.voucher.SalaryDeductions.indexOf(deduction);
|
||||
this.voucher.SalaryDeductions.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.preventAlteration = function (voucher) {
|
||||
if (typeof $scope.perms === 'undefined') {
|
||||
return false;
|
||||
} else if (typeof voucher.VoucherID === 'undefined') {
|
||||
return !$scope.perms['Salary Deduction'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$scope.voucher.$save({type: 'Salary Deduction'}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/SalaryDeduction/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/SalaryDeduction').replace();
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
$scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirm = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Voucher";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.delete();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.employees = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Employee.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
}]
|
||||
|
||||
|
||||
SalaryDeductionCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Voucher.get({type: 'Salary Deduction'}, successCb);
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,125 @@
|
||||
'use strict';
|
||||
|
||||
var SettingsCtrl = ['$scope', '$http', '$q', 'dateFilter', '$modal', 'lockDate', 'Product', function ($scope, $http, $q, dateFilter, $modal, lockDate, Product) {
|
||||
$scope.lockDate = lockDate.data['Lock Date'];
|
||||
$scope.rebaseDate = '';
|
||||
$scope.setLockDate = function () {
|
||||
if (angular.isDate($scope.lockDate)) {
|
||||
$scope.lockDate = dateFilter($scope.lockDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$http({method: 'POST', url: '/api/LockDate', params: {Date: $scope.lockDate}}).
|
||||
success(function (data) {
|
||||
$scope.lockDate = data['Lock Date'];
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.clearLockDate = function () {
|
||||
$http({method: 'POST', url: '/api/LockDate', params: {Clear: ''}}).
|
||||
success(function (data) {
|
||||
$scope.lockDate = data['Lock Date'];
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirmRebase = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Rebase Data";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.rebaseData();
|
||||
});
|
||||
};
|
||||
$scope.rebaseData = function () {
|
||||
if ($scope.rebaseDate === '') {
|
||||
return;
|
||||
}
|
||||
if (angular.isDate($scope.rebaseDate)) {
|
||||
$scope.rebaseDate = dateFilter($scope.rebaseDate, 'dd-MMM-yyyy');
|
||||
}
|
||||
$http({method: 'POST', url: '/api/Rebase/' + $scope.rebaseDate}).
|
||||
success(function (data) {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Data rebased!'});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.confirmResetStock = function () {
|
||||
var modalInstance = $modal.open({
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Reset Stock";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
$modalInstance.close();
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
}]
|
||||
});
|
||||
modalInstance.result.then(function () {
|
||||
$scope.resetStock();
|
||||
});
|
||||
};
|
||||
$scope.resetStock = function () {
|
||||
if (angular.isUndefined($scope.resetDate) || $scope.resetDate === '') {
|
||||
return;
|
||||
}
|
||||
if (angular.isUndefined($scope.stockDate) || $scope.stockDate === '') {
|
||||
return;
|
||||
}
|
||||
if (angular.isUndefined($scope.product) || $scope.product === '') {
|
||||
return;
|
||||
}
|
||||
if (angular.isUndefined($scope.qty) || $scope.qty === '') {
|
||||
return;
|
||||
}
|
||||
var resetDate = angular.isDate($scope.resetDate) ? dateFilter($scope.resetDate, 'dd-MMM-yyyy') : $scope.resetDate;
|
||||
var stockDate = angular.isDate($scope.stockDate) ? dateFilter($scope.stockDate, 'dd-MMM-yyyy') : $scope.stockDate;
|
||||
var qty = Number($scope.qty);
|
||||
$http({method: 'POST', url: '/api/ResetStock/' + $scope.product.ProductID, params: {StockDate: stockDate, ResetDate: resetDate, Quantity: qty}}).
|
||||
success(function (data) {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Data rebased!'});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
|
||||
});
|
||||
};
|
||||
$scope.products = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Product.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
}];
|
||||
|
||||
SettingsCtrl.resolve = {
|
||||
lockDate: ['$http', function ($http) {
|
||||
return $http.get('/api/LockDate', {});
|
||||
}]
|
||||
};
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var TrialBalanceCtrl = ['$scope', '$location', 'dateFilter', 'trial_balance', function ($scope, $location, dateFilter, trial_balance) {
|
||||
$scope.info = trial_balance;
|
||||
|
||||
$scope.show = function () {
|
||||
if (angular.isDate($scope.info.Date)) {
|
||||
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
|
||||
}
|
||||
$location.path('/TrialBalance/' + $scope.info.Date);
|
||||
};
|
||||
$('#txtDate').focus();
|
||||
}];
|
||||
TrialBalanceCtrl.resolve = {
|
||||
trial_balance: ['$q', '$route', 'TrialBalance', function ($q, $route, TrialBalance) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var date = $route.current.params.date;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof date === 'undefined') {
|
||||
TrialBalance.get({}, successCb);
|
||||
} else {
|
||||
TrialBalance.get({date: date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var UnpostedCtrl = ['$scope', 'info', 'Unposted', function ($scope, info, Unposted) {
|
||||
$scope.info = info;
|
||||
$scope.refresh = function () {
|
||||
Unposted.query({}, function (result) {
|
||||
$scope.info = result;
|
||||
$scope.apply();
|
||||
});
|
||||
}
|
||||
}]
|
||||
UnpostedCtrl.resolve = {
|
||||
info:['$q', 'Unposted', function ($q, Unposted) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Unposted.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var UserListCtrl = ['$scope', 'users', function ($scope, users) {
|
||||
$scope.info = users;
|
||||
}]
|
||||
|
||||
UserListCtrl.resolve = {
|
||||
users: ['$q', 'User', function ($q, User) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
User.query({}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var UserCtrl = ['$scope', '$location', 'user', function ($scope, $location, user) {
|
||||
$scope.user = user;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.user.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Users');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.user.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Users');
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
}];
|
||||
|
||||
UserCtrl.resolve = {
|
||||
user: ['$q', '$route', 'User', function ($q, $route, User) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
User.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* Created by tanshu on 27/9/13.
|
||||
*/
|
||||
Reference in new issue
Block a user