Commit 670981d447781428bdb88195265995738f768856
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !4
Showing
8 changed files
Show diff stats
src/js/controller-productividad.js
| ... | ... | @@ -0,0 +1,175 @@ |
| 1 | +angular.module('focaModalInforme') | |
| 2 | + .controller('focaModalInformeProductividadController', | |
| 3 | + [ | |
| 4 | + '$filter', | |
| 5 | + '$scope', | |
| 6 | + '$uibModalInstance', | |
| 7 | + 'focaModalInformeProductividadService', | |
| 8 | + 'i18nService', | |
| 9 | + 'focaModalService', | |
| 10 | + function($filter, $scope, $uibModalInstance, | |
| 11 | + focaModalInformeProductividadService, i18nService, focaModalService | |
| 12 | + ) { | |
| 13 | + i18nService.setCurrentLang('es'); | |
| 14 | + var fecha = new Date(); | |
| 15 | + $scope.generando = false; | |
| 16 | + $scope.buscar = true; | |
| 17 | + $scope.informe = {}; | |
| 18 | + $scope.params = { | |
| 19 | + fechaHasta: new Date(), | |
| 20 | + fechaDesde: new Date(fecha.setMonth(fecha.getMonth() - 1)), | |
| 21 | + sector: undefined, | |
| 22 | + diferenciarProductos: false, | |
| 23 | + diferenciarMeses: false | |
| 24 | + }; | |
| 25 | + $scope.gridOptions = { | |
| 26 | + enableGridMenu: true, | |
| 27 | + exporterMenuCsv: false, | |
| 28 | + exporterPdfPageSize: 'A4', | |
| 29 | + exporterPdfFooter: function (currentPage, pageCount) { | |
| 30 | + return { | |
| 31 | + columns: [ | |
| 32 | + {text: $filter('date')(new Date(), 'dd/MM/yyyy'), | |
| 33 | + margin: [40, 0]}, | |
| 34 | + {text: currentPage + ' de ' + pageCount, | |
| 35 | + margin: [28, 0], alignment: 'right'} | |
| 36 | + ] | |
| 37 | + }; | |
| 38 | + }, | |
| 39 | + columnDefs: [ | |
| 40 | + { | |
| 41 | + field: 'cliente', | |
| 42 | + enableSorting: false, | |
| 43 | + cellClass: function(grid, row, col) { | |
| 44 | + var value = grid.getCellValue(row,col); | |
| 45 | + | |
| 46 | + if (value.indexOf('Vendedores') !== -1 || | |
| 47 | + value.indexOf('Cobradores') !== -1 || | |
| 48 | + value.indexOf('Transportistas') !== -1) | |
| 49 | + return 'yellow w-100'; | |
| 50 | + if (value.indexOf('Vendedor:') !== -1 || | |
| 51 | + value.indexOf('Cobrador:') !== -1 || | |
| 52 | + value.indexOf('Transportista:') !== -1) | |
| 53 | + return 'red w-100'; | |
| 54 | + if (value.indexOf('Fecha:') !== -1) | |
| 55 | + return 'green w-100'; | |
| 56 | + } | |
| 57 | + }, | |
| 58 | + { | |
| 59 | + field: 'fecha', | |
| 60 | + enableSorting: false, | |
| 61 | + cellClass: function(grid, row, col) { | |
| 62 | + if (!grid.getCellValue(row,col)) | |
| 63 | + return 'd-none'; | |
| 64 | + } | |
| 65 | + }, | |
| 66 | + { | |
| 67 | + field: 'kmRecorridos', | |
| 68 | + enableSorting: false, | |
| 69 | + cellClass: function(grid, row, col) { | |
| 70 | + if (!grid.getCellValue(row,col)) | |
| 71 | + return 'd-none'; | |
| 72 | + } | |
| 73 | + }, | |
| 74 | + { | |
| 75 | + field: 'geolocalizacion', | |
| 76 | + enableSorting: false, | |
| 77 | + cellClass: function(grid, row, col) { | |
| 78 | + if (!grid.getCellValue(row,col)) | |
| 79 | + return 'd-none'; | |
| 80 | + } | |
| 81 | + } | |
| 82 | + ] | |
| 83 | + }; | |
| 84 | + $scope.generarInforme = function() { | |
| 85 | + //$scope.generando = true; | |
| 86 | + focaModalInformeProductividadService | |
| 87 | + .getInformeData($scope.params) | |
| 88 | + .then(function(res) { | |
| 89 | + var result = []; | |
| 90 | + console.log(res); | |
| 91 | + if (true) { | |
| 92 | + result.push({ | |
| 93 | + cliente: 'Vendedores' | |
| 94 | + }); | |
| 95 | + res.data.vendedores.forEach(function(vendedor) { | |
| 96 | + result.push({ | |
| 97 | + cliente: 'Vendedor: ' + vendedor.NOM | |
| 98 | + }); | |
| 99 | + vendedor.notasPedido.forEach(function(notaPedido) { | |
| 100 | + var seguimiento = notaPedido.seguimiento; | |
| 101 | + result.push({ | |
| 102 | + cliente: notaPedido.cliente.NOM, | |
| 103 | + fecha: seguimiento ? $filter('date')(seguimiento.fecha) : $filter('date')(notaPedido.fechaCarga), | |
| 104 | + kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), | |
| 105 | + geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' | |
| 106 | + }); | |
| 107 | + }); | |
| 108 | + }); | |
| 109 | + } | |
| 110 | + if (true) { | |
| 111 | + result.push({ | |
| 112 | + cliente: 'Cobradores' | |
| 113 | + }); | |
| 114 | + res.data.cobradores.forEach(function(cobrador) { | |
| 115 | + result.push({ | |
| 116 | + cliente: 'Cobrador: ' + cobrador.NOM | |
| 117 | + }); | |
| 118 | + cobrador.cobranzas.forEach(function(cobranza) { | |
| 119 | + var seguimiento = cobranza.seguimiento; | |
| 120 | + result.push({ | |
| 121 | + cliente: cobranza.cliente.NOM, | |
| 122 | + fecha: seguimiento ? $filter('date')(seguimiento.fecha, 'dd/MM/yyyy') : $filter('date')(cobranza.FEC), | |
| 123 | + kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), | |
| 124 | + geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' | |
| 125 | + }); | |
| 126 | + }); | |
| 127 | + }); | |
| 128 | + } | |
| 129 | + if (true) { | |
| 130 | + result.push({ | |
| 131 | + cliente: 'Transportistas' | |
| 132 | + }); | |
| 133 | + res.data.transportistas.forEach(function(transportista) { | |
| 134 | + result.push({ | |
| 135 | + cliente: 'Transportista: ' + transportista.NOM | |
| 136 | + }); | |
| 137 | + transportista.remitos.forEach(function(remito) { | |
| 138 | + var kms = 0, | |
| 139 | + geolocalizacion; | |
| 140 | + remito.hojaRutaMovimiento.forEach(function(movimiento) { | |
| 141 | + kms += movimiento.seguimiento.kmRecorridos || 0; | |
| 142 | + geolocalizacion = geolocalizacion || | |
| 143 | + movimiento.seguimiento.latitud + ', ' + | |
| 144 | + movimiento.seguimiento.longitud; | |
| 145 | + }); | |
| 146 | + result.push({ | |
| 147 | + cliente: remito.cliente.NOM, | |
| 148 | + fecha: $filter('date')(remito.fechaRemito, 'dd/MM/yyyy'), | |
| 149 | + kmRecorridos: $filter('number')(kms, 2), | |
| 150 | + geolocalizacion: geolocalizacion | |
| 151 | + }); | |
| 152 | + }); | |
| 153 | + }); | |
| 154 | + } | |
| 155 | + $scope.gridOptions.data = result; | |
| 156 | + $scope.generando = false; | |
| 157 | + $scope.buscar = false; | |
| 158 | + }); | |
| 159 | + }; | |
| 160 | + | |
| 161 | + | |
| 162 | + $scope.volver = function() { | |
| 163 | + $scope.buscar = true; | |
| 164 | + }; | |
| 165 | + $scope.cancel = function() { | |
| 166 | + $uibModalInstance.dismiss('Cancelar'); | |
| 167 | + }; | |
| 168 | + $scope.clearSector = function() { | |
| 169 | + $scope.params.sector = undefined; | |
| 170 | + }; | |
| 171 | + | |
| 172 | + | |
| 173 | + } | |
| 174 | + ] | |
| 175 | + ); |
src/js/service.js
| ... | ... | @@ -76,4 +76,16 @@ angular.module('focaModalInforme') |
| 76 | 76 | } |
| 77 | 77 | }; |
| 78 | 78 | } |
| 79 | + ]) | |
| 80 | + .factory('focaModalInformeProductividadService', [ | |
| 81 | + '$http', | |
| 82 | + 'API_ENDPOINT', | |
| 83 | + function($http, API_ENDPOINT) { | |
| 84 | + return { | |
| 85 | + getInformeData: function(params) { | |
| 86 | + return $http.post(API_ENDPOINT.URL + '/informe/productividad', | |
| 87 | + {params: params}); | |
| 88 | + } | |
| 89 | + }; | |
| 90 | + } | |
| 79 | 91 | ]); |
src/views/informe-chofer.html
| ... | ... | @@ -66,17 +66,17 @@ |
| 66 | 66 | </div> |
| 67 | 67 | </div> |
| 68 | 68 | <div class="modal-footer py-1"> |
| 69 | - <button | |
| 70 | - class="btn btn-sm btn-secondary" | |
| 71 | - type="button" | |
| 72 | - ng-click="cancel()" | |
| 73 | - ng-show="buscar">Cancelar</button> | |
| 74 | 69 | <button |
| 75 | 70 | ladda="generando" |
| 76 | 71 | class="btn btn-sm btn-secondary" |
| 77 | 72 | type="button" |
| 78 | 73 | ng-click="generarInforme()" |
| 79 | 74 | ng-show="buscar">Generar</button> |
| 75 | + <button | |
| 76 | + class="btn btn-sm btn-secondary" | |
| 77 | + type="button" | |
| 78 | + ng-click="cancel()" | |
| 79 | + ng-show="buscar">Salir</button> | |
| 80 | 80 | <button |
| 81 | 81 | class="btn btn-sm btn-secondary" |
| 82 | 82 | type="button" |
src/views/informe-general-unidad.html
| ... | ... | @@ -118,17 +118,17 @@ |
| 118 | 118 | </div> |
| 119 | 119 | </div> |
| 120 | 120 | <div class="modal-footer py-1"> |
| 121 | - <button | |
| 122 | - class="btn btn-sm btn-secondary" | |
| 123 | - type="button" | |
| 124 | - ng-click="cancel()" | |
| 125 | - ng-show="buscar">Cancelar</button> | |
| 126 | 121 | <button |
| 127 | 122 | ladda="generando" |
| 128 | 123 | class="btn btn-sm btn-secondary" |
| 129 | 124 | type="button" |
| 130 | 125 | ng-click="generarInforme()" |
| 131 | 126 | ng-show="buscar">Generar</button> |
| 127 | + <button | |
| 128 | + class="btn btn-sm btn-secondary" | |
| 129 | + type="button" | |
| 130 | + ng-click="cancel()" | |
| 131 | + ng-show="buscar">Salir</button> | |
| 132 | 132 | <button |
| 133 | 133 | class="btn btn-sm btn-secondary" |
| 134 | 134 | type="button" |
src/views/informe-hoja-ruta.html
| ... | ... | @@ -69,16 +69,16 @@ |
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | 71 | <div class="modal-footer py-1"> |
| 72 | - <button | |
| 73 | - class="btn btn-sm btn-secondary" | |
| 74 | - type="button" | |
| 75 | - ng-click="cancel()" | |
| 76 | - ng-show="buscar">Cancelar</button> | |
| 77 | 72 | <button |
| 78 | 73 | class="btn btn-sm btn-secondary" |
| 79 | 74 | type="button" |
| 80 | 75 | ng-click="generarInforme()" |
| 81 | 76 | ng-show="buscar">Generar</button> |
| 77 | + <button | |
| 78 | + class="btn btn-sm btn-secondary" | |
| 79 | + type="button" | |
| 80 | + ng-click="cancel()" | |
| 81 | + ng-show="buscar">Salir</button> | |
| 82 | 82 | <button |
| 83 | 83 | class="btn btn-sm btn-secondary" |
| 84 | 84 | type="button" |
src/views/informe-litros-km-unidad.html
| ... | ... | @@ -91,17 +91,17 @@ |
| 91 | 91 | </div> |
| 92 | 92 | </div> |
| 93 | 93 | <div class="modal-footer py-1"> |
| 94 | - <button | |
| 95 | - class="btn btn-sm btn-secondary" | |
| 96 | - type="button" | |
| 97 | - ng-click="cancel()" | |
| 98 | - ng-show="buscar">Cancelar</button> | |
| 99 | 94 | <button |
| 100 | 95 | ladda="generando" |
| 101 | 96 | class="btn btn-sm btn-secondary" |
| 102 | 97 | type="button" |
| 103 | 98 | ng-click="generarInforme()" |
| 104 | 99 | ng-show="buscar">Generar</button> |
| 100 | + <button | |
| 101 | + class="btn btn-sm btn-secondary" | |
| 102 | + type="button" | |
| 103 | + ng-click="cancel()" | |
| 104 | + ng-show="buscar">Salir</button> | |
| 105 | 105 | <button |
| 106 | 106 | class="btn btn-sm btn-secondary" |
| 107 | 107 | type="button" |
src/views/informe-productividad.html
| ... | ... | @@ -0,0 +1,113 @@ |
| 1 | +<div class="modal-header py-1"> | |
| 2 | + <div class="row w-100"> | |
| 3 | + <div class="col-12"><h5 class="modal-title">Informe de productividad</h5></div> | |
| 4 | + <div class="col-12" ng-hide="buscar"> | |
| 5 | + Filtros: Fecha desde: {{params.fechaDesde | date: 'dd/MM/yyyy'}}, | |
| 6 | + Fecha hasta: {{params.fechaHasta | date: 'dd/MM/yyyy'}} | |
| 7 | + <span ng-if="params.sector">, Sector: {{params.sector.NOMBRE}}</span> | |
| 8 | + <span ng-if="params.diferenciarProductos">, Productos diferenciados</span> | |
| 9 | + <span ng-if="params.diferenciarMeses">, Meses diferenciados</span> | |
| 10 | + </div> | |
| 11 | + </div> | |
| 12 | + </div> | |
| 13 | + <div class="modal-body" id="modal-body"> | |
| 14 | + | |
| 15 | + <div class="input-group row" | |
| 16 | + ng-show="buscar"> | |
| 17 | + <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> | |
| 18 | + <div class="col-md-4 col-8 input-group mb-2"> | |
| 19 | + <div class="input-group-prepend"> | |
| 20 | + <div class="input-group-text form-control-sm"> | |
| 21 | + <i class="fa fa-calendar"></i> | |
| 22 | + </div> | |
| 23 | + </div> | |
| 24 | + <input | |
| 25 | + class="form-control form-control-sm" | |
| 26 | + id="inlineFormInputGroup" | |
| 27 | + type="text" | |
| 28 | + ng-model="params.fechaDesde" | |
| 29 | + ng-required="true" | |
| 30 | + uib-datepicker-popup="dd/MM/yyyy" | |
| 31 | + show-button-bar="false" | |
| 32 | + is-open="datepickerOpen" | |
| 33 | + on-open-focus="false" | |
| 34 | + ng-focus="datepickerOpen = true" | |
| 35 | + datepicker-options="dateOptions" | |
| 36 | + /> | |
| 37 | + </div> | |
| 38 | + <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small> | |
| 39 | + <div class="col-md-4 col-8 input-group mb-2"> | |
| 40 | + <div class="input-group-prepend"> | |
| 41 | + <div class="input-group-text form-control-sm"> | |
| 42 | + <i class="fa fa-calendar"></i> | |
| 43 | + </div> | |
| 44 | + </div> | |
| 45 | + <input | |
| 46 | + class="form-control form-control-sm" | |
| 47 | + id="inlineFormInputGroup" | |
| 48 | + type="text" | |
| 49 | + ng-model="params.fechaHasta" | |
| 50 | + ng-required="true" | |
| 51 | + uib-datepicker-popup="dd/MM/yyyy" | |
| 52 | + show-button-bar="false" | |
| 53 | + is-open="datepicker2Open" | |
| 54 | + on-open-focus="false" | |
| 55 | + ng-focus="datepicker2Open = true" | |
| 56 | + /> | |
| 57 | + </div> | |
| 58 | + <small class="col-md-2 col-4 text-left my-1">Entidad</small> | |
| 59 | + <div class="col-md-4 col-8 input-group mb-2"> | |
| 60 | + <select class="form-control"> | |
| 61 | + <option value="0">Todos</option> | |
| 62 | + <option value="1">Vendedores</option> | |
| 63 | + <option value="2">Cobradores</option> | |
| 64 | + <option value="3">Transportistas</option> | |
| 65 | + </select> | |
| 66 | + <button type="button" class="clear-input text-danger" ng-click="clearSector()"> | |
| 67 | + <i class="fa fa-times"></i> | |
| 68 | + </button> | |
| 69 | + <!-- <div class="input-group-append"> | |
| 70 | + <div class="input-group-append" ng-hide="ingreso"> | |
| 71 | + <button | |
| 72 | + ladda="searchLoading" | |
| 73 | + data-spinner-color="#FF0000" | |
| 74 | + class="btn btn-outline-secondary" | |
| 75 | + type="button" | |
| 76 | + ng-click="seleccionarSector(13)"> | |
| 77 | + <i class="fa fa-search" aria-hidden="true"></i> | |
| 78 | + </button> | |
| 79 | + </div> | |
| 80 | + </div> --> | |
| 81 | + </div> | |
| 82 | + </div> | |
| 83 | + <div | |
| 84 | + ng-if="!buscar" | |
| 85 | + class="row"> | |
| 86 | + <div class="col-12"> | |
| 87 | + <div | |
| 88 | + class="gridInforme" | |
| 89 | + ui-grid="gridOptions" | |
| 90 | + ui-grid-exporter | |
| 91 | + ui-grid-resize-columns | |
| 92 | + ></div> | |
| 93 | + </div> | |
| 94 | + </div> | |
| 95 | + </div> | |
| 96 | + <div class="modal-footer py-1"> | |
| 97 | + <button | |
| 98 | + ladda="generando" | |
| 99 | + class="btn btn-sm btn-secondary" | |
| 100 | + type="button" | |
| 101 | + ng-click="generarInforme()" | |
| 102 | + ng-show="buscar">Generar</button> | |
| 103 | + <button | |
| 104 | + class="btn btn-sm btn-secondary" | |
| 105 | + type="button" | |
| 106 | + ng-click="cancel()" | |
| 107 | + ng-show="buscar">Salir</button> | |
| 108 | + <button | |
| 109 | + class="btn btn-sm btn-secondary" | |
| 110 | + type="button" | |
| 111 | + ng-click="volver()" | |
| 112 | + ng-hide="buscar">Volver</button> | |
| 113 | + </div> |
src/views/informe-reparto-optimo.html
| ... | ... | @@ -116,17 +116,17 @@ |
| 116 | 116 | </div> |
| 117 | 117 | </div> |
| 118 | 118 | <div class="modal-footer py-1"> |
| 119 | - <button | |
| 120 | - class="btn btn-sm btn-secondary" | |
| 121 | - type="button" | |
| 122 | - ng-click="cancel()" | |
| 123 | - ng-show="buscar">Cancelar</button> | |
| 124 | 119 | <button |
| 125 | 120 | ladda="generando" |
| 126 | 121 | class="btn btn-sm btn-secondary" |
| 127 | 122 | type="button" |
| 128 | 123 | ng-click="generarInforme()" |
| 129 | 124 | ng-show="buscar">Generar</button> |
| 125 | + <button | |
| 126 | + class="btn btn-sm btn-secondary" | |
| 127 | + type="button" | |
| 128 | + ng-click="cancel()" | |
| 129 | + ng-show="buscar">Salir</button> | |
| 130 | 130 | <button |
| 131 | 131 | class="btn btn-sm btn-secondary" |
| 132 | 132 | type="button" |