Commit 23cf964408901141cccc3bbce0c79b89ff87c502

Authored by Eric Fernandez
Exists in master and in 2 other branches develop, lab

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !16
1 { 1 {
2 "name": "foca-hoja-ruta", 2 "name": "foca-hoja-ruta",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "foca-hoja-ruta", 4 "description": "foca-hoja-ruta",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "refresh" : "gulp uglify && cp tmp/foca-hoja-ruta.js ../wrapper-demo/node_modules/foca-hoja-ruta/dist/foca-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+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/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+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git"
12 }, 13 },
13 "pre-commit": [ 14 "pre-commit": [
14 "gulp-pre-commit" 15 "gulp-pre-commit"
15 ], 16 ],
16 "repository": { 17 "repository": {
17 "type": "git", 18 "type": "git",
18 "url": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git" 19 "url": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git"
19 }, 20 },
20 "author": "Foca Software", 21 "author": "Foca Software",
21 "license": "ISC", 22 "license": "ISC",
22 "devDependencies": { 23 "devDependencies": {
23 "angular": "^1.7.5", 24 "angular": "^1.7.5",
24 "angular-ladda": "^0.4.3", 25 "angular-ladda": "^0.4.3",
25 "angular-route": "^1.7.5", 26 "angular-route": "^1.7.5",
26 "bootstrap": "^4.1.3", 27 "bootstrap": "^4.1.3",
27 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", 28 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
28 "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", 29 "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git",
29 "font-awesome": "^4.7.0", 30 "font-awesome": "^4.7.0",
30 "gulp": "^3.9.1", 31 "gulp": "^3.9.1",
31 "gulp-angular-templatecache": "^2.2.5", 32 "gulp-angular-templatecache": "^2.2.5",
32 "gulp-clean": "^0.4.0", 33 "gulp-clean": "^0.4.0",
33 "gulp-concat": "^2.6.1", 34 "gulp-concat": "^2.6.1",
34 "gulp-connect": "^5.6.1", 35 "gulp-connect": "^5.6.1",
35 "gulp-htmlmin": "^5.0.1", 36 "gulp-htmlmin": "^5.0.1",
36 "gulp-jshint": "^2.1.0", 37 "gulp-jshint": "^2.1.0",
37 "gulp-rename": "^1.4.0", 38 "gulp-rename": "^1.4.0",
38 "gulp-replace": "^1.0.0", 39 "gulp-replace": "^1.0.0",
39 "gulp-sequence": "^1.0.0", 40 "gulp-sequence": "^1.0.0",
40 "gulp-uglify": "^3.0.1", 41 "gulp-uglify": "^3.0.1",
41 "gulp-uglify-es": "^1.0.4", 42 "gulp-uglify-es": "^1.0.4",
42 "jasmine-core": "^3.3.0", 43 "jasmine-core": "^3.3.0",
43 "jquery": "^3.3.1", 44 "jquery": "^3.3.1",
44 "jshint": "^2.9.6", 45 "jshint": "^2.9.6",
45 "ladda": "^1.0.6", 46 "ladda": "^1.0.6",
46 "pre-commit": "^1.2.2", 47 "pre-commit": "^1.2.2",
47 "pump": "^3.0.0", 48 "pump": "^3.0.0",
48 "ui-bootstrap4": "^3.0.5" 49 "ui-bootstrap4": "^3.0.5"
49 } 50 }
50 } 51 }
51 52
src/js/controller.js
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .controller('listaHojaRutaCtrl', 2 .controller('listaHojaRutaCtrl',
3 [ 3 [
4 '$scope', 4 '$scope',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 '$uibModal', 7 '$uibModal',
8 'hojaRutaService', 8 'hojaRutaService',
9 'focaLoginService', 9 'focaLoginService',
10 'focaModalService', 10 'focaModalService',
11 '$rootScope', 11 '$rootScope',
12 '$localStorage', 12 '$localStorage',
13 function( 13 function (
14 $scope, 14 $scope,
15 $location, 15 $location,
16 $filter, 16 $filter,
17 $uibModal, 17 $uibModal,
18 hojaRutaService, 18 hojaRutaService,
19 focaLoginService, 19 focaLoginService,
20 focaModalService, 20 focaModalService,
21 $rootScope, 21 $rootScope,
22 $localStorage 22 $localStorage
23 ) { 23 ) {
24 24
25 var loginData = focaLoginService.getLoginData(); 25 var loginData = focaLoginService.getLoginData();
26 26
27 config(); 27 config();
28 28
29 function config() { 29 function config() {
30 30
31 $scope.cabecera = []; 31 $scope.cabecera = [];
32 $scope.showCabecera = true; 32 $scope.showCabecera = true;
33 $scope.now = new Date(); 33 $scope.now = new Date();
34 $scope.puntoVenta = '0000'; 34 $scope.puntoVenta = '0000';
35 $scope.comprobante = '00000000'; 35 $scope.comprobante = '00000000';
36 } 36 }
37 37
38 hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) { 38 hojaRutaService.getHojaRuta(loginData.chofer).then(function (res) {
39 39
40 if (res.data) { 40 if (res.data) {
41 var hojaRuta = res.data; 41 var hojaRuta = res.data;
42 $scope.hojaRuta = hojaRuta; 42 $scope.hojaRuta = hojaRuta;
43 $scope.puntoVenta = hojaRuta.sucursal; 43 $scope.puntoVenta = hojaRuta.sucursal;
44 $scope.comprobante = hojaRuta.numeroHojaRuta; 44 $scope.comprobante = hojaRuta.numeroHojaRuta;
45 addCabecera('Transportista:', hojaRuta.transportista.NOM); 45 addCabecera('Transportista:', hojaRuta.transportista.NOM);
46 addCabecera('Chofer:', hojaRuta.chofer.nombre); 46 addCabecera('Chofer:', hojaRuta.chofer.nombre);
47 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); 47 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor);
48 } else { 48 } else {
49 focaModalService.alert('Sin hoja de ruta asignada'); 49 focaModalService.alert('Sin hoja de ruta asignada');
50 $location.path('/'); 50 $location.path('/');
51 } 51 }
52 52
53 watch(); 53 watch();
54 54
55 if (!$scope.esatadoRed) { 55 if (!$scope.esatadoRed) {
56 getLSHojaRuta(); 56 getLSHojaRuta();
57 } 57 }
58 58
59 }); 59 });
60 60
61 function watch() { 61 function watch() {
62 62
63 $scope.$watch('hojaRuta', function(nuevoValor) { 63 $scope.$watch('hojaRuta', function (nuevoValor) {
64 $localStorage.hojaRuta = JSON.stringify(nuevoValor); 64 $localStorage.hojaRuta = JSON.stringify(nuevoValor);
65 }, true); 65 }, true);
66 } 66 }
67 67
68 $scope.verDetalle = function(remito) { 68 $scope.verDetalle = function (remito) {
69 var modalInstance = $uibModal.open( 69 var modalInstance = $uibModal.open(
70 { 70 {
71 ariaLabelledBy: 'Detalle hoja ruta', 71 ariaLabelledBy: 'Detalle hoja ruta',
72 templateUrl: 'modal-detalle-hoja-ruta.html', 72 templateUrl: 'modal-detalle-hoja-ruta.html',
73 controller: 'focaModalDetalleHojaRutaController', 73 controller: 'focaModalDetalleHojaRutaController',
74 resolve: { 74 resolve: {
75 parametros: { 75 parametros: {
76 remito: remito, 76 remito: remito,
77 } 77 }
78 }, 78 },
79 size: 'lg' 79 size: 'lg'
80 } 80 }
81 ); 81 );
82 modalInstance.result.then(function() { 82 modalInstance.result.then(function () {
83 //funcion se ejecuta cuando se carga pantalla 83 //funcion se ejecuta cuando se carga pantalla
84 }); 84 });
85 }; 85 };
86 86
87 function addCabecera(label, valor) { 87 function addCabecera(label, valor) {
88 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 88 var propiedad = $filter('filter')($scope.cabecera, { label: label }, true);
89 if(propiedad.length === 1) { 89 if (propiedad.length === 1) {
90 propiedad[0].valor = valor; 90 propiedad[0].valor = valor;
91 } else { 91 } else {
92 $scope.cabecera.push({label: label, valor: valor}); 92 $scope.cabecera.push({ label: label, valor: valor });
93 } 93 }
94 } 94 }
95 95
96 $scope.rellenar = function(relleno, longitud) { 96 $scope.rellenar = function (relleno, longitud) {
97 relleno = '' + relleno; 97 relleno = '' + relleno;
98 while (relleno.length < longitud) { 98 while (relleno.length < longitud) {
99 relleno = '0' + relleno; 99 relleno = '0' + relleno;
100 } 100 }
101 101
102 return relleno; 102 return relleno;
103 }; 103 };
104 104
105 $scope.salir = function() { 105 $scope.salir = function () {
106 $location.path('/'); 106 $location.path('/');
107 }; 107 };
108 108
109 $scope.terminarHojaRuta = function() { 109 $scope.terminarHojaRuta = function () {
110 focaModalService 110 focaModalService
111 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + 111 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' +
112 'otra descarga ni modificación') 112 'otra descarga ni modificación')
113 .then(function() {$scope.datosExtraCierre(terminar);}); 113 .then(function () { $scope.datosExtraCierre(terminar); });
114 function terminar(datosExtraCierre) { 114 function terminar(datosExtraCierre) {
115 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre); 115 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre);
116 //limpio objeto para guardar 116 //limpio objeto para guardar
117 delete $scope.hojaRuta.chofer; 117 delete $scope.hojaRuta.chofer;
118 delete $scope.hojaRuta.remitos; 118 delete $scope.hojaRuta.remitos;
119 delete $scope.hojaRuta.transportista; 119 delete $scope.hojaRuta.transportista;
120 delete $scope.hojaRuta.vehiculo; 120 delete $scope.hojaRuta.vehiculo;
121 121
122 $scope.hojaRuta.fechaCreacion = 122 $scope.hojaRuta.fechaCreacion =
123 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' '); 123 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' ');
124 $scope.hojaRuta.fechaReparto = 124 $scope.hojaRuta.fechaReparto =
125 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' '); 125 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' ');
126 $scope.hojaRuta.estado = 2; 126 $scope.hojaRuta.estado = 2;
127 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then( 127 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then(
128 function() { 128 function () {
129 focaModalService.alert( 129 focaModalService.alert(
130 'Hoja de ruta ' + 130 'Hoja de ruta ' +
131 $filter('comprobante')([$scope.puntoVenta, 131 $filter('comprobante')([$scope.puntoVenta,
132 $scope.comprobante]) + ' cerrada con éxito'); 132 $scope.comprobante]) + ' cerrada con éxito');
133 $location.path('/'); 133 $location.path('/');
134 } 134 }
135 ); 135 );
136 } 136 }
137 }; 137 };
138 138
139 $scope.datosExtraCierre = function(terminar) { 139 $scope.datosExtraCierre = function (terminar) {
140 var modalInstance = $uibModal.open( 140 var modalInstance = $uibModal.open(
141 { 141 {
142 templateUrl: 'focaDatosExtra.html', 142 templateUrl: 'focaDatosExtra.html',
143 controller: 'focaModalDatosExtraCierre', 143 controller: 'focaModalDatosExtraCierre',
144 } 144 }
145 ); 145 );
146 modalInstance.result.then(terminar); 146 modalInstance.result.then(terminar);
147 }; 147 };
148 148
149 $rootScope.$on('estadoRed', function(event, value) { 149 $scope.modalDescargas = function () {
150 delete $scope.hojaRuta.remitos[0].cliente;
151 var modalInstance = $uibModal.open(
152 {
153 templateUrl: 'foca-modal-descarga.html',
154 controller: 'focaModalDescargaCtrl',
155 resolve: {
156 remito: function () { return $scope.hojaRuta.remitos[0]; }
157 },
158 }
159 );
160
161 modalInstance.result.then(function (data) {
162
163 console.log(data);
164 });
165 };
166
167 $rootScope.$on('estadoRed', function (event, value) {
150 $scope.esatadoRed = value; 168 $scope.esatadoRed = value;
151 }); 169 });
152 170
153 function getLSHojaRuta() { 171 function getLSHojaRuta() {
154 172
155 var hojaRuta = JSON.parse($localStorage.hojaRuta || null); 173 var hojaRuta = JSON.parse($localStorage.hojaRuta || null);
156 174
157 if (hojaRuta) { 175 if (hojaRuta) {
158 $scope.hojaRuta = hojaRuta; 176 $scope.hojaRuta = hojaRuta;
159 delete $localStorage.hojaRuta; 177 delete $localStorage.hojaRuta;
160 } 178 }
161 } 179 }
162 180
163 } 181 }
164 ]); 182 ]);
165 183
src/views/lista-hoja-ruta.html
1 <div> 1 <div>
2 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> 2 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
3 <div class="row p-1 panel-informativo"> 3 <div class="row p-1 panel-informativo">
4 <div class="col-12"> 4 <div class="col-12">
5 <div class="row"> 5 <div class="row">
6 <div class="col-12 col-sm-4 nota-pedido"> 6 <div class="col-12 col-sm-4 nota-pedido">
7 <h5>Hojas de ruta</h5> 7 <h5>Hojas de ruta</h5>
8 </div> 8 </div>
9 <div class="col-5 col-sm-4 numero-pedido"> 9 <div class="col-5 col-sm-4 numero-pedido">
10 Nº <span ng-bind="[puntoVenta, comprobante] | comprobante"></span> 10 Nº <span ng-bind="[puntoVenta, comprobante] | comprobante"></span>
11 </div> 11 </div>
12 <div class="col-7 col-sm-4 text-right"> 12 <div class="col-7 col-sm-4 text-right">
13 Fecha: 13 Fecha:
14 <span 14 <span
15 ng-show="!datepickerAbierto" 15 ng-show="!datepickerAbierto"
16 ng-bind="now | date:'dd/MM/yyyy HH:mm'" 16 ng-bind="now | date:'dd/MM/yyyy HH:mm'"
17 ng-click="datepickerAbierto = true" 17 ng-click="datepickerAbierto = true"
18 > 18 >
19 </span> 19 </span>
20 <input 20 <input
21 ng-show="datepickerAbierto" 21 ng-show="datepickerAbierto"
22 type="date" 22 type="date"
23 ng-model="now" 23 ng-model="now"
24 ng-change="datepickerAbierto = false" 24 ng-change="datepickerAbierto = false"
25 ng-blur="datepickerAbierto = false" 25 ng-blur="datepickerAbierto = false"
26 class="form-control form-control-sm col-8 float-right" 26 class="form-control form-control-sm col-8 float-right"
27 foca-focus="datepickerAbierto" 27 foca-focus="datepickerAbierto"
28 hasta-hoy 28 hasta-hoy
29 /> 29 />
30 </div> 30 </div>
31 </div> 31 </div>
32 <div class="row"> 32 <div class="row">
33 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> 33 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera">
34 <span class="label" ng-bind="cab.label"></span> 34 <span class="label" ng-bind="cab.label"></span>
35 <span class="valor" ng-bind="cab.valor"></span> 35 <span class="valor" ng-bind="cab.valor"></span>
36 </div> 36 </div>
37 </div> 37 </div>
38 </div> 38 </div>
39 </div> 39 </div>
40 <div class="row p-1 botonera-secundaria"> 40 <div class="row p-1 botonera-secundaria">
41 <div class="col-12"> 41 <div class="col-12">
42 <div class="row"> 42 <div class="row">
43 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> 43 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera">
44 <button 44 <button
45 type="button" 45 type="button"
46 class="btn btn-default btn-block btn-xs text-left py-2" 46 class="btn btn-default btn-block btn-xs text-left py-2"
47 ng-click="boton.accion()" 47 ng-click="boton.accion()"
48 ng-class="{'d-none d-sm-block': boton.texto == ''}" 48 ng-class="{'d-none d-sm-block': boton.texto == ''}"
49 > 49 >
50 <i 50 <i
51 class="fa fa-arrow-circle-right" 51 class="fa fa-arrow-circle-right"
52 ng-show="boton.texto != ''" 52 ng-show="boton.texto != ''"
53 ></i> 53 ></i>
54 &nbsp; 54 &nbsp;
55 {{boton.texto}} 55 {{boton.texto}}
56 </button> 56 </button>
57 </div> 57 </div>
58 </div> 58 </div>
59 </div> 59 </div>
60 </div> 60 </div>
61 </div> 61 </div>
62 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> 62 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2">
63 <div class="row grilla-articulo"> 63 <div class="row grilla-articulo">
64 <table class="table table-responsive table-striped table-sm table-dark"> 64 <table ng-hide="hojaRuta.abierta" class="table table-responsive table-striped table-sm table-dark">
65 <thead> 65 <thead>
66 <tr> 66 <tr>
67 <th>#</th> 67 <th>#</th>
68 <th>Número</th> 68 <th>Número</th>
69 <th>Razon Social</th> 69 <th>Razon Social</th>
70 <th>Domicilio</th> 70 <th>Domicilio</th>
71 <th>&nbsp;</th> 71 <th>&nbsp;</th>
72 </tr> 72 </tr>
73 </thead> 73 </thead>
74 <tbody class="tabla-articulo-body"> 74 <tbody class="tabla-articulo-body">
75 <tr 75 <tr
76 ng-repeat="(key, remito) in hojaRuta.remitos" 76 ng-repeat="(key, remito) in hojaRuta.remitos"
77 > 77 >
78 <td ng-bind="key + 1"></td> 78 <td ng-bind="key + 1"></td>
79 <td 79 <td
80 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante" 80 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"
81 ></td> 81 ></td>
82 <td ng-bind="remito.nombreCliente"></td> 82 <td ng-bind="remito.nombreCliente"></td>
83 <td ng-bind="remito.domicilioStamp"></td> 83 <td ng-bind="remito.domicilioStamp"></td>
84 <td> 84 <td>
85 <button 85 <button
86 class="btn btn-secondary" 86 class="btn btn-secondary"
87 type="button" 87 type="button"
88 ng-click="verDetalle(remito)" 88 ng-click="verDetalle(remito)"
89 ><i class="fa fa-search" aria-hidden="true"></i> 89 ><i class="fa fa-search" aria-hidden="true"></i>
90 </button> 90 </button>
91 </td> 91 </td>
92 </tr> 92 </tr>
93 </tbody> 93 </tbody>
94 </table> 94 </table>
95 95 </div>
96 <div ng-show="hojaRuta.abierta" class="row grilla-articulo">
97 <table class="table table-striped table-sm table-dark">
98 <thead>
99 <tr>
100 <th colspan="3" class="text-center">Remito abierto Nº
101 {{[hojaRuta.remitos[0].sucursal, hojaRuta.remitos[0].numeroRemito] | comprobante}}
102 </th>
103 </tr>
104 <tr>
105 <th>Cisterna</th>
106 <th>Producto</th>
107 <th>Disponibles</th>
108 </tr>
109 </thead>
110 <tbody>
111 <tr ng-repeat="cisterna in hojaRuta.remitos[0].cisternas">
112 <td ng-bind="cisterna.codigo"></td>
113 <td ng-bind="cisterna.cisternaCarga.articulo.DetArt"></td>
114 <td ng-bind="cisterna.cisternaCarga.cantidad"></td>
115 </tr>
116 </tbody>
117 </table>
118 <table class="table table-striped table-sm table-dark">
119 <thead>
120 <tr>
121 <th>Descarga en cliente</th>
122 <th>
123 <button class="btn btn-outline-debo" ng-click="modalDescargas()">
124 <i class="fa fa-plus"></i>
125 </button>
126 </th>
127 </tr>
128 <tr></tr>
129 </thead>
130 <tbody>
131 <tr ng-repeat="remito in remitos"></tr>
132 </tbody>
133 </table>
96 </div> 134 </div>
97 </div> 135 </div>
98 <div class="row d-md-none fixed-bottom"> 136 <div class="row d-md-none fixed-bottom">
99 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 137 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
100 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 138 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
101 <span 139 <span
102 class="mr-3 ml-auto" 140 class="mr-3 ml-auto"
103 ng-click="terminarHojaRuta()" 141 ng-click="terminarHojaRuta()"
104 ladda="saveLoading" 142 ladda="saveLoading"
105 data-style="expand-left" 143 data-style="expand-left"
106 >Terminar</span> 144 >Terminar</span>
107 </div> 145 </div>
108 </div> 146 </div>
109 </div> 147 </div>
110 148