Commit de330bd4476fe6e1bd06130abafec44c0b080a3e

Authored by Nicolás Guarnieri
1 parent 4b63e4145a
Exists in master

falta guardar

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