Commit 482e242ad02884fad751449f9e3eb8decf17d826

Authored by Marcelo Puebla
Exists in master

Merge branch 'master' into 'develop'

Master(benjamin)

See merge request !4
src/js/controller.js
1 angular.module('focaOrdenCarga') 1 angular.module('focaOrdenCarga')
2 .controller('focaOrdenCargaController', [ 2 .controller('focaOrdenCargaController', [
3 '$scope', 3 '$scope',
4 '$location', 4 '$location',
5 '$filter', 5 '$filter',
6 '$timeout', 6 '$timeout',
7 'focaOrdenCargaService', 7 'focaOrdenCargaService',
8 'focaBotoneraLateralService', 8 'focaBotoneraLateralService',
9 'focaModalService', 9 'focaModalService',
10 '$uibModal', 10 '$uibModal',
11 function ( 11 function (
12 $scope, $location, $filter, $timeout, focaOrdenCargaService, 12 $scope, $location, $filter, $timeout, focaOrdenCargaService,
13 focaBotoneraLateralService, focaModalService, $uibModal) { 13 focaBotoneraLateralService, focaModalService, $uibModal) {
14 14
15 init(); 15 init();
16 16
17 function init() { 17 function init() {
18 // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA 18 // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA
19 $scope.fecha = new Date(); 19 $scope.fecha = new Date();
20 $scope.isNumber = angular.isNumber; 20 $scope.isNumber = angular.isNumber;
21 $scope.show = false; 21 $scope.show = false;
22 $scope.cargando = true; 22 $scope.cargando = true;
23 $scope.cabeceras = []; 23 $scope.cabeceras = [];
24 $scope.botonera = focaOrdenCargaService.getBotonera(); 24 $scope.botonera = focaOrdenCargaService.getBotonera();
25 $scope.dateOptions = { 25 $scope.dateOptions = {
26 maxDate: new Date(), 26 maxDate: new Date(),
27 minDate: new Date(2010, 0, 1) 27 minDate: new Date(2010, 0, 1)
28 }; 28 };
29 $scope.ordenCarga = { 29 $scope.ordenCarga = {
30 id: 0, 30 id: 0,
31 cliente: {}, 31 cliente: {},
32 proveedor: {}, 32 proveedor: {},
33 domicilio: { dom: '' }, 33 domicilio: { dom: '' },
34 vendedor: {}, 34 vendedor: {},
35 fechaCarga: new Date(), 35 fechaCarga: new Date(),
36 cotizacion: {}, 36 cotizacion: {},
37 articulosNotaPedido: [], 37 articulosNotaPedido: [],
38 notaPedidoPlazo: [], 38 notaPedidoPlazo: [],
39 notaPedidoPuntoDescarga: [] 39 notaPedidoPuntoDescarga: []
40 }; 40 };
41 $scope.hojaRuta = { 41 $scope.hojaRuta = {
42 fecha: new Date(), 42 fecha: new Date(),
43 litros: 0, 43 litros: 0,
44 chofer: {}, 44 chofer: {},
45 vehiculo: { 45 vehiculo: {
46 capacidad: 0, 46 capacidad: 0,
47 cisternas: [] 47 cisternas: []
48 }, 48 },
49 transportista: {}, 49 transportista: {},
50 remitosTabla: [] 50 remitosTabla: []
51 }; 51 };
52 } 52 }
53 53
54 //SETEO BOTONERA LATERAL 54 //SETEO BOTONERA LATERAL
55 $timeout(function () { 55 $timeout(function () {
56 focaBotoneraLateralService.showSalir(false); 56 focaBotoneraLateralService.showSalir(false);
57 focaBotoneraLateralService.showPausar(true); 57 focaBotoneraLateralService.showPausar(true);
58 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); 58 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido);
59 focaBotoneraLateralService.addCustomButton('Salir', salir); 59 focaBotoneraLateralService.addCustomButton('Salir', salir);
60 }); 60 });
61 61
62 $scope.seleccionarVehiculo = function () { 62 $scope.seleccionarVehiculo = function () {
63 63
64 seleccionarTransportista().then( 64 seleccionarTransportista().then(
65 65
66 function (transportista) { 66 function (transportista) {
67 elegirTransportista(transportista); 67 elegirTransportista(transportista);
68 68
69 var parametrosModal = { 69 var parametrosModal = {
70 columnas: [ 70 columnas: [
71 { 71 {
72 propiedad: 'codigo', 72 propiedad: 'codigo',
73 nombre: 'Código' 73 nombre: 'Código'
74 }, 74 },
75 { 75 {
76 propiedad: 'tractor', 76 propiedad: 'tractor',
77 nombre: 'tractor' 77 nombre: 'tractor'
78 }, 78 },
79 { 79 {
80 propiedad: 'semi', 80 propiedad: 'semi',
81 nombre: 'Semi' 81 nombre: 'Semi'
82 }, 82 },
83 { 83 {
84 propiedad: 'capacidadTotalCisternas', 84 propiedad: 'capacidadTotalCisternas',
85 nombre: 'Capacidad' 85 nombre: 'Capacidad'
86 } 86 },
87 // {
88 // propiedad: 'cantidad',
89 // nombre: 'carga'
90 // }
87 ], 91 ],
88 query: '/vehiculo/transportista/' + transportista.COD, 92 query: '/vehiculo/transportista/' + transportista.COD,
93 // query: '/cisterna_carga/cisterna/vehiculo/transportista/' + transportista.COD,
89 titulo: 'Búsqueda de vehiculos', 94 titulo: 'Búsqueda de vehiculos',
90 subTitulo: transportista.COD + '-' + transportista.NOM 95 subTitulo: transportista.COD + '-' + transportista.NOM
91 }; 96 };
92 97
93 focaModalService.modal(parametrosModal).then( 98 focaModalService.modal(parametrosModal).then(
94 function (vehiculo) { 99 function (vehiculo) {
95 $scope.$broadcast('addCabecera', { 100 $scope.$broadcast('addCabecera', {
96 label: 'Vehículo:', 101 label: 'Vehículo:',
97 valor: vehiculo.codigo 102 valor: vehiculo.codigo
98 }); 103 });
99 $scope.hojaRuta.vehiculo = vehiculo; 104 $scope.hojaRuta.vehiculo = vehiculo;
100 $scope.hojaRuta.transportista = transportista; 105 $scope.hojaRuta.transportista = transportista;
101 $scope.hojaRuta.vehiculo.cisternas = vehiculo.cisternas; 106 $scope.hojaRuta.vehiculo.cisternas = vehiculo.cisternas;
102 getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas); 107 getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas);
103 }, function () { 108 }, function () {
104 seleccionarTransportista(); 109 seleccionarTransportista();
105 }); 110 });
106 }); 111 });
107 }; 112 };
108 113
109 function seleccionarTransportista() { 114 function seleccionarTransportista() {
110 var parametrosModal = { 115 var parametrosModal = {
111 titulo: 'Búsqueda de Transportista', 116 titulo: 'Búsqueda de Transportista',
112 query: '/transportista', 117 query: '/transportista',
113 columnas: [ 118 columnas: [
114 { 119 {
115 nombre: 'Código', 120 nombre: 'Código',
116 propiedad: 'COD' 121 propiedad: 'COD'
117 }, 122 },
118 { 123 {
119 nombre: 'Nombre', 124 nombre: 'Nombre',
120 propiedad: 'NOM' 125 propiedad: 'NOM'
121 }, 126 },
122 { 127 {
123 nombre: 'CUIT', 128 nombre: 'CUIT',
124 propiedad: 'CUIT' 129 propiedad: 'CUIT'
125 } 130 }
126 ] 131 ]
127 }; 132 };
128 return focaModalService.modal(parametrosModal); 133 return focaModalService.modal(parametrosModal);
129 }; 134 };
130 135
131 $scope.seleccionarFechaDeReparto = function () { 136 $scope.seleccionarFechaDeReparto = function () {
132 focaModalService.modalFecha('Fecha').then(function (fecha) { 137 focaModalService.modalFecha('Fecha').then(function (fecha) {
133 $scope.$broadcast('addCabecera', { 138 $scope.$broadcast('addCabecera', {
134 label: 'Fecha:', 139 label: 'Fecha:',
135 valor: fecha.toLocaleDateString() 140 valor: fecha.toLocaleDateString()
136 }); 141 });
137 142
138 $scope.fecha = fecha; 143 $scope.fecha = fecha;
139 if ($scope.hojaRuta.vehiculo.cisternas) 144 if ($scope.hojaRuta.vehiculo.cisternas)
140 getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas); 145 getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas);
141 }); 146 });
142 }; 147 };
143 148
144 $scope.seleccionarHojasDeRuta = function () { 149 $scope.seleccionarHojasDeRuta = function () {
145 if (!$scope.hojaRuta.vehiculo.cisternas.length) { 150 if (!$scope.hojaRuta.vehiculo.cisternas.length) {
146 focaModalService.alert('Primero seleccione un vehículo con cisternas'); 151 focaModalService.alert('Primero seleccione un vehículo con cisternas');
147 return; 152 return;
148 } 153 }
149 $uibModal.open( 154 $uibModal.open(
150 { 155 {
151 ariaLabelledBy: 'Hojas de Ruta', 156 ariaLabelledBy: 'Hojas de Ruta',
152 templateUrl: 'modal-hojas-ruta.html', 157 templateUrl: 'modal-hojas-ruta.html',
153 controller: 'focaOrdenCargaController', 158 controller: 'focaOrdenCargaController',
154 size: 'md', 159 size: 'md',
155 resolve: { 160 resolve: {
156 filters: { 161 filters: {
157 cisternas: $scope.hojaRuta.vehiculo.id 162 cisternas: $scope.hojaRuta.vehiculo.id
158 } 163 }
159 } 164 }
160 } 165 }
161 ); 166 );
162 var idVehiculo = $scope.hojaRuta.vehiculo.id 167 var idVehiculo = $scope.hojaRuta.vehiculo.id
163 focaOrdenCargaService.getHojasRuta(idVehiculo) 168 focaOrdenCargaService.getHojasRuta(idVehiculo)
164 .then(function (res) { 169 .then(function (res) {
165 console.log(res); 170 console.log(res);
166 }) 171 })
167 .catch(function (err) { 172 .catch(function (err) {
168 console.error(err) 173 console.error(err)
169 }) 174 })
170 } 175 }
171 176
172 $scope.seleccionarRemitoAbierto = function () { 177 $scope.seleccionarRemitoAbierto = function () {
173 if ($scope.hojaRuta.vehiculo.capacidad === 0) { 178 if ($scope.hojaRuta.vehiculo.capacidad === 0) {
174 focaModalService.alert('Debe ingresar vehiculo'); 179 focaModalService.alert('Debe ingresar vehiculo');
175 return; 180 return;
176 } else { 181 } else {
177 mostrarDetalle($scope.hojaRuta); 182 mostrarDetalle($scope.hojaRuta);
178 } 183 }
179 }; 184 };
180 185
181 $scope.seleccionarChofer = function () { 186 $scope.seleccionarChofer = function () {
182 var parametrosModal = { 187 var parametrosModal = {
183 titulo: 'Búsqueda de Chofer', 188 titulo: 'Búsqueda de Chofer',
184 query: '/chofer', 189 query: '/chofer',
185 columnas: [ 190 columnas: [
186 { 191 {
187 propiedad: 'id', 192 propiedad: 'id',
188 nombre: 'Código', 193 nombre: 'Código',
189 filtro: { 194 filtro: {
190 nombre: 'rellenarDigitos', 195 nombre: 'rellenarDigitos',
191 parametro: 3 196 parametro: 3
192 } 197 }
193 }, 198 },
194 { 199 {
195 propiedad: 'nombre', 200 propiedad: 'nombre',
196 nombre: 'Nombre' 201 nombre: 'Nombre'
197 }, 202 },
198 { 203 {
199 propiedad: 'dni', 204 propiedad: 'dni',
200 nombre: 'DNI' 205 nombre: 'DNI'
201 }, 206 },
202 { 207 {
203 propiedad: 'telefono', 208 propiedad: 'telefono',
204 nombre: 'Teléfono' 209 nombre: 'Teléfono'
205 } 210 }
206 ] 211 ]
207 }; 212 };
208 focaModalService.modal(parametrosModal).then( 213 focaModalService.modal(parametrosModal).then(
209 function (chofer) { 214 function (chofer) {
210 $scope.ordenCarga.chofer = chofer; 215 $scope.ordenCarga.chofer = chofer;
211 $scope.$broadcast('addCabecera', { 216 $scope.$broadcast('addCabecera', {
212 label: 'Chofer:', 217 label: 'Chofer:',
213 valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre 218 valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre
214 }); 219 });
215 220
216 $filter('filter')($scope.botonera, { 221 $filter('filter')($scope.botonera, {
217 label: 'Chofer', 222 label: 'Chofer',
218 })[0].checked = true; 223 })[0].checked = true;
219 }, function () { 224 }, function () {
220 // funcion ejecutada cuando se cancela el modal 225 // funcion ejecutada cuando se cancela el modal
221 } 226 }
222 ); 227 );
223 }; 228 };
224 229
225 $scope.seleccionarGraficar = function () { 230 $scope.seleccionarGraficar = function () {
226 if (!$scope.hojaRuta.vehiculo.cisternas.length) { 231 if (!$scope.hojaRuta.vehiculo.cisternas.length) {
227 focaModalService.alert('Primero seleccione un vehículo con cisternas'); 232 focaModalService.alert('Primero seleccione un vehículo con cisternas');
228 return; 233 return;
229 } 234 }
230 $uibModal.open( 235 $uibModal.open(
231 { 236 {
232 ariaLabelledBy: 'Grafico de cisternas', 237 ariaLabelledBy: 'Grafico de cisternas',
233 templateUrl: 'modal-grafico-cisternas.html', 238 templateUrl: 'modal-grafico-cisternas.html',
234 controller: 'focaModalGraficoCisternasController', 239 controller: 'focaModalGraficoCisternasController',
235 size: 'md', 240 size: 'md',
236 resolve: { 241 resolve: {
237 filters: { 242 filters: {
238 cisternas: $scope.hojaRuta.vehiculo.cisternas 243 cisternas: $scope.hojaRuta.vehiculo.cisternas
239 } 244 }
240 } 245 }
241 } 246 }
242 ); 247 );
243 }; 248 };
244 249
245 function elegirTransportista(transportista) { 250 function elegirTransportista(transportista) {
246 var codigo = ('00000' + transportista.COD).slice(-5); 251 var codigo = ('00000' + transportista.COD).slice(-5);
247 $scope.idTransportista = transportista.COD; 252 $scope.idTransportista = transportista.COD;
248 $scope.filtros = transportista.NOM.trim(); 253 $scope.filtros = transportista.NOM.trim();
249 $scope.$broadcast('addCabecera', { 254 $scope.$broadcast('addCabecera', {
250 label: 'Transportista:', 255 label: 'Transportista:',
251 valor: codigo + ' - ' + transportista.NOM 256 valor: codigo + ' - ' + transportista.NOM
252 }); 257 });
253 } 258 }
254 259
255 function getEstadosCisternas(cisternas) { 260 function getEstadosCisternas(cisternas) {
256 cisternas.forEach(function (cisterna) { 261 cisternas.forEach(function (cisterna) {
257 focaOrdenCargaService 262 focaOrdenCargaService
258 .getEstadoCisterna(cisterna.id, $scope.fecha) 263 .getEstadoCisterna(cisterna.id, $scope.fecha)
259 .then(function (res) { 264 .then(function (res) {
260 cisterna.estado = res.data; 265 cisterna.estado = res.data;
261 }) 266 })
262 .catch(function (err) { console.error(err) }); 267 .catch(function (err) { console.error(err) });
263 }); 268 });
264 } 269 }
265 270
266 function mostrarDetalle(hojasRutas) { 271 function mostrarDetalle(hojasRutas) {
267 var modalInstance = $uibModal.open( 272 var modalInstance = $uibModal.open(
268 { 273 {
269 ariaLabelledBy: '', 274 ariaLabelledBy: '',
270 templateUrl: 'modal-detalle-carga.html', 275 templateUrl: 'modal-detalle-carga.html',
271 controller: 'focaModalDetalleController', 276 controller: 'focaModalDetalleController',
272 resolve: { 277 resolve: {
273 parametrosModal: function () { 278 parametrosModal: function () {
274 return { 279 return {
275 hojasRutas: hojasRutas, 280 hojasRutas: hojasRutas,
276 orden: $scope.hojaRuta.orden 281 orden: $scope.hojaRuta.orden
277 }; 282 };
278 } 283 }
279 }, 284 },
280 size: 'lg', 285 size: 'lg',
281 backdrop: false 286 backdrop: false
282 } 287 }
283 ); 288 );
284 return modalInstance.result 289 return modalInstance.result
285 .then(function (res) { 290 .then(function (res) {
286 res.cisternas.forEach(function (cisterna) { 291 res.cisternas.forEach(function (cisterna) {
287 $scope.cisternaCargas.push(cisterna.cisternaCarga); 292 $scope.cisternaCargas.push(cisterna.cisternaCarga);
288 }); 293 });
289 $scope.cisternaMovimientos = res.movimientos; 294 $scope.cisternaMovimientos = res.movimientos;
290 $scope.articulosRecibidos = res.articulos; 295 $scope.articulosRecibidos = res.articulos;
291 $scope.articulos = res.articulos; 296 $scope.articulos = res.articulos;
292 $filter('filter')($scope.botonera, { 297 $filter('filter')($scope.botonera, {
293 label: 'Detalle de Carga', 298 label: 'Detalle de Carga',
294 })[0].checked = true; 299 })[0].checked = true;
295 }) 300 })
296 .catch(function (e) { console.error(e); }); 301 .catch(function (e) { console.error(e); });
297 }; 302 };
298 303
299 function crearOrdenCarga() { 304 function crearOrdenCarga() {
300 if (!$scope.hojaRuta.vehiculo) { 305 if (!$scope.hojaRuta.vehiculo) {
301 focaModalService.alert('Ingrese Vehículo'); 306 focaModalService.alert('Ingrese Vehículo');
302 return; 307 return;
303 } else if (!$scope.hojaRuta.chofer) { 308 } else if (!$scope.hojaRuta.chofer) {
304 focaBotoneraLateralService.alert('Ingrese Chofer'); 309 focaBotoneraLateralService.alert('Ingrese Chofer');
305 return; 310 return;
306 } 311 }
307 312
308 focaBotoneraLateralService.startGuardar(); 313 focaBotoneraLateralService.startGuardar();
309 $scope.saveLoading = true; 314 $scope.saveLoading = true;
310 315
311 } 316 }
312 317
313 $scope.$watch('ordenCarga', function (newValue) { 318 $scope.$watch('ordenCarga', function (newValue) {
314 focaBotoneraLateralService.setPausarData({ 319 focaBotoneraLateralService.setPausarData({
315 label: 'ordenCarga', 320 label: 'ordenCarga',
316 val: newValue 321 val: newValue
317 }); 322 });
318 }, true); 323 }, true);
319 324
320 $scope.$watch('ordenCarga', function (newValue) { 325 $scope.$watch('ordenCarga', function (newValue) {
321 focaBotoneraLateralService.setPausarData({ 326 focaBotoneraLateralService.setPausarData({
322 label: 'ordenCarga', 327 label: 'ordenCarga',
323 val: newValue 328 val: newValue
324 }); 329 });
325 focaBotoneraLateralService.setRutasPausadas({ 330 focaBotoneraLateralService.setRutasPausadas({
326 label: 'rutas', 331 label: 'rutas',
327 val: 'orden-carga' 332 val: 'orden-carga'
328 }); 333 });
329 }, true); 334 }, true);
330 335
331 $scope.salir = function () { 336 $scope.salir = function () {
332 $location.path('/'); 337 $location.path('/');
333 }; 338 };
334 339
335 function salir() { 340 function salir() {
336 var confirmacion = false; 341 var confirmacion = false;
337 342
338 if (!angular.equals($scope.ordenCarga, $scope.inicial)) { 343 if (!angular.equals($scope.ordenCarga, $scope.inicial)) {
339 confirmacion = true; 344 confirmacion = true;
340 } 345 }
341 346
342 if (confirmacion) { 347 if (confirmacion) {
343 focaModalService.confirm( 348 focaModalService.confirm(
344 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 349 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
345 ).then(function (data) { 350 ).then(function (data) {
346 if (data) { 351 if (data) {
347 $location.path('/'); 352 $location.path('/');
348 } 353 }
349 }); 354 });
350 } else { 355 } else {
351 $location.path('/'); 356 $location.path('/');
352 } 357 }
353 } 358 }
354 }]); 359 }]);
355 360
src/views/orden-carga.html
1 <div class="row"> 1 <div class="row">
2 <foca-cabecera-facturador titulo="'Orden de Carga'" numero="puntoVenta + '-' + comprobante" 2 <foca-cabecera-facturador titulo="'Orden de Carga'" numero="puntoVenta + '-' + comprobante"
3 fecha="ordenCarga.fechaCarga" class="mb-0 col-lg-12"></foca-cabecera-facturador> 3 fecha="ordenCarga.fechaCarga" class="mb-0 col-lg-12"></foca-cabecera-facturador>
4 </div> 4 </div>
5 <div class="row"> 5 <div class="row">
6 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> 6 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded">
7 <div class="row px-5 py-2 botonera-secundaria"> 7 <div class="row px-5 py-2 botonera-secundaria">
8 <div class="col-12"> 8 <div class="col-12">
9 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> 9 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador>
10 </div> 10 </div>
11 </div> 11 </div>
12 12
13 <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> 13 <table class="cursero-default table table-default table-hover table-sm table-abm table-striped mb-0">
14 <thead> 14 <thead>
15 <tr> 15 <tr>
16 <th>Cisterna</th> 16 <th>Cisterna</th>
17 <th>Producto</th> 17 <th>Producto</th>
18 <th>Capacidad Total</th> 18 <th>Capacidad Total</th>
19 <th>Carga</th> 19 <th>Carga</th>
20 <th>Disponible</th> 20 <th class="text-center">Disponible</th>
21 <th class="text-center">
22 </th>
23 </tr> 21 </tr>
24 </thead> 22 </thead>
25 <tbody> 23 <tbody>
26 <tr ng-repeat="cisterna in hojaRuta.vehiculo.cisternas"> 24 <tr ng-repeat="cisterna in hojaRuta.vehiculo.cisternas">
27 <td ng-bind="cisterna.codigo"></td> 25 <td ng-bind="cisterna.codigo"></td>
28 <td>producto</td> 26 <td>producto</td>
29 <td ng-bind="cisterna.capacidad"></td> 27 <td ng-bind="cisterna.capacidad"></td>
30 <td ng-bind="cisterna.cantidadDescargada"></td> 28 <td ng-bind="cisterna.cantidadDescargada"></td>
31 <td>{{cisterna.capacidad - cisterna.cantidadDescargada}}</td> 29 <td class="text-center">{{cisterna.capacidad - cisterna.cantidadDescargada}}</td>
32 </tr> 30 </tr>
33 </tbody> 31 </tbody>
34 </table> 32 </table>
35 </div> 33 </div>
36 </div> 34 </div>
37 35