controllerUltimosDespachos.js
1.79 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
angular.module('focaCrearFactura')
.controller('ultimosDespachosController', [
'$filter',
'$scope',
'$uibModalInstance',
'crearFacturaService',
'parametros',
function ($filter, $scope, $uibModalInstance, crearFacturaService, parametros) {
config();
function config() {
$scope.productos = [];
crearFacturaService.getUltimosDespachos(parametros.planilla).then(function (res) {
res.data.slice(1, res.data.length).forEach(function (producto) {
producto.mangueras = [];
producto.despachos.forEach(function (despacho) {
var findCsu = producto.mangueras.filter(function (csu) {
return csu.csu === despacho.CSU.trim();
})[0];
if (!findCsu) {
var manguera = {
csu: despacho.CSU.trim(),
despachos: [despacho],
show: true
};
producto.mangueras.unshift(manguera);
} else {
findCsu.despachos.push(despacho);
}
});
$scope.productos.push(producto);
});
console.log($scope.productos);
});
}
$scope.aceptar = function (despacho) {
$uibModalInstance.close(despacho);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
}
]);