controller.js
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
angular.module('focaAbmChofer')
.controller('focaAbmChoferesController', [
'$scope', 'focaAbmChoferService', '$location', 'focaModalService',
function($scope, focaAbmChoferService, $location, focaModalService) {
$scope.filters = '';
$scope.choferes = [];
$scope.choferesFiltrados = [];
focaAbmChoferService.getChoferes().then(function(datos) {
$scope.choferes = datos.data;
$scope.choferesFiltrados = $scope.choferes;
});
$scope.editar = function(id) {
$location.path('/chofer/' + id);
};
$scope.solicitarConfirmacion = function(chofer) {
focaModalService.confirm('¿Está seguro que desea borrar el chofer '+
chofer.nombre + ' ?').then( function(confirmed) {
if(confirmed){
focaAbmChoferService.deleteChofer(chofer.id);
$scope.choferes.splice($scope.choferes.indexOf(chofer), 1);
}
});
};
}
])
.controller('focaAbmChoferController', [
'$scope', 'focaAbmChoferService', '$routeParams', '$location',
function($scope, focaAbmChoferService, $routeParams, $location) {
$scope.chofer = {};
$scope.transportistas = [];
focaAbmChoferService.getChofer($routeParams.id).then(function(res) {
if (res.data) $scope.chofer = res.data;
});
focaAbmChoferService.getTransportistas().then(function(res) {
$scope.transportistas = res.data;
});
$scope.cancelar = function() {
$location.path('/chofer');
};
$scope.guardar = function() {
$scope.chofer.idTransportista = $scope.chofer.transportista.COD;
delete $scope.chofer.transportista;
focaAbmChoferService.guardarChofer($scope.chofer).then(function() {
$location.path('/chofer');
});
};
}
]);