Commit 23f668444968c0d79b00fc6d69d05c9a79d3ebde

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !10
src/js/controller.js
... ... @@ -19,10 +19,10 @@ angular.module('focaHojaRuta')
19 19 ) {
20 20 var loginData = focaLoginService.getLoginData();
21 21  
22   - hojaRutaService.getHojasRuta(loginData.chofer).then(function(res) {
  22 + hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) {
23 23 if (res.data) {
24 24 var hojaRuta = res.data;
25   - $scope.hojasRuta = hojaRuta;
  25 + $scope.hojaRuta = hojaRuta;
26 26 $scope.puntoVenta = hojaRuta.sucursal;
27 27 $scope.comprobante = hojaRuta.numeroHojaRuta;
28 28 addCabecera('Transportista:', hojaRuta.transportista.NOM);
... ... @@ -92,18 +92,28 @@ angular.module('focaHojaRuta')
92 92 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' +
93 93 'otra descarga ni modificación')
94 94 .then(function() {$scope.datosExtraCierre(terminar);});
95   - function terminar(hojaRuta) {
96   - console.log(hojaRuta);
97   - //TODO: refactor servivcio para recibir nuevos parámetros
98   - // hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then(
99   - // function() {
100   - // focaModalService.alert(
101   - // 'Hoja de ruta ' +
102   - // $filter('comprobante')([$scope.puntoVenta,
103   - // $scope.comprobante]) + ' cerrada con éxito');
104   - // $location.path('/');
105   - // }
106   - // );
  95 + function terminar(datosExtraCierre) {
  96 + $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre);
  97 + //limpio objeto para guardar
  98 + delete $scope.hojaRuta.chofer;
  99 + delete $scope.hojaRuta.remitos;
  100 + delete $scope.hojaRuta.transportista;
  101 + delete $scope.hojaRuta.vehiculo;
  102 +
  103 + $scope.hojaRuta.fechaCreacion =
  104 + $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' ');
  105 + $scope.hojaRuta.fechaReparto =
  106 + $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' ');
  107 + $scope.hojaRuta.estado = 2;
  108 + hojaRutaService.terminarHojaRuta($scope.hojaRuta).then(
  109 + function() {
  110 + focaModalService.alert(
  111 + 'Hoja de ruta ' +
  112 + $filter('comprobante')([$scope.puntoVenta,
  113 + $scope.comprobante]) + ' cerrada con éxito');
  114 + $location.path('/');
  115 + }
  116 + );
107 117 }
108 118 };
109 119  
1 1 angular.module('focaHojaRuta')
2   - .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
  2 + .factory('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 3 var route = API_ENDPOINT.URL;
4 4 return {
5   - getHojasRuta: function(chofer) {
  5 + getHojaRuta: function(chofer) {
6 6 return $http.get(route + '/hoja-ruta/chofer/' + chofer);
7 7 },
8 8 terminarHojaRuta: function(hojaRuta) {
9   - return $http.get(route + '/hoja-ruta/terminar/' + hojaRuta);
  9 + return $http.post(route + '/hoja-ruta/terminar', {hojaRuta: hojaRuta});
10 10 }
11 11 };
12 12 }]);
src/views/lista-hoja-ruta.html
... ... @@ -73,7 +73,7 @@
73 73 </thead>
74 74 <tbody class="tabla-articulo-body">
75 75 <tr
76   - ng-repeat="(key, remito) in hojasRuta.remitos"
  76 + ng-repeat="(key, remito) in hojaRuta.remitos"
77 77 >
78 78 <td ng-bind="key + 1"></td>
79 79 <td