Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. function CreateOtherTransactionController($scope,LocaleService,PreCacheDataService,STATICRESOURCES,Transaction,UploadUrl,FileService, $modal){
  2.  
  3. $scope.transaction = new Transaction();
  4. $scope.transactionTypes=[];
  5.  
  6. PreCacheDataService.fetchStaticDataFromDb(STATICRESOURCES.Costs, LocaleService.browserLanguage()).then(function (items) {
  7. for (var i = items.length - 1; i >= 0; i--) {
  8. if(items[i].ParentId !== null){
  9. $scope.transactionTypes.push(items[i]);
  10. }
  11. }
  12. });
  13.  
  14. $scope.createTransaction = function (){
  15. if($scope.transactionForm.$valid){
  16. $scope.transaction.TransactionDate =getUnixTimeStamp($scope.transactionDate);
  17. $scope.transaction.$save(function (data){
  18. $scope.uploadUrl =UploadUrl('upload.transaction', data.Id);
  19. uploadDocument();showPopup();
  20. });
  21. }
  22. };
  23.  
  24. function getUnixTimeStamp(date){
  25. return parseInt(date.getTime()/1000);
  26. }
  27.  
  28. function uploadDocument(){
  29. return FileService.upload({
  30. url: $scope.uploadUrl,
  31. file: $scope.transactionDoc,
  32. method: 'PUT'
  33. });
  34. }
  35.  
  36. function showPopup(){
  37. $modal.open({
  38. controller: 'MessageTransactionController',
  39. templateUrl: 'templates/common/message-transaction.html',
  40. resolve: {
  41. message: function() {
  42. return "Utils.messages.invalidCompany";
  43. }
  44. }
  45. });
  46. }
  47.  
  48. }
  49. CreateOtherTransactionController.$inject = ['$scope','LocaleService','PreCacheDataService','STATICRESOURCES','Transaction','UploadUrl','FileService','$modal'];
  50. angular.module('Ipsum.home')
  51. .controller('CreateOtherTransactionController',CreateOtherTransactionController);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement