Commit 4628f0848d6b500b6b9e7b8a2e4003fe41cceb34
1 parent
687a0d4b31
Exists in
master
add to do's
Showing
1 changed file
with
34 additions
and
26 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -33,31 +33,37 @@ angular.module('focaCrearNotaPedido') |
| 33 | 33 | $scope.articulosTabla = res.data; |
| 34 | 34 | } |
| 35 | 35 | ); |
| 36 | + //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | |
| 37 | + //(NO REQUERIDO EN ESTA VERSION) | |
| 36 | 38 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 37 | 39 | // function(res) { |
| 38 | 40 | // $scope.notaPedido.domicilio = res.data; |
| 39 | 41 | // } |
| 40 | 42 | // ); |
| 41 | 43 | } else { |
| 42 | - $scope.notaPedido.fechaCarga = new Date(); | |
| 43 | - // $scope.notaPedido.domicilio = [{ id: 0 }]; | |
| 44 | + $scope.notaPedido.fechaCarga = new Date(); | |
| 44 | 45 | $scope.notaPedido.bomba = '0'; |
| 45 | 46 | $scope.notaPedido.flete = '0'; |
| 46 | 47 | idLista = undefined; |
| 47 | 48 | } |
| 48 | - $scope.addNewDom = function() { | |
| 49 | - $scope.notaPedido.domicilio.push({ 'id': 0 }); | |
| 50 | - }; | |
| 51 | - $scope.removeNewChoice = function(choice) { | |
| 52 | - if ($scope.notaPedido.domicilio.length > 1) { | |
| 53 | - $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | |
| 54 | - function(c) { | |
| 55 | - return c.$$hashKey === choice.$$hashKey; | |
| 56 | - } | |
| 57 | - ), 1); | |
| 58 | - } | |
| 59 | - }; | |
| 49 | + //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | |
| 50 | + // $scope.addNewDom = function() { | |
| 51 | + // $scope.notaPedido.domicilio.push({ 'id': 0 }); | |
| 52 | + // }; | |
| 53 | + // $scope.removeNewChoice = function(choice) { | |
| 54 | + // if ($scope.notaPedido.domicilio.length > 1) { | |
| 55 | + // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | |
| 56 | + // function(c) { | |
| 57 | + // return c.$$hashKey === choice.$$hashKey; | |
| 58 | + // } | |
| 59 | + // ), 1); | |
| 60 | + // } | |
| 61 | + // }; | |
| 60 | 62 | $scope.crearNotaPedido = function() { |
| 63 | + if($scope.articulosTabla.length === 0) { | |
| 64 | + focaModalService.alert('Debe cargar almenos un articulo'); | |
| 65 | + return; | |
| 66 | + } | |
| 61 | 67 | if($scope.notaPedido.domicilio.id === undefined) { |
| 62 | 68 | $scope.notaPedido.domicilio.id = 0; |
| 63 | 69 | } |
| ... | ... | @@ -77,15 +83,17 @@ angular.module('focaCrearNotaPedido') |
| 77 | 83 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 78 | 84 | function(data) { |
| 79 | 85 | focaModalService.alert('Nota pedido creada'); |
| 80 | - var flete = { | |
| 81 | - idNotaPedido: data.data.id, | |
| 82 | - idTransportista: $scope.notaPedido.fleteId, | |
| 83 | - idChofer: $scope.notaPedido.chofer.id, | |
| 84 | - idVehiculo: $scope.notaPedido.vehiculo.id, | |
| 85 | - kilometros: $scope.notaPedido.kilometros, | |
| 86 | - costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | |
| 87 | - }; | |
| 88 | - crearNotaPedidoService.crearFlete(flete); | |
| 86 | + if($scope.notaPedido.flete === 1) { | |
| 87 | + var flete = { | |
| 88 | + idNotaPedido: data.data.id, | |
| 89 | + idTransportista: $scope.notaPedido.fleteId, | |
| 90 | + idChofer: $scope.notaPedido.chofer.id, | |
| 91 | + idVehiculo: $scope.notaPedido.vehiculo.id, | |
| 92 | + kilometros: $scope.notaPedido.kilometros, | |
| 93 | + costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | |
| 94 | + }; | |
| 95 | + crearNotaPedidoService.crearFlete(flete); | |
| 96 | + } | |
| 89 | 97 | var articulosNotaPedido = $scope.articulosTabla; |
| 90 | 98 | for(var i = 0; i< articulosNotaPedido.length;i++) { |
| 91 | 99 | delete articulosNotaPedido[i].edit; |
| ... | ... | @@ -214,9 +222,9 @@ angular.module('focaCrearNotaPedido') |
| 214 | 222 | }; |
| 215 | 223 | $scope.getTotal = function() { |
| 216 | 224 | var total = 0; |
| 217 | - var array = $scope.articulosTabla; | |
| 218 | - for (var i = 0; i < array.length; i++) { | |
| 219 | - total += array[i].precio * array[i].cantidad; | |
| 225 | + var arrayTempArticulos = $scope.articulosTabla; | |
| 226 | + for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 227 | + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
| 220 | 228 | } |
| 221 | 229 | return total.toFixed(2); |
| 222 | 230 | }; |