79 lines
2.5 KiB
JavaScript
79 lines
2.5 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
window.app.controller('TransactionController', TransactionController);
|
|
|
|
TransactionController.$inject = ['$scope', '$uibModal', 'transactionSvc', 'uiGridConstants'];
|
|
function TransactionController($scope, $uibModal, transactionSvc, uiGridConstants) {
|
|
var vm = this;
|
|
|
|
var paginationOptions = {
|
|
pageNumber: 1,
|
|
pageSize: 20,
|
|
sort: null
|
|
};
|
|
|
|
vm.gridOptions = {
|
|
enablePaginationControls: true,
|
|
paginationPageSize: paginationOptions.pageSize,
|
|
paginationPageSizes: [20,50,100],
|
|
useExternalPagination: true,
|
|
enableSorting: false,
|
|
columnDefs: [
|
|
{
|
|
field: 'name',
|
|
cellTooltip: function(row) {
|
|
return row.entity.name + "\r" + row.entity.unitsPerCase + " / " + row.entity.containerType;
|
|
},
|
|
cellTemplate: '<div class="ui-grid-cell-contents" ' +
|
|
'title="{{row.entity.name}}' +
|
|
'\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}' +
|
|
'\rExp Date: {{row.entity.expirationDate | date:shortDate}}' +
|
|
'\rAdd Date: {{row.entity.addedDate | date:shortDate}}">' +
|
|
'<a href="#">{{row.entity.name}}</a></div>'
|
|
},
|
|
{ field: 'memo', cellTooltip: true },
|
|
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:MM/dd/yyyy", width: "15%" },
|
|
{ field: 'addedQuantity', name: 'Add Qty', width: "10%", enableSorting: false },
|
|
{ field: 'removedQuantity', name: 'Remove Qty', width: "10%", enableSorting: false },
|
|
{ field: 'currentQuantity', name: 'Current Qty', width: "15%", enableSorting: false }
|
|
],
|
|
onRegisterApi: function(gridApi) {
|
|
vm.gridApi = gridApi;
|
|
//vm.gridApi.core.on.sortChanged($scope,
|
|
// function(grid, sortColumns) {
|
|
// if (sortColumns.length == 0) {
|
|
// paginationOptions.sort = null;
|
|
// } else {
|
|
// paginationOptions.sort = sortColumns[0].sort.direction;
|
|
// }
|
|
// getPage();
|
|
// });
|
|
vm.gridApi.pagination.on.paginationChanged($scope,
|
|
function(newPage, pageSize) {
|
|
paginationOptions.pageNumber = newPage;
|
|
paginationOptions.pageSize = pageSize;
|
|
updateData();
|
|
});
|
|
}
|
|
};
|
|
|
|
var updateData = function () {
|
|
transactionSvc
|
|
.getTransactions(paginationOptions.pageNumber, paginationOptions.pageSize)
|
|
.then(function(data) {
|
|
vm.gridOptions.totalItems = data.totalItems;
|
|
vm.gridOptions.data = data.transactions;
|
|
});
|
|
};
|
|
|
|
updateData();
|
|
|
|
function del() {
|
|
$uibModal.open({
|
|
template: '<inventory-distribute />',
|
|
backdrop: 'static'
|
|
});
|
|
}
|
|
}
|
|
})(); |