controller.js
5.29 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
angular.module('focaCrearNotaPedido')
.controller('notaPedidoCtrl',
[
'$scope',
'$uibModal',
'crearNotaPedidoService',
function ($scope, $uibModal, crearNotaPedidoService) {
$scope.notaPedido = {};
var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
var domiciliosCliente = [
{
dom: 'sanjuan',
id: 3
},
{
dom: 'mendoza',
id: 2
}
]
if (notaPedidoTemp != undefined) {
notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
$scope.notaPedido = notaPedidoTemp;
$scope.notaPedido.domicilio = domiciliosCliente;
} else {
$scope.notaPedido.fechaCarga = new Date();
$scope.notaPedido.domicilio = domiciliosCliente;
}
$scope.precioCondiciones = [
{ nombre: 'Precio y condicion 1' },
{ nombre: 'Precio y condicion 2' },
{ nombre: 'Precio y condicion 3' }
]
$scope.articulosTabla = [
{
codigo: '1',
item: 1,
nombre: 'naftaaskdahsñodaskdjhañslkdjahslñkjdhalskjdhaksjdhkasjhasddddddddddddddddddddddddddddddddddddddddddddddddd',
precio: '14,50',
costoUnitario: '14',
cantidad: 1,
subtotal: '19,22'
}
]
$scope.notaPedido.bomba = '1';
$scope.notaPedido.flete = '1';
$scope.addNewDom = function () {
$scope.notaPedido.domicilio.push({ 'id': 0 });
}
$scope.removeNewChoice = function (choice) {
if ($scope.notaPedido.domicilio.length > 1) {
$scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(c => c.$$hashKey == choice.$$hashKey), 1)
}
}
$scope.crearNotaPedido = function () {
var notaPedido = {
idNotaPedido: 0,
precioCondicion: $scope.notaPedido.precioCondicion,
fechaCarga: $scope.notaPedido.clientefechaCarga,
vendedor: $scope.notaPedido.vendedor,
cliente: $scope.notaPedido.cliente,
producto: $scope.notaPedido.producto,
bomba: $scope.notaPedido.bomba,
petrolera: $scope.notaPedido.petrolera,
domicilio: $scope.notaPedido.domicilio,
kilometros: $scope.notaPedido.kilometros,
jurisdiccionIIBB: $scope.notaPedido.jurisdiccion,
costoFinanciacion: $scope.notaPedido.costoFinanciacion,
flete: $scope.notaPedido.flete,
costoUnitarioKmFlete: $scope.costoUnitarioKmFlete
}
crearNotaPedidoService.crearNotaPedido(notaPedido).then(
function (res) {
alert('Nota pedido creada')
}
)
}
$scope.siguienteTab = function () {
$scope.active = 1;
}
$scope.seleccionarArticulo = function () {
var modalIntance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Productos',
templateUrl: 'modal-busqueda-productos.html',
controller: 'modalBusquedaProductosCtrl',
size: 'md'
}
)
modalInstance.result.then(
function (producto) {
console.info(producto);
// variable producto tiene el producto seleccionado en el modal
}, function () {
// funcion ejecutada cuando se cancela el modal
}
);
}
$scope.obtenerDomicilios = function (id) {
crearNotaPedidoService.getDomicilios(id).then(
function (res) {
$scope.notaPedido.domicilio = res.data;
}
)
}
}
]
)
.controller('notaPedidoListaCtrl', [
'$scope',
'crearNotaPedidoService',
'$location',
function ($scope, crearNotaPedidoService, $location) {
crearNotaPedidoService.obtenerNotaPedido().then(function (datos) {
$scope.notaPedidos = datos.data;
});
$scope.editar = function (notaPedido) {
crearNotaPedidoService.setNotaPedido(notaPedido);
$location.path('/venta-nota-pedido/abm/');
};
}
])