Commit f025a1fdb4a491ebeadd3293d03ccdc5f6d34196

Authored by Pablo Marco del Pont
1 parent 4c587a77ba
Exists in master

Removí el botón detalle.

Showing 1 changed file with 0 additions and 1 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', 1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService',
4 'focaModalService', 4 'focaModalService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService
7 ) { 7 ) {
8 $scope.botonera = [ 8 $scope.botonera = [
9 {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, 9 {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}},
10 {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, 10 {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}},
11 {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, 11 {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}},
12 { 12 {
13 texto: 'Precios y condiciones', 13 texto: 'Precios y condiciones',
14 accion: function() {$scope.abrirModalListaPrecio();}}, 14 accion: function() {$scope.abrirModalListaPrecio();}},
15 {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, 15 {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}},
16 {texto: 'Detalle', accion: function() {}},
17 {texto: 'Totales', accion: function() {}} 16 {texto: 'Totales', accion: function() {}}
18 ]; 17 ];
19 18
20 $scope.show = false; 19 $scope.show = false;
21 $scope.cargando = true; 20 $scope.cargando = true;
22 $scope.dateOptions = { 21 $scope.dateOptions = {
23 maxDate: new Date(), 22 maxDate: new Date(),
24 minDate: new Date(2010, 0, 1) 23 minDate: new Date(2010, 0, 1)
25 }; 24 };
26 25
27 $scope.notaPedido = { 26 $scope.notaPedido = {
28 vendedor: {}, 27 vendedor: {},
29 cliente: {}, 28 cliente: {},
30 domicilio: {dom: ''}, 29 domicilio: {dom: ''},
31 moneda: {detalle: ''} 30 moneda: {detalle: ''}
32 }; 31 };
33 32
34 $scope.cabecera = []; 33 $scope.cabecera = [];
35 34
36 $scope.now = new Date(); 35 $scope.now = new Date();
37 $scope.puntoVenta = Math.round(Math.random() * 10000); 36 $scope.puntoVenta = Math.round(Math.random() * 10000);
38 $scope.comprobante = Math.round(Math.random() * 1000000); 37 $scope.comprobante = Math.round(Math.random() * 1000000);
39 38
40 $scope.articulosTabla = []; 39 $scope.articulosTabla = [];
41 var idLista; 40 var idLista;
42 var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); 41 var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
43 crearNotaPedidoService.getPrecioCondicion().then( 42 crearNotaPedidoService.getPrecioCondicion().then(
44 function(res) { 43 function(res) {
45 $scope.precioCondiciones = res.data; 44 $scope.precioCondiciones = res.data;
46 } 45 }
47 ); 46 );
48 if (notaPedidoTemp !== undefined) { 47 if (notaPedidoTemp !== undefined) {
49 notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); 48 notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
50 $scope.notaPedido = notaPedidoTemp; 49 $scope.notaPedido = notaPedidoTemp;
51 $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); 50 $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
52 $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); 51 $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
53 idLista = $scope.notaPedido.precioCondicion; 52 idLista = $scope.notaPedido.precioCondicion;
54 crearNotaPedidoService 53 crearNotaPedidoService
55 .getArticulosByIdNotaPedido($scope.notaPedido.id).then( 54 .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
56 function(res) { 55 function(res) {
57 $scope.articulosTabla = res.data; 56 $scope.articulosTabla = res.data;
58 } 57 }
59 ); 58 );
60 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO 59 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO
61 //(NO REQUERIDO EN ESTA VERSION) 60 //(NO REQUERIDO EN ESTA VERSION)
62 // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( 61 // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then(
63 // function(res) { 62 // function(res) {
64 // $scope.notaPedido.domicilio = res.data; 63 // $scope.notaPedido.domicilio = res.data;
65 // } 64 // }
66 // ); 65 // );
67 } else { 66 } else {
68 $scope.notaPedido.fechaCarga = new Date(); 67 $scope.notaPedido.fechaCarga = new Date();
69 $scope.notaPedido.bomba = '0'; 68 $scope.notaPedido.bomba = '0';
70 $scope.notaPedido.flete = '0'; 69 $scope.notaPedido.flete = '0';
71 idLista = undefined; 70 idLista = undefined;
72 } 71 }
73 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO 72 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
74 // $scope.addNewDom = function() { 73 // $scope.addNewDom = function() {
75 // $scope.notaPedido.domicilio.push({ 'id': 0 }); 74 // $scope.notaPedido.domicilio.push({ 'id': 0 });
76 // }; 75 // };
77 // $scope.removeNewChoice = function(choice) { 76 // $scope.removeNewChoice = function(choice) {
78 // if ($scope.notaPedido.domicilio.length > 1) { 77 // if ($scope.notaPedido.domicilio.length > 1) {
79 // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( 78 // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(
80 // function(c) { 79 // function(c) {
81 // return c.$$hashKey === choice.$$hashKey; 80 // return c.$$hashKey === choice.$$hashKey;
82 // } 81 // }
83 // ), 1); 82 // ), 1);
84 // } 83 // }
85 // }; 84 // };
86 $scope.crearNotaPedido = function() { 85 $scope.crearNotaPedido = function() {
87 if($scope.articulosTabla.length === 0) { 86 if($scope.articulosTabla.length === 0) {
88 focaModalService.alert('Debe cargar almenos un articulo'); 87 focaModalService.alert('Debe cargar almenos un articulo');
89 return; 88 return;
90 } 89 }
91 if($scope.notaPedido.domicilio.id === undefined) { 90 if($scope.notaPedido.domicilio.id === undefined) {
92 $scope.notaPedido.domicilio.id = 0; 91 $scope.notaPedido.domicilio.id = 0;
93 } 92 }
94 var date = new Date(); 93 var date = new Date();
95 var notaPedido = { 94 var notaPedido = {
96 id: 0, 95 id: 0,
97 fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 96 fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
98 .toISOString().slice(0, 19).replace('T', ' '), 97 .toISOString().slice(0, 19).replace('T', ' '),
99 vendedor: $scope.notaPedido.vendedor.nombre, 98 vendedor: $scope.notaPedido.vendedor.nombre,
100 idCliente: $scope.notaPedido.cliente.id, 99 idCliente: $scope.notaPedido.cliente.id,
101 domicilio: $scope.notaPedido.domicilio, 100 domicilio: $scope.notaPedido.domicilio,
102 precioCondicion: $scope.notaPedido.precioCondicion, 101 precioCondicion: $scope.notaPedido.precioCondicion,
103 bomba: $scope.notaPedido.bomba, 102 bomba: $scope.notaPedido.bomba,
104 flete: $scope.notaPedido.flete, 103 flete: $scope.notaPedido.flete,
105 total: $scope.getTotal() 104 total: $scope.getTotal()
106 }; 105 };
107 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 106 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
108 function(data) { 107 function(data) {
109 focaModalService.alert('Nota pedido creada'); 108 focaModalService.alert('Nota pedido creada');
110 if($scope.notaPedido.flete === 1) { 109 if($scope.notaPedido.flete === 1) {
111 var flete = { 110 var flete = {
112 idNotaPedido: data.data.id, 111 idNotaPedido: data.data.id,
113 idTransportista: $scope.notaPedido.fleteId, 112 idTransportista: $scope.notaPedido.fleteId,
114 idChofer: $scope.notaPedido.chofer.id, 113 idChofer: $scope.notaPedido.chofer.id,
115 idVehiculo: $scope.notaPedido.vehiculo.id, 114 idVehiculo: $scope.notaPedido.vehiculo.id,
116 kilometros: $scope.notaPedido.kilometros, 115 kilometros: $scope.notaPedido.kilometros,
117 costoKilometro: $scope.notaPedido.costoUnitarioKmFlete 116 costoKilometro: $scope.notaPedido.costoUnitarioKmFlete
118 }; 117 };
119 crearNotaPedidoService.crearFlete(flete); 118 crearNotaPedidoService.crearFlete(flete);
120 } 119 }
121 var articulosNotaPedido = $scope.articulosTabla; 120 var articulosNotaPedido = $scope.articulosTabla;
122 for(var i = 0; i < articulosNotaPedido.length; i++) { 121 for(var i = 0; i < articulosNotaPedido.length; i++) {
123 delete articulosNotaPedido[i].edit; 122 delete articulosNotaPedido[i].edit;
124 articulosNotaPedido[i].idNotaPedido = data.data.id; 123 articulosNotaPedido[i].idNotaPedido = data.data.id;
125 crearNotaPedidoService 124 crearNotaPedidoService
126 .crearArticulosParaNotaPedido(articulosNotaPedido[i]); 125 .crearArticulosParaNotaPedido(articulosNotaPedido[i]);
127 } 126 }
128 $scope.limpiarPantalla(); 127 $scope.limpiarPantalla();
129 } 128 }
130 ); 129 );
131 }; 130 };
132 131
133 $scope.seleccionarArticulo = function() { 132 $scope.seleccionarArticulo = function() {
134 if (idLista === undefined) { 133 if (idLista === undefined) {
135 focaModalService.alert( 134 focaModalService.alert(
136 'Primero seleccione una lista de precio y condicion'); 135 'Primero seleccione una lista de precio y condicion');
137 return; 136 return;
138 } 137 }
139 var modalInstance = $uibModal.open( 138 var modalInstance = $uibModal.open(
140 { 139 {
141 ariaLabelledBy: 'Busqueda de Productos', 140 ariaLabelledBy: 'Busqueda de Productos',
142 templateUrl: 'modal-busqueda-productos.html', 141 templateUrl: 'modal-busqueda-productos.html',
143 controller: 'modalBusquedaProductosCtrl', 142 controller: 'modalBusquedaProductosCtrl',
144 resolve: { idLista: function() { return idLista; } }, 143 resolve: { idLista: function() { return idLista; } },
145 size: 'lg' 144 size: 'lg'
146 } 145 }
147 ); 146 );
148 modalInstance.result.then( 147 modalInstance.result.then(
149 function(producto) { 148 function(producto) {
150 var newArt = 149 var newArt =
151 { 150 {
152 id: 0, 151 id: 0,
153 codigo: producto.codigo, 152 codigo: producto.codigo,
154 sector: producto.sector, 153 sector: producto.sector,
155 descripcion: producto.descripcion, 154 descripcion: producto.descripcion,
156 item: $scope.articulosTabla.length + 1, 155 item: $scope.articulosTabla.length + 1,
157 nombre: producto.descripcion, 156 nombre: producto.descripcion,
158 precio: producto.precio.toFixed(2), 157 precio: producto.precio.toFixed(2),
159 costoUnitario: producto.costo, 158 costoUnitario: producto.costo,
160 edit: false 159 edit: false
161 }; 160 };
162 $scope.articuloACargar = newArt; 161 $scope.articuloACargar = newArt;
163 $scope.cargando = false; 162 $scope.cargando = false;
164 }, function() { 163 }, function() {
165 // funcion ejecutada cuando se cancela el modal 164 // funcion ejecutada cuando se cancela el modal
166 } 165 }
167 ); 166 );
168 }; 167 };
169 168
170 $scope.seleccionarVendedor = function() { 169 $scope.seleccionarVendedor = function() {
171 var modalInstance = $uibModal.open( 170 var modalInstance = $uibModal.open(
172 { 171 {
173 ariaLabelledBy: 'Busqueda de Vendedores', 172 ariaLabelledBy: 'Busqueda de Vendedores',
174 templateUrl: 'modal-vendedores.html', 173 templateUrl: 'modal-vendedores.html',
175 controller: 'modalVendedoresCtrl', 174 controller: 'modalVendedoresCtrl',
176 size: 'lg' 175 size: 'lg'
177 } 176 }
178 ); 177 );
179 modalInstance.result.then( 178 modalInstance.result.then(
180 function(vendedor) { 179 function(vendedor) {
181 addCabecera('Vendedor:', vendedor.NomVen); 180 addCabecera('Vendedor:', vendedor.NomVen);
182 $scope.notaPedido.vendedor.nombre = vendedor.NomVen; 181 $scope.notaPedido.vendedor.nombre = vendedor.NomVen;
183 }, function() { 182 }, function() {
184 183
185 } 184 }
186 ); 185 );
187 }; 186 };
188 187
189 $scope.seleccionarPetrolera = function() { 188 $scope.seleccionarPetrolera = function() {
190 var modalInstance = $uibModal.open( 189 var modalInstance = $uibModal.open(
191 { 190 {
192 ariaLabelledBy: 'Busqueda de Petrolera', 191 ariaLabelledBy: 'Busqueda de Petrolera',
193 templateUrl: 'modal-petroleras.html', 192 templateUrl: 'modal-petroleras.html',
194 controller: 'modalPetrolerasCtrl', 193 controller: 'modalPetrolerasCtrl',
195 size: 'lg' 194 size: 'lg'
196 } 195 }
197 ); 196 );
198 modalInstance.result.then( 197 modalInstance.result.then(
199 function(petrolera) { 198 function(petrolera) {
200 $scope.notaPedido.petrolera = petrolera.NOM; 199 $scope.notaPedido.petrolera = petrolera.NOM;
201 }, function() { 200 }, function() {
202 201
203 } 202 }
204 ); 203 );
205 }; 204 };
206 205
207 $scope.seleccionarCliente = function() { 206 $scope.seleccionarCliente = function() {
208 var modalInstance = $uibModal.open( 207 var modalInstance = $uibModal.open(
209 { 208 {
210 ariaLabelledBy: 'Busqueda de Cliente', 209 ariaLabelledBy: 'Busqueda de Cliente',
211 templateUrl: 'foca-busqueda-cliente-modal.html', 210 templateUrl: 'foca-busqueda-cliente-modal.html',
212 controller: 'focaBusquedaClienteModalController', 211 controller: 'focaBusquedaClienteModalController',
213 size: 'lg' 212 size: 'lg'
214 } 213 }
215 ); 214 );
216 modalInstance.result.then( 215 modalInstance.result.then(
217 function(cliente) { 216 function(cliente) {
218 $scope.notaPedido.cliente.nombre = cliente.nom; 217 $scope.notaPedido.cliente.nombre = cliente.nom;
219 $scope.notaPedido.cliente.id = cliente.cod; 218 $scope.notaPedido.cliente.id = cliente.cod;
220 crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( 219 crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then(
221 function(data) { 220 function(data) {
222 if(data.data.length === 0){ 221 if(data.data.length === 0){
223 focaModalService 222 focaModalService
224 .alert('El cliente no tienen domicilios de entrega') 223 .alert('El cliente no tienen domicilios de entrega')
225 .then( 224 .then(
226 function() { 225 function() {
227 $scope.seleccionarCliente(); 226 $scope.seleccionarCliente();
228 $scope.notaPedido.cliente = {nombre: ''}; 227 $scope.notaPedido.cliente = {nombre: ''};
229 } 228 }
230 ); 229 );
231 return; 230 return;
232 } 231 }
233 $scope.domiciliosCliente = data.data; 232 $scope.domiciliosCliente = data.data;
234 } 233 }
235 ); 234 );
236 235
237 addCabecera('Cliente:', cliente.nom); 236 addCabecera('Cliente:', cliente.nom);
238 }, function() { 237 }, function() {
239 238
240 } 239 }
241 ); 240 );
242 }; 241 };
243 242
244 $scope.mostrarFichaCliente = function() { 243 $scope.mostrarFichaCliente = function() {
245 $uibModal.open( 244 $uibModal.open(
246 { 245 {
247 ariaLabelledBy: 'Datos del Cliente', 246 ariaLabelledBy: 'Datos del Cliente',
248 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', 247 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html',
249 controller: 'focaCrearNotaPedidoFichaClienteController', 248 controller: 'focaCrearNotaPedidoFichaClienteController',
250 size: 'lg' 249 size: 'lg'
251 } 250 }
252 ); 251 );
253 }; 252 };
254 253
255 $scope.getTotal = function() { 254 $scope.getTotal = function() {
256 var total = 0; 255 var total = 0;
257 var arrayTempArticulos = $scope.articulosTabla; 256 var arrayTempArticulos = $scope.articulosTabla;
258 for (var i = 0; i < arrayTempArticulos.length; i++) { 257 for (var i = 0; i < arrayTempArticulos.length; i++) {
259 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 258 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
260 } 259 }
261 return total.toFixed(2); 260 return total.toFixed(2);
262 }; 261 };
263 262
264 $scope.getSubTotal = function() { 263 $scope.getSubTotal = function() {
265 if($scope.articuloACargar) { 264 if($scope.articuloACargar) {
266 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 265 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
267 } 266 }
268 }; 267 };
269 268
270 $scope.abrirModalListaPrecio = function() { 269 $scope.abrirModalListaPrecio = function() {
271 var modalInstance = $uibModal.open( 270 var modalInstance = $uibModal.open(
272 { 271 {
273 ariaLabelledBy: 'Busqueda de Precio Condición', 272 ariaLabelledBy: 'Busqueda de Precio Condición',
274 templateUrl: 'modal-precio-condicion.html', 273 templateUrl: 'modal-precio-condicion.html',
275 controller: 'focaModalPrecioCondicionController', 274 controller: 'focaModalPrecioCondicionController',
276 size: 'lg' 275 size: 'lg'
277 } 276 }
278 ); 277 );
279 modalInstance.result.then( 278 modalInstance.result.then(
280 function(precioCondicion) { 279 function(precioCondicion) {
281 $scope.notaPedido.precioCondicion = precioCondicion.nombre; 280 $scope.notaPedido.precioCondicion = precioCondicion.nombre;
282 idLista = precioCondicion.idListaPrecio; 281 idLista = precioCondicion.idListaPrecio;
283 $scope.articulosTabla = []; 282 $scope.articulosTabla = [];
284 283
285 addCabecera('Precios y condiciones:', precioCondicion.nombre); 284 addCabecera('Precios y condiciones:', precioCondicion.nombre);
286 }, function() { 285 }, function() {
287 286
288 } 287 }
289 ); 288 );
290 }; 289 };
291 290
292 $scope.abrirModalFlete = function() { 291 $scope.abrirModalFlete = function() {
293 var modalInstance = $uibModal.open( 292 var modalInstance = $uibModal.open(
294 { 293 {
295 ariaLabelledBy: 'Busqueda de Flete', 294 ariaLabelledBy: 'Busqueda de Flete',
296 templateUrl: 'modal-flete.html', 295 templateUrl: 'modal-flete.html',
297 controller: 'focaModalFleteController', 296 controller: 'focaModalFleteController',
298 size: 'lg', 297 size: 'lg',
299 resolve: { 298 resolve: {
300 parametrosFlete: 299 parametrosFlete:
301 function() { 300 function() {
302 return { 301 return {
303 flete: $scope.notaPedido.flete, 302 flete: $scope.notaPedido.flete,
304 bomba: $scope.notaPedido.bomba, 303 bomba: $scope.notaPedido.bomba,
305 kilometros: $scope.notaPedido.kilometros 304 kilometros: $scope.notaPedido.kilometros
306 }; 305 };
307 } 306 }
308 } 307 }
309 } 308 }
310 ); 309 );
311 modalInstance.result.then( 310 modalInstance.result.then(
312 function(datos) { 311 function(datos) {
313 $scope.notaPedido.flete = datos.flete; 312 $scope.notaPedido.flete = datos.flete;
314 $scope.notaPedido.bomba = datos.bomba; 313 $scope.notaPedido.bomba = datos.bomba;
315 $scope.notaPedido.kilometros = datos.kilometros; 314 $scope.notaPedido.kilometros = datos.kilometros;
316 315
317 addCabecera('Flete:', datos.flete); 316 addCabecera('Flete:', datos.flete);
318 if(datos.flete === 'si') { 317 if(datos.flete === 'si') {
319 addCabecera('Bomba:', datos.bomba); 318 addCabecera('Bomba:', datos.bomba);
320 addCabecera('Kilometros:', datos.kilometros); 319 addCabecera('Kilometros:', datos.kilometros);
321 } else { 320 } else {
322 removeCabecera('Bomba:'); 321 removeCabecera('Bomba:');
323 removeCabecera('Kilometros:'); 322 removeCabecera('Kilometros:');
324 } 323 }
325 }, function() { 324 }, function() {
326 325
327 } 326 }
328 ); 327 );
329 }; 328 };
330 329
331 $scope.abrirModalMoneda = function() { 330 $scope.abrirModalMoneda = function() {
332 var modalInstance = $uibModal.open( 331 var modalInstance = $uibModal.open(
333 { 332 {
334 ariaLabelledBy: 'Busqueda de Moneda', 333 ariaLabelledBy: 'Busqueda de Moneda',
335 templateUrl: 'modal-moneda.html', 334 templateUrl: 'modal-moneda.html',
336 controller: 'focaModalMonedaController', 335 controller: 'focaModalMonedaController',
337 size: 'lg' 336 size: 'lg'
338 } 337 }
339 ); 338 );
340 modalInstance.result.then( 339 modalInstance.result.then(
341 function(moneda) { 340 function(moneda) {
342 $scope.notaPedido.moneda = { 341 $scope.notaPedido.moneda = {
343 id: moneda.ID, 342 id: moneda.ID,
344 detalle: moneda.DETALLE, 343 detalle: moneda.DETALLE,
345 simbolo: moneda.SIMBOLO 344 simbolo: moneda.SIMBOLO
346 }; 345 };
347 346
348 addCabecera('Moneda:', moneda.DETALLE); 347 addCabecera('Moneda:', moneda.DETALLE);
349 }, function() { 348 }, function() {
350 349
351 } 350 }
352 ); 351 );
353 }; 352 };
354 353
355 $scope.agregarATabla = function(key) { 354 $scope.agregarATabla = function(key) {
356 if(key === 13) { 355 if(key === 13) {
357 if($scope.articuloACargar.cantidad === undefined || 356 if($scope.articuloACargar.cantidad === undefined ||
358 $scope.articuloACargar.cantidad === 0 || 357 $scope.articuloACargar.cantidad === 0 ||
359 $scope.articuloACargar.cantidad === null ){ 358 $scope.articuloACargar.cantidad === null ){
360 focaModalService.alert('El valor debe ser al menos 1'); 359 focaModalService.alert('El valor debe ser al menos 1');
361 return; 360 return;
362 } 361 }
363 $scope.articulosTabla.unshift($scope.articuloACargar); 362 $scope.articulosTabla.unshift($scope.articuloACargar);
364 $scope.cargando = true; 363 $scope.cargando = true;
365 } 364 }
366 }; 365 };
367 366
368 $scope.quitarArticulo = function(key) { 367 $scope.quitarArticulo = function(key) {
369 $scope.articulosTabla.splice(key, 1); 368 $scope.articulosTabla.splice(key, 1);
370 }; 369 };
371 370
372 $scope.editarArticulo = function(key, articulo) { 371 $scope.editarArticulo = function(key, articulo) {
373 if(key === 13) { 372 if(key === 13) {
374 if(articulo.cantidad === null || articulo.cantidad === 0 || 373 if(articulo.cantidad === null || articulo.cantidad === 0 ||
375 articulo.cantidad === undefined){ 374 articulo.cantidad === undefined){
376 focaModalService.alert('El valor debe ser al menos 1'); 375 focaModalService.alert('El valor debe ser al menos 1');
377 return; 376 return;
378 } 377 }
379 articulo.edit = false; 378 articulo.edit = false;
380 } 379 }
381 }; 380 };
382 381
383 $scope.cambioEdit = function(articulo) { 382 $scope.cambioEdit = function(articulo) {
384 articulo.edit = true; 383 articulo.edit = true;
385 }; 384 };
386 385
387 $scope.limpiarFlete = function() { 386 $scope.limpiarFlete = function() {
388 $scope.notaPedido.fleteNombre = ''; 387 $scope.notaPedido.fleteNombre = '';
389 $scope.notaPedido.chofer = ''; 388 $scope.notaPedido.chofer = '';
390 $scope.notaPedido.vehiculo = ''; 389 $scope.notaPedido.vehiculo = '';
391 $scope.notaPedido.kilometros = ''; 390 $scope.notaPedido.kilometros = '';
392 $scope.notaPedido.costoUnitarioKmFlete = ''; 391 $scope.notaPedido.costoUnitarioKmFlete = '';
393 $scope.choferes = ''; 392 $scope.choferes = '';
394 $scope.vehiculos = ''; 393 $scope.vehiculos = '';
395 }; 394 };
396 395
397 $scope.limpiarPantalla = function() { 396 $scope.limpiarPantalla = function() {
398 $scope.limpiarFlete(); 397 $scope.limpiarFlete();
399 $scope.notaPedido.flete = '0'; 398 $scope.notaPedido.flete = '0';
400 $scope.notaPedido.bomba = '0'; 399 $scope.notaPedido.bomba = '0';
401 $scope.notaPedido.precioCondicion = ''; 400 $scope.notaPedido.precioCondicion = '';
402 $scope.articulosTabla = []; 401 $scope.articulosTabla = [];
403 $scope.notaPedido.vendedor.nombre = ''; 402 $scope.notaPedido.vendedor.nombre = '';
404 $scope.notaPedido.cliente = {nombre: ''}; 403 $scope.notaPedido.cliente = {nombre: ''};
405 $scope.notaPedido.domicilio = {dom: ''}; 404 $scope.notaPedido.domicilio = {dom: ''};
406 $scope.domiciliosCliente = []; 405 $scope.domiciliosCliente = [];
407 }; 406 };
408 407
409 $scope.resetFilter = function() { 408 $scope.resetFilter = function() {
410 $scope.articuloACargar = {}; 409 $scope.articuloACargar = {};
411 $scope.cargando = true; 410 $scope.cargando = true;
412 }; 411 };
413 412
414 $scope.selectFocus = function($event) { 413 $scope.selectFocus = function($event) {
415 $event.target.select(); 414 $event.target.select();
416 }; 415 };
417 416
418 $scope.salir = function() { 417 $scope.salir = function() {
419 $location.path('/'); 418 $location.path('/');
420 }; 419 };
421 420
422 function addCabecera(label, valor) { 421 function addCabecera(label, valor) {
423 var propiedad = $filter('filter')($scope.cabecera, {label: label}); 422 var propiedad = $filter('filter')($scope.cabecera, {label: label});
424 if(propiedad.length === 1) { 423 if(propiedad.length === 1) {
425 propiedad[0].valor = valor; 424 propiedad[0].valor = valor;
426 } else { 425 } else {
427 $scope.cabecera.push({label: label, valor: valor}); 426 $scope.cabecera.push({label: label, valor: valor});
428 } 427 }
429 } 428 }
430 429
431 function removeCabecera(label) { 430 function removeCabecera(label) {
432 var propiedad = $filter('filter')($scope.cabecera, {label: label}); 431 var propiedad = $filter('filter')($scope.cabecera, {label: label});
433 if(propiedad.length === 1){ 432 if(propiedad.length === 1){
434 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 433 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
435 } 434 }
436 } 435 }
437 } 436 }
438 ] 437 ]
439 ) 438 )
440 .controller('notaPedidoListaCtrl', [ 439 .controller('notaPedidoListaCtrl', [
441 '$scope', 440 '$scope',
442 'crearNotaPedidoService', 441 'crearNotaPedidoService',
443 '$location', 442 '$location',
444 function($scope, crearNotaPedidoService, $location) { 443 function($scope, crearNotaPedidoService, $location) {
445 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 444 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
446 $scope.notaPedidos = datos.data; 445 $scope.notaPedidos = datos.data;
447 }); 446 });
448 $scope.editar = function(notaPedido) { 447 $scope.editar = function(notaPedido) {
449 crearNotaPedidoService.setNotaPedido(notaPedido); 448 crearNotaPedidoService.setNotaPedido(notaPedido);
450 $location.path('/venta-nota-pedido/abm/'); 449 $location.path('/venta-nota-pedido/abm/');
451 }; 450 };
452 $scope.crearPedido = function() { 451 $scope.crearPedido = function() {
453 crearNotaPedidoService.clearNotaPedido(); 452 crearNotaPedidoService.clearNotaPedido();
454 $location.path('/venta-nota-pedido/abm/'); 453 $location.path('/venta-nota-pedido/abm/');
455 }; 454 };
456 } 455 }
457 ]) 456 ])
458 .controller('focaCrearNotaPedidoFichaClienteController', [ 457 .controller('focaCrearNotaPedidoFichaClienteController', [
459 '$scope', 458 '$scope',
460 'crearNotaPedidoService', 459 'crearNotaPedidoService',
461 '$location', 460 '$location',
462 function($scope, crearNotaPedidoService, $location) { 461 function($scope, crearNotaPedidoService, $location) {
463 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 462 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
464 $scope.notaPedidos = datos.data; 463 $scope.notaPedidos = datos.data;
465 }); 464 });
466 $scope.editar = function(notaPedido) { 465 $scope.editar = function(notaPedido) {
467 crearNotaPedidoService.setNotaPedido(notaPedido); 466 crearNotaPedidoService.setNotaPedido(notaPedido);
468 $location.path('/venta-nota-pedido/abm/'); 467 $location.path('/venta-nota-pedido/abm/');
469 }; 468 };
470 $scope.crearPedido = function() { 469 $scope.crearPedido = function() {
471 crearNotaPedidoService.clearNotaPedido(); 470 crearNotaPedidoService.clearNotaPedido();
472 $location.path('/venta-nota-pedido/abm/'); 471 $location.path('/venta-nota-pedido/abm/');
473 }; 472 };
474 } 473 }
475 ]); 474 ]);
476 475