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