Commit a91d70519e999231a417b37e98e1d02863124f9e

Authored by Marcelo Puebla
Exists in master

Merge branch 'develop' of git.focasoftware.com:npm/foca-crear-hoja-ruta

src/js/controller.js
... ... @@ -208,7 +208,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
208 208 }
209 209 };
210 210  
211   - $scope.quitarArticulo = function (key ,articulo) {
  211 + $scope.quitarArticulo = function (key) {
212 212 $scope.articulos.splice(key, 1);
213 213 };
214 214  
... ... @@ -271,7 +271,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
271 271 return true;
272 272  
273 273 }
274   -
  274 +
275 275 function getImporte(propiedad) {
276 276 var importe = 0;
277 277  
... ... @@ -301,7 +301,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
301 301 cuitCliente: $scope.hojaRuta.cliente.CUIT,
302 302 idVendedor: $cookies.get('vendedorCobrador'),
303 303 idProveedor: $scope.hojaRuta.proveedor.COD,
304   - idDomicilio: $scope.hojaRuta.idDomicilio || $scope.hojaRuta.domicilio.id,
  304 + idDomicilio: $scope.hojaRuta.idDomicilio ||
  305 + $scope.hojaRuta.domicilio.id,
305 306 idCotizacion: $scope.hojaRuta.cotizacion.ID,
306 307 domicilioStamp: $scope.hojaRuta.domicilioStamp,
307 308 observaciones: $scope.hojaRuta.observaciones,
... ... @@ -361,7 +362,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
361 362 guardarHojaRuta(data.data.id);
362 363  
363 364 }, function (error) {
364   - focaModalService.alert(error.data || 'Hubo un error al crear el remito');
  365 + focaModalService.alert(
  366 + error.data || 'Hubo un error al crear el remito');
365 367 focaBotoneraLateralService.endGuardar();
366 368 $scope.saveLoading = false;
367 369 console.info(error);
... ... @@ -379,14 +381,17 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
379 381 idChofer: $scope.hojaRuta.chofer.id,
380 382 idVehiculo: $scope.hojaRuta.vehiculo.id,
381 383 proveedor: $scope.hojaRuta.proveedor.id,
382   - fechaReparto:
383   - new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10),
  384 + fechaReparto: new Date($scope.hojaRuta.fechaReparto)
  385 + .toISOString()
  386 + .substring(0, 10),
384 387 estado: 0,
385 388 abierta: 1
386 389 },
387 390 remitos: [{id: idRemito}]
388   - }
389   - save2.hojaRuta = angular.extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra);
  391 + };
  392 +
  393 + save2.hojaRuta = angular
  394 + .extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra);
