Commit 5634823744b90fe8c3455d9aca92a6036fd2499c
1 parent
da15a2d281
Exists in
master
and in
1 other branch
Agrego validaciones para no permitir cantidad en 0
Showing
1 changed file
with
11 additions
and
0 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
| 2 | .controller('notaPedidoCtrl', | 2 | .controller('notaPedidoCtrl', |
| 3 | ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', | 3 | ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', |
| 4 | function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { | 4 | function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { |
| 5 | $scope.show = false; | 5 | $scope.show = false; |
| 6 | $scope.cargando = true; | 6 | $scope.cargando = true; |
| 7 | $scope.dateOptions = { | 7 | $scope.dateOptions = { |
| 8 | maxDate: new Date(), | 8 | maxDate: new Date(), |
| 9 | minDate: new Date(2010, 0, 1) | 9 | minDate: new Date(2010, 0, 1) |
| 10 | }; | 10 | }; |
| 11 | $scope.notaPedido = { | 11 | $scope.notaPedido = { |
| 12 | vendedor: {}, | 12 | vendedor: {}, |
| 13 | cliente: {} | 13 | cliente: {} |
| 14 | }; | 14 | }; |
| 15 | $scope.articulosTabla = []; | 15 | $scope.articulosTabla = []; |
| 16 | var idLista; | 16 | var idLista; |
| 17 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 17 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 18 | $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); | 18 | $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); |
| 19 | crearNotaPedidoService.getPrecioCondicion().then( | 19 | crearNotaPedidoService.getPrecioCondicion().then( |
| 20 | function(res) { | 20 | function(res) { |
| 21 | $scope.precioCondiciones = res.data; | 21 | $scope.precioCondiciones = res.data; |
| 22 | } | 22 | } |
| 23 | ); | 23 | ); |
| 24 | if (notaPedidoTemp !== undefined) { | 24 | if (notaPedidoTemp !== undefined) { |
| 25 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 25 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 26 | $scope.notaPedido = notaPedidoTemp; | 26 | $scope.notaPedido = notaPedidoTemp; |
| 27 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 27 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 28 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 28 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 29 | idLista = $scope.notaPedido.precioCondicion; | 29 | idLista = $scope.notaPedido.precioCondicion; |
| 30 | crearNotaPedidoService | 30 | crearNotaPedidoService |
| 31 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 31 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 32 | function(res) { | 32 | function(res) { |
| 33 | $scope.articulosTabla = res.data; | 33 | $scope.articulosTabla = res.data; |
| 34 | } | 34 | } |
| 35 | ); | 35 | ); |
| 36 | crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 36 | crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 37 | function(res) { | 37 | function(res) { |
| 38 | $scope.notaPedido.domicilio = res.data; | 38 | $scope.notaPedido.domicilio = res.data; |
| 39 | } | 39 | } |
| 40 | ); | 40 | ); |
| 41 | } else { | 41 | } else { |
| 42 | $scope.notaPedido.fechaCarga = new Date(); | 42 | $scope.notaPedido.fechaCarga = new Date(); |
| 43 | $scope.notaPedido.domicilio = [{ id: 0 }]; | 43 | $scope.notaPedido.domicilio = [{ id: 0 }]; |
| 44 | $scope.notaPedido.bomba = '1'; | 44 | $scope.notaPedido.bomba = '1'; |
| 45 | $scope.notaPedido.flete = '0'; | 45 | $scope.notaPedido.flete = '0'; |
| 46 | idLista = undefined; | 46 | idLista = undefined; |
| 47 | } | 47 | } |
| 48 | $scope.addNewDom = function() { | 48 | $scope.addNewDom = function() { |
| 49 | $scope.notaPedido.domicilio.push({ 'id': 0 }); | 49 | $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 50 | }; | 50 | }; |
| 51 | $scope.removeNewChoice = function(choice) { | 51 | $scope.removeNewChoice = function(choice) { |
| 52 | if ($scope.notaPedido.domicilio.length > 1) { | 52 | if ($scope.notaPedido.domicilio.length > 1) { |
| 53 | $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 53 | $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 54 | function(c) { | 54 | function(c) { |
| 55 | return c.$$hashKey === choice.$$hashKey; | 55 | return c.$$hashKey === choice.$$hashKey; |
| 56 | } | 56 | } |
| 57 | ), 1); | 57 | ), 1); |
| 58 | } | 58 | } |
| 59 | }; | 59 | }; |
| 60 | $scope.crearNotaPedido = function() { | 60 | $scope.crearNotaPedido = function() { |
| 61 | var notaPedido = { | 61 | var notaPedido = { |
| 62 | id: 0, | 62 | id: 0, |
| 63 | fechaCarga: $scope.notaPedido.fechaCarga, | 63 | fechaCarga: $scope.notaPedido.fechaCarga, |
| 64 | vendedor: $scope.notaPedido.vendedor.nombre, | 64 | vendedor: $scope.notaPedido.vendedor.nombre, |
| 65 | cliente: $scope.notaPedido.cliente.nombre, | 65 | cliente: $scope.notaPedido.cliente.nombre, |
| 66 | domicilio: $scope.notaPedido.domicilio.id, | 66 | domicilio: $scope.notaPedido.domicilio.id, |
| 67 | precioCondicion: $scope.notaPedido.precioCondicion, | 67 | precioCondicion: $scope.notaPedido.precioCondicion, |
| 68 | bomba: $scope.notaPedido.bomba, | 68 | bomba: $scope.notaPedido.bomba, |
| 69 | flete: $scope.notaPedido.flete, | 69 | flete: $scope.notaPedido.flete, |
| 70 | total: $scope.getTotal() | 70 | total: $scope.getTotal() |
| 71 | }; | 71 | }; |
| 72 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 72 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 73 | function() { | 73 | function() { |
| 74 | focaModalService.alert('Nota pedido creada'); | 74 | focaModalService.alert('Nota pedido creada'); |
| 75 | // $location.path('/venta-nota-pedido'); | 75 | // $location.path('/venta-nota-pedido'); |
| 76 | // var flete = { | 76 | // var flete = { |
| 77 | // idNotaPedido: data.data.id, | 77 | // idNotaPedido: data.data.id, |
| 78 | // idTransportista: $scope.notaPedido.fleteId, | 78 | // idTransportista: $scope.notaPedido.fleteId, |
| 79 | // idChofer: $scope.chofer.id, | 79 | // idChofer: $scope.chofer.id, |
| 80 | // idVehiculo: $scope.vehiculo.id, | 80 | // idVehiculo: $scope.vehiculo.id, |
| 81 | // kilometros: $scope.notaPedido.kilometros, | 81 | // kilometros: $scope.notaPedido.kilometros, |
| 82 | // costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 82 | // costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
| 83 | // }; | 83 | // }; |
| 84 | //TO DO - Insert de flete | 84 | //TO DO - Insert de flete |
| 85 | } | 85 | } |
| 86 | ); | 86 | ); |
| 87 | var articulosNotaPedido = $scope.articulosTabla; | 87 | var articulosNotaPedido = $scope.articulosTabla; |
| 88 | for(var i = 0; i< articulosNotaPedido.length;i++) { | 88 | for(var i = 0; i< articulosNotaPedido.length;i++) { |
| 89 | crearNotaPedidoService | 89 | crearNotaPedidoService |
| 90 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( | 90 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( |
| 91 | function() { | 91 | function() { |
| 92 | return; | 92 | return; |
| 93 | } | 93 | } |
| 94 | ); | 94 | ); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | }; | 97 | }; |
| 98 | $scope.siguienteTab = function() { | 98 | $scope.siguienteTab = function() { |
| 99 | $scope.active = 1; | 99 | $scope.active = 1; |
| 100 | }; | 100 | }; |
| 101 | $scope.seleccionarArticulo = function() { | 101 | $scope.seleccionarArticulo = function() { |
| 102 | if (idLista === undefined) { | 102 | if (idLista === undefined) { |
| 103 | focaModalService.alert( | 103 | focaModalService.alert( |
| 104 | 'primero seleccione una lista de precio y condicion'); | 104 | 'primero seleccione una lista de precio y condicion'); |
| 105 | return; | 105 | return; |
| 106 | } | 106 | } |
| 107 | var modalInstance = $uibModal.open( | 107 | var modalInstance = $uibModal.open( |
| 108 | { | 108 | { |
| 109 | ariaLabelledBy: 'Busqueda de Productos', | 109 | ariaLabelledBy: 'Busqueda de Productos', |
| 110 | templateUrl: 'modal-busqueda-productos.html', | 110 | templateUrl: 'modal-busqueda-productos.html', |
| 111 | controller: 'modalBusquedaProductosCtrl', | 111 | controller: 'modalBusquedaProductosCtrl', |
| 112 | resolve: { idLista: function() { return idLista; } }, | 112 | resolve: { idLista: function() { return idLista; } }, |
| 113 | size: 'lg' | 113 | size: 'lg' |
| 114 | } | 114 | } |
| 115 | ); | 115 | ); |
| 116 | modalInstance.result.then( | 116 | modalInstance.result.then( |
| 117 | function(producto) { | 117 | function(producto) { |
| 118 | var newArt = | 118 | var newArt = |
| 119 | { | 119 | { |
| 120 | id: 0, | 120 | id: 0, |
| 121 | codigo: producto.codigo, | 121 | codigo: producto.codigo, |
| 122 | sector: producto.sector, | 122 | sector: producto.sector, |
| 123 | descripcion: producto.descripcion, | 123 | descripcion: producto.descripcion, |
| 124 | item: $scope.articulosTabla.length + 1, | 124 | item: $scope.articulosTabla.length + 1, |
| 125 | nombre: producto.descripcion, | 125 | nombre: producto.descripcion, |
| 126 | precio: producto.precio.toFixed(2), | 126 | precio: producto.precio.toFixed(2), |
| 127 | costoUnitario: producto.costo, | 127 | costoUnitario: producto.costo, |
| 128 | edit: false | 128 | edit: false |
| 129 | }; | 129 | }; |
| 130 | $scope.articuloACargar = newArt; | 130 | $scope.articuloACargar = newArt; |
| 131 | $scope.cargando = false; | 131 | $scope.cargando = false; |
| 132 | }, function() { | 132 | }, function() { |
| 133 | // funcion ejecutada cuando se cancela el modal | 133 | // funcion ejecutada cuando se cancela el modal |
| 134 | } | 134 | } |
| 135 | ); | 135 | ); |
| 136 | }; | 136 | }; |
| 137 | $scope.seleccionarVendedor = function() { | 137 | $scope.seleccionarVendedor = function() { |
| 138 | var modalInstance = $uibModal.open( | 138 | var modalInstance = $uibModal.open( |
| 139 | { | 139 | { |
| 140 | ariaLabelledBy: 'Busqueda de Vendedores', | 140 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 141 | templateUrl: 'modal-vendedores.html', | 141 | templateUrl: 'modal-vendedores.html', |
| 142 | controller: 'modalVendedoresCtrl', | 142 | controller: 'modalVendedoresCtrl', |
| 143 | size: 'lg' | 143 | size: 'lg' |
| 144 | } | 144 | } |
| 145 | ); | 145 | ); |
| 146 | modalInstance.result.then( | 146 | modalInstance.result.then( |
| 147 | function(vendedor) { | 147 | function(vendedor) { |
| 148 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 148 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
| 149 | }, function() { | 149 | }, function() { |
| 150 | 150 | ||
| 151 | } | 151 | } |
| 152 | ); | 152 | ); |
| 153 | }; | 153 | }; |
| 154 | $scope.seleccionarPetrolera = function() { | 154 | $scope.seleccionarPetrolera = function() { |
| 155 | var modalInstance = $uibModal.open( | 155 | var modalInstance = $uibModal.open( |
| 156 | { | 156 | { |
| 157 | ariaLabelledBy: 'Busqueda de Petrolera', | 157 | ariaLabelledBy: 'Busqueda de Petrolera', |
| 158 | templateUrl: 'modal-petroleras.html', | 158 | templateUrl: 'modal-petroleras.html', |
| 159 | controller: 'modalPetrolerasCtrl', | 159 | controller: 'modalPetrolerasCtrl', |
| 160 | size: 'lg' | 160 | size: 'lg' |
| 161 | } | 161 | } |
| 162 | ); | 162 | ); |
| 163 | modalInstance.result.then( | 163 | modalInstance.result.then( |
| 164 | function(petrolera) { | 164 | function(petrolera) { |
| 165 | $scope.notaPedido.petrolera = petrolera.NOM; | 165 | $scope.notaPedido.petrolera = petrolera.NOM; |
| 166 | }, function() { | 166 | }, function() { |
| 167 | 167 | ||
| 168 | } | 168 | } |
| 169 | ); | 169 | ); |
| 170 | }; | 170 | }; |
| 171 | $scope.seleccionarCliente = function() { | 171 | $scope.seleccionarCliente = function() { |
| 172 | var modalInstance = $uibModal.open( | 172 | var modalInstance = $uibModal.open( |
| 173 | { | 173 | { |
| 174 | ariaLabelledBy: 'Busqueda de Cliente', | 174 | ariaLabelledBy: 'Busqueda de Cliente', |
| 175 | templateUrl: 'foca-busqueda-cliente-modal.html', | 175 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 176 | controller: 'focaBusquedaClienteModalController', | 176 | controller: 'focaBusquedaClienteModalController', |
| 177 | size: 'lg' | 177 | size: 'lg' |
| 178 | } | 178 | } |
| 179 | ); | 179 | ); |
| 180 | modalInstance.result.then( | 180 | modalInstance.result.then( |
| 181 | function(cliente) { | 181 | function(cliente) { |
| 182 | $scope.notaPedido.cliente.nombre = cliente.nom; | 182 | $scope.notaPedido.cliente.nombre = cliente.nom; |
| 183 | }, function() { | 183 | }, function() { |
| 184 | 184 | ||
| 185 | } | 185 | } |
| 186 | ); | 186 | ); |
| 187 | }; | 187 | }; |
| 188 | $scope.mostrarFichaCliente = function() { | 188 | $scope.mostrarFichaCliente = function() { |
| 189 | $uibModal.open( | 189 | $uibModal.open( |
| 190 | { | 190 | { |
| 191 | ariaLabelledBy: 'Datos del Cliente', | 191 | ariaLabelledBy: 'Datos del Cliente', |
| 192 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 192 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 193 | controller: 'focaCrearNotaPedidoFichaClienteController', | 193 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 194 | size: 'lg' | 194 | size: 'lg' |
| 195 | } | 195 | } |
| 196 | ); | 196 | ); |
| 197 | }; | 197 | }; |
| 198 | $scope.obtenerDomicilios = function(id) { | 198 | $scope.obtenerDomicilios = function(id) { |
| 199 | crearNotaPedidoService.getDomicilios(id).then( | 199 | crearNotaPedidoService.getDomicilios(id).then( |
| 200 | function(res) { | 200 | function(res) { |
| 201 | $scope.notaPedido.domicilio = res.data; | 201 | $scope.notaPedido.domicilio = res.data; |
| 202 | } | 202 | } |
| 203 | ); | 203 | ); |
| 204 | }; | 204 | }; |
| 205 | $scope.getTotal = function() { | 205 | $scope.getTotal = function() { |
| 206 | var total = 0; | 206 | var total = 0; |
| 207 | var array = $scope.articulosTabla; | 207 | var array = $scope.articulosTabla; |
| 208 | for (var i = 0; i < array.length; i++) { | 208 | for (var i = 0; i < array.length; i++) { |
| 209 | total += array[i].precio * array[i].cantidad; | 209 | total += array[i].precio * array[i].cantidad; |
| 210 | } | 210 | } |
| 211 | return total.toFixed(2); | 211 | return total.toFixed(2); |
| 212 | }; | 212 | }; |
| 213 | $scope.getSubTotal = function() { | 213 | $scope.getSubTotal = function() { |
| 214 | if($scope.articuloACargar) { | 214 | if($scope.articuloACargar) { |
| 215 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 215 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 216 | } | 216 | } |
| 217 | }; | 217 | }; |
| 218 | $scope.cargarArticulos = function() { | 218 | $scope.cargarArticulos = function() { |
| 219 | idLista = $scope.notaPedido.precioCondicion; | 219 | idLista = $scope.notaPedido.precioCondicion; |
| 220 | $scope.articulosTabla = []; | 220 | $scope.articulosTabla = []; |
| 221 | }; | 221 | }; |
| 222 | $scope.abrirModalListaPrecio = function() { | 222 | $scope.abrirModalListaPrecio = function() { |
| 223 | var modalInstance = $uibModal.open( | 223 | var modalInstance = $uibModal.open( |
| 224 | { | 224 | { |
| 225 | ariaLabelledBy: 'Busqueda de Precio Condición', | 225 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 226 | templateUrl: 'modal-precio-condicion.html', | 226 | templateUrl: 'modal-precio-condicion.html', |
| 227 | controller: 'focaModalPrecioCondicionController', | 227 | controller: 'focaModalPrecioCondicionController', |
| 228 | size: 'lg' | 228 | size: 'lg' |
| 229 | } | 229 | } |
| 230 | ); | 230 | ); |
| 231 | modalInstance.result.then( | 231 | modalInstance.result.then( |
| 232 | function(precioCondicion) { | 232 | function(precioCondicion) { |
| 233 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 233 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
| 234 | idLista = precioCondicion.idListaPrecio; | 234 | idLista = precioCondicion.idListaPrecio; |
| 235 | $scope.articulosTabla = []; | 235 | $scope.articulosTabla = []; |
| 236 | }, function() { | 236 | }, function() { |
| 237 | 237 | ||
| 238 | } | 238 | } |
| 239 | ); | 239 | ); |
| 240 | }; | 240 | }; |
| 241 | $scope.abrirModalFlete = function() { | 241 | $scope.abrirModalFlete = function() { |
| 242 | if($scope.notaPedido.flete === '1') { | 242 | if($scope.notaPedido.flete === '1') { |
| 243 | var modalInstance = $uibModal.open( | 243 | var modalInstance = $uibModal.open( |
| 244 | { | 244 | { |
| 245 | ariaLabelledBy: 'Busqueda de Flete', | 245 | ariaLabelledBy: 'Busqueda de Flete', |
| 246 | templateUrl: 'modal-flete.html', | 246 | templateUrl: 'modal-flete.html', |
| 247 | controller: 'focaModalFleteController', | 247 | controller: 'focaModalFleteController', |
| 248 | size: 'lg' | 248 | size: 'lg' |
| 249 | } | 249 | } |
| 250 | ); | 250 | ); |
| 251 | modalInstance.result.then( | 251 | modalInstance.result.then( |
| 252 | function(flete) { | 252 | function(flete) { |
| 253 | $scope.choferes = ''; | 253 | $scope.choferes = ''; |
| 254 | $scope.vehiculos = ''; | 254 | $scope.vehiculos = ''; |
| 255 | $scope.notaPedido.chofer = ''; | 255 | $scope.notaPedido.chofer = ''; |
| 256 | $scope.notaPedido.vehiculo = ''; | 256 | $scope.notaPedido.vehiculo = ''; |
| 257 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 257 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 258 | $scope.notaPedido.fleteNombre = flete.nombre; | 258 | $scope.notaPedido.fleteNombre = flete.nombre; |
| 259 | $scope.notaPedido.fleteId = flete.id; | 259 | $scope.notaPedido.fleteId = flete.id; |
| 260 | $scope.choferes = flete.chofer; | 260 | $scope.choferes = flete.chofer; |
| 261 | $scope.vehiculos = flete.vehiculo; | 261 | $scope.vehiculos = flete.vehiculo; |
| 262 | }, function() { | 262 | }, function() { |
| 263 | 263 | ||
| 264 | } | 264 | } |
| 265 | ); | 265 | ); |
| 266 | } | 266 | } |
| 267 | }; | 267 | }; |
| 268 | $scope.agregarATabla = function(key) { | 268 | $scope.agregarATabla = function(key) { |
| 269 | if(key === 13) { | 269 | if(key === 13) { |
| 270 | if($scope.articuloACargar.cantidad === undefined || | ||
| 271 | $scope.articuloACargar.cantidad === 0 || | ||
| 272 | $scope.articuloACargar.cantidad === null ){ | ||
| 273 | focaModalService.alert('El valor debe ser al menos 1'); | ||
| 274 | return; | ||
| 275 | } | ||
| 270 | $scope.articulosTabla.unshift($scope.articuloACargar); | 276 | $scope.articulosTabla.unshift($scope.articuloACargar); |
| 271 | $scope.cargando = true; | 277 | $scope.cargando = true; |
| 272 | } | 278 | } |
| 273 | }; | 279 | }; |
| 274 | $scope.quitarArticulo = function(key) { | 280 | $scope.quitarArticulo = function(key) { |
| 275 | $scope.articulosTabla.splice(key, 1); | 281 | $scope.articulosTabla.splice(key, 1); |
| 276 | }; | 282 | }; |
| 277 | $scope.editarArticulo = function(key, articulo) { | 283 | $scope.editarArticulo = function(key, articulo) { |
| 278 | if(key === 13) { | 284 | if(key === 13) { |
| 285 | if(articulo.cantidad === null || articulo.cantidad === 0 || | ||
| 286 | articulo.cantidad === undefined){ | ||
| 287 | focaModalService.alert('El valor debe ser al menos 1'); | ||
| 288 | return; | ||
| 289 | } | ||
| 279 | articulo.edit = false; | 290 | articulo.edit = false; |
| 280 | } | 291 | } |
| 281 | }; | 292 | }; |
| 282 | $scope.cambioEdit = function(articulo) { | 293 | $scope.cambioEdit = function(articulo) { |
| 283 | articulo.edit = true; | 294 | articulo.edit = true; |
| 284 | }; | 295 | }; |
| 285 | $scope.limpiarFlete = function() { | 296 | $scope.limpiarFlete = function() { |
| 286 | $scope.notaPedido.fleteNombre = ''; | 297 | $scope.notaPedido.fleteNombre = ''; |
| 287 | $scope.notaPedido.chofer = ''; | 298 | $scope.notaPedido.chofer = ''; |
| 288 | $scope.notaPedido.vehiculo = ''; | 299 | $scope.notaPedido.vehiculo = ''; |
| 289 | $scope.notaPedido.kilometros = ''; | 300 | $scope.notaPedido.kilometros = ''; |
| 290 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 301 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 291 | }; | 302 | }; |
| 292 | $scope.crearPedidoDemo = function() { | 303 | $scope.crearPedidoDemo = function() { |
| 293 | focaModalService.alert('Pedido Creado'); | 304 | focaModalService.alert('Pedido Creado'); |
| 294 | $scope.notaPedido.precioCondicion = ''; | 305 | $scope.notaPedido.precioCondicion = ''; |
| 295 | $scope.articulosTabla = []; | 306 | $scope.articulosTabla = []; |
| 296 | $scope.notaPedido.fleteNombre = ''; | 307 | $scope.notaPedido.fleteNombre = ''; |
| 297 | $scope.notaPedido.chofer = ''; | 308 | $scope.notaPedido.chofer = ''; |
| 298 | $scope.notaPedido.vehiculo = ''; | 309 | $scope.notaPedido.vehiculo = ''; |
| 299 | $scope.notaPedido.kilometros = ''; | 310 | $scope.notaPedido.kilometros = ''; |
| 300 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 311 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 301 | $scope.notaPedido.vendedor.nombre = ''; | 312 | $scope.notaPedido.vendedor.nombre = ''; |
| 302 | $scope.notaPedido.cliente.nombre = ''; | 313 | $scope.notaPedido.cliente.nombre = ''; |
| 303 | $scope.domicilio.dom = ''; | 314 | $scope.domicilio.dom = ''; |
| 304 | $scope.notaPedido.flete = 0; | 315 | $scope.notaPedido.flete = 0; |
| 305 | }; | 316 | }; |
| 306 | $scope.resetFilter = function() { | 317 | $scope.resetFilter = function() { |
| 307 | $scope.articuloACargar = {}; | 318 | $scope.articuloACargar = {}; |
| 308 | $scope.cargando = true; | 319 | $scope.cargando = true; |
| 309 | }; | 320 | }; |
| 310 | } | 321 | } |
| 311 | ] | 322 | ] |
| 312 | ) | 323 | ) |
| 313 | .controller('notaPedidoListaCtrl', [ | 324 | .controller('notaPedidoListaCtrl', [ |
| 314 | '$scope', | 325 | '$scope', |
| 315 | 'crearNotaPedidoService', | 326 | 'crearNotaPedidoService', |
| 316 | '$location', | 327 | '$location', |
| 317 | function($scope, crearNotaPedidoService, $location) { | 328 | function($scope, crearNotaPedidoService, $location) { |
| 318 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 329 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 319 | $scope.notaPedidos = datos.data; | 330 | $scope.notaPedidos = datos.data; |
| 320 | }); | 331 | }); |
| 321 | $scope.editar = function(notaPedido) { | 332 | $scope.editar = function(notaPedido) { |
| 322 | crearNotaPedidoService.setNotaPedido(notaPedido); | 333 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 323 | $location.path('/venta-nota-pedido/abm/'); | 334 | $location.path('/venta-nota-pedido/abm/'); |
| 324 | }; | 335 | }; |
| 325 | $scope.crearPedido = function() { | 336 | $scope.crearPedido = function() { |
| 326 | crearNotaPedidoService.clearNotaPedido(); | 337 | crearNotaPedidoService.clearNotaPedido(); |
| 327 | $location.path('/venta-nota-pedido/abm/'); | 338 | $location.path('/venta-nota-pedido/abm/'); |
| 328 | }; | 339 | }; |
| 329 | } | 340 | } |
| 330 | ]) | 341 | ]) |
| 331 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 342 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 332 | '$scope', | 343 | '$scope', |
| 333 | 'crearNotaPedidoService', | 344 | 'crearNotaPedidoService', |
| 334 | '$location', | 345 | '$location', |
| 335 | function($scope, crearNotaPedidoService, $location) { | 346 | function($scope, crearNotaPedidoService, $location) { |
| 336 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 347 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 337 | $scope.notaPedidos = datos.data; | 348 | $scope.notaPedidos = datos.data; |
| 338 | }); | 349 | }); |
| 339 | $scope.editar = function(notaPedido) { | 350 | $scope.editar = function(notaPedido) { |
| 340 | crearNotaPedidoService.setNotaPedido(notaPedido); | 351 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 341 | $location.path('/venta-nota-pedido/abm/'); | 352 | $location.path('/venta-nota-pedido/abm/'); |
| 342 | }; | 353 | }; |
| 343 | $scope.crearPedido = function() { | 354 | $scope.crearPedido = function() { |
| 344 | crearNotaPedidoService.clearNotaPedido(); | 355 | crearNotaPedidoService.clearNotaPedido(); |
| 345 | $location.path('/venta-nota-pedido/abm/'); | 356 | $location.path('/venta-nota-pedido/abm/'); |
| 346 | }; | 357 | }; |
| 347 | } | 358 | } |
| 348 | ]); | 359 | ]); |
| 349 | 360 |