Commit bd9543280c48e1eb84d1eb1964040cbb6a76dabc
1 parent
82e7210ad8
Exists in
master
and in
1 other branch
Implementación agregar domicilio
Showing
1 changed file
with
1 additions
and
15 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', 'focaSeguimientoService', 'notaPedidoBusinessService', | 4 | 'focaModalService', 'focaSeguimientoService', 'notaPedidoBusinessService', |
| 5 | function( | 5 | function( |
| 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, |
| 7 | focaSeguimientoService, notaPedidoBusinessService | 7 | focaSeguimientoService, notaPedidoBusinessService |
| 8 | ) { | 8 | ) { |
| 9 | $scope.botonera = [ | 9 | $scope.botonera = [ |
| 10 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 10 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
| 11 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 11 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
| 12 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 12 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
| 13 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 13 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
| 14 | { | 14 | { |
| 15 | texto: 'Precios y condiciones', | 15 | texto: 'Precios y condiciones', |
| 16 | accion: function() {$scope.abrirModalListaPrecio();}}, | 16 | accion: function() {$scope.abrirModalListaPrecio();}}, |
| 17 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 17 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
| 18 | {texto: '', accion: function() {}}, | 18 | {texto: '', accion: function() {}}, |
| 19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
| 20 | ]; | 20 | ]; |
| 21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
| 22 | 22 | ||
| 23 | $scope.show = false; | 23 | $scope.show = false; |
| 24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
| 25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
| 26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
| 27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | $scope.notaPedido = { | 30 | $scope.notaPedido = { |
| 31 | vendedor: {}, | 31 | vendedor: {}, |
| 32 | cliente: {}, | 32 | cliente: {}, |
| 33 | proveedor: {}, | 33 | proveedor: {}, |
| 34 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
| 35 | moneda: {}, | 35 | moneda: {}, |
| 36 | cotizacion: {} | 36 | cotizacion: {} |
| 37 | }; | 37 | }; |
| 38 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
| 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 40 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
| 41 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
| 42 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
| 43 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
| 44 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
| 45 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
| 46 | }; | 46 | }; |
| 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
| 48 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
| 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
| 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
| 51 | $scope.notaPedido.moneda = monedaPorDefecto; | 51 | $scope.notaPedido.moneda = monedaPorDefecto; |
| 52 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
| 53 | }); | 53 | }); |
| 54 | 54 | ||
| 55 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
| 56 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
| 57 | 57 | ||
| 58 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
| 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
| 60 | $scope.comprobante = Math.round(Math.random() * 1000000); | 60 | $scope.comprobante = Math.round(Math.random() * 1000000); |
| 61 | 61 | ||
| 62 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
| 63 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
| 64 | //La pantalla solo se usa para cargar pedidos | 64 | //La pantalla solo se usa para cargar pedidos |
| 65 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 65 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 66 | 66 | ||
| 67 | crearNotaPedidoService.getPrecioCondicion().then( | 67 | crearNotaPedidoService.getPrecioCondicion().then( |
| 68 | function(res) { | 68 | function(res) { |
| 69 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
| 70 | } | 70 | } |
| 71 | ); | 71 | ); |
| 72 | //La pantalla solo se usa para cargar pedidos | 72 | //La pantalla solo se usa para cargar pedidos |
| 73 | // if (notaPedidoTemp !== undefined) { | 73 | // if (notaPedidoTemp !== undefined) { |
| 74 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 74 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 75 | // $scope.notaPedido = notaPedidoTemp; | 75 | // $scope.notaPedido = notaPedidoTemp; |
| 76 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 76 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 77 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 77 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 78 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 78 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
| 79 | // crearNotaPedidoService | 79 | // crearNotaPedidoService |
| 80 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 80 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 81 | // function(res) { | 81 | // function(res) { |
| 82 | // $scope.articulosTabla = res.data; | 82 | // $scope.articulosTabla = res.data; |
| 83 | // } | 83 | // } |
| 84 | // ); | 84 | // ); |
| 85 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 85 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 86 | //(NO REQUERIDO EN ESTA VERSION) | 86 | //(NO REQUERIDO EN ESTA VERSION) |
| 87 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 87 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 88 | // function(res) { | 88 | // function(res) { |
| 89 | // $scope.notaPedido.domicilio = res.data; | 89 | // $scope.notaPedido.domicilio = res.data; |
| 90 | // } | 90 | // } |
| 91 | // ); | 91 | // ); |
| 92 | // } else { | 92 | // } else { |
| 93 | // $scope.notaPedido.fechaCarga = new Date(); | 93 | // $scope.notaPedido.fechaCarga = new Date(); |
| 94 | // $scope.notaPedido.bomba = '0'; | 94 | // $scope.notaPedido.bomba = '0'; |
| 95 | // $scope.notaPedido.flete = '0'; | 95 | // $scope.notaPedido.flete = '0'; |
| 96 | // $scope.idLista = undefined; | 96 | // $scope.idLista = undefined; |
| 97 | // } | 97 | // } |
| 98 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 98 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 99 | // $scope.addNewDom = function() { | 99 | // $scope.addNewDom = function() { |
| 100 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 100 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 101 | // }; | 101 | // }; |
| 102 | // $scope.removeNewChoice = function(choice) { | 102 | // $scope.removeNewChoice = function(choice) { |
| 103 | // if ($scope.notaPedido.domicilio.length > 1) { | 103 | // if ($scope.notaPedido.domicilio.length > 1) { |
| 104 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 104 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 105 | // function(c) { | 105 | // function(c) { |
| 106 | // return c.$$hashKey === choice.$$hashKey; | 106 | // return c.$$hashKey === choice.$$hashKey; |
| 107 | // } | 107 | // } |
| 108 | // ), 1); | 108 | // ), 1); |
| 109 | // } | 109 | // } |
| 110 | // }; | 110 | // }; |
| 111 | 111 | ||
| 112 | $scope.crearNotaPedido = function() { | 112 | $scope.crearNotaPedido = function() { |
| 113 | if(!$scope.notaPedido.vendedor.codigo) { | 113 | if(!$scope.notaPedido.vendedor.codigo) { |
| 114 | focaModalService.alert('Ingrese Vendedor'); | 114 | focaModalService.alert('Ingrese Vendedor'); |
| 115 | return; | 115 | return; |
| 116 | } else if(!$scope.notaPedido.cliente.cod) { | 116 | } else if(!$scope.notaPedido.cliente.cod) { |
| 117 | focaModalService.alert('Ingrese Cliente'); | 117 | focaModalService.alert('Ingrese Cliente'); |
| 118 | return; | 118 | return; |
| 119 | } else if(!$scope.notaPedido.proveedor.codigo) { | 119 | } else if(!$scope.notaPedido.proveedor.codigo) { |
| 120 | focaModalService.alert('Ingrese Proveedor'); | 120 | focaModalService.alert('Ingrese Proveedor'); |
| 121 | return; | 121 | return; |
| 122 | } else if(!$scope.notaPedido.moneda.id) { | 122 | } else if(!$scope.notaPedido.moneda.id) { |
| 123 | focaModalService.alert('Ingrese Moneda'); | 123 | focaModalService.alert('Ingrese Moneda'); |
| 124 | return; | 124 | return; |
| 125 | } else if(!$scope.notaPedido.cotizacion.ID) { | 125 | } else if(!$scope.notaPedido.cotizacion.ID) { |
| 126 | focaModalService.alert('Ingrese Cotización'); | 126 | focaModalService.alert('Ingrese Cotización'); |
| 127 | return; | 127 | return; |
| 128 | } else if(!$scope.plazosPagos) { | 128 | } else if(!$scope.plazosPagos) { |
| 129 | focaModalService.alert('Ingrese Precios y Condiciones'); | 129 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 130 | return; | 130 | return; |
| 131 | } else if( | 131 | } else if( |
| 132 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 132 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
| 133 | { | 133 | { |
| 134 | focaModalService.alert('Ingrese Flete'); | 134 | focaModalService.alert('Ingrese Flete'); |
| 135 | return; | 135 | return; |
| 136 | } else if(!$scope.notaPedido.domicilio.id) { | 136 | } else if(!$scope.notaPedido.domicilio.id) { |
| 137 | focaModalService.aler('Ingrese Domicilio'); | 137 | focaModalService.aler('Ingrese Domicilio'); |
| 138 | return; | 138 | return; |
| 139 | } else if($scope.articulosTabla.length === 0) { | 139 | } else if($scope.articulosTabla.length === 0) { |
| 140 | focaModalService.alert('Debe cargar al menos un articulo'); | 140 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 141 | return; | 141 | return; |
| 142 | } | 142 | } |
| 143 | var date = new Date(); | 143 | var date = new Date(); |
| 144 | var notaPedido = { | 144 | var notaPedido = { |
| 145 | id: 0, | 145 | id: 0, |
| 146 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 146 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 147 | .toISOString().slice(0, 19).replace('T', ' '), | 147 | .toISOString().slice(0, 19).replace('T', ' '), |
| 148 | idVendedor: $scope.notaPedido.vendedor.codigo, | 148 | idVendedor: $scope.notaPedido.vendedor.codigo, |
| 149 | idCliente: $scope.notaPedido.cliente.cod, | 149 | idCliente: $scope.notaPedido.cliente.cod, |
| 150 | nombreCliente: $scope.notaPedido.cliente.nom, | 150 | nombreCliente: $scope.notaPedido.cliente.nom, |
| 151 | cuitCliente: $scope.notaPedido.cliente.cuit, | 151 | cuitCliente: $scope.notaPedido.cliente.cuit, |
| 152 | idProveedor: $scope.notaPedido.proveedor.codigo, | 152 | idProveedor: $scope.notaPedido.proveedor.codigo, |
| 153 | idDomicilio: $scope.notaPedido.domicilio.id, | 153 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 154 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 154 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 155 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, | 155 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, |
| 156 | flete: $scope.notaPedido.flete, | 156 | flete: $scope.notaPedido.flete, |
| 157 | fob: $scope.notaPedido.fob, | 157 | fob: $scope.notaPedido.fob, |
| 158 | bomba: $scope.notaPedido.bomba, | 158 | bomba: $scope.notaPedido.bomba, |
| 159 | kilometros: $scope.notaPedido.kilometros, | 159 | kilometros: $scope.notaPedido.kilometros, |
| 160 | estado: 0, | 160 | estado: 0, |
| 161 | total: $scope.getTotal() | 161 | total: $scope.getTotal() |
| 162 | }; | 162 | }; |
| 163 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 163 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 164 | function(data) { | 164 | function(data) { |
| 165 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 165 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
| 166 | data.data.id, $scope.notaPedido.cotizacion.COTIZACION); | 166 | data.data.id, $scope.notaPedido.cotizacion.COTIZACION); |
| 167 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); | 167 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); |
| 168 | var plazos = $scope.plazosPagos; | 168 | var plazos = $scope.plazosPagos; |
| 169 | for(var j = 0; j < plazos.length; j++) { | 169 | for(var j = 0; j < plazos.length; j++) { |
| 170 | var json = { | 170 | var json = { |
| 171 | idPedido: data.data.id, | 171 | idPedido: data.data.id, |
| 172 | dias: plazos[j].dias | 172 | dias: plazos[j].dias |
| 173 | }; | 173 | }; |
| 174 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 174 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
| 175 | } | 175 | } |
| 176 | notaPedidoBusinessService.addEstado(data.data.id, | 176 | notaPedidoBusinessService.addEstado(data.data.id, |
| 177 | $scope.notaPedido.vendedor.codigo); | 177 | $scope.notaPedido.vendedor.codigo); |
| 178 | 178 | ||
| 179 | focaModalService.alert('Nota pedido creada'); | 179 | focaModalService.alert('Nota pedido creada'); |
| 180 | $scope.cabecera = []; | 180 | $scope.cabecera = []; |
| 181 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 181 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
| 182 | addCabecera( | 182 | addCabecera( |
| 183 | 'Fecha cotizacion:', | 183 | 'Fecha cotizacion:', |
| 184 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 184 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
| 185 | ); | 185 | ); |
| 186 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); | 186 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); |
| 187 | $scope.notaPedido.vendedor = {}; | 187 | $scope.notaPedido.vendedor = {}; |
| 188 | $scope.notaPedido.cliente = {}; | 188 | $scope.notaPedido.cliente = {}; |
| 189 | $scope.notaPedido.proveedor = {}; | 189 | $scope.notaPedido.proveedor = {}; |
| 190 | $scope.notaPedido.domicilio = {}; | 190 | $scope.notaPedido.domicilio = {}; |
| 191 | $scope.notaPedido.flete = null; | 191 | $scope.notaPedido.flete = null; |
| 192 | $scope.notaPedido.fob = null; | 192 | $scope.notaPedido.fob = null; |
| 193 | $scope.notaPedido.bomba = null; | 193 | $scope.notaPedido.bomba = null; |
| 194 | $scope.notaPedido.kilometros = null; | 194 | $scope.notaPedido.kilometros = null; |
| 195 | $scope.articulosTabla = []; | 195 | $scope.articulosTabla = []; |
| 196 | } | 196 | } |
| 197 | ); | 197 | ); |
| 198 | }; | 198 | }; |
| 199 | 199 | ||
| 200 | $scope.seleccionarArticulo = function() { | 200 | $scope.seleccionarArticulo = function() { |
| 201 | if ($scope.idLista === undefined) { | 201 | if ($scope.idLista === undefined) { |
| 202 | focaModalService.alert( | 202 | focaModalService.alert( |
| 203 | 'Primero seleccione una lista de precio y condicion'); | 203 | 'Primero seleccione una lista de precio y condicion'); |
| 204 | return; | 204 | return; |
| 205 | } | 205 | } |
| 206 | var modalInstance = $uibModal.open( | 206 | var modalInstance = $uibModal.open( |
| 207 | { | 207 | { |
| 208 | ariaLabelledBy: 'Busqueda de Productos', | 208 | ariaLabelledBy: 'Busqueda de Productos', |
| 209 | templateUrl: 'modal-busqueda-productos.html', | 209 | templateUrl: 'modal-busqueda-productos.html', |
| 210 | controller: 'modalBusquedaProductosCtrl', | 210 | controller: 'modalBusquedaProductosCtrl', |
| 211 | resolve: { | 211 | resolve: { |
| 212 | parametroProducto: { | 212 | parametroProducto: { |
| 213 | idLista: $scope.idLista, | 213 | idLista: $scope.idLista, |
| 214 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, | 214 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, |
| 215 | simbolo: $scope.notaPedido.moneda.simbolo | 215 | simbolo: $scope.notaPedido.moneda.simbolo |
| 216 | } | 216 | } |
| 217 | }, | 217 | }, |
| 218 | size: 'lg' | 218 | size: 'lg' |
| 219 | } | 219 | } |
| 220 | ); | 220 | ); |
| 221 | modalInstance.result.then( | 221 | modalInstance.result.then( |
| 222 | function(producto) { | 222 | function(producto) { |
| 223 | var newArt = | 223 | var newArt = |
| 224 | { | 224 | { |
| 225 | id: 0, | 225 | id: 0, |
| 226 | codigo: producto.codigo, | 226 | codigo: producto.codigo, |
| 227 | sector: producto.sector, | 227 | sector: producto.sector, |
| 228 | sectorCodigo: producto.sector + '-' + producto.codigo, | 228 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 229 | descripcion: producto.descripcion, | 229 | descripcion: producto.descripcion, |
| 230 | item: $scope.articulosTabla.length + 1, | 230 | item: $scope.articulosTabla.length + 1, |
| 231 | nombre: producto.descripcion, | 231 | nombre: producto.descripcion, |
| 232 | precio: parseFloat(producto.precio.toFixed(4)), | 232 | precio: parseFloat(producto.precio.toFixed(4)), |
| 233 | costoUnitario: producto.costo, | 233 | costoUnitario: producto.costo, |
| 234 | editCantidad: false, | 234 | editCantidad: false, |
| 235 | editPrecio: false | 235 | editPrecio: false |
| 236 | }; | 236 | }; |
| 237 | $scope.articuloACargar = newArt; | 237 | $scope.articuloACargar = newArt; |
| 238 | $scope.cargando = false; | 238 | $scope.cargando = false; |
| 239 | }, function() { | 239 | }, function() { |
| 240 | // funcion ejecutada cuando se cancela el modal | 240 | // funcion ejecutada cuando se cancela el modal |
| 241 | } | 241 | } |
| 242 | ); | 242 | ); |
| 243 | }; | 243 | }; |
| 244 | 244 | ||
| 245 | $scope.seleccionarVendedor = function() { | 245 | $scope.seleccionarVendedor = function() { |
| 246 | var modalInstance = $uibModal.open( | 246 | var modalInstance = $uibModal.open( |
| 247 | { | 247 | { |
| 248 | ariaLabelledBy: 'Busqueda de Vendedores', | 248 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 249 | templateUrl: 'modal-vendedores.html', | 249 | templateUrl: 'modal-vendedores.html', |
| 250 | controller: 'modalVendedoresCtrl', | 250 | controller: 'modalVendedoresCtrl', |
| 251 | size: 'lg' | 251 | size: 'lg' |
| 252 | } | 252 | } |
| 253 | ); | 253 | ); |
| 254 | modalInstance.result.then( | 254 | modalInstance.result.then( |
| 255 | function(vendedor) { | 255 | function(vendedor) { |
| 256 | addCabecera('Vendedor:', vendedor.NomVen); | 256 | addCabecera('Vendedor:', vendedor.NomVen); |
| 257 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 257 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
| 258 | }, function() { | 258 | }, function() { |
| 259 | 259 | ||
| 260 | } | 260 | } |
| 261 | ); | 261 | ); |
| 262 | }; | 262 | }; |
| 263 | 263 | ||
| 264 | $scope.seleccionarProveedor = function() { | 264 | $scope.seleccionarProveedor = function() { |
| 265 | var modalInstance = $uibModal.open( | 265 | var modalInstance = $uibModal.open( |
| 266 | { | 266 | { |
| 267 | ariaLabelledBy: 'Busqueda de Proveedor', | 267 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 268 | templateUrl: 'modal-proveedor.html', | 268 | templateUrl: 'modal-proveedor.html', |
| 269 | controller: 'focaModalProveedorCtrl', | 269 | controller: 'focaModalProveedorCtrl', |
| 270 | size: 'lg' | 270 | size: 'lg' |
| 271 | } | 271 | } |
| 272 | ); | 272 | ); |
| 273 | modalInstance.result.then( | 273 | modalInstance.result.then( |
| 274 | function(proveedor) { | 274 | function(proveedor) { |
| 275 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 275 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
| 276 | addCabecera('Proveedor:', proveedor.NOM); | 276 | addCabecera('Proveedor:', proveedor.NOM); |
| 277 | }, function() { | 277 | }, function() { |
| 278 | 278 | ||
| 279 | } | 279 | } |
| 280 | ); | 280 | ); |
| 281 | }; | 281 | }; |
| 282 | 282 | ||
| 283 | $scope.seleccionarCliente = function() { | 283 | $scope.seleccionarCliente = function() { |
| 284 | 284 | ||
| 285 | var modalInstance = $uibModal.open( | 285 | var modalInstance = $uibModal.open( |
| 286 | { | 286 | { |
| 287 | ariaLabelledBy: 'Busqueda de Cliente', | 287 | ariaLabelledBy: 'Busqueda de Cliente', |
| 288 | templateUrl: 'foca-busqueda-cliente-modal.html', | 288 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 289 | controller: 'focaBusquedaClienteModalController', | 289 | controller: 'focaBusquedaClienteModalController', |
| 290 | size: 'lg' | 290 | size: 'lg' |
| 291 | } | 291 | } |
| 292 | ); | 292 | ); |
| 293 | modalInstance.result.then( | 293 | modalInstance.result.then( |
| 294 | function(cliente) { | 294 | function(cliente) { |
| 295 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 295 | $scope.abrirModalDomicilios(cliente); |
| 296 | function(data) { | ||
| 297 | if(data.data.length === 0){ | ||
| 298 | focaModalService | ||
| 299 | .alert('El cliente no tienen domicilios de entrega') | ||
| 300 | .then( | ||
| 301 | function() { | ||
| 302 | $scope.seleccionarCliente(); | ||
| 303 | } | ||
| 304 | ); | ||
| 305 | return; | ||
| 306 | } | ||
| 307 | $scope.abrirModalDomicilios(cliente); | ||
| 308 | } | ||
| 309 | ); | ||
| 310 | }, function() { | 296 | }, function() { |
| 311 | 297 | ||
| 312 | } | 298 | } |
| 313 | ); | 299 | ); |
| 314 | }; | 300 | }; |
| 315 | 301 | ||
| 316 | $scope.abrirModalDomicilios = function(cliente) { | 302 | $scope.abrirModalDomicilios = function(cliente) { |
| 317 | var modalInstanceDomicilio = $uibModal.open( | 303 | var modalInstanceDomicilio = $uibModal.open( |
| 318 | { | 304 | { |
| 319 | ariaLabelledBy: 'Busqueda de Domicilios', | 305 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 320 | templateUrl: 'modal-domicilio.html', | 306 | templateUrl: 'modal-domicilio.html', |
| 321 | controller: 'focaModalDomicilioController', | 307 | controller: 'focaModalDomicilioController', |
| 322 | resolve: { idCliente: function() { return cliente.cod; }}, | 308 | resolve: { idCliente: function() { return cliente.cod; }}, |
| 323 | size: 'lg', | 309 | size: 'lg', |
| 324 | } | 310 | } |
| 325 | ); | 311 | ); |
| 326 | modalInstanceDomicilio.result.then( | 312 | modalInstanceDomicilio.result.then( |
| 327 | function(domicilio) { | 313 | function(domicilio) { |
| 328 | $scope.notaPedido.domicilio.id = domicilio.id; | 314 | $scope.notaPedido.domicilio.id = domicilio.id; |
| 329 | $scope.notaPedido.cliente = cliente; | 315 | $scope.notaPedido.cliente = cliente; |
| 330 | 316 | ||
| 331 | addCabecera('Cliente:', cliente.nom); | 317 | addCabecera('Cliente:', cliente.nom); |
| 332 | addCabecera('Domicilio:', domicilio.dom); | 318 | addCabecera('Domicilio:', domicilio.dom); |
| 333 | }, function() { | 319 | }, function() { |
| 334 | $scope.seleccionarCliente(); | 320 | $scope.seleccionarCliente(); |
| 335 | return; | 321 | return; |
| 336 | } | 322 | } |
| 337 | ); | 323 | ); |
| 338 | }; | 324 | }; |
| 339 | 325 | ||
| 340 | $scope.mostrarFichaCliente = function() { | 326 | $scope.mostrarFichaCliente = function() { |
| 341 | $uibModal.open( | 327 | $uibModal.open( |
| 342 | { | 328 | { |
| 343 | ariaLabelledBy: 'Datos del Cliente', | 329 | ariaLabelledBy: 'Datos del Cliente', |
| 344 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 330 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 345 | controller: 'focaCrearNotaPedidoFichaClienteController', | 331 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 346 | size: 'lg' | 332 | size: 'lg' |
| 347 | } | 333 | } |
| 348 | ); | 334 | ); |
| 349 | }; | 335 | }; |
| 350 | 336 | ||
| 351 | $scope.getTotal = function() { | 337 | $scope.getTotal = function() { |
| 352 | var total = 0; | 338 | var total = 0; |
| 353 | var arrayTempArticulos = $scope.articulosTabla; | 339 | var arrayTempArticulos = $scope.articulosTabla; |
| 354 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 340 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 355 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 341 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 356 | } | 342 | } |
| 357 | return parseFloat(total.toFixed(2)); | 343 | return parseFloat(total.toFixed(2)); |
| 358 | }; | 344 | }; |
| 359 | 345 | ||
| 360 | $scope.getSubTotal = function() { | 346 | $scope.getSubTotal = function() { |
| 361 | if($scope.articuloACargar) { | 347 | if($scope.articuloACargar) { |
| 362 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 348 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 363 | } | 349 | } |
| 364 | }; | 350 | }; |
| 365 | 351 | ||
| 366 | $scope.abrirModalListaPrecio = function() { | 352 | $scope.abrirModalListaPrecio = function() { |
| 367 | var modalInstance = $uibModal.open( | 353 | var modalInstance = $uibModal.open( |
| 368 | { | 354 | { |
| 369 | ariaLabelledBy: 'Busqueda de Precio Condición', | 355 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 370 | templateUrl: 'modal-precio-condicion.html', | 356 | templateUrl: 'modal-precio-condicion.html', |
| 371 | controller: 'focaModalPrecioCondicionController', | 357 | controller: 'focaModalPrecioCondicionController', |
| 372 | size: 'lg' | 358 | size: 'lg' |
| 373 | } | 359 | } |
| 374 | ); | 360 | ); |
| 375 | modalInstance.result.then( | 361 | modalInstance.result.then( |
| 376 | function(precioCondicion) { | 362 | function(precioCondicion) { |
| 377 | var cabecera = ''; | 363 | var cabecera = ''; |
| 378 | var plazosConcat = ''; | 364 | var plazosConcat = ''; |
| 379 | if(!Array.isArray(precioCondicion)) { | 365 | if(!Array.isArray(precioCondicion)) { |
| 380 | $scope.plazosPagos = precioCondicion.plazoPago; | 366 | $scope.plazosPagos = precioCondicion.plazoPago; |
| 381 | $scope.idLista = precioCondicion.idListaPrecio; | 367 | $scope.idLista = precioCondicion.idListaPrecio; |
| 382 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 368 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 383 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 369 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 384 | } | 370 | } |
| 385 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 371 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 386 | } else { //Cuando se ingresan los plazos manualmente | 372 | } else { //Cuando se ingresan los plazos manualmente |
| 387 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 373 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
| 388 | $scope.plazosPagos = precioCondicion; | 374 | $scope.plazosPagos = precioCondicion; |
| 389 | for(var j = 0; j < precioCondicion.length; j++) { | 375 | for(var j = 0; j < precioCondicion.length; j++) { |
| 390 | plazosConcat += precioCondicion[j].dias + ' '; | 376 | plazosConcat += precioCondicion[j].dias + ' '; |
| 391 | } | 377 | } |
| 392 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 378 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 393 | } | 379 | } |
| 394 | $scope.articulosTabla = []; | 380 | $scope.articulosTabla = []; |
| 395 | addCabecera('Precios y condiciones:', cabecera); | 381 | addCabecera('Precios y condiciones:', cabecera); |
| 396 | }, function() { | 382 | }, function() { |
| 397 | 383 | ||
| 398 | } | 384 | } |
| 399 | ); | 385 | ); |
| 400 | }; | 386 | }; |
| 401 | 387 | ||
| 402 | $scope.abrirModalFlete = function() { | 388 | $scope.abrirModalFlete = function() { |
| 403 | var modalInstance = $uibModal.open( | 389 | var modalInstance = $uibModal.open( |
| 404 | { | 390 | { |
| 405 | ariaLabelledBy: 'Busqueda de Flete', | 391 | ariaLabelledBy: 'Busqueda de Flete', |
| 406 | templateUrl: 'modal-flete.html', | 392 | templateUrl: 'modal-flete.html', |
| 407 | controller: 'focaModalFleteController', | 393 | controller: 'focaModalFleteController', |
| 408 | size: 'lg', | 394 | size: 'lg', |
| 409 | resolve: { | 395 | resolve: { |
| 410 | parametrosFlete: | 396 | parametrosFlete: |
| 411 | function() { | 397 | function() { |
| 412 | return { | 398 | return { |
| 413 | flete: $scope.notaPedido.flete ? '1' : | 399 | flete: $scope.notaPedido.flete ? '1' : |
| 414 | ($scope.notaPedido.fob ? 'FOB' : | 400 | ($scope.notaPedido.fob ? 'FOB' : |
| 415 | ($scope.notaPedido.flete === undefined ? null : '0')), | 401 | ($scope.notaPedido.flete === undefined ? null : '0')), |
| 416 | bomba: $scope.notaPedido.bomba ? '1' : | 402 | bomba: $scope.notaPedido.bomba ? '1' : |
| 417 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 403 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
| 418 | kilometros: $scope.notaPedido.kilometros | 404 | kilometros: $scope.notaPedido.kilometros |
| 419 | }; | 405 | }; |
| 420 | } | 406 | } |
| 421 | } | 407 | } |
| 422 | } | 408 | } |
| 423 | ); | 409 | ); |
| 424 | modalInstance.result.then( | 410 | modalInstance.result.then( |
| 425 | function(datos) { | 411 | function(datos) { |
| 426 | $scope.notaPedido.flete = datos.flete; | 412 | $scope.notaPedido.flete = datos.flete; |
| 427 | $scope.notaPedido.fob = datos.FOB; | 413 | $scope.notaPedido.fob = datos.FOB; |
| 428 | $scope.notaPedido.bomba = datos.bomba; | 414 | $scope.notaPedido.bomba = datos.bomba; |
| 429 | $scope.notaPedido.kilometros = datos.kilometros; | 415 | $scope.notaPedido.kilometros = datos.kilometros; |
| 430 | 416 | ||
| 431 | addCabecera('Flete:', datos.flete ? 'Si' : | 417 | addCabecera('Flete:', datos.flete ? 'Si' : |
| 432 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 418 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
| 433 | if(datos.flete) { | 419 | if(datos.flete) { |
| 434 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 420 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
| 435 | addCabecera('Kilometros:', datos.kilometros); | 421 | addCabecera('Kilometros:', datos.kilometros); |
| 436 | } else { | 422 | } else { |
| 437 | removeCabecera('Bomba:'); | 423 | removeCabecera('Bomba:'); |
| 438 | removeCabecera('Kilometros:'); | 424 | removeCabecera('Kilometros:'); |
| 439 | $scope.notaPedido.fob = false; | 425 | $scope.notaPedido.fob = false; |
| 440 | $scope.notaPedido.bomba = false; | 426 | $scope.notaPedido.bomba = false; |
| 441 | $scope.notaPedido.kilometros = null; | 427 | $scope.notaPedido.kilometros = null; |
| 442 | } | 428 | } |
| 443 | }, function() { | 429 | }, function() { |
| 444 | 430 | ||
| 445 | } | 431 | } |
| 446 | ); | 432 | ); |
| 447 | }; | 433 | }; |
| 448 | 434 | ||
| 449 | $scope.abrirModalMoneda = function() { | 435 | $scope.abrirModalMoneda = function() { |
| 450 | var modalInstance = $uibModal.open( | 436 | var modalInstance = $uibModal.open( |
| 451 | { | 437 | { |
| 452 | ariaLabelledBy: 'Busqueda de Moneda', | 438 | ariaLabelledBy: 'Busqueda de Moneda', |
| 453 | templateUrl: 'modal-moneda.html', | 439 | templateUrl: 'modal-moneda.html', |
| 454 | controller: 'focaModalMonedaController', | 440 | controller: 'focaModalMonedaController', |
| 455 | size: 'lg' | 441 | size: 'lg' |
| 456 | } | 442 | } |
| 457 | ); | 443 | ); |
| 458 | modalInstance.result.then( | 444 | modalInstance.result.then( |
| 459 | function(moneda) { | 445 | function(moneda) { |
| 460 | $scope.abrirModalCotizacion(moneda); | 446 | $scope.abrirModalCotizacion(moneda); |
| 461 | }, function() { | 447 | }, function() { |
| 462 | 448 | ||
| 463 | } | 449 | } |
| 464 | ); | 450 | ); |
| 465 | }; | 451 | }; |
| 466 | 452 | ||
| 467 | $scope.abrirModalCotizacion = function(moneda) { | 453 | $scope.abrirModalCotizacion = function(moneda) { |
| 468 | var modalInstance = $uibModal.open( | 454 | var modalInstance = $uibModal.open( |
| 469 | { | 455 | { |
| 470 | ariaLabelledBy: 'Busqueda de Cotización', | 456 | ariaLabelledBy: 'Busqueda de Cotización', |
| 471 | templateUrl: 'modal-cotizacion.html', | 457 | templateUrl: 'modal-cotizacion.html', |
| 472 | controller: 'focaModalCotizacionController', | 458 | controller: 'focaModalCotizacionController', |
| 473 | size: 'lg', | 459 | size: 'lg', |
| 474 | resolve: {idMoneda: function() {return moneda.ID;}} | 460 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 475 | } | 461 | } |
| 476 | ); | 462 | ); |
| 477 | modalInstance.result.then( | 463 | modalInstance.result.then( |
| 478 | function(cotizacion) { | 464 | function(cotizacion) { |
| 479 | var articulosTablaTemp = $scope.articulosTabla; | 465 | var articulosTablaTemp = $scope.articulosTabla; |
| 480 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 466 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 481 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 467 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 482 | $scope.notaPedido.cotizacion.COTIZACION; | 468 | $scope.notaPedido.cotizacion.COTIZACION; |
| 483 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 469 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 484 | cotizacion.COTIZACION; | 470 | cotizacion.COTIZACION; |
| 485 | } | 471 | } |
| 486 | $scope.articulosTabla = articulosTablaTemp; | 472 | $scope.articulosTabla = articulosTablaTemp; |
| 487 | $scope.notaPedido.moneda = { | 473 | $scope.notaPedido.moneda = { |
| 488 | id: moneda.ID, | 474 | id: moneda.ID, |
| 489 | detalle: moneda.DETALLE, | 475 | detalle: moneda.DETALLE, |
| 490 | simbolo: moneda.SIMBOLO | 476 | simbolo: moneda.SIMBOLO |
| 491 | }; | 477 | }; |
| 492 | $scope.notaPedido.cotizacion = { | 478 | $scope.notaPedido.cotizacion = { |
| 493 | ID: cotizacion.ID, | 479 | ID: cotizacion.ID, |
| 494 | COTIZACION: cotizacion.COTIZACION, | 480 | COTIZACION: cotizacion.COTIZACION, |
| 495 | FECHA: cotizacion.FECHA | 481 | FECHA: cotizacion.FECHA |
| 496 | }; | 482 | }; |
| 497 | addCabecera('Moneda:', moneda.DETALLE); | 483 | addCabecera('Moneda:', moneda.DETALLE); |
| 498 | addCabecera( | 484 | addCabecera( |
| 499 | 'Fecha cotizacion:', | 485 | 'Fecha cotizacion:', |
| 500 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 486 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 501 | ); | 487 | ); |
| 502 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 488 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
| 503 | }, function() { | 489 | }, function() { |
| 504 | 490 | ||
| 505 | } | 491 | } |
| 506 | ); | 492 | ); |
| 507 | }; | 493 | }; |
| 508 | 494 | ||
| 509 | $scope.agregarATabla = function(key) { | 495 | $scope.agregarATabla = function(key) { |
| 510 | if(key === 13) { | 496 | if(key === 13) { |
| 511 | if($scope.articuloACargar.cantidad === undefined || | 497 | if($scope.articuloACargar.cantidad === undefined || |
| 512 | $scope.articuloACargar.cantidad === 0 || | 498 | $scope.articuloACargar.cantidad === 0 || |
| 513 | $scope.articuloACargar.cantidad === null ){ | 499 | $scope.articuloACargar.cantidad === null ){ |
| 514 | focaModalService.alert('El valor debe ser al menos 1'); | 500 | focaModalService.alert('El valor debe ser al menos 1'); |
| 515 | return; | 501 | return; |
| 516 | } | 502 | } |
| 517 | delete $scope.articuloACargar.sectorCodigo; | 503 | delete $scope.articuloACargar.sectorCodigo; |
| 518 | $scope.articulosTabla.push($scope.articuloACargar); | 504 | $scope.articulosTabla.push($scope.articuloACargar); |
| 519 | $scope.cargando = true; | 505 | $scope.cargando = true; |
| 520 | } | 506 | } |
| 521 | }; | 507 | }; |
| 522 | 508 | ||
| 523 | $scope.quitarArticulo = function(key) { | 509 | $scope.quitarArticulo = function(key) { |
| 524 | $scope.articulosTabla.splice(key, 1); | 510 | $scope.articulosTabla.splice(key, 1); |
| 525 | }; | 511 | }; |
| 526 | 512 | ||
| 527 | $scope.editarArticulo = function(key, articulo) { | 513 | $scope.editarArticulo = function(key, articulo) { |
| 528 | if(key === 13) { | 514 | if(key === 13) { |
| 529 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 515 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 530 | articulo.cantidad === undefined){ | 516 | articulo.cantidad === undefined){ |
| 531 | focaModalService.alert('El valor debe ser al menos 1'); | 517 | focaModalService.alert('El valor debe ser al menos 1'); |
| 532 | return; | 518 | return; |
| 533 | } | 519 | } |
| 534 | articulo.editCantidad = false; | 520 | articulo.editCantidad = false; |
| 535 | articulo.editPrecio = false; | 521 | articulo.editPrecio = false; |
| 536 | } | 522 | } |
| 537 | }; | 523 | }; |
| 538 | 524 | ||
| 539 | $scope.cambioEdit = function(articulo, propiedad) { | 525 | $scope.cambioEdit = function(articulo, propiedad) { |
| 540 | if(propiedad === 'cantidad') { | 526 | if(propiedad === 'cantidad') { |
| 541 | articulo.editCantidad = true; | 527 | articulo.editCantidad = true; |
| 542 | } else if(propiedad === 'precio') { | 528 | } else if(propiedad === 'precio') { |
| 543 | articulo.editPrecio = true; | 529 | articulo.editPrecio = true; |
| 544 | } | 530 | } |
| 545 | }; | 531 | }; |
| 546 | 532 | ||
| 547 | $scope.limpiarFlete = function() { | 533 | $scope.limpiarFlete = function() { |
| 548 | $scope.notaPedido.fleteNombre = ''; | 534 | $scope.notaPedido.fleteNombre = ''; |
| 549 | $scope.notaPedido.chofer = ''; | 535 | $scope.notaPedido.chofer = ''; |
| 550 | $scope.notaPedido.vehiculo = ''; | 536 | $scope.notaPedido.vehiculo = ''; |
| 551 | $scope.notaPedido.kilometros = ''; | 537 | $scope.notaPedido.kilometros = ''; |
| 552 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 538 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 553 | $scope.choferes = ''; | 539 | $scope.choferes = ''; |
| 554 | $scope.vehiculos = ''; | 540 | $scope.vehiculos = ''; |
| 555 | }; | 541 | }; |
| 556 | 542 | ||
| 557 | $scope.limpiarPantalla = function() { | 543 | $scope.limpiarPantalla = function() { |
| 558 | $scope.limpiarFlete(); | 544 | $scope.limpiarFlete(); |
| 559 | $scope.notaPedido.flete = '0'; | 545 | $scope.notaPedido.flete = '0'; |
| 560 | $scope.notaPedido.bomba = '0'; | 546 | $scope.notaPedido.bomba = '0'; |
| 561 | $scope.notaPedido.precioCondicion = ''; | 547 | $scope.notaPedido.precioCondicion = ''; |
| 562 | $scope.articulosTabla = []; | 548 | $scope.articulosTabla = []; |
| 563 | $scope.notaPedido.vendedor.nombre = ''; | 549 | $scope.notaPedido.vendedor.nombre = ''; |
| 564 | $scope.notaPedido.cliente = {nombre: ''}; | 550 | $scope.notaPedido.cliente = {nombre: ''}; |
| 565 | $scope.notaPedido.domicilio = {dom: ''}; | 551 | $scope.notaPedido.domicilio = {dom: ''}; |
| 566 | $scope.domiciliosCliente = []; | 552 | $scope.domiciliosCliente = []; |
| 567 | }; | 553 | }; |
| 568 | 554 | ||
| 569 | $scope.resetFilter = function() { | 555 | $scope.resetFilter = function() { |
| 570 | $scope.articuloACargar = {}; | 556 | $scope.articuloACargar = {}; |
| 571 | $scope.cargando = true; | 557 | $scope.cargando = true; |
| 572 | }; | 558 | }; |
| 573 | 559 | ||
| 574 | $scope.selectFocus = function($event) { | 560 | $scope.selectFocus = function($event) { |
| 575 | $event.target.select(); | 561 | $event.target.select(); |
| 576 | }; | 562 | }; |
| 577 | 563 | ||
| 578 | $scope.salir = function() { | 564 | $scope.salir = function() { |
| 579 | $location.path('/'); | 565 | $location.path('/'); |
| 580 | }; | 566 | }; |
| 581 | 567 | ||
| 582 | function addCabecera(label, valor) { | 568 | function addCabecera(label, valor) { |
| 583 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 569 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 584 | if(propiedad.length === 1) { | 570 | if(propiedad.length === 1) { |
| 585 | propiedad[0].valor = valor; | 571 | propiedad[0].valor = valor; |
| 586 | } else { | 572 | } else { |
| 587 | $scope.cabecera.push({label: label, valor: valor}); | 573 | $scope.cabecera.push({label: label, valor: valor}); |
| 588 | } | 574 | } |
| 589 | } | 575 | } |
| 590 | 576 | ||
| 591 | function removeCabecera(label) { | 577 | function removeCabecera(label) { |
| 592 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 578 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 593 | if(propiedad.length === 1){ | 579 | if(propiedad.length === 1){ |
| 594 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 580 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 595 | } | 581 | } |
| 596 | } | 582 | } |
| 597 | } | 583 | } |
| 598 | ] | 584 | ] |
| 599 | ) | 585 | ) |
| 600 | .controller('notaPedidoListaCtrl', [ | 586 | .controller('notaPedidoListaCtrl', [ |
| 601 | '$scope', | 587 | '$scope', |
| 602 | 'crearNotaPedidoService', | 588 | 'crearNotaPedidoService', |
| 603 | '$location', | 589 | '$location', |
| 604 | function($scope, crearNotaPedidoService, $location) { | 590 | function($scope, crearNotaPedidoService, $location) { |
| 605 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 591 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 606 | $scope.notaPedidos = datos.data; | 592 | $scope.notaPedidos = datos.data; |
| 607 | }); | 593 | }); |
| 608 | $scope.editar = function(notaPedido) { | 594 | $scope.editar = function(notaPedido) { |
| 609 | crearNotaPedidoService.setNotaPedido(notaPedido); | 595 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 610 | $location.path('/venta-nota-pedido/abm/'); | 596 | $location.path('/venta-nota-pedido/abm/'); |
| 611 | }; | 597 | }; |
| 612 | $scope.crearPedido = function() { | 598 | $scope.crearPedido = function() { |
| 613 | crearNotaPedidoService.clearNotaPedido(); | 599 | crearNotaPedidoService.clearNotaPedido(); |
| 614 | $location.path('/venta-nota-pedido/abm/'); | 600 | $location.path('/venta-nota-pedido/abm/'); |
| 615 | }; | 601 | }; |
| 616 | } | 602 | } |
| 617 | ]) | 603 | ]) |
| 618 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 604 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 619 | '$scope', | 605 | '$scope', |
| 620 | 'crearNotaPedidoService', | 606 | 'crearNotaPedidoService', |
| 621 | '$location', | 607 | '$location', |
| 622 | function($scope, crearNotaPedidoService, $location) { | 608 | function($scope, crearNotaPedidoService, $location) { |
| 623 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 609 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 624 | $scope.notaPedidos = datos.data; | 610 | $scope.notaPedidos = datos.data; |
| 625 | }); | 611 | }); |
| 626 | $scope.editar = function(notaPedido) { | 612 | $scope.editar = function(notaPedido) { |
| 627 | crearNotaPedidoService.setNotaPedido(notaPedido); | 613 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 628 | $location.path('/venta-nota-pedido/abm/'); | 614 | $location.path('/venta-nota-pedido/abm/'); |
| 629 | }; | 615 | }; |
| 630 | $scope.crearPedido = function() { | 616 | $scope.crearPedido = function() { |
| 631 | crearNotaPedidoService.clearNotaPedido(); | 617 | crearNotaPedidoService.clearNotaPedido(); |
| 632 | $location.path('/venta-nota-pedido/abm/'); | 618 | $location.path('/venta-nota-pedido/abm/'); |
| 633 | }; | 619 | }; |
| 634 | } | 620 | } |
| 635 | ]); | 621 | ]); |
| 636 | 622 |