Commit efb31c9217e763d6234e4f7a5beb3d9277296097
1 parent
fd7e00c8eb
Exists in
master
demo
Showing
1 changed file
with
1 additions
and
1 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 | articulosNotaPedido.edit = undefined; | 89 | articulosNotaPedido[i].edit = undefined; |
| 90 | crearNotaPedidoService | 90 | crearNotaPedidoService |
| 91 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( | 91 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( |
| 92 | function() { | 92 | function() { |
| 93 | return; | 93 | return; |
| 94 | } | 94 | } |
| 95 | ); | 95 | ); |
| 96 | } | 96 | } |
| 97 | $scope.notaPedido.precioCondicion = ''; | 97 | $scope.notaPedido.precioCondicion = ''; |
| 98 | $scope.articulosTabla = []; | 98 | $scope.articulosTabla = []; |
| 99 | $scope.notaPedido.fleteNombre = ''; | 99 | $scope.notaPedido.fleteNombre = ''; |
| 100 | $scope.notaPedido.chofer = ''; | 100 | $scope.notaPedido.chofer = ''; |
| 101 | $scope.notaPedido.vehiculo = ''; | 101 | $scope.notaPedido.vehiculo = ''; |
| 102 | $scope.notaPedido.kilometros = ''; | 102 | $scope.notaPedido.kilometros = ''; |
| 103 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 103 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 104 | $scope.notaPedido.vendedor.nombre = ''; | 104 | $scope.notaPedido.vendedor.nombre = ''; |
| 105 | $scope.notaPedido.cliente.nombre = ''; | 105 | $scope.notaPedido.cliente.nombre = ''; |
| 106 | $scope.domicilio.dom = ''; | 106 | $scope.domicilio.dom = ''; |
| 107 | $scope.notaPedido.flete = 0; | 107 | $scope.notaPedido.flete = 0; |
| 108 | focaModalService.alert('Nota de pedido creada'); | 108 | focaModalService.alert('Nota de pedido creada'); |
| 109 | }; | 109 | }; |
| 110 | $scope.siguienteTab = function() { | 110 | $scope.siguienteTab = function() { |
| 111 | $scope.active = 1; | 111 | $scope.active = 1; |
| 112 | }; | 112 | }; |
| 113 | $scope.seleccionarArticulo = function() { | 113 | $scope.seleccionarArticulo = function() { |
| 114 | if (idLista === undefined) { | 114 | if (idLista === undefined) { |
| 115 | focaModalService.alert( | 115 | focaModalService.alert( |
| 116 | 'primero seleccione una lista de precio y condicion'); | 116 | 'primero seleccione una lista de precio y condicion'); |
| 117 | return; | 117 | return; |
| 118 | } | 118 | } |
| 119 | var modalInstance = $uibModal.open( | 119 | var modalInstance = $uibModal.open( |
| 120 | { | 120 | { |
| 121 | ariaLabelledBy: 'Busqueda de Productos', | 121 | ariaLabelledBy: 'Busqueda de Productos', |
| 122 | templateUrl: 'modal-busqueda-productos.html', | 122 | templateUrl: 'modal-busqueda-productos.html', |
| 123 | controller: 'modalBusquedaProductosCtrl', | 123 | controller: 'modalBusquedaProductosCtrl', |
| 124 | resolve: { idLista: function() { return idLista; } }, | 124 | resolve: { idLista: function() { return idLista; } }, |
| 125 | size: 'lg' | 125 | size: 'lg' |
| 126 | } | 126 | } |
| 127 | ); | 127 | ); |
| 128 | modalInstance.result.then( | 128 | modalInstance.result.then( |
| 129 | function(producto) { | 129 | function(producto) { |
| 130 | var newArt = | 130 | var newArt = |
| 131 | { | 131 | { |
| 132 | id: 0, | 132 | id: 0, |
| 133 | codigo: producto.codigo, | 133 | codigo: producto.codigo, |
| 134 | sector: producto.sector, | 134 | sector: producto.sector, |
| 135 | descripcion: producto.descripcion, | 135 | descripcion: producto.descripcion, |
| 136 | item: $scope.articulosTabla.length + 1, | 136 | item: $scope.articulosTabla.length + 1, |
| 137 | nombre: producto.descripcion, | 137 | nombre: producto.descripcion, |
| 138 | precio: producto.precio.toFixed(2), | 138 | precio: producto.precio.toFixed(2), |
| 139 | costoUnitario: producto.costo, | 139 | costoUnitario: producto.costo, |
| 140 | edit: false | 140 | edit: false |
| 141 | }; | 141 | }; |
| 142 | $scope.articuloACargar = newArt; | 142 | $scope.articuloACargar = newArt; |
| 143 | $scope.cargando = false; | 143 | $scope.cargando = false; |
| 144 | }, function() { | 144 | }, function() { |
| 145 | // funcion ejecutada cuando se cancela el modal | 145 | // funcion ejecutada cuando se cancela el modal |
| 146 | } | 146 | } |
| 147 | ); | 147 | ); |
| 148 | }; | 148 | }; |
| 149 | $scope.seleccionarVendedor = function() { | 149 | $scope.seleccionarVendedor = function() { |
| 150 | var modalInstance = $uibModal.open( | 150 | var modalInstance = $uibModal.open( |
| 151 | { | 151 | { |
| 152 | ariaLabelledBy: 'Busqueda de Vendedores', | 152 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 153 | templateUrl: 'modal-vendedores.html', | 153 | templateUrl: 'modal-vendedores.html', |
| 154 | controller: 'modalVendedoresCtrl', | 154 | controller: 'modalVendedoresCtrl', |
| 155 | size: 'lg' | 155 | size: 'lg' |
| 156 | } | 156 | } |
| 157 | ); | 157 | ); |
| 158 | modalInstance.result.then( | 158 | modalInstance.result.then( |
| 159 | function(vendedor) { | 159 | function(vendedor) { |
| 160 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 160 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
| 161 | }, function() { | 161 | }, function() { |
| 162 | 162 | ||
| 163 | } | 163 | } |
| 164 | ); | 164 | ); |
| 165 | }; | 165 | }; |
| 166 | $scope.seleccionarPetrolera = function() { | 166 | $scope.seleccionarPetrolera = function() { |
| 167 | var modalInstance = $uibModal.open( | 167 | var modalInstance = $uibModal.open( |
| 168 | { | 168 | { |
| 169 | ariaLabelledBy: 'Busqueda de Petrolera', | 169 | ariaLabelledBy: 'Busqueda de Petrolera', |
| 170 | templateUrl: 'modal-petroleras.html', | 170 | templateUrl: 'modal-petroleras.html', |
| 171 | controller: 'modalPetrolerasCtrl', | 171 | controller: 'modalPetrolerasCtrl', |
| 172 | size: 'lg' | 172 | size: 'lg' |
| 173 | } | 173 | } |
| 174 | ); | 174 | ); |
| 175 | modalInstance.result.then( | 175 | modalInstance.result.then( |
| 176 | function(petrolera) { | 176 | function(petrolera) { |
| 177 | $scope.notaPedido.petrolera = petrolera.NOM; | 177 | $scope.notaPedido.petrolera = petrolera.NOM; |
| 178 | }, function() { | 178 | }, function() { |
| 179 | 179 | ||
| 180 | } | 180 | } |
| 181 | ); | 181 | ); |
| 182 | }; | 182 | }; |
| 183 | $scope.seleccionarCliente = function() { | 183 | $scope.seleccionarCliente = function() { |
| 184 | var modalInstance = $uibModal.open( | 184 | var modalInstance = $uibModal.open( |
| 185 | { | 185 | { |
| 186 | ariaLabelledBy: 'Busqueda de Cliente', | 186 | ariaLabelledBy: 'Busqueda de Cliente', |
| 187 | templateUrl: 'foca-busqueda-cliente-modal.html', | 187 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 188 | controller: 'focaBusquedaClienteModalController', | 188 | controller: 'focaBusquedaClienteModalController', |
| 189 | size: 'lg' | 189 | size: 'lg' |
| 190 | } | 190 | } |
| 191 | ); | 191 | ); |
| 192 | modalInstance.result.then( | 192 | modalInstance.result.then( |
| 193 | function(cliente) { | 193 | function(cliente) { |
| 194 | $scope.notaPedido.cliente.nombre = cliente.nom; | 194 | $scope.notaPedido.cliente.nombre = cliente.nom; |
| 195 | }, function() { | 195 | }, function() { |
| 196 | 196 | ||
| 197 | } | 197 | } |
| 198 | ); | 198 | ); |
| 199 | }; | 199 | }; |
| 200 | $scope.mostrarFichaCliente = function() { | 200 | $scope.mostrarFichaCliente = function() { |
| 201 | $uibModal.open( | 201 | $uibModal.open( |
| 202 | { | 202 | { |
| 203 | ariaLabelledBy: 'Datos del Cliente', | 203 | ariaLabelledBy: 'Datos del Cliente', |
| 204 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 204 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 205 | controller: 'focaCrearNotaPedidoFichaClienteController', | 205 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 206 | size: 'lg' | 206 | size: 'lg' |
| 207 | } | 207 | } |
| 208 | ); | 208 | ); |
| 209 | }; | 209 | }; |
| 210 | $scope.obtenerDomicilios = function(id) { | 210 | $scope.obtenerDomicilios = function(id) { |
| 211 | crearNotaPedidoService.getDomicilios(id).then( | 211 | crearNotaPedidoService.getDomicilios(id).then( |
| 212 | function(res) { | 212 | function(res) { |
| 213 | $scope.notaPedido.domicilio = res.data; | 213 | $scope.notaPedido.domicilio = res.data; |
| 214 | } | 214 | } |
| 215 | ); | 215 | ); |
| 216 | }; | 216 | }; |
| 217 | $scope.getTotal = function() { | 217 | $scope.getTotal = function() { |
| 218 | var total = 0; | 218 | var total = 0; |
| 219 | var array = $scope.articulosTabla; | 219 | var array = $scope.articulosTabla; |
| 220 | for (var i = 0; i < array.length; i++) { | 220 | for (var i = 0; i < array.length; i++) { |
| 221 | total += array[i].precio * array[i].cantidad; | 221 | total += array[i].precio * array[i].cantidad; |
| 222 | } | 222 | } |
| 223 | return total.toFixed(2); | 223 | return total.toFixed(2); |
| 224 | }; | 224 | }; |
| 225 | $scope.getSubTotal = function() { | 225 | $scope.getSubTotal = function() { |
| 226 | if($scope.articuloACargar) { | 226 | if($scope.articuloACargar) { |
| 227 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 227 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 228 | } | 228 | } |
| 229 | }; | 229 | }; |
| 230 | $scope.cargarArticulos = function() { | 230 | $scope.cargarArticulos = function() { |
| 231 | idLista = $scope.notaPedido.precioCondicion; | 231 | idLista = $scope.notaPedido.precioCondicion; |
| 232 | $scope.articulosTabla = []; | 232 | $scope.articulosTabla = []; |
| 233 | }; | 233 | }; |
| 234 | $scope.abrirModalListaPrecio = function() { | 234 | $scope.abrirModalListaPrecio = function() { |
| 235 | var modalInstance = $uibModal.open( | 235 | var modalInstance = $uibModal.open( |
| 236 | { | 236 | { |
| 237 | ariaLabelledBy: 'Busqueda de Precio Condición', | 237 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 238 | templateUrl: 'modal-precio-condicion.html', | 238 | templateUrl: 'modal-precio-condicion.html', |
| 239 | controller: 'focaModalPrecioCondicionController', | 239 | controller: 'focaModalPrecioCondicionController', |
| 240 | size: 'lg' | 240 | size: 'lg' |
| 241 | } | 241 | } |
| 242 | ); | 242 | ); |
| 243 | modalInstance.result.then( | 243 | modalInstance.result.then( |
| 244 | function(precioCondicion) { | 244 | function(precioCondicion) { |
| 245 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 245 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
| 246 | idLista = precioCondicion.idListaPrecio; | 246 | idLista = precioCondicion.idListaPrecio; |
| 247 | $scope.articulosTabla = []; | 247 | $scope.articulosTabla = []; |
| 248 | }, function() { | 248 | }, function() { |
| 249 | 249 | ||
| 250 | } | 250 | } |
| 251 | ); | 251 | ); |
| 252 | }; | 252 | }; |
| 253 | $scope.abrirModalFlete = function() { | 253 | $scope.abrirModalFlete = function() { |
| 254 | if($scope.notaPedido.flete === '1') { | 254 | if($scope.notaPedido.flete === '1') { |
| 255 | var modalInstance = $uibModal.open( | 255 | var modalInstance = $uibModal.open( |
| 256 | { | 256 | { |
| 257 | ariaLabelledBy: 'Busqueda de Flete', | 257 | ariaLabelledBy: 'Busqueda de Flete', |
| 258 | templateUrl: 'modal-flete.html', | 258 | templateUrl: 'modal-flete.html', |
| 259 | controller: 'focaModalFleteController', | 259 | controller: 'focaModalFleteController', |
| 260 | size: 'lg' | 260 | size: 'lg' |
| 261 | } | 261 | } |
| 262 | ); | 262 | ); |
| 263 | modalInstance.result.then( | 263 | modalInstance.result.then( |
| 264 | function(flete) { | 264 | function(flete) { |
| 265 | $scope.choferes = ''; | 265 | $scope.choferes = ''; |
| 266 | $scope.vehiculos = ''; | 266 | $scope.vehiculos = ''; |
| 267 | $scope.notaPedido.chofer = ''; | 267 | $scope.notaPedido.chofer = ''; |
| 268 | $scope.notaPedido.vehiculo = ''; | 268 | $scope.notaPedido.vehiculo = ''; |
| 269 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 269 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 270 | $scope.notaPedido.fleteNombre = flete.nombre; | 270 | $scope.notaPedido.fleteNombre = flete.nombre; |
| 271 | $scope.notaPedido.fleteId = flete.id; | 271 | $scope.notaPedido.fleteId = flete.id; |
| 272 | $scope.choferes = flete.chofer; | 272 | $scope.choferes = flete.chofer; |
| 273 | $scope.vehiculos = flete.vehiculo; | 273 | $scope.vehiculos = flete.vehiculo; |
| 274 | }, function() { | 274 | }, function() { |
| 275 | 275 | ||
| 276 | } | 276 | } |
| 277 | ); | 277 | ); |
| 278 | } | 278 | } |
| 279 | }; | 279 | }; |
| 280 | $scope.agregarATabla = function(key) { | 280 | $scope.agregarATabla = function(key) { |
| 281 | if(key === 13) { | 281 | if(key === 13) { |
| 282 | if($scope.articuloACargar.cantidad === undefined || | 282 | if($scope.articuloACargar.cantidad === undefined || |
| 283 | $scope.articuloACargar.cantidad === 0 || | 283 | $scope.articuloACargar.cantidad === 0 || |
| 284 | $scope.articuloACargar.cantidad === null ){ | 284 | $scope.articuloACargar.cantidad === null ){ |
| 285 | focaModalService.alert('El valor debe ser al menos 1'); | 285 | focaModalService.alert('El valor debe ser al menos 1'); |
| 286 | return; | 286 | return; |
| 287 | } | 287 | } |
| 288 | $scope.articulosTabla.unshift($scope.articuloACargar); | 288 | $scope.articulosTabla.unshift($scope.articuloACargar); |
| 289 | $scope.cargando = true; | 289 | $scope.cargando = true; |
| 290 | } | 290 | } |
| 291 | }; | 291 | }; |
| 292 | $scope.quitarArticulo = function(key) { | 292 | $scope.quitarArticulo = function(key) { |
| 293 | $scope.articulosTabla.splice(key, 1); | 293 | $scope.articulosTabla.splice(key, 1); |
| 294 | }; | 294 | }; |
| 295 | $scope.editarArticulo = function(key, articulo) { | 295 | $scope.editarArticulo = function(key, articulo) { |
| 296 | if(key === 13) { | 296 | if(key === 13) { |
| 297 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 297 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 298 | articulo.cantidad === undefined){ | 298 | articulo.cantidad === undefined){ |
| 299 | focaModalService.alert('El valor debe ser al menos 1'); | 299 | focaModalService.alert('El valor debe ser al menos 1'); |
| 300 | return; | 300 | return; |
| 301 | } | 301 | } |
| 302 | articulo.edit = false; | 302 | articulo.edit = false; |
| 303 | } | 303 | } |
| 304 | }; | 304 | }; |
| 305 | $scope.cambioEdit = function(articulo) { | 305 | $scope.cambioEdit = function(articulo) { |
| 306 | articulo.edit = true; | 306 | articulo.edit = true; |
| 307 | }; | 307 | }; |
| 308 | $scope.limpiarFlete = function() { | 308 | $scope.limpiarFlete = function() { |
| 309 | $scope.notaPedido.fleteNombre = ''; | 309 | $scope.notaPedido.fleteNombre = ''; |
| 310 | $scope.notaPedido.chofer = ''; | 310 | $scope.notaPedido.chofer = ''; |
| 311 | $scope.notaPedido.vehiculo = ''; | 311 | $scope.notaPedido.vehiculo = ''; |
| 312 | $scope.notaPedido.kilometros = ''; | 312 | $scope.notaPedido.kilometros = ''; |
| 313 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 313 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 314 | }; | 314 | }; |
| 315 | $scope.crearPedidoDemo = function() { | 315 | $scope.crearPedidoDemo = function() { |
| 316 | focaModalService.alert('Pedido Creado'); | 316 | focaModalService.alert('Pedido Creado'); |
| 317 | $scope.notaPedido.precioCondicion = ''; | 317 | $scope.notaPedido.precioCondicion = ''; |
| 318 | $scope.articulosTabla = []; | 318 | $scope.articulosTabla = []; |
| 319 | $scope.notaPedido.fleteNombre = ''; | 319 | $scope.notaPedido.fleteNombre = ''; |
| 320 | $scope.notaPedido.chofer = ''; | 320 | $scope.notaPedido.chofer = ''; |
| 321 | $scope.notaPedido.vehiculo = ''; | 321 | $scope.notaPedido.vehiculo = ''; |
| 322 | $scope.notaPedido.kilometros = ''; | 322 | $scope.notaPedido.kilometros = ''; |
| 323 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 323 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 324 | $scope.notaPedido.vendedor.nombre = ''; | 324 | $scope.notaPedido.vendedor.nombre = ''; |
| 325 | $scope.notaPedido.cliente.nombre = ''; | 325 | $scope.notaPedido.cliente.nombre = ''; |
| 326 | $scope.domicilio.dom = ''; | 326 | $scope.domicilio.dom = ''; |
| 327 | $scope.notaPedido.flete = 0; | 327 | $scope.notaPedido.flete = 0; |
| 328 | }; | 328 | }; |
| 329 | $scope.resetFilter = function() { | 329 | $scope.resetFilter = function() { |
| 330 | $scope.articuloACargar = {}; | 330 | $scope.articuloACargar = {}; |
| 331 | $scope.cargando = true; | 331 | $scope.cargando = true; |
| 332 | }; | 332 | }; |
| 333 | } | 333 | } |
| 334 | ] | 334 | ] |
| 335 | ) | 335 | ) |
| 336 | .controller('notaPedidoListaCtrl', [ | 336 | .controller('notaPedidoListaCtrl', [ |
| 337 | '$scope', | 337 | '$scope', |
| 338 | 'crearNotaPedidoService', | 338 | 'crearNotaPedidoService', |
| 339 | '$location', | 339 | '$location', |
| 340 | function($scope, crearNotaPedidoService, $location) { | 340 | function($scope, crearNotaPedidoService, $location) { |
| 341 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 341 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 342 | $scope.notaPedidos = datos.data; | 342 | $scope.notaPedidos = datos.data; |
| 343 | }); | 343 | }); |
| 344 | $scope.editar = function(notaPedido) { | 344 | $scope.editar = function(notaPedido) { |
| 345 | crearNotaPedidoService.setNotaPedido(notaPedido); | 345 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 346 | $location.path('/venta-nota-pedido/abm/'); | 346 | $location.path('/venta-nota-pedido/abm/'); |
| 347 | }; | 347 | }; |
| 348 | $scope.crearPedido = function() { | 348 | $scope.crearPedido = function() { |
| 349 | crearNotaPedidoService.clearNotaPedido(); | 349 | crearNotaPedidoService.clearNotaPedido(); |
| 350 | $location.path('/venta-nota-pedido/abm/'); | 350 | $location.path('/venta-nota-pedido/abm/'); |
| 351 | }; | 351 | }; |
| 352 | } | 352 | } |
| 353 | ]) | 353 | ]) |
| 354 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 354 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 355 | '$scope', | 355 | '$scope', |
| 356 | 'crearNotaPedidoService', | 356 | 'crearNotaPedidoService', |
| 357 | '$location', | 357 | '$location', |
| 358 | function($scope, crearNotaPedidoService, $location) { | 358 | function($scope, crearNotaPedidoService, $location) { |
| 359 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 359 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 360 | $scope.notaPedidos = datos.data; | 360 | $scope.notaPedidos = datos.data; |
| 361 | }); | 361 | }); |
| 362 | $scope.editar = function(notaPedido) { | 362 | $scope.editar = function(notaPedido) { |
| 363 | crearNotaPedidoService.setNotaPedido(notaPedido); | 363 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 364 | $location.path('/venta-nota-pedido/abm/'); | 364 | $location.path('/venta-nota-pedido/abm/'); |
| 365 | }; | 365 | }; |
| 366 | $scope.crearPedido = function() { | 366 | $scope.crearPedido = function() { |
| 367 | crearNotaPedidoService.clearNotaPedido(); | 367 | crearNotaPedidoService.clearNotaPedido(); |
| 368 | $location.path('/venta-nota-pedido/abm/'); | 368 | $location.path('/venta-nota-pedido/abm/'); |
| 369 | }; | 369 | }; |
| 370 | } | 370 | } |
| 371 | ]); | 371 | ]); |
| 372 | 372 |