Commit ed3fe759008a22fbc4d017ba2b4a1d2b0c8dfee6
1 parent
7319d2a914
Exists in
master
and in
1 other branch
Agregué Vendedor y Total al detalle de la posición.
Fix de paginador.
Showing
2 changed files
with
7 additions
and
4 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', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService', | 4 | 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService', |
| 5 | function( | 5 | function( |
| 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, |
| 7 | notaPedidoBusinessService, $rootScope, focaSeguimientoService | 7 | notaPedidoBusinessService, $rootScope, focaSeguimientoService |
| 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].VENDEDOR); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); |
| 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 = '0000'; | 59 | $scope.puntoVenta = '0000'; |
| 60 | $scope.comprobante = '00000000'; | 60 | $scope.comprobante = '00000000'; |
| 61 | $scope.articulosTabla = []; | 61 | $scope.articulosTabla = []; |
| 62 | $scope.idLista = undefined; | 62 | $scope.idLista = undefined; |
| 63 | //La pantalla solo se usa para cargar pedidos | 63 | //La pantalla solo se usa para cargar pedidos |
| 64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 65 | 65 | ||
| 66 | crearNotaPedidoService.getPrecioCondicion().then( | 66 | crearNotaPedidoService.getPrecioCondicion().then( |
| 67 | function(res) { | 67 | function(res) { |
| 68 | $scope.precioCondiciones = res.data; | 68 | $scope.precioCondiciones = res.data; |
| 69 | } | 69 | } |
| 70 | ); | 70 | ); |
| 71 | 71 | ||
| 72 | crearNotaPedidoService.getNumeroNotaPedido().then( | 72 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 73 | function(res) { | 73 | function(res) { |
| 74 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 74 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 75 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 75 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
| 76 | }, | 76 | }, |
| 77 | function(err) { | 77 | function(err) { |
| 78 | focaModalService.alert('La terminal no esta configurada correctamente'); | 78 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 79 | console.info(err); | 79 | console.info(err); |
| 80 | } | 80 | } |
| 81 | ); | 81 | ); |
| 82 | //La pantalla solo se usa para cargar pedidos | 82 | //La pantalla solo se usa para cargar pedidos |
| 83 | // if (notaPedidoTemp !== undefined) { | 83 | // if (notaPedidoTemp !== undefined) { |
| 84 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 84 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 85 | // $scope.notaPedido = notaPedidoTemp; | 85 | // $scope.notaPedido = notaPedidoTemp; |
| 86 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 86 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 87 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 87 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 88 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 88 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
| 89 | // crearNotaPedidoService | 89 | // crearNotaPedidoService |
| 90 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 90 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 91 | // function(res) { | 91 | // function(res) { |
| 92 | // $scope.articulosTabla = res.data; | 92 | // $scope.articulosTabla = res.data; |
| 93 | // } | 93 | // } |
| 94 | // ); | 94 | // ); |
| 95 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 95 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 96 | //(NO REQUERIDO EN ESTA VERSION) | 96 | //(NO REQUERIDO EN ESTA VERSION) |
| 97 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 97 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 98 | // function(res) { | 98 | // function(res) { |
| 99 | // $scope.notaPedido.domicilio = res.data; | 99 | // $scope.notaPedido.domicilio = res.data; |
| 100 | // } | 100 | // } |
| 101 | // ); | 101 | // ); |
| 102 | // } else { | 102 | // } else { |
| 103 | // $scope.notaPedido.fechaCarga = new Date(); | 103 | // $scope.notaPedido.fechaCarga = new Date(); |
| 104 | // $scope.notaPedido.bomba = '0'; | 104 | // $scope.notaPedido.bomba = '0'; |
| 105 | // $scope.notaPedido.flete = '0'; | 105 | // $scope.notaPedido.flete = '0'; |
| 106 | // $scope.idLista = undefined; | 106 | // $scope.idLista = undefined; |
| 107 | // } | 107 | // } |
| 108 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 108 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 109 | // $scope.addNewDom = function() { | 109 | // $scope.addNewDom = function() { |
| 110 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 110 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 111 | // }; | 111 | // }; |
| 112 | // $scope.removeNewChoice = function(choice) { | 112 | // $scope.removeNewChoice = function(choice) { |
| 113 | // if ($scope.notaPedido.domicilio.length > 1) { | 113 | // if ($scope.notaPedido.domicilio.length > 1) { |
| 114 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 114 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 115 | // function(c) { | 115 | // function(c) { |
| 116 | // return c.$$hashKey === choice.$$hashKey; | 116 | // return c.$$hashKey === choice.$$hashKey; |
| 117 | // } | 117 | // } |
| 118 | // ), 1); | 118 | // ), 1); |
| 119 | // } | 119 | // } |
| 120 | // }; | 120 | // }; |
| 121 | 121 | ||
| 122 | $scope.crearNotaPedido = function() { | 122 | $scope.crearNotaPedido = function() { |
| 123 | if(!$scope.notaPedido.vendedor.codigo) { | 123 | if(!$scope.notaPedido.vendedor.codigo) { |
| 124 | focaModalService.alert('Ingrese Vendedor'); | 124 | focaModalService.alert('Ingrese Vendedor'); |
| 125 | return; | 125 | return; |
| 126 | } else if(!$scope.notaPedido.cliente.cod) { | 126 | } else if(!$scope.notaPedido.cliente.cod) { |
| 127 | focaModalService.alert('Ingrese Cliente'); | 127 | focaModalService.alert('Ingrese Cliente'); |
| 128 | return; | 128 | return; |
| 129 | } else if(!$scope.notaPedido.proveedor.codigo) { | 129 | } else if(!$scope.notaPedido.proveedor.codigo) { |
| 130 | focaModalService.alert('Ingrese Proveedor'); | 130 | focaModalService.alert('Ingrese Proveedor'); |
| 131 | return; | 131 | return; |
| 132 | } else if(!$scope.notaPedido.moneda.id) { | 132 | } else if(!$scope.notaPedido.moneda.id) { |
| 133 | focaModalService.alert('Ingrese Moneda'); | 133 | focaModalService.alert('Ingrese Moneda'); |
| 134 | return; | 134 | return; |
| 135 | } else if(!$scope.notaPedido.cotizacion.ID) { | 135 | } else if(!$scope.notaPedido.cotizacion.ID) { |
| 136 | focaModalService.alert('Ingrese Cotización'); | 136 | focaModalService.alert('Ingrese Cotización'); |
| 137 | return; | 137 | return; |
| 138 | } else if(!$scope.plazosPagos) { | 138 | } else if(!$scope.plazosPagos) { |
| 139 | focaModalService.alert('Ingrese Precios y Condiciones'); | 139 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 140 | return; | 140 | return; |
| 141 | } else if( | 141 | } else if( |
| 142 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 142 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
| 143 | { | 143 | { |
| 144 | focaModalService.alert('Ingrese Flete'); | 144 | focaModalService.alert('Ingrese Flete'); |
| 145 | return; | 145 | return; |
| 146 | } else if(!$scope.notaPedido.domicilio.id) { | 146 | } else if(!$scope.notaPedido.domicilio.id) { |
| 147 | focaModalService.alert('Ingrese Domicilio'); | 147 | focaModalService.alert('Ingrese Domicilio'); |
| 148 | return; | 148 | return; |
| 149 | } else if($scope.articulosTabla.length === 0) { | 149 | } else if($scope.articulosTabla.length === 0) { |
| 150 | focaModalService.alert('Debe cargar al menos un articulo'); | 150 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 151 | return; | 151 | return; |
| 152 | } | 152 | } |
| 153 | var date = new Date(); | 153 | var date = new Date(); |
| 154 | var notaPedido = { | 154 | var notaPedido = { |
| 155 | id: 0, | 155 | id: 0, |
| 156 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 156 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 157 | .toISOString().slice(0, 19).replace('T', ' '), | 157 | .toISOString().slice(0, 19).replace('T', ' '), |
| 158 | idVendedor: $scope.notaPedido.vendedor.codigo, | 158 | idVendedor: $scope.notaPedido.vendedor.codigo, |
| 159 | idCliente: $scope.notaPedido.cliente.cod, | 159 | idCliente: $scope.notaPedido.cliente.cod, |
| 160 | nombreCliente: $scope.notaPedido.cliente.nom, | 160 | nombreCliente: $scope.notaPedido.cliente.nom, |
| 161 | cuitCliente: $scope.notaPedido.cliente.cuit, | 161 | cuitCliente: $scope.notaPedido.cliente.cuit, |
| 162 | idProveedor: $scope.notaPedido.proveedor.codigo, | 162 | idProveedor: $scope.notaPedido.proveedor.codigo, |
| 163 | idDomicilio: $scope.notaPedido.domicilio.id, | 163 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 164 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 164 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 165 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 165 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
| 166 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 166 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 167 | flete: $scope.notaPedido.flete, | 167 | flete: $scope.notaPedido.flete, |
| 168 | fob: $scope.notaPedido.fob, | 168 | fob: $scope.notaPedido.fob, |
| 169 | bomba: $scope.notaPedido.bomba, | 169 | bomba: $scope.notaPedido.bomba, |
| 170 | kilometros: $scope.notaPedido.kilometros, | 170 | kilometros: $scope.notaPedido.kilometros, |
| 171 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 171 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 172 | estado: 0, | 172 | estado: 0, |
| 173 | total: $scope.getTotal() | 173 | total: $scope.getTotal() |
| 174 | }; | 174 | }; |
| 175 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 175 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 176 | function(data) { | 176 | function(data) { |
| 177 | // Al guardar los datos de la nota de pedido logueamos la | 177 | // Al guardar los datos de la nota de pedido logueamos la |
| 178 | // actividad para su seguimiento. | 178 | // actividad para su seguimiento. |
| 179 | focaSeguimientoService.guardarPosicion( | 179 | focaSeguimientoService.guardarPosicion( |
| 180 | $scope.notaPedido.vendedor.codigo, | 180 | $scope.notaPedido.vendedor.codigo, |
| 181 | 'Nota de pedido', | 181 | 'Nota de pedido', |
| 182 | 'Nº: ' + $filter('comprobante')([ | 182 | 'Nº: ' + $filter('comprobante')([ |
| 183 | $scope.puntoVenta, | 183 | $scope.puntoVenta, |
| 184 | $scope.comprobante | 184 | $scope.comprobante |
| 185 | ]) | 185 | ]) + '<br/>' + |
| 186 | 'Vendedor: ' + $scope.notaPedido.vendedor.nombre + '<br/>' + | ||
| 187 | 'Total: ' + $filter('currency')($scope.getTotal()) | ||
| 186 | ); | 188 | ); |
| 187 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 189 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
| 188 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 190 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 189 | var plazos = $scope.plazosPagos; | 191 | var plazos = $scope.plazosPagos; |
| 190 | 192 | ||
| 191 | for(var j = 0; j < plazos.length; j++) { | 193 | for(var j = 0; j < plazos.length; j++) { |
| 192 | var json = { | 194 | var json = { |
| 193 | idPedido: data.data.id, | 195 | idPedido: data.data.id, |
| 194 | dias: plazos[j].dias | 196 | dias: plazos[j].dias |
| 195 | }; | 197 | }; |
| 196 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 198 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
| 197 | } | 199 | } |
| 198 | notaPedidoBusinessService.addEstado(data.data.id, | 200 | notaPedidoBusinessService.addEstado(data.data.id, |
| 199 | $scope.notaPedido.vendedor.codigo); | 201 | $scope.notaPedido.vendedor.codigo); |
| 200 | 202 | ||
| 201 | focaModalService.alert('Nota pedido creada'); | 203 | focaModalService.alert('Nota pedido creada'); |
| 202 | $scope.cabecera = []; | 204 | $scope.cabecera = []; |
| 203 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 205 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
| 204 | addCabecera( | 206 | addCabecera( |
| 205 | 'Fecha cotizacion:', | 207 | 'Fecha cotizacion:', |
| 206 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 208 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
| 207 | ); | 209 | ); |
| 208 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); | 210 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); |
| 209 | $scope.notaPedido.vendedor = {}; | 211 | $scope.notaPedido.vendedor = {}; |
| 210 | $scope.notaPedido.cliente = {}; | 212 | $scope.notaPedido.cliente = {}; |
| 211 | $scope.notaPedido.proveedor = {}; | 213 | $scope.notaPedido.proveedor = {}; |
| 212 | $scope.notaPedido.domicilio = {}; | 214 | $scope.notaPedido.domicilio = {}; |
| 213 | $scope.notaPedido.flete = null; | 215 | $scope.notaPedido.flete = null; |
| 214 | $scope.notaPedido.fob = null; | 216 | $scope.notaPedido.fob = null; |
| 215 | $scope.notaPedido.bomba = null; | 217 | $scope.notaPedido.bomba = null; |
| 216 | $scope.notaPedido.kilometros = null; | 218 | $scope.notaPedido.kilometros = null; |
| 217 | $scope.articulosTabla = []; | 219 | $scope.articulosTabla = []; |
| 218 | }, | 220 | }, |
| 219 | function(error) { | 221 | function(error) { |
| 220 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 222 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 221 | console.info(error); | 223 | console.info(error); |
| 222 | } | 224 | } |
| 223 | ); | 225 | ); |
| 224 | }; | 226 | }; |
| 225 | 227 | ||
| 226 | $scope.seleccionarArticulo = function() { | 228 | $scope.seleccionarArticulo = function() { |
| 227 | if ($scope.idLista === undefined) { | 229 | if ($scope.idLista === undefined) { |
| 228 | focaModalService.alert( | 230 | focaModalService.alert( |
| 229 | 'Primero seleccione una lista de precio y condicion'); | 231 | 'Primero seleccione una lista de precio y condicion'); |
| 230 | return; | 232 | return; |
| 231 | } | 233 | } |
| 232 | var modalInstance = $uibModal.open( | 234 | var modalInstance = $uibModal.open( |
| 233 | { | 235 | { |
| 234 | ariaLabelledBy: 'Busqueda de Productos', | 236 | ariaLabelledBy: 'Busqueda de Productos', |
| 235 | templateUrl: 'modal-busqueda-productos.html', | 237 | templateUrl: 'modal-busqueda-productos.html', |
| 236 | controller: 'modalBusquedaProductosCtrl', | 238 | controller: 'modalBusquedaProductosCtrl', |
| 237 | resolve: { | 239 | resolve: { |
| 238 | parametroProducto: { | 240 | parametroProducto: { |
| 239 | idLista: $scope.idLista, | 241 | idLista: $scope.idLista, |
| 240 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 242 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 241 | simbolo: $scope.notaPedido.moneda.simbolo | 243 | simbolo: $scope.notaPedido.moneda.simbolo |
| 242 | } | 244 | } |
| 243 | }, | 245 | }, |
| 244 | size: 'lg' | 246 | size: 'lg' |
| 245 | } | 247 | } |
| 246 | ); | 248 | ); |
| 247 | modalInstance.result.then( | 249 | modalInstance.result.then( |
| 248 | function(producto) { | 250 | function(producto) { |
| 249 | var newArt = | 251 | var newArt = |
| 250 | { | 252 | { |
| 251 | id: 0, | 253 | id: 0, |
| 252 | codigo: producto.codigo, | 254 | codigo: producto.codigo, |
| 253 | sector: producto.sector, | 255 | sector: producto.sector, |
| 254 | sectorCodigo: producto.sector + '-' + producto.codigo, | 256 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 255 | descripcion: producto.descripcion, | 257 | descripcion: producto.descripcion, |
| 256 | item: $scope.articulosTabla.length + 1, | 258 | item: $scope.articulosTabla.length + 1, |
| 257 | nombre: producto.descripcion, | 259 | nombre: producto.descripcion, |
| 258 | precio: parseFloat(producto.precio.toFixed(4)), | 260 | precio: parseFloat(producto.precio.toFixed(4)), |
| 259 | costoUnitario: producto.costo, | 261 | costoUnitario: producto.costo, |
| 260 | editCantidad: false, | 262 | editCantidad: false, |
| 261 | editPrecio: false, | 263 | editPrecio: false, |
| 262 | rubro: producto.CodRub, | 264 | rubro: producto.CodRub, |
| 263 | exentoUnitario: producto.precio, | 265 | exentoUnitario: producto.precio, |
| 264 | ivaUnitario: producto.IMPIVA, | 266 | ivaUnitario: producto.IMPIVA, |
| 265 | impuestoInternoUnitario: producto.ImpInt, | 267 | impuestoInternoUnitario: producto.ImpInt, |
| 266 | impuestoInterno1Unitario: producto.ImpInt2, | 268 | impuestoInterno1Unitario: producto.ImpInt2, |
| 267 | impuestoInterno2Unitario: producto.ImpInt3, | 269 | impuestoInterno2Unitario: producto.ImpInt3, |
| 268 | precioLista: producto.precio, | 270 | precioLista: producto.precio, |
| 269 | combustible: 1, | 271 | combustible: 1, |
| 270 | facturado: 0 | 272 | facturado: 0 |
| 271 | }; | 273 | }; |
| 272 | $scope.articuloACargar = newArt; | 274 | $scope.articuloACargar = newArt; |
| 273 | $scope.cargando = false; | 275 | $scope.cargando = false; |
| 274 | }, function() { | 276 | }, function() { |
| 275 | // funcion ejecutada cuando se cancela el modal | 277 | // funcion ejecutada cuando se cancela el modal |
| 276 | } | 278 | } |
| 277 | ); | 279 | ); |
| 278 | }; | 280 | }; |
| 279 | 281 | ||
| 280 | $scope.seleccionarVendedor = function() { | 282 | $scope.seleccionarVendedor = function() { |
| 281 | var modalInstance = $uibModal.open( | 283 | var modalInstance = $uibModal.open( |
| 282 | { | 284 | { |
| 283 | ariaLabelledBy: 'Busqueda de Vendedores', | 285 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 284 | templateUrl: 'modal-vendedores.html', | 286 | templateUrl: 'modal-vendedores.html', |
| 285 | controller: 'modalVendedoresCtrl', | 287 | controller: 'modalVendedoresCtrl', |
| 286 | size: 'lg' | 288 | size: 'lg' |
| 287 | } | 289 | } |
| 288 | ); | 290 | ); |
| 289 | modalInstance.result.then( | 291 | modalInstance.result.then( |
| 290 | function(vendedor) { | 292 | function(vendedor) { |
| 291 | addCabecera('Vendedor:', vendedor.NomVen); | 293 | addCabecera('Vendedor:', vendedor.NomVen); |
| 292 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 294 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
| 295 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | ||
| 293 | }, function() { | 296 | }, function() { |
| 294 | 297 | ||
| 295 | } | 298 | } |
| 296 | ); | 299 | ); |
| 297 | }; | 300 | }; |
| 298 | 301 | ||
| 299 | $scope.seleccionarProveedor = function() { | 302 | $scope.seleccionarProveedor = function() { |
| 300 | var modalInstance = $uibModal.open( | 303 | var modalInstance = $uibModal.open( |
| 301 | { | 304 | { |
| 302 | ariaLabelledBy: 'Busqueda de Proveedor', | 305 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 303 | templateUrl: 'modal-proveedor.html', | 306 | templateUrl: 'modal-proveedor.html', |
| 304 | controller: 'focaModalProveedorCtrl', | 307 | controller: 'focaModalProveedorCtrl', |
| 305 | size: 'lg', | 308 | size: 'lg', |
| 306 | resolve: { | 309 | resolve: { |
| 307 | transportista: function() { | 310 | transportista: function() { |
| 308 | return false; | 311 | return false; |
| 309 | } | 312 | } |
| 310 | } | 313 | } |
| 311 | } | 314 | } |
| 312 | ); | 315 | ); |
| 313 | modalInstance.result.then( | 316 | modalInstance.result.then( |
| 314 | function(proveedor) { | 317 | function(proveedor) { |
| 315 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 318 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
| 316 | addCabecera('Proveedor:', proveedor.NOM); | 319 | addCabecera('Proveedor:', proveedor.NOM); |
| 317 | }, function() { | 320 | }, function() { |
| 318 | 321 | ||
| 319 | } | 322 | } |
| 320 | ); | 323 | ); |
| 321 | }; | 324 | }; |
| 322 | 325 | ||
| 323 | $scope.seleccionarCliente = function() { | 326 | $scope.seleccionarCliente = function() { |
| 324 | 327 | ||
| 325 | var modalInstance = $uibModal.open( | 328 | var modalInstance = $uibModal.open( |
| 326 | { | 329 | { |
| 327 | ariaLabelledBy: 'Busqueda de Cliente', | 330 | ariaLabelledBy: 'Busqueda de Cliente', |
| 328 | templateUrl: 'foca-busqueda-cliente-modal.html', | 331 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 329 | controller: 'focaBusquedaClienteModalController', | 332 | controller: 'focaBusquedaClienteModalController', |
| 330 | size: 'lg' | 333 | size: 'lg' |
| 331 | } | 334 | } |
| 332 | ); | 335 | ); |
| 333 | modalInstance.result.then( | 336 | modalInstance.result.then( |
| 334 | function(cliente) { | 337 | function(cliente) { |
| 335 | $scope.abrirModalDomicilios(cliente); | 338 | $scope.abrirModalDomicilios(cliente); |
| 336 | }, function() { | 339 | }, function() { |
| 337 | 340 | ||
| 338 | } | 341 | } |
| 339 | ); | 342 | ); |
| 340 | }; | 343 | }; |
| 341 | 344 | ||
| 342 | $scope.abrirModalDomicilios = function(cliente) { | 345 | $scope.abrirModalDomicilios = function(cliente) { |
| 343 | var modalInstanceDomicilio = $uibModal.open( | 346 | var modalInstanceDomicilio = $uibModal.open( |
| 344 | { | 347 | { |
| 345 | ariaLabelledBy: 'Busqueda de Domicilios', | 348 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 346 | templateUrl: 'modal-domicilio.html', | 349 | templateUrl: 'modal-domicilio.html', |
| 347 | controller: 'focaModalDomicilioController', | 350 | controller: 'focaModalDomicilioController', |
| 348 | resolve: { idCliente: function() { return cliente.cod; }}, | 351 | resolve: { idCliente: function() { return cliente.cod; }}, |
| 349 | size: 'lg', | 352 | size: 'lg', |
| 350 | } | 353 | } |
| 351 | ); | 354 | ); |
| 352 | modalInstanceDomicilio.result.then( | 355 | modalInstanceDomicilio.result.then( |
| 353 | function(domicilio) { | 356 | function(domicilio) { |
| 354 | $scope.notaPedido.domicilio.id = domicilio.id; | 357 | $scope.notaPedido.domicilio.id = domicilio.id; |
| 355 | $scope.notaPedido.cliente = cliente; | 358 | $scope.notaPedido.cliente = cliente; |
| 356 | addCabecera('Cliente:', cliente.nom); | 359 | addCabecera('Cliente:', cliente.nom); |
| 357 | var domicilioStamp = | 360 | var domicilioStamp = |
| 358 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 361 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 359 | domicilio.Localidad + ', ' + domicilio.Provincia; | 362 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 360 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 363 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
| 361 | addCabecera('Domicilio:', domicilioStamp); | 364 | addCabecera('Domicilio:', domicilioStamp); |
| 362 | }, function() { | 365 | }, function() { |
| 363 | $scope.seleccionarCliente(); | 366 | $scope.seleccionarCliente(); |
| 364 | return; | 367 | return; |
| 365 | } | 368 | } |
| 366 | ); | 369 | ); |
| 367 | }; | 370 | }; |
| 368 | 371 | ||
| 369 | $scope.mostrarFichaCliente = function() { | 372 | $scope.mostrarFichaCliente = function() { |
| 370 | $uibModal.open( | 373 | $uibModal.open( |
| 371 | { | 374 | { |
| 372 | ariaLabelledBy: 'Datos del Cliente', | 375 | ariaLabelledBy: 'Datos del Cliente', |
| 373 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 376 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 374 | controller: 'focaCrearNotaPedidoFichaClienteController', | 377 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 375 | size: 'lg' | 378 | size: 'lg' |
| 376 | } | 379 | } |
| 377 | ); | 380 | ); |
| 378 | }; | 381 | }; |
| 379 | 382 | ||
| 380 | $scope.getTotal = function() { | 383 | $scope.getTotal = function() { |
| 381 | var total = 0; | 384 | var total = 0; |
| 382 | var arrayTempArticulos = $scope.articulosTabla; | 385 | var arrayTempArticulos = $scope.articulosTabla; |
| 383 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 386 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 384 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 387 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 385 | } | 388 | } |
| 386 | return parseFloat(total.toFixed(2)); | 389 | return parseFloat(total.toFixed(2)); |
| 387 | }; | 390 | }; |
| 388 | 391 | ||
| 389 | $scope.getSubTotal = function() { | 392 | $scope.getSubTotal = function() { |
| 390 | if($scope.articuloACargar) { | 393 | if($scope.articuloACargar) { |
| 391 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 394 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 392 | } | 395 | } |
| 393 | }; | 396 | }; |
| 394 | 397 | ||
| 395 | $scope.abrirModalListaPrecio = function() { | 398 | $scope.abrirModalListaPrecio = function() { |
| 396 | var modalInstance = $uibModal.open( | 399 | var modalInstance = $uibModal.open( |
| 397 | { | 400 | { |
| 398 | ariaLabelledBy: 'Busqueda de Precio Condición', | 401 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 399 | templateUrl: 'modal-precio-condicion.html', | 402 | templateUrl: 'modal-precio-condicion.html', |
| 400 | controller: 'focaModalPrecioCondicionController', | 403 | controller: 'focaModalPrecioCondicionController', |
| 401 | size: 'lg' | 404 | size: 'lg' |
| 402 | } | 405 | } |
| 403 | ); | 406 | ); |
| 404 | modalInstance.result.then( | 407 | modalInstance.result.then( |
| 405 | function(precioCondicion) { | 408 | function(precioCondicion) { |
| 406 | var cabecera = ''; | 409 | var cabecera = ''; |
| 407 | var plazosConcat = ''; | 410 | var plazosConcat = ''; |
| 408 | if(!Array.isArray(precioCondicion)) { | 411 | if(!Array.isArray(precioCondicion)) { |
| 409 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 412 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
| 410 | $scope.plazosPagos = precioCondicion.plazoPago; | 413 | $scope.plazosPagos = precioCondicion.plazoPago; |
| 411 | $scope.idLista = precioCondicion.idListaPrecio; | 414 | $scope.idLista = precioCondicion.idListaPrecio; |
| 412 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 415 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 413 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 416 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 414 | } | 417 | } |
| 415 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 418 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 416 | } else { //Cuando se ingresan los plazos manualmente | 419 | } else { //Cuando se ingresan los plazos manualmente |
| 417 | $scope.notaPedido.idPrecioCondicion = 0; | 420 | $scope.notaPedido.idPrecioCondicion = 0; |
| 418 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 421 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
| 419 | $scope.plazosPagos = precioCondicion; | 422 | $scope.plazosPagos = precioCondicion; |
| 420 | for(var j = 0; j < precioCondicion.length; j++) { | 423 | for(var j = 0; j < precioCondicion.length; j++) { |
| 421 | plazosConcat += precioCondicion[j].dias + ' '; | 424 | plazosConcat += precioCondicion[j].dias + ' '; |
| 422 | } | 425 | } |
| 423 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 426 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 424 | } | 427 | } |
| 425 | $scope.articulosTabla = []; | 428 | $scope.articulosTabla = []; |
| 426 | addCabecera('Precios y condiciones:', cabecera); | 429 | addCabecera('Precios y condiciones:', cabecera); |
| 427 | }, function() { | 430 | }, function() { |
| 428 | 431 | ||
| 429 | } | 432 | } |
| 430 | ); | 433 | ); |
| 431 | }; | 434 | }; |
| 432 | 435 | ||
| 433 | $scope.abrirModalFlete = function() { | 436 | $scope.abrirModalFlete = function() { |
| 434 | var modalInstance = $uibModal.open( | 437 | var modalInstance = $uibModal.open( |
| 435 | { | 438 | { |
| 436 | ariaLabelledBy: 'Busqueda de Flete', | 439 | ariaLabelledBy: 'Busqueda de Flete', |
| 437 | templateUrl: 'modal-flete.html', | 440 | templateUrl: 'modal-flete.html', |
| 438 | controller: 'focaModalFleteController', | 441 | controller: 'focaModalFleteController', |
| 439 | size: 'lg', | 442 | size: 'lg', |
| 440 | resolve: { | 443 | resolve: { |
| 441 | parametrosFlete: | 444 | parametrosFlete: |
| 442 | function() { | 445 | function() { |
| 443 | return { | 446 | return { |
| 444 | flete: $scope.notaPedido.flete ? '1' : | 447 | flete: $scope.notaPedido.flete ? '1' : |
| 445 | ($scope.notaPedido.fob ? 'FOB' : | 448 | ($scope.notaPedido.fob ? 'FOB' : |
| 446 | ($scope.notaPedido.flete === undefined ? null : '0')), | 449 | ($scope.notaPedido.flete === undefined ? null : '0')), |
| 447 | bomba: $scope.notaPedido.bomba ? '1' : | 450 | bomba: $scope.notaPedido.bomba ? '1' : |
| 448 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 451 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
| 449 | kilometros: $scope.notaPedido.kilometros | 452 | kilometros: $scope.notaPedido.kilometros |
| 450 | }; | 453 | }; |
| 451 | } | 454 | } |
| 452 | } | 455 | } |
| 453 | } | 456 | } |
| 454 | ); | 457 | ); |
| 455 | modalInstance.result.then( | 458 | modalInstance.result.then( |
| 456 | function(datos) { | 459 | function(datos) { |
| 457 | $scope.notaPedido.flete = datos.flete; | 460 | $scope.notaPedido.flete = datos.flete; |
| 458 | $scope.notaPedido.fob = datos.FOB; | 461 | $scope.notaPedido.fob = datos.FOB; |
| 459 | $scope.notaPedido.bomba = datos.bomba; | 462 | $scope.notaPedido.bomba = datos.bomba; |
| 460 | $scope.notaPedido.kilometros = datos.kilometros; | 463 | $scope.notaPedido.kilometros = datos.kilometros; |
| 461 | 464 | ||
| 462 | addCabecera('Flete:', datos.flete ? 'Si' : | 465 | addCabecera('Flete:', datos.flete ? 'Si' : |
| 463 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 466 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
| 464 | if(datos.flete) { | 467 | if(datos.flete) { |
| 465 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 468 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
| 466 | addCabecera('Kilometros:', datos.kilometros); | 469 | addCabecera('Kilometros:', datos.kilometros); |
| 467 | } else { | 470 | } else { |
| 468 | removeCabecera('Bomba:'); | 471 | removeCabecera('Bomba:'); |
| 469 | removeCabecera('Kilometros:'); | 472 | removeCabecera('Kilometros:'); |
| 470 | $scope.notaPedido.fob = false; | 473 | $scope.notaPedido.fob = false; |
| 471 | $scope.notaPedido.bomba = false; | 474 | $scope.notaPedido.bomba = false; |
| 472 | $scope.notaPedido.kilometros = null; | 475 | $scope.notaPedido.kilometros = null; |
| 473 | } | 476 | } |
| 474 | }, function() { | 477 | }, function() { |
| 475 | 478 | ||
| 476 | } | 479 | } |
| 477 | ); | 480 | ); |
| 478 | }; | 481 | }; |
| 479 | 482 | ||
| 480 | $scope.abrirModalMoneda = function() { | 483 | $scope.abrirModalMoneda = function() { |
| 481 | var modalInstance = $uibModal.open( | 484 | var modalInstance = $uibModal.open( |
| 482 | { | 485 | { |
| 483 | ariaLabelledBy: 'Busqueda de Moneda', | 486 | ariaLabelledBy: 'Busqueda de Moneda', |
| 484 | templateUrl: 'modal-moneda.html', | 487 | templateUrl: 'modal-moneda.html', |
| 485 | controller: 'focaModalMonedaController', | 488 | controller: 'focaModalMonedaController', |
| 486 | size: 'lg' | 489 | size: 'lg' |
| 487 | } | 490 | } |
| 488 | ); | 491 | ); |
| 489 | modalInstance.result.then( | 492 | modalInstance.result.then( |
| 490 | function(moneda) { | 493 | function(moneda) { |
| 491 | $scope.abrirModalCotizacion(moneda); | 494 | $scope.abrirModalCotizacion(moneda); |
| 492 | }, function() { | 495 | }, function() { |
| 493 | 496 | ||
| 494 | } | 497 | } |
| 495 | ); | 498 | ); |
| 496 | }; | 499 | }; |
| 497 | 500 | ||
| 498 | $scope.abrirModalCotizacion = function(moneda) { | 501 | $scope.abrirModalCotizacion = function(moneda) { |
| 499 | var modalInstance = $uibModal.open( | 502 | var modalInstance = $uibModal.open( |
| 500 | { | 503 | { |
| 501 | ariaLabelledBy: 'Busqueda de Cotización', | 504 | ariaLabelledBy: 'Busqueda de Cotización', |
| 502 | templateUrl: 'modal-cotizacion.html', | 505 | templateUrl: 'modal-cotizacion.html', |
| 503 | controller: 'focaModalCotizacionController', | 506 | controller: 'focaModalCotizacionController', |
| 504 | size: 'lg', | 507 | size: 'lg', |
| 505 | resolve: {idMoneda: function() {return moneda.ID;}} | 508 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 506 | } | 509 | } |
| 507 | ); | 510 | ); |
| 508 | modalInstance.result.then( | 511 | modalInstance.result.then( |
| 509 | function(cotizacion) { | 512 | function(cotizacion) { |
| 510 | var articulosTablaTemp = $scope.articulosTabla; | 513 | var articulosTablaTemp = $scope.articulosTabla; |
| 511 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 514 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 512 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 515 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 513 | $scope.notaPedido.cotizacion.VENDEDOR; | 516 | $scope.notaPedido.cotizacion.VENDEDOR; |
| 514 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 517 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 515 | cotizacion.VENDEDOR; | 518 | cotizacion.VENDEDOR; |
| 516 | } | 519 | } |
| 517 | $scope.articulosTabla = articulosTablaTemp; | 520 | $scope.articulosTabla = articulosTablaTemp; |
| 518 | $scope.notaPedido.moneda = { | 521 | $scope.notaPedido.moneda = { |
| 519 | id: moneda.ID, | 522 | id: moneda.ID, |
| 520 | detalle: moneda.DETALLE, | 523 | detalle: moneda.DETALLE, |
| 521 | simbolo: moneda.SIMBOLO | 524 | simbolo: moneda.SIMBOLO |
| 522 | }; | 525 | }; |
| 523 | $scope.notaPedido.cotizacion = cotizacion; | 526 | $scope.notaPedido.cotizacion = cotizacion; |
| 524 | addCabecera('Moneda:', moneda.DETALLE); | 527 | addCabecera('Moneda:', moneda.DETALLE); |
| 525 | addCabecera( | 528 | addCabecera( |
| 526 | 'Fecha cotizacion:', | 529 | 'Fecha cotizacion:', |
| 527 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 530 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 528 | ); | 531 | ); |
| 529 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); | 532 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); |
| 530 | }, function() { | 533 | }, function() { |
| 531 | 534 | ||
| 532 | } | 535 | } |
| 533 | ); | 536 | ); |
| 534 | }; | 537 | }; |
| 535 | 538 | ||
| 536 | $scope.agregarATabla = function(key) { | 539 | $scope.agregarATabla = function(key) { |
| 537 | if(key === 13) { | 540 | if(key === 13) { |
| 538 | if($scope.articuloACargar.cantidad === undefined || | 541 | if($scope.articuloACargar.cantidad === undefined || |
| 539 | $scope.articuloACargar.cantidad === 0 || | 542 | $scope.articuloACargar.cantidad === 0 || |
| 540 | $scope.articuloACargar.cantidad === null ) { | 543 | $scope.articuloACargar.cantidad === null ) { |
| 541 | focaModalService.alert('El valor debe ser al menos 1'); | 544 | focaModalService.alert('El valor debe ser al menos 1'); |
| 542 | return; | 545 | return; |
| 543 | } | 546 | } |
| 544 | delete $scope.articuloACargar.sectorCodigo; | 547 | delete $scope.articuloACargar.sectorCodigo; |
| 545 | $scope.articulosTabla.push($scope.articuloACargar); | 548 | $scope.articulosTabla.push($scope.articuloACargar); |
| 546 | $scope.cargando = true; | 549 | $scope.cargando = true; |
| 547 | } | 550 | } |
| 548 | }; | 551 | }; |
| 549 | 552 | ||
| 550 | $scope.quitarArticulo = function(key) { | 553 | $scope.quitarArticulo = function(key) { |
| 551 | $scope.articulosTabla.splice(key, 1); | 554 | $scope.articulosTabla.splice(key, 1); |
| 552 | }; | 555 | }; |
| 553 | 556 | ||
| 554 | $scope.editarArticulo = function(key, articulo) { | 557 | $scope.editarArticulo = function(key, articulo) { |
| 555 | if(key === 13) { | 558 | if(key === 13) { |
| 556 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 559 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 557 | articulo.cantidad === undefined) { | 560 | articulo.cantidad === undefined) { |
| 558 | focaModalService.alert('El valor debe ser al menos 1'); | 561 | focaModalService.alert('El valor debe ser al menos 1'); |
| 559 | return; | 562 | return; |
| 560 | } | 563 | } |
| 561 | articulo.editCantidad = false; | 564 | articulo.editCantidad = false; |
| 562 | articulo.editPrecio = false; | 565 | articulo.editPrecio = false; |
| 563 | } | 566 | } |
| 564 | }; | 567 | }; |
| 565 | 568 | ||
| 566 | $scope.cambioEdit = function(articulo, propiedad) { | 569 | $scope.cambioEdit = function(articulo, propiedad) { |
| 567 | if(propiedad === 'cantidad') { | 570 | if(propiedad === 'cantidad') { |
| 568 | articulo.editCantidad = true; | 571 | articulo.editCantidad = true; |
| 569 | } else if(propiedad === 'precio') { | 572 | } else if(propiedad === 'precio') { |
| 570 | articulo.editPrecio = true; | 573 | articulo.editPrecio = true; |
| 571 | } | 574 | } |
| 572 | }; | 575 | }; |
| 573 | 576 | ||
| 574 | $scope.limpiarFlete = function() { | 577 | $scope.limpiarFlete = function() { |
| 575 | $scope.notaPedido.fleteNombre = ''; | 578 | $scope.notaPedido.fleteNombre = ''; |
| 576 | $scope.notaPedido.chofer = ''; | 579 | $scope.notaPedido.chofer = ''; |
| 577 | $scope.notaPedido.vehiculo = ''; | 580 | $scope.notaPedido.vehiculo = ''; |
| 578 | $scope.notaPedido.kilometros = ''; | 581 | $scope.notaPedido.kilometros = ''; |
| 579 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 582 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 580 | $scope.choferes = ''; | 583 | $scope.choferes = ''; |
| 581 | $scope.vehiculos = ''; | 584 | $scope.vehiculos = ''; |
| 582 | }; | 585 | }; |
| 583 | 586 | ||
| 584 | $scope.limpiarPantalla = function() { | 587 | $scope.limpiarPantalla = function() { |
| 585 | $scope.limpiarFlete(); | 588 | $scope.limpiarFlete(); |
| 586 | $scope.notaPedido.flete = '0'; | 589 | $scope.notaPedido.flete = '0'; |
| 587 | $scope.notaPedido.bomba = '0'; | 590 | $scope.notaPedido.bomba = '0'; |
| 588 | $scope.notaPedido.precioCondicion = ''; | 591 | $scope.notaPedido.precioCondicion = ''; |
| 589 | $scope.articulosTabla = []; | 592 | $scope.articulosTabla = []; |
| 590 | $scope.notaPedido.vendedor.nombre = ''; | 593 | $scope.notaPedido.vendedor.nombre = ''; |
| 591 | $scope.notaPedido.cliente = {nombre: ''}; | 594 | $scope.notaPedido.cliente = {nombre: ''}; |
| 592 | $scope.notaPedido.domicilio = {dom: ''}; | 595 | $scope.notaPedido.domicilio = {dom: ''}; |
| 593 | $scope.domiciliosCliente = []; | 596 | $scope.domiciliosCliente = []; |
| 594 | }; | 597 | }; |
| 595 | 598 | ||
| 596 | $scope.resetFilter = function() { | 599 | $scope.resetFilter = function() { |
| 597 | $scope.articuloACargar = {}; | 600 | $scope.articuloACargar = {}; |
| 598 | $scope.cargando = true; | 601 | $scope.cargando = true; |
| 599 | }; | 602 | }; |
| 600 | //Recibe aviso si el teclado está en uso | 603 | //Recibe aviso si el teclado está en uso |
| 601 | $rootScope.$on('usarTeclado', function(event, data) { | 604 | $rootScope.$on('usarTeclado', function(event, data) { |
| 602 | if(data) { | 605 | if(data) { |
| 603 | $scope.mostrarTeclado = true; | 606 | $scope.mostrarTeclado = true; |
| 604 | return; | 607 | return; |
| 605 | } | 608 | } |
| 606 | $scope.mostrarTeclado = false; | 609 | $scope.mostrarTeclado = false; |
| 607 | }); | 610 | }); |
| 608 | 611 | ||
| 609 | $scope.selectFocus = function($event) { | 612 | $scope.selectFocus = function($event) { |
| 610 | // Si el teclado esta en uso no selecciona el valor | 613 | // Si el teclado esta en uso no selecciona el valor |
| 611 | if($scope.mostrarTeclado) { | 614 | if($scope.mostrarTeclado) { |
| 612 | return; | 615 | return; |
| 613 | } | 616 | } |
| 614 | $event.target.select(); | 617 | $event.target.select(); |
| 615 | }; | 618 | }; |
| 616 | 619 | ||
| 617 | $scope.salir = function() { | 620 | $scope.salir = function() { |
| 618 | $location.path('/'); | 621 | $location.path('/'); |
| 619 | }; | 622 | }; |
| 620 | 623 | ||
| 621 | $scope.parsearATexto = function(articulo) { | 624 | $scope.parsearATexto = function(articulo) { |
| 622 | articulo.cantidad = parseFloat(articulo.cantidad); | 625 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 623 | articulo.precio = parseFloat(articulo.precio); | 626 | articulo.precio = parseFloat(articulo.precio); |
| 624 | }; | 627 | }; |
| 625 | 628 | ||
| 626 | function addCabecera(label, valor) { | 629 | function addCabecera(label, valor) { |
| 627 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 630 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 628 | if(propiedad.length === 1) { | 631 | if(propiedad.length === 1) { |
| 629 | propiedad[0].valor = valor; | 632 | propiedad[0].valor = valor; |
| 630 | } else { | 633 | } else { |
| 631 | $scope.cabecera.push({label: label, valor: valor}); | 634 | $scope.cabecera.push({label: label, valor: valor}); |
| 632 | } | 635 | } |
| 633 | } | 636 | } |
| 634 | 637 | ||
| 635 | function removeCabecera(label) { | 638 | function removeCabecera(label) { |
| 636 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 639 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 637 | if(propiedad.length === 1) { | 640 | if(propiedad.length === 1) { |
| 638 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 641 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 639 | } | 642 | } |
| 640 | } | 643 | } |
| 641 | 644 | ||
| 642 | function rellenar(relleno, longitud) { | 645 | function rellenar(relleno, longitud) { |
| 643 | relleno = '' + relleno; | 646 | relleno = '' + relleno; |
| 644 | while (relleno.length < longitud) { | 647 | while (relleno.length < longitud) { |
| 645 | relleno = '0' + relleno; | 648 | relleno = '0' + relleno; |
| 646 | } | 649 | } |
| 647 | 650 | ||
| 648 | return relleno; | 651 | return relleno; |
| 649 | } | 652 | } |
| 650 | } | 653 | } |
| 651 | ] | 654 | ] |
| 652 | ) | 655 | ) |
| 653 | .controller('notaPedidoListaCtrl', [ | 656 | .controller('notaPedidoListaCtrl', [ |
| 654 | '$scope', | 657 | '$scope', |
| 655 | 'crearNotaPedidoService', | 658 | 'crearNotaPedidoService', |
| 656 | '$location', | 659 | '$location', |
| 657 | function($scope, crearNotaPedidoService, $location) { | 660 | function($scope, crearNotaPedidoService, $location) { |
| 658 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 661 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 659 | $scope.notaPedidos = datos.data; | 662 | $scope.notaPedidos = datos.data; |
| 660 | }); | 663 | }); |
| 661 | $scope.editar = function(notaPedido) { | 664 | $scope.editar = function(notaPedido) { |
| 662 | crearNotaPedidoService.setNotaPedido(notaPedido); | 665 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 663 | $location.path('/venta-nota-pedido/abm/'); | 666 | $location.path('/venta-nota-pedido/abm/'); |
| 664 | }; | 667 | }; |
| 665 | $scope.crearPedido = function() { | 668 | $scope.crearPedido = function() { |
| 666 | crearNotaPedidoService.clearNotaPedido(); | 669 | crearNotaPedidoService.clearNotaPedido(); |
| 667 | $location.path('/venta-nota-pedido/abm/'); | 670 | $location.path('/venta-nota-pedido/abm/'); |
| 668 | }; | 671 | }; |
| 669 | } | 672 | } |
| 670 | ]) | 673 | ]) |
| 671 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 674 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 672 | '$scope', | 675 | '$scope', |
| 673 | 'crearNotaPedidoService', | 676 | 'crearNotaPedidoService', |
| 674 | '$location', | 677 | '$location', |
| 675 | function($scope, crearNotaPedidoService, $location) { | 678 | function($scope, crearNotaPedidoService, $location) { |
| 676 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 679 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 677 | $scope.notaPedidos = datos.data; | 680 | $scope.notaPedidos = datos.data; |
| 678 | }); | 681 | }); |
| 679 | $scope.editar = function(notaPedido) { | 682 | $scope.editar = function(notaPedido) { |
| 680 | crearNotaPedidoService.setNotaPedido(notaPedido); | 683 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 681 | $location.path('/venta-nota-pedido/abm/'); | 684 | $location.path('/venta-nota-pedido/abm/'); |
| 682 | }; | 685 | }; |
| 683 | $scope.crearPedido = function() { | 686 | $scope.crearPedido = function() { |
| 684 | crearNotaPedidoService.clearNotaPedido(); | 687 | crearNotaPedidoService.clearNotaPedido(); |
| 685 | $location.path('/venta-nota-pedido/abm/'); | 688 | $location.path('/venta-nota-pedido/abm/'); |
| 686 | }; | 689 | }; |
| 687 | } | 690 | } |
| 688 | ]); | 691 | ]); |
| 689 | 692 |
src/views/foca-crear-nota-pedido-ficha-cliente.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
| 2 | <h3 class="modal-title"></h3> | 2 | <h3 class="modal-title"></h3> |
| 3 | </div> | 3 | </div> |
| 4 | <div class="modal-body" id="modal-body"> | 4 | <div class="modal-body" id="modal-body"> |
| 5 | <div class="input-group mb-3"> | 5 | <div class="input-group mb-3"> |
| 6 | <input | 6 | <input |
| 7 | type="text" | 7 | type="text" |
| 8 | class="form-control" | 8 | class="form-control" |
| 9 | placeholder="Busqueda" | 9 | placeholder="Busqueda" |
| 10 | ng-model="filters" | 10 | ng-model="filters" |
| 11 | ng-change="search()" | 11 | ng-change="search()" |
| 12 | ng-keydown="busquedaDown($event.keyCode)" | 12 | ng-keydown="busquedaDown($event.keyCode)" |
| 13 | ng-keypress="busquedaPress($event.keyCode)" | 13 | ng-keypress="busquedaPress($event.keyCode)" |
| 14 | foca-focus="selectedVendedor == -1" | 14 | foca-focus="selectedVendedor == -1" |
| 15 | ng-focus="selectedVendedor = -1" | 15 | ng-focus="selectedVendedor = -1" |
| 16 | > | 16 | > |
| 17 | <table class="table table-striped table-sm"> | 17 | <table class="table table-striped table-sm"> |
| 18 | <thead> | 18 | <thead> |
| 19 | <tr> | 19 | <tr> |
| 20 | <th>Código</th> | 20 | <th>Código</th> |
| 21 | <th>Nombre</th> | 21 | <th>Nombre</th> |
| 22 | <th></th> | 22 | <th></th> |
| 23 | </tr> | 23 | </tr> |
| 24 | </thead> | 24 | </thead> |
| 25 | <tbody> | 25 | <tbody> |
| 26 | <tr ng-repeat="(key, vendedor) in currentPageVendedores"> | 26 | <tr ng-repeat="(key, vendedor) in currentPageVendedores"> |
| 27 | <td ng-bind="vendedor.CodVen"></td> | 27 | <td ng-bind="vendedor.CodVen"></td> |
| 28 | <td ng-bind="vendedor.NomVen"></td> | 28 | <td ng-bind="vendedor.NomVen"></td> |
| 29 | <td> | 29 | <td> |
| 30 | <button | 30 | <button |
| 31 | type="button" | 31 | type="button" |
| 32 | class="btn p-2 float-right btn-sm" | 32 | class="btn p-2 float-right btn-sm" |
| 33 | ng-class="{ | 33 | ng-class="{ |
| 34 | 'btn-secondary': selectedVendedor != key, | 34 | 'btn-secondary': selectedVendedor != key, |
| 35 | 'btn-primary': selectedVendedor == key | 35 | 'btn-primary': selectedVendedor == key |
| 36 | }" | 36 | }" |
| 37 | ng-click="select(vendedor)" | 37 | ng-click="select(vendedor)" |
| 38 | foca-focus="selectedVendedor == {{key}}" | 38 | foca-focus="selectedVendedor == {{key}}" |
| 39 | ng-keydown="itemVendedor($event.keyCode)"> | 39 | ng-keydown="itemVendedor($event.keyCode)"> |
| 40 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | 40 | <i class="fa fa-arrow-right" aria-hidden="true"></i> |
| 41 | </button> | 41 | </button> |
| 42 | </td> | 42 | </td> |
| 43 | </tr> | 43 | </tr> |
| 44 | </tbody> | 44 | </tbody> |
| 45 | </table> | 45 | </table> |
| 46 | <nav> | 46 | <nav> |
| 47 | <ul class="pagination justify-content-end"> | 47 | <ul class="pagination justify-content-end"> |
| 48 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | 48 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
| 49 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | 49 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> |
| 50 | <span aria-hidden="true">«</span> | 50 | <span aria-hidden="true">«</span> |
| 51 | <span class="sr-only">Anterior</span> | 51 | <span class="sr-only">Anterior</span> |
| 52 | </a> | 52 | </a> |
| 53 | </li> | 53 | </li> |
| 54 | <li | 54 | <li |
| 55 | class="page-item" | 55 | class="page-item" |
| 56 | ng-repeat="pagina in paginas" | 56 | ng-repeat="pagina in paginas" |
| 57 | ng-class="{'active': pagina == currentPage}" | 57 | ng-class="{'active': pagina == currentPage}" |
| 58 | > | 58 | > |
| 59 | <a | 59 | <a |
| 60 | class="page-link" | 60 | class="page-link" |
| 61 | href="#" | 61 | href="javascript:void();" |
| 62 | ng-click="selectPage(pagina)" | 62 | ng-click="selectPage(pagina)" |
| 63 | ng-bind="pagina" | 63 | ng-bind="pagina" |
| 64 | ></a> | 64 | ></a> |
| 65 | </li> | 65 | </li> |
| 66 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | 66 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> |
| 67 | <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | 67 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> |
| 68 | <span aria-hidden="true">»</span> | 68 | <span aria-hidden="true">»</span> |
| 69 | <span class="sr-only">Siguiente</span> | 69 | <span class="sr-only">Siguiente</span> |
| 70 | </a> | 70 | </a> |
| 71 | </li> | 71 | </li> |
| 72 | </ul> | 72 | </ul> |
| 73 | </nav> | 73 | </nav> |
| 74 | </div> | 74 | </div> |
| 75 | </div> | 75 | </div> |
| 76 | <div class="modal-footer"> | 76 | <div class="modal-footer"> |
| 77 | <button class="btn btn-secondary" data-dismiss="modal">Cerrar</button> | 77 | <button class="btn btn-secondary" data-dismiss="modal">Cerrar</button> |
| 78 | </div> | 78 | </div> |
| 79 | 79 |