390 395 focaCrearHojaRutaService.crearHojaRuta(save2).then(
391 396 function (data) {
392 397 var remitoNumero;
... ... @@ -405,7 +410,10 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
405 410 config();
406 411 },
407 412 function (error) {
408   - focaModalService.alert('Hubo un error al crear la hoja de ruta');
  413 +
  414 + focaModalService
  415 + .alert('Hubo un error al crear la hoja de ruta');
  416 +
409 417 console.info(error);
410 418 }
411 419 );
src/js/controllerDetalles.js
1 1 angular.module('focaCrearHojaRuta')
2 2 .controller('focaModalDetalleController', [
3 3 '$scope', '$timeout', '$uibModalInstance', 'focaModalService',
4   - 'focaCrearHojaRutaService', 'hojasRutas', '$uibModal', '$filter',
  4 + 'focaCrearHojaRutaService', 'hojasRutas',
5 5 function ($scope, $timeout, $uibModalInstance, focaModalService,
6   - focaCrearHojaRutaService, hojasRutas, $uibModal, $filter) {
  6 + focaCrearHojaRutaService, hojasRutas) {
7 7  
8 8 $scope.mostrar = false;
9 9 $scope.articulos = [];
... ... @@ -144,23 +144,21 @@ angular.module('focaCrearHojaRuta')
144 144 };
145 145  
146 146 $scope.cancel = function () {
147   - var validarCisternas = validarArticulos();
148   - if (validarCisternas !== undefined) {
149   - $uibModalInstance.dismiss(null);
150   - }
  147 + $uibModalInstance.dismiss(null);
151 148 };
152 149  
153 150 function validarArticulos () {
154   - var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) {
155   - return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado;
156   - });
  151 + var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas
  152 + .filter(function (cisterna) {
  153 + return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado;
  154 + });
157 155  
158 156 var cisternasIncompletas = cisternasFilter.filter(function(cisterna) {
159 157 return (cisterna.articuloSeleccionado && !cisterna.disponible) ||
160 158 (!cisterna.articuloSeleccionado && cisterna.disponible);
161 159 });
162 160  
163   - if (cisternasIncompletas.length || !cisternasFilter.length) {
  161 + if (cisternasIncompletas.length > 0 && cisternasFilter.length > 0 ) {
164 162 focaModalService.alert('Ingrese todos los campos para completar el remito');
165 163 cisternasFilter = undefined;
166 164 }
... ... @@ -8,9 +8,8 @@ angular.module('focaCrearHojaRuta')
8 8 return $http.post(route + '/hoja-ruta', hojaRuta);
9 9 },
10 10 crearRemito: function(remito) {
11   - console.log('Crear remito-----: ', remito);
12 11 // TODO: Cambiar para usar el servicio /remito
13   - return $http.post(route + '/remito', remito);
  12 + return $http.post(route + '/remito/guardar', remito);
14 13 },
15 14 obtenerHojaRuta: function() {
16 15 return $http.get(route +'/hoja-ruta');
src/views/hoja-ruta.html
... ... @@ -24,9 +24,8 @@
24 24 </div>
25 25 <div class="row">
26 26 <div class="col">
27   - <!-- PC -->
28 27 <div class="row grilla-articulo align-items-end d-none d-sm-flex">
29   - <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
  28 + <table ng-show="remitoAbierto" class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
30 29 <thead>
31 30 <tr class="d-flex">
32 31 <th class="">#</th>
... ... @@ -193,6 +192,79 @@
193 192 </tr>
194 193 </tfoot>
195 194 </table>
  195 + <table ng-hide="remitoAbierto" class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
  196 + <thead>
  197 + <tr class="d-flex">
  198 + <th class="col-auto">#</th>
  199 + <th class="col-2">Remito</th>
  200 + <th class="col">Cliente</th>
  201 + <th class="col">Direcciรณn</th>
  202 + <th class="col-auto"></th>
  203 + <th class="col-auto">
  204 + <button
  205 + class="btn btn-outline-light selectable"
  206 + ng-click="show = !show; masMenos()"
  207 + >
  208 + <i
  209 + class="fa fa-chevron-down"
  210 + ng-show="show"
  211 + aria-hidden="true"
  212 + >
  213 + </i>
  214 + <i
  215 + class="fa fa-chevron-up"
  216 + ng-hide="show"
  217 + aria-hidden="true">
  218 + </i>
  219 + </button>
  220 + </th>
  221 + </tr>
  222 + </thead>
  223 + <tbody class="tabla-articulo-body">
  224 + <tr
  225 + ng-repeat="(key, remito) in hojaRuta.remitosTabla"
  226 + class="d-flex"
  227 + ng-show="show || key == hojaRuta.remitosTabla.length - 1"
  228 + >
  229 + <td ng-bind="key + 1" class="col-auto"></td>
  230 + <td
  231 + class="col-2"
  232 + >{{remito.sucursal | rellenarDigitos: 4}}-{{remito.numeroRemito | rellenarDigitos: 8}}</td>
  233 + <th class="col" ng-bind="remito.nombreCliente"></th>
  234 + <th class="col" ng-bind="remito.domicilioStamp"></th>
  235 + <td class="text-center col-auto">
  236 + <button
  237 + class="btn btn-outline-light"
  238 + ng-click="verProductosRemito(remito.id)"
  239 + title="Ver productos"
  240 + >
  241 + <i class="fa fa-eye"></i>
  242 + </button>
  243 + </td>
  244 + <td class="text-center col-auto">
  245 + <button
  246 + class="btn btn-outline-light"
  247 + ng-click="desasociarRemito(key, remito.id)"
  248 + title="Eliminar">
  249 + <i class="fa fa-trash"></i>
  250 + </button>
  251 + </td>
  252 + </tr>
  253 + </tbody>
  254 + <tfoot>
  255 + <tr class="d-flex">
  256 + <td class="col-auto px-1">
  257 + <strong>Remitos:</strong>
  258 + <a ng-bind="hojaRuta.remitosTabla.length"></a>
  259 + </td>
  260 + <td class="col"></td>
  261 + <td class="col-auto px-1">
  262 + <strong>Cantidad:</strong>
  263 + <a ng-bind="hojaRuta.litros"></a>
  264 + </td>
  265 + </tr>
  266 + </tfoot>
  267 + </table>
196 268 </div>
197 269 </div>
198 270 </div>