Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateOtherTransactionController($scope,LocaleService,PreCacheDataService,STATICRESOURCES,Transaction,UploadUrl,FileService, $modal){
- $scope.transaction = new Transaction();
- $scope.transactionTypes=[];
- PreCacheDataService.fetchStaticDataFromDb(STATICRESOURCES.Costs, LocaleService.browserLanguage()).then(function (items) {
- for (var i = items.length - 1; i >= 0; i--) {
- if(items[i].ParentId !== null){
- $scope.transactionTypes.push(items[i]);
- }
- }
- });
- $scope.createTransaction = function (){
- if($scope.transactionForm.$valid){
- $scope.transaction.TransactionDate =getUnixTimeStamp($scope.transactionDate);
- $scope.transaction.$save(function (data){
- $scope.uploadUrl =UploadUrl('upload.transaction', data.Id);
- uploadDocument();showPopup();
- });
- }
- };
- function getUnixTimeStamp(date){
- return parseInt(date.getTime()/1000);
- }
- function uploadDocument(){
- return FileService.upload({
- url: $scope.uploadUrl,
- file: $scope.transactionDoc,
- method: 'PUT'
- });
- }
- function showPopup(){
- $modal.open({
- controller: 'MessageTransactionController',
- templateUrl: 'templates/common/message-transaction.html',
- resolve: {
- message: function() {
- return "Utils.messages.invalidCompany";
- }
- }
- });
- }
- }
- CreateOtherTransactionController.$inject = ['$scope','LocaleService','PreCacheDataService','STATICRESOURCES','Transaction','UploadUrl','FileService','$modal'];
- angular.module('Ipsum.home')
- .controller('CreateOtherTransactionController',CreateOtherTransactionController);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement