Commit ee8ec706d225f26dfa2795fe6fdb5f79c4b53075
1 parent
d1dceaf34b
Exists in
master
and in
1 other branch
implementación domicilio
Showing
3 changed files
with
23 additions
and
2 deletions
Show diff stats
index.html
| 1 | <html ng-app="focaCrearNotaPedido"> | 1 | <html ng-app="focaCrearNotaPedido"> |
| 2 | <head> | 2 | <head> |
| 3 | <meta charset="UTF-8"/> | 3 | <meta charset="UTF-8"/> |
| 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 5 | 5 | ||
| 6 | <!--CSS--> | 6 | <!--CSS--> |
| 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> |
| 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> |
| 9 | 9 | ||
| 10 | <!--VENDOR JS--> | 10 | <!--VENDOR JS--> |
| 11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
| 12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
| 13 | <script src="node_modules/angular/angular.min.js"></script> | 13 | <script src="node_modules/angular/angular.min.js"></script> |
| 14 | <script src="node_modules/angular-route/angular-route.min.js"></script> | 14 | <script src="node_modules/angular-route/angular-route.min.js"></script> |
| 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
| 16 | 16 | ||
| 17 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 17 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
| 18 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> | 18 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> |
| 19 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> | 19 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> |
| 20 | <script src="node_modules/foca-modal-petroleras/dist/foca-modal-petroleras.min.js"></script> | 20 | <script src="node_modules/foca-modal-petroleras/dist/foca-modal-petroleras.min.js"></script> |
| 21 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> | 21 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> |
| 22 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> | 22 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> |
| 23 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> | 23 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> |
| 24 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | 24 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
| 25 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> | ||
| 25 | 26 | ||
| 26 | <script src="src/js/app.js"></script> | 27 | <script src="src/js/app.js"></script> |
| 27 | <script src="src/js/controller.js"></script> | 28 | <script src="src/js/controller.js"></script> |
| 28 | <script src="src/js/service.js"></script> | 29 | <script src="src/js/service.js"></script> |
| 29 | <script src="src/js/route.js"></script> | 30 | <script src="src/js/route.js"></script> |
| 30 | 31 | ||
| 31 | <script src="src/etc/develop.js"></script> | 32 | <script src="src/etc/develop.js"></script> |
| 32 | </head> | 33 | </head> |
| 33 | <body> | 34 | <body> |
| 34 | <div ng-view class="container-fluid"></div> | 35 | <div ng-view class="container-fluid"></div> |
| 35 | </body> | 36 | </body> |
| 36 | </html> | 37 | </html> |
| 37 | 38 |
src/js/app.js
| 1 | angular.module('focaCrearNotaPedido', [ | 1 | angular.module('focaCrearNotaPedido', [ |
| 2 | 'ngRoute', | 2 | 'ngRoute', |
| 3 | 'ui.bootstrap', | 3 | 'ui.bootstrap', |
| 4 | 'focaModalVendedores', | 4 | 'focaModalVendedores', |
| 5 | 'focaBusquedaProductos', | 5 | 'focaBusquedaProductos', |
| 6 | 'focaModalPetroleras', | 6 | 'focaModalPetroleras', |
| 7 | 'focaBusquedaCliente', | 7 | 'focaBusquedaCliente', |
| 8 | 'focaModalPrecioCondicion', | 8 | 'focaModalPrecioCondicion', |
| 9 | 'focaModalFlete', | 9 | 'focaModalFlete', |
| 10 | 'focaDirectivas', | 10 | 'focaDirectivas', |
| 11 | 'focaModal' | 11 | 'focaModal', |
| 12 | 'focaModalDomicilio' | ||
| 12 | ]); | 13 | ]); |
| 13 | 14 |
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', | 3 | '$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', |
| 4 | function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { | 4 | function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { |
| 5 | $scope.botonera = [ | 5 | $scope.botonera = [ |
| 6 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 6 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
| 7 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 7 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
| 8 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 8 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
| 9 | { | 9 | { |
| 10 | texto: 'Precios y condiciones', | 10 | texto: 'Precios y condiciones', |
| 11 | accion: function() {$scope.abrirModalListaPrecio();}}, | 11 | accion: function() {$scope.abrirModalListaPrecio();}}, |
| 12 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 12 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
| 13 | {texto: 'Bomba', accion: function() {}}, | 13 | {texto: 'Bomba', accion: function() {}}, |
| 14 | {texto: 'Detalle', accion: function() {}}, | 14 | {texto: 'Detalle', accion: function() {}}, |
| 15 | {texto: 'Totales', accion: function() {}} | 15 | {texto: 'Totales', accion: function() {}} |
| 16 | ]; | 16 | ]; |
| 17 | 17 | ||
| 18 | $scope.show = false; | 18 | $scope.show = false; |
| 19 | $scope.cargando = true; | 19 | $scope.cargando = true; |
| 20 | $scope.dateOptions = { | 20 | $scope.dateOptions = { |
| 21 | maxDate: new Date(), | 21 | maxDate: new Date(), |
| 22 | minDate: new Date(2010, 0, 1) | 22 | minDate: new Date(2010, 0, 1) |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | $scope.notaPedido = { | 25 | $scope.notaPedido = { |
| 26 | vendedor: {}, | 26 | vendedor: {}, |
| 27 | cliente: {}, | 27 | cliente: {}, |
| 28 | domicilio: {dom: ''}, | 28 | domicilio: {dom: ''}, |
| 29 | moneda: {detalle: ''} | 29 | moneda: {detalle: ''} |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | $scope.cabecera = []; | 32 | $scope.cabecera = []; |
| 33 | 33 | ||
| 34 | $scope.now = new Date(); | 34 | $scope.now = new Date(); |
| 35 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 35 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
| 36 | $scope.comprobante = Math.round(Math.random() * 1000000); | 36 | $scope.comprobante = Math.round(Math.random() * 1000000); |
| 37 | 37 | ||
| 38 | $scope.articulosTabla = []; | 38 | $scope.articulosTabla = []; |
| 39 | var idLista; | 39 | var idLista; |
| 40 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 40 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 41 | crearNotaPedidoService.getPrecioCondicion().then( | 41 | crearNotaPedidoService.getPrecioCondicion().then( |
| 42 | function(res) { | 42 | function(res) { |
| 43 | $scope.precioCondiciones = res.data; | 43 | $scope.precioCondiciones = res.data; |
| 44 | } | 44 | } |
| 45 | ); | 45 | ); |
| 46 | if (notaPedidoTemp !== undefined) { | 46 | if (notaPedidoTemp !== undefined) { |
| 47 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 47 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 48 | $scope.notaPedido = notaPedidoTemp; | 48 | $scope.notaPedido = notaPedidoTemp; |
| 49 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 49 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 50 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 50 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 51 | idLista = $scope.notaPedido.precioCondicion; | 51 | idLista = $scope.notaPedido.precioCondicion; |
| 52 | crearNotaPedidoService | 52 | crearNotaPedidoService |
| 53 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 53 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 54 | function(res) { | 54 | function(res) { |
| 55 | $scope.articulosTabla = res.data; | 55 | $scope.articulosTabla = res.data; |
| 56 | } | 56 | } |
| 57 | ); | 57 | ); |
| 58 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 58 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 59 | //(NO REQUERIDO EN ESTA VERSION) | 59 | //(NO REQUERIDO EN ESTA VERSION) |
| 60 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 60 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 61 | // function(res) { | 61 | // function(res) { |
| 62 | // $scope.notaPedido.domicilio = res.data; | 62 | // $scope.notaPedido.domicilio = res.data; |
| 63 | // } | 63 | // } |
| 64 | // ); | 64 | // ); |
| 65 | } else { | 65 | } else { |
| 66 | $scope.notaPedido.fechaCarga = new Date(); | 66 | $scope.notaPedido.fechaCarga = new Date(); |
| 67 | $scope.notaPedido.bomba = '0'; | 67 | $scope.notaPedido.bomba = '0'; |
| 68 | $scope.notaPedido.flete = '0'; | 68 | $scope.notaPedido.flete = '0'; |
| 69 | idLista = undefined; | 69 | idLista = undefined; |
| 70 | } | 70 | } |
| 71 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 71 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 72 | // $scope.addNewDom = function() { | 72 | // $scope.addNewDom = function() { |
| 73 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 73 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 74 | // }; | 74 | // }; |
| 75 | // $scope.removeNewChoice = function(choice) { | 75 | // $scope.removeNewChoice = function(choice) { |
| 76 | // if ($scope.notaPedido.domicilio.length > 1) { | 76 | // if ($scope.notaPedido.domicilio.length > 1) { |
| 77 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 77 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 78 | // function(c) { | 78 | // function(c) { |
| 79 | // return c.$$hashKey === choice.$$hashKey; | 79 | // return c.$$hashKey === choice.$$hashKey; |
| 80 | // } | 80 | // } |
| 81 | // ), 1); | 81 | // ), 1); |
| 82 | // } | 82 | // } |
| 83 | // }; | 83 | // }; |
| 84 | $scope.crearNotaPedido = function() { | 84 | $scope.crearNotaPedido = function() { |
| 85 | if($scope.articulosTabla.length === 0) { | 85 | if($scope.articulosTabla.length === 0) { |
| 86 | focaModalService.alert('Debe cargar almenos un articulo'); | 86 | focaModalService.alert('Debe cargar almenos un articulo'); |
| 87 | return; | 87 | return; |
| 88 | } | 88 | } |
| 89 | if($scope.notaPedido.domicilio.id === undefined) { | 89 | if($scope.notaPedido.domicilio.id === undefined) { |
| 90 | $scope.notaPedido.domicilio.id = 0; | 90 | $scope.notaPedido.domicilio.id = 0; |
| 91 | } | 91 | } |
| 92 | var date = new Date(); | 92 | var date = new Date(); |
| 93 | var notaPedido = { | 93 | var notaPedido = { |
| 94 | id: 0, | 94 | id: 0, |
| 95 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 95 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 96 | .toISOString().slice(0, 19).replace('T', ' '), | 96 | .toISOString().slice(0, 19).replace('T', ' '), |
| 97 | vendedor: $scope.notaPedido.vendedor.nombre, | 97 | vendedor: $scope.notaPedido.vendedor.nombre, |
| 98 | idCliente: $scope.notaPedido.cliente.id, | 98 | idCliente: $scope.notaPedido.cliente.id, |
| 99 | domicilio: $scope.notaPedido.domicilio, | 99 | domicilio: $scope.notaPedido.domicilio, |
| 100 | precioCondicion: $scope.notaPedido.precioCondicion, | 100 | precioCondicion: $scope.notaPedido.precioCondicion, |
| 101 | bomba: $scope.notaPedido.bomba, | 101 | bomba: $scope.notaPedido.bomba, |
| 102 | flete: $scope.notaPedido.flete, | 102 | flete: $scope.notaPedido.flete, |
| 103 | total: $scope.getTotal() | 103 | total: $scope.getTotal() |
| 104 | }; | 104 | }; |
| 105 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 105 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 106 | function(data) { | 106 | function(data) { |
| 107 | focaModalService.alert('Nota pedido creada'); | 107 | focaModalService.alert('Nota pedido creada'); |
| 108 | if($scope.notaPedido.flete === 1) { | 108 | if($scope.notaPedido.flete === 1) { |
| 109 | var flete = { | 109 | var flete = { |
| 110 | idNotaPedido: data.data.id, | 110 | idNotaPedido: data.data.id, |
| 111 | idTransportista: $scope.notaPedido.fleteId, | 111 | idTransportista: $scope.notaPedido.fleteId, |
| 112 | idChofer: $scope.notaPedido.chofer.id, | 112 | idChofer: $scope.notaPedido.chofer.id, |
| 113 | idVehiculo: $scope.notaPedido.vehiculo.id, | 113 | idVehiculo: $scope.notaPedido.vehiculo.id, |
| 114 | kilometros: $scope.notaPedido.kilometros, | 114 | kilometros: $scope.notaPedido.kilometros, |
| 115 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 115 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
| 116 | }; | 116 | }; |
| 117 | crearNotaPedidoService.crearFlete(flete); | 117 | crearNotaPedidoService.crearFlete(flete); |
| 118 | } | 118 | } |
| 119 | var articulosNotaPedido = $scope.articulosTabla; | 119 | var articulosNotaPedido = $scope.articulosTabla; |
| 120 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 120 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
| 121 | delete articulosNotaPedido[i].edit; | 121 | delete articulosNotaPedido[i].edit; |
| 122 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 122 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
| 123 | crearNotaPedidoService | 123 | crearNotaPedidoService |
| 124 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 124 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
| 125 | } | 125 | } |
| 126 | $scope.limpiarPantalla(); | 126 | $scope.limpiarPantalla(); |
| 127 | } | 127 | } |
| 128 | ); | 128 | ); |
| 129 | }; | 129 | }; |
| 130 | 130 | ||
| 131 | $scope.seleccionarArticulo = function() { | 131 | $scope.seleccionarArticulo = function() { |
| 132 | if (idLista === undefined) { | 132 | if (idLista === undefined) { |
| 133 | focaModalService.alert( | 133 | focaModalService.alert( |
| 134 | 'Primero seleccione una lista de precio y condicion'); | 134 | 'Primero seleccione una lista de precio y condicion'); |
| 135 | return; | 135 | return; |
| 136 | } | 136 | } |
| 137 | var modalInstance = $uibModal.open( | 137 | var modalInstance = $uibModal.open( |
| 138 | { | 138 | { |
| 139 | ariaLabelledBy: 'Busqueda de Productos', | 139 | ariaLabelledBy: 'Busqueda de Productos', |
| 140 | templateUrl: 'modal-busqueda-productos.html', | 140 | templateUrl: 'modal-busqueda-productos.html', |
| 141 | controller: 'modalBusquedaProductosCtrl', | 141 | controller: 'modalBusquedaProductosCtrl', |
| 142 | resolve: { idLista: function() { return idLista; } }, | 142 | resolve: { idLista: function() { return idLista; } }, |
| 143 | size: 'lg' | 143 | size: 'lg' |
| 144 | } | 144 | } |
| 145 | ); | 145 | ); |
| 146 | modalInstance.result.then( | 146 | modalInstance.result.then( |
| 147 | function(producto) { | 147 | function(producto) { |
| 148 | var newArt = | 148 | var newArt = |
| 149 | { | 149 | { |
| 150 | id: 0, | 150 | id: 0, |
| 151 | codigo: producto.codigo, | 151 | codigo: producto.codigo, |
| 152 | sector: producto.sector, | 152 | sector: producto.sector, |
| 153 | descripcion: producto.descripcion, | 153 | descripcion: producto.descripcion, |
| 154 | item: $scope.articulosTabla.length + 1, | 154 | item: $scope.articulosTabla.length + 1, |
| 155 | nombre: producto.descripcion, | 155 | nombre: producto.descripcion, |
| 156 | precio: producto.precio.toFixed(2), | 156 | precio: producto.precio.toFixed(2), |
| 157 | costoUnitario: producto.costo, | 157 | costoUnitario: producto.costo, |
| 158 | edit: false | 158 | edit: false |
| 159 | }; | 159 | }; |
| 160 | $scope.articuloACargar = newArt; | 160 | $scope.articuloACargar = newArt; |
| 161 | $scope.cargando = false; | 161 | $scope.cargando = false; |
| 162 | }, function() { | 162 | }, function() { |
| 163 | // funcion ejecutada cuando se cancela el modal | 163 | // funcion ejecutada cuando se cancela el modal |
| 164 | } | 164 | } |
| 165 | ); | 165 | ); |
| 166 | }; | 166 | }; |
| 167 | 167 | ||
| 168 | $scope.seleccionarVendedor = function() { | 168 | $scope.seleccionarVendedor = function() { |
| 169 | var modalInstance = $uibModal.open( | 169 | var modalInstance = $uibModal.open( |
| 170 | { | 170 | { |
| 171 | ariaLabelledBy: 'Busqueda de Vendedores', | 171 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 172 | templateUrl: 'modal-vendedores.html', | 172 | templateUrl: 'modal-vendedores.html', |
| 173 | controller: 'modalVendedoresCtrl', | 173 | controller: 'modalVendedoresCtrl', |
| 174 | size: 'lg' | 174 | size: 'lg' |
| 175 | } | 175 | } |
| 176 | ); | 176 | ); |
| 177 | modalInstance.result.then( | 177 | modalInstance.result.then( |
| 178 | function(vendedor) { | 178 | function(vendedor) { |
| 179 | addCabecera('Vendedor:', vendedor.NomVen); | 179 | addCabecera('Vendedor:', vendedor.NomVen); |
| 180 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 180 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
| 181 | }, function() { | 181 | }, function() { |
| 182 | 182 | ||
| 183 | } | 183 | } |
| 184 | ); | 184 | ); |
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | $scope.seleccionarPetrolera = function() { | 187 | $scope.seleccionarPetrolera = function() { |
| 188 | var modalInstance = $uibModal.open( | 188 | var modalInstance = $uibModal.open( |
| 189 | { | 189 | { |
| 190 | ariaLabelledBy: 'Busqueda de Petrolera', | 190 | ariaLabelledBy: 'Busqueda de Petrolera', |
| 191 | templateUrl: 'modal-petroleras.html', | 191 | templateUrl: 'modal-petroleras.html', |
| 192 | controller: 'modalPetrolerasCtrl', | 192 | controller: 'modalPetrolerasCtrl', |
| 193 | size: 'lg' | 193 | size: 'lg' |
| 194 | } | 194 | } |
| 195 | ); | 195 | ); |
| 196 | modalInstance.result.then( | 196 | modalInstance.result.then( |
| 197 | function(petrolera) { | 197 | function(petrolera) { |
| 198 | $scope.notaPedido.petrolera = petrolera.NOM; | 198 | $scope.notaPedido.petrolera = petrolera.NOM; |
| 199 | }, function() { | 199 | }, function() { |
| 200 | 200 | ||
| 201 | } | 201 | } |
| 202 | ); | 202 | ); |
| 203 | }; | 203 | }; |
| 204 | 204 | ||
| 205 | $scope.seleccionarCliente = function() { | 205 | $scope.seleccionarCliente = function() { |
| 206 | var modalInstance = $uibModal.open( | 206 | var modalInstance = $uibModal.open( |
| 207 | { | 207 | { |
| 208 | ariaLabelledBy: 'Busqueda de Cliente', | 208 | ariaLabelledBy: 'Busqueda de Cliente', |
| 209 | templateUrl: 'foca-busqueda-cliente-modal.html', | 209 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 210 | controller: 'focaBusquedaClienteModalController', | 210 | controller: 'focaBusquedaClienteModalController', |
| 211 | size: 'lg' | 211 | size: 'lg' |
| 212 | } | 212 | } |
| 213 | ); | 213 | ); |
| 214 | modalInstance.result.then( | 214 | modalInstance.result.then( |
| 215 | function(cliente) { | 215 | function(cliente) { |
| 216 | $scope.notaPedido.cliente.nombre = cliente.nom; | 216 | $scope.notaPedido.cliente.nombre = cliente.nom; |
| 217 | $scope.notaPedido.cliente.id = cliente.cod; | 217 | $scope.notaPedido.cliente.id = cliente.cod; |
| 218 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 218 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
| 219 | function(data) { | 219 | function(data) { |
| 220 | if(data.data.length === 0){ | 220 | if(data.data.length === 0){ |
| 221 | focaModalService | 221 | focaModalService |
| 222 | .alert('El cliente no tienen domicilios de entrega') | 222 | .alert('El cliente no tienen domicilios de entrega') |
| 223 | .then( | 223 | .then( |
| 224 | function() { | 224 | function() { |
| 225 | $scope.seleccionarCliente(); | 225 | $scope.seleccionarCliente(); |
| 226 | $scope.notaPedido.cliente = {nombre: ''}; | 226 | $scope.notaPedido.cliente = {nombre: ''}; |
| 227 | } | 227 | } |
| 228 | ); | 228 | ); |
| 229 | return; | 229 | return; |
| 230 | } | 230 | } |
| 231 | $scope.domiciliosCliente = data.data; | 231 | var modalInstanceDomicilio = $uibModal.open( |
| 232 | { | ||
| 233 | ariaLabelledBy: 'Busqueda de Domicilios', | ||
| 234 | templateUrl: 'modal-domicilio.html', | ||
| 235 | controller: 'focaModalDomicilioController', | ||
| 236 | resolve: { idCliente: function() { return cliente.cod; }}, | ||
| 237 | size: 'lg', | ||
| 238 | backdrop: 'static', | ||
| 239 | } | ||
| 240 | ); | ||
| 241 | modalInstanceDomicilio.result.then( | ||
| 242 | function(domicilio) { | ||
| 243 | focaModalService.alert('Domicilio '+domicilio.dom); | ||
| 244 | }, function() { | ||
| 245 | $scope.notaPedido.cliente.nombre = ''; | ||
| 246 | $scope.notaPedido.cliente.id = ''; | ||
| 247 | $scope.seleccionarCliente(); | ||
| 248 | return; | ||
| 249 | } | ||
| 250 | ); | ||
| 232 | } | 251 | } |
| 233 | ); | 252 | ); |
| 234 | 253 | ||
| 235 | addCabecera('Cliente:', cliente.nom); | 254 | addCabecera('Cliente:', cliente.nom); |
| 236 | }, function() { | 255 | }, function() { |
| 237 | 256 | ||
| 238 | } | 257 | } |
| 239 | ); | 258 | ); |
| 240 | }; | 259 | }; |
| 241 | 260 | ||
| 242 | $scope.mostrarFichaCliente = function() { | 261 | $scope.mostrarFichaCliente = function() { |
| 243 | $uibModal.open( | 262 | $uibModal.open( |
| 244 | { | 263 | { |
| 245 | ariaLabelledBy: 'Datos del Cliente', | 264 | ariaLabelledBy: 'Datos del Cliente', |
| 246 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 265 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 247 | controller: 'focaCrearNotaPedidoFichaClienteController', | 266 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 248 | size: 'lg' | 267 | size: 'lg' |
| 249 | } | 268 | } |
| 250 | ); | 269 | ); |
| 251 | }; | 270 | }; |
| 252 | 271 | ||
| 253 | $scope.getTotal = function() { | 272 | $scope.getTotal = function() { |
| 254 | var total = 0; | 273 | var total = 0; |
| 255 | var arrayTempArticulos = $scope.articulosTabla; | 274 | var arrayTempArticulos = $scope.articulosTabla; |
| 256 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 275 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 257 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 276 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 258 | } | 277 | } |
| 259 | return total.toFixed(2); | 278 | return total.toFixed(2); |
| 260 | }; | 279 | }; |
| 261 | 280 | ||
| 262 | $scope.getSubTotal = function() { | 281 | $scope.getSubTotal = function() { |
| 263 | if($scope.articuloACargar) { | 282 | if($scope.articuloACargar) { |
| 264 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 283 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 265 | } | 284 | } |
| 266 | }; | 285 | }; |
| 267 | 286 | ||
| 268 | $scope.abrirModalListaPrecio = function() { | 287 | $scope.abrirModalListaPrecio = function() { |
| 269 | var modalInstance = $uibModal.open( | 288 | var modalInstance = $uibModal.open( |
| 270 | { | 289 | { |
| 271 | ariaLabelledBy: 'Busqueda de Precio Condición', | 290 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 272 | templateUrl: 'modal-precio-condicion.html', | 291 | templateUrl: 'modal-precio-condicion.html', |
| 273 | controller: 'focaModalPrecioCondicionController', | 292 | controller: 'focaModalPrecioCondicionController', |
| 274 | size: 'lg' | 293 | size: 'lg' |
| 275 | } | 294 | } |
| 276 | ); | 295 | ); |
| 277 | modalInstance.result.then( | 296 | modalInstance.result.then( |
| 278 | function(precioCondicion) { | 297 | function(precioCondicion) { |
| 279 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 298 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
| 280 | idLista = precioCondicion.idListaPrecio; | 299 | idLista = precioCondicion.idListaPrecio; |
| 281 | $scope.articulosTabla = []; | 300 | $scope.articulosTabla = []; |
| 282 | 301 | ||
| 283 | addCabecera('Precios y condiciones:', precioCondicion.nombre); | 302 | addCabecera('Precios y condiciones:', precioCondicion.nombre); |
| 284 | }, function() { | 303 | }, function() { |
| 285 | 304 | ||
| 286 | } | 305 | } |
| 287 | ); | 306 | ); |
| 288 | }; | 307 | }; |
| 289 | 308 | ||
| 290 | $scope.abrirModalFlete = function() { | 309 | $scope.abrirModalFlete = function() { |
| 291 | var modalInstance = $uibModal.open( | 310 | var modalInstance = $uibModal.open( |
| 292 | { | 311 | { |
| 293 | ariaLabelledBy: 'Busqueda de Flete', | 312 | ariaLabelledBy: 'Busqueda de Flete', |
| 294 | templateUrl: 'modal-flete.html', | 313 | templateUrl: 'modal-flete.html', |
| 295 | controller: 'focaModalFleteController', | 314 | controller: 'focaModalFleteController', |
| 296 | size: 'lg' | 315 | size: 'lg' |
| 297 | } | 316 | } |
| 298 | ); | 317 | ); |
| 299 | modalInstance.result.then( | 318 | modalInstance.result.then( |
| 300 | function(flete) { | 319 | function(flete) { |
| 301 | $scope.limpiarFlete(); | 320 | $scope.limpiarFlete(); |
| 302 | $scope.notaPedido.fleteNombre = flete.nombre; | 321 | $scope.notaPedido.fleteNombre = flete.nombre; |
| 303 | $scope.notaPedido.fleteId = flete.id; | 322 | $scope.notaPedido.fleteId = flete.id; |
| 304 | $scope.choferes = flete.chofer; | 323 | $scope.choferes = flete.chofer; |
| 305 | $scope.vehiculos = flete.vehiculo; | 324 | $scope.vehiculos = flete.vehiculo; |
| 306 | 325 | ||
| 307 | addCabecera('Flete:', flete.nombre); | 326 | addCabecera('Flete:', flete.nombre); |
| 308 | }, function() { | 327 | }, function() { |
| 309 | 328 | ||
| 310 | } | 329 | } |
| 311 | ); | 330 | ); |
| 312 | }; | 331 | }; |
| 313 | 332 | ||
| 314 | $scope.abrirModalMoneda = function() { | 333 | $scope.abrirModalMoneda = function() { |
| 315 | var modalInstance = $uibModal.open( | 334 | var modalInstance = $uibModal.open( |
| 316 | { | 335 | { |
| 317 | ariaLabelledBy: 'Busqueda de Moneda', | 336 | ariaLabelledBy: 'Busqueda de Moneda', |
| 318 | templateUrl: 'modal-moneda.html', | 337 | templateUrl: 'modal-moneda.html', |
| 319 | controller: 'focaModalMonedaController', | 338 | controller: 'focaModalMonedaController', |
| 320 | size: 'lg' | 339 | size: 'lg' |
| 321 | } | 340 | } |
| 322 | ); | 341 | ); |
| 323 | modalInstance.result.then( | 342 | modalInstance.result.then( |
| 324 | function(moneda) { | 343 | function(moneda) { |
| 325 | $scope.notaPedido.moneda = { | 344 | $scope.notaPedido.moneda = { |
| 326 | id: moneda.ID, | 345 | id: moneda.ID, |
| 327 | detalle: moneda.DETALLE, | 346 | detalle: moneda.DETALLE, |
| 328 | simbolo: moneda.SIMBOLO | 347 | simbolo: moneda.SIMBOLO |
| 329 | }; | 348 | }; |
| 330 | 349 | ||
| 331 | addCabecera('Moneda:', moneda.DETALLE); | 350 | addCabecera('Moneda:', moneda.DETALLE); |
| 332 | }, function() { | 351 | }, function() { |
| 333 | 352 | ||
| 334 | } | 353 | } |
| 335 | ); | 354 | ); |
| 336 | }; | 355 | }; |
| 337 | 356 | ||
| 338 | $scope.agregarATabla = function(key) { | 357 | $scope.agregarATabla = function(key) { |
| 339 | if(key === 13) { | 358 | if(key === 13) { |
| 340 | if($scope.articuloACargar.cantidad === undefined || | 359 | if($scope.articuloACargar.cantidad === undefined || |
| 341 | $scope.articuloACargar.cantidad === 0 || | 360 | $scope.articuloACargar.cantidad === 0 || |
| 342 | $scope.articuloACargar.cantidad === null ){ | 361 | $scope.articuloACargar.cantidad === null ){ |
| 343 | focaModalService.alert('El valor debe ser al menos 1'); | 362 | focaModalService.alert('El valor debe ser al menos 1'); |
| 344 | return; | 363 | return; |
| 345 | } | 364 | } |
| 346 | $scope.articulosTabla.unshift($scope.articuloACargar); | 365 | $scope.articulosTabla.unshift($scope.articuloACargar); |
| 347 | $scope.cargando = true; | 366 | $scope.cargando = true; |
| 348 | } | 367 | } |
| 349 | }; | 368 | }; |
| 350 | 369 | ||
| 351 | $scope.quitarArticulo = function(key) { | 370 | $scope.quitarArticulo = function(key) { |
| 352 | $scope.articulosTabla.splice(key, 1); | 371 | $scope.articulosTabla.splice(key, 1); |
| 353 | }; | 372 | }; |
| 354 | 373 | ||
| 355 | $scope.editarArticulo = function(key, articulo) { | 374 | $scope.editarArticulo = function(key, articulo) { |
| 356 | if(key === 13) { | 375 | if(key === 13) { |
| 357 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 376 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 358 | articulo.cantidad === undefined){ | 377 | articulo.cantidad === undefined){ |
| 359 | focaModalService.alert('El valor debe ser al menos 1'); | 378 | focaModalService.alert('El valor debe ser al menos 1'); |
| 360 | return; | 379 | return; |
| 361 | } | 380 | } |
| 362 | articulo.edit = false; | 381 | articulo.edit = false; |
| 363 | } | 382 | } |
| 364 | }; | 383 | }; |
| 365 | 384 | ||
| 366 | $scope.cambioEdit = function(articulo) { | 385 | $scope.cambioEdit = function(articulo) { |
| 367 | articulo.edit = true; | 386 | articulo.edit = true; |
| 368 | }; | 387 | }; |
| 369 | 388 | ||
| 370 | $scope.limpiarFlete = function() { | 389 | $scope.limpiarFlete = function() { |
| 371 | $scope.notaPedido.fleteNombre = ''; | 390 | $scope.notaPedido.fleteNombre = ''; |
| 372 | $scope.notaPedido.chofer = ''; | 391 | $scope.notaPedido.chofer = ''; |
| 373 | $scope.notaPedido.vehiculo = ''; | 392 | $scope.notaPedido.vehiculo = ''; |
| 374 | $scope.notaPedido.kilometros = ''; | 393 | $scope.notaPedido.kilometros = ''; |
| 375 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 394 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 376 | $scope.choferes = ''; | 395 | $scope.choferes = ''; |
| 377 | $scope.vehiculos = ''; | 396 | $scope.vehiculos = ''; |
| 378 | }; | 397 | }; |
| 379 | 398 | ||
| 380 | $scope.limpiarPantalla = function() { | 399 | $scope.limpiarPantalla = function() { |
| 381 | $scope.limpiarFlete(); | 400 | $scope.limpiarFlete(); |
| 382 | $scope.notaPedido.flete = '0'; | 401 | $scope.notaPedido.flete = '0'; |
| 383 | $scope.notaPedido.bomba = '0'; | 402 | $scope.notaPedido.bomba = '0'; |
| 384 | $scope.notaPedido.precioCondicion = ''; | 403 | $scope.notaPedido.precioCondicion = ''; |
| 385 | $scope.articulosTabla = []; | 404 | $scope.articulosTabla = []; |
| 386 | $scope.notaPedido.vendedor.nombre = ''; | 405 | $scope.notaPedido.vendedor.nombre = ''; |
| 387 | $scope.notaPedido.cliente = {nombre: ''}; | 406 | $scope.notaPedido.cliente = {nombre: ''}; |
| 388 | $scope.notaPedido.domicilio = {dom: ''}; | 407 | $scope.notaPedido.domicilio = {dom: ''}; |
| 389 | $scope.domiciliosCliente = []; | 408 | $scope.domiciliosCliente = []; |
| 390 | }; | 409 | }; |
| 391 | 410 | ||
| 392 | $scope.resetFilter = function() { | 411 | $scope.resetFilter = function() { |
| 393 | $scope.articuloACargar = {}; | 412 | $scope.articuloACargar = {}; |
| 394 | $scope.cargando = true; | 413 | $scope.cargando = true; |
| 395 | }; | 414 | }; |
| 396 | 415 | ||
| 397 | $scope.selectFocus = function($event) { | 416 | $scope.selectFocus = function($event) { |
| 398 | $event.target.select(); | 417 | $event.target.select(); |
| 399 | }; | 418 | }; |
| 400 | 419 | ||
| 401 | $scope.salir = function() { | 420 | $scope.salir = function() { |
| 402 | $location.path('/'); | 421 | $location.path('/'); |
| 403 | }; | 422 | }; |
| 404 | 423 | ||
| 405 | function addCabecera(label, valor) { | 424 | function addCabecera(label, valor) { |
| 406 | let existe = false; | 425 | let existe = false; |
| 407 | 426 | ||
| 408 | for (var i = $scope.cabecera.length - 1; i >= 0; i--) { | 427 | for (var i = $scope.cabecera.length - 1; i >= 0; i--) { |
| 409 | if ($scope.cabecera[i].label === label) { | 428 | if ($scope.cabecera[i].label === label) { |
| 410 | $scope.cabecera[i].valor = valor; | 429 | $scope.cabecera[i].valor = valor; |
| 411 | existe = true; | 430 | existe = true; |
| 412 | break; | 431 | break; |
| 413 | } | 432 | } |
| 414 | 433 | ||
| 415 | } | 434 | } |
| 416 | 435 | ||
| 417 | if (!existe) { | 436 | if (!existe) { |
| 418 | $scope.cabecera.push({ | 437 | $scope.cabecera.push({ |
| 419 | label: label, | 438 | label: label, |
| 420 | valor: valor | 439 | valor: valor |
| 421 | }); | 440 | }); |
| 422 | } | 441 | } |
| 423 | } | 442 | } |
| 424 | } | 443 | } |
| 425 | ] | 444 | ] |
| 426 | ) | 445 | ) |
| 427 | .controller('notaPedidoListaCtrl', [ | 446 | .controller('notaPedidoListaCtrl', [ |
| 428 | '$scope', | 447 | '$scope', |
| 429 | 'crearNotaPedidoService', | 448 | 'crearNotaPedidoService', |
| 430 | '$location', | 449 | '$location', |
| 431 | function($scope, crearNotaPedidoService, $location) { | 450 | function($scope, crearNotaPedidoService, $location) { |
| 432 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 451 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 433 | $scope.notaPedidos = datos.data; | 452 | $scope.notaPedidos = datos.data; |
| 434 | }); | 453 | }); |
| 435 | $scope.editar = function(notaPedido) { | 454 | $scope.editar = function(notaPedido) { |
| 436 | crearNotaPedidoService.setNotaPedido(notaPedido); | 455 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 437 | $location.path('/venta-nota-pedido/abm/'); | 456 | $location.path('/venta-nota-pedido/abm/'); |
| 438 | }; | 457 | }; |
| 439 | $scope.crearPedido = function() { | 458 | $scope.crearPedido = function() { |
| 440 | crearNotaPedidoService.clearNotaPedido(); | 459 | crearNotaPedidoService.clearNotaPedido(); |
| 441 | $location.path('/venta-nota-pedido/abm/'); | 460 | $location.path('/venta-nota-pedido/abm/'); |
| 442 | }; | 461 | }; |
| 443 | } | 462 | } |
| 444 | ]) | 463 | ]) |
| 445 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 464 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 446 | '$scope', | 465 | '$scope', |
| 447 | 'crearNotaPedidoService', | 466 | 'crearNotaPedidoService', |
| 448 | '$location', | 467 | '$location', |
| 449 | function($scope, crearNotaPedidoService, $location) { | 468 | function($scope, crearNotaPedidoService, $location) { |
| 450 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 469 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 451 | $scope.notaPedidos = datos.data; | 470 | $scope.notaPedidos = datos.data; |
| 452 | }); | 471 | }); |
| 453 | $scope.editar = function(notaPedido) { | 472 | $scope.editar = function(notaPedido) { |
| 454 | crearNotaPedidoService.setNotaPedido(notaPedido); | 473 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 455 | $location.path('/venta-nota-pedido/abm/'); | 474 | $location.path('/venta-nota-pedido/abm/'); |
| 456 | }; | 475 | }; |
| 457 | $scope.crearPedido = function() { | 476 | $scope.crearPedido = function() { |
| 458 | crearNotaPedidoService.clearNotaPedido(); | 477 | crearNotaPedidoService.clearNotaPedido(); |
| 459 | $location.path('/venta-nota-pedido/abm/'); | 478 | $location.path('/venta-nota-pedido/abm/'); |
| 460 | }; | 479 | }; |
| 461 | } | 480 | } |
| 462 | ]); | 481 | ]); |
| 463 | 482 |