Commit b39c3ddb88524a187b5bd5eccaa8b37d7bafcca6

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !22
... ... @@ -4,6 +4,7 @@
4 4 "description": "Modal de búsqueda de detalles de hoja de ruta",
5 5 "main": "index.js",
6 6 "scripts": {
  7 + "refresh" : "gulp uglify && cp tmp/foca-modal-detalle-hoja-ruta.js ../wrapper-demo/node_modules/foca-modal-detalle-hoja-ruta/dist/foca-modal-detalle-hoja-ruta.min.js",
7 8 "test": "echo \"Error: no test specified\" && exit 1",
8 9 "gulp-pre-commit": "gulp pre-commit",
9 10 "compile": "gulp uglify",
src/js/controller.js
1 1 angular.module('focaModalDetalleHojaRuta')
2   - .controller('focaModalDetalleHojaRutaController',
  2 + .controller('focaModalDetalleHojaRutaController',
3 3 [
4   - '$filter',
5   - '$scope',
6   - '$uibModalInstance',
7   - 'parametros',
8   - 'focaModalDetalleHojaRutaService',
9   - 'focaModalService',
10   - 'focaSeguimientoService',
11   - '$uibModal',
12   - function($filter, $scope, $uibModalInstance, parametros, focaModalDetalleHojaRutaService,
13   - focaModalService, focaSeguimientoService, $uibModal)
14   - {
15   - //Seteo variables
  4 + '$filter', '$scope', '$uibModalInstance', 'parametros', 'focaModalDetalleHojaRutaService',
  5 + 'focaModalService', 'focaSeguimientoService', '$uibModal',
  6 + function ($filter, $scope, $uibModalInstance, parametros, focaModalDetalleHojaRutaService,
  7 + focaModalService, focaSeguimientoService, $uibModal) {
  8 + //#region SETEO VARIABLES
16 9 $scope.remito = parametros.remito;
17 10 $scope.cisternas = parametros.remito.cisternas;
18 11 $scope.articuloSeleccionado = {};
19 12 $scope.aDescargar = [];
20 13 $scope.cargando = false;
  14 + //#endregion
21 15  
22   - if ($scope.remito.rechazado) {
23   -
24   - $scope.readonly = true;
  16 + function init() {
  17 + if ($scope.remito.rechazado) {
  18 + $scope.readonly = true;
  19 + }
  20 + var articuloAChequear = $scope.remito.articulosRemito.filter(function (articulo) {
  21 + return !articulo.descargado;
  22 + });
  23 + if (!articuloAChequear.length || $scope.remito.rechazado) {
  24 + $scope.readonly = true;
  25 + $scope.cambio($scope.remito.articulosRemito[0]);
  26 + } else {
  27 + $scope.cambio(articuloAChequear[0]);
  28 + }
25 29 }
26 30  
27   - //Datos
28   - // var promesaRemito = focaModalDetalleHojaRutaService
29   - // .getRemitoById(idRemito);
30   - // var promesaCisternas = focaModalDetalleHojaRutaService
31   - // .getCisternasByIdRemito(idRemito);
32   -
33   - // Promise.all([promesaRemito, promesaCisternas]).then(function(res) {
34   - // $scope.cargando = false;
35   - // $scope.remito = res[0].data;
36   - // $scope.cisternas = res[1].data;
37   - // var articuloAChequear = $scope.remito.articulosRemito.filter(
38   - // function(articulo) {
39   - // return !articulo.descargado;
40   - // });
41   - // if(!articuloAChequear.length || $scope.remito.rechazado) {
42   - // $scope.readonly = true;
43   - // $scope.cambio($scope.remito.articulosRemito[0]);
44   - // }else {
45   - // $scope.cambio(articuloAChequear[0]);
46   - // }
47   - // $scope.$digest();
48   - // }, function() {
49   - // focaModalService.alert('El servicio no responde intente más tarde');
50   - // $uibModalInstance.dismiss();
51   - // });
52   - $scope.cambio = function(articulo) {
53   - if(!$scope.articuloSeleccionado.descargado) {
  31 + $scope.cambio = function (articulo) {
  32 + if (!$scope.articuloSeleccionado.descargado) {
54 33 $scope.articuloSeleccionado.cantidadDescargada = 0;
55 34 }
56 35 $scope.aDescargar = [];
57 36 $scope.articuloSeleccionado = articulo;
58 37 };
59   - $scope.descargar = function(key) {
60   - if(key === 13) {
  38 + $scope.descargar = function (key) {
  39 + if (key === 13) {
61 40 $scope.cargando = true;
62 41 var hojaRutaMovimientos = [];
63 42 var cisternaMovimientos = [];
64 43 var cisternaCargas = [];
65 44 var totalADescargar = 0;
66   - for(var i = 0; i < $scope.aDescargar.length; i++) {
  45 + for (var i = 0; i < $scope.aDescargar.length; i++) {
67 46 totalADescargar += $scope.aDescargar[i] || 0;
68 47 }
69 48 focaModalService
70 49 .confirm('¿Desea descargar ' + totalADescargar + ' litros de ' +
71   - $scope.articuloSeleccionado.descripcion + '?')
72   - .then(descargar, function() {
  50 + $scope.articuloSeleccionado.descripcion + '?')
  51 + .then(descargar, function () {
73 52 $scope.cargando = false;
74 53 });
75 54 }
76 55 function descargar() {
77   - for(var i = 0; i < $scope.cisternas.length; i++) {
  56 + for (var i = 0; i < $scope.cisternas.length; i++) {
78 57 var descarga = $scope.aDescargar[i];
79 58 var cisternaCarga = $scope.cisternas[i].cisternaCarga;
80   - if(!descarga) continue;
81   - if(descarga > cisternaCarga.cantidad) {
  59 + if (!descarga) continue;
  60 + if (descarga > cisternaCarga.cantidad) {
82 61 focaModalService.alert('La cantidad a descargar no debe ser ' +
83 62 'mayor a la cantidad de la cisterna');
84 63 $scope.cargando = false;
... ... @@ -117,13 +96,13 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
117 96 $scope.remito.observaciones = '';
118 97  
119 98 if ($scope.articuloSeleccionado.cantidadDescargada ===
120   - $scope.articuloSeleccionado.cantidad ) {
  99 + $scope.articuloSeleccionado.cantidad) {
121 100  
122   - $scope.articuloSeleccionado.descargado = true;
  101 + $scope.articuloSeleccionado.descargado = true;
123 102 }
124 103  
125 104 var siguienteArticulo = $scope.remito.articulosRemito.filter(
126   - function(articulo) {
  105 + function (articulo) {
127 106 return articulo.id != $scope.articuloSeleccionado.id;
128 107 }
129 108 );
... ... @@ -132,7 +111,7 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
132 111 $scope.cambio(siguienteArticulo[0]);
133 112 }
134 113  
135   - success().then(function() {
  114 + success().then(function () {
136 115 $uibModalInstance.close($scope.remito);
137 116 });
138 117 //TODO: enviar puntos de descarga, se quita para la demo.
... ... @@ -159,80 +138,83 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
159 138 }
160 139 }
161 140 };
162   -
163   - $scope.cancel = function() {
  141 + $scope.cancel = function () {
164 142 $uibModalInstance.dismiss('cancel');
165 143 };
166   -
167   - $scope.distribucionDisponible = function() {
168   - return $scope.articuloSeleccionado.cantidadDescargada &&
  144 + $scope.distribucionDisponible = function () {
  145 + return $scope.articuloSeleccionado.cantidadDescargada &&
169 146 $scope.articuloSeleccionado.cantidadDescargada <=
170 147 $scope.articuloSeleccionado.cantidad;
171 148 };
172   -
173   - $scope.actualizarArticulo = function() {
  149 + $scope.actualizarArticulo = function () {
174 150 $scope.articuloSeleccionado.cantidadDescargada = 0;
175   - for(var i = 0; i < $scope.aDescargar.length; i++) {
  151 + for (var i = 0; i < $scope.aDescargar.length; i++) {
176 152 $scope.articuloSeleccionado.cantidadDescargada +=
177 153 parseFloat($scope.aDescargar[i]) || 0;
178 154 }
179 155 };
180   -
181   - $scope.actualizarPuntoDescarga = function() {
  156 + $scope.actualizarPuntoDescarga = function () {
182 157 var modalInstance = $uibModal.open(
183 158 {
184 159 ariaLabelledBy: 'Actualizar punto de descarga',
185 160 templateUrl: 'modal-actualizar-punto-descarga.html',
186 161 controller: 'focaModalActualizarPuntoDescargaController',
187 162 resolve: {
188   - notaPedido: function() {
  163 + notaPedido: function () {
189 164 return $scope.remito.notaPedido;
190 165 }
191 166 },
192 167 size: 'lg'
193 168 }
194 169 );
195   - modalInstance.result.then(function() {
196   - success().then(function() {
  170 + modalInstance.result.then(function () {
  171 + success().then(function () {
197 172 $uibModalInstance.close($scope.remito);
198 173 });
199   - }, function() {
200   - success().then(function() {
  174 + }, function () {
  175 + success().then(function () {
201 176 $uibModalInstance.close($scope.remito);
202 177 });
203 178 });
204 179 };
205   -
206   - $scope.rechazar = function() {
  180 + $scope.rechazar = function () {
207 181 focaModalService
208 182 .prompt({
209 183 titulo: 'Aclare el motivo de rechazo'
210 184 })
211   - .then(function(motivo) {
  185 + .then(function (motivo) {
212 186 $scope.cargando = true;
213 187 var remitoRechazado = $.extend(true, {}, $scope.remito);
214 188 delete remitoRechazado.articulosRemito;
215 189 delete remitoRechazado.notaPedido;
216 190 delete remitoRechazado.cisternas;
  191 + delete remitoRechazado.cotizacion;
  192 + delete remitoRechazado.proveedor;
  193 + delete remitoRechazado.vendedor;
217 194 remitoRechazado.rechazado = true;
218 195 remitoRechazado.motivoRechazo = motivo;
219 196 remitoRechazado.fechaRemito =
220 197 remitoRechazado.fechaRemito.slice(0, 19).replace('T', ' ');
221 198  
222 199 focaModalDetalleHojaRutaService.rechazarRemito(remitoRechazado)
223   - .then(function(res) {
  200 + .then(function (res) {
224 201 focaSeguimientoService.guardarPosicion(
225 202 'Entrega de producto',
226 203 res.data[1].id,
227 204 motivo);
228   - success();
229   - })
  205 + $scope.remito.rechazado = true;
  206 + success().then(function () {
  207 + $uibModalInstance.close($scope.remito);
  208 + });
  209 + })
230 210 .catch(error);
231 211 $scope.readonly = true;
232   - });
  212 + })
  213 + .catch(function (e) { console.info("modal", e); });
233 214 };
234 215  
235   - //funciones
  216 + //#region FUNCIONES
  217 + init();
236 218 function error(error) {
237 219 focaModalService.alert('Hubo un error ' + error);
238 220 }
... ... @@ -240,22 +222,10 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
240 222 $scope.cargando = false;
241 223 return focaModalService.alert('Operación realizada con éxito');
242 224 }
243   -
244   - var articuloAChequear = $scope.remito.articulosRemito.filter(
245   - function(articulo) {
246   - return !articulo.descargado;
247   - });
248   -
249   - if (!articuloAChequear.length || $scope.remito.rechazado) {
250   - $scope.readonly = true;
251   - $scope.cambio($scope.remito.articulosRemito[0]);
252   - } else {
253   - $scope.cambio(articuloAChequear[0]);
254   - }
255   -
  225 + //#endregion
256 226 }
257 227 ])
258   - .controller('focaModalActualizarPuntoDescargaController',
  228 + .controller('focaModalActualizarPuntoDescargaController',
259 229 [
260 230 '$scope',
261 231 '$uibModalInstance',
... ... @@ -263,16 +233,15 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
263 233 'focaModalService',
264 234 'notaPedido',
265 235 'focaModalDetalleHojaRutaService',
266   - function($scope, $uibModalInstance, focaSeguimientoService,
267   - focaModalService, notaPedido, focaModalDetalleHojaRutaService)
268   - {
  236 + function ($scope, $uibModalInstance, focaSeguimientoService,
  237 + focaModalService, notaPedido, focaModalDetalleHojaRutaService) {
269 238 $scope.notaPedido = notaPedido;
270 239 $scope.descripcion = '';
271   - focaSeguimientoService.obtenerPosicion(function(res) {
  240 + focaSeguimientoService.obtenerPosicion(function (res) {
272 241 $scope.posicion = res.coords;
273 242 });
274 243  
275   - $scope.cancel = function() {
  244 + $scope.cancel = function () {
276 245 if ($scope.ingreso) {
277 246 $scope.ingreso = false;
278 247 } else {
... ... @@ -280,7 +249,7 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
280 249 }
281 250 };
282 251  
283   - $scope.select = function(puntoDescarga) {
  252 + $scope.select = function (puntoDescarga) {
284 253 if (!$scope.posicion) {
285 254 focaModalService.alert('No se pudo obtener la ubicación');
286 255 return;
... ... @@ -291,7 +260,7 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
291 260 $uibModalInstance.close();
292 261 };
293 262  
294   - $scope.guardar = function() {
  263 + $scope.guardar = function () {
295 264 if (!$scope.posicion) {
296 265 focaModalService.alert('No se pudo obtener la ubicación');
297 266 return;
... ... @@ -305,7 +274,7 @@ angular.module(&#39;focaModalDetalleHojaRuta&#39;)
305 274 latitud: $scope.posicion.latitude,
306 275 longitud: $scope.posicion.longitude
307 276 })
308   - .then(function(res) {
  277 + .then(function (res) {
309 278 $uibModalInstance.close(res.data);
310 279 });
311 280 };
src/views/modal-detalle-hoja-ruta.html
1   -<div class="modal-header py-1">
  1 +<div class="modal-header">
2 2 <h5 class="modal-title">Detalle de descarga</h5>
3 3 </div>
4 4 <div class="modal-body" id="modal-body" ladda="cargando" data-spinner-color="#FF0000" data-spinner-size="5">
5 5 <form name="formDetalleHojaRuta">
6 6 <div class="form-group row" ng-show="!cargando">
7   - <div class="col-12 px-0">
  7 + <div class="col-12">
8 8 <strong>Información Remito</strong>
9 9 <button
10 10 class="btn btn-sm btn-light selectable"
11   - ng-click="verInformacion = !verInformacion"
12   - ><i
13   - class="fa fa-chevron-up"
14   - ng-show="verInformacion"></i>
15   - <i
16   - class="fa fa-chevron-down"
17   - ng-hide="verInformacion">
18   - </i>
  11 + ng-click="verInformacion = !verInformacion">
  12 + <i class="fa fa-chevron-up" ng-show="verInformacion"></i>
  13 + <i class="fa fa-chevron-down" ng-hide="verInformacion"></i>
19 14 </button>
20 15 </div>
21   - <div class="row" ng-show="verInformacion">
  16 + <div class="row m-0" ng-show="verInformacion">
22 17 <div class="col-12">
23   - <label class="form-control-sm">
  18 + <small>
24 19 <b>Remito Nº</b>
25 20 <span ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"/>
26   - </label>
  21 + </small>
27 22 </div>
28 23 <div class="col-12">
29   - <label class="form-control-sm">
  24 + <small>
30 25 <b>Cliente</b>
31   - </label>
32   - <span ng-bind="remito.nombreCliente"/>
  26 + <span ng-bind="remito.nombreCliente"/>
  27 + </small>
33 28 </div>
34 29 <div class="col-12">
35   - <label class="form-control-sm">
  30 + <small>
36 31 <b>Domicilio</b>
37 32 <span ng-bind="remito.domicilioStamp"/>
38   - </label>
  33 + </small>
39 34 </div>
40 35 <div ng-show="remito.notaPedido.notaPedidoPuntoDescarga.length" class="px-3">
41 36 <label class="form-control-sm">
... ... @@ -54,94 +49,106 @@
54 49 </table>
55 50 </div>
56 51 </div>
57   - <strong>Articulo a descargar</strong>
58   - <table class="table table-sm">
59   - <thead>
60   - <tr>
61   - <th></th>
62   - <th>Articulo</th>
63   - <th>Total</th>
64   - <th>Descargado</th>
65   - </tr>
66   - </thead>
67   - <tbody>
68   - <tr ng-repeat="(key, articulo) in remito.articulosRemito">
69   - <td class="pt-2">
70   - <input
71   - type="radio"
72   - name="articuloRadio"
73   - id="{{'articulo' + articulo.id}}"
74   - ng-click="cambio(articulo)"
75   - ng-disabled="articulo.descargado || readonly"
76   - ng-checked="articuloSeleccionado.id === articulo.id"
77   - ></td>
78   - <td ng-bind="articulo.descripcion"></td>
79   - <td ng-bind="articulo.cantidad"></td>
80   - <td ng-bind="articulo.cantidadDescargada || 0"></td>
81   - </tbody>
82   - </table>
83   - <strong>Cisterna</strong>
84   - <table class="table table-sm">
85   - <thead>
86   - <tr>
87   - <th>Código</th>
  52 + <div class="col py-3">
  53 + <strong>Articulo a descargar</strong>
  54 + <table class="table table-sm mt-2">
  55 + <thead>
  56 + <tr>
  57 + <th></th>
88 58 <th>Articulo</th>
89 59 <th>Total</th>
90   - <th>A descargar</th>
  60 + <th>Descargado</th>
91 61 </tr>
92   - </thead>
93   - <tbody>
94   - <tr ng-repeat="(key, cisterna) in cisternas">
95   - <td ng-bind="cisterna.codigo"></td>
96   - <td ng-bind="cisterna.cisternaCarga.articulo.DetArt"></td>
97   - <td ng-bind="cisterna.cisternaCarga.cantidad"></td>
98   - <td><input
  62 + </thead>
  63 + <tbody>
  64 + <tr ng-repeat="(key, articulo) in remito.articulosRemito">
  65 + <td class="pt-2">
  66 + <input
  67 + type="radio"
  68 + name="articuloRadio"
  69 + id="{{'articulo' + articulo.id}}"
  70 + ng-click="cambio(articulo)"
  71 + ng-disabled="articulo.descargado || readonly"
  72 + ng-checked="articuloSeleccionado.id === articulo.id"
  73 + ></td>
  74 + <td ng-bind="articulo.descripcion"></td>
  75 + <td ng-bind="articulo.cantidad"></td>
  76 + <td ng-bind="articulo.cantidadDescargada || 0"></td>
  77 + </tbody>
  78 + </table>
  79 + <strong>Cisterna</strong>
  80 + <table class="table table-sm mt-2">
  81 + <thead>
  82 + <tr>
  83 + <th>Código</th>
  84 + <th>Articulo</th>
  85 + <th>Total</th>
  86 + <th>A Descargar</th>
  87 + </tr>
  88 + </thead>
  89 + <tbody>
  90 + <tr ng-repeat="(key, cisterna) in cisternas">
  91 + <td class="align-middle" ng-bind="cisterna.codigo"></td>
  92 + <td class="align-middle" ng-bind="cisterna.cisternaCarga.articulo.DetArt"></td>
  93 + <td class="align-middle" ng-bind="cisterna.cisternaCarga.cantidad"></td>
  94 + <td><input
  95 + class="form-control form-control-sm"
  96 + type="number"
  97 + ng-model="aDescargar[key]"
  98 + ng-change="actualizarArticulo()"
  99 + foca-focus="articuloSeleccionado.idArticulo == cisterna.cisternaCarga.idProducto"
  100 + ng-disabled="articuloSeleccionado.idArticulo != cisterna.cisternaCarga.idProducto
  101 + || readonly"/></td>
  102 + </tr>
  103 + </tbody>
  104 + </table>
  105 + <div class="col-12 px-0">
  106 + <label class="small">
  107 + <b>Observaciones</b>
  108 + </label>
  109 + </div>
  110 + <div class="col-12 px-0">
  111 + <textarea
  112 + ng-model="remito.observaciones"
  113 + ng-disabled="readonly"
99 114 class="form-control form-control-sm"
100   - type="number"
101   - ng-model="aDescargar[key]"
102   - ng-change="actualizarArticulo()"
103   - foca-focus="articuloSeleccionado.idArticulo == cisterna.cisternaCarga.idProducto"
104   - ng-disabled="articuloSeleccionado.idArticulo != cisterna.cisternaCarga.idProducto
105   - || readonly"/></td>
106   - </tr>
107   - </tbody>
108   - </table>
109   - <div class="col-12 px-0">
110   - <label class="form-control-sm px-0">
111   - <b>Observaciones</b>
112   - </label>
113   - </div>
114   - <div class="col-12">
115   - <textarea
116   - ng-model="remito.observaciones"
117   - ng-disabled="readonly"
118   - class="form-control form-control-sm"
119   - rows="1"
120   - ></textarea>
121   - </div>
122   - <div class="col-12 row mt-2">
123   - <label class="form-control-sm px-0 col-3"><b>Nº Recibo</b></label>
124   - <input
125   - class="form-control form-control-sm col-4"
126   - type="number"
127   - ng-disabled="readonly"
128   - ng-model="numeroRecibo"
129   - ng-keypress="descargar($event.keyCode)"
130   - foca-focus="articuloSeleccionado.cantidadDescargada === articuloSeleccionado.cantidad">
131   - <button
132   - class="ml-4 form-control-sm btn btn-success col-4"
133   - ladda="cargando"
134   - data-spinner-color="#FF0000"
135   - type="button"
136   - ng-disabled="!distribucionDisponible() || !numeroRecibo"
137   - ng-click="descargar(13)">
138   - Descargar
139   - </button>
  115 + rows="1"
  116 + ></textarea>
  117 + </div>
  118 + <div class="row mt-2">
  119 + <div class="col-auto my-auto">
  120 + <span class="small"><b>Nº Recibo</b></span>
  121 + </div>
  122 + <div class="col px-0">
  123 + <input
  124 + class="form-control form-control-sm"
  125 + type="number"
  126 + ng-disabled="readonly"
  127 + ng-model="numeroRecibo"
  128 + ng-keypress="descargar($event.keyCode)"
  129 + foca-focus="articuloSeleccionado.cantidadDescargada === articuloSeleccionado.cantidad">
  130 + </div>
  131 + <div class="col-auto">
  132 + <button
  133 + class="btn btn-success btn-sm btn-block"
  134 + ladda="cargando"
  135 + data-spinner-color="#FF0000"
  136 + type="button"
  137 + ng-disabled="!distribucionDisponible() || !numeroRecibo"
  138 + ng-click="descargar(13)">
  139 + Descargar
  140 + </button>
  141 + </div>
  142 + </div>
  143 + <div class="row mt-3" ng-show="remito.rechazado">
  144 + <div class="col-12">
  145 + <div class="bg-danger text-center text-white p-2">
  146 + Remito rechazado
  147 + </div>
  148 + </div>
  149 + </div>
  150 + </div>
140 151 </div>
141   -
142   - <label
143   - class="col-12 bg-danger text-white" ng-show="remito.rechazado"
144   - >Remito rechazado</label>
145 152 </form>
146 153 </div>
147 154 <div class="modal-footer py-2">