Commit 41ec225d390cdff563335a5acf86e1806d638a3b
1 parent
99088101d8
Exists in
master
and in
1 other branch
agrego informe productividad
Showing
3 changed files
with
301 additions
and
0 deletions
Show diff stats
src/js/controller-productividad.js
| File was created | 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 | ); | ||
| 176 |
src/js/service.js
| 1 | angular.module('focaModalInforme') | 1 | angular.module('focaModalInforme') |
| 2 | .factory('focaModalInformeChoferService', [ | 2 | .factory('focaModalInformeChoferService', [ |
| 3 | '$http', | 3 | '$http', |
| 4 | 'API_ENDPOINT', | 4 | 'API_ENDPOINT', |
| 5 | function($http, API_ENDPOINT) { | 5 | function($http, API_ENDPOINT) { |
| 6 | return { | 6 | return { |
| 7 | getDescargas: function(fechaDesde, fechaHasta) { | 7 | getDescargas: function(fechaDesde, fechaHasta) { |
| 8 | return $http.post(API_ENDPOINT.URL + '/informe/chofer', | 8 | return $http.post(API_ENDPOINT.URL + '/informe/chofer', |
| 9 | {fechaDesde: fechaDesde, fechaHasta: fechaHasta}); | 9 | {fechaDesde: fechaDesde, fechaHasta: fechaHasta}); |
| 10 | }, | 10 | }, |
| 11 | getEmpresa: function(id) { | 11 | getEmpresa: function(id) { |
| 12 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); | 12 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); |
| 13 | }, | 13 | }, |
| 14 | getDistanciaPorIdRemito: function(ids) { | 14 | getDistanciaPorIdRemito: function(ids) { |
| 15 | return $http.post(API_ENDPOINT.URL + '/remito/distancia', {ids: ids}); | 15 | return $http.post(API_ENDPOINT.URL + '/remito/distancia', {ids: ids}); |
| 16 | } | 16 | } |
| 17 | }; | 17 | }; |
| 18 | } | 18 | } |
| 19 | ]) | 19 | ]) |
| 20 | .factory('focaModalInformeGeneralUnidadService', [ | 20 | .factory('focaModalInformeGeneralUnidadService', [ |
| 21 | '$http', | 21 | '$http', |
| 22 | 'API_ENDPOINT', | 22 | 'API_ENDPOINT', |
| 23 | function($http, API_ENDPOINT) { | 23 | function($http, API_ENDPOINT) { |
| 24 | return { | 24 | return { |
| 25 | getEmpresa: function(id) { | 25 | getEmpresa: function(id) { |
| 26 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); | 26 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); |
| 27 | }, | 27 | }, |
| 28 | getInformeData: function(params) { | 28 | getInformeData: function(params) { |
| 29 | return $http.post(API_ENDPOINT.URL + '/informe/general-unidad-reparto', | 29 | return $http.post(API_ENDPOINT.URL + '/informe/general-unidad-reparto', |
| 30 | {params: params}); | 30 | {params: params}); |
| 31 | } | 31 | } |
| 32 | }; | 32 | }; |
| 33 | } | 33 | } |
| 34 | ]) | 34 | ]) |
| 35 | .factory('focaModalInformeLitrosKmUnidadService', [ | 35 | .factory('focaModalInformeLitrosKmUnidadService', [ |
| 36 | '$http', | 36 | '$http', |
| 37 | 'API_ENDPOINT', | 37 | 'API_ENDPOINT', |
| 38 | function($http, API_ENDPOINT) { | 38 | function($http, API_ENDPOINT) { |
| 39 | return { | 39 | return { |
| 40 | getDescargas: function(idVehiculo, fechaDesde, fechaHasta) { | 40 | getDescargas: function(idVehiculo, fechaDesde, fechaHasta) { |
| 41 | return $http.post(API_ENDPOINT.URL + '/informe/litros-por-km', | 41 | return $http.post(API_ENDPOINT.URL + '/informe/litros-por-km', |
| 42 | {idVehiculo: idVehiculo, fechaDesde: fechaDesde, fechaHasta: fechaHasta}); | 42 | {idVehiculo: idVehiculo, fechaDesde: fechaDesde, fechaHasta: fechaHasta}); |
| 43 | }, | 43 | }, |
| 44 | getEmpresa: function(id) { | 44 | getEmpresa: function(id) { |
| 45 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); | 45 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); |
| 46 | }, | 46 | }, |
| 47 | getDistanciaPorIdRemito: function(ids) { | 47 | getDistanciaPorIdRemito: function(ids) { |
| 48 | return $http.post(API_ENDPOINT.URL + '/remito/distancia', {ids: ids}); | 48 | return $http.post(API_ENDPOINT.URL + '/remito/distancia', {ids: ids}); |
| 49 | } | 49 | } |
| 50 | }; | 50 | }; |
| 51 | } | 51 | } |
| 52 | ]) | 52 | ]) |
| 53 | .factory('focaModalInformeHojaRutaService', [ | 53 | .factory('focaModalInformeHojaRutaService', [ |
| 54 | '$http', | 54 | '$http', |
| 55 | 'API_ENDPOINT', | 55 | 'API_ENDPOINT', |
| 56 | function($http, API_ENDPOINT) { | 56 | function($http, API_ENDPOINT) { |
| 57 | return { | 57 | return { |
| 58 | getHojasRuta: function(fechaDesde, fechaHasta) { | 58 | getHojasRuta: function(fechaDesde, fechaHasta) { |
| 59 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/listar/' + | 59 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/listar/' + |
| 60 | fechaDesde + '/' + fechaHasta); | 60 | fechaDesde + '/' + fechaHasta); |
| 61 | }, | 61 | }, |
| 62 | getEmpresa: function(id) { | 62 | getEmpresa: function(id) { |
| 63 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); | 63 | return $http.get(API_ENDPOINT.URL + '/empresa/' + id); |
| 64 | } | 64 | } |
| 65 | }; | 65 | }; |
| 66 | } | 66 | } |
| 67 | ]) | 67 | ]) |
| 68 | .factory('focaModalInformeRepartoOptimoService', [ | 68 | .factory('focaModalInformeRepartoOptimoService', [ |
| 69 | '$http', | 69 | '$http', |
| 70 | 'API_ENDPOINT', | 70 | 'API_ENDPOINT', |
| 71 | function($http, API_ENDPOINT) { | 71 | function($http, API_ENDPOINT) { |
| 72 | return { | 72 | return { |
| 73 | getInformeData: function(params) { | 73 | getInformeData: function(params) { |
| 74 | return $http.post(API_ENDPOINT.URL + '/informe/reparto-optimo', | 74 | return $http.post(API_ENDPOINT.URL + '/informe/reparto-optimo', |
| 75 | {params: params}); | 75 | {params: params}); |
| 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 | ]); |
| 80 | 92 |
src/views/informe-productividad.html
| File was created | 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 | class="btn btn-sm btn-secondary" | ||
| 99 | type="button" | ||
| 100 | ng-click="cancel()" | ||
| 101 | ng-show="buscar">Cancelar</button> | ||
| 102 | <button | ||
| 103 | ladda="generando" | ||
| 104 | class="btn btn-sm btn-secondary" | ||
| 105 | type="button" | ||
| 106 | ng-click="generarInforme()" | ||
| 107 | ng-show="buscar">Generar</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> | ||
| 114 |