Commit 1de9e1b00544becbd74a5306308f28d347fb76a6

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

See merge request !16
1 { 1 {
2 "name": "foca-activar-hoja-ruta", 2 "name": "foca-activar-hoja-ruta",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "", 4 "description": "",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "refresh": "gulp uglify && cp tmp/foca-activar-hoja-ruta.js ../wrapper-demo/node_modules/foca-activar-hoja-ruta/dist/foca-activar-hoja-ruta.min.js",
7 "test": "echo \"Error: no test specified\" && exit 1", 8 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 9 "compile": "gulp uglify",
9 "gulp-pre-commit": "gulp pre-commit", 10 "gulp-pre-commit": "gulp pre-commit",
10 "postinstall": "npm run compile && gulp clean-post-install", 11 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-remito.git" 12 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git git+ssh://git@debonline.dyndns.org:npm/foca-modal-remito.git"
12 }, 13 },
13 "pre-commit": [ 14 "pre-commit": [
14 "gulp-pre-commit" 15 "gulp-pre-commit"
15 ], 16 ],
16 "author": "", 17 "author": "",
17 "license": "ISC", 18 "license": "ISC",
18 "devDependencies": { 19 "devDependencies": {
19 "gulp": "^3.9.1", 20 "gulp": "^3.9.1",
20 "gulp-angular-templatecache": "^2.2.6", 21 "gulp-angular-templatecache": "^2.2.6",
21 "gulp-clean": "^0.4.0", 22 "gulp-clean": "^0.4.0",
22 "gulp-connect": "^5.7.0", 23 "gulp-connect": "^5.7.0",
23 "gulp-htmlmin": "^5.0.1", 24 "gulp-htmlmin": "^5.0.1",
24 "gulp-jshint": "^2.1.0", 25 "gulp-jshint": "^2.1.0",
25 "gulp-rename": "^1.4.0", 26 "gulp-rename": "^1.4.0",
26 "gulp-replace": "^1.0.0", 27 "gulp-replace": "^1.0.0",
27 "gulp-uglify": "^3.0.1", 28 "gulp-uglify": "^3.0.1",
28 "jshint": "^2.9.7", 29 "jshint": "^2.9.7",
29 "pre-commit": "^1.2.2", 30 "pre-commit": "^1.2.2",
30 "pump": "^3.0.0" 31 "pump": "^3.0.0"
31 } 32 }
32 } 33 }
33 34
src/js/controller.js
1 angular.module('focaActivarHojaRuta') 1 angular.module('focaActivarHojaRuta')
2 .controller('focaActivarHojaRutaController', [ 2 .controller('focaActivarHojaRutaController', [
3 '$scope', 'focaActivarHojaRutaService', 'focaModalService', 'focaBotoneraLateralService', 3 '$scope', 'focaActivarHojaRutaService', 'focaModalService',
4 '$filter','$uibModal', 4 'focaBotoneraLateralService', '$filter', '$uibModal',
5 function($scope, focaActivarHojaRutaService, focaModalService, focaBotoneraLateralService, 5 function ($scope, focaActivarHojaRutaService, focaModalService,
6 $filter, $uibModal) { 6 focaBotoneraLateralService, $filter, $uibModal) {
7 config(); 7 config();
8 8
9 //METODOS 9 //METODOS
10 function config() { 10 function config() {
11 $scope.botonera = [{ 11 $scope.botonera = [{
12 label: 'Chofer', 12 label: 'Chofer',
13 image: 'cliente.png' 13 image: 'cliente.png'
14 }]; 14 }];
15 //SETEO BOTONERA LATERAL 15 //SETEO BOTONERA LATERAL
16 focaBotoneraLateralService.showSalir(true); 16 focaBotoneraLateralService.showSalir(true);
17 focaBotoneraLateralService.showPausar(false); 17 focaBotoneraLateralService.showPausar(false);
18 focaBotoneraLateralService.showCancelar(false); 18 focaBotoneraLateralService.showCancelar(false);
19 focaBotoneraLateralService.showGuardar(false); 19 focaBotoneraLateralService.showGuardar(false);
20 20
21 init(); 21 init();
22 } 22 }
23 23
24 function init() { 24 function init() {
25 $scope.now = new Date(); 25 $scope.now = new Date();
26 $scope.hojasRuta = []; 26 $scope.hojasRuta = [];
27 $scope.$broadcast('removeCabecera', 'Chofer:'); 27 $scope.$broadcast('removeCabecera', 'Chofer:');
28 } 28 }
29 29
30 $scope.seleccionarChofer = function() { 30 $scope.seleccionarChofer = function () {
31 var parametrosModal = { 31 var parametrosModal = {
32 titulo: 'Búsqueda de Chofer', 32 titulo: 'Búsqueda de Chofer',
33 query: '/chofer', 33 query: '/chofer',
34 columnas: [ 34 columnas: [
35 { 35 {
36 propiedad: 'id', 36 propiedad: 'id',
37 nombre: 'Código', 37 nombre: 'Código',
38 filtro: { 38 filtro: {
39 nombre: 'rellenarDigitos', 39 nombre: 'rellenarDigitos',
40 parametro: 3 40 parametro: 3
41 } 41 }
42 }, 42 },
43 { 43 {
44 propiedad: 'nombre', 44 propiedad: 'nombre',
45 nombre: 'Nombre' 45 nombre: 'Nombre'
46 }, 46 },
47 { 47 {
48 propiedad: 'dni', 48 propiedad: 'dni',
49 nombre: 'DNI' 49 nombre: 'DNI'
50 }, 50 },
51 { 51 {
52 propiedad: 'telefono', 52 propiedad: 'telefono',
53 nombre: 'Teléfono' 53 nombre: 'Teléfono'
54 } 54 }
55 ] 55 ]
56 }; 56 };
57 focaModalService.modal(parametrosModal).then( 57 focaModalService.modal(parametrosModal).then(
58 function(chofer) { 58 function (chofer) {
59 $scope.chofer = chofer.id; 59 $scope.chofer = chofer.id;
60 focaActivarHojaRutaService.getHojasRutas($scope.chofer) 60 focaActivarHojaRutaService.getHojasRutas($scope.chofer)
61 .then(function(hojasRutas) { 61 .then(function (hojasRutas) {
62 $scope.$broadcast('addCabecera', { 62 $scope.$broadcast('addCabecera', {
63 label: 'Chofer:', 63 label: 'Chofer:',
64 valor: $scope.chofer + ' - ' + chofer.nombre 64 valor: $scope.chofer + ' - ' + chofer.nombre
65 }); 65 });
66 66
67 $scope.hojasRuta = hojasRutas.data; 67 $scope.hojasRuta = hojasRutas.data;
68 }); 68 });
69 }, function() {} 69 }, function () { }
70 ); 70 );
71 }; 71 };
72 72
73 $scope.mostrarRemitos = function (hojasRutas) { 73 $scope.mostrarRemitos = function (hojasRutas) {
74 $uibModal.open( 74 $uibModal.open(
75 { 75 {
76 ariaLabelledBy: '', 76 ariaLabelledBy: '',
77 templateUrl: 'modal-remitos.html', 77 templateUrl: 'modal-remitos.html',
78 controller: 'focaModalRemitosHojaRutaController', 78 controller: 'focaModalRemitosHojaRutaController',
79 resolve: { 79 resolve: {
80 hojasRutas: function () { return hojasRutas; }, 80 hojasRutas: function () { return hojasRutas; },
81 }, 81 },
82 size: 'lg', 82 size: 'lg',
83 } 83 }
84 ); 84 );
85 }; 85 };
86 86
87 $scope.setearEstado = function (estado) { 87 $scope.setearEstado = function (estado) {
88 var texto = ''; 88 var texto = '';
89 switch (estado) { 89 switch (estado) {
90 case 0: 90 case 0:
91 texto = 'Disponible'; 91 texto = 'Disponible';
92 break; 92 break;
93 case 1: 93 case 1:
94 texto = 'Asignada'; 94 texto = 'Activada';
95 break; 95 break;
96 case 2: 96 case 2:
97 texto = 'Terminada'; 97 texto = 'Terminada';
98 break; 98 break;
99 default: 99 default:
100 break; 100 break;
101 } 101 }
102 return texto; 102 return texto;
103 }; 103 };
104 104
105 $scope.activarHojaRuta = function(hojaRuta) { 105 $scope.activarHojaRuta = function (hojaRuta) {
106 validarChoferDisponible().then(function(hojaRutaAsignada) {
107 if (hojaRutaAsignada) {
108 var texto = 'El chofer tiene asignada la Hoja de Ruta Nº ' +
109 $filter('comprobante')([hojaRutaAsignada.sucursal,
110 hojaRutaAsignada.numeroHojaRuta]) +
111 ', ¿desea reemplazarla por esta?';
112
113 focaModalService
114 .confirm(texto)
115 .then(function(res) {
116 if (res) activar();
117 });
118 } else {
119 activar();
120 }
121
122 function activar() {
123 focaActivarHojaRutaService
124 .activarHojaRuta(hojaRuta.id, $scope.chofer)
125 .then(function() {
126 hojaRuta.estado = 1;
127 init();
128 focaModalService.alert('Hoja de ruta activada');
129 });
130 }
131 });
132 };
133
134 function validarChoferDisponible() {
135 return new Promise(function(resolve, reject) {
136 focaActivarHojaRutaService
137 .getHojaRutaByIdChofer($scope.chofer)
138 .then(function(res) {
139 resolve(res.data);
140 })
141 .catch(reject);
142 });
143 }
144
145
146 /*
147
148 if(focaActivarHojaRutaService.transportistaSeleccionado.COD) {
149 elegirTransportista(focaActivarHojaRutaService.transportistaSeleccionado);
150 }
151 focaActivarHojaRutaService.cleanCisternasLocal();
152 $scope.editar = function(id) {
153 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
154 };
155 $scope.solicitarConfirmacion = function(vehiculo) {
156 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
157 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
158 function(data) {
159 if(data) {
160 focaActivarHojaRutaService.deleteVehiculo(vehiculo.id);
161 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
162 }
163 }
164 );
165 };
166
167 function elegirTransportista(transportista) {
168 var codigo = ('00000' + transportista.COD).slice(-5);
169 $scope.idTransportista = transportista.COD;
170 $scope.filtros = transportista.NOM.trim();
171 $timeout(function() {
172 $scope.$broadcast('addCabecera', {
173 label: 'Transportista:',
174 valor: codigo + ' - ' + transportista.NOM
175 });
176 });
177 buscar(transportista.COD);
178 }
179
180 function buscar(idTransportista) {
181 focaActivarHojaRutaService 106 focaActivarHojaRutaService
182 .getVehiculosPorTransportista(idTransportista) 107 .activarHojaRuta(hojaRuta.id, $scope.chofer)
183 .then(function(datos) { 108 .then(function () {
184 $scope.vehiculos = datos.data; 109 hojaRuta.estado = hojaRuta.estado === 0 ? 1 : 0;
110 focaModalService
111 .alert(hojaRuta.estado === 1 ?
112 'Hoja de ruta activada' : 'Hoja de ruta desactivada');
185 }); 113 });
186 }*/ 114 };
1 angular.module('focaActivarHojaRuta') 1 angular.module('focaActivarHojaRuta')
2 .factory('focaActivarHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .factory('focaActivarHojaRutaService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) {
3 return { 3 return {
4 getHojasRutas: function(chofer) { 4 getHojasRutas: function (chofer) {
5 return $http.get(API_ENDPOINT.URL + '/hoja-ruta/disponible/' + chofer); 5 return $http.get(API_ENDPOINT.URL + '/hoja-ruta/disponible/' + chofer);
6 }, 6 },
7 activarHojaRuta: function(hoja_ruta, chofer) { 7 activarHojaRuta: function (hoja_ruta, chofer) {
8 return $http.get(API_ENDPOINT.URL + '/hoja-ruta/activar/' + hoja_ruta + '/' + chofer); 8 return $http.get(API_ENDPOINT.URL + '/hoja-ruta/activar/' +
9 hoja_ruta + '/' + chofer);
9 }, 10 },
10 getHojaRutaByIdChofer: function(chofer) { 11 getHojaRutaByIdChofer: function (chofer) {
11 return $http.get(API_ENDPOINT.URL + '/hoja-ruta/chofer/' + chofer); 12 return $http.get(API_ENDPOINT.URL + '/hoja-ruta/chofer/' + chofer);
12 } 13 }
13 }; 14 };
14 }]); 15 }]);
15 16
src/views/activar-hoja-ruta.html
1 <div class="row"> 1 <div class="row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'Activar Hoja de Ruta'" 3 titulo="'Activar Hoja de Ruta'"
4 fecha="now" 4 fecha="now"
5 class="mb-0 col-lg-12" 5 class="mb-0 col-lg-12"
6 ></foca-cabecera-facturador> 6 ></foca-cabecera-facturador>
7 </div> 7 </div>
8 <div class="row"> 8 <div class="row">
9 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> 9 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded">
10 <div class="row px-5 py-2 botonera-secundaria"> 10 <div class="row px-5 py-2 botonera-secundaria">
11 <div class="col-12"> 11 <div class="col-12">
12 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> 12 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador>
13 </div> 13 </div>
14 </div> 14 </div>
15 <!-- <div class="col-6 form-group"> 15 <!-- <div class="col-6 form-group">
16 <input seleccionarTransportista() 16 <input seleccionarTransportista()
17 type="text" 17 type="text"
18 teclado-virtual 18 teclado-virtual
19 class="form-control form-control-sm" 19 class="form-control form-control-sm"
20 placeholder="Búsqueda" 20 placeholder="Búsqueda"
21 ng-model="filtros" 21 ng-model="filtros"
22 /> 22 />
23 </div> --> 23 </div> -->
24 <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> 24 <table class="table table-default table-hover table-sm table-abm table-striped mb-0">
25 <thead> 25 <thead>
26 <tr> 26 <tr>
27 <th>Número</th> 27 <th>Número</th>
28 <th>Fecha</th> 28 <th>Fecha</th>
29 <th>Remitos</th> 29 <th>Remitos</th>
30 <th>Estados</th> 30 <th>Estados</th>
31 <th></th> 31 <th></th>
32 <th class="text-center"> 32 <th class="text-center">
33 </th> 33 </th>
34 </tr> 34 </tr>
35 </thead> 35 </thead>
36 <tbody> 36 <tbody>
37 <tr ng-repeat="hojaRuta in hojasRuta | filter:filtros"> 37 <tr ng-repeat="hojaRuta in hojasRuta | filter:filtros">
38 <td> 38 <td>
39 <b ng-show="hojaRuta.abierta !== null">RA </b> 39 <b ng-show="hojaRuta.abierta !== null">RA </b>
40 <b ng-show="hojaRuta.abierta === null">&emsp;&nbsp;</b> 40 <b ng-show="hojaRuta.abierta === null">&emsp;&nbsp;</b>
41 <span ng-bind="[hojaRuta.sucursal, hojaRuta.numeroHojaRuta] | comprobante"></span> 41 <span ng-bind="[hojaRuta.sucursal, hojaRuta.numeroHojaRuta] | comprobante"></span>
42 </td> 42 </td>
43 <td ng-bind="hojaRuta.fechaReparto | date:'yyyy-MM-dd':'-0300'"></td> 43 <td ng-bind="hojaRuta.fechaReparto | date:'yyyy-MM-dd':'-0300'"></td>
44 <td> 44 <td>
45 <div ng-bind="hojaRuta.remitos.length" class="d-inline-block"></div> 45 <div ng-bind="hojaRuta.remitos.length" class="d-inline-block"></div>
46 <button class="btn btn-outline-dark boton-accion" ng-click="mostrarRemitos(hojaRuta)"> 46 <button class="btn btn-outline-dark boton-accion" ng-click="mostrarRemitos(hojaRuta)">
47 <i class="fa fa-eye"></i> 47 <i class="fa fa-eye"></i>
48 </button> 48 </button>
49 </td> 49 </td>
50 <td 50 <td
51 ng-bind="setearEstado(hojaRuta.estado)" 51 ng-bind="setearEstado(hojaRuta.estado)"
52 ng-class="{'text-white':hojaRuta.estado == 0, 52 ng-class="{'text-white':hojaRuta.estado == 0,
53 'text-danger':hojaRuta.estado == 1, 53 'text-danger':hojaRuta.estado == 1,
54 'text-dark': hojaRuta.estado == 2 54 'text-dark': hojaRuta.estado == 2
55 }" 55 }"
56 ></td> 56 ></td>
57 <td></td> 57 <td></td>
58 <td class="text-center"> 58 <td class="text-center">
59 <button 59 <button
60 class="btn btn-outline-dark boton-accion" 60 class="btn btn-outline-dark boton-accion"
61 title="Activar" 61 title="Activar"
62 ng-click="activarHojaRuta(hojaRuta)" 62 ng-click="activarHojaRuta(hojaRuta)"
63 > 63 >
64 <i class="fa fa-check"></i> 64 <i
65 </button> 65 ng-class="{'fa-check': hojaRuta.estado == 0,'fa-times': hojaRuta.estado == 1}"
66 class="fa">
67 </i>
68 </button>
66 </td> 69 </td>
67 </tr> 70 </tr>
68 </body> 71 </body>
69 </table> 72 </table>
70 </div> 73 </div>
71 </div> 74 </div>
72 75