Commit 99231e93fffe866957c7f37b15b5e723f0e3c18e
1 parent
c1551fdadb
Exists in
master
and in
1 other branch
inputs text change to number, keyboard virtual
Showing
2 changed files
with
18 additions
and
10 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 = '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 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, | 165 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, |
| 166 | flete: $scope.notaPedido.flete, | 166 | flete: $scope.notaPedido.flete, |
| 167 | fob: $scope.notaPedido.fob, | 167 | fob: $scope.notaPedido.fob, |
| 168 | bomba: $scope.notaPedido.bomba, | 168 | bomba: $scope.notaPedido.bomba, |
| 169 | kilometros: $scope.notaPedido.kilometros, | 169 | kilometros: $scope.notaPedido.kilometros, |
| 170 | estado: 0, | 170 | estado: 0, |
| 171 | total: $scope.getTotal() | 171 | total: $scope.getTotal() |
| 172 | }; | 172 | }; |
| 173 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 173 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 174 | function(data) { | 174 | function(data) { |
| 175 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 175 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
| 176 | data.data.id, $scope.notaPedido.cotizacion.COTIZACION); | 176 | data.data.id, $scope.notaPedido.cotizacion.COTIZACION); |
| 177 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); | 177 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); |
| 178 | var plazos = $scope.plazosPagos; | 178 | var plazos = $scope.plazosPagos; |
| 179 | 179 | ||
| 180 | for(var j = 0; j < plazos.length; j++) { | 180 | for(var j = 0; j < plazos.length; j++) { |
| 181 | var json = { | 181 | var json = { |
| 182 | idPedido: data.data.id, | 182 | idPedido: data.data.id, |
| 183 | dias: plazos[j].dias | 183 | dias: plazos[j].dias |
| 184 | }; | 184 | }; |
| 185 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 185 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
| 186 | } | 186 | } |
| 187 | notaPedidoBusinessService.addEstado(data.data.id, | 187 | notaPedidoBusinessService.addEstado(data.data.id, |
| 188 | $scope.notaPedido.vendedor.codigo); | 188 | $scope.notaPedido.vendedor.codigo); |
| 189 | 189 | ||
| 190 | focaModalService.alert('Nota pedido creada'); | 190 | focaModalService.alert('Nota pedido creada'); |
| 191 | $scope.cabecera = []; | 191 | $scope.cabecera = []; |
| 192 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 192 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
| 193 | addCabecera( | 193 | addCabecera( |
| 194 | 'Fecha cotizacion:', | 194 | 'Fecha cotizacion:', |
| 195 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 195 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
| 196 | ); | 196 | ); |
| 197 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); | 197 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); |
| 198 | $scope.notaPedido.vendedor = {}; | 198 | $scope.notaPedido.vendedor = {}; |
| 199 | $scope.notaPedido.cliente = {}; | 199 | $scope.notaPedido.cliente = {}; |
| 200 | $scope.notaPedido.proveedor = {}; | 200 | $scope.notaPedido.proveedor = {}; |
| 201 | $scope.notaPedido.domicilio = {}; | 201 | $scope.notaPedido.domicilio = {}; |
| 202 | $scope.notaPedido.flete = null; | 202 | $scope.notaPedido.flete = null; |
| 203 | $scope.notaPedido.fob = null; | 203 | $scope.notaPedido.fob = null; |
| 204 | $scope.notaPedido.bomba = null; | 204 | $scope.notaPedido.bomba = null; |
| 205 | $scope.notaPedido.kilometros = null; | 205 | $scope.notaPedido.kilometros = null; |
| 206 | $scope.articulosTabla = []; | 206 | $scope.articulosTabla = []; |
| 207 | }, | 207 | }, |
| 208 | function(error) { | 208 | function(error) { |
| 209 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 209 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 210 | console.info(error); | 210 | console.info(error); |
| 211 | } | 211 | } |
| 212 | ); | 212 | ); |
| 213 | }; | 213 | }; |
| 214 | 214 | ||
| 215 | $scope.seleccionarArticulo = function() { | 215 | $scope.seleccionarArticulo = function() { |
| 216 | if ($scope.idLista === undefined) { | 216 | if ($scope.idLista === undefined) { |
| 217 | focaModalService.alert( | 217 | focaModalService.alert( |
| 218 | 'Primero seleccione una lista de precio y condicion'); | 218 | 'Primero seleccione una lista de precio y condicion'); |
| 219 | return; | 219 | return; |
| 220 | } | 220 | } |
| 221 | var modalInstance = $uibModal.open( | 221 | var modalInstance = $uibModal.open( |
| 222 | { | 222 | { |
| 223 | ariaLabelledBy: 'Busqueda de Productos', | 223 | ariaLabelledBy: 'Busqueda de Productos', |
| 224 | templateUrl: 'modal-busqueda-productos.html', | 224 | templateUrl: 'modal-busqueda-productos.html', |
| 225 | controller: 'modalBusquedaProductosCtrl', | 225 | controller: 'modalBusquedaProductosCtrl', |
| 226 | resolve: { | 226 | resolve: { |
| 227 | parametroProducto: { | 227 | parametroProducto: { |
| 228 | idLista: $scope.idLista, | 228 | idLista: $scope.idLista, |
| 229 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, | 229 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION, |
| 230 | simbolo: $scope.notaPedido.moneda.simbolo | 230 | simbolo: $scope.notaPedido.moneda.simbolo |
| 231 | } | 231 | } |
| 232 | }, | 232 | }, |
| 233 | size: 'lg' | 233 | size: 'lg' |
| 234 | } | 234 | } |
| 235 | ); | 235 | ); |
| 236 | modalInstance.result.then( | 236 | modalInstance.result.then( |
| 237 | function(producto) { | 237 | function(producto) { |
| 238 | var newArt = | 238 | var newArt = |
| 239 | { | 239 | { |
| 240 | id: 0, | 240 | id: 0, |
| 241 | codigo: producto.codigo, | 241 | codigo: producto.codigo, |
| 242 | sector: producto.sector, | 242 | sector: producto.sector, |
| 243 | sectorCodigo: producto.sector + '-' + producto.codigo, | 243 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 244 | descripcion: producto.descripcion, | 244 | descripcion: producto.descripcion, |
| 245 | item: $scope.articulosTabla.length + 1, | 245 | item: $scope.articulosTabla.length + 1, |
| 246 | nombre: producto.descripcion, | 246 | nombre: producto.descripcion, |
| 247 | precio: parseFloat(producto.precio.toFixed(4)), | 247 | precio: parseFloat(producto.precio.toFixed(4)), |
| 248 | costoUnitario: producto.costo, | 248 | costoUnitario: producto.costo, |
| 249 | editCantidad: false, | 249 | editCantidad: false, |
| 250 | editPrecio: false | 250 | editPrecio: false |
| 251 | }; | 251 | }; |
| 252 | $scope.articuloACargar = newArt; | 252 | $scope.articuloACargar = newArt; |
| 253 | $scope.cargando = false; | 253 | $scope.cargando = false; |
| 254 | }, function() { | 254 | }, function() { |
| 255 | // funcion ejecutada cuando se cancela el modal | 255 | // funcion ejecutada cuando se cancela el modal |
| 256 | } | 256 | } |
| 257 | ); | 257 | ); |
| 258 | }; | 258 | }; |
| 259 | 259 | ||
| 260 | $scope.seleccionarVendedor = function() { | 260 | $scope.seleccionarVendedor = function() { |
| 261 | var modalInstance = $uibModal.open( | 261 | var modalInstance = $uibModal.open( |
| 262 | { | 262 | { |
| 263 | ariaLabelledBy: 'Busqueda de Vendedores', | 263 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 264 | templateUrl: 'modal-vendedores.html', | 264 | templateUrl: 'modal-vendedores.html', |
| 265 | controller: 'modalVendedoresCtrl', | 265 | controller: 'modalVendedoresCtrl', |
| 266 | size: 'lg' | 266 | size: 'lg' |
| 267 | } | 267 | } |
| 268 | ); | 268 | ); |
| 269 | modalInstance.result.then( | 269 | modalInstance.result.then( |
| 270 | function(vendedor) { | 270 | function(vendedor) { |
| 271 | addCabecera('Vendedor:', vendedor.NomVen); | 271 | addCabecera('Vendedor:', vendedor.NomVen); |
| 272 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 272 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
| 273 | }, function() { | 273 | }, function() { |
| 274 | 274 | ||
| 275 | } | 275 | } |
| 276 | ); | 276 | ); |
| 277 | }; | 277 | }; |
| 278 | 278 | ||
| 279 | $scope.seleccionarProveedor = function() { | 279 | $scope.seleccionarProveedor = function() { |
| 280 | var modalInstance = $uibModal.open( | 280 | var modalInstance = $uibModal.open( |
| 281 | { | 281 | { |
| 282 | ariaLabelledBy: 'Busqueda de Proveedor', | 282 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 283 | templateUrl: 'modal-proveedor.html', | 283 | templateUrl: 'modal-proveedor.html', |
| 284 | controller: 'focaModalProveedorCtrl', | 284 | controller: 'focaModalProveedorCtrl', |
| 285 | size: 'lg' | 285 | size: 'lg' |
| 286 | } | 286 | } |
| 287 | ); | 287 | ); |
| 288 | modalInstance.result.then( | 288 | modalInstance.result.then( |
| 289 | function(proveedor) { | 289 | function(proveedor) { |
| 290 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 290 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
| 291 | addCabecera('Proveedor:', proveedor.NOM); | 291 | addCabecera('Proveedor:', proveedor.NOM); |
| 292 | }, function() { | 292 | }, function() { |
| 293 | 293 | ||
| 294 | } | 294 | } |
| 295 | ); | 295 | ); |
| 296 | }; | 296 | }; |
| 297 | 297 | ||
| 298 | $scope.seleccionarCliente = function() { | 298 | $scope.seleccionarCliente = function() { |
| 299 | 299 | ||
| 300 | var modalInstance = $uibModal.open( | 300 | var modalInstance = $uibModal.open( |
| 301 | { | 301 | { |
| 302 | ariaLabelledBy: 'Busqueda de Cliente', | 302 | ariaLabelledBy: 'Busqueda de Cliente', |
| 303 | templateUrl: 'foca-busqueda-cliente-modal.html', | 303 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 304 | controller: 'focaBusquedaClienteModalController', | 304 | controller: 'focaBusquedaClienteModalController', |
| 305 | size: 'lg' | 305 | size: 'lg' |
| 306 | } | 306 | } |
| 307 | ); | 307 | ); |
| 308 | modalInstance.result.then( | 308 | modalInstance.result.then( |
| 309 | function(cliente) { | 309 | function(cliente) { |
| 310 | $scope.abrirModalDomicilios(cliente); | 310 | $scope.abrirModalDomicilios(cliente); |
| 311 | }, function() { | 311 | }, function() { |
| 312 | 312 | ||
| 313 | } | 313 | } |
| 314 | ); | 314 | ); |
| 315 | }; | 315 | }; |
| 316 | 316 | ||
| 317 | $scope.abrirModalDomicilios = function(cliente) { | 317 | $scope.abrirModalDomicilios = function(cliente) { |
| 318 | var modalInstanceDomicilio = $uibModal.open( | 318 | var modalInstanceDomicilio = $uibModal.open( |
| 319 | { | 319 | { |
| 320 | ariaLabelledBy: 'Busqueda de Domicilios', | 320 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 321 | templateUrl: 'modal-domicilio.html', | 321 | templateUrl: 'modal-domicilio.html', |
| 322 | controller: 'focaModalDomicilioController', | 322 | controller: 'focaModalDomicilioController', |
| 323 | resolve: { idCliente: function() { return cliente.cod; }}, | 323 | resolve: { idCliente: function() { return cliente.cod; }}, |
| 324 | size: 'lg', | 324 | size: 'lg', |
| 325 | } | 325 | } |
| 326 | ); | 326 | ); |
| 327 | modalInstanceDomicilio.result.then( | 327 | modalInstanceDomicilio.result.then( |
| 328 | function(domicilio) { | 328 | function(domicilio) { |
| 329 | $scope.notaPedido.domicilio.id = domicilio.nivel2; | 329 | $scope.notaPedido.domicilio.id = domicilio.nivel2; |
| 330 | $scope.notaPedido.cliente = cliente; | 330 | $scope.notaPedido.cliente = cliente; |
| 331 | 331 | ||
| 332 | addCabecera('Cliente:', cliente.nom); | 332 | addCabecera('Cliente:', cliente.nom); |
| 333 | addCabecera('Domicilio:', domicilio.dom); | 333 | addCabecera('Domicilio:', domicilio.dom); |
| 334 | }, function() { | 334 | }, function() { |
| 335 | $scope.seleccionarCliente(); | 335 | $scope.seleccionarCliente(); |
| 336 | return; | 336 | return; |
| 337 | } | 337 | } |
| 338 | ); | 338 | ); |
| 339 | }; | 339 | }; |
| 340 | 340 | ||
| 341 | $scope.mostrarFichaCliente = function() { | 341 | $scope.mostrarFichaCliente = function() { |
| 342 | $uibModal.open( | 342 | $uibModal.open( |
| 343 | { | 343 | { |
| 344 | ariaLabelledBy: 'Datos del Cliente', | 344 | ariaLabelledBy: 'Datos del Cliente', |
| 345 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 345 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 346 | controller: 'focaCrearNotaPedidoFichaClienteController', | 346 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 347 | size: 'lg' | 347 | size: 'lg' |
| 348 | } | 348 | } |
| 349 | ); | 349 | ); |
| 350 | }; | 350 | }; |
| 351 | 351 | ||
| 352 | $scope.getTotal = function() { | 352 | $scope.getTotal = function() { |
| 353 | var total = 0; | 353 | var total = 0; |
| 354 | var arrayTempArticulos = $scope.articulosTabla; | 354 | var arrayTempArticulos = $scope.articulosTabla; |
| 355 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 355 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 356 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 356 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 357 | } | 357 | } |
| 358 | return parseFloat(total.toFixed(2)); | 358 | return parseFloat(total.toFixed(2)); |
| 359 | }; | 359 | }; |
| 360 | 360 | ||
| 361 | $scope.getSubTotal = function() { | 361 | $scope.getSubTotal = function() { |
| 362 | if($scope.articuloACargar) { | 362 | if($scope.articuloACargar) { |
| 363 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 363 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 364 | } | 364 | } |
| 365 | }; | 365 | }; |
| 366 | 366 | ||
| 367 | $scope.abrirModalListaPrecio = function() { | 367 | $scope.abrirModalListaPrecio = function() { |
| 368 | var modalInstance = $uibModal.open( | 368 | var modalInstance = $uibModal.open( |
| 369 | { | 369 | { |
| 370 | ariaLabelledBy: 'Busqueda de Precio Condición', | 370 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 371 | templateUrl: 'modal-precio-condicion.html', | 371 | templateUrl: 'modal-precio-condicion.html', |
| 372 | controller: 'focaModalPrecioCondicionController', | 372 | controller: 'focaModalPrecioCondicionController', |
| 373 | size: 'lg' | 373 | size: 'lg' |
| 374 | } | 374 | } |
| 375 | ); | 375 | ); |
| 376 | modalInstance.result.then( | 376 | modalInstance.result.then( |
| 377 | function(precioCondicion) { | 377 | function(precioCondicion) { |
| 378 | var cabecera = ''; | 378 | var cabecera = ''; |
| 379 | var plazosConcat = ''; | 379 | var plazosConcat = ''; |
| 380 | if(!Array.isArray(precioCondicion)) { | 380 | if(!Array.isArray(precioCondicion)) { |
| 381 | $scope.plazosPagos = precioCondicion.plazoPago; | 381 | $scope.plazosPagos = precioCondicion.plazoPago; |
| 382 | $scope.idLista = precioCondicion.idListaPrecio; | 382 | $scope.idLista = precioCondicion.idListaPrecio; |
| 383 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 383 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 384 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 384 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 385 | } | 385 | } |
| 386 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 386 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 387 | } else { //Cuando se ingresan los plazos manualmente | 387 | } else { //Cuando se ingresan los plazos manualmente |
| 388 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 388 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
| 389 | $scope.plazosPagos = precioCondicion; | 389 | $scope.plazosPagos = precioCondicion; |
| 390 | for(var j = 0; j < precioCondicion.length; j++) { | 390 | for(var j = 0; j < precioCondicion.length; j++) { |
| 391 | plazosConcat += precioCondicion[j].dias + ' '; | 391 | plazosConcat += precioCondicion[j].dias + ' '; |
| 392 | } | 392 | } |
| 393 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 393 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 394 | } | 394 | } |
| 395 | $scope.articulosTabla = []; | 395 | $scope.articulosTabla = []; |
| 396 | addCabecera('Precios y condiciones:', cabecera); | 396 | addCabecera('Precios y condiciones:', cabecera); |
| 397 | }, function() { | 397 | }, function() { |
| 398 | 398 | ||
| 399 | } | 399 | } |
| 400 | ); | 400 | ); |
| 401 | }; | 401 | }; |
| 402 | 402 | ||
| 403 | $scope.abrirModalFlete = function() { | 403 | $scope.abrirModalFlete = function() { |
| 404 | var modalInstance = $uibModal.open( | 404 | var modalInstance = $uibModal.open( |
| 405 | { | 405 | { |
| 406 | ariaLabelledBy: 'Busqueda de Flete', | 406 | ariaLabelledBy: 'Busqueda de Flete', |
| 407 | templateUrl: 'modal-flete.html', | 407 | templateUrl: 'modal-flete.html', |
| 408 | controller: 'focaModalFleteController', | 408 | controller: 'focaModalFleteController', |
| 409 | size: 'lg', | 409 | size: 'lg', |
| 410 | resolve: { | 410 | resolve: { |
| 411 | parametrosFlete: | 411 | parametrosFlete: |
| 412 | function() { | 412 | function() { |
| 413 | return { | 413 | return { |
| 414 | flete: $scope.notaPedido.flete ? '1' : | 414 | flete: $scope.notaPedido.flete ? '1' : |
| 415 | ($scope.notaPedido.fob ? 'FOB' : | 415 | ($scope.notaPedido.fob ? 'FOB' : |
| 416 | ($scope.notaPedido.flete === undefined ? null : '0')), | 416 | ($scope.notaPedido.flete === undefined ? null : '0')), |
| 417 | bomba: $scope.notaPedido.bomba ? '1' : | 417 | bomba: $scope.notaPedido.bomba ? '1' : |
| 418 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 418 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
| 419 | kilometros: $scope.notaPedido.kilometros | 419 | kilometros: $scope.notaPedido.kilometros |
| 420 | }; | 420 | }; |
| 421 | } | 421 | } |
| 422 | } | 422 | } |
| 423 | } | 423 | } |
| 424 | ); | 424 | ); |
| 425 | modalInstance.result.then( | 425 | modalInstance.result.then( |
| 426 | function(datos) { | 426 | function(datos) { |
| 427 | $scope.notaPedido.flete = datos.flete; | 427 | $scope.notaPedido.flete = datos.flete; |
| 428 | $scope.notaPedido.fob = datos.FOB; | 428 | $scope.notaPedido.fob = datos.FOB; |
| 429 | $scope.notaPedido.bomba = datos.bomba; | 429 | $scope.notaPedido.bomba = datos.bomba; |
| 430 | $scope.notaPedido.kilometros = datos.kilometros; | 430 | $scope.notaPedido.kilometros = datos.kilometros; |
| 431 | 431 | ||
| 432 | addCabecera('Flete:', datos.flete ? 'Si' : | 432 | addCabecera('Flete:', datos.flete ? 'Si' : |
| 433 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 433 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
| 434 | if(datos.flete) { | 434 | if(datos.flete) { |
| 435 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 435 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
| 436 | addCabecera('Kilometros:', datos.kilometros); | 436 | addCabecera('Kilometros:', datos.kilometros); |
| 437 | } else { | 437 | } else { |
| 438 | removeCabecera('Bomba:'); | 438 | removeCabecera('Bomba:'); |
| 439 | removeCabecera('Kilometros:'); | 439 | removeCabecera('Kilometros:'); |
| 440 | $scope.notaPedido.fob = false; | 440 | $scope.notaPedido.fob = false; |
| 441 | $scope.notaPedido.bomba = false; | 441 | $scope.notaPedido.bomba = false; |
| 442 | $scope.notaPedido.kilometros = null; | 442 | $scope.notaPedido.kilometros = null; |
| 443 | } | 443 | } |
| 444 | }, function() { | 444 | }, function() { |
| 445 | 445 | ||
| 446 | } | 446 | } |
| 447 | ); | 447 | ); |
| 448 | }; | 448 | }; |
| 449 | 449 | ||
| 450 | $scope.abrirModalMoneda = function() { | 450 | $scope.abrirModalMoneda = function() { |
| 451 | var modalInstance = $uibModal.open( | 451 | var modalInstance = $uibModal.open( |
| 452 | { | 452 | { |
| 453 | ariaLabelledBy: 'Busqueda de Moneda', | 453 | ariaLabelledBy: 'Busqueda de Moneda', |
| 454 | templateUrl: 'modal-moneda.html', | 454 | templateUrl: 'modal-moneda.html', |
| 455 | controller: 'focaModalMonedaController', | 455 | controller: 'focaModalMonedaController', |
| 456 | size: 'lg' | 456 | size: 'lg' |
| 457 | } | 457 | } |
| 458 | ); | 458 | ); |
| 459 | modalInstance.result.then( | 459 | modalInstance.result.then( |
| 460 | function(moneda) { | 460 | function(moneda) { |
| 461 | $scope.abrirModalCotizacion(moneda); | 461 | $scope.abrirModalCotizacion(moneda); |
| 462 | }, function() { | 462 | }, function() { |
| 463 | 463 | ||
| 464 | } | 464 | } |
| 465 | ); | 465 | ); |
| 466 | }; | 466 | }; |
| 467 | 467 | ||
| 468 | $scope.abrirModalCotizacion = function(moneda) { | 468 | $scope.abrirModalCotizacion = function(moneda) { |
| 469 | var modalInstance = $uibModal.open( | 469 | var modalInstance = $uibModal.open( |
| 470 | { | 470 | { |
| 471 | ariaLabelledBy: 'Busqueda de Cotización', | 471 | ariaLabelledBy: 'Busqueda de Cotización', |
| 472 | templateUrl: 'modal-cotizacion.html', | 472 | templateUrl: 'modal-cotizacion.html', |
| 473 | controller: 'focaModalCotizacionController', | 473 | controller: 'focaModalCotizacionController', |
| 474 | size: 'lg', | 474 | size: 'lg', |
| 475 | resolve: {idMoneda: function() {return moneda.ID;}} | 475 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 476 | } | 476 | } |
| 477 | ); | 477 | ); |
| 478 | modalInstance.result.then( | 478 | modalInstance.result.then( |
| 479 | function(cotizacion) { | 479 | function(cotizacion) { |
| 480 | var articulosTablaTemp = $scope.articulosTabla; | 480 | var articulosTablaTemp = $scope.articulosTabla; |
| 481 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 481 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 482 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 482 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 483 | $scope.notaPedido.cotizacion.COTIZACION; | 483 | $scope.notaPedido.cotizacion.COTIZACION; |
| 484 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 484 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 485 | cotizacion.COTIZACION; | 485 | cotizacion.COTIZACION; |
| 486 | } | 486 | } |
| 487 | $scope.articulosTabla = articulosTablaTemp; | 487 | $scope.articulosTabla = articulosTablaTemp; |
| 488 | $scope.notaPedido.moneda = { | 488 | $scope.notaPedido.moneda = { |
| 489 | id: moneda.ID, | 489 | id: moneda.ID, |
| 490 | detalle: moneda.DETALLE, | 490 | detalle: moneda.DETALLE, |
| 491 | simbolo: moneda.SIMBOLO | 491 | simbolo: moneda.SIMBOLO |
| 492 | }; | 492 | }; |
| 493 | $scope.notaPedido.cotizacion = { | 493 | $scope.notaPedido.cotizacion = { |
| 494 | ID: cotizacion.ID, | 494 | ID: cotizacion.ID, |
| 495 | COTIZACION: cotizacion.COTIZACION, | 495 | COTIZACION: cotizacion.COTIZACION, |
| 496 | FECHA: cotizacion.FECHA | 496 | FECHA: cotizacion.FECHA |
| 497 | }; | 497 | }; |
| 498 | addCabecera('Moneda:', moneda.DETALLE); | 498 | addCabecera('Moneda:', moneda.DETALLE); |
| 499 | addCabecera( | 499 | addCabecera( |
| 500 | 'Fecha cotizacion:', | 500 | 'Fecha cotizacion:', |
| 501 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 501 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 502 | ); | 502 | ); |
| 503 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 503 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
| 504 | }, function() { | 504 | }, function() { |
| 505 | 505 | ||
| 506 | } | 506 | } |
| 507 | ); | 507 | ); |
| 508 | }; | 508 | }; |
| 509 | 509 | ||
| 510 | $scope.agregarATabla = function(key) { | 510 | $scope.agregarATabla = function(key) { |
| 511 | if(key === 13) { | 511 | if(key === 13) { |
| 512 | if($scope.articuloACargar.cantidad === undefined || | 512 | if($scope.articuloACargar.cantidad === undefined || |
| 513 | $scope.articuloACargar.cantidad === 0 || | 513 | $scope.articuloACargar.cantidad === 0 || |
| 514 | $scope.articuloACargar.cantidad === null ){ | 514 | $scope.articuloACargar.cantidad === null ){ |
| 515 | focaModalService.alert('El valor debe ser al menos 1'); | 515 | focaModalService.alert('El valor debe ser al menos 1'); |
| 516 | return; | 516 | return; |
| 517 | } | 517 | } |
| 518 | delete $scope.articuloACargar.sectorCodigo; | 518 | delete $scope.articuloACargar.sectorCodigo; |
| 519 | $scope.articulosTabla.push($scope.articuloACargar); | 519 | $scope.articulosTabla.push($scope.articuloACargar); |
| 520 | $scope.cargando = true; | 520 | $scope.cargando = true; |
| 521 | } | 521 | } |
| 522 | }; | 522 | }; |
| 523 | 523 | ||
| 524 | $scope.quitarArticulo = function(key) { | 524 | $scope.quitarArticulo = function(key) { |
| 525 | $scope.articulosTabla.splice(key, 1); | 525 | $scope.articulosTabla.splice(key, 1); |
| 526 | }; | 526 | }; |
| 527 | 527 | ||
| 528 | $scope.editarArticulo = function(key, articulo) { | 528 | $scope.editarArticulo = function(key, articulo) { |
| 529 | if(key === 13) { | 529 | if(key === 13) { |
| 530 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 530 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 531 | articulo.cantidad === undefined){ | 531 | articulo.cantidad === undefined){ |
| 532 | focaModalService.alert('El valor debe ser al menos 1'); | 532 | focaModalService.alert('El valor debe ser al menos 1'); |
| 533 | return; | 533 | return; |
| 534 | } | 534 | } |
| 535 | articulo.editCantidad = false; | 535 | articulo.editCantidad = false; |
| 536 | articulo.editPrecio = false; | 536 | articulo.editPrecio = false; |
| 537 | } | 537 | } |
| 538 | }; | 538 | }; |
| 539 | 539 | ||
| 540 | $scope.cambioEdit = function(articulo, propiedad) { | 540 | $scope.cambioEdit = function(articulo, propiedad) { |
| 541 | if(propiedad === 'cantidad') { | 541 | if(propiedad === 'cantidad') { |
| 542 | articulo.editCantidad = true; | 542 | articulo.editCantidad = true; |
| 543 | } else if(propiedad === 'precio') { | 543 | } else if(propiedad === 'precio') { |
| 544 | articulo.editPrecio = true; | 544 | articulo.editPrecio = true; |
| 545 | } | 545 | } |
| 546 | }; | 546 | }; |
| 547 | 547 | ||
| 548 | $scope.limpiarFlete = function() { | 548 | $scope.limpiarFlete = function() { |
| 549 | $scope.notaPedido.fleteNombre = ''; | 549 | $scope.notaPedido.fleteNombre = ''; |
| 550 | $scope.notaPedido.chofer = ''; | 550 | $scope.notaPedido.chofer = ''; |
| 551 | $scope.notaPedido.vehiculo = ''; | 551 | $scope.notaPedido.vehiculo = ''; |
| 552 | $scope.notaPedido.kilometros = ''; | 552 | $scope.notaPedido.kilometros = ''; |
| 553 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 553 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 554 | $scope.choferes = ''; | 554 | $scope.choferes = ''; |
| 555 | $scope.vehiculos = ''; | 555 | $scope.vehiculos = ''; |
| 556 | }; | 556 | }; |
| 557 | 557 | ||
| 558 | $scope.limpiarPantalla = function() { | 558 | $scope.limpiarPantalla = function() { |
| 559 | $scope.limpiarFlete(); | 559 | $scope.limpiarFlete(); |
| 560 | $scope.notaPedido.flete = '0'; | 560 | $scope.notaPedido.flete = '0'; |
| 561 | $scope.notaPedido.bomba = '0'; | 561 | $scope.notaPedido.bomba = '0'; |
| 562 | $scope.notaPedido.precioCondicion = ''; | 562 | $scope.notaPedido.precioCondicion = ''; |
| 563 | $scope.articulosTabla = []; | 563 | $scope.articulosTabla = []; |
| 564 | $scope.notaPedido.vendedor.nombre = ''; | 564 | $scope.notaPedido.vendedor.nombre = ''; |
| 565 | $scope.notaPedido.cliente = {nombre: ''}; | 565 | $scope.notaPedido.cliente = {nombre: ''}; |
| 566 | $scope.notaPedido.domicilio = {dom: ''}; | 566 | $scope.notaPedido.domicilio = {dom: ''}; |
| 567 | $scope.domiciliosCliente = []; | 567 | $scope.domiciliosCliente = []; |
| 568 | }; | 568 | }; |
| 569 | 569 | ||
| 570 | $scope.resetFilter = function() { | 570 | $scope.resetFilter = function() { |
| 571 | $scope.articuloACargar = {}; | 571 | $scope.articuloACargar = {}; |
| 572 | $scope.cargando = true; | 572 | $scope.cargando = true; |
| 573 | }; | 573 | }; |
| 574 | 574 | ||
| 575 | $scope.selectFocus = function($event) { | 575 | $scope.selectFocus = function($event) { |
| 576 | $event.target.select(); | 576 | $event.target.select(); |
| 577 | }; | 577 | }; |
| 578 | 578 | ||
| 579 | $scope.salir = function() { | 579 | $scope.salir = function() { |
| 580 | $location.path('/'); | 580 | $location.path('/'); |
| 581 | }; | 581 | }; |
| 582 | 582 | ||
| 583 | $scope.parsearATexto = function(articulo) { | ||
| 584 | articulo.cantidad = parseFloat(articulo.cantidad); | ||
| 585 | articulo.precio = parseFloat(articulo.precio); | ||
| 586 | }; | ||
| 587 | |||
| 583 | function addCabecera(label, valor) { | 588 | function addCabecera(label, valor) { |
| 584 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 589 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 585 | if(propiedad.length === 1) { | 590 | if(propiedad.length === 1) { |
| 586 | propiedad[0].valor = valor; | 591 | propiedad[0].valor = valor; |
| 587 | } else { | 592 | } else { |
| 588 | $scope.cabecera.push({label: label, valor: valor}); | 593 | $scope.cabecera.push({label: label, valor: valor}); |
| 589 | } | 594 | } |
| 590 | } | 595 | } |
| 591 | 596 | ||
| 592 | function removeCabecera(label) { | 597 | function removeCabecera(label) { |
| 593 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 598 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 594 | if(propiedad.length === 1){ | 599 | if(propiedad.length === 1){ |
| 595 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 600 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 596 | } | 601 | } |
| 597 | } | 602 | } |
| 598 | 603 | ||
| 599 | function rellenar(relleno, longitud) { | 604 | function rellenar(relleno, longitud) { |
| 600 | relleno = '' + relleno; | 605 | relleno = '' + relleno; |
| 601 | while (relleno.length < longitud) { | 606 | while (relleno.length < longitud) { |
| 602 | relleno = '0' + relleno; | 607 | relleno = '0' + relleno; |
| 603 | } | 608 | } |
| 604 | 609 | ||
| 605 | return relleno; | 610 | return relleno; |
| 606 | } | 611 | } |
| 607 | } | 612 | } |
| 608 | ] | 613 | ] |
| 609 | ) | 614 | ) |
| 610 | .controller('notaPedidoListaCtrl', [ | 615 | .controller('notaPedidoListaCtrl', [ |
| 611 | '$scope', | 616 | '$scope', |
| 612 | 'crearNotaPedidoService', | 617 | 'crearNotaPedidoService', |
| 613 | '$location', | 618 | '$location', |
| 614 | function($scope, crearNotaPedidoService, $location) { | 619 | function($scope, crearNotaPedidoService, $location) { |
| 615 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 620 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 616 | $scope.notaPedidos = datos.data; | 621 | $scope.notaPedidos = datos.data; |
| 617 | }); | 622 | }); |
| 618 | $scope.editar = function(notaPedido) { | 623 | $scope.editar = function(notaPedido) { |
| 619 | crearNotaPedidoService.setNotaPedido(notaPedido); | 624 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 620 | $location.path('/venta-nota-pedido/abm/'); | 625 | $location.path('/venta-nota-pedido/abm/'); |
| 621 | }; | 626 | }; |
| 622 | $scope.crearPedido = function() { | 627 | $scope.crearPedido = function() { |
| 623 | crearNotaPedidoService.clearNotaPedido(); | 628 | crearNotaPedidoService.clearNotaPedido(); |
| 624 | $location.path('/venta-nota-pedido/abm/'); | 629 | $location.path('/venta-nota-pedido/abm/'); |
| 625 | }; | 630 | }; |
| 626 | } | 631 | } |
| 627 | ]) | 632 | ]) |
| 628 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 633 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 629 | '$scope', | 634 | '$scope', |
| 630 | 'crearNotaPedidoService', | 635 | 'crearNotaPedidoService', |
| 631 | '$location', | 636 | '$location', |
| 632 | function($scope, crearNotaPedidoService, $location) { | 637 | function($scope, crearNotaPedidoService, $location) { |
| 633 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 638 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 634 | $scope.notaPedidos = datos.data; | 639 | $scope.notaPedidos = datos.data; |
| 635 | }); | 640 | }); |
| 636 | $scope.editar = function(notaPedido) { | 641 | $scope.editar = function(notaPedido) { |
| 637 | crearNotaPedidoService.setNotaPedido(notaPedido); | 642 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 638 | $location.path('/venta-nota-pedido/abm/'); | 643 | $location.path('/venta-nota-pedido/abm/'); |
| 639 | }; | 644 | }; |
| 640 | $scope.crearPedido = function() { | 645 | $scope.crearPedido = function() { |
| 641 | crearNotaPedidoService.clearNotaPedido(); | 646 | crearNotaPedidoService.clearNotaPedido(); |
| 642 | $location.path('/venta-nota-pedido/abm/'); | 647 | $location.path('/venta-nota-pedido/abm/'); |
| 643 | }; | 648 | }; |
| 644 | } | 649 | } |
| 645 | ]); | 650 | ]); |
| 646 | 651 |
src/views/nota-pedido.html
| 1 | <div class="crear-nota-pedido"> | 1 | <div class="crear-nota-pedido"> |
| 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> | 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> |
| 3 | <div class="row"> | 3 | <div class="row"> |
| 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> | 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> |
| 5 | <div class="row p-1 panel-informativo"> | 5 | <div class="row p-1 panel-informativo"> |
| 6 | <div class="col-12"> | 6 | <div class="col-12"> |
| 7 | <div class="row"> | 7 | <div class="row"> |
| 8 | <div class="col-12 col-sm-4 nota-pedido"> | 8 | <div class="col-12 col-sm-4 nota-pedido"> |
| 9 | <h5>NOTA DE PEDIDO</h5> | 9 | <h5>NOTA DE PEDIDO</h5> |
| 10 | </div> | 10 | </div> |
| 11 | <div class="col-5 col-sm-4 numero-pedido" | 11 | <div class="col-5 col-sm-4 numero-pedido" |
| 12 | >Nº {{puntoVenta}}-{{comprobante}} | 12 | >Nº {{puntoVenta}}-{{comprobante}} |
| 13 | </div> | 13 | </div> |
| 14 | <div class="col-7 col-sm-4 text-right"> | 14 | <div class="col-7 col-sm-4 text-right"> |
| 15 | Fecha: | 15 | Fecha: |
| 16 | <span | 16 | <span |
| 17 | ng-show="!datepickerAbierto" | 17 | ng-show="!datepickerAbierto" |
| 18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" | 18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" |
| 19 | ng-click="datepickerAbierto = true" | 19 | ng-click="datepickerAbierto = true" |
| 20 | > | 20 | > |
| 21 | </span> | 21 | </span> |
| 22 | <input | 22 | <input |
| 23 | ng-show="datepickerAbierto" | 23 | ng-show="datepickerAbierto" |
| 24 | type="date" | 24 | type="date" |
| 25 | ng-model="now" | 25 | ng-model="now" |
| 26 | ng-change="datepickerAbierto = false" | 26 | ng-change="datepickerAbierto = false" |
| 27 | ng-blur="datepickerAbierto = false" | 27 | ng-blur="datepickerAbierto = false" |
| 28 | class="form-control form-control-sm col-8 float-right" | 28 | class="form-control form-control-sm col-8 float-right" |
| 29 | foca-focus="datepickerAbierto" | 29 | foca-focus="datepickerAbierto" |
| 30 | hasta-hoy | 30 | hasta-hoy |
| 31 | /> | 31 | /> |
| 32 | </div> | 32 | </div> |
| 33 | </div> | 33 | </div> |
| 34 | <div class="row"> | 34 | <div class="row"> |
| 35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | 35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> |
| 36 | <span class="label" ng-bind="cab.label"></span> | 36 | <span class="label" ng-bind="cab.label"></span> |
| 37 | <span class="valor" ng-bind="cab.valor"></span> | 37 | <span class="valor" ng-bind="cab.valor"></span> |
| 38 | </div> | 38 | </div> |
| 39 | <a | 39 | <a |
| 40 | class="btn col-12 btn-secondary d-sm-none" | 40 | class="btn col-12 btn-secondary d-sm-none" |
| 41 | ng-show="cabecera.length > 0" | 41 | ng-show="cabecera.length > 0" |
| 42 | ng-click="showCabecera = !showCabecera" | 42 | ng-click="showCabecera = !showCabecera" |
| 43 | > | 43 | > |
| 44 | <i | 44 | <i |
| 45 | class="fa fa-chevron-down" | 45 | class="fa fa-chevron-down" |
| 46 | ng-hide="showCabecera" | 46 | ng-hide="showCabecera" |
| 47 | aria-hidden="true" | 47 | aria-hidden="true" |
| 48 | > | 48 | > |
| 49 | </i> | 49 | </i> |
| 50 | <i | 50 | <i |
| 51 | class="fa fa-chevron-up" | 51 | class="fa fa-chevron-up" |
| 52 | ng-show="showCabecera" | 52 | ng-show="showCabecera" |
| 53 | aria-hidden="true"> | 53 | aria-hidden="true"> |
| 54 | </i> | 54 | </i> |
| 55 | </a> | 55 | </a> |
| 56 | </div> | 56 | </div> |
| 57 | </div> | 57 | </div> |
| 58 | </div> | 58 | </div> |
| 59 | <div class="row p-1 botonera-secundaria"> | 59 | <div class="row p-1 botonera-secundaria"> |
| 60 | <div class="col-12"> | 60 | <div class="col-12"> |
| 61 | <div class="row"> | 61 | <div class="row"> |
| 62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> | 62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> |
| 63 | <button | 63 | <button |
| 64 | type="button" | 64 | type="button" |
| 65 | class="btn btn-default btn-block btn-xs text-left py-2" | 65 | class="btn btn-default btn-block btn-xs text-left py-2" |
| 66 | ng-click="boton.accion()" | 66 | ng-click="boton.accion()" |
| 67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" | 67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" |
| 68 | > | 68 | > |
| 69 | <i | 69 | <i |
| 70 | class="fa fa-arrow-circle-right" | 70 | class="fa fa-arrow-circle-right" |
| 71 | ng-show="boton.texto != ''" | 71 | ng-show="boton.texto != ''" |
| 72 | ></i> | 72 | ></i> |
| 73 | | 73 | |
| 74 | {{boton.texto}} | 74 | {{boton.texto}} |
| 75 | </button> | 75 | </button> |
| 76 | </div> | 76 | </div> |
| 77 | </div> | 77 | </div> |
| 78 | </div> | 78 | </div> |
| 79 | </div> | 79 | </div> |
| 80 | </div> | 80 | </div> |
| 81 | </div> | 81 | </div> |
| 82 | </form> | 82 | </form> |
| 83 | <div class="row"> | 83 | <div class="row"> |
| 84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
| 85 | <!-- PC --> | 85 | <!-- PC --> |
| 86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
| 87 | <table class="table tabla-articulo table-striped table-sm table-dark"> | 87 | <table class="table tabla-articulo table-striped table-sm table-dark"> |
| 88 | <thead> | 88 | <thead> |
| 89 | <tr class="d-flex"> | 89 | <tr class="d-flex"> |
| 90 | <th class="">#</th> | 90 | <th class="">#</th> |
| 91 | <th class="col">Código</th> | 91 | <th class="col">Código</th> |
| 92 | <th class="col-4">Descripción</th> | 92 | <th class="col-4">Descripción</th> |
| 93 | <th class="col text-right">Cantidad</th> | 93 | <th class="col text-right">Cantidad</th> |
| 94 | <th class="col text-right">Precio Unitario</th> | 94 | <th class="col text-right">Precio Unitario</th> |
| 95 | <th class="col text-right">SubTotal</th> | 95 | <th class="col text-right">SubTotal</th> |
| 96 | <th class="text-right"> | 96 | <th class="text-right"> |
| 97 | <button | 97 | <button |
| 98 | class="btn btn-outline-secondary selectable" | 98 | class="btn btn-outline-secondary selectable" |
| 99 | ng-click="show = !show; masMenos()" | 99 | ng-click="show = !show; masMenos()" |
| 100 | > | 100 | > |
| 101 | <i | 101 | <i |
| 102 | class="fa fa-chevron-down" | 102 | class="fa fa-chevron-down" |
| 103 | ng-show="show" | 103 | ng-show="show" |
| 104 | aria-hidden="true" | 104 | aria-hidden="true" |
| 105 | > | 105 | > |
| 106 | </i> | 106 | </i> |
| 107 | <i | 107 | <i |
| 108 | class="fa fa-chevron-up" | 108 | class="fa fa-chevron-up" |
| 109 | ng-hide="show" | 109 | ng-hide="show" |
| 110 | aria-hidden="true"> | 110 | aria-hidden="true"> |
| 111 | </i> | 111 | </i> |
| 112 | </button> | 112 | </button> |
| 113 | </th> | 113 | </th> |
| 114 | </tr> | 114 | </tr> |
| 115 | </thead> | 115 | </thead> |
| 116 | <tbody class="tabla-articulo-body"> | 116 | <tbody class="tabla-articulo-body"> |
| 117 | <tr | 117 | <tr |
| 118 | ng-repeat="(key, articulo) in articulosTabla" | 118 | ng-repeat="(key, articulo) in articulosTabla" |
| 119 | ng-show="show || key == (articulosTabla.length - 1)" | 119 | ng-show="show || key == (articulosTabla.length - 1)" |
| 120 | class="d-flex" | 120 | class="d-flex" |
| 121 | > | 121 | > |
| 122 | <td ng-bind="key + 1"></td> | 122 | <td ng-bind="key + 1"></td> |
| 123 | <td | 123 | <td |
| 124 | class="col" | 124 | class="col" |
| 125 | ng-bind="articulo.sector + '-' + articulo.codigo" | 125 | ng-bind="articulo.sector + '-' + articulo.codigo" |
| 126 | ></td> | 126 | ></td> |
| 127 | <td | 127 | <td |
| 128 | class="col-4" | 128 | class="col-4" |
| 129 | ng-bind="articulo.descripcion" | 129 | ng-bind="articulo.descripcion" |
| 130 | ></td> | 130 | ></td> |
| 131 | <td class="col text-right"> | 131 | <td class="col text-right"> |
| 132 | <input | 132 | <input |
| 133 | ng-show="articulo.editCantidad" | 133 | ng-show="articulo.editCantidad" |
| 134 | ng-model="articulo.cantidad" | 134 | ng-model="articulo.cantidad" |
| 135 | class="form-control" | 135 | class="form-control" |
| 136 | type="number" | 136 | type="text" |
| 137 | min="1" | ||
| 138 | foca-focus="articulo.editCantidad" | 137 | foca-focus="articulo.editCantidad" |
| 139 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 138 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
| 140 | ng-focus="selectFocus($event)" | 139 | ng-focus="selectFocus($event)" |
| 140 | ng-blur="parsearATexto(articulo)" | ||
| 141 | teclado-virtual | ||
| 141 | > | 142 | > |
| 142 | <i | 143 | <i |
| 143 | class="selectable" | 144 | class="selectable" |
| 144 | ng-click="cambioEdit(articulo, 'cantidad')" | 145 | ng-click="cambioEdit(articulo, 'cantidad')" |
| 145 | ng-hide="articulo.editCantidad" | 146 | ng-hide="articulo.editCantidad" |
| 146 | ng-bind="articulo.cantidad"> | 147 | ng-bind="articulo.cantidad"> |
| 147 | </i> | 148 | </i> |
| 148 | </td> | 149 | </td> |
| 149 | <td class="col text-right"> | 150 | <td class="col text-right"> |
| 150 | <input | 151 | <input |
| 151 | ng-show="articulo.editPrecio" | 152 | ng-show="articulo.editPrecio" |
| 152 | ng-model="articulo.precio" | 153 | ng-model="articulo.precio" |
| 153 | class="form-control" | 154 | class="form-control" |
| 154 | type="number" | 155 | type="text" |
| 155 | min="1" | ||
| 156 | step="0.0001" | ||
| 157 | foca-focus="articulo.editPrecio" | 156 | foca-focus="articulo.editPrecio" |
| 158 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 157 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
| 159 | ng-focus="selectFocus($event)" | 158 | ng-focus="selectFocus($event)" |
| 159 | ng-blur="parsearATexto(articulo)" | ||
| 160 | teclado-virtual | ||
| 160 | > | 161 | > |
| 161 | <i | 162 | <i |
| 162 | class="selectable" | 163 | class="selectable" |
| 163 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | 164 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" |
| 164 | ng-hide="articulo.editPrecio" | 165 | ng-hide="articulo.editPrecio" |
| 165 | ng-bind="articulo.precio | currency: notaPedido.moneda.simbolo : 4"> | 166 | ng-bind="articulo.precio | currency: notaPedido.moneda.simbolo : 4"> |
| 166 | </i> | 167 | </i> |
| 167 | </td> | 168 | </td> |
| 168 | <td | 169 | <td |
| 169 | class="col text-right" | 170 | class="col text-right" |
| 170 | ng-bind="(articulo.precio * articulo.cantidad) | currency: notaPedido.moneda.simbolo"> | 171 | ng-bind="(articulo.precio * articulo.cantidad) | currency: notaPedido.moneda.simbolo"> |
| 171 | </td> | 172 | </td> |
| 172 | <td class="text-center"> | 173 | <td class="text-center"> |
| 173 | <button | 174 | <button |
| 174 | class="btn btn-outline-secondary" | 175 | class="btn btn-outline-secondary" |
| 175 | ng-click="quitarArticulo(key)" | 176 | ng-click="quitarArticulo(key)" |
| 176 | > | 177 | > |
| 177 | <i class="fa fa-trash"></i> | 178 | <i class="fa fa-trash"></i> |
| 178 | </button> | 179 | </button> |
| 179 | </td> | 180 | </td> |
| 180 | </tr> | 181 | </tr> |
| 181 | </tbody> | 182 | </tbody> |
| 182 | <tfoot> | 183 | <tfoot> |
| 183 | <tr ng-show="!cargando" class="d-flex"> | 184 | <tr ng-show="!cargando" class="d-flex"> |
| 184 | <td | 185 | <td |
| 185 | class="align-middle" | 186 | class="align-middle" |
| 186 | ng-bind="articulosTabla.length + 1" | 187 | ng-bind="articulosTabla.length + 1" |
| 187 | ></td> | 188 | ></td> |
| 188 | <td class="col"> | 189 | <td class="col"> |
| 189 | <input | 190 | <input |
| 190 | class="form-control" | 191 | class="form-control" |
| 191 | ng-model="articuloACargar.sectorCodigo" | 192 | ng-model="articuloACargar.sectorCodigo" |
| 192 | readonly | 193 | readonly |
| 193 | > | 194 | > |
| 194 | </td> | 195 | </td> |
| 195 | <td class="col-4 tabla-articulo-descripcion"> | 196 | <td class="col-4 tabla-articulo-descripcion"> |
| 196 | <input | 197 | <input |
| 197 | class="form-control" | 198 | class="form-control" |
| 198 | ng-model="articuloACargar.descripcion" | 199 | ng-model="articuloACargar.descripcion" |
| 199 | readonly | 200 | readonly |
| 200 | > | 201 | > |
| 201 | </td> | 202 | </td> |
| 202 | <td class="col text-right"> | 203 | <td class="col text-right"> |
| 203 | <input | 204 | <input |
| 204 | class="form-control" | 205 | class="form-control" |
| 205 | type="number" | 206 | type="text" |
| 206 | min="1" | ||
| 207 | ng-model="articuloACargar.cantidad" | 207 | ng-model="articuloACargar.cantidad" |
| 208 | foca-focus="!cargando" | 208 | foca-focus="!cargando" |
| 209 | esc-key="resetFilter()" | 209 | esc-key="resetFilter()" |
| 210 | ng-keypress="agregarATabla($event.keyCode)" | 210 | ng-keypress="agregarATabla($event.keyCode)" |
| 211 | ng-blur="parsearATexto(articuloACargar)" | ||
| 212 | teclado-virtual | ||
| 211 | > | 213 | > |
| 212 | </td> | 214 | </td> |
| 213 | <td class="col text-right"> | 215 | <td class="col text-right"> |
| 214 | <input | 216 | <input |
| 215 | class="form-control" | 217 | class="form-control" |
| 216 | ng-value="articuloACargar.precio | currency: notaPedido.moneda.simbolo : 4" | 218 | ng-value="articuloACargar.precio | currency: notaPedido.moneda.simbolo : 4" |
| 217 | ng-show="idLista != -1" | 219 | ng-show="idLista != -1" |
| 218 | readonly | 220 | readonly |
| 219 | > | 221 | > |
| 220 | <input | 222 | <input |
| 221 | class="form-control" | 223 | class="form-control" |
| 222 | type="number" | 224 | type="text" |
| 223 | step="0.0001" | ||
| 224 | ng-model="articuloACargar.precio" | 225 | ng-model="articuloACargar.precio" |
| 225 | esc-key="resetFilter()" | 226 | esc-key="resetFilter()" |
| 226 | ng-keypress="agregarATabla($event.keyCode)" | 227 | ng-keypress="agregarATabla($event.keyCode)" |
| 227 | ng-show="idLista == -1" | 228 | ng-show="idLista == -1" |
| 229 | ng-blur="parsearATexto(articuloACargar)" | ||
| 230 | teclado-virtual | ||
| 228 | > | 231 | > |
| 229 | </td> | 232 | </td> |
| 230 | <td class="col text-right"> | 233 | <td class="col text-right"> |
| 231 | <input | 234 | <input |
| 232 | class="form-control" | 235 | class="form-control" |
| 233 | ng-value="getSubTotal() | currency: notaPedido.moneda.simbolo" | 236 | ng-value="getSubTotal() | currency: notaPedido.moneda.simbolo" |
| 234 | readonly | 237 | readonly |
| 235 | ></td> | 238 | ></td> |
| 236 | <td class="text-center align-middle"> | 239 | <td class="text-center align-middle"> |
| 237 | <button | 240 | <button |
| 238 | class="btn btn-outline-secondary" | 241 | class="btn btn-outline-secondary" |
| 239 | ng-click="agregarATabla(13)" | 242 | ng-click="agregarATabla(13)" |
| 240 | > | 243 | > |
| 241 | <i class="fa fa-save"></i> | 244 | <i class="fa fa-save"></i> |
| 242 | </button> | 245 | </button> |
| 243 | </td> | 246 | </td> |
| 244 | </tr> | 247 | </tr> |
| 245 | <tr ng-show="cargando" class="d-flex"> | 248 | <tr ng-show="cargando" class="d-flex"> |
| 246 | <td colspan="7" class="col-12"> | 249 | <td colspan="7" class="col-12"> |
| 247 | <input | 250 | <input |
| 248 | placeholder="Seleccione Articulo" | 251 | placeholder="Seleccione Articulo" |
| 249 | class="form-control form-control-sm" | 252 | class="form-control form-control-sm" |
| 250 | readonly | 253 | readonly |
| 251 | ng-click="seleccionarArticulo()" | 254 | ng-click="seleccionarArticulo()" |
| 252 | /> | 255 | /> |
| 253 | </td> | 256 | </td> |
| 254 | </tr> | 257 | </tr> |
| 255 | <tr class="d-flex"> | 258 | <tr class="d-flex"> |
| 256 | <td colspan="4" class="no-border-top"> | 259 | <td colspan="4" class="no-border-top"> |
| 257 | <strong>Items:</strong> | 260 | <strong>Items:</strong> |
| 258 | <a ng-bind="articulosTabla.length"></a> | 261 | <a ng-bind="articulosTabla.length"></a> |
| 259 | </td> | 262 | </td> |
| 260 | <td class="text-right ml-auto table-celda-total no-border-top"> | 263 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 261 | <h3>Total:</h3> | 264 | <h3>Total:</h3> |
| 262 | </td> | 265 | </td> |
| 263 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 266 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
| 264 | <h3>{{getTotal() | currency: notaPedido.moneda.simbolo}}</h3> | 267 | <h3>{{getTotal() | currency: notaPedido.moneda.simbolo}}</h3> |
| 265 | </td> | 268 | </td> |
| 266 | <td class="text-right no-border-top"> | 269 | <td class="text-right no-border-top"> |
| 267 | <button | 270 | <button |
| 268 | type="button" | 271 | type="button" |
| 269 | class="btn btn-default btn-sm" | 272 | class="btn btn-default btn-sm" |
| 270 | > | 273 | > |
| 271 | Totales | 274 | Totales |
| 272 | </button> | 275 | </button> |
| 273 | </td> | 276 | </td> |
| 274 | </tr> | 277 | </tr> |
| 275 | </tfoot> | 278 | </tfoot> |
| 276 | </table> | 279 | </table> |
| 277 | </div> | 280 | </div> |
| 278 | 281 | ||
| 279 | <!-- MOBILE --> | 282 | <!-- MOBILE --> |
| 280 | <div class="row d-sm-none"> | 283 | <div class="row d-sm-none"> |
| 281 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> | 284 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> |
| 282 | <thead> | 285 | <thead> |
| 283 | <tr class="d-flex"> | 286 | <tr class="d-flex"> |
| 284 | <th class="">#</th> | 287 | <th class="">#</th> |
| 285 | <th class="col px-0"> | 288 | <th class="col px-0"> |
| 286 | <div class="d-flex"> | 289 | <div class="d-flex"> |
| 287 | <div class="col-4 px-1">Código</div> | 290 | <div class="col-4 px-1">Código</div> |
| 288 | <div class="col-8 px-1">Descripción</div> | 291 | <div class="col-8 px-1">Descripción</div> |
| 289 | </div> | 292 | </div> |
| 290 | <div class="d-flex"> | 293 | <div class="d-flex"> |
| 291 | <div class="col-3 px-1">Cantidad</div> | 294 | <div class="col-3 px-1">Cantidad</div> |
| 292 | <div class="col px-1 text-right">P. Uni.</div> | 295 | <div class="col px-1 text-right">P. Uni.</div> |
| 293 | <div class="col px-1 text-right">Subtotal</div> | 296 | <div class="col px-1 text-right">Subtotal</div> |
| 294 | </div> | 297 | </div> |
| 295 | </th> | 298 | </th> |
| 296 | <th class="text-center tamaño-boton"> | 299 | <th class="text-center tamaño-boton"> |
| 297 | | 300 | |
| 298 | </th> | 301 | </th> |
| 299 | </tr> | 302 | </tr> |
| 300 | </thead> | 303 | </thead> |
| 301 | <tbody> | 304 | <tbody> |
| 302 | <tr | 305 | <tr |
| 303 | ng-repeat="(key, articulo) in articulosTabla" | 306 | ng-repeat="(key, articulo) in articulosTabla" |
| 304 | ng-show="show || key == articulosTabla.length - 1" | 307 | ng-show="show || key == articulosTabla.length - 1" |
| 305 | > | 308 | > |
| 306 | <td class="w-100 align-middle d-flex p-0"> | 309 | <td class="w-100 align-middle d-flex p-0"> |
| 307 | <div class="align-middle p-1"> | 310 | <div class="align-middle p-1"> |
| 308 | <span ng-bind="key+1" class="align-middle"></span> | 311 | <span ng-bind="key+1" class="align-middle"></span> |
| 309 | </div> | 312 | </div> |
| 310 | <div class="col px-0"> | 313 | <div class="col px-0"> |
| 311 | <div class="d-flex"> | 314 | <div class="d-flex"> |
| 312 | <div class="col-4 px-1"> | 315 | <div class="col-4 px-1"> |
| 313 | <span | 316 | <span |
| 314 | ng-bind="articulo.sector + '-' + articulo.codigo" | 317 | ng-bind="articulo.sector + '-' + articulo.codigo" |
| 315 | ></span> | 318 | ></span> |
| 316 | </div> | 319 | </div> |
| 317 | <div class="col-8 px-1"> | 320 | <div class="col-8 px-1"> |
| 318 | <span ng-bind="articulo.descripcion"></span> | 321 | <span ng-bind="articulo.descripcion"></span> |
| 319 | </div> | 322 | </div> |
| 320 | </div> | 323 | </div> |
| 321 | <div class="d-flex"> | 324 | <div class="d-flex"> |
| 322 | <div class="col-3 px-1"> | 325 | <div class="col-3 px-1"> |
| 323 | <span ng-bind="'x' + articulo.cantidad"></span> | 326 | <span ng-bind="'x' + articulo.cantidad"></span> |
| 324 | </div> | 327 | </div> |
| 325 | <div class="col-3 px-1 text-right"> | 328 | <div class="col-3 px-1 text-right"> |
| 326 | <span ng-bind="articulo.precio | currency: notaPedido.moneda.simbolo : 4"></span> | 329 | <span ng-bind="articulo.precio | currency: notaPedido.moneda.simbolo : 4"></span> |
| 327 | </div> | 330 | </div> |
| 328 | <div class="col px-1 text-right"> | 331 | <div class="col px-1 text-right"> |
| 329 | <span | 332 | <span |
| 330 | ng-bind="(articulo.precio * articulo.cantidad) | currency: notaPedido.moneda.simbolo" | 333 | ng-bind="(articulo.precio * articulo.cantidad) | currency: notaPedido.moneda.simbolo" |
| 331 | > | 334 | > |
| 332 | </span> | 335 | </span> |
| 333 | </div> | 336 | </div> |
| 334 | </div> | 337 | </div> |
| 335 | </div> | 338 | </div> |
| 336 | <div class="align-middle p-1"> | 339 | <div class="align-middle p-1"> |
| 337 | <button | 340 | <button |
| 338 | class="btn btn-outline-secondary" | 341 | class="btn btn-outline-secondary" |
| 339 | ng-click="quitarArticulo(key)" | 342 | ng-click="quitarArticulo(key)" |
| 340 | > | 343 | > |
| 341 | <i class="fa fa-trash"></i> | 344 | <i class="fa fa-trash"></i> |
| 342 | </button> | 345 | </button> |
| 343 | </div> | 346 | </div> |
| 344 | </td> | 347 | </td> |
| 345 | </tr> | 348 | </tr> |
| 346 | </tbody> | 349 | </tbody> |
| 347 | <tfoot> | 350 | <tfoot> |
| 348 | <!-- CARGANDO ITEM --> | 351 | <!-- CARGANDO ITEM --> |
| 349 | <tr ng-show="!cargando" class="d-flex"> | 352 | <tr ng-show="!cargando" class="d-flex"> |
| 350 | <td | 353 | <td |
| 351 | class="align-middle p-1" | 354 | class="align-middle p-1" |
| 352 | ng-bind="articulosTabla.length + 1" | 355 | ng-bind="articulosTabla.length + 1" |
| 353 | ></td> | 356 | ></td> |
| 354 | <td class="col p-0"> | 357 | <td class="col p-0"> |
| 355 | <div class="d-flex"> | 358 | <div class="d-flex"> |
| 356 | <div class="col-4 px-1"> | 359 | <div class="col-4 px-1"> |
| 357 | <span | 360 | <span |
| 358 | ng-bind="articuloACargar.sectorCodigo" | 361 | ng-bind="articuloACargar.sectorCodigo" |
| 359 | ></span> | 362 | ></span> |
| 360 | </div> | 363 | </div> |
| 361 | <div class="col-8 px-1"> | 364 | <div class="col-8 px-1"> |
| 362 | <span ng-bind="articuloACargar.descripcion"></span> | 365 | <span ng-bind="articuloACargar.descripcion"></span> |
| 363 | </div> | 366 | </div> |
| 364 | </div> | 367 | </div> |
| 365 | <div class="d-flex"> | 368 | <div class="d-flex"> |
| 366 | <div class="col-3 px-1 m-1"> | 369 | <div class="col-3 px-1 m-1"> |
| 367 | <input | 370 | <input |
| 368 | class="form-control p-1" | 371 | class="form-control p-1" |
| 369 | type="number" | 372 | type="number" |
| 370 | min="1" | 373 | min="1" |
| 371 | ng-model="articuloACargar.cantidad" | 374 | ng-model="articuloACargar.cantidad" |
| 372 | foca-focus="!cargando" | 375 | foca-focus="!cargando" |
| 373 | ng-keypress="agregarATabla($event.keyCode)" | 376 | ng-keypress="agregarATabla($event.keyCode)" |
| 374 | style="height: auto; line-height: 1.1em" | 377 | style="height: auto; line-height: 1.1em" |
| 375 | > | 378 | > |
| 376 | </div> | 379 | </div> |
| 377 | <div class="col-3 px-1 text-right"> | 380 | <div class="col-3 px-1 text-right"> |
| 378 | <span ng-bind="articuloACargar.precio | currency: notaPedido.moneda.simbolo : 4"></span> | 381 | <span ng-bind="articuloACargar.precio | currency: notaPedido.moneda.simbolo : 4"></span> |
| 379 | </div> | 382 | </div> |
| 380 | <div class="col px-1 text-right"> | 383 | <div class="col px-1 text-right"> |
| 381 | <span | 384 | <span |
| 382 | ng-bind="getSubTotal() | currency: notaPedido.moneda.simbolo" | 385 | ng-bind="getSubTotal() | currency: notaPedido.moneda.simbolo" |
| 383 | > | 386 | > |
| 384 | </span> | 387 | </span> |
| 385 | </div> | 388 | </div> |
| 386 | </div> | 389 | </div> |
| 387 | </td> | 390 | </td> |
| 388 | <td class="text-center align-middle"> | 391 | <td class="text-center align-middle"> |
| 389 | <button | 392 | <button |
| 390 | class="btn btn-outline-secondary" | 393 | class="btn btn-outline-secondary" |
| 391 | ng-click="agregarATabla(13)" | 394 | ng-click="agregarATabla(13)" |
| 392 | > | 395 | > |
| 393 | <i class="fa fa-save"></i> | 396 | <i class="fa fa-save"></i> |
| 394 | </button> | 397 | </button> |
| 395 | </td> | 398 | </td> |
| 396 | </tr> | 399 | </tr> |
| 397 | <!-- SELECCIONAR PRODUCTO --> | 400 | <!-- SELECCIONAR PRODUCTO --> |
| 398 | <tr ng-show="cargando" class="d-flex"> | 401 | <tr ng-show="cargando" class="d-flex"> |
| 399 | <td class="col-12"> | 402 | <td class="col-12"> |
| 400 | <input | 403 | <input |
| 401 | placeholder="Seleccione Articulo" | 404 | placeholder="Seleccione Articulo" |
| 402 | class="form-control form-control-sm" | 405 | class="form-control form-control-sm" |
| 403 | readonly | 406 | readonly |
| 404 | ng-click="seleccionarArticulo()" | 407 | ng-click="seleccionarArticulo()" |
| 405 | /> | 408 | /> |
| 406 | </td> | 409 | </td> |
| 407 | </tr> | 410 | </tr> |
| 408 | <!-- TOOGLE EXPANDIR --> | 411 | <!-- TOOGLE EXPANDIR --> |
| 409 | <tr> | 412 | <tr> |
| 410 | <td class="col"> | 413 | <td class="col"> |
| 411 | <button | 414 | <button |
| 412 | class="btn btn-outline-secondary selectable w-100" | 415 | class="btn btn-outline-secondary selectable w-100" |
| 413 | ng-click="show = !show; masMenos()" | 416 | ng-click="show = !show; masMenos()" |
| 414 | ng-show="articulosTabla.length > 0" | 417 | ng-show="articulosTabla.length > 0" |
| 415 | > | 418 | > |
| 416 | <i | 419 | <i |
| 417 | class="fa fa-chevron-down" | 420 | class="fa fa-chevron-down" |
| 418 | ng-hide="show" | 421 | ng-hide="show" |
| 419 | aria-hidden="true" | 422 | aria-hidden="true" |
| 420 | > | 423 | > |
| 421 | </i> | 424 | </i> |
| 422 | <i | 425 | <i |
| 423 | class="fa fa-chevron-up" | 426 | class="fa fa-chevron-up" |
| 424 | ng-show="show" | 427 | ng-show="show" |
| 425 | aria-hidden="true"> | 428 | aria-hidden="true"> |
| 426 | </i> | 429 | </i> |
| 427 | </button> | 430 | </button> |
| 428 | </td> | 431 | </td> |
| 429 | </tr> | 432 | </tr> |
| 430 | <!-- FOOTER --> | 433 | <!-- FOOTER --> |
| 431 | <tr class="d-flex"> | 434 | <tr class="d-flex"> |
| 432 | <td class="align-middle no-border-top" colspan="2"> | 435 | <td class="align-middle no-border-top" colspan="2"> |
| 433 | <strong>Cantidad Items:</strong> | 436 | <strong>Cantidad Items:</strong> |
| 434 | <a ng-bind="articulosTabla.length"></a> | 437 | <a ng-bind="articulosTabla.length"></a> |
| 435 | </td> | 438 | </td> |
| 436 | <td class="text-right ml-auto table-celda-total no-border-top"> | 439 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 437 | <h3>Total:</h3> | 440 | <h3>Total:</h3> |
| 438 | </td> | 441 | </td> |
| 439 | <td class="table-celda-total text-right no-border-top"> | 442 | <td class="table-celda-total text-right no-border-top"> |
| 440 | <h3>{{getTotal() | currency: notaPedido.moneda.simbolo}}</h3> | 443 | <h3>{{getTotal() | currency: notaPedido.moneda.simbolo}}</h3> |
| 441 | </td> | 444 | </td> |
| 442 | </tr> | 445 | </tr> |
| 443 | </tfoot> | 446 | </tfoot> |
| 444 | </table> | 447 | </table> |
| 445 | </div> | 448 | </div> |
| 446 | </div> | 449 | </div> |
| 447 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> | 450 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> |
| 448 | <div class="row align-items-end"> | 451 | <div class="row align-items-end"> |
| 449 | <div class="col-12"> | 452 | <div class="col-12"> |
| 450 | <button | 453 | <button |
| 451 | ng-click="crearNotaPedido()" | 454 | ng-click="crearNotaPedido()" |
| 452 | type="submit" | 455 | type="submit" |
| 453 | title="Crear nota pedido" | 456 | title="Crear nota pedido" |
| 454 | class="btn btn-default btn-block mb-2"> | 457 | class="btn btn-default btn-block mb-2"> |
| 455 | Guardar | 458 | Guardar |
| 456 | </button> | 459 | </button> |
| 457 | <button | 460 | <button |
| 458 | ng-click="salir()" | 461 | ng-click="salir()" |
| 459 | type="button" | 462 | type="button" |
| 460 | title="Salir" | 463 | title="Salir" |
| 461 | class="btn btn-default btn-block"> | 464 | class="btn btn-default btn-block"> |
| 462 | Salir | 465 | Salir |
| 463 | </button> | 466 | </button> |
| 464 | </div> | 467 | </div> |
| 465 | </div> | 468 | </div> |
| 466 | </div> | 469 | </div> |
| 467 | </div> | 470 | </div> |
| 468 | <div class="row d-md-none fixed-bottom"> | 471 | <div class="row d-md-none fixed-bottom"> |
| 469 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 472 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
| 470 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 473 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |