Commit df5fab47a8820b832005a423673ecd600f739c64
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
envio a modal idTransportista, nuevas imgs botonera See merge request !9
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'crearHojaRutaService', | 8 | 'crearHojaRutaService', |
| 9 | 'focaModalService', | 9 | 'focaModalService', |
| 10 | 'focaBotoneraLateralService', | 10 | 'focaBotoneraLateralService', |
| 11 | function($scope, $uibModal, $location, $filter, $timeout, | 11 | function($scope, $uibModal, $location, $filter, $timeout, |
| 12 | crearHojaRutaService, focaModalService, focaBotoneraLateralService) { | 12 | crearHojaRutaService, focaModalService, focaBotoneraLateralService) { |
| 13 | 13 | ||
| 14 | $scope.botonera = crearHojaRutaService.getBotonera(); | 14 | $scope.botonera = crearHojaRutaService.getBotonera(); |
| 15 | $scope.datepickerAbierto = false; | 15 | $scope.datepickerAbierto = false; |
| 16 | 16 | ||
| 17 | $scope.show = false; | 17 | $scope.show = false; |
| 18 | $scope.cargando = true; | 18 | $scope.cargando = true; |
| 19 | $scope.dateOptions = { | 19 | $scope.dateOptions = { |
| 20 | maxDate: new Date(), | 20 | maxDate: new Date(), |
| 21 | minDate: new Date(2010, 0, 1) | 21 | minDate: new Date(2010, 0, 1) |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | $scope.hojaRuta = { | 24 | $scope.hojaRuta = { |
| 25 | fecha: new Date(), | 25 | fecha: new Date(), |
| 26 | litros: 0, | 26 | litros: 0, |
| 27 | chofer: {}, | 27 | chofer: {}, |
| 28 | vehiculo: { | 28 | vehiculo: { |
| 29 | capacidad: 0 | 29 | capacidad: 0 |
| 30 | }, | 30 | }, |
| 31 | transportista: {}, | 31 | transportista: {}, |
| 32 | tarifario: { | 32 | tarifario: { |
| 33 | costo: null | 33 | costo: null |
| 34 | } | 34 | } |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | $scope.showCabecera = true; | 37 | $scope.showCabecera = true; |
| 38 | 38 | ||
| 39 | $scope.now = new Date(); | 39 | $scope.now = new Date(); |
| 40 | $scope.puntoVenta = '0000'; | 40 | $scope.puntoVenta = '0000'; |
| 41 | $scope.comprobante = '00000000'; | 41 | $scope.comprobante = '00000000'; |
| 42 | $scope.remitosTabla = []; | 42 | $scope.remitosTabla = []; |
| 43 | $scope.idLista = undefined; | 43 | $scope.idLista = undefined; |
| 44 | //La pantalla solo se usa para cargar pedidos | 44 | //La pantalla solo se usa para cargar pedidos |
| 45 | //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); | 45 | //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); |
| 46 | 46 | ||
| 47 | //SETEO BOTONERA LATERAL | 47 | //SETEO BOTONERA LATERAL |
| 48 | $timeout(function() { | 48 | $timeout(function() { |
| 49 | focaBotoneraLateralService.showSalir(true); | 49 | focaBotoneraLateralService.showSalir(true); |
| 50 | focaBotoneraLateralService.showPausar(true); | 50 | focaBotoneraLateralService.showPausar(true); |
| 51 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); | 51 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
| 52 | }); | 52 | }); |
| 53 | 53 | ||
| 54 | crearHojaRutaService.getNumeroHojaRuta().then( | 54 | crearHojaRutaService.getNumeroHojaRuta().then( |
| 55 | function(res) { | 55 | function(res) { |
| 56 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); | 56 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); |
| 57 | $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); | 57 | $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); |
| 58 | }, | 58 | }, |
| 59 | function(err) { | 59 | function(err) { |
| 60 | focaModalService.alert('La terminal no esta configurada correctamente'); | 60 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 61 | console.info(err); | 61 | console.info(err); |
| 62 | } | 62 | } |
| 63 | ); | 63 | ); |
| 64 | //La pantalla solo se usa para cargar pedidos | 64 | //La pantalla solo se usa para cargar pedidos |
| 65 | // if (hojaRutaTemp !== undefined) { | 65 | // if (hojaRutaTemp !== undefined) { |
| 66 | // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga); | 66 | // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga); |
| 67 | // $scope.hojaRuta = hojaRutaTemp; | 67 | // $scope.hojaRuta = hojaRutaTemp; |
| 68 | // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString(); | 68 | // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString(); |
| 69 | // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString(); | 69 | // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString(); |
| 70 | // $scope.idLista = $scope.hojaRuta.precioCondicion; | 70 | // $scope.idLista = $scope.hojaRuta.precioCondicion; |
| 71 | // crearHojaRutaService | 71 | // crearHojaRutaService |
| 72 | // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then( | 72 | // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then( |
| 73 | // function(res) { | 73 | // function(res) { |
| 74 | // $scope.remitosTabla = res.data; | 74 | // $scope.remitosTabla = res.data; |
| 75 | // } | 75 | // } |
| 76 | // ); | 76 | // ); |
| 77 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 77 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 78 | //(NO REQUERIDO EN ESTA VERSION) | 78 | //(NO REQUERIDO EN ESTA VERSION) |
| 79 | // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then( | 79 | // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then( |
| 80 | // function(res) { | 80 | // function(res) { |
| 81 | // $scope.hojaRuta.domicilio = res.data; | 81 | // $scope.hojaRuta.domicilio = res.data; |
| 82 | // } | 82 | // } |
| 83 | // ); | 83 | // ); |
| 84 | // } else { | 84 | // } else { |
| 85 | // $scope.hojaRuta.fechaCarga = new Date(); | 85 | // $scope.hojaRuta.fechaCarga = new Date(); |
| 86 | // $scope.hojaRuta.bomba = '0'; | 86 | // $scope.hojaRuta.bomba = '0'; |
| 87 | // $scope.hojaRuta.flete = '0'; | 87 | // $scope.hojaRuta.flete = '0'; |
| 88 | // $scope.idLista = undefined; | 88 | // $scope.idLista = undefined; |
| 89 | // } | 89 | // } |
| 90 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 90 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 91 | // $scope.addNewDom = function() { | 91 | // $scope.addNewDom = function() { |
| 92 | // $scope.hojaRuta.domicilio.push({ 'id': 0 }); | 92 | // $scope.hojaRuta.domicilio.push({ 'id': 0 }); |
| 93 | // }; | 93 | // }; |
| 94 | // $scope.removeNewChoice = function(choice) { | 94 | // $scope.removeNewChoice = function(choice) { |
| 95 | // if ($scope.hojaRuta.domicilio.length > 1) { | 95 | // if ($scope.hojaRuta.domicilio.length > 1) { |
| 96 | // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex( | 96 | // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex( |
| 97 | // function(c) { | 97 | // function(c) { |
| 98 | // return c.$$hashKey === choice.$$hashKey; | 98 | // return c.$$hashKey === choice.$$hashKey; |
| 99 | // } | 99 | // } |
| 100 | // ), 1); | 100 | // ), 1); |
| 101 | // } | 101 | // } |
| 102 | // }; | 102 | // }; |
| 103 | 103 | ||
| 104 | $scope.crearHojaRuta = function() { | 104 | $scope.crearHojaRuta = function() { |
| 105 | if($scope.hojaRuta.litros <= 0) { | 105 | if($scope.hojaRuta.litros <= 0) { |
| 106 | focaModalService.alert('Ingrese Remitos'); | 106 | focaModalService.alert('Ingrese Remitos'); |
| 107 | return; | 107 | return; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | if(!$scope.hojaRuta.chofer.id) { | 110 | if(!$scope.hojaRuta.chofer.id) { |
| 111 | focaModalService.alert('Ingrese Chofer'); | 111 | focaModalService.alert('Ingrese Chofer'); |
| 112 | return; | 112 | return; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | if(!$scope.hojaRuta.vehiculo.id) { | 115 | if(!$scope.hojaRuta.vehiculo.id) { |
| 116 | focaModalService.alert('Ingrese Vehiculo'); | 116 | focaModalService.alert('Ingrese Vehiculo'); |
| 117 | return; | 117 | return; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | if(!$scope.hojaRuta.transportista.codigo) { | 120 | if(!$scope.hojaRuta.transportista.codigo) { |
| 121 | focaModalService.alert('Ingrese Transportista'); | 121 | focaModalService.alert('Ingrese Transportista'); |
| 122 | return; | 122 | return; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) { | 125 | if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) { |
| 126 | focaModalService.alert( | 126 | focaModalService.alert( |
| 127 | 'La capacidad del Vehiculo es menor a lo ingresado en Remitos' | 127 | 'La capacidad del Vehiculo es menor a lo ingresado en Remitos' |
| 128 | ); | 128 | ); |
| 129 | return; | 129 | return; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | if(!$scope.hojaRuta.tarifario.costo) { | 132 | if(!$scope.hojaRuta.tarifario.costo) { |
| 133 | focaModalService.alert('Ingrese Tarifario'); | 133 | focaModalService.alert('Ingrese Tarifario'); |
| 134 | return; | 134 | return; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | var date = new Date(); | 137 | var date = new Date(); |
| 138 | var save = { | 138 | var save = { |
| 139 | hojaRuta: { | 139 | hojaRuta: { |
| 140 | id: 0, | 140 | id: 0, |
| 141 | fechaCreacion: | 141 | fechaCreacion: |
| 142 | new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 142 | new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 143 | .toISOString().slice(0, 19) .replace('T', ' '), | 143 | .toISOString().slice(0, 19) .replace('T', ' '), |
| 144 | idTransportista: $scope.hojaRuta.transportista.codigo, | 144 | idTransportista: $scope.hojaRuta.transportista.codigo, |
| 145 | idChofer: $scope.hojaRuta.chofer.id, | 145 | idChofer: $scope.hojaRuta.chofer.id, |
| 146 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 146 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
| 147 | tarifaFlete: $scope.hojaRuta.tarifario.costo | 147 | tarifaFlete: $scope.hojaRuta.tarifario.costo |
| 148 | }, | 148 | }, |
| 149 | remitos: $scope.remitosTabla | 149 | remitos: $scope.remitosTabla |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | crearHojaRutaService.crearHojaRuta(save).then( | 152 | crearHojaRutaService.crearHojaRuta(save).then( |
| 153 | function(data) { | 153 | function(data) { |
| 154 | focaModalService.alert( | 154 | focaModalService.alert( |
| 155 | 'Hoja ruta creada Nº: ' + | 155 | 'Hoja ruta creada Nº: ' + |
| 156 | $scope.rellenar(data.data.sucursal, 4) + | 156 | $scope.rellenar(data.data.sucursal, 4) + |
| 157 | '-' + | 157 | '-' + |
| 158 | $scope.rellenar(data.data.numeroHojaRuta, 8) | 158 | $scope.rellenar(data.data.numeroHojaRuta, 8) |
| 159 | ); | 159 | ); |
| 160 | $scope.hojaRuta = { | 160 | $scope.hojaRuta = { |
| 161 | fecha: new Date(), | 161 | fecha: new Date(), |
| 162 | litros: 0, | 162 | litros: 0, |
| 163 | chofer: {}, | 163 | chofer: {}, |
| 164 | vehiculo: { | 164 | vehiculo: { |
| 165 | capacidad: 0 | 165 | capacidad: 0 |
| 166 | }, | 166 | }, |
| 167 | transportista: {}, | 167 | transportista: {}, |
| 168 | tarifario: { | 168 | tarifario: { |
| 169 | costo: null | 169 | costo: null |
| 170 | } | 170 | } |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| 173 | $scope.remitosTabla = []; | 173 | $scope.remitosTabla = []; |
| 174 | $scope.$broadcast('cleanCabecera'); | 174 | $scope.$broadcast('cleanCabecera'); |
| 175 | 175 | ||
| 176 | crearHojaRutaService.getNumeroHojaRuta().then(function(res) { | 176 | crearHojaRutaService.getNumeroHojaRuta().then(function(res) { |
| 177 | $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); | 177 | $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); |
| 178 | }); | 178 | }); |
| 179 | }, | 179 | }, |
| 180 | function(error) { | 180 | function(error) { |
| 181 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 181 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 182 | console.info(error); | 182 | console.info(error); |
| 183 | } | 183 | } |
| 184 | ); | 184 | ); |
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | $scope.seleccionarTransportista = function() { | 187 | $scope.seleccionarTransportista = function() { |
| 188 | var modalInstance = $uibModal.open( | 188 | var modalInstance = $uibModal.open( |
| 189 | { | 189 | { |
| 190 | ariaLabelledBy: 'Busqueda de Transportista', | 190 | ariaLabelledBy: 'Busqueda de Transportista', |
| 191 | templateUrl: 'modal-proveedor.html', | 191 | templateUrl: 'modal-proveedor.html', |
| 192 | controller: 'focaModalProveedorCtrl', | 192 | controller: 'focaModalProveedorCtrl', |
| 193 | size: 'lg', | 193 | size: 'lg', |
| 194 | resolve: { | 194 | resolve: { |
| 195 | transportista: function() { | 195 | transportista: function() { |
| 196 | return true; | 196 | return true; |
| 197 | } | 197 | } |
| 198 | } | 198 | } |
| 199 | } | 199 | } |
| 200 | ); | 200 | ); |
| 201 | modalInstance.result.then( | 201 | modalInstance.result.then( |
| 202 | function(proveedor) { | 202 | function(proveedor) { |
| 203 | console.info($scope.hojaRuta); | 203 | console.info($scope.hojaRuta); |
| 204 | $scope.hojaRuta.transportista.codigo = proveedor.COD; | 204 | $scope.hojaRuta.transportista.codigo = proveedor.COD; |
| 205 | $scope.$broadcast('addCabecera', { | 205 | $scope.$broadcast('addCabecera', { |
| 206 | label: 'Transportista:', | 206 | label: 'Transportista:', |
| 207 | valor: proveedor.NOM | 207 | valor: proveedor.NOM |
| 208 | }); | 208 | }); |
| 209 | }, function() { | 209 | }, function() { |
| 210 | 210 | ||
| 211 | } | 211 | } |
| 212 | ); | 212 | ); |
| 213 | }; | 213 | }; |
| 214 | 214 | ||
| 215 | $scope.seleccionarChofer = function() { | 215 | $scope.seleccionarChofer = function() { |
| 216 | var modalInstance = $uibModal.open( | 216 | var modalInstance = $uibModal.open( |
| 217 | { | 217 | { |
| 218 | ariaLabelledBy: 'Busqueda de Chofer', | 218 | ariaLabelledBy: 'Busqueda de Chofer', |
| 219 | templateUrl: 'modal-chofer.html', | 219 | templateUrl: 'modal-chofer.html', |
| 220 | controller: 'focaModalChoferController', | 220 | controller: 'focaModalChoferController', |
| 221 | size: 'lg' | 221 | size: 'lg' |
| 222 | } | 222 | } |
| 223 | ); | 223 | ); |
| 224 | 224 | ||
| 225 | modalInstance.result.then( | 225 | modalInstance.result.then( |
| 226 | function(chofer) { | 226 | function(chofer) { |
| 227 | $scope.hojaRuta.chofer = chofer; | 227 | $scope.hojaRuta.chofer = chofer; |
| 228 | $scope.$broadcast('addCabecera', { | 228 | $scope.$broadcast('addCabecera', { |
| 229 | label: 'Chofer:', | 229 | label: 'Chofer:', |
| 230 | valor: chofer.nombre | 230 | valor: chofer.nombre |
| 231 | }); | 231 | }); |
| 232 | }, function() { | 232 | }, function() { |
| 233 | // funcion ejecutada cuando se cancela el modal | 233 | // funcion ejecutada cuando se cancela el modal |
| 234 | } | 234 | } |
| 235 | ); | 235 | ); |
| 236 | }; | 236 | }; |
| 237 | 237 | ||
| 238 | $scope.seleccionarVehiculo = function() { | 238 | $scope.seleccionarVehiculo = function() { |
| 239 | var modalInstance = $uibModal.open( | 239 | var modalInstance = $uibModal.open( |
| 240 | { | 240 | { |
| 241 | ariaLabelledBy: 'Busqueda de Vehiculo', | 241 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 242 | templateUrl: 'modal-vehiculo.html', | 242 | templateUrl: 'modal-vehiculo.html', |
| 243 | controller: 'focaModalVehiculoController', | 243 | controller: 'focaModalVehiculoController', |
| 244 | size: 'lg', | 244 | size: 'lg', |
| 245 | resolve: { | 245 | resolve: { |
| 246 | idTransportista: function() { | 246 | idTransportista: $scope.hojaRuta.transportista.codigo |
| 247 | return -1; | ||
| 248 | } | ||
| 249 | } | 247 | } |
| 250 | } | 248 | } |
| 251 | ); | 249 | ); |
| 252 | 250 | ||
| 253 | modalInstance.result.then( | 251 | modalInstance.result.then( |
| 254 | function(vehiculo) { | 252 | function(vehiculo) { |
| 255 | $scope.hojaRuta.vehiculo = vehiculo; | 253 | $scope.hojaRuta.vehiculo = vehiculo; |
| 256 | $scope.$broadcast('addCabecera', { | 254 | $scope.$broadcast('addCabecera', { |
| 257 | label: 'Tractor:', | 255 | label: 'Tractor:', |
| 258 | valor: vehiculo.tractor | 256 | valor: vehiculo.tractor |
| 259 | }); | 257 | }); |
| 260 | $scope.$broadcast('addCabecera', { | 258 | $scope.$broadcast('addCabecera', { |
| 261 | label: 'Semi:', | 259 | label: 'Semi:', |
| 262 | valor: vehiculo.semi | 260 | valor: vehiculo.semi |
| 263 | }); | 261 | }); |
| 264 | $scope.$broadcast('addCabecera', { | 262 | $scope.$broadcast('addCabecera', { |
| 265 | label: 'Capacidad:', | 263 | label: 'Capacidad:', |
| 266 | valor: vehiculo.capacidad | 264 | valor: vehiculo.capacidad |
| 267 | }); | 265 | }); |
| 268 | }, function() { | 266 | }, function() { |
| 269 | // funcion ejecutada cuando se cancela el modal | 267 | // funcion ejecutada cuando se cancela el modal |
| 270 | } | 268 | } |
| 271 | ); | 269 | ); |
| 272 | }; | 270 | }; |
| 273 | 271 | ||
| 274 | $scope.seleccionarTarifario = function() { | 272 | $scope.seleccionarTarifario = function() { |
| 275 | var modalInstance = $uibModal.open( | 273 | var modalInstance = $uibModal.open( |
| 276 | { | 274 | { |
| 277 | ariaLabelledBy: 'Busqueda de Tarifario', | 275 | ariaLabelledBy: 'Busqueda de Tarifario', |
| 278 | templateUrl: 'modal-tarifa-flete.html', | 276 | templateUrl: 'modal-tarifa-flete.html', |
| 279 | controller: 'focaModalTarifaFleteController', | 277 | controller: 'focaModalTarifaFleteController', |
| 280 | size: 'lg', | 278 | size: 'lg', |
| 281 | resolve: { | 279 | resolve: { |
| 282 | parametrosTarifaFlete: function() { | 280 | parametrosTarifaFlete: function() { |
| 283 | return $scope.hojaRuta.tarifario.costo; | 281 | return $scope.hojaRuta.tarifario.costo; |
| 284 | } | 282 | } |
| 285 | } | 283 | } |
| 286 | } | 284 | } |
| 287 | ); | 285 | ); |
| 288 | 286 | ||
| 289 | modalInstance.result.then( | 287 | modalInstance.result.then( |
| 290 | function(tarifario) { | 288 | function(tarifario) { |
| 291 | $scope.hojaRuta.tarifario = tarifario; | 289 | $scope.hojaRuta.tarifario = tarifario; |
| 292 | $scope.$broadcast('addCabecera', { | 290 | $scope.$broadcast('addCabecera', { |
| 293 | label: 'Tarifario:', | 291 | label: 'Tarifario:', |
| 294 | valor: tarifario.costo | 292 | valor: tarifario.costo |
| 295 | }); | 293 | }); |
| 296 | }, function() { | 294 | }, function() { |
| 297 | // funcion ejecutada cuando se cancela el modal | 295 | // funcion ejecutada cuando se cancela el modal |
| 298 | } | 296 | } |
| 299 | ); | 297 | ); |
| 300 | }; | 298 | }; |
| 301 | 299 | ||
| 302 | $scope.seleccionarRemitos = function() { | 300 | $scope.seleccionarRemitos = function() { |
| 303 | var modalInstance = $uibModal.open( | 301 | var modalInstance = $uibModal.open( |
| 304 | { | 302 | { |
| 305 | ariaLabelledBy: 'Busqueda de Remito', | 303 | ariaLabelledBy: 'Busqueda de Remito', |
| 306 | templateUrl: 'foca-modal-remito.html', | 304 | templateUrl: 'foca-modal-remito.html', |
| 307 | controller: 'focaModalRemitoController', | 305 | controller: 'focaModalRemitoController', |
| 308 | size: 'lg', | 306 | size: 'lg', |
| 309 | resolve: {usadoPor: function() {return 'hojaRuta';}} | 307 | resolve: {usadoPor: function() {return 'hojaRuta';}} |
| 310 | } | 308 | } |
| 311 | ); | 309 | ); |
| 312 | modalInstance.result.then( | 310 | modalInstance.result.then( |
| 313 | function(remito) { | 311 | function(remito) { |
| 314 | for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | 312 | for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { |
| 315 | if ($scope.remitosTabla[i].id === remito.id) { | 313 | if ($scope.remitosTabla[i].id === remito.id) { |
| 316 | focaModalService.alert('Remito ya incluido'); | 314 | focaModalService.alert('Remito ya incluido'); |
| 317 | return; | 315 | return; |
| 318 | } | 316 | } |
| 319 | } | 317 | } |
| 320 | 318 | ||
| 321 | var litros = 0; | 319 | var litros = 0; |
| 322 | for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | 320 | for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { |
| 323 | litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | 321 | litros = litros + parseFloat(remito.articulosRemito[j].cantidad); |
| 324 | } | 322 | } |
| 325 | 323 | ||
| 326 | if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | 324 | if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { |
| 327 | focaModalService.alert( | 325 | focaModalService.alert( |
| 328 | 'Debe ingresar toda la información para el transporte' | 326 | 'Debe ingresar toda la información para el transporte' |
| 329 | ); | 327 | ); |
| 330 | return; | 328 | return; |
| 331 | } | 329 | } |
| 332 | 330 | ||
| 333 | if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | 331 | if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) |
| 334 | { | 332 | { |
| 335 | var litrostotales = litros; | 333 | var litrostotales = litros; |
| 336 | litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | 334 | litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; |
| 337 | focaModalService.alert( | 335 | focaModalService.alert( |
| 338 | 'La carga excede la capacidad disponible del vehiculo. ' + | 336 | 'La carga excede la capacidad disponible del vehiculo. ' + |
| 339 | 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | 337 | 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' |
| 340 | ); | 338 | ); |
| 341 | } | 339 | } |
| 342 | 340 | ||
| 343 | remito.litros = litros; | 341 | remito.litros = litros; |
| 344 | $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | 342 | $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
| 345 | $scope.remitosTabla.push(remito); | 343 | $scope.remitosTabla.push(remito); |
| 346 | }, function() { | 344 | }, function() { |
| 347 | // funcion ejecutada cuando se cancela el modal | 345 | // funcion ejecutada cuando se cancela el modal |
| 348 | } | 346 | } |
| 349 | ); | 347 | ); |
| 350 | }; | 348 | }; |
| 351 | 349 | ||
| 352 | $scope.getTotal = function() { | 350 | $scope.getTotal = function() { |
| 353 | var total = 0; | 351 | var total = 0; |
| 354 | var arrayTempArticulos = $scope.remitosTabla; | 352 | var arrayTempArticulos = $scope.remitosTabla; |
| 355 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 353 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 356 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 354 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 357 | } | 355 | } |
| 358 | return parseFloat(total.toFixed(2)); | 356 | return parseFloat(total.toFixed(2)); |
| 359 | }; | 357 | }; |
| 360 | 358 | ||
| 361 | $scope.getSubTotal = function() { | 359 | $scope.getSubTotal = function() { |
| 362 | if($scope.articuloACargar) { | 360 | if($scope.articuloACargar) { |
| 363 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 361 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 364 | } | 362 | } |
| 365 | }; | 363 | }; |
| 366 | 364 | ||
| 367 | $scope.limpiarPantalla = function() { | 365 | $scope.limpiarPantalla = function() { |
| 368 | $scope.limpiarFlete(); | 366 | $scope.limpiarFlete(); |
| 369 | $scope.hojaRuta.flete = '0'; | 367 | $scope.hojaRuta.flete = '0'; |
| 370 | $scope.hojaRuta.bomba = '0'; | 368 | $scope.hojaRuta.bomba = '0'; |
| 371 | $scope.hojaRuta.precioCondicion = ''; | 369 | $scope.hojaRuta.precioCondicion = ''; |
| 372 | $scope.remitosTabla = []; | 370 | $scope.remitosTabla = []; |
| 373 | $scope.hojaRuta.vendedor.nombre = ''; | 371 | $scope.hojaRuta.vendedor.nombre = ''; |
| 374 | $scope.hojaRuta.cliente = {nombre: ''}; | 372 | $scope.hojaRuta.cliente = {nombre: ''}; |
| 375 | $scope.hojaRuta.domicilio = {dom: ''}; | 373 | $scope.hojaRuta.domicilio = {dom: ''}; |
| 376 | $scope.hojaRuta.litros = 0; | 374 | $scope.hojaRuta.litros = 0; |
| 377 | $scope.domiciliosCliente = []; | 375 | $scope.domiciliosCliente = []; |
| 378 | }; | 376 | }; |
| 379 | //Recibe aviso si el teclado está en uso | 377 | //Recibe aviso si el teclado está en uso |
| 380 | // $rootScope.$on('usarTeclado', function(event, data) { | 378 | // $rootScope.$on('usarTeclado', function(event, data) { |
| 381 | // if(data) { | 379 | // if(data) { |
| 382 | // $scope.mostrarTeclado = true; | 380 | // $scope.mostrarTeclado = true; |
| 383 | // return; | 381 | // return; |
| 384 | // } | 382 | // } |
| 385 | // $scope.mostrarTeclado = false; | 383 | // $scope.mostrarTeclado = false; |
| 386 | // }) | 384 | // }) |
| 387 | $scope.selectFocus = function($event) { | 385 | $scope.selectFocus = function($event) { |
| 388 | //Si el teclado esta en uso no selecciona el valor | 386 | //Si el teclado esta en uso no selecciona el valor |
| 389 | // if($scope.mostrarTeclado) { | 387 | // if($scope.mostrarTeclado) { |
| 390 | // return; | 388 | // return; |
| 391 | // } | 389 | // } |
| 392 | $event.target.select(); | 390 | $event.target.select(); |
| 393 | }; | 391 | }; |
| 394 | 392 | ||
| 395 | $scope.salir = function() { | 393 | $scope.salir = function() { |
| 396 | $location.path('/'); | 394 | $location.path('/'); |
| 397 | }; | 395 | }; |
| 398 | 396 | ||
| 399 | $scope.parsearATexto = function(articulo) { | 397 | $scope.parsearATexto = function(articulo) { |
| 400 | articulo.cantidad = parseFloat(articulo.cantidad); | 398 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 401 | articulo.precio = parseFloat(articulo.precio); | 399 | articulo.precio = parseFloat(articulo.precio); |
| 402 | }; | 400 | }; |
| 403 | 401 | ||
| 404 | $scope.rellenar = function(relleno, longitud) { | 402 | $scope.rellenar = function(relleno, longitud) { |
| 405 | relleno = '' + relleno; | 403 | relleno = '' + relleno; |
| 406 | while (relleno.length < longitud) { | 404 | while (relleno.length < longitud) { |
| 407 | relleno = '0' + relleno; | 405 | relleno = '0' + relleno; |
| 408 | } | 406 | } |
| 409 | 407 | ||
| 410 | return relleno; | 408 | return relleno; |
| 411 | }; | 409 | }; |
| 412 | 410 | ||
| 413 | $scope.quitarArticulo = function(key) { | 411 | $scope.quitarArticulo = function(key) { |
| 414 | $scope.remitosTabla.splice(key, 1); | 412 | $scope.remitosTabla.splice(key, 1); |
| 415 | var litros = 0; | 413 | var litros = 0; |
| 416 | 414 | ||
| 417 | for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | 415 | for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { |
| 418 | litros += parseFloat($scope.remitosTabla[i].litros); | 416 | litros += parseFloat($scope.remitosTabla[i].litros); |
| 419 | } | 417 | } |
| 420 | 418 | ||
| 421 | $scope.hojaRuta.litros = litros; | 419 | $scope.hojaRuta.litros = litros; |
| 422 | 420 | ||
| 423 | }; | 421 | }; |
| 424 | } | 422 | } |
| 425 | ] | 423 | ] |
| 426 | ) | 424 | ) |
| 427 | .controller('hojaRutaListaCtrl', [ | 425 | .controller('hojaRutaListaCtrl', [ |
| 428 | '$scope', | 426 | '$scope', |
| 429 | 'crearHojaRutaService', | 427 | 'crearHojaRutaService', |
| 430 | '$location', | 428 | '$location', |
| 431 | function($scope, crearHojaRutaService, $location) { | 429 | function($scope, crearHojaRutaService, $location) { |
| 432 | crearHojaRutaService.obtenerHojaRuta().then(function(datos) { | 430 | crearHojaRutaService.obtenerHojaRuta().then(function(datos) { |
| 433 | $scope.hojaRutas = datos.data; | 431 | $scope.hojaRutas = datos.data; |
| 434 | }); | 432 | }); |
| 435 | $scope.editar = function(hojaRuta) { | 433 | $scope.editar = function(hojaRuta) { |
| 436 | crearHojaRutaService.setHojaRuta(hojaRuta); | 434 | crearHojaRutaService.setHojaRuta(hojaRuta); |
| 437 | $location.path('/venta-nota-pedido/abm/'); | 435 | $location.path('/venta-nota-pedido/abm/'); |
| 438 | }; | 436 | }; |
| 439 | $scope.crearPedido = function() { | 437 | $scope.crearPedido = function() { |
| 440 | crearHojaRutaService.clearHojaRuta(); | 438 | crearHojaRutaService.clearHojaRuta(); |
| 441 | $location.path('/venta-nota-pedido/abm/'); | 439 | $location.path('/venta-nota-pedido/abm/'); |
| 442 | }; | 440 | }; |
| 443 | } | 441 | } |
| 444 | ]) | 442 | ]) |
| 445 | .controller('focaCrearHojaRutaFichaClienteController', [ | 443 | .controller('focaCrearHojaRutaFichaClienteController', [ |
| 446 | '$scope', | 444 | '$scope', |
| 447 | 'crearHojaRutaService', | 445 | 'crearHojaRutaService', |
| 448 | '$location', | 446 | '$location', |
| 449 | function($scope, crearHojaRutaService, $location) { | 447 | function($scope, crearHojaRutaService, $location) { |
| 450 | crearHojaRutaService.obtenerHojaRuta().then(function(datos) { | 448 | crearHojaRutaService.obtenerHojaRuta().then(function(datos) { |
| 451 | $scope.hojaRutas = datos.data; | 449 | $scope.hojaRutas = datos.data; |
| 452 | }); | 450 | }); |
| 453 | $scope.editar = function(hojaRuta) { | 451 | $scope.editar = function(hojaRuta) { |
| 454 | crearHojaRutaService.setHojaRuta(hojaRuta); | 452 | crearHojaRutaService.setHojaRuta(hojaRuta); |
| 455 | $location.path('/venta-nota-pedido/abm/'); | 453 | $location.path('/venta-nota-pedido/abm/'); |
| 456 | }; | 454 | }; |
| 457 | $scope.crearPedido = function() { | 455 | $scope.crearPedido = function() { |
| 458 | crearHojaRutaService.clearHojaRuta(); | 456 | crearHojaRutaService.clearHojaRuta(); |
| 459 | $location.path('/venta-nota-pedido/abm/'); | 457 | $location.path('/venta-nota-pedido/abm/'); |
| 460 | }; | 458 | }; |
| 461 | } | 459 | } |
| 462 | ]); | 460 | ]); |
| 463 | 461 |
src/js/service.js
| 1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
| 2 | .service('crearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('crearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | var route = API_ENDPOINT.URL; | 3 | var route = API_ENDPOINT.URL; |
| 4 | return { | 4 | return { |
| 5 | crearHojaRuta: function(hojaRuta) { | 5 | crearHojaRuta: function(hojaRuta) { |
| 6 | return $http.post(route + '/hoja-ruta', hojaRuta); | 6 | return $http.post(route + '/hoja-ruta', hojaRuta); |
| 7 | }, | 7 | }, |
| 8 | obtenerHojaRuta: function() { | 8 | obtenerHojaRuta: function() { |
| 9 | return $http.get(route +'/hoja-ruta'); | 9 | return $http.get(route +'/hoja-ruta'); |
| 10 | }, | 10 | }, |
| 11 | setHojaRuta: function(hojaRuta) { | 11 | setHojaRuta: function(hojaRuta) { |
| 12 | this.hojaRuta = hojaRuta; | 12 | this.hojaRuta = hojaRuta; |
| 13 | }, | 13 | }, |
| 14 | clearHojaRuta: function() { | 14 | clearHojaRuta: function() { |
| 15 | this.hojaRuta = undefined; | 15 | this.hojaRuta = undefined; |
| 16 | }, | 16 | }, |
| 17 | getHojaRuta: function() { | 17 | getHojaRuta: function() { |
| 18 | return this.hojaRuta; | 18 | return this.hojaRuta; |
| 19 | }, | 19 | }, |
| 20 | getArticulosByIdHojaRuta: function(id) { | 20 | getArticulosByIdHojaRuta: function(id) { |
| 21 | return $http.get(route+'/articulos/hoja-ruta/'+id); | 21 | return $http.get(route+'/articulos/hoja-ruta/'+id); |
| 22 | }, | 22 | }, |
| 23 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { | 23 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { |
| 24 | return $http.post(route + '/articulos/hoja-ruta', | 24 | return $http.post(route + '/articulos/hoja-ruta', |
| 25 | {articuloHojaRuta: articuloHojaRuta}); | 25 | {articuloHojaRuta: articuloHojaRuta}); |
| 26 | }, | 26 | }, |
| 27 | getDomiciliosByIdHojaRuta: function(id) { | 27 | getDomiciliosByIdHojaRuta: function(id) { |
| 28 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); | 28 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); |
| 29 | }, | 29 | }, |
| 30 | getDomiciliosByIdCliente: function(id) { | 30 | getDomiciliosByIdCliente: function(id) { |
| 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 33 | }, | 33 | }, |
| 34 | getPrecioCondicion: function() { | 34 | getPrecioCondicion: function() { |
| 35 | return $http.get(route + '/precio-condicion'); | 35 | return $http.get(route + '/precio-condicion'); |
| 36 | }, | 36 | }, |
| 37 | getPrecioCondicionById: function(id) { | 37 | getPrecioCondicionById: function(id) { |
| 38 | return $http.get(route + '/precio-condicion/' + id); | 38 | return $http.get(route + '/precio-condicion/' + id); |
| 39 | }, | 39 | }, |
| 40 | getPlazoPagoByPrecioCondicion: function(id) { | 40 | getPlazoPagoByPrecioCondicion: function(id) { |
| 41 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); | 41 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); |
| 42 | }, | 42 | }, |
| 43 | crearFlete: function(flete) { | 43 | crearFlete: function(flete) { |
| 44 | return $http.post(route + '/flete', {flete : flete}); | 44 | return $http.post(route + '/flete', {flete : flete}); |
| 45 | }, | 45 | }, |
| 46 | crearPlazosParaHojaRuta: function(plazos) { | 46 | crearPlazosParaHojaRuta: function(plazos) { |
| 47 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); | 47 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); |
| 48 | }, | 48 | }, |
| 49 | getCotizacionByIdMoneda: function(id) { | 49 | getCotizacionByIdMoneda: function(id) { |
| 50 | return $http.get(route + '/moneda/' + id); | 50 | return $http.get(route + '/moneda/' + id); |
| 51 | }, | 51 | }, |
| 52 | crearEstadoParaHojaRuta: function(estado) { | 52 | crearEstadoParaHojaRuta: function(estado) { |
| 53 | return $http.post(route + '/estado', {estado: estado}); | 53 | return $http.post(route + '/estado', {estado: estado}); |
| 54 | }, | 54 | }, |
| 55 | getNumeroHojaRuta: function() { | 55 | getNumeroHojaRuta: function() { |
| 56 | return $http.get(route + '/hoja-ruta/numero-siguiente'); | 56 | return $http.get(route + '/hoja-ruta/numero-siguiente'); |
| 57 | }, | 57 | }, |
| 58 | getBotonera: function() { | 58 | getBotonera: function() { |
| 59 | return [ | 59 | return [ |
| 60 | { | 60 | { |
| 61 | label: 'Transportista', | 61 | label: 'Transportista', |
| 62 | image: 'cliente.png' | 62 | image: 'transportista.png' |
| 63 | }, | 63 | }, |
| 64 | { | 64 | { |
| 65 | label: 'Chofer', | 65 | label: 'Chofer', |
| 66 | image: 'vendedor.png' | 66 | image: 'chofer.png' |
| 67 | }, | 67 | }, |
| 68 | { | 68 | { |
| 69 | label: 'Vehiculo', | 69 | label: 'Vehiculo', |
| 70 | image: 'flete.png' | 70 | image: 'vehiculos.png' |
| 71 | }, | 71 | }, |
| 72 | { | 72 | { |
| 73 | label: 'Tarifario', | 73 | label: 'Tarifario', |
| 74 | image: 'precios-condiciones.png' | 74 | image: 'tarifario.png' |
| 75 | }, | 75 | }, |
| 76 | { | 76 | { |
| 77 | label: 'Remitos', | 77 | label: 'Remitos', |
| 78 | image: 'precios-condiciones.png' | 78 | image: 'remito.png' |
| 79 | } | 79 | } |
| 80 | ]; | 80 | ]; |
| 81 | } | 81 | } |
| 82 | }; | 82 | }; |
| 83 | }]); | 83 | }]); |
| 84 | 84 |