Commit dafcad032b69621477ff5fe8a3896c1f97f25804

Authored by Eric Fernandez
1 parent 608a057800
Exists in master and in 1 other branch develop

quito console

Showing 1 changed file with 0 additions and 1 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaAbmVehiculo') 1 angular.module('focaAbmVehiculo')
2 .controller('focaAbmVehiculosController', [ 2 .controller('focaAbmVehiculosController', [
3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal', 3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal',
4 function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) { 4 function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) {
5 $scope.buscar = function(idTransportista) { 5 $scope.buscar = function(idTransportista) {
6 focaAbmVehiculoService 6 focaAbmVehiculoService
7 .getVehiculosPorTransportista(idTransportista) 7 .getVehiculosPorTransportista(idTransportista)
8 .then(function(datos) { 8 .then(function(datos) {
9 $scope.vehiculos = datos.data; 9 $scope.vehiculos = datos.data;
10 }); 10 });
11 }; 11 };
12 $scope.editar = function(id) { 12 $scope.editar = function(id) {
13 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); 13 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
14 }; 14 };
15 $scope.solicitarConfirmacion = function(vehiculo) { 15 $scope.solicitarConfirmacion = function(vehiculo) {
16 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + 16 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
17 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( 17 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
18 function(data) { 18 function(data) {
19 if(data) { 19 if(data) {
20 focaAbmVehiculoService.deleteVehiculo(vehiculo.id); 20 focaAbmVehiculoService.deleteVehiculo(vehiculo.id);
21 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 21 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
22 } 22 }
23 } 23 }
24 ); 24 );
25 }; 25 };
26 $scope.seleccionarTransportista = function() { 26 $scope.seleccionarTransportista = function() {
27 var modalInstance = $uibModal.open( 27 var modalInstance = $uibModal.open(
28 { 28 {
29 ariaLabelledBy: 'Busqueda de Transportista', 29 ariaLabelledBy: 'Busqueda de Transportista',
30 templateUrl: 'modal-proveedor.html', 30 templateUrl: 'modal-proveedor.html',
31 controller: 'focaModalProveedorCtrl', 31 controller: 'focaModalProveedorCtrl',
32 size: 'lg', 32 size: 'lg',
33 resolve: { 33 resolve: {
34 transportista: function() { 34 transportista: function() {
35 return true; 35 return true;
36 } 36 }
37 } 37 }
38 } 38 }
39 ); 39 );
40 modalInstance.result.then( 40 modalInstance.result.then(
41 function(transprotista) { 41 function(transprotista) {
42 $scope.idTransportista = transprotista.COD; 42 $scope.idTransportista = transprotista.COD;
43 $scope.filtros = transprotista.NOM.trim(); 43 $scope.filtros = transprotista.NOM.trim();
44 $scope.buscar(transprotista.COD); 44 $scope.buscar(transprotista.COD);
45 }, function() { 45 }, function() {
46 46
47 } 47 }
48 ); 48 );
49 }; 49 };
50 } 50 }
51 ]) 51 ])
52 .controller('focaAbmVehiculoController', [ 52 .controller('focaAbmVehiculoController', [
53 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', 53 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
54 'focaModalService', 54 'focaModalService',
55 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, 55 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
56 focaModalService) { 56 focaModalService) {
57 $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false; 57 $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false;
58 if($scope.nuevo) { 58 if($scope.nuevo) {
59 focaAbmVehiculoService 59 focaAbmVehiculoService
60 .getTransportistaPorId($routeParams.idTransportista) 60 .getTransportistaPorId($routeParams.idTransportista)
61 .then(function(res) { 61 .then(function(res) {
62 console.log(res.data);
63 $scope.vehiculo.transportista = res.data; 62 $scope.vehiculo.transportista = res.data;
64 }) 63 })
65 } 64 }
66 $scope.vehiculo = {}; 65 $scope.vehiculo = {};
67 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { 66 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
68 if(res.data) $scope.vehiculo = res.data; 67 if(res.data) $scope.vehiculo = res.data;
69 }); 68 });
70 focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) 69 focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo)
71 .then(function(res) { 70 .then(function(res) {
72 $scope.cisternas = res.data; 71 $scope.cisternas = res.data;
73 }); 72 });
74 $scope.cancelar = function() { 73 $scope.cancelar = function() {
75 $location.path('/vehiculo'); 74 $location.path('/vehiculo');
76 }; 75 };
77 $scope.editar = function(id) { 76 $scope.editar = function(id) {
78 $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); 77 $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id);
79 }; 78 };
80 $scope.guardar = function() { 79 $scope.guardar = function() {
81 if(!$scope.vehiculo.transportista){ 80 if(!$scope.vehiculo.transportista){
82 focaModalService.alert('Elija Transportista'); 81 focaModalService.alert('Elija Transportista');
83 return; 82 return;
84 } 83 }
85 delete $scope.vehiculo.transportista; 84 delete $scope.vehiculo.transportista;
86 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { 85 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) {
87 $location.path('/vehiculo/' + res.data.id); 86 $location.path('/vehiculo/' + res.data.id);
88 }); 87 });
89 }; 88 };
90 $scope.solicitarConfirmacionCisterna = function(cisterna) { 89 $scope.solicitarConfirmacionCisterna = function(cisterna) {
91 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + 90 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' +
92 cisterna.id + ' ' + cisterna.codigo + ' ?').then( 91 cisterna.id + ' ' + cisterna.codigo + ' ?').then(
93 function(data) { 92 function(data) {
94 if(data) { 93 if(data) {
95 focaAbmVehiculoService.deleteCisterna(cisterna.id); 94 focaAbmVehiculoService.deleteCisterna(cisterna.id);
96 $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); 95 $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1);
97 } 96 }
98 } 97 }
99 ); 98 );
100 }; 99 };
101 $scope.seleccionarTransportista = function() { 100 $scope.seleccionarTransportista = function() {
102 var modalInstance = $uibModal.open( 101 var modalInstance = $uibModal.open(
103 { 102 {
104 ariaLabelledBy: 'Busqueda de Transportista', 103 ariaLabelledBy: 'Busqueda de Transportista',
105 templateUrl: 'modal-proveedor.html', 104 templateUrl: 'modal-proveedor.html',
106 controller: 'focaModalProveedorCtrl', 105 controller: 'focaModalProveedorCtrl',
107 size: 'lg', 106 size: 'lg',
108 resolve: { 107 resolve: {
109 transportista: function() { 108 transportista: function() {
110 return true; 109 return true;
111 } 110 }
112 } 111 }
113 } 112 }
114 ); 113 );
115 modalInstance.result.then( 114 modalInstance.result.then(
116 function(transprotista) { 115 function(transprotista) {
117 $scope.vehiculo.idTransportista = transprotista.COD; 116 $scope.vehiculo.idTransportista = transprotista.COD;
118 $scope.vehiculo.transportista = transprotista; 117 $scope.vehiculo.transportista = transprotista;
119 }, function() { 118 }, function() {
120 119
121 } 120 }
122 ); 121 );
123 }; 122 };
124 } 123 }
125 ]); 124 ]);
126 125